As I mention in the Simulations Using SAS page, I would rather use Python and NumPy for breeding strategy simulation. Once the data are generated (which I should explain how one day; summary: Cholesky decomposition), data can be saved and there are two additional steps:
- Call AS Reml from Python, and
- Read the results of the analysis. This provides two types of files:
- Nicely column formatted (easy piecy) and
- Free form, with the prime example being the .asr file.
The first part is handled in the same way as in SAS (or almost any language with the exception of R and S+), calling a .bat file (do you remember DOS?). Let’s say that analysis.bat contains the following commands:
exit
then we can call the .bat file from Python using a function like:
os.system('analysis.bat')
The second part, particularly reading the .asr file uses a function like the one below:
inputFile = open(fileName)
outputDic = {}
outputDic['LogLStatus'] = 'Unknown'
for line in inputFile:
record = string.split(line)
if len(record) > 0:
if record[0] in componentsList:
outputDic[record[0]] = record[4]
if 'LogL=' in record:
outputDic['LogL'] = record[2]
if 'Converged' in record:
outputDic['LogLStatus'] = 'Converged'
inputFile.close()
return outputDic
A simple way to call the function would be:
componentsList = ['Variance', 'treeID', 'plot']
simuResults = readAsr(asrFile, componentsList)
You can throw everything in a loop and you are in business.