-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathRakefile
More file actions
119 lines (98 loc) · 2.89 KB
/
Rakefile
File metadata and controls
119 lines (98 loc) · 2.89 KB
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
require 'yaml'
PROCS = `gnproc`.to_i
tmp = YAML.load_file(ENV.key?('CONF') ? ENV['CONF'] : 'conf.yaml')
CONF = tmp['LIBS']
DEFAULTS = tmp['DEFAULTS']
LIBIDS = ENV.key?('LIBS') ? ENV['LIBS'].split(',') : CONF.keys
WELLIDS = Array.new
['A', 'B', 'C', 'D', 'E', 'F'].each do |col|
1.upto(8).each do |row|
WELLIDS.push("#{col}#{row}")
end
end
LIBWELLIDS = Array.new
LIBIDS.each do |libid|
WELLIDS.each do |wellid|
LIBWELLIDS.push("#{libid}.#{wellid}")
end
end
##
require 'csv'
require 'spreadsheet'
rule '.xls' => '.csv' do |t|
book = Spreadsheet::Workbook.new
sheet = book.create_worksheet
csv = CSV.read(t.source)
sheet.row(0).replace csv.first
table = CSV.table(t.source)
rowidx = 1
table.each do |row|
sheet.row(rowidx).replace row.fields
rowidx += 1
end
book.write(t.name)
end
##
qc_targets = Array.new
LIBIDS.each do |libid|
CONF[libid]['FASTQS'].each_index do |runid|
qc_targets.push("tmp/#{libid}.#{runid}.step1b")
end
end
LIBIDS.each do |libid|
qc_targets.push("tmp/#{libid}.step2a")
end
LIBWELLIDS.each do |libwellid|
qc_targets.push("tmp/#{libwellid}.step2f")
end
LIBWELLIDS.each do |libwellid|
qc_targets.push("tmp/byGene/#{libwellid}.step3b")
end
LIBWELLIDS.each do |libwellid|
qc_targets.push("tmp/byGene/#{libwellid}.step3c")
end
task :qc => qc_targets + ['out/byGene/samples.xls']
##
classes = ['global']
begin
infp = open('src/samples.csv', 'rt')
colnames = infp.gets.rstrip.split(',')
infp.close
(colnames.select { |colname| /^CLASS\.\d+$/.match(colname) }).each do |cls|
classes.push(/^CLASS\.(\d+)$/.match(cls).to_a[1])
end
end
plugin_byGene_targets = Array.new
plugin_byTFE_targets = Array.new
Dir.glob('plugins/*') do |script|
if /[\#~]$/ !~ script
plugin = script.pathmap('%n')
classes.each do |cls|
target = "out/byGene/plugin_#{plugin}_#{cls}.timestamp"
plugin_byGene_targets.push(target)
file target => ['out/byGene/diffexp.csv', 'out/byGene/samples.csv'] do |t|
sh "#{script} byGene #{cls} #{t.sources.join(' ')} conf.yaml > #{t.name.pathmap("%X")}.log 2>&1"
sh "touch #{t.name}"
end
target = "out/byTFE/plugin_#{plugin}_#{cls}.timestamp"
plugin_byTFE_targets.push(target)
file target => ['out/byTFE/diffexp.csv', 'out/byGene/samples.csv'] do |t|
sh "#{script} byTFE #{cls} #{t.sources.join(' ')} conf.yaml > #{t.name.pathmap("%X")}.log 2>&1"
sh "touch #{t.name}"
end
end
end
end
task :gene => qc_targets +
plugin_byGene_targets +
['out/byGene/samples.xls',
'out/byGene/diffexp.xls',
'out/web/regions_byGene.bed.gz']
##
task :default => qc_targets +
plugin_byGene_targets +
plugin_byTFE_targets +
['out/byGene/samples.xls',
'out/byGene/diffexp.xls',
'out/byTFE/diffexp.xls',
:web]