| 1 | #!/bin/bash |
| 2 | |
| 3 | usage(){ |
| 4 | echo " |
| 5 | Written by Brian Bushnell |
| 6 | Last modified August 29, 2017 |
| 7 | |
| 8 | Description: Generates synthetic contaminated partial genomes from clean genomes. |
| 9 | Output is formatted as (prefix)_bases1_fname1_bases2_fname2_counter_(suffix). |
| 10 | |
| 11 | Usage: makecontaminatedgenomes.sh in=<file> out=<pattern> |
| 12 | |
| 13 | I/O parameters: |
| 14 | in=<file> A file containing one input file path per line. |
| 15 | out=<pattern> A file name containing a # symbol (or other regex). |
| 16 | The regex will be replaced by source filenames. |
| 17 | |
| 18 | Processing Parameters: |
| 19 | count=1 Number of output files to make. |
| 20 | seed=-1 RNG seed; negative for a random seed. |
| 21 | exp1=1 Exponent for genome 1 size fraction. |
| 22 | exp2=1 Exponent for genome 2 size fraction. |
| 23 | subrate=0 Rate to add substitutions to new genomes (0-1). |
| 24 | indelrate=0 Rate to add substitutions to new genomes (0-1). |
| 25 | regex=# Use this substitution regex for replacement. |
| 26 | delimiter=_ Use this delimiter in the new file names. |
| 27 | |
| 28 | Java Parameters: |
| 29 | -Xmx This will set Java's memory usage, overriding autodetection. |
| 30 | -Xmx20g will specify 20 gigs of RAM, and -Xmx200m will specify 200 megs. |
| 31 | The max is typically 85% of physical memory. |
| 32 | -eoom This flag will cause the process to exit if an out-of-memory |
| 33 | exception occurs. Requires Java 8u92+. |
| 34 | -da Disable assertions. |
| 35 | |
| 36 | Please contact Brian Bushnell at [email protected] if you encounter any problems. |
| 37 | " |
| 38 | } |
| 39 | |
| 40 | #This block allows symlinked shellscripts to correctly set classpath. |
| 41 | pushd . > /dev/null |
| 42 | DIR="${BASH_SOURCE[0]}" |
| 43 | while [ -h "$DIR" ]; do |
| 44 | cd "$(dirname "$DIR")" |
| 45 | DIR="$(readlink "$(basename "$DIR")")" |
| 46 | done |
| 47 | cd "$(dirname "$DIR")" |
| 48 | DIR="$(pwd)/" |
| 49 | popd > /dev/null |
| 50 | |
| 51 | #DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/" |
| 52 | CP="$DIR""current/" |
| 53 | |
| 54 | z="-Xmx4g" |
| 55 | z2="-Xms4g" |
| 56 | set=0 |
| 57 | |
| 58 | if [ -z "$1" ] || [[ $1 == -h ]] || [[ $1 == --help ]]; then |
| 59 | usage |
| 60 | exit |
| 61 | fi |
| 62 | |
| 63 | calcXmx () { |
| 64 | source "$DIR""/calcmem.sh" |
| 65 | setEnvironment |
| 66 | parseXmx "$@" |
| 67 | if [[ $set == 1 ]]; then |
| 68 | return |
| 69 | fi |
| 70 | freeRam 4000m 42 |
| 71 | z="-Xmx${RAM}m" |
| 72 | } |
| 73 | calcXmx "$@" |
| 74 | |
| 75 | makecontaminatedgenomes() { |
| 76 | local CMD="java $EA $EOOM $z -cp $CP jgi.MakeContaminatedGenomes $@" |
| 77 | echo $CMD >&2 |
| 78 | eval $CMD |
| 79 | } |
| 80 | |
| 81 | makecontaminatedgenomes "$@" |