1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 """
25 PDBModel with attached Xplor topology (PSF).
26 """
27
28
29
30
31
32 import os.path
33
34 import tools as t
35 from PDBModel import PDBModel
36
37
39 """
40 PDBModel with attached Xplor topology (PSF).
41 Creates more problems than it solves...
42 """
43
44 - def __init__(self, fPsf=None, source=None, pdbCode=None, **params):
45 """
46 @param fPsf: file name of psf
47 @type fPsf: str
48 @param source: file name of pdb OR PDBModel instance
49 @type source: str | PDBModel
50 @param pdbCode: if None, first 4 letters of filename will be used
51 @type pdbCode: str
52 """
53 PDBModel.__init__( self, source=source, pdbCode=pdbCode, **params )
54
55 if fPsf: fPsf = t.absfile( fPsf )
56
57
58 self.psfFileName = fPsf or getattr( source, 'psfFileName', None)
59
60
61 self.initVersion = self.version()
62
63
66
67
69 """
70 @return: file name
71 @rtype: str
72 """
73 return self.psfFileName
74
75
76 - def take(self, i, deepcopy=0 ):
77 r = PDBModel.take( self, i, deepcopy )
78 r.psfFileName = self.psfFileName
79 r.initVersion = self.initVersion
80 return r
81
82
84 r = PDBModel.concat( self, *models )
85 r.psfFileName = self.psfFileName
86 r.initVersion = self.initVersion
87 return r
88
89
90
91
92
93
95 """
96 Test class
97 """
98
99
100 - def run( self, local=0 ):
101 """
102 run function test
103
104 @param local: transfer local variables to global and perform
105 other tasks only when run locally
106 @type local: 1|0
107
108 @return: rmsd value
109 @rtype: float
110 """
111
112 m_com = PCRModel( t.testRoot() + "/com/1BGS.psf",
113 t.testRoot() + "/com/1BGS.pdb" )
114
115 m_rec = PCRModel( t.testRoot() + "/rec/1A2P.psf",
116 t.testRoot() + "/rec/1A2P.pdb" )
117
118
119 m_com = m_com.compress( m_com.maskProtein() )
120 m_rec = m_rec.compress( m_rec.maskProtein() )
121
122
123 m_com_fit = m_com.magicFit( m_rec )
124
125
126
127 rms = m_com_fit.rms(m_com, fit=0)
128
129 if local:
130 print 'Rmsd between the two complex structures: %.2f Angstrom'%rms
131 globals().update( locals() )
132
133 return rms
134
135
137 """
138 Precalculated result to check for consistent performance.
139
140 @return: rmsd value
141 @rtype: float
142 """
143 return 58.784401345508634
144
145
146 if __name__ == '__main__':
147
148 test = Test()
149
150 assert abs( test.run( local=1 ) - test.expected_result() ) < 1e-8
151