Пример #1
0
 def do_clustering(self, confs_RFs, max_rmsd):
     """
         Cluster configurations for a model based on RMSD.
         An IMP.ConfigurationSet is built using the reference frames for
         of the components of the assembly for each solution
         @param confs_RFs A lsit containing a tuples of reference frames.
             Each tuple contains the reference frame for the rigid body
             of one component of the assembly
         @param max_rmsd Maximum RMSD tolerated when clustering
     """
     model = IMP.Model()
     assembly = representation.create_assembly(model, self.exp.fn_pdbs)
     rbs = representation.create_rigid_bodies(assembly)
     configuration_set = IMP.ConfigurationSet(model)
     for RFs in confs_RFs:
         representation.set_reference_frames(rbs, RFs)
         configuration_set.save_configuration()
     particles_container = container.ListSingletonContainer(model)
     particles_container.add_particles(atom.get_leaves(assembly))
     metric = stats.ConfigurationSetRMSDMetric(
                             configuration_set,particles_container, True)
     log.info("Clustering ... ")
     maximum_centrality = 10
     self.pclus = stats.create_centrality_clustering( metric, max_rmsd,
                                             maximum_centrality)
     n = self.pclus.get_number_of_clusters()
     log.info("Number of clusters found: %s", n)
Пример #2
0
    def get_restraints_for_native(self, restraints_names):
        """
            Get values of the restraints for the native structure
            @param restraints_names Names of the restraints requested
            @return a list with the values of all scores, and the total score
        """
        saved = [rb.get_reference_frame() for rb in self.components_rbs]
        # Set the state of the model to native
        for rb,rn  in zip(self.components_rbs, self.native_rbs):
            # remove sub-rigid bodies
            rb_members = filter(
                           lambda m: not core.RigidBody.get_is_setup(
                                     m.get_particle()), rb.get_members())
            rn_members =  filter(
                           lambda m: not core.RigidBody.get_is_setup(
                                     m.get_particle()), rn.get_members())
            rb_coords = [m.get_coordinates() for m in rb_members]
            rn_coords = [m.get_coordinates() for m in rn_members]

            # align and put rb in the position of rn
            if len(rn_coords) != len(rb_coords) :
                raise ValueError("Mismatch in the number of members. "
                "Reference %d Aligned %d " % (len(rn_coords), len(rb_coords)))
            T = alg.get_transformation_aligning_first_to_second(rb_coords,
                                                                rn_coords)
            t = rb.get_reference_frame().get_transformation_to()
            new_t =  alg.compose(T, t)
            rb.set_reference_frame(alg.ReferenceFrame3D(new_t))
        scores = []
        for name in restraints_names:
            scores.append( self.restraints[name].evaluate(False))
        total_score = sum(scores)
        representation.set_reference_frames(self.components_rbs, saved)
        return scores, total_score
Пример #3
0
 def write_pdb_for_reference_frames(self,RFs, fn_pdb):
     """
         Write a PDB file with a solution given by a set of reference frames
         @param RFs Reference frames for the elements of the complex
         @param fn_pdb File to write the solution
     """
     log.debug("Writting PDB %s for reference frames %s",fn_pdb, RFs)
     representation.set_reference_frames(self.components_rbs,RFs)
     atom.write_pdb(self.assembly, fn_pdb)
Пример #4
0
 def write_pdbs_for_reference_frames(self,RFs, fn_base):
     """
         Write a separate PDB for each of the elements
         @param RFs Reference frames for the elements of the complex
         @param fn_base base string to buid the names of the PDBs files
     """
     log.debug("Writting PDBs with basename %s",fn_base)
     representation.set_reference_frames(self.components_rbs,RFs)
     for i,ch in enumerate(self.assembly.get_children()):
         atom.write_pdb(ch, fn_base + "component-%02d.pdb" % i )
Пример #5
0
def align_and_get_placement_scores(reference_rbs, rbs):
    """
        reference_rbs - Reference rigid bodies.
        The rigid bodies are aligned using their centroids.
        NOTE: The function changes but restores the reference frames of rbs.
                 The rigid bodies refs_rbs of the reference are not changed.
    """
    saved_refs = [rb.get_reference_frame() for rb in rbs]
    best_rmsd, new_refs = \
        alignments.get_reference_frames_aligning_rbs(rbs, reference_rbs)
    representation.set_reference_frames(rbs, new_refs)
    distances, angles = get_placement_scores(reference_rbs, rbs)
    representation.set_reference_frames(rbs, saved_refs)
    return distances, angles