1 """@namespace IMP.pmi.restraints.stereochemistry
2 Restraints for keeping correct stereochemistry.
5 from __future__
import print_function
14 from operator
import itemgetter
15 from math
import pi,log,sqrt
21 """ This class creates a restraint between consecutive TempResidue objects OR an entire
22 PMI MOlecule object. """
27 disorderedlength=
False,
32 @param objects - a list of hierarchies, PMI TempResidues OR a single Molecule
33 @param scale Scale the maximal distance between the beads by this factor when disorderedlength is False.
34 The maximal distance is calculated as ((float(residuegap) + 1.0) * 3.6) * scale.
35 @param disorderedlength - This flag uses either disordered length
36 calculated for random coil peptides (True) or zero
37 surface-to-surface distance between beads (False)
38 as optimal distance for the sequence connectivity
40 @param upperharmonic - This flag uses either harmonic (False)
41 or upperharmonic (True) in the intra-pair
42 connectivity restraint.
43 @param resolution - The resolution to connect things at - only used if you pass PMI objects
44 @param label - A string to identify this restraint in the output/stat file
51 raise Exception(
"ConnectivityRestraint: only pass stuff from one Molecule, please")
55 self.m = list(hiers)[0].get_model()
71 SortedSegments.append((start, end, startres))
72 SortedSegments = sorted(SortedSegments, key=itemgetter(2))
75 self.particle_pairs=[]
76 for x
in range(len(SortedSegments) - 1):
78 last = SortedSegments[x][1]
79 first = SortedSegments[x + 1][0]
81 apply_restraint =
True
95 apply_restraint =
False
104 residuegap = firstresn - lastresn - 1
105 if disorderedlength
and (nreslast / 2 + nresfirst / 2 + residuegap) > 20.0:
108 optdist = sqrt(5 / 3) * 1.93 * \
109 (nreslast / 2 + nresfirst / 2 + residuegap) ** 0.6
117 optdist = (0.0 + (float(residuegap) + 1.0) * 3.6) * scale
124 pt0 = last.get_particle()
125 pt1 = first.get_particle()
126 self.particle_pairs.append((pt0,pt1))
129 print(
"Adding sequence connectivity restraint between", pt0.get_name(),
" and ", pt1.get_name(),
'of distance', optdist)
130 self.rs.add_restraint(r)
132 def set_label(self, label):
135 def get_weight(self):
138 def add_to_model(self):
141 def get_restraint(self):
144 def set_weight(self, weight):
146 self.rs.set_weight(weight)
148 def get_output(self):
150 score = self.weight * self.rs.unprotected_evaluate(
None)
151 output[
"_TotalScore"] = str(score)
152 output[
"ConnectivityRestraint_" + self.label] = str(score)
156 """ Returns number of connectivity restraints """
157 return len(self.rs.get_restraints())
160 """ Returns the list of connected particles pairs """
161 return self.particle_pairs
164 return self.weight * self.rs.unprotected_evaluate(
None)
167 """A class to create an excluded volume restraint for a set of particles at a given resolution.
168 Can be initialized as a bipartite restraint between two sets of particles.
169 # Potential additional function: Variable resolution for each PMI object. Perhaps passing selection_tuples
170 with (PMI_object, resolution)
175 included_objects=
None,
180 @param representation DEPRECATED - just pass objects
181 @param included_objects Can be one of the following inputs:
182 IMP Hierarchy, PMI System/State/Molecule/TempResidue, or a list/set of them
183 @param other_objects Initializes a bipartite restraint between included_objects and other_objects
184 Same format as included_objects
185 @param resolution The resolution particles at which to impose the restraint.
186 By default, the coarsest particles will be chosen.
187 If a number is chosen, for each particle, the closest
188 resolution will be used (see IMP.atom.Selection).
189 @param kappa Restraint strength
203 if other_objects
is not None:
212 if representation
is None:
213 if hierarchies
is None:
214 raise Exception(
"Must at least pass included objects")
215 self.mdl = hierarchies[0].get_model()
216 included_ps = [h.get_particle()
for h
in hierarchies]
218 other_ps = [h.get_particle()
for h
in other_hierarchies]
220 raise Exception(
"Must pass included_objects")
243 self.rs.add_restraint(evr)
245 def add_excluded_particle_pairs(self, excluded_particle_pairs):
247 inverted=[(p1,p0)
for p0,p1
in excluded_particle_pairs]
252 self.cpc.add_pair_filter(icpf)
254 def set_label(self, label):
257 def add_to_model(self):
260 def get_restraint(self):
263 def set_weight(self, weight):
265 self.rs.set_weight(weight)
267 def get_output(self):
269 score = self.weight * self.rs.unprotected_evaluate(
None)
270 output[
"_TotalScore"] = str(score)
271 output[
"ExcludedVolumeSphere_" + self.label] = str(score)
275 return self.weight * self.rs.unprotected_evaluate(
None)
278 """Enforce ideal Helix dihedrals and bonds for a selection at resolution 0"""
285 @param hierarchy the root node
286 @param selection_tuple (start, stop, molname, copynum=0)
289 self.mdl = hierarchy.get_model()
293 start = selection_tuple[0]
294 stop = selection_tuple[1]
295 mol = selection_tuple[2]
297 if len(selection_tuple)>3:
298 copy_index = selection_tuple[3]
301 residue_indexes=range(start,stop+1))
302 ps = sel.get_selected_particles(with_representation=
False)
306 self.rs.add_restraint(self.r)
307 print(
'Created helix %s.%i.%i-%i with %i dihedrals and %i bonds'%(
308 mol,copy_index,start,stop,
309 self.get_number_of_bonds(),self.get_number_of_dihedrals()))
310 def set_label(self, label):
313 def get_weight(self):
316 def add_to_model(self):
319 def get_restraint(self):
322 def set_weight(self, weight):
324 self.rs.set_weight(weight)
326 def get_number_of_bonds(self):
327 return self.r.get_number_of_bonds()
329 def get_number_of_dihedrals(self):
330 return self.r.get_number_of_dihedrals()
333 return self.weight * self.rs.unprotected_evaluate(
None)
335 def get_output(self):
337 score = self.evaluate()
338 output[
"_TotalScore"] = str(score)
339 output[
"HelixRestraint_" + self.label] = str(score)
343 """ Add bond restraint between pair of consecutive
344 residues/beads to enforce the stereochemistry.
348 selection_tuple=
None,
354 @param representation (PMI1)
355 @param selection_tuple Requested selection (PMI1)
356 @param objects (PMI2)
357 @param distance Resting distance for restraint
358 @param strength Bond constant
359 @param jitter Defines the +- added to the optimal distance in the harmonic well restraint
360 used to increase the tolerance
363 if representation
is not None and selection_tuple
is not None:
364 self.m = representation.prot.get_model()
365 particles = IMP.pmi.tools.select_by_tuple(
370 elif objects
is not None:
372 self.m = particles[0].get_model()
385 (distance - jitter, distance + jitter), strength)
390 raise ValueError(
"wrong length of pair")
393 raise TypeError(
"%s is not a residue" % p)
396 print(
"ResidueBondRestraint: adding a restraint between %s %s" % (pair[0].get_name(), pair[1].get_name()))
397 self.rs.add_restraint(
402 def set_label(self, label):
404 self.rs.set_name(label)
405 for r
in self.rs.get_restraints():
408 def add_to_model(self):
411 def get_restraint(self):
414 def set_weight(self, weight):
416 self.rs.set_weight(weight)
418 def get_excluded_pairs(self):
419 return self.pairslist
421 def get_output(self):
423 score = self.weight * self.rs.unprotected_evaluate(
None)
424 output[
"_TotalScore"] = str(score)
425 output[
"ResidueBondRestraint_" + self.label] = str(score)
430 """Add angular restraint between triplets of consecutive
431 residues/beads to enforce the stereochemistry.
435 selection_tuple=
None,
441 if representation
is not None and selection_tuple
is not None:
442 self.m = representation.prot.get_model()
443 particles = IMP.pmi.tools.select_by_tuple(
448 elif objects
is not None:
450 self.m = particles[0].get_model()
458 (pi * anglemin / 180.0,
459 pi * anglemax / 180.0),
465 raise ValueError(
"wrong length of triplet")
468 raise TypeError(
"%s is not a residue" % p)
471 print(
"ResidueAngleRestraint: adding a restraint between %s %s %s" % (triplet[0].get_name(), triplet[1].get_name(), triplet[2].get_name()))
472 self.rs.add_restraint(
480 def set_label(self, label):
482 self.rs.set_name(label)
483 for r
in self.rs.get_restraints():
486 def add_to_model(self):
489 def get_restraint(self):
492 def set_weight(self, weight):
494 self.rs.set_weight(weight)
496 def get_excluded_pairs(self):
497 return self.pairslist
499 def get_output(self):
501 score = self.weight * self.rs.unprotected_evaluate(
None)
502 output[
"_TotalScore"] = str(score)
503 output[
"ResidueAngleRestraint_" + self.label] = str(score)
508 """Add dihedral restraints between quadruplet of consecutive
509 residues/beads to enforce the stereochemistry.
510 Give as input a string of "C" and "T", meaning cys (0+-40) or trans (180+-40)
511 dihedral. The length of the string must be \#residue-3.
512 Without the string, the dihedral will be assumed trans.
517 selection_tuple=
None,
522 if representation
is not None and selection_tuple
is not None:
523 self.m = representation.prot.get_model()
524 particles = IMP.pmi.tools.select_by_tuple(
529 elif objects
is not None:
531 self.m = particles[0].get_model()
538 if stringsequence
is None:
539 stringsequence =
"T" * (len(particles) - 3)
544 raise ValueError(
"wrong length of quadruplet")
547 raise TypeError(
"%s is not a residue" % p)
550 dihedraltype = stringsequence[n]
551 if dihedraltype ==
"C":
555 (pi * anglemin / 180.0,
556 pi * anglemax / 180.0),
558 print(
"ResidueDihedralRestraint: adding a CYS restraint between %s %s %s %s" % (quadruplet[0].get_name(), quadruplet[1].get_name(),
559 quadruplet[2].get_name(), quadruplet[3].get_name()))
560 if dihedraltype ==
"T":
561 anglemin = 180 - 70.0
562 anglemax = 180 + 70.0
564 (pi * anglemin / 180.0,
565 pi * anglemax / 180.0),
567 print(
"ResidueDihedralRestraint: adding a TRANS restraint between %s %s %s %s" % (quadruplet[0].get_name(), quadruplet[1].get_name(),
568 quadruplet[2].get_name(), quadruplet[3].get_name()))
569 self.rs.add_restraint(
575 self.pairslist.append(
577 self.pairslist.append(
580 def set_label(self, label):
582 self.rs.set_name(label)
583 for r
in self.rs.get_restraints():
586 def add_to_model(self):
589 def get_restraint(self):
592 def set_weight(self, weight):
594 self.rs.set_weight(weight)
596 def get_excluded_pairs(self):
597 return self.pairslist
599 def get_output(self):
601 score = self.weight * self.rs.unprotected_evaluate(
None)
602 output[
"_TotalScore"] = str(score)
603 output[
"ResidueDihedralRestraint_" + self.label] = str(score)
607 """Experimental, requires isd_emxl for now"""
617 raise ValueError(
"IMP.isd_emxl is needed")
622 self.particles = IMP.pmi.tools.select_by_tuple(
626 self.m = representation.prot.get_model()
630 self.anglfilename = IMP.isd_emxl.get_data_path(
"CAAngleRestraint.dat")
631 self.dihefilename = IMP.isd_emxl.get_data_path(
632 "CADihedralRestraint.dat")
633 self.nativeness = nativeness
634 self.kt_caff = kt_caff
640 if len(self.particles) != len(ssstring):
641 print(len(self.particles), len(ssstring))
642 print(
"SecondaryStructure: residue range and SS string incompatible")
643 self.ssstring = ssstring
645 (bondrslist, anglrslist, diherslist,
646 pairslist) = self.get_CA_force_field()
647 self.pairslist = pairslist
650 self.anglrs.add_restraints(anglrslist)
651 self.dihers.add_restraints(diherslist)
652 self.bondrs.add_restraints(bondrslist)
654 def set_label(self, label):
657 def add_to_model(self):
662 def get_CA_force_field(self):
668 for res
in range(0, len(self.particles) - 1):
670 ps = self.particles[res:res + 2]
673 br = self.get_distance_restraint(ps[0], ps[1], 3.78, 416.0)
674 br.set_name(
'Bond_restraint')
675 bondrslist.append(br)
677 for res
in range(0, len(self.particles) - 4):
682 ps = self.particles[res:res + 5]
685 score_dih] = self.read_potential_dihedral(
686 self.ssstring[res:res + 4],
692 dr = IMP.isd_emxl.CADihedralRestraint(
701 dr.set_name(
'Dihedral restraint')
702 diherslist.append(dr)
704 for res
in range(0, len(self.particles) - 2):
705 ps = self.particles[res:res + 3]
706 [psi, score_ang] = self.read_potential_angle(
707 self.ssstring[res:res + 2],
True)
710 dr = IMP.isd_emxl.CAAngleRestraint(
716 dr.set_name(
'Angle restraint')
717 anglrslist.append(dr)
718 return (bondrslist, anglrslist, diherslist, pairslist)
720 def read_potential_dihedral(self, string, mix=False):
725 for i
in range(0, 36):
726 phi0.append(i * 10.0 / 180.0 * pi)
727 phi1.append(i * 10.0 / 180.0 * pi)
728 for j
in range(0, 36):
729 score_dih.append(0.0)
732 f = open(self.dihefilename,
'r')
733 for line
in f.readlines():
734 riga = (line.strip()).split()
735 if (len(riga) == 4
and riga[0] == string):
736 ii = int(float(riga[1]) / 10.0)
737 jj = int(float(riga[2]) / 10.0)
738 score_dih[ii * len(phi0) + jj] = - \
739 self.kt_caff * self.log(float(riga[3]))
744 for i
in range(0, 36):
745 for j
in range(0, 36):
747 f = open(self.dihefilename,
'r')
748 for line
in f.readlines():
749 riga = (line.strip()).split()
750 if (len(riga) == 4
and riga[0] == string):
751 ii = int(float(riga[1]) / 10.0)
752 jj = int(float(riga[2]) / 10.0)
753 counts[ii * len(phi0) + jj] += self.nativeness * \
755 if (len(riga) == 4
and riga[0] ==
"-----"):
756 ii = int(float(riga[1]) / 10.0)
757 jj = int(float(riga[2]) / 10.0)
758 counts[ii * len(phi0) + jj] += (1.0 - self.nativeness) * \
761 for i
in range(len(counts)):
762 score_dih[i] = -self.kt_caff * self.log(counts[i])
763 return [phi0, phi1, score_dih]
765 def read_potential_angle(self, string, mix=False):
769 for i
in range(0, 180):
770 psi.append(i / 180.0 * pi)
771 score_ang.append(0.0)
774 f = open(self.anglfilename,
'r')
775 for line
in f.readlines():
776 riga = (line.strip()).split()
777 if (len(riga) == 3
and riga[0] == string):
779 score_ang[ii] = -self.kt_caff * self.log(float(riga[2]))
784 for i
in range(0, 180):
787 f = open(self.anglfilename,
'r')
788 for line
in f.readlines():
789 riga = (line.strip()).split()
790 if (len(riga) == 3
and riga[0] == string):
792 counts[ii] += self.nativeness * float(riga[2])
793 if (len(riga) == 3
and riga[0] ==
"---"):
795 counts[ii] += (1.0 - self.nativeness) * float(riga[2])
797 for i
in range(0, 180):
798 score_ang[i] = -self.kt_caff * self.log(counts[i])
799 return [psi, score_ang]
801 def get_excluded_pairs(self):
802 return self.pairslist
804 def get_restraint(self):
806 tmprs.add_restraint(self.anglrs)
807 tmprs.add_restraint(self.dihers)
808 tmprs.add_restraint(self.bondrs)
811 def get_distance_restraint(self, p0, p1, d0, kappa):
817 def get_output(self):
819 score_angle = self.anglrs.unprotected_evaluate(
None)
820 score_dihers = self.dihers.unprotected_evaluate(
None)
821 score_bondrs = self.bondrs.unprotected_evaluate(
None)
822 output[
"_TotalScore"] = str(score_angle + score_dihers + score_bondrs)
824 output[
"SecondaryStructure_Angles_" + self.label] = str(score_angle)
825 output[
"SecondaryStructure_Dihedrals_" +
826 self.label] = str(score_dihers)
827 output[
"SecondaryStructure_Bonds_" + self.label] = str(score_bondrs)
832 """Add harmonic restraints between all pairs
834 def __init__(self,representation=None,
835 selection_tuples=
None,
842 @param representation Representation object
843 @param selection_tuples Selecting regions for the restraint [[start,stop,molname,copy_index=0],...]
844 @param resolution Resolution for applying restraint
845 @param strength Bond strength
846 @param dist_cutoff Cutoff for making restraints
847 @param ca_only Selects only CAlphas. Only matters if resolution=0.
848 @param hierarchy Root hierarchy to select from, use this instead of representation
852 if representation
is None and hierarchy
is not None:
853 self.m = hierarchy.get_model()
854 for st
in selection_tuples:
859 sel =
IMP.atom.Selection(hierarchy,molecule=st[2],residue_indexes=range(st[0],st[1]+1),
860 copy_index=copy_index)
862 sel =
IMP.atom.Selection(hierarchy,molecule=st[2],residue_indexes=range(st[0],st[1]+1),
863 copy_index=copy_index,
865 particles+=sel.get_selected_particles()
875 for r
in self.rs.get_restraints():
876 a1,a2 = r.get_inputs()
879 print(
'ElasticNetwork: created',self.rs.get_number_of_restraints(),
'restraints')
881 def set_label(self, label):
883 self.rs.set_name(label)
884 for r
in self.rs.get_restraints():
887 def add_to_model(self):
890 def get_restraint(self):
893 def set_weight(self, weight):
895 self.rs.set_weight(weight)
897 def get_excluded_pairs(self):
898 return self.pairslist
900 def get_output(self):
902 score = self.weight * self.rs.unprotected_evaluate(
None)
903 output[
"_TotalScore"] = str(score)
904 output[
"ElasticNetworkRestraint_" + self.label] = str(score)
909 """ Enable CHARMM force field """
915 enable_nonbonded=
True,
917 zone_nonbonded=
False,
918 representation=
None):
919 """Setup the CHARMM restraint on a selection. Expecting atoms.
920 @param root The node at which to apply the restraint
921 @param ff_temp The temperature of the force field
922 @param zone_ps Create a zone around this set of particles
923 Automatically includes the entire residue (incl. backbone)
924 @param zone_size The size for looking for neighbor residues
925 @param enable_nonbonded Allow the repulsive restraint
926 @param enable_bonded Allow the bonded restraint
927 @param zone_nonbonded EXPERIMENTAL: exclude from nonbonded all sidechains that aren't in zone!
928 @param representation Legacy representation object
931 kB = (1.381 * 6.02214) / 4184.0
932 if representation
is not None:
933 root = representation.prot
935 self.mdl = root.get_model()
937 self.nonbonded_rs =
IMP.RestraintSet(self.mdl, 1.0 / (kB * ff_temp),
'NONBONDED')
944 topology = ff.create_topology(root)
945 topology.apply_default_patches()
946 topology.setup_hierarchy(root)
947 if zone_ps
is not None:
948 limit_to_ps=IMP.pmi.topology.get_particles_within_zone(
952 entire_residues=
True,
953 exclude_backbone=
False)
957 self.ps = limit_to_ps
961 print(
'init bonds score',r.unprotected_evaluate(
None))
962 self.bonds_rs.add_restraint(r)
964 ff.add_well_depths(root)
966 atoms = IMP.atom.get_by_type(root,IMP.atom.ATOM_TYPE)
969 if (zone_ps
is not None)
and zone_nonbonded:
970 print(
'stereochemistry: zone_nonbonded is True')
972 backbone_types=[
'C',
'N',
'CB',
'O']
974 for n
in backbone_types])
975 backbone_atoms = sel.get_selected_particles()
977 sel_ps=IMP.pmi.topology.get_particles_within_zone(
981 entire_residues=
True,
982 exclude_backbone=
True)
992 self.nbl.add_pair_filter(r.get_full_pair_filter())
995 self.nonbonded_rs.add_restraint(pr)
996 print(
'CHARMM is set up')
998 def set_label(self, label):
1000 self.rs.set_name(label)
1001 for r
in self.rs.get_restraints():
1004 def add_to_model(self):
1008 def get_restraint(self):
1011 def get_close_pair_container(self):
1014 def set_weight(self, weight):
1015 self.weight = weight
1016 self.rs.set_weight(weight)
1018 def get_output(self):
1020 bonds_score = self.weight * self.bonds_rs.unprotected_evaluate(
None)
1021 nonbonded_score = self.weight * self.nonbonded_rs.unprotected_evaluate(
None)
1022 score=bonds_score+nonbonded_score
1023 output[
"_TotalScore"] = str(score)
1024 output[
"CHARMM_BONDS"] = str(bonds_score)
1025 output[
"CHARMM_NONBONDED"] = str(nonbonded_score)
1030 """Add bonds and improper dihedral restraints for the CBs
1033 self, rnums, representation, selection_tuple, strength=10.0, kappa=1.0,
1034 jitter_angle=0.0, jitter_improper=0.0):
1038 ca-cb is a constraint, no restraint needed
1043 self.m = representation.prot.get_model()
1053 ca, cb = self.get_ca_cb(
1054 IMP.pmi.tools.select_by_tuple(representation,
1055 (rnum, rnum,
'chainA'), resolution=0))
1059 ca_prev, cb_prev = self.get_ca_cb(
1060 IMP.pmi.tools.select_by_tuple(representation,
1061 (rnum - 1, rnum - 1,
'chainA'), resolution=0))
1062 ca_next, cb_next = self.get_ca_cb(
1063 IMP.pmi.tools.select_by_tuple(representation,
1064 (rnum + 1, rnum + 1,
'chainA'), resolution=0))
1098 self.rset_angles.add_restraint(ar13u)
1099 self.rset_angles.add_restraint(ar13l)
1105 self.rset_angles.add_restraint(ar23u)
1106 self.rset_angles.add_restraint(ar23l)
1107 if not nter
and not cter:
1131 self.rset_angles.add_restraint(idru)
1132 self.rset_angles.add_restraint(idrl)
1133 self.rs.add_restraint(self.rset_bonds)
1134 self.rs.add_restraint(self.rset_angles)
1136 def get_ca_cb(self, atoms):
1141 ca = a.get_particle()
1143 cb = a.get_particle()
1146 def set_label(self, label):
1148 self.rs.set_name(label)
1149 for r
in self.rs.get_restraints():
1152 def add_to_model(self):
1155 def get_restraint(self):
1158 def set_weight(self, weight):
1159 self.weight = weight
1160 self.rs.set_weight(weight)
1162 def get_excluded_pairs(self):
1163 return self.pairslist
1165 def get_output(self):
1167 score = self.weight * self.rs.unprotected_evaluate(
None)
1168 output[
"_TotalScore"] = str(score)
1169 output[
"PseudoAtomicRestraint_" + self.label] = str(score)
1173 """Create harmonic restraints between the reference and (transformed) clones.
1174 @note Wraps IMP::core::TransformedDistancePairScore with an IMP::core::Harmonic
1184 @param references Can be one of the following inputs:
1185 IMP Hierarchy, PMI System/State/Molecule/TempResidue, or a list/set of them
1186 @param clones_list List of lists of the above
1187 @param transforms Transforms moving each selection to the first selection
1188 @param label Label for output
1189 @param strength The elastic bond strength
1190 @param ca_only Optionally select so only CAlpha particles are used
1194 self.mdl = refs[0].get_model()
1198 if len(clones_list)!=len(transforms):
1199 raise Exception(
'Error: There should be as many clones as transforms')
1202 for tmp_clones,trans
in zip(clones_list,transforms):
1204 if len(clones)!=len(refs):
1205 raise Exception(
"Error: len(references)!=len(clones)")
1207 for p0,p1
in zip(refs,clones):
1211 p1.get_particle_index()])
1212 self.rs.add_restraint(r)
1213 print(
'created symmetry network with',self.rs.get_number_of_restraints(),
'restraints')
1215 def set_label(self, label):
1217 self.rs.set_name(label)
1218 for r
in self.rs.get_restraints():
1221 def add_to_model(self):
1224 def get_restraint(self):
1227 def set_weight(self, weight):
1228 self.weight = weight
1229 self.rs.set_weight(weight)
1231 def get_excluded_pairs(self):
1232 return self.pairslist
1234 def get_output(self):
1236 score = self.weight * self.rs.unprotected_evaluate(
None)
1237 output[
"SymmetryRestraint_" + self.label] = str(score)
1238 output[
"_TotalScore"] = str(score)
1243 """ This class creates a restraint between the termini two polypeptides, to simulate the sequence connectivity. """
1248 disorderedlength=
False,
1253 @param nterminal - single PMI2 Hierarchy/molecule at the nterminal
1254 @param cterminal - single PMI2 Hierarchy/molecule at the cterminal
1255 @param scale Scale the maximal distance between the beads by this factor when disorderedlength is False.
1256 The maximal distance is calculated as ((float(residuegap) + 1.0) * 3.6) * scale.
1257 @param disorderedlength - This flag uses either disordered length
1258 calculated for random coil peptides (True) or zero
1259 surface-to-surface distance between beads (False)
1260 as optimal distance for the sequence connectivity
1262 @param upperharmonic - This flag uses either harmonic (False)
1263 or upperharmonic (True) in the intra-pair
1264 connectivity restraint.
1265 @param resolution - The resolution to connect things at - only used if you pass PMI objects
1266 @param label - A string to identify this restraint in the output/stat file
1272 nter_lastres=ssn[-1][1]
1273 cter_firstres=ssc[0][0]
1274 self.m = nter_lastres.get_model()
1278 optdist = (3.6) * scale
1285 pt0 = nter_lastres.get_particle()
1286 pt1 = cter_firstres.get_particle()
1289 print(
"Adding fusion connectivity restraint between", pt0.get_name(),
" and ", pt1.get_name(),
'of distance', optdist)
1290 self.rs.add_restraint(r)
1292 def set_label(self, label):
1295 def get_weight(self):
1298 def add_to_model(self):
1301 def get_restraint(self):
1304 def set_weight(self, weight):
1305 self.weight = weight
1306 self.rs.set_weight(weight)
1308 def get_output(self):
1310 score = self.weight * self.rs.unprotected_evaluate(
None)
1311 output[
"_TotalScore"] = str(score)
1312 output[
"FusionRestraint_" + self.label] = str(score)
1316 return self.weight * self.rs.unprotected_evaluate(
None)
1323 """Restrain the dihedral between planes defined by three particles.
1325 This restraint is useful for restraining the twist of a string of
1326 more or less identical rigid bodies, so long as the curvature is mild.
1329 def __init__(self, particle_triplets, angle=0., k=1., label=None,
1332 @param particle_triplets List of lists of 3 particles. Each triplet
1333 defines a plane. Dihedrals of adjacent planes
1335 @param angle Angle of plane dihedral in degrees
1336 @param k Strength of restraint
1337 @param label Label for output
1338 @param weight Weight of restraint
1339 @note Particles defining planes should be rigid and more or less
1340 parallel for proper behavior
1342 model = particle_triplets[0][0].get_model()
1343 super(PlaneDihedralRestraint, self).
__init__(model, label=label,
1346 angle = pi * angle / 180.
1348 for i, t1
in enumerate(particle_triplets[:-1]):
1349 t2 = particle_triplets[i + 1]
1350 q1 = [t1[1], t1[0], t2[0], t2[1]]
1351 q2 = [t1[2], t1[0], t2[0], t2[2]]
1352 self.rs.add_restraint(
1354 self.rs.add_restraint(
A filter which returns true if a container containers the Pair.
Add dihedral restraints between quadruplet of consecutive residues/beads to enforce the stereochemist...
CHARMMParameters * get_heavy_atom_CHARMM_parameters()
Lower bound harmonic function (non-zero when feature < mean)
static bool get_is_setup(const IMP::ParticleAdaptor &p)
Enforce CHARMM stereochemistry on the given Hierarchy.
A member of a rigid body, it has internal (local) coordinates.
static bool get_is_setup(const IMP::ParticleAdaptor &p)
Various classes to hold sets of particles.
Upper bound harmonic function (non-zero when feature > mean)
Enable CHARMM force field.
A class to store an fixed array of same-typed values.
Enforce ideal Helix dihedrals and bonds for a selection at resolution 0.
This class creates a restraint between the termini two polypeptides, to simulate the sequence connect...
Add harmonic restraints between all pairs.
Restrain the dihedral between planes defined by three particles.
Dihedral restraint between four particles.
A score on the distance between the surfaces of two spheres.
Return all close unordered pairs of particles taken from the SingletonContainer.
static bool get_is_setup(const IMP::ParticleAdaptor &p)
Return all spatially-proximals pairs of particles (a,b) from the two SingletonContainers A and B...
GenericHierarchies get_leaves(Hierarchy mhd)
Get all the leaves of the bit of hierarchy.
Distance restraint between two particles.
Object used to hold a set of restraints.
Store a list of ParticleIndexPairs.
A well with harmonic barriers.
Angle restraint between three particles.
ParticleIndexPairs get_indexes(const ParticlePairsTemp &ps)
Add bond restraint between pair of consecutive residues/beads to enforce the stereochemistry.
The standard decorator for manipulating molecular structures.
RestraintSet * create_elastic_network(const Particles &ps, Float dist_cutoff, Float strength)
Create an elastic network restraint set.
Add bonds and improper dihedral restraints for the CBs.
Store a list of ParticleIndexes.
A decorator for a particle representing an atom.
def get_particle_pairs
Returns the list of connected particles pairs.
def __init__
Setup the CHARMM restraint on a selection.
Create harmonic restraints between the reference and (transformed) clones.
Add angular restraint between triplets of consecutive residues/beads to enforce the stereochemistry...
def get_num_restraints
Returns number of connectivity restraints.
A decorator for a residue.
Basic functionality that is expected to be used by a wide variety of IMP users.
General purpose algebraic and geometric methods that are expected to be used by a wide variety of IMP...
This class creates a restraint between consecutive TempResidue objects OR an entire PMI MOlecule obje...
A class to create an excluded volume restraint for a set of particles at a given resolution.
The general base class for IMP exceptions.
def __init__
need to add: ca-ca bond ca-cb is a constraint, no restraint needed ca-ca-ca cb-ca-ca-cb ...
Applies a PairScore to a Pair.
Experimental, requires isd_emxl for now.
Functionality for loading, creating, manipulating and scoring atomic structures.
Select hierarchy particles identified by the biological name.
Applies a PairScore to each Pair in a list.
A repulsive potential on the distance between two atoms.
Perform more efficient close pair finding when rigid bodies are involved.
Base class for PMI restraints, which wrap IMP.Restraint(s).
Inferential scoring building on methods developed as part of the Inferential Structure Determination ...
Harmonic function (symmetric about the mean)
Restraint a set of residues to use ideal helix dihedrals and bonds.