-
Notifications
You must be signed in to change notification settings - Fork 1
/
parp.rb
39 lines (31 loc) · 1.13 KB
/
parp.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
require 'yaml'
require 'open-uri'
class MySketch < Processing::App
end
require File.dirname(__FILE__) + '/lib/sketch.rb'
CONFIG_FILE = File.dirname(__FILE__) + '/data/config.yml'
config = YAML::load(File.open(CONFIG_FILE))
WIDTH = config['width']
HEIGHT = config['height']
DATA_DIRECTORY = config['data_directory']
if WIDTH.nil? or HEIGHT.nil? or DATA_DIRECTORY.nil?
STDERR.puts "[ERROR] At least width, height and data_directory have to be specified in config file"
exit
end
S = MySketch.new :title => "My Sketch", :width => WIDTH, :height => HEIGHT, :data_directory => DATA_DIRECTORY
# Apply zooms as defined in config file
until S.initialized
sleep 1
end
unless config['loci'].nil?
config['loci'].each do |locus|
center_bp = ((locus['start'] + locus['stop']).to_f/2).floor
center_bp += S.chromosomes[locus['chromosome'].to_s].start_cumulative_bp
length_bp = locus['stop'] - locus['start'] + 1
length_pixel = (S.circumference.to_f/3).floor
Slice.add(center_bp, length_bp, length_pixel)
end
S.buffer_images[:zoomed] = S.draw_zoomed_buffer
S.buffer_images[:information_panel] = S.draw_information_panel
S.redraw
end