bio-svgenes 0.3.3 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.3
1
+ 0.4.0
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "bio-svgenes"
8
- s.version = "0.3.3"
8
+ s.version = "0.4.0"
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-06-06"
12
+ s.date = "2014-01-03"
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 = [
@@ -431,9 +431,8 @@ attr_reader :glyphs
431
431
  :stroke_width => args[:exon_stroke_width],
432
432
  :style => args[:exon_style]} )
433
433
  end
434
- if args[:exons].length > 1
435
- if args[:gap_marker] == "angled" and not args[:block_gaps].empty?
436
- $stderr.puts args[:exons].length
434
+ if not args[:block_gaps].empty?
435
+ if args[:gap_marker] == "angled"
437
436
  args[:block_gaps].each do |gap|
438
437
  points = "#{gap.first},#{args[:y] + (args[:height]/2) } #{gap.first + (gap.last/2)},#{args[:y]} #{gap.first + gap.last},#{args[:y] + (args[:height]/2)}"
439
438
  composite << Bio::Graphics::Primitive.new(:polyline, {
@@ -5,7 +5,7 @@ module Bio
5
5
  #A Bio::Graphics::MiniFeature object represents a single genomic feature (e.g. a gene, transcript, exon, start codon, etc), it is a lightweight object that
6
6
  #holds the minimum information needed to do the render.
7
7
  class MiniFeature
8
- attr_accessor :start, :end, :strand, :exons, :utrs, :block_gaps, :segment_height, :id
8
+ attr_accessor :start, :end, :strand, :exons, :utrs, :block_gaps, :segment_height, :id, :params
9
9
  #Creates a new MiniFeature
10
10
  #
11
11
  #== args
@@ -41,8 +41,9 @@ class MiniFeature
41
41
  @block_gaps = []
42
42
  @id = args[:id]
43
43
  @segment_height = args[:segment_height]
44
+ @params = args[:params]
44
45
  end
45
46
  end
46
47
 
47
48
  end
48
- end
49
+ end
@@ -227,6 +227,18 @@ module Bio
227
227
  @scale_stop = highest if highest > @scale_stop
228
228
  @nt_per_px_x = (@scale_stop - @scale_start).to_f / @width.to_f
229
229
  end
230
+ begin
231
+ old_nt_per_px_x = @nt_per_px_x
232
+ @tracks.each do |track|
233
+ highest = track.features.map { |feat|
234
+ feat_end = feat.end
235
+ feat_end += (8 * @nt_per_px_x * feat.id.to_s.length).to_i if feat.id
236
+ feat_end
237
+ }.max
238
+ @scale_stop = highest if highest > @scale_stop
239
+ @nt_per_px_x = (@scale_stop - @scale_start).to_f / @width.to_f
240
+ end
241
+ end while (@nt_per_px_x - old_nt_per_px_x).abs > 1
230
242
  end
231
243
 
232
244
  #Adds scale bar to the list of objects to be rendered in the final
@@ -358,7 +370,8 @@ module Bio
358
370
  :exons => f.exons,
359
371
  :utrs => f.utrs,
360
372
  :block_gaps => f.block_gaps,
361
- :height => track.feature_height
373
+ :height => track.feature_height,
374
+ :params => f.params
362
375
  }.merge!(track.args))
363
376
 
364
377
  if f.id
@@ -398,4 +411,4 @@ module Bio
398
411
  end
399
412
  end
400
413
  end
401
- end
414
+ end
@@ -81,7 +81,10 @@ class SVGEE
81
81
  end
82
82
 
83
83
  def common_attributes(a={})
84
- %{stroke="#{a[:stroke]}" stroke-width="#{a[:stroke_width]}" style="#{a[:style]}"}
84
+ param_str = ""
85
+ a[:params].each{|k,v| param_str << %{ #{k}="#{v}"}} if a[:params]
86
+
87
+ %{stroke="#{a[:stroke]}" stroke-width="#{a[:stroke_width]}" style="#{a[:style]}"} + param_str
85
88
  end
86
89
 
87
90
  def method_missing(primitive, args={}) #only used to dynamically select the primitive type..
@@ -142,4 +145,4 @@ prim.update(:x_center => 200)
142
145
  s.add_primitive(prim) #add one of the returned, updated Primitive objects
143
146
 
144
147
  s.draw
145
- =end
148
+ =end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bio-svgenes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.4.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-06-06 00:00:00.000000000 Z
12
+ date: 2014-01-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: shoulda
@@ -333,7 +333,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
333
333
  version: '0'
334
334
  segments:
335
335
  - 0
336
- hash: -2909691261569895312
336
+ hash: -4059527771038564991
337
337
  required_rubygems_version: !ruby/object:Gem::Requirement
338
338
  none: false
339
339
  requirements: