Esempio n. 1
0
def test_join_states():
    cmd.reinitialize()
    cmd.load(DATA_PATH / "1nmr-frag-nohydro.pdb", "m1", multiplex=1)
    assert len(cmd.get_names()) == 4
    assert cmd.count_states() == 1

    psico.creating.join_states("m2", "m1_*", discrete=0)
    assert cmd.count_states("m2") == 4
    assert cmd.count_discrete("m2") == 0
    assert cmd.count_atoms("m2") == 241

    psico.creating.join_states("m3", "m1_*", discrete=1)
    assert cmd.count_states("m3") == 4
    assert cmd.count_discrete("m3") == 1
    assert cmd.count_atoms("m3") == 241 * 4
Esempio n. 2
0
    def testCreateDiscrete(self, discrete_source):
        self.create_many_states("methanol", "m1", 2)
        self.create_many_states("benzene", "m2", 2)
        pymol.editing.set_discrete("m1", discrete=discrete_source)
        pymol.editing.set_discrete("m2", discrete=discrete_source)

        # create new
        cmd.create('dm', 'm1', 0, -1, discrete=1)
        self.assertTrue(cmd.count_discrete('dm'))
        self.assertEqual(cmd.count_states('dm'), 2)
        self.assertEqual(cmd.count_atoms('dm'), 2 * 6)
        self.assertEqual(len(cmd.get_bonds('dm')), 5)

        # append to existing
        cmd.create('dm', 'm2', 0, -1, discrete=1)
        self.assertTrue(cmd.count_discrete('dm'))
        self.assertEqual(cmd.count_states('dm'), 4)
        self.assertEqual(cmd.count_atoms('dm'), 2 * 6 + 2 * 12)
        self.assertEqual(len(cmd.get_bonds('dm', 1)), 5)
        self.assertEqual(len(cmd.get_bonds('dm', 4)), 12)
        self.assertEqual(len(cmd.get_bonds('dm', 0)), 2 * 5 + 2 * 12)
Esempio n. 3
0
    def test_set_discrete(self):
        import pymol

        cmd.fragment('ala', 'm1')
        cmd.create('m1', 'm1', 1, 2)

        self.assertEqual(0, cmd.count_discrete('*'))
        self.assertEqual(2, cmd.count_states())
        self.assertEqual(10, cmd.count_atoms())

        pymol.editing.set_discrete('m1', 1)

        self.assertEqual(1, cmd.count_discrete('*'))
        self.assertEqual(2, cmd.count_states())
        self.assertEqual(20, cmd.count_atoms())

        pymol.editing.set_discrete('m1', 0)

        self.assertEqual(0, cmd.count_discrete('*'))
        self.assertEqual(2, cmd.count_states())
        self.assertEqual(10, cmd.count_atoms())
Esempio n. 4
0
    def test_set_discrete(self):
        import pymol

        cmd.fragment('ala', 'm1')
        cmd.create('m1', 'm1', 1, 2)

        self.assertEqual(0, cmd.count_discrete('*'))
        self.assertEqual(2, cmd.count_states())
        self.assertEqual(10, cmd.count_atoms())

        pymol.editing.set_discrete('m1', 1)

        self.assertEqual(1, cmd.count_discrete('*'))
        self.assertEqual(2, cmd.count_states())
        self.assertEqual(20, cmd.count_atoms())

        pymol.editing.set_discrete('m1', 0)

        self.assertEqual(0, cmd.count_discrete('*'))
        self.assertEqual(2, cmd.count_states())
        self.assertEqual(10, cmd.count_atoms())
Esempio n. 5
0
    def testLoad_multi(self, ext, discrete):
        '''
        Load multi-state files with discrete=0/1 and multiplex=0/1
        '''
        N = 10
        filename = self.datafile('ligs3d.' + ext)

        # mutiplex=0
        cmd.load(filename, discrete=discrete, multiplex=0)
        self.assertEqual(cmd.count_discrete('*'), discrete)
        self.assertEqual(cmd.count_states(), N)
        self.assertEqual(len(cmd.get_object_list()), 1)

        if ext in ['mmd']:
            return

        # mutiplex=1
        cmd.delete('*')
        cmd.load(filename, discrete=discrete, multiplex=1)
        self.assertEqual(cmd.count_discrete('*'), discrete * N)
        self.assertEqual(cmd.count_states(), 1)
        self.assertEqual(len(cmd.get_object_list()), N)
Esempio n. 6
0
    def testLoad_multi(self, ext, discrete):
        '''
        Load multi-state files with discrete=0/1 and multiplex=0/1
        '''
        N = 10
        filename = self.datafile('ligs3d.' + ext)

        # mutiplex=0
        cmd.load(filename, discrete=discrete, multiplex=0)
        self.assertEqual(cmd.count_discrete('*'), discrete)
        self.assertEqual(cmd.count_states(), N)
        self.assertEqual(len(cmd.get_object_list()), 1)

        if ext in ['mmd']:
            return

        # mutiplex=1
        cmd.delete('*')
        cmd.load(filename, discrete=discrete, multiplex=1)
        self.assertEqual(cmd.count_discrete('*'), discrete * N)
        self.assertEqual(cmd.count_states(), 1)
        self.assertEqual(len(cmd.get_object_list()), N)
Esempio n. 7
0
    def testSelectByAtomType(self):
        cmd.load(self.datafile('1oky.pdb.gz'))
        cmd.remove("alt 'B'")
        cmd.select('foo', "resn STU and text_type 'C.3'")
        self.assertEquals(cmd.count_atoms('foo'), 8)

        # discrete object
        cmd.delete('*')
        cmd.load(self.datafile('ligs3d.sdf'))
        self.assertTrue(cmd.count_discrete('*') > 0)
        n = cmd.select('foo', "text_type 'C.3'")
        self.assertEquals(n, 115)

        # only run label test if selection tests passed. Don't wnat
        # more than one failing tests for builds with NO_MMLIBS
        cmd.delete('*')
        self._testLabelByAtomType()
Esempio n. 8
0
    def testLoadMae(self, multiplex, discrete):
        cmd.load(self.datafile('multimae.maegz'), 'm',
                multiplex=multiplex, discrete=discrete)

        nstate = 4
        natoms = 79
        nmodel = 1
        ndiscrete = discrete

        if multiplex:
            natoms *= nstate
            ndiscrete *= nstate
            nmodel = nstate
            nstate = 1
        elif discrete:
            self.assertEqual(cmd.count_atoms(state=1), natoms)
            natoms *= nstate

        self.assertEqual(cmd.count_states(), nstate)
        self.assertEqual(cmd.count_discrete('*'), ndiscrete)
        self.assertEqual(cmd.count_atoms(), natoms)
        self.assertEqual(len(cmd.get_object_list()), nmodel)
Esempio n. 9
0
    def testLoadMae(self, multiplex, discrete):
        cmd.load(self.datafile('multimae.maegz'),
                 'm',
                 multiplex=multiplex,
                 discrete=discrete)

        nstate = 4
        natoms = 79
        nmodel = 1
        ndiscrete = discrete

        if multiplex:
            natoms *= nstate
            ndiscrete *= nstate
            nmodel = nstate
            nstate = 1
        elif discrete:
            self.assertEqual(cmd.count_atoms(state=1), natoms)
            natoms *= nstate

        self.assertEqual(cmd.count_states(), nstate)
        self.assertEqual(cmd.count_discrete('*'), ndiscrete)
        self.assertEqual(cmd.count_atoms(), natoms)
        self.assertEqual(len(cmd.get_object_list()), nmodel)