Debian Codegraph @

run_discoSnp++_ML.sh

raw symbols ◀ ▶ SCIP
1 Debian patch 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
22 red=`tputscip-shell system . . tput. setaf 1`
23 green=`tputscip-shell system . . tput. setaf 2`
24 yellow=`tputscip-shell system . . tput. setaf 3`
25 cyan=`tputscip-shell system . . tput. setaf 6`
26 bold=`tputscip-shell system . . tput. bold`
27 reset=`tputscip-shell system . . tput. sgr0`
28
29 diescip-shell shell discosnp 1:2.6.2-5 die().() {
30 printfscip-shell system . . printf. '%s\n' "$1" >&2
31 exit 1
32 }
33 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); }
34
35 option_cores_gatb=""
36 option_cores_post_analysis=""
37
38 Ttot="$(datescip-shell system . . date. +%s)"
39 #### constant #####
40 max_C=2147483647 #$((2**31-1))
41
42 ###########################################################
43 #################### DEFAULT VALUES #######################
44 ###########################################################
45 version="2.3.X"
46 read_sets="" # A file of file(s)
47 read_sets_kissreads=""
48 prefix="discoRes" # all intermediate and final files will be written will start with this prefix
49 k=31 # size of kmers
50 b=0 # smart branching approach: bubbles in which both paths are equaly branching are discarded, all others are accepted
51 c=3 # minimal coverage
52 C=$max_C # maximal coverage
53 d=1 # estimated number of error per read (used by kissreads only)
54 D=100 # maximal size of searched deletions
55 max_ambigous_indel=20
56 P=3 # number of polymorphsim per bubble
57 option_max_symmetrical_crossroads=""
58 l="-l"
59 extend="-t"
60 x=""
61 y=""
62 output_coverage_option=""
63 genotyping="-genotype"
64 remove=1
65 verbose=1
66 stop_after_kissnp=0
67 e=""
68 prefix_trash=`headscip-shell system . . head. /dev/urandomscip-shell filesystem . . `/dev/urandom`. | trscip-shell system . . tr. -dc A-Za-z0-9 | headscip-shell system . . head. -c 13 ; echoscip-shell system . . echo. ''`
69 #EDIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
•70 EDIR=$( python3scip-shell system . . python3. -c "import os.path; print(os.path.dirname(os.path.realpath(\"${BASH_SOURCE[0]}\")))" ) # as suggested by Philippe Bordron
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 create_coverage_h5_file_bin=$EDIR/build/bin/create_coverage_h5_file
79 else # VERSION BINARY
80 read_file_names_bin=$EDIR/bin/read_file_names
81 dbgh5_bin=$EDIR/bin/dbgh5
82 kissnp2_bin=$EDIR/bin/kissnp2
83 kissreads2_bin=$EDIR/bin/kissreads2
84 create_coverage_h5_file_bin=$EDIR/bin/create_coverage_h5_file
85 fi
86
87 chmodscip-shell system . . chmod. +x $EDIR/scripts/*.sh $EDIR/run_discoSnpRad.sh 2>/dev/nullscip-shell filesystem . . `/dev/null`. # Usefull for binary distributions
88
89 useref=""
90 wraith="false"
91 genome=""
92 bwa_path_option=""
93 option_phase_variants=""
94 bwa_distance=4
95
96 dsk_build_dir=""
97
98 #######################################################################
99 #################### END HEADER #######################
100 #######################################################################
101
102 function helpscip-shell shell discosnp 1:2.6.2-5 help(). {
103 echoscip-shell system . . echo. " ************"
104 echoscip-shell system . . echo. " *** HELP ***"
105 echoscip-shell system . . echo. " ************"
106 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"
107 echoscip-shell system . . echo. "Version "$version
108 echoscip-shell system . . echo. "Usage: ./run_discoSnp++.sh -r read_file_of_files [OPTIONS]"
109 echoscip-shell system . . echo. -e "MANDATORY"
110 echoscip-shell system . . echo. -e "\t -r|--fof <file name of a file of file(s)>"
111 echoscip-shell system . . echo. -e "\t\t The input read files indicated in a file of file(s)"
112 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"
113 echoscip-shell system . . echo. -e "\t -f Absolute path to compiled dsk (directory containing compiled dsk and dsk2ascii)"
114
115 echoscip-shell system . . echo. -e "\nOPTIONS"
116 echoscip-shell system . . echo. -e "\t -k | --k_size value <int value>"
117 echoscip-shell system . . echo. -e "\t\t Set the length of used kmers. Must fit the compiled value."
118 echoscip-shell system . . echo. -e "\t\t Default=31"
119 echoscip-shell system . . echo. -e "\t -c | --min_coverage value <int value>"
120 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)."
121 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."
122 echoscip-shell system . . echo. -e "\t\t Default=3"
123 echoscip-shell system . . echo. -e "\t -C | --max_coverage value <int value in 0, 1 or 2>"
124 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)."
125 echoscip-shell system . . echo. -e "\t\t Default=2^31-1"
126 echoscip-shell system . . echo. -e "\t -b | --branching value. "
127 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)."
128 echoscip-shell system . . echo. -e "\t\t Default value"
129 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"
130 echoscip-shell system . . echo. -e "\t\t2: No limitation on branching (lowers the precision, high recall)"
131 echoscip-shell system . . echo. -e "\t -s | --symmetrical value <int value>"
132 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"
133 echoscip-shell system . . echo. -e "\t -g | --graph"
134 echoscip-shell system . . echo. -e "\t\t Reuse a previously created graph (.h5 file) with same prefix and same k and c parameters (here, contrary to discoSnp++.sh, no graph file can be specified)."
135 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."
136 echoscip-shell system . . echo. -e "\t -D | --deletion_max_size <int>"
137 echoscip-shell system . . echo. -e "\t\t discoSnp++ will search for deletions of size from 1 to D included. Default=100"
138 echoscip-shell system . . echo. -e "\t -a | --ambiguity_max_size <int>"
139 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']"
140 echoscip-shell system . . echo. -e "\t -P | --max_snp_per_bubble <int>"
141 echoscip-shell system . . echo. -e "\t\t discoSnp++ will search up to P SNPs in a unique bubble. Default=3"
142 echoscip-shell system . . echo. -e "\t --fof_mapping <file name of a file of file(s)>"
143 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"
144 echoscip-shell system . . echo. -e "\t -p | --prefix <string>"
145 echoscip-shell system . . echo. -e "\t\t All out files will start with this prefix. Default=\"discoRes\""
146 echoscip-shell system . . echo. -e "\t -l | --no_low_complexity"
147 echoscip-shell system . . echo. -e "\t\t Remove low complexity bubbles"
148 echoscip-shell system . . echo. -e "\t -T | --contigs"
149 echoscip-shell system . . echo. -e "\t\t Extend found polymorphisms with contigs (default: extend with unitigs)"
150 echoscip-shell system . . echo. -e "\t -d | --max_substitutions <int>"
151 echoscip-shell system . . echo. -e "\t\t Set the number of authorized substitutions used while mapping reads on found SNPs (kissreads). Default=1"
152 echoscip-shell system . . echo. -e "\t -n | --no_genotype"
153 echoscip-shell system . . echo. -e "\t\t Do not compute the genotypes"
154 echoscip-shell system . . echo. -e "\t -u | --max_threads <int>"
155 echoscip-shell system . . echo. -e "\t\t Max number of used threads. 0 means all threads"
156 echoscip-shell system . . echo. -e "\t\t default 0"
157
158
159 echoscip-shell system . . echo. -e "\nREFERENCE GENOME AND/OR VCF CREATION OPTIONS"
160 echoscip-shell system . . echo. -e "\t -G | --reference_genome <file name>"
161 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."
162 echoscip-shell system . . echo. -e "\t -R"
163 echoscip-shell system . . echo. -e "\t\t Use the reference file also in the variant calling, not only for mapping results"
164 echoscip-shell system . . echo. -e "\t -B | --bwa_path <directory name>"
165 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)"
166 echoscip-shell system . . echo. -e "\t\t Optional unless option -G used and bwa is not in the binary path."
167 echoscip-shell system . . echo. -e "\t -e\t Map variant predictions on reference genome with their unitig or contig extensions."
168 echoscip-shell system . . echo. -e "\t\t Useless unless mapping on reference genome is required (option -G). "
169 echoscip-shell system . . echo.
170
171 echoscip-shell system . . echo. -e "\t -w\t Wraith mode: only show all discoSnp++ commands without running them"
172 echoscip-shell system . . echo. -e "\t -v <0 or 1>"
173 echoscip-shell system . . echo. -e "\t\t Verbose 0 (avoids progress output) or 1 (enables progress output) -- default=1."
174 echoscip-shell system . . echo. -e "\t -h | --help"
175 echoscip-shell system . . echo. -e "\t\t Prints this message and exist\n"
176
177 echoscip-shell system . . echo. "Any further question: read the readme file or contact us via the Biostar forum: https://www.biostars.org/t/discosnp/"
178 }
179
180
181
182
183
184
185 while :; do
186 case $1 in
187 -f)
188 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
189 dsk_build_dir=$2
190 shift
191 else
192 diescip-shell shell discosnp 1:2.6.2-5 die(). 'ERROR: "'$1'" option requires a non-empty option argument.'
193 fi
194 ;;
195 -A)
196 option_phase_variants="-phasing"
197 echoscip-shell system . . echo. "Will phase variants during kissreads process - WARNING this option is too experimental and thus not described in the help message"
198 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"
199 ;;
200 -X)
201 stop_after_kissnp=1
202 ;;
203 -w)
204 wraith="true"
205 ;;
206 -R)
207 useref="true"
208 output_coverage_option="-dont_output_first_coverage"
209 ;;
210
211 -a|--ambiguity_max_size)
212 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
213 max_ambigous_indel=$2
214 shift
215 else
216 diescip-shell shell discosnp 1:2.6.2-5 die(). 'ERROR: "'$1'" option requires a non-empty option argument.'
217 fi
218 ;;
219
220 -v)
221 if [scip-shell system . . `[`. "$2" ] && [scip-shell system . . `[`. ${2:0:1} != "-" ] ; then
222 verbose=$2
223 shift
224 else
225 diescip-shell shell discosnp 1:2.6.2-5 die(). 'ERROR: "'$1'" option requires a non-empty option argument.'
226 fi
227 ;;
228
229 -s|--symmetrical)
230 if [scip-shell system . . `[`. "$2" ] && [scip-shell system . . `[`. ${2:0:1} != "-" ] ; then
231 option_max_symmetrical_crossroads="-max_symmetrical_crossroads "$2
232 shift
233 else
234 diescip-shell shell discosnp 1:2.6.2-5 die(). 'ERROR: "'$1'" option requires a non-empty option argument.'
235 fi
236 ;;
237
238
239
240 -T|--contigs)
241 extend="-T"
242 ;;
243
244 -g|--graph)
245 remove=0
246 ;;
247
248
249 -n|--no_genotype)
250 genotyping=""
251 ;;
252
253 -l|--no_low_complexity)
254 l=""
255 ;;
256 -h|-\?|--help)
257 helpscip-shell shell discosnp 1:2.6.2-5 help().
258 exit
259 ;;
260
261 -r|--fof)
262 if [scip-shell system . . `[`. "$2" ] && [scip-shell system . . `[`. ${2:0:1} != "-" ] ; then
263 read_sets=$2
264 shift
265 else
266 diescip-shell shell discosnp 1:2.6.2-5 die(). 'ERROR: "'$1'" option requires a non-empty option argument.'
267 fi
268 ;;
269
270 --fof_mapping)
271 if [scip-shell system . . `[`. "$2" ] && [scip-shell system . . `[`. ${2:0:1} != "-" ] ; then
272 read_sets_kissreads=$2
273 shift
274 else
275 diescip-shell shell discosnp 1:2.6.2-5 die(). 'ERROR: "'$1'" option requires a non-empty option argument.'
276 fi
277 ;;
278
279 -b|--branching)
280 if [scip-shell system . . `[`. "$2" ] && [scip-shell system . . `[`. ${2:0:1} != "-" ] ; then
281 b=$2
282 shift
283 else
284 diescip-shell shell discosnp 1:2.6.2-5 die(). 'ERROR: "'$1'" option requires a non-empty option argument.'
285 fi
286 ;;
287
288 -p|--prefix)
289 if [scip-shell system . . `[`. "$2" ] && [scip-shell system . . `[`. ${2:0:1} != "-" ] ; then
290 prefix=$2
291 shift
292 else
293 diescip-shell shell discosnp 1:2.6.2-5 die(). 'ERROR: "'$1'" option requires a non-empty option argument.'
294 fi
295 ;;
296
297 -k | --k_size)
298 if [scip-shell system . . `[`. "$2" ] && [scip-shell system . . `[`. ${2:0:1} != "-" ] ; then
299 k=$2
300 shift
301 else
302 diescip-shell shell discosnp 1:2.6.2-5 die(). 'ERROR: "'$1'" option requires a non-empty option argument.'
303 fi
304 ;;
305
306
307 -P|--max_snp_per_bubble)
308 if [scip-shell system . . `[`. "$2" ] && [scip-shell system . . `[`. ${2:0:1} != "-" ] ; then
309 P=$2
310 shift
311 else
312 diescip-shell shell discosnp 1:2.6.2-5 die(). 'ERROR: "'$1'" option requires a non-empty option argument.'
313 fi
314 ;;
315
316 -c|--min_coverage)
317 if [scip-shell system . . `[`. "$2" ] && [scip-shell system . . `[`. ${2:0:1} != "-" ] ; then
318 c=$2
319 shift
320 else
321 diescip-shell shell discosnp 1:2.6.2-5 die(). 'ERROR: "'$1'" option requires a non-empty option argument.'
322 fi
323 ;;
324
325 -C|--max_coverage)
326 if [scip-shell system . . `[`. "$2" ] && [scip-shell system . . `[`. ${2:0:1} != "-" ] ; then
327 C=$2
328 shift
329 else
330 diescip-shell shell discosnp 1:2.6.2-5 die(). 'ERROR: "'$1'" option requires a non-empty option argument.'
331 fi
332 ;;
333
334 -d|--max_substitutions)
335 if [scip-shell system . . `[`. "$2" ] && [scip-shell system . . `[`. ${2:0:1} != "-" ] ; then
336 d=$2
337 shift
338 else
339 diescip-shell shell discosnp 1:2.6.2-5 die(). 'ERROR: "'$1'" option requires a non-empty option argument.'
340 fi
341 ;;
342
343 -D|--deletion_max_size)
344 if [scip-shell system . . `[`. "$2" ] && [scip-shell system . . `[`. ${2:0:1} != "-" ] ; then
345 D=$2
346 shift
347 else
348 diescip-shell shell discosnp 1:2.6.2-5 die(). 'ERROR: "'$1'" option requires a non-empty option argument.'
349 fi
350 ;;
351
352 B|--bwa_path)
353 if [scip-shell system . . `[`. "$2" ] && [scip-shell system . . `[`. ${2:0:1} != "-" ] ; then
354 bwa_path_option="-B "$2
355 shift
356 else
357 diescip-shell shell discosnp 1:2.6.2-5 die(). 'ERROR: "'$1'" option requires a non-empty option argument.'
358 fi
359 ;;
360
361 -x)
362 x="-x" ##CHARLOTTE
363 ;;
364
365 -y)
366 y="-x" ##CHARLOTTE
367 ;;
368
369 -G|--reference_genome)
370 if [scip-shell system . . `[`. "$2" ] && [scip-shell system . . `[`. ${2:0:1} != "-" ] ; then
371 genome=$2
372 shift
373 else
374 diescip-shell shell discosnp 1:2.6.2-5 die(). 'ERROR: "'$1'" option requires a non-empty option argument.'
375 fi
376 ;;
377
378
379 -e)
380 e="-e"
381 ;;
382
383 -u|--max_threads)
384 if [scip-shell system . . `[`. "$2" ] && [scip-shell system . . `[`. ${2:0:1} != "-" ] ; then
385 option_cores_gatb="-nb-cores $2"
386 option_cores_post_analysis="-t $2"
387 shift
388 else
389 diescip-shell shell discosnp 1:2.6.2-5 die(). 'ERROR: "'$1'" option requires a non-empty option argument.'
390 fi
391 ;;
392
393 -?*)
394 printfscip-shell system . . printf. 'WARN: Unknown option (exit): %s\n' "$1" >&2
395 exit 1
396 ;;
397
398 :)
399 echoscip-shell system . . echo. "${red}Option $1 requires an argument.${reset}" >&2
400 exit 1
401 ;;
402 --) # End of all options.
403 shift
404 break
405 ;;
406 -?*)
407 printfscip-shell system . . printf. 'WARN: Unknown option (ignored): %s\n' "$1" >&2
408 ;;
409 *) # Default case: No more options, so break out of the loop.
410 break
411 esac
412
413 shift
414 done
415
416
417 if [scip-shell system . . `[`. ! -d "$dsk_build_dir" ]; then
418 echoscip-shell system . . echo. "${red}You must provide dsk bin direction (option -f)${reset}"
419 helpscip-shell shell discosnp 1:2.6.2-5 help().
420 exit 1
421 fi
422
423 if [scip-shell system . . `[`. -z "$read_sets" ]; then
424 echoscip-shell system . . echo. "${red}You must provide at least one read set (-r|--fof)${reset}"
425 helpscip-shell shell discosnp 1:2.6.2-5 help().
426 exit 1
427 fi
428
429
430 ######### CHECK THE k PARITY ##########
431 rest=$(( $k % 2 ))
432 if [scip-shell system . . `[`. $rest -eq 0 ]
433 then
434 echoscip-shell system . . echo. "${red}k=$k is even number, to avoid palindromes, we set it to $(($k-1))${reset}"
435 k=$(($k-1))
436 fi
437
438
439 #######################################
440 c_filename=`echoscip-shell system . . echo. ${c} | trscip-shell system . . tr. ',' '_'`
441 if [scip-shell system . . `[`. $C -ne $max_C ]
442 then
443 h5prefix=${prefix}_k_${k}_c_${c_filename}_C_${C}
444 else
445 h5prefix=${prefix}_k_${k}_c_${c_filename}
446
447 fi
448 kissprefix=${h5prefix}_D_${D}_P_${P}_b_${b}
449 readsFilesDump=${prefix}_read_files_correspondance.txt
450 mapped_readsFilesDump=${prefix}_mapped_read_files_correspondance.txt
451
452
453 #######################################
454 c_dbgh5=$c
455 rmscip-shell system . . rm. -f ${read_sets}_${kissprefix}_removemeplease
456 if [[ "$useref" == "true" ]]; then
457
458 if [scip-shell system . . `[`. -z "$genome" ]; then
459 echoscip-shell system . . echo. "${red}You can't use option -R without providing a reference genome (-G)${reset}"
460 helpscip-shell shell discosnp 1:2.6.2-5 help().
461 exit 1
462 fi
463
464 myrealpathscip-shell shell discosnp 1:2.6.2-5 myrealpath(). $genome > ${read_sets}_${kissprefix}_removemeplease
465 c_dbgh5="1,"$c
466
467 fi
468 catscip-shell system . . cat. $read_sets >> ${read_sets}_${kissprefix}_removemeplease
469
470
471
472 #######################################################################
473 #################### OPTIONS SUMMARY #######################
474 #######################################################################
475 if [[ "$wraith" == "false" ]]; then
476 echoscip-shell system . . echo. -e "${yellow}Running discoSnp++ "$version", in directory "$EDIR" with following parameters:"
477 echoscip-shell system . . echo. -e "\t read_sets="$read_sets
478 echoscip-shell system . . echo. -e "\t prefix="$h5prefix
479 echoscip-shell system . . echo. -e "\t c="$c
480 echoscip-shell system . . echo. -e "\t C="$C
481 echoscip-shell system . . echo. -e "\t k="$k
482 echoscip-shell system . . echo. -e "\t b="$b
483 echoscip-shell system . . echo. -e "\t d="$d
484 echoscip-shell system . . echo. -e "\t D="$D
485 echoscip-shell system . . echo. -e "\t s="$option_max_symmetrical_crossroads
486 echoscip-shell system . . echo. -e "\t P="$P
487 if [scip-shell system . . `[`. ! -z "${read_sets_kissreads}" ]; then
488 echoscip-shell system . . echo. -e "\t fof_mapping read_file_of_files="${read_sets_kissreads}
489 fi
490 echoscip-shell system . . echo. -e "\t p="$prefix
491 echoscip-shell system . . echo. -e "\t G="$genome
492 echoscip-shell system . . echo. -e "\t e="$e
493
494
495
496 echoscip-shell system . . echo. -e -n "\t starting date="
497 datescip-shell system . . date.
498 echoscip-shell system . . echo. "${reset}"
499 fi
500
501 #######################################################################
502 #################### END OPTIONS SUMMARY #######################
503 #######################################################################
504
505 #############################################################
506 #################### DUMP READ FILES #######################
507 #############################################################
508 ${read_file_names_bin} -in $read_sets > $readsFilesDump
509 if [scip-shell system . . `[`. ! -z "${read_sets_kissreads}" ]; then
510 ${read_file_names_bin} -in ${read_sets_kissreads} > $mapped_readsFilesDump
511 fi
512
513
514 ############################################################
515 #################### GRAPH CREATION #######################
516 ############################################################
517 if [scip-shell system . . `[`. $remove -eq 1 ]; then
518 rmscip-shell system . . rm. -f $h5prefix.h5
519 fi
520
521 if [scip-shell system . . `[`. ! -e $h5prefix.h5 ]; then
522 T="$(datescip-shell system . . date. +%s)"
523 echoscip-shell system . . echo. -e "${yellow}############################################################"
524 echoscip-shell system . . echo. -e "#################### GRAPH CREATION #######################"
525 echoscip-shell system . . echo. -e "############################################################${reset}"
526 i=0
527
528 # cleaning
529 rmCmd="rm -f *trashme_[0-9]*.fa.gz"
530 echoscip-shell system . . echo. "${green}"${rmCmd}"${cyan}"
531 ${rmCmd}
532 echoscip-shell system . . echo. ${reset}
533 #
534 input_h5s=""
535 IFS=',' read -r -a array <<< "${c_dbgh5}" # split the cmin entry (comma separated)
536 ab_index_size="${#array[@]}"
537 for line in `catscip-shell system . . cat. ${read_sets}_${kissprefix}_removemeplease`; do
538 min_abundance="${array[$i]}"
539 if [scip-shell system . . `[`. $i -ge ${ab_index_size} ]
540 then
541 min_abundance="${array[${ab_index_size}-1]}";
542 fi
543 i=`exprscip-shell system . . expr. $i + 1`
544 dskCmd="${dsk_build_dir}/dsk -file ${line} -abundance-min ${min_abundance} -abundance-max 2147483647 -solidity-kind sum -kmer-size $k -out ${prefix_trash}_trashme_${i}.h5"
545
546
547 toaskiiCmd="${dsk_build_dir}/dsk2ascii -file ${prefix_trash}_trashme_${i}.h5 -out /dev/null/dummy -fasta -c"
548 dump_cov_cmd="${create_coverage_h5_file_bin} -in ${prefix_trash}_trashme_${i}.h5 -coverage_file ${prefix_trash}_trashme_${i}_cov_only.h5"
549 rm_dsk_h5_file_cmd="rm -f ${prefix_trash}_trashme_${i}.h5"
550
551 echoscip-shell system . . echo. "${green}"${dskCmd} ${cyan}" && "${green} ${toaskiiCmd} " | gzip -1 > ${prefix_trash}_trashme_${i}.fa.gz && "${dump_cov_cmd}" && "${rm_dsk_h5_file_cmd}"&${cyan} "
552 if [[ "$wraith" == "false" ]]; then
553 ${dskCmd} && ${toaskiiCmd} | gzipscip-shell system . . gzip. -1> ${prefix_trash}_trashme_${i}.fa.gz && ${dump_cov_cmd} && ${rm_dsk_h5_file_cmd} &
554 fi
555 # echo ${reset}
556 if [scip-shell system . . `[`. $? -ne 0 ]
557 then
558 echoscip-shell system . . echo. "${red}there was a problem with dsk${reset}"
559 exit 1
560 fi
561 input_h5s=${input_h5s}${prefix_trash}_trashme_${i}_cov_only.h5,
562 # enables to run up to 10 jobs in parallel
563 while [scip-shell system . . `[`. 1 ]
564 do
565 a=`jobs -r|wcscip-shell system . . wc. -l` # number of previous jobs stilil running
566 if [scip-shell system . . `[`. $a -lt 10 ]
567 then
568 break
569 fi
570 sleepscip-shell system . . sleep. 10
571 done
572 done
573 # wait for the last jobs to finish
574 for job in `jobs -p`
575 do
576 wait $job || let "FAIL+=1"
577 done
578
579
580 rmCmd="rm -f ${prefix_trash}_trashme_allsolid.fa.gz"
581
582 for file in `lsscip-shell system . . ls. ${prefix_trash}_trashme_[0-9]*.fa.gz`;
583 do
584 cat_cmd="cat $file >> ${prefix_trash}_trashme_allsolid.fa.gz && rm -f $file"
585 echoscip-shell system . . echo. "${green}"${cat_cmd}"${cyan}"
586 if [[ "$wraith" == "false" ]]; then
587 catscip-shell system . . cat. $file >> ${prefix_trash}_trashme_allsolid.fa.gz && rmscip-shell system . . rm. -f $file
588 fi
589 if [scip-shell system . . `[`. $? -ne 0 ]
590 then
591 echoscip-shell system . . echo. "${red}there was a problem concatenation of single kmer fasta files${reset}"
592 exit 1
593 fi
594 done
595
596
597 # echo "${green}"${rmCmd}"${cyan}"
598 # ${rmCmd}
599 # catCmd="cat ${prefix_trash}_trashme_[0-9]*.fa.gz" #> allsolid.fa.gz
600 # echo "${green}"${catCmd} "> ${prefix_trash}_trashme_allsolid.fa.gz${cyan}"
601 # if [[ "$wraith" == "false" ]]; then
602 # ${catCmd} > ${prefix_trash}_trashme_allsolid.fa.gz
603 # fi
604 # if [ $? -ne 0 ]
605 # then
606 # echo "${red}there was a problem concatenation of single kmer fasta files${reset}"
607 # exit 1
608 # fi
609 echoscip-shell system . . echo. "${green}ls ${prefix_trash}_trashme_allsolid.fa.gz > ${prefix_trash}_trashme_allsolid.txt${cyan}"
610 lsscip-shell system . . ls. ${prefix_trash}_trashme_allsolid.fa.gz > ${prefix_trash}_trashme_allsolid.txt
611
612 graphCmd="${dbgh5_bin} -in ${prefix_trash}_trashme_allsolid.txt -out $h5prefix -kmer-size $k -abundance-min 1 -abundance-max $C -solidity-kind sum ${option_cores_gatb} -verbose $verbose -skip-bcalm -skip-bglue -no-mphf"
613 echoscip-shell system . . echo. "${green}"${graphCmd}"${cyan}"
614 if [[ "$wraith" == "false" ]]; then
615 ${graphCmd}
616 fi
617 echoscip-shell system . . echo. "${reset}"
618 if [scip-shell system . . `[`. $? -ne 0 ]
619 then
620 echoscip-shell system . . echo. "there was a problem with graph construction"
621 exit 1
622 fi
623
624
625
626 #####################################################################
627 #################### COVERAGE FILE CREATION #######################
628 #####################################################################
629 ## create the string trashme_1.h5,trashme_2.h5,...,trashme_n.h5 string
630 create_cov_file_cmd="${create_coverage_h5_file_bin} -in ${input_h5s} -coverage_file ${h5prefix}_cov.h5"
631 echoscip-shell system . . echo. "${green}"${create_cov_file_cmd}"${cyan}"
632 if [[ "$wraith" == "false" ]]; then
633 ${create_cov_file_cmd}
634 fi
635 echoscip-shell system . . echo. ${reset}
636 if [scip-shell system . . `[`. $? -ne 0 ]
637 then
638 echoscip-shell system . . echo. "${red}there was a problem with graph construction${reset}"
639 exit 1
640 fi
641
642 cleanCmd="rm -rf ${prefix_trash}_trashme_*"
643 echoscip-shell system . . echo. ${green}${cleanCmd}${reset}
644 if [[ "$wraith" == "false" ]]; then
645 ${cleanCmd}
646 fi
647
648
649 T="$(($(datescip-shell system . . date. +%s)-T))"
650 if [[ "$wraith" == "false" ]]; then
651 echoscip-shell system . . echo. "${yellow}Graph creation time in seconds: ${T}${reset}"
652 fi
653
654 else
655 if [[ "$wraith" == "false" ]]; then
656 echoscip-shell system . . echo. -e "${yellow}File $h5prefix.h5 exists. We use it as input graph${reset}"
657 fi
658 fi
659
660
661
662
663 ######################################################
664 #################### KISSNP2 #######################
665 ######################################################
666 T="$(datescip-shell system . . date. +%s)"
667 echoscip-shell system . . echo. -e "${yellow}############################################################"
668 echoscip-shell system . . echo. -e "#################### KISSNP2 MODULE #######################"
669 echoscip-shell system . . echo. -e "############################################################${reset}"
670 kissnp2Cmd="${kissnp2_bin} -in $h5prefix.h5 -out $kissprefix -b $b $l $x -P $P -D $D $extend $option_cores_gatb $output_coverage_option -coverage_file ${prefix_trash}_trashme_fake_cov.h5 -max_ambigous_indel ${max_ambigous_indel} ${option_max_symmetrical_crossroads} -verbose $verbose"
671 echoscip-shell system . . echo. ${green}${kissnp2Cmd}${cyan}
672 if [[ "$wraith" == "false" ]]; then
673 ${kissnp2Cmd}
674 fi
675 echoscip-shell system . . echo. ${reset}
676 if [scip-shell system . . `[`. $? -ne 0 ]
677 then
678 echoscip-shell system . . echo. "${red}there was a problem with kissnp2${reset}"
679 exit 1
680 fi
681 rmscip-shell system . . rm. -f ${prefix_trash}_trashme_allsolid.txt
682 T="$(($(datescip-shell system . . date. +%s)-T))"
683 if [[ "$wraith" == "false" ]]; then
684 echoscip-shell system . . echo. "${yellow}Bubble detection time in seconds: ${T}${reset}"
685 fi
686
687 if [scip-shell system . . `[`. ! -f $kissprefix.fa ]
688 then
689 if [[ "$wraith" == "false" ]]; then
690 echoscip-shell system . . echo. "${yellow}No polymorphism predicted by discoSnp++"
691 echoscip-shell system . . echo. -e -n "\t ending date="
692 datescip-shell system . . date.
693 echoscip-shell system . . echo. -e " Thanks for using discoSnp++ - http://colibread.inria.fr/discoSnp/${reset}"
694 exit
695 fi
696 fi
697
698 if [scip-shell system . . `[`. $stop_after_kissnp -eq 1 ]; then
699 if [[ "$wraith" == "false" ]]; then
700 echoscip-shell system . . echo. "${yellow}-X option detected, computation stopped after variant detection."
701 echoscip-shell system . . echo. "Results (with no read coverage) are located here: "$kissprefix.fa
702 echoscip-shell system . . echo. -e -n "\t ending date="
703 datescip-shell system . . date.
704 echoscip-shell system . . echo. -e " Thanks for using discoSnp++ - http://colibread.inria.fr/discoSnp/${reset}"
705 exit
706 fi
707 fi
708
709 #######################################################################
710 #################### KISSREADS #######################
711 #######################################################################
712
713 T="$(datescip-shell system . . date. +%s)"
714 if [[ "$wraith" == "false" ]]; then
715 echoscip-shell system . . echo. -e "${yellow}#############################################################"
716 echoscip-shell system . . echo. -e "#################### KISSREADS MODULE #######################"
717 echoscip-shell system . . echo. -e "#############################################################${reset}"
718 fi
719
720 smallk=$k
721 if (( $smallk>31 )) ; then
722 smallk=31
723 fi
724 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).
725 index_stride=$(($i+1)); size_seed=$(($smallk-$i)) # DON'T modify this.
726
727 if [scip-shell system . . `[`. ! -z "${read_sets_kissreads}" ]; then
728 read_sets=${read_sets_kissreads}
729 fi
730 kissreadsCmd="${kissreads2_bin} -predictions $kissprefix.fa -reads $read_sets -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 $y ${option_phase_variants}"
731
732 echoscip-shell system . . echo. ${green}$kissreadsCmd${cyan}
733 if [[ "$wraith" == "false" ]]; then
734 $kissreadsCmd
735 fi
736
737 if [scip-shell system . . `[`. $? -ne 0 ]
738 then
739 echoscip-shell system . . echo. "${red}there was a problem with kissreads2${reset}":
740 exit 1
741 fi
742
743 T="$(($(datescip-shell system . . date. +%s)-T))"
744 echoscip-shell system . . echo. "${yellow}Kissreads (mapping reads on bubbles) time in seconds: ${T}${reset}"
745
746
747 #######################################################################
748 #################### SORT AND FORMAT RESULTS #########################
749 #######################################################################
750
751 echoscip-shell system . . echo. -e "${yellow}###############################################################"
752 echoscip-shell system . . echo. -e "#################### SORT AND FORMAT RESULTS #################"
753 echoscip-shell system . . echo. -e "###############################################################${reset}"
754 if [[ "$wraith" == "false" ]]; then
755 sortscip-shell system . . sort. -rg ${kissprefix}_coherent | cutscip-shell system . . cut. -d " " -f 2 | trscip-shell system . . tr. ';' '\n' > ${kissprefix}_coherent.fa
756 fi
757 if [scip-shell system . . `[`. $? -ne 0 ]
758 then
759 echoscip-shell system . . echo. "${red}there was a problem with the result sorting.${reset}"
760 exit 1
761 fi
762
763 if [[ "$wraith" == "false" ]]; then
764 sortscip-shell system . . sort. -rg ${kissprefix}_uncoherent | cutscip-shell system . . cut. -d " " -f 2 | trscip-shell system . . tr. ';' '\n' > ${kissprefix}_uncoherent.fa
765 fi
766
767 if [scip-shell system . . `[`. $? -ne 0 ]
768 then
769 echoscip-shell system . . echo. "${red}there was a problem with the result sorting.${reset}"
770 exit 1
771 fi
772
773 rmscip-shell system . . rm. -f $kissprefix.fa ${kissprefix}_coherent ${kissprefix}_uncoherent
774 rmscip-shell system . . rm. -rf ${read_sets}_${kissprefix}_removemeplease
775 rmscip-shell system . . rm. -rf ${prefix_trash}_trashme
776
777 #######################################################################
778 #################### DISCOSNP FINISHED ###############################
779 #######################################################################
780
781
782
783
784
785
786 #######################################################################
787 #################### Deal with VCF ###############################
788 #######################################################################
789
790 T="$(datescip-shell system . . date. +%s)"
791 echoscip-shell system . . echo. -e "${yellow}###############################################################"
792 echoscip-shell system . . echo. -e "#################### CREATE VCF #######################"
793 echoscip-shell system . . echo. -e "###############################################################${reset}"
794
795 if [scip-shell system . . `[`. -z "$genome" ]; then # NO reference genome use, vcf creator mode 1
796 vcfCreatorCmd="$EDIR/scripts/run_VCF_creator.sh -p ${kissprefix}_coherent.fa -o ${kissprefix}_coherent.vcf"
797 echoscip-shell system . . echo. ${green}$vcfCreatorCmd${cyan}
798 if [[ "$wraith" == "false" ]]; then
799 $vcfCreatorCmd
800 fi
801 echoscip-shell system . . echo. ${reset}
802
803 if [scip-shell system . . `[`. $? -ne 0 ]
804 then
805 echoscip-shell system . . echo. "${red}there was a problem with VCF creation. See how to use the \"run_VCF_creator.sh\" alone.${reset}"
806 exit 1
807 fi
808 else # A Reference genome is provided, vcf creator mode 2
809 vcfCreatorCmd="$EDIR/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"
810 echoscip-shell system . . echo. ${green}$vcfCreatorCmd${cyan}
811 if [[ "$wraith" == "false" ]]; then
812 $vcfCreatorCmd
813 fi
814
815 if [scip-shell system . . `[`. $? -ne 0 ]
816 then
817 echoscip-shell system . . echo. "${red}there was a problem with VCF creation. See how to use the \"run_VCF_creator.sh\" alone.${reset}"
818 exit 1
819 fi
820 fi
821
822 T="$(($(datescip-shell system . . date. +%s)-T))"
823 if [[ "$wraith" == "false" ]]; then
824 echoscip-shell system . . echo. "${yellow}Vcf creation time in seconds: ${T}"
825
826 echoscip-shell system . . echo. -e "###############################################################"
827 echoscip-shell system . . echo. -e "#################### DISCOSNP++ FINISHED ######################"
828 echoscip-shell system . . echo. -e "###############################################################"
829 Ttot="$(($(datescip-shell system . . date. +%s)-Ttot))"
830 echoscip-shell system . . echo. "DiscoSnp++ total time in seconds: ${Ttot}"
831 echoscip-shell system . . echo. -e "################################################################################################################"
832 echoscip-shell system . . echo. -e " fasta of predicted variant is \""${kissprefix}_coherent.fa"\""
833
834 if [scip-shell system . . `[`. -z "$genome" ]; then
835 echoscip-shell system . . echo. -e " Ghost VCF file (1-based) is \""${kissprefix}_coherent.vcf"\""
836 else
837 echoscip-shell system . . echo. -e " VCF file (1-based) is \""${kissprefix}_coherent.vcf"\""
838 echoscip-shell system . . echo. -e " An IGV ready VCF file (sorted by position, only mapped variants, 0-based) is \""${kissprefix}_coherent_for_IGV.vcf"\""
839 fi
840 echoscip-shell system . . echo. -e " Thanks for using discoSnp++ - http://colibread.inria.fr/discoSnp/ - Forum: http://www.biostars.org/t/discoSnp/"
841 echoscip-shell system . . echo. -e "################################################################################################################${reset}"
•842 fi