Ejemplo n.º 1
0
    def test_distance_filter(self):
        """Test filtering distances with domino """
        IMP.base.set_log_level(IMP.base.VERBOSE)
        m = IMP.kernel.Model()
        particles = [IMP.kernel.Particle(m) for i in range(0, 3)]
        for i, p in enumerate(particles):
            p.set_name("pparticle_%d" % i)

        xyzs = [core.XYZ.setup_particle(p) for p in particles]
        positions = [alg.Vector3D(x * 1.0, 0., 0.) for x in range(0, 100, 10)]

        states = domino.XYZStates(positions)
        states_table = domino.ParticleStatesTable()
        for p in particles:
            states_table.set_particle_states(p, states)
            print p
        # Restraints
        sf = IMP.core.Harmonic(10.0, 1.0)
        r1 = IMP.core.DistanceRestraint(sf, particles[0], particles[1])
        m.add_restraint(r1)
        r3 = IMP.core.DistanceRestraint(sf, particles[1], particles[2])
        m.add_restraint(r3)
        ig = domino.get_interaction_graph(m.get_restraints(), states_table)
        # generate a junction tree from the interaction graph
        jt = domino.get_junction_tree(ig)
        # print jt.show_graphviz()

        # Filters
        maximum_distance = 21
        ftable2 = em2d.DistanceFilterTable(
            IMP.domino.Subset([particles[0], particles[1]]), states_table,
            maximum_distance)
        ftable2.set_name("my filtertable2")
        ftable3 = em2d.DistanceFilterTable(
            IMP.domino.Subset([particles[1], particles[2]]), states_table,
            maximum_distance)
        ftable3.set_name("my filtertable3")
        ftable1 = domino.ExclusionSubsetFilterTable(states_table)
        ftable1.set_name("my filtertable1")

        filter_tables = [ftable2, ftable3, ftable1]

        assignments_table = \
            domino.BranchAndBoundAssignmentsTable(states_table, filter_tables)

        sampler = domino.DominoSampler(m, states_table)
        sampler.set_assignments_table(assignments_table)
        sampler.set_subset_filter_tables(filter_tables)

        configuration_set = sampler.create_sample()
        n = configuration_set.get_number_of_configurations()
        print "number of possible_configurations", n
        for i in range(n):
            configuration_set.load_configuration(i)
            # Check that the distance between the particles is correct
            self.assertLess(core.get_distance(xyzs[0], xyzs[1]),
                            maximum_distance)
            self.assertLess(core.get_distance(xyzs[1], xyzs[2]),
                            maximum_distance)
Ejemplo n.º 2
0
    def test_distance_filter(self):
        """Test filtering distances with domino """
        IMP.base.set_log_level(IMP.base.VERBOSE)
        m = IMP.kernel.Model()
        particles = [IMP.kernel.Particle(m) for i in range(0,3)]
        for i, p in enumerate(particles):
            p.set_name("pparticle_%d" % i)


        xyzs = [core.XYZ.setup_particle(p) for p in particles]
        positions = [alg.Vector3D(x*1.0,0.,0.) for x in range(0,100,10)]

        states = domino.XYZStates(positions)
        states_table = domino.ParticleStatesTable()
        for p in particles:
            states_table.set_particle_states(p, states)
            print p
        # Restraints
        sf = IMP.core.Harmonic(10.0, 1.0)
        r1=IMP.core.DistanceRestraint(sf, particles[0],particles[1])
        m.add_restraint(r1)
        r3=IMP.core.DistanceRestraint(sf, particles[1],particles[2])
        m.add_restraint(r3)
        ig = domino.get_interaction_graph( m.get_restraints(), states_table)
        # generate a junction tree from the interaction graph
        jt= domino.get_junction_tree(ig)
        # print jt.show_graphviz()

        # Filters
        maximum_distance = 21
        ftable2 = em2d.DistanceFilterTable(IMP.domino.Subset([particles[0], particles[1]]),
                                            states_table, maximum_distance)
        ftable2.set_name("my filtertable2")
        ftable3 = em2d.DistanceFilterTable(IMP.domino.Subset([particles[1], particles[2]]),
                                            states_table, maximum_distance)
        ftable3.set_name("my filtertable3")
        ftable1 = domino.ExclusionSubsetFilterTable(states_table)
        ftable1.set_name("my filtertable1")

        filter_tables = [ ftable2, ftable3, ftable1]

        assignments_table = \
            domino.BranchAndBoundAssignmentsTable(states_table, filter_tables)

        sampler = domino.DominoSampler(m, states_table)
        sampler.set_assignments_table(assignments_table)
        sampler.set_subset_filter_tables(filter_tables)

        configuration_set = sampler.get_sample()
        n = configuration_set.get_number_of_configurations()
        print "number of possible_configurations",n
        for i in range(n):
            configuration_set.load_configuration(i)
            # Check that the distance between the particles is correct
            self.assertLess(core.get_distance( xyzs[0], xyzs[1] ), maximum_distance)
            self.assertLess(core.get_distance( xyzs[1], xyzs[2] ), maximum_distance)
Ejemplo n.º 3
0
 def create_merge_tree(self):
     """
         Creates a merge tree from the restraints that are set already
     """
     rs = self.model.get_restraints()
     ig = domino.get_interaction_graph(rs, self.rb_states_table)
     jt = domino.get_junction_tree(ig)
     self.merge_tree = domino.get_balanced_merge_tree(jt)
     log.info("Balanced merge tree created")
     log.info("%s",self.merge_tree.show_graphviz() )
Ejemplo n.º 4
0
    def create_merge_tree(self):
        """
            Creates a merge tree from the restraints that are set already
        """
        rs = self.restraints.values()
        ig = domino.get_interaction_graph(rs, self.rb_states_table)
#        pruned_dep = IMP.get_pruned_dependency_graph(self.model)
#        IMP.show_graphviz(pruned_dep)
#        IMP.show_graphviz(ig)
        jt = domino.get_junction_tree(ig)
#        IMP.show_graphviz(jt)
        self.merge_tree = domino.get_balanced_merge_tree(jt)
#        IMP.show_graphviz(self.merge_tree)
        log.info("Balanced merge tree created")
        log.info("%s", self.merge_tree.show_graphviz())
Ejemplo n.º 5
0
    def create_merge_tree(self):
        """
            Creates a merge tree from the restraints that are set already
        """
        rs = self.restraints.values()
        ig = domino.get_interaction_graph(rs, self.rb_states_table)
#        pruned_dep = IMP.get_pruned_dependency_graph(self.model)
#        IMP.show_graphviz(pruned_dep)
#        IMP.show_graphviz(ig)
        jt = domino.get_junction_tree(ig)
#        IMP.show_graphviz(jt)
        self.merge_tree = domino.get_balanced_merge_tree(jt)
#        IMP.show_graphviz(self.merge_tree)
        log.info("Balanced merge tree created")
        log.info("%s", self.merge_tree.show_graphviz())