Back to index

python-biopython  1.60
Public Member Functions | Public Attributes | Private Member Functions
Bio.SCOP.Residues.Residues Class Reference

List of all members.

Public Member Functions

def __init__
def __str__

Public Attributes

 pdbid
 fragments

Private Member Functions

def _parse

Detailed Description

A collection of residues from a PDB structure.

This class provides code to work with SCOP domain definitions. These
are concisely expressed as a one or more chain fragments. For example,
"(1bba A:10-20,B:)" indicates residue 10 through 20 (inclusive) of
chain A, and every residue of chain B in the pdb structure 1bba. The pdb
id and brackets are optional. In addition "-" indicates every residue of
a pbd structure with one unnamed chain.

Start and end residue ids consist of the residue sequence number and an
optional single letter insertion code. e.g. "12", "-1", "1a", "1000"


pdbid -- An optional PDB id, e.g. "1bba"

fragments -- A sequence of tuples (chainID, startResID, endResID)

Definition at line 16 of file Residues.py.


Constructor & Destructor Documentation

def Bio.SCOP.Residues.Residues.__init__ (   self,
  str = None 
)

Definition at line 37 of file Residues.py.

00037 
00038     def __init__(self, str=None):
00039         self.pdbid = ''
00040         self.fragments = ()
00041         if str is not None : self._parse(str)
00042 


Member Function Documentation

Definition at line 75 of file Residues.py.

00075 
00076     def __str__(self):
00077         prefix =""
00078         if self.pdbid:
00079             prefix =self.pdbid +' '
00080             
00081         if not self.fragments: return prefix+'-'
00082         strs = []
00083         for chain, start, end in self.fragments:
00084             s = []
00085             if chain: s.append("%s:" % chain)
00086             if start: s.append("%s-%s" % (start, end))
00087             strs.append("".join(s))
00088         return prefix+ ",".join(strs)
00089 
00090 
00091 
00092 
00093 
00094 
00095 
00096 
def Bio.SCOP.Residues.Residues._parse (   self,
  str 
) [private]

Definition at line 43 of file Residues.py.

00043 
00044     def _parse(self, str):
00045         str = str.strip()
00046 
00047         #Is there a pdbid at the front? e.g. 1bba A:1-100
00048         m = _pdbid_re.match(str)
00049         if m is not None:
00050             self.pdbid = m.group(1)
00051             str = m.group(2) # Everything else
00052 
00053         if str=='' or str == '-' or str=='(-)':  # no fragments, whole sequence
00054             return
00055     
00056         fragments = []
00057         for l in str.split(","):
00058             m = _fragment_re.match(l)
00059             if m is None:
00060                 raise ValueError("I don't understand the format of %s" % l)
00061             chain, start, end, postfix = m.groups()
00062 
00063             if postfix != "":
00064                  raise ValueError("I don't understand the format of %s" % l)
00065 
00066             if chain:
00067                 if chain[-1] != ':':
00068                     raise ValueError("I don't understand the chain in %s" % l)
00069                 chain = chain[:-1]   # chop off the ':'
00070             else:
00071                 chain ="" 
00072             
00073             fragments.append((chain, start, end))
00074         self.fragments = tuple(fragments)
            

Member Data Documentation

Definition at line 39 of file Residues.py.

Definition at line 38 of file Residues.py.


The documentation for this class was generated from the following file: