1 """@namespace IMP.pmi.restraints.proteomics
2 Restraints for handling various kinds of proteomics data.
5 from __future__
import print_function
14 class ConnectivityRestraint(object):
17 generate a connectivity restraint between domains
18 setting up the restraint
20 cr=restraints.ConnectivityRestraint(simo,["CCC",(1,100,"TTT"),(100,150,"AAA")])
25 Multistate support =No
26 Selection type=selection tuple
41 if self.label ==
"None":
42 self.label = str(selection_tuples)
43 self.m = representation.prot.get_model()
48 for s
in selection_tuples:
49 particles = IMP.pmi.tools.select_by_tuple(representation, s,
50 resolution=resolution, name_is_ambiguous=
True)
58 self.rs.add_restraint(cr)
60 def set_label(self, label):
62 self.rs.set_name(label)
63 for r
in self.rs.get_restraints():
66 def add_to_model(self):
67 self.m.add_restraint(self.rs)
69 def get_restraint(self):
74 for r
in self.rs.get_restraints():
75 rlist.append(IMP.core.PairRestraint.get_from(r))
78 def set_weight(self, weight):
80 self.rs.set_weight(weight)
85 score = self.weight * self.rs.unprotected_evaluate(
None)
86 output[
"_TotalScore"] = str(score)
87 output[
"ConnectivityRestraint_" + self.label] = str(score)
95 handleparticles is a selection tuple
96 compositeparticles is a list of selection tuples
103 handleparticles_tuples,
104 compositeparticles_tuple_list,
113 self.m = representation.prot.get_model()
117 for s
in handleparticles_tuples:
118 handleparticles += IMP.pmi.tools.select_by_tuple(representation, s,
119 resolution=resolution, name_is_ambiguous=
True)
121 compositeparticle_list = []
122 for list
in compositeparticles_tuple_list:
123 compositeparticles = []
125 compositeparticles += IMP.pmi.tools.select_by_tuple(
127 resolution=resolution, name_is_ambiguous=
True)
128 compositeparticle_list.append(compositeparticles)
137 for ps
in compositeparticle_list:
139 ln.add_composite_particle(ps)
141 self.rs.add_restraint(ln)
143 def set_label(self, label):
146 def add_to_model(self):
147 self.m.add_restraint(self.rs)
149 def get_output(self):
152 score = self.rs.unprotected_evaluate(
None)
153 output[
"_TotalScore"] = str(score)
154 output[
"CompositeRestraint_" + self.label] = str(score)
162 this restraint allows ambiguous crosslinking between multiple copies
163 excluding between symmetric copies
164 It allows name ambiguity
178 self.m = representation.prot.get_model()
183 self.outputlevel =
"low"
184 self.cut_off = cut_off
186 self.plateau = plateau
188 fl = IMP.pmi.tools.open_file_or_inline_text(restraints_file)
192 tokens = line.split()
194 if (tokens[0] ==
"#"):
203 resolution=resolution,
205 name_is_ambiguous=
True,
207 hrc1 = [representation.hier_db.particle_to_name[p]
for p
in ps1]
212 hrc1nosym = [representation.hier_db.particle_to_name[p]
216 print(
"AmbiguousCompositeRestraint: WARNING> residue %d of chain %s is not there" % (r1, c1))
221 resolution=resolution,
223 name_is_ambiguous=
True,
225 hrc2 = [representation.hier_db.particle_to_name[p]
for p
in ps2]
230 hrc2nosym = [representation.hier_db.particle_to_name[p]
234 print(
"AmbiguousCompositeRestraint: WARNING> residue %d of chain %s is not there" % (r2, c2))
244 cr.add_composite_particle(ps2)
246 self.rs.add_restraint(cr)
265 cr.add_composite_particle(ps2nosym)
267 self.rs.add_restraint(cr)
296 cr.add_composite_particle([p2])
299 for i
in range(npoints):
303 scores.append(cr.unprotected_evaluate(
None))
304 output.plot_xy_data(dists, scores)
306 def set_label(self, label):
308 self.rs.set_name(label)
309 for r
in self.rs.get_restraints():
312 def add_to_model(self):
313 self.m.add_restraint(self.rs)
315 def get_hierarchies(self):
318 def get_restraint_sets(self):
321 def get_restraint(self):
324 def set_output_level(self, level="low"):
326 self.outputlevel = level
328 def set_weight(self, weight):
330 self.rs.set_weight(weight)
332 def get_output(self):
338 score = self.weight * self.rs.unprotected_evaluate(
None)
339 output[
"_TotalScore"] = str(score)
340 output[
"AmbiguousCompositeRestraint_Score_" + self.label] = str(score)
341 for n, p
in enumerate(self.pairs):
352 for n1, p1
in enumerate(ps1):
355 for n2, p2
in enumerate(ps2):
359 label = str(r1) +
":" + name1 +
"_" + str(r2) +
":" + name2
360 output[
"AmbiguousCompositeRestraint_Distance_" +
363 label = str(r1) +
":" + c1 +
"_" + str(r2) +
":" + c2
364 output[
"AmbiguousCompositeRestraint_Score_" +
365 label] = str(self.weight * cr.unprotected_evaluate(
None))
371 class SimplifiedPEMAP(object):
381 self.m = representation.prot.get_model()
386 self.outputlevel =
"low"
387 self.expdistance = expdistance
388 self.strength = strength
390 fl = IMP.pmi.tools.open_file_or_inline_text(restraints_file)
394 tokens = line.split()
396 if (tokens[0] ==
"#"):
402 pcc = float(tokens[4])
406 resolution=resolution,
408 name_is_ambiguous=
False,
411 print(
"SimplifiedPEMAP: WARNING> residue %d of chain %s is not there (w/ %d %s)" % (r1, c1, r2, c2))
414 print(
"SimplifiedPEMAP: WARNING> residue %d of chain %s selected multiple particles" % (r1, c1))
419 resolution=resolution,
421 name_is_ambiguous=
False,
424 print(
"SimplifiedPEMAP: WARNING> residue %d of chain %s is not there (w/ %d %s)" % (r1, c1, r2, c2))
427 print(
"SimplifiedPEMAP: WARNING> residue %d of chain %s selected multiple particles" % (r2, c2))
434 upperdist = self.get_upper_bond(pcc)
435 limit = self.strength * (upperdist + 15) ** 2 + 10.0
448 self.rs.add_restraint(dr)
449 self.pairs.append((p1, p2, dr, r1, c1, r2, c2))
452 lowerdist = self.get_lower_bond(pcc)
453 limit = self.strength * (lowerdist - 15) ** 2 + 10.0
466 self.rs.add_restraint(dr2)
467 self.pairs.append((p1, p2, dr2, r1, c1, r2, c2))
469 def get_upper_bond(self, pearsoncc):
471 return (pearsoncc - .5) / (-0.005415)
473 def get_lower_bond(self, pearsoncc):
474 return (pearsoncc - 1.) / -0.0551
476 def set_label(self, label):
479 def add_to_model(self):
480 self.m.add_restraint(self.rs)
482 def get_hierarchies(self):
485 def get_restraint_sets(self):
488 def set_output_level(self, level="low"):
490 self.outputlevel = level
492 def get_output(self):
498 score = self.rs.unprotected_evaluate(
None)
499 output[
"_TotalScore"] = str(score)
500 output[
"SimplifiedPEMAP_Score_" + self.label] = str(score)
501 for i
in range(len(self.pairs)):
503 p0 = self.pairs[i][0]
504 p1 = self.pairs[i][1]
505 crosslinker =
'standard'
506 ln = self.pairs[i][2]
507 resid1 = self.pairs[i][3]
508 chain1 = self.pairs[i][4]
509 resid2 = self.pairs[i][5]
510 chain2 = self.pairs[i][6]
512 label = str(resid1) +
":" + chain1 +
"_" + \
513 str(resid2) +
":" + chain2
514 output[
"SimplifiedPEMAP_Score_" + crosslinker +
"_" +
515 label] = str(ln.unprotected_evaluate(
None))
519 output[
"SimplifiedPEMAP_Distance_" +
A function that is harmonic over an interval.
this restraint allows ambiguous crosslinking between multiple copies excluding between symmetric copi...
Various classes to hold sets of particles.
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.
kernel::RestraintsTemp get_restraints(const Subset &s, const ParticleStatesTable *pst, const DependencyGraph &dg, kernel::RestraintSet *rs)
A score on the distance between the surfaces of two spheres.
double get_distance(XYZR a, XYZR b)
Compute the sphere distance between a and b.
static XYZR setup_particle(kernel::Model *m, ParticleIndex pi)
A restraint for ambiguous cross-linking MS data and multiple state approach.
kernel::Restraint * create_connectivity_restraint(const Selections &s, double x0, double k, std::string name="Connectivity%1%")
Create a restraint connecting the selections.
A decorator for a particle with x,y,z coordinates.
handleparticles is a selection tuple compositeparticles is a list of selection tuples ...
Class to handle individual model particles.
Classes for writing output files and processing them.
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...
Applies a PairScore to a Pair.
Python classes to represent, score, sample and analyze models.
Functionality for loading, creating, manipulating and scoring atomic structures.
Select hierarchy particles identified by the biological name.
A decorator for a particle with x,y,z coordinates and a radius.