3 """@namespace IMP.pmi.representation
4 Representation of the system.
7 from __future__
import print_function
15 from math
import pi, sqrt
17 from operator
import itemgetter
25 class Representation(object):
29 Set up the representation of all proteins and nucleic acid macromolecules.
31 Create the molecular hierarchies, representation,
32 sequence connectivity for the various involved proteins and
33 nucleic acid macromolecules:
35 Create a protein, DNA or RNA, represent it as a set of connected balls of appropriate
36 radii and number of residues, PDB at given resolution(s), or ideal helices.
38 How to use the SimplifiedModel class (typical use):
40 see test/test_hierarchy_contruction.py
44 1) Create a chain of helices and flexible parts
46 c_1_119 =self.add_component_necklace("prot1",1,119,20)
47 c_120_131 =self.add_component_ideal_helix("prot1",resolutions=[1,10],resrange=(120,131))
48 c_132_138 =self.add_component_beads("prot1",[(132,138)])
49 c_139_156 =self.add_component_ideal_helix("prot1",resolutions=[1,10],resrange=(139,156))
50 c_157_174 =self.add_component_beads("prot1",[(157,174)])
51 c_175_182 =self.add_component_ideal_helix("prot1",resolutions=[1,10],resrange=(175,182))
52 c_183_194 =self.add_component_beads("prot1",[(183,194)])
53 c_195_216 =self.add_component_ideal_helix("prot1",resolutions=[1,10],resrange=(195,216))
54 c_217_250 =self.add_component_beads("prot1",[(217,250)])
57 self.set_rigid_body_from_hierarchies(c_120_131)
58 self.set_rigid_body_from_hierarchies(c_139_156)
59 self.set_rigid_body_from_hierarchies(c_175_182)
60 self.set_rigid_body_from_hierarchies(c_195_216)
62 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,
65 self.set_chain_of_super_rigid_bodies(clist,2,3)
67 self.set_super_rigid_bodies(["prot1"])
71 def __init__(self, m, upperharmonic=True, disorderedlength=True):
74 @param upperharmonic This flag uses either harmonic (False)
75 or upperharmonic (True) in the intra-pair
76 connectivity restraint.
77 @param disorderedlength This flag uses either disordered length
78 calculated for random coil peptides (True) or zero
79 surface-to-surface distance between beads (False)
80 as optimal distance for the sequence connectivity
91 self.upperharmonic = upperharmonic
92 self.disorderedlength = disorderedlength
93 self.rigid_bodies = []
94 self.fixed_rigid_bodies = []
95 self.fixed_floppy_bodies = []
96 self.floppy_bodies = []
102 self.super_rigid_bodies = []
103 self.output_level =
"low"
106 self.maxtrans_rb = 2.0
107 self.maxrot_rb = 0.04
108 self.maxtrans_srb = 2.0
109 self.maxrot_srb = 0.2
110 self.rigidbodiesarefixed =
False
111 self.maxtrans_fb = 3.0
112 self.resolution = 10.0
113 self.bblenght = 100.0
117 self.representation_is_modified =
False
118 self.unmodeledregions_cr_dict = {}
119 self.sortedsegments_cr_dict = {}
121 self.connected_intra_pairs = []
124 self.sequence_dict = {}
125 self.hier_geometry_pairs = {}
131 self.hier_representation = {}
132 self.hier_resolution = {}
135 self.reference_structures = {}
138 self.linker_restraints_dict = {}
139 self.threetoone = {
'ALA':
'A',
'ARG':
'R', 'ASN': 'N', 'ASP': 'D',
140 'CYS':
'C',
'GLU':
'E',
'GLN':
'Q',
'GLY':
'G',
141 'HIS':
'H',
'ILE':
'I',
'LEU':
'L',
'LYS':
'K',
142 'MET':
'M',
'PHE':
'F',
'PRO':
'P',
'SER':
'S',
143 'THR':
'T',
'TRP':
'W',
'TYR':
'Y',
'VAL':
'V',
'UNK':
'X'}
145 self.onetothree = dict((v, k)
for k, v
in self.threetoone.items())
149 def set_label(self, label):
152 def create_component(self, name, color=0.0):
154 protein_h.set_name(name)
155 self.hier_dict[name] = protein_h
156 self.hier_representation[name] = {}
157 self.hier_db.add_name(name)
158 self.prot.add_child(protein_h)
159 self.color_dict[name] = color
160 self.elements[name] = []
165 def add_component_name(self, *args, **kwargs):
166 self.create_component(*args, **kwargs)
168 def get_component_names(self):
169 return list(self.hier_dict.keys())
174 Add the primary sequence for a single component.
176 @param name Human-readable name of the component
177 @param filename Name of the FASTA file
178 @param id Identifier of the sequence in the FASTA file header
179 (if not provided, use `name` instead)
181 from Bio
import SeqIO
182 handle = open(filename,
"rU")
183 record_dict = SeqIO.to_dict(SeqIO.parse(handle,
"fasta"))
188 length = len(record_dict[id].seq)
190 raise KeyError(
"id %s not found in fasta file" % id)
192 self.sequence_dict[name] = str(record_dict[id].seq).replace(
"*",
"")
195 self.sequence_dict[name]=offs_str+self.sequence_dict[name]
197 self.elements[name].append((length, length,
" ",
"end"))
199 def autobuild_model(self, name, pdbname, chain,
200 resolutions=
None, resrange=
None,
203 color=
None, pdbresrange=
None, offset=0,
204 show=
False, isnucleicacid=
False,
207 if not beadsize
is None:
208 IMP.pmi.tools.print_deprecation_warning(
212 self.representation_is_modified =
True
216 color = self.color_dict[name]
218 self.color_dict[name] = color
220 if resolutions
is None:
222 print(
"autobuild_model: constructing %s from pdb %s and chain %s" % (name, pdbname, str(chain)))
231 t.get_children()[0].get_children()[0]).
get_index()
233 t.get_children()[0].get_children()[-1]).
get_index()
239 if name
in self.sequence_dict:
240 resrange = (1, len(self.sequence_dict[name]))
242 resrange = (start + offset, end + offset)
244 start = resrange[0] - offset
245 end = resrange[1] - offset
262 for n, g
in enumerate(gaps):
266 print(
"autobuild_model: constructing fragment %s from pdb" % (str((first, last))))
268 chain, resolutions=resolutions,
269 color=color, cacenters=
True,
270 resrange=(first, last),
271 offset=offset, isnucleicacid=isnucleicacid)
272 elif g[2] ==
"gap" and n > 0:
273 print(
"autobuild_model: constructing fragment %s as a bead" % (str((first, last))))
274 parts = self.hier_db.get_particles_at_closest_resolution(
281 first+offset, last+offset, missingbeadsize, incoord=xyz)
283 elif g[2] ==
"gap" and n == 0:
285 print(
"autobuild_model: constructing fragment %s as a bead" % (str((first, last))))
287 first+offset, last+offset, missingbeadsize, incoord=xyznter)
294 def autobuild_pdb_and_intervening_beads(self, *args, **kwargs):
295 r = self.autobuild_model(*args, **kwargs)
299 resrange=
None, offset=0, cacenters=
True, show=
False,
300 isnucleicacid=
False, readnonwateratoms=
False,
301 read_ca_cb_only=
False):
303 Add a component that has an associated 3D structure in a PDB file.
305 Reads the PDB, and constructs the fragments corresponding to contiguous
308 @return a list of hierarchies.
310 @param name (string) the name of the component
311 @param pdbname (string) the name of the PDB file
312 @param chain (string or integer) can be either a string (eg, "A")
313 or an integer (eg, 0 or 1) in case you want
314 to get the corresponding chain number in the PDB.
315 @param resolutions (integers) a list of integers that corresponds
316 to the resolutions that have to be generated
317 @param color (float from 0 to 1) the color applied to the
318 hierarchies generated
319 @param resrange (tuple of integers): the residue range to extract
320 from the PDB. It is a tuple (beg,end). If not specified,
321 all residues belonging to the specified chain are read.
322 @param offset (integer) specifies the residue index offset to be
323 applied when reading the PDB (the FASTA sequence is
324 assumed to start from residue 1, so use this parameter
325 if the PDB file does not start at residue 1)
326 @param cacenters (boolean) if True generates resolution=1 beads
327 centered on C-alpha atoms.
328 @param show (boolean) print out the molecular hierarchy at the end.
329 @param isnucleicacid (boolean) use True if you're reading a PDB
331 @param readnonwateratoms (boolean) if True fixes some pathological PDB.
332 @param read_ca_cb_only (boolean) if True, only reads CA/CB
335 self.representation_is_modified =
True
338 color = self.color_dict[name]
339 protein_h = self.hier_dict[name]
349 if type(chain) == str:
357 t.get_children()[0].get_children()[0]).
get_index()
359 t.get_children()[0].get_children()[-1]).
get_index()
371 if not resrange
is None:
372 if resrange[0] > start:
374 if resrange[1] < end:
377 if not isnucleicacid:
381 residue_indexes=list(range(
384 atom_type=IMP.atom.AT_CA)
390 residue_indexes=list(range(
393 atom_type=IMP.atom.AT_P)
395 ps = sel.get_selected_particles()
397 raise ValueError(
"%s no residue found in pdb %s chain %s that overlaps with the queried stretch %s-%s" \
398 % (name, pdbname, str(chain), str(resrange[0]), str(resrange[1])))
406 start = start + offset
409 self.elements[name].append(
410 (start, end, pdbname.split(
"/")[-1] +
":" + chain,
"pdb"))
413 resolutions, isnucleicacid, c0, protein_h,
"pdb", color)
424 def add_component_ideal_helix(
432 self.representation_is_modified =
True
433 from math
import pi, cos, sin
435 protein_h = self.hier_dict[name]
438 color = self.color_dict[name]
442 self.elements[name].append((start, end,
" ",
"helix"))
444 for n, res
in enumerate(range(start, end + 1)):
445 if name
in self.sequence_dict:
447 rtstr = self.onetothree[
448 self.sequence_dict[name][res-1]]
468 x = 2.3 * cos(n * 2 * pi / 3.6)
469 y = 2.3 * sin(n * 2 * pi / 3.6)
470 z = 6.2 / 3.6 / 2 * n * 2 * pi / 3.6
479 resolutions,
False, c0, protein_h,
"helix", color)
488 """ add beads to the representation
489 @param name the component name
490 @param ds a list of tuples corresponding to the residue ranges
492 @param colors a list of colors associated to the beads
493 @param incoord the coordinate tuple correspoding to the position
498 self.representation_is_modified =
True
500 protein_h = self.hier_dict[name]
503 colors = [self.color_dict[name]]
506 for n, dss
in enumerate(ds):
507 ds_frag = (dss[0], dss[1])
508 self.elements[name].append((dss[0], dss[1],
" ",
"bead"))
510 if ds_frag[0] == ds_frag[1]:
512 if name
in self.sequence_dict:
514 rtstr = self.onetothree[
515 self.sequence_dict[name][ds_frag[0]-1]]
522 h.set_name(name +
'_%i_bead' % (ds_frag[0]))
523 prt.set_name(name +
'_%i_bead' % (ds_frag[0]))
527 h.set_name(name +
'_%i-%i_bead' % (ds_frag[0], ds_frag[1]))
528 prt.set_name(name +
'_%i-%i_bead' % (ds_frag[0], ds_frag[1]))
529 h.set_residue_indexes(list(range(ds_frag[0], ds_frag[1] + 1)))
530 resolution = len(h.get_residue_indexes())
531 if "Beads" not in self.hier_representation[name]:
533 root.set_name(
"Beads")
534 self.hier_representation[name][
"Beads"] = root
535 protein_h.add_child(root)
536 self.hier_representation[name][
"Beads"].add_child(h)
538 for kk
in range(ds_frag[0], ds_frag[1] + 1):
539 self.hier_db.add_particles(name, kk, resolution, [h])
562 ptem.set_radius(radius)
565 radius = 0.8 * (3.0 / 4.0 / pi * volume) ** (1.0 / 3.0)
567 ptem.set_radius(radius)
569 if not tuple(incoord)
is None:
570 ptem.set_coordinates(incoord)
575 self.floppy_bodies.append(prt)
584 Generates a string of beads with given length.
586 self.representation_is_modified =
True
594 [(chunk[0], chunk[-1])], colors=colors,incoord=incoord)
598 self, name, hierarchies=
None, selection_tuples=
None,
600 resolution=0.0, num_components=10,
601 inputfile=
None, outputfile=
None,
604 covariance_type=
'full', voxel_size=1.0,
606 sampled_points=1000000, num_iter=100,
608 multiply_by_total_mass=
True,
610 intermediate_map_fn=
None,
611 density_ps_to_copy=
None,
612 use_precomputed_gaussians=
False):
614 Sets up a Gaussian Mixture Model for this component.
615 Can specify input GMM file or it will be computed.
616 @param name component name
617 @param hierarchies set up GMM for some hierarchies
618 @param selection_tuples (list of tuples) example (first_residue,last_residue,component_name)
619 @param particles set up GMM for particles directly
620 @param resolution usual PMI resolution for selecting particles from the hierarchies
621 @param inputfile read the GMM from this file
622 @param outputfile fit and write the GMM to this file (text)
623 @param outputmap after fitting, create GMM density file (mrc)
624 @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
625 @param covariance_type for fitting the GMM. options are 'full', 'diagonal' and 'spherical'
626 @param voxel_size for creating the intermediate density map and output map.
627 lower number increases accuracy but also rasterizing time grows
628 @param out_hier_name name of the output density hierarchy
629 @param sampled_points number of points to sample. more will increase accuracy and fitting time
630 @param num_iter num GMM iterations. more will increase accuracy and fitting time
631 @param multiply_by_total_mass multiply the weights of the GMM by this value (only works on creation!)
632 @param transform for input file only, apply a transformation (eg for multiple copies same GMM)
633 @param intermediate_map_fn for debugging, this will write the itermediate (simulated) map
634 @param density_ps_to_copy in case you already created the appropriate GMM (eg, for beads)
635 @param use_precomputed_gaussians Set this flag and pass fragments - will use roughly spherical Gaussian setup
643 self.representation_is_modified =
True
645 protein_h = self.hier_dict[name]
646 if "Densities" not in self.hier_representation[name]:
648 root.set_name(
"Densities")
649 self.hier_representation[name][
"Densities"] = root
650 protein_h.add_child(root)
653 fragment_particles = []
654 if not particles
is None:
655 fragment_particles += particles
656 if not hierarchies
is None:
658 self, resolution=resolution,
659 hierarchies=hierarchies)
660 if not selection_tuples
is None:
661 for st
in selection_tuples:
662 fragment_particles += IMP.pmi.tools.select_by_tuple(
663 self, tupleselection=st,
664 resolution=resolution,
665 name_is_ambiguous=
False)
668 density_particles = []
671 inputfile, density_particles,
673 elif density_ps_to_copy:
674 for ip
in density_ps_to_copy:
680 density_particles.append(p)
681 elif use_precomputed_gaussians:
682 if len(fragment_particles) == 0:
683 print(
"add_component_density: no particle was selected")
685 for p
in fragment_particles:
688 raise Exception(
"The particles you selected must be Fragments and XYZs")
690 pos=
IMP.core.XYZ(self.m,p.get_particle_index()).get_coordinates()
695 raise Exception(
"We haven't created a bead file for",nres,
"residues")
702 if len(fragment_particles) == 0:
703 print(
"add_component_density: no particle was selected")
706 density_particles = IMP.isd.gmm_tools.sample_and_fit_to_particles(
715 multiply_by_total_mass,
721 s0.set_name(out_hier_name)
722 self.hier_representation[name][
"Densities"].add_child(s0)
724 for nps, p
in enumerate(density_particles):
726 p.set_name(s0.get_name() +
'_gaussian_%i' % nps)
729 def get_component_density(self, name):
730 return self.hier_representation[name][
"Densities"]
733 selection_tuples=
None,
738 '''Decorates all specified particles as Gaussians directly.
739 @param name component name
740 @param hierarchies set up GMM for some hierarchies
741 @param selection_tuples (list of tuples) example (first_residue,last_residue,component_name)
742 @param particles set up GMM for particles directly
743 @param resolution usual PMI resolution for selecting particles from the hierarchies
749 from math
import sqrt
750 self.representation_is_modified =
False
752 if particles
is None:
753 fragment_particles = []
755 fragment_particles = particles
757 if not hierarchies
is None:
759 self, resolution=resolution,
760 hierarchies=hierarchies)
762 if not selection_tuples
is None:
763 for st
in selection_tuples:
764 fragment_particles += IMP.pmi.tools.select_by_tuple(
765 self, tupleselection=st,
766 resolution=resolution,
767 name_is_ambiguous=
False)
769 if len(fragment_particles) == 0:
770 print(
"add all atom densities: no particle was selected")
774 print(
'setting up all atom gaussians num_particles',len(fragment_particles))
775 for n,p
in enumerate(fragment_particles):
783 print(
'setting up particle',p.get_name(),
" as individual gaussian particle")
785 if not output_map
is None:
786 print(
'writing map to', output_map)
794 Make a copy of a hierarchy and append it to a component.
797 self.representation_is_modified =
True
798 protein_h = self.hier_dict[name]
800 hierclone.set_name(hierclone.get_name() +
"_clone")
801 protein_h.add_child(hierclone)
802 outhier.append(hierclone)
808 for n, pmain
in enumerate(psmain):
814 self.hier_db.add_particles(
832 rmf_component_name=
None,
833 check_number_particles=
True,
835 '''Read and replace coordinates from an RMF file.
836 Replace the coordinates of particles with the same name.
837 It assumes that the RMF and the representation have the particles
839 @param component_name Component name
840 @param rmf_component_name Name of the component in the RMF file
841 (if not specified, use `component_name`)
847 prots = IMP.pmi.analysis.get_hiers_from_rmf(
853 raise ValueError(
"cannot read hiearchy from rmf")
866 p, self.hier_dict.keys())
867 if not rmf_component_name
is None and protname == rmf_component_name:
869 elif rmf_component_name
is None and protname == component_name:
874 if check_number_particles:
875 if len(psrmf) != len(psrepr):
876 raise ValueError(
"%s cannot proceed the rmf and the representation don't have the same number of particles; "
877 "particles in rmf: %s particles in the representation: %s" % (str(component_name), str(len(psrmf)), str(len(psrepr))))
879 for n, prmf
in enumerate(psrmf):
880 prmfname = prmf.get_name()
881 preprname = psrepr[n].get_name()
883 raise ValueError(
"component %s cannot proceed if rigid bodies were initialized. Use the function before defining the rigid bodies" % component_name)
885 raise ValueError(
"component %s cannot proceed if rigid bodies were initialized. Use the function before defining the rigid bodies" % component_name)
887 if prmfname != preprname:
888 print(
"set_coordinates_from_rmf: WARNING rmf particle and representation particles have not the same name %s %s " % (prmfname, preprname))
897 If the root hierarchy does not exist, construct it.
899 if "Res:" + str(int(resolution))
not in self.hier_representation[name]:
901 root.set_name(name +
"_Res:" + str(int(resolution)))
902 self.hier_representation[name][
903 "Res:" + str(int(resolution))] = root
904 protein_h.add_child(root)
907 input_hierarchy, protein_h, type, color):
909 Generate all needed coarse grained layers.
911 @param name name of the protein
912 @param resolutions list of resolutions
913 @param protein_h root hierarchy
914 @param input_hierarchy hierarchy to coarse grain
915 @param type a string, typically "pdb" or "helix"
919 if (1
in resolutions)
or (0
in resolutions):
925 s1.set_name(
'%s_%i-%i_%s' % (name, start, end, type))
927 self.hier_representation[name][
"Res:1"].add_child(s1)
932 s0.set_name(
'%s_%i-%i_%s' % (name, start, end, type))
934 self.hier_representation[name][
"Res:0"].add_child(s0)
937 if not isnucleicacid:
940 atom_type=IMP.atom.AT_CA)
944 atom_type=IMP.atom.AT_P)
946 for p
in sel.get_selected_particles():
952 s0.add_child(resclone0)
953 self.hier_db.add_particles(
957 resclone0.get_children())
959 chil = resclone0.get_children()
972 s1.add_child(resclone1)
973 self.hier_db.add_particles(name, resindex, 1, [resclone1])
977 prt = resclone1.get_particle()
978 prt.set_name(
'%s_%i_%s' % (name, resindex, type))
1000 for r
in resolutions:
1001 if r != 0
and r != 1:
1007 chil = s.get_children()
1009 s0.set_name(
'%s_%i-%i_%s' % (name, start, end, type))
1013 self.hier_representation[name][
1014 "Res:" + str(int(r))].add_child(s0)
1023 prt.set_name(
'%s_%i_%s' % (name, first, type))
1025 prt.set_name(
'%s_%i_%i_%s' % (name, first, last, type))
1027 self.hier_db.add_particles(name, kk, r, [prt])
1048 Get the hierarchies at the given resolution.
1050 The map between resolution and hierarchies is cached to accelerate
1051 the selection algorithm. The cache is invalidated when the
1052 representation was changed by any add_component_xxx.
1055 if self.representation_is_modified:
1056 rhbr = self.hier_db.get_all_root_hierarchies_by_resolution(
1058 self.hier_resolution[resolution] = rhbr
1059 self.representation_is_modified =
False
1062 if resolution
in self.hier_resolution:
1063 return self.hier_resolution[resolution]
1065 rhbr = self.hier_db.get_all_root_hierarchies_by_resolution(
1067 self.hier_resolution[resolution] = rhbr
1071 self, max_translation=300., max_rotation=2.0 * pi,
1072 avoidcollision=
True, cutoff=10.0, niterations=100,
1074 excluded_rigid_bodies=
None,
1075 hierarchies_excluded_from_collision=
None):
1077 Shuffle configuration; used to restart the optimization.
1079 The configuration of the system is initialized by placing each
1080 rigid body and each bead randomly in a box with a side of
1081 `max_translation` angstroms, and far enough from each other to
1082 prevent any steric clashes. The rigid bodies are also randomly rotated.
1084 @param avoidcollision check if the particle/rigid body was
1085 placed close to another particle; uses the optional
1086 arguments cutoff and niterations
1087 @param bounding_box defined by ((x1,y1,z1),(x2,y2,z2))
1090 if excluded_rigid_bodies
is None:
1091 excluded_rigid_bodies = []
1092 if hierarchies_excluded_from_collision
is None:
1093 hierarchies_excluded_from_collision = []
1095 if len(self.rigid_bodies) == 0:
1096 print(
"shuffle_configuration: rigid bodies were not intialized")
1099 gcpf.set_distance(cutoff)
1101 hierarchies_excluded_from_collision_indexes = []
1110 if not bounding_box
is None:
1111 ((x1, y1, z1), (x2, y2, z2)) = bounding_box
1116 for h
in hierarchies_excluded_from_collision:
1120 allparticleindexes = list(
1121 set(allparticleindexes) - set(hierarchies_excluded_from_collision_indexes))
1123 print(hierarchies_excluded_from_collision)
1124 print(len(allparticleindexes),len(hierarchies_excluded_from_collision_indexes))
1126 for rb
in self.rigid_bodies:
1127 if rb
not in excluded_rigid_bodies:
1130 rbindexes = rb.get_member_particle_indexes()
1133 set(rbindexes) - set(hierarchies_excluded_from_collision_indexes))
1134 otherparticleindexes = list(
1135 set(allparticleindexes) - set(rbindexes))
1137 if len(otherparticleindexes)
is None:
1141 while niter < niterations:
1142 rbxyz = (rb.get_x(), rb.get_y(), rb.get_z())
1144 if not bounding_box
is None:
1162 gcpf.get_close_pairs(
1164 otherparticleindexes,
1170 print(
"shuffle_configuration: rigid body placed close to other %d particles, trying again..." % npairs)
1171 print(
"shuffle_configuration: rigid body name: " + rb.get_name())
1172 if niter == niterations:
1173 raise ValueError(
"tried the maximum number of iterations to avoid collisions, increase the distance cutoff")
1177 print(
'shuffling', len(self.floppy_bodies),
'floppy bodies')
1178 for fb
in self.floppy_bodies:
1184 otherparticleindexes = list(
1185 set(allparticleindexes) - set(fbindexes))
1186 if len(otherparticleindexes)
is None:
1192 while niter < niterations:
1194 if not bounding_box
is None:
1209 gcpf.get_close_pairs(
1211 otherparticleindexes,
1217 print(
"shuffle_configuration: floppy body placed close to other %d particles, trying again..." % npairs)
1218 if niter == niterations:
1219 raise ValueError(
"tried the maximum number of iterations to avoid collisions, increase the distance cutoff")
1223 def set_current_coordinates_as_reference_for_rmsd(self, label="None"):
1227 self.reference_structures[label] = (
1231 def get_all_rmsds(self):
1234 for label
in self.reference_structures:
1236 current_coordinates = [
IMP.core.XYZ(p).get_coordinates()
1237 for p
in self.reference_structures[label][1]]
1238 reference_coordinates = self.reference_structures[label][0]
1239 if len(reference_coordinates) != len(current_coordinates):
1240 print(
"calculate_all_rmsds: reference and actual coordinates are not the same")
1243 current_coordinates,
1244 reference_coordinates)
1246 reference_coordinates,
1247 current_coordinates)
1251 reference_coordinates,
1252 current_coordinates)
1253 rmsds[label +
"_GlobalRMSD"] = rmsd_global
1254 rmsds[label +
"_RelativeDRMS"] = rmsd_relative
1257 def setup_component_geometry(self, name, color=None, resolution=1.0):
1259 color = self.color_dict[name]
1263 self.hier_geometry_pairs[name] = []
1264 protein_h = self.hier_dict[name]
1266 pbr = IMP.pmi.tools.sort_by_residues(pbr)
1268 for n
in range(len(pbr) - 1):
1269 self.hier_geometry_pairs[name].append((pbr[n], pbr[n + 1], color))
1272 self, name, resolution=10, scale=1.0):
1274 Generate restraints between contiguous fragments in the hierarchy.
1275 The linkers are generated at resolution 10 by default.
1282 protein_h = self.hier_dict[name]
1284 frs = self.hier_db.get_preroot_fragments_by_resolution(
1290 start = fr.get_children()[0]
1295 end = fr.get_children()[-1]
1301 SortedSegments.append((start, end, startres))
1302 SortedSegments = sorted(SortedSegments, key=itemgetter(2))
1305 for x
in range(len(SortedSegments) - 1):
1306 last = SortedSegments[x][1]
1307 first = SortedSegments[x + 1][0]
1314 residuegap = firstresn - lastresn - 1
1315 if self.disorderedlength
and (nreslast / 2 + nresfirst / 2 + residuegap) > 20.0:
1318 optdist = sqrt(5 / 3) * 1.93 * \
1319 (nreslast / 2 + nresfirst / 2 + residuegap) ** 0.6
1321 if self.upperharmonic:
1327 optdist = (0.0 + (float(residuegap) + 1.0) * 3.6) * scale
1328 if self.upperharmonic:
1334 pt0 = last.get_particle()
1335 pt1 = first.get_particle()
1338 print(
"Adding sequence connectivity restraint between", pt0.get_name(),
" and ", pt1.get_name(),
'of distance', optdist)
1339 sortedsegments_cr.add_restraint(r)
1340 self.linker_restraints_dict[
1341 "LinkerRestraint-" + pt0.get_name() +
"-" + pt1.get_name()] = r
1342 self.connected_intra_pairs.append((pt0, pt1))
1343 self.connected_intra_pairs.append((pt1, pt0))
1347 self.linker_restraints.add_restraint(sortedsegments_cr)
1348 self.linker_restraints.add_restraint(unmodeledregions_cr)
1349 self.sortedsegments_cr_dict[name] = sortedsegments_cr
1350 self.unmodeledregions_cr_dict[name] = unmodeledregions_cr
1352 def optimize_floppy_bodies(self, nsteps, temperature=1.0):
1354 pts = IMP.pmi.tools.ParticleToSampleList()
1355 for n, fb
in enumerate(self.floppy_bodies):
1356 pts.add_particle(fb,
"Floppy_Bodies", 1.0,
"Floppy_Body_" + str(n))
1357 if len(pts.get_particles_to_sample()) > 0:
1359 print(
"optimize_floppy_bodies: optimizing %i floppy bodies" % len(self.floppy_bodies))
1362 print(
"optimize_floppy_bodies: no particle to optimize")
1364 def create_rotational_symmetry(self, maincopy, copies):
1366 self.representation_is_modified =
True
1367 ncopies = len(copies) + 1
1370 mainparticles = sel.get_selected_particles()
1372 for k
in range(len(copies)):
1378 copyparticles = sel.get_selected_particles()
1382 for n, p
in enumerate(mainparticles):
1384 pc = copyparticles[n]
1386 mainpurged.append(p)
1389 copypurged.append(pc)
1393 for n, p
in enumerate(mainpurged):
1396 print(
"setting " + p.get_name() +
" as reference for " + pc.get_name())
1402 self.m.add_score_state(c)
1406 def create_amyloid_fibril_symmetry(self, maincopy, axial_copies,
1407 longitudinal_copies, axis=(0, 0, 1), translation_value=4.8):
1410 self.representation_is_modified =
True
1413 protein_h = self.hier_dict[maincopy]
1416 for ilc
in range(-longitudinal_copies, longitudinal_copies + 1):
1417 for iac
in range(axial_copies):
1418 copyname = maincopy +
"_a" + str(ilc) +
"_l" + str(iac)
1419 self.add_component_name(copyname, 0.0)
1420 for hier
in protein_h.get_children():
1422 copyhier = self.hier_dict[copyname]
1423 outhiers.append(copyhier)
1427 2 * pi / axial_copies * (float(iac)))
1428 translation_vector = tuple(
1429 [translation_value * float(ilc) * x
for x
in axis])
1430 print(translation_vector)
1435 for n, p
in enumerate(mainparts):
1444 self.m.add_score_state(c)
1450 Load coordinates in the current representation.
1451 This should be done only if the hierarchy self.prot is identical
1452 to the one as stored in the rmf i.e. all components were added.
1457 rh = RMF.open_rmf_file_read_only(rmfname)
1465 create the representation (i.e. hierarchies) from the rmf file.
1466 it will be stored in self.prot, which will be overwritten.
1467 load the coordinates from the rmf file at frameindex.
1469 rh = RMF.open_rmf_file(rmfname)
1475 for p
in self.prot.get_children():
1476 self.add_component_name(p.get_name())
1477 self.hier_dict[p.get_name()] = p
1479 still missing: save rigid bodies contained in the rmf in self.rigid_bodies
1480 save floppy bodies in self.floppy_bodies
1481 get the connectivity restraints
1486 Construct a rigid body from hierarchies (and optionally particles).
1488 @param hiers list of hierarchies to make rigid
1489 @param particles list of particles to add to the rigid body
1492 if particles
is None:
1495 rigid_parts = set(particles)
1498 print(
"set_rigid_body_from_hierarchies> setting up a new rigid body")
1505 print(
"set_rigid_body_from_hierarchies> WARNING particle %s already belongs to rigid body %s" % (p.get_name(), rb.get_name()))
1508 name += hier.get_name() +
"-"
1509 print(
"set_rigid_body_from_hierarchies> adding %s to the rigid body" % hier.get_name())
1511 if len(list(rigid_parts)) != 0:
1513 rb.set_coordinates_are_optimized(
True)
1514 rb.set_name(name +
"rigid_body")
1515 self.rigid_bodies.append(rb)
1519 print(
"set_rigid_body_from_hierarchies> rigid body could not be setup")
1523 Construct a rigid body from a list of subunits.
1525 Each subunit is a tuple that identifies the residue ranges and the
1526 component name (as used in create_component()).
1528 subunits: [(name_1,(first_residue_1,last_residue_1)),(name_2,(first_residue_2,last_residue_2)),.....]
1530 [name_1,name_2,(name_3,(first_residue_3,last_residue_3)),.....]
1532 example: ["prot1","prot2",("prot3",(1,10))]
1534 sometimes, we know about structure of an interaction
1535 and here we make such PPIs rigid
1540 if type(s) == type(tuple())
and len(s) == 2:
1544 residue_indexes=list(range(s[1][0],
1546 if len(sel.get_selected_particles()) == 0:
1547 print(
"set_rigid_bodies: selected particle does not exists")
1548 for p
in sel.get_selected_particles():
1552 print(
"set_rigid_body_from_hierarchies> WARNING particle %s already belongs to rigid body %s" % (p.get_name(), rb.get_name()))
1556 elif type(s) == type(str()):
1558 if len(sel.get_selected_particles()) == 0:
1559 print(
"set_rigid_bodies: selected particle does not exists")
1560 for p
in sel.get_selected_particles():
1564 print(
"set_rigid_body_from_hierarchies> WARNING particle %s already belongs to rigid body %s" % (p.get_name(), rb.get_name()))
1569 rb.set_coordinates_are_optimized(
True)
1570 rb.set_name(
''.join(str(subunits)) +
"_rigid_body")
1571 self.rigid_bodies.append(rb)
1574 def set_super_rigid_body_from_hierarchies(
1580 super_rigid_xyzs = set()
1581 super_rigid_rbs = set()
1583 print(
"set_super_rigid_body_from_hierarchies> setting up a new SUPER rigid body")
1590 super_rigid_rbs.add(rb)
1592 super_rigid_xyzs.add(p)
1593 print(
"set_rigid_body_from_hierarchies> adding %s to the rigid body" % hier.get_name())
1594 if len(super_rigid_rbs) < min_size:
1597 self.super_rigid_bodies.append((super_rigid_xyzs, super_rigid_rbs))
1600 self.super_rigid_bodies.append(
1601 (super_rigid_xyzs, super_rigid_rbs, axis))
1603 def fix_rigid_bodies(self, rigid_bodies):
1604 self.fixed_rigid_bodies += rigid_bodies
1608 self, hiers, min_length=
None, max_length=
None, axis=
None):
1610 Make a chain of super rigid bodies from a list of hierarchies.
1612 Takes a linear list of hierarchies (they are supposed to be
1613 sequence-contiguous) and produces a chain of super rigid bodies
1614 with given length range, specified by min_length and max_length.
1617 hiers = IMP.pmi.tools.flatten_list(hiers)
1621 self.set_super_rigid_body_from_hierarchies(hs, axis, min_length)
1623 def set_super_rigid_bodies(self, subunits, coords=None):
1624 super_rigid_xyzs = set()
1625 super_rigid_rbs = set()
1628 if type(s) == type(tuple())
and len(s) == 3:
1632 residue_indexes=list(range(s[0],
1634 if len(sel.get_selected_particles()) == 0:
1635 print(
"set_rigid_bodies: selected particle does not exists")
1636 for p
in sel.get_selected_particles():
1639 super_rigid_rbs.add(rb)
1641 super_rigid_xyzs.add(p)
1642 elif type(s) == type(str()):
1644 if len(sel.get_selected_particles()) == 0:
1645 print(
"set_rigid_bodies: selected particle does not exists")
1646 for p
in sel.get_selected_particles():
1650 super_rigid_rbs.add(rb)
1652 super_rigid_xyzs.add(p)
1653 self.super_rigid_bodies.append((super_rigid_xyzs, super_rigid_rbs))
1657 Remove leaves of hierarchies from the floppy bodies list.
1659 Given a list of hierarchies, get the leaves and remove the
1660 corresponding particles from the floppy bodies list. We need this
1661 function because sometimes
1662 we want to constrain the floppy bodies in a rigid body - for instance
1663 when you want to associate a bead with a density particle.
1665 for h
in hierarchies:
1668 if p
in self.floppy_bodies:
1669 print(
"remove_floppy_bodies: removing %s from floppy body list" % p.get_name())
1670 self.floppy_bodies.remove(p)
1673 def set_floppy_bodies(self):
1674 for p
in self.floppy_bodies:
1676 p.set_name(name +
"_floppy_body")
1678 print(
"I'm trying to make this particle flexible although it was assigned to a rigid body", p.get_name())
1681 rb.set_is_rigid_member(p.get_index(),
False)
1684 rb.set_is_rigid_member(p.get_particle_index(),
False)
1685 p.set_name(p.get_name() +
"_rigid_body_member")
1687 def set_floppy_bodies_from_hierarchies(self, hiers):
1692 self.floppy_bodies.append(p)
1699 selection tuples must be [(r1,r2,"name1"),(r1,r2,"name2"),....]
1700 @return the particles
1703 print(selection_tuples)
1704 for s
in selection_tuples:
1705 ps = IMP.pmi.tools.select_by_tuple(
1706 representation=self, tupleselection=tuple(s),
1707 resolution=
None, name_is_ambiguous=
False)
1711 def get_connected_intra_pairs(self):
1712 return self.connected_intra_pairs
1714 def set_rigid_bodies_max_trans(self, maxtrans):
1715 self.maxtrans_rb = maxtrans
1717 def set_rigid_bodies_max_rot(self, maxrot):
1718 self.maxrot_rb = maxrot
1720 def set_super_rigid_bodies_max_trans(self, maxtrans):
1721 self.maxtrans_srb = maxtrans
1723 def set_super_rigid_bodies_max_rot(self, maxrot):
1724 self.maxrot_srb = maxrot
1726 def set_floppy_bodies_max_trans(self, maxtrans):
1727 self.maxtrans_fb = maxtrans
1731 Fix rigid bodies in their actual position.
1732 The get_particles_to_sample() function will return
1733 just the floppy bodies.
1735 self.rigidbodiesarefixed = rigidbodiesarefixed
1737 def draw_hierarchy_graph(self):
1739 print(
"Drawing hierarchy graph for " + c.get_name())
1740 IMP.pmi.output.get_graph_from_hierarchy(c)
1742 def get_geometries(self):
1745 for name
in self.hier_geometry_pairs:
1746 for pt
in self.hier_geometry_pairs[name]:
1760 def setup_bonds(self):
1763 for name
in self.hier_geometry_pairs:
1764 for pt
in self.hier_geometry_pairs[name]:
1778 def show_component_table(self, name):
1779 if name
in self.sequence_dict:
1780 lastresn = len(self.sequence_dict[name])
1783 residues = self.hier_db.get_residue_numbers(name)
1784 firstresn = min(residues)
1785 lastresn = max(residues)
1787 for nres
in range(firstresn, lastresn + 1):
1789 resolutions = self.hier_db.get_residue_resolutions(name, nres)
1791 for r
in resolutions:
1792 ps += self.hier_db.get_particles(name, nres, r)
1793 print(
"%20s %7s" % (name, nres),
" ".join([
"%20s %7s" % (str(p.get_name()),
1796 print(
"%20s %20s" % (name, nres),
"**** not represented ****")
1798 def draw_hierarchy_composition(self):
1800 ks = list(self.elements.keys())
1804 for k
in self.elements:
1805 for l
in self.elements[k]:
1810 self.draw_component_composition(k, max)
1812 def draw_component_composition(self, name, max=1000, draw_pdb_names=False):
1813 from matplotlib
import pyplot
1814 import matplotlib
as mpl
1816 tmplist = sorted(self.elements[k], key=itemgetter(0))
1818 endres = tmplist[-1][1]
1820 print(
"draw_component_composition: missing information for component %s" % name)
1822 fig = pyplot.figure(figsize=(26.0 * float(endres) / max + 2, 2))
1823 ax = fig.add_axes([0.05, 0.475, 0.9, 0.15])
1828 norm = mpl.colors.Normalize(vmin=5, vmax=10)
1832 for n, l
in enumerate(tmplist):
1836 if bounds[-1] != l[0]:
1837 colors.append(
"white")
1840 colors.append(
"#99CCFF")
1842 colors.append(
"#FFFF99")
1844 colors.append(
"#33CCCC")
1846 bounds.append(l[1] + 1)
1849 colors.append(
"#99CCFF")
1851 colors.append(
"#FFFF99")
1853 colors.append(
"#33CCCC")
1855 bounds.append(l[1] + 1)
1857 if bounds[-1] - 1 == l[0]:
1861 colors.append(
"white")
1864 bounds.append(bounds[-1])
1865 colors.append(
"white")
1866 cmap = mpl.colors.ListedColormap(colors)
1867 cmap.set_over(
'0.25')
1868 cmap.set_under(
'0.75')
1870 norm = mpl.colors.BoundaryNorm(bounds, cmap.N)
1871 cb2 = mpl.colorbar.ColorbarBase(ax, cmap=cmap,
1877 spacing=
'proportional',
1878 orientation=
'horizontal')
1887 mid = 1.0 / endres * float(l[0])
1892 l[2], xy=(mid, 1), xycoords=
'axes fraction',
1893 xytext=(mid + 0.025, float(npdb - 1) / 2.0 + 1.5), textcoords=
'axes fraction',
1894 arrowprops=dict(arrowstyle=
"->",
1895 connectionstyle=
"angle,angleA=0,angleB=90,rad=10"),
1897 extra_artists.append(t)
1900 title = ax.text(-0.005, 0.5, k, ha=
"right", va=
"center", rotation=90,
1903 extra_artists.append(title)
1905 labels = len(bounds) * [
" "]
1906 ax.set_xticklabels(labels)
1907 mid = 1.0 / endres * float(bounds[0])
1908 t = ax.annotate(bounds[0], xy=(mid, 0), xycoords=
'axes fraction',
1909 xytext=(mid - 0.01, -0.5), textcoords=
'axes fraction',)
1910 extra_artists.append(t)
1911 offsets = [0, -0.5, -1.0]
1913 for n
in range(1, len(bounds)):
1914 if bounds[n] == bounds[n - 1]:
1916 mid = 1.0 / endres * float(bounds[n])
1917 if (float(bounds[n]) - float(bounds[n - 1])) / max <= 0.01:
1919 offset = offsets[nclashes % 3]
1925 bounds[n], xy=(mid, 0), xycoords=
'axes fraction',
1926 xytext=(mid, -0.5 + offset), textcoords=
'axes fraction')
1929 bounds[n], xy=(mid, 0), xycoords=
'axes fraction',
1930 xytext=(mid, -0.5 + offset), textcoords=
'axes fraction', arrowprops=dict(arrowstyle=
"-"))
1931 extra_artists.append(t)
1933 cb2.add_lines(bounds, [
"black"] * len(bounds), [1] * len(bounds))
1937 k +
"structure.pdf",
1940 bbox_extra_artists=(extra_artists),
1941 bbox_inches=
'tight')
1944 def draw_coordinates_projection(self):
1945 import matplotlib.pyplot
as pp
1948 for name
in self.hier_geometry_pairs:
1949 for pt
in self.hier_geometry_pairs[name]:
1959 xpairs.append([x1, x2])
1960 ypairs.append([y1, y2])
1963 for xends, yends
in zip(xpairs, ypairs):
1968 pp.plot(xlist, ylist,
'b-', alpha=0.1)
1971 def get_prot_name_from_particle(self, particle):
1972 names = self.get_component_names()
1973 particle0 = particle
1975 while not name
in names:
1978 particle0 = h.get_particle()
1982 def get_particles_to_sample(self):
1992 if not self.rigidbodiesarefixed:
1993 for rb
in self.rigid_bodies:
1998 if rb
not in self.fixed_rigid_bodies:
2001 for fb
in self.floppy_bodies:
2008 for srb
in self.super_rigid_bodies:
2011 rigid_bodies = list(srb[1])
2012 filtered_rigid_bodies = []
2013 for rb
in rigid_bodies:
2014 if rb
not in self.fixed_rigid_bodies:
2015 filtered_rigid_bodies.append(rb)
2016 srbtmp.append((srb[0], filtered_rigid_bodies))
2018 self.rigid_bodies = rbtmp
2019 self.floppy_bodies = fbtmp
2020 self.super_rigid_bodies = srbtmp
2022 ps[
"Rigid_Bodies_SimplifiedModel"] = (
2026 ps[
"Floppy_Bodies_SimplifiedModel"] = (
2029 ps[
"SR_Bodies_SimplifiedModel"] = (
2030 self.super_rigid_bodies,
2035 def set_output_level(self, level):
2036 self.output_level = level
2038 def _evaluate(self, deriv):
2039 """Evaluate the total score of all added restraints"""
2041 return r.evaluate(deriv)
2043 def get_output(self):
2047 output[
"SimplifiedModel_Total_Score_" +
2048 self.label] = str(self._evaluate(
False))
2049 output[
"SimplifiedModel_Linker_Score_" +
2050 self.label] = str(self.linker_restraints.unprotected_evaluate(
None))
2051 for name
in self.sortedsegments_cr_dict:
2052 partialscore = self.sortedsegments_cr_dict[name].evaluate(
False)
2053 score += partialscore
2055 "SimplifiedModel_Link_SortedSegments_" +
2060 partialscore = self.unmodeledregions_cr_dict[name].evaluate(
False)
2061 score += partialscore
2063 "SimplifiedModel_Link_UnmodeledRegions_" +
2068 for name
in self.linker_restraints_dict:
2073 self.linker_restraints_dict[
2074 name].unprotected_evaluate(
2077 if len(self.reference_structures.keys()) != 0:
2078 rmsds = self.get_all_rmsds()
2081 "SimplifiedModel_" +
2084 self.label] = rmsds[
2087 if self.output_level ==
"high":
2090 output[
"Coordinates_" +
2091 p.get_name() +
"_" + self.label] = str(d)
2093 output[
"_TotalScore"] = str(score)
2096 def get_test_output(self):
2098 output = self.get_output()
2099 for n, p
in enumerate(self.get_particles_to_sample()):
2100 output[
"Particle_to_sample_" + str(n)] = str(p)
2102 output[
"Hierarchy_Dictionary"] = list(self.hier_dict.keys())
2103 output[
"Number_of_floppy_bodies"] = len(self.floppy_bodies)
2104 output[
"Number_of_rigid_bodies"] = len(self.rigid_bodies)
2105 output[
"Number_of_super_bodies"] = len(self.super_rigid_bodies)
2106 output[
"Selection_resolution_1"] = len(
2108 output[
"Selection_resolution_5"] = len(
2110 output[
"Selection_resolution_7"] = len(
2112 output[
"Selection_resolution_10"] = len(
2114 output[
"Selection_resolution_100"] = len(
2117 output[
"Selection_resolution=1"] = len(
2119 output[
"Selection_resolution=1,resid=10"] = len(
2121 for resolution
in self.hier_resolution:
2122 output[
"Hier_resolution_dictionary" +
2123 str(resolution)] = len(self.hier_resolution[resolution])
2124 for name
in self.hier_dict:
2126 "Selection_resolution=1,resid=10,name=" +
2134 "Selection_resolution=1,resid=10,name=" +
2136 ",ambiguous"] = len(
2141 name_is_ambiguous=
True,
2144 "Selection_resolution=1,resid=10,name=" +
2146 ",ambiguous"] = len(
2151 name_is_ambiguous=
True,
2154 "Selection_resolution=1,resrange=(10,20),name=" +
2163 "Selection_resolution=1,resrange=(10,20),name=" +
2165 ",ambiguous"] = len(
2170 name_is_ambiguous=
True,
2174 "Selection_resolution=10,resrange=(10,20),name=" +
2183 "Selection_resolution=10,resrange=(10,20),name=" +
2185 ",ambiguous"] = len(
2190 name_is_ambiguous=
True,
2194 "Selection_resolution=100,resrange=(10,20),name=" +
2203 "Selection_resolution=100,resrange=(10,20),name=" +
2205 ",ambiguous"] = len(
2210 name_is_ambiguous=
True,
2222 def __init__(self, *args, **kwargs):
2223 Representation.__init__(self, *args, **kwargs)
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.
A decorator to associate a particle with a part of a protein/DNA/RNA.
static Gaussian setup_particle(Model *m, ParticleIndex pi)
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.
atom::Hierarchies create_hierarchies(RMF::FileConstHandle fh, Model *m)
def shuffle_configuration
Shuffle configuration; used to restart the optimization.
static Atom setup_particle(Model *m, ParticleIndex pi, Atom other)
static Fragment setup_particle(Model *m, ParticleIndex pi)
Upper bound harmonic function (non-zero when feature > mean)
static Symmetric setup_particle(Model *m, ParticleIndex pi, Float symmetric)
def set_coordinates_from_rmf
Read and replace coordinates from an RMF file.
static XYZR setup_particle(Model *m, ParticleIndex pi)
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.
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.
def setup_component_sequence_connectivity
Generate restraints between contiguous fragments in the hierarchy.
Add uncertainty to a particle.
A score on the distance between the surfaces of two spheres.
static Residue setup_particle(Model *m, ParticleIndex pi, ResidueType t, int index, int insertion_code)
static bool get_is_setup(const IMP::ParticleAdaptor &p)
static bool get_is_setup(const IMP::ParticleAdaptor &p)
static XYZ setup_particle(Model *m, ParticleIndex pi)
void read_pdb(TextInput input, int model, Hierarchy h)
def remove_floppy_bodies
Remove leaves of hierarchies from the floppy bodies list.
Vector3D get_random_vector_in(const Cylinder3D &c)
Generate a random vector in a cylinder with uniform density.
static Uncertainty setup_particle(Model *m, ParticleIndex pi, Float uncertainty)
Add resolution to a particle.
Bond create_bond(Bonded a, Bonded b, Bond o)
Connect the two wrapped particles by a custom bond.
Object used to hold a set of restraints.
static Molecule setup_particle(Model *m, ParticleIndex pi)
Rotation3D get_rotation_about_axis(const Vector3D &axis, double angle)
Generate a Rotation3D object from a rotation around an axis.
Select all CB ATOM records.
A Gaussian distribution in 3D.
static bool get_is_setup(Model *m, ParticleIndex pi)
static Hierarchy setup_particle(Model *m, ParticleIndex pi, ParticleIndexesAdaptor children=ParticleIndexesAdaptor())
Create a Hierarchy of level t by adding the needed attributes.
ParticleIndexPairs get_indexes(const ParticlePairsTemp &ps)
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.
Ints get_index(const ParticlesTemp &particles, const Subset &subset, const Subsets &excluded)
Store a list of ParticleIndexes.
def deprecated_method
Python decorator to mark a method as deprecated.
A decorator for a particle representing an atom.
void transform(XYZ a, const algebra::Transformation3D &tr)
Apply a transformation to the particle.
static Mass setup_particle(Model *m, ParticleIndex pi, Float mass)
Hierarchies get_by_type(Hierarchy mhd, GetByType t)
Gather all the molecular particles of a certain level in the hierarchy.
static Bonded setup_particle(Model *m, ParticleIndex pi)
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.
void load_frame(RMF::FileConstHandle file, RMF::FrameID frame)
Hierarchy create_clone_one(Hierarchy d)
Clone the node in the Hierarchy.
A decorator for a particle with x,y,z coordinates.
static bool get_is_setup(Model *m, ParticleIndex pi)
static Colored setup_particle(Model *m, ParticleIndex pi, Color color)
def set_chain_of_super_rigid_bodies
Make a chain of super rigid bodies from a list of hierarchies.
def add_component_sequence
Add the primary sequence for a single component.
Tools for clustering and cluster analysis.
static Resolution setup_particle(Model *m, ParticleIndex pi, Float resolution)
def create_components_from_rmf
still not working.
Find all nearby pairs by testing all pairs.
Classes for writing output files and processing them.
Simple implementation of segments in 3D.
def deprecated_object
Python decorator to mark a class as deprecated.
A decorator for a residue.
Basic functionality that is expected to be used by a wide variety of IMP users.
General purpose algebraic and geometric methods that are expected to be used by a wide variety of IMP...
static bool get_is_setup(const IMP::ParticleAdaptor &p)
def add_component_density
Sets up a Gaussian Mixture Model for this component.
Sample using Monte Carlo.
The general base class for IMP exceptions.
Hierarchy create_simplified_along_backbone(Chain input, const IntRanges &residue_segments, bool keep_detailed=false)
IMP::core::RigidBody create_rigid_body(Hierarchy h)
static Reference setup_particle(Model *m, ParticleIndex pi, ParticleIndexAdaptor reference)
Rotation3D get_identity_rotation_3d()
Return a rotation that does not do anything.
void link_hierarchies(RMF::FileConstHandle fh, const atom::Hierarchies &hs)
Class to handle individual model particles.
std::string get_data_path(std::string file_name)
Return the full path to one of this module's data files.
Select atoms which are selected by either selector.
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)
double get_resolution(Model *m, ParticleIndex pi)
Estimate the resolution of the hierarchy as used by Representation.
Set up the representation of all proteins and nucleic acid macromolecules.
static bool get_is_setup(const IMP::ParticleAdaptor &p)
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.
static Chain setup_particle(Model *m, ParticleIndex pi, std::string id)
Hierarchies get_leaves(const Selection &h)
def add_component_necklace
Generates a string of beads with given length.
An exception for an invalid value being passed to IMP.
Select hierarchy particles identified by the biological name.
Select all ATOM and HETATM records with the given chain ids.
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).
static bool get_is_setup(const IMP::ParticleAdaptor &p)
Transformation3D get_random_local_transformation(Vector3D origin, double max_translation=5., double max_angle_in_rad=0.26)
Get a local transformation.
def check_root
If the root hierarchy does not exist, construct it.
def add_component_beads
add beads to the representation
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.