viral_seq 1.7.1 → 1.8.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +29 -24
- data/README.md +33 -18
- data/bin/tcs +39 -8
- data/bin/tcs_log +27 -16
- data/bin/tcs_sdrm +23 -14
- data/lib/viral_seq/R.rb +31 -0
- data/lib/viral_seq/constant.rb +0 -41
- data/lib/viral_seq/muscle.rb +1 -1
- data/lib/viral_seq/recency.rb +56 -2
- data/lib/viral_seq/recency_report.rb +193 -0
- data/lib/viral_seq/root.rb +7 -0
- data/lib/viral_seq/seq_hash.rb +4 -4
- data/lib/viral_seq/seq_hash_pair.rb +154 -27
- data/lib/viral_seq/tcs_dr.rb +168 -81
- data/lib/viral_seq/util/check_env.r +9 -0
- data/lib/viral_seq/util/recency_model/rt_only_fit.Rdata +0 -0
- data/lib/viral_seq/util/recency_model/rt_v1v3_fit.Rdata +0 -0
- data/lib/viral_seq/util/recency_model/v1v3_only_fit.Rdata +0 -0
- data/lib/viral_seq/util/sdrm_r.r +34 -0
- data/lib/viral_seq/version.rb +2 -2
- data/lib/viral_seq.rb +6 -0
- data/viral_seq.gemspec +2 -2
- metadata +17 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 11381ab74d67a54b5d922e8f1a7085866fe5349f4124a971b9dc64709fa763f1
|
4
|
+
data.tar.gz: dd578b649b9857cf1c7ff8a23fff62db51f665ef23c74c8000a2b4d7f4500f9e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: add86e088cd1ef50c0ce546eb4f755b7b5725a072ddf1119982ec0cccd20246bc25aab077c51673032e442f098e15f4c40d9a526ff67af8a5514aab580f255a8
|
7
|
+
data.tar.gz: 4b6cdbe344c2835c3f07c10b86f33613e0d5cdba5a9405da50d9d7f208796da6cdee709993b465f72e2a14a49667ea5ddfed84ddaf8ff21bda4a09448ebdde1b
|
data/Gemfile.lock
CHANGED
@@ -1,52 +1,57 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
viral_seq (1.
|
4
|
+
viral_seq (1.8.0.pre)
|
5
5
|
colorize (~> 0.1)
|
6
6
|
combine_pdf (~> 1.0, >= 1.0.0)
|
7
|
-
muscle_bio (
|
7
|
+
muscle_bio (= 0.4)
|
8
8
|
prawn (~> 2.3, >= 2.3.0)
|
9
9
|
prawn-table (~> 0.2, >= 0.2.0)
|
10
10
|
|
11
11
|
GEM
|
12
12
|
remote: https://rubygems.org/
|
13
13
|
specs:
|
14
|
+
bigdecimal (3.1.7)
|
14
15
|
colorize (0.8.1)
|
15
|
-
combine_pdf (1.0.
|
16
|
+
combine_pdf (1.0.26)
|
17
|
+
matrix
|
16
18
|
ruby-rc4 (>= 0.1.5)
|
17
|
-
diff-lcs (1.
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
19
|
+
diff-lcs (1.5.1)
|
20
|
+
matrix (0.4.2)
|
21
|
+
muscle_bio (0.4.0)
|
22
|
+
pdf-core (0.10.0)
|
23
|
+
prawn (2.5.0)
|
24
|
+
matrix (~> 0.4)
|
25
|
+
pdf-core (~> 0.10.0)
|
26
|
+
ttfunk (~> 1.8)
|
23
27
|
prawn-table (0.2.2)
|
24
28
|
prawn (>= 1.3.0, < 3.0.0)
|
25
|
-
rake (13.
|
26
|
-
rspec (3.
|
27
|
-
rspec-core (~> 3.
|
28
|
-
rspec-expectations (~> 3.
|
29
|
-
rspec-mocks (~> 3.
|
30
|
-
rspec-core (3.
|
31
|
-
rspec-support (~> 3.
|
32
|
-
rspec-expectations (3.
|
29
|
+
rake (13.2.1)
|
30
|
+
rspec (3.13.0)
|
31
|
+
rspec-core (~> 3.13.0)
|
32
|
+
rspec-expectations (~> 3.13.0)
|
33
|
+
rspec-mocks (~> 3.13.0)
|
34
|
+
rspec-core (3.13.0)
|
35
|
+
rspec-support (~> 3.13.0)
|
36
|
+
rspec-expectations (3.13.0)
|
33
37
|
diff-lcs (>= 1.2.0, < 2.0)
|
34
|
-
rspec-support (~> 3.
|
35
|
-
rspec-mocks (3.
|
38
|
+
rspec-support (~> 3.13.0)
|
39
|
+
rspec-mocks (3.13.0)
|
36
40
|
diff-lcs (>= 1.2.0, < 2.0)
|
37
|
-
rspec-support (~> 3.
|
38
|
-
rspec-support (3.
|
41
|
+
rspec-support (~> 3.13.0)
|
42
|
+
rspec-support (3.13.1)
|
39
43
|
ruby-rc4 (0.1.5)
|
40
|
-
ttfunk (1.
|
44
|
+
ttfunk (1.8.0)
|
45
|
+
bigdecimal (~> 3.1)
|
41
46
|
|
42
47
|
PLATFORMS
|
43
48
|
ruby
|
44
49
|
|
45
50
|
DEPENDENCIES
|
46
|
-
bundler (~> 2.
|
51
|
+
bundler (~> 2.5)
|
47
52
|
rake (~> 13.0)
|
48
53
|
rspec (~> 3.0)
|
49
54
|
viral_seq!
|
50
55
|
|
51
56
|
BUNDLED WITH
|
52
|
-
2.
|
57
|
+
2.5.7
|
data/README.md
CHANGED
@@ -10,7 +10,7 @@ A Ruby Gem containing bioinformatics tools for processing viral NGS data.
|
|
10
10
|
|
11
11
|
Specifically for Primer ID sequencing and HIV drug resistance analysis.
|
12
12
|
|
13
|
-
CLI tools `tcs`, `tcs_sdrm`, `tcs_log` and `locator` included in the gem.
|
13
|
+
CLI tools `tcs`, `tcs_sdrm`, `tcs_log` and `locator` included in the gem.
|
14
14
|
|
15
15
|
#### tcs web app - https://primer-id.org/
|
16
16
|
|
@@ -20,8 +20,8 @@ CLI tools `tcs`, `tcs_sdrm`, `tcs_log` and `locator` included in the gem.
|
|
20
20
|
![Primer ID Sequencing](./docs/assets/img/cover.jpg)
|
21
21
|
|
22
22
|
### Reference readings on the Primer ID sequencing
|
23
|
-
[Explantion of Primer ID sequencing](https://doi.org/10.21769/BioProtoc.3938)
|
24
|
-
[Primer ID MiSeq protocol](https://doi.org/10.1128/JVI.00522-15)
|
23
|
+
[Explantion of Primer ID sequencing](https://doi.org/10.21769/BioProtoc.3938)
|
24
|
+
[Primer ID MiSeq protocol](https://doi.org/10.1128/JVI.00522-15)
|
25
25
|
[Application of Primer ID sequencing in COVID-19 research](https://doi.org/10.1126/scitranslmed.abb5883)
|
26
26
|
|
27
27
|
## Requirements
|
@@ -40,7 +40,7 @@ Required RubyGems version: >= 1.3.6
|
|
40
40
|
|
41
41
|
### Excutables
|
42
42
|
|
43
|
-
### `tcs`
|
43
|
+
### `tcs`
|
44
44
|
Use executable `tcs` pipeline to process **Primer ID MiSeq sequencing** data.
|
45
45
|
|
46
46
|
Web-based `tcs` analysis can be accessed at https://primer-id.org/
|
@@ -66,14 +66,14 @@ Example commands:
|
|
66
66
|
Use `tcs_log` script to pool run logs and TCS fasta files after one batch of `tcs` jobs. This command generates log.html to visualize the sequencing runs.
|
67
67
|
|
68
68
|
|
69
|
-
Example file structure:
|
69
|
+
Example file structure:
|
70
70
|
```
|
71
|
-
batch_tcs_jobs/
|
72
|
-
├── lib1
|
73
|
-
├── lib2
|
74
|
-
├── lib3
|
75
|
-
├── lib4
|
76
|
-
├── ...
|
71
|
+
batch_tcs_jobs/
|
72
|
+
├── lib1
|
73
|
+
├── lib2
|
74
|
+
├── lib3
|
75
|
+
├── lib4
|
76
|
+
├── ...
|
77
77
|
```
|
78
78
|
|
79
79
|
Example command:
|
@@ -121,7 +121,7 @@ Output data in a new dir as 'libs_dir_SDRM'
|
|
121
121
|
|
122
122
|
---
|
123
123
|
|
124
|
-
### `locator`
|
124
|
+
### `locator`
|
125
125
|
Use executable `locator` to get the coordinates of the sequences on HIV/SIV reference genome from a FASTA file through a terminal
|
126
126
|
|
127
127
|
```bash
|
@@ -187,21 +187,36 @@ qc_seqhash.sdrm_hiv_pr(cut_off)
|
|
187
187
|
|
188
188
|
## Updates
|
189
189
|
|
190
|
-
### Version-1.7.1-05120203
|
191
190
|
|
192
|
-
|
191
|
+
### Version-1.8.1-06042024
|
192
|
+
|
193
|
+
1. Fixed a bug that causes `tcs_sdrm` pipeline to crash.
|
194
|
+
|
195
|
+
### Version-1.8.0-04052024
|
196
|
+
|
197
|
+
1. Use `muscle-v3.8.1` as default aligner because of the compatibility issues with `muscle-v5` on some platforms.
|
198
|
+
2. Adjust the end-join model for short insert (insert size less than read length substracted by adaptor size)
|
199
|
+
3. Add an option in the DR pipeline for different versions of the pipeline, default version as "v1".
|
200
|
+
4. Add Days Post Infection (DPI) prediction model in the SDRM pipeline.
|
201
|
+
5. Re-organize the R scripts as stand-alone R files.
|
202
|
+
6. Bug fix.
|
203
|
+
7. **NOT SOLVED**: to include versions of DR in reports
|
204
|
+
|
205
|
+
### Version-1.7.1-05122023
|
206
|
+
|
207
|
+
1. Add a size check for the raw sequences. If the size smaller than the input params, error messages will be sent to users. IF the actual size is greater than the input params, extra bases will be truncated.
|
193
208
|
2. Now allows mismatch for the primer region sequences. Forward primer region allows 2 nt differences and cDNA primer region allows 3 nt differences.
|
194
|
-
3. Bug fix.
|
209
|
+
3. Bug fix.
|
195
210
|
4. TCS version to 2.5.2
|
196
211
|
|
197
212
|
### Version-1.7.0-08242022
|
198
213
|
|
199
|
-
1. Add warnings if `tcs` pipeline is excecuting through source instead of installing from `gem`.
|
200
|
-
2. Optimized `ViralSeq:SeqHash#a3g` hypermut algorithm. Allowing a external reference other than the sample reference.
|
214
|
+
1. Add warnings if `tcs` pipeline is excecuting through source instead of installing from `gem`.
|
215
|
+
2. Optimized `ViralSeq:SeqHash#a3g` hypermut algorithm. Allowing a external reference other than the sample reference.
|
201
216
|
|
202
217
|
### Version-1.6.4-07182022
|
203
218
|
|
204
|
-
1. Included region "P17" in the default `tcs -d` pipeline setting. `tcs` pipeline updated to version 2.5.1.
|
219
|
+
1. Included region "P17" in the default `tcs -d` pipeline setting. `tcs` pipeline updated to version 2.5.1.
|
205
220
|
2. Loosen the locator params for the "V1V3" end region for rare alignment issues. Now the default "V1V3" region end with position 7205 to 7210 instead of 7208.
|
206
221
|
3. `tcs_sdrm` now analyse "P17" region for pairwise diversity.
|
207
222
|
|
data/bin/tcs
CHANGED
@@ -31,15 +31,15 @@ def gem_installed?(gem_name)
|
|
31
31
|
begin
|
32
32
|
found_gem = Gem::Specification.find_by_name(gem_name)
|
33
33
|
rescue Gem::LoadError
|
34
|
-
return false
|
34
|
+
return false
|
35
35
|
else
|
36
|
-
return true
|
36
|
+
return true
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
40
|
if gem_installed?('viral_seq')
|
41
41
|
require 'viral_seq'
|
42
|
-
else
|
42
|
+
else
|
43
43
|
printf "\n****************************************************\n"
|
44
44
|
printf "**** THIS PACKAGE CANNOT BE RUN FROM SOURCE ********\n"
|
45
45
|
printf "**** PLEASE INSTALL USING `gem install viral_seq` **\n"
|
@@ -47,7 +47,6 @@ else
|
|
47
47
|
exit 1
|
48
48
|
end
|
49
49
|
|
50
|
-
|
51
50
|
require 'json'
|
52
51
|
require 'colorize'
|
53
52
|
require 'optparse'
|
@@ -77,8 +76,8 @@ OptionParser.new do |opts|
|
|
77
76
|
options[:input] = p
|
78
77
|
end
|
79
78
|
|
80
|
-
opts.on("-
|
81
|
-
options[:dr] =
|
79
|
+
opts.on("-d", "--dr_pipeline VERSION", "HIV drug resistance MPID pipeline, choose your version") do |p|
|
80
|
+
options[:dr] = p.downcase
|
82
81
|
end
|
83
82
|
|
84
83
|
opts.on("-h", "--help", "Prints this help") do
|
@@ -90,6 +89,14 @@ OptionParser.new do |opts|
|
|
90
89
|
options[:keep] = true
|
91
90
|
end
|
92
91
|
|
92
|
+
opts.on("--dr_params VERSION", "show params for a specific VERSION of DR pipeline") do |p|
|
93
|
+
options[:dr_params] = p.downcase
|
94
|
+
end
|
95
|
+
|
96
|
+
opts.on("--dr_list_params", "show params for ALL DR pipeline versions") do |p|
|
97
|
+
options[:dr_list_params] = true
|
98
|
+
end
|
99
|
+
|
93
100
|
opts.on("-v", "--version", "Version info") do
|
94
101
|
puts "tcs version: " + ViralSeq::TCS_VERSION.red.bold
|
95
102
|
puts "viral_seq version: " + ViralSeq::VERSION.red.bold
|
@@ -101,10 +108,33 @@ OptionParser.new do |opts|
|
|
101
108
|
# end
|
102
109
|
end.parse!
|
103
110
|
|
111
|
+
def safe_dr_params(version)
|
112
|
+
if version == "r"
|
113
|
+
version = "v1"
|
114
|
+
end # adding this statement to allow the backward compatiblity with previous `tcs -dr` command
|
115
|
+
|
116
|
+
params = ViralSeq::TcsDr::PARAMS[version]
|
117
|
+
|
118
|
+
if params.nil?
|
119
|
+
abort "The input DR version #{version} not exist. \nThe current supported versions for the DR pipeline are: \n#{ViralSeq::TcsDr::PARAMS.keys.join("\n")}\n\nRun `tcs --dr_params [VERSION]` for the detailed params used by each version".red
|
120
|
+
else
|
121
|
+
return params
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
104
125
|
if options[:json_generator]
|
105
126
|
params = ViralSeq::TcsJson.generate
|
127
|
+
elsif options[:dr_params]
|
128
|
+
params = safe_dr_params(options[:dr_params])
|
129
|
+
puts "The DR params for the version you entered is: "
|
130
|
+
puts JSON.pretty_generate params
|
131
|
+
exit
|
132
|
+
elsif options[:dr_list_params]
|
133
|
+
params = ViralSeq::TcsDr::PARAMS
|
134
|
+
puts JSON.pretty_generate params
|
135
|
+
exit
|
106
136
|
elsif options[:dr]
|
107
|
-
params =
|
137
|
+
params = safe_dr_params(options[:dr])
|
108
138
|
elsif (options[:params_json] && File.exist?(options[:params_json]))
|
109
139
|
params = JSON.parse(File.read(options[:params_json]), symbolize_names: true)
|
110
140
|
else
|
@@ -121,6 +151,7 @@ unless indir and File.exist?(indir)
|
|
121
151
|
abort "No input sequence directory found. Script terminated.".red.bold
|
122
152
|
end
|
123
153
|
|
154
|
+
|
124
155
|
# log file
|
125
156
|
|
126
157
|
runtime_log_file = File.join(indir,"runtime.log")
|
@@ -165,7 +196,7 @@ begin
|
|
165
196
|
|
166
197
|
r1_raw_size = r1_fastq_sh.dna_hash.values[0].size
|
167
198
|
r2_raw_size = r2_fastq_sh.dna_hash.values[0].size
|
168
|
-
|
199
|
+
|
169
200
|
if r1_raw_size >= $platform_sequencing_length
|
170
201
|
r1_size_diff = r1_raw_size - $platform_sequencing_length
|
171
202
|
else
|
data/bin/tcs_log
CHANGED
@@ -12,6 +12,8 @@
|
|
12
12
|
# command example:
|
13
13
|
# $ tcs_log batch_tcs_jobs
|
14
14
|
|
15
|
+
# NOTE some libraries can be named {digit} and these are invalid query selectors, keep prepended with a string
|
16
|
+
|
15
17
|
require 'viral_seq'
|
16
18
|
require 'pathname'
|
17
19
|
require 'json'
|
@@ -135,8 +137,8 @@ class String
|
|
135
137
|
gsub '-',''
|
136
138
|
end
|
137
139
|
def shorten_html
|
138
|
-
gsub
|
139
|
-
gsub
|
140
|
+
gsub(/\n/, '')
|
141
|
+
gsub(/\t/, '')
|
140
142
|
end
|
141
143
|
end
|
142
144
|
|
@@ -216,10 +218,10 @@ end
|
|
216
218
|
#process each library's html
|
217
219
|
library_links = "
|
218
220
|
<ul>
|
219
|
-
<li id='link_basic-statistics' class='pointer current_page' onclick='showPage(\"basic-statistics\")'>Basic Statistics</li>
|
221
|
+
<li id='link_basic-statistics' class='pointer lib_link current_page' onclick='showPage(\"basic-statistics\")'>Basic Statistics</li>
|
220
222
|
<li>Libraries
|
221
223
|
<ul style='margin-left: 16px;'>" + lib_names.map { |lib_name| "
|
222
|
-
<li id='link_#{lib_name}' class='pointer' onclick='showPage(\""+lib_name+"\")'>"+lib_name+"</li>"
|
224
|
+
<li id='link_#{lib_name}' class='pointer lib_link' onclick='showPage(\""+lib_name+"\")'>"+lib_name+"</li>"
|
223
225
|
}.join + "
|
224
226
|
</ul>
|
225
227
|
</li>
|
@@ -227,7 +229,7 @@ library_links = "
|
|
227
229
|
"
|
228
230
|
|
229
231
|
library_pages = lib_names.map { |lib_name|
|
230
|
-
"<div id='"+lib_name+"' class='page hidden'>
|
232
|
+
"<div id='page_"+lib_name+"' class='page hidden'>
|
231
233
|
<div class='error-message'></div>
|
232
234
|
<div style='display: flex; gap: 16px; min-height: 45vh;'>
|
233
235
|
<div class='card' style='flex: 1; display: flex; flex-direction: column;'>
|
@@ -391,7 +393,7 @@ end
|
|
391
393
|
|
392
394
|
#create JS that initializes charts
|
393
395
|
paired_raw_js = paired_raw.map { |lib, data| '
|
394
|
-
var element_pie_'+lib.var_safe+' = document.querySelector("#'+lib+' .pie_chart")
|
396
|
+
var element_pie_'+lib.var_safe+' = document.querySelector("#page_'+lib+' .pie_chart")
|
395
397
|
if(isVisible(element_pie_'+lib.var_safe+')){
|
396
398
|
var chart_pie_'+lib.var_safe+' = new google.visualization.PieChart(element_pie_'+lib.var_safe+');
|
397
399
|
chart_pie_'+lib.var_safe+'.draw(
|
@@ -419,7 +421,7 @@ paired_raw_js = paired_raw.map { |lib, data| '
|
|
419
421
|
|
420
422
|
tree_charts_js = tree_charts.map { |lib, d|
|
421
423
|
d.map { |region, data| '
|
422
|
-
var element_chart_tree_'+lib.var_safe+'_'+region.var_safe+' = document.querySelector("#'+lib+' .'+region+' .treemap")
|
424
|
+
var element_chart_tree_'+lib.var_safe+'_'+region.var_safe+' = document.querySelector("#page_'+lib+' .'+region+' .treemap")
|
423
425
|
if(isVisible(element_chart_tree_'+lib.var_safe+'_'+region.var_safe+')){
|
424
426
|
var chart_tree_'+lib.var_safe+'_'+region.var_safe+' = new google.visualization.TreeMap(element_chart_tree_'+lib.var_safe+'_'+region.var_safe+');
|
425
427
|
chart_tree_'+lib.var_safe+'_'+region.var_safe+'.draw(
|
@@ -439,7 +441,7 @@ tree_charts_js = tree_charts.map { |lib, d|
|
|
439
441
|
}.join
|
440
442
|
|
441
443
|
tcs_bar_chart_js = tcs_bar_chart.map { |lib, data| '
|
442
|
-
var element_tcs_bar_chart_'+lib.var_safe+' = document.querySelector("#'+lib+' .tcs_bar_chart")
|
444
|
+
var element_tcs_bar_chart_'+lib.var_safe+' = document.querySelector("#page_'+lib+' .tcs_bar_chart")
|
443
445
|
if(isVisible(element_tcs_bar_chart_'+lib.var_safe+')){
|
444
446
|
var tcs_bar_chart_'+lib.var_safe+' = new google.charts.Bar(element_tcs_bar_chart_'+lib.var_safe+');
|
445
447
|
tcs_bar_chart_'+lib.var_safe+'.draw(
|
@@ -454,12 +456,12 @@ tcs_bar_chart_js = tcs_bar_chart.map { |lib, data| '
|
|
454
456
|
}
|
455
457
|
})
|
456
458
|
);
|
457
|
-
document.querySelector("#'+lib+' .tcs_warnings").innerHTML = "'+data['warnings']+'";
|
459
|
+
document.querySelector("#page_'+lib+' .tcs_warnings").innerHTML = "'+data['warnings']+'";
|
458
460
|
}
|
459
461
|
' }.join
|
460
462
|
|
461
463
|
detection_sensitivity_js = detection_sensitivity_chart.map { |lib, data| '
|
462
|
-
var element_detection_'+lib.var_safe+' = document.querySelector("#'+lib+' .detection_sensitivity_chart")
|
464
|
+
var element_detection_'+lib.var_safe+' = document.querySelector("#page_'+lib+' .detection_sensitivity_chart")
|
463
465
|
if(isVisible(element_detection_'+lib.var_safe+')){
|
464
466
|
var detection_'+lib.var_safe+' = new google.visualization.ColumnChart(element_detection_'+lib.var_safe+');
|
465
467
|
detection_'+lib.var_safe+'.draw(
|
@@ -483,7 +485,7 @@ detection_sensitivity_js = detection_sensitivity_chart.map { |lib, data| '
|
|
483
485
|
'}.join
|
484
486
|
|
485
487
|
distinct_bar_chart_js = distinct_bar_chart.map { |lib, data| '
|
486
|
-
var element_distinct_'+lib.var_safe+' = document.querySelector("#'+lib+' .raw_bar_chart")
|
488
|
+
var element_distinct_'+lib.var_safe+' = document.querySelector("#page_'+lib+' .raw_bar_chart")
|
487
489
|
if(isVisible(element_distinct_'+lib.var_safe+')){
|
488
490
|
var distinct_'+lib.var_safe+' = new google.visualization.ColumnChart(element_distinct_'+lib.var_safe+');
|
489
491
|
distinct_'+lib.var_safe+'.draw(
|
@@ -499,7 +501,7 @@ distinct_bar_chart_js = distinct_bar_chart.map { |lib, data| '
|
|
499
501
|
' }.join
|
500
502
|
|
501
503
|
resampling_bar_chart_js = resampling_bar_chart.map { |lib, data| '
|
502
|
-
var element_resampling_'+lib.var_safe+' = document.querySelector("#'+lib+' .resampling_bar_chart")
|
504
|
+
var element_resampling_'+lib.var_safe+' = document.querySelector("#page_'+lib+' .resampling_bar_chart")
|
503
505
|
if(isVisible(element_resampling_'+lib.var_safe+')){
|
504
506
|
var resampling_'+lib.var_safe+' = new google.visualization.ColumnChart(element_resampling_'+lib.var_safe+');
|
505
507
|
resampling_'+lib.var_safe+'.draw(
|
@@ -516,7 +518,7 @@ resampling_bar_chart_js = resampling_bar_chart.map { |lib, data| '
|
|
516
518
|
|
517
519
|
scatter_charts_js = scatter_charts.map { |lib, d|
|
518
520
|
d.map { |region, data| '
|
519
|
-
var element_chart_scatter_'+lib.var_safe+'_'+region.var_safe+' = document.querySelector("#'+lib+' .'+region+'.scatter")
|
521
|
+
var element_chart_scatter_'+lib.var_safe+'_'+region.var_safe+' = document.querySelector("#page_'+lib+' .'+region+'.scatter")
|
520
522
|
if(isVisible(element_chart_scatter_'+lib.var_safe+'_'+region.var_safe+')){
|
521
523
|
var chart_scatter_'+lib.var_safe+'_'+region.var_safe+' = new google.visualization.ComboChart(element_chart_scatter_'+lib.var_safe+'_'+region.var_safe+');
|
522
524
|
|
@@ -601,7 +603,7 @@ html = '
|
|
601
603
|
|
602
604
|
function showPage(pageID){
|
603
605
|
document.querySelectorAll(".page").forEach(element => element.classList.add("hidden"))
|
604
|
-
document.getElementById(pageID).classList.remove("hidden")
|
606
|
+
document.getElementById("page_"+pageID).classList.remove("hidden")
|
605
607
|
|
606
608
|
document.querySelectorAll(".current_page").forEach(element => element.classList.remove("current_page"));
|
607
609
|
document.getElementById("link_"+pageID).classList.add("current_page");
|
@@ -620,7 +622,7 @@ html = '
|
|
620
622
|
'+library_links+'
|
621
623
|
</div>
|
622
624
|
<div id="pages" style="flex: 1; overflow: auto; height: 100vh;">
|
623
|
-
<div style="display: flex; flex-direction: column; align-items: center; height: 100vh;" id="
|
625
|
+
<div style="display: flex; flex-direction: column; align-items: center; height: 100vh;" id="page_basic-statistics" class="page">
|
624
626
|
<div class="error-message"></div>
|
625
627
|
<div class="card" style="margin-top: 16px; width: 100%;">
|
626
628
|
<table id="home-table">
|
@@ -694,7 +696,8 @@ html = '
|
|
694
696
|
padding: 8px;
|
695
697
|
}
|
696
698
|
.current_page {
|
697
|
-
|
699
|
+
color: white;
|
700
|
+
background: #BAA !important;
|
698
701
|
}
|
699
702
|
.error-message {
|
700
703
|
background: red !important;
|
@@ -709,6 +712,14 @@ html = '
|
|
709
712
|
.error-message:empty {
|
710
713
|
display: none;
|
711
714
|
}
|
715
|
+
|
716
|
+
.lib_link:nth-child(odd){
|
717
|
+
background: #FFF6FF;
|
718
|
+
}
|
719
|
+
|
720
|
+
.lib_link:hover {
|
721
|
+
background: #EEEFEE;
|
722
|
+
}
|
712
723
|
</style>
|
713
724
|
</html>
|
714
725
|
'.shorten_html
|
data/bin/tcs_sdrm
CHANGED
@@ -32,13 +32,8 @@ unless ARGV[0] && File.directory?(ARGV[0])
|
|
32
32
|
abort "No sequence data provided. `tcs_sdrm` pipeline aborted. "
|
33
33
|
end
|
34
34
|
|
35
|
-
|
36
|
-
|
37
|
-
r_check = `R -e '#{ViralSeq::R_SCRIPT_CHECK_PACKAGES}' > /dev/null 2>&1`
|
38
|
-
rescue Errno::ENOENT
|
39
|
-
abort '"R" is not installed. Install R at https://www.r-project.org/' +
|
40
|
-
"\n`tcs_sdrm` pipeline aborted."
|
41
|
-
end
|
35
|
+
r_version = ViralSeq::R.check_R
|
36
|
+
ViralSeq::R.check_R_packages
|
42
37
|
|
43
38
|
def abstract_line(data)
|
44
39
|
return_data = data[3] + data[2] + data[4] + ":" +
|
@@ -72,7 +67,7 @@ Dir.mkdir(outdir) unless File.directory?(outdir)
|
|
72
67
|
|
73
68
|
libs.each do |lib|
|
74
69
|
|
75
|
-
r_script = ViralSeq::
|
70
|
+
r_script = ViralSeq::R.get_sdrm_rscript
|
76
71
|
|
77
72
|
next unless File.directory?(lib)
|
78
73
|
|
@@ -106,6 +101,8 @@ libs.each do |lib|
|
|
106
101
|
summary_json_file = File.join(out_lib_dir, (lib_name + "_summary.json"))
|
107
102
|
summary_json_out = File.open(summary_json_file,"w")
|
108
103
|
|
104
|
+
recency_report_file = File.join(out_lib_dir, (lib_name + "_recency_report.pdf"))
|
105
|
+
|
109
106
|
filtered_seq_dir = File.join(out_lib_dir, (lib_name + "_filtered_seq"))
|
110
107
|
Dir.mkdir(filtered_seq_dir) unless File.directory?(filtered_seq_dir)
|
111
108
|
|
@@ -290,12 +287,12 @@ libs.each do |lib|
|
|
290
287
|
tcs_IN = 0
|
291
288
|
tcs_V1V3 = 0
|
292
289
|
tcs_P17 = 0
|
293
|
-
pi_RT =
|
294
|
-
pi_V1V3 =
|
295
|
-
pi_P17 =
|
296
|
-
dist20_RT =
|
297
|
-
dist20_V1V3 =
|
298
|
-
dist20_P17 =
|
290
|
+
pi_RT = "NA"
|
291
|
+
pi_V1V3 = "NA"
|
292
|
+
pi_P17 = "NA"
|
293
|
+
dist20_RT = "NA"
|
294
|
+
dist20_V1V3 = "NA"
|
295
|
+
dist20_P17 = "NA"
|
299
296
|
summary_lines.each do |line|
|
300
297
|
data = line.chomp.split(",")
|
301
298
|
if data[0] == "PR"
|
@@ -326,6 +323,12 @@ libs.each do |lib|
|
|
326
323
|
dist20_V1V3: dist20_V1V3
|
327
324
|
)
|
328
325
|
|
326
|
+
dpi_res = ViralSeq::Recency.dpi(pi_RT, pi_V1V3)
|
327
|
+
dpi = dpi_res[0]
|
328
|
+
dpi_lwr = dpi_res[1]
|
329
|
+
dpi_upr = dpi_res[2]
|
330
|
+
possible_dual_infection = ViralSeq::Recency.possible_dual_infection(recency, dpi_res)
|
331
|
+
|
329
332
|
sdrm_lines = File.readlines(point_mutation_file)
|
330
333
|
sdrm_lines.shift
|
331
334
|
sdrm_PR = ""
|
@@ -357,6 +360,10 @@ libs.each do |lib|
|
|
357
360
|
dist20_V1V3: dist20_V1V3,
|
358
361
|
dist20_P17: dist20_P17,
|
359
362
|
recency: recency,
|
363
|
+
dpi: dpi,
|
364
|
+
dpi_lwr: dpi_lwr,
|
365
|
+
dpi_upr: dpi_upr,
|
366
|
+
possible_dual_infection: possible_dual_infection,
|
360
367
|
sdrm_PR: sdrm_PR,
|
361
368
|
sdrm_RT: sdrm_RT,
|
362
369
|
sdrm_IN: sdrm_IN
|
@@ -365,6 +372,8 @@ libs.each do |lib|
|
|
365
372
|
summary_json_out.puts JSON.pretty_generate(summary_json)
|
366
373
|
summary_json_out.close
|
367
374
|
|
375
|
+
ViralSeq::RecencyReport.generate(summary_json[0], recency_report_file)
|
376
|
+
|
368
377
|
csvs = [
|
369
378
|
{
|
370
379
|
name: "summary",
|
data/lib/viral_seq/R.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
module ViralSeq
|
2
|
+
module R
|
3
|
+
|
4
|
+
# check if R is installed. if R is installed, return the version number of R.
|
5
|
+
|
6
|
+
def self.check_R
|
7
|
+
begin
|
8
|
+
r_version = `R --version`.split("\n")[0]
|
9
|
+
rescue Errno::ENOENT
|
10
|
+
abort '"R" is not installed. Install R at https://www.r-project.org/' +
|
11
|
+
"\n`tcs_sdrm` pipeline aborted."
|
12
|
+
end
|
13
|
+
end # end check_R
|
14
|
+
|
15
|
+
# check if required R packages is installed.
|
16
|
+
def self.check_R_packages
|
17
|
+
if system "Rscript #{File.join( ViralSeq.root, "viral_seq", "util", "check_env.r")}"
|
18
|
+
return 0
|
19
|
+
else
|
20
|
+
raise "Non-zero exit code. Error happens when checking required R packages."
|
21
|
+
end
|
22
|
+
end # end check_R_packages.
|
23
|
+
|
24
|
+
# read sdrm rscript as a string.
|
25
|
+
|
26
|
+
def self.get_sdrm_rscript
|
27
|
+
File.read(File.join(ViralSeq.root, "viral_seq", "util", "sdrm_r.r"))
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|