1
2
3
4
5
6
7 """ Handle the SCOP DEScription file.
8
9 The file format is described in the scop
10 "release notes.":http://scop.berkeley.edu/release-notes-1.55.html
11 The latest DES file can be found
12 "elsewhere at SCOP.":http://scop.mrc-lmb.cam.ac.uk/scop/parse/
13
14 "Release 1.55":http://scop.berkeley.edu/parse/des.cla.scop.txt_1.55 (July 2001)
15 """
16
17
19 """Holds information for one node in the SCOP hierarchy.
20
21 sunid -- SCOP unique identifiers
22
23 nodetype -- One of 'cl' (class), 'cf' (fold), 'sf' (superfamily),
24 'fa' (family), 'dm' (protein), 'sp' (species),
25 'px' (domain). Additional node types may be added.
26
27 sccs -- SCOP concise classification strings. e.g. b.1.2.1
28
29 name -- The SCOP ID (sid) for domains (e.g. d1anu1),
30 currently empty for other node types
31
32 description -- e.g. "All beta proteins","Fibronectin type III",
33
34 """
36 self.sunid = ''
37 self.nodetype = ''
38 self.sccs = ''
39 self.name = ''
40 self.description =''
41 if line:
42 self._process(line)
43
45 """Parses DES records.
46
47 Records consist of 5 tab deliminated fields,
48 sunid, node type, sccs, node name, node description.
49 """
50
51
52
53
54
55
56
57
58 line = line.rstrip()
59 columns = line.split("\t")
60 if len(columns) != 5:
61 raise ValueError("I don't understand the format of %s" % line)
62
63 sunid, self.nodetype, self.sccs, self.name, self.description = columns
64 if self.name=='-': self.name =''
65 self.sunid = int(sunid)
66
67
79
80
82 """Iterates over a DES file, returning a Des record for each line
83 in the file.
84
85 Arguments:
86 handle -- file-like object
87 """
88 for line in handle:
89 yield Record(line)
90
91
93 """Iterates over a DES file.
94 """
95 - def __init__(self, handle, parser=None):
96 """Create an object that iterates over a DES file.
97
98 handle -- file-like object.
99
100 parser -- an optional Parser object to chang the results into
101 another form. If set to None, then the raw contents
102 of the file will be returned.
103
104 """
105 import warnings
106 warnings.warn("Bio.SCOP.Des.Iterator is deprecated. Please use Bio.SCOP.Des.parse() instead.", DeprecationWarning)
107 from types import FileType, InstanceType
108 if type(handle) is not FileType and type(handle) is not InstanceType:
109 raise TypeError("I expected a file handle or file-like object")
110 self._handle = handle
111 self._parser = parser
112
114 """Retrieve the next DES record."""
115 while 1:
116 line = self._handle.readline()
117 if not line: return None
118 if line[0] !='#': break
119 if self._parser is not None :
120 return self._parser.parse(line)
121 return line
122
124 return iter(self.next, None)
125
126
129 import warnings
130 warnings.warn("""Bio.SCOP.Des.Parser is deprecated.
131 Instead of
132
133 parser = Des.Parser()
134 record = parser.parse(entry)
135
136 please use
137
138 record = Des.Record(entry)
139 """, DeprecationWarning)
140
142 """Returns a Des Record """
143 return Record(entry)
144