[Biopython] multiple sequence blast

Brad Chapman chapmanb at 50mail.com
Thu Jun 30 10:42:27 UTC 2011


Dilara;
Thanks for the message. It would be helpful if you'd include the
error message traceback that you got stuck on; this will help
pinpoint the problem.

>From reading your code, my guess is that you are getting and IOError
about files not existing. When you do os.listdir, it only includes
the name of the files, not the full path to where they are located.

> allfiles=os.listdir("/Users/dally/Desktop/NextGenData/Python_Scripts/pract_input/")
> for fname in allfiles:
>     print fname
>     handle = open(fname, "rU") <==it doesn't recognize the file just the name?

You can fix this by using os.path.join with the directory name and
fname. For instance:

>>> dirname = "biopython"
>>> allfiles = os.listdir(dirname)
>>> print allfiles
['CONTRIB', 'Scripts', 'Doc', '.git', 'MANIFEST.in', 'Bio', 'BioSQL', 'README', 
'DEPRECATED', 'Tests', 'NEWS', 'setup.py', '.gitignore', 'do2to3.py', 'LICENSE']
>>> print [os.path.join(dirname, f) for f in allfiles]
['biopython/CONTRIB', 'biopython/Scripts', 'biopython/Doc', 'biopython/.git', 'biopython/MANIFEST.in', 
'biopython/Bio', 'biopython/BioSQL', 'biopython/README', 'biopython/DEPRECATED', 'biopython/Tests', 
'biopython/NEWS', 'biopython/setup.py', 'biopython/.gitignore', 'biopython/do2to3.py', 'biopython/LICENSE']

Hope this helps,
Brad



More information about the Biopython mailing list