bio-graphics 1.0 → 1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. data/doc/classes/Bio/Graphics.html +11 -1
  2. data/doc/classes/Bio/Graphics/Panel.html +5 -2
  3. data/doc/classes/Bio/Graphics/Panel.src/M000005.html +4 -4
  4. data/doc/classes/Bio/Graphics/Panel.src/M000006.html +3 -3
  5. data/doc/classes/Bio/Graphics/Panel.src/M000007.html +6 -5
  6. data/doc/classes/Bio/Graphics/Panel/Ruler.html +16 -16
  7. data/doc/classes/Bio/Graphics/Panel/Ruler.src/M000014.html +6 -14
  8. data/doc/classes/Bio/Graphics/Panel/Ruler.src/M000015.html +10 -41
  9. data/doc/classes/Bio/Graphics/Panel/Ruler.src/M000016.html +59 -0
  10. data/doc/classes/Bio/Graphics/Panel/Ruler.src/M000017.html +20 -0
  11. data/doc/classes/Bio/Graphics/Panel/Ruler.src/M000018.html +28 -0
  12. data/doc/classes/Bio/Graphics/Panel/Ruler.src/M000019.html +59 -0
  13. data/doc/classes/Bio/Graphics/Panel/Track.html +30 -15
  14. data/doc/classes/Bio/Graphics/Panel/Track.src/M000008.html +8 -5
  15. data/doc/classes/Bio/Graphics/Panel/Track.src/M000009.html +2 -2
  16. data/doc/classes/Bio/Graphics/Panel/Track.src/M000010.html +12 -245
  17. data/doc/classes/Bio/Graphics/Panel/Track/Feature.html +109 -0
  18. data/doc/classes/Bio/Graphics/Panel/Track/Feature.src/M000011.html +1 -1
  19. data/doc/classes/Bio/Graphics/Panel/Track/Feature.src/M000012.html +39 -0
  20. data/doc/classes/Bio/Graphics/Panel/Track/Feature.src/M000013.html +27 -0
  21. data/doc/classes/Bio/Graphics/Panel/Track/Feature.src/M000014.html +209 -49
  22. data/doc/classes/Bio/Graphics/Panel/Track/Feature.src/M000015.html +48 -0
  23. data/doc/classes/Bio/Graphics/Panel/Track/Feature/PixelRange.html +5 -5
  24. data/doc/classes/Bio/Graphics/Panel/Track/Feature/PixelRange.src/M000013.html +18 -0
  25. data/doc/classes/Bio/Graphics/Panel/Track/Feature/PixelRange.src/M000016.html +18 -0
  26. data/doc/created.rid +1 -1
  27. data/doc/files/README_DEV.html +7 -11
  28. data/doc/files/TUTORIAL.html +3 -3
  29. data/doc/files/lib/bio-graphics_rb.html +3 -1
  30. data/doc/files/lib/bio/graphics/feature_rb.html +6 -11
  31. data/doc/files/lib/bio/graphics/image_map_rb.html +1 -1
  32. data/doc/files/lib/bio/graphics/panel_rb.html +1 -1
  33. data/doc/files/lib/bio/graphics/ruler_rb.html +1 -1
  34. data/doc/files/lib/bio/graphics/track_rb.html +1 -1
  35. data/doc/fr_method_index.html +8 -4
  36. data/doc/images/example_labels.png +0 -0
  37. data/doc/images/glyph_showcase.png +0 -0
  38. data/doc/images/terms.png +0 -0
  39. data/doc/index.html +2 -2
  40. data/images/example_labels.png +0 -0
  41. data/images/glyph_showcase.png +0 -0
  42. data/images/terms.png +0 -0
  43. data/images/terms.svg +146 -132
  44. data/lib/bio-graphics.rb +2 -1
  45. data/lib/bio/graphics/feature.rb +304 -0
  46. data/lib/bio/graphics/panel.rb +15 -11
  47. data/lib/bio/graphics/ruler.rb +1 -1
  48. data/lib/bio/graphics/track.rb +23 -254
  49. data/samples/arkdb_features.rb +8 -8
  50. data/samples/glyph_showcase.rb +10 -6
  51. data/test/unit/test_creation.rb +51 -0
  52. metadata +14 -2
@@ -127,17 +127,22 @@ documentation for explanation of interplay between different classes.
127
127
  <div class="name-list">
128
128
  <table>
129
129
  <tr class="top-aligned-row context-row">
130
- <td class="context-item-name">feature_colour</td>
130
+ <td class="context-item-name">colour</td>
131
131
  <td class="context-item-value">&nbsp;[RW]&nbsp;</td>
132
132
  <td class="context-item-desc"></td>
133
133
  </tr>
134
134
  <tr class="top-aligned-row context-row">
135
- <td class="context-item-name">feature_glyph</td>
135
+ <td class="context-item-name">features</td>
136
136
  <td class="context-item-value">&nbsp;[RW]&nbsp;</td>
137
137
  <td class="context-item-desc"></td>
138
138
  </tr>
139
139
  <tr class="top-aligned-row context-row">
140
- <td class="context-item-name">features</td>
140
+ <td class="context-item-name">glyph</td>
141
+ <td class="context-item-value">&nbsp;[RW]&nbsp;</td>
142
+ <td class="context-item-desc"></td>
143
+ </tr>
144
+ <tr class="top-aligned-row context-row">
145
+ <td class="context-item-name">grid</td>
141
146
  <td class="context-item-value">&nbsp;[RW]&nbsp;</td>
142
147
  <td class="context-item-desc"></td>
143
148
  </tr>
@@ -152,7 +157,7 @@ documentation for explanation of interplay between different classes.
152
157
  <td class="context-item-desc"></td>
153
158
  </tr>
154
159
  <tr class="top-aligned-row context-row">
155
- <td class="context-item-name">number_of_times_bumped</td>
160
+ <td class="context-item-name">number_of_feature_rows</td>
156
161
  <td class="context-item-value">&nbsp;[RW]&nbsp;</td>
157
162
  <td class="context-item-desc"></td>
158
163
  </tr>
@@ -161,6 +166,16 @@ documentation for explanation of interplay between different classes.
161
166
  <td class="context-item-value">&nbsp;[RW]&nbsp;</td>
162
167
  <td class="context-item-desc"></td>
163
168
  </tr>
169
+ <tr class="top-aligned-row context-row">
170
+ <td class="context-item-name">show_label</td>
171
+ <td class="context-item-value">&nbsp;[RW]&nbsp;</td>
172
+ <td class="context-item-desc"></td>
173
+ </tr>
174
+ <tr class="top-aligned-row context-row">
175
+ <td class="context-item-name">vertical_offset</td>
176
+ <td class="context-item-value">&nbsp;[RW]&nbsp;</td>
177
+ <td class="context-item-desc"></td>
178
+ </tr>
164
179
  </table>
165
180
  </div>
166
181
  </div>
@@ -177,7 +192,7 @@ documentation for explanation of interplay between different classes.
177
192
  <div class="method-heading">
178
193
  <a href="Track.src/M000008.html" target="Code" class="method-signature"
179
194
  onclick="popupCode('Track.src/M000008.html');return false;">
180
- <span class="method-name">new</span><span class="method-args">(panel, name, feature_colour = [0,0,1], feature_glyph = 'generic')</span>
195
+ <span class="method-name">new</span><span class="method-args">(panel, name, label = true, colour = [0,0,1], glyph = :generic)</span>
181
196
  </a>
182
197
  </div>
183
198
 
@@ -200,6 +215,10 @@ belongs to
200
215
  <li><em>name</em> (required) :: Name of the track to be displayed (e.g.
201
216
  &#8216;genes&#8217;)
202
217
 
218
+ </li>
219
+ <li><em>label</em> :: Boolean: should the label for each feature be drawn or
220
+ not
221
+
203
222
  </li>
204
223
  <li><em>colour</em> :: Colour to be used to <a
205
224
  href="Track.html#M000010">draw</a> the features within the track. Default =
@@ -207,11 +226,11 @@ href="Track.html#M000010">draw</a> the features within the track. Default =
207
226
 
208
227
  </li>
209
228
  <li><em>glyph</em> :: Glyph to use for drawing the features. Options are:
210
- &#8216;generic&#8217;, &#8216;directed_generic&#8217;, &#8216;spliced,
211
- &#8216;directed_spliced&#8217; and &#8216;triangle&#8217;. Triangles can be
212
- used for features whose start and stop positions are the same (e.g. SNPs).
213
- If you try to <a href="Track.html#M000010">draw</a> a feature that is
214
- longer with triangles, an error will be shown.
229
+ :generic, :directed_generic, :spliced, :directed_spliced, :line and
230
+ :triangle. Triangles can be used for features whose start and stop
231
+ positions are the same (e.g. SNPs). If you try to <a
232
+ href="Track.html#M000010">draw</a> a feature that is longer with triangles,
233
+ an error will be shown.
215
234
 
216
235
  </li>
217
236
  </ul>
@@ -297,7 +316,7 @@ added. If it should be only partly visible, it is added completely.
297
316
  <div class="method-heading">
298
317
  <a href="Track.src/M000010.html" target="Code" class="method-signature"
299
318
  onclick="popupCode('Track.src/M000010.html');return false;">
300
- <span class="method-name">draw</span><span class="method-args">(panel_drawing, vertical_offset)</span>
319
+ <span class="method-name">draw</span><span class="method-args">(panel_drawing)</span>
301
320
  </a>
302
321
  </div>
303
322
 
@@ -313,10 +332,6 @@ href="../Panel.html#M000007">Bio::Graphics::Panel.draw</a>
313
332
  <ul>
314
333
  <li><em>paneldrawing</em> (required) :: the panel cairo object
315
334
 
316
- </li>
317
- <li><em>verticaloffset</em> (required) :: number of pixels to offset the track
318
- downwards, based on the height of other tracks that were drawn above it
319
-
320
335
  </li>
321
336
  </ul>
322
337
  <table>
@@ -10,14 +10,17 @@
10
10
  <link rel="stylesheet" href="../../../../.././rdoc-style.css" type="text/css" media="screen" />
11
11
  </head>
12
12
  <body class="standalone-code">
13
- <pre><span class="ruby-comment cmt"># File lib/bio/graphics/track.rb, line 38</span>
14
- <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">panel</span>, <span class="ruby-identifier">name</span>, <span class="ruby-identifier">feature_colour</span> = [<span class="ruby-value">0</span>,<span class="ruby-value">0</span>,<span class="ruby-value">1</span>], <span class="ruby-identifier">feature_glyph</span> = <span class="ruby-value str">'generic'</span>)
13
+ <pre><span class="ruby-comment cmt"># File lib/bio/graphics/track.rb, line 39</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">panel</span>, <span class="ruby-identifier">name</span>, <span class="ruby-identifier">label</span> = <span class="ruby-keyword kw">true</span>, <span class="ruby-identifier">colour</span> = [<span class="ruby-value">0</span>,<span class="ruby-value">0</span>,<span class="ruby-value">1</span>], <span class="ruby-identifier">glyph</span> = <span class="ruby-identifier">:generic</span>)
15
15
  <span class="ruby-ivar">@panel</span> = <span class="ruby-identifier">panel</span>
16
16
  <span class="ruby-ivar">@name</span> = <span class="ruby-identifier">name</span>
17
- <span class="ruby-ivar">@feature_colour</span> = <span class="ruby-identifier">feature_colour</span>
18
- <span class="ruby-ivar">@feature_glyph</span> = <span class="ruby-identifier">feature_glyph</span>
17
+ <span class="ruby-ivar">@show_label</span> = <span class="ruby-identifier">label</span>
18
+ <span class="ruby-ivar">@colour</span> = <span class="ruby-identifier">colour</span>
19
+ <span class="ruby-ivar">@glyph</span> = <span class="ruby-identifier">glyph</span>
19
20
  <span class="ruby-ivar">@features</span> = <span class="ruby-constant">Array</span>.<span class="ruby-identifier">new</span>
20
- <span class="ruby-ivar">@number_of_times_bumped</span> = <span class="ruby-value">0</span>
21
+ <span class="ruby-ivar">@number_of_feature_rows</span> = <span class="ruby-value">0</span>
22
+ <span class="ruby-ivar">@vertical_offset</span> = <span class="ruby-value">0</span>
23
+ <span class="ruby-ivar">@grid</span> = <span class="ruby-constant">Hash</span>.<span class="ruby-identifier">new</span>
21
24
  <span class="ruby-keyword kw">end</span></pre>
22
25
  </body>
23
26
  </html>
@@ -10,7 +10,7 @@
10
10
  <link rel="stylesheet" href="../../../../.././rdoc-style.css" type="text/css" media="screen" />
11
11
  </head>
12
12
  <body class="standalone-code">
13
- <pre><span class="ruby-comment cmt"># File lib/bio/graphics/track.rb, line 76</span>
13
+ <pre><span class="ruby-comment cmt"># File lib/bio/graphics/track.rb, line 80</span>
14
14
  <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">add_feature</span>(<span class="ruby-identifier">name</span>, <span class="ruby-identifier">location_string</span> = <span class="ruby-value str">'1..'</span> <span class="ruby-operator">+</span> <span class="ruby-ivar">@panel</span>.<span class="ruby-identifier">length</span>.<span class="ruby-identifier">to_s</span>, <span class="ruby-identifier">link</span> = <span class="ruby-keyword kw">nil</span>)
15
15
  <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">link</span> <span class="ruby-operator">==</span> <span class="ruby-value str">''</span>
16
16
  <span class="ruby-identifier">link</span> = <span class="ruby-keyword kw">nil</span>
@@ -29,7 +29,7 @@
29
29
  <span class="ruby-comment cmt"># looking at, don't bother storing the stuff. I think this makes huge
30
30
  <span class="ruby-comment cmt"># speed and memory differences if you've got a chromosome with
31
31
  <span class="ruby-comment cmt"># thousands of features.
32
- <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">stop</span> <span class="ruby-operator">&lt;=</span> <span class="ruby-identifier">panel</span>.<span class="ruby-identifier">display_start</span> <span class="ruby-keyword kw">or</span> <span class="ruby-identifier">start</span> <span class="ruby-operator">&gt;=</span> <span class="ruby-identifier">panel</span>.<span class="ruby-identifier">display_stop</span>
32
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">stop</span> <span class="ruby-operator">&lt;=</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">panel</span>.<span class="ruby-identifier">display_start</span> <span class="ruby-keyword kw">or</span> <span class="ruby-identifier">start</span> <span class="ruby-operator">&gt;=</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">panel</span>.<span class="ruby-identifier">display_stop</span>
33
33
  <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">nil</span>
34
34
  <span class="ruby-keyword kw">else</span> <span class="ruby-comment cmt">#elsif start &gt;= panel.display_start and stop &lt;= panel.display_stop
35
35
  <span class="ruby-ivar">@features</span>.<span class="ruby-identifier">push</span>(<span class="ruby-constant">Bio</span><span class="ruby-operator">::</span><span class="ruby-constant">Graphics</span><span class="ruby-operator">::</span><span class="ruby-constant">Panel</span><span class="ruby-operator">::</span><span class="ruby-constant">Track</span><span class="ruby-operator">::</span><span class="ruby-constant">Feature</span>.<span class="ruby-identifier">new</span>(<span class="ruby-keyword kw">self</span>, <span class="ruby-identifier">name</span>, <span class="ruby-identifier">location_object</span>, <span class="ruby-identifier">link</span>))
@@ -10,274 +10,41 @@
10
10
  <link rel="stylesheet" href="../../../../.././rdoc-style.css" type="text/css" media="screen" />
11
11
  </head>
12
12
  <body class="standalone-code">
13
- <pre><span class="ruby-comment cmt"># File lib/bio/graphics/track.rb, line 113</span>
14
- <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">draw</span>(<span class="ruby-identifier">panel_drawing</span>, <span class="ruby-identifier">vertical_offset</span>)
13
+ <pre><span class="ruby-comment cmt"># File lib/bio/graphics/track.rb, line 115</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">draw</span>(<span class="ruby-identifier">panel_drawing</span>)
15
15
  <span class="ruby-identifier">track_drawing</span> = <span class="ruby-constant">Cairo</span><span class="ruby-operator">::</span><span class="ruby-constant">Context</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">panel_drawing</span>)
16
16
 
17
17
  <span class="ruby-comment cmt"># Draw thin line above title
18
18
  <span class="ruby-identifier">track_drawing</span>.<span class="ruby-identifier">set_source_rgb</span>(<span class="ruby-value">0</span><span class="ruby-value">.75</span>,<span class="ruby-value">0</span><span class="ruby-value">.75</span>,<span class="ruby-value">0</span><span class="ruby-value">.75</span>)
19
- <span class="ruby-identifier">track_drawing</span>.<span class="ruby-identifier">move_to</span>(<span class="ruby-value">0</span>, <span class="ruby-identifier">vertical_offset</span>)
20
- <span class="ruby-identifier">track_drawing</span>.<span class="ruby-identifier">line_to</span>(<span class="ruby-identifier">panel</span>.<span class="ruby-identifier">width</span>, <span class="ruby-identifier">vertical_offset</span>)
19
+ <span class="ruby-identifier">track_drawing</span>.<span class="ruby-identifier">move_to</span>(<span class="ruby-value">0</span>, <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">vertical_offset</span>)
20
+ <span class="ruby-identifier">track_drawing</span>.<span class="ruby-identifier">line_to</span>(<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">panel</span>.<span class="ruby-identifier">width</span>, <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">vertical_offset</span>)
21
21
  <span class="ruby-identifier">track_drawing</span>.<span class="ruby-identifier">stroke</span>
22
22
 
23
23
  <span class="ruby-comment cmt"># Draw track title
24
24
  <span class="ruby-identifier">track_drawing</span>.<span class="ruby-identifier">set_source_rgb</span>(<span class="ruby-value">0</span>,<span class="ruby-value">0</span>,<span class="ruby-value">0</span>)
25
- <span class="ruby-identifier">track_drawing</span>.<span class="ruby-identifier">select_font_face</span>(<span class="ruby-value str">'Georgia'</span>,<span class="ruby-value">1</span>,<span class="ruby-value">1</span>)
25
+ <span class="ruby-comment cmt"># track_drawing.select_font_face('Georgia',1,1)
26
+ <span class="ruby-identifier">track_drawing</span>.<span class="ruby-identifier">select_font_face</span>(<span class="ruby-operator">*</span>(<span class="ruby-constant">FONT</span>))
26
27
  <span class="ruby-identifier">track_drawing</span>.<span class="ruby-identifier">set_font_size</span>(<span class="ruby-constant">TRACK_HEADER_HEIGHT</span>)
27
- <span class="ruby-identifier">track_drawing</span>.<span class="ruby-identifier">move_to</span>(<span class="ruby-value">0</span>,<span class="ruby-constant">TRACK_HEADER_HEIGHT</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">vertical_offset</span> <span class="ruby-operator">+</span> <span class="ruby-value">10</span>)
28
+ <span class="ruby-identifier">track_drawing</span>.<span class="ruby-identifier">move_to</span>(<span class="ruby-value">0</span>,<span class="ruby-constant">TRACK_HEADER_HEIGHT</span> <span class="ruby-operator">+</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">vertical_offset</span> <span class="ruby-operator">+</span> <span class="ruby-value">10</span>)
28
29
  <span class="ruby-identifier">track_drawing</span>.<span class="ruby-identifier">show_text</span>(<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">name</span>)
29
30
 
30
31
  <span class="ruby-comment cmt"># Draw the features
31
- <span class="ruby-identifier">grid</span> = <span class="ruby-constant">Hash</span>.<span class="ruby-identifier">new</span>
32
-
33
32
  <span class="ruby-identifier">track_drawing</span>.<span class="ruby-identifier">save</span> <span class="ruby-keyword kw">do</span>
34
- <span class="ruby-identifier">track_drawing</span>.<span class="ruby-identifier">translate</span>(<span class="ruby-value">0</span>, <span class="ruby-identifier">vertical_offset</span> <span class="ruby-operator">+</span> <span class="ruby-constant">TRACK_HEADER_HEIGHT</span>)
35
- <span class="ruby-identifier">track_drawing</span>.<span class="ruby-identifier">set_source_rgb</span>(<span class="ruby-ivar">@feature_colour</span>)
33
+ <span class="ruby-identifier">track_drawing</span>.<span class="ruby-identifier">translate</span>(<span class="ruby-value">0</span>, <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">vertical_offset</span> <span class="ruby-operator">+</span> <span class="ruby-constant">TRACK_HEADER_HEIGHT</span>)
34
+ <span class="ruby-identifier">track_drawing</span>.<span class="ruby-identifier">set_source_rgb</span>(<span class="ruby-ivar">@colour</span>)
36
35
 
37
- <span class="ruby-comment cmt"># Now draw the features
38
- <span class="ruby-comment cmt"># These are the basic steps:
39
- <span class="ruby-comment cmt"># A. find out what row to draw it on
40
- <span class="ruby-comment cmt"># B. see if we want to change the glyph type from directed to
41
- <span class="ruby-comment cmt"># undirected
42
- <span class="ruby-comment cmt"># C. draw the thing
43
- <span class="ruby-ivar">@features</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">feature</span><span class="ruby-operator">|</span>
36
+ <span class="ruby-ivar">@features</span>.<span class="ruby-identifier">sort_by</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">f</span><span class="ruby-operator">|</span> <span class="ruby-identifier">f</span>.<span class="ruby-identifier">start</span>}.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">feature</span><span class="ruby-operator">|</span>
44
37
  <span class="ruby-comment cmt"># Don't even bother if the feature is not in the view
45
38
  <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">feature</span>.<span class="ruby-identifier">stop</span> <span class="ruby-operator">&lt;=</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">panel</span>.<span class="ruby-identifier">display_start</span> <span class="ruby-keyword kw">or</span> <span class="ruby-identifier">feature</span>.<span class="ruby-identifier">start</span> <span class="ruby-operator">&gt;=</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">panel</span>.<span class="ruby-identifier">display_stop</span>
46
39
  <span class="ruby-keyword kw">next</span>
47
40
  <span class="ruby-keyword kw">else</span>
48
- <span class="ruby-identifier">feature_drawn</span> = <span class="ruby-keyword kw">false</span>
49
-
50
- <span class="ruby-comment cmt"># A. find out what row to draw it on
51
- <span class="ruby-identifier">feature_range</span> = (<span class="ruby-identifier">feature</span>.<span class="ruby-identifier">start</span>.<span class="ruby-identifier">floor</span><span class="ruby-operator">..</span><span class="ruby-identifier">feature</span>.<span class="ruby-identifier">stop</span>.<span class="ruby-identifier">ceil</span>)
52
- <span class="ruby-identifier">row</span> = <span class="ruby-value">1</span>
53
- <span class="ruby-identifier">row_available</span> = <span class="ruby-keyword kw">true</span>
54
- <span class="ruby-keyword kw">until</span> <span class="ruby-identifier">feature_drawn</span>
55
- <span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span> <span class="ruby-identifier">grid</span>[<span class="ruby-identifier">row</span>].<span class="ruby-identifier">nil?</span>
56
- <span class="ruby-identifier">grid</span>[<span class="ruby-identifier">row</span>].<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">covered</span><span class="ruby-operator">|</span>
57
- <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">feature_range</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">covered</span>.<span class="ruby-identifier">first</span>) <span class="ruby-keyword kw">or</span> <span class="ruby-identifier">covered</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">feature_range</span>.<span class="ruby-identifier">first</span>)
58
- <span class="ruby-identifier">row_available</span> = <span class="ruby-keyword kw">false</span>
59
- <span class="ruby-keyword kw">end</span>
60
- <span class="ruby-keyword kw">end</span>
61
- <span class="ruby-keyword kw">end</span>
62
-
63
- <span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span> <span class="ruby-identifier">row_available</span>
64
- <span class="ruby-identifier">row</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span>
65
- <span class="ruby-identifier">row_available</span> = <span class="ruby-keyword kw">true</span>
66
- <span class="ruby-keyword kw">else</span>
67
- <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">grid</span>[<span class="ruby-identifier">row</span>].<span class="ruby-identifier">nil?</span>
68
- <span class="ruby-identifier">grid</span>[<span class="ruby-identifier">row</span>] = <span class="ruby-constant">Array</span>.<span class="ruby-identifier">new</span>
69
- <span class="ruby-keyword kw">end</span>
70
- <span class="ruby-identifier">grid</span>[<span class="ruby-identifier">row</span>].<span class="ruby-identifier">push</span>(<span class="ruby-identifier">feature_range</span>)
71
-
72
- <span class="ruby-comment cmt"># B. see if we want to change the glyph type from directed to
73
- <span class="ruby-comment cmt"># undirected
74
- <span class="ruby-comment cmt"># There are 2 cases where we don't want to draw arrows on
75
- <span class="ruby-comment cmt"># features:
76
- <span class="ruby-comment cmt"># (a) when the picture is really zoomed out, features are
77
- <span class="ruby-comment cmt"># so small that the arrow itself is too big
78
- <span class="ruby-comment cmt"># (b) if a directed feature on the fw strand extends beyond
79
- <span class="ruby-comment cmt"># the end of the picture, the arrow is out of view. This
80
- <span class="ruby-comment cmt"># is the same as considering the feature as undirected.
81
- <span class="ruby-comment cmt"># The same obviously goes for features on the reverse
82
- <span class="ruby-comment cmt"># strand that extend beyond the left side of the image.
83
- <span class="ruby-comment cmt">#
84
- <span class="ruby-comment cmt"># (a) Zoomed out
85
- <span class="ruby-identifier">replace_directed_with_undirected</span> = <span class="ruby-keyword kw">false</span>
86
- <span class="ruby-keyword kw">if</span> (<span class="ruby-identifier">feature</span>.<span class="ruby-identifier">stop</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">feature</span>.<span class="ruby-identifier">start</span>).<span class="ruby-identifier">to_f</span><span class="ruby-operator">/</span><span class="ruby-identifier">panel</span>.<span class="ruby-identifier">rescale_factor</span>.<span class="ruby-identifier">to_f</span> <span class="ruby-operator">&lt;</span> <span class="ruby-value">2</span>
87
- <span class="ruby-identifier">replace_directed_with_undirected</span> = <span class="ruby-keyword kw">true</span>
88
- <span class="ruby-keyword kw">end</span>
89
- <span class="ruby-comment cmt"># (b) Extending beyond borders picture
90
- <span class="ruby-keyword kw">if</span> ( <span class="ruby-identifier">feature</span>.<span class="ruby-identifier">chopped_at_stop</span> <span class="ruby-keyword kw">and</span> <span class="ruby-identifier">feature</span>.<span class="ruby-identifier">strand</span> = <span class="ruby-value">1</span> ) <span class="ruby-keyword kw">or</span> ( <span class="ruby-identifier">feature</span>.<span class="ruby-identifier">chopped_at_start</span> <span class="ruby-keyword kw">and</span> <span class="ruby-identifier">feature</span>.<span class="ruby-identifier">strand</span> = <span class="ruby-value">-1</span> )
91
- <span class="ruby-identifier">replace_directed_with_undirected</span> = <span class="ruby-keyword kw">true</span>
92
- <span class="ruby-keyword kw">end</span>
93
-
94
- <span class="ruby-identifier">local_feature_glyph</span> = <span class="ruby-keyword kw">nil</span>
95
- <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">feature_glyph</span> <span class="ruby-operator">==</span> <span class="ruby-value str">'directed_generic'</span> <span class="ruby-keyword kw">and</span> <span class="ruby-identifier">replace_directed_with_undirected</span>
96
- <span class="ruby-identifier">local_feature_glyph</span> = <span class="ruby-value str">'generic'</span>
97
- <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">feature_glyph</span> <span class="ruby-operator">==</span> <span class="ruby-value str">'directed_spliced'</span> <span class="ruby-keyword kw">and</span> <span class="ruby-identifier">replace_directed_with_undirected</span>
98
- <span class="ruby-identifier">local_feature_glyph</span> = <span class="ruby-value str">'spliced'</span>
99
- <span class="ruby-keyword kw">else</span>
100
- <span class="ruby-identifier">local_feature_glyph</span> = <span class="ruby-identifier">feature_glyph</span>
101
- <span class="ruby-keyword kw">end</span>
102
-
103
- <span class="ruby-comment cmt"># C. And draw the thing.
104
- <span class="ruby-identifier">top_pixel_of_feature</span> = <span class="ruby-constant">FEATURE_V_DISTANCE</span> <span class="ruby-operator">+</span> (<span class="ruby-constant">FEATURE_HEIGHT</span><span class="ruby-operator">+</span><span class="ruby-constant">FEATURE_V_DISTANCE</span>)<span class="ruby-operator">*</span><span class="ruby-identifier">row</span>
105
- <span class="ruby-identifier">bottom_pixel_of_feature</span> = <span class="ruby-identifier">top_pixel_of_feature</span> <span class="ruby-operator">+</span> <span class="ruby-constant">FEATURE_HEIGHT</span>
106
-
107
- <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">local_feature_glyph</span>
108
- <span class="ruby-comment cmt"># triangles are typical for features which have a 1 bp position (start == stop)
109
- <span class="ruby-keyword kw">when</span> <span class="ruby-value str">'triangle'</span>
110
- <span class="ruby-identifier">raise</span> <span class="ruby-value str">&quot;Start and stop are not the same (necessary if you want triangle glyphs)&quot;</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">feature</span>.<span class="ruby-identifier">start</span> <span class="ruby-operator">!=</span> <span class="ruby-identifier">feature</span>.<span class="ruby-identifier">stop</span>
111
-
112
- <span class="ruby-comment cmt"># Need to get this for the imagemap
113
- <span class="ruby-identifier">left_pixel_of_feature</span> = <span class="ruby-identifier">feature</span>.<span class="ruby-identifier">pixel_range_collection</span>[<span class="ruby-value">0</span>].<span class="ruby-identifier">start_pixel</span> <span class="ruby-operator">-</span> <span class="ruby-value">3</span>
114
- <span class="ruby-identifier">right_pixel_of_feature</span> = <span class="ruby-identifier">feature</span>.<span class="ruby-identifier">pixel_range_collection</span>[<span class="ruby-value">0</span>].<span class="ruby-identifier">stop_pixel</span> <span class="ruby-operator">+</span> <span class="ruby-value">3</span>
115
- <span class="ruby-identifier">track_drawing</span>.<span class="ruby-identifier">move_to</span>(<span class="ruby-identifier">left_pixel_of_feature</span> <span class="ruby-operator">+</span> <span class="ruby-value">3</span>, <span class="ruby-identifier">top_pixel_of_feature</span>)
116
- <span class="ruby-identifier">track_drawing</span>.<span class="ruby-identifier">rel_line_to</span>(<span class="ruby-value">-3</span>, <span class="ruby-constant">FEATURE_HEIGHT</span>)
117
- <span class="ruby-identifier">track_drawing</span>.<span class="ruby-identifier">rel_line_to</span>(<span class="ruby-value">6</span>, <span class="ruby-value">0</span>)
118
- <span class="ruby-identifier">track_drawing</span>.<span class="ruby-identifier">close_path</span>.<span class="ruby-identifier">fill</span>
119
-
120
- <span class="ruby-keyword kw">when</span> <span class="ruby-value str">'directed_generic'</span>
121
- <span class="ruby-comment cmt"># Need to get this for the imagemap
122
- <span class="ruby-identifier">left_pixel_of_feature</span> = <span class="ruby-identifier">feature</span>.<span class="ruby-identifier">pixel_range_collection</span>.<span class="ruby-identifier">sort_by</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">pr</span><span class="ruby-operator">|</span> <span class="ruby-identifier">pr</span>.<span class="ruby-identifier">start_pixel</span>}[<span class="ruby-value">0</span>].<span class="ruby-identifier">start_pixel</span>
123
- <span class="ruby-identifier">right_pixel_of_feature</span> = <span class="ruby-identifier">feature</span>.<span class="ruby-identifier">pixel_range_collection</span>.<span class="ruby-identifier">sort_by</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">pr</span><span class="ruby-operator">|</span> <span class="ruby-identifier">pr</span>.<span class="ruby-identifier">start_pixel</span>}[<span class="ruby-value">-1</span>].<span class="ruby-identifier">stop_pixel</span>
124
- <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">feature</span>.<span class="ruby-identifier">strand</span> <span class="ruby-operator">==</span> <span class="ruby-value">-1</span> <span class="ruby-comment cmt"># Reverse strand
125
- <span class="ruby-comment cmt"># Draw main box
126
- <span class="ruby-identifier">track_drawing</span>.<span class="ruby-identifier">rectangle</span>(<span class="ruby-identifier">left_pixel_of_feature</span><span class="ruby-operator">+</span><span class="ruby-constant">FEATURE_ARROW_LENGTH</span>, <span class="ruby-identifier">top_pixel_of_feature</span>, <span class="ruby-identifier">right_pixel_of_feature</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">left_pixel_of_feature</span> <span class="ruby-operator">-</span> <span class="ruby-constant">FEATURE_ARROW_LENGTH</span>, <span class="ruby-constant">FEATURE_HEIGHT</span>).<span class="ruby-identifier">fill</span>
127
-
128
- <span class="ruby-comment cmt"># Draw arrow
129
- <span class="ruby-identifier">track_drawing</span>.<span class="ruby-identifier">move_to</span>(<span class="ruby-identifier">left_pixel_of_feature</span><span class="ruby-operator">+</span><span class="ruby-constant">FEATURE_ARROW_LENGTH</span>, <span class="ruby-identifier">top_pixel_of_feature</span>)
130
- <span class="ruby-identifier">track_drawing</span>.<span class="ruby-identifier">rel_line_to</span>(<span class="ruby-operator">-</span><span class="ruby-constant">FEATURE_ARROW_LENGTH</span>, <span class="ruby-constant">FEATURE_HEIGHT</span><span class="ruby-operator">/</span><span class="ruby-value">2</span>)
131
- <span class="ruby-identifier">track_drawing</span>.<span class="ruby-identifier">rel_line_to</span>(<span class="ruby-constant">FEATURE_ARROW_LENGTH</span>, <span class="ruby-constant">FEATURE_HEIGHT</span><span class="ruby-operator">/</span><span class="ruby-value">2</span>)
132
- <span class="ruby-identifier">track_drawing</span>.<span class="ruby-identifier">close_path</span>.<span class="ruby-identifier">fill</span>
133
-
134
- <span class="ruby-keyword kw">else</span> <span class="ruby-comment cmt">#default is forward strand
135
- <span class="ruby-identifier">track_drawing</span>.<span class="ruby-identifier">rectangle</span>(<span class="ruby-identifier">left_pixel_of_feature</span>, <span class="ruby-identifier">top_pixel_of_feature</span>, <span class="ruby-identifier">right_pixel_of_feature</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">left_pixel_of_feature</span> <span class="ruby-operator">-</span> <span class="ruby-constant">FEATURE_ARROW_LENGTH</span>, <span class="ruby-constant">FEATURE_HEIGHT</span>).<span class="ruby-identifier">fill</span>
136
- <span class="ruby-identifier">track_drawing</span>.<span class="ruby-identifier">move_to</span>(<span class="ruby-identifier">right_pixel_of_feature</span> <span class="ruby-operator">-</span> <span class="ruby-constant">FEATURE_ARROW_LENGTH</span>, <span class="ruby-identifier">top_pixel_of_feature</span>)
137
- <span class="ruby-identifier">track_drawing</span>.<span class="ruby-identifier">rel_line_to</span>(<span class="ruby-constant">FEATURE_ARROW_LENGTH</span>, <span class="ruby-constant">FEATURE_HEIGHT</span><span class="ruby-operator">/</span><span class="ruby-value">2</span>)
138
- <span class="ruby-identifier">track_drawing</span>.<span class="ruby-identifier">rel_line_to</span>(<span class="ruby-operator">-</span><span class="ruby-constant">FEATURE_ARROW_LENGTH</span>, <span class="ruby-constant">FEATURE_HEIGHT</span><span class="ruby-operator">/</span><span class="ruby-value">2</span>)
139
- <span class="ruby-identifier">track_drawing</span>.<span class="ruby-identifier">close_path</span>.<span class="ruby-identifier">fill</span>
140
- <span class="ruby-keyword kw">end</span>
141
- <span class="ruby-keyword kw">when</span> <span class="ruby-value str">'spliced'</span>
142
- <span class="ruby-identifier">gap_starts</span> = <span class="ruby-constant">Array</span>.<span class="ruby-identifier">new</span>
143
- <span class="ruby-identifier">gap_stops</span> = <span class="ruby-constant">Array</span>.<span class="ruby-identifier">new</span>
144
-
145
- <span class="ruby-comment cmt"># Need to get this for the imagemap
146
- <span class="ruby-identifier">left_pixel_of_feature</span> = <span class="ruby-identifier">feature</span>.<span class="ruby-identifier">pixel_range_collection</span>.<span class="ruby-identifier">sort_by</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">pr</span><span class="ruby-operator">|</span> <span class="ruby-identifier">pr</span>.<span class="ruby-identifier">start_pixel</span>}[<span class="ruby-value">0</span>].<span class="ruby-identifier">start_pixel</span>
147
- <span class="ruby-identifier">right_pixel_of_feature</span> = <span class="ruby-identifier">feature</span>.<span class="ruby-identifier">pixel_range_collection</span>.<span class="ruby-identifier">sort_by</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">pr</span><span class="ruby-operator">|</span> <span class="ruby-identifier">pr</span>.<span class="ruby-identifier">start_pixel</span>}[<span class="ruby-value">-1</span>].<span class="ruby-identifier">stop_pixel</span>
148
-
149
- <span class="ruby-comment cmt"># First draw the parts
150
- <span class="ruby-identifier">feature</span>.<span class="ruby-identifier">pixel_range_collection</span>.<span class="ruby-identifier">sort_by</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">pr</span><span class="ruby-operator">|</span> <span class="ruby-identifier">pr</span>.<span class="ruby-identifier">start_pixel</span>}.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">pr</span><span class="ruby-operator">|</span>
151
- <span class="ruby-identifier">track_drawing</span>.<span class="ruby-identifier">rectangle</span>(<span class="ruby-identifier">pr</span>.<span class="ruby-identifier">start_pixel</span>, <span class="ruby-identifier">top_pixel_of_feature</span>, (<span class="ruby-identifier">pr</span>.<span class="ruby-identifier">stop_pixel</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">pr</span>.<span class="ruby-identifier">start_pixel</span>), <span class="ruby-constant">FEATURE_HEIGHT</span>).<span class="ruby-identifier">fill</span>
152
- <span class="ruby-identifier">gap_starts</span>.<span class="ruby-identifier">push</span>(<span class="ruby-identifier">pr</span>.<span class="ruby-identifier">stop_pixel</span>)
153
- <span class="ruby-identifier">gap_stops</span>.<span class="ruby-identifier">push</span>(<span class="ruby-identifier">pr</span>.<span class="ruby-identifier">start_pixel</span>)
154
- <span class="ruby-keyword kw">end</span>
155
-
156
- <span class="ruby-comment cmt"># And then draw the connections in the gaps
157
- <span class="ruby-comment cmt"># Start with removing the very first start and the very last stop.
158
- <span class="ruby-identifier">gap_starts</span>.<span class="ruby-identifier">sort!</span>.<span class="ruby-identifier">pop</span>
159
- <span class="ruby-identifier">gap_stops</span>.<span class="ruby-identifier">sort!</span>.<span class="ruby-identifier">shift</span>
160
-
161
- <span class="ruby-identifier">gap_starts</span>.<span class="ruby-identifier">length</span>.<span class="ruby-identifier">times</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">gap_number</span><span class="ruby-operator">|</span>
162
- <span class="ruby-identifier">from</span> = <span class="ruby-identifier">gap_starts</span>[<span class="ruby-identifier">gap_number</span>].<span class="ruby-identifier">to_f</span>
163
- <span class="ruby-identifier">to</span> = <span class="ruby-identifier">gap_stops</span>[<span class="ruby-identifier">gap_number</span>].<span class="ruby-identifier">to_f</span>
164
- <span class="ruby-identifier">middle</span> = <span class="ruby-identifier">from</span> <span class="ruby-operator">+</span> ((<span class="ruby-identifier">to</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">from</span>)<span class="ruby-operator">/</span><span class="ruby-value">2</span>)
165
- <span class="ruby-identifier">track_drawing</span>.<span class="ruby-identifier">move_to</span>(<span class="ruby-identifier">from</span>, <span class="ruby-identifier">top_pixel_of_feature</span><span class="ruby-operator">+</span><span class="ruby-value">2</span>)
166
- <span class="ruby-identifier">track_drawing</span>.<span class="ruby-identifier">line_to</span>(<span class="ruby-identifier">middle</span>, <span class="ruby-identifier">top_pixel_of_feature</span><span class="ruby-operator">+</span><span class="ruby-value">7</span>)
167
- <span class="ruby-identifier">track_drawing</span>.<span class="ruby-identifier">line_to</span>(<span class="ruby-identifier">to</span>, <span class="ruby-identifier">top_pixel_of_feature</span><span class="ruby-operator">+</span><span class="ruby-value">2</span>)
168
- <span class="ruby-identifier">track_drawing</span>.<span class="ruby-identifier">stroke</span>
169
- <span class="ruby-keyword kw">end</span>
170
-
171
- <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">feature</span>.<span class="ruby-identifier">hidden_subfeatures_at_stop</span>
172
- <span class="ruby-identifier">from</span> = <span class="ruby-identifier">feature</span>.<span class="ruby-identifier">pixel_range_collection</span>.<span class="ruby-identifier">sort_by</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">pr</span><span class="ruby-operator">|</span> <span class="ruby-identifier">pr</span>.<span class="ruby-identifier">start_pixel</span>}[<span class="ruby-value">-1</span>].<span class="ruby-identifier">stop_pixel</span>
173
- <span class="ruby-identifier">to</span> = <span class="ruby-identifier">panel</span>.<span class="ruby-identifier">width</span>
174
- <span class="ruby-identifier">track_drawing</span>.<span class="ruby-identifier">move_to</span>(<span class="ruby-identifier">from</span>, <span class="ruby-identifier">top_pixel_of_feature</span><span class="ruby-operator">+</span><span class="ruby-value">5</span>)
175
- <span class="ruby-identifier">track_drawing</span>.<span class="ruby-identifier">line_to</span>(<span class="ruby-identifier">to</span>, <span class="ruby-identifier">top_pixel_of_feature</span><span class="ruby-operator">+</span><span class="ruby-value">5</span>)
176
- <span class="ruby-identifier">track_drawing</span>.<span class="ruby-identifier">stroke</span>
177
- <span class="ruby-keyword kw">end</span>
178
-
179
- <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">feature</span>.<span class="ruby-identifier">hidden_subfeatures_at_start</span>
180
- <span class="ruby-identifier">from</span> = <span class="ruby-value">1</span>
181
- <span class="ruby-identifier">to</span> = <span class="ruby-identifier">feature</span>.<span class="ruby-identifier">pixel_range_collection</span>.<span class="ruby-identifier">sort_by</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">pr</span><span class="ruby-operator">|</span> <span class="ruby-identifier">pr</span>.<span class="ruby-identifier">start_pixel</span>}[<span class="ruby-value">0</span>].<span class="ruby-identifier">start_pixel</span>
182
- <span class="ruby-identifier">track_drawing</span>.<span class="ruby-identifier">move_to</span>(<span class="ruby-identifier">from</span>, <span class="ruby-identifier">top_pixel_of_feature</span><span class="ruby-operator">+</span><span class="ruby-value">5</span>)
183
- <span class="ruby-identifier">track_drawing</span>.<span class="ruby-identifier">line_to</span>(<span class="ruby-identifier">to</span>, <span class="ruby-identifier">top_pixel_of_feature</span><span class="ruby-operator">+</span><span class="ruby-value">5</span>)
184
- <span class="ruby-identifier">track_drawing</span>.<span class="ruby-identifier">stroke</span>
185
- <span class="ruby-keyword kw">end</span>
186
-
187
- <span class="ruby-keyword kw">when</span> <span class="ruby-value str">'directed_spliced'</span>
188
- <span class="ruby-identifier">gap_starts</span> = <span class="ruby-constant">Array</span>.<span class="ruby-identifier">new</span>
189
- <span class="ruby-identifier">gap_stops</span> = <span class="ruby-constant">Array</span>.<span class="ruby-identifier">new</span>
190
- <span class="ruby-comment cmt"># First draw the parts
191
- <span class="ruby-identifier">locations</span> = <span class="ruby-identifier">feature</span>.<span class="ruby-identifier">location</span>.<span class="ruby-identifier">sort_by</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">l</span><span class="ruby-operator">|</span> <span class="ruby-identifier">l</span>.<span class="ruby-identifier">from</span>}
192
-
193
- <span class="ruby-comment cmt"># Need to get this for the imagemap
194
- <span class="ruby-identifier">left_pixel_of_feature</span> = <span class="ruby-identifier">feature</span>.<span class="ruby-identifier">pixel_range_collection</span>.<span class="ruby-identifier">sort_by</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">pr</span><span class="ruby-operator">|</span> <span class="ruby-identifier">pr</span>.<span class="ruby-identifier">start_pixel</span>}[<span class="ruby-value">0</span>].<span class="ruby-identifier">start_pixel</span>
195
- <span class="ruby-identifier">right_pixel_of_feature</span> = <span class="ruby-identifier">feature</span>.<span class="ruby-identifier">pixel_range_collection</span>.<span class="ruby-identifier">sort_by</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">pr</span><span class="ruby-operator">|</span> <span class="ruby-identifier">pr</span>.<span class="ruby-identifier">start_pixel</span>}[<span class="ruby-value">-1</span>].<span class="ruby-identifier">stop_pixel</span>
196
-
197
- <span class="ruby-comment cmt"># Start with the one with the arrow
198
- <span class="ruby-identifier">pixel_ranges</span> = <span class="ruby-identifier">feature</span>.<span class="ruby-identifier">pixel_range_collection</span>.<span class="ruby-identifier">sort_by</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">pr</span><span class="ruby-operator">|</span> <span class="ruby-identifier">pr</span>.<span class="ruby-identifier">start_pixel</span>}
199
- <span class="ruby-identifier">range_with_arrow</span> = <span class="ruby-keyword kw">nil</span>
200
- <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">feature</span>.<span class="ruby-identifier">strand</span> <span class="ruby-operator">==</span> <span class="ruby-value">-1</span> <span class="ruby-comment cmt"># reverse strand =&gt; box with arrow is first one
201
- <span class="ruby-identifier">range_with_arrow</span> = <span class="ruby-identifier">pixel_ranges</span>.<span class="ruby-identifier">shift</span>
202
- <span class="ruby-identifier">track_drawing</span>.<span class="ruby-identifier">rectangle</span>((<span class="ruby-identifier">range_with_arrow</span>.<span class="ruby-identifier">start_pixel</span>)<span class="ruby-operator">+</span><span class="ruby-constant">FEATURE_ARROW_LENGTH</span>, <span class="ruby-identifier">top_pixel_of_feature</span>, <span class="ruby-identifier">range_with_arrow</span>.<span class="ruby-identifier">stop_pixel</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">range_with_arrow</span>.<span class="ruby-identifier">start_pixel</span>, <span class="ruby-constant">FEATURE_HEIGHT</span>).<span class="ruby-identifier">fill</span>
203
- <span class="ruby-identifier">track_drawing</span>.<span class="ruby-identifier">move_to</span>(<span class="ruby-identifier">range_with_arrow</span>.<span class="ruby-identifier">start_pixel</span><span class="ruby-operator">+</span><span class="ruby-constant">FEATURE_ARROW_LENGTH</span>, <span class="ruby-identifier">top_pixel_of_feature</span>)
204
- <span class="ruby-identifier">track_drawing</span>.<span class="ruby-identifier">rel_line_to</span>(<span class="ruby-operator">-</span><span class="ruby-constant">FEATURE_ARROW_LENGTH</span>, <span class="ruby-constant">FEATURE_HEIGHT</span><span class="ruby-operator">/</span><span class="ruby-value">2</span>)
205
- <span class="ruby-identifier">track_drawing</span>.<span class="ruby-identifier">rel_line_to</span>(<span class="ruby-constant">FEATURE_ARROW_LENGTH</span>, <span class="ruby-constant">FEATURE_HEIGHT</span><span class="ruby-operator">/</span><span class="ruby-value">2</span>)
206
- <span class="ruby-identifier">track_drawing</span>.<span class="ruby-identifier">close_path</span>.<span class="ruby-identifier">fill</span>
207
- <span class="ruby-keyword kw">else</span> <span class="ruby-comment cmt"># forward strand =&gt; box with arrow is last one
208
- <span class="ruby-identifier">range_with_arrow</span> = <span class="ruby-identifier">pixel_ranges</span>.<span class="ruby-identifier">pop</span>
209
- <span class="ruby-identifier">track_drawing</span>.<span class="ruby-identifier">rectangle</span>(<span class="ruby-identifier">range_with_arrow</span>.<span class="ruby-identifier">start_pixel</span><span class="ruby-operator">-</span><span class="ruby-constant">FEATURE_ARROW_LENGTH</span>, <span class="ruby-identifier">top_pixel_of_feature</span>, <span class="ruby-identifier">range_with_arrow</span>.<span class="ruby-identifier">stop_pixel</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">range_with_arrow</span>.<span class="ruby-identifier">start_pixel</span>, <span class="ruby-constant">FEATURE_HEIGHT</span>).<span class="ruby-identifier">fill</span>
210
- <span class="ruby-identifier">track_drawing</span>.<span class="ruby-identifier">move_to</span>(<span class="ruby-identifier">range_with_arrow</span>.<span class="ruby-identifier">stop_pixel</span><span class="ruby-operator">-</span><span class="ruby-constant">FEATURE_ARROW_LENGTH</span>, <span class="ruby-identifier">top_pixel_of_feature</span>)
211
- <span class="ruby-identifier">track_drawing</span>.<span class="ruby-identifier">rel_line_to</span>(<span class="ruby-constant">FEATURE_ARROW_LENGTH</span>, <span class="ruby-constant">FEATURE_HEIGHT</span><span class="ruby-operator">/</span><span class="ruby-value">2</span>)
212
- <span class="ruby-identifier">track_drawing</span>.<span class="ruby-identifier">rel_line_to</span>(<span class="ruby-operator">-</span><span class="ruby-constant">FEATURE_ARROW_LENGTH</span>, <span class="ruby-constant">FEATURE_HEIGHT</span><span class="ruby-operator">/</span><span class="ruby-value">2</span>)
213
- <span class="ruby-keyword kw">end</span>
214
- <span class="ruby-identifier">gap_starts</span>.<span class="ruby-identifier">push</span>(<span class="ruby-identifier">range_with_arrow</span>.<span class="ruby-identifier">stop_pixel</span>)
215
- <span class="ruby-identifier">gap_stops</span>.<span class="ruby-identifier">push</span>(<span class="ruby-identifier">range_with_arrow</span>.<span class="ruby-identifier">start_pixel</span>)
216
-
217
- <span class="ruby-comment cmt"># And then add the others
218
- <span class="ruby-identifier">pixel_ranges</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">range</span><span class="ruby-operator">|</span>
219
- <span class="ruby-identifier">track_drawing</span>.<span class="ruby-identifier">rectangle</span>(<span class="ruby-identifier">range</span>.<span class="ruby-identifier">start_pixel</span>, <span class="ruby-identifier">top_pixel_of_feature</span>, <span class="ruby-identifier">range</span>.<span class="ruby-identifier">stop_pixel</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">range</span>.<span class="ruby-identifier">start_pixel</span>, <span class="ruby-constant">FEATURE_HEIGHT</span>).<span class="ruby-identifier">fill</span>
220
- <span class="ruby-identifier">gap_starts</span>.<span class="ruby-identifier">push</span>(<span class="ruby-identifier">range</span>.<span class="ruby-identifier">stop_pixel</span>)
221
- <span class="ruby-identifier">gap_stops</span>.<span class="ruby-identifier">push</span>(<span class="ruby-identifier">range</span>.<span class="ruby-identifier">start_pixel</span>)
222
- <span class="ruby-keyword kw">end</span>
223
-
224
- <span class="ruby-comment cmt"># And then draw the connections in the gaps
225
- <span class="ruby-comment cmt"># Start with removing the very first start and the very last stop.
226
- <span class="ruby-identifier">gap_starts</span>.<span class="ruby-identifier">sort!</span>.<span class="ruby-identifier">pop</span>
227
- <span class="ruby-identifier">gap_stops</span>.<span class="ruby-identifier">sort!</span>.<span class="ruby-identifier">shift</span>
228
-
229
- <span class="ruby-identifier">gap_starts</span>.<span class="ruby-identifier">length</span>.<span class="ruby-identifier">times</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">gap_number</span><span class="ruby-operator">|</span>
230
- <span class="ruby-identifier">from</span> = <span class="ruby-identifier">gap_starts</span>[<span class="ruby-identifier">gap_number</span>].<span class="ruby-identifier">to_f</span>
231
- <span class="ruby-identifier">to</span> = <span class="ruby-identifier">gap_stops</span>[<span class="ruby-identifier">gap_number</span>].<span class="ruby-identifier">to_f</span>
232
- <span class="ruby-identifier">middle</span> = <span class="ruby-identifier">from</span> <span class="ruby-operator">+</span> ((<span class="ruby-identifier">to</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">from</span>)<span class="ruby-operator">/</span><span class="ruby-value">2</span>)
233
- <span class="ruby-identifier">track_drawing</span>.<span class="ruby-identifier">move_to</span>(<span class="ruby-identifier">from</span>, <span class="ruby-identifier">top_pixel_of_feature</span><span class="ruby-operator">+</span><span class="ruby-value">2</span>)
234
- <span class="ruby-identifier">track_drawing</span>.<span class="ruby-identifier">line_to</span>(<span class="ruby-identifier">middle</span>, <span class="ruby-identifier">top_pixel_of_feature</span><span class="ruby-operator">+</span><span class="ruby-value">7</span>)
235
- <span class="ruby-identifier">track_drawing</span>.<span class="ruby-identifier">line_to</span>(<span class="ruby-identifier">to</span>, <span class="ruby-identifier">top_pixel_of_feature</span><span class="ruby-operator">+</span><span class="ruby-value">2</span>)
236
- <span class="ruby-identifier">track_drawing</span>.<span class="ruby-identifier">stroke</span>
237
- <span class="ruby-keyword kw">end</span>
238
-
239
- <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">feature</span>.<span class="ruby-identifier">hidden_subfeatures_at_stop</span>
240
- <span class="ruby-identifier">from</span> = <span class="ruby-identifier">feature</span>.<span class="ruby-identifier">pixel_range_collection</span>.<span class="ruby-identifier">sort_by</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">pr</span><span class="ruby-operator">|</span> <span class="ruby-identifier">pr</span>.<span class="ruby-identifier">start_pixel</span>}[<span class="ruby-value">-1</span>].<span class="ruby-identifier">stop_pixel</span>
241
- <span class="ruby-identifier">to</span> = <span class="ruby-identifier">panel</span>.<span class="ruby-identifier">width</span>
242
- <span class="ruby-identifier">track_drawing</span>.<span class="ruby-identifier">move_to</span>(<span class="ruby-identifier">from</span>, <span class="ruby-identifier">top_pixel_of_feature</span><span class="ruby-operator">+</span><span class="ruby-value">5</span>)
243
- <span class="ruby-identifier">track_drawing</span>.<span class="ruby-identifier">line_to</span>(<span class="ruby-identifier">to</span>, <span class="ruby-identifier">top_pixel_of_feature</span><span class="ruby-operator">+</span><span class="ruby-value">5</span>)
244
- <span class="ruby-identifier">track_drawing</span>.<span class="ruby-identifier">stroke</span>
245
- <span class="ruby-keyword kw">end</span>
246
-
247
- <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">feature</span>.<span class="ruby-identifier">hidden_subfeatures_at_start</span>
248
- <span class="ruby-identifier">from</span> = <span class="ruby-value">1</span>
249
- <span class="ruby-identifier">to</span> = <span class="ruby-identifier">feature</span>.<span class="ruby-identifier">pixel_range_collection</span>.<span class="ruby-identifier">sort_by</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">pr</span><span class="ruby-operator">|</span> <span class="ruby-identifier">pr</span>.<span class="ruby-identifier">start_pixel</span>}[<span class="ruby-value">0</span>].<span class="ruby-identifier">start_pixel</span>
250
- <span class="ruby-identifier">track_drawing</span>.<span class="ruby-identifier">move_to</span>(<span class="ruby-identifier">from</span>, <span class="ruby-identifier">top_pixel_of_feature</span><span class="ruby-operator">+</span><span class="ruby-value">5</span>)
251
- <span class="ruby-identifier">track_drawing</span>.<span class="ruby-identifier">line_to</span>(<span class="ruby-identifier">to</span>, <span class="ruby-identifier">top_pixel_of_feature</span><span class="ruby-operator">+</span><span class="ruby-value">5</span>)
252
- <span class="ruby-identifier">track_drawing</span>.<span class="ruby-identifier">stroke</span>
253
- <span class="ruby-keyword kw">end</span>
254
-
255
- <span class="ruby-keyword kw">else</span> <span class="ruby-comment cmt">#treat as 'generic'
256
- <span class="ruby-identifier">left_pixel_of_feature</span>, <span class="ruby-identifier">right_pixel_of_feature</span> = <span class="ruby-identifier">feature</span>.<span class="ruby-identifier">pixel_range_collection</span>[<span class="ruby-value">0</span>].<span class="ruby-identifier">start_pixel</span>, <span class="ruby-identifier">feature</span>.<span class="ruby-identifier">pixel_range_collection</span>[<span class="ruby-value">0</span>].<span class="ruby-identifier">stop_pixel</span>
257
- <span class="ruby-identifier">track_drawing</span>.<span class="ruby-identifier">rectangle</span>(<span class="ruby-identifier">left_pixel_of_feature</span>, <span class="ruby-identifier">top_pixel_of_feature</span>, (<span class="ruby-identifier">right_pixel_of_feature</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">left_pixel_of_feature</span>), <span class="ruby-constant">FEATURE_HEIGHT</span>).<span class="ruby-identifier">fill</span>
258
- <span class="ruby-keyword kw">end</span>
259
-
260
- <span class="ruby-comment cmt"># And add the region to the image map
261
- <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">panel</span>.<span class="ruby-identifier">clickable</span>
262
- <span class="ruby-comment cmt"># Comment: we have to add the vertical_offset and TRACK_HEADER_HEIGHT!
263
- <span class="ruby-identifier">panel</span>.<span class="ruby-identifier">image_map</span>.<span class="ruby-identifier">elements</span>.<span class="ruby-identifier">push</span>(<span class="ruby-constant">ImageMap</span><span class="ruby-operator">::</span><span class="ruby-constant">ImageMapElement</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">left_pixel_of_feature</span>,
264
- <span class="ruby-identifier">top_pixel_of_feature</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">vertical_offset</span> <span class="ruby-operator">+</span> <span class="ruby-constant">TRACK_HEADER_HEIGHT</span>,
265
- <span class="ruby-identifier">right_pixel_of_feature</span>,
266
- <span class="ruby-identifier">bottom_pixel_of_feature</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">vertical_offset</span> <span class="ruby-operator">+</span> <span class="ruby-constant">TRACK_HEADER_HEIGHT</span>,
267
- <span class="ruby-identifier">feature</span>.<span class="ruby-identifier">link</span>
268
- ))
269
- <span class="ruby-keyword kw">end</span>
270
-
271
-
272
- <span class="ruby-identifier">feature_drawn</span> = <span class="ruby-keyword kw">true</span>
273
- <span class="ruby-keyword kw">end</span>
274
- <span class="ruby-keyword kw">end</span>
41
+ <span class="ruby-identifier">feature</span>.<span class="ruby-identifier">draw</span>(<span class="ruby-identifier">track_drawing</span>)
275
42
  <span class="ruby-keyword kw">end</span>
276
43
  <span class="ruby-keyword kw">end</span>
277
44
 
278
45
  <span class="ruby-keyword kw">end</span>
279
46
 
280
- <span class="ruby-ivar">@number_of_times_bumped</span> = ( <span class="ruby-identifier">grid</span>.<span class="ruby-identifier">keys</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span> ) <span class="ruby-operator">?</span> <span class="ruby-value">1</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">grid</span>.<span class="ruby-identifier">keys</span>.<span class="ruby-identifier">max</span> <span class="ruby-operator">+</span> <span class="ruby-value">1</span>
47
+ <span class="ruby-ivar">@number_of_feature_rows</span> = ( <span class="ruby-ivar">@grid</span>.<span class="ruby-identifier">keys</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span> ) <span class="ruby-operator">?</span> <span class="ruby-value">1</span> <span class="ruby-operator">:</span> <span class="ruby-ivar">@grid</span>.<span class="ruby-identifier">keys</span>.<span class="ruby-identifier">max</span> <span class="ruby-operator">+</span> <span class="ruby-value">1</span>
281
48
 
282
49
  <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">panel_drawing</span>
283
50
  <span class="ruby-keyword kw">end</span></pre>
@@ -99,6 +99,10 @@ features.
99
99
  <h3 class="section-bar">Methods</h3>
100
100
 
101
101
  <div class="name-list">
102
+ <a href="#M000012">arrow</a>&nbsp;&nbsp;
103
+ <a href="#M000013">connector</a>&nbsp;&nbsp;
104
+ <a href="#M000014">draw</a>&nbsp;&nbsp;
105
+ <a href="#M000015">find_row</a>&nbsp;&nbsp;
102
106
  <a href="#M000011">new</a>&nbsp;&nbsp;
103
107
  </div>
104
108
  </div>
@@ -272,6 +276,111 @@ strand
272
276
  <table>
273
277
  <tr><td valign="top"><b>Returns</b>:</td><td>Bio::Graphics::Track::Feature object
274
278
 
279
+ </td></tr>
280
+ </table>
281
+ </div>
282
+ </div>
283
+
284
+ <h3 class="section-bar">Public Instance methods</h3>
285
+
286
+ <div id="method-M000012" class="method-detail">
287
+ <a name="M000012"></a>
288
+
289
+ <div class="method-heading">
290
+ <a href="Feature.src/M000012.html" target="Code" class="method-signature"
291
+ onclick="popupCode('Feature.src/M000012.html');return false;">
292
+ <span class="method-name">arrow</span><span class="method-args">(track,direction,x,y,size)</span>
293
+ </a>
294
+ </div>
295
+
296
+ <div class="method-description">
297
+ <p>
298
+ Method to <a href="Feature.html#M000014">draw</a> the arrows of directed
299
+ glyphs. Not to be used directly, but called by <a
300
+ href="Feature.html#M000014">Feature#draw</a>.
301
+ </p>
302
+ </div>
303
+ </div>
304
+
305
+ <div id="method-M000013" class="method-detail">
306
+ <a name="M000013"></a>
307
+
308
+ <div class="method-heading">
309
+ <a href="Feature.src/M000013.html" target="Code" class="method-signature"
310
+ onclick="popupCode('Feature.src/M000013.html');return false;">
311
+ <span class="method-name">connector</span><span class="method-args">(track,from,to,top, color)</span>
312
+ </a>
313
+ </div>
314
+
315
+ <div class="method-description">
316
+ <p>
317
+ Method to <a href="Feature.html#M000014">draw</a> the connections (introns)
318
+ of spliced glyphs. Not to be used directly, but called by <a
319
+ href="Feature.html#M000014">Feature#draw</a>.
320
+ </p>
321
+ </div>
322
+ </div>
323
+
324
+ <div id="method-M000014" class="method-detail">
325
+ <a name="M000014"></a>
326
+
327
+ <div class="method-heading">
328
+ <a href="Feature.src/M000014.html" target="Code" class="method-signature"
329
+ onclick="popupCode('Feature.src/M000014.html');return false;">
330
+ <span class="method-name">draw</span><span class="method-args">(track_drawing)</span>
331
+ </a>
332
+ </div>
333
+
334
+ <div class="method-description">
335
+ <p>
336
+ Adds the feature to the track cairo context. This method should not be used
337
+ directly by the user, but is called by <a
338
+ href="../Track.html#M000010">Bio::Graphics::Panel::Track.draw</a>
339
+ </p>
340
+ <hr size="1"></hr><p>
341
+ <b>Arguments</b>:
342
+ </p>
343
+ <ul>
344
+ <li><em>trackdrawing</em> (required) :: the track cairo object
345
+
346
+ </li>
347
+ <li><em>row</em> (required) :: row within the track that this feature has
348
+
349
+ <pre>
350
+ been bumped to
351
+ </pre>
352
+ </li>
353
+ </ul>
354
+ <table>
355
+ <tr><td valign="top"><b>Returns</b>:</td><td>FIXME: I don&#8216;t know
356
+
357
+ </td></tr>
358
+ </table>
359
+ </div>
360
+ </div>
361
+
362
+ <div id="method-M000015" class="method-detail">
363
+ <a name="M000015"></a>
364
+
365
+ <div class="method-heading">
366
+ <a href="Feature.src/M000015.html" target="Code" class="method-signature"
367
+ onclick="popupCode('Feature.src/M000015.html');return false;">
368
+ <span class="method-name">find_row</span><span class="method-args">()</span>
369
+ </a>
370
+ </div>
371
+
372
+ <div class="method-description">
373
+ <p>
374
+ Calculates the row within the track where this feature should be drawn.
375
+ This method should not be used directly by the user, but is called by <a
376
+ href="Feature.html#M000014">Bio::Graphics::Panel::Track::Feature.draw</a>
377
+ </p>
378
+ <hr size="1"></hr><table>
379
+ <tr><td valign="top"><b>Arguments</b>:</td><td>none
380
+
381
+ </td></tr>
382
+ <tr><td valign="top"><b>Returns</b>:</td><td>row number
383
+
275
384
  </td></tr>
276
385
  </table>
277
386
  </div>