Method: Bio::Graphics::Panel#initialize
- Defined in:
- lib/bio/graphics/panel.rb
#initialize(length, opts = {}) ⇒ Panel
Create a new Bio::Graphics::Panel object
g = Bio::Graphics::Panel.new(456)
The height of the image is calculated automatically depending on how many tracks and features it contains. The width of the image defaults to 800 pt but can be set manually by using the width argument to the opts hash:
g = Bio::Graphics::Panel.new(456, :width => 1200)
See also: Bio::Graphics::Panel::Track, Bio::Graphics::Panel::Track::Feature
Arguments:
- length
-
length of the thing you want to visualize, e.g for
visualizing a sequence that is 3.24 kb long, use 324. (required)
- :width
-
width of the resulting image in pixels. (default: 800)
- :clickable
-
whether the picture should have clickable glyphs or not
(default: false) If set to true, a html file will be created with the map.
- :display_start
-
start coordinate to be displayed (default: 1)
- :display_stop
-
stop coordinate to be displayed (default: length of sequence)
- :vertical
-
Boolean: false = horizontal (= default)
- :format
-
File format of the picture. Can be :png, :svg, :pdf or :ps
(default: :png)
- Returns
-
Bio::Graphics::Panel object
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 |
# File 'lib/bio/graphics/panel.rb', line 110 def initialize(length, opts = {}) @length = length opts = { :width => DEFAULT_PANEL_WIDTH, :display_range => Range.new(0,@length), :vertical => false, :clickable => false, :format => :png }.merge(opts) @width = opts[:width].to_i @display_range = opts[:display_range] @display_start = [0, @display_range.lend].max @display_stop = [@length,@display_range.rend].min if @display_stop <= @display_start raise "[ERROR] Start coordinate to be displayed has to be smaller than stop coordinate." end @display_range = Range.new(@display_start,@display_stop) @vertical = opts[:vertical] @clickable = opts[:clickable] @format = opts[:format] if ! [:png, :svg, :pdf, :ps].include?(@format) raise "[ERROR] Format has to be one of :png, :svg, :pdf or :ps." end @tracks = Array.new @number_of_feature_rows = 0 @image_map = ImageMap.new @rescale_factor = (@display_stop - @display_start).to_f / @width # To prevent that we do the whole drawing thing multiple times @final_panel_destination = nil end |