1 """@namespace IMP.pmi.restraints.proteomics
2 Restraints for handling various kinds of proteomics data.
5 from __future__
import print_function
13 class ConnectivityRestraint(object):
16 generate a connectivity restraint between domains
17 setting up the restraint
19 cr=restraints.ConnectivityRestraint(simo,["CCC",(1,100,"TTT"),(100,150,"AAA")])
22 Multistate support =No
23 Selection type=selection tuple
38 if self.label ==
"None":
39 self.label = str(selection_tuples)
40 self.m = representation.prot.get_model()
45 for s
in selection_tuples:
46 particles = IMP.pmi.tools.select_by_tuple(representation, s,
47 resolution=resolution, name_is_ambiguous=
True)
55 self.rs.add_restraint(cr)
57 def set_label(self, label):
59 self.rs.set_name(label)
60 for r
in self.rs.get_restraints():
63 def add_to_model(self):
66 def get_restraint(self):
69 def get_restraints(self):
71 for r
in self.rs.get_restraints():
72 rlist.append(IMP.core.PairRestraint.get_from(r))
75 def set_weight(self, weight):
77 self.rs.set_weight(weight)
82 score = self.weight * self.rs.unprotected_evaluate(
None)
83 output[
"_TotalScore"] = str(score)
84 output[
"ConnectivityRestraint_" + self.label] = str(score)
91 handleparticles is a selection tuple
92 compositeparticles is a list of selection tuples
99 handleparticles_tuples,
100 compositeparticles_tuple_list,
109 self.m = representation.prot.get_model()
112 self.handleparticles = []
113 for s
in handleparticles_tuples:
114 self.handleparticles += IMP.pmi.tools.select_by_tuple(representation, s,
115 resolution=resolution, name_is_ambiguous=
True)
116 self.compositeparticles=[]
117 compositeparticle_list = []
118 for list
in compositeparticles_tuple_list:
121 tmplist += IMP.pmi.tools.select_by_tuple(
123 resolution=resolution, name_is_ambiguous=
True)
124 compositeparticle_list.append(tmplist)
125 self.compositeparticles+=tmplist
130 self.handleparticles,
136 for ps
in compositeparticle_list:
138 ln.add_composite_particle(ps)
140 self.rs.add_restraint(ln)
142 def set_label(self, label):
145 def get_handle_particles(self):
146 return self.handleparticles
148 def get_composite_particles(self):
149 return self.compositeparticles
151 def get_restraint(self):
154 def add_to_model(self):
157 def get_output(self):
160 score = self.rs.unprotected_evaluate(
None)
161 output[
"_TotalScore"] = str(score)
162 output[
"CompositeRestraint_" + self.label] = str(score)
170 this restraint allows ambiguous crosslinking between multiple copies
171 excluding between symmetric copies
172 It allows name ambiguity
186 self.m = representation.prot.get_model()
191 self.outputlevel =
"low"
192 self.cut_off = cut_off
194 self.plateau = plateau
196 fl = IMP.pmi.tools.open_file_or_inline_text(restraints_file)
200 tokens = line.split()
202 if (tokens[0] ==
"#"):
211 resolution=resolution,
213 name_is_ambiguous=
True,
215 hrc1 = [representation.hier_db.particle_to_name[p]
for p
in ps1]
220 hrc1nosym = [representation.hier_db.particle_to_name[p]
224 print(
"AmbiguousCompositeRestraint: WARNING> residue %d of chain %s is not there" % (r1, c1))
229 resolution=resolution,
231 name_is_ambiguous=
True,
233 hrc2 = [representation.hier_db.particle_to_name[p]
for p
in ps2]
238 hrc2nosym = [representation.hier_db.particle_to_name[p]
242 print(
"AmbiguousCompositeRestraint: WARNING> residue %d of chain %s is not there" % (r2, c2))
252 cr.add_composite_particle(ps2)
254 self.rs.add_restraint(cr)
273 cr.add_composite_particle(ps2nosym)
275 self.rs.add_restraint(cr)
304 cr.add_composite_particle([p2])
307 for i
in range(npoints):
311 scores.append(cr.unprotected_evaluate(
None))
312 output.plot_xy_data(dists, scores)
314 def set_label(self, label):
316 self.rs.set_name(label)
317 for r
in self.rs.get_restraints():
320 def add_to_model(self):
323 def get_hierarchies(self):
326 def get_restraint_sets(self):
329 def get_restraint(self):
332 def set_output_level(self, level="low"):
334 self.outputlevel = level
336 def set_weight(self, weight):
338 self.rs.set_weight(weight)
340 def get_output(self):
346 score = self.weight * self.rs.unprotected_evaluate(
None)
347 output[
"_TotalScore"] = str(score)
348 output[
"AmbiguousCompositeRestraint_Score_" + self.label] = str(score)
349 for n, p
in enumerate(self.pairs):
360 for n1, p1
in enumerate(ps1):
363 for n2, p2
in enumerate(ps2):
367 label = str(r1) +
":" + name1 +
"_" + str(r2) +
":" + name2
368 output[
"AmbiguousCompositeRestraint_Distance_" +
371 label = str(r1) +
":" + c1 +
"_" + str(r2) +
":" + c2
372 output[
"AmbiguousCompositeRestraint_Score_" +
373 label] = str(self.weight * cr.unprotected_evaluate(
None))
379 class SimplifiedPEMAP(object):
389 self.m = representation.prot.get_model()
394 self.outputlevel =
"low"
395 self.expdistance = expdistance
396 self.strength = strength
398 fl = IMP.pmi.tools.open_file_or_inline_text(restraints_file)
402 tokens = line.split()
404 if (tokens[0] ==
"#"):
410 pcc = float(tokens[4])
414 resolution=resolution,
416 name_is_ambiguous=
False,
419 print(
"SimplifiedPEMAP: WARNING> residue %d of chain %s is not there (w/ %d %s)" % (r1, c1, r2, c2))
422 print(
"SimplifiedPEMAP: WARNING> residue %d of chain %s selected multiple particles" % (r1, c1))
427 resolution=resolution,
429 name_is_ambiguous=
False,
432 print(
"SimplifiedPEMAP: WARNING> residue %d of chain %s is not there (w/ %d %s)" % (r1, c1, r2, c2))
435 print(
"SimplifiedPEMAP: WARNING> residue %d of chain %s selected multiple particles" % (r2, c2))
442 upperdist = self.get_upper_bond(pcc)
443 limit = self.strength * (upperdist + 15) ** 2 + 10.0
456 self.rs.add_restraint(dr)
457 self.pairs.append((p1, p2, dr, r1, c1, r2, c2))
460 lowerdist = self.get_lower_bond(pcc)
461 limit = self.strength * (lowerdist - 15) ** 2 + 10.0
474 self.rs.add_restraint(dr2)
475 self.pairs.append((p1, p2, dr2, r1, c1, r2, c2))
477 def get_upper_bond(self, pearsoncc):
479 return (pearsoncc - .5) / (-0.005415)
481 def get_lower_bond(self, pearsoncc):
482 return (pearsoncc - 1.) / -0.0551
484 def set_label(self, label):
487 def add_to_model(self):
490 def get_hierarchies(self):
493 def get_restraint_sets(self):
496 def set_output_level(self, level="low"):
498 self.outputlevel = level
500 def get_output(self):
506 score = self.rs.unprotected_evaluate(
None)
507 output[
"_TotalScore"] = str(score)
508 output[
"SimplifiedPEMAP_Score_" + self.label] = str(score)
509 for i
in range(len(self.pairs)):
511 p0 = self.pairs[i][0]
512 p1 = self.pairs[i][1]
513 crosslinker =
'standard'
514 ln = self.pairs[i][2]
515 resid1 = self.pairs[i][3]
516 chain1 = self.pairs[i][4]
517 resid2 = self.pairs[i][5]
518 chain2 = self.pairs[i][6]
520 label = str(resid1) +
":" + chain1 +
"_" + \
521 str(resid2) +
":" + chain2
522 output[
"SimplifiedPEMAP_Score_" + crosslinker +
"_" +
523 label] = str(ln.unprotected_evaluate(
None))
527 output[
"SimplifiedPEMAP_Distance_" +
536 generates and wraps a IMP.pmi.ConnectivityRestraint between domains
538 cr=restraints.ConnectivityNetworkRestraint(simo,["CCC",(1,100,"TTT"),(100,150,"AAA")])
542 Multistate support =No
543 Selection type=selection tuple
558 if self.label ==
"None":
559 self.label = str(selection_tuples)
561 self.m = representation.m
564 cr=CompositeNetworkRestraint(self.m)
566 for s
in selection_tuples:
567 particles = IMP.pmi.tools.select_by_tuple(representation, s,
568 resolution=resolution,
569 name_is_ambiguous=
False)
571 cr.add_particles([p.get_particle()
for p
in particles])
573 self.rs.add_restraint(cr)
575 def set_label(self, label):
577 self.rs.set_name(label)
578 for r
in self.rs.get_restraints():
581 def add_to_model(self):
584 def get_restraint(self):
587 def get_restraints(self):
589 for r
in self.rs.get_restraints():
590 rlist.append(IMP.core.PairRestraint.get_from(r))
593 def set_weight(self, weight):
595 self.rs.set_weight(weight)
597 def get_output(self):
600 score = self.weight * self.rs.unprotected_evaluate(
None)
601 output[
"_TotalScore"] = str(score)
602 output[
"ConnectivityNetworkRestraint_" + self.label] = str(score)
610 a python restraint that computes the score for a composite of proteins
611 Authors: G. Bouvier, R. Pellarin. Pasteur Institute.
617 def __init__(self,m,slope=1.0,theta=5.0,plateau=0.01,linear_slope=0.01):
619 input a list of particles, the slope and theta of the sigmoid potential
620 theta is the cutoff distance for a protein-protein contact
622 IMP.Restraint.__init__(self, m,
"ConnectivityNetworkRestraint %1%")
625 self.linear_slope=linear_slope
627 self.particles_blocks=[]
628 self.particle_list=[]
630 def get_number_of_particle_blocks(self):
631 return len(self.particles_blocks)
633 def get_number_of_particles_for_block(self,block_index):
634 return len(self.particles_blocks[block_index])
637 self.particles_blocks.append(particles)
638 self.particle_list+=particles
642 get the full graph of distances between every particle pair
648 pdist_mat=scipy.spatial.distance.squareform(pdist_array)
649 pdist_mat[pdist_mat < 0] = 0
650 graph = networkx.Graph(pdist_mat)
655 return the minimum spanning tree
659 graph = networkx.minimum_spanning_tree(graph)
664 a sigmoid function that scores the probability of a contact
668 argvalue=(x-self.theta)/self.slope
669 return 1.0-(1.0-self.plateau)/(1.0+self.math.exp(-argvalue))
671 def unprotected_evaluate(self,da):
674 for e
in graph.edges():
675 dist=graph.get_edge_data(*e)[
'weight']
677 score+=-self.numpy.log(prob)
678 score+=self.linear_slope*dist
682 return self.particle_list
A function that is harmonic over an interval.
this restraint allows ambiguous crosslinking between multiple copies excluding between symmetric copi...
void add_particles(RMF::FileHandle fh, const ParticlesTemp &hs)
Various classes to hold sets of particles.
static XYZR setup_particle(Model *m, ParticleIndex pi)
def get_full_graph
get the full graph of distances between every particle pair
Add symmetric attribute to a particle.
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.
Object used to hold a set of restraints.
generates and wraps a IMP.pmi.ConnectivityRestraint between domains example: cr=restraints.ConnectivityNetworkRestraint(simo,["CCC",(1,100,"TTT"),(100,150,"AAA")]) cr.add_to_model() cr.set_label("CR1")
def get_minimum_spanning_tree
return the minimum spanning tree
A restraint for ambiguous cross-linking MS data and multiple state approach.
A decorator for a particle with x,y,z coordinates.
handleparticles is a selection tuple compositeparticles is a list of selection tuples ...
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...
def __init__
input a list of particles, the slope and theta of the sigmoid potential theta is the cutoff distance ...
Class to handle individual model particles.
Floats get_list_of_bipartite_minimum_sphere_distance(const ParticlesTemps &pss)
def sigmoid
a sigmoid function that scores the probability of a contact between two proteins
Restraint * create_connectivity_restraint(const Selections &s, double x0, double k, std::string name="Connectivity%1%")
Create a restraint connecting the selections.
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.
virtual ModelObjectsTemp do_get_inputs() const =0
A restraint is a term in an IMP ScoringFunction.
A decorator for a particle with x,y,z coordinates and a radius.