Esempio n. 1
0
    def test_loop_reconstruction(self):
        """Test loop reconstruction"""

        # input parameter
        pdbfile = self.get_input_file_name(
                   "loop_reconstruction/starting.structure.pdb")
        fastafile = self.get_input_file_name(
                   "loop_reconstruction/sequence.fasta")
        fastids = tools.get_ids_from_fasta_file(fastafile)
        missing_bead_size = 1

        # Component  pdbfile    chainid  rgb color     fastafile     sequence id
        # in fastafile
        data = [("chainA", pdbfile, "A", 0.00000000,  (fastafile,    0)),
                ("chainB", pdbfile, "B", 0.50000000,  (fastafile,    0))]

        # create the representation
        log_objects = []
        optimizable_objects = []

        sw = tools.Stopwatch()
        log_objects.append(sw)

        m = IMP.Model()
        r = representation.Representation(m)

        hierarchies = {}

        for d in data:
            component_name = d[0]
            pdb_file = d[1]
            chain_id = d[2]
            color_id = d[3]
            fasta_file = d[4][0]
            fasta_file_id = d[4][1]
            # avoid adding a component with the same name
            r.create_component(component_name, color=color_id)

            r.add_component_sequence(component_name,
                                     fasta_file,
                                     id=fastids[fasta_file_id])

            hierarchies = r.autobuild_model(component_name, pdb_file,
                                            chain_id, resolutions=[1, 10],
                                            missingbeadsize=missing_bead_size)

            r.show_component_table(component_name)

        rbAB = r.set_rigid_bodies(["chainA", "chainB"])

        r.set_floppy_bodies()
        r.fix_rigid_bodies([rbAB])
        r.setup_bonds()

        log_objects.append(r)

        listofexcludedpairs = []

        lof = [(1, 12, "chainA"), (1, 12, "chainB"),
               (294, 339, "chainA"), (294, 339, "chainB"),
               (686, 701, "chainA"), (686, 701, "chainB"),
               (454, 464, "chainA"), (454, 464, "chainB"),
               (472, 486, "chainA"), (472, 486, "chainB"),
               (814, 859, "chainA"), (814, 859, "chainB")]


        # add bonds and angles
        for l in lof:

            rbr = IMP.pmi.restraints.stereochemistry.ResidueBondRestraint(r, l)
            rbr.add_to_model()
            listofexcludedpairs += rbr.get_excluded_pairs()
            log_objects.append(rbr)

            rar = IMP.pmi.restraints.stereochemistry.ResidueAngleRestraint(r, l)
            rar.add_to_model()
            listofexcludedpairs += rar.get_excluded_pairs()
            log_objects.append(rar)

        # add excluded volume

        ev = IMP.pmi.restraints.stereochemistry.ExcludedVolumeSphere(
                                                   r, resolution=10.0)
        ev.add_excluded_particle_pairs(listofexcludedpairs)
        ev.add_to_model()
        log_objects.append(ev)

        mc = samplers.MonteCarlo(m, [r], 1.0)
        log_objects.append(mc)

        o = output.Output()

        print("Starting test")
        o.write_test("test.current.dict", log_objects)
        o.test(self.get_input_file_name(
                     "loop_reconstruction/test.IMP-ee1763c6.PMI-4669cfca.dict"),
               log_objects)
        os.unlink('test.current.dict')
Esempio n. 2
0
pdbfile = IMP.pmi.get_data_path("benchmark_starting_structure.pdb")
fastafile = IMP.pmi.get_data_path("benchmark_sequence.fasta")
fastids = tools.get_ids_from_fasta_file(fastafile)
missing_bead_size = 1

#         Component  pdbfile    chainid  rgb color     fastafile     sequence id
# in fastafile
data = [("chainA", pdbfile, "A", 0.00000000, (fastafile, 0)),
        ("chainB", pdbfile, "B", 0.50000000, (fastafile, 0))]

# create the representation
log_objects = []
optimizable_objects = []

sw = tools.Stopwatch()
log_objects.append(sw)

m = IMP.Model()
r = representation.Representation(m)

hierarchies = {}

for d in data:
    component_name = d[0]
    pdb_file = d[1]
    chain_id = d[2]
    color_id = d[3]
    fasta_file = d[4][0]
    fasta_file_id = d[4][1]
    # avoid to add a component with the same name
    def test_loop_reconstruction(self):
        """Test loop reconstruction"""

        # input parameter
        pdbfile = self.get_input_file_name(
            "loop_reconstruction/starting.structure.pdb")
        fastafile = self.get_input_file_name(
            "loop_reconstruction/sequence.fasta")
        sequences = IMP.pmi.topology.Sequences(fastafile)

        # create the representation
        log_objects = []
        optimizable_objects = []

        sw = tools.Stopwatch()
        log_objects.append(sw)

        m = IMP.Model()
        s = IMP.pmi.topology.System(m)
        st = s.create_state()

        cA = st.create_molecule("chainA", sequence=sequences[0])
        atomic = cA.add_structure(pdbfile, chain_id='A')
        cA.add_representation(atomic, resolutions=[1, 10], color=0.)
        cA.add_representation(cA.get_non_atomic_residues(),
                              resolutions=[1],
                              color=0.)

        cB = st.create_molecule("chainB", sequence=sequences[0])
        atomic = cB.add_structure(pdbfile, chain_id='B')
        cB.add_representation(atomic, resolutions=[1, 10], color=0.5)
        cB.add_representation(cB.get_non_atomic_residues(),
                              resolutions=[1],
                              color=0.)
        root_hier = s.build()

        dof = IMP.pmi.dof.DegreesOfFreedom(m)
        dof.create_rigid_body(cA)
        dof.create_rigid_body(cB)

        cr = IMP.pmi.restraints.stereochemistry.ConnectivityRestraint(
            root_hier)
        cr.add_to_model()
        log_objects.append(cr)

        listofexcludedpairs = []

        lof = [
            cA[:12], cB[:12], cA[293:339], cB[293:339], cA[685:701],
            cB[685:701], cA[453:464], cB[453:464], cA[471:486], cB[471:486],
            cA[813:859], cB[813:859]
        ]

        # add bonds and angles
        for l in lof:

            print(l)
            rbr = IMP.pmi.restraints.stereochemistry.ResidueBondRestraint(
                objects=l)
            rbr.add_to_model()
            listofexcludedpairs += rbr.get_excluded_pairs()
            log_objects.append(rbr)

            rar = IMP.pmi.restraints.stereochemistry.ResidueAngleRestraint(
                objects=l)
            rar.add_to_model()
            listofexcludedpairs += rar.get_excluded_pairs()
            log_objects.append(rar)

        # add excluded volume

        ev = IMP.pmi.restraints.stereochemistry.ExcludedVolumeSphere(
            included_objects=root_hier, resolution=10.0)
        ev.add_excluded_particle_pairs(listofexcludedpairs)
        ev.add_to_model()
        log_objects.append(ev)

        mc = samplers.MonteCarlo(m, dof.get_movers(), 1.0)
        log_objects.append(mc)

        o = output.Output()

        print("Starting test")
        o.write_test("test.current.dict", log_objects)
        o.test(
            self.get_input_file_name(
                "loop_reconstruction/test.IMP-ee1763c6.PMI-4669cfca.dict"),
            log_objects)
        os.unlink('test.current.dict')