bio-graphics 1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. data/doc/classes/Bio.html +135 -0
  2. data/doc/classes/Bio/Graphics.html +247 -0
  3. data/doc/classes/Bio/Graphics/Panel.html +344 -0
  4. data/doc/classes/Bio/Graphics/Panel.src/M000005.html +29 -0
  5. data/doc/classes/Bio/Graphics/Panel.src/M000006.html +19 -0
  6. data/doc/classes/Bio/Graphics/Panel.src/M000007.html +67 -0
  7. data/doc/classes/Bio/Graphics/Panel/Ruler.html +238 -0
  8. data/doc/classes/Bio/Graphics/Panel/Ruler.src/M000008.html +20 -0
  9. data/doc/classes/Bio/Graphics/Panel/Ruler.src/M000009.html +28 -0
  10. data/doc/classes/Bio/Graphics/Panel/Ruler.src/M000010.html +54 -0
  11. data/doc/classes/Bio/Graphics/Panel/Ruler.src/M000013.html +20 -0
  12. data/doc/classes/Bio/Graphics/Panel/Ruler.src/M000014.html +28 -0
  13. data/doc/classes/Bio/Graphics/Panel/Ruler.src/M000015.html +59 -0
  14. data/doc/classes/Bio/Graphics/Panel/Track.html +342 -0
  15. data/doc/classes/Bio/Graphics/Panel/Track.src/M000008.html +23 -0
  16. data/doc/classes/Bio/Graphics/Panel/Track.src/M000009.html +42 -0
  17. data/doc/classes/Bio/Graphics/Panel/Track.src/M000010.html +285 -0
  18. data/doc/classes/Bio/Graphics/Panel/Track.src/M000011.html +23 -0
  19. data/doc/classes/Bio/Graphics/Panel/Track.src/M000012.html +43 -0
  20. data/doc/classes/Bio/Graphics/Panel/Track.src/M000013.html +259 -0
  21. data/doc/classes/Bio/Graphics/Panel/Track/Feature.html +292 -0
  22. data/doc/classes/Bio/Graphics/Panel/Track/Feature.src/M000011.html +65 -0
  23. data/doc/classes/Bio/Graphics/Panel/Track/Feature.src/M000014.html +65 -0
  24. data/doc/classes/Bio/Graphics/Panel/Track/Feature/PixelRange.html +155 -0
  25. data/doc/classes/Bio/Graphics/Panel/Track/Feature/PixelRange.src/M000012.html +18 -0
  26. data/doc/classes/Bio/Graphics/Panel/Track/Feature/PixelRange.src/M000015.html +18 -0
  27. data/doc/classes/ImageMap.html +185 -0
  28. data/doc/classes/ImageMap.src/M000001.html +18 -0
  29. data/doc/classes/ImageMap.src/M000002.html +24 -0
  30. data/doc/classes/ImageMap/ImageMapElement.html +187 -0
  31. data/doc/classes/ImageMap/ImageMapElement.src/M000003.html +19 -0
  32. data/doc/classes/ImageMap/ImageMapElement.src/M000004.html +20 -0
  33. data/doc/created.rid +1 -0
  34. data/doc/files/README_DEV.html +432 -0
  35. data/doc/files/TUTORIAL.html +358 -0
  36. data/doc/files/lib/bio-graphics_rb.html +121 -0
  37. data/doc/files/lib/bio/graphics/feature_rb.html +113 -0
  38. data/doc/files/lib/bio/graphics/image_map_rb.html +113 -0
  39. data/doc/files/lib/bio/graphics/panel_rb.html +113 -0
  40. data/doc/files/lib/bio/graphics/ruler_rb.html +113 -0
  41. data/doc/files/lib/bio/graphics/track_rb.html +113 -0
  42. data/doc/fr_class_index.html +35 -0
  43. data/doc/fr_file_index.html +34 -0
  44. data/doc/fr_method_index.html +41 -0
  45. data/doc/images/example.png +0 -0
  46. data/doc/images/glyph_showcase.png +0 -0
  47. data/doc/images/terms.png +0 -0
  48. data/doc/images/terms.svg +166 -0
  49. data/doc/index.html +24 -0
  50. data/images/example.png +0 -0
  51. data/images/glyph_showcase.png +0 -0
  52. data/images/terms.png +0 -0
  53. data/images/terms.svg +166 -0
  54. data/lib/bio-graphics.rb +18 -0
  55. data/lib/bio/graphics/feature.rb +136 -0
  56. data/lib/bio/graphics/image_map.rb +37 -0
  57. data/lib/bio/graphics/panel.rb +205 -0
  58. data/lib/bio/graphics/ruler.rb +96 -0
  59. data/lib/bio/graphics/track.rb +387 -0
  60. data/samples/arkdb_features.rb +37 -0
  61. data/samples/data.txt +32 -0
  62. data/samples/glyph_showcase.rb +29 -0
  63. metadata +137 -0
@@ -0,0 +1,23 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html>
7
+ <head>
8
+ <title>new (Bio::Graphics::Panel::Track)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../../../../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
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>)
15
+ <span class="ruby-ivar">@panel</span> = <span class="ruby-identifier">panel</span>
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>
19
+ <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-keyword kw">end</span></pre>
22
+ </body>
23
+ </html>
@@ -0,0 +1,42 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html>
7
+ <head>
8
+ <title>add_feature (Bio::Graphics::Panel::Track)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../../../../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
12
+ <body class="standalone-code">
13
+ <pre><span class="ruby-comment cmt"># File lib/bio/graphics/track.rb, line 76</span>
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
+ <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
+ <span class="ruby-identifier">link</span> = <span class="ruby-keyword kw">nil</span>
17
+ <span class="ruby-keyword kw">end</span>
18
+
19
+ <span class="ruby-comment cmt"># Calculate the ultimate start and stop of the feature: the start
20
+ <span class="ruby-comment cmt"># of the first subfeature (e.g. exon) and the stop of the last one.
21
+ <span class="ruby-comment cmt"># The only reason we want to know these positions, is because we want
22
+ <span class="ruby-comment cmt"># to determine if the feature falls within the view of the image or
23
+ <span class="ruby-comment cmt"># not (see below).
24
+ <span class="ruby-identifier">location_object</span> = <span class="ruby-constant">Bio</span><span class="ruby-operator">::</span><span class="ruby-constant">Locations</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">location_string</span>)
25
+ <span class="ruby-identifier">start</span> = <span class="ruby-identifier">location_object</span>.<span class="ruby-identifier">collect</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>}.<span class="ruby-identifier">min</span>.<span class="ruby-identifier">to_i</span>
26
+ <span class="ruby-identifier">stop</span> = <span class="ruby-identifier">location_object</span>.<span class="ruby-identifier">collect</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">to</span>}.<span class="ruby-identifier">max</span>.<span class="ruby-identifier">to_i</span>
27
+
28
+ <span class="ruby-comment cmt"># If the feature wouldn't show because it's not in the region we're
29
+ <span class="ruby-comment cmt"># looking at, don't bother storing the stuff. I think this makes huge
30
+ <span class="ruby-comment cmt"># speed and memory differences if you've got a chromosome with
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>
33
+ <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">nil</span>
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
+ <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>))
36
+ <span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@features</span>[<span class="ruby-value">-1</span>]
37
+ <span class="ruby-keyword kw">end</span>
38
+
39
+ <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">self</span>
40
+ <span class="ruby-keyword kw">end</span></pre>
41
+ </body>
42
+ </html>
@@ -0,0 +1,285 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html>
7
+ <head>
8
+ <title>draw (Bio::Graphics::Panel::Track)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../../../../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
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>)
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
+
17
+ <span class="ruby-comment cmt"># Draw thin line above title
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>)
21
+ <span class="ruby-identifier">track_drawing</span>.<span class="ruby-identifier">stroke</span>
22
+
23
+ <span class="ruby-comment cmt"># Draw track title
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>)
26
+ <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">show_text</span>(<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">name</span>)
29
+
30
+ <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
+ <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>)
36
+
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>
44
+ <span class="ruby-comment cmt"># Don't even bother if the feature is not in the view
45
+ <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
+ <span class="ruby-keyword kw">next</span>
47
+ <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>
275
+ <span class="ruby-keyword kw">end</span>
276
+ <span class="ruby-keyword kw">end</span>
277
+
278
+ <span class="ruby-keyword kw">end</span>
279
+
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>
281
+
282
+ <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">panel_drawing</span>
283
+ <span class="ruby-keyword kw">end</span></pre>
284
+ </body>
285
+ </html>
@@ -0,0 +1,23 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html>
7
+ <head>
8
+ <title>new (Bio::Graphics::Panel::Track)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../../../../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
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>)
15
+ <span class="ruby-ivar">@panel</span> = <span class="ruby-identifier">panel</span>
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>
19
+ <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-keyword kw">end</span></pre>
22
+ </body>
23
+ </html>
@@ -0,0 +1,43 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html>
7
+ <head>
8
+ <title>add_feature (Bio::Graphics::Panel::Track)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../../../../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
12
+ <body class="standalone-code">
13
+ <pre><span class="ruby-comment cmt"># File lib/bio/graphics/track.rb, line 76</span>
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">'0..'</span> <span class="ruby-operator">+</span> (<span class="ruby-ivar">@panel</span>.<span class="ruby-identifier">width</span> <span class="ruby-operator">*</span> <span class="ruby-ivar">@panel</span>.<span class="ruby-identifier">rescale_factor</span>).<span class="ruby-identifier">to_s</span>, <span class="ruby-identifier">link</span> = <span class="ruby-keyword kw">nil</span>)
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
+ <span class="ruby-identifier">link</span> = <span class="ruby-keyword kw">nil</span>
17
+ <span class="ruby-keyword kw">end</span>
18
+ <span class="ruby-identifier">location_object</span> = <span class="ruby-constant">Bio</span><span class="ruby-operator">::</span><span class="ruby-constant">Locations</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">location_string</span>)
19
+ <span class="ruby-identifier">start</span> = <span class="ruby-identifier">location_object</span>.<span class="ruby-identifier">collect</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>}.<span class="ruby-identifier">min</span>.<span class="ruby-identifier">to_i</span>
20
+ <span class="ruby-identifier">stop</span> = <span class="ruby-identifier">location_object</span>.<span class="ruby-identifier">collect</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">to</span>}.<span class="ruby-identifier">max</span>.<span class="ruby-identifier">to_i</span>
21
+
22
+ <span class="ruby-comment cmt">#if start &lt; 0 or stop &gt; (panel.width.to_f * panel.rescale_factor.to_f).to_i
23
+ <span class="ruby-comment cmt"># raise &quot;ERROR: feature &quot; + name + &quot; has coordinates that lie outside of panel&quot;
24
+ <span class="ruby-comment cmt">#end
25
+ <span class="ruby-comment cmt">#@features.push(Bio::Graphics::Panel::Track::Feature.new(self, name, location_object, link))
26
+ <span class="ruby-comment cmt">#return @features[-1]
27
+
28
+ <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>
29
+ <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">nil</span>
30
+ <span class="ruby-keyword kw">else</span> <span class="ruby-comment cmt">#elsif start &gt;= panel.display_start and stop &lt;= panel.display_stop
31
+ <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>))
32
+ <span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@features</span>[<span class="ruby-value">-1</span>]
33
+ <span class="ruby-comment cmt"># TODO: chop bits of that extend beyond display
34
+ <span class="ruby-comment cmt">#elsif ( start &gt;= panel.display_start and stop &gt; panel.display_stop ) #Feature extends beyond right border
35
+ <span class="ruby-comment cmt"># new_location_object = Bio::Locations.new
36
+ <span class="ruby-comment cmt"># location_object.each do |l|
37
+ <span class="ruby-comment cmt"># if l.to &lt;= panel.display_stop
38
+ <span class="ruby-comment cmt"># new_location_object.push(Bio::Location.new('l
39
+ <span class="ruby-comment cmt"># end
40
+ <span class="ruby-keyword kw">end</span>
41
+ <span class="ruby-keyword kw">end</span></pre>
42
+ </body>
43
+ </html>
@@ -0,0 +1,259 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html>
7
+ <head>
8
+ <title>draw (Bio::Graphics::Panel::Track)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../../../../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
12
+ <body class="standalone-code">
13
+ <pre><span class="ruby-comment cmt"># File lib/bio/graphics/track.rb, line 114</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>)
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
+
17
+ <span class="ruby-comment cmt"># Draw thin line above title
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>)
21
+ <span class="ruby-identifier">track_drawing</span>.<span class="ruby-identifier">stroke</span>
22
+
23
+ <span class="ruby-comment cmt"># Draw track title
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>)
26
+ <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">show_text</span>(<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">name</span>)
29
+
30
+ <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
+ <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>)
36
+
37
+ <span class="ruby-comment cmt"># Now draw the features
38
+ <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>
39
+ <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>
40
+ <span class="ruby-keyword kw">next</span>
41
+ <span class="ruby-keyword kw">else</span>
42
+
43
+ <span class="ruby-identifier">feature_drawn</span> = <span class="ruby-keyword kw">false</span>
44
+ <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>)
45
+ <span class="ruby-identifier">row</span> = <span class="ruby-value">1</span>
46
+ <span class="ruby-identifier">row_available</span> = <span class="ruby-keyword kw">true</span>
47
+ <span class="ruby-keyword kw">until</span> <span class="ruby-identifier">feature_drawn</span>
48
+ <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>
49
+ <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>
50
+ <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>)
51
+ <span class="ruby-identifier">row_available</span> = <span class="ruby-keyword kw">false</span>
52
+ <span class="ruby-keyword kw">end</span>
53
+ <span class="ruby-keyword kw">end</span>
54
+ <span class="ruby-keyword kw">end</span>
55
+
56
+ <span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span> <span class="ruby-identifier">row_available</span>
57
+ <span class="ruby-identifier">row</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span>
58
+ <span class="ruby-identifier">row_available</span> = <span class="ruby-keyword kw">true</span>
59
+ <span class="ruby-keyword kw">else</span>
60
+ <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>
61
+ <span class="ruby-identifier">grid</span>[<span class="ruby-identifier">row</span>] = <span class="ruby-constant">Array</span>.<span class="ruby-identifier">new</span>
62
+ <span class="ruby-keyword kw">end</span>
63
+ <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>)
64
+
65
+ <span class="ruby-comment cmt"># There are 2 cases where we don't want to draw arrows on
66
+ <span class="ruby-comment cmt"># features:
67
+ <span class="ruby-comment cmt"># (a) when the picture is really zoomed out, features are
68
+ <span class="ruby-comment cmt"># so small that the arrow itself is too big
69
+ <span class="ruby-comment cmt"># (b) if a directed feature on the fw strand extends beyond
70
+ <span class="ruby-comment cmt"># the end of the picture, the arrow is out of view. This
71
+ <span class="ruby-comment cmt"># is the same as considering the feature as undirected.
72
+ <span class="ruby-comment cmt"># The same obviously goes for features on the reverse
73
+ <span class="ruby-comment cmt"># strand that extend beyond the left side of the image.
74
+ <span class="ruby-comment cmt">#
75
+ <span class="ruby-comment cmt"># (a) Zoomed out
76
+ <span class="ruby-identifier">replace_directed_with_undirected</span> = <span class="ruby-keyword kw">false</span>
77
+ <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>
78
+ <span class="ruby-identifier">replace_directed_with_undirected</span> = <span class="ruby-keyword kw">true</span>
79
+ <span class="ruby-keyword kw">end</span>
80
+ <span class="ruby-comment cmt"># (b) Extending beyond borders picture
81
+ <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> )
82
+ <span class="ruby-identifier">replace_directed_with_undirected</span> = <span class="ruby-keyword kw">true</span>
83
+ <span class="ruby-keyword kw">end</span>
84
+
85
+ <span class="ruby-identifier">local_feature_glyph</span> = <span class="ruby-keyword kw">nil</span>
86
+ <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>
87
+ <span class="ruby-identifier">local_feature_glyph</span> = <span class="ruby-value str">'generic'</span>
88
+ <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>
89
+ <span class="ruby-identifier">local_feature_glyph</span> = <span class="ruby-value str">'spliced'</span>
90
+ <span class="ruby-keyword kw">else</span>
91
+ <span class="ruby-identifier">local_feature_glyph</span> = <span class="ruby-identifier">feature_glyph</span>
92
+ <span class="ruby-keyword kw">end</span>
93
+
94
+ <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>
95
+ <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>
96
+
97
+ <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">local_feature_glyph</span>
98
+ <span class="ruby-comment cmt"># triangles are typical for features which have a 1 bp position (start == stop)
99
+ <span class="ruby-keyword kw">when</span> <span class="ruby-value str">'triangle'</span>
100
+ <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>
101
+
102
+ <span class="ruby-comment cmt"># Need to get this for the imagemap
103
+ <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>
104
+ <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>
105
+ <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>)
106
+ <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>)
107
+ <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>)
108
+ <span class="ruby-identifier">track_drawing</span>.<span class="ruby-identifier">close_path</span>.<span class="ruby-identifier">fill</span>
109
+
110
+ <span class="ruby-keyword kw">when</span> <span class="ruby-value str">'directed_generic'</span>
111
+ <span class="ruby-comment cmt"># Need to get this for the imagemap
112
+ <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>
113
+ <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>
114
+ <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
115
+ <span class="ruby-comment cmt"># Draw main box
116
+ <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>
117
+
118
+ <span class="ruby-comment cmt"># Draw arrow
119
+ <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>)
120
+ <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>)
121
+ <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>)
122
+ <span class="ruby-identifier">track_drawing</span>.<span class="ruby-identifier">close_path</span>.<span class="ruby-identifier">fill</span>
123
+
124
+ <span class="ruby-keyword kw">else</span> <span class="ruby-comment cmt">#default is forward strand
125
+ <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>
126
+ <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>)
127
+ <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>)
128
+ <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>)
129
+ <span class="ruby-identifier">track_drawing</span>.<span class="ruby-identifier">close_path</span>.<span class="ruby-identifier">fill</span>
130
+ <span class="ruby-keyword kw">end</span>
131
+ <span class="ruby-keyword kw">when</span> <span class="ruby-value str">'spliced'</span>
132
+ <span class="ruby-identifier">gap_starts</span> = <span class="ruby-constant">Array</span>.<span class="ruby-identifier">new</span>
133
+ <span class="ruby-identifier">gap_stops</span> = <span class="ruby-constant">Array</span>.<span class="ruby-identifier">new</span>
134
+
135
+ <span class="ruby-comment cmt"># Need to get this for the imagemap
136
+ <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>
137
+ <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>
138
+
139
+ <span class="ruby-comment cmt"># First draw the parts
140
+ <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>
141
+ <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>
142
+ <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>)
143
+ <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>)
144
+ <span class="ruby-keyword kw">end</span>
145
+
146
+ <span class="ruby-comment cmt"># And then draw the connections in the gaps
147
+ <span class="ruby-comment cmt"># Start with removing the very first start and the very last stop.
148
+ <span class="ruby-identifier">gap_starts</span>.<span class="ruby-identifier">sort!</span>.<span class="ruby-identifier">pop</span>
149
+ <span class="ruby-identifier">gap_stops</span>.<span class="ruby-identifier">sort!</span>.<span class="ruby-identifier">shift</span>
150
+
151
+ <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>
152
+ <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>
153
+ <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>
154
+ <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>)
155
+ <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>)
156
+ <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>)
157
+ <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>)
158
+ <span class="ruby-identifier">track_drawing</span>.<span class="ruby-identifier">stroke</span>
159
+ <span class="ruby-keyword kw">end</span>
160
+
161
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">feature</span>.<span class="ruby-identifier">hidden_subfeatures_at_stop</span>
162
+ <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>
163
+ <span class="ruby-identifier">to</span> = <span class="ruby-identifier">panel</span>.<span class="ruby-identifier">width</span>
164
+ <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>)
165
+ <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>)
166
+ <span class="ruby-identifier">track_drawing</span>.<span class="ruby-identifier">stroke</span>
167
+ <span class="ruby-keyword kw">end</span>
168
+
169
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">feature</span>.<span class="ruby-identifier">hidden_subfeatures_at_start</span>
170
+ <span class="ruby-identifier">from</span> = <span class="ruby-value">1</span>
171
+ <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>
172
+ <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>)
173
+ <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>)
174
+ <span class="ruby-identifier">track_drawing</span>.<span class="ruby-identifier">stroke</span>
175
+ <span class="ruby-keyword kw">end</span>
176
+
177
+ <span class="ruby-keyword kw">when</span> <span class="ruby-value str">'directed_spliced'</span>
178
+ <span class="ruby-identifier">gap_starts</span> = <span class="ruby-constant">Array</span>.<span class="ruby-identifier">new</span>
179
+ <span class="ruby-identifier">gap_stops</span> = <span class="ruby-constant">Array</span>.<span class="ruby-identifier">new</span>
180
+ <span class="ruby-comment cmt"># First draw the parts
181
+ <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>}
182
+
183
+ <span class="ruby-comment cmt"># Need to get this for the imagemap
184
+ <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>
185
+ <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>
186
+
187
+ <span class="ruby-comment cmt"># Start with the one with the arrow
188
+ <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>}
189
+ <span class="ruby-identifier">range_with_arrow</span> = <span class="ruby-keyword kw">nil</span>
190
+ <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
191
+ <span class="ruby-identifier">range_with_arrow</span> = <span class="ruby-identifier">pixel_ranges</span>.<span class="ruby-identifier">shift</span>
192
+ <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>
193
+ <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>)
194
+ <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>)
195
+ <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>)
196
+ <span class="ruby-identifier">track_drawing</span>.<span class="ruby-identifier">close_path</span>.<span class="ruby-identifier">fill</span>
197
+ <span class="ruby-keyword kw">else</span> <span class="ruby-comment cmt"># forward strand =&gt; box with arrow is last one
198
+ <span class="ruby-identifier">range_with_arrow</span> = <span class="ruby-identifier">pixel_ranges</span>.<span class="ruby-identifier">pop</span>
199
+ <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>
200
+ <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>)
201
+ <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>)
202
+ <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>)
203
+ <span class="ruby-keyword kw">end</span>
204
+ <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>)
205
+ <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>)
206
+
207
+ <span class="ruby-comment cmt"># And then add the others
208
+ <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>
209
+ <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>
210
+ <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>)
211
+ <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>)
212
+ <span class="ruby-keyword kw">end</span>
213
+
214
+ <span class="ruby-comment cmt"># And then draw the connections in the gaps
215
+ <span class="ruby-comment cmt"># Start with removing the very first start and the very last stop.
216
+ <span class="ruby-identifier">gap_starts</span>.<span class="ruby-identifier">sort!</span>.<span class="ruby-identifier">pop</span>
217
+ <span class="ruby-identifier">gap_stops</span>.<span class="ruby-identifier">sort!</span>.<span class="ruby-identifier">shift</span>
218
+
219
+ <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>
220
+ <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>
221
+ <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>
222
+ <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>)
223
+ <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>)
224
+ <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>)
225
+ <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>)
226
+ <span class="ruby-identifier">track_drawing</span>.<span class="ruby-identifier">stroke</span>
227
+ <span class="ruby-keyword kw">end</span>
228
+
229
+ <span class="ruby-keyword kw">else</span> <span class="ruby-comment cmt">#treat as 'generic'
230
+ <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>
231
+ <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>
232
+ <span class="ruby-keyword kw">end</span>
233
+
234
+ <span class="ruby-comment cmt"># And add the region to the image map
235
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">panel</span>.<span class="ruby-identifier">clickable</span>
236
+ <span class="ruby-comment cmt"># Comment: we have to add the vertical_offset and TRACK_HEADER_HEIGHT!
237
+ <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>,
238
+ <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>,
239
+ <span class="ruby-identifier">right_pixel_of_feature</span>,
240
+ <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>,
241
+ <span class="ruby-identifier">feature</span>.<span class="ruby-identifier">link</span>
242
+ ))
243
+ <span class="ruby-keyword kw">end</span>
244
+
245
+
246
+ <span class="ruby-identifier">feature_drawn</span> = <span class="ruby-keyword kw">true</span>
247
+ <span class="ruby-keyword kw">end</span>
248
+ <span class="ruby-keyword kw">end</span>
249
+ <span class="ruby-keyword kw">end</span>
250
+ <span class="ruby-keyword kw">end</span>
251
+
252
+ <span class="ruby-keyword kw">end</span>
253
+
254
+ <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>
255
+
256
+ <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">panel_drawing</span>
257
+ <span class="ruby-keyword kw">end</span></pre>
258
+ </body>
259
+ </html>