bio-graphics 1.2 → 1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (331) hide show
  1. data/doc/classes/Bio.html +4 -26
  2. data/doc/classes/Bio/Feature.html +350 -0
  3. data/doc/classes/Bio/Feature.src/M000010.html +21 -0
  4. data/doc/classes/Bio/Feature.src/M000011.html +20 -0
  5. data/doc/classes/Bio/Feature.src/M000012.html +19 -0
  6. data/doc/classes/Bio/Feature.src/M000014.html +21 -0
  7. data/doc/classes/Bio/Feature.src/M000016.html +21 -0
  8. data/doc/classes/Bio/Feature.src/M000034.html +21 -0
  9. data/doc/classes/Bio/Feature.src/M000035.html +20 -0
  10. data/doc/classes/Bio/Feature.src/M000036.html +19 -0
  11. data/doc/classes/Bio/Feature.src/M000038.html +21 -0
  12. data/doc/classes/Bio/Feature.src/M000040.html +21 -0
  13. data/doc/classes/Bio/Feature.src/M000042.html +21 -0
  14. data/doc/classes/Bio/Feature.src/M000043.html +20 -0
  15. data/doc/classes/Bio/Feature.src/M000044.html +21 -0
  16. data/doc/classes/Bio/Feature.src/M000045.html +20 -0
  17. data/doc/classes/Bio/Feature.src/M000046.html +19 -0
  18. data/doc/classes/Bio/Feature.src/M000048.html +21 -0
  19. data/doc/classes/Bio/Feature.src/M000050.html +21 -0
  20. data/doc/classes/Bio/Feature.src/M000074.html +21 -0
  21. data/doc/classes/Bio/Feature.src/M000075.html +20 -0
  22. data/doc/classes/Bio/Feature.src/M000076.html +19 -0
  23. data/doc/classes/Bio/Feature.src/M000078.html +21 -0
  24. data/doc/classes/Bio/Feature.src/M000080.html +21 -0
  25. data/doc/classes/Bio/Feature/Qualifier.html +189 -0
  26. data/doc/classes/Bio/Feature/Qualifier.src/M000017.html +18 -0
  27. data/doc/classes/Bio/Feature/Qualifier.src/M000041.html +18 -0
  28. data/doc/classes/Bio/Feature/Qualifier.src/M000049.html +18 -0
  29. data/doc/classes/Bio/Feature/Qualifier.src/M000051.html +18 -0
  30. data/doc/classes/Bio/Feature/Qualifier.src/M000081.html +18 -0
  31. data/doc/classes/Bio/Features.html +329 -0
  32. data/doc/classes/Bio/Features.src/M000004.html +18 -0
  33. data/doc/classes/Bio/Features.src/M000005.html +19 -0
  34. data/doc/classes/Bio/Features.src/M000006.html +21 -0
  35. data/doc/classes/Bio/Features.src/M000007.html +18 -0
  36. data/doc/classes/Bio/Features.src/M000008.html +18 -0
  37. data/doc/classes/Bio/Features.src/M000009.html +18 -0
  38. data/doc/classes/Bio/Features.src/M000028.html +18 -0
  39. data/doc/classes/Bio/Features.src/M000029.html +19 -0
  40. data/doc/classes/Bio/Features.src/M000030.html +21 -0
  41. data/doc/classes/Bio/Features.src/M000031.html +18 -0
  42. data/doc/classes/Bio/Features.src/M000032.html +18 -0
  43. data/doc/classes/Bio/Features.src/M000033.html +18 -0
  44. data/doc/classes/Bio/Features.src/M000036.html +18 -0
  45. data/doc/classes/Bio/Features.src/M000037.html +19 -0
  46. data/doc/classes/Bio/Features.src/M000038.html +18 -0
  47. data/doc/classes/Bio/Features.src/M000039.html +19 -0
  48. data/doc/classes/Bio/Features.src/M000040.html +21 -0
  49. data/doc/classes/Bio/Features.src/M000041.html +18 -0
  50. data/doc/classes/Bio/Features.src/M000042.html +18 -0
  51. data/doc/classes/Bio/Features.src/M000043.html +18 -0
  52. data/doc/classes/Bio/Features.src/M000068.html +18 -0
  53. data/doc/classes/Bio/Features.src/M000069.html +19 -0
  54. data/doc/classes/Bio/Features.src/M000070.html +21 -0
  55. data/doc/classes/Bio/Features.src/M000071.html +18 -0
  56. data/doc/classes/Bio/Features.src/M000072.html +18 -0
  57. data/doc/classes/Bio/Features.src/M000073.html +18 -0
  58. data/doc/classes/Bio/Graphics.html +28 -42
  59. data/doc/classes/Bio/Graphics/{Panel/Track/Feature.html → Feature.html} +98 -125
  60. data/doc/classes/Bio/Graphics/Feature.src/M000020.html +51 -0
  61. data/doc/classes/Bio/Graphics/Feature.src/M000021.html +65 -0
  62. data/doc/classes/Bio/Graphics/Feature.src/M000022.html +55 -0
  63. data/doc/classes/Bio/Graphics/Feature.src/M000023.html +66 -0
  64. data/doc/classes/Bio/Graphics/Feature.src/M000024.html +51 -0
  65. data/doc/classes/Bio/Graphics/Feature.src/M000025.html +65 -0
  66. data/doc/classes/Bio/Graphics/Feature.src/M000026.html +55 -0
  67. data/doc/classes/Bio/Graphics/Feature.src/M000054.html +51 -0
  68. data/doc/classes/Bio/Graphics/Feature.src/M000055.html +65 -0
  69. data/doc/classes/Bio/Graphics/Feature.src/M000056.html +55 -0
  70. data/doc/classes/Bio/Graphics/Feature/SubFeature.html +348 -0
  71. data/doc/classes/Bio/Graphics/Feature/SubFeature.src/M000025.html +68 -0
  72. data/doc/classes/Bio/Graphics/Feature/SubFeature.src/M000026.html +67 -0
  73. data/doc/classes/Bio/Graphics/Glyph.html +178 -0
  74. data/doc/classes/Bio/Graphics/Glyph/Box.html +139 -0
  75. data/doc/classes/Bio/Graphics/Glyph/Box.src/M000004.html +24 -0
  76. data/doc/classes/Bio/Graphics/Glyph/Box.src/M000032.html +24 -0
  77. data/doc/classes/Bio/Graphics/Glyph/Common.html +187 -0
  78. data/doc/classes/Bio/Graphics/Glyph/Common.src/M000004.html +18 -0
  79. data/doc/classes/Bio/Graphics/Glyph/Common.src/M000005.html +18 -0
  80. data/doc/classes/Bio/Graphics/Glyph/Common.src/M000006.html +24 -0
  81. data/doc/classes/Bio/Graphics/Glyph/Common.src/M000007.html +24 -0
  82. data/doc/classes/Bio/Graphics/Glyph/Common.src/M000033.html +18 -0
  83. data/doc/classes/Bio/Graphics/Glyph/Common.src/M000034.html +24 -0
  84. data/doc/classes/Bio/Graphics/Glyph/Common.src/M000035.html +24 -0
  85. data/doc/classes/Bio/Graphics/Glyph/CustomTestGlyph.html +139 -0
  86. data/doc/classes/Bio/Graphics/Glyph/CustomTestGlyph.src/M000037.html +22 -0
  87. data/doc/classes/Bio/Graphics/Glyph/CustomTestGlyphInFile.html +139 -0
  88. data/doc/classes/Bio/Graphics/Glyph/CustomTestGlyphInFile.src/M000038.html +22 -0
  89. data/doc/classes/Bio/Graphics/Glyph/DirectedBox.html +139 -0
  90. data/doc/classes/Bio/Graphics/Glyph/DirectedBox.src/M000009.html +31 -0
  91. data/doc/classes/Bio/Graphics/Glyph/DirectedBox.src/M000039.html +31 -0
  92. data/doc/classes/Bio/Graphics/Glyph/DirectedGeneric.html +139 -0
  93. data/doc/classes/Bio/Graphics/Glyph/DirectedGeneric.src/M000011.html +26 -0
  94. data/doc/classes/Bio/Graphics/Glyph/DirectedGeneric.src/M000013.html +26 -0
  95. data/doc/classes/Bio/Graphics/Glyph/DirectedGeneric.src/M000043.html +26 -0
  96. data/doc/classes/Bio/Graphics/Glyph/DirectedSpliced.html +139 -0
  97. data/doc/classes/Bio/Graphics/Glyph/DirectedSpliced.src/M000008.html +40 -0
  98. data/doc/classes/Bio/Graphics/Glyph/DirectedSpliced.src/M000010.html +40 -0
  99. data/doc/classes/Bio/Graphics/Glyph/DirectedSpliced.src/M000040.html +40 -0
  100. data/doc/classes/Bio/Graphics/{Panel/Track/Feature/PixelRange.html → Glyph/Dot.html} +16 -19
  101. data/doc/classes/Bio/Graphics/Glyph/Dot.src/M000013.html +22 -0
  102. data/doc/classes/Bio/Graphics/Glyph/Dot.src/M000015.html +22 -0
  103. data/doc/classes/Bio/Graphics/Glyph/Dot.src/M000045.html +22 -0
  104. data/doc/classes/Bio/Graphics/Glyph/Generic.html +139 -0
  105. data/doc/classes/Bio/Graphics/Glyph/Generic.src/M000009.html +18 -0
  106. data/doc/classes/Bio/Graphics/Glyph/Generic.src/M000011.html +18 -0
  107. data/doc/classes/Bio/Graphics/Glyph/Generic.src/M000041.html +18 -0
  108. data/doc/classes/Bio/Graphics/Glyph/Line.html +139 -0
  109. data/doc/classes/Bio/Graphics/Glyph/Line.src/M000012.html +20 -0
  110. data/doc/classes/Bio/Graphics/Glyph/Line.src/M000014.html +20 -0
  111. data/doc/classes/Bio/Graphics/Glyph/Line.src/M000044.html +20 -0
  112. data/doc/classes/Bio/Graphics/Glyph/LineWithHandles.html +139 -0
  113. data/doc/classes/Bio/Graphics/Glyph/LineWithHandles.src/M000014.html +28 -0
  114. data/doc/classes/Bio/Graphics/Glyph/LineWithHandles.src/M000016.html +28 -0
  115. data/doc/classes/Bio/Graphics/Glyph/LineWithHandles.src/M000046.html +28 -0
  116. data/doc/classes/Bio/Graphics/Glyph/Spliced.html +139 -0
  117. data/doc/classes/Bio/Graphics/Glyph/Spliced.src/M000010.html +19 -0
  118. data/doc/classes/Bio/Graphics/Glyph/Spliced.src/M000012.html +19 -0
  119. data/doc/classes/Bio/Graphics/Glyph/Spliced.src/M000042.html +19 -0
  120. data/doc/classes/Bio/Graphics/Glyph/Transcript.html +113 -0
  121. data/doc/classes/Bio/Graphics/Glyph/Triangle.html +139 -0
  122. data/doc/classes/Bio/Graphics/Glyph/Triangle.src/M000007.html +21 -0
  123. data/doc/classes/Bio/Graphics/Glyph/Triangle.src/M000008.html +21 -0
  124. data/doc/classes/Bio/Graphics/Glyph/Triangle.src/M000036.html +21 -0
  125. data/doc/classes/{ImageMap.html → Bio/Graphics/ImageMap.html} +50 -16
  126. data/doc/classes/{ImageMap.src/M000001.html → Bio/Graphics/ImageMap.src/M000030.html} +3 -3
  127. data/doc/classes/Bio/Graphics/ImageMap.src/M000031.html +18 -0
  128. data/doc/classes/Bio/Graphics/ImageMap.src/M000032.html +18 -0
  129. data/doc/classes/Bio/Graphics/ImageMap.src/M000033.html +18 -0
  130. data/doc/classes/{ImageMap.src/M000002.html → Bio/Graphics/ImageMap.src/M000034.html} +7 -4
  131. data/doc/classes/Bio/Graphics/ImageMap.src/M000035.html +24 -0
  132. data/doc/classes/Bio/Graphics/ImageMap.src/M000062.html +18 -0
  133. data/doc/classes/Bio/Graphics/ImageMap.src/M000063.html +18 -0
  134. data/doc/classes/Bio/Graphics/ImageMap.src/M000064.html +27 -0
  135. data/doc/classes/Bio/Graphics/ImageMap.src/M000065.html +24 -0
  136. data/doc/classes/{ImageMap/ImageMapElement.html → Bio/Graphics/ImageMap/Element.html} +14 -14
  137. data/doc/classes/{ImageMap/ImageMapElement.src/M000003.html → Bio/Graphics/ImageMap/Element.src/M000034.html} +3 -3
  138. data/doc/classes/{ImageMap/ImageMapElement.src/M000004.html → Bio/Graphics/ImageMap/Element.src/M000035.html} +6 -4
  139. data/doc/classes/Bio/Graphics/ImageMap/Element.src/M000036.html +19 -0
  140. data/doc/classes/Bio/Graphics/ImageMap/Element.src/M000037.html +22 -0
  141. data/doc/classes/Bio/Graphics/ImageMap/Element.src/M000066.html +19 -0
  142. data/doc/classes/Bio/Graphics/ImageMap/Element.src/M000067.html +22 -0
  143. data/doc/classes/Bio/Graphics/Panel.html +70 -69
  144. data/doc/classes/Bio/Graphics/Panel.src/M000025.html +52 -0
  145. data/doc/classes/Bio/Graphics/Panel.src/M000026.html +20 -0
  146. data/doc/classes/Bio/Graphics/Panel.src/M000027.html +98 -0
  147. data/doc/classes/Bio/Graphics/Panel.src/M000028.html +20 -0
  148. data/doc/classes/Bio/Graphics/Panel.src/M000029.html +52 -0
  149. data/doc/classes/Bio/Graphics/Panel.src/M000030.html +20 -0
  150. data/doc/classes/Bio/Graphics/Panel.src/M000031.html +98 -0
  151. data/doc/classes/Bio/Graphics/Panel.src/M000059.html +52 -0
  152. data/doc/classes/Bio/Graphics/Panel.src/M000060.html +20 -0
  153. data/doc/classes/Bio/Graphics/Panel.src/M000061.html +98 -0
  154. data/doc/classes/Bio/Graphics/{Panel/Ruler.html → Ruler.html} +50 -21
  155. data/doc/classes/Bio/Graphics/Ruler.src/M000015.html +30 -0
  156. data/doc/classes/Bio/Graphics/Ruler.src/M000016.html +20 -0
  157. data/doc/classes/Bio/Graphics/Ruler.src/M000017.html +30 -0
  158. data/doc/classes/Bio/Graphics/Ruler.src/M000018.html +20 -0
  159. data/doc/classes/Bio/Graphics/Ruler.src/M000019.html +26 -0
  160. data/doc/classes/Bio/Graphics/Ruler.src/M000020.html +45 -0
  161. data/doc/classes/Bio/Graphics/Ruler.src/M000047.html +30 -0
  162. data/doc/classes/Bio/Graphics/Ruler.src/M000048.html +20 -0
  163. data/doc/classes/Bio/Graphics/Ruler.src/M000049.html +26 -0
  164. data/doc/classes/Bio/Graphics/Ruler.src/M000050.html +45 -0
  165. data/doc/classes/Bio/Graphics/SubFeature.html +348 -0
  166. data/doc/classes/Bio/Graphics/SubFeature.src/M000001.html +73 -0
  167. data/doc/classes/Bio/Graphics/SubFeature.src/M000002.html +69 -0
  168. data/doc/classes/Bio/Graphics/SubFeature.src/M000023.html +73 -0
  169. data/doc/classes/Bio/Graphics/SubFeature.src/M000024.html +69 -0
  170. data/doc/classes/Bio/Graphics/SubFeature.src/M000027.html +73 -0
  171. data/doc/classes/Bio/Graphics/SubFeature.src/M000028.html +69 -0
  172. data/doc/classes/Bio/Graphics/SubFeature.src/M000057.html +73 -0
  173. data/doc/classes/Bio/Graphics/SubFeature.src/M000058.html +69 -0
  174. data/doc/classes/Bio/Graphics/{Panel/Track.html → Track.html} +67 -69
  175. data/doc/classes/Bio/Graphics/Track.src/M000017.html +39 -0
  176. data/doc/classes/Bio/Graphics/Track.src/M000018.html +37 -0
  177. data/doc/classes/Bio/Graphics/Track.src/M000019.html +45 -0
  178. data/doc/classes/Bio/Graphics/Track.src/M000020.html +41 -0
  179. data/doc/classes/Bio/Graphics/Track.src/M000021.html +39 -0
  180. data/doc/classes/Bio/Graphics/Track.src/M000022.html +37 -0
  181. data/doc/classes/Bio/Graphics/Track.src/M000023.html +45 -0
  182. data/doc/classes/Bio/Graphics/Track.src/M000051.html +39 -0
  183. data/doc/classes/Bio/Graphics/Track.src/M000052.html +37 -0
  184. data/doc/classes/Bio/Graphics/Track.src/M000053.html +45 -0
  185. data/doc/classes/Range.html +129 -0
  186. data/doc/classes/String.html +167 -0
  187. data/doc/classes/String.src/M000001.html +18 -0
  188. data/doc/classes/String.src/M000002.html +18 -0
  189. data/doc/classes/String.src/M000003.html +23 -0
  190. data/doc/classes/String.src/M000029.html +18 -0
  191. data/doc/classes/String.src/M000030.html +18 -0
  192. data/doc/classes/String.src/M000031.html +23 -0
  193. data/doc/classes/TestCustomGlyph.html +137 -0
  194. data/doc/classes/TestCustomGlyph.src/M000025.html +25 -0
  195. data/doc/classes/TestCustomGlyphInFile.html +167 -0
  196. data/doc/classes/TestCustomGlyphInFile.src/M000026.html +19 -0
  197. data/doc/classes/TestCustomGlyphInFile.src/M000027.html +25 -0
  198. data/doc/classes/TestCustomGlyphInFile.src/M000028.html +18 -0
  199. data/doc/classes/TestExtensions.html +152 -0
  200. data/doc/classes/TestExtensions.src/M000015.html +22 -0
  201. data/doc/classes/TestExtensions.src/M000016.html +25 -0
  202. data/doc/classes/TestFeature.html +152 -0
  203. data/doc/classes/TestFeature.src/M000017.html +19 -0
  204. data/doc/classes/TestFeature.src/M000018.html +21 -0
  205. data/doc/classes/TestImageMap.html +182 -0
  206. data/doc/classes/TestImageMap.src/M000019.html +22 -0
  207. data/doc/classes/TestImageMap.src/M000020.html +56 -0
  208. data/doc/classes/TestImageMap.src/M000021.html +56 -0
  209. data/doc/classes/TestImageMap.src/M000022.html +20 -0
  210. data/doc/classes/TestPanel.html +276 -0
  211. data/doc/classes/TestPanel.src/M000001.html +18 -0
  212. data/doc/classes/TestPanel.src/M000002.html +61 -0
  213. data/doc/classes/TestPanel.src/M000003.html +35 -0
  214. data/doc/classes/TestPanel.src/M000004.html +54 -0
  215. data/doc/classes/TestPanel.src/M000005.html +54 -0
  216. data/doc/classes/TestPanel.src/M000006.html +41 -0
  217. data/doc/classes/TestPanel.src/M000007.html +36 -0
  218. data/doc/classes/TestPanel.src/M000008.html +20 -0
  219. data/doc/classes/TestPanel.src/M000009.html +26 -0
  220. data/doc/classes/TestPanel.src/M000010.html +21 -0
  221. data/doc/classes/TestRuler.html +152 -0
  222. data/doc/classes/TestRuler.src/M000013.html +22 -0
  223. data/doc/classes/TestRuler.src/M000014.html +31 -0
  224. data/doc/classes/TestSubFeature.html +152 -0
  225. data/doc/classes/TestSubFeature.src/M000023.html +21 -0
  226. data/doc/classes/TestSubFeature.src/M000024.html +18 -0
  227. data/doc/classes/TestTrack.html +152 -0
  228. data/doc/classes/TestTrack.src/M000011.html +19 -0
  229. data/doc/classes/TestTrack.src/M000012.html +23 -0
  230. data/doc/created.rid +1 -1
  231. data/doc/files/README_DEV.html +399 -70
  232. data/doc/files/TUTORIAL.html +188 -67
  233. data/doc/files/lib/bio-graphics_rb.html +3 -2
  234. data/doc/files/lib/bio/graphics/feature_rb.html +12 -6
  235. data/doc/files/lib/bio/graphics/glyphs/box_rb.html +113 -0
  236. data/doc/files/lib/bio/graphics/glyphs/common_rb.html +113 -0
  237. data/doc/files/lib/bio/graphics/glyphs/directed_box_rb.html +113 -0
  238. data/doc/files/lib/bio/graphics/glyphs/directed_generic_rb.html +113 -0
  239. data/doc/files/lib/bio/graphics/glyphs/directed_spliced_rb.html +113 -0
  240. data/doc/files/lib/bio/graphics/glyphs/dot_rb.html +113 -0
  241. data/doc/files/lib/bio/graphics/glyphs/generic_rb.html +113 -0
  242. data/doc/files/lib/bio/graphics/glyphs/line_rb.html +113 -0
  243. data/doc/files/lib/bio/graphics/glyphs/line_with_handles_rb.html +113 -0
  244. data/doc/files/lib/bio/graphics/glyphs/spliced_rb.html +113 -0
  245. data/doc/files/lib/bio/graphics/glyphs/transcript_rb.html +113 -0
  246. data/doc/files/lib/bio/graphics/glyphs/triangle_rb.html +113 -0
  247. data/doc/files/lib/bio/graphics/image_map_rb.html +3 -2
  248. data/doc/files/lib/bio/graphics/panel_rb.html +10 -2
  249. data/doc/files/lib/bio/graphics/ruler_rb.html +3 -2
  250. data/doc/files/lib/bio/graphics/subfeature_rb.html +114 -0
  251. data/doc/files/lib/bio/graphics/track_rb.html +3 -2
  252. data/doc/files/lib/feature_rb.html +101 -0
  253. data/doc/files/samples/arkdb_features_rb.html +101 -0
  254. data/doc/files/samples/glyph_showcase_rb.html +108 -0
  255. data/doc/files/samples/protein_domains_rb.html +115 -0
  256. data/doc/files/samples/subfeatures_rb.html +108 -0
  257. data/doc/files/scripts/gff2png_rb.html +154 -0
  258. data/doc/files/test/unit/custom_glyph_in_file_rb.html +101 -0
  259. data/doc/files/test/unit/test_class_extensions_rb.html +108 -0
  260. data/doc/files/test/unit/test_creation_rb.html +108 -0
  261. data/doc/files/test/unit/test_custom_glyph_rb.html +108 -0
  262. data/doc/files/test/unit/test_draw_rb.html +108 -0
  263. data/doc/files/test/unit/test_imagemap_rb.html +108 -0
  264. data/doc/files/test/unit/test_subfeatures_rb.html +108 -0
  265. data/doc/fr_class_index.html +24 -6
  266. data/doc/fr_file_index.html +14 -0
  267. data/doc/fr_method_index.html +51 -19
  268. data/doc/images/glyph_showcase.png +0 -0
  269. data/doc/images/terms.svg +146 -132
  270. data/images/glyph_showcase.png +0 -0
  271. data/lib/bio-graphics.rb +38 -6
  272. data/lib/bio/graphics/feature.rb +212 -440
  273. data/lib/bio/graphics/glyphs/box.rb +21 -0
  274. data/lib/bio/graphics/glyphs/common.rb +149 -0
  275. data/lib/bio/graphics/glyphs/directed_box.rb +28 -0
  276. data/lib/bio/graphics/glyphs/directed_generic.rb +23 -0
  277. data/lib/bio/graphics/glyphs/directed_spliced.rb +39 -0
  278. data/lib/bio/graphics/glyphs/dot.rb +21 -0
  279. data/lib/bio/graphics/glyphs/generic.rb +15 -0
  280. data/lib/bio/graphics/glyphs/line.rb +17 -0
  281. data/lib/bio/graphics/glyphs/line_with_handles.rb +25 -0
  282. data/lib/bio/graphics/glyphs/spliced.rb +16 -0
  283. data/lib/bio/graphics/glyphs/transcript.rb +12 -0
  284. data/lib/bio/graphics/glyphs/triangle.rb +18 -0
  285. data/lib/bio/graphics/image_map.rb +25 -4
  286. data/lib/bio/graphics/panel.rb +266 -209
  287. data/lib/bio/graphics/ruler.rb +95 -96
  288. data/lib/bio/graphics/subfeature.rb +187 -0
  289. data/lib/bio/graphics/track.rb +155 -156
  290. data/lib/feature.rb +204 -0
  291. data/samples/arkdb_features.rb +10 -8
  292. data/samples/glyph_showcase.rb +58 -22
  293. data/samples/protein_domains.rb +19 -0
  294. data/samples/subfeatures.rb +31 -0
  295. data/test/unit/custom_glyph_in_file.rb +12 -0
  296. data/test/unit/data.txt +32 -0
  297. data/test/unit/test_class_extensions.rb +23 -0
  298. data/test/unit/test_creation.rb +43 -13
  299. data/test/unit/test_custom_glyph.rb +50 -0
  300. data/test/unit/test_draw.rb +211 -0
  301. data/test/unit/test_imagemap.rb +134 -0
  302. data/test/unit/test_subfeatures.rb +17 -0
  303. metadata +396 -119
  304. data/doc/classes/Bio/Graphics/Panel.src/M000005.html +0 -29
  305. data/doc/classes/Bio/Graphics/Panel.src/M000006.html +0 -19
  306. data/doc/classes/Bio/Graphics/Panel.src/M000007.html +0 -68
  307. data/doc/classes/Bio/Graphics/Panel/Ruler.src/M000008.html +0 -20
  308. data/doc/classes/Bio/Graphics/Panel/Ruler.src/M000009.html +0 -28
  309. data/doc/classes/Bio/Graphics/Panel/Ruler.src/M000010.html +0 -54
  310. data/doc/classes/Bio/Graphics/Panel/Ruler.src/M000013.html +0 -20
  311. data/doc/classes/Bio/Graphics/Panel/Ruler.src/M000014.html +0 -20
  312. data/doc/classes/Bio/Graphics/Panel/Ruler.src/M000015.html +0 -28
  313. data/doc/classes/Bio/Graphics/Panel/Ruler.src/M000016.html +0 -59
  314. data/doc/classes/Bio/Graphics/Panel/Ruler.src/M000017.html +0 -20
  315. data/doc/classes/Bio/Graphics/Panel/Ruler.src/M000018.html +0 -28
  316. data/doc/classes/Bio/Graphics/Panel/Ruler.src/M000019.html +0 -59
  317. data/doc/classes/Bio/Graphics/Panel/Track.src/M000008.html +0 -26
  318. data/doc/classes/Bio/Graphics/Panel/Track.src/M000009.html +0 -42
  319. data/doc/classes/Bio/Graphics/Panel/Track.src/M000010.html +0 -52
  320. data/doc/classes/Bio/Graphics/Panel/Track.src/M000011.html +0 -23
  321. data/doc/classes/Bio/Graphics/Panel/Track.src/M000012.html +0 -43
  322. data/doc/classes/Bio/Graphics/Panel/Track.src/M000013.html +0 -259
  323. data/doc/classes/Bio/Graphics/Panel/Track/Feature.src/M000011.html +0 -65
  324. data/doc/classes/Bio/Graphics/Panel/Track/Feature.src/M000012.html +0 -39
  325. data/doc/classes/Bio/Graphics/Panel/Track/Feature.src/M000013.html +0 -27
  326. data/doc/classes/Bio/Graphics/Panel/Track/Feature.src/M000014.html +0 -225
  327. data/doc/classes/Bio/Graphics/Panel/Track/Feature.src/M000015.html +0 -48
  328. data/doc/classes/Bio/Graphics/Panel/Track/Feature/PixelRange.src/M000012.html +0 -18
  329. data/doc/classes/Bio/Graphics/Panel/Track/Feature/PixelRange.src/M000013.html +0 -18
  330. data/doc/classes/Bio/Graphics/Panel/Track/Feature/PixelRange.src/M000015.html +0 -18
  331. data/doc/classes/Bio/Graphics/Panel/Track/Feature/PixelRange.src/M000016.html +0 -18
@@ -1,96 +1,95 @@
1
- #
2
- # = bio/graphics/ruler - ruler class
3
- #
4
- # Copyright:: Copyright (C) 2007
5
- # Jan Aerts <jan.aerts@bbsrc.ac.uk>
6
- # License:: The Ruby License
7
- #
8
- module Bio
9
- module Graphics
10
- class Panel
11
- # The Bio::Graphics::Ruler class describes the ruler to be drawn on the
12
- # graph. This is created automatically when creating the picture by using
13
- # Bio::Graphics::Panel.to_svg. See BioExt::Graphics documentation for
14
- # explanation of interplay between different classes.
15
- #--
16
- # TODO: the ruler might be implemented as a special case of a track, so
17
- # it would inherit from it (class Ruler < Bio::Graphics::Panel::Track).
18
- # But I haven't really thought this through yet.
19
- #++
20
- class Ruler
21
- # Creates a new Bio::Graphics::Panel::Ruler object.
22
- # ---
23
- # *Arguments*:
24
- # * _panel_ (required) :: Bio::Graphics::Panel object that this ruler
25
- # belongs to
26
- # * _colour_ :: colour of the ruler. Default = 'black'
27
- # *Returns*:: Bio::Graphics::Ruler object
28
- def initialize(panel, colour = [0,0,0])
29
- @panel = panel
30
- @name = 'ruler'
31
- @colour = colour
32
- end
33
- attr_accessor :panel, :name, :colour, :height, :minor_tick_distance, :major_tick_distance
34
-
35
- def calculate_tick_distance
36
- min_tick_distance_requirement_met = false
37
- self.minor_tick_distance = 1 # in basepairs.
38
- while ! min_tick_distance_requirement_met
39
- if self.minor_tick_distance/panel.rescale_factor >= RULER_MIN_DISTANCE_TICKS_PIXEL
40
- min_tick_distance_requirement_met = true
41
- else
42
- self.minor_tick_distance = self.minor_tick_distance*5
43
- end
44
- end
45
-
46
- self.major_tick_distance = self.minor_tick_distance * 10
47
- end
48
-
49
- def draw(panel_drawing, vertical_offset)
50
- ruler_drawing = Cairo::Context.new(panel_drawing)
51
-
52
- self.calculate_tick_distance
53
-
54
- # Draw line
55
- ruler_drawing.move_to(0,10)
56
- ruler_drawing.line_to(panel.width, 10)
57
- ruler_drawing.stroke
58
-
59
- # Draw ticks
60
- # * Find position of first tick.
61
- # Most of the time, we don't want the first tick on the very first
62
- # basepair of the view. Suppose that would be position 333 in the
63
- # sequence. Then the numbers under the major tickmarks would be:
64
- # 343, 353, 363, 373 and so on. Instead, we want 350, 360, 370, 380.
65
- # So we want to find the position of the first tick.
66
- first_tick_position = panel.display_start
67
- while first_tick_position.modulo(minor_tick_distance) != 0
68
- first_tick_position += 1
69
- end
70
-
71
- # * And start drawing the rest.
72
- first_tick_position.step(panel.display_stop, minor_tick_distance) do |tick|
73
- tick_pixel_position = (tick - panel.display_start) / panel.rescale_factor
74
- ruler_drawing.move_to(tick_pixel_position.floor, 5)
75
- if tick.modulo(major_tick_distance) == 0
76
- ruler_drawing.rel_line_to(0, 15)
77
-
78
- # Draw tick number
79
- ruler_drawing.select_font_face(*(FONT))
80
- ruler_drawing.set_font_size(RULER_TEXT_HEIGHT)
81
- ruler_drawing.move_to(tick_pixel_position.floor, 20 + RULER_TEXT_HEIGHT)
82
- ruler_drawing.show_text(tick.to_i.to_s)
83
- else
84
- ruler_drawing.rel_line_to(0, 5)
85
-
86
- end
87
- ruler_drawing.stroke
88
- end
89
-
90
-
91
- @height = 25 + RULER_TEXT_HEIGHT
92
- end
93
- end #Ruler
94
- end #Panel
95
- end #Graphics
96
- end #Bio
1
+ #
2
+ # = bio/graphics/ruler - ruler class
3
+ #
4
+ # Copyright:: Copyright (C) 2007
5
+ # Jan Aerts <jan.aerts@bbsrc.ac.uk>
6
+ # Charles Comstock <dgtized@gmail.com>
7
+ # License:: The Ruby License
8
+ #
9
+
10
+ # The Bio::Graphics::Ruler class describes the ruler to be drawn on the
11
+ # graph. This is created automatically when creating the picture by using
12
+ # Bio::Graphics::Panel.to_svg. See BioExt::Graphics documentation for
13
+ # explanation of interplay between different classes.
14
+ #--
15
+ # TODO: the ruler might be implemented as a special case of a track, so
16
+ # it would inherit from it (class Ruler < Bio::Graphics::Track).
17
+ # But I haven't really thought this through yet.
18
+ #++
19
+ class Bio::Graphics::Ruler
20
+ # Creates a new Bio::Graphics::Ruler object.
21
+ # ---
22
+ # *Arguments*:
23
+ # * _panel_ (required) :: Bio::Graphics::Panel object that this ruler
24
+ # belongs to
25
+ # * _colour_ :: colour of the ruler. Default = 'black'
26
+ # *Returns*:: Bio::Graphics::Ruler object
27
+ def initialize(panel, colour = [0,0,0])
28
+ @panel = panel
29
+ @name = 'ruler'
30
+ @colour = colour
31
+
32
+ # Number of pixels between each tick, used to calculate tick spacing
33
+ @min_pixels_per_tick = 5
34
+ # The base height of minor ticks in pixels
35
+ @tick_height = 5
36
+ # The height of the text in pixels
37
+ @tick_text_height = 10
38
+
39
+ @minor_tick_distance = @min_pixels_per_tick ** self.scaling_factor
40
+ @major_tick_distance = @minor_tick_distance * 10
41
+ end
42
+ attr_accessor(:panel, :name, :colour, :height,
43
+ :minor_tick_distance, :major_tick_distance,
44
+ :min_pixels_per_tick, :tick_height, :tick_text_height)
45
+
46
+ def scaling_factor(min_pixels_per_tick = @min_pixels_per_tick,
47
+ rescale_factor = @panel.rescale_factor)
48
+ (Math.log(min_pixels_per_tick * rescale_factor) /
49
+ Math.log(min_pixels_per_tick)).ceil
50
+ end
51
+
52
+ def first_tick_position(start = @panel.display_start,
53
+ minor_tick = @minor_tick_distance)
54
+ # * Find position of first tick.
55
+ # Most of the time, we don't want the first tick on the very first
56
+ # basepair of the view. Suppose that would be position 333 in the
57
+ # sequence. Then the numbers under the major tickmarks would be:
58
+ # 343, 353, 363, 373 and so on. Instead, we want 350, 360, 370, 380.
59
+ # So we want to find the position of the first tick.
60
+ modulo_from_tick = (start % minor_tick)
61
+ start + (modulo_from_tick > 0 ? (minor_tick - modulo_from_tick + 1) : 0)
62
+ end
63
+
64
+ def draw(panel_drawing)
65
+ ruler_drawing = Cairo::Context.new(panel_drawing)
66
+
67
+ # Draw line
68
+ ruler_drawing.move_to(0,10)
69
+ ruler_drawing.line_to(panel.width, 10)
70
+ ruler_drawing.stroke
71
+
72
+ # Draw ticks
73
+ # * And start drawing the rest.
74
+ first_tick_position.step(@panel.display_stop, @minor_tick_distance) do |tick|
75
+ tick_pixel_position = (tick - panel.display_start) / @panel.rescale_factor
76
+ ruler_drawing.move_to(tick_pixel_position.floor, @min_pixels_per_tick)
77
+ if tick.modulo(@major_tick_distance) == 0
78
+ ruler_drawing.rel_line_to(0, 3*@tick_height)
79
+
80
+ # Draw tick number
81
+ ruler_drawing.select_font_face(*Bio::Graphics::FONT)
82
+ ruler_drawing.set_font_size(@tick_text_height)
83
+ ruler_drawing.move_to(tick_pixel_position.floor, 4*@tick_height + @tick_text_height)
84
+ ruler_drawing.show_text(tick.to_i.to_s)
85
+ else
86
+ ruler_drawing.rel_line_to(0, @tick_height)
87
+
88
+ end
89
+ ruler_drawing.stroke
90
+ end
91
+
92
+ @height = 5*@tick_height + @tick_text_height
93
+ end
94
+ end
95
+
@@ -0,0 +1,187 @@
1
+ #
2
+ # = bio/graphics/subfeature.rb - subfeature class
3
+ #
4
+ # Copyright:: Copyright (C) 2007, 2008
5
+ # Jan Aerts <jan.aerts@bbsrc.ac.uk>
6
+ # Charles Comstock <dgtized@gmail.com>
7
+ # License:: The Ruby License
8
+ #
9
+
10
+ # TODO: Documentation for SubFeature
11
+ class Bio::Graphics::SubFeature
12
+ # !!Not to be used directly.
13
+ # ---
14
+ # *Arguments*:
15
+ # * _feature_ (required) :: Bio::Graphics::Feature
16
+ # object that this subfeature belongs to
17
+ # * _feature_ _object_ (required) :: A Bio::Feature object (see bioruby)
18
+ # * :glyph :: Glyph to use. Default = glyph of the track
19
+ # * :colour :: Colour. Default = colour of the track
20
+ # *Returns*:: Bio::Graphics::SubFeature object
21
+ def initialize(feature, feature_object, opts = {})
22
+ @feature = feature
23
+ @feature_object = feature_object
24
+ opts = {
25
+ :glyph => @feature.glyph,
26
+ :colour => @feature.colour
27
+ }.merge(opts)
28
+
29
+ @glyph = opts[:glyph]
30
+ @colour = opts[:colour]
31
+
32
+ @locations = @feature_object.locations
33
+
34
+ @start = @locations.collect{|l| l.from}.min.to_i
35
+ @stop = @locations.collect{|l| l.to}.max.to_i
36
+ @strand = @locations[0].strand.to_i
37
+ @pixel_range_collection = Array.new
38
+ @chopped_at_start = false
39
+ @chopped_at_stop = false
40
+ @hidden_subfeatures_at_start = false
41
+ @hidden_subfeatures_at_stop = false
42
+
43
+ # Get all pixel ranges for the subfeatures
44
+ @locations.each do |l|
45
+ # xxxxxx [ ]
46
+ if l.to < @feature.track.panel.display_start
47
+ @hidden_subfeatures_at_start = true
48
+ next
49
+ # [ ] xxxxx
50
+ elsif l.from > @feature.track.panel.display_stop
51
+ @hidden_subfeatures_at_stop = true
52
+ next
53
+ # xxxx[xxx ]
54
+ elsif l.from < @feature.track.panel.display_start and l.to > @feature.track.panel.display_start
55
+ start_pixel = 1
56
+ stop_pixel = ( l.to - @feature.track.panel.display_start ).to_f / @feature.track.panel.rescale_factor
57
+ @chopped_at_start = true
58
+ # [ xxxx]xxxx
59
+ elsif l.from < @feature.track.panel.display_stop and l.to > @feature.track.panel.display_stop
60
+ start_pixel = ( l.from - @feature.track.panel.display_start ).to_f / @feature.track.panel.rescale_factor
61
+ stop_pixel = @feature.track.panel.width
62
+ @chopped_at_stop = true
63
+ # xxxx[xxxxxxxxxx]xxxx
64
+ elsif l.from < @feature.track.panel.display_start and l.to > @feature.track.panel.display_stop
65
+ start_pixel = 1
66
+ stop_pixel = @feature.track.panel.width
67
+ @chopped_at_start = true
68
+ @chopped_at_stop = true
69
+ # [ xxxxx ]
70
+ else
71
+ start_pixel = ( l.from - @feature.track.panel.display_start ).to_f / @feature.track.panel.rescale_factor
72
+ stop_pixel = ( l.to - @feature.track.panel.display_start ).to_f / @feature.track.panel.rescale_factor
73
+ end
74
+
75
+ @pixel_range_collection.push(Range.new(start_pixel, stop_pixel))
76
+
77
+ end
78
+ end
79
+
80
+ # The bioruby Bio::Feature object
81
+ attr_accessor :feature_object
82
+
83
+ # The feature that this subfeature belongs to
84
+ attr_accessor :feature
85
+
86
+ # The label of the feature
87
+ attr_accessor :label
88
+ alias :name :label
89
+
90
+ # The locations of the feature (which is a Bio::Locations object)
91
+ attr_accessor :locations
92
+ alias :location :locations
93
+
94
+ # The start position of the feature (in bp)
95
+ attr_accessor :start
96
+
97
+ # The stop position of the feature (in bp)
98
+ attr_accessor :stop
99
+
100
+ # The strand of the feature
101
+ attr_accessor :strand
102
+
103
+ # The glyph to use to draw this (sub)feature
104
+ attr_accessor :glyph
105
+
106
+ # The colour to use to draw this (sub)feature
107
+ attr_accessor :colour
108
+
109
+ # The array keeping the pixel ranges for the sub-features. Unspliced
110
+ # features will just have one element, while spliced features will
111
+ # have more than one.
112
+ attr_accessor :pixel_range_collection
113
+
114
+ # Is the first subfeature incomplete?
115
+ attr_accessor :chopped_at_start
116
+
117
+ # Is the last subfeature incomplete?
118
+ attr_accessor :chopped_at_stop
119
+
120
+ # Are there subfeatures out of view at the left side of the picture?
121
+ attr_accessor :hidden_subfeatures_at_start
122
+
123
+ # Are there subfeatures out of view at the right side of the picture?
124
+ attr_accessor :hidden_subfeatures_at_stop
125
+
126
+ # Adds the subfeature to the track cairo context. This method should not
127
+ # be used directly by the user, but is called by
128
+ # Bio::Graphics::Feature::SubFeature.draw
129
+ # ---
130
+ # *Arguments*:
131
+ # * _track_drawing_ (required) :: the track cairo object
132
+ # *Returns*:: FIXME: I don't know
133
+ def draw(feature_context)
134
+ # Set the glyph to be used. The glyph can be set as a symbol (e.g. :generic)
135
+ # or as a hash (e.g. {'utr' => :line, 'cds' => :directed_spliced}).
136
+ if @feature.glyph.class == Hash
137
+ @glyph = @feature.glyph[@feature_object.feature]
138
+ else
139
+ @glyph = @feature.glyph
140
+ end
141
+
142
+ # We have to check if we want to change the glyph type from directed to
143
+ # undirected
144
+ # There are 2 cases where we don't want to draw arrows on
145
+ # features:
146
+ # (a) when the picture is really zoomed out, features are
147
+ # so small that the arrow itself is too big
148
+ # (b) if a directed feature on the fw strand extends beyond
149
+ # the end of the picture, the arrow is out of view. This
150
+ # is the same as considering the feature as undirected.
151
+ # The same obviously goes for features on the reverse
152
+ # strand that extend beyond the left side of the image.
153
+ #
154
+ # (a) Zoomed out
155
+ replace_directed_with_undirected = false
156
+ if (@stop - @start).to_f/@feature.track.panel.rescale_factor.to_f < 2
157
+ replace_directed_with_undirected = true
158
+ end
159
+ # (b) Extending beyond borders picture
160
+ if ( @chopped_at_stop and @strand = 1 ) or ( @chopped_at_start and @strand = -1 )
161
+ replace_directed_with_undirected = true
162
+ end
163
+
164
+ local_feature_glyph = nil
165
+ if @glyph == :directed_generic and replace_directed_with_undirected
166
+ local_feature_glyph = :generic
167
+ elsif @glyph == :directed_spliced and replace_directed_with_undirected
168
+ local_feature_glyph = :spliced
169
+ elsif @glyph == :directed_box and replace_directed_with_undirected
170
+ local_feature_glyph = :box
171
+ else
172
+ local_feature_glyph = @glyph
173
+ end
174
+
175
+ # And draw the thing.
176
+
177
+ feature_context.set_source_rgb(@colour)
178
+
179
+ glyph = ("Bio::Graphics::Glyph::" + local_feature_glyph.to_s.camel_case).to_class.new(self, feature_context)
180
+ glyph.draw
181
+
182
+ @feature.left_pixel_of_subfeatures.push(glyph.left_pixel)
183
+ @feature.right_pixel_of_subfeatures.push(glyph.right_pixel)
184
+
185
+
186
+ end
187
+ end #SubFeature
@@ -1,156 +1,155 @@
1
- #
2
- # = bio/graphics/track - track class
3
- #
4
- # Copyright:: Copyright (C) 2007
5
- # Jan Aerts <jan.aerts@bbsrc.ac.uk>
6
- # License:: The Ruby License
7
- #
8
- module Bio
9
- module Graphics
10
- class Panel
11
- # The Bio::Graphics::Track class describes the container for features of
12
- # the same type. See Bio::Graphics documentation for explanation of
13
- # interplay between different classes.
14
- class Track
15
- # !!Not to be used directly. Use Bio::Graphics::Panel.add_track instead!!
16
- # A track can not exist except within the confines of a
17
- # Bio::Graphics::Panel object.
18
- #
19
- #--
20
- # This is necessary because the track needs to know the rescale_factor
21
- # and width of the picture, both of which are defined within the panel.
22
- #++
23
- #
24
- # ---
25
- # *Arguments*:
26
- # * _panel_ (required) :: Bio::Graphics::Panel object that this track
27
- # belongs to
28
- # * _name_ (required) :: Name of the track to be displayed (e.g. 'genes')
29
- # * _label_ :: Boolean: should the label for each feature be drawn or not
30
- # * _colour_ :: Colour to be used to draw the features within the track.
31
- # Default = 'blue'
32
- # * _glyph_ :: Glyph to use for drawing the features. Options are:
33
- # :generic, :directed_generic, :spliced, :directed_spliced, :line and
34
- # :triangle. Triangles can be used
35
- # for features whose start and stop positions are the same (e.g. SNPs).
36
- # If you try to draw a feature that is longer with triangles, an error
37
- # will be shown.
38
- # *Returns*:: Bio::Graphics::Track object
39
- def initialize(panel, name, label = true, colour = [0,0,1], glyph = :generic)
40
- @panel = panel
41
- @name = name
42
- @show_label = label
43
- @colour = colour
44
- @glyph = glyph
45
- @features = Array.new
46
- @number_of_feature_rows = 0
47
- @vertical_offset = 0
48
- @grid = Hash.new
49
- end
50
- attr_accessor :panel, :name, :show_label, :colour, :glyph, :features, :number_of_feature_rows, :height, :vertical_offset, :grid
51
-
52
- # Adds a Bio::Graphics::Panel::Track::Feature to this track. A track contains
53
- # features of the same type, e.g. (for sequence annotation:) genes,
54
- # polymorphisms, ESTs, etc.
55
- #
56
- # est_track.add_feature('EST1','50..60')
57
- # est_track.add_feature('EST2','52..73')
58
- # est_track.add_feature('EST3','41..69')
59
- # gene_track.add_feature('gene2','39..73')
60
- #
61
- # For spliced features:
62
- # est_track.add_feature('EST4','join(34..53,153..191)')
63
- #
64
- # Or on the complement strand:
65
- # est_track.add_feature('EST5','complement(join(34..53,153..191))')
66
- #
67
- # See the documentation in Bio::Locations for a full description of
68
- # how locations can be defined.
69
- #
70
- # Features are only added if they are at least partly in the displayed
71
- # region. If a feature is completely outside of the region, it's not
72
- # added. If it should be only partly visible, it is added completely.
73
- #
74
- # ---
75
- # *Arguments*:
76
- # * _name_ (required) :: Name of the feature
77
- # * _location_ :: String. Default: whole of panel, forward strand.
78
- # * _link_ :: URL to link to for this glyph
79
- # *Returns*:: Bio::Graphics::Track::Feature object that was created or nil
80
- def add_feature(name, location_string = '1..' + @panel.length.to_s, link = nil)
81
- if link == ''
82
- link = nil
83
- end
84
-
85
- # Calculate the ultimate start and stop of the feature: the start
86
- # of the first subfeature (e.g. exon) and the stop of the last one.
87
- # The only reason we want to know these positions, is because we want
88
- # to determine if the feature falls within the view of the image or
89
- # not (see below).
90
- location_object = Bio::Locations.new(location_string)
91
- start = location_object.collect{|l| l.from}.min.to_i
92
- stop = location_object.collect{|l| l.to}.max.to_i
93
-
94
- # If the feature wouldn't show because it's not in the region we're
95
- # looking at, don't bother storing the stuff. I think this makes huge
96
- # speed and memory differences if you've got a chromosome with
97
- # thousands of features.
98
- if stop <= self.panel.display_start or start >= self.panel.display_stop
99
- return nil
100
- else #elsif start >= panel.display_start and stop <= panel.display_stop
101
- @features.push(Bio::Graphics::Panel::Track::Feature.new(self, name, location_object, link))
102
- return @features[-1]
103
- end
104
-
105
- return self
106
- end
107
-
108
-
109
- # Adds the track to a cairo drawing. This method should not be used
110
- # directly by the user, but is called by Bio::Graphics::Panel.draw
111
- # ---
112
- # *Arguments*:
113
- # * _paneldrawing_ (required) :: the panel cairo object
114
- # *Returns*:: FIXME: I don't know
115
- def draw(panel_drawing)
116
- track_drawing = Cairo::Context.new(panel_drawing)
117
-
118
- # Draw thin line above title
119
- track_drawing.set_source_rgb(0.75,0.75,0.75)
120
- track_drawing.move_to(0, self.vertical_offset)
121
- track_drawing.line_to(self.panel.width, self.vertical_offset)
122
- track_drawing.stroke
123
-
124
- # Draw track title
125
- track_drawing.set_source_rgb(0,0,0)
126
- # track_drawing.select_font_face('Georgia',1,1)
127
- track_drawing.select_font_face(*(FONT))
128
- track_drawing.set_font_size(TRACK_HEADER_HEIGHT)
129
- track_drawing.move_to(0,TRACK_HEADER_HEIGHT + self.vertical_offset + 10)
130
- track_drawing.show_text(self.name)
131
-
132
- # Draw the features
133
- track_drawing.save do
134
- track_drawing.translate(0, self.vertical_offset + TRACK_HEADER_HEIGHT)
135
- track_drawing.set_source_rgb(@colour)
136
-
137
- @features.sort_by{|f| f.start}.each do |feature|
138
- # Don't even bother if the feature is not in the view
139
- if feature.stop <= self.panel.display_start or feature.start >= self.panel.display_stop
140
- next
141
- else
142
- feature.draw(track_drawing)
143
- end
144
- end
145
-
146
- end
147
-
148
- @number_of_feature_rows = ( @grid.keys.length == 0 ) ? 1 : @grid.keys.max + 1
149
-
150
- return panel_drawing
151
- end
152
-
153
- end #Track
154
- end #Panel
155
- end #Graphics
156
- end #Bio
1
+ #
2
+ # = bio/graphics/track - track class
3
+ #
4
+ # Copyright:: Copyright (C) 2007, 2008
5
+ # Jan Aerts <jan.aerts@bbsrc.ac.uk>
6
+ # Charles Comstock <dgtized@gmail.com>
7
+ # License:: The Ruby License
8
+ #
9
+
10
+ # The Bio::Graphics::Track class describes the container for features of
11
+ # the same type. See Bio::Graphics documentation for explanation of
12
+ # interplay between different classes.
13
+ class Bio::Graphics::Track
14
+ # !!Not to be used directly. Use Bio::Graphics::Panel.add_track instead!!
15
+ # A track can not exist except within the confines of a
16
+ # Bio::Graphics::Panel object.
17
+ #
18
+ #--
19
+ # This is necessary because the track needs to know the rescale_factor
20
+ # and width of the picture, both of which are defined within the panel.
21
+ #++
22
+ #
23
+ # ---
24
+ # *Arguments*:
25
+ # * _panel_ (required) :: Bio::Graphics::Panel object that this track
26
+ # belongs to
27
+ # * _name_ (required) :: Name of the track to be displayed (e.g. 'genes')
28
+ # * _:label_ :: Boolean: should the label for each feature be drawn or not
29
+ # Default = true
30
+ # * _:glyph_ :: Glyph to use for drawing the features. Options are:
31
+ # :generic, :directed_generic, :box, directed_box, :spliced,
32
+ # :directed_spliced, :dot, :triangle, :line and :line_with_handles.
33
+ # Default = :generic
34
+ # * _colour_ :: Colour to be used to draw the features within the track (in
35
+ # RGB) Default = [0,0,1] (i.e. blue)
36
+ # *Returns*:: Bio::Graphics::Track object
37
+ def initialize(panel, name, opts = {})
38
+ @panel = panel
39
+ @name = name
40
+ opts = {
41
+ :label => true,
42
+ :glyph => :generic,
43
+ :colour => [0,0,1]
44
+ }.merge(opts)
45
+
46
+ @show_label = opts[:label]
47
+ @glyph = opts[:glyph]
48
+ @colour = opts[:colour]
49
+
50
+ # As far as I know, I can't do this in the glyph file for transcript, so we
51
+ # have to do it here instead.
52
+ if @glyph == :transcript
53
+ @glyph = { 'utr5' => :box, 'utr3' => :directed_box, 'cds' => :spliced }
54
+ end
55
+
56
+ @features = Array.new
57
+ @number_of_feature_rows = 0
58
+ @vertical_offset = 0
59
+ @grid = Hash.new
60
+ end
61
+ attr_accessor :panel, :name, :show_label, :colour, :glyph, :features, :number_of_feature_rows, :height, :vertical_offset, :grid
62
+
63
+ # Takes a Bio::Feature and adds it as a Bio::Graphics::Feature to this track.
64
+ # A track contains features of the same type, e.g. (for sequence annotation:)
65
+ # genes, polymorphisms, ESTs, etc.
66
+ #
67
+ # est_track.add_feature(Bio::Feature.new('EST1','50..60'))
68
+ # est_track.add_feature(Bio::Feature.new('EST2','52..73'))
69
+ # est_track.add_feature(Bio::Feature.new('EST3','41..69'))
70
+ # gene_track.add_feature(Bio::Feature.new('gene2','39..73'))
71
+ #
72
+ # For spliced features:
73
+ # est_track.add_feature('EST4','join(34..53,153..191)')
74
+ #
75
+ # Or on the complement strand:
76
+ # est_track.add_feature('EST5','complement(join(34..53,153..191))')
77
+ #
78
+ # See the documentation in Bio::Locations for a full description of
79
+ # how locations can be defined.
80
+ #
81
+ # Features are only added if they are at least partly in the displayed
82
+ # region. If a feature is completely outside of the region, it's not
83
+ # added. If it should be only partly visible, it is added completely.
84
+ #
85
+ # ---
86
+ # *Arguments*:
87
+ # * _feature_ _object_ (required) :: A Bio::Feature object
88
+ # * _label_ :: Label for the feature. Default = 'anonymous'
89
+ # * _link_ :: URL to link to for this glyph. Default = nil
90
+ # * _glyph_ :: Glyph for the feature. Default = glyph of the track
91
+ # * _colour_ :: Colour for the feature. Default = colour of the track
92
+ # *Returns*:: Bio::Graphics::Feature object that was created or nil
93
+ def add_feature(feature_object, opts = {})
94
+ # Calculate the ultimate start and stop of the feature: the start
95
+ # of the first subfeature (e.g. exon) and the stop of the last one.
96
+ # The only reason we want to know these positions, is because we want
97
+ # to determine if the feature falls within the view of the image or
98
+ # not (see below).
99
+ start = feature_object.locations.collect{|l| l.from}.min.to_i
100
+ stop = feature_object.locations.collect{|l| l.to}.max.to_i
101
+
102
+ # If the feature wouldn't show because it's not in the region we're
103
+ # looking at, don't bother storing the stuff. I think this makes huge
104
+ # speed and memory differences if you've got a chromosome with
105
+ # thousands of features.
106
+ if stop <= self.panel.display_start or start >= self.panel.display_stop
107
+ return nil
108
+ else #elsif start >= panel.display_start and stop <= panel.display_stop
109
+ @features.push(Bio::Graphics::Feature.new(self, feature_object, opts))
110
+ return @features[-1]
111
+ end
112
+
113
+ return self
114
+ end
115
+
116
+
117
+ # Adds the track to a cairo drawing. This method should not be used
118
+ # directly by the user, but is called by Bio::Graphics::Panel.draw
119
+ # ---
120
+ # *Arguments*:
121
+ # * _panel__drawing_ (required) :: the panel cairo object
122
+ # *Returns*:: FIXME: I don't know
123
+ def draw(panel_destination)
124
+ track_context = Cairo::Context.new(panel_destination)
125
+
126
+ # Draw thin line above title
127
+ track_context.set_source_rgb(0.75,0.75,0.75)
128
+ track_context.move_to(0, self.vertical_offset)
129
+ track_context.line_to(self.panel.width, self.vertical_offset)
130
+ track_context.stroke
131
+
132
+ # Draw track title
133
+ track_context.set_source_rgb(0,0,0)
134
+ track_context.select_font_face(*(Bio::Graphics::FONT))
135
+ track_context.set_font_size(Bio::Graphics::TRACK_HEADER_HEIGHT)
136
+ track_context.move_to(0,Bio::Graphics::TRACK_HEADER_HEIGHT + self.vertical_offset + 10)
137
+ track_context.show_text(self.name)
138
+
139
+ # Draw the features
140
+ @features.sort_by{|f| f.start}.each do |feature|
141
+ # Don't even bother if the feature is not in the view
142
+ if feature.stop <= self.panel.display_start or feature.start >= self.panel.display_stop
143
+ next
144
+ else
145
+ feature.draw(panel_destination)
146
+ end
147
+ end
148
+
149
+ @number_of_feature_rows = ( @grid.keys.length == 0 ) ? 1 : @grid.keys.max + 1
150
+
151
+ return panel_destination
152
+ end
153
+
154
+ end #Track
155
+