How to get Uniprot and swissprot cross references using Biopython 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('; ') 
    record.cross_references.append(tuple(cols)) 


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
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'))
record.cross_references


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