예제 #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')))
예제 #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')))
예제 #3
0
    def test2638(self):
        cmd.set('retain_order')
        cmd.fragment('ala', 'm1')
        n = cmd.count_atoms()

        ##
        ## Make long identifiers
        ##

        chain = [randhex()] * n
        resn = [randhex()] * n
        resv = [randint(10**4, 10**6 - 1)] * n
        names = [randhex(4) + str(i) for i in range(n)]

        identif_str = '(chain, resn, resv, name)'
        identifiers = list(zip(chain, resn, resv, names))
        afterload = []

        cmd.alter('m1',
                  identif_str + ' = _next()',
                  space={'_next': next_decorator(identifiers)})

        ##
        ## Test if cif in/out preserves identifiers
        ##

        with testing.mktemp('.cif') as filename:
            cmd.save(filename, 'm1')
            cmd.load(filename, 'm2')

        cmd.iterate('m2',
                    '_afterload.append(' + identif_str + ')',
                    space={'_afterload': afterload})

        self.assertEqual(identifiers, afterload)

        ##
        ## Test if various formats preserve coordinates
        ##

        coords = cmd.get_coordset('m1')

        for ext in ['.pdb', '.xyz', '.mol2', '.sdf']:
            cmd.delete('m2')

            with testing.mktemp(ext) as filename:
                cmd.save(filename, 'm1')
                cmd.load(filename, 'm2')

            self.assertArrayEqual(coords,
                                  cmd.get_coordset('m2'),
                                  delta=1e-3,
                                  msg='not preserving coordinates: ' + ext)
예제 #4
0
    def test2638(self):
        cmd.set('retain_order')
        cmd.fragment('ala', 'm1')
        n = cmd.count_atoms()

        ##
        ## Make long identifiers
        ##

        chain = [randhex()] * n
        resn = [randhex()] * n
        resv = [randint(10**4, 10**6 - 1)] * n
        names = [randhex(4) + str(i) for i in range(n)]

        identif_str = '(chain, resn, resv, name)'
        identifiers = list(zip(chain, resn, resv, names))
        afterload = []

        cmd.alter('m1', identif_str + ' = _next()',
                space={'_next': next_decorator(identifiers)})

        ##
        ## Test if cif in/out preserves identifiers
        ##

        with testing.mktemp('.cif') as filename:
            cmd.save(filename, 'm1')
            cmd.load(filename, 'm2')

        cmd.iterate('m2', '_afterload.append(' + identif_str + ')',
                space={'_afterload': afterload})

        self.assertEqual(identifiers, afterload)

        ##
        ## Test if various formats preserve coordinates
        ##

        coords = cmd.get_coordset('m1')

        for ext in ['.pdb', '.xyz', '.mol2', '.sdf']:
            cmd.delete('m2')

            with testing.mktemp(ext) as filename:
                cmd.save(filename, 'm1')
                cmd.load(filename, 'm2')

            self.assertArrayEqual(coords, cmd.get_coordset('m2'), delta=1e-3,
                    msg='not preserving coordinates: ' + ext)
예제 #5
0
    def test_set_state_order(self):
        import numpy

        cmd.fragment('ala', 'm1')
        for i in (2, 3):
            cmd.create('m1', 'm1', i - 1, i);
            cmd.rotate('x', 10.0, 'm1', i)

        coords1 = cmd.get_coordset('m1', 1)
        coords3 = cmd.get_coordset('m1', 3)

        self.assertEqual(coords1.shape, (10, 3))
        self.assertFalse(numpy.allclose(coords1, coords3))

        cmd.set_state_order('m1', (3, 2, 1))

        self.assertTrue(numpy.allclose(coords1, cmd.get_coordset('m1', 3)))
        self.assertTrue(numpy.allclose(coords3, cmd.get_coordset('m1', 1)))
예제 #6
0
    def test_set_state_order(self):
        import numpy

        cmd.fragment('ala', 'm1')
        for i in (2, 3):
            cmd.create('m1', 'm1', i - 1, i)
            cmd.rotate('x', 10.0, 'm1', i)

        coords1 = cmd.get_coordset('m1', 1)
        coords3 = cmd.get_coordset('m1', 3)

        self.assertEqual(coords1.shape, (10, 3))
        self.assertFalse(numpy.allclose(coords1, coords3))

        cmd.set_state_order('m1', (3, 2, 1))

        self.assertTrue(numpy.allclose(coords1, cmd.get_coordset('m1', 3)))
        self.assertTrue(numpy.allclose(coords3, cmd.get_coordset('m1', 1)))
예제 #7
0
def save_coords(object_name):
    cmd.create("{}".format(object_name), object_name)
    coordinate_set = cmd.get_coordset("{}".format(object_name), 1)
    print("Got ", object_name, "'s coordinates: ", coordinate_set)
    print(type(coordinate_set))

    filename_string = '{name}_coordinates.npy'.format(name=object_name)
    np.save(filename_string, coordinate_set, allow_pickle=True)
    move_to_coords(filename_string)
    print("Coordinates saved successfully under ./Coordinates/{}".format(
        filename_string))
예제 #8
0
    def testDistanceMode4(self):
        # create two 2-state objects
        cmd.fragment('gly', 'm1', origin=0)
        cmd.create('m1', 'm1', 1, 2)
        cmd.create('m2', 'm1', 1, 1)
        cmd.create('m2', 'm1', 1, 2)

        # shift one state by 5 and the other by 9 angstrom
        cs = cmd.get_coordset('m1', state=1, copy=0)
        cs += [5., 0., 0.]
        cs = cmd.get_coordset('m2', state=2, copy=0)
        cs += [9., 0., 0.]

        # creates one distance measure per state
        d = cmd.distance('d1', '?m1', '?m2', mode=4)

        # expecting 7 = (5 + 9) / 2
        self.assertAlmostEqual(d, 7.0, delta=1e-4)

        # one distance measurement has 2 * 3 coordinates
        d1states = cmd.get_session('d1', 1, 1, 0, 0)['names'][0][5][2]
        self.assertEqual(len(d1states[0][1]), 6)
        self.assertEqual(len(d1states[1][1]), 6)
예제 #9
0
    def testDistanceMode4(self):
        # create two 2-state objects
        cmd.fragment('gly', 'm1', origin=0)
        cmd.create('m1', 'm1', 1, 2)
        cmd.create('m2', 'm1', 1, 1)
        cmd.create('m2', 'm1', 1, 2)

        # shift one state by 5 and the other by 9 angstrom
        cs = cmd.get_coordset('m1', state=1, copy=0)
        cs += [5., 0., 0.]
        cs = cmd.get_coordset('m2', state=2, copy=0)
        cs += [9., 0., 0.]

        # creates one distance measure per state
        d = cmd.distance('d1', '?m1', '?m2', mode=4)

        # expecting 7 = (5 + 9) / 2
        self.assertAlmostEqual(d, 7.0, delta=1e-4)

        # one distance measurement has 2 * 3 coordinates
        d1states = cmd.get_session('d1', 1, 1, 0, 0)['names'][0][5][2]
        self.assertEqual(len(d1states[0][1]), 6)
        self.assertEqual(len(d1states[1][1]), 6)
예제 #10
0
 def test(self):
     cmd.load(self.datafile('PYMOL-2985.sdf'), 'm1')
     cset_before = cmd.get_coordset('m1')
     cmd.clean('m1')
     cset_after = cmd.get_coordset('m1')
     self.assertArrayNotEqual(cset_before, cset_after)
예제 #11
0
 def test(self):
     cmd.load(self.datafile('PYMOL-2985.sdf'), 'm1')
     cset_before = cmd.get_coordset('m1')
     cmd.clean('m1')
     cset_after = cmd.get_coordset('m1')
     self.assertArrayNotEqual(cset_before, cset_after)
예제 #12
0
from pymol import cmd
import os
import sys

#cmd.h_add(selection='(all)')
#preset.ball_and_stick(selection='all', mode=1)
lis = cmd.get_object_list(selection='(all)')

for i in lis:
    xyz = cmd.get_coordset(i, 1)
    print xyz