1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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
35 """
36 Provide the right PDBParser for different structure sources.
37 """
38
39 @staticmethod
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