1
2
3
4
5
6
7
8
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 types import *
19
20 from Residues import Residues
21
23 """Holds information for one SCOP domain.
24
25 sid -- The SCOP ID of the entry, e.g. d1anu1
26
27 residues -- The domain definition as a Residues object
28
29 hierarchy -- A string specifying where this domain is in the hierarchy.
30 """
32 self.sid = ''
33 self.residues = []
34 self.hierarchy = ''
35
37 s = []
38 s.append(self.sid)
39 s.append(str(self.residues).replace(" ","\t") )
40 s.append(self.hierarchy)
41 return "\t".join(s) + "\n"
42
44 """Iterates over a DOM file.
45 """
46 - def __init__(self, handle, parser=None):
47 """Create an object that iterates over a DES file.
48
49 handle -- file-like object.
50
51 parser -- an optional Parser object to change the results into
52 another form. If set to None, then the raw contents
53 of the file will be returned.
54
55 """
56 if type(handle) is not FileType and type(handle) is not InstanceType:
57 raise ValueError, "I expected a file handle or file-like object"
58 self._handle = handle
59 self._parser = parser
60
62 line = self._handle.readline()
63 if not line:
64 return None
65 if self._parser is not None:
66 return self._parser.parse(line)
67 return line
68
70 """Parses DOM records.
71
72 Records consist of 4 tab deliminated fields;
73 sid, pdbid, residues, hierarchy
74 """
75
76
77
78
79
80
81
83 """Returns a Dom.Record """
84 entry = entry.rstrip()
85 columns = entry.split("\t")
86 if len(columns) != 4:
87 raise SyntaxError, "I don't understand the format of %s" % entry
88 dom = Record()
89 dom.sid, pdbid, res, dom.hierarchy = columns
90 dom.residues = Residues(res)
91 dom.residues.pdbid =pdbid
92 return dom
93