1 """@namespace IMP.pmi.io.xltable
2 Tools to plot a contact map overlaid with cross-links.
5 from __future__
import print_function
7 from scipy.spatial.distance
import cdist
9 import matplotlib
as mpl
11 import matplotlib.cm
as cm
12 import matplotlib.pyplot
as plt
14 from collections
import defaultdict
27 """ class to read, analyze, and plot xlink data on contact maps
28 Canonical way to read the data:
29 1) load sequences and name them
30 2) load coordinates for those sequences from PDB file
36 def __init__(self,contact_threshold):
38 self.cross_link_db =
None
39 self.residue_pair_list = []
40 self.distance_maps = []
41 self.contact_freqs =
None
44 self.index_dict = defaultdict(list)
45 self.contact_threshold = contact_threshold
52 def _colormap_distance(self, dist, threshold=35, tolerance=0):
53 if dist < threshold - tolerance:
55 elif dist >= threshold + tolerance:
60 def _colormap_satisfaction(self, sat, threshold=0.5, tolerance=0.1):
61 if sat >= threshold + tolerance:
64 elif sat < threshold + tolerance
and sat >= threshold - tolerance :
71 def _get_percentage_satisfaction(self,r1,c1,r2,c2,threshold=35):
73 idx1=self.index_dict[c1][r1]
77 idx2=self.index_dict[c2][r2]
81 for dists
in self.dist_maps:
83 if dist<threshold: nsatisfied+=1
84 return float(nsatisfied)/len(self.dist_maps)
86 def _get_distance(self,r1,c1,r2,c2):
87 if self.index_dict
is not None:
89 idx1=self.index_dict[c1][r1]
93 idx2=self.index_dict[c2][r2]
96 return self.av_dist_map[idx1,idx2]
98 if (r1,c1,r2,c2)
not in self.stored_dists.keys():
100 selpart=sel.get_selected_particles()
101 selpart_res_one=list(set(self.particles_resolution_one) & set(selpart))
102 if len(selpart_res_one)>1:
return None
103 if len(selpart_res_one)==0:
return None
104 selpart_res_one_1=selpart_res_one[0]
106 selpart=sel.get_selected_particles()
107 selpart_res_one=list(set(self.particles_resolution_one) & set(selpart))
108 if len(selpart_res_one)>1:
return None
109 if len(selpart_res_one)==0:
return None
110 selpart_res_one_2=selpart_res_one[0]
114 self.stored_dists[(r1,c1,r2,c2)]=dist
116 dist=self.stored_dists[(r1,c1,r2,c2)]
120 def _get_distance_and_particle_pair(self,r1,c1,r2,c2):
121 '''more robust and slower version of above'''
123 selpart=sel.get_selected_particles()
124 selpart_res_one=list(set(self.particles_resolution_one) & set(selpart))
125 if len(selpart_res_one)>1:
return None
126 if len(selpart_res_one)==0:
return None
127 selpart_res_one_1=selpart_res_one[0]
129 selpart=sel.get_selected_particles()
130 selpart_res_one=list(set(self.particles_resolution_one) & set(selpart))
131 if len(selpart_res_one)>1:
return None
132 if len(selpart_res_one)==0:
return None
133 selpart_res_one_2=selpart_res_one[0]
137 return (dist,selpart_res_one_1,selpart_res_one_2)
139 def _internal_load_maps(self,maps_fn):
140 npzfile = np.load(maps_fn)
141 cname_array=npzfile[
'cname_array']
142 idx_array=npzfile[
'idx_array']
144 for cname,idxs
in zip(cname_array,idx_array):
147 index_dict[cname]=tmp[0:tmp.index(-1)]
149 index_dict[cname]=tmp
150 av_dist_map = npzfile[
'av_dist_map']
151 contact_map = npzfile[
'contact_map']
152 return index_dict,av_dist_map,contact_map
155 """ read sequence. structures are displayed in the same order as sequences are read.
156 fasta_file: file to read
157 id_in_fasta_file: id of desired sequence
158 protein_name: identifier for this sequence (use same name when handling coordinates)
159 can provide the fasta name (for retrieval) and the protein name (for storage) """
162 if id_in_fasta_file
is None:
163 id_in_fasta_file = name
164 if id_in_fasta_file
not in record_dict:
165 raise KeyError(
"id %s not found in fasta file" % id_in_fasta_file)
166 length = len(record_dict[id_in_fasta_file])
168 self.sequence_dict[protein_name] = str(record_dict[id_in_fasta_file])
171 """ read coordinates from a pdb file. also appends to distance maps
172 @param pdbfile file for reading coords
173 @param chain_to_name_map correspond chain ID with protein name (will ONLY read these chains)
174 Key: PDB chain ID. Value: Protein name (set in sequence reading)
175 \note This function returns an error if the sequence for each chain has NOT been read
178 total_len = sum(len(self.sequence_dict[s])
for s
in self.sequence_dict)
179 coords = np.ones((total_len,3)) * 1e5
181 for cid
in chain_to_name_map:
182 cname = chain_to_name_map[cid]
183 if cname
not in self.sequence_dict:
184 print(
"ERROR: chain",cname,
'has not been read or has a naming mismatch')
187 self.index_dict[cname]=range(prev_stop,prev_stop+len(self.sequence_dict[cname]))
189 for p
in sel.get_selected_particles():
191 coords[rnum+prev_stop-1,:] = list(
IMP.core.XYZ(p).get_coordinates())
192 prev_stop+=len(self.sequence_dict[cname])
193 dists = cdist(coords, coords)
194 binary_dists = np.where((dists <= self.contact_threshold) & (dists >= 1.0), 1.0, 0.0)
196 self.dist_maps= [dists]
197 self.av_dist_map = dists
198 self.contact_freqs = binary_dists
201 self.dist_maps.append(dists)
202 self.av_dist_map += dists
203 self.contact_freqs += binary_dists
209 """ read coordinates from a rmf file. It needs IMP to run.
210 rmf has been created using IMP.pmi conventions. It gets the
211 highest resolution automatically. Also appends to distance maps
212 @param rmf_name file for reading coords
213 @param rmf_frame_index frame index from the rmf
214 @param nomap Default False, if True it will not calculate the contact map
216 (particles_resolution_one, prots)=self._get_rmf_structure(rmf_name,rmf_frame_index)
218 total_len = sum(len(self.sequence_dict[s])
for s
in self.sequence_dict)
219 print(self.sequence_dict,total_len)
221 coords = np.ones((total_len,3)) * 1e6
223 sorted_particles=IMP.pmi.tools.sort_by_residues(particles_resolution_one)
226 self.particles_resolution_one=particles_resolution_one
231 for cname
in chain_names:
234 self.index_dict[cname]=range(prev_stop,prev_stop+len(self.sequence_dict[cname]))
235 rindexes=range(1,len(self.sequence_dict[cname])+1)
236 for rnum
in rindexes:
238 selpart=sel.get_selected_particles()
239 selpart_res_one=list(set(particles_resolution_one) & set(selpart))
240 if len(selpart_res_one)>1:
continue
241 if len(selpart_res_one)==0:
continue
242 selpart_res_one=selpart_res_one[0]
244 coords[rnum+prev_stop-1,:]=
IMP.core.XYZ(selpart_res_one).get_coordinates()
246 print(
"Error: exceed max size",prev_stop,total_len,cname,rnum)
248 prev_stop+=len(self.sequence_dict[cname])
249 dists = cdist(coords, coords)
250 binary_dists = np.where((dists <= self.contact_threshold) & (dists >= 1.0), 1.0, 0.0)
252 self.dist_maps= [dists]
253 self.av_dist_map = dists
254 self.contact_freqs = binary_dists
257 self.dist_maps.append(dists)
258 self.av_dist_map += dists
259 self.contact_freqs += binary_dists
263 def _get_rmf_structure(self,rmf_name,rmf_frame_index):
264 rh= RMF.open_rmf_file_read_only(rmf_name)
267 print(
"getting coordinates for frame %i rmf file %s" % (rmf_frame_index, rmf_name))
272 protein_names=particle_dict.keys()
273 particles_resolution_one=[]
274 for k
in particle_dict:
275 particles_resolution_one+=(particle_dict[k])
277 return particles_resolution_one, prots
280 def save_maps(self,maps_fn):
281 maxlen=max(len(self.index_dict[key])
for key
in self.index_dict)
284 for cname,idx
in self.index_dict.iteritems():
286 idxs.append(idx+[-1]*(maxlen-len(idx)))
287 idx_array=np.array(idxs)
288 cname_array=np.array(cnames)
290 cname_array=cname_array,
292 av_dist_map=self.av_dist_map,
293 contact_map=self.contact_freqs)
295 def load_maps(self,maps_fn):
296 self.index_dict,self.av_dist_map,self.contact_freqs=self._internal_load_maps(maps_fn)
299 """ read crosslinks from a CSV file.
300 provide a CrossLinkDataBaseKeywordsConverter to explain the columns
301 @distance_field is the optional keyword for the distance to be read form the file.
302 This can skip the rmf reading to calculate the distance of cross-links if
303 already provided in the csv file."""
304 if type(CrossLinkDataBase)
is not IMP.pmi.io.crosslink.CrossLinkDataBase:
305 raise TypeError(
"Crosslink database must be a IMP.pmi.io.CrossLinkDataBase type")
306 self.cross_link_db=CrossLinkDataBase
307 if distance_field
is not None:
308 total_len = sum(len(self.sequence_dict[s])
for s
in self.sequence_dict)
309 zeros = np.zeros((total_len,3))
310 self.av_dist_map = cdist(zeros,zeros)
311 for xl
in self.cross_link_db:
312 c1=xl[self.cross_link_db.protein1_key]
313 c2=xl[self.cross_link_db.protein2_key]
314 r1=xl[self.cross_link_db.residue1_key]
315 r2=xl[self.cross_link_db.residue2_key]
317 self.stored_dists[(r1,c1,r2,c2)]=float(xl[distance_field])
318 self.stored_dists[(r2,c2,r1,c1)]=float(xl[distance_field])
320 self.stored_dists[(r1,c1,r2,c2)]=10e6
321 self.stored_dists[(r2,c2,r1,c1)]=10e6
324 """ select the atom names of residue pairs to plot on the contact map
325 list of residues types must be single letter code
326 e.g. residue_type_pair=("K","K")
328 rtp=sorted(residue_type_pair)
329 for prot1
in self.sequence_dict:
330 seq1=self.sequence_dict[prot1]
331 for nres1,res1
in enumerate(seq1):
332 for prot2
in self.sequence_dict:
333 seq2=self.sequence_dict[prot2]
334 for nres2,res2
in enumerate(seq2):
335 if sorted((res1,res2))==rtp:
336 self.residue_pair_list.append((nres1+1,prot1,nres2+1,prot2))
339 """ loop through each distance map and get frequency of contacts
341 if self.num_pdbs!=0
and self.num_rmfs==0:
342 self.av_dist_map = 1.0/self.num_pdbs * self.av_dist_map
343 self.contact_freqs = 1.0/self.num_pdbs * self.contact_freqs
344 if self.num_pdbs==0
and self.num_rmfs!=0:
345 self.av_dist_map = 1.0/self.num_rmfs * self.av_dist_map
346 self.contact_freqs = 1.0/self.num_rmfs * self.contact_freqs
348 def setup_difference_map(self,maps_fn1,maps_fn2,thresh):
349 idx1,av1,contact1=self._internal_load_maps(maps_fn1)
350 idx2,av2,contact2=self._internal_load_maps(maps_fn2)
352 print(
"UH OH: index dictionaries do not match!")
360 elif c1>thresh
and c2<thresh:
362 elif c1<thresh
and c2>thresh:
366 f = np.vectorize(logic,otypes=[np.int])
367 print(
'computing contact map')
368 self.contact_freqs = f(contact1,contact2)
373 def spring_layout(self,ax,plt,data, annotations, iterations = 100, k=1):
375 import networkx
as nx
383 Author: G. Bouvier, Pasteur Institute, Paris
384 Website: http://bloggb.fr/2015/10/19/spring_layout_for_annotating_plot_in_matplotlib.html
385 - data: coordinates of your points [(x1,y1), (x2,y2), ..., (xn,yn)]
386 - annotations: text for your annotation ['str_1', 'str_2', ..., 'str_n']
387 - iterations: number of iterations for spring layout
388 - k: optimal distance between nodes
392 x, y = [e[0]
for e
in data], [e[1]
for e
in data]
393 xmin, xmax = min(x), max(x)
394 ymin, ymax = min(y), max(y)
403 for i,xy
in enumerate(data):
430 ps = particles.values()+particles_fixed.values()
437 rs.add_restraint(evr)
441 #G.add_edge(xy, text)
444 delTri = scipy.spatial.Delaunay(data)
445 #plt.scatter([e[0] for e in data], [e[1] for e in data])
446 # create a set for edges that are indexes of the points
448 # for each Delaunay triangle
449 for n in xrange(delTri.nsimplex):
450 # for each edge of the triangle
452 # (sorting avoids duplicated edges being added to the set)
453 # and add to the edges set
454 edge = sorted([delTri.vertices[n,0], delTri.vertices[n,1]])
455 edges.add((edge[0], edge[1]))
456 edge = sorted([delTri.vertices[n,0], delTri.vertices[n,2]])
457 edges.add((edge[0], edge[1]))
458 edge = sorted([delTri.vertices[n,1], delTri.vertices[n,2]])
459 edges.add((edge[0], edge[1]))
463 G.add_edge(e[0],e[1])
465 d1=IMP.core.XYZ(particles[e[0]])
466 d2=IMP.core.XYZ(particles[e[1]])
467 dist=IMP.core.get_distance(d1,d2)
468 ts1 = IMP.core.Harmonic(dist+150, 0.001)
470 IMP.core.DistanceRestraint(m, ts1,
478 mc.set_scoring_function(rs)
479 mc.set_return_best(
False)
485 pos = nx.spring_layout(G ,pos=init_pos)
488 for i,xy in enumerate(data):
489 xynew = pos[i] * [xmax-xmin, ymax-ymin] + [xmin, ymin]
490 plt.plot((xy[0],xynew[0]), (xy[1],xynew[1]), 'k-')
491 x_list.append(xynew[0])
492 y_list.append(xynew[1])
493 #plt.annotate(name, xy, size=5, xycoords='data', xytext=xytext, textcoords='data', bbox=dict(boxstyle='round,pad=0.2', fc='yellow', alpha=0.3),\
494 # arrowprops=dict(arrowstyle="-", connectionstyle="arc3", color='gray'))
496 points=ax.scatter(x_list,y_list,alpha=1)
497 #pos*=[numpy.ptp([e[0] for e in data]), numpy.ptp([e[1] for e in data])]
503 mc.optimize(1000*len(particles.keys())*2)
504 print(rs.evaluate(
False))
507 for i,xy
in enumerate(data):
510 xynew = (coord[0],coord[1])
511 plt.plot((xy[0],xynew[0]), (xy[1],xynew[1]),
'k-')
512 x_list.append(xynew[0])
513 y_list.append(xynew[1])
514 points=ax.scatter(x_list,y_list,alpha=1,facecolors=
'none', edgecolors=
'k')
519 def show_mpld3(self,fig,ax,points,xl_list,xl_labels):
521 from mpld3
import plugins
528 border-collapse: collapse;
533 background-color: #ffffff;
537 background-color: #cccccc;
541 font-family:Arial, Helvetica, sans-serif;
542 border: 1px solid black;
547 df = pd.DataFrame(index=xl_labels)
549 sorted_keys=sorted(xl_list[0].keys())
551 for k
in sorted_keys:
552 df[k] = np.array([xl[k]
for xl
in xl_list])
555 for i
in range(len(xl_labels)):
556 label = df.ix[[i], :].T
558 labels.append(str(label.to_html()))
560 tooltip = plugins.PointHTMLTooltip(points, labels,
561 voffset=10, hoffset=10, css=css)
562 plugins.connect(fig, tooltip)
563 mpld3.save_html(fig,
"output.html")
565 def save_xl_distances(self,filename):
571 sorted_group_ids=sorted(self.cross_link_db.data_base.keys())
572 for group
in sorted_group_ids:
575 for xl
in self.cross_link_db.data_base[group]:
577 sorted_ids=sorted(xl.keys())
578 data.append(sorted_ids+[
"UniqueID",
"Distance",
"MinAmbiguousDistance"])
579 (c1,c2,r1,r2)=IMP.pmi.io.crosslink._ProteinsResiduesArray(xl)
580 mdist=self._get_distance(r1,c1,r2,c2)
581 values=[xl[k]
for k
in sorted_ids]
582 values+=[group,mdist]
583 group_dists.append(mdist)
584 group_block.append(values)
585 for l
in group_block:
586 l.append(min(group_dists))
589 with open(filename,
'w')
as fp:
590 a = csv.writer(fp, delimiter=
',')
593 def save_rmf_snapshot(self,filename):
596 sorted_group_ids=sorted(self.cross_link_db.data_base.keys())
598 for group
in sorted_group_ids:
600 group_dists_particles=[]
601 for xl
in self.cross_link_db.data_base[group]:
602 xllabel=self.cross_link_db.get_short_cross_link_string(xl)
603 (c1,c2,r1,r2)=IMP.pmi.io.crosslink._ProteinsResiduesArray(xl)
605 (mdist,p1,p2)=self._get_distance_and_particle_pair(r1,c1,r2,c2)
608 group_dists_particles.append((mdist,p1,p2,xllabel))
609 if group_dists_particles:
610 (minmdist,minp1,minp2,minxllabel)=min(group_dists_particles, key =
lambda t: t[0])
611 list_of_pairs.append((minp1,minp2,xllabel))
615 m=self.prots[0].get_model()
617 linear.set_slope(1.0)
621 for pair
in list_of_pairs:
624 rslin.add_restraint(pr)
626 rh = RMF.create_rmf_file(filename)
636 confidence_info=
False,
638 display_residue_pairs=
False,
641 confidence_classes=
None,
643 scale_symbol_size=1.0,
644 gap_between_components=0,
645 dictionary_of_gaps={},
647 crosslink_threshold=
None,
652 color_crosslinks_by_distance=
True):
653 """ plot the xlink table with optional contact map.
654 prot_listx: list of protein names on the x-axis
655 prot_listy: list of protein names on the y-axis
656 no_dist_info: plot only the cross-links as grey spots
658 filter: list of tuples to filter on. each one contains:
659 keyword in the database to be filtered on
660 relationship ">","==","<"
662 example ("ID_Score",">",40)
663 display_residue_pairs: display all pairs defined in self.residue_pair_list
664 contactmap: display the contact map
665 filename: save to file (adds .pdf extension)
668 scale_symbol_size: rescale the symbol for the crosslink
669 gap_between_components: the numbeber of residues to leave blannk between each component
670 dictionary_of_gaps: add extra space after the given protein. dictionary_of_gaps={prot_name:extra_gap}
675 fig = plt.figure(figsize=(100, 100))
676 ax = fig.add_subplot(111)
680 if cbar_labels
is not None:
681 if len(cbar_labels)!=4:
682 print(
"to provide cbar labels, give 3 fields (first=first input file, last=last input) in oppose order of input contact maps")
685 if prot_listx
is None:
686 prot_listx = self.sequence_dict.keys()
688 nresx = gap_between_components + \
689 sum([len(self.sequence_dict[name])
690 + gap_between_components
for name
in prot_listx]) + \
691 sum([dictionary_of_gaps[prot]
for prot
in dictionary_of_gaps.keys()])
694 if prot_listy
is None:
695 prot_listy = self.sequence_dict.keys()
697 nresy = gap_between_components + \
698 sum([len(self.sequence_dict[name])
699 + gap_between_components
for name
in prot_listy]) + \
700 sum([dictionary_of_gaps[prot]
for prot
in dictionary_of_gaps.keys()])
705 res = gap_between_components
706 for prot
in prot_listx:
707 resoffsetx[prot] = res
708 res += len(self.sequence_dict[prot])
710 res += gap_between_components
711 if prot
in dictionary_of_gaps.keys(): res+= dictionary_of_gaps[prot]
715 res = gap_between_components
716 for prot
in prot_listy:
717 resoffsety[prot] = res
718 res += len(self.sequence_dict[prot])
720 res += gap_between_components
721 if prot
in dictionary_of_gaps.keys(): res+= dictionary_of_gaps[prot]
723 resoffsetdiagonal = {}
724 res = gap_between_components
725 for prot
in IMP.pmi.io.utilities.OrderedSet(prot_listx + prot_listy):
726 resoffsetdiagonal[prot] = res
727 res += len(self.sequence_dict[prot])
728 res += gap_between_components
729 if prot
in dictionary_of_gaps.keys(): res+= dictionary_of_gaps[prot]
734 for n, prot
in enumerate(prot_listx):
735 res = resoffsetx[prot]
737 for proty
in prot_listy:
738 resy = resoffsety[proty]
739 endy = resendy[proty]
740 ax.plot([res, res], [resy, endy], linestyle=
'-',color=
'gray', lw=0.4)
741 ax.plot([end, end], [resy, endy], linestyle=
'-',color=
'gray', lw=0.4)
742 xticks.append((float(res) + float(end)) / 2)
747 for n, prot
in enumerate(prot_listy):
748 res = resoffsety[prot]
750 for protx
in prot_listx:
751 resx = resoffsetx[protx]
752 endx = resendx[protx]
753 ax.plot([resx, endx], [res, res], linestyle=
'-',color=
'gray', lw=0.4)
754 ax.plot([resx, endx], [end, end], linestyle=
'-',color=
'gray', lw=0.4)
755 yticks.append((float(res) + float(end)) / 2)
760 tmp_array = np.zeros((nresx, nresy))
761 for px
in prot_listx:
762 for py
in prot_listy:
763 resx = resoffsetx[px]
764 lengx = resendx[px] - 1
765 resy = resoffsety[py]
766 lengy = resendy[py] - 1
767 indexes_x = self.index_dict[px]
768 minx = min(indexes_x)
769 maxx = max(indexes_x)
770 indexes_y = self.index_dict[py]
771 miny = min(indexes_y)
772 maxy = max(indexes_y)
773 tmp_array[resx:lengx,resy:lengy] = self.contact_freqs[minx:maxx,miny:maxy]
775 cax = ax.imshow(tmp_array,
780 interpolation=
'nearest')
782 ax.set_xticks(xticks)
783 ax.set_xticklabels(xlabels, rotation=90)
784 ax.set_yticks(yticks)
785 ax.set_yticklabels(ylabels)
786 plt.setp(ax.get_xticklabels(), fontsize=30)
787 plt.setp(ax.get_yticklabels(), fontsize=30)
790 already_added_xls = []
791 xl_coordinates_tuple_list = []
798 markersize = 5 * scale_symbol_size
799 for xl
in self.cross_link_db:
801 (c1,c2,r1,r2)=IMP.pmi.io.crosslink._ProteinsResiduesArray(xl)
802 label=xl[self.cross_link_db.unique_sub_id_key]
803 if color_crosslinks_by_distance:
806 mdist=self._get_distance(r1,c1,r2,c2)
807 if mdist
is None:
continue
808 color = self._colormap_distance(mdist,threshold=crosslink_threshold)
815 ps=self._get_percentage_satisfaction(r1,c1,r2,c2)
816 if ps
is None:
continue
817 color = self._colormap_satisfaction(ps,threshold=0.2,tolerance=0.1)
822 pos1 = r1 + resoffsetx[c1]
826 pos2 = r2 + resoffsety[c2]
833 pos_for_diagonal1 = r1 + resoffsetdiagonal[c1]
834 pos_for_diagonal2 = r2 + resoffsetdiagonal[c2]
836 if confidence ==
'0.01':
837 markersize = 14 * scale_symbol_size
838 elif confidence ==
'0.05':
839 markersize = 9 * scale_symbol_size
840 elif confidence ==
'0.1':
841 markersize = 6 * scale_symbol_size
843 markersize = 15 * scale_symbol_size
845 markersize = 5 * scale_symbol_size
852 markersize=markersize)
859 markersize=markersize)
865 color_list.append(color)
866 color_list.append(color)
871 xl_labels.append(label)
872 xl_coordinates_tuple_list.append((float(pos1),float(pos2)))
873 xl_labels.append(label+
"*")
874 xl_coordinates_tuple_list.append((float(pos2),float(pos1)))
876 points=ax.scatter(x_list,y_list,s=markersize,c=color_list,alpha=alphablend)
879 if display_residue_pairs:
880 for rp
in self.residue_pair_list:
887 dist=self._get_distance(r1,c1,r2,c2)
894 pos1 = r1 + resoffsetx[c1]
898 pos2 = r2 + resoffsety[c2]
907 markersize=markersize)
910 fig.set_size_inches(0.002 * nresx, 0.002 * nresy)
911 [i.set_linewidth(2.0)
for i
in ax.spines.itervalues()]
912 if cbar_labels
is not None:
913 cbar = fig.colorbar(cax, ticks=[0.5,1.5,2.5,3.5])
914 cbar.ax.set_yticklabels(cbar_labels)
918 points=self.spring_layout(ax,plt,xl_coordinates_tuple_list, xl_labels)
922 plt.savefig(filename, dpi=300,transparent=
"False")
926 self.show_mpld3(fig,ax,points,xl_list,xl_labels)
Utility classes and functions for IO.
atom::Hierarchies create_hierarchies(RMF::FileConstHandle fh, Model *m)
RMF::FrameID save_frame(RMF::FileHandle file, std::string name="")
Save the current state of the linked objects as a new RMF frame.
Set of python classes to create a multi-state, multi-resolution IMP hierarchy.
Upper bound harmonic function (non-zero when feature > mean)
class to read, analyze, and plot xlink data on contact maps Canonical way to read the data: 1) load s...
static XYZR setup_particle(Model *m, ParticleIndex pi)
Utility classes and functions for reading and storing PMI files.
def plot_table
plot the xlink table with optional contact map.
def load_rmf_coordinates
read coordinates from a rmf file.
Handles cross-link data sets.
Return all close unordered pairs of particles taken from the SingletonContainer.
def load_pdb_coordinates
read coordinates from a pdb file.
Distance restraint between two particles.
double get_distance(XYZR a, XYZR b)
Compute the sphere distance between a and b.
void read_pdb(TextInput input, int model, Hierarchy h)
Object used to hold a set of restraints.
def setup_contact_map
loop through each distance map and get frequency of contacts
Class for storing model, its restraints, constraints, and particles.
def load_sequence_from_fasta_file
read sequence.
ParticleIndexPairs get_indexes(const ParticlePairsTemp &ps)
def set_residue_pairs_to_display
select the atom names of residue pairs to plot on the contact map list of residues types must be sing...
Ints get_index(const ParticlesTemp &particles, const Subset &subset, const Subsets &excluded)
Store a list of ParticleIndexes.
A decorator for a particle representing an atom.
def load_crosslinks
read crosslinks from a CSV file.
void load_frame(RMF::FileConstHandle file, RMF::FrameID frame)
A decorator for a particle with x,y,z coordinates.
def get_particles_at_resolution_one
Get particles at res 1, or any beads, based on the name.
void add_hierarchies(RMF::NodeHandle fh, const atom::Hierarchies &hs)
void add_restraints(RMF::NodeHandle fh, const Restraints &hs)
Tools for clustering and cluster analysis.
Modify a set of continuous variables using a normal distribution.
Residue get_residue(Atom d, bool nothrow=false)
Return the Residue containing this atom.
Class to handle individual model particles.
Applies a PairScore to a Pair.
Select all CA ATOM records.
static const FloatKeys & get_xyz_keys()
Get a vector containing the keys for x,y,z.
Python classes to represent, score, sample and analyze models.
A dictionary-like wrapper for reading and storing sequence data.
Functionality for loading, creating, manipulating and scoring atomic structures.
Select hierarchy particles identified by the biological name.
Support for the RMF file format for storing hierarchical molecular data and markup.
Applies a list of movers one at a time.
Applies a PairScore to each Pair in a list.
Perform more efficient close pair finding when rigid bodies are involved.
A decorator for a particle with x,y,z coordinates and a radius.