[BioPython] Getting the location from a Genbank record
Peter
biopython at maubp.freeserve.co.uk
Mon Sep 3 06:46:32 EDT 2007
On 9/3/07, Sebastian Bassi <sbassi at gmail.com> wrote:
> I can get the "location" of the genes I want, but I have them in a
> "print mode" (calling __str__), but I don't see how to get the start
> and end position in a way I could use to slice the seq. There are
> private attributes _start and _end but I don't know if using them if
> the "right" way to do it.
>
> from Bio import SeqIO
> mr = SeqIO.parse(open("MTtabaco.gbk"), "genbank").next()
> targets=(['cox2'],['atp6'],['atp9'],['cob'])
> for x in mr.features:
> if x.qualifiers.get('gene') in targets:
> print x.location
> #print mr.seq
I'm not at my own computer right now, but I think you need to do
something like this to get the slice - assuming nothing funny like
joins:
start = x.location.start.position
end = x.location.end.position
print mr.seq[start:end]
print mr.seq[start:end].reverse_complement()
See also: http://www.warwick.ac.uk/go/peter_cock/python/genbank/
Peter
More information about the BioPython
mailing list