1 """@namespace IMP.pmi.restraints.stereochemistry
2 Restraints for keeping correct stereochemistry.
5 from __future__
import print_function
12 from operator
import itemgetter
13 from math
import pi,log,sqrt
17 """Create a restraint between consecutive TempResidue objects
18 or an entire PMI Molecule object."""
23 disorderedlength=
False,
28 @param objects - a list of hierarchies, PMI TempResidues OR a single Molecule
29 @param scale Scale the maximal distance between the beads by this factor when disorderedlength is False.
30 The maximal distance is calculated as ((float(residuegap) + 1.0) * 3.6) * scale.
31 @param disorderedlength - This flag uses either disordered length
32 calculated for random coil peptides (True) or zero
33 surface-to-surface distance between beads (False)
34 as optimal distance for the sequence connectivity
36 @param upperharmonic - This flag uses either harmonic (False)
37 or upperharmonic (True) in the intra-pair
38 connectivity restraint.
39 @param resolution - The resolution to connect things at - only used if you pass PMI objects
40 @param label - A string to identify this restraint in the output/stat file
47 raise Exception(
"ConnectivityRestraint: only pass stuff from one Molecule, please")
51 self.m = list(hiers)[0].get_model()
67 SortedSegments.append((start, end, startres))
68 SortedSegments = sorted(SortedSegments, key=itemgetter(2))
71 self.particle_pairs=[]
72 for x
in range(len(SortedSegments) - 1):
74 last = SortedSegments[x][1]
75 first = SortedSegments[x + 1][0]
77 apply_restraint =
True
91 apply_restraint =
False
100 residuegap = firstresn - lastresn - 1
101 if disorderedlength
and (nreslast / 2 + nresfirst / 2 + residuegap) > 20.0:
104 optdist = sqrt(5 / 3) * 1.93 * \
105 (nreslast / 2 + nresfirst / 2 + residuegap) ** 0.6
113 optdist = (0.0 + (float(residuegap) + 1.0) * 3.6) * scale
120 pt0 = last.get_particle()
121 pt1 = first.get_particle()
122 self.particle_pairs.append((pt0,pt1))
125 print(
"Adding sequence connectivity restraint between", pt0.get_name(),
" and ", pt1.get_name(),
'of distance', optdist)
126 self.rs.add_restraint(r)
128 def set_label(self, label):
131 def get_weight(self):
134 def add_to_model(self):
137 def get_restraint(self):
140 def set_weight(self, weight):
142 self.rs.set_weight(weight)
144 def get_output(self):
146 score = self.weight * self.rs.unprotected_evaluate(
None)
147 output[
"_TotalScore"] = str(score)
148 output[
"ConnectivityRestraint_" + self.label] = str(score)
152 """ Returns number of connectivity restraints """
153 return len(self.rs.get_restraints())
156 """ Returns the list of connected particles pairs """
157 return self.particle_pairs
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)
175 @param included_objects Can be one of the following inputs:
176 IMP Hierarchy, PMI System/State/Molecule/TempResidue, or a list/set of them
177 @param other_objects Initializes a bipartite restraint between included_objects and other_objects
178 Same format as included_objects
179 @param resolution The resolution particles at which to impose the restraint.
180 By default, the coarsest particles will be chosen.
181 If a number is chosen, for each particle, the closest
182 resolution will be used (see IMP.atom.Selection).
183 @param kappa Restraint strength
197 if other_objects
is not None:
205 if hierarchies
is None:
206 raise Exception(
"Must at least pass included objects")
207 self.mdl = hierarchies[0].get_model()
208 included_ps = [h.get_particle()
for h
in hierarchies]
210 other_ps = [h.get_particle()
for h
in other_hierarchies]
233 self.rs.add_restraint(evr)
235 def add_excluded_particle_pairs(self, excluded_particle_pairs):
237 inverted=[(p1,p0)
for p0,p1
in excluded_particle_pairs]
242 self.cpc.add_pair_filter(icpf)
244 def set_label(self, label):
247 def add_to_model(self):
250 def get_restraint(self):
253 def set_weight(self, weight):
255 self.rs.set_weight(weight)
257 def get_output(self):
259 score = self.weight * self.rs.unprotected_evaluate(
None)
260 output[
"_TotalScore"] = str(score)
261 output[
"ExcludedVolumeSphere_" + self.label] = str(score)
265 return self.weight * self.rs.unprotected_evaluate(
None)
268 """Enforce ideal Helix dihedrals and bonds for a selection at resolution 0"""
275 @param hierarchy the root node
276 @param selection_tuple (start, stop, molname, copynum=0)
279 self.mdl = hierarchy.get_model()
283 start = selection_tuple[0]
284 stop = selection_tuple[1]
285 mol = selection_tuple[2]
287 if len(selection_tuple)>3:
288 copy_index = selection_tuple[3]
291 residue_indexes=range(start,stop+1))
292 ps = sel.get_selected_particles(with_representation=
False)
296 self.rs.add_restraint(self.r)
297 print(
'Created helix %s.%i.%i-%i with %i dihedrals and %i bonds'%(
298 mol,copy_index,start,stop,
299 self.get_number_of_bonds(),self.get_number_of_dihedrals()))
300 def set_label(self, label):
303 def get_weight(self):
306 def add_to_model(self):
309 def get_restraint(self):
312 def set_weight(self, weight):
314 self.rs.set_weight(weight)
316 def get_number_of_bonds(self):
317 return self.r.get_number_of_bonds()
319 def get_number_of_dihedrals(self):
320 return self.r.get_number_of_dihedrals()
323 return self.weight * self.rs.unprotected_evaluate(
None)
325 def get_output(self):
327 score = self.evaluate()
328 output[
"_TotalScore"] = str(score)
329 output[
"HelixRestraint_" + self.label] = str(score)
333 """ Add bond restraint between pair of consecutive
334 residues/beads to enforce the stereochemistry.
336 def __init__(self, objects, distance=3.78, strength=10.0, jitter=None):
338 @param objects Objects to restrain
339 @param distance Resting distance for restraint
340 @param strength Bond constant
341 @param jitter Defines the +- added to the optimal distance in the harmonic well restraint
342 used to increase the tolerance
346 self.m = particles[0].get_model()
359 (distance - jitter, distance + jitter), strength)
364 raise ValueError(
"wrong length of pair")
367 raise TypeError(
"%s is not a residue" % p)
370 print(
"ResidueBondRestraint: adding a restraint between %s %s" % (pair[0].get_name(), pair[1].get_name()))
371 self.rs.add_restraint(
376 def set_label(self, label):
378 self.rs.set_name(label)
379 for r
in self.rs.get_restraints():
382 def add_to_model(self):
385 def get_restraint(self):
388 def set_weight(self, weight):
390 self.rs.set_weight(weight)
392 def get_excluded_pairs(self):
393 return self.pairslist
395 def get_output(self):
397 score = self.weight * self.rs.unprotected_evaluate(
None)
398 output[
"_TotalScore"] = str(score)
399 output[
"ResidueBondRestraint_" + self.label] = str(score)
404 """Add angular restraint between triplets of consecutive
405 residues/beads to enforce the stereochemistry.
407 def __init__(self, objects, anglemin=100.0, anglemax=140.0, strength=10.0):
410 self.m = particles[0].get_model()
418 (pi * anglemin / 180.0,
419 pi * anglemax / 180.0),
425 raise ValueError(
"wrong length of triplet")
428 raise TypeError(
"%s is not a residue" % p)
431 print(
"ResidueAngleRestraint: adding a restraint between %s %s %s" % (triplet[0].get_name(), triplet[1].get_name(), triplet[2].get_name()))
432 self.rs.add_restraint(
440 def set_label(self, label):
442 self.rs.set_name(label)
443 for r
in self.rs.get_restraints():
446 def add_to_model(self):
449 def get_restraint(self):
452 def set_weight(self, weight):
454 self.rs.set_weight(weight)
456 def get_excluded_pairs(self):
457 return self.pairslist
459 def get_output(self):
461 score = self.weight * self.rs.unprotected_evaluate(
None)
462 output[
"_TotalScore"] = str(score)
463 output[
"ResidueAngleRestraint_" + self.label] = str(score)
468 """Add dihedral restraints between quadruplet of consecutive
469 residues/beads to enforce the stereochemistry.
470 Give as input a string of "C" and "T", meaning cys (0+-40) or trans (180+-40)
471 dihedral. The length of the string must be \#residue-3.
472 Without the string, the dihedral will be assumed trans.
474 def __init__(self, objects, stringsequence=None, strength=10.0):
477 self.m = particles[0].get_model()
484 if stringsequence
is None:
485 stringsequence =
"T" * (len(particles) - 3)
490 raise ValueError(
"wrong length of quadruplet")
493 raise TypeError(
"%s is not a residue" % p)
496 dihedraltype = stringsequence[n]
497 if dihedraltype ==
"C":
501 (pi * anglemin / 180.0,
502 pi * anglemax / 180.0),
504 print(
"ResidueDihedralRestraint: adding a CYS restraint between %s %s %s %s" % (quadruplet[0].get_name(), quadruplet[1].get_name(),
505 quadruplet[2].get_name(), quadruplet[3].get_name()))
506 if dihedraltype ==
"T":
507 anglemin = 180 - 70.0
508 anglemax = 180 + 70.0
510 (pi * anglemin / 180.0,
511 pi * anglemax / 180.0),
513 print(
"ResidueDihedralRestraint: adding a TRANS restraint between %s %s %s %s" % (quadruplet[0].get_name(), quadruplet[1].get_name(),
514 quadruplet[2].get_name(), quadruplet[3].get_name()))
515 self.rs.add_restraint(
521 self.pairslist.append(
523 self.pairslist.append(
526 def set_label(self, label):
528 self.rs.set_name(label)
529 for r
in self.rs.get_restraints():
532 def add_to_model(self):
535 def get_restraint(self):
538 def set_weight(self, weight):
540 self.rs.set_weight(weight)
542 def get_excluded_pairs(self):
543 return self.pairslist
545 def get_output(self):
547 score = self.weight * self.rs.unprotected_evaluate(
None)
548 output[
"_TotalScore"] = str(score)
549 output[
"ResidueDihedralRestraint_" + self.label] = str(score)
553 """Experimental, requires isd_emxl for now"""
563 raise ValueError(
"IMP.isd_emxl is needed")
568 self.particles = IMP.pmi.tools.select_by_tuple(
572 self.m = representation.prot.get_model()
576 self.anglfilename = IMP.isd_emxl.get_data_path(
"CAAngleRestraint.dat")
577 self.dihefilename = IMP.isd_emxl.get_data_path(
578 "CADihedralRestraint.dat")
579 self.nativeness = nativeness
580 self.kt_caff = kt_caff
586 if len(self.particles) != len(ssstring):
587 print(len(self.particles), len(ssstring))
588 print(
"SecondaryStructure: residue range and SS string incompatible")
589 self.ssstring = ssstring
591 (bondrslist, anglrslist, diherslist,
592 pairslist) = self.get_CA_force_field()
593 self.pairslist = pairslist
596 self.anglrs.add_restraints(anglrslist)
597 self.dihers.add_restraints(diherslist)
598 self.bondrs.add_restraints(bondrslist)
600 def set_label(self, label):
603 def add_to_model(self):
608 def get_CA_force_field(self):
614 for res
in range(0, len(self.particles) - 1):
616 ps = self.particles[res:res + 2]
619 br = self.get_distance_restraint(ps[0], ps[1], 3.78, 416.0)
620 br.set_name(
'Bond_restraint')
621 bondrslist.append(br)
623 for res
in range(0, len(self.particles) - 4):
628 ps = self.particles[res:res + 5]
631 score_dih] = self.read_potential_dihedral(
632 self.ssstring[res:res + 4],
638 dr = IMP.isd_emxl.CADihedralRestraint(
647 dr.set_name(
'Dihedral restraint')
648 diherslist.append(dr)
650 for res
in range(0, len(self.particles) - 2):
651 ps = self.particles[res:res + 3]
652 [psi, score_ang] = self.read_potential_angle(
653 self.ssstring[res:res + 2],
True)
656 dr = IMP.isd_emxl.CAAngleRestraint(
662 dr.set_name(
'Angle restraint')
663 anglrslist.append(dr)
664 return (bondrslist, anglrslist, diherslist, pairslist)
666 def read_potential_dihedral(self, string, mix=False):
671 for i
in range(0, 36):
672 phi0.append(i * 10.0 / 180.0 * pi)
673 phi1.append(i * 10.0 / 180.0 * pi)
674 for j
in range(0, 36):
675 score_dih.append(0.0)
678 f = open(self.dihefilename,
'r')
679 for line
in f.readlines():
680 riga = (line.strip()).split()
681 if (len(riga) == 4
and riga[0] == string):
682 ii = int(float(riga[1]) / 10.0)
683 jj = int(float(riga[2]) / 10.0)
684 score_dih[ii * len(phi0) + jj] = - \
685 self.kt_caff * self.log(float(riga[3]))
690 for i
in range(0, 36):
691 for j
in range(0, 36):
693 f = open(self.dihefilename,
'r')
694 for line
in f.readlines():
695 riga = (line.strip()).split()
696 if (len(riga) == 4
and riga[0] == string):
697 ii = int(float(riga[1]) / 10.0)
698 jj = int(float(riga[2]) / 10.0)
699 counts[ii * len(phi0) + jj] += self.nativeness * \
701 if (len(riga) == 4
and riga[0] ==
"-----"):
702 ii = int(float(riga[1]) / 10.0)
703 jj = int(float(riga[2]) / 10.0)
704 counts[ii * len(phi0) + jj] += (1.0 - self.nativeness) * \
707 for i
in range(len(counts)):
708 score_dih[i] = -self.kt_caff * self.log(counts[i])
709 return [phi0, phi1, score_dih]
711 def read_potential_angle(self, string, mix=False):
715 for i
in range(0, 180):
716 psi.append(i / 180.0 * pi)
717 score_ang.append(0.0)
720 f = open(self.anglfilename,
'r')
721 for line
in f.readlines():
722 riga = (line.strip()).split()
723 if (len(riga) == 3
and riga[0] == string):
725 score_ang[ii] = -self.kt_caff * self.log(float(riga[2]))
730 for i
in range(0, 180):
733 f = open(self.anglfilename,
'r')
734 for line
in f.readlines():
735 riga = (line.strip()).split()
736 if (len(riga) == 3
and riga[0] == string):
738 counts[ii] += self.nativeness * float(riga[2])
739 if (len(riga) == 3
and riga[0] ==
"---"):
741 counts[ii] += (1.0 - self.nativeness) * float(riga[2])
743 for i
in range(0, 180):
744 score_ang[i] = -self.kt_caff * self.log(counts[i])
745 return [psi, score_ang]
747 def get_excluded_pairs(self):
748 return self.pairslist
750 def get_restraint(self):
752 tmprs.add_restraint(self.anglrs)
753 tmprs.add_restraint(self.dihers)
754 tmprs.add_restraint(self.bondrs)
757 def get_distance_restraint(self, p0, p1, d0, kappa):
763 def get_output(self):
765 score_angle = self.anglrs.unprotected_evaluate(
None)
766 score_dihers = self.dihers.unprotected_evaluate(
None)
767 score_bondrs = self.bondrs.unprotected_evaluate(
None)
768 output[
"_TotalScore"] = str(score_angle + score_dihers + score_bondrs)
770 output[
"SecondaryStructure_Angles_" + self.label] = str(score_angle)
771 output[
"SecondaryStructure_Dihedrals_" +
772 self.label] = str(score_dihers)
773 output[
"SecondaryStructure_Bonds_" + self.label] = str(score_bondrs)
778 """Add harmonic restraints between all pairs
780 def __init__(self, hierarchy, selection_tuples=None, resolution=1,
781 strength=0.01, dist_cutoff=10.0, ca_only=
True):
783 @param hierarchy Root hierarchy to select from
784 @param selection_tuples Selecting regions for the restraint [[start,stop,molname,copy_index=0],...]
785 @param resolution Resolution for applying restraint
786 @param strength Bond strength
787 @param dist_cutoff Cutoff for making restraints
788 @param ca_only Selects only CAlphas. Only matters if resolution=0.
792 self.m = hierarchy.get_model()
793 for st
in selection_tuples:
799 hierarchy, molecule=st[2],
800 residue_indexes=range(st[0],st[1]+1),
801 copy_index=copy_index)
804 hierarchy, molecule=st[2],
805 residue_indexes=range(st[0],st[1]+1),
806 copy_index=copy_index,
808 particles+=sel.get_selected_particles()
816 for r
in self.rs.get_restraints():
817 a1,a2 = r.get_inputs()
820 print(
'ElasticNetwork: created',self.rs.get_number_of_restraints(),
'restraints')
822 def set_label(self, label):
824 self.rs.set_name(label)
825 for r
in self.rs.get_restraints():
828 def add_to_model(self):
831 def get_restraint(self):
834 def set_weight(self, weight):
836 self.rs.set_weight(weight)
838 def get_excluded_pairs(self):
839 return self.pairslist
841 def get_output(self):
843 score = self.weight * self.rs.unprotected_evaluate(
None)
844 output[
"_TotalScore"] = str(score)
845 output[
"ElasticNetworkRestraint_" + self.label] = str(score)
850 """ Enable CHARMM force field """
856 enable_nonbonded=
True,
858 zone_nonbonded=
False):
859 """Setup the CHARMM restraint on a selection. Expecting atoms.
860 @param root The node at which to apply the restraint
861 @param ff_temp The temperature of the force field
862 @param zone_ps Create a zone around this set of particles
863 Automatically includes the entire residue (incl. backbone)
864 @param zone_size The size for looking for neighbor residues
865 @param enable_nonbonded Allow the repulsive restraint
866 @param enable_bonded Allow the bonded restraint
867 @param zone_nonbonded EXPERIMENTAL: exclude from nonbonded all sidechains that aren't in zone!
870 kB = (1.381 * 6.02214) / 4184.0
872 self.mdl = root.get_model()
874 self.nonbonded_rs =
IMP.RestraintSet(self.mdl, 1.0 / (kB * ff_temp),
'NONBONDED')
881 topology = ff.create_topology(root)
882 topology.apply_default_patches()
883 topology.setup_hierarchy(root)
884 if zone_ps
is not None:
885 limit_to_ps=IMP.pmi.topology.get_particles_within_zone(
889 entire_residues=
True,
890 exclude_backbone=
False)
894 self.ps = limit_to_ps
898 print(
'init bonds score',r.unprotected_evaluate(
None))
899 self.bonds_rs.add_restraint(r)
901 ff.add_well_depths(root)
903 atoms = IMP.atom.get_by_type(root,IMP.atom.ATOM_TYPE)
906 if (zone_ps
is not None)
and zone_nonbonded:
907 print(
'stereochemistry: zone_nonbonded is True')
909 backbone_types=[
'C',
'N',
'CB',
'O']
911 for n
in backbone_types])
912 backbone_atoms = sel.get_selected_particles()
914 sel_ps=IMP.pmi.topology.get_particles_within_zone(
918 entire_residues=
True,
919 exclude_backbone=
True)
929 self.nbl.add_pair_filter(r.get_full_pair_filter())
932 self.nonbonded_rs.add_restraint(pr)
933 print(
'CHARMM is set up')
935 def set_label(self, label):
937 self.rs.set_name(label)
938 for r
in self.rs.get_restraints():
941 def add_to_model(self):
945 def get_restraint(self):
948 def get_close_pair_container(self):
951 def set_weight(self, weight):
953 self.rs.set_weight(weight)
955 def get_output(self):
957 bonds_score = self.weight * self.bonds_rs.unprotected_evaluate(
None)
958 nonbonded_score = self.weight * self.nonbonded_rs.unprotected_evaluate(
None)
959 score=bonds_score+nonbonded_score
960 output[
"_TotalScore"] = str(score)
961 output[
"CHARMM_BONDS"] = str(bonds_score)
962 output[
"CHARMM_NONBONDED"] = str(nonbonded_score)
967 """Add bonds and improper dihedral restraints for the CBs
970 self, rnums, representation, selection_tuple, strength=10.0, kappa=1.0,
971 jitter_angle=0.0, jitter_improper=0.0):
975 ca-cb is a constraint, no restraint needed
980 self.m = representation.prot.get_model()
990 ca, cb = self.get_ca_cb(
991 IMP.pmi.tools.select_by_tuple(representation,
992 (rnum, rnum,
'chainA'), resolution=0))
996 ca_prev, cb_prev = self.get_ca_cb(
997 IMP.pmi.tools.select_by_tuple(representation,
998 (rnum - 1, rnum - 1,
'chainA'), resolution=0))
999 ca_next, cb_next = self.get_ca_cb(
1000 IMP.pmi.tools.select_by_tuple(representation,
1001 (rnum + 1, rnum + 1,
'chainA'), resolution=0))
1035 self.rset_angles.add_restraint(ar13u)
1036 self.rset_angles.add_restraint(ar13l)
1042 self.rset_angles.add_restraint(ar23u)
1043 self.rset_angles.add_restraint(ar23l)
1044 if not nter
and not cter:
1068 self.rset_angles.add_restraint(idru)
1069 self.rset_angles.add_restraint(idrl)
1070 self.rs.add_restraint(self.rset_bonds)
1071 self.rs.add_restraint(self.rset_angles)
1073 def get_ca_cb(self, atoms):
1078 ca = a.get_particle()
1080 cb = a.get_particle()
1083 def set_label(self, label):
1085 self.rs.set_name(label)
1086 for r
in self.rs.get_restraints():
1089 def add_to_model(self):
1092 def get_restraint(self):
1095 def set_weight(self, weight):
1096 self.weight = weight
1097 self.rs.set_weight(weight)
1099 def get_excluded_pairs(self):
1100 return self.pairslist
1102 def get_output(self):
1104 score = self.weight * self.rs.unprotected_evaluate(
None)
1105 output[
"_TotalScore"] = str(score)
1106 output[
"PseudoAtomicRestraint_" + self.label] = str(score)
1110 """Create harmonic restraints between the reference and (transformed) clones.
1111 @note Wraps IMP::core::TransformedDistancePairScore with an IMP::core::Harmonic
1121 @param references Can be one of the following inputs:
1122 IMP Hierarchy, PMI System/State/Molecule/TempResidue, or a list/set of them
1123 @param clones_list List of lists of the above
1124 @param transforms Transforms moving each selection to the first selection
1125 @param label Label for output
1126 @param strength The elastic bond strength
1127 @param ca_only Optionally select so only CAlpha particles are used
1131 self.mdl = refs[0].get_model()
1135 if len(clones_list)!=len(transforms):
1136 raise Exception(
'Error: There should be as many clones as transforms')
1139 for tmp_clones,trans
in zip(clones_list,transforms):
1141 if len(clones)!=len(refs):
1142 raise Exception(
"Error: len(references)!=len(clones)")
1144 for p0,p1
in zip(refs,clones):
1148 p1.get_particle_index()])
1149 self.rs.add_restraint(r)
1150 print(
'created symmetry network with',self.rs.get_number_of_restraints(),
'restraints')
1152 def set_label(self, label):
1154 self.rs.set_name(label)
1155 for r
in self.rs.get_restraints():
1158 def add_to_model(self):
1161 def get_restraint(self):
1164 def set_weight(self, weight):
1165 self.weight = weight
1166 self.rs.set_weight(weight)
1168 def get_excluded_pairs(self):
1169 return self.pairslist
1171 def get_output(self):
1173 score = self.weight * self.rs.unprotected_evaluate(
None)
1174 output[
"SymmetryRestraint_" + self.label] = str(score)
1175 output[
"_TotalScore"] = str(score)
1180 """ This class creates a restraint between the termini two polypeptides, to simulate the sequence connectivity. """
1185 disorderedlength=
False,
1190 @param nterminal - single PMI2 Hierarchy/molecule at the nterminal
1191 @param cterminal - single PMI2 Hierarchy/molecule at the cterminal
1192 @param scale Scale the maximal distance between the beads by this factor when disorderedlength is False.
1193 The maximal distance is calculated as ((float(residuegap) + 1.0) * 3.6) * scale.
1194 @param disorderedlength - This flag uses either disordered length
1195 calculated for random coil peptides (True) or zero
1196 surface-to-surface distance between beads (False)
1197 as optimal distance for the sequence connectivity
1199 @param upperharmonic - This flag uses either harmonic (False)
1200 or upperharmonic (True) in the intra-pair
1201 connectivity restraint.
1202 @param resolution - The resolution to connect things at - only used if you pass PMI objects
1203 @param label - A string to identify this restraint in the output/stat file
1209 nter_lastres=ssn[-1][1]
1210 cter_firstres=ssc[0][0]
1211 self.m = nter_lastres.get_model()
1215 optdist = (3.6) * scale
1222 pt0 = nter_lastres.get_particle()
1223 pt1 = cter_firstres.get_particle()
1226 print(
"Adding fusion connectivity restraint between", pt0.get_name(),
" and ", pt1.get_name(),
'of distance', optdist)
1227 self.rs.add_restraint(r)
1229 def set_label(self, label):
1232 def get_weight(self):
1235 def add_to_model(self):
1238 def get_restraint(self):
1241 def set_weight(self, weight):
1242 self.weight = weight
1243 self.rs.set_weight(weight)
1245 def get_output(self):
1247 score = self.weight * self.rs.unprotected_evaluate(
None)
1248 output[
"_TotalScore"] = str(score)
1249 output[
"FusionRestraint_" + self.label] = str(score)
1253 return self.weight * self.rs.unprotected_evaluate(
None)
1260 """Restrain the dihedral between planes defined by three particles.
1262 This restraint is useful for restraining the twist of a string of
1263 more or less identical rigid bodies, so long as the curvature is mild.
1266 def __init__(self, particle_triplets, angle=0., k=1., label=None,
1269 @param particle_triplets List of lists of 3 particles. Each triplet
1270 defines a plane. Dihedrals of adjacent planes
1272 @param angle Angle of plane dihedral in degrees
1273 @param k Strength of restraint
1274 @param label Label for output
1275 @param weight Weight of restraint
1276 @note Particles defining planes should be rigid and more or less
1277 parallel for proper behavior
1279 model = particle_triplets[0][0].get_model()
1280 super(PlaneDihedralRestraint, self).
__init__(model, label=label,
1283 angle = pi * angle / 180.
1285 for i, t1
in enumerate(particle_triplets[:-1]):
1286 t2 = particle_triplets[i + 1]
1287 q1 = [t1[1], t1[0], t2[0], t2[1]]
1288 q2 = [t1[2], t1[0], t2[0], t2[2]]
1289 self.rs.add_restraint(
1291 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.
Create a restraint between consecutive TempResidue objects or an entire PMI Molecule object...
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.
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.