1 """@namespace IMP.pmi.restraints.stereochemistry
2 Restraints for keeping correct stereochemistry.
5 from __future__
import print_function
15 from operator
import itemgetter
16 from math
import pi,log,sqrt
22 """ This class creates a restraint between consecutive TempResidue objects OR an entire
23 PMI MOlecule object. """
28 disorderedlength=
False,
33 @param objects - a list of hierarchies, PMI TempResidues OR a single Molecule
34 @param scale Scale the maximal distance between the beads by this factor when disorderedlength is False.
35 The maximal distance is calculated as ((float(residuegap) + 1.0) * 3.6) * scale.
36 @param disorderedlength - This flag uses either disordered length
37 calculated for random coil peptides (True) or zero
38 surface-to-surface distance between beads (False)
39 as optimal distance for the sequence connectivity
41 @param upperharmonic - This flag uses either harmonic (False)
42 or upperharmonic (True) in the intra-pair
43 connectivity restraint.
44 @param resolution - The resolution to connect things at - only used if you pass PMI objects
45 @param label - A string to identify this restraint in the output/stat file
52 raise Exception(
"ConnectivityRestraint: only pass stuff from one Molecule, please")
56 self.m = list(hiers)[0].get_model()
72 SortedSegments.append((start, end, startres))
73 SortedSegments = sorted(SortedSegments, key=itemgetter(2))
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()
128 print(
"Adding sequence connectivity restraint between", pt0.get_name(),
" and ", pt1.get_name(),
'of distance', optdist)
129 self.rs.add_restraint(r)
131 def set_label(self, label):
134 def get_weight(self):
137 def add_to_model(self):
140 def get_restraint(self):
143 def set_weight(self, weight):
145 self.rs.set_weight(weight)
147 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 return self.weight * self.rs.unprotected_evaluate(
None)
163 """A class to create an excluded volume restraint for a set of particles at a given resolution.
164 Can be initialized as a bipartite restraint between two sets of particles.
165 # Potential additional function: Variable resolution for each PMI object. Perhaps passing selection_tuples
166 with (PMI_object, resolution)
171 included_objects=
None,
176 @param representation DEPRECATED - just pass objects
177 @param included_objects Can be one of the following inputs:
178 IMP Hierarchy, PMI System/State/Molecule/TempResidue, or a list/set of them
179 @param other_objects Initializes a bipartite restraint between included_objects and other_objects
180 Same format as included_objects
181 @param resolution The resolution particles at which to impose the restraint.
182 By default, the coarsest particles will be chosen.
183 If a number is chosen, for each particle, the closest
184 resolution will be used (see IMP.atom.Selection).
185 @param kappa Restraint strength
199 if other_objects
is not None:
208 if representation
is None:
209 if hierarchies
is None:
210 raise Exception(
"Must at least pass included objects")
211 self.mdl = hierarchies[0].get_model()
212 included_ps = [h.get_particle()
for h
in hierarchies]
214 other_ps = [h.get_particle()
for h
in other_hierarchies]
216 self.mdl = representation.m
219 resolution=resolution,
220 hierarchies=hierarchies)
224 resolution=resolution,
225 hierarchies=other_hierarchies)
227 raise Exception(
"Must pass Representation or included_objects")
250 self.rs.add_restraint(evr)
252 def add_excluded_particle_pairs(self, excluded_particle_pairs):
257 self.cpc.add_pair_filter(icpf)
259 def set_label(self, label):
262 def add_to_model(self):
265 def get_restraint(self):
268 def set_weight(self, weight):
270 self.rs.set_weight(weight)
272 def get_output(self):
275 score = self.weight * self.rs.unprotected_evaluate(
None)
276 output[
"_TotalScore"] = str(score)
277 output[
"ExcludedVolumeSphere_" + self.label] = str(score)
281 return self.weight * self.rs.unprotected_evaluate(
None)
284 """Enforce ideal Helix dihedrals and bonds for a selection at resolution 0"""
291 @param hierarchy the root node
292 @param selection_tuple (start, stop, molname, copynum=0)
295 self.mdl = hierarchy.get_model()
299 start = selection_tuple[0]
300 stop = selection_tuple[1]
301 mol = selection_tuple[2]
303 if len(selection_tuple)>3:
304 copy_index = selection_tuple[3]
307 residue_indexes=range(start,stop+1))
308 ps = sel.get_selected_particles(with_representation=
False)
312 self.rs.add_restraint(self.r)
313 print(
'Created helix %s.%i.%i-%i with %i dihedrals and %i bonds'%(
314 mol,copy_index,start,stop,
315 self.get_number_of_bonds(),self.get_number_of_dihedrals()))
316 def set_label(self, label):
319 def get_weight(self):
322 def add_to_model(self):
325 def get_restraint(self):
328 def set_weight(self, weight):
330 self.rs.set_weight(weight)
332 def get_number_of_bonds(self):
333 return self.r.get_number_of_bonds()
335 def get_number_of_dihedrals(self):
336 return self.r.get_number_of_dihedrals()
339 return self.weight * self.rs.unprotected_evaluate(
None)
341 def get_output(self):
344 score = self.evaluate()
345 output[
"_TotalScore"] = str(score)
346 output[
"HelixRestraint_" + self.label] = str(score)
350 """ Add bond restraint between pair of consecutive
351 residues/beads to enforce the stereochemistry.
355 selection_tuple=
None,
361 @param representation (PMI1)
362 @param selection_tuple Requested selection (PMI1)
363 @param objects (PMI2)
364 @param distance Resting distance for restraint
365 @param strength Bond constant
366 @param jitter Defines the +- added to the optimal distance in the harmonic well restraint
367 used to increase the tolerance
370 if representation
is not None and selection_tuple
is not None:
371 self.m = representation.prot.get_model()
372 particles = IMP.pmi.tools.select_by_tuple(
377 elif objects
is not None:
379 self.m = particles[0].get_model()
392 (distance - jitter, distance + jitter), strength)
397 raise ValueError(
"wrong length of pair")
400 raise TypeError(
"not a residue")
403 print(
"ResidueBondRestraint: adding a restraint between %s %s" % (pair[0].get_name(), pair[1].get_name()))
404 self.rs.add_restraint(
409 def set_label(self, label):
411 self.rs.set_name(label)
412 for r
in self.rs.get_restraints():
415 def add_to_model(self):
418 def get_restraint(self):
421 def set_weight(self, weight):
423 self.rs.set_weight(weight)
425 def get_excluded_pairs(self):
426 return self.pairslist
428 def get_output(self):
431 score = self.weight * self.rs.unprotected_evaluate(
None)
432 output[
"_TotalScore"] = str(score)
433 output[
"ResidueBondRestraint_" + self.label] = str(score)
438 """Add angular restraint between triplets of consecutive
439 residues/beads to enforce the stereochemistry.
443 selection_tuple=
None,
449 if representation
is not None and selection_tuple
is not None:
450 self.m = representation.prot.get_model()
451 particles = IMP.pmi.tools.select_by_tuple(
456 elif objects
is not None:
458 self.m = particles[0].get_model()
466 (pi * anglemin / 180.0,
467 pi * anglemax / 180.0),
473 raise ValueError(
"wrong length of triplet")
476 raise TypeError(
"not a residue")
479 print(
"ResidueAngleRestraint: adding a restraint between %s %s %s" % (triplet[0].get_name(), triplet[1].get_name(), triplet[2].get_name()))
480 self.rs.add_restraint(
488 def set_label(self, label):
490 self.rs.set_name(label)
491 for r
in self.rs.get_restraints():
494 def add_to_model(self):
497 def get_restraint(self):
500 def set_weight(self, weight):
502 self.rs.set_weight(weight)
504 def get_excluded_pairs(self):
505 return self.pairslist
507 def get_output(self):
510 score = self.weight * self.rs.unprotected_evaluate(
None)
511 output[
"_TotalScore"] = str(score)
512 output[
"ResidueAngleRestraint_" + self.label] = str(score)
517 """Add dihedral restraints between quadruplet of consecutive
518 residues/beads to enforce the stereochemistry.
519 Give as input a string of "C" and "T", meaning cys (0+-40) or trans (180+-40)
520 dihedral. The length of the string must be \#residue-3.
521 Without the string, the dihedral will be assumed trans.
526 selection_tuple=
None,
531 if representation
is not None and selection_tuple
is not None:
532 self.m = representation.prot.get_model()
533 particles = IMP.pmi.tools.select_by_tuple(
538 elif objects
is not None:
540 self.m = particles[0].get_model()
547 if stringsequence
is None:
548 stringsequence =
"T" * (len(particles) - 3)
553 raise ValueError(
"wrong length of quadruplet")
556 raise TypeError(
"not a residue")
559 dihedraltype = stringsequence[n]
560 if dihedraltype ==
"C":
564 (pi * anglemin / 180.0,
565 pi * anglemax / 180.0),
567 print(
"ResidueDihedralRestraint: adding a CYS restraint between %s %s %s %s" % (quadruplet[0].get_name(), quadruplet[1].get_name(),
568 quadruplet[2].get_name(), quadruplet[3].get_name()))
569 if dihedraltype ==
"T":
570 anglemin = 180 - 70.0
571 anglemax = 180 + 70.0
573 (pi * anglemin / 180.0,
574 pi * anglemax / 180.0),
576 print(
"ResidueDihedralRestraint: adding a TRANS restraint between %s %s %s %s" % (quadruplet[0].get_name(), quadruplet[1].get_name(),
577 quadruplet[2].get_name(), quadruplet[3].get_name()))
578 self.rs.add_restraint(
584 self.pairslist.append(
586 self.pairslist.append(
589 def set_label(self, label):
591 self.rs.set_name(label)
592 for r
in self.rs.get_restraints():
595 def add_to_model(self):
598 def get_restraint(self):
601 def set_weight(self, weight):
603 self.rs.set_weight(weight)
605 def get_excluded_pairs(self):
606 return self.pairslist
608 def get_output(self):
611 score = self.weight * self.rs.unprotected_evaluate(
None)
612 output[
"_TotalScore"] = str(score)
613 output[
"ResidueDihedralRestraint_" + self.label] = str(score)
617 """Experimental, requires isd_emxl for now"""
627 raise ValueError(
"IMP.isd_emxl is needed")
632 self.particles = IMP.pmi.tools.select_by_tuple(
636 self.m = representation.prot.get_model()
640 self.anglfilename = IMP.isd_emxl.get_data_path(
"CAAngleRestraint.dat")
641 self.dihefilename = IMP.isd_emxl.get_data_path(
642 "CADihedralRestraint.dat")
643 self.nativeness = nativeness
644 self.kt_caff = kt_caff
650 if len(self.particles) != len(ssstring):
651 print(len(self.particles), len(ssstring))
652 print(
"SecondaryStructure: residue range and SS string incompatible")
653 self.ssstring = ssstring
655 (bondrslist, anglrslist, diherslist,
656 pairslist) = self.get_CA_force_field()
657 self.pairslist = pairslist
660 self.anglrs.add_restraints(anglrslist)
661 self.dihers.add_restraints(diherslist)
662 self.bondrs.add_restraints(bondrslist)
664 def set_label(self, label):
667 def add_to_model(self):
672 def get_CA_force_field(self):
678 for res
in range(0, len(self.particles) - 1):
680 ps = self.particles[res:res + 2]
683 br = self.get_distance_restraint(ps[0], ps[1], 3.78, 416.0)
684 br.set_name(
'Bond_restraint')
685 bondrslist.append(br)
687 for res
in range(0, len(self.particles) - 4):
692 ps = self.particles[res:res + 5]
695 score_dih] = self.read_potential_dihedral(
696 self.ssstring[res:res + 4],
702 dr = IMP.isd_emxl.CADihedralRestraint(
711 dr.set_name(
'Dihedral restraint')
712 diherslist.append(dr)
714 for res
in range(0, len(self.particles) - 2):
715 ps = self.particles[res:res + 3]
716 [psi, score_ang] = self.read_potential_angle(
717 self.ssstring[res:res + 2],
True)
720 dr = IMP.isd_emxl.CAAngleRestraint(
726 dr.set_name(
'Angle restraint')
727 anglrslist.append(dr)
728 return (bondrslist, anglrslist, diherslist, pairslist)
730 def read_potential_dihedral(self, string, mix=False):
735 for i
in range(0, 36):
736 phi0.append(i * 10.0 / 180.0 * pi)
737 phi1.append(i * 10.0 / 180.0 * pi)
738 for j
in range(0, 36):
739 score_dih.append(0.0)
742 f = open(self.dihefilename,
'r')
743 for line
in f.readlines():
744 riga = (line.strip()).split()
745 if (len(riga) == 4
and riga[0] == string):
746 ii = int(float(riga[1]) / 10.0)
747 jj = int(float(riga[2]) / 10.0)
748 score_dih[ii * len(phi0) + jj] = - \
749 self.kt_caff * self.log(float(riga[3]))
754 for i
in range(0, 36):
755 for j
in range(0, 36):
757 f = open(self.dihefilename,
'r')
758 for line
in f.readlines():
759 riga = (line.strip()).split()
760 if (len(riga) == 4
and riga[0] == string):
761 ii = int(float(riga[1]) / 10.0)
762 jj = int(float(riga[2]) / 10.0)
763 counts[ii * len(phi0) + jj] += self.nativeness * \
765 if (len(riga) == 4
and riga[0] ==
"-----"):
766 ii = int(float(riga[1]) / 10.0)
767 jj = int(float(riga[2]) / 10.0)
768 counts[ii * len(phi0) + jj] += (1.0 - self.nativeness) * \
771 for i
in range(len(counts)):
772 score_dih[i] = -self.kt_caff * self.log(counts[i])
773 return [phi0, phi1, score_dih]
775 def read_potential_angle(self, string, mix=False):
779 for i
in range(0, 180):
780 psi.append(i / 180.0 * pi)
781 score_ang.append(0.0)
784 f = open(self.anglfilename,
'r')
785 for line
in f.readlines():
786 riga = (line.strip()).split()
787 if (len(riga) == 3
and riga[0] == string):
789 score_ang[ii] = -self.kt_caff * self.log(float(riga[2]))
794 for i
in range(0, 180):
797 f = open(self.anglfilename,
'r')
798 for line
in f.readlines():
799 riga = (line.strip()).split()
800 if (len(riga) == 3
and riga[0] == string):
802 counts[ii] += self.nativeness * float(riga[2])
803 if (len(riga) == 3
and riga[0] ==
"---"):
805 counts[ii] += (1.0 - self.nativeness) * float(riga[2])
807 for i
in range(0, 180):
808 score_ang[i] = -self.kt_caff * self.log(counts[i])
809 return [psi, score_ang]
811 def get_excluded_pairs(self):
812 return self.pairslist
814 def get_restraint(self):
816 tmprs.add_restraint(self.anglrs)
817 tmprs.add_restraint(self.dihers)
818 tmprs.add_restraint(self.bondrs)
821 def get_distance_restraint(self, p0, p1, d0, kappa):
827 def get_output(self):
830 score_angle = self.anglrs.unprotected_evaluate(
None)
831 score_dihers = self.dihers.unprotected_evaluate(
None)
832 score_bondrs = self.bondrs.unprotected_evaluate(
None)
833 output[
"_TotalScore"] = str(score_angle + score_dihers + score_bondrs)
835 output[
"SecondaryStructure_Angles_" + self.label] = str(score_angle)
836 output[
"SecondaryStructure_Dihedrals_" +
837 self.label] = str(score_dihers)
838 output[
"SecondaryStructure_Bonds_" + self.label] = str(score_bondrs)
843 """Add harmonic restraints between all pairs
845 def __init__(self,representation=None,
846 selection_tuples=
None,
853 @param representation Representation object
854 @param selection_tuples Selecting regions for the restraint [[start,stop,molname,copy_index=0],...]
855 @param resolution Resolution for applying restraint
856 @param strength Bond strength
857 @param dist_cutoff Cutoff for making restraints
858 @param ca_only Selects only CAlphas. Only matters if resolution=0.
859 @param hierarchy Root hierarchy to select from, use this instead of representation
863 if representation
is None and hierarchy
is not None:
864 self.m = hierarchy.get_model()
865 for st
in selection_tuples:
870 sel =
IMP.atom.Selection(hierarchy,molecule=st[2],residue_indexes=range(st[0],st[1]+1),
871 copy_index=copy_index)
873 sel =
IMP.atom.Selection(hierarchy,molecule=st[2],residue_indexes=range(st[0],st[1]+1),
874 copy_index=copy_index,
876 particles+=sel.get_selected_particles()
878 self.m = representation.mdl
879 for st
in selection_tuples:
880 print(
'selecting with',st)
881 for p
in IMP.pmi.tools.select_by_tuple(representation,st,resolution=resolution):
885 particles.append(p.get_particle())
887 raise Exception(
"must pass representation or hierarchy")
895 for r
in self.rs.get_restraints():
896 a1,a2 = r.get_inputs()
899 print(
'ElasticNetwork: created',self.rs.get_number_of_restraints(),
'restraints')
901 def set_label(self, label):
903 self.rs.set_name(label)
904 for r
in self.rs.get_restraints():
907 def add_to_model(self):
910 def get_restraint(self):
913 def set_weight(self, weight):
915 self.rs.set_weight(weight)
917 def get_excluded_pairs(self):
918 return self.pairslist
920 def get_output(self):
923 score = self.weight * self.rs.unprotected_evaluate(
None)
924 output[
"_TotalScore"] = str(score)
925 output[
"ElasticNetworkRestraint_" + self.label] = str(score)
930 """ Enable CHARMM force field """
936 enable_nonbonded=
True,
938 zone_nonbonded=
False,
939 representation=
None):
940 """Setup the CHARMM restraint on a selection. Expecting atoms.
941 @param root The node at which to apply the restraint
942 @param ff_temp The temperature of the force field
943 @param zone_ps Create a zone around this set of particles
944 Automatically includes the entire residue (incl. backbone)
945 @param zone_size The size for looking for neighbor residues
946 @param enable_nonbonded Allow the repulsive restraint
947 @param enable_bonded Allow the bonded restraint
948 @param zone_nonbonded EXPERIMENTAL: exclude from nonbonded all sidechains that aren't in zone!
949 @param representation Legacy representation object
952 kB = (1.381 * 6.02214) / 4184.0
953 if representation
is not None:
954 root = representation.prot
956 self.mdl = root.get_model()
958 self.nonbonded_rs =
IMP.RestraintSet(self.mdl, 1.0 / (kB * ff_temp),
'NONBONDED')
965 topology = ff.create_topology(root)
966 topology.apply_default_patches()
967 topology.setup_hierarchy(root)
968 if zone_ps
is not None:
969 limit_to_ps=IMP.pmi.topology.get_particles_within_zone(
973 entire_residues=
True,
974 exclude_backbone=
False)
978 self.ps = limit_to_ps
982 print(
'init bonds score',r.unprotected_evaluate(
None))
983 self.bonds_rs.add_restraint(r)
985 ff.add_well_depths(root)
987 atoms = IMP.atom.get_by_type(root,IMP.atom.ATOM_TYPE)
990 if (zone_ps
is not None)
and zone_nonbonded:
991 print(
'stereochemistry: zone_nonbonded is True')
993 backbone_types=[
'C',
'N',
'CB',
'O']
995 for n
in backbone_types])
996 backbone_atoms = sel.get_selected_particles()
998 sel_ps=IMP.pmi.topology.get_particles_within_zone(
1002 entire_residues=
True,
1003 exclude_backbone=
True)
1013 self.nbl.add_pair_filter(r.get_full_pair_filter())
1016 self.nonbonded_rs.add_restraint(pr)
1017 print(
'CHARMM is set up')
1019 def set_label(self, label):
1021 self.rs.set_name(label)
1022 for r
in self.rs.get_restraints():
1025 def add_to_model(self):
1029 def get_restraint(self):
1032 def get_close_pair_container(self):
1035 def set_weight(self, weight):
1036 self.weight = weight
1037 self.rs.set_weight(weight)
1039 def get_output(self):
1042 bonds_score = self.weight * self.bonds_rs.unprotected_evaluate(
None)
1043 nonbonded_score = self.weight * self.nonbonded_rs.unprotected_evaluate(
None)
1044 score=bonds_score+nonbonded_score
1045 output[
"_TotalScore"] = str(score)
1046 output[
"CHARMM_BONDS"] = str(bonds_score)
1047 output[
"CHARMM_NONBONDED"] = str(nonbonded_score)
1052 """Add bonds and improper dihedral restraints for the CBs
1055 self, rnums, representation, selection_tuple, strength=10.0, kappa=1.0,
1056 jitter_angle=0.0, jitter_improper=0.0):
1060 ca-cb is a constraint, no restraint needed
1065 self.m = representation.prot.get_model()
1075 ca, cb = self.get_ca_cb(
1076 IMP.pmi.tools.select_by_tuple(representation,
1077 (rnum, rnum,
'chainA'), resolution=0))
1081 ca_prev, cb_prev = self.get_ca_cb(
1082 IMP.pmi.tools.select_by_tuple(representation,
1083 (rnum - 1, rnum - 1,
'chainA'), resolution=0))
1084 ca_next, cb_next = self.get_ca_cb(
1085 IMP.pmi.tools.select_by_tuple(representation,
1086 (rnum + 1, rnum + 1,
'chainA'), resolution=0))
1120 self.rset_angles.add_restraint(ar13u)
1121 self.rset_angles.add_restraint(ar13l)
1127 self.rset_angles.add_restraint(ar23u)
1128 self.rset_angles.add_restraint(ar23l)
1129 if not nter
and not cter:
1153 self.rset_angles.add_restraint(idru)
1154 self.rset_angles.add_restraint(idrl)
1155 self.rs.add_restraint(self.rset_bonds)
1156 self.rs.add_restraint(self.rset_angles)
1158 def get_ca_cb(self, atoms):
1163 ca = a.get_particle()
1165 cb = a.get_particle()
1168 def set_label(self, label):
1170 self.rs.set_name(label)
1171 for r
in self.rs.get_restraints():
1174 def add_to_model(self):
1177 def get_restraint(self):
1180 def set_weight(self, weight):
1181 self.weight = weight
1182 self.rs.set_weight(weight)
1184 def get_excluded_pairs(self):
1185 return self.pairslist
1187 def get_output(self):
1190 score = self.weight * self.rs.unprotected_evaluate(
None)
1191 output[
"_TotalScore"] = str(score)
1192 output[
"PseudoAtomicRestraint_" + self.label] = str(score)
1196 """Create harmonic restraints between the reference and (transformed) clones.
1197 \note Wraps IMP::core::TransformedDistancePairScore with an IMP::core::Harmonic
1206 @param references List of particles for symmetry reference
1207 @param clones_list List of lists of clone particles
1208 @param transforms Transforms moving each selection to the first selection
1209 @param label Label for output
1210 @param strength The elastic bond strength
1211 \note You will have to perform an IMP::atom::Selection to get the particles you need.
1212 Will check to make sure the numbers match.
1214 self.mdl = root.get_model()
1218 if len(clones_list)!=len(transforms):
1219 raise Exception(
'Error: There should be as many clones as transforms')
1222 for clones,trans
in zip(clones_list,transforms):
1223 if len(clones)!=len(references):
1224 raise Exception(
"Error: len(references)!=len(clones)")
1226 for p0,p1
in zip(references,clones):
1228 self.rs.add_restraint(r)
1230 print(
'created symmetry network with',self.rs.get_number_of_restraints(),
'restraints')
1232 def set_label(self, label):
1234 self.rs.set_name(label)
1235 for r
in self.rs.get_restraints():
1238 def add_to_model(self):
1241 def get_restraint(self):
1244 def set_weight(self, weight):
1245 self.weight = weight
1246 self.rs.set_weight(weight)
1248 def get_excluded_pairs(self):
1249 return self.pairslist
1251 def get_output(self):
1254 score = self.weight * self.rs.unprotected_evaluate(
None)
1255 output[
"SymmetryRestraint_" + self.label] = str(score)
1256 output[
"_TotalScore"] = str(score)
1261 """ This class creates a restraint between the termini two polypeptides, to simulate the sequence connectivity. """
1266 disorderedlength=
False,
1271 @param nterminal - single PMI2 Hierarchy/molecule at the nterminal
1272 @param cterminal - single PMI2 Hierarchy/molecule at the cterminal
1273 @param scale Scale the maximal distance between the beads by this factor when disorderedlength is False.
1274 The maximal distance is calculated as ((float(residuegap) + 1.0) * 3.6) * scale.
1275 @param disorderedlength - This flag uses either disordered length
1276 calculated for random coil peptides (True) or zero
1277 surface-to-surface distance between beads (False)
1278 as optimal distance for the sequence connectivity
1280 @param upperharmonic - This flag uses either harmonic (False)
1281 or upperharmonic (True) in the intra-pair
1282 connectivity restraint.
1283 @param resolution - The resolution to connect things at - only used if you pass PMI objects
1284 @param label - A string to identify this restraint in the output/stat file
1290 nter_lastres=ssn[-1][1]
1291 cter_firstres=ssc[0][0]
1292 self.m = nter_lastres.get_model()
1296 optdist = (3.6) * scale
1303 pt0 = nter_lastres.get_particle()
1304 pt1 = cter_firstres.get_particle()
1307 print(
"Adding fusion connectivity restraint between", pt0.get_name(),
" and ", pt1.get_name(),
'of distance', optdist)
1308 self.rs.add_restraint(r)
1310 def set_label(self, label):
1313 def get_weight(self):
1316 def add_to_model(self):
1319 def get_restraint(self):
1322 def set_weight(self, weight):
1323 self.weight = weight
1324 self.rs.set_weight(weight)
1326 def get_output(self):
1329 score = self.weight * self.rs.unprotected_evaluate(
None)
1330 output[
"_TotalScore"] = str(score)
1331 output[
"FusionRestraint_" + self.label] = str(score)
1335 return self.weight * self.rs.unprotected_evaluate(
None)
1342 """Restrain the dihedral between planes defined by three particles.
1344 This restraint is useful for restraining the twist of a string of
1345 more or less identical rigid bodies, so long as the curvature is mild.
1348 def __init__(self, particle_triplets, angle=0., k=1., label=None,
1351 @param particle_triplets List of lists of 3 particles. Each triplet
1352 defines a plane. Dihedrals of adjacent planes
1354 @param angle Angle of plane dihedral in degrees
1355 @param k Strength of restraint
1356 @param label Label for output
1357 @param weight Weight of restraint
1358 \note Particles defining planes should be rigid and more or less
1359 parallel for proper behavior
1361 m = particle_triplets[0][0].get_model()
1362 super(PlaneDihedralRestraint, self).
__init__(m, label=label,
1365 angle = pi * angle / 180.
1367 for i, t1
in enumerate(particle_triplets[:-1]):
1368 t2 = particle_triplets[i + 1]
1369 q1 = [t1[1], t1[0], t2[0], t2[1]]
1370 q2 = [t1[2], t1[0], t2[0], t2[2]]
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.
Representation of the system.
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 __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.
Set up the representation of all proteins and nucleic acid macromolecules.
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.