I have several files stored in a folder called controlFiles. The path to this folder is Users/Desktop/myproject/controlFiles.
I am attempting to run a subprocess command in my python script with the following code:
def codeml(codeml_location, control_location):
runPath = codeml_location + '/codeml'
for file in os.listdir(control_location):
ctlPath = os.path.abspath(file)
subprocess.call([runPath, ctlPath])
The script's function is to run a command line tool called codeml, with the first argument being the location of the codeml executable, and the second being a folder of control files that codeml uses. When I run this script codeml runs but I get the error:
error when opening file /Users/Desktop/myproject/subtree.39.tre.ctl
tell me the full path-name of the file?
My confusion comes from the fact that the controlFiles folder is not within that path, yet it still identifies the files within the folder.
To check I was entering the correct control_location argument I edited the code as such:
def codeml(codeml_location, control_location):
runPath = codeml_location + '/codeml'
for file in os.listdir(control_location):
print os.path.abspath(file)
Running this printed all the files in the controlFiles folder, but again without the folder within the paths. Here is a sample of the print out:
/Users/Desktop/myproject/subtree.68.tre.ctl
/Users/Desktop/myproject/subtree.69.tre.ctl
/Users/Desktop/myproject/subtree.70.tre.ctl
/Users/Desktop/myproject/subtree.71.tre.ctl
To run the function my control location argument is:
control_location = /Users/Desktop/myproject/controlFiles
A final point is that my working directory in the terminal is /Users/Desktop/myproject and this is because this is the location of my Click project. Why are the files being picked up but not the folder containing them?