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

Source Code for Module Biskit.PDBParserFactory

 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 20:53:22 $ 
22  ## $Revision: 2.1 $ 
23  """ 
24  @see L{Biskit.PDBParser} 
25  @see L{Biskit.PDBParseFile} 
26  @see L{Biskit.PDBParseModel} 
27  @see L{Biskit.PDBParsePickle} 
28  """ 
29   
30  from PDBParseFile   import PDBParseFile 
31  from PDBParseModel  import PDBParseModel 
32  from PDBParsePickle import PDBParsePickle 
33   
34 -class PDBParserFactory:
35 """ 36 Provide the right PDBParser for different structure sources. 37 """ 38 39 @staticmethod
40 - def getParser( source ):
41 """ 42 getParser( source ) -> PDBParser; Fetch a Parser for the source. 43 44 The method is static and should be called directly with the class:: 45 46 p = ParserFactory.getParser( 'myfile.pdb' ) 47 48 @param source: structure source (PDB file, PDBModel, pickled model) 49 @type source: str | LocalPath | PDBModel 50 51 @return: a parser that should be able to handle the given source 52 @rtype: PDBParser (child) 53 54 @raise PDBError: if no compatible parser is found 55 """ 56 57 if PDBParseFile.supports( source ): 58 return PDBParseFile() 59 60 if PDBParseModel.supports( source ): 61 return PDBParseModel() 62 63 if PDBParsePickle.supports( source ): 64 return PDBParsePickle() 65 66 raise PDBParserError, 'Format of %r is not recognized.' % source
67