2
$\begingroup$

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
$\endgroup$

1 Answer 1

3
$\begingroup$

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

$\endgroup$

Your Answer

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

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