def __init__(self, mol, origin, confIndex):
        Kinematics.__init__(self, mol.allAtoms.coords, mol.torTree, tolist=1)
        # this stoc object will leave always deposite it's coords
        # in the given confIndex slot.
        self.confIndex = confIndex
        
        mol.allAtoms.setConformation(confIndex)
        
        def __prepareNode(node, allAtoms, o):
            """Supply each node with atomSet, coords, and atomRange,
            Pre-compute and save the torsionUnitVector, 
            Transform the coords to their local space by subtracting
            the origin
            """
            atomSet = []
            coords = []
            for i in node.atomList:
                atom = allAtoms[i]
                atomSet.append(atom)
                # start with the original coordinates
                c = atom.coords
                # subract the origin
                coords.append((c[0]-o[0], c[1]-o[1], c[2]-o[2], 1.0))
            node.atomSet = atomSet
            node.coords = coords
            node.atomRange = range(len(atomSet))
            if node.bond[0] != None: # skip the root node
                node.a = allAtoms[node.bond[0]]
                node.b = allAtoms[node.bond[1]]

        # add atomSets to each node
        root = mol.torTree.rootNode
        root.pre_traverse(__prepareNode, root, mol.allAtoms, origin)
Exemplo n.º 2
0
    def __init__(self, mol, origin, confIndex):
        Kinematics.__init__(self, mol.allAtoms.coords, mol.torTree, tolist=1)
        # this stoc object will leave always deposite it's coords
        # in the given confIndex slot.
        self.confIndex = confIndex

        mol.allAtoms.setConformation(confIndex)

        def __prepareNode(node, allAtoms, o):
            """Supply each node with atomSet, coords, and atomRange,
            Pre-compute and save the torsionUnitVector, 
            Transform the coords to their local space by subtracting
            the origin
            """
            atomSet = []
            coords = []
            for i in node.atomList:
                atom = allAtoms[i]
                atomSet.append(atom)
                # start with the original coordinates
                c = atom.coords
                # subract the origin
                coords.append((c[0] - o[0], c[1] - o[1], c[2] - o[2], 1.0))
            node.atomSet = atomSet
            node.coords = coords
            node.atomRange = list(range(len(atomSet)))
            if node.bond[0] != None:  # skip the root node
                node.a = allAtoms[node.bond[0]]
                node.b = allAtoms[node.bond[1]]

        # add atomSets to each node
        root = mol.torTree.rootNode
        root.pre_traverse(__prepareNode, root, mol.allAtoms, origin)
Exemplo n.º 3
0
    def test_applyAngList022(self):
        """applyAngList     -- return correct coords ( 0,-90, 0)"""
        ko = Kinematics(self.known_points, self.torTree, tolist=0)
        result = ko.applyAngList([0., -90., 0.], self.idmtx)[:, :3]

        self.known_points[0] = [1., 1., 1.]
        self.known_points[2] = [1., 0., 0.]
        self.assertArrayEqual(self.known_points, result)
    def test_applyAngList022(self):
        """applyAngList     -- return correct coords ( 0,-90, 0)"""
        ko = Kinematics(self.known_points, self.torTree, tolist=0)
        result = ko.applyAngList([0.,-90.,0.], self.idmtx)[:,:3]

        self.known_points[0] = [1., 1., 1.]
        self.known_points[2] = [1., 0., 0.]
        self.assertArrayEqual(self.known_points, result)
Exemplo n.º 5
0
    def test_applyTorsion02(self):
        """applyTorsion     -- return correct coords torsion=1, angle=90."""
        ko = Kinematics(self.known_points, self.torTree, tolist=0)
        result = ko.applyTorsion(ko.torsions[1], 90.)[:, :3]

        self.known_points[0] = [1., -1., 1.]
        self.known_points[2] = [1., 0., 2.]
        self.assertArrayEqual(self.known_points, result)
    def test_applyTorsion02(self):
        """applyTorsion     -- return correct coords torsion=1, angle=90."""
        ko = Kinematics(self.known_points, self.torTree, tolist=0)
        result = ko.applyTorsion(ko.torsions[1], 90.)[:,:3]

        self.known_points[0] = [1., -1., 1.]
        self.known_points[2] = [1., 0., 2.]
        self.assertArrayEqual(self.known_points, result)
    def test_applyAngList021(self):
        """applyAngList     -- return correct coords (90, 0, 0)"""
        ko = Kinematics(self.known_points, self.torTree, tolist=0)
        result = ko.applyAngList([90.0, 0.0, 0.0], self.idmtx)[:, :3]

        self.known_points[0] = [0.0, 1.0, 2.0]
        self.known_points[1] = [0.0, 1.0, 1.0]
        self.known_points[2] = [-1.0, 1.0, 1.0]
        self.assertArrayEqual(self.known_points, result)
Exemplo n.º 8
0
    def test_applyTorsion02(self):
        """applyTorsion     -- apply torsions in any order"""
        ko1 = Kinematics(self.known_points, self.torTree, tolist=0)
        ko1.applyTorsion(ko1.torsions[0], 90.)
        result1 = ko1.applyTorsion(ko1.torsions[1], -90.)

        ko2 = Kinematics(self.known_points, self.torTree, tolist=0)
        ko2.applyTorsion(ko2.torsions[1], -90.)
        result2 = ko2.applyTorsion(ko2.torsions[0], 90.)
        self.assertArrayEqual(result1, result2)
    def test_applyTorsion02(self):
        """applyTorsion     -- apply torsions in any order"""
        ko1 = Kinematics(self.known_points, self.torTree, tolist=0)
        ko1.applyTorsion(ko1.torsions[0], 90.)
        result1 = ko1.applyTorsion(ko1.torsions[1], -90.)

        ko2 = Kinematics(self.known_points, self.torTree, tolist=0)
        ko2.applyTorsion(ko2.torsions[1], -90.)
        result2 = ko2.applyTorsion(ko2.torsions[0], 90.)
        self.assertArrayEqual(result1, result2)
Exemplo n.º 10
0
    def test_applyAngList04(self):
        """applyAngList     -- one-at-time equals all-at-once"""
        ko1 = Kinematics(self.known_points, self.torTree, tolist=0)
        ko2 = Kinematics(self.known_points, self.torTree, tolist=0)
        result1 = ko1.applyAngList([90., -90., 0.], self.idmtx)[:, :3]

        # do the rotations separately
        ko2.applyAngList([90., 0., 0.])
        result2 = ko2.applyAngList([0., -90., 0.], self.idmtx)[:, :3]
        self.assertArrayEqual(result1, result2)
    def test_applyAngList04(self):
        """applyAngList     -- one-at-time equals all-at-once"""
        ko1 = Kinematics(self.known_points, self.torTree, tolist=0)
        ko2 = Kinematics(self.known_points, self.torTree, tolist=0)        
        result1 = ko1.applyAngList([90.,-90.,0.], self.idmtx)[:,:3]

        # do the rotations separately
        ko2.applyAngList([90.,0.,0.])
        result2 = ko2.applyAngList([0.,-90.,0.], self.idmtx)[:,:3]
        self.assertArrayEqual(result1, result2)
 def test_applyAngList01(self):
     """applyAngList     -- return correct coords (360., 360., 360.)"""
     ko = Kinematics(self.known_points, self.torTree, tolist=0)
     result = ko.applyAngList([360.,360.,360.], self.idmtx)[:,:3]
     self.assertArrayEqual(self.known_points, result)
Exemplo n.º 13
0
 def test_applyTorsion01(self):
     """applyTorsion     -- return correct coords torsion=0, angle=0."""
     ko = Kinematics(self.known_points, self.torTree, tolist=1)
     self.assertEqual(self.known_points,
                      ko.applyTorsion(ko.torsions[0], 0.))
Exemplo n.º 14
0
 def test_applyAngList05(self):
     """applyAngList     -- ValueError if len(angList) != len(torsions)"""
     ko = Kinematics(self.known_points, self.torTree, tolist=1)
     self.assertRaises(ValueError, ko.applyAngList, ([0, 0], self.idmtx))
Exemplo n.º 15
0
 def test_applyAngList01(self):
     """applyAngList     -- return correct coords (360., 360., 360.)"""
     ko = Kinematics(self.known_points, self.torTree, tolist=0)
     result = ko.applyAngList([360., 360., 360.], self.idmtx)[:, :3]
     self.assertArrayEqual(self.known_points, result)
Exemplo n.º 16
0
 def test_applyAngList00(self):
     """applyAngList     -- return correct coords (0., 0., 0.)"""
     ko = Kinematics(self.known_points, self.torTree, tolist=1)
     self.assertEqual(self.known_points,
                      ko.applyAngList([0, 0, 0], self.idmtx))
 def test_applyAngList00(self):
     """applyAngList     -- return correct coords (0., 0., 0.)"""
     ko = Kinematics(self.known_points, self.torTree, tolist=1)
     self.assertEqual(self.known_points, ko.applyAngList([0,0,0], self.idmtx))
 def test_applyTorsion01(self):
     """applyTorsion     -- return correct coords torsion=0, angle=0."""
     ko = Kinematics(self.known_points, self.torTree, tolist=1)
     self.assertEqual(self.known_points, ko.applyTorsion( ko.torsions[0], 0.) )