Beispiel #1
0
 def setUp(self):
     self.ramp = restraints.ConstantRamp()
Beispiel #2
0
 def setUp(self):
     p = SubSystemFromSequence("GLY GLY GLY GLY")
     b = SystemBuilder()
     self.system = b.build_system([p])
     self.scaler = restraints.ConstantScaler()
     self.ramp = restraints.ConstantRamp()
Beispiel #3
0
def get_rdc_restraints(
    system: interfaces.ISystem,
    patcher: patchers.RdcAlignmentPatcher,
    scaler: restraints.RestraintScaler,
    ramp: Optional[restraints.TimeRamp] = None,
    quadratic_cut: Optional[u.Quantity] = None,
    scale_factor: float = 1.0e4,
    filename: Optional[str] = None,
    content: Optional[str] = None,
    file: Optional[TextIO] = None,
) -> List[restraints.RdcRestraint]:
    """
    Reads restraints from file and returns as RdcRestraint object.

    Args:
        system: the system object for the restraints to be added to.
        patcher: the patcher that was used to add alignment tensor dummy atoms
        scaler: object to scale the force constant.
        ramp: ramp, default is ConstantRamp()
        quadratic_cut: restraints become linear beyond this deviation, default 999 Hz
        scale_factor: scale factor for kappa and alignment tensor
        filename : filename to open
        content : contents to process
        file : object to read from

    Returns:
        list of restraints from input

    .. note::
       The value of `kappa` will be scaled down by `scale_factor`. This will
       result in the alignment tensor being scaled up by `scale_factor`.
       Ideally, the largest values of the scaled alignment tensor should be
       approximately 1. As typical values of the alignment are on the order
       of 1e-4, the default value of 1e4 is a reasonable guess. The value
       of `scale_factor` must be the same for all experiments that share the
       same alignment.

    .. note::
        The value of kappa is assumed to be in units of Hz A^3.
    """

    quadratic_cut = 999.0 / u.seconds if quadratic_cut is None else quadratic_cut

    if ramp is None:
        ramp = restraints.ConstantRamp()

    contents = _handle_arguments(filename, content, file)
    lines = contents.splitlines()
    lines = [line.strip() for line in lines if not line.startswith("#")]

    restraint_list = []
    for line in lines:
        cols = line.split()
        res_i = int(cols[0])
        atom_i = cols[1]
        res_j = int(cols[2])
        atom_j = cols[3]
        obs = float(cols[4])
        expt = int(cols[5])
        tolerance = float(cols[6])
        kappa = float(cols[7]) / scale_factor
        force_const = float(cols[8])
        weight = float(cols[9])

        atom_index_i = system.index.atom(res_i, atom_i, one_based=True)
        atom_index_j = system.index.atom(res_j, atom_j, one_based=True)

        rest = restraints.RdcRestraint(
            system,
            scaler,
            ramp,
            atom_index_i,
            atom_index_j,
            kappa * u.second**-1 * u.angstrom**3,
            obs * u.second**-1,
            tolerance * u.second**-1,
            force_const * u.kilojoule_per_mole * u.second**2,
            quadratic_cut,
            weight,
            expt,
            patcher,
        )
        restraint_list.append(rest)
    return restraint_list
Beispiel #4
0
def get_secondary_structure_restraints(
    system: interfaces.ISystem,
    scaler: restraints.RestraintScaler,
    ramp: Optional[restraints.TimeRamp] = None,
    torsion_force_constant: Optional[u.Quantity] = None,
    distance_force_constant: Optional[u.Quantity] = None,
    quadratic_cut: Optional[u.Quantity] = None,
    first_residue: Optional[indexing.ResidueIndex] = None,
    min_secondary_match: int = 4,
    filename: Optional[str] = None,
    content: Optional[str] = None,
    file: Optional[TextIO] = None,
) -> List[restraints.RestraintGroup]:
    """
    Get a list of secondary structure restraints.

    Args:
        system: the system
        scaler: the force scaler
        ramp: the ramp, default is ConstantRamp
        torsion_force_constant: force constant for torsions, default 2.5e-2 kJ/mol/deg^2
        distance_force_constant: force constant for distances, default 2.5 kJ/mol/nm^2
        quadratic_cut: switch from quadratic to linear beyond this distance, default 0.2 nm
        min_secondary_match: minimum number of elements to match in secondary structure
        first_residue: residue at which these secondary structure restraints start
        filename: filename to open
        content: contents to process
        file: object to read from

    Returns
        A list of :class:`RestraintGroups`

    .. note::
       Specify exactly one of filename, contents, file.
    """

    torsion_force_constant = (2.5e-2 * u.kilojoule_per_mole /
                              u.degree**2 if torsion_force_constant is None
                              else torsion_force_constant)
    distance_force_constant = (2500 * u.kilojoule_per_mole / u.nanometer**2
                               if distance_force_constant is None else
                               distance_force_constant)
    quadratic_cut = 0.2 * u.nanometer if quadratic_cut is None else quadratic_cut

    if ramp is None:
        ramp = restraints.ConstantRamp()

    if first_residue is None:
        first_residue = indexing.ResidueIndex(0)
    else:
        assert isinstance(first_residue, indexing.ResidueIndex)

    if min_secondary_match > 5:
        raise RuntimeError(
            "Minimum number of elements to match in secondary structure "
            "must be less than or equal to 5.")
    min_secondary_match = int(min_secondary_match)

    contents = _get_secondary_sequence(filename, content, file)

    groups = []

    helices = _extract_secondary_runs(contents, "H", 5, min_secondary_match,
                                      first_residue)
    for helix in helices:
        rests: List[restraints.SelectableRestraint] = []
        for index in range(helix.start + 1, helix.end - 1):
            phi = restraints.TorsionRestraint(
                system,
                scaler,
                ramp,
                system.index.atom(index - 1, "C"),
                system.index.atom(index, "N"),
                system.index.atom(index, "CA"),
                system.index.atom(index, "C"),
                -62.5 * u.degree,
                17.5 * u.degree,
                torsion_force_constant,
            )
            psi = restraints.TorsionRestraint(
                system,
                scaler,
                ramp,
                system.index.atom(index, "N"),
                system.index.atom(index, "CA"),
                system.index.atom(index, "C"),
                system.index.atom(index + 1, "N"),
                -42.5 * u.degree,
                17.5 * u.degree,
                torsion_force_constant,
            )
            rests.append(phi)
            rests.append(psi)
        d1 = restraints.DistanceRestraint(
            system,
            scaler,
            ramp,
            system.index.atom(helix.start, "CA"),
            system.index.atom(helix.start + 3, "CA"),
            0 * u.nanometer,
            0.485 * u.nanometer,
            0.561 * u.nanometer,
            0.561 * u.nanometer + quadratic_cut,
            distance_force_constant,
        )
        d2 = restraints.DistanceRestraint(
            system,
            scaler,
            ramp,
            system.index.atom(helix.start + 1, "CA"),
            system.index.atom(helix.start + 4, "CA"),
            0 * u.nanometer,
            0.485 * u.nanometer,
            0.561 * u.nanometer,
            0.561 * u.nanometer + quadratic_cut,
            distance_force_constant,
        )
        d3 = restraints.DistanceRestraint(
            system,
            scaler,
            ramp,
            system.index.atom(helix.start, "CA"),
            system.index.atom(helix.start + 4, "CA"),
            0 * u.nanometer,
            0.581 * u.nanometer,
            0.684 * u.nanometer,
            0.684 * u.nanometer + quadratic_cut,
            distance_force_constant,
        )
        rests.append(d1)
        rests.append(d2)
        rests.append(d3)
        group = restraints.RestraintGroup(rests, len(rests))
        groups.append(group)

    extended = _extract_secondary_runs(contents, "E", 5, min_secondary_match,
                                       first_residue)
    for ext in extended:
        rests = []
        for index in range(ext.start + 1, ext.end - 1):
            phi = restraints.TorsionRestraint(
                system,
                scaler,
                ramp,
                system.index.atom(index - 1, "C"),
                system.index.atom(index, "N"),
                system.index.atom(index, "CA"),
                system.index.atom(index, "C"),
                -117.5 * u.degree,
                27.5 * u.degree,
                torsion_force_constant,
            )
            psi = restraints.TorsionRestraint(
                system,
                scaler,
                ramp,
                system.index.atom(index, "N"),
                system.index.atom(index, "CA"),
                system.index.atom(index, "C"),
                system.index.atom(index + 1, "N"),
                145 * u.degree,
                25.0 * u.degree,
                torsion_force_constant,
            )
            rests.append(phi)
            rests.append(psi)
        d1 = restraints.DistanceRestraint(
            system,
            scaler,
            ramp,
            system.index.atom(ext.start, "CA"),
            system.index.atom(ext.start + 3, "CA"),
            0 * u.nanometer,
            0.785 * u.nanometer,
            1.063 * u.nanometer,
            1.063 * u.nanometer + quadratic_cut,
            distance_force_constant,
        )
        d2 = restraints.DistanceRestraint(
            system,
            scaler,
            ramp,
            system.index.atom(ext.start + 1, "CA"),
            system.index.atom(ext.start + 4, "CA"),
            0 * u.nanometer,
            0.785 * u.nanometer,
            1.063 * u.nanometer,
            1.063 * u.nanometer + quadratic_cut,
            distance_force_constant,
        )
        d3 = restraints.DistanceRestraint(
            system,
            scaler,
            ramp,
            system.index.atom(ext.start, "CA"),
            system.index.atom(ext.start + 4, "CA"),
            0 * u.nanometer,
            1.086 * u.nanometer,
            1.394 * u.nanometer,
            1.394 * u.nanometer + quadratic_cut,
            distance_force_constant,
        )
        rests.append(d1)
        rests.append(d2)
        rests.append(d3)
        group = restraints.RestraintGroup(rests, len(rests))
        groups.append(group)

    return groups
Beispiel #5
0
 def setUp(self):
     self.mock_system = mock.Mock()
     self.scaler = restraints.ConstantScaler()
     self.ramp = restraints.ConstantRamp()
Beispiel #6
0
 def setUp(self):
     p = system.ProteinMoleculeFromSequence("GLY GLY GLY GLY")
     b = system.SystemBuilder()
     self.system = b.build_system_from_molecules([p])
     self.scaler = restraints.ConstantScaler()
     self.ramp = restraints.ConstantRamp()