from Bio import SwissProt
fh = open('spfile.txt')
records = SwissProt.parse(fh)
for record in records:
    print('Entry name: %s' % record.entry_name)
    print('Accession(s): %s' % ','.join(record.accessions))
    print('Keywords: %s' % ','.join(record.keywords))
    print('Sequence: %s' % record.sequence)
fh.close()

This code is part of the book "Python for Bioinformatics", by Sebastian Bassi (sbassi@genesdigitales.com). Return to home page.