示例#1
0
        r_xy_2 = v[:, 0]**2 + v[:, 1]**2
        ## r_xy = sqrt(r_xy_2) # not needed

        # to get radius, take maximum -- not sure if max(r_xy_2) would use Numeric code, but this will for sure:
        i = argmax(r_xy_2)
        max_xy_2 = r_xy_2[i]
        radius = sqrt(max_xy_2)
        # to get limits along axis (since we won't assume center is centered between them), use min/max z:
        z = v[:, 2]
        min_z = z[argmin(z)]
        max_z = z[argmax(z)]
        bcenter = chunk.abs_to_base(center)
        # return, in chunk-relative coords, end1, end2, and radius of the cylinder, and color.
        color = chunk.color
        if color is None:
            color = V(0.5, 0.5, 0.5)
        # make sure it's longer than zero (in case of a single-atom chunk); in fact, add a small margin all around
        # (note: this is not sufficient to enclose all atoms entirely; that's intentional)
        margin = 0.2
        min_z -= margin
        max_z += margin
        radius += margin
        return (bcenter + min_z * axis, bcenter + max_z * axis, radius, color)

    pass  # end of class CylinderChunks


ChunkDisplayMode.register_display_mode_class(CylinderChunks)

# end
        v = dot( points, matrix)
        # compute xy distances-squared between axis line and atom centers
        r_xy_2 = v[:,0]**2 + v[:,1]**2
        ## r_xy = sqrt(r_xy_2) # not needed

        # to get radius, take maximum -- not sure if max(r_xy_2) would use Numeric code, but this will for sure:
        i = argmax(r_xy_2)
        max_xy_2 = r_xy_2[i]
        radius = sqrt(max_xy_2)
        # to get limits along axis (since we won't assume center is centered between them), use min/max z:
        z = v[:,2]
        min_z = z[argmin(z)]
        max_z = z[argmax(z)]
        bcenter = chunk.abs_to_base(center)
        # return, in chunk-relative coords, end1, end2, and radius of the cylinder, and color.
        color = chunk.color
        if color is None:
            color = V(0.5,0.5,0.5)
        # make sure it's longer than zero (in case of a single-atom chunk); in fact, add a small margin all around
        # (note: this is not sufficient to enclose all atoms entirely; that's intentional)
        margin = 0.2
        min_z -= margin
        max_z += margin
        radius += margin
        return (bcenter + min_z * axis, bcenter + max_z * axis, radius, color)
    pass # end of class CylinderChunks

ChunkDisplayMode.register_display_mode_class(CylinderChunks)

# end
示例#3
0
                    pos1 =  2.0 * pos2 - pos3
                    sec[-2] = (pos1, ss1, aa1, idx1, dpos1, cbpos1)                

                # Make sure that the interior surface of helices 
                # is properly oriented.

                if ss == 1:
                    pos2, ss2, aa2, idx2, dpos2, cbpos2 = sec[2]
                    pos3, ss3, aa3, idx3, dpos3, cbpos3 = sec[3]
                    pos4, ss4, aa4, idx4, dpos4, cbpos4 = sec[4]

                    xvec = cross(pos4-pos3, pos3-pos2)
                    sign = dot(xvec, dpos3)

                    if sign > 0: 
                        # Wrong orientation, invert peptide plates
                        for n in range(2, len(sec)-2):
                            (pos1, ss1, aa1, idx1, dpos1, cbpos1) = sec[n]
                            dpos1 *= -1
                            sec[n] = (pos1, ss1, aa1, idx1, dpos1, cbpos1)
                            pass
                # Append the secondary structure element.
                structure.append((sec, ss))
                n_sec += 1

                sec = []                            

        return (structure, n_ca, ca_list, n_sec)

ChunkDisplayMode.register_display_mode_class(ProteinChunks)
示例#4
0
                p = a.posn() - center
                s.spheres.append(Triple(p[0], p[1], p[2]))
                r = p[0]**2+p[1]**2+p[2]**2
                if r > rad: rad = r
            rad = sqrt(rad)
            radius = rad + margin
            for i in range(len(s.spheres)):
                s.spheres[i] /= radius
                s.radiuses[i] /= radius
            color = chunk.drawing_color()
            if color is None:
                color = V(0.5,0.5,0.5)
            #  create surface
            level = 3
            if rad > 6 : level = 4
            ts = getSphereTriangles(level)
            #ts = s.TorusTriangles(0.7, 0.3, 20)
            tm = s.SurfaceTriangles(ts)
            nm = s.SurfaceNormals()

        QApplication.restoreOverrideCursor() # Restore the cursor. Mark 060621.
        env.history.message(self.cmdname + "Done.") # Mark 060621.

        return (bcenter, radius, color, tm, nm)

    pass # end of class SurfaceChunks

ChunkDisplayMode.register_display_mode_class(SurfaceChunks)

# end
示例#5
0
                r = p[0]**2 + p[1]**2 + p[2]**2
                if r > rad: rad = r
            rad = sqrt(rad)
            radius = rad + margin
            for i in range(len(s.spheres)):
                s.spheres[i] /= radius
                s.radiuses[i] /= radius
            color = chunk.drawing_color()
            if color is None:
                color = V(0.5, 0.5, 0.5)
            #  create surface
            level = 3
            if rad > 6: level = 4
            ts = getSphereTriangles(level)
            #ts = s.TorusTriangles(0.7, 0.3, 20)
            tm = s.SurfaceTriangles(ts)
            nm = s.SurfaceNormals()

        QApplication.restoreOverrideCursor(
        )  # Restore the cursor. Mark 060621.
        env.history.message(self.cmdname + "Done.")  # Mark 060621.

        return (bcenter, radius, color, tm, nm)

    pass  # end of class SurfaceChunks


ChunkDisplayMode.register_display_mode_class(SurfaceChunks)

# end