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