Package Bio :: Package SCOP :: Module Dom
[hide private]
[frames] | no frames]

Source Code for Module Bio.SCOP.Dom

 1  # Copyright 2000 by Jeffrey Chang.  All rights reserved. 
 2  # This code is part of the Biopython distribution and governed by its 
 3  # license.  Please see the LICENSE file that should have been included 
 4  # as part of this package. 
 5   
 6  # Gavin E. Crooks 2001-11-07: 
 7  #     Interface and comments modified to reflect changes to the SCOP 
 8  #     module, and to SCOP itself. 
 9   
10  """Handle the SCOP DOMain file. 
11   
12  The DOM file has been officially deprecated. For more information see 
13  the SCOP"release notes.":http://scop.berkeley.edu/release-notes-1.55.html 
14  The DOM files for older releases can be found 
15  "elsewhere at SCOP.":http://scop.mrc-lmb.cam.ac.uk/scop/parse/ 
16  """ 
17   
18  from .Residues import Residues 
19   
20   
21 -class Record(object):
22 """Holds information for one SCOP domain. 23 24 Attribues: 25 - sid - The SCOP ID of the entry, e.g. d1anu1 26 - residues - The domain definition as a Residues object 27 - hierarchy - A string specifying where this domain is in the hierarchy. 28 29 """ 30
31 - def __init__(self, line=None):
32 self.sid = '' 33 self.residues = [] 34 self.hierarchy = '' 35 if line: 36 self._process(line)
37
38 - def _process(self, line):
39 """Parses DOM records. 40 41 Records consist of 4 tab deliminated fields; 42 sid, pdbid, residues, hierarchy 43 """ 44 # For example :: 45 # 46 # d1sctg_ 1sct g: 1.001.001.001.001.001 47 # d1scth_ 1sct h: 1.001.001.001.001.001 48 # d1flp__ 1flp - 1.001.001.001.001.002 49 # d1moh__ 1moh - 1.001.001.001.001.002 50 51 line = line.rstrip() # no trailing whitespace 52 columns = line.split("\t") # separate the tab-delineated cols 53 if len(columns) != 4: 54 raise ValueError("I don't understand the format of %s" % line) 55 self.sid, pdbid, res, self.hierarchy = columns 56 self.residues = Residues(res) 57 self.residues.pdbid = pdbid
58
59 - def __str__(self):
60 s = [] 61 s.append(self.sid) 62 s.append(str(self.residues).replace(" ", "\t")) 63 s.append(self.hierarchy) 64 return "\t".join(s) + "\n"
65 66
67 -def parse(handle):
68 """Iterates over a DOM file as a Dom record for each line. 69 70 Arguments: 71 - handle -- file-like object. 72 73 """ 74 for line in handle: 75 if line.startswith('#'): 76 continue 77 yield Record(line)
78