I am struggling to use biopython to gather cross references such as GO annotation from Uniprot/swissprot text files ("DR" in the .txt files) using biopython.

From the source code:

def _read_dr(record, value): 
    cols = value.rstrip(".").split('; ') 

This leads me to think that the following code should work, as this is how other features like annotation and features work.

for record in SeqIO.parse(filename, "swiss"):
    print(record.cross_references) #does not work, should return a list of DR rows
    print(record.features) #works, returns a list of parsed FT rows

1 Answer 1


I believe the attribute you should be looking for is dbxrefs:

[x for x in record.dbxrefs if x.startswith('GO:')]

Apparently SeqIO handles uniprot text files differently than the SwissProt module:

from Bio import SwissProt
record = SwissProt.read(open('single_record_from_uniprot.txt'))

So you should change you code to use the SwissProt module to get the behavior you expect


Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.