This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How detect complement reverse sequence in a EMBL/Genbank file with biopython?

Hi,

I'm trying to parse GenBank file and extract the genes sequences, but I didn't find how to detect the complement sequences. I tried regex by searching "complenent" in "feature.location" but that didn't work.

If you are some ideas you're welcome :)

genome

1 answer

Each feature object has a .strand (actually an alias for the feature's location's strand, .location.strand), e.g.

from Bio import SeqIO
for record in SeqIO.parse(filename, "embl"):
    print(record.id)
    for feature in record.features:
        print(feature.strand)
        print(feature.extract(record.seq))

The last line of the example shows how to get the sequence associated with the feature.

See also the SeqFeature built in documentation, also available at http://biopython.org/DIST/docs/api/Bio.SeqFeature-module.html

As explained there and in the Biopython Tutorial http://biopython.org/DIST/docs/tutorial/Tutorial.html the .strand will be -1 for features on the complement strand.

Thanks a lot, that's what I need, and this tutorial is very hepfull too.

Log in to answer this question.