1#!/usr/local/bin/bash 2 3usage(){ 4echo " 5Written by Brian Bushnell 6Last modified February 17, 2015 7 8Description: Generates synthetic cross-contaminated files from clean files. 9Intended for use with synthetic reads generated by SynthMDA or RandomReads. 10 11Usage: crosscontaminate.sh in=<file,file,...> out=<file,file,...> 12 13Input parameters: 14in=<file,file,...> Clean input reads. 15innamefile=<file> A file containing the names of input files, 16 one name per line. 17interleaved=auto (int) t/f overrides interleaved autodetection. 18qin=auto Input quality offset: 33 (Sanger), 64, or auto. 19reads=-1 If positive, quit after processing X reads or pairs. 20 21Processing Parameters: 22minsinks=1 Min contamination destinations from one source. 23maxsinks=8 Max contamination destinations from one source. 24minprob=0.000005 Min allowed contamination rate (geometric distribution). 25maxprob=0.025 Max allowed contamination rate. 26 27Output parameters: 28out=<file,file,...> Contaminated output reads. 29outnamefile=<file> A file containing the names of output files, 30 one name per line. 31overwrite=t (ow) Grant permission to overwrite files. 32#showspeed=t (ss) 'f' suppresses display of processing speed. 33ziplevel=2 (zl) Compression level; 1 (min) through 9 (max). 34threads=auto (t) Set number of threads to use; default is number of 35 logical processors. 36qout=auto Output quality offset: 33 (Sanger), 64, or auto. 37shuffle=f Shuffle contents of output files. 38shufflethreads=3 Use this many threads for shuffling (uses more memory). 39 40Java Parameters: 41-Xmx This will set Java's memory usage, overriding autodetection. 42 -Xmx20g will specify 20 gigs of RAM, and -Xmx200m will specify 200 megs. 43 The max is typically 85% of physical memory. 44-eoom This flag will cause the process to exit if an 45 out-of-memory exception occurs. Requires Java 8u92+. 46-da Disable assertions. 47 48Please contact Brian Bushnell at bbushnell@lbl.gov if you encounter any problems. 49" 50} 51 52#This block allows symlinked shellscripts to correctly set classpath. 53pushd . > /dev/null 54DIR="${BASH_SOURCE[0]}" 55while [ -h "$DIR" ]; do 56 cd "$(dirname "$DIR")" 57 DIR="$(readlink "$(basename "$DIR")")" 58done 59cd "$(dirname "$DIR")" 60DIR="$(pwd)/" 61popd > /dev/null 62 63#DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/" 64CP="$DIR""current/" 65 66z="-Xmx4g" 67z2="-Xms4g" 68set=0 69 70if [ -z "$1" ] || [[ $1 == -h ]] || [[ $1 == --help ]]; then 71 usage 72 exit 73fi 74 75calcXmx () { 76 source "$DIR""/calcmem.sh" 77 setEnvironment 78 parseXmx "$@" 79 if [[ $set == 1 ]]; then 80 return 81 fi 82 freeRam 4000m 42 83 z="-Xmx${RAM}m" 84} 85calcXmx "$@" 86 87crosscontaminate() { 88 local CMD="java $EA $EOOM $z -cp $CP jgi.CrossContaminate $@" 89 echo $CMD >&2 90 eval $CMD 91} 92 93crosscontaminate "$@" 94