Pfam Access

The part shows how to access Pfam database. You can search protein family accession numbers and information using a sequence or PDB/UniProt identifiers. MSA files for families of interest can be retrieved in a number of formats.

In [1]: from prody import *

In [2]: from matplotlib.pylab import *

In [3]: ion()  # turn interactive mode on

Search Pfam

We use searchPfam() for searching. Valid inputs are UniProt ID, e.g. PIWI_ARCFU, or PDB identifier, e.g. 3luc or "3lucA" with chain identifier.

Matching Pfam accession (one or more) as keys will map to a dictionary that contains locations (alignment start, end, evalue etc), pfam family type, accession and id.

We query Pfam using the searchPfam(). with a UniProt ID.

It is a good practice to save this record on disk, as NCBI may not respond to repeated searches for the same sequence. We can do this using Python standard library pickle as follows:

In [4]: import pickle

Record is save using dump() function into an open file:

Then, it can be loaded using load() function:

In [5]: matches = pickle.load(open('pfam_search_PIWI_ARCFU.pkl'))

In [6]: matches
{'PF02171': {'accession': 'PF02171',
  'id': 'Piwi',
  'locations': [{'ali_end': '405',
    'ali_start': '111',
    'bitscore': '228.70',
    'end': '406',
    'evalue': '1.1e-64',
    'hmm_end': '301',
    'hmm_start': '2',
    'start': '110'}],
  'type': 'Pfam-A'}}

like search_b which will search pfam B and skip_a that will not search pfamA database. Additional parameters include ga that uses gathering threshold instead of e-value, evalue cutoff can also be specified and timeout that can be set higher especially when searching larger sequences, default is timeout=60 seconds.

Retrieve MSA files

Data from Pfam database can be fetched using fetchPfamMSA().

Valid inputs are Pfam ID, e.g. Piwi, or Pfam accession, e.g. PF02171 obtained from searchPfam().

Alignment type can be "full' (default), "seed", "ncbi" or "metagenomics" or "rp15" or "rp35" or "rp55" or "rp75".

A compressed file can be downloaded by setting compressed=True. The format of the MSA can be of "selex" (default), "stockholm" or "fasta". This will return the path of the downloaded MSA file. The output name can be specified, for by default it will have "accession/ID_alignment.format".

Note that in this case we passed a folder name, the downloaded file is saved in this folder, after it is created if it did not exist. Also longer timeouts are necessary for larger families. Some other parameters like gap, order or inserts can be set, as shown in the following example.