bpy25. Saving Proteins from UniProtKB using Biopython

We save insulin proteins, from the protein database UniProtKB, for both human and mouse.

The accession strings are stored in the accessions list.

Later, we will parse these files. However, it is better to save the files, rather than always loading them. We save them to two separate files in the subfolder ‘data’.


# bpy25.py
import os
from Bio import ExPASy
accessions = ['P08069','Q60751']
records = []
for accession in accessions:
handle = ExPASy.get_sprot_raw(accession)
fpath = os.path.join('data',accession+'.txt')
with open(fpath,'w') as fout:
fout.write(handle.read())

Leave a Reply

Your email address will not be published. Required fields are marked *