pKaTool/dist_geom.py
def find_match(self):
        """find match for the coordinates in teh PDB"""
        if not self.P:
            return
        #
        # Number of groups from distance geometry
        #
        groups=self.coords.keys()        
        num_groups=len(groups)
        #
        # Get the titratable groups in the protein
        #
        self.P.get_titratable_groups()
        tit_grps=self.P.titratable_groups
        tres=tit_grps.keys()
        tres.sort()
        #
        #
        #
        grp_centers={}
        for res in tres:
            name=self.P.resname(res)
            if not name in ['ARG','LYS','GLU','ASP','HIS']:
                continue
            for group in tit_grps[res]:
                atoms=[]
                for atom in group['atoms']:
                    atomname=res+':'+atom
                    if self.P.atoms.has_key(atomname):
                        atoms.append(self.P.GetPosition(atomname))
                #
                # Get avg coordinate
                #
                avg=numpy.zeros([3])
                for c in atoms:
                    avg=avg+c
                avg=avg/float(len(atoms))
                #
                # Construct group name
                #
                gname=res+':'+group['name']
                grp_centers[gname]=avg
        #
        # Construct all permutations and find best match
        #
        # Number of groups to fit is num_groups
        #
        prot_groups=grp_centers.keys()
        prot_groups.sort()
        print 'Protein groups'
        print prot_groups
        self.permutations=self.construct_permutations(num_groups,prot_groups)
        #
        # Load the coordinates from the distance geometry calc
        #
        fit_coords=numpy.zeros([num_groups,3])
        count=0
        for group in groups:
            fit_coords[count][0]=self.coords[group]['X']
            fit_coords[count][1]=self.coords[group]['Y']
            fit_coords[count][2]=self.coords[group]['Z']
            count=count+1
        #
        # Search for good matches in all group_centers
        #
        print 'Number of permutations to search: %d' %(len(self.permutations.keys()))
        fit_results={}
        big_count=0
        import sys
        for perm in self.permutations.keys():
            ref_coords=numpy.zeros([num_groups,3])
            count=0
            for group_name in eval(perm):
                ref_coords[count]=grp_centers[group_name]
                count=count+1
            #
            # Do the fit
            #
            rot_mat,trans_vec,rms,rtv,ftv=self.P.superpose(ref_coords,fit_coords)
            self.permutations[perm]=rms
            big_count=big_count+1
            streng='\b\b\b\b\b\b\b\b\b\b %8d' %big_count
            print streng,
            sys.stdout.flush()
        #
        # Get the best ten solutions
        #
        sols=[]
        rmsds=self.permutations.values()
        rmsds.sort()
        print rmsds[:10]
        for rms in rmsds:
            if rms:
                for perm in self.permutations.keys():
                    if not perm in sols:
                        if self.permutations[perm]==rms:
                            sols.append(perm)
            if len(sols)==10:
                break
        #
        # Print them
        #
        self.PDB_text.delete(1.0,END)
        for sol in sols:
            self.PDB_text.insert(END,'%30s %7.2f\n' %(sol,self.permutations[sol])) 

        x=[[':0035:',':0078:',':0172:'],[':0035:',':0172:',':0078:'],
           [':0078:',':0035:',':0172:'],[':0078:',':0172:',':0035:'],
           [':0172:',':0035:',':0078:'],[':0172:',':0078:',':0035:']]
        for p in x:
            self.PDB_text.insert(END,'\n%30s %7.2f\n' %(str(p),self.permutations[str(p)]))
            
        return
find match for the coordinates in teh PDB
find match for the coordinates in teh PDB
find match for the coordinates in teh PDB
def find_match(self):
        if not self.P:
            return
         Number of groups from distance geometry
        groups=self.coords.keys()        
        num_groups=len(groups)
         Get the titratable groups in the protein
        self.P.get_titratable_groups()
        tit_grps=self.P.titratable_groups
        tres=tit_grps.keys()
        tres.sort()
        grp_centers={}
        for res in tres:
            name=self.P.resname(res)
            if not name in ['ARG','LYS','GLU','ASP','HIS']:
                continue
            for group in tit_grps[res]:
                atoms=[]
                for atom in group['atoms']:
                    atomname=res+':'+atom
                    if self.P.atoms.has_key(atomname):
                        atoms.append(self.P.GetPosition(atomname))
                 Get avg coordinate
                avg=numpy.zeros([3])
                for c in atoms:
                    avg=avg+c
                avg=avg/float(len(atoms))
                 Construct group name
                gname=res+':'+group['name']
                grp_centers[gname]=avg
         Construct all permutations and find best match
         Number of groups to fit is num_groups
        prot_groups=grp_centers.keys()
        prot_groups.sort()
        print 'Protein groups'
        print prot_groups
        self.permutations=self.construct_permutations(num_groups,prot_groups)
         Load the coordinates from the distance geometry calc
        fit_coords=numpy.zeros([num_groups,3])
        count=0
        for group in groups:
            fit_coords[count][0]=self.coords[group]['X']
            fit_coords[count][1]=self.coords[group]['Y']
            fit_coords[count][2]=self.coords[group]['Z']
            count=count+1
         Search for good matches in all group_centers
        print 'Number of permutations to search: %d' %(len(self.permutations.keys()))
        fit_results={}
        big_count=0
        import sys
        for perm in self.permutations.keys():
            ref_coords=numpy.zeros([num_groups,3])
            count=0
            for group_name in eval(perm):
                ref_coords[count]=grp_centers[group_name]
                count=count+1
             Do the fit
            rot_mat,trans_vec,rms,rtv,ftv=self.P.superpose(ref_coords,fit_coords)
            self.permutations[perm]=rms
            big_count=big_count+1
            streng='\b\b\b\b\b\b\b\b\b\b %8d' %big_count
            print streng,
            sys.stdout.flush()
         Get the best ten solutions
        sols=[]
        rmsds=self.permutations.values()
        rmsds.sort()
        print rmsds[:10]
        for rms in rmsds:
            if rms:
                for perm in self.permutations.keys():
                    if not perm in sols:
                        if self.permutations[perm]==rms:
                            sols.append(perm)
            if len(sols)==10:
                break
         Print them
        self.PDB_text.delete(1.0,END)
        for sol in sols:
            self.PDB_text.insert(END,'%30s %7.2f\n' %(sol,self.permutations[sol])) 
        x=[[':0035:',':0078:',':0172:'],[':0035:',':0172:',':0078:'],
           [':0078:',':0035:',':0172:'],[':0078:',':0172:',':0035:'],
           [':0172:',':0035:',':0078:'],[':0172:',':0078:',':0035:']]
        for p in x:
            self.PDB_text.insert(END,'\n%30s %7.2f\n' %(str(p),self.permutations[str(p)]))
        return
def find_match ( self ) : if not self . P : return groups = self . coords . keys ( ) num_groups = len ( groups ) self . P . get_titratable_groups ( ) tit_grps = self . P . titratable_groups tres = tit_grps . keys ( ) tres . sort ( ) grp_centers = { } for res in tres : name = self . P . resname ( res ) if not name in [ 'ARG' , 'LYS' , 'GLU' , 'ASP' , 'HIS' ] : continue for group in tit_grps [ res ] : atoms = [ ] for atom in group [ 'atoms' ] : atomname = res + ':' + atom if self . P . atoms . has_key ( atomname ) : atoms . append ( self . P . GetPosition ( atomname ) ) avg = numpy . zeros ( [ 3 ] ) for c in atoms : avg = avg + c avg = avg / float ( len ( atoms ) ) gname = res + ':' + group [ 'name' ] grp_centers [ gname ] = avg prot_groups = grp_centers . keys ( ) prot_groups . sort ( ) print 'Protein groups' print prot_groups self . permutations = self . construct_permutations ( num_groups , prot_groups ) fit_coords = numpy . zeros ( [ num_groups , 3 ] ) count = 0 for group in groups : fit_coords [ count ] [ 0 ] = self . coords [ group ] [ 'X' ] fit_coords [ count ] [ 1 ] = self . coords [ group ] [ 'Y' ] fit_coords [ count ] [ 2 ] = self . coords [ group ] [ 'Z' ] count = count + 1 print 'Number of permutations to search: %d' % ( len ( self . permutations . keys ( ) ) ) fit_results = { } big_count = 0 import sys for perm in self . permutations . keys ( ) : ref_coords = numpy . zeros ( [ num_groups , 3 ] ) count = 0 for group_name in eval ( perm ) : ref_coords [ count ] = grp_centers [ group_name ] count = count + 1 rot_mat , trans_vec , rms , rtv , ftv = self . P . superpose ( ref_coords , fit_coords ) self . permutations [ perm ] = rms big_count = big_count + 1 streng = '\b\b\b\b\b\b\b\b\b\b %8d' % big_count print streng , sys . stdout . flush ( ) sols = [ ] rmsds = self . permutations . values ( ) rmsds . sort ( ) print rmsds [ : 10 ] for rms in rmsds : if rms : for perm in self . permutations . keys ( ) : if not perm in sols : if self . permutations [ perm ] == rms : sols . append ( perm ) if len ( sols ) == 10 : break self . PDB_text . delete ( 1.0 , END ) for sol in sols : self . PDB_text . insert ( END , '%30s %7.2f\n' % ( sol , self . permutations [ sol ] ) ) x = [ [ ':0035:' , ':0078:' , ':0172:' ] , [ ':0035:' , ':0172:' , ':0078:' ] , [ ':0078:' , ':0035:' , ':0172:' ] , [ ':0078:' , ':0172:' , ':0035:' ] , [ ':0172:' , ':0035:' , ':0078:' ] , [ ':0172:' , ':0078:' , ':0035:' ] ] for p in x : self . PDB_text . insert ( END , '\n%30s %7.2f\n' % ( str ( p ) , self . permutations [ str ( p ) ] ) ) return
find match for the coordinates in teh PDB
find match for the coordinates in teh PDB
"""find match for the coordinates in teh PDB""" # # Number of groups from distance geometry # # # Get the titratable groups in the protein # # # # # # Get avg coordinate # # # Construct group name # # # Construct all permutations and find best match # # Number of groups to fit is num_groups # # # Load the coordinates from the distance geometry calc # # # Search for good matches in all group_centers # # # Do the fit # # # Get the best ten solutions # # # Print them #
self