Reputation: 31
I am a new user to Python and I tried to import genbank and fasta format files. In their documentation, they provide an example that illustrates how we can import datasets into Python. specifically, they provide the following example in the Biopython Tutorial and Cookbook, page 16:
from Bio import SeqIO
for seq_record in SeqIO.parse("ls_orchid.gbk", "genbank"):
print seq_record.id
print repr(seq_record.seq)
print len(seq_record)
Now, they mention in page 14 that the Biopython source code contains this file which is true. However, how does python know through the Bio import SeqIO where the file exactly is? Note that I tried the above code after installing biopython and its components but it never worked?
Also, can I just specify the path for the genbank file and open it somehow!
Thank you
Upvotes: 2
Views: 1510
Reputation: 668
It seems that you need to save the ls_orchid.gbk file in the same directory as your python script, otherwise you would need to specify the full path to the file. You can also just download any genbank file from NCBI and add it to the directory, or specify its location as such
for seq_record in SeqIO.parse("~/File Location/File Name", "genbank")
Upvotes: 1
Reputation: 1
i put Genbank and FASTA in C:\Python27 I could parse all kind of other file formats such as Newick, PhyloXML, etc U should contact the developers for further information
Upvotes: -1
Reputation: 33509
According to http://biopython.org/DIST/docs/tutorial/Tutorial.html#htoc10
You need to copy the files to your local directory
When this tutorial was originally written, this search gave us only 94 hits, which we saved as a FASTA formatted text file and as a GenBank formatted text file (files ls_orchid.fasta and ls_orchid.gbk, also included with the Biopython source code under docs/tutorial/examples/).
If you run the search today, you’ll get hundreds of results! When following the tutorial, if you want to see the same list of genes, just download the two files above or copy them from docs/examples/ in the Biopython source code. In Section 2.5 we will look at how to do a search like this from within Python.
Upvotes: 1