File: pdb.py

package info (click to toggle)
python-cogent 1.4.1-1.2
  • links: PTS, VCS
  • area: non-free
  • in suites: squeeze
  • size: 13,260 kB
  • ctags: 20,087
  • sloc: python: 116,163; ansic: 732; makefile: 74; sh: 9
file content (31 lines) | stat: -rw-r--r-- 841 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
#!/usr/bin/env python
"""Retrieves records by id from PDB, the Protein Data Bank."""
from cogent.db.util import UrlGetter

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

pdb_base='http://www.rcsb.org/pdb/files/'

class Pdb(UrlGetter):
    """Returns a pdb file."""
    BaseUrl = pdb_base
    Suffix='.pdb'
    Key=None

    def __str__(self):
        return self.BaseUrl + str(self.Key) + self.Suffix

    def __getitem__(self, item):
        """Returns handle to file containing specified PDB id."""
        orig_key = self.Key
        self.Key = item.lower()
        result = self.open()
        self.Key = orig_key
        return result