[Bug 2544] Bio.GenBank and SeqFeature improvements
<bugzilla-daemon <at> portal.open-bio.org>
2009-01-02 18:15:46 GMT
http://bugzilla.open-bio.org/show_bug.cgi?id=2544
------- Comment #5 from biopython-bugzilla <at> maubp.freeserve.co.uk 2009-01-02 13:15 EST -------
(In reply to comment #4)
> Can I instantiate GenBank file, reverse-complement the sequence
> (keep letter casing) in the SeqIO object and dump it back to a
> GenBank file?
I think this question would have been better handled on the mailing lists,
rather than on this bug. Note that currently our GenBank output via Bio.SeqIO
does not include the features and references - see Bug 2294.
I would do this based on the approach described in the tutorial, which assumes
there could be many records in the input file. Here is a variation for just
one record (untested):
from Bio import SeqIO
from Bio.SeqRecord import SeqRecord
record = SeqIO.read(open("example.gbk"), "genbank")
rc_record = SeqRecord(seq = record.seq.reverse_complement(), \
id = "rc_" + record.id, \
name = "rc_" + record.name, \
description = "reverse complement")
out_handle = open("rc_example.gbk","w")
SeqIO.write([rc_record], out_handle, "genbank")
out_handle.close()
Note you *could* override the record's sequence in situ:
record.seq = record.seq.reverse_complement() #BAD IDEA
This is a bad idea because none of the annotations will have been changed - in
(Continue reading)