3 """@namespace IMP.pmi.representation
4 Representation of the system.
15 from math
import pi, sqrt
17 from operator
import itemgetter
25 class Representation(object):
29 This class creates the molecular hierarchies, representation,
30 sequence connectivity for the various involved proteins and
31 nucleic acid macromolecules:
33 Create a protein, DNA or RNA, represent it as a set of connected balls of appropriate
34 radii and number of residues, pdb at given resolution(s), or ideal helices.
36 To initialize the class:
39 upperharmonic Bool This flag uses either harmonic (False)
40 or upperharmonic (True) in the intra-pair
41 connectivity restraint. Default is True.
42 disorderedlength Bool This flag uses either disordered length
43 calculated for random coil peptides (True) or zero
44 surface-to-surface distance between beads (False)
45 as optimal distance for the sequence connectivity
46 restraint. Default is False.
48 How to use the SimplifiedModel class (typical use):
50 see test/test_hierarchy_contruction.py
54 1) Create a chain of helices and flexible parts
56 c_1_119 =self.add_component_necklace("prot1",1,119,20)
57 c_120_131 =self.add_component_ideal_helix("prot1",resolutions=[1,10],resrange=(120,131))
58 c_132_138 =self.add_component_beads("prot1",[(132,138)])
59 c_139_156 =self.add_component_ideal_helix("prot1",resolutions=[1,10],resrange=(139,156))
60 c_157_174 =self.add_component_beads("prot1",[(157,174)])
61 c_175_182 =self.add_component_ideal_helix("prot1",resolutions=[1,10],resrange=(175,182))
62 c_183_194 =self.add_component_beads("prot1",[(183,194)])
63 c_195_216 =self.add_component_ideal_helix("prot1",resolutions=[1,10],resrange=(195,216))
64 c_217_250 =self.add_component_beads("prot1",[(217,250)])
67 self.set_rigid_body_from_hierarchies(c_120_131)
68 self.set_rigid_body_from_hierarchies(c_139_156)
69 self.set_rigid_body_from_hierarchies(c_175_182)
70 self.set_rigid_body_from_hierarchies(c_195_216)
72 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,
75 self.set_chain_of_super_rigid_bodies(clist,2,3)
77 self.set_super_rigid_bodies(["prot1"])
81 def __init__(self, m, upperharmonic=True, disorderedlength=True):
90 self.upperharmonic = upperharmonic
91 self.disorderedlength = disorderedlength
92 self.rigid_bodies = []
93 self.fixed_rigid_bodies = []
94 self.fixed_floppy_bodies = []
95 self.floppy_bodies = []
101 self.super_rigid_bodies = []
102 self.output_level =
"low"
105 self.maxtrans_rb = 2.0
106 self.maxrot_rb = 0.04
107 self.maxtrans_srb = 2.0
108 self.maxrot_srb = 0.2
109 self.rigidbodiesarefixed =
False
110 self.maxtrans_fb = 3.0
111 self.resolution = 10.0
112 self.bblenght = 100.0
116 self.representation_is_modified =
False
117 self.unmodeledregions_cr_dict = {}
118 self.sortedsegments_cr_dict = {}
120 self.connected_intra_pairs = []
123 self.sequence_dict = {}
124 self.hier_geometry_pairs = {}
125 self.hier_db = IMP.pmi.tools.HierarchyDatabase()
130 self.hier_representation = {}
131 self.hier_resolution = {}
134 self.reference_structures = {}
137 self.linker_restraints_dict = {}
138 self.threetoone = {
'ALA':
'A',
'ARG':
'R', 'ASN': 'N', 'ASP': 'D',
139 'CYS':
'C',
'GLU':
'E',
'GLN':
'Q',
'GLY':
'G',
140 'HIS':
'H',
'ILE':
'I',
'LEU':
'L',
'LYS':
'K',
141 'MET':
'M',
'PHE':
'F',
'PRO':
'P',
'SER':
'S',
142 'THR':
'T',
'TRP':
'W',
'TYR':
'Y',
'VAL':
'V',
'UNK':
'X'}
144 self.onetothree = dict((v, k)
for k, v
in self.threetoone.iteritems())
148 def set_label(self, label):
151 def create_component(self, name, color=None):
153 protein_h.set_name(name)
154 self.hier_dict[name] = protein_h
155 self.hier_representation[name] = {}
156 self.hier_db.add_name(name)
157 self.prot.add_child(protein_h)
158 self.color_dict[name] = color
159 self.elements[name] = []
163 def add_component_name(self, *args, **kwargs):
164 IMP.pmi.tools.print_deprecation_warning(
165 "add_component_name",
167 self.create_component(*args, **kwargs)
169 def get_component_names(self):
170 return self.hier_dict.keys()
172 def add_component_sequence(self, name, filename, id=None, offs=None, format="FASTA"):
174 give the component name, the fasta filename,
175 and the id stored in the fasta file (i.e., the header)
176 If the id is not provided, it will assume the same compoennt
179 from Bio
import SeqIO
180 handle = open(filename,
"rU")
181 record_dict = SeqIO.to_dict(SeqIO.parse(handle,
"fasta"))
186 length = len(record_dict[id].seq)
188 raise KeyError(
"id %s not found in fasta file" % id)
190 self.sequence_dict[name] = str(record_dict[id].seq).replace(
"*",
"")
193 self.sequence_dict[name]=offs_str+self.sequence_dict[name]
195 self.elements[name].append((length, length,
" ",
"end"))
197 def autobuild_model(self, name, pdbname, chain,
198 resolutions=
None, resrange=
None,
201 color=
None, pdbresrange=
None, offset=0,
202 show=
False, isnucleicacid=
False,
205 if not beadsize
is None:
206 IMP.pmi.tools.print_deprecation_warning(
210 self.representation_is_modified =
True
214 color = self.color_dict[name]
216 self.color_dict[name] = color
218 if resolutions
is None:
220 print "autobuild_model: constructing %s from pdb %s and chain %s" % (name, pdbname, str(chain))
229 t.get_children()[0].get_children()[0]).
get_index()
231 t.get_children()[0].get_children()[-1]).
get_index()
237 if name
in self.sequence_dict:
238 resrange = (1, len(self.sequence_dict[name]))
240 resrange = (start + offset, end + offset)
242 start = resrange[0] - offset
243 end = resrange[1] - offset
260 for n, g
in enumerate(gaps):
264 print "autobuild_model: constructing fragment %s from pdb" % (str((first, last)))
265 outhiers += self.add_component_pdb(name, pdbname,
266 chain, resolutions=resolutions,
267 color=color, cacenters=
True,
268 resrange=(first, last),
269 offset=offset, isnucleicacid=isnucleicacid)
270 elif g[2] ==
"gap" and n > 0:
271 print "autobuild_model: constructing fragment %s as a bead" % (str((first, last)))
272 parts = self.hier_db.get_particles_at_closest_resolution(
278 outhiers += self.add_component_necklace(name,
279 first+offset, last+offset, missingbeadsize, incoord=xyz)
281 elif g[2] ==
"gap" and n == 0:
283 print "autobuild_model: constructing fragment %s as a bead" % (str((first, last)))
284 outhiers += self.add_component_necklace(name,
285 first+offset, last+offset, missingbeadsize, incoord=xyznter)
291 def autobuild_pdb_and_intervening_beads(self, *args, **kwargs):
292 IMP.pmi.tools.print_deprecation_warning(
293 "autobuild_pdb_and_intervening_beads",
295 r = self.autobuild_model(*args, **kwargs)
298 def add_component_pdb(
299 self, name, pdbname, chain, resolutions, color=
None, resrange=
None, offset=0,
300 cacenters=
True, show=
False, isnucleicacid=
False, readnonwateratoms=
False,
301 read_ca_cb_only=
False):
303 This method reads a pdb, constructs the fragments corresponding to contiguous senquence stretches,
304 and returns a list of hierarchies.
306 name: (string) the name of the component
307 pdbname: (string) the name of the pdb
308 chain: (string or integer) can be either a string (eg, "A")
309 or an integer (eg, 0 or 1) in case you want
310 to get the corresponding chain number in the pdb.
311 resolutions: (integers) a list of integers that corresponds to the resolutions that have to be
313 color: (float from 0 to 1, optional default=None): the color applied to the hierarchies generated
315 resrange: (tuple of integers, optional, default=None): specifies the residue range to extract from the pdb
316 it is a tuple (beg,end). If not specified, it takes all residues belonging to
318 offset: (integer, optional, default=0): specifies the residue index offset to be applied when reading the pdb
319 cacenters: (boolean, optional, default=True): if True generates resolution=1 beads centered on C-alpha atoms.
320 show: (boolean, optional, default=False): print out the molecular hierarchy at the end.
321 isnucleicacid: (boolean, optional, default=False): use True if you're reading a pdb with nucleic acid.
322 readnonwateratoms:(boolean, optional, default=False): if True fixes some pathological pdb.
323 read_ca_cb_only: (boolean, optional, default=False): if True, only reads CA/CB
326 self.representation_is_modified =
True
329 color = self.color_dict[name]
330 protein_h = self.hier_dict[name]
340 if type(chain) == str:
348 t.get_children()[0].get_children()[0]).
get_index()
350 t.get_children()[0].get_children()[-1]).
get_index()
362 if not resrange
is None:
363 if resrange[0] > start:
365 if resrange[1] < end:
368 if not isnucleicacid:
372 residue_indexes=range(
375 atom_type=IMP.atom.AT_CA)
381 residue_indexes=range(
384 atom_type=IMP.atom.AT_P)
386 ps = sel.get_selected_particles()
388 raise ValueError(
"%s no residue found in pdb %s chain %s that overlaps with the queried stretch %s-%s" \
389 % (name, pdbname, str(chain), str(resrange[0]), str(resrange[1])))
397 start = start + offset
400 self.elements[name].append(
401 (start, end, pdbname.split(
"/")[-1] +
":" + chain,
"pdb"))
403 outhiers += self.coarse_hierarchy(name, start, end,
404 resolutions, isnucleicacid, c0, protein_h,
"pdb", color)
415 def add_component_ideal_helix(
423 self.representation_is_modified =
True
424 from math
import pi, cos, sin
426 protein_h = self.hier_dict[name]
429 color = self.color_dict[name]
433 self.elements[name].append((start, end,
" ",
"helix"))
435 for n, res
in enumerate(range(start, end + 1)):
436 if name
in self.sequence_dict:
438 rtstr = self.onetothree[
439 self.sequence_dict[name][res-1]]
459 x = 2.3 * cos(n * 2 * pi / 3.6)
460 y = 2.3 * sin(n * 2 * pi / 3.6)
461 z = 6.2 / 3.6 / 2 * n * 2 * pi / 3.6
469 outhiers += self.coarse_hierarchy(name, start, end,
470 resolutions,
False, c0, protein_h,
"helix", color)
478 def add_component_beads(self, name, ds, colors=None, incoord=None):
481 self.representation_is_modified =
True
483 protein_h = self.hier_dict[name]
486 colors = [self.color_dict[name]]
488 for n, dss
in enumerate(ds):
489 ds_frag = (dss[0], dss[1])
490 self.elements[name].append((dss[0], dss[1],
" ",
"bead"))
492 if ds_frag[0] == ds_frag[1]:
494 if name
in self.sequence_dict:
496 rtstr = self.onetothree[
497 self.sequence_dict[name][ds_frag[0]-1]]
504 h.set_name(name +
'_%i_bead' % (ds_frag[0]))
505 prt.set_name(name +
'_%i_bead' % (ds_frag[0]))
509 h.set_name(name +
'_%i-%i_bead' % (ds_frag[0], ds_frag[1]))
510 prt.set_name(name +
'_%i-%i_bead' % (ds_frag[0], ds_frag[1]))
511 h.set_residue_indexes(range(ds_frag[0], ds_frag[1] + 1))
512 resolution = len(h.get_residue_indexes())
513 if "Beads" not in self.hier_representation[name]:
515 root.set_name(
"Beads")
516 self.hier_representation[name][
"Beads"] = root
517 protein_h.add_child(root)
518 self.hier_representation[name][
"Beads"].add_child(h)
520 for kk
in range(ds_frag[0], ds_frag[1] + 1):
521 self.hier_db.add_particles(name, kk, resolution, [h])
544 ptem.set_radius(radius)
547 radius = 0.8 * (3.0 / 4.0 / pi * volume) ** (1.0 / 3.0)
549 ptem.set_radius(radius)
551 if not tuple(incoord)
is None:
552 ptem.set_coordinates(incoord)
557 self.floppy_bodies.append(prt)
563 def add_component_necklace(self, name, begin, end, length, color=None, incoord=None):
565 generates a string of beads with given length
567 self.representation_is_modified =
True
574 outhiers += self.add_component_beads(name,
575 [(chunk[0], chunk[-1])], colors=colors,incoord=incoord)
578 def add_component_density(
579 self, name, hierarchies=
None, selection_tuples=
None,
581 resolution=0.0, num_components=10,
582 inputfile=
None, outputfile=
None,
585 covariance_type=
'full', voxel_size=1.0,
587 sampled_points=1000000, num_iter=100,
589 multiply_by_total_mass=
True,
591 intermediate_map_fn=
None,
592 density_ps_to_copy=
None,
593 use_precomputed_gaussians=
False):
595 This function sets up a GMM for this component.
596 Can specify input GMM file or it will be computed.
598 hierarchies: set up GMM for some hierarchies
599 selection_tuples: (list of tuples) example (first_residue,last_residue,component_name)
600 particles: set up GMM for particles directly
601 resolution: usual PMI resolution for selecting particles from the hierarchies
602 inputfile: read the GMM from this file
603 outputfile: fit and write the GMM to this file (text)
604 outputmap: after fitting, create GMM density file (mrc)
605 kernel_type: for creating the intermediate density (points are sampled to make GMM)
606 options are IMP.em.GAUSSIAN, IMP.em.SPHERE, and IMP.em.BINARIZED_SPHERE
607 covariance_type: for fitting the GMM. options are 'full', 'diagonal' and 'spherical'
608 voxel_size: for creating the intermediate density map and output map.
609 lower number increases accuracy but also rasterizing time grows
610 out_hier_name: name of the output density hierarchy
611 sampled_points: number of points to sample. more will increase accuracy and fitting time
612 num_iter: num GMM iterations. more will increase accuracy and fitting time
613 multiply_by_total_mass: multiply the weights of the GMM by this value (only works on creation!)
614 transform: for input file only, apply a transformation (eg for multiple copies same GMM)
615 intermediate_map_fn: for debugging, this will write the itermediate (simulated) map
616 density_ps_to_copy: in case you already created the appropriate GMM (eg, for beads)
617 use_precomputed_gaussians: Set this flag and pass fragments - will use roughly spherical gaussian setup
625 self.representation_is_modified =
True
627 protein_h = self.hier_dict[name]
628 if "Densities" not in self.hier_representation[name]:
630 root.set_name(
"Densities")
631 self.hier_representation[name][
"Densities"] = root
632 protein_h.add_child(root)
635 fragment_particles = []
636 if not particles
is None:
637 fragment_particles += particles
638 if not hierarchies
is None:
640 self, resolution=resolution,
641 hierarchies=hierarchies)
642 if not selection_tuples
is None:
643 for st
in selection_tuples:
644 fragment_particles += IMP.pmi.tools.select_by_tuple(
645 self, tupleselection=st,
646 resolution=resolution,
647 name_is_ambiguous=
False)
650 density_particles = []
653 inputfile, density_particles,
655 elif density_ps_to_copy:
656 for ip
in density_ps_to_copy:
662 density_particles.append(p)
663 elif use_precomputed_gaussians:
664 if len(fragment_particles) == 0:
665 print "add_component_density: no particle was selected"
667 for p
in fragment_particles:
670 raise Exception(
"The particles you selected must be Fragments and XYZs")
672 pos=
IMP.core.XYZ(self.m,p.get_particle_index()).get_coordinates()
677 raise Exception(
"We haven't created a bead file for",nres,
"residues")
684 if len(fragment_particles) == 0:
685 print "add_component_density: no particle was selected"
688 density_particles = IMP.isd.gmm_tools.sample_and_fit_to_particles(
697 multiply_by_total_mass,
703 s0.set_name(out_hier_name)
704 self.hier_representation[name][
"Densities"].add_child(s0)
706 for nps, p
in enumerate(density_particles):
708 p.set_name(s0.get_name() +
'_gaussian_%i' % nps)
711 def get_component_density(self, name):
712 return self.hier_representation[name][
"Densities"]
714 def add_all_atom_densities(self, name, hierarchies=None,
715 selection_tuples=
None,
720 '''This function decorates all specified particles as Gaussians directly.
722 hierarchies: set up GMM for some hierarchies
723 selection_tuples: (list of tuples) example (first_residue,last_residue,component_name)
724 particles: set up GMM for particles directly
725 resolution: usual PMI resolution for selecting particles from the hierarchies
726 intermediate_map_fn: for debugging, this will write the itermediate (simulated) map
732 from math
import sqrt
733 self.representation_is_modified =
False
735 if particles
is None:
736 fragment_particles = []
738 fragment_particles = particles
740 if not hierarchies
is None:
742 self, resolution=resolution,
743 hierarchies=hierarchies)
745 if not selection_tuples
is None:
746 for st
in selection_tuples:
747 fragment_particles += IMP.pmi.tools.select_by_tuple(
748 self, tupleselection=st,
749 resolution=resolution,
750 name_is_ambiguous=
False)
752 if len(fragment_particles) == 0:
753 print "add all atom densities: no particle was selected"
757 print 'setting up all atom gaussians num_particles',len(fragment_particles)
758 for n,p
in enumerate(fragment_particles):
766 print 'setting up particle',p.get_name(),
" as individual gaussian particle"
768 if not output_map
is None:
769 print 'writing map to', output_map
775 def add_component_hierarchy_clone(self, name, hierarchy):
777 this function makes a copy of a hierarchy and append it to a
781 self.representation_is_modified =
True
782 protein_h = self.hier_dict[name]
784 hierclone.set_name(hierclone.get_name() +
"_clone")
785 protein_h.add_child(hierclone)
786 outhier.append(hierclone)
792 for n, pmain
in enumerate(psmain):
798 self.hier_db.add_particles(
814 def set_coordinates_from_rmf(
819 rmf_component_name=
None):
820 '''This function read and replace coordinates from an rmf file
821 It looks for the component with the same name, unless the rmf_component_name
822 is defined. Replace the coordinates of particles with the same name
823 It assumes that the rmf and the represdentation have the particles in the same order'''
827 prot = IMP.pmi.analysis.get_hier_from_rmf(
833 raise ValueError(
"cannot read hiearchy from rmf")
843 p, self.hier_dict.keys())
844 if not rmf_component_name
is None and protname == rmf_component_name:
846 elif rmf_component_name
is None and protname == component_name:
851 if len(psrmf) != len(psrepr):
852 raise ValueError(
"cannot proceed the rmf and the representation don't have the same number of particles; "
853 "particles in rmf: %s particles in the representation: %s" % (str(len(psrmf)), str(len(psrepr))))
855 for n, prmf
in enumerate(psrmf):
856 prmfname = prmf.get_name()
857 preprname = psrepr[n].get_name()
859 raise ValueError(
"component %s cannot proceed if rigid bodies were initialized. Use the function before defining the rigid bodies" % component_name)
861 raise ValueError(
"component %s cannot proceed if rigid bodies were initialized. Use the function before defining the rigid bodies" % component_name)
863 if prmfname != preprname:
864 print "set_coordinates_from_rmf: WARNING rmf particle and representation particles have not the same name %s %s " % (prmfname, preprname)
871 def check_root(self, name, protein_h, resolution):
873 checks whether the root hierarchy exists, and if not
874 suitably constructs it
876 if "Res:" + str(int(resolution))
not in self.hier_representation[name]:
878 root.set_name(name +
"_Res:" + str(int(resolution)))
879 self.hier_representation[name][
880 "Res:" + str(int(resolution))] = root
881 protein_h.add_child(root)
883 def coarse_hierarchy(
895 this function generates all needed coarse grained layers
896 name is the name of the protein
897 resolutions is the list of resolutions
898 protein_h is the root hierarchy
899 input hierarchy is the hierarchy to coarse grain
900 type is a string, typically "pdb" or "helix"
904 if (1
in resolutions)
or (0
in resolutions):
908 self.check_root(name, protein_h, 1)
910 s1.set_name(
'%s_%i-%i_%s' % (name, start, end, type))
912 self.hier_representation[name][
"Res:1"].add_child(s1)
915 self.check_root(name, protein_h, 0)
917 s0.set_name(
'%s_%i-%i_%s' % (name, start, end, type))
919 self.hier_representation[name][
"Res:0"].add_child(s0)
922 if not isnucleicacid:
925 atom_type=IMP.atom.AT_CA)
929 atom_type=IMP.atom.AT_P)
931 for p
in sel.get_selected_particles():
937 s0.add_child(resclone0)
938 self.hier_db.add_particles(
942 resclone0.get_children())
944 chil = resclone0.get_children()
957 s1.add_child(resclone1)
958 self.hier_db.add_particles(name, resindex, 1, [resclone1])
962 prt = resclone1.get_particle()
963 prt.set_name(
'%s_%i_%s' % (name, resindex, type))
985 for r
in resolutions:
986 if r != 0
and r != 1:
987 self.check_root(name, protein_h, r)
992 chil = s.get_children()
994 s0.set_name(
'%s_%i-%i_%s' % (name, start, end, type))
998 self.hier_representation[name][
999 "Res:" + str(int(r))].add_child(s0)
1008 prt.set_name(
'%s_%i_%s' % (name, first, type))
1010 prt.set_name(
'%s_%i_%i_%s' % (name, first, last, type))
1012 self.hier_db.add_particles(name, kk, r, [prt])
1031 def get_hierarchies_at_given_resolution(self, resolution):
1033 this function caches the map between resolution and hierarchies
1034 to accelerate the selection algorithm
1035 if the representation was changed by any add_component_xxx, the function recalculates
1039 if self.representation_is_modified:
1040 rhbr = self.hier_db.get_all_root_hierarchies_by_resolution(
1042 self.hier_resolution[resolution] = rhbr
1043 self.representation_is_modified =
False
1046 if resolution
in self.hier_resolution:
1047 return self.hier_resolution[resolution]
1049 rhbr = self.hier_db.get_all_root_hierarchies_by_resolution(
1051 self.hier_resolution[resolution] = rhbr
1054 def shuffle_configuration(
1055 self, max_translation=300., max_rotation=2.0 * pi,
1056 avoidcollision=
True, cutoff=10.0, niterations=100,
1058 excluded_rigid_bodies=
None,
1059 hierarchies_excluded_from_collision=
None):
1061 shuffle configuration, used to restart the optimization
1062 it works correctly if rigid bodies were initialized
1063 avoidcollision check if the particle/rigid body was placed close to another particle
1064 avoidcollision uses the optional arguments cutoff and niterations
1066 bounding box is defined by ((x1,y1,z1),(x2,y2,z2))
1070 if excluded_rigid_bodies
is None:
1071 excluded_rigid_bodies = []
1072 if hierarchies_excluded_from_collision
is None:
1073 hierarchies_excluded_from_collision = []
1075 if len(self.rigid_bodies) == 0:
1076 print "shuffle_configuration: rigid bodies were not intialized"
1079 gcpf.set_distance(cutoff)
1081 hierarchies_excluded_from_collision_indexes = []
1087 hierarchies_excluded_from_collision_indexes += IMP.get_indexes([p])
1088 allparticleindexes = IMP.get_indexes(ps)
1090 if not bounding_box
is None:
1091 ((x1, y1, z1), (x2, y2, z2)) = bounding_box
1096 for h
in hierarchies_excluded_from_collision:
1100 allparticleindexes = list(
1101 set(allparticleindexes) - set(hierarchies_excluded_from_collision_indexes))
1103 print hierarchies_excluded_from_collision
1104 print len(allparticleindexes),len(hierarchies_excluded_from_collision_indexes)
1106 for rb
in self.rigid_bodies:
1107 if rb
not in excluded_rigid_bodies:
1110 rbindexes = rb.get_member_particle_indexes()
1113 set(rbindexes) - set(hierarchies_excluded_from_collision_indexes))
1114 otherparticleindexes = list(
1115 set(allparticleindexes) - set(rbindexes))
1117 if len(otherparticleindexes)
is None:
1121 while niter < niterations:
1122 rbxyz = (rb.get_x(), rb.get_y(), rb.get_z())
1124 if not bounding_box
is None:
1142 gcpf.get_close_pairs(
1144 otherparticleindexes,
1150 print "shuffle_configuration: rigid body placed close to other %d particles, trying again..." % npairs
1151 print "shuffle_configuration: rigid body name: " + rb.get_name()
1152 if niter == niterations:
1153 raise ValueError(
"tried the maximum number of iterations to avoid collisions, increase the distance cutoff")
1157 print 'shuffling', len(self.floppy_bodies),
'floppy bodies'
1158 for fb
in self.floppy_bodies:
1163 fbindexes = IMP.get_indexes([fb])
1164 otherparticleindexes = list(
1165 set(allparticleindexes) - set(fbindexes))
1166 if len(otherparticleindexes)
is None:
1172 while niter < niterations:
1174 if not bounding_box
is None:
1189 gcpf.get_close_pairs(
1191 otherparticleindexes,
1197 print "shuffle_configuration: floppy body placed close to other %d particles, trying again..." % npairs
1198 if niter == niterations:
1199 raise ValueError(
"tried the maximum number of iterations to avoid collisions, increase the distance cutoff")
1203 def set_current_coordinates_as_reference_for_rmsd(self, label="None"):
1207 self.reference_structures[label] = (
1211 def get_all_rmsds(self):
1214 for label
in self.reference_structures:
1216 current_coordinates = [
IMP.core.XYZ(p).get_coordinates()
1217 for p
in self.reference_structures[label][1]]
1218 reference_coordinates = self.reference_structures[label][0]
1219 if len(reference_coordinates) != len(current_coordinates):
1220 print "calculate_all_rmsds: reference and actual coordinates are not the same"
1223 current_coordinates,
1224 reference_coordinates)
1226 reference_coordinates,
1227 current_coordinates)
1231 reference_coordinates,
1232 current_coordinates)
1233 rmsds[label +
"_GlobalRMSD"] = rmsd_global
1234 rmsds[label +
"_RelativeDRMS"] = rmsd_relative
1237 def setup_component_geometry(self, name, color=None, resolution=1.0):
1239 color = self.color_dict[name]
1243 self.hier_geometry_pairs[name] = []
1244 protein_h = self.hier_dict[name]
1246 pbr = IMP.pmi.tools.sort_by_residues(pbr)
1248 for n
in range(len(pbr) - 1):
1249 self.hier_geometry_pairs[name].append((pbr[n], pbr[n + 1], color))
1251 def setup_component_sequence_connectivity(
1257 This method generates restraints between contiguous fragments
1258 in the hierarchy. The linkers are generated at resolution 10 by default.
1265 protein_h = self.hier_dict[name]
1267 frs = self.hier_db.get_preroot_fragments_by_resolution(
1273 start = fr.get_children()[0]
1278 end = fr.get_children()[-1]
1284 SortedSegments.append((start, end, startres))
1285 SortedSegments = sorted(SortedSegments, key=itemgetter(2))
1288 for x
in xrange(len(SortedSegments) - 1):
1289 last = SortedSegments[x][1]
1290 first = SortedSegments[x + 1][0]
1297 residuegap = firstresn - lastresn - 1
1298 if self.disorderedlength
and (nreslast / 2 + nresfirst / 2 + residuegap) > 20.0:
1301 optdist = sqrt(5 / 3) * 1.93 * \
1302 (nreslast / 2 + nresfirst / 2 + residuegap) ** 0.6
1304 if self.upperharmonic:
1310 optdist = (0.0 + (float(residuegap) + 1.0) * 3.6) * scale
1311 if self.upperharmonic:
1317 pt0 = last.get_particle()
1318 pt1 = first.get_particle()
1321 print "Adding sequence connectivity restraint between", pt0.get_name(),
" and ", pt1.get_name(),
'of distance', optdist
1322 sortedsegments_cr.add_restraint(r)
1323 self.linker_restraints_dict[
1324 "LinkerRestraint-" + pt0.get_name() +
"-" + pt1.get_name()] = r
1325 self.connected_intra_pairs.append((pt0, pt1))
1326 self.connected_intra_pairs.append((pt1, pt0))
1328 self.m.add_restraint(sortedsegments_cr)
1329 self.m.add_restraint(unmodeledregions_cr)
1330 self.linker_restraints.add_restraint(sortedsegments_cr)
1331 self.linker_restraints.add_restraint(unmodeledregions_cr)
1332 self.sortedsegments_cr_dict[name] = sortedsegments_cr
1333 self.unmodeledregions_cr_dict[name] = unmodeledregions_cr
1335 def optimize_floppy_bodies(self, nsteps, temperature=1.0):
1337 pts = IMP.pmi.tools.ParticleToSampleList()
1338 for n, fb
in enumerate(self.floppy_bodies):
1339 pts.add_particle(fb,
"Floppy_Bodies", 1.0,
"Floppy_Body_" + str(n))
1340 if len(pts.get_particles_to_sample()) > 0:
1341 mc = IMP.pmi.samplers.MonteCarlo(self.m, [pts], temperature)
1342 print "optimize_floppy_bodies: optimizing %i floppy bodies" % len(self.floppy_bodies)
1345 print "optimize_floppy_bodies: no particle to optimize"
1347 def create_rotational_symmetry(self, maincopy, copies):
1349 self.representation_is_modified =
True
1350 ncopies = len(copies) + 1
1353 mainparticles = sel.get_selected_particles()
1355 for k
in range(len(copies)):
1361 copyparticles = sel.get_selected_particles()
1365 for n, p
in enumerate(mainparticles):
1367 pc = copyparticles[n]
1369 mainpurged.append(p)
1372 copypurged.append(pc)
1376 for n, p
in enumerate(mainpurged):
1379 print "setting " + p.get_name() +
" as reference for " + pc.get_name()
1385 self.m.add_score_state(c)
1389 def create_amyloid_fibril_symmetry(self, maincopy, axial_copies,
1390 longitudinal_copies, axis=(0, 0, 1), translation_value=4.8):
1393 self.representation_is_modified =
True
1396 protein_h = self.hier_dict[maincopy]
1399 for ilc
in range(-longitudinal_copies, longitudinal_copies + 1):
1400 for iac
in range(axial_copies):
1401 copyname = maincopy +
"_a" + str(ilc) +
"_l" + str(iac)
1402 self.add_component_name(copyname, 0.0)
1403 for hier
in protein_h.get_children():
1404 self.add_component_hierarchy_clone(copyname, hier)
1405 copyhier = self.hier_dict[copyname]
1406 outhiers.append(copyhier)
1410 2 * pi / axial_copies * (float(iac)))
1411 translation_vector = tuple(
1412 [translation_value * float(ilc) * x
for x
in axis])
1413 print translation_vector
1418 for n, p
in enumerate(mainparts):
1427 self.m.add_score_state(c)
1431 def link_components_to_rmf(self, rmfname, frameindex):
1433 load coordinates in the current representation
1434 this should be done only if the hierarchy self.prot is identical to the one
1435 i.e. all components were added
1436 as stored in the rmf
1441 rh = RMF.open_rmf_file_read_only(rmfname)
1446 def create_components_from_rmf(self, rmfname, frameindex):
1449 create the representation (i.e. hierarchies) from the rmf file.
1450 it will be stored in self.prot, which will be overwritten.
1451 load the coordinates from the rmf file at frameindex.
1453 rh = RMF.open_rmf_file(rmfname)
1459 for p
in self.prot.get_children():
1460 self.add_component_name(p.get_name())
1461 self.hier_dict[p.get_name()] = p
1463 still missing: save rigid bodies contained in the rmf in self.rigid_bodies
1464 save floppy bodies in self.floppy_bodies
1465 get the connectivity restraints
1468 def set_rigid_body_from_hierarchies(self, hiers, particles=None):
1470 This method allows the construction of a rigid body given a list
1471 of hierarchies and or a list of particles.
1473 hiers: list of hierarchies
1474 particles: (optional, default=None) list of particles to add to the rigid body
1477 if particles
is None:
1480 rigid_parts = set(particles)
1483 print "set_rigid_body_from_hierarchies> setting up a new rigid body"
1490 print "set_rigid_body_from_hierarchies> WARNING particle %s already belongs to rigid body %s" % (p.get_name(), rb.get_name())
1493 name += hier.get_name() +
"-"
1494 print "set_rigid_body_from_hierarchies> adding %s to the rigid body" % hier.get_name()
1496 if len(list(rigid_parts)) != 0:
1498 rb.set_coordinates_are_optimized(
True)
1499 rb.set_name(name +
"rigid_body")
1500 self.rigid_bodies.append(rb)
1504 print "set_rigid_body_from_hierarchies> rigid body could not be setup"
1506 def set_rigid_bodies(self, subunits):
1508 This method allows the construction of a rigid body given a list
1509 of tuples, that identify the residue ranges and the subunit names (the names used
1510 to create the component by using create_component.
1512 subunits: [(name_1,(first_residue_1,last_residue_1)),(name_2,(first_residue_2,last_residue_2)),.....]
1514 [name_1,name_2,(name_3,(first_residue_3,last_residue_3)),.....]
1516 example: ["prot1","prot2",("prot3",(1,10))]
1518 sometimes, we know about structure of an interaction
1519 and here we make such PPIs rigid
1524 if type(s) == type(tuple())
and len(s) == 2:
1528 residue_indexes=range(s[1][0],
1530 if len(sel.get_selected_particles()) == 0:
1531 print "set_rigid_bodies: selected particle does not exists"
1532 for p
in sel.get_selected_particles():
1536 print "set_rigid_body_from_hierarchies> WARNING particle %s already belongs to rigid body %s" % (p.get_name(), rb.get_name())
1540 elif type(s) == type(str()):
1542 if len(sel.get_selected_particles()) == 0:
1543 print "set_rigid_bodies: selected particle does not exists"
1544 for p
in sel.get_selected_particles():
1548 print "set_rigid_body_from_hierarchies> WARNING particle %s already belongs to rigid body %s" % (p.get_name(), rb.get_name())
1553 rb.set_coordinates_are_optimized(
True)
1554 rb.set_name(
''.join(str(subunits)) +
"_rigid_body")
1555 self.rigid_bodies.append(rb)
1558 def set_super_rigid_body_from_hierarchies(
1564 super_rigid_xyzs = set()
1565 super_rigid_rbs = set()
1567 print "set_super_rigid_body_from_hierarchies> setting up a new SUPER rigid body"
1574 super_rigid_rbs.add(rb)
1576 super_rigid_xyzs.add(p)
1577 print "set_rigid_body_from_hierarchies> adding %s to the rigid body" % hier.get_name()
1578 if len(super_rigid_rbs) < min_size:
1581 self.super_rigid_bodies.append((super_rigid_xyzs, super_rigid_rbs))
1584 self.super_rigid_bodies.append(
1585 (super_rigid_xyzs, super_rigid_rbs, axis))
1587 def fix_rigid_bodies(self, rigid_bodies):
1588 self.fixed_rigid_bodies += rigid_bodies
1591 def set_chain_of_super_rigid_bodies(
1598 this function takes a linear list of hierarchies (they are supposed
1599 to be sequence-contiguous) and
1600 produces a chain of super rigid bodies with given length range, specified
1601 by min_length and max_length
1604 hiers = IMP.pmi.tools.flatten_list(hiers)
1608 self.set_super_rigid_body_from_hierarchies(hs, axis, min_length)
1610 def set_super_rigid_bodies(self, subunits, coords=None):
1611 super_rigid_xyzs = set()
1612 super_rigid_rbs = set()
1615 if type(s) == type(tuple())
and len(s) == 3:
1619 residue_indexes=range(s[0],
1621 if len(sel.get_selected_particles()) == 0:
1622 print "set_rigid_bodies: selected particle does not exists"
1623 for p
in sel.get_selected_particles():
1626 super_rigid_rbs.add(rb)
1628 super_rigid_xyzs.add(p)
1629 elif type(s) == type(str()):
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():
1637 super_rigid_rbs.add(rb)
1639 super_rigid_xyzs.add(p)
1640 self.super_rigid_bodies.append((super_rigid_xyzs, super_rigid_rbs))
1642 def remove_floppy_bodies(self, hierarchies):
1644 give a list of hierarchies, get the leaves and remove the corresponding particles
1645 from the floppy bodies list. We need this function because sometimes
1646 we want to constraint the floppy bodies in a rigid body. For instance
1647 when you want to associate a bead with a density particle.
1649 for h
in hierarchies:
1652 if p
in self.floppy_bodies:
1653 print "remove_floppy_bodies: removing %s from floppy body list" % p.get_name()
1654 self.floppy_bodies.remove(p)
1657 def set_floppy_bodies(self):
1658 for p
in self.floppy_bodies:
1660 p.set_name(name +
"_floppy_body")
1662 print "I'm trying to make this particle flexible although it was assigned to a rigid body", p.get_name()
1665 rb.set_is_rigid_member(p.get_index(),
False)
1668 rb.set_is_rigid_member(p.get_particle_index(),
False)
1669 p.set_name(p.get_name() +
"_rigid_body_member")
1671 def set_floppy_bodies_from_hierarchies(self, hiers):
1676 self.floppy_bodies.append(p)
1678 def get_particles_from_selection_tuples(
1683 selection tuples must be [(r1,r2,"name1"),(r1,r2,"name2"),....]
1684 return the particles
1687 print selection_tuples
1688 for s
in selection_tuples:
1689 ps = IMP.pmi.tools.select_by_tuple(
1690 representation=self, tupleselection=tuple(s),
1691 resolution=
None, name_is_ambiguous=
False)
1695 def get_connected_intra_pairs(self):
1696 return self.connected_intra_pairs
1698 def set_rigid_bodies_max_trans(self, maxtrans):
1699 self.maxtrans_rb = maxtrans
1701 def set_rigid_bodies_max_rot(self, maxrot):
1702 self.maxrot_rb = maxrot
1704 def set_super_rigid_bodies_max_trans(self, maxtrans):
1705 self.maxtrans_srb = maxtrans
1707 def set_super_rigid_bodies_max_rot(self, maxrot):
1708 self.maxrot_srb = maxrot
1710 def set_floppy_bodies_max_trans(self, maxtrans):
1711 self.maxtrans_fb = maxtrans
1713 def set_rigid_bodies_as_fixed(self, rigidbodiesarefixed=True):
1715 this function will fix rigid bodies in their actual
1716 position. the get_particles_to_sample function will return
1717 just the floppy bodies.
1719 self.rigidbodiesarefixed = rigidbodiesarefixed
1721 def draw_hierarchy_graph(self):
1723 print "Drawing hierarchy graph for " + c.get_name()
1724 IMP.pmi.output.get_graph_from_hierarchy(c)
1726 def get_geometries(self):
1729 for name
in self.hier_geometry_pairs:
1730 for pt
in self.hier_geometry_pairs[name]:
1744 def setup_bonds(self):
1747 for name
in self.hier_geometry_pairs:
1748 for pt
in self.hier_geometry_pairs[name]:
1762 def show_component_table(self, name):
1763 if name
in self.sequence_dict:
1764 lastresn = len(self.sequence_dict[name])
1767 residues = self.hier_db.get_residue_numbers(name)
1768 firstresn = min(residues)
1769 lastresn = max(residues)
1771 for nres
in range(firstresn, lastresn + 1):
1773 resolutions = self.hier_db.get_residue_resolutions(name, nres)
1775 for r
in resolutions:
1776 ps += self.hier_db.get_particles(name, nres, r)
1777 print "%20s %7s" % (name, nres),
" ".join([
"%20s %7s" % (str(p.get_name()),
1780 print "%20s %20s" % (name, nres),
"**** not represented ****"
1782 def draw_hierarchy_composition(self):
1784 ks = self.elements.keys()
1788 for k
in self.elements:
1789 for l
in self.elements[k]:
1794 self.draw_component_composition(k, max)
1796 def draw_component_composition(self, name, max=1000, draw_pdb_names=False):
1797 from matplotlib
import pyplot
1798 import matplotlib
as mpl
1800 tmplist = sorted(self.elements[k], key=itemgetter(0))
1802 endres = tmplist[-1][1]
1804 print "draw_component_composition: missing information for component %s" % name
1806 fig = pyplot.figure(figsize=(26.0 * float(endres) / max + 2, 2))
1807 ax = fig.add_axes([0.05, 0.475, 0.9, 0.15])
1812 norm = mpl.colors.Normalize(vmin=5, vmax=10)
1816 for n, l
in enumerate(tmplist):
1820 if bounds[-1] != l[0]:
1821 colors.append(
"white")
1824 colors.append(
"#99CCFF")
1826 colors.append(
"#FFFF99")
1828 colors.append(
"#33CCCC")
1830 bounds.append(l[1] + 1)
1833 colors.append(
"#99CCFF")
1835 colors.append(
"#FFFF99")
1837 colors.append(
"#33CCCC")
1839 bounds.append(l[1] + 1)
1841 if bounds[-1] - 1 == l[0]:
1845 colors.append(
"white")
1848 bounds.append(bounds[-1])
1849 colors.append(
"white")
1850 cmap = mpl.colors.ListedColormap(colors)
1851 cmap.set_over(
'0.25')
1852 cmap.set_under(
'0.75')
1854 norm = mpl.colors.BoundaryNorm(bounds, cmap.N)
1855 cb2 = mpl.colorbar.ColorbarBase(ax, cmap=cmap,
1861 spacing=
'proportional',
1862 orientation=
'horizontal')
1871 mid = 1.0 / endres * float(l[0])
1876 l[2], xy=(mid, 1), xycoords=
'axes fraction',
1877 xytext=(mid + 0.025, float(npdb - 1) / 2.0 + 1.5), textcoords=
'axes fraction',
1878 arrowprops=dict(arrowstyle=
"->",
1879 connectionstyle=
"angle,angleA=0,angleB=90,rad=10"),
1881 extra_artists.append(t)
1884 title = ax.text(-0.005, 0.5, k, ha=
"right", va=
"center", rotation=90,
1887 extra_artists.append(title)
1889 labels = len(bounds) * [
" "]
1890 ax.set_xticklabels(labels)
1891 mid = 1.0 / endres * float(bounds[0])
1892 t = ax.annotate(bounds[0], xy=(mid, 0), xycoords=
'axes fraction',
1893 xytext=(mid - 0.01, -0.5), textcoords=
'axes fraction',)
1894 extra_artists.append(t)
1895 offsets = [0, -0.5, -1.0]
1897 for n
in range(1, len(bounds)):
1898 if bounds[n] == bounds[n - 1]:
1900 mid = 1.0 / endres * float(bounds[n])
1901 if (float(bounds[n]) - float(bounds[n - 1])) / max <= 0.01:
1903 offset = offsets[nclashes % 3]
1909 bounds[n], xy=(mid, 0), xycoords=
'axes fraction',
1910 xytext=(mid, -0.5 + offset), textcoords=
'axes fraction')
1913 bounds[n], xy=(mid, 0), xycoords=
'axes fraction',
1914 xytext=(mid, -0.5 + offset), textcoords=
'axes fraction', arrowprops=dict(arrowstyle=
"-"))
1915 extra_artists.append(t)
1917 cb2.add_lines(bounds, [
"black"] * len(bounds), [1] * len(bounds))
1921 k +
"structure.pdf",
1924 bbox_extra_artists=(extra_artists),
1925 bbox_inches=
'tight')
1928 def draw_coordinates_projection(self):
1929 import matplotlib.pyplot
as pp
1932 for name
in self.hier_geometry_pairs:
1933 for pt
in self.hier_geometry_pairs[name]:
1943 xpairs.append([x1, x2])
1944 ypairs.append([y1, y2])
1947 for xends, yends
in zip(xpairs, ypairs):
1952 pp.plot(xlist, ylist,
'b-', alpha=0.1)
1955 def get_prot_name_from_particle(self, particle):
1956 names = self.get_component_names()
1957 particle0 = particle
1959 while not name
in names:
1962 particle0 = h.get_particle()
1966 def get_particles_to_sample(self):
1976 if not self.rigidbodiesarefixed:
1977 for rb
in self.rigid_bodies:
1982 if rb
not in self.fixed_rigid_bodies:
1985 for fb
in self.floppy_bodies:
1992 for srb
in self.super_rigid_bodies:
1995 rigid_bodies = list(srb[1])
1996 filtered_rigid_bodies = []
1997 for rb
in rigid_bodies:
1998 if rb
not in self.fixed_rigid_bodies:
1999 filtered_rigid_bodies.append(rb)
2000 srbtmp.append((srb[0], filtered_rigid_bodies))
2002 self.rigid_bodies = rbtmp
2003 self.floppy_bodies = fbtmp
2004 self.super_rigid_bodies = srbtmp
2006 ps[
"Rigid_Bodies_SimplifiedModel"] = (
2010 ps[
"Floppy_Bodies_SimplifiedModel"] = (
2013 ps[
"SR_Bodies_SimplifiedModel"] = (
2014 self.super_rigid_bodies,
2019 def set_output_level(self, level):
2020 self.output_level = level
2022 def get_output(self):
2026 output[
"SimplifiedModel_Total_Score_" +
2027 self.label] = str(self.m.evaluate(
False))
2028 output[
"SimplifiedModel_Linker_Score_" +
2029 self.label] = str(self.linker_restraints.unprotected_evaluate(
None))
2030 for name
in self.sortedsegments_cr_dict:
2031 partialscore = self.sortedsegments_cr_dict[name].evaluate(
False)
2032 score += partialscore
2034 "SimplifiedModel_Link_SortedSegments_" +
2039 partialscore = self.unmodeledregions_cr_dict[name].evaluate(
False)
2040 score += partialscore
2042 "SimplifiedModel_Link_UnmodeledRegions_" +
2047 for name
in self.linker_restraints_dict:
2052 self.linker_restraints_dict[
2053 name].unprotected_evaluate(
2056 if len(self.reference_structures.keys()) != 0:
2057 rmsds = self.get_all_rmsds()
2060 "SimplifiedModel_" +
2063 self.label] = rmsds[
2066 if self.output_level ==
"high":
2069 output[
"Coordinates_" +
2070 p.get_name() +
"_" + self.label] = str(d)
2072 output[
"_TotalScore"] = str(score)
2075 def get_test_output(self):
2077 output = self.get_output()
2078 for n, p
in enumerate(self.get_particles_to_sample()):
2079 output[
"Particle_to_sample_" + str(n)] = str(p)
2081 output[
"Hierarchy_Dictionary"] = self.hier_dict.keys()
2082 output[
"Number_of_floppy_bodies"] = len(self.floppy_bodies)
2083 output[
"Number_of_rigid_bodies"] = len(self.rigid_bodies)
2084 output[
"Number_of_super_bodies"] = len(self.super_rigid_bodies)
2085 output[
"Selection_resolution_1"] = len(
2087 output[
"Selection_resolution_5"] = len(
2089 output[
"Selection_resolution_7"] = len(
2091 output[
"Selection_resolution_10"] = len(
2093 output[
"Selection_resolution_100"] = len(
2096 output[
"Selection_resolution=1"] = len(
2098 output[
"Selection_resolution=1,resid=10"] = len(
2100 for resolution
in self.hier_resolution:
2101 output[
"Hier_resolution_dictionary" +
2102 str(resolution)] = len(self.hier_resolution[resolution])
2103 for name
in self.hier_dict:
2105 "Selection_resolution=1,resid=10,name=" +
2113 "Selection_resolution=1,resid=10,name=" +
2115 ",ambiguous"] = len(
2120 name_is_ambiguous=
True,
2123 "Selection_resolution=1,resid=10,name=" +
2125 ",ambiguous"] = len(
2130 name_is_ambiguous=
True,
2133 "Selection_resolution=1,resrange=(10,20),name=" +
2142 "Selection_resolution=1,resrange=(10,20),name=" +
2144 ",ambiguous"] = len(
2149 name_is_ambiguous=
True,
2153 "Selection_resolution=10,resrange=(10,20),name=" +
2162 "Selection_resolution=10,resrange=(10,20),name=" +
2164 ",ambiguous"] = len(
2169 name_is_ambiguous=
True,
2173 "Selection_resolution=100,resrange=(10,20),name=" +
2182 "Selection_resolution=100,resrange=(10,20),name=" +
2184 ",ambiguous"] = len(
2189 name_is_ambiguous=
True,
2198 class SimplifiedModel(Representation):
2200 def __init__(self, *args, **kwargs):
2201 Representation.__init__(self, *args, **kwargs)
2202 IMP.pmi.tools.print_deprecation_warning(
static Residue setup_particle(kernel::Model *m, ParticleIndex pi, ResidueType t, int index, int insertion_code)
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)
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)
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 ...
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)
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.
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)
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)
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.
static Uncertainty setup_particle(kernel::Model *m, ParticleIndex pi, Float uncertainty)
Tools for clustering and cluster analysis.
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...
static bool get_is_setup(kernel::Model *m, kernel::ParticleIndex pi)
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)
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)
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)
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.
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.
static Symmetric setup_particle(kernel::Model *m, ParticleIndex pi, Float symmetric)
Inferential scoring building on methods developed as part of the Inferential Structure Determination ...
Harmonic function (symmetric about the mean)
A decorator for a particle with x,y,z coordinates and a radius.