Package Biskit :: Module PDBParsePickle
[hide private]
[frames] | no frames]

Source Code for Module Biskit.PDBParsePickle

 1  ## 
 2  ## Biskit, a toolkit for the manipulation of macromolecular structures 
 3  ## Copyright (C) 2004-2005 Raik Gruenberg & Johan Leckner 
 4  ## 
 5  ## This program is free software; you can redistribute it and/or 
 6  ## modify it under the terms of the GNU General Public License as 
 7  ## published by the Free Software Foundation; either version 2 of the 
 8  ## License, or any later version. 
 9  ## 
10  ## This program is distributed in the hope that it will be useful, 
11  ## but WITHOUT ANY WARRANTY; without even the implied warranty of 
12  ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 
13  ## General Public License for more details. 
14  ## 
15  ## You find a copy of the GNU General Public License in the file 
16  ## license.txt along with this program; if not, write to the Free 
17  ## Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 
18  ## 
19  ## 
20  ## last $Author: graik $ 
21  ## last $Date: 2006/12/16 23:21:54 $ 
22  ## $Revision: 2.2 $ 
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   
32 -class PDBParsePickle( PDBParseModel ):
33 34 @staticmethod
35 - def supports( source ):
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
50 - def description():
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