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

Source Code for Module Biskit.PCRModel

  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  ## $Revision: 2.4 $ 
 21  ## last $Author: leckner $ 
 22  ## last $Date: 2006/09/12 06:34:36 $ 
 23   
 24  """ 
 25  PDBModel with attached Xplor topology (PSF). 
 26  """ 
 27   
 28  ## PCRModel: 
 29  ## collect and manage information about a ligand or receptor conformation 
 30  ## generated by (PCR)MD 
 31   
 32  import os.path 
 33   
 34  import tools as t 
 35  from PDBModel import PDBModel 
 36   
 37   
38 -class PCRModel( PDBModel ):
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 ## in case given fPDB is already a PCRModel, keep psfFileName 58 self.psfFileName = fPsf or getattr( source, 'psfFileName', None) 59 60 ## version as of creation of this object 61 self.initVersion = self.version()
62 63
64 - def version( self ):
65 return PDBModel.version(self) + '; PCRModel $Revision: 2.4 $'
66 67
68 - def getPsfFile(self):
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
83 - def concat(self, *models ):
84 r = PDBModel.concat( self, *models ) 85 r.psfFileName = self.psfFileName 86 r.initVersion = self.initVersion 87 return r
88 89 90 ############# 91 ## TESTING 92 ############# 93
94 -class Test:
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 ## Loading PDB... 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 ## remove waters 119 m_com = m_com.compress( m_com.maskProtein() ) 120 m_rec = m_rec.compress( m_rec.maskProtein() ) 121 122 ## fit the complex structure to the free receptor 123 m_com_fit = m_com.magicFit( m_rec ) 124 125 ## calculate the rmsd between the original complex and the 126 ## one fitted to the free receptor 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
136 - def expected_result( self ):
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