Mercurial > repos > holtgrewe > ngs_roi
comparison roi_plot_thumbnails.py @ 6:71241c4dc4d0 draft
Uploaded
author | holtgrewe |
---|---|
date | Fri, 28 Jun 2013 14:01:42 -0400 |
parents | 170e48a55078 |
children |
comparison
equal
deleted
inserted
replaced
5:170e48a55078 | 6:71241c4dc4d0 |
---|---|
31 | 31 |
32 | 32 |
33 class LinkRegion(object): | 33 class LinkRegion(object): |
34 """Region on picture with genomic interval.""" | 34 """Region on picture with genomic interval.""" |
35 | 35 |
36 def __init__(self, x1, y1, x2, y2, ref, begin_pos, end_pos): | 36 def __init__(self, x1, y1, x2, y2, ref, begin_pos, end_pos, name): |
37 self.x1 = x1 | 37 self.x1 = x1 |
38 self.x2 = x2 | 38 self.x2 = x2 |
39 self.y1 = y1 | 39 self.y1 = y1 |
40 self.y2 = y2 | 40 self.y2 = y2 |
41 self.ref = ref | 41 self.ref = ref |
42 self.begin_pos = begin_pos | 42 self.begin_pos = begin_pos |
43 self.end_pos = end_pos | 43 self.end_pos = end_pos |
44 self.name = name | |
44 | 45 |
45 | 46 |
46 class RoiPlotGrid(object): | 47 class RoiPlotGrid(object): |
47 """A grid of ROI plots. | 48 """A grid of ROI plots. |
48 | 49 |
86 start_x, start_y = self.plotStart(self.idx) | 87 start_x, start_y = self.plotStart(self.idx) |
87 self.idx += 1 | 88 self.idx += 1 |
88 # Register link region. | 89 # Register link region. |
89 self.link_regions.append(LinkRegion( | 90 self.link_regions.append(LinkRegion( |
90 start_x, start_y, start_x + self.width, start_y + self.height, | 91 start_x, start_y, start_x + self.width, start_y + self.height, |
91 record.ref, record.start_pos, record.end_pos)) | 92 record.ref, record.start_pos, record.end_pos, record.region_name)) |
92 | 93 |
93 | 94 |
94 class GridLinks(object): | 95 class GridLinks(object): |
95 """Link information for one grid.""" | 96 """Link information for one grid.""" |
96 | 97 |
155 for gl in self.grid_links: | 156 for gl in self.grid_links: |
156 vals = (gl.file_name, gl.file_name, self.grid.canvas_width, self.grid.canvas_height) | 157 vals = (gl.file_name, gl.file_name, self.grid.canvas_width, self.grid.canvas_height) |
157 f.write('<img src="%s" usemap="#%s" width="%d" height="%d" />\n' % vals) | 158 f.write('<img src="%s" usemap="#%s" width="%d" height="%d" />\n' % vals) |
158 f.write('<map name="%s">\n' % gl.file_name) | 159 f.write('<map name="%s">\n' % gl.file_name) |
159 for lr in gl.link_regions: | 160 for lr in gl.link_regions: |
160 locus = (lr.ref, lr.begin_pos + 1, lr.end_pos) | 161 locus_label = (lr.ref, lr.begin_pos + 1, lr.end_pos, lr.name) |
161 vals = {'x1': lr.x1, 'x2': lr.x2, 'y1': lr.y1, 'y2': lr.y2, | 162 vals = {'x1': lr.x1, 'x2': lr.x2, 'y1': lr.y1, 'y2': lr.y2, |
162 'title': '%s %d-%d' % locus, | 163 'title': '%s %d-%d (%s)' % locus_label, |
163 'href': self.buildHref(lr.ref, lr.begin_pos, lr.end_pos), | 164 'href': self.buildHref(lr.ref, lr.begin_pos, lr.end_pos), |
164 'onclick': ''} | 165 'onclick': ''} |
165 # Add onclick handler to prevent opening of new window. | 166 # Add onclick handler to prevent opening of new window. |
166 vals['target_attr'] = '' | 167 vals['target_attr'] = '' |
167 if self.args.link_target: | 168 if self.args.link_target: |