This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Parsing A Uniprot Flat File

Can anybody please let me know or help with parsing a uniprot flat file and access the information in the annotation (FT) line and produce an output file in python script. FT line is the one in a general uniprot flat file describing the nature of the proteins. Script written to this must produce an output file with the information in this line.

python biopython parsing uniprot

Can you use Biopython?

I think we can use biopython. Its not homework but part of project.

Please don't forget to accept one of the answers below, the problem appears to be solved.

2 answers

With BioPython, the task to access the feature information is very simple:

from Bio import SwissProt
for record in SwissProt.parse(open('/path/to/your/uniprot_sprot.dat')):
  for feature in record.features:
    print feature

How to save that into a file is also very simple.

Chris

If you can use BioPython, see Chapter 9: Swiss-Prot and ExPASy in the tutorial.

Alternative quick and dirty approach:

grep ^FT myfile.dat

Although that will not deal well with feature descriptions that span several lines.

Log in to answer this question.