Пример #1
0
 def glaccel_glr_axis(self, position, axis, radius):
     """glaccel optimized version of glr_axis.
     """
     if numpy.allclose(AtomMath.length(axis), 0.0):
         return
     end = position + axis
     glaccel.rod(position[0], position[1], position[2], end[0], end[1], end[2], radius)
Пример #2
0
def SuperimposeAtomsOutlierRejection(alist, rmsd_cutoff = 1.0, max_cycles = 100):
    """Superimpose two homologus protein chains. The argument alist is a list of
    2-tuples.  The 2-tuples are the 1:1 atoms to superimpose.  The alignment
    procedure incrementally omits atoms with large deviations until the rmsd of
    the least squares superposition is less than or equal to rmsd_cutoff, or the
    number of cycles exceeds max_cycles.
    """
    for cycle in xrange(max_cycles):
        sresult = SuperimposeAtoms(alist)
        print "Cycle %d NA: %5d RMSD %6.2f" % (cycle, sresult.num_atoms, sresult.rmsd)
        if sresult.rmsd <= rmsd_cutoff:
            return sresult

        deviation = []
        for i in xrange(len(alist)):
            satm, datm = alist[i]            
            spos = sresult.transform(satm.position)
            deviation.append((AtomMath.length(spos - datm.position), i))
        deviation.sort()

        outliers = deviation[-10:]
        outliersr = [(x[1], x[0]) for x in outliers]
        outliersr.sort()
        outliersr.reverse()
        
        for i, d in outliersr:
            if d < rmsd_cutoff: continue
            del alist[i]

    return None
Пример #3
0
def SuperimposeAtomsOutlierRejection(alist, rmsd_cutoff=1.0, max_cycles=100):
    """Superimpose two homologus protein chains. The argument alist is a list of
    2-tuples.  The 2-tuples are the 1:1 atoms to superimpose.  The alignment
    procedure incrementally omits atoms with large deviations until the rmsd of
    the least squares superposition is less than or equal to rmsd_cutoff, or the
    number of cycles exceeds max_cycles.
    """
    for cycle in xrange(max_cycles):
        sresult = SuperimposeAtoms(alist)
        print "Cycle %d NA: %5d RMSD %6.2f" % (cycle, sresult.num_atoms,
                                               sresult.rmsd)
        if sresult.rmsd <= rmsd_cutoff:
            return sresult

        deviation = []
        for i in xrange(len(alist)):
            satm, datm = alist[i]
            spos = sresult.transform(satm.position)
            deviation.append((AtomMath.length(spos - datm.position), i))
        deviation.sort()

        outliers = deviation[-10:]
        outliersr = [(x[1], x[0]) for x in outliers]
        outliersr.sort()
        outliersr.reverse()

        for i, d in outliersr:
            if d < rmsd_cutoff: continue
            del alist[i]

    return None
Пример #4
0
 def glaccel_glr_axis(self, position, axis, radius):
     """glaccel optimized version of glr_axis.
     """
     if numpy.allclose(AtomMath.length(axis), 0.0):
         return
     end = position + axis
     glaccel.rod(position[0], position[1], position[2], end[0], end[1],
                 end[2], radius)
Пример #5
0
    def glr_axis(self, position, axis, radius):
        """Draw a vector axis using the current set material at position
        with the given radius.
        """
        ## don't bother redering small axes -- they look like junk
        if numpy.allclose(AtomMath.length(axis), 0.0):
            return

        self.object_list.append(
            (5, dot43(self.matrix, position),
             dot43(self.matrix,
                   position + axis), radius, self.material_color_r,
             self.material_color_g, self.material_color_b))
Пример #6
0
    def glr_axis(self, position, axis, radius):
        """Draw a vector axis using the current set material at position
        with the given radius.
        """
        ## don't bother redering small axes -- they look like junk
        if numpy.allclose(AtomMath.length(axis), 0.0):
            return
        
        end = position + axis

        l = AtomMath.length(axis)
        R = AtomMath.rmatrixz(axis)

        glPushMatrix()
        self.glr_mult_matrix_Rt(R, position)

        glEnable(GL_LIGHTING)

        quad = gluNewQuadric()
        gluCylindar(quad, radius, radius, l, 10, 1)

        glDisable(GL_LIGHTING)
        glPopMatrix()
Пример #7
0
    def glr_axis(self, position, axis, radius):
        """Draw a vector axis using the current set material at position
        with the given radius.
        """
        ## don't bother redering small axes -- they look like junk
        if numpy.allclose(AtomMath.length(axis), 0.0):
            return

        end = position + axis

        l = AtomMath.length(axis)
        R = AtomMath.rmatrixz(axis)

        glPushMatrix()
        self.glr_mult_matrix_Rt(R, position)

        glEnable(GL_LIGHTING)

        quad = gluNewQuadric()
        gluCylindar(quad, radius, radius, l, 10, 1)

        glDisable(GL_LIGHTING)
        glPopMatrix()
Пример #8
0
    def iter_struct_orth_symops(self, struct):
        """Iterate over the orthogonal-space symmetry operations which will
        place a symmetry related structure near the argument struct.
        """
        ## compute the centroid of the structure
        n = 0
        cent = numpy.zeros(3, float)
        for atm in struct.iter_all_atoms():
            n    += 1
            cent += atm.position
        centroid = cent / n

        ccell = self.calc_cell(self.calc_orth_to_frac(centroid))
        centroid_cell = numpy.array(ccell, float)

        ## compute the distance from the centroid to the farthest point from 
        ## it in the structure.
        max_dist = 0.0
        for frag in struct.iter_amino_acids():
            for atm in frag.iter_atoms():
                dist = AtomMath.length(atm.position - centroid)
                max_dist = max(max_dist, dist)
        max_dist2 = 2.0 * max_dist + 5.0

        for symop in self.space_group.iter_symops():
            for i, j, k in self.cell_search_iter():

                 cell_t  = numpy.array([i, j, k], float)
                 symop_t = SpaceGroups.SymOp(symop.R, symop.t+cell_t)

                 xyz       = self.calc_orth_to_frac(centroid)
                 xyz_symm  = symop_t(xyz)
                 centroid2 = self.calc_frac_to_orth(xyz_symm)

                 if AtomMath.length(centroid - centroid2) <= max_dist2:
                     yield self.calc_orth_symop(symop_t)
Пример #9
0
    def glr_axis(self, position, axis, radius):
        """Draw a vector axis using the current set material at position
        with the given radius.
        """
        ## don't bother redering small axes -- they look like junk
        if numpy.allclose(AtomMath.length(axis), 0.0):
            return

        self.object_list.append(
            (
                5,
                dot43(self.matrix, position),
                dot43(self.matrix, position + axis),
                radius,
                self.material_color_r,
                self.material_color_g,
                self.material_color_b,
            )
        )