Exemplo n.º 1
0
    def testLoadCoordset(self):
        import numpy
        cmd.fragment('gly', 'm1')
        coords = cmd.get_coordset('m1')
        cmd.load_coordset(coords, 'm1', state=2)
        self.assertEqual(2, cmd.count_states('m1'))

        # data manipulation with copy=0
        cmd.get_coordset('m1', copy=0)[:] += 5.0
        self.assertTrue(numpy.allclose(coords + 5.0, cmd.get_coords('m1')))
Exemplo n.º 2
0
    def testLoadCoordset(self):
        import numpy
        cmd.fragment('gly', 'm1')
        coords = cmd.get_coordset('m1')
        cmd.load_coordset(coords, 'm1', state=2)
        self.assertEqual(2, cmd.count_states('m1'))

        # data manipulation with copy=0
        cmd.get_coordset('m1', copy=0)[:] += 5.0
        self.assertTrue(numpy.allclose(coords + 5.0, cmd.get_coords('m1')))
Exemplo n.º 3
0
    def test_update(self):
        # 3 states
        cmd.fragment('gly', 'm1')
        cmd.create('m1', 'm1', 1, 2)
        cmd.create('m1', 'm1', 1, 3)

        # second object, 90 degree rotates
        cmd.copy('m2', 'm1')
        cmd.rotate('x', 90, '(m2)', state=0)

        # reference coordsets
        cs = cmd.get_coordset
        cs1 = cs('m1', 1)
        cs2 = cs('m2', 1)

        # m2/3 will change (pre-check)
        self.assertArrayEqual(cs2, cs('m2', 3))
        self.assertArrayNotEqual(cs1, cs('m2', 3))

        # update explicit state
        cmd.update('m2', 'm1', 3, 2)

        # m2/3 has changed
        self.assertArrayEqual(cs1, cs('m2', 3))
        self.assertArrayNotEqual(cs2, cs('m2', 3))

        # these haven't changed
        self.assertArrayEqual(cs2, cs('m2', 1))
        self.assertArrayEqual(cs2, cs('m2', 2))

        # reset m2/3
        cmd.load_coordset(cs2, 'm2', 3)
        self.assertArrayEqual(cs2, cs('m2', 3))

        # update all states
        cmd.update('m2', 'm1', 0, 0)
        self.assertArrayEqual(cs1, cs('m2', 1))
        self.assertArrayEqual(cs1, cs('m2', 2))
        self.assertArrayEqual(cs1, cs('m2', 3))
Exemplo n.º 4
0
    def test_update(self):
        # 3 states
        cmd.fragment('gly', 'm1')
        cmd.create('m1', 'm1', 1, 2)
        cmd.create('m1', 'm1', 1, 3)

        # second object, 90 degree rotates
        cmd.copy('m2', 'm1')
        cmd.rotate('x', 90, '(m2)', state=0)

        # reference coordsets
        cs = cmd.get_coordset
        cs1 = cs('m1', 1)
        cs2 = cs('m2', 1)

        # m2/3 will change (pre-check)
        self.assertArrayEqual(cs2, cs('m2', 3))
        self.assertArrayNotEqual(cs1, cs('m2', 3))

        # update explicit state
        cmd.update('m2', 'm1', 3, 2)

        # m2/3 has changed
        self.assertArrayEqual(cs1, cs('m2', 3))
        self.assertArrayNotEqual(cs2, cs('m2', 3))

        # these haven't changed
        self.assertArrayEqual(cs2, cs('m2', 1))
        self.assertArrayEqual(cs2, cs('m2', 2))

        # reset m2/3
        cmd.load_coordset(cs2, 'm2', 3)
        self.assertArrayEqual(cs2, cs('m2', 3))

        # update all states
        cmd.update('m2', 'm1', 0, 0)
        self.assertArrayEqual(cs1, cs('m2', 1))
        self.assertArrayEqual(cs1, cs('m2', 2))
        self.assertArrayEqual(cs1, cs('m2', 3))
Exemplo n.º 5
0
def load_coords(coords, object, state, quiet=1):
    '''
DESCRIPTION

    API only. Load object coordinates.

    TODO: How to handle the object matrix?

SEE ALSO

    cmd.load_coordset (new in 1.7.3.0)
    pymol.experimenting.load_coords (considered broken!)
    '''
    if hasattr(cmd, 'load_coordset'):
        return cmd.load_coordset(coords, object, int(state))

    if not (isinstance(coords, list) and isinstance(coords[0], list)):
        coords = list(map(list, coords))
    r = cmd._cmd.load_coords(cmd._COb, object, coords,
                             int(state) - 1, cmd.loadable.model)
    if cmd._raising(r): raise CmdException
    return r
Exemplo n.º 6
0
def load_coords(coords, object, state, quiet=1):
    '''
DESCRIPTION

    API only. Load object coordinates.

    TODO: How to handle the object matrix?

SEE ALSO

    cmd.load_coordset (new in 1.7.3.0)
    pymol.experimenting.load_coords (considered broken!)
    '''
    if hasattr(cmd, 'load_coordset'):
        return cmd.load_coordset(coords, object, int(state))

    if not (isinstance(coords, list) and isinstance(coords[0], list)):
        coords = list(map(list, coords))
    r = cmd._cmd.load_coords(cmd._COb, object, coords, int(state)-1,
            cmd.loadable.model)
    if cmd._raising(r): raise CmdException
    return r