1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 """
24 Parse a certain file / memory object into a PDBModel.
25
26 This module provides helper classes for L{Biskit.PDBModel}. In most
27 cases, it should not be necessary to use it directly.
28
29 @see L{Biskit.PDBModel}
30 @see L{Biskit.PDBParserFactory}
31 @see L{Biskit.PDBParseFile}
32 @see L{Biskit.PDBParseModel}
33 @see L{Biskit.PDBParsePickle}
34 """
35 from Biskit import StdLog, ErrLog
36 import Biskit as B
37
39 """Error while parsing a structure file or object"""
40 pass
41
43 """
44 **Abstract** base class for parsers that generate PDBModel objects from
45 different source formats.
46 """
47
49 """
50 @param log: Log for warnings [default log to STDERR]
51 @type log: Biskit.LogFile.LogFile
52
53 Override if needed. Call parent method in overriding class!
54 """
55 self.log = log or ErrLog()
56
57
58 @staticmethod
60 """
61 Override!
62
63 The method is static and can thus be called directly with the parser
64 class rather than with an instance::
65
66 >>> if PDBParser.supports('myfile.pdb'):
67 >>> ...
68
69 @return: True if the given source is supported by this parser
70 implementation
71 @rtype: bool
72 """
73 raise NotImplementedError, 'issupported() is not implemented.'
74
75
76 @staticmethod
78 """
79 Override!
80
81 The method is static and can thus be called directly with the parser
82 class rather than with an instance::
83
84 >>> if PDBParser.description('myfile.pdb'):
85 >>> ...
86
87 @return: short free text description of the supported format
88 @rtype: str
89 """
90 raise NotImplementedError, 'description() is not implemented.'
91
92
93 - def update( self, model, source, skipRes=None, lookHarder=0 ):
94 """
95 Update empty or missing fields of model from the source. The
96 model will be connected to the source via model.source.
97 Override!
98
99 @param model: existing model
100 @type model: PDBModel
101 @param source: source PDB file or pickled PDBModel or PDBModel object
102 @type source: str || file || PDBModel
103 @param skipRes: list residue names that should not be parsed
104 @type skipRes: [ str ]
105 @param lookHarder: check source for additional profiles that are not
106 yet known for the model [False]
107 @type lookHarder: 1 || 0
108 """
109 raise NotImplementedError, 'update() is not implemented.'
110
111
113 """
114 This function is called by update() to decide whether or not to open
115 the source.
116 Override if needed.
117
118 @param model: model
119 @type model: PDBModel
120 @return: true, if the model needs to be updated from its source
121 @rtype: bool
122 """
123 return (model.atoms is None or model.xyz is None)
124
125
126 - def parse2new( self, source, disconnect=False, skipRes=None ):
127 """
128 Create a new PDBModel from the source.
129
130 @param source: source PDB file or pickled PDBModel or PDBModel object
131 @type source: str || file || PDBModel
132 @param disconnect: do *not* associate new model with the source [False]
133 @type disconnect: bool
134 @param skipRes: list residues that should not be parsed
135 @type skipRes: [ str ]
136
137 @return: new model (always of type PDBModel, regardless of source type)
138 @rtype: PDBModel
139 """
140 m = B.PDBModel()
141 self.update( m, source, skipRes=skipRes)
142
143 if disconnect: m.disconnect()
144
145 return m
146