-
Notifications
You must be signed in to change notification settings - Fork 5
/
Rakefile
94 lines (87 loc) · 3.39 KB
/
Rakefile
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
require_relative 'lib/subscreens'
c = nil
task :default => :check
# Set JS_DEBUG=1 before the rake invocation to disable javascript minification
JS_DEBUG = ENV['JS_DEBUG']
directory "bin"
REQUIRED_LINKS = {
"bigBedSummary" => "http://hgdownload.cse.ucsc.edu/admin/exe/",
"bigBedToBed" => "http://hgdownload.cse.ucsc.edu/admin/exe/",
"bigBedInfo" => "http://hgdownload.cse.ucsc.edu/admin/exe/",
"bigWigSummary" => "http://hgdownload.cse.ucsc.edu/admin/exe/",
"bigWigInfo" => "http://hgdownload.cse.ucsc.edu/admin/exe/",
"twoBitToFa" => "http://hgdownload.cse.ucsc.edu/admin/exe/",
"tabix" => "http://www.htslib.org/download/",
"samtools" => "http://www.htslib.org/download/"
}
REQUIRED_LINK_WARN = <<-EOS
WARN: could not find the following in your $PATH: %1$s
You will need this program to fetch data for the web frontend.
To acquire %2$s, try visiting the following sites:
- %3$s
EOS
$missing_links = {:names=>[], :urls=>[]}
REQUIRED_LINKS.each do |l, url|
file "bin/#{l}" do |t|
which = `which #{l}`.strip
if which.size > 0 then ln_s which, t.name
else $missing_links[:names] << l; $missing_links[:urls] << url; end
end
end
REQUIRED_SCRAPING_BINS = {
"fetchChromSizes"=>"http://hgdownload.cse.ucsc.edu/admin/exe/",
"bedToBigBed"=>"http://hgdownload.cse.ucsc.edu/admin/exe/",
"curl"=>"https://curl.haxx.se/"
}
REQUIRED_SCRAPING_BINS_WARN = <<-EOS
WARN: could not find the following in your $PATH: %1$s
You don't need this program to serve the web frontend of ChromoZoom,
but you do need it to scrape track data from UCSC.
To acquire %2$s, try visiting the following sites:
- %3$s
EOS
file "ucsc.yaml" do
cp "ucsc.dist.yaml", "ucsc.yaml"
end
file ".git/hooks/pre-commit" do
ln_sf "../../git-hooks-pre-commit.sh", ".git/hooks/pre-commit"
end
directory "build"
JAVASCRIPTS = ["build/chromozoom.js", "build/CustomGenomeWorker.js", "build/CustomTrackWorker.js"]
def sources_for_javascript(js)
Dir.glob('js/**/*.js').sort_by{ |src| src.match(/#{File.basename js}$/) ? -1 : 1 }
end
rule /^build\/.+\.js$/ => proc { |js| sources_for_javascript js } do |t|
if JS_DEBUG
sh "browserify #{t.sources.first} -d -o #{t.name}"
else
sh "browserify #{t.sources.first} | uglifyjs > #{t.name}"
end
end
desc "Builds minified (production) ChromoZoom javascripts, outputting them in build/"
task :browserify => JAVASCRIPTS
desc "Builds debuggable versions of ChromoZoom javascripts, updating them upon file save"
task :watchify do
# Useful for development. Compiles in debug mode (with source maps) while you edit the source.
cmds = JAVASCRIPTS.map{ |js| "watchify -d #{sources_for_javascript(js).first} -o #{js} -v"}
Subscreens.split(JAVASCRIPTS.size, cmds)
end
desc "Checks that all requirements for ChromoZoom are in place"
REQUIREMENTS = ["ucsc.yaml", "bin", ".git/hooks/pre-commit"] + REQUIRED_LINKS.keys.map{|l| "bin/#{l}" }
task :check => [:browserify] + REQUIREMENTS do |t|
missing = REQUIRED_SCRAPING_BINS.keys.select{|b| `which #{b}`.strip.size == 0 }
if missing.size > 0
puts REQUIRED_SCRAPING_BINS_WARN % [
missing.join(", "),
missing.size > 1 ? "them" : "it",
REQUIRED_SCRAPING_BINS.values_at(*missing).uniq.join("\n - ")
]
end
if $missing_links[:names].size > 0
fail REQUIRED_LINK_WARN % [
$missing_links[:names].join(", "),
$missing_links[:names].size > 1 ? "them" : "it",
$missing_links[:urls].uniq.join("\n - ")
]
end
end