Beispiel #1
0
 def set_complementarity_restraint(self, name1, name2, rname,
                                   max_sep_distance, max_penetration,
                                   weight, max_score=1e10):
     """
         Set a restraint for geometric complementarity between 2 components
         @param name1 name of
         @param name2 - The restraint is applied to this components
         @param rname - The name given to the restraint
         @param max_sep_distance - maximum distance between molecules
                             tolerated by the restraint
         @param max_penetration - Maximum penetration allowed (angstrom)
         @param weight
         @param max_score
     """
     log.info("Setting geometric complementarity restraint %s: %s - %s",
              rname, name1, name2)
     A = representation.get_component(self.assembly, name1)
     B = representation.get_component(self.assembly, name2)
     restraint = multifit.ComplementarityRestraint(atom.get_leaves(A),
                                                   atom.get_leaves(B), rname)
     restraint.set_maximum_separation(max_sep_distance)
     restraint.set_maximum_penetration(max_penetration)
     log.debug("Maximum separation: %s Maximum penetration score: %s",
               max_sep_distance, max_penetration)
     self.add_restraint(restraint, rname, weight, max_score)
Beispiel #2
0
 def set_complementarity_restraint(self, name1, name2, rname,
                                   max_sep_distance, max_penetration,
                                   weight, max_score=1e10):
     """
         Set a restraint for geometric complementarity between 2 components
         @param name1 name of
         @param name2 - The restraint is applied to this components
         @param rname - The name given to the restraint
         @param max_sep_distance - maximum distance between molecules
                             tolerated by the restraint
         @param max_penetration - Maximum penetration allowed (angstrom)
         @param weight
         @param max_score
     """
     log.info("Setting geometric complementarity restraint %s: %s - %s",
              rname, name1, name2)
     A = representation.get_component(self.assembly, name1)
     B = representation.get_component(self.assembly, name2)
     restraint = multifit.ComplementarityRestraint(atom.get_leaves(A),
                                                   atom.get_leaves(B), rname)
     restraint.set_maximum_separation(max_sep_distance)
     restraint.set_maximum_penetration(max_penetration)
     log.debug("Maximum separation: %s Maximum penetration score: %s",
               max_sep_distance, max_penetration)
     self.add_restraint(restraint, rname, weight, max_score)
Beispiel #3
0
    def set_pair_score_restraint(
        self, name1, name2, restraint_name, distance=10, weight=1.0, n_pairs=1, stddev=2, max_score=None
    ):
        """
            Set a pair_score restraint between the coarse representation
            of two components
            @param name1 Name of the first component
            @param name2 Name of the second component
            @param restraint_name Name for the restraint
            @param distance Maximum distance tolerated between particles
            @param weight Weight of the restraint
            @param n_pairs
            @param max_score Maximum value tolerated for the restraint
            @param stddev Standard deviation used to approximate the
                HarmonicUpperBound function to a Gaussian
        """
        table_refiner = core.TableRefiner()

        # The particles in A are attached to a marker particle via a refiner.
        # When the refiner gets a request for marker1, it returns the attached
        # particles
        A = representation.get_component(self.coarse_assembly, name1)
        marker1 = IMP.Particle(self.model, "marker1 " + restraint_name)
        table_refiner.add_particle(marker1, atom.get_leaves(A))
        # same for B
        B = representation.get_component(self.coarse_assembly, name2)
        marker2 = IMP.Particle(self.model, "marker2 " + restraint_name)
        table_refiner.add_particle(marker2, atom.get_leaves(B))

        k = core.Harmonic.get_k_from_standard_deviation(stddev)
        score = core.HarmonicUpperBoundSphereDistancePairScore(distance, k)
        # The score is set for the n_pairs closest pairs of particles
        pair_score = core.KClosePairsPairScore(score, table_refiner, n_pairs)
        #  When KClosePairsPairScore is called, the refiner will provide the
        # particles for A and B
        if not max_score:
            # Build a maximum score based on the function type that is used,
            # an HarmonicUpperBound
            temp_score = core.HarmonicUpperBound(distance, k)
            error_distance_allowed = 10
            max_score = weight * n_pairs * temp_score.evaluate(distance + error_distance_allowed)

        log.info(
            "Setting pair score restraint for %s %s. k = %s, max_score " "= %s, stddev %s",
            name1,
            name2,
            k,
            max_score,
            stddev,
        )
        r = core.PairRestraint(pair_score, IMP.ParticlePair(marker1, marker2))
        self.add_restraint(r, restraint_name, weight, max_score)
Beispiel #4
0
 def set_xlink_restraint(self, id1, chain1, residue1, id2, chain2, residue2,
                         distance, weight, stddev, max_score=False):
     """
         Set a restraint on the maximum distance between 2 residues
         @param id1 Name of the first component
         @param chain1
         @param residue1 Residue number for the aminoacid in the first
             component.The number is the number in the PDB file, not the
             number relative to the beginning of the chain
         @param id2 Name of the second component
         @param chain2
         @param residue2 Residue number for the aminoacid in the second
           component.
         @param distance Maximum distance tolerated
         @param weight Weight of the restraint
         @param stddev Standard deviation used to approximate the
             HarmonicUpperBound function to a Gaussian
         @param max_score See help for add_restraint(). If none is given,
         the maximum score is set to allow a maximum distance of 10 Angstrom
         greater than the parameter "distance".
     """
     xlink = buildxlinks.Xlink(
         id1,
         chain1,
         residue1,
         id2,
         chain2,
         residue2,
         distance)
     log.info("Setting cross-linking restraint ")
     log.info("%s", xlink.show())
     self.xlinks_dict.add(xlink)
     # setup restraint
     A = representation.get_component(self.assembly, xlink.first_id)
     s1 = IMP.atom.Selection(A, chain=xlink.first_chain,
                             residue_index=xlink.first_residue)
     p1 = s1.get_selected_particles()[0]
     B = representation.get_component(self.assembly, xlink.second_id)
     s2 = IMP.atom.Selection(B, chain=xlink.second_chain,
                             residue_index=xlink.second_residue)
     p2 = s2.get_selected_particles()[0]
     k = core.Harmonic.get_k_from_standard_deviation(stddev)
     score = core.HarmonicUpperBound(xlink.distance, k)
     pair_score = IMP.core.DistancePairScore(score)
     r = IMP.core.PairRestraint(self.model, pair_score, (p1, p2))
     if not max_score:
         error_distance_allowed = 100
         max_score = weight * \
             score.evaluate(distance + error_distance_allowed)
     log.info("%s, max_score %s", xlink.show(), max_score)
     self.add_restraint(r, xlink.get_name(), weight, max_score)
Beispiel #5
0
    def set_pair_score_restraint(self, name1, name2,
                                 restraint_name, distance=10,
                                 weight=1.0, n_pairs=1, stddev=2, max_score=None):
        """
            Set a pair_score restraint between the coarse representation
            of two components
            @param name1 Name of the first component
            @param name2 Name of the second component
            @param restraint_name Name for the restraint
            @param distance Maximum distance tolerated between particles
            @param weight Weight of the restraint
            @param n_pairs
            @param max_score Maximum value tolerated for the restraint
            @param stddev Standard deviation used to approximate the
                HarmonicUpperBound function to a Gaussian
        """
        table_refiner = core.TableRefiner()

        # The particles in A are attached to a marker particle via a refiner.
        # When the refiner gets a request for marker1, it returns the attached
        # particles
        A = representation.get_component(self.coarse_assembly, name1)
        marker1 = IMP.Particle(self.model, "marker1 " + restraint_name)
        table_refiner.add_particle(marker1, atom.get_leaves(A))
        # same for B
        B = representation.get_component(self.coarse_assembly, name2)
        marker2 = IMP.Particle(self.model, "marker2 " + restraint_name)
        table_refiner.add_particle(marker2, atom.get_leaves(B))

        k = core.Harmonic.get_k_from_standard_deviation(stddev)
        score = core.HarmonicUpperBoundSphereDistancePairScore(distance, k)
        # The score is set for the n_pairs closest pairs of particles
        pair_score = core.KClosePairsPairScore(score, table_refiner, n_pairs)
        #  When KClosePairsPairScore is called, the refiner will provide the
        # particles for A and B
        if not max_score:
            # Build a maximum score based on the function type that is used,
            # an HarmonicUpperBound
            temp_score = core.HarmonicUpperBound(distance, k)
            error_distance_allowed = 10
            max_score = weight * n_pairs * \
                temp_score.evaluate(distance + error_distance_allowed)

        log.info("Setting pair score restraint for %s %s. k = %s, max_score "
                 "= %s, stddev %s", name1, name2, k, max_score, stddev)
        r = core.PairRestraint(
            pair_score,
            IMP.ParticlePair(
                marker1,
                marker2))
        self.add_restraint(r, restraint_name, weight, max_score)
Beispiel #6
0
 def set_xlink_restraint(self, id1, chain1, residue1, id2, chain2, residue2,
                         distance, weight, stddev, max_score=False):
     """
         Set a restraint on the maximum distance between 2 residues
         @param id1 Name of the first component
         @param chain1
         @param residue1 Residue number for the aminoacid in the first
             component.The number is the number in the PDB file, not the
             number relative to the beginning of the chain
         @param id2 Name of the second component
         @param chain2
         @param residue2 Residue number for the aminoacid in the second
           component.
         @param distance Maximum distance tolerated
         @param weight Weight of the restraint
         @param stddev Standard deviation used to approximate the
             HarmonicUpperBound function to a Gaussian
         @param max_score See help for add_restraint(). If none is given,
         the maximum score is set to allow a maximum distance of 10 Angstrom
         greater than the parameter "distance".
     """
     xlink = buildxlinks.Xlink(
         id1,
         chain1,
         residue1,
         id2,
         chain2,
         residue2,
         distance)
     log.info("Setting cross-linking restraint ")
     log.info("%s", xlink.show())
     self.xlinks_dict.add(xlink)
     # setup restraint
     A = representation.get_component(self.assembly, xlink.first_id)
     s1 = IMP.atom.Selection(A, chain=xlink.first_chain,
                             residue_index=xlink.first_residue)
     p1 = s1.get_selected_particles()[0]
     B = representation.get_component(self.assembly, xlink.second_id)
     s2 = IMP.atom.Selection(B, chain=xlink.second_chain,
                             residue_index=xlink.second_residue)
     p2 = s2.get_selected_particles()[0]
     k = core.Harmonic.get_k_from_standard_deviation(stddev)
     score = core.HarmonicUpperBound(xlink.distance, k)
     pair_score = IMP.core.DistancePairScore(score)
     r = IMP.core.PairRestraint(pair_score, IMP.ParticlePair(p1, p2))
     if not max_score:
         error_distance_allowed = 100
         max_score = weight * \
             score.evaluate(distance + error_distance_allowed)
     log.info("%s, max_score %s", xlink.show(), max_score)
     self.add_restraint(r, xlink.get_name(), weight, max_score)
Beispiel #7
0
 def set_connectivity_restraint(self, names, rname,
                                distance=10,
                                weight=1.0, max_score=None, n_pairs=1,
                                stddev=2):
     """
         Set a connectivity restraint between the elements of the assembly
         @param names List with all the elements to be connected
         @param distance  Maximum distance tolerated by the restraint
         @param rname Name for the restraint
         @param weight Weight for the restraint
         @param max_score Maximum score for the restraint
         @param n_pairs Number of pairs of particles used in the
                     KClosePairScore of the connectivity restraint
         @param stddev Standard deviation used to approximate the
                             HarmonicUpperBound function to a Gaussian
     """
     components = []
     for name in names:
         c = representation.get_component(self.coarse_assembly, name)
         components.append(c)
     log.info("Connectivity restraint for %s", components)
     spring_constant = core.Harmonic.get_k_from_standard_deviation(stddev)
     if max_score is None:
         max_score = weight * spring_constant * n_pairs * (stddev) ** 2
     r = restraints.get_connectivity_restraint(
         components, distance, n_pairs,
         spring_constant)
     self.add_restraint(r, rname, weight, max_score)
Beispiel #8
0
 def set_connectivity_restraint(self, names, rname,
                                distance=10,
                                weight=1.0, max_score=None, n_pairs=1,
                                stddev=2):
     """
         Set a connectivity restraint between the elements of the assembly
         @param names List with all the elements to be connected
         @param distance  Maximum distance tolerated by the restraint
         @param rname Name for the restraint
         @param weight Weight for the restraint
         @param max_score Maximum score for the restraint
         @param n_pairs Number of pairs of particles used in the
                     KClosePairScore of the connectivity restraint
         @param stddev Standard deviation used to approximate the
                             HarmonicUpperBound function to a Gaussian
     """
     components = []
     for name in names:
         c = representation.get_component(self.coarse_assembly, name)
         components.append(c)
     log.info("Connectivity restraint for %s", components)
     spring_constant = core.Harmonic.get_k_from_standard_deviation(stddev)
     if max_score is None:
         max_score = weight * spring_constant * n_pairs * (stddev) ** 2
     r = restraints.get_connectivity_restraint(
         components, distance, n_pairs,
         spring_constant)
     self.add_restraint(r, rname, weight, max_score)