18from io
import StringIO
20from random
import random
22kB = (1.381 * 6.02214) / 4184.0
27 def __init__(self, cont, md, n_md_steps):
30 self.n_md_steps = n_md_steps
37 for i
in range(self.cont.get_number_of_particles()):
38 p = self.cont.get_particle(i)
40 self.oldcoords.append(d.get_coordinates())
42 def propose_move(self, prob):
43 self.md.optimize(self.n_md_steps)
46 for i
in range(self.cont.get_number_of_particles()):
47 p = self.cont.get_particle(i)
51 d.set_coordinates(self.oldcoords[i])
53 def get_number_of_steps(self):
54 return self.n_md_steps
56 def set_number_of_steps(self, nsteps):
57 self.n_md_steps = nsteps
63 def __init__(self, model):
66 def add_mover(self, mv):
72 def set_return_best(self, thing):
75 def set_move_probability(self, thing):
79 pot = self.m.evaluate(
False)
81 kin = self.mv.md.get_kinetic_energy()
84 def metropolis(self, old, new):
87 print(
": old %f new %f deltaE %f new_epot: %f"
88 % (old, new, deltaE, self.m.evaluate(
False)), end=
' ')
93 return exp(-deltaE / kT) > random()
95 def optimize(self, nsteps):
97 print(
"=== new MC call")
100 for i
in range(nsteps):
101 print(
"MC step %d " % i, end=
' ')
103 self.mv.md.assign_velocities(self.kT / kB)
105 old = self.get_energy()
107 self.mv.propose_move(1)
109 new = self.get_energy()
110 if self.metropolis(old, new):
120 def get_number_of_forward_steps(self):
126 """nonspecific methods used across all shared function objects.
128 - Their name starts with the name of the parent function (e.g.
130 - they don't store anything in the class, but instead
131 return all created objects.
132 Exceptions: the model, which is self._m
133 the statistics class, which is self.stat
134 - they store what they have to store in the model (e.g. restraints)
135 - they don't print out anything except for long routines (e.g. NOE
137 - the prior RestraintSet is added to the model when it is created, so
138 that when it is passed to another function, it is not added twice.
144 def set_checklevel(self, value):
147 def set_loglevel(self, value):
150 def m(self, name, *args, **kw):
151 "wrapper to call methods of m"
152 func = getattr(self._m, name)
153 return func(*args, **kw)
156 "moves to wd and creates model"
162 self, initpdb, top, par, selector, pairscore,
163 ff_temp=300.0, disulfides=None, representation='custom'):
164 """creates a CHARMM protein representation.
165 creates the charmm force field, bonded and nonbonded.
166 - initpdb: initial structure in pdb format
167 - top is a CHARMM top.lib, read if representation=='custom' (default)
168 - par is a CHARMM par.lib
169 - selector is an instance of
170 one of the selectors of IMP.atom, for example
171 IMP.atom.NonWaterNonHydrogenPDBSelector().
172 - pairscore is an instance of a Pair Score to score the interaction
173 between two atoms. usually, it's either
174 LennardJonesDistancePairScore(0,1) or
175 RepulsiveDistancePairScore(0,1)
176 - ff_temp is the temperature at which the force field should be
178 - disulfides: if not None, a list of tuples corresponding to residue
179 numbers that should be cross-linked. Residues should be
180 cysteines, and residue numbering should start at 0.
181 - representation: 'full' : all-atom CHARMM force field
182 'heavy': heavy atom CHARMM forcefield with polar H
183 'calpha': only C alphas, ball and stick model with
184 bondlength 3.78 angstrom, beads at VdW
185 contact, and harmonic restraint between
187 'custom' (default) : read given CHARMM top and par
189 Returns: prot, ff, rsb, rs
191 - ff: the force field
192 - rsb: the RestraintSet on bonded interactions
193 - rs: the RestraintSet on nonbonded interactions. Both are weighted
198 if not prot.get_is_valid(
True):
199 raise ValueError(
"invalid hierarchy!")
200 if representation ==
'custom':
203 elif representation ==
'heavy':
205 elif representation ==
'full':
207 elif representation ==
'calpha':
210 raise NotImplementedError(representation)
211 if representation ==
'calpha':
212 print(
"setting up simplified C alpha force field")
219 for chain
in prot.get_children():
220 residues = [(chain.get_child(i), chain.get_child(i + 1))
221 for i
in range(chain.get_number_of_children() - 1)]
222 residues = [(i.get_child(0).get_particle(),
223 j.get_child(0).get_particle())
224 for (i, j)
in residues]
225 pairs.extend(residues)
245 rsb.add_restraint(br)
246 rsb.set_weight(1.0 / (kB * ff_temp))
248 nonbonded_pair_filter.set_bonds(bonds)
251 print(
"setting up CHARMM forcefield")
256 topology = ff.create_topology(prot)
261 topology.apply_default_patches()
264 s = topology.get_segment(0)
265 dis = ff.get_patch(
'DISU')
266 for (i, j)
in disulfides:
269 r0 = s.get_residue(i)
270 r1 = s.get_residue(j)
272 r0.set_patched(
False)
274 r1.set_patched(
False)
276 print(
"added disulfide bridge between cysteines %d and %d"
283 topology.setup_hierarchy(prot)
295 ff.add_lennard_jones_types(prot)
296 nonbonded_pair_filter = r.get_pair_filter()
310 nbl.add_pair_filter(nonbonded_pair_filter)
315 return prot, ff, rsb, rs
318 """sets up a Scale particle to the initial default value. It can
319 optionally be constrained between two positive bounds, or else its
320 range is 0 to infinity.
325 scale.set_lower(lower)
327 scale.set_upper(upper)
331 """given a list of scales, returns a RestraintSet('prior') with weight
332 1.0 that contains a list of vonMisesKappaJeffreysRestraint on each
333 scale. If argument prior_rs is used, add them to that RestraintSet
338 prior_rs.set_weight(1.0)
344 """given a list of scales, returns a RestraintSet('prior') with weight
345 1.0 that contains a list of JeffreysRestraint on each scale.
346 If argument prior_rs is used, add them to that RestraintSet instead.
352 prior_rs.add_restraint(jr)
356 """given a list of scales, returns a RestraintSet('prior') with weight
357 1.0 that contains a list of vonMisesKappaConjugateRestraint on each
358 scale. If argument prior_rs is used, add them to that RestraintSet
361 if not (0 <= R <= c):
362 raise ValueError(
"parameters R and c should satisfy 0 <= R <= c")
366 prior_rs.add_restraint(
371 """scans the prot hierarchy and tries to find atom = (resno, name)
372 assumes that resno follows the same numbering as the sequence.
373 Stores already found atoms for increased speed.
375 if not hasattr(self,
'__memoized'):
376 self.__memoized = {prot: {}}
378 return self.__memoized[prot][atom]
383 residue_index=atom[0],
385 ).get_selected_particles()
387 print(
"found multiple atoms for atom %d %s!" % atom)
391 print(
"atom %d %s not found" % atom)
393 self.__memoized[prot][atom] = p0
398 Sets up a vonMises torsion angle restraint using the given kappa
399 particle as concentration parameter. Returns the restraint.
400 data is a list of observations.
406 Sets up a vonMises torsion angle restraint using the given kappa
407 particle as concentration parameter. Returns the restraint.
408 data is (mean, standard deviation).
410 raise NotImplementedError
414 Sets up a lognormal distance restraint using the given sigma and gamma.
415 Returns the restraint.
416 assumes atoms = (atom1, atom2)
417 where atom1 is (resno, atomname) and resno is the residue sequence
435 """Reads an ambiguous NOE restraint. contributions is a list of
436 (atom1, atom2) pairs, where atom1 is (resno, atomname). Sets up a
437 lognormal distance restraint using the given sigma and gamma.
438 Returns the restraint.
441 pairs = [(self.
find_atom(i, prot).get_particle(),
442 self.
find_atom(j, prot).get_particle())
for (i, j)
in
447 pairs, sigma, gamma, distance ** (-6))
451 self, prot, seqfile, tblfile, name='NOE', prior_rs=None,
452 bounds_sigma=(1.0, 0.1, 100), bounds_gamma=(1.0, 0.1, 100),
453 verbose=
True, sequence_match=(1, 1)):
454 """read TBL file and store NOE restraints, using one sigma and one
455 gamma for the whole dataset. Creates the necessary uninformative
457 - prot: protein hierarchy
458 - seqfile: a file with 3-letter sequence
459 - tblfile: a TBL file with the restraints
460 - name: an optional name for the restraintset
461 - prior_rs: when not None, add new sigma and gamma to this
462 RestraintSet instance.
463 - bounds_sigma or gamma: tuple of (initial value, lower, upper bound)
464 bounds can be -1 to set to default range [0,+inf]
465 - verbose: be verbose (default True)
466 - sequence_match : (noe_start, sequence_start)
467 Returns: data_rs, prior_rs, sigma, gamma
471 print(
"Prior for the NOE Scales")
479 seqfile, first_residue_number=sequence_match[1])
480 tblr = IMP.isd.TBLReader.TBLReader(sequence,
481 sequence_match=sequence_match)
482 restraints = tblr.read_distances(tblfile,
'NOE')[
'NOE']
483 for i, restraint
in enumerate(restraints):
484 if verbose
and i % 100 == 0:
485 print(
"\r%d" % i, end=
' ')
490 if len(restraint[0]) > 1:
493 restraint[1], sigma, gamma)
496 restraint[1], sigma, gamma)
499 print(
"\r%d NOE restraints read" % i)
502 return rs, prior_rs, sigma, gamma
505 verbose=True, sequence_match=(1, 1)):
506 """read TBL file and store NOE restraints, using the marginal of the
507 lognormal with one sigma and one gamma, for the whole dataset.
508 - prot: protein hierarchy
509 - seqfile: a file with 3-letter sequence
510 - tblfile: a TBL file with the restraints
511 - name: an optional name for the restraintset
512 - verbose: be verbose (default True)
513 - sequence_match : (noe_start, sequence_start)
520 seqfile, first_residue_number=sequence_match[1])
521 tblr = IMP.isd.TBLReader.TBLReader(sequence,
522 sequence_match=sequence_match)
523 restraints = tblr.read_distances(tblfile,
'NOE')[
'NOE']
525 for i, restraint
in enumerate(restraints):
526 if verbose
and i % 100 == 0:
527 print(
"\r%d" % i, end=
' ')
533 pairs = [(self.
find_atom(i, prot).get_particle(),
534 self.
find_atom(j, prot).get_particle())
for (i, j)
in
537 ln.add_contribution(pairs, restraint[4])
540 print(
"\r%d NOE contributions added" % (len(restraints)))
545 """read TBL file and store lognormal restraints, using the marginal
546 of the lognormal with one sigma and gamma=1, for the whole dataset.
547 - prot: protein hierarchy
548 - seqfile: a file with 3-letter sequence
549 - tblfile: a TBL file with the restraints
550 - name: an optional name for the restraintset
551 - verbose: be verbose (default True)
558 tblr = IMP.isd.TBLReader.TBLReader(sequence)
559 restraints = tblr.read_distances(tblfile,
'HBond')[
'HBond']
561 for i, restraint
in enumerate(restraints):
562 if verbose
and i % 100 == 0:
563 print(
"\r%d" % i, end=
' ')
569 pairs = [(self.
find_atom(i, prot).get_particle(),
570 self.
find_atom(j, prot).get_particle())
for (i, j)
in
573 ln.add_contribution(pairs, restraint[4])
576 print(
"\r%d Hbond contributions added" % (len(restraints)))
580 sequence_match=(1, 1), name=
'TALOS', prior_rs=
None,
581 bounds_kappa=(1.0, 0.1, 10), verbose=
True,
582 prior=
'jeffreys', keep_all=
False):
583 """read TALOS dihedral angle data, and create restraints for phi/psi
584 torsion angles, along with the prior for kappa, which is a scale for
585 the whole dataset, compare to 1/sigma**2 in the NOE case.
586 - prot: protein hierarchy
587 - seqfile: a file with 3-letter sequence
588 - talos_data: either a file (pred.tab), or a folder (pred/) in which
589 all files in the form res???.tab can be found. If
590 possible, try to provide the folder, as statistics are
591 more accurate in that case.
592 - fulldata : either True or False, whether the data is the full TALOS
593 output (predAll.tab or pred/ folder), or just the averages
595 - sequence_match : (talos_no, sequence_no) to adjust for different
597 - name: an optional name for the restraintset
598 - prior_rs: when not None, add new kappa(s) to this RestraintSet
600 - bounds_kappa: tuple of (initial value, lower, upper bound)
601 bounds can be -1 to set to default range [0,+inf]
602 - verbose: be verbose (default True)
603 - prior: either 'jeffreys' or a tuple (R,c), which signifies to use the
604 conjugate prior of the von Mises restraint, with parameters R
605 and c. Good values are R=0 and c=10. Default: jeffreys prior.
606 - keep_all: in case of a folder for 'talos_data', whether to keep
607 candidates marked as 'outliers' by TALOS, or to include
609 Returns: data_rs, prior_rs, kappa
614 print(
"Prior for von Mises Kappa")
619 print(
"reading data")
622 seqfile, first_residue_no=sequence_match[1])
625 sequence,
True, keep_all, sequence_match=sequence_match)
626 if os.path.isdir(talos_data):
628 for i, res
in enumerate(glob(os.path.join(talos_data,
630 if verbose
and i % 100:
631 print(
"\r%d" % i, end=
' ')
636 talosr.read(talos_data)
640 sequence,
False, keep_all, sequence_match=sequence_match)
641 talosr.read(talos_data)
643 data = talosr.get_data()
645 print(
"\rread dihedral data for %d residues" % len(data))
646 print(
"creating restraints")
648 for resno, datum
in data.items():
649 phidata = datum[
'phi']
650 psidata = datum[
'psi']
660 avgR.append(r.get_R0())
665 avgR.append(r.get_R0())
671 avgR.append(r.get_R0())
676 avgR.append(r.get_R0())
678 print(
"%s Restraints created. Average R0: %f"
679 % (len(avgR), sum(avgR) / float(len(avgR))))
680 return rs, prior_rs, kappa
683 self, prot, profilefile, name='SAXS',
684 ff_type=IMP.saxs.HEAVY_ATOMS):
685 """read experimental SAXS profile and apply restraint the standard
687 Returns: a restraintset and the experimental profile
693 rs.add_restraint(saxs_restraint)
694 return rs, saxs_profile
696 def _setup_md(self, prot, temperature=300.0, thermostat='berendsen',
697 coupling=500, md_restraints=None, timestep=1.0,
698 recenter=1000, momentum=1000):
699 """setup molecular dynamics
700 - temperature: target temperature
701 - thermostat: one of 'NVE', rescale_velocities',
702 'berendsen', 'langevin'
703 - coupling: coupling constant (tau (fs) for berendsen,
704 gamma (/fs) for langevin)
705 - md_restraints: if not None, specify the terms of the energy to be
706 used during the md steps via a list of restraints.
707 - timestep: in femtoseconds.
708 - recenter: recenter the molecule every so many steps (Langevin only)
709 - momentum: remove angular momentum every so many steps
711 Returns: an instance of md and an instance of an OptimizerState (the
712 thermostat), or None if NVE.
716 md.assign_velocities(temperature)
717 md.set_time_step(timestep)
718 if thermostat ==
'NVE':
720 elif thermostat ==
'rescale_velocities':
723 md.add_optimizer_state(os)
724 elif thermostat ==
'berendsen':
727 md.add_optimizer_state(os)
730 md.add_optimizer_state(mom)
731 elif thermostat ==
'langevin':
734 md.add_optimizer_state(os)
739 raise NotImplementedError(thermostat)
742 md.set_restraints(md_restraints)
746 def _setup_normal_mover(self, particle, floatkey, stepsize):
747 """setup NormalMover to move particle's floatkey attribute
748 by a gaussian with standard deviation 'stepsize'
749 Returns: mover instance.
755 def _setup_md_mover(self, md, particles, temperature, n_md_steps=10):
756 """setup MDMover using md and particles.
758 - particles: particles to move, usually the leaves of the protein
760 - n_md_steps: number of md steps to perform on each move
761 Returns: mover instance.
765 return IMP.atom.MDMover(cont, md, temperature, n_md_steps)
767 def _setup_mc(self, mover, temperature=300.0, mc_restraints=None):
768 """setup monte carlo using a certain mover.
769 - mover: mover to use, NormalMover or MDMover usually.
770 - temperature: target temperature.
771 - mc_restraints: if not None, list of restraints for the metropolis
773 Returns: mc instance.
779 mc.set_kt(kB * temperature)
781 mc.set_return_best(
False)
784 mc.set_restraints(mc_restraints)
788 self, prot, temperature=300.0, gamma=0.01, n_md_steps=10,
789 md_restraints=None, mc_restraints=None, timestep=1.0,
790 sd_threshold=0.0, sd_stepsize=0.01, sd_maxsteps=100):
791 """setup hybrid monte-carlo on protein. Uses basin hopping with
792 steepest descent minimization.
793 - prot: protein hierarchy.
794 - temperature: target temperature.
795 - gamma: coupling constant for langevin (/fs)
796 - n_md_steps: number of md steps per mc step
797 - md_restraints: if not None, specify the terms of the energy to be
798 used during the md steps.
799 - mc_restraints: if not None, use these energy terms for the metropolis
801 - timestep: time step for md, in femtoseconds.
802 - sd_threshold: stop steepest descent after energy difference drops
804 - sd_stepsize: stepsize to use for the steepest descent, in angstrom.
805 - sd_maxsteps: maximum number of steps for steepest descent
806 Returns: hmc, mdmover, md and OptimizerState (thermostat)
808 raise NotImplementedError
809 md, os = self._setup_md(prot, temperature=temperature,
810 thermostat=
'langevin', coupling=gamma,
811 md_restraints=md_restraints, timestep=timestep)
813 mdmover = self._setup_md_mover(md, particles, temperature, n_md_steps)
814 hmc = self._setup_mc(mdmover, temperature, mc_restraints)
816 sd.set_threshold(sd_threshold)
817 sd.set_step_size(sd_stepsize)
818 hmc.set_local_optimizer(sd)
819 hmc.set_local_steps(sd_maxsteps)
820 hmc.set_use_basin_hopping(
True)
821 return hmc, mdmover, md, os
824 self, prot, temperature=300.0, n_md_steps=100, md_restraints=None,
825 mc_restraints=None, timestep=1.0):
826 """setup hybrid monte-carlo on protein. Uses NVE MD and tries the full
827 - prot: protein hierarchy.
828 - temperature: target temperature.
829 - coupling: coupling constant (tau (fs) for berendsen,
830 gamma (/fs) for langevin)
831 - n_md_steps: number of md steps per mc step
832 - md_restraints: if not None, specify the terms of the energy to be
833 used during the md steps.
834 - mc_restraints: if not None, use these energy terms for the metropolis
836 - timestep: time step for md, in femtoseconds.
837 - sd_threshold: stop steepest descent after energy difference drops
839 - sd_stepsize: stepsize to use for the steepest descent, in angstrom.
840 - sd_maxsteps: maximum number of steps for steepest descent
841 Returns: hmc, mdmover and md
843 prot = self._p[
'prot']
844 md, os = self._setup_md(prot, temperature=temperature,
845 thermostat=
'NVE', coupling=
None, timestep=1.0,
846 md_restraints=md_restraints)
850 mdmover = PyMDMover(cont, md, n_md_steps)
854 mc.add_mover(mdmover)
856 mc.set_kt(kB * temperature)
858 mc.set_return_best(
False)
860 mc.set_move_probability(1.0)
861 return mc, mdmover, md
864 mc_restraints=None, nm_stepsize=0.1):
865 """sets up monte carlo on nuisance, at a certain target temperature,
866 optionally using a certain set of restraints only.
867 - nuis: nuisance particle
868 - temperature: target temperature
869 - mc_restraints: optional set of restraints from which the energy
870 should be drawn instead of the energy of the complete system.
871 - floatkey: the floatkey to move.
872 - nm_stepsize: the stepsize of the normal mover
873 Returns: mc instance, nm instance.
875 nm = self._setup_normal_mover(nuis, nuis.get_nuisance_key(),
877 mc = self._setup_mc(nm, temperature, mc_restraints)
880 def _mc_and_update_nm(self, nsteps, mc, nm, stats_key,
881 adjust_stepsize=True):
882 """run mc using a normal mover on a single particle,
883 update stepsize and store nsteps, acceptance and stepsize in the
884 statistics instance self.stat by using the key stats_key.
888 naccept = mc.get_number_of_forward_steps()
890 self.stat.increment_counter(stats_key, nsteps)
892 accept = float(naccept) / nsteps
893 self.stat.update(stats_key,
'acceptance', accept)
894 stepsize = nm.get_sigma()
895 self.stat.update(stats_key,
'stepsize', stepsize)
898 if 0.4 < accept < 0.6:
904 nm.set_sigma(stepsize * 2 * accept)
906 def _hmc_and_update_md(self, nsteps, hmc, mv, stats_key,
907 adjust_stepsize=True):
908 """run hmc, update stepsize and print statistics. Updates number of MD
909 steps to reach a target acceptance between 0.4 and 0.6, sends
910 statistics to self.stat. MD steps are always at least 10 and at
914 naccept = hmc.get_number_of_forward_steps()
915 self.stat.increment_counter(stats_key, nsteps)
916 accept = float(naccept) / nsteps
917 self.stat.update(stats_key,
'acceptance', accept)
918 mdsteps = mv.get_number_of_steps()
919 self.stat.update(stats_key,
'n_md_steps', mdsteps)
921 if 0.4 < accept < 0.6:
923 mdsteps = int(mdsteps * 2 ** (accept - 0.5))
928 mv.set_nsteps(mdsteps)
931 """returns a string corresponding to the pdb structure of hierarchy
936 return output.getvalue()
938 def get_netcdf(self, prot):
939 raise NotImplementedError
942 temperature=300.0, prot_coordinates=None):
943 """updates statistics for md simulation: target temp, kinetic energy,
944 kinetic temperature, writes coordinates and increments counter.
945 - md_key: stats md key
946 - nsteps: number of steps performed.
947 - md_instance: instance of the MolecularDynamics class.
948 - temperature: target temperature
949 - prot_coordinates: protein coordinates to be passed to the stats
950 class, (should be a string)
952 self.stat.update(md_key,
'target_temp', temperature)
953 kinetic = md_instance.get_kinetic_energy()
954 self.stat.update(md_key,
'E_kinetic', kinetic)
955 self.stat.update(md_key,
'instant_temp',
956 md_instance.get_kinetic_temperature(kinetic))
957 self.stat.update_coordinates(md_key,
'protein', prot_coordinates)
958 self.stat.increment_counter(md_key, nsteps)
961 """shortcut for a frequent series of operations on MC simulations'
962 statistics. Creates an entry for acceptance, stepsize and one
963 coordinate set printed in the statistics file.
966 mc_key = stat.add_category(name=name)
968 stat.add_entry(mc_key, entry=Entry(
'temperature',
'%10G',
None))
969 stat.add_entry(mc_key, entry=Entry(
'acceptance',
'%10G',
None))
970 stat.add_entry(mc_key, entry=Entry(
'stepsize',
'%10G',
None))
972 stat.add_entry(mc_key, entry=Entry(coord,
'%10G',
None))
974 stat.add_entry(mc_key, name=
'counter')
978 """shortcut for a frequent series of operations on MD simulations'
979 statistics. Creates an entry for target temp, instantaneous temp,
980 kinetic energy, and one set of coordinates called 'protein' by
984 md_key = stat.add_category(name=name)
986 stat.add_entry(md_key, entry=Entry(
'target_temp',
'%10G',
None))
987 stat.add_entry(md_key, entry=Entry(
'instant_temp',
'%10G',
None))
988 stat.add_entry(md_key, entry=Entry(
'E_kinetic',
'%10G',
None))
990 stat.add_coordinates(md_key, coord)
992 stat.add_entry(md_key, name=
'counter')
996 """shortcut for a frequent series of operations on HMC simulations'
997 statistics. Adds acceptance, number of MD steps and a trajectory for
1001 hmc_key = stat.add_category(name=name)
1003 stat.add_entry(hmc_key, entry=Entry(
'temperature',
'%10G',
None))
1004 stat.add_entry(hmc_key, entry=Entry(
'acceptance',
'%10G',
None))
1005 stat.add_entry(hmc_key, entry=Entry(
'n_md_steps',
'%10G',
None))
1006 stat.add_entry(hmc_key, entry=Entry(
'E_kinetic',
'%10G',
None))
1008 stat.add_coordinates(hmc_key, coord)
1010 stat.add_entry(hmc_key, name=
'counter')
1014 """rescale the velocities of a bunch of particles having vx vy and vz
1020 p.set_value(k, p.get_value(k) * factor)
Class for storing model, its restraints, constraints, and particles.
Base class for all optimizers.
Class to handle individual particles of a Model object.
Object used to hold a set of restraints.
Maintains temperature during molecular dynamics.
Score the bond based on a UnaryFunction,.
A decorator for a particle which has bonds.
static Bonded setup_particle(Model *m, ParticleIndex pi)
static bool get_is_setup(const IMP::ParticleAdaptor &p)
CHARMM force field parameters.
Enforce CHARMM stereochemistry on the given Hierarchy.
Hierarchies get_by_type(Hierarchy mhd, GetByType t)
Gather all the molecular particles of a certain level in the hierarchy.
Maintains temperature during molecular dynamics.
Simple molecular dynamics simulator.
Removes rigid translation and rotation from the particles.
A decorator for a residue.
Select hierarchy particles identified by the biological name.
A filter that excludes bonds, angles and dihedrals.
Maintains temperature during molecular dynamics by velocity scaling.
Return all close unordered pairs of particles taken from the SingletonContainer.
Store a list of ParticleIndexPairs.
Store a list of ParticleIndexes.
Applies a PairScore to each Pair in a list.
Applies a SingletonScore to each Singleton in a list.
Harmonic function (symmetric about the mean)
Modify a set of continuous variables using a normal distribution.
A simple steepest descent optimizer.
A decorator for a particle with x,y,z coordinates and a radius.
A decorator for a particle with x,y,z coordinates.
Ambiguous NOE distance restraint between a number of pairs of particles.
Apply a lognormal distance restraint between two particles.
Apply an NOE distance restraint between two particles.
Apply an NOE distance restraint between two particles.
static Scale setup_particle(Model *m, ParticleIndex pi)
reads a TALOS file, or a TALOS folder, and stores the data
phi/psi dihedral restraint between four particles, using data from TALOS.
nonspecific methods used across all shared function objects.
init_model_HBonds_marginal(self, prot, seqfile, tblfile, name='NOE', verbose=True)
read TBL file and store lognormal restraints, using the marginal of the lognormal with one sigma and ...
get_pdb(self, prot)
returns a string corresponding to the pdb structure of hierarchy prot.
init_simulation_setup_nuisance_mc(self, nuis, temperature=300.0, mc_restraints=None, nm_stepsize=0.1)
sets up monte carlo on nuisance, at a certain target temperature, optionally using a certain set of r...
init_model_NOEs(self, prot, seqfile, tblfile, name='NOE', prior_rs=None, bounds_sigma=(1.0, 0.1, 100), bounds_gamma=(1.0, 0.1, 100), verbose=True, sequence_match=(1, 1))
read TBL file and store NOE restraints, using one sigma and one gamma for the whole dataset.
init_model_base(self, wd)
moves to wd and creates model
init_model_charmm_protein_and_ff(self, initpdb, top, par, selector, pairscore, ff_temp=300.0, disulfides=None, representation='custom')
creates a CHARMM protein representation.
rescale_velocities(self, particles, factor)
rescale the velocities of a bunch of particles having vx vy and vz floatkeys
init_simulation_setup_protein_hmc_nve(self, prot, temperature=300.0, n_md_steps=100, md_restraints=None, mc_restraints=None, timestep=1.0)
setup hybrid monte-carlo on protein.
init_model_jeffreys_kappa(self, scales, prior_rs=None)
given a list of scales, returns a RestraintSet('prior') with weight 1.0 that contains a list of vonMi...
init_model_ambiguous_NOE_restraint(self, prot, contributions, distance, sigma, gamma)
Reads an ambiguous NOE restraint.
m(self, name, *args, **kw)
wrapper to call methods of m
init_model_standard_SAXS_restraint(self, prot, profilefile, name='SAXS', ff_type=IMP.saxs.HEAVY_ATOMS)
read experimental SAXS profile and apply restraint the standard way (like foxs) Returns: a restraints...
init_model_vonMises_restraint_mean(self, prot, atoms, data, kappa)
Sets up a vonMises torsion angle restraint using the given kappa particle as concentration parameter.
init_model_conjugate_kappa(self, scales, c, R, prior_rs=None)
given a list of scales, returns a RestraintSet('prior') with weight 1.0 that contains a list of vonMi...
find_atom(self, atom, prot)
scans the prot hierarchy and tries to find atom = (resno, name) assumes that resno follows the same n...
do_md_protein_statistics(self, md_key, nsteps, md_instance, temperature=300.0, prot_coordinates=None)
updates statistics for md simulation: target temp, kinetic energy, kinetic temperature,...
init_model_setup_scale(self, default, lower=None, upper=None)
sets up a Scale particle to the initial default value.
init_model_NOEs_marginal(self, prot, seqfile, tblfile, name='NOE', verbose=True, sequence_match=(1, 1))
read TBL file and store NOE restraints, using the marginal of the lognormal with one sigma and one ga...
init_model_TALOS(self, prot, seqfile, talos_data, fulldata=True, sequence_match=(1, 1), name='TALOS', prior_rs=None, bounds_kappa=(1.0, 0.1, 10), verbose=True, prior='jeffreys', keep_all=False)
read TALOS dihedral angle data, and create restraints for phi/psi torsion angles, along with the prio...
init_stats_add_mc_category(self, stat, name='mc', coord='particle')
shortcut for a frequent series of operations on MC simulations' statistics.
init_stats_add_md_category(self, stat, name='md', coord='protein')
shortcut for a frequent series of operations on MD simulations' statistics.
init_simulation_setup_protein_hmc_hopper(self, prot, temperature=300.0, gamma=0.01, n_md_steps=10, md_restraints=None, mc_restraints=None, timestep=1.0, sd_threshold=0.0, sd_stepsize=0.01, sd_maxsteps=100)
setup hybrid monte-carlo on protein.
init_model_NOE_restraint(self, prot, atoms, distance, sigma, gamma)
Sets up a lognormal distance restraint using the given sigma and gamma.
init_model_jeffreys(self, scales, prior_rs=None)
given a list of scales, returns a RestraintSet('prior') with weight 1.0 that contains a list of Jeffr...
init_stats_add_hmc_category(self, stat, name='hmc', coord='protein')
shortcut for a frequent series of operations on HMC simulations' statistics.
init_model_vonMises_restraint_full(self, atoms, data, kappa)
Sets up a vonMises torsion angle restraint using the given kappa particle as concentration parameter.
Conjugate prior for the concentration parameter of a von Mises distribution.
Jeffreys prior for the concentration parameter of a von Mises distribution.
Calculate score based on fit to SAXS profile.
Bond create_custom_bond(Bonded a, Bonded b, Float length, Float stiffness=-1)
Connect the two wrapped particles by a custom bond.
Functionality for loading, creating, manipulating and scoring atomic structures.
Residue get_residue(Atom d, bool nothrow=false)
Return the Residue containing this atom.
Atoms get_psi_dihedral_atoms(Residue rd)
Return the atoms comprising the psi dihedral.
Atoms get_phi_dihedral_atoms(Residue rd)
Return the atoms comprising the phi dihedral.
void write_pdb(const Selection &mhd, TextOutput out, unsigned int model=1)
CHARMMParameters * get_heavy_atom_CHARMM_parameters()
Hierarchy read_pdb(TextInput input, Model *model, PDBSelector *selector=get_default_pdb_selector(), bool select_first_model=true)
Read all the molecules in the first model of the PDB file.
CHARMMParameters * get_all_atom_CHARMM_parameters()
Hierarchies get_leaves(const Selection &h)
Various classes to hold sets of particles.
Basic functionality that is expected to be used by a wide variety of IMP users.
Classes to handle ISD statistics files.
Classes to handle TALOS files or folders.
Classes to handle TBL files.
read_sequence_file(filename, first_residue_number=1)
read sequence of ONE chain, 1-letter or 3-letter, returns dict of no:3-letter code.
Inferential scoring building on methods developed as part of the Inferential Structure Determination ...
Support for small angle X-ray scattering (SAXS) data.
void set_log_level(LogLevel l)
Set the current global log level.
void set_check_level(CheckLevel tf)
Control runtime checks in the code.
ParticleIndexes get_indexes(const ParticlesTemp &ps)
Get the indexes from a list of particles.