Question: [solved] BioPython: CodeML FileNotFoundError: [WinError 2]
0
gravatar for atapee
4.2 years ago by
atapee10
Germany
atapee10 wrote:

I have been trying to run a basic codeML wraper, that I got from the Biopython cookbook, but it doesn't seem to be working. I have been getting the error "FileNotFoundError: [WinError 2]".

This is what the piece of code looks like:

def codeML(outfile):
    cml = codeml.Codeml()
    cml.alignment = "C:\\Users\\User\\Documents\\project\\codonal.fasta"
    cml.tree = "C:\\Users\\User\\Documents\\project\\newtree.nwk"
    cml.out_file = outfile
    cml.working_dir = "C:\\Users\\User\\Documents\\project"
    cml.set_options(seqtype=1,
            verbose=0,
            noisy=0,
            RateAncestor=0,
            model=0,
            NSsites=[0, 1, 2],
            CodonFreq=2,
            cleandata=1,
            fix_alpha=1,
            kappa=4.54006)
    results = cml.run()
    ns_sites = results.get("NSsites")
    m0 = ns_sites.get(0)
    m0_params = m0.get("parameters")
    print(m0_params.get("omega"))   

 

And this is what the error looks like: 

Traceback (most recent call last):
  File "C:\Python34\elgrando.py", line 155, in <module>
    codeML("rezultati.out")
  File "C:\Python34\elgrando.py", line 143, in codeML
    results = cml.run()
  File "C:\Python34\lib\site-packages\Bio\Phylo\PAML\codeml.py", line 186, in run
    Paml.run(self, ctl_file, verbose, command)
  File "C:\Python34\lib\site-packages\Bio\Phylo\PAML\_paml.py", line 143, in run
    stdout=subprocess.PIPE)
  File "C:\Python34\lib\subprocess.py", line 537, in call
    with Popen(*popenargs, **kwargs) as p:
  File "C:\Python34\lib\subprocess.py", line 858, in __init__
    restore_signals, start_new_session)
  File "C:\Python34\lib\subprocess.py", line 1111, in _execute_child
    startupinfo)
FileNotFoundError: [WinError 2]

Python usually gives this error when there is a problem with pathing, but I have checked it twice now and it works if I independently run CodeML. Could it be that python doesn't recognise Paml on my computer or it doesn't have access to it? 

ADD COMMENTlink modified 4.2 years ago by RamRS21k • written 4.2 years ago by atapee10

May be its not in the path i.e not added to Environmental variables ?

ADD REPLYlink written 4.2 years ago by geek_y9.4k

Can you check the input files and ensure they have no access/security problems? Files downloaded from the internet may need to be "unblocked".

ADD REPLYlink written 4.2 years ago by RamRS21k

It could be the Environmental varibles, but it would be strange since other biopython tools work. 

I have been using these files with other Biopython tools, they are probably not the cause of the problem. 

I have been able to reduce the errors to only one:

File "C:/Python34/standalone.py", line 2, in codeML
    cml = codeml.Codeml()
NameError: name 'codeml' is not defined

still don't know what the problem is. 

ADD REPLYlink written 4.2 years ago by atapee10

What does your import statement for codeML look like?

ADD REPLYlink written 4.2 years ago by RamRS21k

from Bio.Phylo.PAML import codeml

Well all the old errors are back, it had a random flash previously 

ADD REPLYlink written 4.2 years ago by atapee10

Try reinstalling the CodeML package.

ADD REPLYlink written 4.2 years ago by RamRS21k

Hello atapee!

It appears that your post has been cross-posted to another site: http://stackoverflow.com/questions/28480506/python-biopythoncodeml-filenotfounderror-winerror-2

This is typically not recommended as it runs the risk of annoying people in both communities.

ADD REPLYlink written 4.2 years ago by RamRS21k

It has been deleted... 

ADD REPLYlink modified 4.2 years ago • written 4.2 years ago by atapee10
0
gravatar for atapee
4.2 years ago by
atapee10
Germany
atapee10 wrote:

I think i have found the problem... 

this is the control file that CodeML produces: 

seqfile = kodonskaporavnava.fasta
outfile = results.out
treefile = novodrevo1.nwk
kappa = 4.54006
cleandata = 1
RateAncestor = 0
seqtype = 1
model = 0
noisy = 0
verbose = 0
fix_alpha = 1
NSsites = 0 1 2
CodonFreq = 2

There are not paths, only file names. If i look up the same file when produced by stand-alone CodeML it has ful paths. CodeML apparently works, but it does not recognise the file paths... I have no idea why, because if i copy/paste them to a different biopython module, they work as intended.

*Sorry for the different file names, they are just in a different language. 

ADD COMMENTlink modified 4.2 years ago • written 4.2 years ago by atapee10

Were you able to sort this out after finding out the issue? I have similar issue with the control file producing just the file names without adding the paths.

ADD REPLYlink written 9 months ago by idowuolawoye0
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 910 users visited in the last hour