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
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
|
# File 'lib/viral_seq/tcs_json.rb', line 5
def generate
puts '-'*58
puts '| JSON Parameter Generator for ' + "TCS #{ViralSeq::TCS_VERSION}".red.bold + " by " + "Shuntai Zhou".blue.bold + ' |'
puts '-'*58 + "\n"
param = {}
puts 'Enter the path to the directory that contains the MiSeq pair-end R1 and R2 .fastq or .fastq.gz file'
print '> '
param[:raw_sequence_dir] = gets.chomp.rstrip
puts "Choose MiSeq Platform (1-3):\n1. 150x7x150\n2. 250x7x250\n3. 300x7x300 (default)"
print "> "
pf_option = gets.chomp.rstrip
case pf_option.to_i
when 1
param[:platform_format] = 150
when 2
param[:platform_format] = 250
else
param[:platform_format] = 300
end
puts 'Enter the estimated platform error rate (for TCS cut-off calculation), default as ' + '0.02'.red.bold
print '> '
input_error = gets.chomp.rstrip.to_f
if input_error == 0.0
param[:platform_error_rate] = 0.02
else
param[:platform_error_rate] = input_error
end
param[:primer_pairs] = []
loop do
data = {}
puts "Enter the name for the sequenced region: "
print '> '
data[:region] = gets.chomp.rstrip
puts "Enter the #{"cDNA".red.bold} primer sequence: "
print '> '
data[:cdna] = gets.chomp.rstrip
puts "Enter the #{"forward".blue.bold} primer sequence: "
print '> '
data[:forward] = gets.chomp.rstrip
puts "Enter supermajority cut-off (0.5 - 1.0). Default Simple Majority"
print '> '
mj = gets.chomp.rstrip.to_f
if (0.5..1.0).include?(mj)
data[:majority] = mj
else
data[:majority] = 0
end
print "Need end-join? Y/N \n> "
ej = gets.chomp.rstrip
if ej =~ /y|yes/i
data[:end_join] = true
puts "End-join option? Choose from (1-4):"
puts "1: simple join, no overlap"
puts "2: known overlap"
puts "3: unknow overlap, use sample consensus to determine overlap, all sequence pairs have same overlap"
puts "4: unknow overlap, determine overlap by individual sequence pairs, sequence pairs can have different overlap"
print "> "
ej_option = gets.chomp.rstrip
while ![1,2,3,4].include?(ej_option.to_i)
puts "Entered end-join option #{ej_option.red.bold} not valid (choose 1-4), try again"
ej_option = gets.chomp.rstrip.to_i
end
case ej_option.to_i
when 1
data[:end_join_option] = 1
data[:overlap] = 0
when 2
data[:end_join_option] = 1
print "overlap bases: \n> "
ol = gets.chomp.rstrip.to_i
data[:overlap] = ol
when 3
data[:end_join_option] = 3
when 4
data[:end_join_option] = 4
end
print "Need QC for TCS? (support for HIV-1 and SIV)? Y/N \n> "
qc = gets.chomp.rstrip
if qc =~ /y|yes/i
data[:TCS_QC] = true
data[:ref_genome] = get_ref
print "reference 5'end ref position or posiiton range, 0 if no need to match this end \n> "
data[:ref_start] = gets.chomp.rstrip.to_i
print "reference 3'end ref position or posiiton range: 0 if no need to match this end \n> "
data[:ref_end] = gets.chomp.rstrip.to_i
print "allow indels? (default as yes) Y/N \n> "
indel = gets.chomp.rstrip
if indel =~ /n|no/i
data[:indel] = false
else
data[:indel] = true
end
else
data[:TCS_QC] = false
end
print "Need trimming to a reference genome? Y/N \n> "
trim_option = gets.chomp.rstrip
if trim_option =~ /y|yes/i
data[:trim] = true
data[:trim_ref] = get_ref
print "reference 5'end ref position \n> "
data[:trim_ref_start] = gets.chomp.rstrip.to_i
print "reference 3'end ref position \n> "
data[:trim_ref_end] = gets.chomp.rstrip.to_i
else
data[:trim] = false
end
else
data[:end_join] = false
end
param[:primer_pairs] << data
print "Do you wish to conintue? Y/N \n> "
continue_sig = gets.chomp.rstrip
break unless continue_sig =~ /y|yes/i
end
puts "\nYour JSON string is:"
puts JSON.pretty_generate(param)
print "\nDo you wish to save it as a file? Y/N \n> "
save_option = gets.chomp.rstrip
if save_option =~ /y|yes/i
print "Path to save JSON file:\n> "
path = gets.chomp.rstrip
while !validate_path_name(path)
print "Entered path no valid, try again.\n".red.bold
print "Path to save JSON file:\n> "
path = gets.chomp.rstrip
end
File.open(validate_path_name(path), 'w') {|f| f.puts JSON.pretty_generate(param)}
end
print "\nDo you wish to execute tcs pipeline with the input params now? Y/N \n> "
rsp = gets.chomp.rstrip
if rsp =~ /y/i
return param
else
abort "Params json file generated. You can execute tcs pipeline using `tcs -p [params.json]`".blue
end
end
|