Debian Codegraph @

run_discoSnp++.sh

raw symbols ◀ ▶ SCIP
2 Debian patches touch this file
1 #!/bin/bashscip-shell filesystem . . `/bin/bash`.
2 #*****************************************************************************
3 # discoSnp++: discovering polymorphism from raw unassembled NGS reads
4 # A tool from the GATB (Genome Assembly Tool Box)
5 # Copyright (C) 2014 INRIA
6 # Authors: P.Peterlongo, E.Drezen
7 #
8 # This program is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU Affero General Public License as
10 # published by the Free Software Foundation, either version 3 of the
11 # License, or (at your option) any later version.
12 #
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU Affero General Public License for more details.
17 #
18 # You should have received a copy of the GNU Affero General Public License
19 # along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #*****************************************************************************
21 red=`tputscip-shell system . . tput. setaf 1`
22 green=`tputscip-shell system . . tput. setaf 2`
23 yellow=`tputscip-shell system . . tput. setaf 3`
24 cyan=`tputscip-shell system . . tput. setaf 6`
25 bold=`tputscip-shell system . . tput. bold`
26 reset=`tputscip-shell system . . tput. sgr0`
27
28 diescip-shell shell discosnp 1:2.6.2-5 die().() {
29 printfscip-shell system . . printf. '%s\n' "$1" >&2
30 exit 1
31 }
32 function myrealpathscip-shell shell discosnp 1:2.6.2-5 myrealpath(). { echoscip-shell system . . echo. $(cd $(dirnamescip-shell system . . dirname. $1); pwdscip-shell system . . pwd.)/$(basenamescip-shell system . . basename. $1); }
33
34 option_cores_gatb=""
35 option_cores_post_analysis=""
36
37 Ttot="$(datescip-shell system . . date. +%s)"
38 #### constant #####
39 max_C=2147483647 #$((2**31-1))
40
41 ###########################################################
42 #################### DEFAULT VALUES #######################
43 ###########################################################
44 version="2.3.X"
45 read_sets="" # A file of file(s)
46 read_sets_kissreads=""
47 prefix="discoRes" # all intermediate and final files will be written will start with this prefix
48 k=31 # size of kmers
49 b=0 # smart branching approach: bubbles in which both paths are equaly branching are discarded, all others are accepted
50 c=3 # minimal coverage
51 C=$max_C # maximal coverage
52 d=1 # estimated number of error per read (used by kissreads only)
53 D=100 # maximal size of searched deletions
54 max_ambigous_indel=20
55 P=3 # number of polymorphsim per bubble
56 option_max_symmetrical_crossroads=""
57 l="-l"
58 extend="-t"
59 x="" # if set to -x : authorize non closed bubbles (used mainly in RNA seq)
60 output_coverage_option=""
61 genotyping="-genotype"
62 verbose=1
63 stop_after_kissnp=0
64 aav=0 # if set to not zero : considers the aav context: 1/ no uncoherent 2/ authorize -x option
65 e="" # if set to -e: Map variant predictions on reference genome with their unitig or contig extensions
66 graph_reused="Egg62hdS7knSFvF3" # with -g option, we use a previously created graph.
67
68 #EDIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
•69 #EDIR=$( python3 -c "import os.path; print(os.path.dirname(os.path.realpath(\"${BASH_SOURCE[0]}\")))" ) # as suggested by Philippe Bordron
70 EDIR="/usrscip-shell filesystem . . `/usr`."
71
72
73 if [scip-shell system . . `[`. -d "$EDIR/build/" ] ; then # VERSION SOURCE COMPILED
74 read_file_names_bin=$EDIR/build/bin/read_file_names
75 dbgh5_bin=$EDIR/build/ext/gatb-core/bin/dbgh5
76 kissnp2_bin=$EDIR/build/bin/kissnp2
77 kissreads2_bin=$EDIR/build/bin/kissreads2
78 else # VERSION BINARY
•79 read_file_names_bin=/usr/lib/discosnp/bin/read_file_namesscip-shell filesystem . . `/usr/lib/discosnp/bin/read_file_names`.
80 dbgh5_bin=$EDIR/bin/dbgh5
81 kissnp2_bin=$EDIR/bin/kissnp2
82 kissreads2_bin=$EDIR/bin/kissreads2
83 fi
84
•85 #chmod +x $EDIR/scripts/*.sh $EDIR/run_discoSnpRad.sh 2>/dev/null # Usefull for binary distributions
86
87 useref=""
88 wraith="false"
89 genome=""
90 bwa_path_option=""
91 option_phase_variants=""
92 bwa_distance=4
93
94 #######################################################################
95 #################### END HEADER #######################
96 #######################################################################
97
98 function helpscip-shell shell discosnp 1:2.6.2-5 help(). {
99 echoscip-shell system . . echo. " ************"
100 echoscip-shell system . . echo. " *** HELP ***"
101 echoscip-shell system . . echo. " ************"
102 echoscip-shell system . . echo. "run_discoSnp++.sh, a pipelining kissnp2 and kissreads for calling SNPs and small indels from NGS reads without the need of a reference genome"
103 echoscip-shell system . . echo. "Version "$version
104 echoscip-shell system . . echo. "Usage: ./run_discoSnp++.sh -r read_file_of_files [OPTIONS]"
105 echoscip-shell system . . echo. -e "MANDATORY"
106 echoscip-shell system . . echo. -e "\t -r|--fof <file name of a file of file(s)>"
107 echoscip-shell system . . echo. -e "\t\t The input read files indicated in a file of file(s)"
108 echoscip-shell system . . echo. -e "\t\t Example: -r bank.fof with bank.fof containing the two lines \n\t\t\t data_sample/reads_sequence1.fasta\n\t\t\t data_sample/reads_sequence2.fasta.gz"
109
110 echoscip-shell system . . echo. -e "\nOPTIONS"
111 echoscip-shell system . . echo. -e "\t -k | --k_size value <int value>"
112 echoscip-shell system . . echo. -e "\t\t Set the length of used kmers. Must fit the compiled value."
113 echoscip-shell system . . echo. -e "\t\t Default=31"
114 echoscip-shell system . . echo. -e "\t -c | --min_coverage value <int value>"
115 echoscip-shell system . . echo. -e "\t\t Set the minimal coverage per read set: Used by kissnp2 (don't use kmers with lower coverage) and kissreads (read coherency threshold)."
116 echoscip-shell system . . echo. -e "\t\t This coverage can be automatically detected per read set (in this case use \"auto\" or specified per read set, see the documentation."
117 echoscip-shell system . . echo. -e "\t\t Default=3"
118 echoscip-shell system . . echo. -e "\t -C | --max_coverage value <int value in 0, 1 or 2>"
119 echoscip-shell system . . echo. -e "\t\t Set the maximal coverage for each read set: Used by kissnp2 (don't use kmers with higher coverage)."
120 echoscip-shell system . . echo. -e "\t\t Default=2^31-1"
121 echoscip-shell system . . echo. -e "\t -b | --branching value. "
122 echoscip-shell system . . echo. -e "\t\t 0: forbid variants for which any of the two paths is branching (high precision, lowers the recall in complex genomes)."
123 echoscip-shell system . . echo. -e "\t\t Default value"
124 echoscip-shell system . . echo. -e "\t\t 1: (smart branching) forbid SNPs for which the two paths are branching (e.g. the two paths can be created either with a 'A' or a 'C' at the same position"
125 echoscip-shell system . . echo. -e "\t\t2: No limitation on branching (lowers the precision, high recall)"
126 echoscip-shell system . . echo. -e "\t -s | --symmetrical value <int value>"
127 echoscip-shell system . . echo. -e "\t\t In -b 2 mode only: maximal number of symmetrical crossroads traversed while trying to close a bubble. Default: no limit"
128 echoscip-shell system . . echo. -e "\t -g | --graph <file name>"
129 echoscip-shell system . . echo. -e "\t\t Reuse a previously created graph (.h5 file)"
130 echoscip-shell system . . echo. -e "\t -X\t Stop discoSnp++ right after variant calling - the output is only a fasta file with no coverage information."
131 echoscip-shell system . . echo. -e "\t -D | --deletion_max_size <int>"
132 echoscip-shell system . . echo. -e "\t\t discoSnp++ will search for deletions of size from 0 to D included. -D 0 means no deletion detected. Default=100."
133 echoscip-shell system . . echo. -e "\t -a | --ambiguity_max_size <int>"
134 echoscip-shell system . . echo. -e "\t\t Maximal size of ambiguity of INDELs. INDELS whose ambiguity is higher than this value are not output [default '20']"
135 echoscip-shell system . . echo. -e "\t -P | --max_snp_per_bubble <int>"
136 echoscip-shell system . . echo. -e "\t\t discoSnp++ will search up to P SNPs in a unique bubble. Default=3"
137 echoscip-shell system . . echo. -e "\t --fof_mapping <file name of a file of file(s)>"
138 echoscip-shell system . . echo. -e "\t\t If this option is used this fof is used when mapping back reads on the predicted variants instead of the original fof file provided by -r|--fof option"
139 echoscip-shell system . . echo. -e "\t -p | --prefix <string>"
140 echoscip-shell system . . echo. -e "\t\t All out files will start with this prefix. Default=\"discoRes\""
141 echoscip-shell system . . echo. -e "\t -l | --no_low_complexity"
142 echoscip-shell system . . echo. -e "\t\t Remove low complexity bubbles"
143 echoscip-shell system . . echo. -e "\t -T | --contigs"
144 echoscip-shell system . . echo. -e "\t\t Extend found polymorphisms with contigs (default: extend with unitigs)"
145 echoscip-shell system . . echo. -e "\t -d | --max_substitutions <int>"
146 echoscip-shell system . . echo. -e "\t\t Set the number of authorized substitutions used while mapping reads on found SNPs (kissreads). Default=1"
147 echoscip-shell system . . echo. -e "\t -n | --no_genotype"
148 echoscip-shell system . . echo. -e "\t\t Do not compute the genotypes"
149 echoscip-shell system . . echo. -e "\t -u | --max_threads <int>"
150 echoscip-shell system . . echo. -e "\t\t Max number of used threads. 0 means all threads"
151 echoscip-shell system . . echo. -e "\t\t default 0"
152
153
154 echoscip-shell system . . echo. -e "\nREFERENCE GENOME AND/OR VCF CREATION OPTIONS"
155 echoscip-shell system . . echo. -e "\t -G | --reference_genome <file name>"
156 echoscip-shell system . . echo. -e "\t\t Reference genome file (fasta, fastq, gzipped or nor). In absence of this file the VCF created by VCF_creator won't contain mapping related results."
157 echoscip-shell system . . echo. -e "\t -R"
158 echoscip-shell system . . echo. -e "\t\t Use the reference file also in the variant calling, not only for mapping results"
159 echoscip-shell system . . echo. -e "\t -B | --bwa_path <directory name>"
160 echoscip-shell system . . echo. -e "\t\t bwa path. e.g. /home/me/my_programs/bwa-0.7.12/ (note that bwa must be pre-compiled)"
161 echoscip-shell system . . echo. -e "\t\t Optional unless option -G used and bwa is not in the binary path."
162 echoscip-shell system . . echo. -e "\t -e\t Map variant predictions on reference genome with their unitig or contig extensions."
163 echoscip-shell system . . echo. -e "\t\t Useless unless mapping on reference genome is required (option -G). "
164
165 echoscip-shell system . . echo. -e "\nCONTEXT OPTION"
166 echoscip-shell system . . echo. -e "\t -z\t Considers AAV context: all predictions are coherents and authorize non closed bubbles (-x option)"
167
168 echoscip-shell system . . echo. -e "\nMISC."
169 echoscip-shell system . . echo. -e "\t -w\t Wraith mode: only show all discoSnp++ commands without running them"
170 echoscip-shell system . . echo. -e "\t -v <0 or 1>"
171 echoscip-shell system . . echo. -e "\t\t Verbose 0 (avoids progress output) or 1 (enables progress output) -- default=1."
172 echoscip-shell system . . echo. -e "\t -h | --help"
173 echoscip-shell system . . echo. -e "\t\t Prints this message and exist\n"
174
175 echoscip-shell system . . echo. "Any further question: read the readme file or contact us via the Biostar forum: https://www.biostars.org/t/discosnp/"
176 }
177
178
179
180
181 echoscip-shell system . . echo. "${yellow}"
182
183 while :; do
184 case $1 in
185 -A)
186 option_phase_variants="-phasing"
187 echoscip-shell system . . echo. "Will phase variants during kissreads process - WARNING this option is too experimental and thus not described in the help message"
188 echoscip-shell system . . echo. "You can obtain clusters using script : \"script/from_phased_alleles_to_clusters.sh file_name_of_phased_alleles\" (the filename(s) is/are given during kissreads process"
189 ;;
190 -X)
191 stop_after_kissnp=1
192 ;;
193
194 -z)
195 aav=1
196 ;;
197 -w)
198 wraith="true"
199 ;;
200 -R)
201 useref="true"
202 output_coverage_option="-dont_output_first_coverage"
203 ;;
204
205 -a|--ambiguity_max_size)
206 if [scip-shell system . . `[`. "$2" ] && [scip-shell system . . `[`. ${2:0:1} != "-" ] ; then # checks that there exists a second value and its is not the start of the next option
207 max_ambigous_indel=$2
208 shift
209 else
210 diescip-shell shell discosnp 1:2.6.2-5 die(). 'ERROR: "'$1'" option requires a non-empty option argument.'
211 fi
212 ;;
213
214 -v)
215 if [scip-shell system . . `[`. "$2" ] && [scip-shell system . . `[`. ${2:0:1} != "-" ] ; then
216 verbose=$2
217 shift
218 else
219 diescip-shell shell discosnp 1:2.6.2-5 die(). 'ERROR: "'$1'" option requires a non-empty option argument.'
220 fi
221 ;;
222
223 -s|--symmetrical)
224 if [scip-shell system . . `[`. "$2" ] && [scip-shell system . . `[`. ${2:0:1} != "-" ] ; then
225 option_max_symmetrical_crossroads="-max_symmetrical_crossroads "$2
226 shift
227 else
228 diescip-shell shell discosnp 1:2.6.2-5 die(). 'ERROR: "'$1'" option requires a non-empty option argument.'
229 fi
230 ;;
231
232
233
234 -T|--contigs)
235 extend="-T"
236 ;;
237
238 -g|--graph)
239 if [scip-shell system . . `[`. "$2" ] && [scip-shell system . . `[`. ${2:0:1} != "-" ] ; then
240 graph_reused=$2
241 shift
242 else
243 diescip-shell shell discosnp 1:2.6.2-5 die(). 'ERROR: "'$1'" option requires a non-empty option argument.'
244 fi
245 ;;
246
247
248 -n|--no_genotype)
249 genotyping=""
250 ;;
251
252 -l|--no_low_complexity)
253 l=""
254 ;;
255 -h|-\?|--help)
256 helpscip-shell shell discosnp 1:2.6.2-5 help().
257 exit
258 ;;
259
260 -r|--fof)
261 if [scip-shell system . . `[`. "$2" ] && [scip-shell system . . `[`. ${2:0:1} != "-" ] ; then
262 read_sets=$2
263 shift
264 else
265 diescip-shell shell discosnp 1:2.6.2-5 die(). 'ERROR: "'$1'" option requires a non-empty option argument.'
266 fi
267 ;;
268
269 --fof_mapping)
270 if [scip-shell system . . `[`. "$2" ] && [scip-shell system . . `[`. ${2:0:1} != "-" ] ; then
271 read_sets_kissreads=$2
272 shift
273 else
274 diescip-shell shell discosnp 1:2.6.2-5 die(). 'ERROR: "'$1'" option requires a non-empty option argument.'
275 fi
276 ;;
277
278 -b|--branching)
279 if [scip-shell system . . `[`. "$2" ] && [scip-shell system . . `[`. ${2:0:1} != "-" ] ; then
280 b=$2
281 shift
282 else
283 diescip-shell shell discosnp 1:2.6.2-5 die(). 'ERROR: "'$1'" option requires a non-empty option argument.'
284 fi
285 ;;
286
287 -p|--prefix)
288 if [scip-shell system . . `[`. "$2" ] && [scip-shell system . . `[`. ${2:0:1} != "-" ] ; then
289 prefix=$2
290 shift
291 else
292 diescip-shell shell discosnp 1:2.6.2-5 die(). 'ERROR: "'$1'" option requires a non-empty option argument.'
293 fi
294 ;;
295
296 -k | --k_size)
297 if [scip-shell system . . `[`. "$2" ] && [scip-shell system . . `[`. ${2:0:1} != "-" ] ; then
298 k=$2
299 shift
300 else
301 diescip-shell shell discosnp 1:2.6.2-5 die(). 'ERROR: "'$1'" option requires a non-empty option argument.'
302 fi
303 ;;
304
305
306 -P|--max_snp_per_bubble)
307 if [scip-shell system . . `[`. "$2" ] && [scip-shell system . . `[`. ${2:0:1} != "-" ] ; then
308 P=$2
309 shift
310 else
311 diescip-shell shell discosnp 1:2.6.2-5 die(). 'ERROR: "'$1'" option requires a non-empty option argument.'
312 fi
313 ;;
314
315 -c|--min_coverage)
316 if [scip-shell system . . `[`. "$2" ] && [scip-shell system . . `[`. ${2:0:1} != "-" ] ; then
317 c=$2
318 shift
319 else
320 diescip-shell shell discosnp 1:2.6.2-5 die(). 'ERROR: "'$1'" option requires a non-empty option argument.'
321 fi
322 ;;
323
324 -C|--max_coverage)
325 if [scip-shell system . . `[`. "$2" ] && [scip-shell system . . `[`. ${2:0:1} != "-" ] ; then
326 C=$2
327 shift
328 else
329 diescip-shell shell discosnp 1:2.6.2-5 die(). 'ERROR: "'$1'" option requires a non-empty option argument.'
330 fi
331 ;;
332
333 -d|--max_substitutions)
334 if [scip-shell system . . `[`. "$2" ] && [scip-shell system . . `[`. ${2:0:1} != "-" ] ; then
335 d=$2
336 shift
337 else
338 diescip-shell shell discosnp 1:2.6.2-5 die(). 'ERROR: "'$1'" option requires a non-empty option argument.'
339 fi
340 ;;
341
342 -D|--deletion_max_size)
343 if [scip-shell system . . `[`. "$2" ] && [scip-shell system . . `[`. ${2:0:1} != "-" ] ; then
344 D=$2
345 shift
346 else
347 diescip-shell shell discosnp 1:2.6.2-5 die(). 'ERROR: "'$1'" option requires a non-empty option argument.'
348 fi
349 ;;
350
351 B|--bwa_path)
352 if [scip-shell system . . `[`. "$2" ] && [scip-shell system . . `[`. ${2:0:1} != "-" ] ; then
353 bwa_path_option="-B "$2
354 shift
355 else
356 diescip-shell shell discosnp 1:2.6.2-5 die(). 'ERROR: "'$1'" option requires a non-empty option argument.'
357 fi
358 ;;
359
360 -x)
361 x="-x" ##Authorise non closed bubbles
362 ;;
363
364 -G|--reference_genome)
365 if [scip-shell system . . `[`. "$2" ] && [scip-shell system . . `[`. ${2:0:1} != "-" ] ; then
366 genome=$2
367 shift
368 else
369 diescip-shell shell discosnp 1:2.6.2-5 die(). 'ERROR: "'$1'" option requires a non-empty option argument.'
370 fi
371 ;;
372
373 -e)
374 e="-e" # map with extensions to the reference genome
375 ;;
376
377 -u|--max_threads)
378 if [scip-shell system . . `[`. "$2" ] && [scip-shell system . . `[`. ${2:0:1} != "-" ] ; then
379 option_cores_gatb="-nb-cores $2"
380 option_cores_post_analysis="-t $2"
381 shift
382 else
383 diescip-shell shell discosnp 1:2.6.2-5 die(). 'ERROR: "'$1'" option requires a non-empty option argument.'
384 fi
385 ;;
386
387 -?*)
388 printfscip-shell system . . printf. 'WARN: Unknown option (exit): %s\n' "$1" >&2
389 exit 1
390 ;;
391
392 :)
393 echoscip-shell system . . echo. "Option $1 requires an argument." >&2
394 exit 1
395 ;;
396 --) # End of all options.
397 shift
398 break
399 ;;
400 -?*)
401 printfscip-shell system . . printf. 'WARN: Unknown option (ignored): %s\n' "$1" >&2
402 ;;
403 *) # Default case: No more options, so break out of the loop.
404 break
405 esac
406
407 shift
408 done
409 echoscip-shell system . . echo. $reset
410
411 if [scip-shell system . . `[`. -z "$read_sets" ]; then
412 echoscip-shell system . . echo. "$red You must provide at least one read set (-r|--fof)"
413 helpscip-shell shell discosnp 1:2.6.2-5 help().
414 echoscip-shell system . . echo. $reset
415 exit 1
416 fi
417
418
419 ######### CHECK THE k PARITY ##########
420 rest=$(( $k % 2 ))
421 if [scip-shell system . . `[`. $rest -eq 0 ]
422 then
423 echoscip-shell system . . echo. "$red k=$k is even number, to avoid palindromes, we set it to $(($k-1)) $reset"
424 k=$(($k-1))
425 fi
426
427
428 #######################################
429 c_filename=`echoscip-shell system . . echo. ${c} | trscip-shell system . . tr. ',' '_'`
430 if [scip-shell system . . `[`. $C -ne $max_C ]
431 then
432 h5prefix=${prefix}_k_${k}_c_${c_filename}_C_${C}
433 else
434 h5prefix=${prefix}_k_${k}_c_${c_filename}
435
436 fi
437 kissprefix=${h5prefix}_D_${D}_P_${P}_b_${b}
438 readsFilesDump=${prefix}_read_files_correspondance.txt
439 mapped_readsFilesDump=${prefix}_mapped_read_files_correspondance.txt
440
441
442 #######################################
443 c_dbgh5=$c
444 rmscip-shell system . . rm. -f ${read_sets}_${kissprefix}_removemeplease
445 if [[ "$useref" == "true" ]]; then
446
447 if [scip-shell system . . `[`. -z "$genome" ]; then
448 echoscip-shell system . . echo. "$red You can't use option -R without providing a reference genome (-G) $reset"
449 helpscip-shell shell discosnp 1:2.6.2-5 help().
450 exit 1
451 fi
452
453 myrealpathscip-shell shell discosnp 1:2.6.2-5 myrealpath(). $genome > ${read_sets}_${kissprefix}_removemeplease
454 c_dbgh5="1,"$c
455
456 fi
457 catscip-shell system . . cat. $read_sets >> ${read_sets}_${kissprefix}_removemeplease
458
459 if [scip-shell system . . `[`. $aav -eq 1 ]; then
460 x="-x"
461 fi
462
463
464 #######################################################################
465 #################### OPTIONS SUMMARY #######################
466 #######################################################################
467 if [[ "$wraith" == "false" ]]; then
468 echoscip-shell system . . echo. -e "$yellow Running discoSnp++ "$version", in directory "$EDIR" with following parameters:"
469 echoscip-shell system . . echo. -e "\t read_sets="$read_sets
470 echoscip-shell system . . echo. -e "\t prefix="$h5prefix
471 echoscip-shell system . . echo. -e "\t c="$c
472 echoscip-shell system . . echo. -e "\t C="$C
473 echoscip-shell system . . echo. -e "\t k="$k
474 echoscip-shell system . . echo. -e "\t b="$b
475 echoscip-shell system . . echo. -e "\t d="$d
476 echoscip-shell system . . echo. -e "\t D="$D
477 echoscip-shell system . . echo. -e "\t s="$option_max_symmetrical_crossroads
478 echoscip-shell system . . echo. -e "\t P="$P
479 if [scip-shell system . . `[`. ! -z "${read_sets_kissreads}" ]; then
480 echoscip-shell system . . echo. -e "\t fof_mapping read_file_of_files="${read_sets_kissreads}
481 fi
482 if [scip-shell system . . `[`. -f ${graph_reused} ]; then
483 echoscip-shell system . . echo. -e "\t reuse graph="${graph_reused}
484 fi
485 echoscip-shell system . . echo. -e "\t p="$prefix
486 echoscip-shell system . . echo. -e "\t G="$genome
487 echoscip-shell system . . echo. -e "\t e="$e
488 echoscip-shell system . . echo. -e "\t x="$x
489
490
491
492 echoscip-shell system . . echo. -e -n "\t starting date="
493 datescip-shell system . . date.
494 echoscip-shell system . . echo.
495 fi
496 echoscip-shell system . . echo. $reset
497 #######################################################################
498 #################### END OPTIONS SUMMARY #######################
499 #######################################################################
500
501 #############################################################
502 #################### DUMP READ FILES #######################
503 #############################################################
504 ${read_file_names_bin} -in $read_sets > $readsFilesDump
505 if [scip-shell system . . `[`. ! -z "${read_sets_kissreads}" ]; then
506 ${read_file_names_bin} -in ${read_sets_kissreads} > $mapped_readsFilesDump
507 fi
508
509
510 ############################################################
511 #################### GRAPH CREATION #######################
512 ############################################################
513 if [scip-shell system . . `[`. ! -f ${graph_reused} ]; then # no graph was given or the given graph was not a file.
514 T="$(datescip-shell system . . date. +%s)"
515 echoscip-shell system . . echo. -e "$yellow ############################################################"
516 echoscip-shell system . . echo. -e " #################### GRAPH CREATION #######################"
517 echoscip-shell system . . echo. -e " ############################################################$reset"
518
519 graphCmd="${dbgh5_bin} -in ${read_sets}_${kissprefix}_removemeplease -out $h5prefix -kmer-size $k -abundance-min ${c_dbgh5} -abundance-max $C -solidity-kind one ${option_cores_gatb} -verbose $verbose -skip-bcalm -skip-bglue -no-mphf -histo-max 1000000"
520 echoscip-shell system . . echo. $green${graphCmd}$cyan
521 if [[ "$wraith" == "false" ]]; then
522 ${graphCmd}
523 fi
524 if [scip-shell system . . `[`. $? -ne 0 ]
525 then
526 echoscip-shell system . . echo. "$red there was a problem with graph construction$ reset"
527 exit 1
528 fi
529
530 T="$(($(datescip-shell system . . date. +%s)-T))"
531 if [[ "$wraith" == "false" ]]; then
532 echoscip-shell system . . echo. "$yellow Graph creation time in seconds: ${T}$reset"
533 fi
534 graph_reused=$h5prefix.h5
535 else
536 if [[ "$wraith" == "false" ]]; then
537 echoscip-shell system . . echo. -e "$yellow File ${graph_reused} exists. We use it as input graph$reset"
538 fi
539 fi
540
541 echoscip-shell system . . echo. $reset
542 cleanCmd="rm -rf trashme_*"
543 echoscip-shell system . . echo. $green${cleanCmd}$cyan
544 if [[ "$wraith" == "false" ]]; then
545 ${cleanCmd}
546 fi
547 echoscip-shell system . . echo. $reset
548
549 ######################################################
550 #################### KISSNP2 #######################
551 ######################################################
552 T="$(datescip-shell system . . date. +%s)"
553 echoscip-shell system . . echo. -e "$yellow ############################################################"
554 echoscip-shell system . . echo. -e " #################### KISSNP2 MODULE #######################"
555 echoscip-shell system . . echo. -e " ############################################################$reset"
556 kissnp2Cmd="${kissnp2_bin} -in ${graph_reused} -out $kissprefix -b $b $l $x -P $P -D $D $extend $option_cores_gatb -coverage_file ${h5prefix}_cov.h5 -max_ambigous_indel ${max_ambigous_indel} ${option_max_symmetrical_crossroads} -verbose $verbose"
557 echoscip-shell system . . echo. $green${kissnp2Cmd}$cyan
558 if [[ "$wraith" == "false" ]]; then
559 ${kissnp2Cmd}
560 fi
561
562 if [scip-shell system . . `[`. $? -ne 0 ]
563 then
564 echoscip-shell system . . echo. "$red there was a problem with kissnp2$reset"
565 exit 1
566 fi
567
568 T="$(($(datescip-shell system . . date. +%s)-T))"
569 if [[ "$wraith" == "false" ]]; then
570 echoscip-shell system . . echo. "$yellow Bubble detection time in seconds: ${T}$reset"
571 fi
572
573 if [scip-shell system . . `[`. ! -f $kissprefix.fa ]
574 then
575 if [[ "$wraith" == "false" ]]; then
576 echoscip-shell system . . echo. "$yellow No polymorphism predicted by discoSnp++"
577 echoscip-shell system . . echo. -e -n "\t ending date="
578 datescip-shell system . . date.
579 echoscip-shell system . . echo. -e " Thanks for using discoSnp++ - http://colibread.inria.fr/discoSnp/$reset"
580 exit
581 fi
582 fi
583
584 if [scip-shell system . . `[`. $stop_after_kissnp -eq 1 ]; then
585 if [[ "$wraith" == "false" ]]; then
586 echoscip-shell system . . echo. "$yellow -X option detected, computation stopped after variant detection."
587 echoscip-shell system . . echo. "Results (with no read coverage) are located here: "$kissprefix.fa
588 echoscip-shell system . . echo. -e -n "\t ending date="
589 datescip-shell system . . date.
590 echoscip-shell system . . echo. -e " Thanks for using discoSnp++ - http://colibread.inria.fr/discoSnp/ $reset"
591 exit
592 fi
593 fi
594
595 #######################################################################
596 #################### KISSREADS #######################
597 #######################################################################
598
599 T="$(datescip-shell system . . date. +%s)"
600 echoscip-shell system . . echo. -e "$yellow #############################################################"
601 echoscip-shell system . . echo. -e " #################### KISSREADS MODULE #######################"
602 echoscip-shell system . . echo. -e " #############################################################$reset"
603
604
605 smallk=$k
606 if (( $smallk>31 )) ; then
607 smallk=31
608 fi
609 i=5 #avoid modidy this (or increase this if memory needed by kissread is too high. Min 1. Large i (7-10) decreases memory and increases time).
610 index_stride=$(($i+1)); size_seed=$(($smallk-$i)) # DON'T modify this.
611
612 if [scip-shell system . . `[`. ! -z "${read_sets_kissreads}" ]; then
613 read_sets=${read_sets_kissreads}
614 fi
615
616 if [scip-shell system . . `[`. $aav -eq 1 ]; then
617 rmcmd="rm -f ${h5prefix}_cov.h5"
618 echoscip-shell system . . echo. $green${rmcmd}$cyan
619 $rmcmd # erase this file so all predictions are coherent after kissreads
620 fi
621 kissreadsCmd="${kissreads2_bin} -predictions $kissprefix.fa -reads ${read_sets}_${kissprefix}_removemeplease -co ${kissprefix}_coherent -unco ${kissprefix}_uncoherent -k $k -size_seeds ${size_seed} -index_stride ${index_stride} -hamming $d $genotyping -coverage_file ${h5prefix}_cov.h5 $option_cores_gatb -verbose $verbose ${option_phase_variants}"
622
623 echoscip-shell system . . echo. $green $kissreadsCmd$cyan
624 if [[ "$wraith" == "false" ]]; then
625 $kissreadsCmd
626 fi
627
628 if [scip-shell system . . `[`. $? -ne 0 ]
629 then
630 echoscip-shell system . . echo. "$red there was a problem with kissreads2$reset":
631 exit 1
632 fi
633 echoscip-shell system . . echo. $reset
634 T="$(($(datescip-shell system . . date. +%s)-T))"
635 # echo "Kissreads (mapping reads on bubbles) time in seconds: ${T}"
636
637
638 #######################################################################
639 #################### SORT AND FORMAT RESULTS #########################
640 #######################################################################
641
642 if [[ "$wraith" == "false" ]]; then
643 echoscip-shell system . . echo. -e "$yellow ###############################################################"
644 echoscip-shell system . . echo. -e " #################### SORT AND FORMAT RESULTS #################"
645 echoscip-shell system . . echo. -e " ###############################################################$reset"
646 fi
647
648 if [[ "$wraith" == "false" ]]; then
649 sortscip-shell system . . sort. -rg ${kissprefix}_coherent | cutscip-shell system . . cut. -d " " -f 2 | trscip-shell system . . tr. ';' '\n' > ${kissprefix}_coherent.fa
650 fi
651 if [scip-shell system . . `[`. $? -ne 0 ]
652 then
653 echoscip-shell system . . echo. "$red there was a problem with the result sorting.$reset"
654 exit 1
655 fi
656
657 if [[ "$wraith" == "false" ]]; then
658 sortscip-shell system . . sort. -rg ${kissprefix}_uncoherent | cutscip-shell system . . cut. -d " " -f 2 | trscip-shell system . . tr. ';' '\n' > ${kissprefix}_uncoherent.fa
659 fi
660
661 if [scip-shell system . . `[`. $? -ne 0 ]
662 then
663 echoscip-shell system . . echo. "$red there was a problem with the result sorting$reset"
664 exit 1
665 fi
666
667 rmscip-shell system . . rm. -f $kissprefix.fa ${kissprefix}_coherent ${kissprefix}_uncoherent
668 rmscip-shell system . . rm. -rf ${read_sets}_${kissprefix}_removemeplease
669
670 #######################################################################
671 #################### DISCOSNP FINISHED ###############################
672 #######################################################################
673
674
675
676
677
678
679 #######################################################################
680 #################### Deal with VCF ###############################
681 #######################################################################
682
683 T="$(datescip-shell system . . date. +%s)"
684 echoscip-shell system . . echo. -e "$yellow ###############################################################"
685 echoscip-shell system . . echo. -e " #################### CREATE VCF #######################"
686 echoscip-shell system . . echo. -e " ############################################################### $reset"
687
688 if [scip-shell system . . `[`. -z "$genome" ]; then # NO reference genome use, vcf creator mode 1
•689 vcfCreatorCmd="/usr/share/discosnp/scripts/run_VCF_creator.sh -p ${kissprefix}_coherent.fa -o ${kissprefix}_coherent.vcf"
690 echoscip-shell system . . echo. $green$vcfCreatorCmd$cyan
691 if [[ "$wraith" == "false" ]]; then
692 $vcfCreatorCmd
693 fi
694 if [scip-shell system . . `[`. $? -ne 0 ]
695 then
696 echoscip-shell system . . echo. "$red there was a problem with VCF creation. See how to use the \"run_VCF_creator.sh\" alone.$reset"
697 exit 1
698 fi
699 else # A Reference genome is provided, vcf creator mode 2
•700 vcfCreatorCmd="/usr/share/discosnp/scripts/run_VCF_creator.sh $bwa_path_option -G $genome $bwa_path_option -p ${kissprefix}_coherent.fa -o ${kissprefix}_coherent.vcf -I $option_cores_post_analysis $e"
701 echoscip-shell system . . echo. $green$vcfCreatorCmd$cyan
702 if [[ "$wraith" == "false" ]]; then
703 $vcfCreatorCmd
704 fi
705
706 if [scip-shell system . . `[`. $? -ne 0 ]
707 then
708 echoscip-shell system . . echo. "$red there was a problem with VCF creation. See how to use the \"run_VCF_creator.sh\" alone.$reset"
709 exit 1
710 fi
711 fi
712 echoscip-shell system . . echo. $reset
713 T="$(($(datescip-shell system . . date. +%s)-T))"
714 if [[ "$wraith" == "false" ]]; then
715 echoscip-shell system . . echo. "$yellow Vcf creation time in seconds: ${T}"
716
717 echoscip-shell system . . echo. -e " ###############################################################"
718 echoscip-shell system . . echo. -e " #################### DISCOSNP++ FINISHED ######################"
719 echoscip-shell system . . echo. -e " ###############################################################"
720 Ttot="$(($(datescip-shell system . . date. +%s)-Ttot))"
721 echoscip-shell system . . echo. "DiscoSnp++ total time in seconds: ${Ttot}"
722 echoscip-shell system . . echo. -e "################################################################################################################"
723 echoscip-shell system . . echo. -e " fasta of predicted variant is \""${kissprefix}_coherent.fa"\""
724
725 if [scip-shell system . . `[`. -z "$genome" ]; then
726 echoscip-shell system . . echo. -e " Ghost VCF file (1-based) is \""${kissprefix}_coherent.vcf"\""
727 else
728 echoscip-shell system . . echo. -e " VCF file (1-based) is \""${kissprefix}_coherent.vcf"\""
729 echoscip-shell system . . echo. -e " An IGV ready VCF file (sorted by position, only mapped variants, 0-based) is \""${kissprefix}_coherent_for_IGV.vcf"\""
730 fi
731 echoscip-shell system . . echo. -e " Thanks for using discoSnp++ - http://colibread.inria.fr/discoSnp/ - Forum: http://www.biostars.org/t/discoSnp/"
732 echoscip-shell system . . echo. -e "################################################################################################################$reset"
•733 fi