bio-svgenes 0.2.3 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.DS_Store +0 -0
- data/VERSION +1 -1
- data/bio-svgenes.gemspec +59 -4
- data/doc/.DS_Store +0 -0
- data/doc/Bio.html +141 -0
- data/doc/Bio/.DS_Store +0 -0
- data/doc/Bio/Graphics.html +147 -0
- data/doc/Bio/Graphics/Glyph.html +1061 -0
- data/doc/Bio/Graphics/MiniFeature.html +342 -0
- data/doc/Bio/Graphics/Page.html +1200 -0
- data/doc/Bio/Graphics/Primitive.html +278 -0
- data/doc/Bio/Graphics/SVGEE.html +471 -0
- data/doc/Bio/Graphics/Track.html +506 -0
- data/doc/LICENSE_txt.html +118 -0
- data/doc/created.rid +9 -0
- data/doc/images/add.png +0 -0
- data/doc/images/arrow_up.png +0 -0
- data/doc/images/brick.png +0 -0
- data/doc/images/brick_link.png +0 -0
- data/doc/images/bug.png +0 -0
- data/doc/images/bullet_black.png +0 -0
- data/doc/images/bullet_toggle_minus.png +0 -0
- data/doc/images/bullet_toggle_plus.png +0 -0
- data/doc/images/date.png +0 -0
- data/doc/images/delete.png +0 -0
- data/doc/images/find.png +0 -0
- data/doc/images/loadingAnimation.gif +0 -0
- data/doc/images/macFFBgHack.png +0 -0
- data/doc/images/package.png +0 -0
- data/doc/images/page_green.png +0 -0
- data/doc/images/page_white_text.png +0 -0
- data/doc/images/page_white_width.png +0 -0
- data/doc/images/plugin.png +0 -0
- data/doc/images/ruby.png +0 -0
- data/doc/images/tag_blue.png +0 -0
- data/doc/images/tag_green.png +0 -0
- data/doc/images/transparent.png +0 -0
- data/doc/images/wrench.png +0 -0
- data/doc/images/wrench_orange.png +0 -0
- data/doc/images/zoom.png +0 -0
- data/doc/index.html +94 -0
- data/doc/js/darkfish.js +155 -0
- data/doc/js/jquery.js +18 -0
- data/doc/js/navigation.js +142 -0
- data/doc/js/search.js +94 -0
- data/doc/js/search_index.js +1 -0
- data/doc/js/searcher.js +228 -0
- data/doc/rdoc.css +595 -0
- data/doc/table_of_contents.html +162 -0
- data/test/gene.gff +4 -0
- data/test/json_config.json +17 -0
- data/test/test_glyph.rb +33 -0
- data/test/test_mini_feature.rb +37 -0
- data/test/test_page.rb +127 -0
- data/test/test_primitive.rb +45 -0
- data/test/test_svgee.rb +73 -0
- data/test/test_track.rb +53 -0
- data/test/test_transcripts.gff +4 -0
- metadata +94 -14
@@ -0,0 +1,342 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
|
6
|
+
|
7
|
+
<title>class Bio::Graphics::MiniFeature - RDoc Documentation</title>
|
8
|
+
|
9
|
+
<link type="text/css" media="screen" href="../../rdoc.css" rel="stylesheet">
|
10
|
+
|
11
|
+
<script type="text/javascript">
|
12
|
+
var rdoc_rel_prefix = "../../";
|
13
|
+
</script>
|
14
|
+
|
15
|
+
<script type="text/javascript" charset="utf-8" src="../../js/jquery.js"></script>
|
16
|
+
<script type="text/javascript" charset="utf-8" src="../../js/navigation.js"></script>
|
17
|
+
<script type="text/javascript" charset="utf-8" src="../../js/search_index.js"></script>
|
18
|
+
<script type="text/javascript" charset="utf-8" src="../../js/search.js"></script>
|
19
|
+
<script type="text/javascript" charset="utf-8" src="../../js/searcher.js"></script>
|
20
|
+
<script type="text/javascript" charset="utf-8" src="../../js/darkfish.js"></script>
|
21
|
+
|
22
|
+
|
23
|
+
<body id="top" class="class">
|
24
|
+
<nav id="metadata">
|
25
|
+
<nav id="home-section" class="section">
|
26
|
+
<h3 class="section-header">
|
27
|
+
<a href="../../index.html">Home</a>
|
28
|
+
<a href="../../table_of_contents.html#classes">Classes</a>
|
29
|
+
<a href="../../table_of_contents.html#methods">Methods</a>
|
30
|
+
</h3>
|
31
|
+
</nav>
|
32
|
+
|
33
|
+
|
34
|
+
<nav id="search-section" class="section project-section" class="initially-hidden">
|
35
|
+
<form action="#" method="get" accept-charset="utf-8">
|
36
|
+
<h3 class="section-header">
|
37
|
+
<input type="text" name="search" placeholder="Search" id="search-field"
|
38
|
+
title="Type to search, Up and Down to navigate, Enter to load">
|
39
|
+
</h3>
|
40
|
+
</form>
|
41
|
+
|
42
|
+
<ul id="search-results" class="initially-hidden"></ul>
|
43
|
+
</nav>
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
|
48
|
+
<div id="file-metadata">
|
49
|
+
<nav id="file-list-section" class="section">
|
50
|
+
<h3 class="section-header">Defined In</h3>
|
51
|
+
<ul>
|
52
|
+
<li>lib/bio/graphics/mini_feature.rb
|
53
|
+
</ul>
|
54
|
+
</nav>
|
55
|
+
|
56
|
+
|
57
|
+
</div>
|
58
|
+
|
59
|
+
<div id="class-metadata">
|
60
|
+
|
61
|
+
<nav id="parent-class-section" class="section">
|
62
|
+
<h3 class="section-header">Parent</h3>
|
63
|
+
|
64
|
+
<p class="link">Object
|
65
|
+
|
66
|
+
</nav>
|
67
|
+
|
68
|
+
|
69
|
+
|
70
|
+
<!-- Method Quickref -->
|
71
|
+
<nav id="method-list-section" class="section">
|
72
|
+
<h3 class="section-header">Methods</h3>
|
73
|
+
|
74
|
+
<ul class="link-list">
|
75
|
+
|
76
|
+
<li ><a href="#method-c-new">::new</a>
|
77
|
+
|
78
|
+
</ul>
|
79
|
+
</nav>
|
80
|
+
|
81
|
+
</div>
|
82
|
+
|
83
|
+
<div id="project-metadata">
|
84
|
+
<nav id="fileindex-section" class="section project-section">
|
85
|
+
<h3 class="section-header">Pages</h3>
|
86
|
+
|
87
|
+
<ul>
|
88
|
+
|
89
|
+
<li class="file"><a href="../../LICENSE_txt.html">LICENSE</a>
|
90
|
+
|
91
|
+
</ul>
|
92
|
+
</nav>
|
93
|
+
|
94
|
+
<nav id="classindex-section" class="section project-section">
|
95
|
+
<h3 class="section-header">Class and Module Index</h3>
|
96
|
+
|
97
|
+
<ul class="link-list">
|
98
|
+
|
99
|
+
<li><a href="../../Bio.html">Bio</a>
|
100
|
+
|
101
|
+
<li><a href="../../Bio/Graphics.html">Bio::Graphics</a>
|
102
|
+
|
103
|
+
<li><a href="../../Bio/Graphics/Glyph.html">Bio::Graphics::Glyph</a>
|
104
|
+
|
105
|
+
<li><a href="../../Bio/Graphics/MiniFeature.html">Bio::Graphics::MiniFeature</a>
|
106
|
+
|
107
|
+
<li><a href="../../Bio/Graphics/Page.html">Bio::Graphics::Page</a>
|
108
|
+
|
109
|
+
<li><a href="../../Bio/Graphics/Primitive.html">Bio::Graphics::Primitive</a>
|
110
|
+
|
111
|
+
<li><a href="../../Bio/Graphics/SVGEE.html">Bio::Graphics::SVGEE</a>
|
112
|
+
|
113
|
+
<li><a href="../../Bio/Graphics/Track.html">Bio::Graphics::Track</a>
|
114
|
+
|
115
|
+
</ul>
|
116
|
+
</nav>
|
117
|
+
|
118
|
+
</div>
|
119
|
+
</nav>
|
120
|
+
|
121
|
+
<div id="documentation">
|
122
|
+
<h1 class="class">class Bio::Graphics::MiniFeature</h1>
|
123
|
+
|
124
|
+
<div id="description" class="description">
|
125
|
+
|
126
|
+
<p>The <a href="MiniFeature.html">MiniFeature</a> class represents any feature
|
127
|
+
(e.g. a gene, transcript, exon, start codon, etc) on a track.</p>
|
128
|
+
|
129
|
+
</div><!-- description -->
|
130
|
+
|
131
|
+
|
132
|
+
|
133
|
+
|
134
|
+
<section id="5Buntitled-5D" class="documentation-section">
|
135
|
+
|
136
|
+
|
137
|
+
|
138
|
+
|
139
|
+
|
140
|
+
|
141
|
+
|
142
|
+
<!-- Attributes -->
|
143
|
+
<section id="attribute-method-details" class="method-section section">
|
144
|
+
<h3 class="section-header">Attributes</h3>
|
145
|
+
|
146
|
+
|
147
|
+
<div id="attribute-i-block_gaps" class="method-detail">
|
148
|
+
<div class="method-heading attribute-method-heading">
|
149
|
+
<span class="method-name">block_gaps</span><span
|
150
|
+
class="attribute-access-type">[RW]</span>
|
151
|
+
</div>
|
152
|
+
|
153
|
+
<div class="method-description">
|
154
|
+
|
155
|
+
|
156
|
+
|
157
|
+
</div>
|
158
|
+
</div>
|
159
|
+
|
160
|
+
<div id="attribute-i-end" class="method-detail">
|
161
|
+
<div class="method-heading attribute-method-heading">
|
162
|
+
<span class="method-name">end</span><span
|
163
|
+
class="attribute-access-type">[RW]</span>
|
164
|
+
</div>
|
165
|
+
|
166
|
+
<div class="method-description">
|
167
|
+
|
168
|
+
|
169
|
+
|
170
|
+
</div>
|
171
|
+
</div>
|
172
|
+
|
173
|
+
<div id="attribute-i-exons" class="method-detail">
|
174
|
+
<div class="method-heading attribute-method-heading">
|
175
|
+
<span class="method-name">exons</span><span
|
176
|
+
class="attribute-access-type">[RW]</span>
|
177
|
+
</div>
|
178
|
+
|
179
|
+
<div class="method-description">
|
180
|
+
|
181
|
+
|
182
|
+
|
183
|
+
</div>
|
184
|
+
</div>
|
185
|
+
|
186
|
+
<div id="attribute-i-id" class="method-detail">
|
187
|
+
<div class="method-heading attribute-method-heading">
|
188
|
+
<span class="method-name">id</span><span
|
189
|
+
class="attribute-access-type">[RW]</span>
|
190
|
+
</div>
|
191
|
+
|
192
|
+
<div class="method-description">
|
193
|
+
|
194
|
+
|
195
|
+
|
196
|
+
</div>
|
197
|
+
</div>
|
198
|
+
|
199
|
+
<div id="attribute-i-segment_height" class="method-detail">
|
200
|
+
<div class="method-heading attribute-method-heading">
|
201
|
+
<span class="method-name">segment_height</span><span
|
202
|
+
class="attribute-access-type">[RW]</span>
|
203
|
+
</div>
|
204
|
+
|
205
|
+
<div class="method-description">
|
206
|
+
|
207
|
+
|
208
|
+
|
209
|
+
</div>
|
210
|
+
</div>
|
211
|
+
|
212
|
+
<div id="attribute-i-start" class="method-detail">
|
213
|
+
<div class="method-heading attribute-method-heading">
|
214
|
+
<span class="method-name">start</span><span
|
215
|
+
class="attribute-access-type">[RW]</span>
|
216
|
+
</div>
|
217
|
+
|
218
|
+
<div class="method-description">
|
219
|
+
|
220
|
+
|
221
|
+
|
222
|
+
</div>
|
223
|
+
</div>
|
224
|
+
|
225
|
+
<div id="attribute-i-strand" class="method-detail">
|
226
|
+
<div class="method-heading attribute-method-heading">
|
227
|
+
<span class="method-name">strand</span><span
|
228
|
+
class="attribute-access-type">[RW]</span>
|
229
|
+
</div>
|
230
|
+
|
231
|
+
<div class="method-description">
|
232
|
+
|
233
|
+
|
234
|
+
|
235
|
+
</div>
|
236
|
+
</div>
|
237
|
+
|
238
|
+
<div id="attribute-i-utrs" class="method-detail">
|
239
|
+
<div class="method-heading attribute-method-heading">
|
240
|
+
<span class="method-name">utrs</span><span
|
241
|
+
class="attribute-access-type">[RW]</span>
|
242
|
+
</div>
|
243
|
+
|
244
|
+
<div class="method-description">
|
245
|
+
|
246
|
+
|
247
|
+
|
248
|
+
</div>
|
249
|
+
</div>
|
250
|
+
|
251
|
+
</section><!-- attribute-method-details -->
|
252
|
+
|
253
|
+
|
254
|
+
<!-- Methods -->
|
255
|
+
|
256
|
+
<section id="public-class-5Buntitled-5D-method-details" class="method-section section">
|
257
|
+
<h3 class="section-header">Public Class Methods</h3>
|
258
|
+
|
259
|
+
|
260
|
+
<div id="method-c-new" class="method-detail ">
|
261
|
+
|
262
|
+
<div class="method-heading">
|
263
|
+
<span class="method-name">new</span><span
|
264
|
+
class="method-args">(args)</span>
|
265
|
+
|
266
|
+
<span class="method-click-advice">click to toggle source</span>
|
267
|
+
|
268
|
+
</div>
|
269
|
+
|
270
|
+
|
271
|
+
<div class="method-description">
|
272
|
+
|
273
|
+
<p>Creates a new <a href="MiniFeature.html">MiniFeature</a></p>
|
274
|
+
|
275
|
+
<p><em>Arguments</em></p>
|
276
|
+
<ul><li>
|
277
|
+
<p>start = the start position of the feature</p>
|
278
|
+
</li><li>
|
279
|
+
<p>end = the end position of the feature</p>
|
280
|
+
</li><li>
|
281
|
+
<p>strand = the strand of the feature</p>
|
282
|
+
</li><li>
|
283
|
+
<p>exons = an array of exon positions</p>
|
284
|
+
</li><li>
|
285
|
+
<p>utrs = an array of utrs positions</p>
|
286
|
+
</li><li>
|
287
|
+
<p>block_gaps = an array of regions with nothing to be drawn, e.g. introns</p>
|
288
|
+
</li><li>
|
289
|
+
<p>id = the name of the feature such as the gene name or transcript ID</p>
|
290
|
+
</li><li>
|
291
|
+
<p>segment_height = the height of the current feature</p>
|
292
|
+
</li></ul>
|
293
|
+
|
294
|
+
<h2 id="method-c-new-label-Example+usage">Example usage<span><a href="#method-c-new-label-Example+usage">¶</a> <a href="#documentation">↑</a></span></h2>
|
295
|
+
|
296
|
+
<pre class="ruby"><span class="ruby-ivar">@mini1</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">MiniFeature</span>.<span class="ruby-identifier">new</span>(:<span class="ruby-identifier">start=</span><span class="ruby-operator">></span><span class="ruby-value">3631</span>, :<span class="ruby-keyword">end</span>=<span class="ruby-operator">></span><span class="ruby-value">5899</span>, :<span class="ruby-identifier">strand=</span><span class="ruby-operator">></span><span class="ruby-string">'+'</span>,
|
297
|
+
:<span class="ruby-identifier">exons=</span><span class="ruby-operator">></span>[<span class="ruby-value">4000</span>, <span class="ruby-value">4500</span>, <span class="ruby-value">4700</span>, <span class="ruby-value">5000</span>], :<span class="ruby-identifier">utrs=</span><span class="ruby-operator">></span>[<span class="ruby-value">3631</span>, <span class="ruby-value">3650</span>], :<span class="ruby-identifier">segment_height=</span><span class="ruby-operator">></span><span class="ruby-value">5</span>, :<span class="ruby-identifier">id=</span><span class="ruby-operator">></span><span class="ruby-string">"AT1G01010"</span>)
|
298
|
+
</pre>
|
299
|
+
|
300
|
+
<h3 id="method-c-new-label-MiniFeatures+and+Tracks">MiniFeatures and Tracks<span><a href="#method-c-new-label-MiniFeatures+and+Tracks">¶</a> <a href="#documentation">↑</a></span></h3>
|
301
|
+
|
302
|
+
<p>MiniFeatures are added to <a href="Track.html">Track</a> objects, with
|
303
|
+
overlapping MiniFeatures being placed onto separate rows</p>
|
304
|
+
|
305
|
+
|
306
|
+
|
307
|
+
|
308
|
+
<div class="method-source-code" id="new-source">
|
309
|
+
<pre><span class="ruby-comment"># File lib/bio/graphics/mini_feature.rb, line 28</span>
|
310
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">args</span>)
|
311
|
+
<span class="ruby-ivar">@start</span> = <span class="ruby-identifier">args</span>[<span class="ruby-value">:start</span>]
|
312
|
+
<span class="ruby-ivar">@end</span> = <span class="ruby-identifier">args</span>[<span class="ruby-value">:end</span>]
|
313
|
+
<span class="ruby-ivar">@strand</span> = <span class="ruby-identifier">args</span>[<span class="ruby-value">:strand</span>]
|
314
|
+
<span class="ruby-ivar">@exons</span> = <span class="ruby-identifier">args</span>[<span class="ruby-value">:exons</span>] <span class="ruby-operator">||</span> []
|
315
|
+
<span class="ruby-ivar">@utrs</span> = <span class="ruby-identifier">args</span>[<span class="ruby-value">:utrs</span>] <span class="ruby-operator">||</span> [] <span class="ruby-comment">#start, ennd, strand, arg[:exons], arg[:utrs]</span>
|
316
|
+
<span class="ruby-ivar">@block_gaps</span> = []
|
317
|
+
<span class="ruby-ivar">@id</span> = <span class="ruby-identifier">args</span>[<span class="ruby-value">:id</span>]
|
318
|
+
<span class="ruby-ivar">@segment_height</span> = <span class="ruby-identifier">args</span>[<span class="ruby-value">:segment_height</span>]
|
319
|
+
<span class="ruby-keyword">end</span></pre>
|
320
|
+
</div><!-- new-source -->
|
321
|
+
|
322
|
+
</div>
|
323
|
+
|
324
|
+
|
325
|
+
|
326
|
+
|
327
|
+
</div><!-- new-method -->
|
328
|
+
|
329
|
+
|
330
|
+
</section><!-- public-class-method-details -->
|
331
|
+
|
332
|
+
</section><!-- 5Buntitled-5D -->
|
333
|
+
|
334
|
+
</div><!-- documentation -->
|
335
|
+
|
336
|
+
|
337
|
+
<footer id="validator-badges">
|
338
|
+
<p><a href="http://validator.w3.org/check/referer">[Validate]</a>
|
339
|
+
<p>Generated by <a href="https://github.com/rdoc/rdoc">RDoc</a> 4.0.0.rc.2.1.
|
340
|
+
<p>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish Rdoc Generator</a> 3.
|
341
|
+
</footer>
|
342
|
+
|
@@ -0,0 +1,1200 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
|
6
|
+
|
7
|
+
<title>class Bio::Graphics::Page - RDoc Documentation</title>
|
8
|
+
|
9
|
+
<link type="text/css" media="screen" href="../../rdoc.css" rel="stylesheet">
|
10
|
+
|
11
|
+
<script type="text/javascript">
|
12
|
+
var rdoc_rel_prefix = "../../";
|
13
|
+
</script>
|
14
|
+
|
15
|
+
<script type="text/javascript" charset="utf-8" src="../../js/jquery.js"></script>
|
16
|
+
<script type="text/javascript" charset="utf-8" src="../../js/navigation.js"></script>
|
17
|
+
<script type="text/javascript" charset="utf-8" src="../../js/search_index.js"></script>
|
18
|
+
<script type="text/javascript" charset="utf-8" src="../../js/search.js"></script>
|
19
|
+
<script type="text/javascript" charset="utf-8" src="../../js/searcher.js"></script>
|
20
|
+
<script type="text/javascript" charset="utf-8" src="../../js/darkfish.js"></script>
|
21
|
+
|
22
|
+
|
23
|
+
<body id="top" class="class">
|
24
|
+
<nav id="metadata">
|
25
|
+
<nav id="home-section" class="section">
|
26
|
+
<h3 class="section-header">
|
27
|
+
<a href="../../index.html">Home</a>
|
28
|
+
<a href="../../table_of_contents.html#classes">Classes</a>
|
29
|
+
<a href="../../table_of_contents.html#methods">Methods</a>
|
30
|
+
</h3>
|
31
|
+
</nav>
|
32
|
+
|
33
|
+
|
34
|
+
<nav id="search-section" class="section project-section" class="initially-hidden">
|
35
|
+
<form action="#" method="get" accept-charset="utf-8">
|
36
|
+
<h3 class="section-header">
|
37
|
+
<input type="text" name="search" placeholder="Search" id="search-field"
|
38
|
+
title="Type to search, Up and Down to navigate, Enter to load">
|
39
|
+
</h3>
|
40
|
+
</form>
|
41
|
+
|
42
|
+
<ul id="search-results" class="initially-hidden"></ul>
|
43
|
+
</nav>
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
|
48
|
+
<div id="file-metadata">
|
49
|
+
<nav id="file-list-section" class="section">
|
50
|
+
<h3 class="section-header">Defined In</h3>
|
51
|
+
<ul>
|
52
|
+
<li>lib/bio/graphics/page.rb
|
53
|
+
</ul>
|
54
|
+
</nav>
|
55
|
+
|
56
|
+
|
57
|
+
</div>
|
58
|
+
|
59
|
+
<div id="class-metadata">
|
60
|
+
|
61
|
+
<nav id="parent-class-section" class="section">
|
62
|
+
<h3 class="section-header">Parent</h3>
|
63
|
+
|
64
|
+
<p class="link">Object
|
65
|
+
|
66
|
+
</nav>
|
67
|
+
|
68
|
+
|
69
|
+
|
70
|
+
<!-- Method Quickref -->
|
71
|
+
<nav id="method-list-section" class="section">
|
72
|
+
<h3 class="section-header">Methods</h3>
|
73
|
+
|
74
|
+
<ul class="link-list">
|
75
|
+
|
76
|
+
<li ><a href="#method-c-from_json">::from_json</a>
|
77
|
+
|
78
|
+
<li ><a href="#method-c-new">::new</a>
|
79
|
+
|
80
|
+
<li ><a href="#method-c-parse_gff">::parse_gff</a>
|
81
|
+
|
82
|
+
<li ><a href="#method-i-add_track">#add_track</a>
|
83
|
+
|
84
|
+
<li ><a href="#method-i-draw">#draw</a>
|
85
|
+
|
86
|
+
<li ><a href="#method-i-draw_circle">#draw_circle</a>
|
87
|
+
|
88
|
+
<li ><a href="#method-i-draw_directed">#draw_directed</a>
|
89
|
+
|
90
|
+
<li ><a href="#method-i-draw_down_triangle">#draw_down_triangle</a>
|
91
|
+
|
92
|
+
<li ><a href="#method-i-draw_features">#draw_features</a>
|
93
|
+
|
94
|
+
<li ><a href="#method-i-draw_generic">#draw_generic</a>
|
95
|
+
|
96
|
+
<li ><a href="#method-i-draw_histogram">#draw_histogram</a>
|
97
|
+
|
98
|
+
<li ><a href="#method-i-draw_label">#draw_label</a>
|
99
|
+
|
100
|
+
<li ><a href="#method-i-draw_scale">#draw_scale</a>
|
101
|
+
|
102
|
+
<li ><a href="#method-i-draw_span">#draw_span</a>
|
103
|
+
|
104
|
+
<li ><a href="#method-i-draw_transcript">#draw_transcript</a>
|
105
|
+
|
106
|
+
<li ><a href="#method-i-draw_up_triangle">#draw_up_triangle</a>
|
107
|
+
|
108
|
+
<li ><a href="#method-i-get_limits">#get_limits</a>
|
109
|
+
|
110
|
+
<li ><a href="#method-i-get_markup">#get_markup</a>
|
111
|
+
|
112
|
+
<li ><a href="#method-i-to_px">#to_px</a>
|
113
|
+
|
114
|
+
<li ><a href="#method-i-write">#write</a>
|
115
|
+
|
116
|
+
</ul>
|
117
|
+
</nav>
|
118
|
+
|
119
|
+
</div>
|
120
|
+
|
121
|
+
<div id="project-metadata">
|
122
|
+
<nav id="fileindex-section" class="section project-section">
|
123
|
+
<h3 class="section-header">Pages</h3>
|
124
|
+
|
125
|
+
<ul>
|
126
|
+
|
127
|
+
<li class="file"><a href="../../LICENSE_txt.html">LICENSE</a>
|
128
|
+
|
129
|
+
</ul>
|
130
|
+
</nav>
|
131
|
+
|
132
|
+
<nav id="classindex-section" class="section project-section">
|
133
|
+
<h3 class="section-header">Class and Module Index</h3>
|
134
|
+
|
135
|
+
<ul class="link-list">
|
136
|
+
|
137
|
+
<li><a href="../../Bio.html">Bio</a>
|
138
|
+
|
139
|
+
<li><a href="../../Bio/Graphics.html">Bio::Graphics</a>
|
140
|
+
|
141
|
+
<li><a href="../../Bio/Graphics/Glyph.html">Bio::Graphics::Glyph</a>
|
142
|
+
|
143
|
+
<li><a href="../../Bio/Graphics/MiniFeature.html">Bio::Graphics::MiniFeature</a>
|
144
|
+
|
145
|
+
<li><a href="../../Bio/Graphics/Page.html">Bio::Graphics::Page</a>
|
146
|
+
|
147
|
+
<li><a href="../../Bio/Graphics/Primitive.html">Bio::Graphics::Primitive</a>
|
148
|
+
|
149
|
+
<li><a href="../../Bio/Graphics/SVGEE.html">Bio::Graphics::SVGEE</a>
|
150
|
+
|
151
|
+
<li><a href="../../Bio/Graphics/Track.html">Bio::Graphics::Track</a>
|
152
|
+
|
153
|
+
</ul>
|
154
|
+
</nav>
|
155
|
+
|
156
|
+
</div>
|
157
|
+
</nav>
|
158
|
+
|
159
|
+
<div id="documentation">
|
160
|
+
<h1 class="class">class Bio::Graphics::Page</h1>
|
161
|
+
|
162
|
+
<div id="description" class="description">
|
163
|
+
|
164
|
+
<p>The <a href="Page.html">Page</a> class represents the top level container
|
165
|
+
on which svg objects are written. It will contain a scale and all the
|
166
|
+
tracks along with their features. The scale will start at the genomic
|
167
|
+
co-ordinates of the start of the first feature and stop at the end of the
|
168
|
+
last feature)</p>
|
169
|
+
|
170
|
+
</div><!-- description -->
|
171
|
+
|
172
|
+
|
173
|
+
|
174
|
+
|
175
|
+
<section id="5Buntitled-5D" class="documentation-section">
|
176
|
+
|
177
|
+
|
178
|
+
|
179
|
+
|
180
|
+
|
181
|
+
|
182
|
+
|
183
|
+
|
184
|
+
<!-- Methods -->
|
185
|
+
|
186
|
+
<section id="public-instance-5Buntitled-5D-method-details" class="method-section section">
|
187
|
+
<h3 class="section-header">Public Instance Methods</h3>
|
188
|
+
|
189
|
+
|
190
|
+
<div id="method-i-add_track" class="method-detail ">
|
191
|
+
|
192
|
+
<div class="method-heading">
|
193
|
+
<span class="method-name">add_track</span><span
|
194
|
+
class="method-args">(args)</span>
|
195
|
+
|
196
|
+
<span class="method-click-advice">click to toggle source</span>
|
197
|
+
|
198
|
+
</div>
|
199
|
+
|
200
|
+
|
201
|
+
<div class="method-description">
|
202
|
+
|
203
|
+
<p>Calculates the colour or gradient for the supplied <a
|
204
|
+
href="Track.html">Bio::Graphics::Track</a> objects and adds them to the <a
|
205
|
+
href="Track.html">Track</a> array for the current <a
|
206
|
+
href="Page.html">Page</a></p>
|
207
|
+
<ul><li>
|
208
|
+
<p><code>args</code> - an Array of <a
|
209
|
+
href="Track.html">Bio::Graphics::Track</a> objects</p>
|
210
|
+
</li><li>
|
211
|
+
<p><code>returns</code> - the last element of the <a
|
212
|
+
href="Track.html">Track</a> array</p>
|
213
|
+
</li></ul>
|
214
|
+
|
215
|
+
|
216
|
+
|
217
|
+
|
218
|
+
<div class="method-source-code" id="add_track-source">
|
219
|
+
<pre><span class="ruby-comment"># File lib/bio/graphics/page.rb, line 138</span>
|
220
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">add_track</span>(<span class="ruby-identifier">args</span>)
|
221
|
+
<span class="ruby-comment">#sort out the colour/gradient options</span>
|
222
|
+
[<span class="ruby-value">:fill_color</span>, <span class="ruby-value">:exon_fill_color</span>, <span class="ruby-value">:utr_fill_color</span>].<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">colour_tag</span><span class="ruby-operator">|</span>
|
223
|
+
<span class="ruby-keyword">if</span> <span class="ruby-constant">Glyph</span>.<span class="ruby-identifier">gradients</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">args</span>[<span class="ruby-identifier">colour_tag</span>])
|
224
|
+
<span class="ruby-ivar">@svg</span>.<span class="ruby-identifier">gradient</span>(<span class="ruby-constant">Glyph</span>.<span class="ruby-identifier">gradient</span>(<span class="ruby-identifier">args</span>[<span class="ruby-identifier">colour_tag</span>]))
|
225
|
+
<span class="ruby-identifier">args</span>[<span class="ruby-identifier">colour_tag</span>] = <span class="ruby-node">"url(##{args[colour_tag]})"</span>
|
226
|
+
<span class="ruby-keyword">elsif</span> <span class="ruby-identifier">args</span>[<span class="ruby-identifier">colour_tag</span>].<span class="ruby-identifier">instance_of?</span>(<span class="ruby-constant">Hash</span>)
|
227
|
+
<span class="ruby-ivar">@svg</span>.<span class="ruby-identifier">gradient</span>(<span class="ruby-identifier">args</span>[<span class="ruby-identifier">colour_tag</span>])
|
228
|
+
<span class="ruby-identifier">args</span>[<span class="ruby-identifier">colour_tag</span>] = <span class="ruby-node">"url(##{args[colour_tag][:id]})"</span>
|
229
|
+
<span class="ruby-keyword">end</span>
|
230
|
+
<span class="ruby-keyword">end</span>
|
231
|
+
<span class="ruby-ivar">@tracks</span> <span class="ruby-operator"><<</span> <span class="ruby-constant">Track</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">args</span>)
|
232
|
+
<span class="ruby-keyword">return</span> <span class="ruby-ivar">@tracks</span>.<span class="ruby-identifier">last</span>
|
233
|
+
<span class="ruby-keyword">end</span></pre>
|
234
|
+
</div><!-- add_track-source -->
|
235
|
+
|
236
|
+
</div>
|
237
|
+
|
238
|
+
|
239
|
+
|
240
|
+
|
241
|
+
</div><!-- add_track-method -->
|
242
|
+
|
243
|
+
|
244
|
+
<div id="method-i-draw" class="method-detail ">
|
245
|
+
|
246
|
+
<div class="method-heading">
|
247
|
+
<span class="method-name">draw</span><span
|
248
|
+
class="method-args">()</span>
|
249
|
+
|
250
|
+
<span class="method-click-advice">click to toggle source</span>
|
251
|
+
|
252
|
+
</div>
|
253
|
+
|
254
|
+
|
255
|
+
<div class="method-description">
|
256
|
+
|
257
|
+
<p>Prints out the svg text</p>
|
258
|
+
|
259
|
+
|
260
|
+
|
261
|
+
|
262
|
+
<div class="method-source-code" id="draw-source">
|
263
|
+
<pre><span class="ruby-comment"># File lib/bio/graphics/page.rb, line 332</span>
|
264
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">draw</span>
|
265
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-identifier">get_markup</span>
|
266
|
+
<span class="ruby-keyword">end</span></pre>
|
267
|
+
</div><!-- draw-source -->
|
268
|
+
|
269
|
+
</div>
|
270
|
+
|
271
|
+
|
272
|
+
|
273
|
+
|
274
|
+
</div><!-- draw-method -->
|
275
|
+
|
276
|
+
|
277
|
+
<div id="method-i-draw_circle" class="method-detail ">
|
278
|
+
|
279
|
+
<div class="method-heading">
|
280
|
+
<span class="method-name">draw_circle</span><span
|
281
|
+
class="method-args">(args)</span>
|
282
|
+
|
283
|
+
<span class="method-click-advice">click to toggle source</span>
|
284
|
+
|
285
|
+
</div>
|
286
|
+
|
287
|
+
|
288
|
+
<div class="method-description">
|
289
|
+
|
290
|
+
<p>Adds the <a href="Primitive.html">Bio::Graphics::Primitive</a> objects to
|
291
|
+
the <a href="SVGEE.html">SVGEE</a> object</p>
|
292
|
+
<ul><li>
|
293
|
+
<p><code>args</code> - an Array of <a
|
294
|
+
href="Primitive.html">Bio::Graphics::Primitive</a> objects of the stated
|
295
|
+
type</p>
|
296
|
+
</li></ul>
|
297
|
+
|
298
|
+
|
299
|
+
|
300
|
+
|
301
|
+
<div class="method-source-code" id="draw_circle-source">
|
302
|
+
<pre><span class="ruby-comment"># File lib/bio/graphics/page.rb, line 189</span>
|
303
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">draw_circle</span>(<span class="ruby-identifier">args</span>)
|
304
|
+
<span class="ruby-constant">Glyph</span>.<span class="ruby-identifier">circle</span>(<span class="ruby-identifier">args</span>).<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">g</span><span class="ruby-operator">|</span> <span class="ruby-ivar">@svg</span>.<span class="ruby-identifier">add_primitive</span>(<span class="ruby-identifier">g</span>) }
|
305
|
+
<span class="ruby-keyword">end</span></pre>
|
306
|
+
</div><!-- draw_circle-source -->
|
307
|
+
|
308
|
+
</div>
|
309
|
+
|
310
|
+
|
311
|
+
|
312
|
+
|
313
|
+
</div><!-- draw_circle-method -->
|
314
|
+
|
315
|
+
|
316
|
+
<div id="method-i-draw_directed" class="method-detail ">
|
317
|
+
|
318
|
+
<div class="method-heading">
|
319
|
+
<span class="method-name">draw_directed</span><span
|
320
|
+
class="method-args">(args)</span>
|
321
|
+
|
322
|
+
<span class="method-click-advice">click to toggle source</span>
|
323
|
+
|
324
|
+
</div>
|
325
|
+
|
326
|
+
|
327
|
+
<div class="method-description">
|
328
|
+
|
329
|
+
<p>Adds the <a href="Primitive.html">Bio::Graphics::Primitive</a> objects to
|
330
|
+
the <a href="SVGEE.html">SVGEE</a> object</p>
|
331
|
+
<ul><li>
|
332
|
+
<p><code>args</code> - an Array of <a
|
333
|
+
href="Primitive.html">Bio::Graphics::Primitive</a> objects of the stated
|
334
|
+
type</p>
|
335
|
+
</li></ul>
|
336
|
+
|
337
|
+
|
338
|
+
|
339
|
+
|
340
|
+
<div class="method-source-code" id="draw_directed-source">
|
341
|
+
<pre><span class="ruby-comment"># File lib/bio/graphics/page.rb, line 184</span>
|
342
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">draw_directed</span>(<span class="ruby-identifier">args</span>)
|
343
|
+
<span class="ruby-constant">Glyph</span>.<span class="ruby-identifier">directed</span>(<span class="ruby-identifier">args</span>).<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">g</span><span class="ruby-operator">|</span> <span class="ruby-ivar">@svg</span>.<span class="ruby-identifier">add_primitive</span>(<span class="ruby-identifier">g</span>) }
|
344
|
+
<span class="ruby-keyword">end</span></pre>
|
345
|
+
</div><!-- draw_directed-source -->
|
346
|
+
|
347
|
+
</div>
|
348
|
+
|
349
|
+
|
350
|
+
|
351
|
+
|
352
|
+
</div><!-- draw_directed-method -->
|
353
|
+
|
354
|
+
|
355
|
+
<div id="method-i-draw_down_triangle" class="method-detail ">
|
356
|
+
|
357
|
+
<div class="method-heading">
|
358
|
+
<span class="method-name">draw_down_triangle</span><span
|
359
|
+
class="method-args">(args)</span>
|
360
|
+
|
361
|
+
<span class="method-click-advice">click to toggle source</span>
|
362
|
+
|
363
|
+
</div>
|
364
|
+
|
365
|
+
|
366
|
+
<div class="method-description">
|
367
|
+
|
368
|
+
<p>Adds the <a href="Primitive.html">Bio::Graphics::Primitive</a> objects to
|
369
|
+
the <a href="SVGEE.html">SVGEE</a> object</p>
|
370
|
+
<ul><li>
|
371
|
+
<p><code>args</code> - an Array of <a
|
372
|
+
href="Primitive.html">Bio::Graphics::Primitive</a> objects of the stated
|
373
|
+
type</p>
|
374
|
+
</li></ul>
|
375
|
+
|
376
|
+
|
377
|
+
|
378
|
+
|
379
|
+
<div class="method-source-code" id="draw_down_triangle-source">
|
380
|
+
<pre><span class="ruby-comment"># File lib/bio/graphics/page.rb, line 209</span>
|
381
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">draw_down_triangle</span>(<span class="ruby-identifier">args</span>)
|
382
|
+
<span class="ruby-constant">Glyph</span>.<span class="ruby-identifier">down_triangle</span>(<span class="ruby-identifier">args</span>).<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">g</span><span class="ruby-operator">|</span> <span class="ruby-ivar">@svg</span>.<span class="ruby-identifier">add_primitive</span>(<span class="ruby-identifier">g</span>) }
|
383
|
+
<span class="ruby-keyword">end</span></pre>
|
384
|
+
</div><!-- draw_down_triangle-source -->
|
385
|
+
|
386
|
+
</div>
|
387
|
+
|
388
|
+
|
389
|
+
|
390
|
+
|
391
|
+
</div><!-- draw_down_triangle-method -->
|
392
|
+
|
393
|
+
|
394
|
+
<div id="method-i-draw_features" class="method-detail ">
|
395
|
+
|
396
|
+
<div class="method-heading">
|
397
|
+
<span class="method-name">draw_features</span><span
|
398
|
+
class="method-args">(track)</span>
|
399
|
+
|
400
|
+
<span class="method-click-advice">click to toggle source</span>
|
401
|
+
|
402
|
+
</div>
|
403
|
+
|
404
|
+
|
405
|
+
<div class="method-description">
|
406
|
+
|
407
|
+
<p>Takes a <a href="Track.html">Bio::Graphics::Track</a> object and sorts out
|
408
|
+
the input information into a user friendly format.</p>
|
409
|
+
|
410
|
+
<p>It examines the the type of track and calculates the required parameters</p>
|
411
|
+
<ul><li>
|
412
|
+
<p><code>args</code> - an Array of <a
|
413
|
+
href="Track.html">Bio::Graphics::Track</a> object</p>
|
414
|
+
</li></ul>
|
415
|
+
|
416
|
+
|
417
|
+
|
418
|
+
|
419
|
+
<div class="method-source-code" id="draw_features-source">
|
420
|
+
<pre><span class="ruby-comment"># File lib/bio/graphics/page.rb, line 222</span>
|
421
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">draw_features</span>(<span class="ruby-identifier">track</span>)
|
422
|
+
<span class="ruby-keyword">if</span> [<span class="ruby-value">:histogram</span>, <span class="ruby-string">"histogram"</span>].<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">track</span>.<span class="ruby-identifier">glyph</span>) <span class="ruby-comment">#do different stuff for data tracks...</span>
|
423
|
+
|
424
|
+
<span class="ruby-identifier">y</span> = <span class="ruby-ivar">@track_top</span> <span class="ruby-operator">+</span> (<span class="ruby-identifier">track</span>.<span class="ruby-identifier">track_height</span>)
|
425
|
+
<span class="ruby-identifier">max</span> = <span class="ruby-identifier">track</span>.<span class="ruby-identifier">max_y</span> <span class="ruby-operator">?</span> <span class="ruby-identifier">track</span>.<span class="ruby-identifier">max_y</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">track</span>.<span class="ruby-identifier">features</span>.<span class="ruby-identifier">sort</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">a</span>, <span class="ruby-identifier">b</span><span class="ruby-operator">|</span> <span class="ruby-identifier">a</span>.<span class="ruby-identifier">segment_height</span> <span class="ruby-operator"><=></span> <span class="ruby-identifier">b</span>.<span class="ruby-identifier">segment_height</span> }.<span class="ruby-identifier">last</span>.<span class="ruby-identifier">segment_height</span>
|
426
|
+
<span class="ruby-identifier">min</span> = <span class="ruby-value">0</span>
|
427
|
+
<span class="ruby-keyword">if</span> <span class="ruby-identifier">track</span>.<span class="ruby-identifier">label</span>
|
428
|
+
<span class="ruby-identifier">draw_label</span>(<span class="ruby-value">:text</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">track</span>.<span class="ruby-identifier">name</span>, <span class="ruby-value">:y</span> =<span class="ruby-operator">></span> <span class="ruby-ivar">@track_top</span> <span class="ruby-operator">+=</span> <span class="ruby-value">30</span>, <span class="ruby-value">:x</span> =<span class="ruby-operator">></span> <span class="ruby-value">3</span>)
|
429
|
+
<span class="ruby-keyword">end</span>
|
430
|
+
<span class="ruby-identifier">draw_label</span>(<span class="ruby-value">:text</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">max</span>, <span class="ruby-value">:x</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">to_px</span>(<span class="ruby-ivar">@scale_stop</span> <span class="ruby-operator">-</span> <span class="ruby-ivar">@scale_start</span>) <span class="ruby-operator">+</span> <span class="ruby-value">5</span>, <span class="ruby-value">:y</span> =<span class="ruby-operator">></span> <span class="ruby-ivar">@track_top</span> <span class="ruby-operator">+</span> <span class="ruby-value">5</span>)
|
431
|
+
<span class="ruby-identifier">draw_label</span>(<span class="ruby-value">:text</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">min</span>, <span class="ruby-value">:x</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">to_px</span>(<span class="ruby-ivar">@scale_stop</span> <span class="ruby-operator">-</span> <span class="ruby-ivar">@scale_start</span>) <span class="ruby-operator">+</span> <span class="ruby-value">5</span>, <span class="ruby-value">:y</span> =<span class="ruby-operator">></span> <span class="ruby-ivar">@track_top</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">track</span>.<span class="ruby-identifier">track_height</span> <span class="ruby-operator">+</span> <span class="ruby-value">5</span>)
|
432
|
+
<span class="ruby-identifier">data_interval</span> = <span class="ruby-identifier">max</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">min</span>
|
433
|
+
<span class="ruby-identifier">data_per_px</span> = <span class="ruby-identifier">track</span>.<span class="ruby-identifier">track_height</span>.<span class="ruby-identifier">to_f</span> <span class="ruby-operator">/</span> <span class="ruby-identifier">data_interval</span>.<span class="ruby-identifier">to_f</span>
|
434
|
+
<span class="ruby-identifier">track</span>.<span class="ruby-identifier">features</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">f</span><span class="ruby-operator">|</span>
|
435
|
+
<span class="ruby-identifier">x</span> = <span class="ruby-identifier">to_px</span>(<span class="ruby-identifier">f</span>.<span class="ruby-identifier">start</span> <span class="ruby-operator">-</span> <span class="ruby-ivar">@scale_start</span>)
|
436
|
+
<span class="ruby-identifier">width</span> = <span class="ruby-identifier">to_px</span>((<span class="ruby-identifier">f</span>.<span class="ruby-identifier">end</span> <span class="ruby-operator">-</span> <span class="ruby-ivar">@scale_start</span>) <span class="ruby-operator">-</span> (<span class="ruby-identifier">f</span>.<span class="ruby-identifier">start</span> <span class="ruby-operator">-</span> <span class="ruby-ivar">@scale_start</span>))
|
437
|
+
<span class="ruby-identifier">height</span> = <span class="ruby-identifier">f</span>.<span class="ruby-identifier">segment_height</span>.<span class="ruby-identifier">to_f</span> <span class="ruby-operator">*</span> <span class="ruby-identifier">data_per_px</span>
|
438
|
+
<span class="ruby-identifier">y</span> = <span class="ruby-ivar">@track_top</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">track</span>.<span class="ruby-identifier">track_height</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">height</span> <span class="ruby-operator">+</span> <span class="ruby-value">5</span>
|
439
|
+
<span class="ruby-comment">#$stderr.puts f.segment_height, data_per_px, data_interval, max, min, "------"</span>
|
440
|
+
<span class="ruby-keyword">self</span>.<span class="ruby-identifier">send</span>(<span class="ruby-node">"draw_#{track.glyph}"</span>, {<span class="ruby-value">:x</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">x</span>,
|
441
|
+
<span class="ruby-value">:y</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">y</span>,
|
442
|
+
<span class="ruby-value">:width</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">width</span>,
|
443
|
+
<span class="ruby-value">:height</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">height</span>}.<span class="ruby-identifier">merge!</span>(<span class="ruby-identifier">track</span>.<span class="ruby-identifier">args</span>))
|
444
|
+
<span class="ruby-keyword">end</span>
|
445
|
+
<span class="ruby-ivar">@track_top</span> <span class="ruby-operator">+=</span> (<span class="ruby-identifier">track</span>.<span class="ruby-identifier">track_height</span>) <span class="ruby-operator">+</span> <span class="ruby-value">20</span>
|
446
|
+
<span class="ruby-keyword">else</span> <span class="ruby-comment">##following stuff for the features</span>
|
447
|
+
<span class="ruby-keyword">if</span> <span class="ruby-identifier">track</span>.<span class="ruby-identifier">label</span>
|
448
|
+
<span class="ruby-identifier">draw_label</span>(<span class="ruby-value">:text</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">track</span>.<span class="ruby-identifier">name</span>, <span class="ruby-value">:y</span> =<span class="ruby-operator">></span> <span class="ruby-ivar">@track_top</span> <span class="ruby-operator">+=</span> <span class="ruby-value">30</span>, <span class="ruby-value">:x</span> =<span class="ruby-operator">></span> <span class="ruby-value">3</span>)
|
449
|
+
<span class="ruby-keyword">end</span>
|
450
|
+
<span class="ruby-identifier">track</span>.<span class="ruby-identifier">get_rows</span> <span class="ruby-comment">##work out how many rows and which features belong in each row...</span>
|
451
|
+
<span class="ruby-identifier">track</span>.<span class="ruby-identifier">features</span>.<span class="ruby-identifier">each_with_index</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">f</span>, <span class="ruby-identifier">index</span><span class="ruby-operator">|</span>
|
452
|
+
<span class="ruby-identifier">x</span> = <span class="ruby-identifier">to_px</span>(<span class="ruby-identifier">f</span>.<span class="ruby-identifier">start</span> <span class="ruby-operator">-</span> <span class="ruby-ivar">@scale_start</span>) <span class="ruby-comment">#bottom left of feature</span>
|
453
|
+
<span class="ruby-identifier">all_sub_blocks</span> = []
|
454
|
+
|
455
|
+
<span class="ruby-comment">#convert the exon and utr start stops to px start stops and px widths</span>
|
456
|
+
<span class="ruby-identifier">exons</span> = []
|
457
|
+
<span class="ruby-keyword">if</span> <span class="ruby-identifier">f</span>.<span class="ruby-identifier">exons</span>
|
458
|
+
<span class="ruby-identifier">f</span>.<span class="ruby-identifier">exons</span>.<span class="ruby-identifier">each_slice</span>(<span class="ruby-value">2</span>).<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">exon</span><span class="ruby-operator">|</span>
|
459
|
+
<span class="ruby-identifier">all_sub_blocks</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">exon</span>
|
460
|
+
<span class="ruby-keyword">next</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">exon</span>.<span class="ruby-identifier">nil?</span>
|
461
|
+
<span class="ruby-identifier">exons</span> <span class="ruby-operator"><<</span> [<span class="ruby-identifier">to_px</span>(<span class="ruby-identifier">exon</span>[<span class="ruby-value">0</span>] <span class="ruby-operator">-</span> <span class="ruby-ivar">@scale_start</span>), <span class="ruby-identifier">to_px</span>((<span class="ruby-identifier">exon</span>[<span class="ruby-value">1</span>] <span class="ruby-operator">-</span> <span class="ruby-ivar">@scale_start</span>) <span class="ruby-operator">-</span> (<span class="ruby-identifier">exon</span>[<span class="ruby-value">0</span>] <span class="ruby-operator">-</span> <span class="ruby-ivar">@scale_start</span>))]
|
462
|
+
<span class="ruby-keyword">end</span>
|
463
|
+
<span class="ruby-keyword">end</span>
|
464
|
+
<span class="ruby-identifier">f</span>.<span class="ruby-identifier">exons</span> = <span class="ruby-identifier">exons</span>
|
465
|
+
|
466
|
+
<span class="ruby-identifier">utrs</span> = []
|
467
|
+
<span class="ruby-keyword">if</span> <span class="ruby-identifier">f</span>.<span class="ruby-identifier">utrs</span>
|
468
|
+
<span class="ruby-identifier">f</span>.<span class="ruby-identifier">utrs</span>.<span class="ruby-identifier">each_slice</span>(<span class="ruby-value">2</span>).<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">utr</span><span class="ruby-operator">|</span>
|
469
|
+
<span class="ruby-identifier">all_sub_blocks</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">utr</span>
|
470
|
+
<span class="ruby-keyword">next</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">utr</span>.<span class="ruby-identifier">nil?</span>
|
471
|
+
<span class="ruby-identifier">utrs</span> <span class="ruby-operator"><<</span> [<span class="ruby-identifier">to_px</span>(<span class="ruby-identifier">utr</span>[<span class="ruby-value">0</span>] <span class="ruby-operator">-</span> <span class="ruby-ivar">@scale_start</span>), <span class="ruby-identifier">to_px</span>((<span class="ruby-identifier">utr</span>[<span class="ruby-value">1</span>] <span class="ruby-operator">-</span> <span class="ruby-ivar">@scale_start</span>) <span class="ruby-operator">-</span> (<span class="ruby-identifier">utr</span>[<span class="ruby-value">0</span>] <span class="ruby-operator">-</span> <span class="ruby-ivar">@scale_start</span>))]
|
472
|
+
<span class="ruby-keyword">end</span>
|
473
|
+
<span class="ruby-keyword">end</span>
|
474
|
+
<span class="ruby-identifier">f</span>.<span class="ruby-identifier">utrs</span> = <span class="ruby-identifier">utrs</span>
|
475
|
+
|
476
|
+
<span class="ruby-comment">#if there are any intron like gaps.. get where they would be</span>
|
477
|
+
<span class="ruby-keyword">if</span> <span class="ruby-keyword">not</span> <span class="ruby-identifier">all_sub_blocks</span>.<span class="ruby-identifier">empty?</span>
|
478
|
+
<span class="ruby-identifier">all_sub_blocks</span> = <span class="ruby-identifier">all_sub_blocks</span>.<span class="ruby-identifier">sort</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">a</span>, <span class="ruby-identifier">b</span><span class="ruby-operator">|</span> <span class="ruby-identifier">a</span>.<span class="ruby-identifier">first</span> <span class="ruby-operator"><=></span> <span class="ruby-identifier">b</span>.<span class="ruby-identifier">first</span> }
|
479
|
+
<span class="ruby-identifier">all_sub_blocks</span>.<span class="ruby-identifier">each_index</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">i</span><span class="ruby-operator">|</span>
|
480
|
+
<span class="ruby-keyword">next</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">i</span> <span class="ruby-operator">+</span> <span class="ruby-value">1</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">all_sub_blocks</span>.<span class="ruby-identifier">length</span> <span class="ruby-keyword">or</span> <span class="ruby-identifier">all_sub_blocks</span>[<span class="ruby-identifier">i</span>].<span class="ruby-identifier">last</span> <span class="ruby-operator">>=</span> <span class="ruby-identifier">all_sub_blocks</span>[<span class="ruby-identifier">i</span> <span class="ruby-operator">+</span> <span class="ruby-value">1</span>].<span class="ruby-identifier">first</span> <span class="ruby-comment">#skip if there is no gap</span>
|
481
|
+
<span class="ruby-identifier">f</span>.<span class="ruby-identifier">block_gaps</span> <span class="ruby-operator"><<</span> [<span class="ruby-identifier">to_px</span>(<span class="ruby-identifier">all_sub_blocks</span>[<span class="ruby-identifier">i</span>].<span class="ruby-identifier">last</span> <span class="ruby-operator">-</span> <span class="ruby-ivar">@scale_start</span>), <span class="ruby-identifier">to_px</span>((<span class="ruby-identifier">all_sub_blocks</span>[<span class="ruby-identifier">i</span> <span class="ruby-operator">+</span> <span class="ruby-value">1</span>].<span class="ruby-identifier">first</span> <span class="ruby-operator">-</span> <span class="ruby-ivar">@scale_start</span>) <span class="ruby-operator">-</span> (<span class="ruby-identifier">all_sub_blocks</span>[<span class="ruby-identifier">i</span>].<span class="ruby-identifier">last</span> <span class="ruby-operator">-</span> <span class="ruby-ivar">@scale_start</span>))]
|
482
|
+
<span class="ruby-keyword">end</span>
|
483
|
+
<span class="ruby-keyword">end</span>
|
484
|
+
|
485
|
+
<span class="ruby-identifier">width</span> = <span class="ruby-identifier">to_px</span>((<span class="ruby-identifier">f</span>.<span class="ruby-identifier">end</span> <span class="ruby-operator">-</span> <span class="ruby-ivar">@scale_start</span>) <span class="ruby-operator">-</span> (<span class="ruby-identifier">f</span>.<span class="ruby-identifier">start</span> <span class="ruby-operator">-</span> <span class="ruby-ivar">@scale_start</span>))
|
486
|
+
<span class="ruby-keyword">if</span> <span class="ruby-identifier">track</span>.<span class="ruby-identifier">min_width</span> <span class="ruby-keyword">and</span> <span class="ruby-identifier">width</span> <span class="ruby-operator"><</span> <span class="ruby-identifier">track</span>.<span class="ruby-identifier">min_width</span>
|
487
|
+
<span class="ruby-identifier">width</span> = <span class="ruby-identifier">track</span>.<span class="ruby-identifier">min_width</span>
|
488
|
+
<span class="ruby-keyword">end</span>
|
489
|
+
<span class="ruby-identifier">y</span> = <span class="ruby-ivar">@track_top</span> <span class="ruby-operator">+</span> (<span class="ruby-identifier">track</span>.<span class="ruby-identifier">feature_rows</span>[<span class="ruby-identifier">index</span>] <span class="ruby-operator">*</span> <span class="ruby-value">2</span> <span class="ruby-operator">*</span> <span class="ruby-identifier">track</span>.<span class="ruby-identifier">feature_height</span>)
|
490
|
+
|
491
|
+
<span class="ruby-keyword">self</span>.<span class="ruby-identifier">send</span>(<span class="ruby-node">"draw_#{track.glyph}"</span>, {<span class="ruby-value">:x</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">x</span>,
|
492
|
+
<span class="ruby-value">:y</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">y</span>,
|
493
|
+
<span class="ruby-value">:width</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">width</span>,
|
494
|
+
<span class="ruby-value">:strand</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">f</span>.<span class="ruby-identifier">strand</span>,
|
495
|
+
<span class="ruby-value">:exons</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">f</span>.<span class="ruby-identifier">exons</span>,
|
496
|
+
<span class="ruby-value">:utrs</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">f</span>.<span class="ruby-identifier">utrs</span>,
|
497
|
+
<span class="ruby-value">:block_gaps</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">f</span>.<span class="ruby-identifier">block_gaps</span>,
|
498
|
+
<span class="ruby-value">:height</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">track</span>.<span class="ruby-identifier">feature_height</span>
|
499
|
+
}.<span class="ruby-identifier">merge!</span>(<span class="ruby-identifier">track</span>.<span class="ruby-identifier">args</span>))
|
500
|
+
|
501
|
+
<span class="ruby-keyword">if</span> <span class="ruby-identifier">f</span>.<span class="ruby-identifier">id</span>
|
502
|
+
<span class="ruby-identifier">draw_label</span>(<span class="ruby-value">:y</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">y</span>, <span class="ruby-value">:x</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">x</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">width</span> <span class="ruby-value">+2</span>, <span class="ruby-value">:text</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">f</span>.<span class="ruby-identifier">id</span>)
|
503
|
+
<span class="ruby-keyword">end</span>
|
504
|
+
<span class="ruby-keyword">end</span>
|
505
|
+
<span class="ruby-ivar">@track_top</span> <span class="ruby-operator">+=</span> (<span class="ruby-identifier">track</span>.<span class="ruby-identifier">feature_height</span> <span class="ruby-operator">*</span> <span class="ruby-identifier">track</span>.<span class="ruby-identifier">number_rows</span> <span class="ruby-operator">*</span> <span class="ruby-value">2</span>) <span class="ruby-operator">+</span> <span class="ruby-value">20</span>
|
506
|
+
<span class="ruby-keyword">end</span>
|
507
|
+
|
508
|
+
<span class="ruby-ivar">@height</span> = <span class="ruby-ivar">@track_top</span> <span class="ruby-operator">+</span> <span class="ruby-value">100</span> <span class="ruby-comment">#fudge...</span>
|
509
|
+
<span class="ruby-ivar">@svg</span>.<span class="ruby-identifier">update_height</span>(<span class="ruby-ivar">@height</span>)
|
510
|
+
<span class="ruby-comment">#@svg.update_width(@width + 200)</span>
|
511
|
+
|
512
|
+
<span class="ruby-keyword">end</span></pre>
|
513
|
+
</div><!-- draw_features-source -->
|
514
|
+
|
515
|
+
</div>
|
516
|
+
|
517
|
+
|
518
|
+
|
519
|
+
|
520
|
+
</div><!-- draw_features-method -->
|
521
|
+
|
522
|
+
|
523
|
+
<div id="method-i-draw_generic" class="method-detail ">
|
524
|
+
|
525
|
+
<div class="method-heading">
|
526
|
+
<span class="method-name">draw_generic</span><span
|
527
|
+
class="method-args">(args)</span>
|
528
|
+
|
529
|
+
<span class="method-click-advice">click to toggle source</span>
|
530
|
+
|
531
|
+
</div>
|
532
|
+
|
533
|
+
|
534
|
+
<div class="method-description">
|
535
|
+
|
536
|
+
<p>Adds the <a href="Primitive.html">Bio::Graphics::Primitive</a> objects to
|
537
|
+
the <a href="SVGEE.html">SVGEE</a> object</p>
|
538
|
+
<ul><li>
|
539
|
+
<p><code>args</code> - an Array of <a
|
540
|
+
href="Primitive.html">Bio::Graphics::Primitive</a> objects of the stated
|
541
|
+
type</p>
|
542
|
+
</li></ul>
|
543
|
+
|
544
|
+
|
545
|
+
|
546
|
+
|
547
|
+
<div class="method-source-code" id="draw_generic-source">
|
548
|
+
<pre><span class="ruby-comment"># File lib/bio/graphics/page.rb, line 179</span>
|
549
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">draw_generic</span>(<span class="ruby-identifier">args</span>) <span class="ruby-comment">#remember presentation info comes from track@args when the track is defined</span>
|
550
|
+
<span class="ruby-constant">Glyph</span>.<span class="ruby-identifier">generic</span>(<span class="ruby-identifier">args</span>).<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">g</span><span class="ruby-operator">|</span> <span class="ruby-ivar">@svg</span>.<span class="ruby-identifier">add_primitive</span>(<span class="ruby-identifier">g</span>) }
|
551
|
+
<span class="ruby-keyword">end</span></pre>
|
552
|
+
</div><!-- draw_generic-source -->
|
553
|
+
|
554
|
+
</div>
|
555
|
+
|
556
|
+
|
557
|
+
|
558
|
+
|
559
|
+
</div><!-- draw_generic-method -->
|
560
|
+
|
561
|
+
|
562
|
+
<div id="method-i-draw_histogram" class="method-detail ">
|
563
|
+
|
564
|
+
<div class="method-heading">
|
565
|
+
<span class="method-name">draw_histogram</span><span
|
566
|
+
class="method-args">(args)</span>
|
567
|
+
|
568
|
+
<span class="method-click-advice">click to toggle source</span>
|
569
|
+
|
570
|
+
</div>
|
571
|
+
|
572
|
+
|
573
|
+
<div class="method-description">
|
574
|
+
|
575
|
+
<p>Adds the <a href="Primitive.html">Bio::Graphics::Primitive</a> objects to
|
576
|
+
the <a href="SVGEE.html">SVGEE</a> object</p>
|
577
|
+
<ul><li>
|
578
|
+
<p><code>args</code> - an Array of <a
|
579
|
+
href="Primitive.html">Bio::Graphics::Primitive</a> objects of the stated
|
580
|
+
type</p>
|
581
|
+
</li></ul>
|
582
|
+
|
583
|
+
|
584
|
+
|
585
|
+
|
586
|
+
<div class="method-source-code" id="draw_histogram-source">
|
587
|
+
<pre><span class="ruby-comment"># File lib/bio/graphics/page.rb, line 199</span>
|
588
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">draw_histogram</span>(<span class="ruby-identifier">args</span>)
|
589
|
+
<span class="ruby-constant">Glyph</span>.<span class="ruby-identifier">generic</span>(<span class="ruby-identifier">args</span>).<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">g</span><span class="ruby-operator">|</span> <span class="ruby-ivar">@svg</span>.<span class="ruby-identifier">add_primitive</span>(<span class="ruby-identifier">g</span>) }
|
590
|
+
<span class="ruby-keyword">end</span></pre>
|
591
|
+
</div><!-- draw_histogram-source -->
|
592
|
+
|
593
|
+
</div>
|
594
|
+
|
595
|
+
|
596
|
+
|
597
|
+
|
598
|
+
</div><!-- draw_histogram-method -->
|
599
|
+
|
600
|
+
|
601
|
+
<div id="method-i-draw_label" class="method-detail ">
|
602
|
+
|
603
|
+
<div class="method-heading">
|
604
|
+
<span class="method-name">draw_label</span><span
|
605
|
+
class="method-args">(args)</span>
|
606
|
+
|
607
|
+
<span class="method-click-advice">click to toggle source</span>
|
608
|
+
|
609
|
+
</div>
|
610
|
+
|
611
|
+
|
612
|
+
<div class="method-description">
|
613
|
+
|
614
|
+
<p>Adds the <a href="Primitive.html">Bio::Graphics::Primitive</a> objects to
|
615
|
+
the <a href="SVGEE.html">SVGEE</a> object</p>
|
616
|
+
<ul><li>
|
617
|
+
<p><code>args</code> - an Array of <a
|
618
|
+
href="Primitive.html">Bio::Graphics::Primitive</a> object</p>
|
619
|
+
</li></ul>
|
620
|
+
|
621
|
+
|
622
|
+
|
623
|
+
|
624
|
+
<div class="method-source-code" id="draw_label-source">
|
625
|
+
<pre><span class="ruby-comment"># File lib/bio/graphics/page.rb, line 172</span>
|
626
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">draw_label</span>(<span class="ruby-identifier">args</span>)
|
627
|
+
<span class="ruby-constant">Glyph</span>.<span class="ruby-identifier">label</span>(<span class="ruby-value">:text</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">args</span>[<span class="ruby-value">:text</span>],
|
628
|
+
<span class="ruby-value">:x</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">args</span>[<span class="ruby-value">:x</span>],
|
629
|
+
<span class="ruby-value">:y</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">args</span>[<span class="ruby-value">:y</span>]).<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">g</span><span class="ruby-operator">|</span> <span class="ruby-ivar">@svg</span>.<span class="ruby-identifier">add_primitive</span>(<span class="ruby-identifier">g</span>) }
|
630
|
+
<span class="ruby-keyword">end</span></pre>
|
631
|
+
</div><!-- draw_label-source -->
|
632
|
+
|
633
|
+
</div>
|
634
|
+
|
635
|
+
|
636
|
+
|
637
|
+
|
638
|
+
</div><!-- draw_label-method -->
|
639
|
+
|
640
|
+
|
641
|
+
<div id="method-i-draw_scale" class="method-detail ">
|
642
|
+
|
643
|
+
<div class="method-heading">
|
644
|
+
<span class="method-name">draw_scale</span><span
|
645
|
+
class="method-args">()</span>
|
646
|
+
|
647
|
+
<span class="method-click-advice">click to toggle source</span>
|
648
|
+
|
649
|
+
</div>
|
650
|
+
|
651
|
+
|
652
|
+
<div class="method-description">
|
653
|
+
|
654
|
+
<p>Adds the <a href="Primitive.html">Bio::Graphics::Primitive</a> objects to
|
655
|
+
the <a href="SVGEE.html">SVGEE</a> object</p>
|
656
|
+
|
657
|
+
|
658
|
+
|
659
|
+
|
660
|
+
<div class="method-source-code" id="draw_scale-source">
|
661
|
+
<pre><span class="ruby-comment"># File lib/bio/graphics/page.rb, line 165</span>
|
662
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">draw_scale</span>
|
663
|
+
<span class="ruby-constant">Glyph</span>.<span class="ruby-identifier">scale</span>(<span class="ruby-value">:start</span> =<span class="ruby-operator">></span> <span class="ruby-ivar">@scale_start</span>,
|
664
|
+
<span class="ruby-value">:stop</span> =<span class="ruby-operator">></span> <span class="ruby-ivar">@scale_stop</span>,
|
665
|
+
<span class="ruby-value">:number_of_intervals</span> =<span class="ruby-operator">></span> <span class="ruby-ivar">@num_intervals</span>, <span class="ruby-value">:page_width</span> =<span class="ruby-operator">></span> <span class="ruby-ivar">@width</span>).<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">g</span><span class="ruby-operator">|</span> <span class="ruby-ivar">@svg</span>.<span class="ruby-identifier">add_primitive</span>(<span class="ruby-identifier">g</span>) }
|
666
|
+
<span class="ruby-keyword">end</span></pre>
|
667
|
+
</div><!-- draw_scale-source -->
|
668
|
+
|
669
|
+
</div>
|
670
|
+
|
671
|
+
|
672
|
+
|
673
|
+
|
674
|
+
</div><!-- draw_scale-method -->
|
675
|
+
|
676
|
+
|
677
|
+
<div id="method-i-draw_span" class="method-detail ">
|
678
|
+
|
679
|
+
<div class="method-heading">
|
680
|
+
<span class="method-name">draw_span</span><span
|
681
|
+
class="method-args">(args)</span>
|
682
|
+
|
683
|
+
<span class="method-click-advice">click to toggle source</span>
|
684
|
+
|
685
|
+
</div>
|
686
|
+
|
687
|
+
|
688
|
+
<div class="method-description">
|
689
|
+
|
690
|
+
<p>Adds the <a href="Primitive.html">Bio::Graphics::Primitive</a> objects to
|
691
|
+
the <a href="SVGEE.html">SVGEE</a> object</p>
|
692
|
+
<ul><li>
|
693
|
+
<p><code>args</code> - an Array of <a
|
694
|
+
href="Primitive.html">Bio::Graphics::Primitive</a> objects of the stated
|
695
|
+
type</p>
|
696
|
+
</li></ul>
|
697
|
+
|
698
|
+
|
699
|
+
|
700
|
+
|
701
|
+
<div class="method-source-code" id="draw_span-source">
|
702
|
+
<pre><span class="ruby-comment"># File lib/bio/graphics/page.rb, line 214</span>
|
703
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">draw_span</span>(<span class="ruby-identifier">args</span>)
|
704
|
+
<span class="ruby-constant">Glyph</span>.<span class="ruby-identifier">span</span>(<span class="ruby-identifier">args</span>).<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">g</span><span class="ruby-operator">|</span> <span class="ruby-ivar">@svg</span>.<span class="ruby-identifier">add_primitive</span>(<span class="ruby-identifier">g</span>) }
|
705
|
+
<span class="ruby-keyword">end</span></pre>
|
706
|
+
</div><!-- draw_span-source -->
|
707
|
+
|
708
|
+
</div>
|
709
|
+
|
710
|
+
|
711
|
+
|
712
|
+
|
713
|
+
</div><!-- draw_span-method -->
|
714
|
+
|
715
|
+
|
716
|
+
<div id="method-i-draw_transcript" class="method-detail ">
|
717
|
+
|
718
|
+
<div class="method-heading">
|
719
|
+
<span class="method-name">draw_transcript</span><span
|
720
|
+
class="method-args">(args)</span>
|
721
|
+
|
722
|
+
<span class="method-click-advice">click to toggle source</span>
|
723
|
+
|
724
|
+
</div>
|
725
|
+
|
726
|
+
|
727
|
+
<div class="method-description">
|
728
|
+
|
729
|
+
<p>Adds the <a href="Primitive.html">Bio::Graphics::Primitive</a> objects to
|
730
|
+
the <a href="SVGEE.html">SVGEE</a> object</p>
|
731
|
+
<ul><li>
|
732
|
+
<p><code>args</code> - an Array of <a
|
733
|
+
href="Primitive.html">Bio::Graphics::Primitive</a> objects of the stated
|
734
|
+
type</p>
|
735
|
+
</li></ul>
|
736
|
+
|
737
|
+
|
738
|
+
|
739
|
+
|
740
|
+
<div class="method-source-code" id="draw_transcript-source">
|
741
|
+
<pre><span class="ruby-comment"># File lib/bio/graphics/page.rb, line 194</span>
|
742
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">draw_transcript</span>(<span class="ruby-identifier">args</span>)
|
743
|
+
<span class="ruby-constant">Glyph</span>.<span class="ruby-identifier">transcript</span>(<span class="ruby-identifier">args</span>).<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">g</span><span class="ruby-operator">|</span> <span class="ruby-ivar">@svg</span>.<span class="ruby-identifier">add_primitive</span>(<span class="ruby-identifier">g</span>) }
|
744
|
+
<span class="ruby-keyword">end</span></pre>
|
745
|
+
</div><!-- draw_transcript-source -->
|
746
|
+
|
747
|
+
</div>
|
748
|
+
|
749
|
+
|
750
|
+
|
751
|
+
|
752
|
+
</div><!-- draw_transcript-method -->
|
753
|
+
|
754
|
+
|
755
|
+
<div id="method-i-draw_up_triangle" class="method-detail ">
|
756
|
+
|
757
|
+
<div class="method-heading">
|
758
|
+
<span class="method-name">draw_up_triangle</span><span
|
759
|
+
class="method-args">(args)</span>
|
760
|
+
|
761
|
+
<span class="method-click-advice">click to toggle source</span>
|
762
|
+
|
763
|
+
</div>
|
764
|
+
|
765
|
+
|
766
|
+
<div class="method-description">
|
767
|
+
|
768
|
+
<p>Adds the <a href="Primitive.html">Bio::Graphics::Primitive</a> objects to
|
769
|
+
the <a href="SVGEE.html">SVGEE</a> object</p>
|
770
|
+
<ul><li>
|
771
|
+
<p><code>args</code> - an Array of <a
|
772
|
+
href="Primitive.html">Bio::Graphics::Primitive</a> objects of the stated
|
773
|
+
type</p>
|
774
|
+
</li></ul>
|
775
|
+
|
776
|
+
|
777
|
+
|
778
|
+
|
779
|
+
<div class="method-source-code" id="draw_up_triangle-source">
|
780
|
+
<pre><span class="ruby-comment"># File lib/bio/graphics/page.rb, line 204</span>
|
781
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">draw_up_triangle</span>(<span class="ruby-identifier">args</span>)
|
782
|
+
<span class="ruby-constant">Glyph</span>.<span class="ruby-identifier">up_triangle</span>(<span class="ruby-identifier">args</span>).<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">g</span><span class="ruby-operator">|</span> <span class="ruby-ivar">@svg</span>.<span class="ruby-identifier">add_primitive</span>(<span class="ruby-identifier">g</span>) }
|
783
|
+
<span class="ruby-keyword">end</span></pre>
|
784
|
+
</div><!-- draw_up_triangle-source -->
|
785
|
+
|
786
|
+
</div>
|
787
|
+
|
788
|
+
|
789
|
+
|
790
|
+
|
791
|
+
</div><!-- draw_up_triangle-method -->
|
792
|
+
|
793
|
+
|
794
|
+
<div id="method-i-get_limits" class="method-detail ">
|
795
|
+
|
796
|
+
<div class="method-heading">
|
797
|
+
<span class="method-name">get_limits</span><span
|
798
|
+
class="method-args">()</span>
|
799
|
+
|
800
|
+
<span class="method-click-advice">click to toggle source</span>
|
801
|
+
|
802
|
+
</div>
|
803
|
+
|
804
|
+
|
805
|
+
<div class="method-description">
|
806
|
+
|
807
|
+
<p>Calculates the <a href="Page.html">Page</a> scale-start and scale-stop
|
808
|
+
position and the nucleotides per pixel for the current <a
|
809
|
+
href="Page.html">Page</a></p>
|
810
|
+
|
811
|
+
|
812
|
+
|
813
|
+
|
814
|
+
<div class="method-source-code" id="get_limits-source">
|
815
|
+
<pre><span class="ruby-comment"># File lib/bio/graphics/page.rb, line 154</span>
|
816
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">get_limits</span>
|
817
|
+
<span class="ruby-ivar">@tracks</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">track</span><span class="ruby-operator">|</span>
|
818
|
+
<span class="ruby-identifier">lowest</span> = <span class="ruby-identifier">track</span>.<span class="ruby-identifier">features</span>.<span class="ruby-identifier">sort</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">x</span>, <span class="ruby-identifier">y</span><span class="ruby-operator">|</span> <span class="ruby-identifier">x</span>.<span class="ruby-identifier">start</span> <span class="ruby-operator"><=></span> <span class="ruby-identifier">y</span>.<span class="ruby-identifier">start</span> }.<span class="ruby-identifier">first</span>.<span class="ruby-identifier">start</span>
|
819
|
+
<span class="ruby-identifier">highest</span> = <span class="ruby-identifier">track</span>.<span class="ruby-identifier">features</span>.<span class="ruby-identifier">sort</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">x</span>, <span class="ruby-identifier">y</span><span class="ruby-operator">|</span> <span class="ruby-identifier">y</span>.<span class="ruby-identifier">end</span> <span class="ruby-operator"><=></span> <span class="ruby-identifier">x</span>.<span class="ruby-identifier">end</span> }.<span class="ruby-identifier">first</span>.<span class="ruby-identifier">end</span>
|
820
|
+
<span class="ruby-ivar">@scale_start</span> = <span class="ruby-identifier">lowest</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">lowest</span> <span class="ruby-operator"><</span> <span class="ruby-ivar">@scale_start</span>
|
821
|
+
<span class="ruby-ivar">@scale_stop</span> = <span class="ruby-identifier">highest</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">highest</span> <span class="ruby-operator">></span> <span class="ruby-ivar">@scale_stop</span>
|
822
|
+
<span class="ruby-ivar">@nt_per_px_x</span> = (<span class="ruby-ivar">@scale_stop</span> <span class="ruby-operator">-</span> <span class="ruby-ivar">@scale_start</span>).<span class="ruby-identifier">to_f</span> <span class="ruby-operator">/</span> <span class="ruby-ivar">@width</span>.<span class="ruby-identifier">to_f</span>
|
823
|
+
<span class="ruby-keyword">end</span>
|
824
|
+
<span class="ruby-keyword">end</span></pre>
|
825
|
+
</div><!-- get_limits-source -->
|
826
|
+
|
827
|
+
</div>
|
828
|
+
|
829
|
+
|
830
|
+
|
831
|
+
|
832
|
+
</div><!-- get_limits-method -->
|
833
|
+
|
834
|
+
|
835
|
+
<div id="method-i-get_markup" class="method-detail ">
|
836
|
+
|
837
|
+
<div class="method-heading">
|
838
|
+
<span class="method-name">get_markup</span><span
|
839
|
+
class="method-args">()</span>
|
840
|
+
|
841
|
+
<span class="method-click-advice">click to toggle source</span>
|
842
|
+
|
843
|
+
</div>
|
844
|
+
|
845
|
+
|
846
|
+
<div class="method-description">
|
847
|
+
|
848
|
+
<p>Pulls together all track information to create svg text which will draw all
|
849
|
+
the features on the page to scale Uses the methods <code>get_limits</code>
|
850
|
+
and <code>draw_scale</code> and then <code>draw_feature</code> for each
|
851
|
+
track on the page</p>
|
852
|
+
|
853
|
+
|
854
|
+
|
855
|
+
|
856
|
+
<div class="method-source-code" id="get_markup-source">
|
857
|
+
<pre><span class="ruby-comment"># File lib/bio/graphics/page.rb, line 323</span>
|
858
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">get_markup</span>
|
859
|
+
<span class="ruby-identifier">get_limits</span>
|
860
|
+
<span class="ruby-identifier">draw_scale</span>
|
861
|
+
<span class="ruby-ivar">@tracks</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">track</span><span class="ruby-operator">|</span>
|
862
|
+
<span class="ruby-identifier">draw_features</span>(<span class="ruby-identifier">track</span>)
|
863
|
+
<span class="ruby-keyword">end</span>
|
864
|
+
<span class="ruby-ivar">@svg</span>.<span class="ruby-identifier">draw</span>
|
865
|
+
<span class="ruby-keyword">end</span></pre>
|
866
|
+
</div><!-- get_markup-source -->
|
867
|
+
|
868
|
+
</div>
|
869
|
+
|
870
|
+
|
871
|
+
|
872
|
+
|
873
|
+
</div><!-- get_markup-method -->
|
874
|
+
|
875
|
+
|
876
|
+
<div id="method-i-to_px" class="method-detail ">
|
877
|
+
|
878
|
+
<div class="method-heading">
|
879
|
+
<span class="method-name">to_px</span><span
|
880
|
+
class="method-args">(num)</span>
|
881
|
+
|
882
|
+
<span class="method-click-advice">click to toggle source</span>
|
883
|
+
|
884
|
+
</div>
|
885
|
+
|
886
|
+
|
887
|
+
<div class="method-description">
|
888
|
+
|
889
|
+
<p>Provides the number of pixels required for a given number of nucleotides,
|
890
|
+
e.g the length of a certain exon</p>
|
891
|
+
<ul><li>
|
892
|
+
<p><code>num</code> - the number of nucleotides</p>
|
893
|
+
</li><li>
|
894
|
+
<p><code>returns</code> - the required number of pixels to draw the object</p>
|
895
|
+
</li></ul>
|
896
|
+
|
897
|
+
|
898
|
+
|
899
|
+
|
900
|
+
<div class="method-source-code" id="to_px-source">
|
901
|
+
<pre><span class="ruby-comment"># File lib/bio/graphics/page.rb, line 317</span>
|
902
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">to_px</span>(<span class="ruby-identifier">num</span>)
|
903
|
+
(<span class="ruby-identifier">num</span>.<span class="ruby-identifier">to_f</span> <span class="ruby-operator">/</span> <span class="ruby-ivar">@nt_per_px_x</span>.<span class="ruby-identifier">to_f</span>)
|
904
|
+
<span class="ruby-keyword">end</span></pre>
|
905
|
+
</div><!-- to_px-source -->
|
906
|
+
|
907
|
+
</div>
|
908
|
+
|
909
|
+
|
910
|
+
|
911
|
+
|
912
|
+
</div><!-- to_px-method -->
|
913
|
+
|
914
|
+
|
915
|
+
<div id="method-i-write" class="method-detail ">
|
916
|
+
|
917
|
+
<div class="method-heading">
|
918
|
+
<span class="method-name">write</span><span
|
919
|
+
class="method-args">(file)</span>
|
920
|
+
|
921
|
+
<span class="method-click-advice">click to toggle source</span>
|
922
|
+
|
923
|
+
</div>
|
924
|
+
|
925
|
+
|
926
|
+
<div class="method-description">
|
927
|
+
|
928
|
+
<p>Writes the svg text to a file</p>
|
929
|
+
<ul><li>
|
930
|
+
<p><code>file</code> - the file to which the svg text should be written</p>
|
931
|
+
</li></ul>
|
932
|
+
|
933
|
+
|
934
|
+
|
935
|
+
|
936
|
+
<div class="method-source-code" id="write-source">
|
937
|
+
<pre><span class="ruby-comment"># File lib/bio/graphics/page.rb, line 338</span>
|
938
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">write</span>(<span class="ruby-identifier">file</span>)
|
939
|
+
<span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">file</span>, <span class="ruby-string">'w'</span>).<span class="ruby-identifier">write</span>(<span class="ruby-identifier">get_markup</span>)
|
940
|
+
<span class="ruby-keyword">end</span></pre>
|
941
|
+
</div><!-- write-source -->
|
942
|
+
|
943
|
+
</div>
|
944
|
+
|
945
|
+
|
946
|
+
|
947
|
+
|
948
|
+
</div><!-- write-method -->
|
949
|
+
|
950
|
+
|
951
|
+
</section><!-- public-instance-method-details -->
|
952
|
+
|
953
|
+
<section id="public-class-5Buntitled-5D-method-details" class="method-section section">
|
954
|
+
<h3 class="section-header">Public Class Methods</h3>
|
955
|
+
|
956
|
+
|
957
|
+
<div id="method-c-from_json" class="method-detail ">
|
958
|
+
|
959
|
+
<div class="method-heading">
|
960
|
+
<span class="method-name">from_json</span><span
|
961
|
+
class="method-args">(args)</span>
|
962
|
+
|
963
|
+
<span class="method-click-advice">click to toggle source</span>
|
964
|
+
|
965
|
+
</div>
|
966
|
+
|
967
|
+
|
968
|
+
<div class="method-description">
|
969
|
+
|
970
|
+
<p>Takes a custom-written json file and writes an svg page to file which will
|
971
|
+
contain the given features described within the json file.</p>
|
972
|
+
<ul><li>
|
973
|
+
<p><code>args</code> - a custom-written json file describing the parameters
|
974
|
+
and resources needed for a new page</p>
|
975
|
+
</li></ul>
|
976
|
+
|
977
|
+
|
978
|
+
|
979
|
+
|
980
|
+
<div class="method-source-code" id="from_json-source">
|
981
|
+
<pre><span class="ruby-comment"># File lib/bio/graphics/page.rb, line 53</span>
|
982
|
+
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">from_json</span>(<span class="ruby-identifier">args</span>)
|
983
|
+
<span class="ruby-identifier">require</span> <span class="ruby-string">'rubygems'</span>
|
984
|
+
<span class="ruby-identifier">require</span> <span class="ruby-string">'json'</span>
|
985
|
+
<span class="ruby-identifier">data</span> = <span class="ruby-constant">JSON</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">args</span>[<span class="ruby-value">:json</span>], <span class="ruby-string">'r'</span>).<span class="ruby-identifier">read</span>)
|
986
|
+
<span class="ruby-identifier">p</span> = <span class="ruby-constant">Page</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">:width</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">data</span>[<span class="ruby-string">"Page"</span>][<span class="ruby-string">"width"</span>],
|
987
|
+
<span class="ruby-value">:height</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">data</span>[<span class="ruby-string">"Page"</span>][<span class="ruby-string">"height"</span>],
|
988
|
+
<span class="ruby-value">:number_of_intervals</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">data</span>[<span class="ruby-string">"Page"</span>][<span class="ruby-string">"intervals"</span>])
|
989
|
+
<span class="ruby-identifier">data</span>[<span class="ruby-string">"Tracks"</span>].<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">track</span><span class="ruby-operator">|</span>
|
990
|
+
<span class="ruby-comment">#prep the track args</span>
|
991
|
+
<span class="ruby-identifier">track_args</span> = <span class="ruby-identifier">track</span>.<span class="ruby-identifier">dup</span>
|
992
|
+
<span class="ruby-identifier">track_args</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-string">"file"</span>)
|
993
|
+
<span class="ruby-identifier">track_args</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-string">"file_type"</span>)
|
994
|
+
<span class="ruby-identifier">track_args</span> = <span class="ruby-identifier">track_args</span>.<span class="ruby-identifier">inject</span>({}) { <span class="ruby-operator">|</span><span class="ruby-identifier">memo</span>, (<span class="ruby-identifier">k</span>, <span class="ruby-identifier">v</span>)<span class="ruby-operator">|</span> <span class="ruby-identifier">memo</span>[<span class="ruby-identifier">k</span>.<span class="ruby-identifier">to_sym</span>] = <span class="ruby-identifier">v</span>; <span class="ruby-identifier">memo</span> }
|
995
|
+
<span class="ruby-comment">##convert any of the pre-made gradient strings in the keys to symbol</span>
|
996
|
+
<span class="ruby-identifier">track_args</span>.<span class="ruby-identifier">each_key</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">k</span><span class="ruby-operator">|</span>
|
997
|
+
<span class="ruby-keyword">next</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">track_args</span>[<span class="ruby-identifier">k</span>].<span class="ruby-identifier">respond_to?</span>(<span class="ruby-value">:to_sym</span>)
|
998
|
+
<span class="ruby-identifier">track_args</span>[<span class="ruby-identifier">k</span>] = <span class="ruby-identifier">track_args</span>[<span class="ruby-identifier">k</span>].<span class="ruby-identifier">to_sym</span> <span class="ruby-keyword">if</span> <span class="ruby-constant">Glyph</span>.<span class="ruby-identifier">gradients</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">track_args</span>[<span class="ruby-identifier">k</span>].<span class="ruby-identifier">to_sym</span>)
|
999
|
+
<span class="ruby-keyword">end</span>
|
1000
|
+
|
1001
|
+
<span class="ruby-identifier">svg_track</span> = <span class="ruby-identifier">p</span>.<span class="ruby-identifier">add_track</span>(<span class="ruby-identifier">track_args</span>)
|
1002
|
+
<span class="ruby-identifier">features</span> = [] <span class="ruby-comment">##set up the features...</span>
|
1003
|
+
|
1004
|
+
<span class="ruby-keyword">case</span> <span class="ruby-identifier">track</span>[<span class="ruby-string">"file_type"</span>] <span class="ruby-comment">##deal with the gff and data files</span>
|
1005
|
+
<span class="ruby-keyword">when</span> <span class="ruby-string">"gff"</span>
|
1006
|
+
<span class="ruby-identifier">groups</span> = {}
|
1007
|
+
<span class="ruby-identifier">parentless_features</span> = []
|
1008
|
+
<span class="ruby-constant">Page</span>.<span class="ruby-identifier">parse_gff</span>(<span class="ruby-identifier">track</span>[<span class="ruby-string">"file"</span>]).<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">gff</span><span class="ruby-operator">|</span> <span class="ruby-comment">#gets features in a list and links their children to them as members of the array at the key</span>
|
1009
|
+
<span class="ruby-identifier">parent_id</span> = <span class="ruby-identifier">gff</span>.<span class="ruby-identifier">attributes</span>.<span class="ruby-identifier">select</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">a</span><span class="ruby-operator">|</span> <span class="ruby-identifier">a</span>.<span class="ruby-identifier">first</span> <span class="ruby-operator">==</span> <span class="ruby-string">'Parent'</span> }
|
1010
|
+
<span class="ruby-keyword">if</span> <span class="ruby-identifier">parent_id</span>.<span class="ruby-identifier">empty?</span>
|
1011
|
+
<span class="ruby-identifier">parentless_features</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">gff</span>
|
1012
|
+
<span class="ruby-keyword">else</span>
|
1013
|
+
<span class="ruby-keyword">if</span> <span class="ruby-identifier">groups</span>[<span class="ruby-identifier">parent_id</span>.<span class="ruby-identifier">first</span>.<span class="ruby-identifier">last</span>].<span class="ruby-identifier">nil?</span>
|
1014
|
+
<span class="ruby-identifier">groups</span>[<span class="ruby-identifier">parent_id</span>.<span class="ruby-identifier">first</span>.<span class="ruby-identifier">last</span>] = []
|
1015
|
+
<span class="ruby-identifier">groups</span>[<span class="ruby-identifier">parent_id</span>.<span class="ruby-identifier">first</span>.<span class="ruby-identifier">last</span>] <span class="ruby-operator"><<</span> <span class="ruby-identifier">gff</span>
|
1016
|
+
<span class="ruby-keyword">else</span>
|
1017
|
+
<span class="ruby-identifier">groups</span>[<span class="ruby-identifier">parent_id</span>.<span class="ruby-identifier">first</span>.<span class="ruby-identifier">last</span>] <span class="ruby-operator"><<</span> <span class="ruby-identifier">gff</span>
|
1018
|
+
<span class="ruby-keyword">end</span>
|
1019
|
+
<span class="ruby-keyword">end</span>
|
1020
|
+
<span class="ruby-keyword">end</span>
|
1021
|
+
<span class="ruby-comment">#now flick through the parentless features and add any exons / UTRs</span>
|
1022
|
+
<span class="ruby-identifier">parentless_features</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">plf</span><span class="ruby-operator">|</span>
|
1023
|
+
<span class="ruby-identifier">require</span> <span class="ruby-string">'pp'</span>
|
1024
|
+
<span class="ruby-comment">#pp parentless_features</span>
|
1025
|
+
<span class="ruby-identifier">gff_id</span> = <span class="ruby-identifier">plf</span>.<span class="ruby-identifier">attributes</span>.<span class="ruby-identifier">select</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">a</span><span class="ruby-operator">|</span> <span class="ruby-identifier">a</span>.<span class="ruby-identifier">first</span> <span class="ruby-operator">==</span> <span class="ruby-string">'ID'</span> }
|
1026
|
+
<span class="ruby-identifier">gff_id</span> = <span class="ruby-identifier">gff_id</span>.<span class="ruby-identifier">first</span>.<span class="ruby-identifier">last</span>
|
1027
|
+
<span class="ruby-identifier">exons</span> = []
|
1028
|
+
<span class="ruby-identifier">utrs</span> = []
|
1029
|
+
<span class="ruby-identifier">children</span> = <span class="ruby-identifier">groups</span>[<span class="ruby-identifier">gff_id</span>] <span class="ruby-operator">||</span> <span class="ruby-identifier">children</span> = []
|
1030
|
+
<span class="ruby-identifier">children</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">child</span><span class="ruby-operator">|</span>
|
1031
|
+
<span class="ruby-keyword">if</span> <span class="ruby-identifier">child</span>.<span class="ruby-identifier">feature</span> <span class="ruby-operator">==</span> <span class="ruby-string">'exon'</span> <span class="ruby-keyword">or</span> <span class="ruby-identifier">child</span>.<span class="ruby-identifier">feature</span> <span class="ruby-operator">==</span> <span class="ruby-string">'CDS'</span>
|
1032
|
+
<span class="ruby-identifier">exons</span> <span class="ruby-operator">+=</span> [<span class="ruby-identifier">child</span>.<span class="ruby-identifier">start</span>, <span class="ruby-identifier">child</span>.<span class="ruby-identifier">end</span>]
|
1033
|
+
<span class="ruby-keyword">elsif</span> <span class="ruby-identifier">child</span>.<span class="ruby-identifier">feature</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp">/utr/</span>
|
1034
|
+
<span class="ruby-identifier">utrs</span> <span class="ruby-operator">+=</span> [<span class="ruby-identifier">child</span>.<span class="ruby-identifier">start</span>, <span class="ruby-identifier">child</span>.<span class="ruby-identifier">end</span>]
|
1035
|
+
<span class="ruby-keyword">end</span>
|
1036
|
+
<span class="ruby-keyword">end</span>
|
1037
|
+
<span class="ruby-identifier">features</span> <span class="ruby-operator"><<</span> <span class="ruby-constant">MiniFeature</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">:start</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">plf</span>.<span class="ruby-identifier">start</span>, <span class="ruby-value">:end</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">plf</span>.<span class="ruby-identifier">end</span>, <span class="ruby-value">:exons</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">exons</span>, <span class="ruby-value">:utrs</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">utrs</span>, <span class="ruby-value">:strand</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">plf</span>.<span class="ruby-identifier">strand</span>, <span class="ruby-value">:id</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">gff_id</span>)
|
1038
|
+
<span class="ruby-keyword">end</span> <span class="ruby-comment">#parentless features end</span>
|
1039
|
+
<span class="ruby-keyword">when</span> <span class="ruby-string">"data"</span>
|
1040
|
+
<span class="ruby-comment">##each line is a data feature</span>
|
1041
|
+
<span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">track</span>[<span class="ruby-string">"file"</span>], <span class="ruby-string">"r"</span>).<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">line</span><span class="ruby-operator">|</span>
|
1042
|
+
<span class="ruby-identifier">start</span>, <span class="ruby-identifier">stop</span>, <span class="ruby-identifier">value</span> = <span class="ruby-identifier">line</span>.<span class="ruby-identifier">split</span>(<span class="ruby-regexp">/\t/</span>)
|
1043
|
+
<span class="ruby-identifier">features</span> <span class="ruby-operator"><<</span> <span class="ruby-constant">MiniFeature</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">:start</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">start</span>.<span class="ruby-identifier">to_i</span>, <span class="ruby-value">:end</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">stop</span>.<span class="ruby-identifier">to_i</span>, <span class="ruby-value">:segment_height</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">value</span>.<span class="ruby-identifier">to_f</span>)
|
1044
|
+
<span class="ruby-keyword">end</span>
|
1045
|
+
<span class="ruby-keyword">end</span> <span class="ruby-comment">#data end</span>
|
1046
|
+
<span class="ruby-identifier">features</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">f</span><span class="ruby-operator">|</span> <span class="ruby-identifier">svg_track</span>.<span class="ruby-identifier">add</span>(<span class="ruby-identifier">f</span>) }
|
1047
|
+
<span class="ruby-keyword">end</span> <span class="ruby-comment">#track end</span>
|
1048
|
+
<span class="ruby-identifier">p</span>.<span class="ruby-identifier">write</span>(<span class="ruby-identifier">args</span>[<span class="ruby-value">:outfile</span>])
|
1049
|
+
<span class="ruby-keyword">end</span></pre>
|
1050
|
+
</div><!-- from_json-source -->
|
1051
|
+
|
1052
|
+
</div>
|
1053
|
+
|
1054
|
+
|
1055
|
+
|
1056
|
+
|
1057
|
+
</div><!-- from_json-method -->
|
1058
|
+
|
1059
|
+
|
1060
|
+
<div id="method-c-new" class="method-detail ">
|
1061
|
+
|
1062
|
+
<div class="method-heading">
|
1063
|
+
<span class="method-name">new</span><span
|
1064
|
+
class="method-args">(args)</span>
|
1065
|
+
|
1066
|
+
<span class="method-click-advice">click to toggle source</span>
|
1067
|
+
|
1068
|
+
</div>
|
1069
|
+
|
1070
|
+
|
1071
|
+
<div class="method-description">
|
1072
|
+
|
1073
|
+
<p>Creates a new <a href="Page.html">Page</a> object.</p>
|
1074
|
+
|
1075
|
+
<p>A new <a href="Page.html">Page</a> contains the following arguments:</p>
|
1076
|
+
<ul><li>
|
1077
|
+
<p>height = the height of the page</p>
|
1078
|
+
</li><li>
|
1079
|
+
<p>width = the width of the page</p>
|
1080
|
+
</li><li>
|
1081
|
+
<p>style = includes the a background colour</p>
|
1082
|
+
</li><li>
|
1083
|
+
<p>svg = a new <a href="SVGEE.html">SVGEE</a> object</p>
|
1084
|
+
</li><li>
|
1085
|
+
<p>scale_start = the scale-start of the page (1.0/0.0)</p>
|
1086
|
+
</li><li>
|
1087
|
+
<p>scale_stop = the scale-stop of the page (-1.0/0.0)</p>
|
1088
|
+
</li><li>
|
1089
|
+
<p>tracks = an array of track objects with loads of features in it…</p>
|
1090
|
+
</li><li>
|
1091
|
+
<p>nt_per_percent = the number of nucleotides that are represented by 1% of
|
1092
|
+
the page (1);</p>
|
1093
|
+
</li><li>
|
1094
|
+
<p>num_intervals = the number of intervals</p>
|
1095
|
+
</li><li>
|
1096
|
+
<p>track_top = the position of the top of the first track (30)</p>
|
1097
|
+
</li></ul>
|
1098
|
+
|
1099
|
+
<p>A new page maybe set up as follows:</p>
|
1100
|
+
|
1101
|
+
<pre class="ruby"><span class="ruby-ivar">@page</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">Page</span>.<span class="ruby-identifier">new</span>(:<span class="ruby-identifier">width</span> =<span class="ruby-operator">></span> <span class="ruby-value">800</span>,
|
1102
|
+
:<span class="ruby-identifier">height</span> =<span class="ruby-operator">></span> <span class="ruby-value">110</span>, :<span class="ruby-identifier">number_of_intervals</span> =<span class="ruby-operator">></span> <span class="ruby-value">10</span>)
|
1103
|
+
</pre>
|
1104
|
+
|
1105
|
+
|
1106
|
+
|
1107
|
+
|
1108
|
+
<div class="method-source-code" id="new-source">
|
1109
|
+
<pre><span class="ruby-comment"># File lib/bio/graphics/page.rb, line 30</span>
|
1110
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">args</span>)
|
1111
|
+
<span class="ruby-ivar">@height</span> = <span class="ruby-identifier">args</span>[<span class="ruby-value">:height</span>]
|
1112
|
+
<span class="ruby-ivar">@width</span> = <span class="ruby-identifier">args</span>[<span class="ruby-value">:width</span>]
|
1113
|
+
<span class="ruby-identifier">args</span>[<span class="ruby-value">:style</span>] = <span class="ruby-node">"background-color:#{args[:background_color]};"</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">args</span>[<span class="ruby-value">:background_color</span>]
|
1114
|
+
<span class="ruby-ivar">@svg</span> = <span class="ruby-constant">SVGEE</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">args</span>)
|
1115
|
+
<span class="ruby-ivar">@scale_start</span> = <span class="ruby-value">1.0</span><span class="ruby-operator">/</span><span class="ruby-value">0.0</span>
|
1116
|
+
<span class="ruby-ivar">@scale_stop</span> = <span class="ruby-value">-1.0</span><span class="ruby-operator">/</span><span class="ruby-value">0.0</span>
|
1117
|
+
<span class="ruby-ivar">@tracks</span> = [] <span class="ruby-comment">#array of track objects with loads of features in it...</span>
|
1118
|
+
<span class="ruby-ivar">@nt_per_percent</span> = <span class="ruby-value">1</span>;
|
1119
|
+
<span class="ruby-ivar">@num_intervals</span> = <span class="ruby-identifier">args</span>[<span class="ruby-value">:number_of_intervals</span>]
|
1120
|
+
<span class="ruby-ivar">@track_top</span> = <span class="ruby-value">30</span>
|
1121
|
+
|
1122
|
+
<span class="ruby-keyword">def</span> <span class="ruby-ivar">@svg</span>.<span class="ruby-identifier">update_height</span>(<span class="ruby-identifier">height</span>)
|
1123
|
+
<span class="ruby-ivar">@height</span> = <span class="ruby-identifier">height</span>
|
1124
|
+
<span class="ruby-keyword">end</span>
|
1125
|
+
|
1126
|
+
<span class="ruby-comment">#def @svg.update_width(width)</span>
|
1127
|
+
<span class="ruby-comment"># @width = width</span>
|
1128
|
+
<span class="ruby-comment">#end</span>
|
1129
|
+
<span class="ruby-keyword">end</span></pre>
|
1130
|
+
</div><!-- new-source -->
|
1131
|
+
|
1132
|
+
</div>
|
1133
|
+
|
1134
|
+
|
1135
|
+
|
1136
|
+
|
1137
|
+
</div><!-- new-method -->
|
1138
|
+
|
1139
|
+
|
1140
|
+
<div id="method-c-parse_gff" class="method-detail ">
|
1141
|
+
|
1142
|
+
<div class="method-heading">
|
1143
|
+
<span class="method-name">parse_gff</span><span
|
1144
|
+
class="method-args">(gff_file)</span>
|
1145
|
+
|
1146
|
+
<span class="method-click-advice">click to toggle source</span>
|
1147
|
+
|
1148
|
+
</div>
|
1149
|
+
|
1150
|
+
|
1151
|
+
<div class="method-description">
|
1152
|
+
|
1153
|
+
<p>Parses a GFF file into an Array of <a
|
1154
|
+
href="http://bioruby.org/rdoc/Bio/GFF/GFF3/Record.html">Bio::GFF::GFF3::Record</a>
|
1155
|
+
objects</p>
|
1156
|
+
<ul><li>
|
1157
|
+
<p><code>gff_file</code> - a GFF-formatted file</p>
|
1158
|
+
</li><li>
|
1159
|
+
<p><code>returns</code> - an Array of <a
|
1160
|
+
href="http://bioruby.org/rdoc/Bio/GFF/GFF3/Record.html">Bio::GFF::GFF3::Record</a>
|
1161
|
+
objects</p>
|
1162
|
+
</li></ul>
|
1163
|
+
|
1164
|
+
|
1165
|
+
|
1166
|
+
|
1167
|
+
<div class="method-source-code" id="parse_gff-source">
|
1168
|
+
<pre><span class="ruby-comment"># File lib/bio/graphics/page.rb, line 125</span>
|
1169
|
+
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">parse_gff</span>(<span class="ruby-identifier">gff_file</span>)
|
1170
|
+
<span class="ruby-identifier">require</span> <span class="ruby-string">'bio'</span>
|
1171
|
+
<span class="ruby-identifier">a</span> = []
|
1172
|
+
<span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">gff_file</span>).<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">line</span><span class="ruby-operator">|</span>
|
1173
|
+
<span class="ruby-keyword">next</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">line</span> <span class="ruby-operator">=~</span> <span class="ruby-node">/^#/</span>
|
1174
|
+
<span class="ruby-identifier">a</span> <span class="ruby-operator"><<</span> <span class="ruby-constant">Bio</span><span class="ruby-operator">::</span><span class="ruby-constant">GFF</span><span class="ruby-operator">::</span><span class="ruby-constant">GFF3</span><span class="ruby-operator">::</span><span class="ruby-constant">Record</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">line</span>)
|
1175
|
+
<span class="ruby-keyword">end</span>
|
1176
|
+
<span class="ruby-identifier">a</span>
|
1177
|
+
<span class="ruby-keyword">end</span></pre>
|
1178
|
+
</div><!-- parse_gff-source -->
|
1179
|
+
|
1180
|
+
</div>
|
1181
|
+
|
1182
|
+
|
1183
|
+
|
1184
|
+
|
1185
|
+
</div><!-- parse_gff-method -->
|
1186
|
+
|
1187
|
+
|
1188
|
+
</section><!-- public-class-method-details -->
|
1189
|
+
|
1190
|
+
</section><!-- 5Buntitled-5D -->
|
1191
|
+
|
1192
|
+
</div><!-- documentation -->
|
1193
|
+
|
1194
|
+
|
1195
|
+
<footer id="validator-badges">
|
1196
|
+
<p><a href="http://validator.w3.org/check/referer">[Validate]</a>
|
1197
|
+
<p>Generated by <a href="https://github.com/rdoc/rdoc">RDoc</a> 4.0.0.rc.2.1.
|
1198
|
+
<p>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish Rdoc Generator</a> 3.
|
1199
|
+
</footer>
|
1200
|
+
|