Entrez.efetch helpfully gives me the feature table of a nuccore entry.
If I understand correctly, efetch can only return the feature table in a textual format (e.g., as mentioned here).

Is there any built-in Python/Biopython function that parses this textual format of a feature table?

Here is a code snippet that uses efetch and writes the feature table to a file:

from Bio import Entrez
Entrez.email = "[email protected]"
with Entrez.efetch(db='nuccore', id='U00096.3', rettype='ft') as handle:
    feature_table = handle.read()

with open('feature_table.txt', 'w') as f:

Here are the first 20 lines of feature_table.txt:

>Feature gb|U00096.3|
190 255 gene
            gene    thrL
            gene_syn    ECK0001
            locus_tag   b0001
            db_xref ASAP:ABE-0000006
            db_xref ECOCYC:EG11277
            db_xref EcoGene:EG11277
190 255 CDS
            product thr operon leader peptide
            transl_table    11
            protein_id  gb|AAC73112.1|
            transcript_id   gnl|b0001|mrna.b0001
            db_xref UniProtKB/Swiss-Prot:P0AD86
337 2799    gene
            gene    thrA
            gene_syn    ECK0002
            gene_syn    Hs
            gene_syn    thrA1
            gene_syn    thrA2


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.