[BioPython] script to extract records from nucleotide database
Matthew Abravanel
vmatthewa at gmail.com
Mon Nov 12 16:19:27 EST 2007
Hi Christof,
I tried out the code you sent me just to see if it would work but I get an
attribute error or something? Here is the error I get:
Traceback (most recent call last):
File "./run", line 3, in ?
from Bio import GenBank
File "/usr/pkg/lib/python2.4/site-packages/Bio/GenBank/__init__.py", line
47, in ?
File "/usr/pkg/lib/python2.4/site-packages/Bio/GenBank/Scanner.py", line
20, in ?
from Bio.SeqRecord import SeqRecord
File "/usr/pkg/lib/python2.4/site-packages/Bio/SeqRecord.py", line 11, in
?
File "/usr/pkg/lib/python2.4/site-packages/Bio/FormatIO.py", line 55, in
__init__
AttributeError: 'module' object has no attribute 'formats'
Here is the code I have used:
#!/usr/pkg/bin/python2.4
from Bio import GenBank
featureParser = GenBank.FeatureParser()
ncbiDict = GenBank.NCBIDictionary("nucleotide",
"genbank",parser=featureParser)
accessionNumbers=["BC063166", "NM_028459"]
for accessionNo in accessionNumbers:
giList = GenBank.search_for(accessionNo)
for gi in giList:
record = ncbiDict[gi]
for feature in record.features:
if feature.type =="CDS":
codingStart = feature.location._start.position
codingEnd = feature.location._end.position
completeSequence = record.seq.tostring()
fiveUTRSequence = completeSequence[:codingStart]
codingSequence = completeSequence[codingStart:codingEnd]
threeUTRSequence = completeSequence[codingEnd:]
if feature.type=="gene":
geneName=feature.qualifiers['gene'][0]
print "Found",gi,geneName,len(completeSequence)
I do not know if it is a difference in python2.4 version or not? Any help
would be appreciate, thanks.
Matthew
More information about the BioPython
mailing list