Esempio n. 1
0
 def setRigidBodyConstraints(self, universe=None):
     """
     Sets distance constraints that make the object fully rigid.
     """
     if universe is None:
         universe = self.universe()
     if universe is None:
         import Universe
         universe = Universe.InfiniteUniverse()
     atoms = self.atomList()
     if len(atoms) > 1:
         self.addDistanceConstraint(atoms[0], atoms[1],
                                    universe.distance(atoms[0], atoms[1]))
     if len(atoms) > 2:
         self.addDistanceConstraint(atoms[0], atoms[2],
                                    universe.distance(atoms[0], atoms[2]))
         self.addDistanceConstraint(atoms[1], atoms[2],
                                    universe.distance(atoms[1], atoms[2]))
     if len(atoms) > 3:
         for a in atoms[3:]:
             self.addDistanceConstraint(atoms[0], a,
                                        universe.distance(atoms[0], a))
             self.addDistanceConstraint(atoms[1], a,
                                        universe.distance(atoms[1], a))
             self.addDistanceConstraint(atoms[2], a,
                                        universe.distance(atoms[2], a))
 def phiPsi(self, conf=None):
     "Returns the values of the backbone dihedral angles phi and psi."
     universe = self.universe()
     if universe is None:
         universe = Universe.InfiniteUniverse()
     C = None
     for a in self.peptide.N.bondedTo():
         if a.parent.parent != self:
             C = a
             break
     if C is None:
         phi = None
     else:
         phi = universe.dihedral(self.peptide.C, self.peptide.C_alpha,
                                 self.peptide.N, C, conf)
     N = None
     for a in self.peptide.C.bondedTo():
         if a.parent.parent != self:
             N = a
             break
     if N is None:
         psi = None
     else:
         psi = universe.dihedral(N, self.peptide.C, self.peptide.C_alpha,
                                 self.peptide.N, conf)
     return phi, psi
 def write(self, object, configuration=None, distance=None):
     if distance is None:
         try:
             distance = object.universe().distanceVector
         except AttributeError:
             distance = Universe.InfiniteUniverse().distanceVector
     if not ChemicalObjects.isChemicalObject(object):
         for o in object:
             self.write(o, configuration, distance)
     else:
         for bu in object.bondedUnits():
             for a in bu.atomList():
                 self.writeAtom(a, configuration)
             if hasattr(bu, 'bonds'):
                 for b in bu.bonds:
                     self.writeBond(b, configuration, distance)
 def phiPsi(self, conf=None):
     """Returns a list of the (phi, psi) backbone angle pairs
     for each residue."""
     universe = self.universe()
     if universe is None:
         universe = Universe.InfiniteUniverse()
     angles = []
     for i in range(len(self)):
         r = self[i]
         if i == 0:
             phi = None
         else:
             phi = universe.dihedral(r.peptide.C, r.peptide.C_alpha,
                                     r.peptide.N, self[i - 1].peptide.C,
                                     conf)
         if i == len(self) - 1:
             psi = None
         else:
             psi = universe.dihedral(self[i + 1].peptide.N, r.peptide.C,
                                     r.peptide.C_alpha, r.peptide.N, conf)
         angles.append((phi, psi))
     return angles