3 """@namespace IMP.pmi.representation
4 Representation of the system.
14 from math
import pi, sqrt
16 from operator
import itemgetter
24 class Representation(object):
28 This class creates the molecular hierarchies, representation,
29 sequence connectivity for the various involved proteins and
30 nucleic acid macromolecules:
32 Create a protein, DNA or RNA, represent it as a set of connected balls of appropriate
33 radii and number of residues, pdb at given resolution(s), or ideal helices.
35 To initialize the class:
38 upperharmonic Bool This flag uses either harmonic (False)
39 or upperharmonic (True) in the intra-pair
40 connectivity restraint. Default is True.
41 disorderedlength Bool This flag uses either disordered length
42 calculated for random coil peptides (True) or zero
43 surface-to-surface distance between beads (False)
44 as optimal distance for the sequence connectivity
45 restraint. Default is False.
47 How to use the SimplifiedModel class (typical use):
49 see test/test_hierarchy_contruction.py
53 1) Create a chain of helices and flexible parts
55 c_1_119 =self.add_component_necklace("prot1",1,119,20)
56 c_120_131 =self.add_component_ideal_helix("prot1",resolutions=[1,10],resrange=(120,131))
57 c_132_138 =self.add_component_beads("prot1",[(132,138)])
58 c_139_156 =self.add_component_ideal_helix("prot1",resolutions=[1,10],resrange=(139,156))
59 c_157_174 =self.add_component_beads("prot1",[(157,174)])
60 c_175_182 =self.add_component_ideal_helix("prot1",resolutions=[1,10],resrange=(175,182))
61 c_183_194 =self.add_component_beads("prot1",[(183,194)])
62 c_195_216 =self.add_component_ideal_helix("prot1",resolutions=[1,10],resrange=(195,216))
63 c_217_250 =self.add_component_beads("prot1",[(217,250)])
66 self.set_rigid_body_from_hierarchies(c_120_131)
67 self.set_rigid_body_from_hierarchies(c_139_156)
68 self.set_rigid_body_from_hierarchies(c_175_182)
69 self.set_rigid_body_from_hierarchies(c_195_216)
71 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,
74 self.set_chain_of_super_rigid_bodies(clist,2,3)
76 self.set_super_rigid_bodies(["prot1"])
80 def __init__(self, m, upperharmonic=True, disorderedlength=True):
89 self.upperharmonic = upperharmonic
90 self.disorderedlength = disorderedlength
91 self.rigid_bodies = []
92 self.fixed_rigid_bodies = []
93 self.fixed_floppy_bodies = []
94 self.floppy_bodies = []
100 self.super_rigid_bodies = []
101 self.output_level =
"low"
104 self.maxtrans_rb = 2.0
105 self.maxrot_rb = 0.04
106 self.maxtrans_srb = 2.0
107 self.maxrot_srb = 0.2
108 self.rigidbodiesarefixed =
False
109 self.maxtrans_fb = 3.0
110 self.resolution = 10.0
111 self.bblenght = 100.0
115 self.representation_is_modified =
False
116 self.unmodeledregions_cr_dict = {}
117 self.sortedsegments_cr_dict = {}
119 self.connected_intra_pairs = []
122 self.sequence_dict = {}
123 self.hier_geometry_pairs = {}
124 self.hier_db = IMP.pmi.tools.HierarchyDatabase()
129 self.hier_representation = {}
130 self.hier_resolution = {}
133 self.reference_structures = {}
136 self.linker_restraints_dict = {}
137 self.threetoone = {
'ALA':
'A',
'ARG':
'R', 'ASN': 'N', 'ASP': 'D',
138 'CYS':
'C',
'GLU':
'E',
'GLN':
'Q',
'GLY':
'G',
139 'HIS':
'H',
'ILE':
'I',
'LEU':
'L',
'LYS':
'K',
140 'MET':
'M',
'PHE':
'F',
'PRO':
'P',
'SER':
'S',
141 'THR':
'T',
'TRP':
'W',
'TYR':
'Y',
'VAL':
'V',
'UNK':
'X'}
143 self.onetothree = dict((v, k)
for k, v
in self.threetoone.iteritems())
147 def set_label(self, label):
150 def create_component(self, name, color=None):
152 protein_h.set_name(name)
153 self.hier_dict[name] = protein_h
154 self.hier_representation[name] = {}
155 self.hier_db.add_name(name)
156 self.prot.add_child(protein_h)
157 self.color_dict[name] = color
158 self.elements[name] = []
162 def add_component_name(self, *args, **kwargs):
163 IMP.pmi.tools.print_deprecation_warning(
164 "add_component_name",
166 self.create_component(*args, **kwargs)
168 def get_component_names(self):
169 return self.hier_dict.keys()
171 def add_component_sequence(self, name, filename, id=None, offs=None, format="FASTA"):
173 give the component name, the fasta filename,
174 and the id stored in the fasta file (i.e., the header)
175 If the id is not provided, it will assume the same compoennt
178 from Bio
import SeqIO
179 handle = open(filename,
"rU")
180 record_dict = SeqIO.to_dict(SeqIO.parse(handle,
"fasta"))
185 length = len(record_dict[id].seq)
187 print "add_component_sequence: 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 print "ERROR add_component_pdb: %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]))
398 start = start + offset
401 self.elements[name].append(
402 (start, end, pdbname.split(
"/")[-1] +
":" + chain,
"pdb"))
404 outhiers += self.coarse_hierarchy(name, start, end,
405 resolutions, isnucleicacid, c0, protein_h,
"pdb", color)
416 def add_component_ideal_helix(
424 self.representation_is_modified =
True
425 from math
import pi, cos, sin
427 protein_h = self.hier_dict[name]
430 color = self.color_dict[name]
434 self.elements[name].append((start, end,
" ",
"helix"))
436 for n, res
in enumerate(range(start, end + 1)):
437 if name
in self.sequence_dict:
439 rtstr = self.onetothree[
440 self.sequence_dict[name][res-1]]
460 x = 2.3 * cos(n * 2 * pi / 3.6)
461 y = 2.3 * sin(n * 2 * pi / 3.6)
462 z = 6.2 / 3.6 / 2 * n * 2 * pi / 3.6
470 outhiers += self.coarse_hierarchy(name, start, end,
471 resolutions,
False, c0, protein_h,
"helix", color)
479 def add_component_beads(self, name, ds, colors=None, incoord=None):
482 self.representation_is_modified =
True
484 protein_h = self.hier_dict[name]
487 colors = [self.color_dict[name]]
489 for n, dss
in enumerate(ds):
490 ds_frag = (dss[0], dss[1])
491 self.elements[name].append((dss[0], dss[1],
" ",
"bead"))
493 if ds_frag[0] == ds_frag[1]:
495 if name
in self.sequence_dict:
497 rtstr = self.onetothree[
498 self.sequence_dict[name][ds_frag[0]-1]]
505 h.set_name(name +
'_%i_bead' % (ds_frag[0]))
506 prt.set_name(name +
'_%i_bead' % (ds_frag[0]))
510 h.set_name(name +
'_%i-%i_bead' % (ds_frag[0], ds_frag[1]))
511 prt.set_name(name +
'_%i-%i_bead' % (ds_frag[0], ds_frag[1]))
512 h.set_residue_indexes(range(ds_frag[0], ds_frag[1] + 1))
513 resolution = len(h.get_residue_indexes())
514 if "Beads" not in self.hier_representation[name]:
516 root.set_name(
"Beads")
517 self.hier_representation[name][
"Beads"] = root
518 protein_h.add_child(root)
519 self.hier_representation[name][
"Beads"].add_child(h)
521 for kk
in range(ds_frag[0], ds_frag[1] + 1):
522 self.hier_db.add_particles(name, kk, resolution, [h])
545 ptem.set_radius(radius)
548 radius = 0.8 * (3.0 / 4.0 / pi * volume) ** (1.0 / 3.0)
550 ptem.set_radius(radius)
552 if not tuple(incoord)
is None:
553 ptem.set_coordinates(incoord)
558 self.floppy_bodies.append(prt)
564 def add_component_necklace(self, name, begin, end, length, color=None, incoord=None):
566 generates a string of beads with given length
568 self.representation_is_modified =
True
575 outhiers += self.add_component_beads(name,
576 [(chunk[0], chunk[-1])], colors=colors,incoord=incoord)
579 def add_component_density(
580 self, name, hierarchies=
None, selection_tuples=
None,
582 resolution=0.0, num_components=10,
583 inputfile=
None, outputfile=
None,
586 covariance_type=
'full', voxel_size=1.0,
588 sampled_points=1000000, num_iter=100,
590 multiply_by_total_mass=
True,
592 intermediate_map_fn=
None,
593 density_ps_to_copy=
None,
594 use_precomputed_gaussians=
False):
596 This function sets up a GMM for this component.
597 Can specify input GMM file or it will be computed.
599 hierarchies: set up GMM for some hierarchies
600 selection_tuples: (list of tuples) example (first_residue,last_residue,component_name)
601 particles: set up GMM for particles directly
602 resolution: usual PMI resolution for selecting particles from the hierarchies
603 inputfile: read the GMM from this file
604 outputfile: fit and write the GMM to this file (text)
605 outputmap: after fitting, create GMM density file (mrc)
606 kernel_type: for creating the intermediate density (points are sampled to make GMM)
607 options are IMP.em.GAUSSIAN, IMP.em.SPHERE, and IMP.em.BINARIZED_SPHERE
608 covariance_type: for fitting the GMM. options are 'full', 'diagonal' and 'spherical'
609 voxel_size: for creating the intermediate density map and output map.
610 lower number increases accuracy but also rasterizing time grows
611 out_hier_name: name of the output density hierarchy
612 sampled_points: number of points to sample. more will increase accuracy and fitting time
613 num_iter: num GMM iterations. more will increase accuracy and fitting time
614 multiply_by_total_mass: multiply the weights of the GMM by this value (only works on creation!)
615 transform: for input file only, apply a transformation (eg for multiple copies same GMM)
616 intermediate_map_fn: for debugging, this will write the itermediate (simulated) map
617 density_ps_to_copy: in case you already created the appropriate GMM (eg, for beads)
618 use_precomputed_gaussians: Set this flag and pass fragments - will use roughly spherical gaussian setup
622 import IMP.isd_emxl.gmm_tools
628 self.representation_is_modified =
True
630 protein_h = self.hier_dict[name]
631 if "Densities" not in self.hier_representation[name]:
633 root.set_name(
"Densities")
634 self.hier_representation[name][
"Densities"] = root
635 protein_h.add_child(root)
638 fragment_particles = []
639 if not particles
is None:
640 fragment_particles += particles
641 if not hierarchies
is None:
643 self, resolution=resolution,
644 hierarchies=hierarchies)
645 if not selection_tuples
is None:
646 for st
in selection_tuples:
647 fragment_particles += IMP.pmi.tools.select_by_tuple(
648 self, tupleselection=st,
649 resolution=resolution,
650 name_is_ambiguous=
False)
653 density_particles = []
655 IMP.isd_emxl.gmm_tools.decorate_gmm_from_text(
656 inputfile, density_particles,
658 elif density_ps_to_copy:
659 for ip
in density_ps_to_copy:
665 density_particles.append(p)
666 elif use_precomputed_gaussians:
667 if len(fragment_particles) == 0:
668 print "add_component_density: no particle was selected"
670 for p
in fragment_particles:
673 raise Exception(
"The particles you selected must be Fragments and XYZs")
675 pos=
IMP.core.XYZ(self.m,p.get_particle_index()).get_coordinates()
678 IMP.isd_emxl.get_data_path(
"beads/bead_%i.txt"%nres)
680 raise Exception(
"We haven't created a bead file for",nres,
"residues")
682 IMP.isd_emxl.gmm_tools.decorate_gmm_from_text(
683 IMP.isd_emxl.get_data_path(
"beads/bead_%i.txt"%nres), density_particles,
687 if len(fragment_particles) == 0:
688 print "add_component_density: no particle was selected"
691 density_particles = IMP.isd_emxl.gmm_tools.sample_and_fit_to_particles(
700 multiply_by_total_mass,
706 s0.set_name(out_hier_name)
707 self.hier_representation[name][
"Densities"].add_child(s0)
709 for nps, p
in enumerate(density_particles):
711 p.set_name(s0.get_name() +
'_gaussian_%i' % nps)
714 def get_component_density(self, name):
715 return self.hier_representation[name][
"Densities"]
717 def add_all_atom_densities(self, name, hierarchies=None,
718 selection_tuples=
None,
723 '''This function decorates all specified particles as Gaussians directly.
725 hierarchies: set up GMM for some hierarchies
726 selection_tuples: (list of tuples) example (first_residue,last_residue,component_name)
727 particles: set up GMM for particles directly
728 resolution: usual PMI resolution for selecting particles from the hierarchies
729 intermediate_map_fn: for debugging, this will write the itermediate (simulated) map
733 import IMP.isd_emxl.gmm_tools
737 from math
import sqrt
738 self.representation_is_modified =
True
740 if particles
is None:
741 fragment_particles = []
743 fragment_particles = particles
745 if not hierarchies
is None:
747 self, resolution=resolution,
748 hierarchies=hierarchies)
750 if not selection_tuples
is None:
751 for st
in selection_tuples:
752 fragment_particles += IMP.pmi.tools.select_by_tuple(
753 self, tupleselection=st,
754 resolution=resolution,
755 name_is_ambiguous=
False)
757 if len(fragment_particles) == 0:
758 print "add all atom densities: no particle was selected"
762 print 'setting up all atom gaussians num_particles',len(fragment_particles)
763 for n,p
in enumerate(fragment_particles):
773 if not output_map
is None:
774 print 'writing map to', output_map
775 IMP.isd_emxl.gmm_tools.write_gmm_to_map(
780 def add_component_hierarchy_clone(self, name, hierarchy):
782 this function makes a copy of a hierarchy and append it to a
786 self.representation_is_modified =
True
787 protein_h = self.hier_dict[name]
789 hierclone.set_name(hierclone.get_name() +
"_clone")
790 protein_h.add_child(hierclone)
791 outhier.append(hierclone)
797 for n, pmain
in enumerate(psmain):
803 self.hier_db.add_particles(
819 def set_coordinates_from_rmf(
824 rmf_component_name=
None):
825 '''This function read and replace coordinates from an rmf file
826 It looks for the component with the same name, unless the rmf_component_name
827 is defined. Replace the coordinates of particles with the same name
828 It assumes that the rmf and the represdentation have the particles in the same order'''
832 prot = IMP.pmi.analysis.get_hier_from_rmf(
839 print "set_coordinates_from_rmf: cannot read hiearchy from rmf"
850 p, self.hier_dict.keys())
851 if not rmf_component_name
is None and protname == rmf_component_name:
853 elif rmf_component_name
is None and protname == component_name:
858 if len(psrmf) != len(psrepr):
859 print "set_coordinates_from_rmf: cannot proceed the rmf and the representation don't have the same number of particles"
860 print "particles in rmf: %s particles in the representation: %s" % (str(len(psrmf)), str(len(psrepr)))
863 for n, prmf
in enumerate(psrmf):
864 prmfname = prmf.get_name()
865 preprname = psrepr[n].get_name()
867 print "set_coordinates_from_rmf: component %s cannot proceed if rigid bodies were initialized. Use the function before defining the rigid bodies" % component_name
870 print "set_coordinates_from_rmf: component %s cannot proceed if rigid bodies were initialized. Use the function before defining the rigid bodies" % component_name
873 if prmfname != preprname:
874 print "set_coordinates_from_rmf: WARNING rmf particle and representation particles have not the same name %s %s " % (prmfname, preprname)
881 def check_root(self, name, protein_h, resolution):
883 checks whether the root hierarchy exists, and if not
884 suitably constructs it
886 if "Res:" + str(int(resolution))
not in self.hier_representation[name]:
888 root.set_name(name +
"_Res:" + str(int(resolution)))
889 self.hier_representation[name][
890 "Res:" + str(int(resolution))] = root
891 protein_h.add_child(root)
893 def coarse_hierarchy(
905 this function generates all needed coarse grained layers
906 name is the name of the protein
907 resolutions is the list of resolutions
908 protein_h is the root hierarchy
909 input hierarchy is the hierarchy to coarse grain
910 type is a string, typically "pdb" or "helix"
914 if (1
in resolutions)
or (0
in resolutions):
918 self.check_root(name, protein_h, 1)
920 s1.set_name(
'%s_%i-%i_%s' % (name, start, end, type))
922 self.hier_representation[name][
"Res:1"].add_child(s1)
925 self.check_root(name, protein_h, 0)
927 s0.set_name(
'%s_%i-%i_%s' % (name, start, end, type))
929 self.hier_representation[name][
"Res:0"].add_child(s0)
932 if not isnucleicacid:
935 atom_type=IMP.atom.AT_CA)
939 atom_type=IMP.atom.AT_P)
941 for p
in sel.get_selected_particles():
947 s0.add_child(resclone0)
948 self.hier_db.add_particles(
952 resclone0.get_children())
954 chil = resclone0.get_children()
967 s1.add_child(resclone1)
968 self.hier_db.add_particles(name, resindex, 1, [resclone1])
972 prt = resclone1.get_particle()
973 prt.set_name(
'%s_%i_%s' % (name, resindex, type))
995 for r
in resolutions:
996 if r != 0
and r != 1:
997 self.check_root(name, protein_h, r)
1002 chil = s.get_children()
1004 s0.set_name(
'%s_%i-%i_%s' % (name, start, end, type))
1008 self.hier_representation[name][
1009 "Res:" + str(int(r))].add_child(s0)
1018 prt.set_name(
'%s_%i_%s' % (name, first, type))
1020 prt.set_name(
'%s_%i_%i_%s' % (name, first, last, type))
1022 self.hier_db.add_particles(name, kk, r, [prt])
1041 def get_hierarchies_at_given_resolution(self, resolution):
1043 this function caches the map between resolution and hierarchies
1044 to accelerate the selection algorithm
1045 if the representation was changed by any add_component_xxx, the function recalculates
1049 if self.representation_is_modified:
1050 rhbr = self.hier_db.get_all_root_hierarchies_by_resolution(
1052 self.hier_resolution[resolution] = rhbr
1053 self.representation_is_modified =
False
1056 if resolution
in self.hier_resolution:
1057 return self.hier_resolution[resolution]
1059 rhbr = self.hier_db.get_all_root_hierarchies_by_resolution(
1061 self.hier_resolution[resolution] = rhbr
1064 def shuffle_configuration(
1065 self, max_translation=300., max_rotation=2.0 * pi,
1066 avoidcollision=
True, cutoff=10.0, niterations=100,
1068 excluded_rigid_bodies=
None,
1069 hierarchies_excluded_from_collision=
None):
1071 shuffle configuration, used to restart the optimization
1072 it works correctly if rigid bodies were initialized
1073 avoidcollision check if the particle/rigid body was placed close to another particle
1074 avoidcollision uses the optional arguments cutoff and niterations
1076 bounding box is defined by ((x1,y1,z1),(x2,y2,z2))
1079 if excluded_rigid_bodies
is None:
1080 excluded_rigid_bodies = []
1081 if hierarchies_excluded_from_collision
is None:
1082 hierarchies_excluded_from_collision = []
1084 if len(self.rigid_bodies) == 0:
1085 print "shuffle_configuration: rigid bodies were not intialized"
1088 gcpf.set_distance(cutoff)
1093 allparticleindexes = IMP.get_indexes(ps)
1095 if not bounding_box
is None:
1096 ((x1, y1, z1), (x2, y2, z2)) = bounding_box
1101 hierarchies_excluded_from_collision_indexes = []
1102 for h
in hierarchies_excluded_from_collision:
1106 for name
in self.hier_representation:
1109 self.hier_representation[name][
"Densities"])
1110 hierarchies_excluded_from_collision_indexes += IMP.get_indexes(ps)
1114 allparticleindexes = list(
1115 set(allparticleindexes) - set(hierarchies_excluded_from_collision_indexes))
1117 for rb
in self.rigid_bodies:
1118 if rb
not in excluded_rigid_bodies:
1121 rbindexes = rb.get_member_particle_indexes()
1124 set(rbindexes) - set(hierarchies_excluded_from_collision_indexes))
1125 otherparticleindexes = list(
1126 set(allparticleindexes) - set(rbindexes))
1127 if len(otherparticleindexes)
is None:
1131 while niter < niterations:
1132 rbxyz = (rb.get_x(), rb.get_y(), rb.get_z())
1134 if not bounding_box
is None:
1152 gcpf.get_close_pairs(
1154 otherparticleindexes,
1160 print "shuffle_configuration: rigid body placed close to other %d particles, trying again..." % npairs
1161 print "shuffle_configuration: rigid body name: " + rb.get_name()
1162 if niter == niterations:
1163 print "shuffle_configuration: tried the maximum number of iterations to avoid collisions, increase the distance cutoff"
1168 print 'shuffling', len(self.floppy_bodies),
'floppy bodies'
1169 for fb
in self.floppy_bodies:
1174 fbindexes = IMP.get_indexes([fb])
1175 otherparticleindexes = list(
1176 set(allparticleindexes) - set(fbindexes))
1177 if len(otherparticleindexes)
is None:
1183 while niter < niterations:
1185 if not bounding_box
is None:
1200 gcpf.get_close_pairs(
1202 otherparticleindexes,
1208 print "shuffle_configuration: floppy body placed close to other %d particles, trying again..." % npairs
1209 if niter == niterations:
1210 print "shuffle_configuration: tried the maximum number of iterations to avoid collisions, increase the distance cutoff"
1215 def set_current_coordinates_as_reference_for_rmsd(self, label="None"):
1219 self.reference_structures[label] = (
1223 def get_all_rmsds(self):
1226 for label
in self.reference_structures:
1228 current_coordinates = [
IMP.core.XYZ(p).get_coordinates()
1229 for p
in self.reference_structures[label][1]]
1230 reference_coordinates = self.reference_structures[label][0]
1231 if len(reference_coordinates) != len(current_coordinates):
1232 print "calculate_all_rmsds: reference and actual coordinates are not the same"
1235 current_coordinates,
1236 reference_coordinates)
1238 reference_coordinates,
1239 current_coordinates)
1243 reference_coordinates,
1244 current_coordinates)
1245 rmsds[label +
"_GlobalRMSD"] = rmsd_global
1246 rmsds[label +
"_RelativeDRMS"] = rmsd_relative
1249 def setup_component_geometry(self, name, color=None, resolution=1.0):
1251 color = self.color_dict[name]
1255 self.hier_geometry_pairs[name] = []
1256 protein_h = self.hier_dict[name]
1258 pbr = IMP.pmi.tools.sort_by_residues(pbr)
1260 for n
in range(len(pbr) - 1):
1261 self.hier_geometry_pairs[name].append((pbr[n], pbr[n + 1], color))
1263 def setup_component_sequence_connectivity(
1269 This method generates restraints between contiguous fragments
1270 in the hierarchy. The linkers are generated at resolution 10 by default.
1277 protein_h = self.hier_dict[name]
1279 frs = self.hier_db.get_preroot_fragments_by_resolution(
1285 start = fr.get_children()[0]
1290 end = fr.get_children()[-1]
1296 SortedSegments.append((start, end, startres))
1297 SortedSegments = sorted(SortedSegments, key=itemgetter(2))
1300 for x
in xrange(len(SortedSegments) - 1):
1301 last = SortedSegments[x][1]
1302 first = SortedSegments[x + 1][0]
1309 residuegap = firstresn - lastresn - 1
1310 if self.disorderedlength
and (nreslast / 2 + nresfirst / 2 + residuegap) > 20.0:
1313 optdist = sqrt(5 / 3) * 1.93 * \
1314 (nreslast / 2 + nresfirst / 2 + residuegap) ** 0.6
1316 if self.upperharmonic:
1322 optdist = (0.0 + (float(residuegap) + 1.0) * 3.6) * scale
1323 if self.upperharmonic:
1329 pt0 = last.get_particle()
1330 pt1 = first.get_particle()
1333 print "Adding sequence connectivity restraint between", pt0.get_name(),
" and ", pt1.get_name(),
'of distance', optdist
1334 sortedsegments_cr.add_restraint(r)
1335 self.linker_restraints_dict[
1336 "LinkerRestraint-" + pt0.get_name() +
"-" + pt1.get_name()] = r
1337 self.connected_intra_pairs.append((pt0, pt1))
1338 self.connected_intra_pairs.append((pt1, pt0))
1340 self.m.add_restraint(sortedsegments_cr)
1341 self.m.add_restraint(unmodeledregions_cr)
1342 self.linker_restraints.add_restraint(sortedsegments_cr)
1343 self.linker_restraints.add_restraint(unmodeledregions_cr)
1344 self.sortedsegments_cr_dict[name] = sortedsegments_cr
1345 self.unmodeledregions_cr_dict[name] = unmodeledregions_cr
1347 def optimize_floppy_bodies(self, nsteps, temperature=1.0):
1349 pts = IMP.pmi.tools.ParticleToSampleList()
1350 for n, fb
in enumerate(self.floppy_bodies):
1351 pts.add_particle(fb,
"Floppy_Bodies", 1.0,
"Floppy_Body_" + str(n))
1352 if len(pts.get_particles_to_sample()) > 0:
1353 mc = IMP.pmi.samplers.MonteCarlo(self.m, [pts], temperature)
1354 print "optimize_floppy_bodies: optimizing %i floppy bodies" % len(self.floppy_bodies)
1357 print "optimize_floppy_bodies: no particle to optimize"
1359 def create_rotational_symmetry(self, maincopy, copies):
1361 self.representation_is_modified =
True
1362 ncopies = len(copies) + 1
1365 mainparticles = sel.get_selected_particles()
1367 for k
in range(len(copies)):
1373 copyparticles = sel.get_selected_particles()
1377 for n, p
in enumerate(mainparticles):
1379 pc = copyparticles[n]
1381 mainpurged.append(p)
1384 copypurged.append(pc)
1388 for n, p
in enumerate(mainpurged):
1391 print "setting " + p.get_name() +
" as reference for " + pc.get_name()
1397 self.m.add_score_state(c)
1401 def create_amyloid_fibril_symmetry(self, maincopy, axial_copies,
1402 longitudinal_copies, axis=(0, 0, 1), translation_value=4.8):
1405 self.representation_is_modified =
True
1408 protein_h = self.hier_dict[maincopy]
1411 for ilc
in range(-longitudinal_copies, longitudinal_copies + 1):
1412 for iac
in range(axial_copies):
1413 copyname = maincopy +
"_a" + str(ilc) +
"_l" + str(iac)
1414 self.add_component_name(copyname, 0.0)
1415 for hier
in protein_h.get_children():
1416 self.add_component_hierarchy_clone(copyname, hier)
1417 copyhier = self.hier_dict[copyname]
1418 outhiers.append(copyhier)
1422 2 * pi / axial_copies * (float(iac)))
1423 translation_vector = tuple(
1424 [translation_value * float(ilc) * x
for x
in axis])
1425 print translation_vector
1430 for n, p
in enumerate(mainparts):
1439 self.m.add_score_state(c)
1443 def link_components_to_rmf(self, rmfname, frameindex):
1445 load coordinates in the current representation
1446 this should be done only if the hierarchy self.prot is identical to the one
1447 i.e. all components were added
1448 as stored in the rmf
1453 rh = RMF.open_rmf_file_read_only(rmfname)
1458 def create_components_from_rmf(self, rmfname, frameindex):
1461 create the representation (i.e. hierarchies) from the rmf file.
1462 it will be stored in self.prot, which will be overwritten.
1463 load the coordinates from the rmf file at frameindex.
1465 rh = RMF.open_rmf_file(rmfname)
1471 for p
in self.prot.get_children():
1472 self.add_component_name(p.get_name())
1473 self.hier_dict[p.get_name()] = p
1475 still missing: save rigid bodies contained in the rmf in self.rigid_bodies
1476 save floppy bodies in self.floppy_bodies
1477 get the connectivity restraints
1480 def set_rigid_body_from_hierarchies(self, hiers, particles=None):
1482 This method allows the construction of a rigid body given a list
1483 of hierarchies and or a list of particles.
1485 hiers: list of hierarchies
1486 particles: (optional, default=None) list of particles to add to the rigid body
1489 if particles
is None:
1492 rigid_parts = set(particles)
1495 print "set_rigid_body_from_hierarchies> setting up a new rigid body"
1502 print "set_rigid_body_from_hierarchies> WARNING particle %s already belongs to rigid body %s" % (p.get_name(), rb.get_name())
1505 name += hier.get_name() +
"-"
1506 print "set_rigid_body_from_hierarchies> adding %s to the rigid body" % hier.get_name()
1508 if len(list(rigid_parts)) != 0:
1510 rb.set_coordinates_are_optimized(
True)
1511 rb.set_name(name +
"rigid_body")
1512 self.rigid_bodies.append(rb)
1516 print "set_rigid_body_from_hierarchies> rigid body could not be setup"
1518 def set_rigid_bodies(self, subunits):
1520 This method allows the construction of a rigid body given a list
1521 of tuples, that identify the residue ranges and the subunit names (the names used
1522 to create the component by using create_component.
1524 subunits: [(name_1,(first_residue_1,last_residue_1)),(name_2,(first_residue_2,last_residue_2)),.....]
1526 [name_1,name_2,(name_3,(first_residue_3,last_residue_3)),.....]
1528 example: ["prot1","prot2",("prot3",(1,10))]
1530 sometimes, we know about structure of an interaction
1531 and here we make such PPIs rigid
1536 if type(s) == type(tuple())
and len(s) == 2:
1540 residue_indexes=range(s[1][0],
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())
1552 elif type(s) == type(str()):
1554 if len(sel.get_selected_particles()) == 0:
1555 print "set_rigid_bodies: selected particle does not exists"
1556 for p
in sel.get_selected_particles():
1560 print "set_rigid_body_from_hierarchies> WARNING particle %s already belongs to rigid body %s" % (p.get_name(), rb.get_name())
1565 rb.set_coordinates_are_optimized(
True)
1566 rb.set_name(
''.join(str(subunits)) +
"_rigid_body")
1567 self.rigid_bodies.append(rb)
1570 def set_super_rigid_body_from_hierarchies(
1576 super_rigid_xyzs = set()
1577 super_rigid_rbs = set()
1579 print "set_super_rigid_body_from_hierarchies> setting up a new SUPER rigid body"
1586 super_rigid_rbs.add(rb)
1588 super_rigid_xyzs.add(p)
1589 print "set_rigid_body_from_hierarchies> adding %s to the rigid body" % hier.get_name()
1590 if len(super_rigid_rbs) < min_size:
1593 self.super_rigid_bodies.append((super_rigid_xyzs, super_rigid_rbs))
1596 self.super_rigid_bodies.append(
1597 (super_rigid_xyzs, super_rigid_rbs, axis))
1599 def fix_rigid_bodies(self, rigid_bodies):
1600 self.fixed_rigid_bodies += rigid_bodies
1603 def set_chain_of_super_rigid_bodies(
1610 this function takes a linear list of hierarchies (they are supposed
1611 to be sequence-contiguous) and
1612 produces a chain of super rigid bodies with given length range, specified
1613 by min_length and max_length
1616 hiers = IMP.pmi.tools.flatten_list(hiers)
1620 self.set_super_rigid_body_from_hierarchies(hs, axis, min_length)
1622 def set_super_rigid_bodies(self, subunits, coords=None):
1623 super_rigid_xyzs = set()
1624 super_rigid_rbs = set()
1627 if type(s) == type(tuple())
and len(s) == 3:
1631 residue_indexes=range(s[0],
1633 if len(sel.get_selected_particles()) == 0:
1634 print "set_rigid_bodies: selected particle does not exists"
1635 for p
in sel.get_selected_particles():
1638 super_rigid_rbs.add(rb)
1640 super_rigid_xyzs.add(p)
1641 elif type(s) == type(str()):
1643 if len(sel.get_selected_particles()) == 0:
1644 print "set_rigid_bodies: selected particle does not exists"
1645 for p
in sel.get_selected_particles():
1649 super_rigid_rbs.add(rb)
1651 super_rigid_xyzs.add(p)
1652 self.super_rigid_bodies.append((super_rigid_xyzs, super_rigid_rbs))
1654 def remove_floppy_bodies(self, hierarchies):
1656 give a list of hierarchies, get the leaves and remove the corresponding particles
1657 from the floppy bodies list. We need this function because sometimes
1658 we want to constraint the floppy bodies in a rigid body. For instance
1659 when you want to associate a bead with a density particle.
1661 for h
in hierarchies:
1664 if p
in self.floppy_bodies:
1665 print "remove_floppy_bodies: removing %s from floppy body list" % p.get_name()
1666 self.floppy_bodies.remove(p)
1669 def set_floppy_bodies(self):
1670 for p
in self.floppy_bodies:
1672 p.set_name(name +
"_floppy_body")
1674 print "I'm trying to make this particle flexible although it was assigned to a rigid body", p.get_name()
1677 rb.set_is_rigid_member(p.get_index(),
False)
1680 rb.set_is_rigid_member(p.get_particle_index(),
False)
1681 p.set_name(p.get_name() +
"_rigid_body_member")
1683 def set_floppy_bodies_from_hierarchies(self, hiers):
1688 self.floppy_bodies.append(p)
1690 def get_particles_from_selection_tuples(
1695 selection tuples must be [(r1,r2,"name1"),(r1,r2,"name2"),....]
1696 return the particles
1699 print selection_tuples
1700 for s
in selection_tuples:
1701 ps = IMP.pmi.tools.select_by_tuple(
1702 representation=self, tupleselection=tuple(s),
1703 resolution=
None, name_is_ambiguous=
False)
1707 def get_connected_intra_pairs(self):
1708 return self.connected_intra_pairs
1710 def set_rigid_bodies_max_trans(self, maxtrans):
1711 self.maxtrans_rb = maxtrans
1713 def set_rigid_bodies_max_rot(self, maxrot):
1714 self.maxrot_rb = maxrot
1716 def set_super_rigid_bodies_max_trans(self, maxtrans):
1717 self.maxtrans_srb = maxtrans
1719 def set_super_rigid_bodies_max_rot(self, maxrot):
1720 self.maxrot_srb = maxrot
1722 def set_floppy_bodies_max_trans(self, maxtrans):
1723 self.maxtrans_fb = maxtrans
1725 def set_rigid_bodies_as_fixed(self, rigidbodiesarefixed=True):
1727 this function will fix rigid bodies in their actual
1728 position. the get_particles_to_sample function will return
1729 just the floppy bodies.
1731 self.rigidbodiesarefixed = rigidbodiesarefixed
1733 def draw_hierarchy_graph(self):
1735 print "Drawing hierarchy graph for " + c.get_name()
1736 IMP.pmi.output.get_graph_from_hierarchy(c)
1738 def get_geometries(self):
1741 for name
in self.hier_geometry_pairs:
1742 for pt
in self.hier_geometry_pairs[name]:
1756 def setup_bonds(self):
1759 for name
in self.hier_geometry_pairs:
1760 for pt
in self.hier_geometry_pairs[name]:
1774 def show_component_table(self, name):
1775 if name
in self.sequence_dict:
1776 lastresn = len(self.sequence_dict[name])
1779 residues = self.hier_db.get_residue_numbers(name)
1780 firstresn = min(residues)
1781 lastresn = max(residues)
1783 for nres
in range(firstresn, lastresn + 1):
1785 resolutions = self.hier_db.get_residue_resolutions(name, nres)
1787 for r
in resolutions:
1788 ps += self.hier_db.get_particles(name, nres, r)
1789 print "%20s %7s" % (name, nres),
" ".join([
"%20s %7s" % (str(p.get_name()),
1792 print "%20s %20s" % (name, nres),
"**** not represented ****"
1794 def draw_hierarchy_composition(self):
1796 ks = self.elements.keys()
1800 for k
in self.elements:
1801 for l
in self.elements[k]:
1806 self.draw_component_composition(k, max)
1808 def draw_component_composition(self, name, max=1000, draw_pdb_names=False):
1809 from matplotlib
import pyplot
1810 import matplotlib
as mpl
1812 tmplist = sorted(self.elements[k], key=itemgetter(0))
1814 endres = tmplist[-1][1]
1816 print "draw_component_composition: missing information for component %s" % name
1818 fig = pyplot.figure(figsize=(26.0 * float(endres) / max + 2, 2))
1819 ax = fig.add_axes([0.05, 0.475, 0.9, 0.15])
1824 norm = mpl.colors.Normalize(vmin=5, vmax=10)
1828 for n, l
in enumerate(tmplist):
1832 if bounds[-1] != l[0]:
1833 colors.append(
"white")
1836 colors.append(
"#99CCFF")
1838 colors.append(
"#FFFF99")
1840 colors.append(
"#33CCCC")
1842 bounds.append(l[1] + 1)
1845 colors.append(
"#99CCFF")
1847 colors.append(
"#FFFF99")
1849 colors.append(
"#33CCCC")
1851 bounds.append(l[1] + 1)
1853 if bounds[-1] - 1 == l[0]:
1857 colors.append(
"white")
1860 bounds.append(bounds[-1])
1861 colors.append(
"white")
1862 cmap = mpl.colors.ListedColormap(colors)
1863 cmap.set_over(
'0.25')
1864 cmap.set_under(
'0.75')
1866 norm = mpl.colors.BoundaryNorm(bounds, cmap.N)
1867 cb2 = mpl.colorbar.ColorbarBase(ax, cmap=cmap,
1873 spacing=
'proportional',
1874 orientation=
'horizontal')
1883 mid = 1.0 / endres * float(l[0])
1888 l[2], xy=(mid, 1), xycoords=
'axes fraction',
1889 xytext=(mid + 0.025, float(npdb - 1) / 2.0 + 1.5), textcoords=
'axes fraction',
1890 arrowprops=dict(arrowstyle=
"->",
1891 connectionstyle=
"angle,angleA=0,angleB=90,rad=10"),
1893 extra_artists.append(t)
1896 title = ax.text(-0.005, 0.5, k, ha=
"right", va=
"center", rotation=90,
1899 extra_artists.append(title)
1901 labels = len(bounds) * [
" "]
1902 ax.set_xticklabels(labels)
1903 mid = 1.0 / endres * float(bounds[0])
1904 t = ax.annotate(bounds[0], xy=(mid, 0), xycoords=
'axes fraction',
1905 xytext=(mid - 0.01, -0.5), textcoords=
'axes fraction',)
1906 extra_artists.append(t)
1907 offsets = [0, -0.5, -1.0]
1909 for n
in range(1, len(bounds)):
1910 if bounds[n] == bounds[n - 1]:
1912 mid = 1.0 / endres * float(bounds[n])
1913 if (float(bounds[n]) - float(bounds[n - 1])) / max <= 0.01:
1915 offset = offsets[nclashes % 3]
1921 bounds[n], xy=(mid, 0), xycoords=
'axes fraction',
1922 xytext=(mid, -0.5 + offset), textcoords=
'axes fraction')
1925 bounds[n], xy=(mid, 0), xycoords=
'axes fraction',
1926 xytext=(mid, -0.5 + offset), textcoords=
'axes fraction', arrowprops=dict(arrowstyle=
"-"))
1927 extra_artists.append(t)
1929 cb2.add_lines(bounds, [
"black"] * len(bounds), [1] * len(bounds))
1933 k +
"structure.png",
1936 bbox_extra_artists=(extra_artists),
1937 bbox_inches=
'tight')
1940 def draw_coordinates_projection(self):
1941 import matplotlib.pyplot
as pp
1944 for name
in self.hier_geometry_pairs:
1945 for pt
in self.hier_geometry_pairs[name]:
1955 xpairs.append([x1, x2])
1956 ypairs.append([y1, y2])
1959 for xends, yends
in zip(xpairs, ypairs):
1964 pp.plot(xlist, ylist,
'b-', alpha=0.1)
1967 def get_prot_name_from_particle(self, particle):
1968 names = self.get_component_names()
1969 particle0 = particle
1971 while not name
in names:
1974 particle0 = h.get_particle()
1978 def get_particles_to_sample(self):
1988 if not self.rigidbodiesarefixed:
1989 for rb
in self.rigid_bodies:
1994 if rb
not in self.fixed_rigid_bodies:
1997 for fb
in self.floppy_bodies:
2004 for srb
in self.super_rigid_bodies:
2007 rigid_bodies = list(srb[1])
2008 filtered_rigid_bodies = []
2009 for rb
in rigid_bodies:
2010 if rb
not in self.fixed_rigid_bodies:
2011 filtered_rigid_bodies.append(rb)
2012 srbtmp.append((srb[0], filtered_rigid_bodies))
2014 self.rigid_bodies = rbtmp
2015 self.floppy_bodies = fbtmp
2016 self.super_rigid_bodies = srbtmp
2018 ps[
"Rigid_Bodies_SimplifiedModel"] = (
2022 ps[
"Floppy_Bodies_SimplifiedModel"] = (
2025 ps[
"SR_Bodies_SimplifiedModel"] = (
2026 self.super_rigid_bodies,
2031 def set_output_level(self, level):
2032 self.output_level = level
2034 def get_output(self):
2038 output[
"SimplifiedModel_Total_Score_" +
2039 self.label] = str(self.m.evaluate(
False))
2040 output[
"SimplifiedModel_Linker_Score_" +
2041 self.label] = str(self.linker_restraints.unprotected_evaluate(
None))
2042 for name
in self.sortedsegments_cr_dict:
2043 partialscore = self.sortedsegments_cr_dict[name].evaluate(
False)
2044 score += partialscore
2046 "SimplifiedModel_Link_SortedSegments_" +
2051 partialscore = self.unmodeledregions_cr_dict[name].evaluate(
False)
2052 score += partialscore
2054 "SimplifiedModel_Link_UnmodeledRegions_" +
2059 for name
in self.linker_restraints_dict:
2064 self.linker_restraints_dict[
2065 name].unprotected_evaluate(
2068 if len(self.reference_structures.keys()) != 0:
2069 rmsds = self.get_all_rmsds()
2072 "SimplifiedModel_" +
2075 self.label] = rmsds[
2078 if self.output_level ==
"high":
2081 output[
"Coordinates_" +
2082 p.get_name() +
"_" + self.label] = str(d)
2084 output[
"_TotalScore"] = str(score)
2087 def get_test_output(self):
2089 output = self.get_output()
2090 for n, p
in enumerate(self.get_particles_to_sample()):
2091 output[
"Particle_to_sample_" + str(n)] = str(p)
2093 output[
"Hierarchy_Dictionary"] = self.hier_dict.keys()
2094 output[
"Number_of_floppy_bodies"] = len(self.floppy_bodies)
2095 output[
"Number_of_rigid_bodies"] = len(self.rigid_bodies)
2096 output[
"Number_of_super_bodies"] = len(self.super_rigid_bodies)
2097 output[
"Selection_resolution_1"] = len(
2099 output[
"Selection_resolution_5"] = len(
2101 output[
"Selection_resolution_7"] = len(
2103 output[
"Selection_resolution_10"] = len(
2105 output[
"Selection_resolution_100"] = len(
2108 output[
"Selection_resolution=1"] = len(
2110 output[
"Selection_resolution=1,resid=10"] = len(
2112 for resolution
in self.hier_resolution:
2113 output[
"Hier_resolution_dictionary" +
2114 str(resolution)] = len(self.hier_resolution[resolution])
2115 for name
in self.hier_dict:
2117 "Selection_resolution=1,resid=10,name=" +
2125 "Selection_resolution=1,resid=10,name=" +
2127 ",ambiguous"] = len(
2132 name_is_ambiguous=
True,
2135 "Selection_resolution=1,resid=10,name=" +
2137 ",ambiguous"] = len(
2142 name_is_ambiguous=
True,
2145 "Selection_resolution=1,resrange=(10,20),name=" +
2154 "Selection_resolution=1,resrange=(10,20),name=" +
2156 ",ambiguous"] = len(
2161 name_is_ambiguous=
True,
2165 "Selection_resolution=10,resrange=(10,20),name=" +
2174 "Selection_resolution=10,resrange=(10,20),name=" +
2176 ",ambiguous"] = len(
2181 name_is_ambiguous=
True,
2185 "Selection_resolution=100,resrange=(10,20),name=" +
2194 "Selection_resolution=100,resrange=(10,20),name=" +
2196 ",ambiguous"] = len(
2201 name_is_ambiguous=
True,
2210 class SimplifiedModel(Representation):
2212 def __init__(self, *args, **kwargs):
2213 Representation.__init__(self, *args, **kwargs)
2214 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)
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)
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)
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)
Harmonic function (symmetric about the mean)
A decorator for a particle with x,y,z coordinates and a radius.