[Biopython-dev] [Bug 2544] Bio.GenBank and SeqFeature improvements

bugzilla-daemon at portal.open-bio.org bugzilla-daemon at portal.open-bio.org
Fri Jan 2 18:15:46 UTC 2009


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
addition to the name/id/description still being the same, all the feature
locations etc will still be for the forward sequence.

--

I'm leaving this bug open for defining __repr__ for the
Bio.SeqFeature.Reference object (and perhaps tweaking the display of the
references in the SeqRecord __str__ method) ONLY.

Please continue any other discussion on the mailing lists.  Thanks.

Peter.


-- 
Configure bugmail: http://bugzilla.open-bio.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.



More information about the Biopython-dev mailing list