Protool/electrostatics.py
def calculate_matrix(self,filename=None,eps=8,exdi=80,updater=None):
        """
        # This function calculates a simplified version of the charge-charge interaction
        # energy matrix
        #
        #
        # Calculate the factor that converts formal charges and distances in A into kT energies
        # eps is the dielectric constant
        """
        factor=(1.0/(4.0*pi*e0))*(e*e/A)*1.0/eps*1.0/(k*T)
        #
        # Get the fast scaled accessibility
        #
        acc=self.get_atoms_around(updater=updater)
        #
        # And now we calculate the matrix
        #
        import string
        if not getattr(self,'titratable_groups',None):
            self.get_titratable_groups()
        self.matrix={}
        self.distmatrix={}
        titgrps=self.titratable_groups
        residues=titgrps.keys()
        residues.sort()
        #
        # Get the total number of calcs
        #
        ncalcs=len(residues)*len(residues)
        count=0
        for residue in residues:
            for group in titgrps[residue]:
                name1=self.get_titgroup_name(residue,group) 
                if not self.matrix.has_key(name1):
                    self.matrix[name1]={}
                if not self.distmatrix.has_key(name1):
                    self.distmatrix[name1]={}
                #
                # Calculate distance from center of atoms
                #
                x=0.0
                y=0.0
                z=0.0
                for atom in group['atoms']:
                    x=x+self.atoms[residue+':'+atom]['X']/float(len(group['atoms']))
                    y=y+self.atoms[residue+':'+atom]['Y']/float(len(group['atoms']))
                    z=z+self.atoms[residue+':'+atom]['Z']/float(len(group['atoms']))
                #
                # Now for the second residue
                #
                for residue2 in titgrps.keys():
                    for group2 in titgrps[residue2]:
                        if not updater is None:
                            updater('%d of %d (%4.1f%% completed)' %(count,ncalcs,float(count)/float(ncalcs)*100.0))
                        count=count+1
                        name2=self.get_titgroup_name(residue2,group2)
                        if self.matrix[name1].has_key(name2):
                            continue
                        #
                        # Get center of atoms for this res
                        #
                        x2=0.0
                        y2=0.0
                        z2=0.0
                        for atom in group2['atoms']:
                            x2=x2+self.atoms[residue2+':'+atom]['X']/float(len(group2['atoms']))
                            y2=y2+self.atoms[residue2+':'+atom]['Y']/float(len(group2['atoms']))
                            z2=z2+self.atoms[residue2+':'+atom]['Z']/float(len(group2['atoms']))
                        #
                        # Get the distance
                        #
                        v1=numpy.array([x,y,z])
                        v2=numpy.array([x2,y2,z2])
                        import geometry
                        dist=geometry.length(v1-v2)
 
                        if dist!=0:
                            crg1=group['charge']
                            crg2=group2['charge']
                            ene=factor*float(crg1*crg2)/(math.pow(dist,1.5))
                            #
                            # Get the influence of the acc
                            #
                            acc_frac=math.sqrt(acc[name1]*acc[name2])
                            acc_frac=math.pow(acc_frac,2.0)
                            ene=ene*1.99*acc_frac+(1.0-acc_frac)*float(eps)/float(exdi)*ene
                        else:
                            ene=0.0
                        #if ene:
                        #    print '%20s - %20s: %7.3f' %(name1,name2,ene)
                        self.matrix[name1][name2]=[ene,0.0,0.0,0.0]
                        self.distmatrix[name1][name2]=dist 
                        if not self.matrix.has_key(name2):
                            self.matrix[name2]={}
                            self.matrix[name2]={}
                        self.matrix[name2][name1]=[ene,0.0,0.0,0.0]
                        self.distmatrix[name2][name1]=dist
        #
        # Write the matrix file
        #
        if filename:
            import pKaIO
            X=pKaIO.pKaIO()
            X.matrix=self.matrix
            X.write_matrix(filename+'.MATRIX.DAT')
        return self.matrix

        # This function calculates a simplified version of the charge-charge interaction
        # energy matrix
        #
        #
        # Calculate the factor that converts formal charges and distances in A into kT energies
        # eps is the dielectric constant
        
This function calculates a simplified version of the charge-charge interaction
energy matrix

Calculate the factor that converts formal charges and distances in A into kT energies
eps is the dielectric constant
This function calculates a simplified version of the charge - charge interaction energy matrix Calculate the factor that converts formal charges and distances in A into kT energies eps is the dielectric constant
def calculate_matrix(self,filename=None,eps=8,exdi=80,updater=None):
        factor=(1.0/(4.0*pi*e0))*(e*e/A)*1.0/eps*1.0/(k*T)
         Get the fast scaled accessibility
        acc=self.get_atoms_around(updater=updater)
         And now we calculate the matrix
        import string
        if not getattr(self,'titratable_groups',None):
            self.get_titratable_groups()
        self.matrix={}
        self.distmatrix={}
        titgrps=self.titratable_groups
        residues=titgrps.keys()
        residues.sort()
         Get the total number of calcs
        ncalcs=len(residues)*len(residues)
        count=0
        for residue in residues:
            for group in titgrps[residue]:
                name1=self.get_titgroup_name(residue,group) 
                if not self.matrix.has_key(name1):
                    self.matrix[name1]={}
                if not self.distmatrix.has_key(name1):
                    self.distmatrix[name1]={}
                 Calculate distance from center of atoms
                x=0.0
                y=0.0
                z=0.0
                for atom in group['atoms']:
                    x=x+self.atoms[residue+':'+atom]['X']/float(len(group['atoms']))
                    y=y+self.atoms[residue+':'+atom]['Y']/float(len(group['atoms']))
                    z=z+self.atoms[residue+':'+atom]['Z']/float(len(group['atoms']))
                 Now for the second residue
                for residue2 in titgrps.keys():
                    for group2 in titgrps[residue2]:
                        if not updater is None:
                            updater('%d of %d (%4.1f%% completed)' %(count,ncalcs,float(count)/float(ncalcs)*100.0))
                        count=count+1
                        name2=self.get_titgroup_name(residue2,group2)
                        if self.matrix[name1].has_key(name2):
                            continue
                         Get center of atoms for this res
                        x2=0.0
                        y2=0.0
                        z2=0.0
                        for atom in group2['atoms']:
                            x2=x2+self.atoms[residue2+':'+atom]['X']/float(len(group2['atoms']))
                            y2=y2+self.atoms[residue2+':'+atom]['Y']/float(len(group2['atoms']))
                            z2=z2+self.atoms[residue2+':'+atom]['Z']/float(len(group2['atoms']))
                         Get the distance
                        v1=numpy.array([x,y,z])
                        v2=numpy.array([x2,y2,z2])
                        import geometry
                        dist=geometry.length(v1-v2)
                        if dist!=0:
                            crg1=group['charge']
                            crg2=group2['charge']
                            ene=factor*float(crg1*crg2)/(math.pow(dist,1.5))
                             Get the influence of the acc
                            acc_frac=math.sqrt(acc[name1]*acc[name2])
                            acc_frac=math.pow(acc_frac,2.0)
                            ene=ene*1.99*acc_frac+(1.0-acc_frac)*float(eps)/float(exdi)*ene
                        else:
                            ene=0.0
                        if ene:
                            print '%20s - %20s: %7.3f' %(name1,name2,ene)
                        self.matrix[name1][name2]=[ene,0.0,0.0,0.0]
                        self.distmatrix[name1][name2]=dist 
                        if not self.matrix.has_key(name2):
                            self.matrix[name2]={}
                            self.matrix[name2]={}
                        self.matrix[name2][name1]=[ene,0.0,0.0,0.0]
                        self.distmatrix[name2][name1]=dist
         Write the matrix file
        if filename:
            import pKaIO
            X=pKaIO.pKaIO()
            X.matrix=self.matrix
            X.write_matrix(filename+'.MATRIX.DAT')
        return self.matrix
def calculate_matrix ( self , filename = None , eps = 8 , exdi = 80 , updater = None ) : factor = ( 1.0 / ( 4.0 * pi * e0 ) ) * ( e * e / A ) * 1.0 / eps * 1.0 / ( k * T ) acc = self . get_atoms_around ( updater = updater ) import string if not getattr ( self , 'titratable_groups' , None ) : self . get_titratable_groups ( ) self . matrix = { } self . distmatrix = { } titgrps = self . titratable_groups residues = titgrps . keys ( ) residues . sort ( ) ncalcs = len ( residues ) * len ( residues ) count = 0 for residue in residues : for group in titgrps [ residue ] : name1 = self . get_titgroup_name ( residue , group ) if not self . matrix . has_key ( name1 ) : self . matrix [ name1 ] = { } if not self . distmatrix . has_key ( name1 ) : self . distmatrix [ name1 ] = { } x = 0.0 y = 0.0 z = 0.0 for atom in group [ 'atoms' ] : x = x + self . atoms [ residue + ':' + atom ] [ 'X' ] / float ( len ( group [ 'atoms' ] ) ) y = y + self . atoms [ residue + ':' + atom ] [ 'Y' ] / float ( len ( group [ 'atoms' ] ) ) z = z + self . atoms [ residue + ':' + atom ] [ 'Z' ] / float ( len ( group [ 'atoms' ] ) ) for residue2 in titgrps . keys ( ) : for group2 in titgrps [ residue2 ] : if not updater is None : updater ( '%d of %d (%4.1f%% completed)' % ( count , ncalcs , float ( count ) / float ( ncalcs ) * 100.0 ) ) count = count + 1 name2 = self . get_titgroup_name ( residue2 , group2 ) if self . matrix [ name1 ] . has_key ( name2 ) : continue x2 = 0.0 y2 = 0.0 z2 = 0.0 for atom in group2 [ 'atoms' ] : x2 = x2 + self . atoms [ residue2 + ':' + atom ] [ 'X' ] / float ( len ( group2 [ 'atoms' ] ) ) y2 = y2 + self . atoms [ residue2 + ':' + atom ] [ 'Y' ] / float ( len ( group2 [ 'atoms' ] ) ) z2 = z2 + self . atoms [ residue2 + ':' + atom ] [ 'Z' ] / float ( len ( group2 [ 'atoms' ] ) ) v1 = numpy . array ( [ x , y , z ] ) v2 = numpy . array ( [ x2 , y2 , z2 ] ) import geometry dist = geometry . length ( v1 - v2 ) if dist != 0 : crg1 = group [ 'charge' ] crg2 = group2 [ 'charge' ] ene = factor * float ( crg1 * crg2 ) / ( math . pow ( dist , 1.5 ) ) acc_frac = math . sqrt ( acc [ name1 ] * acc [ name2 ] ) acc_frac = math . pow ( acc_frac , 2.0 ) ene = ene * 1.99 * acc_frac + ( 1.0 - acc_frac ) * float ( eps ) / float ( exdi ) * ene else : ene = 0.0 self . matrix [ name1 ] [ name2 ] = [ ene , 0.0 , 0.0 , 0.0 ] self . distmatrix [ name1 ] [ name2 ] = dist if not self . matrix . has_key ( name2 ) : self . matrix [ name2 ] = { } self . matrix [ name2 ] = { } self . matrix [ name2 ] [ name1 ] = [ ene , 0.0 , 0.0 , 0.0 ] self . distmatrix [ name2 ] [ name1 ] = dist if filename : import pKaIO X = pKaIO . pKaIO ( ) X . matrix = self . matrix X . write_matrix ( filename + '.MATRIX.DAT' ) return self . matrix
This function calculates a simplified version of the charge-charge interaction
 energy matrix
This function calculates a simplified version of the charge - charge interaction energy matrix
"""
        # This function calculates a simplified version of the charge-charge interaction
        # energy matrix
        #
        #
        # Calculate the factor that converts formal charges and distances in A into kT energies
        # eps is the dielectric constant
        """ # # Get the fast scaled accessibility # # # And now we calculate the matrix # # # Get the total number of calcs # # # Calculate distance from center of atoms # # # Now for the second residue # # # Get center of atoms for this res # # # Get the distance # # # Get the influence of the acc # #if ene: #    print '%20s - %20s: %7.3f' %(name1,name2,ene) # # Write the matrix file #
self
filename
eps
exdi
updater