Thanks for this. I tried it but got the error:
line 3
SyntaxError: Non-ASCII character '\xe2' in file /home/kpenn/Python.scripts.dir/Split.Genbank.to.faa.std.input.py on line 3, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details
This is the script:
#!/usr/bin/python
# """
Usage: converter.py foo.gbk
Produces a converted file: foo_converted.faa
#"""
import sys, os
from Bio import GenBank, SeqIO
gbk_filename = sys.argv[1]
root_name = os.path.splitext(gbk_filename)[0]
faa_filename = root_name + "_converted.faa"
input_handle = open(gbk_filename, "r")
output_handle = open(faa_filename, "w")
for seq_record in SeqIO.parse(input_handle, "genbank") :
print "Dealing with GenBank record %s" % seq_record.id
for seq_feature in seq_record.features :
if seq_feature.type=="CDS" :
assert len(seq_feature.qualifiers['translation'])==1
output_handle.write(">%s from %s\n%s\n" % (
seq_feature.qualifiers['locus_tag'][0],
seq_record.name,
seq_feature.qualifiers['translation'][0]))
output_handle.close()
input_handle.close()
print "Done"
i am not familiar with scripts but instead I think you can retrieve Genbank Protein GI (from http://biodbnet.abcc.ncifcrf.gov/db/db2db.php) then in Batch Entrez you can retrieve the bulk protein sequence
Yes but the main function I am looking for is to get the sequences parsed into separate files based on the different gb accession for the overall contig.
don't worry friend, your problem will be solved soon...