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