예제 #1
0
class VRMLChargeFile(VRMLWireframeFile):

    color_scale = VRML.SymmetricColorScale(1.)

    def writeAtom(self, atom, configuration):
        p = atom.position(configuration)
        c = atom.charge()
        c = max(min(c, 1.), -1.)
        if p is None:
            self.warning = 1
        else:
            s = VRML.Sphere(p, 0.1*Units.Ang,
                            material = VRML.Material(diffuse_color =
                                                     self.color_scale(c)))
            s.writeToFile(self)

    bond_material = VRML.DiffuseMaterial('black')

    def writeBond(self, bond, configuration, distance):
        p1 = bond.a1.position(configuration)
        p2 = bond.a2.position(configuration)
        if p1 is not None and p2 is not None:
            bond_vector = 0.5*distance(bond.a1, bond.a2, configuration)
            cut = bond_vector != 0.5*(p2-p1)
            if not cut:
                c = VRML.Line(p1, p2, material = self.bond_material)
                c.writeToFile(self)
            else:
                c = VRML.Line(p1, p1+bond_vector, material = self.bond_material)
                c.writeToFile(self)
                c = VRML.Line(p2, p2-bond_vector, material = self.bond_material)
                c.writeToFile(self)
예제 #2
0
 def writeAtom(self, atom, configuration):
     p = atom.position(configuration)
     if p is None:
         self.warning = 1
     else:
         color = self.atomColor(atom)
         s = VRML.Sphere(p, 0.1*Units.Ang,
                         material = VRML.DiffuseMaterial(color),
                         reuse = 1)
         s.writeToFile(self)
예제 #3
0
 def writeAtom(self, atom, configuration):
     p = atom.position(configuration)
     c = atom.charge()
     c = max(min(c, 1.), -1.)
     if p is None:
         self.warning = 1
     else:
         s = VRML.Sphere(p, 0.1*Units.Ang,
                         material = VRML.Material(diffuse_color =
                                                  self.color_scale(c)))
         s.writeToFile(self)
예제 #4
0
 def writeBond(self, bond, configuration, distance):
     p1 = bond.a1.position(configuration)
     p2 = bond.a2.position(configuration)
     if p1 is not None and p2 is not None:
         bond_vector = 0.5*distance(bond.a1, bond.a2, configuration)
         cut = bond_vector != 0.5*(p2-p1)
         if not cut:
             c = VRML.Line(p1, p2, material = self.bond_material)
             c.writeToFile(self)
         else:
             c = VRML.Line(p1, p1+bond_vector, material = self.bond_material)
             c.writeToFile(self)
             c = VRML.Line(p2, p2-bond_vector, material = self.bond_material)
             c.writeToFile(self)
예제 #5
0
 def writeAtom(self, atom, configuration):
     try:
         highlight = atom.highlight
     except AttributeError:
         highlight = 0
     if highlight:
         p = atom.position(configuration)
         if p is None:
             self.warning = 1
         else:
             s = VRML.Sphere(p, 0.1*Units.Ang,
                             material = VRML.DiffuseMaterial(atom.color),
                             reuse = 1)
             s.writeToFile(self)
예제 #6
0
파일: ConfigIO.py 프로젝트: torkos/MMTK
 def __init__(self, filename, color_values=None):
     VRML.VRMLFile.__init__(self, filename, 'w')
     self.warning = 0
     self.color_values = color_values
     if self.color_values is not None:
         lower = N.minimum.reduce(color_values.array)
         upper = N.maximum.reduce(color_values.array)
         self.color_scale = VRML.ColorScale((lower, upper))
예제 #7
0
 def view(self, scale=1., color=None):
     """Shows a graphical representation of the field using
     a VRML viewer. All values are multiplied by |scale|. |color|
     permits the choice of a color for the graphics objects."""
     from Scientific.Visualization import VRML
     objects = self.graphicsObjects(scale=scale,
                                    color=color,
                                    graphics_module=VRML)
     VRML.Scene(objects).view()
예제 #8
0
파일: ConfigIO.py 프로젝트: torkos/MMTK
 def writeBond(self, bond, configuration, distance):
     p1 = bond.a1.position(configuration)
     p2 = bond.a2.position(configuration)
     if p1 is not None and p2 is not None:
         bond_vector = 0.5 * distance(bond.a1, bond.a2, configuration)
         cut = bond_vector != 0.5 * (p2 - p1)
         color1 = self.atomColor(bond.a1)
         color2 = self.atomColor(bond.a2)
         material1 = VRML.EmissiveMaterial(color1)
         material2 = VRML.EmissiveMaterial(color2)
         if color1 == color2 and not cut:
             c = VRML.Line(p1, p2, material=material1)
             c.writeToFile(self)
         else:
             c = VRML.Line(p1, p1 + bond_vector, material=material1)
             c.writeToFile(self)
             c = VRML.Line(p2, p2 - bond_vector, material=material2)
             c.writeToFile(self)
예제 #9
0
 def writeToFile(self, filename, scale=1., color=None):
     """Writes a graphical representation of the field
     to the VRML file named by |filename|, multiplying
     all values by |scale|. |color| permits the choice
     of a color for the graphics objects."""
     from Scientific.Visualization import VRML
     objects = self.graphicsObjects(scale=scale,
                                    color=color,
                                    graphics_module=VRML)
     VRML.Scene(objects).writeToFile(filename)
예제 #10
0
chain.applyTransformation(transformation)

# Let's calculate the local deformation due to the change in conformation
# for each atom. Small values indicate rigid regions and large values
# indicate flexible regions. The visualization requires a VRML viewer.
# Reference: K. Hinsen, A. Thomas, M.J. Field:  Proteins 34, 369 (1999)

from MMTK.Deformation import FiniteDeformationFunction
from Scientific.Visualization import VRML
difference = monomer_configuration - universe.configuration()
deformation_function = FiniteDeformationFunction(universe, 0.3, 0.6)
deformation = deformation_function(difference)
graphics = universe.graphicsObjects(color_values=deformation,
                                    graphics_module=VRML)
VRML.Scene(graphics).view()

# The deformation shows a small rigid region and a much larger
# more flexible region.

# Action: We show an animation of the two configurations. This requires
# an animation-capable external viewer, e.g. VMD.

from MMTK.Visualization import viewSequence
viewSequence(chain, [universe.configuration(), monomer_configuration])

# Interesting: there's a floppy loop with residues Gln61, Glu62, and Glu63
# at the tip. It seems to do a funny rotation relative to a closeby helix
# (His94-Lys101) when switching between the two configurations. Let's
# find out what this rotation is!