File: rfam.py

package info (click to toggle)
python-cogent 1.5.3-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 16,424 kB
  • ctags: 24,343
  • sloc: python: 134,200; makefile: 100; ansic: 17; sh: 10
file content (35 lines) | stat: -rw-r--r-- 1,179 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/env python
"""Retrieves records by id from RFAM, the RNA families database."""
from cogent.db.util import UrlGetter

__author__ = "Rob Knight"
__copyright__ = "Copyright 2007-2012, The Cogent Project"
__credits__ = ["Rob Knight","Jeremy Widmann"]
__license__ = "GPL"
__version__ = "1.5.3"
__maintainer__ = "Rob Knight"
__email__ = "rob@spot.colorado.edu"
__status__ = "Production"

rfam_base='http://rfam.sanger.ac.uk/family/alignment/download/format?'
rfam_formats = dict.fromkeys('stockholm pfam fasta fastau')
rfam_types = dict.fromkeys(['seed','full'])

class Rfam(UrlGetter):
    """Returns a pdb file."""
    Defaults={'alnType':'seed','format':'stockholm','acc':None,'nseLabels':'1',
        'download':'0'}
    PrintedFields=dict.fromkeys('acc alnType nseLabels format download'.split())
    BaseUrl = rfam_base

    def __getitem__(self, item):
        """Returns handle to file containing aln of specified rfam id."""
        orig_acc = self.acc
        item = str(item).upper()
        if not item.startswith('RF'):
            item = 'RF'+item
        
        self.acc = item
        result = self.open()
        self.acc = orig_acc
        return result