3 """@namespace IMP.pmi.representation
4 Representation of the system.
7 from __future__
import print_function
16 from math
import pi, sqrt
18 from operator
import itemgetter
26 class Representation(object):
30 Set up the representation of all proteins and nucleic acid macromolecules.
32 Create the molecular hierarchies, representation,
33 sequence connectivity for the various involved proteins and
34 nucleic acid macromolecules:
36 Create a protein, DNA or RNA, represent it as a set of connected balls of appropriate
37 radii and number of residues, PDB at given resolution(s), or ideal helices.
39 How to use the SimplifiedModel class (typical use):
41 see test/test_hierarchy_contruction.py
45 1) Create a chain of helices and flexible parts
47 c_1_119 =self.add_component_necklace("prot1",1,119,20)
48 c_120_131 =self.add_component_ideal_helix("prot1",resolutions=[1,10],resrange=(120,131))
49 c_132_138 =self.add_component_beads("prot1",[(132,138)])
50 c_139_156 =self.add_component_ideal_helix("prot1",resolutions=[1,10],resrange=(139,156))
51 c_157_174 =self.add_component_beads("prot1",[(157,174)])
52 c_175_182 =self.add_component_ideal_helix("prot1",resolutions=[1,10],resrange=(175,182))
53 c_183_194 =self.add_component_beads("prot1",[(183,194)])
54 c_195_216 =self.add_component_ideal_helix("prot1",resolutions=[1,10],resrange=(195,216))
55 c_217_250 =self.add_component_beads("prot1",[(217,250)])
58 self.set_rigid_body_from_hierarchies(c_120_131)
59 self.set_rigid_body_from_hierarchies(c_139_156)
60 self.set_rigid_body_from_hierarchies(c_175_182)
61 self.set_rigid_body_from_hierarchies(c_195_216)
63 clist=[c_1_119,c_120_131,c_132_138,c_139_156,c_157_174,c_175_182,c_183_194,c_195_216,
66 self.set_chain_of_super_rigid_bodies(clist,2,3)
68 self.set_super_rigid_bodies(["prot1"])
72 def __init__(self, m, upperharmonic=True, disorderedlength=True):
75 @param upperharmonic This flag uses either harmonic (False)
76 or upperharmonic (True) in the intra-pair
77 connectivity restraint.
78 @param disorderedlength This flag uses either disordered length
79 calculated for random coil peptides (True) or zero
80 surface-to-surface distance between beads (False)
81 as optimal distance for the sequence connectivity
92 self.upperharmonic = upperharmonic
93 self.disorderedlength = disorderedlength
94 self.rigid_bodies = []
95 self.fixed_rigid_bodies = []
96 self.fixed_floppy_bodies = []
97 self.floppy_bodies = []
103 self.super_rigid_bodies = []
104 self.output_level =
"low"
107 self.maxtrans_rb = 2.0
108 self.maxrot_rb = 0.04
109 self.maxtrans_srb = 2.0
110 self.maxrot_srb = 0.2
111 self.rigidbodiesarefixed =
False
112 self.maxtrans_fb = 3.0
113 self.resolution = 10.0
114 self.bblenght = 100.0
118 self.representation_is_modified =
False
119 self.unmodeledregions_cr_dict = {}
120 self.sortedsegments_cr_dict = {}
122 self.connected_intra_pairs = []
125 self.sequence_dict = {}
126 self.hier_geometry_pairs = {}
132 self.hier_representation = {}
133 self.hier_resolution = {}
136 self.reference_structures = {}
139 self.linker_restraints_dict = {}
140 self.threetoone = {
'ALA':
'A',
'ARG':
'R', 'ASN': 'N', 'ASP': 'D',
141 'CYS':
'C',
'GLU':
'E',
'GLN':
'Q',
'GLY':
'G',
142 'HIS':
'H',
'ILE':
'I',
'LEU':
'L',
'LYS':
'K',
143 'MET':
'M',
'PHE':
'F',
'PRO':
'P',
'SER':
'S',
144 'THR':
'T',
'TRP':
'W',
'TYR':
'Y',
'VAL':
'V',
'UNK':
'X'}
146 self.onetothree = dict((v, k)
for k, v
in self.threetoone.items())
150 def set_label(self, label):
153 def create_component(self, name, color=0.0):
155 protein_h.set_name(name)
156 self.hier_dict[name] = protein_h
157 self.hier_representation[name] = {}
158 self.hier_db.add_name(name)
159 self.prot.add_child(protein_h)
160 self.color_dict[name] = color
161 self.elements[name] = []
165 def add_component_name(self, *args, **kwargs):
166 IMP.pmi.tools.print_deprecation_warning(
167 "add_component_name",
169 self.create_component(*args, **kwargs)
171 def get_component_names(self):
172 return list(self.hier_dict.keys())
177 Add the primary sequence for a single component.
179 @param name Human-readable name of the component
180 @param filename Name of the FASTA file
181 @param id Identifier of the sequence in the FASTA file header
182 (if not provided, use `name` instead)
184 from Bio
import SeqIO
185 handle = open(filename,
"rU")
186 record_dict = SeqIO.to_dict(SeqIO.parse(handle,
"fasta"))
191 length = len(record_dict[id].seq)
193 raise KeyError(
"id %s not found in fasta file" % id)
195 self.sequence_dict[name] = str(record_dict[id].seq).replace(
"*",
"")
198 self.sequence_dict[name]=offs_str+self.sequence_dict[name]
200 self.elements[name].append((length, length,
" ",
"end"))
202 def autobuild_model(self, name, pdbname, chain,
203 resolutions=
None, resrange=
None,
206 color=
None, pdbresrange=
None, offset=0,
207 show=
False, isnucleicacid=
False,
210 if not beadsize
is None:
211 IMP.pmi.tools.print_deprecation_warning(
215 self.representation_is_modified =
True
219 color = self.color_dict[name]
221 self.color_dict[name] = color
223 if resolutions
is None:
225 print(
"autobuild_model: constructing %s from pdb %s and chain %s" % (name, pdbname, str(chain)))
234 t.get_children()[0].get_children()[0]).
get_index()
236 t.get_children()[0].get_children()[-1]).
get_index()
242 if name
in self.sequence_dict:
243 resrange = (1, len(self.sequence_dict[name]))
245 resrange = (start + offset, end + offset)
247 start = resrange[0] - offset
248 end = resrange[1] - offset
265 for n, g
in enumerate(gaps):
269 print(
"autobuild_model: constructing fragment %s from pdb" % (str((first, last))))
271 chain, resolutions=resolutions,
272 color=color, cacenters=
True,
273 resrange=(first, last),
274 offset=offset, isnucleicacid=isnucleicacid)
275 elif g[2] ==
"gap" and n > 0:
276 print(
"autobuild_model: constructing fragment %s as a bead" % (str((first, last))))
277 parts = self.hier_db.get_particles_at_closest_resolution(
284 first+offset, last+offset, missingbeadsize, incoord=xyz)
286 elif g[2] ==
"gap" and n == 0:
288 print(
"autobuild_model: constructing fragment %s as a bead" % (str((first, last))))
290 first+offset, last+offset, missingbeadsize, incoord=xyznter)
296 def autobuild_pdb_and_intervening_beads(self, *args, **kwargs):
297 IMP.pmi.tools.print_deprecation_warning(
298 "autobuild_pdb_and_intervening_beads",
300 r = self.autobuild_model(*args, **kwargs)
304 resrange=
None, offset=0, cacenters=
True, show=
False,
305 isnucleicacid=
False, readnonwateratoms=
False,
306 read_ca_cb_only=
False):
308 Add a component that has an associated 3D structure in a PDB file.
310 Reads the PDB, and constructs the fragments corresponding to contiguous
313 @return a list of hierarchies.
315 @param name (string) the name of the component
316 @param pdbname (string) the name of the PDB file
317 @param chain (string or integer) can be either a string (eg, "A")
318 or an integer (eg, 0 or 1) in case you want
319 to get the corresponding chain number in the PDB.
320 @param resolutions (integers) a list of integers that corresponds
321 to the resolutions that have to be generated
322 @param color (float from 0 to 1) the color applied to the
323 hierarchies generated
324 @param resrange (tuple of integers): the residue range to extract
325 from the PDB. It is a tuple (beg,end). If not specified,
326 all residues belonging to the specified chain are read.
327 @param offset (integer) specifies the residue index offset to be
328 applied when reading the PDB (the FASTA sequence is
329 assumed to start from residue 1, so use this parameter
330 if the PDB file does not start at residue 1)
331 @param cacenters (boolean) if True generates resolution=1 beads
332 centered on C-alpha atoms.
333 @param show (boolean) print out the molecular hierarchy at the end.
334 @param isnucleicacid (boolean) use True if you're reading a PDB
336 @param readnonwateratoms (boolean) if True fixes some pathological PDB.
337 @param read_ca_cb_only (boolean) if True, only reads CA/CB
340 self.representation_is_modified =
True
343 color = self.color_dict[name]
344 protein_h = self.hier_dict[name]
354 if type(chain) == str:
362 t.get_children()[0].get_children()[0]).
get_index()
364 t.get_children()[0].get_children()[-1]).
get_index()
376 if not resrange
is None:
377 if resrange[0] > start:
379 if resrange[1] < end:
382 if not isnucleicacid:
386 residue_indexes=list(range(
389 atom_type=IMP.atom.AT_CA)
395 residue_indexes=list(range(
398 atom_type=IMP.atom.AT_P)
400 ps = sel.get_selected_particles()
402 raise ValueError(
"%s no residue found in pdb %s chain %s that overlaps with the queried stretch %s-%s" \
403 % (name, pdbname, str(chain), str(resrange[0]), str(resrange[1])))
411 start = start + offset
414 self.elements[name].append(
415 (start, end, pdbname.split(
"/")[-1] +
":" + chain,
"pdb"))
418 resolutions, isnucleicacid, c0, protein_h,
"pdb", color)
429 def add_component_ideal_helix(
437 self.representation_is_modified =
True
438 from math
import pi, cos, sin
440 protein_h = self.hier_dict[name]
443 color = self.color_dict[name]
447 self.elements[name].append((start, end,
" ",
"helix"))
449 for n, res
in enumerate(range(start, end + 1)):
450 if name
in self.sequence_dict:
452 rtstr = self.onetothree[
453 self.sequence_dict[name][res-1]]
473 x = 2.3 * cos(n * 2 * pi / 3.6)
474 y = 2.3 * sin(n * 2 * pi / 3.6)
475 z = 6.2 / 3.6 / 2 * n * 2 * pi / 3.6
484 resolutions,
False, c0, protein_h,
"helix", color)
492 def add_component_beads(self, name, ds, colors=None, incoord=None):
493 """ add beads to the representation
494 @name the component name
495 @ds a list of tuples corresponding to the residue ranges of the beads
496 @colors a list of colors associated to the beads
497 @incoord the coordinate tuple correspoding to the position of the beads
501 self.representation_is_modified =
True
503 protein_h = self.hier_dict[name]
506 colors = [self.color_dict[name]]
509 for n, dss
in enumerate(ds):
510 ds_frag = (dss[0], dss[1])
511 self.elements[name].append((dss[0], dss[1],
" ",
"bead"))
513 if ds_frag[0] == ds_frag[1]:
515 if name
in self.sequence_dict:
517 rtstr = self.onetothree[
518 self.sequence_dict[name][ds_frag[0]-1]]
525 h.set_name(name +
'_%i_bead' % (ds_frag[0]))
526 prt.set_name(name +
'_%i_bead' % (ds_frag[0]))
530 h.set_name(name +
'_%i-%i_bead' % (ds_frag[0], ds_frag[1]))
531 prt.set_name(name +
'_%i-%i_bead' % (ds_frag[0], ds_frag[1]))
532 h.set_residue_indexes(list(range(ds_frag[0], ds_frag[1] + 1)))
533 resolution = len(h.get_residue_indexes())
534 if "Beads" not in self.hier_representation[name]:
536 root.set_name(
"Beads")
537 self.hier_representation[name][
"Beads"] = root
538 protein_h.add_child(root)
539 self.hier_representation[name][
"Beads"].add_child(h)
541 for kk
in range(ds_frag[0], ds_frag[1] + 1):
542 self.hier_db.add_particles(name, kk, resolution, [h])
565 ptem.set_radius(radius)
568 radius = 0.8 * (3.0 / 4.0 / pi * volume) ** (1.0 / 3.0)
570 ptem.set_radius(radius)
572 if not tuple(incoord)
is None:
573 ptem.set_coordinates(incoord)
578 self.floppy_bodies.append(prt)
587 Generates a string of beads with given length.
589 self.representation_is_modified =
True
597 [(chunk[0], chunk[-1])], colors=colors,incoord=incoord)
601 self, name, hierarchies=
None, selection_tuples=
None,
603 resolution=0.0, num_components=10,
604 inputfile=
None, outputfile=
None,
607 covariance_type=
'full', voxel_size=1.0,
609 sampled_points=1000000, num_iter=100,
611 multiply_by_total_mass=
True,
613 intermediate_map_fn=
None,
614 density_ps_to_copy=
None,
615 use_precomputed_gaussians=
False):
617 Sets up a Gaussian Mixture Model for this component.
618 Can specify input GMM file or it will be computed.
619 @parm name component name
620 @param hierarchies set up GMM for some hierarchies
621 @param selection_tuples (list of tuples) example (first_residue,last_residue,component_name)
622 @param particles set up GMM for particles directly
623 @param resolution usual PMI resolution for selecting particles from the hierarchies
624 @param inputfile read the GMM from this file
625 @param outputfile fit and write the GMM to this file (text)
626 @param outputmap after fitting, create GMM density file (mrc)
627 @param kernel_type for creating the intermediate density (points are sampled to make GMM). Options are IMP.em.GAUSSIAN, IMP.em.SPHERE, and IMP.em.BINARIZED_SPHERE
628 @param covariance_type for fitting the GMM. options are 'full', 'diagonal' and 'spherical'
629 @param voxel_size for creating the intermediate density map and output map.
630 lower number increases accuracy but also rasterizing time grows
631 @param out_hier_name name of the output density hierarchy
632 @param sampled_points number of points to sample. more will increase accuracy and fitting time
633 @param num_iter num GMM iterations. more will increase accuracy and fitting time
634 @param multiply_by_total_mass multiply the weights of the GMM by this value (only works on creation!)
635 @param transform for input file only, apply a transformation (eg for multiple copies same GMM)
636 @param intermediate_map_fn for debugging, this will write the itermediate (simulated) map
637 @param density_ps_to_copy in case you already created the appropriate GMM (eg, for beads)
638 @param use_precomputed_gaussians Set this flag and pass fragments - will use roughly spherical Gaussian setup
646 self.representation_is_modified =
True
648 protein_h = self.hier_dict[name]
649 if "Densities" not in self.hier_representation[name]:
651 root.set_name(
"Densities")
652 self.hier_representation[name][
"Densities"] = root
653 protein_h.add_child(root)
656 fragment_particles = []
657 if not particles
is None:
658 fragment_particles += particles
659 if not hierarchies
is None:
661 self, resolution=resolution,
662 hierarchies=hierarchies)
663 if not selection_tuples
is None:
664 for st
in selection_tuples:
665 fragment_particles += IMP.pmi.tools.select_by_tuple(
666 self, tupleselection=st,
667 resolution=resolution,
668 name_is_ambiguous=
False)
671 density_particles = []
674 inputfile, density_particles,
676 elif density_ps_to_copy:
677 for ip
in density_ps_to_copy:
683 density_particles.append(p)
684 elif use_precomputed_gaussians:
685 if len(fragment_particles) == 0:
686 print(
"add_component_density: no particle was selected")
688 for p
in fragment_particles:
691 raise Exception(
"The particles you selected must be Fragments and XYZs")
693 pos=
IMP.core.XYZ(self.m,p.get_particle_index()).get_coordinates()
698 raise Exception(
"We haven't created a bead file for",nres,
"residues")
705 if len(fragment_particles) == 0:
706 print(
"add_component_density: no particle was selected")
709 density_particles = IMP.isd.gmm_tools.sample_and_fit_to_particles(
718 multiply_by_total_mass,
724 s0.set_name(out_hier_name)
725 self.hier_representation[name][
"Densities"].add_child(s0)
727 for nps, p
in enumerate(density_particles):
729 p.set_name(s0.get_name() +
'_gaussian_%i' % nps)
732 def get_component_density(self, name):
733 return self.hier_representation[name][
"Densities"]
736 selection_tuples=
None,
741 '''Decorates all specified particles as Gaussians directly.
742 @param name component name
743 @param hierarchies set up GMM for some hierarchies
744 @param selection_tuples (list of tuples) example (first_residue,last_residue,component_name)
745 @param particles set up GMM for particles directly
746 @param resolution usual PMI resolution for selecting particles from the hierarchies
747 @param intermediate_map_fn for debugging, this will write the itermediate (simulated) map
753 from math
import sqrt
754 self.representation_is_modified =
False
756 if particles
is None:
757 fragment_particles = []
759 fragment_particles = particles
761 if not hierarchies
is None:
763 self, resolution=resolution,
764 hierarchies=hierarchies)
766 if not selection_tuples
is None:
767 for st
in selection_tuples:
768 fragment_particles += IMP.pmi.tools.select_by_tuple(
769 self, tupleselection=st,
770 resolution=resolution,
771 name_is_ambiguous=
False)
773 if len(fragment_particles) == 0:
774 print(
"add all atom densities: no particle was selected")
778 print(
'setting up all atom gaussians num_particles',len(fragment_particles))
779 for n,p
in enumerate(fragment_particles):
787 print(
'setting up particle',p.get_name(),
" as individual gaussian particle")
789 if not output_map
is None:
790 print(
'writing map to', output_map)
798 Make a copy of a hierarchy and append it to a component.
801 self.representation_is_modified =
True
802 protein_h = self.hier_dict[name]
804 hierclone.set_name(hierclone.get_name() +
"_clone")
805 protein_h.add_child(hierclone)
806 outhier.append(hierclone)
812 for n, pmain
in enumerate(psmain):
818 self.hier_db.add_particles(
835 rmf_frame_number, rmf_component_name=
None,check_number_particles=
True):
836 '''Read and replace coordinates from an RMF file.
837 Replace the coordinates of particles with the same name.
838 It assumes that the RMF and the representation have the particles
840 @param component_name Component name
841 @param rmf_component_name Name of the component in the RMF file
842 (if not specified, use `component_name`)
847 prot = IMP.pmi.analysis.get_hier_from_rmf(
853 raise ValueError(
"cannot read hiearchy from rmf")
863 p, self.hier_dict.keys())
864 if not rmf_component_name
is None and protname == rmf_component_name:
866 elif rmf_component_name
is None and protname == component_name:
871 if check_number_particles:
872 if len(psrmf) != len(psrepr):
873 raise ValueError(
"%s cannot proceed the rmf and the representation don't have the same number of particles; "
874 "particles in rmf: %s particles in the representation: %s" % (str(component_name), str(len(psrmf)), str(len(psrepr))))
876 for n, prmf
in enumerate(psrmf):
877 prmfname = prmf.get_name()
878 preprname = psrepr[n].get_name()
880 raise ValueError(
"component %s cannot proceed if rigid bodies were initialized. Use the function before defining the rigid bodies" % component_name)
882 raise ValueError(
"component %s cannot proceed if rigid bodies were initialized. Use the function before defining the rigid bodies" % component_name)
884 if prmfname != preprname:
885 print(
"set_coordinates_from_rmf: WARNING rmf particle and representation particles have not the same name %s %s " % (prmfname, preprname))
894 If the root hierarchy does not exist, construct it.
896 if "Res:" + str(int(resolution))
not in self.hier_representation[name]:
898 root.set_name(name +
"_Res:" + str(int(resolution)))
899 self.hier_representation[name][
900 "Res:" + str(int(resolution))] = root
901 protein_h.add_child(root)
904 input_hierarchy, protein_h, type, color):
906 Generate all needed coarse grained layers.
908 @param name name of the protein
909 @param resolutions list of resolutions
910 @param protein_h root hierarchy
911 @param input_hierarchy hierarchy to coarse grain
912 @param type a string, typically "pdb" or "helix"
916 if (1
in resolutions)
or (0
in resolutions):
922 s1.set_name(
'%s_%i-%i_%s' % (name, start, end, type))
924 self.hier_representation[name][
"Res:1"].add_child(s1)
929 s0.set_name(
'%s_%i-%i_%s' % (name, start, end, type))
931 self.hier_representation[name][
"Res:0"].add_child(s0)
934 if not isnucleicacid:
937 atom_type=IMP.atom.AT_CA)
941 atom_type=IMP.atom.AT_P)
943 for p
in sel.get_selected_particles():
949 s0.add_child(resclone0)
950 self.hier_db.add_particles(
954 resclone0.get_children())
956 chil = resclone0.get_children()
969 s1.add_child(resclone1)
970 self.hier_db.add_particles(name, resindex, 1, [resclone1])
974 prt = resclone1.get_particle()
975 prt.set_name(
'%s_%i_%s' % (name, resindex, type))
997 for r
in resolutions:
998 if r != 0
and r != 1:
1004 chil = s.get_children()
1006 s0.set_name(
'%s_%i-%i_%s' % (name, start, end, type))
1010 self.hier_representation[name][
1011 "Res:" + str(int(r))].add_child(s0)
1020 prt.set_name(
'%s_%i_%s' % (name, first, type))
1022 prt.set_name(
'%s_%i_%i_%s' % (name, first, last, type))
1024 self.hier_db.add_particles(name, kk, r, [prt])
1045 Get the hierarchies at the given resolution.
1047 The map between resolution and hierarchies is cached to accelerate
1048 the selection algorithm. The cache is invalidated when the
1049 representation was changed by any add_component_xxx.
1052 if self.representation_is_modified:
1053 rhbr = self.hier_db.get_all_root_hierarchies_by_resolution(
1055 self.hier_resolution[resolution] = rhbr
1056 self.representation_is_modified =
False
1059 if resolution
in self.hier_resolution:
1060 return self.hier_resolution[resolution]
1062 rhbr = self.hier_db.get_all_root_hierarchies_by_resolution(
1064 self.hier_resolution[resolution] = rhbr
1068 self, max_translation=300., max_rotation=2.0 * pi,
1069 avoidcollision=
True, cutoff=10.0, niterations=100,
1071 excluded_rigid_bodies=
None,
1072 hierarchies_excluded_from_collision=
None):
1074 Shuffle configuration; used to restart the optimization.
1076 The configuration of the system is initialized by placing each
1077 rigid body and each bead randomly in a box with a side of
1078 `max_translation` angstroms, and far enough from each other to
1079 prevent any steric clashes. The rigid bodies are also randomly rotated.
1081 @param avoidcollision check if the particle/rigid body was
1082 placed close to another particle; uses the optional
1083 arguments cutoff and niterations
1084 @param bounding_box defined by ((x1,y1,z1),(x2,y2,z2))
1087 if excluded_rigid_bodies
is None:
1088 excluded_rigid_bodies = []
1089 if hierarchies_excluded_from_collision
is None:
1090 hierarchies_excluded_from_collision = []
1092 if len(self.rigid_bodies) == 0:
1093 print(
"shuffle_configuration: rigid bodies were not intialized")
1096 gcpf.set_distance(cutoff)
1098 hierarchies_excluded_from_collision_indexes = []
1104 hierarchies_excluded_from_collision_indexes += IMP.get_indexes([p])
1105 allparticleindexes = IMP.get_indexes(ps)
1107 if not bounding_box
is None:
1108 ((x1, y1, z1), (x2, y2, z2)) = bounding_box
1113 for h
in hierarchies_excluded_from_collision:
1117 allparticleindexes = list(
1118 set(allparticleindexes) - set(hierarchies_excluded_from_collision_indexes))
1120 print(hierarchies_excluded_from_collision)
1121 print(len(allparticleindexes),len(hierarchies_excluded_from_collision_indexes))
1123 for rb
in self.rigid_bodies:
1124 if rb
not in excluded_rigid_bodies:
1127 rbindexes = rb.get_member_particle_indexes()
1130 set(rbindexes) - set(hierarchies_excluded_from_collision_indexes))
1131 otherparticleindexes = list(
1132 set(allparticleindexes) - set(rbindexes))
1134 if len(otherparticleindexes)
is None:
1138 while niter < niterations:
1139 rbxyz = (rb.get_x(), rb.get_y(), rb.get_z())
1141 if not bounding_box
is None:
1159 gcpf.get_close_pairs(
1161 otherparticleindexes,
1167 print(
"shuffle_configuration: rigid body placed close to other %d particles, trying again..." % npairs)
1168 print(
"shuffle_configuration: rigid body name: " + rb.get_name())
1169 if niter == niterations:
1170 raise ValueError(
"tried the maximum number of iterations to avoid collisions, increase the distance cutoff")
1174 print(
'shuffling', len(self.floppy_bodies),
'floppy bodies')
1175 for fb
in self.floppy_bodies:
1180 fbindexes = IMP.get_indexes([fb])
1181 otherparticleindexes = list(
1182 set(allparticleindexes) - set(fbindexes))
1183 if len(otherparticleindexes)
is None:
1189 while niter < niterations:
1191 if not bounding_box
is None:
1206 gcpf.get_close_pairs(
1208 otherparticleindexes,
1214 print(
"shuffle_configuration: floppy body placed close to other %d particles, trying again..." % npairs)
1215 if niter == niterations:
1216 raise ValueError(
"tried the maximum number of iterations to avoid collisions, increase the distance cutoff")
1220 def set_current_coordinates_as_reference_for_rmsd(self, label="None"):
1224 self.reference_structures[label] = (
1228 def get_all_rmsds(self):
1231 for label
in self.reference_structures:
1233 current_coordinates = [
IMP.core.XYZ(p).get_coordinates()
1234 for p
in self.reference_structures[label][1]]
1235 reference_coordinates = self.reference_structures[label][0]
1236 if len(reference_coordinates) != len(current_coordinates):
1237 print(
"calculate_all_rmsds: reference and actual coordinates are not the same")
1240 current_coordinates,
1241 reference_coordinates)
1243 reference_coordinates,
1244 current_coordinates)
1248 reference_coordinates,
1249 current_coordinates)
1250 rmsds[label +
"_GlobalRMSD"] = rmsd_global
1251 rmsds[label +
"_RelativeDRMS"] = rmsd_relative
1254 def setup_component_geometry(self, name, color=None, resolution=1.0):
1256 color = self.color_dict[name]
1260 self.hier_geometry_pairs[name] = []
1261 protein_h = self.hier_dict[name]
1263 pbr = IMP.pmi.tools.sort_by_residues(pbr)
1265 for n
in range(len(pbr) - 1):
1266 self.hier_geometry_pairs[name].append((pbr[n], pbr[n + 1], color))
1269 self, name, resolution=10, scale=1.0):
1271 Generate restraints between contiguous fragments in the hierarchy.
1272 The linkers are generated at resolution 10 by default.
1279 protein_h = self.hier_dict[name]
1281 frs = self.hier_db.get_preroot_fragments_by_resolution(
1287 start = fr.get_children()[0]
1292 end = fr.get_children()[-1]
1298 SortedSegments.append((start, end, startres))
1299 SortedSegments = sorted(SortedSegments, key=itemgetter(2))
1302 for x
in range(len(SortedSegments) - 1):
1303 last = SortedSegments[x][1]
1304 first = SortedSegments[x + 1][0]
1311 residuegap = firstresn - lastresn - 1
1312 if self.disorderedlength
and (nreslast / 2 + nresfirst / 2 + residuegap) > 20.0:
1315 optdist = sqrt(5 / 3) * 1.93 * \
1316 (nreslast / 2 + nresfirst / 2 + residuegap) ** 0.6
1318 if self.upperharmonic:
1324 optdist = (0.0 + (float(residuegap) + 1.0) * 3.6) * scale
1325 if self.upperharmonic:
1331 pt0 = last.get_particle()
1332 pt1 = first.get_particle()
1335 print(
"Adding sequence connectivity restraint between", pt0.get_name(),
" and ", pt1.get_name(),
'of distance', optdist)
1336 sortedsegments_cr.add_restraint(r)
1337 self.linker_restraints_dict[
1338 "LinkerRestraint-" + pt0.get_name() +
"-" + pt1.get_name()] = r
1339 self.connected_intra_pairs.append((pt0, pt1))
1340 self.connected_intra_pairs.append((pt1, pt0))
1342 self.m.add_restraint(sortedsegments_cr)
1343 self.m.add_restraint(unmodeledregions_cr)
1344 self.linker_restraints.add_restraint(sortedsegments_cr)
1345 self.linker_restraints.add_restraint(unmodeledregions_cr)
1346 self.sortedsegments_cr_dict[name] = sortedsegments_cr
1347 self.unmodeledregions_cr_dict[name] = unmodeledregions_cr
1349 def optimize_floppy_bodies(self, nsteps, temperature=1.0):
1351 pts = IMP.pmi.tools.ParticleToSampleList()
1352 for n, fb
in enumerate(self.floppy_bodies):
1353 pts.add_particle(fb,
"Floppy_Bodies", 1.0,
"Floppy_Body_" + str(n))
1354 if len(pts.get_particles_to_sample()) > 0:
1356 print(
"optimize_floppy_bodies: optimizing %i floppy bodies" % len(self.floppy_bodies))
1359 print(
"optimize_floppy_bodies: no particle to optimize")
1361 def create_rotational_symmetry(self, maincopy, copies):
1363 self.representation_is_modified =
True
1364 ncopies = len(copies) + 1
1367 mainparticles = sel.get_selected_particles()
1369 for k
in range(len(copies)):
1375 copyparticles = sel.get_selected_particles()
1379 for n, p
in enumerate(mainparticles):
1381 pc = copyparticles[n]
1383 mainpurged.append(p)
1386 copypurged.append(pc)
1390 for n, p
in enumerate(mainpurged):
1393 print(
"setting " + p.get_name() +
" as reference for " + pc.get_name())
1399 self.m.add_score_state(c)
1403 def create_amyloid_fibril_symmetry(self, maincopy, axial_copies,
1404 longitudinal_copies, axis=(0, 0, 1), translation_value=4.8):
1407 self.representation_is_modified =
True
1410 protein_h = self.hier_dict[maincopy]
1413 for ilc
in range(-longitudinal_copies, longitudinal_copies + 1):
1414 for iac
in range(axial_copies):
1415 copyname = maincopy +
"_a" + str(ilc) +
"_l" + str(iac)
1416 self.add_component_name(copyname, 0.0)
1417 for hier
in protein_h.get_children():
1419 copyhier = self.hier_dict[copyname]
1420 outhiers.append(copyhier)
1424 2 * pi / axial_copies * (float(iac)))
1425 translation_vector = tuple(
1426 [translation_value * float(ilc) * x
for x
in axis])
1427 print(translation_vector)
1432 for n, p
in enumerate(mainparts):
1441 self.m.add_score_state(c)
1447 Load coordinates in the current representation.
1448 This should be done only if the hierarchy self.prot is identical
1449 to the one as stored in the rmf i.e. all components were added.
1454 rh = RMF.open_rmf_file_read_only(rmfname)
1462 create the representation (i.e. hierarchies) from the rmf file.
1463 it will be stored in self.prot, which will be overwritten.
1464 load the coordinates from the rmf file at frameindex.
1466 rh = RMF.open_rmf_file(rmfname)
1472 for p
in self.prot.get_children():
1473 self.add_component_name(p.get_name())
1474 self.hier_dict[p.get_name()] = p
1476 still missing: save rigid bodies contained in the rmf in self.rigid_bodies
1477 save floppy bodies in self.floppy_bodies
1478 get the connectivity restraints
1483 Construct a rigid body from hierarchies (and optionally particles).
1485 @param hiers list of hierarchies to make rigid
1486 @parm particles list of particles to add to the rigid body
1489 if particles
is None:
1492 rigid_parts = set(particles)
1495 print(
"set_rigid_body_from_hierarchies> setting up a new rigid body")
1502 print(
"set_rigid_body_from_hierarchies> WARNING particle %s already belongs to rigid body %s" % (p.get_name(), rb.get_name()))
1505 name += hier.get_name() +
"-"
1506 print(
"set_rigid_body_from_hierarchies> adding %s to the rigid body" % hier.get_name())
1508 if len(list(rigid_parts)) != 0:
1510 rb.set_coordinates_are_optimized(
True)
1511 rb.set_name(name +
"rigid_body")
1512 self.rigid_bodies.append(rb)
1516 print(
"set_rigid_body_from_hierarchies> rigid body could not be setup")
1520 Construct a rigid body from a list of subunits.
1522 Each subunit is a tuple that identifies the residue ranges and the
1523 component name (as used in create_component()).
1525 subunits: [(name_1,(first_residue_1,last_residue_1)),(name_2,(first_residue_2,last_residue_2)),.....]
1527 [name_1,name_2,(name_3,(first_residue_3,last_residue_3)),.....]
1529 example: ["prot1","prot2",("prot3",(1,10))]
1531 sometimes, we know about structure of an interaction
1532 and here we make such PPIs rigid
1537 if type(s) == type(tuple())
and len(s) == 2:
1541 residue_indexes=list(range(s[1][0],
1543 if len(sel.get_selected_particles()) == 0:
1544 print(
"set_rigid_bodies: selected particle does not exists")
1545 for p
in sel.get_selected_particles():
1549 print(
"set_rigid_body_from_hierarchies> WARNING particle %s already belongs to rigid body %s" % (p.get_name(), rb.get_name()))
1553 elif type(s) == type(str()):
1555 if len(sel.get_selected_particles()) == 0:
1556 print(
"set_rigid_bodies: selected particle does not exists")
1557 for p
in sel.get_selected_particles():
1561 print(
"set_rigid_body_from_hierarchies> WARNING particle %s already belongs to rigid body %s" % (p.get_name(), rb.get_name()))
1566 rb.set_coordinates_are_optimized(
True)
1567 rb.set_name(
''.join(str(subunits)) +
"_rigid_body")
1568 self.rigid_bodies.append(rb)
1571 def set_super_rigid_body_from_hierarchies(
1577 super_rigid_xyzs = set()
1578 super_rigid_rbs = set()
1580 print(
"set_super_rigid_body_from_hierarchies> setting up a new SUPER rigid body")
1587 super_rigid_rbs.add(rb)
1589 super_rigid_xyzs.add(p)
1590 print(
"set_rigid_body_from_hierarchies> adding %s to the rigid body" % hier.get_name())
1591 if len(super_rigid_rbs) < min_size:
1594 self.super_rigid_bodies.append((super_rigid_xyzs, super_rigid_rbs))
1597 self.super_rigid_bodies.append(
1598 (super_rigid_xyzs, super_rigid_rbs, axis))
1600 def fix_rigid_bodies(self, rigid_bodies):
1601 self.fixed_rigid_bodies += rigid_bodies
1605 self, hiers, min_length=
None, max_length=
None, axis=
None):
1607 Make a chain of super rigid bodies from a list of hierarchies.
1609 Takes a linear list of hierarchies (they are supposed to be
1610 sequence-contiguous) and produces a chain of super rigid bodies
1611 with given length range, specified by min_length and max_length.
1614 hiers = IMP.pmi.tools.flatten_list(hiers)
1618 self.set_super_rigid_body_from_hierarchies(hs, axis, min_length)
1620 def set_super_rigid_bodies(self, subunits, coords=None):
1621 super_rigid_xyzs = set()
1622 super_rigid_rbs = set()
1625 if type(s) == type(tuple())
and len(s) == 3:
1629 residue_indexes=list(range(s[0],
1631 if len(sel.get_selected_particles()) == 0:
1632 print(
"set_rigid_bodies: selected particle does not exists")
1633 for p
in sel.get_selected_particles():
1636 super_rigid_rbs.add(rb)
1638 super_rigid_xyzs.add(p)
1639 elif type(s) == type(str()):
1641 if len(sel.get_selected_particles()) == 0:
1642 print(
"set_rigid_bodies: selected particle does not exists")
1643 for p
in sel.get_selected_particles():
1647 super_rigid_rbs.add(rb)
1649 super_rigid_xyzs.add(p)
1650 self.super_rigid_bodies.append((super_rigid_xyzs, super_rigid_rbs))
1654 Remove leaves of hierarchies from the floppy bodies list.
1656 Given a list of hierarchies, get the leaves and remove the
1657 corresponding particles from the floppy bodies list. We need this
1658 function because sometimes
1659 we want to constrain the floppy bodies in a rigid body - for instance
1660 when you want to associate a bead with a density particle.
1662 for h
in hierarchies:
1665 if p
in self.floppy_bodies:
1666 print(
"remove_floppy_bodies: removing %s from floppy body list" % p.get_name())
1667 self.floppy_bodies.remove(p)
1670 def set_floppy_bodies(self):
1671 for p
in self.floppy_bodies:
1673 p.set_name(name +
"_floppy_body")
1675 print(
"I'm trying to make this particle flexible although it was assigned to a rigid body", p.get_name())
1678 rb.set_is_rigid_member(p.get_index(),
False)
1681 rb.set_is_rigid_member(p.get_particle_index(),
False)
1682 p.set_name(p.get_name() +
"_rigid_body_member")
1684 def set_floppy_bodies_from_hierarchies(self, hiers):
1689 self.floppy_bodies.append(p)
1696 selection tuples must be [(r1,r2,"name1"),(r1,r2,"name2"),....]
1697 @return the particles
1700 print(selection_tuples)
1701 for s
in selection_tuples:
1702 ps = IMP.pmi.tools.select_by_tuple(
1703 representation=self, tupleselection=tuple(s),
1704 resolution=
None, name_is_ambiguous=
False)
1708 def get_connected_intra_pairs(self):
1709 return self.connected_intra_pairs
1711 def set_rigid_bodies_max_trans(self, maxtrans):
1712 self.maxtrans_rb = maxtrans
1714 def set_rigid_bodies_max_rot(self, maxrot):
1715 self.maxrot_rb = maxrot
1717 def set_super_rigid_bodies_max_trans(self, maxtrans):
1718 self.maxtrans_srb = maxtrans
1720 def set_super_rigid_bodies_max_rot(self, maxrot):
1721 self.maxrot_srb = maxrot
1723 def set_floppy_bodies_max_trans(self, maxtrans):
1724 self.maxtrans_fb = maxtrans
1728 Fix rigid bodies in their actual position.
1729 The get_particles_to_sample() function will return
1730 just the floppy bodies.
1732 self.rigidbodiesarefixed = rigidbodiesarefixed
1734 def draw_hierarchy_graph(self):
1736 print(
"Drawing hierarchy graph for " + c.get_name())
1737 IMP.pmi.output.get_graph_from_hierarchy(c)
1739 def get_geometries(self):
1742 for name
in self.hier_geometry_pairs:
1743 for pt
in self.hier_geometry_pairs[name]:
1757 def setup_bonds(self):
1760 for name
in self.hier_geometry_pairs:
1761 for pt
in self.hier_geometry_pairs[name]:
1775 def show_component_table(self, name):
1776 if name
in self.sequence_dict:
1777 lastresn = len(self.sequence_dict[name])
1780 residues = self.hier_db.get_residue_numbers(name)
1781 firstresn = min(residues)
1782 lastresn = max(residues)
1784 for nres
in range(firstresn, lastresn + 1):
1786 resolutions = self.hier_db.get_residue_resolutions(name, nres)
1788 for r
in resolutions:
1789 ps += self.hier_db.get_particles(name, nres, r)
1790 print(
"%20s %7s" % (name, nres),
" ".join([
"%20s %7s" % (str(p.get_name()),
1793 print(
"%20s %20s" % (name, nres),
"**** not represented ****")
1795 def draw_hierarchy_composition(self):
1797 ks = list(self.elements.keys())
1801 for k
in self.elements:
1802 for l
in self.elements[k]:
1807 self.draw_component_composition(k, max)
1809 def draw_component_composition(self, name, max=1000, draw_pdb_names=False):
1810 from matplotlib
import pyplot
1811 import matplotlib
as mpl
1813 tmplist = sorted(self.elements[k], key=itemgetter(0))
1815 endres = tmplist[-1][1]
1817 print(
"draw_component_composition: missing information for component %s" % name)
1819 fig = pyplot.figure(figsize=(26.0 * float(endres) / max + 2, 2))
1820 ax = fig.add_axes([0.05, 0.475, 0.9, 0.15])
1825 norm = mpl.colors.Normalize(vmin=5, vmax=10)
1829 for n, l
in enumerate(tmplist):
1833 if bounds[-1] != l[0]:
1834 colors.append(
"white")
1837 colors.append(
"#99CCFF")
1839 colors.append(
"#FFFF99")
1841 colors.append(
"#33CCCC")
1843 bounds.append(l[1] + 1)
1846 colors.append(
"#99CCFF")
1848 colors.append(
"#FFFF99")
1850 colors.append(
"#33CCCC")
1852 bounds.append(l[1] + 1)
1854 if bounds[-1] - 1 == l[0]:
1858 colors.append(
"white")
1861 bounds.append(bounds[-1])
1862 colors.append(
"white")
1863 cmap = mpl.colors.ListedColormap(colors)
1864 cmap.set_over(
'0.25')
1865 cmap.set_under(
'0.75')
1867 norm = mpl.colors.BoundaryNorm(bounds, cmap.N)
1868 cb2 = mpl.colorbar.ColorbarBase(ax, cmap=cmap,
1874 spacing=
'proportional',
1875 orientation=
'horizontal')
1884 mid = 1.0 / endres * float(l[0])
1889 l[2], xy=(mid, 1), xycoords=
'axes fraction',
1890 xytext=(mid + 0.025, float(npdb - 1) / 2.0 + 1.5), textcoords=
'axes fraction',
1891 arrowprops=dict(arrowstyle=
"->",
1892 connectionstyle=
"angle,angleA=0,angleB=90,rad=10"),
1894 extra_artists.append(t)
1897 title = ax.text(-0.005, 0.5, k, ha=
"right", va=
"center", rotation=90,
1900 extra_artists.append(title)
1902 labels = len(bounds) * [
" "]
1903 ax.set_xticklabels(labels)
1904 mid = 1.0 / endres * float(bounds[0])
1905 t = ax.annotate(bounds[0], xy=(mid, 0), xycoords=
'axes fraction',
1906 xytext=(mid - 0.01, -0.5), textcoords=
'axes fraction',)
1907 extra_artists.append(t)
1908 offsets = [0, -0.5, -1.0]
1910 for n
in range(1, len(bounds)):
1911 if bounds[n] == bounds[n - 1]:
1913 mid = 1.0 / endres * float(bounds[n])
1914 if (float(bounds[n]) - float(bounds[n - 1])) / max <= 0.01:
1916 offset = offsets[nclashes % 3]
1922 bounds[n], xy=(mid, 0), xycoords=
'axes fraction',
1923 xytext=(mid, -0.5 + offset), textcoords=
'axes fraction')
1926 bounds[n], xy=(mid, 0), xycoords=
'axes fraction',
1927 xytext=(mid, -0.5 + offset), textcoords=
'axes fraction', arrowprops=dict(arrowstyle=
"-"))
1928 extra_artists.append(t)
1930 cb2.add_lines(bounds, [
"black"] * len(bounds), [1] * len(bounds))
1934 k +
"structure.pdf",
1937 bbox_extra_artists=(extra_artists),
1938 bbox_inches=
'tight')
1941 def draw_coordinates_projection(self):
1942 import matplotlib.pyplot
as pp
1945 for name
in self.hier_geometry_pairs:
1946 for pt
in self.hier_geometry_pairs[name]:
1956 xpairs.append([x1, x2])
1957 ypairs.append([y1, y2])
1960 for xends, yends
in zip(xpairs, ypairs):
1965 pp.plot(xlist, ylist,
'b-', alpha=0.1)
1968 def get_prot_name_from_particle(self, particle):
1969 names = self.get_component_names()
1970 particle0 = particle
1972 while not name
in names:
1975 particle0 = h.get_particle()
1979 def get_particles_to_sample(self):
1989 if not self.rigidbodiesarefixed:
1990 for rb
in self.rigid_bodies:
1995 if rb
not in self.fixed_rigid_bodies:
1998 for fb
in self.floppy_bodies:
2005 for srb
in self.super_rigid_bodies:
2008 rigid_bodies = list(srb[1])
2009 filtered_rigid_bodies = []
2010 for rb
in rigid_bodies:
2011 if rb
not in self.fixed_rigid_bodies:
2012 filtered_rigid_bodies.append(rb)
2013 srbtmp.append((srb[0], filtered_rigid_bodies))
2015 self.rigid_bodies = rbtmp
2016 self.floppy_bodies = fbtmp
2017 self.super_rigid_bodies = srbtmp
2019 ps[
"Rigid_Bodies_SimplifiedModel"] = (
2023 ps[
"Floppy_Bodies_SimplifiedModel"] = (
2026 ps[
"SR_Bodies_SimplifiedModel"] = (
2027 self.super_rigid_bodies,
2032 def set_output_level(self, level):
2033 self.output_level = level
2035 def get_output(self):
2039 output[
"SimplifiedModel_Total_Score_" +
2040 self.label] = str(self.m.evaluate(
False))
2041 output[
"SimplifiedModel_Linker_Score_" +
2042 self.label] = str(self.linker_restraints.unprotected_evaluate(
None))
2043 for name
in self.sortedsegments_cr_dict:
2044 partialscore = self.sortedsegments_cr_dict[name].evaluate(
False)
2045 score += partialscore
2047 "SimplifiedModel_Link_SortedSegments_" +
2052 partialscore = self.unmodeledregions_cr_dict[name].evaluate(
False)
2053 score += partialscore
2055 "SimplifiedModel_Link_UnmodeledRegions_" +
2060 for name
in self.linker_restraints_dict:
2065 self.linker_restraints_dict[
2066 name].unprotected_evaluate(
2069 if len(self.reference_structures.keys()) != 0:
2070 rmsds = self.get_all_rmsds()
2073 "SimplifiedModel_" +
2076 self.label] = rmsds[
2079 if self.output_level ==
"high":
2082 output[
"Coordinates_" +
2083 p.get_name() +
"_" + self.label] = str(d)
2085 output[
"_TotalScore"] = str(score)
2088 def get_test_output(self):
2090 output = self.get_output()
2091 for n, p
in enumerate(self.get_particles_to_sample()):
2092 output[
"Particle_to_sample_" + str(n)] = str(p)
2094 output[
"Hierarchy_Dictionary"] = list(self.hier_dict.keys())
2095 output[
"Number_of_floppy_bodies"] = len(self.floppy_bodies)
2096 output[
"Number_of_rigid_bodies"] = len(self.rigid_bodies)
2097 output[
"Number_of_super_bodies"] = len(self.super_rigid_bodies)
2098 output[
"Selection_resolution_1"] = len(
2100 output[
"Selection_resolution_5"] = len(
2102 output[
"Selection_resolution_7"] = len(
2104 output[
"Selection_resolution_10"] = len(
2106 output[
"Selection_resolution_100"] = len(
2109 output[
"Selection_resolution=1"] = len(
2111 output[
"Selection_resolution=1,resid=10"] = len(
2113 for resolution
in self.hier_resolution:
2114 output[
"Hier_resolution_dictionary" +
2115 str(resolution)] = len(self.hier_resolution[resolution])
2116 for name
in self.hier_dict:
2118 "Selection_resolution=1,resid=10,name=" +
2126 "Selection_resolution=1,resid=10,name=" +
2128 ",ambiguous"] = len(
2133 name_is_ambiguous=
True,
2136 "Selection_resolution=1,resid=10,name=" +
2138 ",ambiguous"] = len(
2143 name_is_ambiguous=
True,
2146 "Selection_resolution=1,resrange=(10,20),name=" +
2155 "Selection_resolution=1,resrange=(10,20),name=" +
2157 ",ambiguous"] = len(
2162 name_is_ambiguous=
True,
2166 "Selection_resolution=10,resrange=(10,20),name=" +
2175 "Selection_resolution=10,resrange=(10,20),name=" +
2177 ",ambiguous"] = len(
2182 name_is_ambiguous=
True,
2186 "Selection_resolution=100,resrange=(10,20),name=" +
2195 "Selection_resolution=100,resrange=(10,20),name=" +
2197 ",ambiguous"] = len(
2202 name_is_ambiguous=
True,
2213 def __init__(self, *args, **kwargs):
2214 Representation.__init__(self, *args, **kwargs)
2215 IMP.pmi.tools.print_deprecation_warning(
static Residue setup_particle(kernel::Model *m, ParticleIndex pi, ResidueType t, int index, int insertion_code)
def link_components_to_rmf
Load coordinates in the current representation.
Select non water and non hydrogen atoms.
double get_volume_from_residue_type(ResidueType rt)
Return an estimate for the volume of a given residue.
atom::Hierarchies create_hierarchies(RMF::FileConstHandle fh, kernel::Model *m)
A decorator to associate a particle with a part of a protein/DNA/RNA.
void show_molecular_hierarchy(Hierarchy h)
Print out the molecular hierarchy.
double get_drms(const Vector3DsOrXYZs0 &m1, const Vector3DsOrXYZs1 &m2)
Apply a SingletonFunction to a SingletonContainer to maintain an invariant.
Ints get_index(const kernel::ParticlesTemp &particles, const Subset &subset, const Subsets &excluded)
def shuffle_configuration
Shuffle configuration; used to restart the optimization.
static Atom setup_particle(kernel::Model *m, ParticleIndex pi, Atom other)
Upper bound harmonic function (non-zero when feature > mean)
static bool get_is_setup(const IMP::kernel::ParticleAdaptor &p)
def set_coordinates_from_rmf
Read and replace coordinates from an RMF file.
A decorator for a particle which has bonds.
Select atoms which are selected by both selectors.
Hierarchy create_clone(Hierarchy d)
Clone the Hierarchy.
Rotation3D get_random_rotation_3d(const Rotation3D ¢er, double distance)
Pick a rotation at random near the provided one.
double get_mass(ResidueType c)
Get the mass from the residue type.
Color get_rgb_color(double f)
Return the color for f from the RGB color map.
double get_mass_from_number_of_residues(unsigned int num_aa)
Estimate the mass of a protein from the number of amino acids.
double get_resolution(kernel::Model *m, kernel::ParticleIndex pi)
Object used to hold a set of restraints.
Low level functionality (logging, error handling, profiling, command line flags etc) that is used by ...
def set_rigid_bodies_as_fixed
Fix rigid bodies in their actual position.
def get_particles_from_selection_tuples
selection tuples must be [(r1,r2,"name1"),(r1,r2,"name2"),....
Add symmetric attribute to a particle.
double get_ball_radius_from_volume_3d(double volume)
Return the radius of a sphere with a given volume.
static XYZ setup_particle(kernel::Model *m, ParticleIndex pi)
def setup_component_sequence_connectivity
Generate restraints between contiguous fragments in the hierarchy.
void load_frame(RMF::FileConstHandle file, unsigned int frame)
Add uncertainty to a particle.
A score on the distance between the surfaces of two spheres.
def remove_floppy_bodies
Remove leaves of hierarchies from the floppy bodies list.
static Resolution setup_particle(kernel::Model *m, ParticleIndex pi, Float resolution)
Vector3D get_random_vector_in(const Cylinder3D &c)
Generate a random vector in a cylinder with uniform density.
static bool get_is_setup(const IMP::kernel::ParticleAdaptor &p)
Add resolution to a particle.
static bool get_is_setup(const IMP::kernel::ParticleAdaptor &p)
Bond create_bond(Bonded a, Bonded b, Bond o)
Connect the two wrapped particles by a custom bond.
Rotation3D get_rotation_about_axis(const Vector3D &axis, double angle)
Generate a Rotation3D object from a rotation around an axis.
static Reference setup_particle(kernel::Model *m, ParticleIndex pi, kernel::ParticleIndexAdaptor reference)
A class to store an fixed array of same-typed values.
Select all CB ATOM records.
A Gaussian distribution in 3D.
static XYZR setup_particle(kernel::Model *m, ParticleIndex pi)
static Bonded setup_particle(kernel::Model *m, ParticleIndex pi)
static Molecule setup_particle(kernel::Model *m, ParticleIndex pi)
def set_rigid_bodies
Construct a rigid body from a list of subunits.
double get_volume_from_mass(double m, ProteinDensityReference ref=ALBER)
Estimate the volume of a protein from its mass.
The standard decorator for manipulating molecular structures.
static Hierarchy setup_particle(kernel::Model *m, kernel::ParticleIndex pi, kernel::ParticleIndexesAdaptor children=kernel::ParticleIndexesAdaptor())
Store a kernel::ParticleIndexes.
A decorator for a particle representing an atom.
void transform(XYZ a, const algebra::Transformation3D &tr)
Apply a transformation to the particle.
Hierarchies get_by_type(Hierarchy mhd, GetByType t)
static Colored setup_particle(kernel::Model *m, ParticleIndex pi, Color color)
static bool get_is_setup(Model *m, ParticleIndex pi)
double get_rmsd(const Vector3DsOrXYZs0 &m1, const Vector3DsOrXYZs1 &m2)
def add_all_atom_densities
Decorates all specified particles as Gaussians directly.
def coarse_hierarchy
Generate all needed coarse grained layers.
def add_component_pdb
Add a component that has an associated 3D structure in a PDB file.
Basic utilities for handling cryo-electron microscopy 3D density maps.
Hierarchy create_clone_one(Hierarchy d)
Clone the node in the Hierarchy.
A decorator for a particle with x,y,z coordinates.
static Chain setup_particle(kernel::Model *m, ParticleIndex pi, std::string id)
static bool get_is_setup(Model *m, ParticleIndex pi)
Class to handle individual model particles.
def set_chain_of_super_rigid_bodies
Make a chain of super rigid bodies from a list of hierarchies.
static Uncertainty setup_particle(kernel::Model *m, ParticleIndex pi, Float uncertainty)
def add_component_sequence
Add the primary sequence for a single component.
Tools for clustering and cluster analysis.
def create_components_from_rmf
still not working.
static Mass setup_particle(kernel::Model *m, ParticleIndex pi, Float mass)
Find all nearby pairs by testing all pairs.
Classes for writing output files and processing them.
Simple implementation of segments in 3D.
A decorator for a residue.
static bool get_is_setup(const IMP::kernel::ParticleAdaptor &p)
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...
def add_component_density
Sets up a Gaussian Mixture Model for this component.
static bool get_is_setup(kernel::Model *m, kernel::ParticleIndex pi)
Sample using Monte Carlo.
static bool get_is_setup(const IMP::kernel::ParticleAdaptor &p)
Hierarchy create_simplified_along_backbone(Chain input, const IntRanges &residue_segments, bool keep_detailed=false)
IMP::core::RigidBody create_rigid_body(Hierarchy h)
Rotation3D get_identity_rotation_3d()
Return a rotation that does not do anything.
void link_hierarchies(RMF::FileConstHandle fh, const atom::Hierarchies &hs)
std::string get_data_path(std::string file_name)
Return the full path to installed data.
Select atoms which are selected by either selector.
static Fragment setup_particle(kernel::Model *m, ParticleIndex pi)
def get_hierarchies_at_given_resolution
Get the hierarchies at the given resolution.
Store info for a chain of a protein.
Applies a PairScore to a Pair.
Select all CA ATOM records.
Python classes to represent, score, sample and analyze models.
static bool get_is_setup(Model *m, ParticleIndex pi)
Set up the representation of all proteins and nucleic acid macromolecules.
Transformation3D get_transformation_aligning_first_to_second(Vector3Ds a, Vector3Ds b)
Output IMP model data in various file formats.
Functionality for loading, creating, manipulating and scoring atomic structures.
void read_pdb(base::TextInput input, int model, Hierarchy h)
Hierarchies get_leaves(const Selection &h)
def add_component_necklace
Generates a string of beads with given length.
Select hierarchy particles identified by the biological name.
Select all ATOM and HETATM records with the given chain ids.
static Gaussian setup_particle(kernel::Model *m, ParticleIndex pi)
Support for the RMF file format for storing hierarchical molecular data and markup.
def set_rigid_body_from_hierarchies
Construct a rigid body from hierarchies (and optionally particles).
Transformation3D get_random_local_transformation(Vector3D origin, double max_translation=5., double max_angle_in_rad=0.26)
Get a local transformation.
An exception for an invalid value being passed to IMP.
def check_root
If the root hierarchy does not exist, construct it.
static Symmetric setup_particle(kernel::Model *m, ParticleIndex pi, Float symmetric)
Inferential scoring building on methods developed as part of the Inferential Structure Determination ...
def add_component_hierarchy_clone
Make a copy of a hierarchy and append it to a component.
Harmonic function (symmetric about the mean)
A decorator for a particle with x,y,z coordinates and a radius.