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 pickled PDBModel from disc into a new PDBModel instance
25 """
26 import Biskit.tools as T
27 import Biskit as B
28
29 from PDBParser import PDBParserError
30 from PDBParseModel import PDBParseModel
31
33
34 @staticmethod
36 """
37 The method is static and can thus be called directly with the parser
38 class rather than with an instance::
39
40 >>> if ParsePDBModel.supports( model ):
41 >>> ...
42
43 @return: True if the given source is supported by this parser
44 implementation (equivalent to isinstance( source, PDBModel) )
45 @rtype: bool
46 """
47 return (type(source) is str) or isinstance(source, B.LocalPath)
48
49 @staticmethod
51 """
52 The method is static and can thus be called directly with the parser
53 class rather than with an instance::
54
55 >>> if ParsePDBModel.description():
56 >>> ...
57
58 @return: short free text description of the supported format
59 @rtype: str
60 """
61 return 'pickled PDBModel (file)'
62
63
64 - def update( self, model, source, skipRes=None, lookHarder=0 ):
65 """
66 Update empty or missing fields of model from the source. The
67 model will be connected to the source via model.source.
68
69 @param model: existing model
70 @type model: PDBModel
71 @param source: source PDB file or pickled PDBModel or PDBModel object
72 @type source: str || file || PDBModel
73 @param skipRes: list residue names that should not be parsed
74 @type skipRes: [ str ]
75 """
76 try:
77 if self.needsUpdate( model ):
78
79 s = T.Load( source )
80
81 super( PDBParsePickle, self ).update(
82 model, s, skipRes=skipRes, lookHarder=lookHarder)
83
84 except Exception, why:
85 raise PDBParserError, "Cannot unpickle source model from %s, "\
86 % str(source) + "Reason:\n" + str(why)
87
88 model.setSource( source )
89