Exemplo n.º 1
0
        def setUpClass(cls):
            cls.ldr = stc.StructureLoader()

            cls.s1 = cls.ldr.load_structure(cls.s1n)[0]
            cls.s2 = cls.ldr.load_structure(cls.s2n)[0]

            cls.s1.set_contact_map()
            cls.s2.set_contact_map()

            end = 10 if fast else None

            s1ds = stc.AbstractDescriptor.create_descriptors(cls.s1)
            s2ds = stc.AbstractDescriptor.create_descriptors(cls.s2)

            cls.rdic1 = {}
            cls.rdic2 = {}
            for d1, d2 in zip(s1ds, s2ds):
                try:
                    cls.rdic1[d1.central_element.central_monomer.ind] = d1
                except AttributeError:
                    pass
                try:
                    cls.rdic2[d2.central_element.central_monomer.ind] = d2
                except AttributeError:
                    pass

            cls.res = [(cpd.compdesc(d1, d2), d1, d2) for d1 in s1ds[:end]
                       for d2 in s2ds[:end] if None not in (d1, d2)]

            if len(cls.res) == 0:
                raise Warning("No results from compdesc.")
Exemplo n.º 2
0
 def test_pdbstring(self):
     stg = self.struct.create_pdbstring()
     self.struct.save_pdb('stc_test.pdb')
     nstc = structure.StructureLoader().load_structure(
         'test', path='stc_test.pdb')[0]
     stg2 = nstc.create_pdbstring()
     self.assertEqual(stg.read(), stg2.read())
Exemplo n.º 3
0
def make_trajectorytest(strname):
    """Create and return a StructureTest testcase for a structures linked with dcd trajectories."""

    sl = structure.StructureLoader()

    class TrajectoryTest(unittest.TestCase):
        name = strname

        @classmethod
        def setUpClass(cls):
            cls.pdb_structure = sl.load_structure("mdm2",
                                                  path=dcd_data_dir +
                                                  cls.name + ".pdb")[0]

        @testing(structure.Structure.link_dcd_file)
        @testing(structure.Structure.disconnect_trajectory)
        @testing(structure.Structure.next_frame)
        @testing(structure.Structure.frame)
        def test_linking_trajectory(self):
            self.assertIsNone(self.pdb_structure.frame)
            self.pdb_structure.link_dcd_file(dcd_data_dir + self.name + ".dcd")
            fr = self.pdb_structure.frame
            self.pdb_structure.next_frame()
            self.assertEqual(fr + 1, self.pdb_structure.frame)
            self.assertIsNotNone(self.pdb_structure.frame)
            self.pdb_structure.disconnect_trajectory()
            self.assertIsNone(self.pdb_structure.frame)

    return TrajectoryTest
Exemplo n.º 4
0
def w_load(app):
    """Creates structure loader and calls load_structure method with parameters given by user in dialog window."""
    loader = structure.StructureLoader()
    pdb_code = tkSimpleDialog.askstring("PyDesc", "Please enter a 4-char pdb code:", parent=app.root)
    try:
        loader.load_structure(pdb_code)
    except:
        tkMessageBox.showerror("Invalid code", "The code you entered is incorrect:" + pdb_code)
        raise
Exemplo n.º 5
0
    def test_loader(self):
        """ Test StructureLoader.load_structure. """
        loader = structure.StructureLoader()
        for name in self.structures:
            with warnings.catch_warnings(record=True):
                struct = loader.load_structure(name)
            f = loader.handler.get_file(name)
            pdb_models = Bio.PDB.PDBParser(QUIET=True).get_structure(name, f)

            for s in struct:
                self.assertIsInstance(s, structure.Structure)

            self.assertEqual(len(struct), len(pdb_models))
Exemplo n.º 6
0
 def setUpClass(cls):
     cls.s = structure.StructureLoader().load_structure(str_name)[0]
     cls.s.set_contact_map(contacts.RcContact())
     cls.ds = filter(
         bool, structure.AbstractDescriptor.create_descriptors(cls.s))