pKaTool/MD_elec.py
def distance_geometry(self,dists,error=0.5):
        #
        """From a set of distances produce coordinates that are consistent with them"""
        """The distances can vary +/- error A"""
        #
        #
        # Do triangle smoothing
        #
        atoms=self.dists.keys()
        atoms.sort()
        not_converged=None
        round=0
        while not_converged>0:
            #
            # Maybe we will converge this time?
            #
            not_converged=0
            round=round+1
            #
            # Loop over all triangles
            #
            for atom1 in atoms:
                for atom2 in atoms:
                    for atom3 in atoms:
                        #
                        # Is dist atom1-atom2 <= atom1-atom3 + atom3-atom2?
                        #
                        if dists[atom1][atom2]>(dists[atom1][atom3]+dists[atom3][atom2])+3*error:
                            #
                            # Decrease the atom1,atom2 distance by error
                            #
                            dists[atom1][atom2]=dists[atom1][atom2]-error
                            dists[atom2][atom1]=dists[atom1][atom2]
                            not_converged=not_converged+1
                        #
                        # Is dist atom1-atom2 < dist atom1-atom3 - atom3-atom2 ?
                        #
                        if dists[atom1][atom2] < dists[atom1][atom3]-dists[atom3][atom2] -3*error:
                            #
                            # Increase the atom1,atom2 distance by error
                            #
                            dists[atom1][atom2]=dists[atom1][atom2]+error
                            dists[atom2][atom1]=dists[atom1][atom2]
                            not_converged=not_converged+1
            #
            # Converged?
            #
            print 'Round: %4d, Incorrect triangles: %4d ' %(round,not_converged)
        return
From a set of distances produce coordinates that are consistent with them
From a set of distances produce coordinates that are consistent with them
From a set of distances produce coordinates that are consistent with them
def distance_geometry(self,dists,error=0.5):
         Do triangle smoothing
        atoms=self.dists.keys()
        atoms.sort()
        not_converged=None
        round=0
        while not_converged>0:
             Maybe we will converge this time?
            not_converged=0
            round=round+1
             Loop over all triangles
            for atom1 in atoms:
                for atom2 in atoms:
                    for atom3 in atoms:
                         Is dist atom1-atom2 <= atom1-atom3 + atom3-atom2?
                        if dists[atom1][atom2]>(dists[atom1][atom3]+dists[atom3][atom2])+3*error:
                             Decrease the atom1,atom2 distance by error
                            dists[atom1][atom2]=dists[atom1][atom2]-error
                            dists[atom2][atom1]=dists[atom1][atom2]
                            not_converged=not_converged+1
                         Is dist atom1-atom2 < dist atom1-atom3 - atom3-atom2 ?
                        if dists[atom1][atom2] < dists[atom1][atom3]-dists[atom3][atom2] -3*error:
                             Increase the atom1,atom2 distance by error
                            dists[atom1][atom2]=dists[atom1][atom2]+error
                            dists[atom2][atom1]=dists[atom1][atom2]
                            not_converged=not_converged+1
             Converged?
            print 'Round: %4d, Incorrect triangles: %4d ' %(round,not_converged)
        return
def distance_geometry ( self , dists , error = 0.5 ) : """The distances can vary +/- error A""" atoms = self . dists . keys ( ) atoms . sort ( ) not_converged = None round = 0 while not_converged > 0 : not_converged = 0 round = round + 1 for atom1 in atoms : for atom2 in atoms : for atom3 in atoms : if dists [ atom1 ] [ atom2 ] > ( dists [ atom1 ] [ atom3 ] + dists [ atom3 ] [ atom2 ] ) + 3 * error : dists [ atom1 ] [ atom2 ] = dists [ atom1 ] [ atom2 ] - error dists [ atom2 ] [ atom1 ] = dists [ atom1 ] [ atom2 ] not_converged = not_converged + 1 if dists [ atom1 ] [ atom2 ] < dists [ atom1 ] [ atom3 ] - dists [ atom3 ] [ atom2 ] - 3 * error : dists [ atom1 ] [ atom2 ] = dists [ atom1 ] [ atom2 ] + error dists [ atom2 ] [ atom1 ] = dists [ atom1 ] [ atom2 ] not_converged = not_converged + 1 print 'Round: %4d, Incorrect triangles: %4d ' % ( round , not_converged ) return
From a set of distances produce coordinates that are consistent with them
From a set of distances produce coordinates that are consistent with them
# """From a set of distances produce coordinates that are consistent with them""" """The distances can vary +/- error A""" # # # Do triangle smoothing # # # Maybe we will converge this time? # # # Loop over all triangles # # # Is dist atom1-atom2 <= atom1-atom3 + atom3-atom2? # # # Decrease the atom1,atom2 distance by error # # # Is dist atom1-atom2 < dist atom1-atom3 - atom3-atom2 ? # # # Increase the atom1,atom2 distance by error # # # Converged? #
self
dists
error