bio-svgenes 0.2.2 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION +1 -1
- data/bio-svgenes.gemspec +4 -3
- data/examples/draw_from_json.rb +0 -1
- data/examples/make_example.rb +291 -0
- data/lib/bio/graphics/glyph.rb +53 -1
- data/lib/bio/graphics/page.rb +22 -2
- data/lib/bio/graphics/track.rb +2 -1
- metadata +63 -96
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.2.
|
|
1
|
+
0.2.3
|
data/bio-svgenes.gemspec
CHANGED
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
|
|
6
6
|
Gem::Specification.new do |s|
|
|
7
7
|
s.name = "bio-svgenes"
|
|
8
|
-
s.version = "0.2.
|
|
8
|
+
s.version = "0.2.3"
|
|
9
9
|
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
|
11
11
|
s.authors = ["Dan MacLean"]
|
|
12
|
-
s.date = "2013-01-
|
|
12
|
+
s.date = "2013-01-30"
|
|
13
13
|
s.description = "This bio-gem facilitates the creation of pretty, publication quality SVG images from feature data."
|
|
14
14
|
s.email = "maclean.daniel@gmail.com"
|
|
15
15
|
s.extra_rdoc_files = [
|
|
@@ -38,6 +38,7 @@ Gem::Specification.new do |s|
|
|
|
38
38
|
"examples/example_config.json",
|
|
39
39
|
"examples/gene.gff",
|
|
40
40
|
"examples/get_coverage_in_windows.rb",
|
|
41
|
+
"examples/make_example.rb",
|
|
41
42
|
"examples/transcripts.gff",
|
|
42
43
|
"lib/.DS_Store",
|
|
43
44
|
"lib/bio-svgenes.rb",
|
|
@@ -54,7 +55,7 @@ Gem::Specification.new do |s|
|
|
|
54
55
|
s.homepage = "http://github.com/danmaclean/bioruby-svgenes"
|
|
55
56
|
s.licenses = ["MIT"]
|
|
56
57
|
s.require_paths = ["lib"]
|
|
57
|
-
s.rubygems_version = "1.8.
|
|
58
|
+
s.rubygems_version = "1.8.10"
|
|
58
59
|
s.summary = "Create pretty SVG-format images of features, gene models and data tracks"
|
|
59
60
|
|
|
60
61
|
if s.respond_to? :specification_version then
|
data/examples/draw_from_json.rb
CHANGED
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
#
|
|
3
|
+
# untitled
|
|
4
|
+
#
|
|
5
|
+
# Created by Dan MacLean (TSL) on 2013-01-18.
|
|
6
|
+
# Copyright (c) . All rights reserved.
|
|
7
|
+
###################################################
|
|
8
|
+
|
|
9
|
+
##to do:
|
|
10
|
+
## background colour
|
|
11
|
+
## single nt features : minimum size on circles, squares, triangles, diamonds, span (t bar)
|
|
12
|
+
## label sizes
|
|
13
|
+
## label positions
|
|
14
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
|
15
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
|
16
|
+
require 'bio-svgenes'
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
page = Bio::Graphics::Page.new(
|
|
21
|
+
:width => 800,
|
|
22
|
+
:height => 200,
|
|
23
|
+
:number_of_intervals => 10,
|
|
24
|
+
:background_color => "#F8F8F8"
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def new_gene_track_on page
|
|
29
|
+
page.add_track(
|
|
30
|
+
:glyph => :directed,
|
|
31
|
+
:height => 15,
|
|
32
|
+
:name => "Genes",
|
|
33
|
+
:label => true,
|
|
34
|
+
:stroke => :green,
|
|
35
|
+
:fill_color => :green_white_h
|
|
36
|
+
)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def new_mRNA_track_on page
|
|
40
|
+
page.add_track(
|
|
41
|
+
:glyph => :transcript,
|
|
42
|
+
:name => "mRNA",
|
|
43
|
+
:height => 15,
|
|
44
|
+
:label => true,
|
|
45
|
+
:exon_stroke => :black,
|
|
46
|
+
:exon_stroke_width => 1,
|
|
47
|
+
:exon_fill_color => :blue,
|
|
48
|
+
:utr_fill_color => :purple,
|
|
49
|
+
:utr_stroke => :black,
|
|
50
|
+
:utr_stroke_width => 1,
|
|
51
|
+
:gap_marker => 'angled',
|
|
52
|
+
:line_color => :black,
|
|
53
|
+
:style => "fill-opacity:0.4;"
|
|
54
|
+
)
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def new_te_insertion_site_track_on page
|
|
58
|
+
page.add_track(
|
|
59
|
+
:glyph => :circle,
|
|
60
|
+
:name => "TE Insertions",
|
|
61
|
+
:label => true,
|
|
62
|
+
:fill_color => :blue,
|
|
63
|
+
:radius => 3,
|
|
64
|
+
:stroke => :blue,
|
|
65
|
+
:stroke_width => 0.5,
|
|
66
|
+
:style => "fill-opacity:0.4;"
|
|
67
|
+
)
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def new_cDNA_match_track_on page
|
|
71
|
+
page.add_track(
|
|
72
|
+
:glyph => :directed,
|
|
73
|
+
:name => "cDNA matches",
|
|
74
|
+
:label => true,
|
|
75
|
+
:stroke => :red,
|
|
76
|
+
:height => 15,
|
|
77
|
+
:fill_color => :red_white_h
|
|
78
|
+
)
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def new_microarray_probe_track_on page
|
|
83
|
+
page.add_track(
|
|
84
|
+
:glyph => :generic,
|
|
85
|
+
:height => 15,
|
|
86
|
+
:name => "Microarray probes",
|
|
87
|
+
:label => true,
|
|
88
|
+
:fill_color => 'green',
|
|
89
|
+
:stroke_width => 0,
|
|
90
|
+
:style => "fill-opacity:1.0;"
|
|
91
|
+
)
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
def new_insertion_track_on page
|
|
95
|
+
page.add_track(
|
|
96
|
+
:glyph => :down_triangle,
|
|
97
|
+
:name => "Insertions",
|
|
98
|
+
:label => true,
|
|
99
|
+
:min_width => 6,
|
|
100
|
+
:fill_color => :red,
|
|
101
|
+
:stroke_width => 0,
|
|
102
|
+
:style => "fill-opacity:0.4;"
|
|
103
|
+
)
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
def new_deletion_track_on page
|
|
108
|
+
page.add_track(
|
|
109
|
+
:glyph => :up_triangle,
|
|
110
|
+
:name => "Deletions",
|
|
111
|
+
:label => true,
|
|
112
|
+
:fill_color => :green,
|
|
113
|
+
:min_width => 6,
|
|
114
|
+
:stroke_width => 0,
|
|
115
|
+
:style => "fill-opacity:0.4;"
|
|
116
|
+
)
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
def new_marker_track_on page
|
|
120
|
+
page.add_track(
|
|
121
|
+
:glyph => :span,
|
|
122
|
+
:height => 20,
|
|
123
|
+
:name => "Markers",
|
|
124
|
+
:label => true,
|
|
125
|
+
:stroke => :orange,
|
|
126
|
+
:stroke_width => 15
|
|
127
|
+
)
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
all_features = Bio::Graphics::Page.parse_gff( ARGV[0] )
|
|
132
|
+
puts all_features.length
|
|
133
|
+
#all_features.collect {|f| f.feature }.uniq.each do | feature_type |
|
|
134
|
+
['gene', 'mRNA','cDNA_match', 'microarray_probe', 'insertion','deletion','substitution','transposable_element_insertion_site'].each do |feature_type|
|
|
135
|
+
#['gene', 'mRNA','cDNA_match', 'microarray_probe','transposable_element_insertion_site'].each do |feature_type|
|
|
136
|
+
puts "rendering #{feature_type}"
|
|
137
|
+
case feature_type
|
|
138
|
+
when 'gene'
|
|
139
|
+
track = new_gene_track_on page
|
|
140
|
+
all_features.select {|f| f.feature == feature_type }.each do |feature|
|
|
141
|
+
mf = Bio::Graphics::MiniFeature.new(
|
|
142
|
+
:start => feature.start,
|
|
143
|
+
:end => feature.end,
|
|
144
|
+
:strand => feature.strand,
|
|
145
|
+
:id => feature.attributes.select {|a| a.first == 'Name'}.first.last
|
|
146
|
+
)
|
|
147
|
+
track.add(mf)
|
|
148
|
+
end
|
|
149
|
+
when 'cDNA_match'
|
|
150
|
+
track = new_cDNA_match_track_on page
|
|
151
|
+
all_features.select {|f| f.feature == feature_type }.each do |feature|
|
|
152
|
+
mf = Bio::Graphics::MiniFeature.new(
|
|
153
|
+
:start => feature.start,
|
|
154
|
+
:strand => feature.strand,
|
|
155
|
+
:end => feature.end
|
|
156
|
+
)
|
|
157
|
+
track.add(mf)
|
|
158
|
+
end
|
|
159
|
+
when 'mRNA'
|
|
160
|
+
track = new_mRNA_track_on page
|
|
161
|
+
five_utrs = all_features.select {|x| x.feature_type == 'five_prime_UTR'}
|
|
162
|
+
three_utrs = all_features.select {|z| z.feature_type == 'three_prime_UTR'}
|
|
163
|
+
all_exons = all_features.select {|z| z.feature_type == 'CDS'}
|
|
164
|
+
require 'pp'
|
|
165
|
+
pp all_exons
|
|
166
|
+
all_features.select {|f| f.feature == feature_type }.each do |feature|
|
|
167
|
+
|
|
168
|
+
feature_id = feature.attributes.select {|y| y.first == "ID"}.first.last
|
|
169
|
+
five_utr = five_utrs.select {|x| x.attributes_to_hash["Parent"] == feature_id }.first
|
|
170
|
+
three_utr = three_utrs.select {|z| z.attributes_to_hash["Parent"] == feature_id }.first
|
|
171
|
+
utrs = []
|
|
172
|
+
if not five_utr.nil? and not three_utr.nil?
|
|
173
|
+
utrs = [five_utr.start,five_utr.end, three_utr.start,three_utr.end]
|
|
174
|
+
require 'pp'
|
|
175
|
+
utrs.sort!
|
|
176
|
+
|
|
177
|
+
end
|
|
178
|
+
exons = []
|
|
179
|
+
exons = all_exons.select {|x| x.attributes_to_hash["Parent"] == feature_id }
|
|
180
|
+
exons = exons.collect {|x| [x.start, x.end] }.flatten
|
|
181
|
+
#if not exons.empty?
|
|
182
|
+
# exons = exons.sort
|
|
183
|
+
#end
|
|
184
|
+
mf = Bio::Graphics::MiniFeature.new(
|
|
185
|
+
:start => feature.start,
|
|
186
|
+
:end => feature.end,
|
|
187
|
+
:utrs => utrs,
|
|
188
|
+
:exons => exons,
|
|
189
|
+
:strand => feature.strand
|
|
190
|
+
)
|
|
191
|
+
track.add(mf)
|
|
192
|
+
end
|
|
193
|
+
when 'microarray_probe'
|
|
194
|
+
track = new_microarray_probe_track_on page
|
|
195
|
+
all_features.select {|f| f.feature == feature_type }.each do |feature|
|
|
196
|
+
mf = Bio::Graphics::MiniFeature.new(
|
|
197
|
+
:start => feature.start,
|
|
198
|
+
:strand => feature.strand,
|
|
199
|
+
:end => feature.end
|
|
200
|
+
)
|
|
201
|
+
track.add(mf)
|
|
202
|
+
end
|
|
203
|
+
when 'transposable_element_insertion_site'
|
|
204
|
+
track = new_te_insertion_site_track_on page
|
|
205
|
+
all_features.select {|f| f.feature == feature_type }.each do |feature|
|
|
206
|
+
mf = Bio::Graphics::MiniFeature.new(
|
|
207
|
+
:start => feature.start,
|
|
208
|
+
:strand => feature.strand,
|
|
209
|
+
:end => feature.end
|
|
210
|
+
)
|
|
211
|
+
track.add(mf)
|
|
212
|
+
end
|
|
213
|
+
when 'insertion'
|
|
214
|
+
track = new_insertion_track_on page
|
|
215
|
+
all_features.select {|f| f.feature == feature_type }.each do |feature|
|
|
216
|
+
mf = Bio::Graphics::MiniFeature.new(
|
|
217
|
+
:start => feature.start,
|
|
218
|
+
:end => feature.end
|
|
219
|
+
)
|
|
220
|
+
track.add(mf)
|
|
221
|
+
end
|
|
222
|
+
when 'deletion'
|
|
223
|
+
track = new_deletion_track_on page
|
|
224
|
+
all_features.select {|f| f.feature == feature_type }.each do |feature|
|
|
225
|
+
mf = Bio::Graphics::MiniFeature.new(
|
|
226
|
+
:start => feature.start,
|
|
227
|
+
:end => feature.end
|
|
228
|
+
)
|
|
229
|
+
track.add(mf)
|
|
230
|
+
end
|
|
231
|
+
when 'marker'
|
|
232
|
+
track = new_marker_track_on page
|
|
233
|
+
all_features.select {|f| f.feature == feature_type }.each do |feature|
|
|
234
|
+
mf = Bio::Graphics::MiniFeature.new(
|
|
235
|
+
:start => feature.start,
|
|
236
|
+
:end => feature.end
|
|
237
|
+
)
|
|
238
|
+
track.add(mf)
|
|
239
|
+
end
|
|
240
|
+
end
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
end
|
|
244
|
+
|
|
245
|
+
data_track1 = page.add_track(:glyph => :histogram, #might also be :density or heatmap ##page doesn't know how to deal with individual file types, rather page object takes a list of values (e.g bar heights) from pre-processed data source and renders those
|
|
246
|
+
:stroke_color => 'black',
|
|
247
|
+
:fill_color => :blue,
|
|
248
|
+
:track_height => 75,
|
|
249
|
+
:name => 'Simulated NGS coverage (transformed sine function)',
|
|
250
|
+
:label => true,
|
|
251
|
+
:stroke_width => 0,
|
|
252
|
+
:style => "fill-opacity:0.6;"
|
|
253
|
+
|
|
254
|
+
)
|
|
255
|
+
##generate a load of data, each data point becomes a feature...
|
|
256
|
+
data = (19597235..19637234).step(10) do |start|
|
|
257
|
+
#data = (19616011..19618459).step(1) do |start|
|
|
258
|
+
height = Math::sin(start)
|
|
259
|
+
height = height * -1 if height < 0
|
|
260
|
+
height = Math::log(height)
|
|
261
|
+
height = height * -1 if height < 0
|
|
262
|
+
data_feature = Bio::Graphics::MiniFeature.new(:start => start,
|
|
263
|
+
:end => start + 30,
|
|
264
|
+
:segment_height => height * 10
|
|
265
|
+
)
|
|
266
|
+
data_track1.add(data_feature)
|
|
267
|
+
|
|
268
|
+
end
|
|
269
|
+
|
|
270
|
+
data_track2 = page.add_track(:glyph => :histogram, #might also be :density or heatmap ##page doesn't know how to deal with individual file types, rather page object takes a list of values (e.g bar heights) from pre-processed data source and renders those
|
|
271
|
+
:stroke_color => 'black',
|
|
272
|
+
:fill_color => :yellow,
|
|
273
|
+
:track_height => 75,
|
|
274
|
+
:name => 'Random bar height',
|
|
275
|
+
:label => true,
|
|
276
|
+
:stroke_width => 1,
|
|
277
|
+
:style => "fill-opacity:0.4;"
|
|
278
|
+
|
|
279
|
+
)
|
|
280
|
+
##generate a load of data, each data point becomes a feature...
|
|
281
|
+
data = (19597235..19637234).step(200) do |start|
|
|
282
|
+
#data = (19616011..19618459).step(30) do |start|
|
|
283
|
+
data_feature = Bio::Graphics::MiniFeature.new(:start => start,
|
|
284
|
+
:end => start + 200,
|
|
285
|
+
:segment_height => rand(30)
|
|
286
|
+
)
|
|
287
|
+
data_track2.add(data_feature)
|
|
288
|
+
|
|
289
|
+
end
|
|
290
|
+
|
|
291
|
+
page.write( "out.svg" )
|
data/lib/bio/graphics/glyph.rb
CHANGED
|
@@ -3,7 +3,7 @@ module Bio
|
|
|
3
3
|
class Glyph
|
|
4
4
|
attr_reader :glyphs
|
|
5
5
|
#holds a load of definitions for glyphs .. a glyph is an array of primitives...
|
|
6
|
-
@glyphs = [:generic, :directed, :transcript, :scale, :label, :histogram]
|
|
6
|
+
@glyphs = [:generic, :directed, :transcript, :scale, :label, :histogram, :circle, :down_triangle, :up_triangle, :span]
|
|
7
7
|
|
|
8
8
|
def self.generic(args) #:x, :y, :width :fill, :stroke :stroke_width, :style, :height,
|
|
9
9
|
args = {
|
|
@@ -17,6 +17,20 @@ class Glyph
|
|
|
17
17
|
[Bio::Graphics::Primitive.new(:rectangle, args)]
|
|
18
18
|
end
|
|
19
19
|
|
|
20
|
+
def self.circle(args)
|
|
21
|
+
args = {
|
|
22
|
+
:radius => 10,
|
|
23
|
+
:fill_color => 'red',
|
|
24
|
+
:stroke => "black",
|
|
25
|
+
:stroke_width => 1,
|
|
26
|
+
:style => ""}.merge!(args)
|
|
27
|
+
args[:x_center] = args[:x]
|
|
28
|
+
args[:y_center] = args[:y]
|
|
29
|
+
[:x, :y].each {|e| args.delete(e)}
|
|
30
|
+
[Bio::Graphics::Primitive.new(:circle, args)]
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
|
|
20
34
|
def self.directed(args) #:x, :y, :width :fill, :stroke :stroke_width, :style, :height
|
|
21
35
|
args = {
|
|
22
36
|
|
|
@@ -34,6 +48,44 @@ class Glyph
|
|
|
34
48
|
[Bio::Graphics::Primitive.new(:polygon, args)]
|
|
35
49
|
end
|
|
36
50
|
|
|
51
|
+
def self.down_triangle(args) #:x, :y, :width :fill, :stroke :stroke_width, :style, :height
|
|
52
|
+
args = {
|
|
53
|
+
|
|
54
|
+
:height => 10,
|
|
55
|
+
:fill_color => 'red',
|
|
56
|
+
:stroke => "black",
|
|
57
|
+
:stroke_width => 1,
|
|
58
|
+
:style => "fill-opacity:0.4;"}.merge!(args)
|
|
59
|
+
args[:points] = "#{args[:x]},#{args[:y]} #{args[:x] + args[:width]},#{args[:y]} #{ args[:x] + (args[:width]/2) },#{(args[:y] + args[:height]) }"
|
|
60
|
+
[Bio::Graphics::Primitive.new(:polygon, args)]
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def self.up_triangle(args) #:x, :y, :width :fill, :stroke :stroke_width, :style, :height
|
|
64
|
+
args = {
|
|
65
|
+
:height => 10,
|
|
66
|
+
:fill_color => 'red',
|
|
67
|
+
:stroke => "black",
|
|
68
|
+
:stroke_width => 1,
|
|
69
|
+
:style => "fill-opacity:0.4;"}.merge!(args)
|
|
70
|
+
args[:points] = "#{args[:x]},#{args[:y] + args[:height]} #{args[:x] + args[:width]},#{args[:y] + args[:height]} #{ args[:x] + (args[:width]/2) },#{args[:y] }"
|
|
71
|
+
[Bio::Graphics::Primitive.new(:polygon, args)]
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def self.span(args)
|
|
75
|
+
args = {
|
|
76
|
+
:height => 10,
|
|
77
|
+
:fill_color => 'red',
|
|
78
|
+
:stroke => "black",
|
|
79
|
+
:stroke_width => 1,
|
|
80
|
+
:style => "fill-opacity:1;"
|
|
81
|
+
}.merge!(args)
|
|
82
|
+
args[:x1] = args[:x]
|
|
83
|
+
args[:x2] = args[:x] + args[:width]
|
|
84
|
+
args[:y1] = args[:y]
|
|
85
|
+
args[:y2] = args[:y]
|
|
86
|
+
[Bio::Graphics::Primitive.new(:line, args)]
|
|
87
|
+
end
|
|
88
|
+
|
|
37
89
|
def self.transcript(args)
|
|
38
90
|
args = {
|
|
39
91
|
:height => 10,
|
data/lib/bio/graphics/page.rb
CHANGED
|
@@ -5,6 +5,7 @@ class Page
|
|
|
5
5
|
def initialize(args)
|
|
6
6
|
@height = args[:height]
|
|
7
7
|
@width = args[:width]
|
|
8
|
+
args[:style] = "background-color:#{args[:background_color]};" if args[:background_color]
|
|
8
9
|
@svg = SVGEE.new(args)
|
|
9
10
|
@scale_start = 1.0/0.0
|
|
10
11
|
@scale_stop = -1.0/0.0
|
|
@@ -25,7 +26,6 @@ class Page
|
|
|
25
26
|
def self.from_json(args)
|
|
26
27
|
require 'rubygems'
|
|
27
28
|
require 'json'
|
|
28
|
-
puts "memememe"
|
|
29
29
|
data = JSON.parse(File.open(args[:json], 'r').read)
|
|
30
30
|
p = Page.new(:width => data["Page"]["width"],
|
|
31
31
|
:height => data["Page"]["height"],
|
|
@@ -64,6 +64,8 @@ class Page
|
|
|
64
64
|
end
|
|
65
65
|
#now flick through the parentless features and add any exons / UTRs
|
|
66
66
|
parentless_features.each do |plf|
|
|
67
|
+
require 'pp'
|
|
68
|
+
pp parentless_features
|
|
67
69
|
gff_id = plf.attributes.select {|a| a.first == 'ID'}
|
|
68
70
|
gff_id = gff_id.first.last
|
|
69
71
|
exons = []
|
|
@@ -146,6 +148,10 @@ class Page
|
|
|
146
148
|
Glyph.directed(args).each {|g| @svg.add_primitive(g) }
|
|
147
149
|
end
|
|
148
150
|
|
|
151
|
+
def draw_circle(args)
|
|
152
|
+
Glyph.circle(args).each {|g| @svg.add_primitive(g) }
|
|
153
|
+
end
|
|
154
|
+
|
|
149
155
|
def draw_transcript(args)
|
|
150
156
|
Glyph.transcript(args).each {|g| @svg.add_primitive(g) }
|
|
151
157
|
end
|
|
@@ -154,6 +160,18 @@ class Page
|
|
|
154
160
|
Glyph.generic(args).each {|g| @svg.add_primitive(g) }
|
|
155
161
|
end
|
|
156
162
|
|
|
163
|
+
def draw_up_triangle(args)
|
|
164
|
+
Glyph.up_triangle(args).each {|g| @svg.add_primitive(g) }
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
def draw_down_triangle(args)
|
|
168
|
+
Glyph.down_triangle(args).each {|g| @svg.add_primitive(g) }
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
def draw_span(args)
|
|
172
|
+
Glyph.span(args).each {|g| @svg.add_primitive(g) }
|
|
173
|
+
end
|
|
174
|
+
|
|
157
175
|
def draw_features(track) #sort out the input information into a user friendly format..
|
|
158
176
|
if [:histogram, "histogram"].include?(track.glyph) #do different stuff for data tracks...
|
|
159
177
|
|
|
@@ -219,7 +237,9 @@ class Page
|
|
|
219
237
|
end
|
|
220
238
|
|
|
221
239
|
width = to_px( (f.end - @scale_start) - (f.start - @scale_start) )
|
|
222
|
-
|
|
240
|
+
if track.min_width and width < track.min_width
|
|
241
|
+
width = track.min_width
|
|
242
|
+
end
|
|
223
243
|
y = @track_top + (track.feature_rows[index] * 2 * track.feature_height)
|
|
224
244
|
|
|
225
245
|
self.send("draw_#{track.glyph}", {:x => x,
|
data/lib/bio/graphics/track.rb
CHANGED
|
@@ -2,7 +2,7 @@ module Bio
|
|
|
2
2
|
class Graphics
|
|
3
3
|
|
|
4
4
|
class Track
|
|
5
|
-
attr_reader :glyph, :name, :label, :args, :track_height, :scale, :max_y
|
|
5
|
+
attr_reader :glyph, :name, :label, :args, :track_height, :scale, :max_y, :min_width
|
|
6
6
|
attr_accessor :features, :feature_rows, :name, :number_rows, :feature_height
|
|
7
7
|
def initialize(args)
|
|
8
8
|
@args = {:glyph => :generic,
|
|
@@ -20,6 +20,7 @@ class Track
|
|
|
20
20
|
@feature_height = @args[:feature_height]
|
|
21
21
|
@number_of_rows = 1
|
|
22
22
|
@max_y = args[:max_y]
|
|
23
|
+
@min_width = args[:min_width]
|
|
23
24
|
|
|
24
25
|
|
|
25
26
|
end
|
metadata
CHANGED
|
@@ -1,108 +1,80 @@
|
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: bio-svgenes
|
|
3
|
-
version: !ruby/object:Gem::Version
|
|
4
|
-
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.2.3
|
|
5
5
|
prerelease:
|
|
6
|
-
segments:
|
|
7
|
-
- 0
|
|
8
|
-
- 2
|
|
9
|
-
- 2
|
|
10
|
-
version: 0.2.2
|
|
11
6
|
platform: ruby
|
|
12
|
-
authors:
|
|
7
|
+
authors:
|
|
13
8
|
- Dan MacLean
|
|
14
9
|
autorequire:
|
|
15
10
|
bindir: bin
|
|
16
11
|
cert_chain: []
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
- !ruby/object:Gem::Dependency
|
|
21
|
-
type: :development
|
|
22
|
-
prerelease: false
|
|
23
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
|
24
|
-
none: false
|
|
25
|
-
requirements:
|
|
26
|
-
- - ">="
|
|
27
|
-
- !ruby/object:Gem::Version
|
|
28
|
-
hash: 3
|
|
29
|
-
segments:
|
|
30
|
-
- 0
|
|
31
|
-
version: "0"
|
|
32
|
-
version_requirements: *id001
|
|
12
|
+
date: 2013-01-30 00:00:00.000000000 Z
|
|
13
|
+
dependencies:
|
|
14
|
+
- !ruby/object:Gem::Dependency
|
|
33
15
|
name: shoulda
|
|
34
|
-
|
|
16
|
+
requirement: &70232196114400 !ruby/object:Gem::Requirement
|
|
17
|
+
none: false
|
|
18
|
+
requirements:
|
|
19
|
+
- - ! '>='
|
|
20
|
+
- !ruby/object:Gem::Version
|
|
21
|
+
version: '0'
|
|
35
22
|
type: :development
|
|
36
23
|
prerelease: false
|
|
37
|
-
|
|
24
|
+
version_requirements: *70232196114400
|
|
25
|
+
- !ruby/object:Gem::Dependency
|
|
26
|
+
name: bundler
|
|
27
|
+
requirement: &70232196113480 !ruby/object:Gem::Requirement
|
|
38
28
|
none: false
|
|
39
|
-
requirements:
|
|
29
|
+
requirements:
|
|
40
30
|
- - ~>
|
|
41
|
-
- !ruby/object:Gem::Version
|
|
42
|
-
hash: 23
|
|
43
|
-
segments:
|
|
44
|
-
- 1
|
|
45
|
-
- 0
|
|
46
|
-
- 0
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
47
32
|
version: 1.0.0
|
|
48
|
-
version_requirements: *id002
|
|
49
|
-
name: bundler
|
|
50
|
-
- !ruby/object:Gem::Dependency
|
|
51
33
|
type: :development
|
|
52
34
|
prerelease: false
|
|
53
|
-
|
|
35
|
+
version_requirements: *70232196113480
|
|
36
|
+
- !ruby/object:Gem::Dependency
|
|
37
|
+
name: jeweler
|
|
38
|
+
requirement: &70232196112820 !ruby/object:Gem::Requirement
|
|
54
39
|
none: false
|
|
55
|
-
requirements:
|
|
40
|
+
requirements:
|
|
56
41
|
- - ~>
|
|
57
|
-
- !ruby/object:Gem::Version
|
|
58
|
-
hash: 7
|
|
59
|
-
segments:
|
|
60
|
-
- 1
|
|
61
|
-
- 6
|
|
62
|
-
- 4
|
|
42
|
+
- !ruby/object:Gem::Version
|
|
63
43
|
version: 1.6.4
|
|
64
|
-
version_requirements: *id003
|
|
65
|
-
name: jeweler
|
|
66
|
-
- !ruby/object:Gem::Dependency
|
|
67
44
|
type: :development
|
|
68
45
|
prerelease: false
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
requirements:
|
|
72
|
-
- - ">="
|
|
73
|
-
- !ruby/object:Gem::Version
|
|
74
|
-
hash: 3
|
|
75
|
-
segments:
|
|
76
|
-
- 0
|
|
77
|
-
version: "0"
|
|
78
|
-
version_requirements: *id004
|
|
46
|
+
version_requirements: *70232196112820
|
|
47
|
+
- !ruby/object:Gem::Dependency
|
|
79
48
|
name: rcov
|
|
80
|
-
|
|
49
|
+
requirement: &70232196111740 !ruby/object:Gem::Requirement
|
|
50
|
+
none: false
|
|
51
|
+
requirements:
|
|
52
|
+
- - ! '>='
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '0'
|
|
81
55
|
type: :development
|
|
82
56
|
prerelease: false
|
|
83
|
-
|
|
57
|
+
version_requirements: *70232196111740
|
|
58
|
+
- !ruby/object:Gem::Dependency
|
|
59
|
+
name: bio
|
|
60
|
+
requirement: &70232196111080 !ruby/object:Gem::Requirement
|
|
84
61
|
none: false
|
|
85
|
-
requirements:
|
|
86
|
-
- -
|
|
87
|
-
- !ruby/object:Gem::Version
|
|
88
|
-
hash: 3
|
|
89
|
-
segments:
|
|
90
|
-
- 1
|
|
91
|
-
- 4
|
|
92
|
-
- 2
|
|
62
|
+
requirements:
|
|
63
|
+
- - ! '>='
|
|
64
|
+
- !ruby/object:Gem::Version
|
|
93
65
|
version: 1.4.2
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
66
|
+
type: :development
|
|
67
|
+
prerelease: false
|
|
68
|
+
version_requirements: *70232196111080
|
|
69
|
+
description: This bio-gem facilitates the creation of pretty, publication quality
|
|
70
|
+
SVG images from feature data.
|
|
97
71
|
email: maclean.daniel@gmail.com
|
|
98
72
|
executables: []
|
|
99
|
-
|
|
100
73
|
extensions: []
|
|
101
|
-
|
|
102
|
-
extra_rdoc_files:
|
|
74
|
+
extra_rdoc_files:
|
|
103
75
|
- LICENSE.txt
|
|
104
76
|
- README.rdoc
|
|
105
|
-
files:
|
|
77
|
+
files:
|
|
106
78
|
- .DS_Store
|
|
107
79
|
- .document
|
|
108
80
|
- Gemfile
|
|
@@ -124,6 +96,7 @@ files:
|
|
|
124
96
|
- examples/example_config.json
|
|
125
97
|
- examples/gene.gff
|
|
126
98
|
- examples/get_coverage_in_windows.rb
|
|
99
|
+
- examples/make_example.rb
|
|
127
100
|
- examples/transcripts.gff
|
|
128
101
|
- lib/.DS_Store
|
|
129
102
|
- lib/bio-svgenes.rb
|
|
@@ -137,37 +110,31 @@ files:
|
|
|
137
110
|
- test/helper.rb
|
|
138
111
|
- test/test_bio-svgenes.rb
|
|
139
112
|
homepage: http://github.com/danmaclean/bioruby-svgenes
|
|
140
|
-
licenses:
|
|
113
|
+
licenses:
|
|
141
114
|
- MIT
|
|
142
115
|
post_install_message:
|
|
143
116
|
rdoc_options: []
|
|
144
|
-
|
|
145
|
-
require_paths:
|
|
117
|
+
require_paths:
|
|
146
118
|
- lib
|
|
147
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
|
119
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
148
120
|
none: false
|
|
149
|
-
requirements:
|
|
150
|
-
- -
|
|
151
|
-
- !ruby/object:Gem::Version
|
|
152
|
-
|
|
153
|
-
segments:
|
|
121
|
+
requirements:
|
|
122
|
+
- - ! '>='
|
|
123
|
+
- !ruby/object:Gem::Version
|
|
124
|
+
version: '0'
|
|
125
|
+
segments:
|
|
154
126
|
- 0
|
|
155
|
-
|
|
156
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
127
|
+
hash: 1694400785006489552
|
|
128
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
157
129
|
none: false
|
|
158
|
-
requirements:
|
|
159
|
-
- -
|
|
160
|
-
- !ruby/object:Gem::Version
|
|
161
|
-
|
|
162
|
-
segments:
|
|
163
|
-
- 0
|
|
164
|
-
version: "0"
|
|
130
|
+
requirements:
|
|
131
|
+
- - ! '>='
|
|
132
|
+
- !ruby/object:Gem::Version
|
|
133
|
+
version: '0'
|
|
165
134
|
requirements: []
|
|
166
|
-
|
|
167
135
|
rubyforge_project:
|
|
168
|
-
rubygems_version: 1.8.
|
|
136
|
+
rubygems_version: 1.8.10
|
|
169
137
|
signing_key:
|
|
170
138
|
specification_version: 3
|
|
171
139
|
summary: Create pretty SVG-format images of features, gene models and data tracks
|
|
172
140
|
test_files: []
|
|
173
|
-
|