| 1 | #!/bin/bash |
| 2 | |
| 3 | usage(){ |
| 4 | echo " |
| 5 | Written by Brian Bushnell |
| 6 | Last modified October 22, 2015 |
| 7 | |
| 8 | Description: Generates synthetic reads following an MDA-amplified single cell's coverage distribution. |
| 9 | |
| 10 | Usage: synthmda.sh in=<reference> out=<reads out file> |
| 11 | |
| 12 | Input may be fasta or fastq, compressed or uncompressed. |
| 13 | |
| 14 | Parameters: |
| 15 | reads=12000000 Generate this many reads. |
| 16 | paired=t Generate paired reads. |
| 17 | length=150 Reads should be this long. |
| 18 | minlen=4000 Min length of MDA contig. |
| 19 | maxlen=150000 Max length of MDA contig. |
| 20 | cycles=9 Number of MDA cycles; higher is more spiky. |
| 21 | initialratio=1.3 Fraction of genome initially replicated; |
| 22 | lower is more spiky. |
| 23 | ratio=1.7 Fraction of genome replicated per cycle. |
| 24 | refout=null Write MDA'd genome to this file. |
| 25 | perfect=0 This fraction of reads will be error-free. |
| 26 | amp=200 'amp' flag sent to RandomReads (higher is more spiky). |
| 27 | build=7 Index MDA'd genome in this location. |
| 28 | prefix=null Generated reads will start with this prefix. |
| 29 | overwrite=t (ow) Set to false to force the program to abort rather |
| 30 | than overwrite an existing file. |
| 31 | |
| 32 | Java Parameters: |
| 33 | -Xmx This will set Java's memory usage, overriding autodetection. |
| 34 | -Xmx20g will specify 20 gigs of RAM, and -Xmx200m will specify 200 megs. |
| 35 | The max is typically 85% of physical memory. |
| 36 | -eoom This flag will cause the process to exit if an |
| 37 | out-of-memory exception occurs. Requires Java 8u92+. |
| 38 | -da Disable assertions. |
| 39 | |
| 40 | Please contact Brian Bushnell at [email protected] if you encounter any problems. |
| 41 | " |
| 42 | } |
| 43 | |
| 44 | #This block allows symlinked shellscripts to correctly set classpath. |
| 45 | pushd . > /dev/null |
| 46 | DIR="${BASH_SOURCE[0]}" |
| 47 | while [ -h "$DIR" ]; do |
| 48 | cd "$(dirname "$DIR")" |
| 49 | DIR="$(readlink "$(basename "$DIR")")" |
| 50 | done |
| 51 | cd "$(dirname "$DIR")" |
| 52 | DIR="$(pwd)/" |
| 53 | popd > /dev/null |
| 54 | |
| 55 | #DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/" |
| 56 | CP="$DIR""current/" |
| 57 | |
| 58 | z="-Xmx4g" |
| 59 | z2="-Xms4g" |
| 60 | set=0 |
| 61 | |
| 62 | if [ -z "$1" ] || [[ $1 == -h ]] || [[ $1 == --help ]]; then |
| 63 | usage |
| 64 | exit |
| 65 | fi |
| 66 | |
| 67 | calcXmx () { |
| 68 | source "$DIR""/calcmem.sh" |
| 69 | setEnvironment |
| 70 | parseXmx "$@" |
| 71 | if [[ $set == 1 ]]; then |
| 72 | return |
| 73 | fi |
| 74 | freeRam 4000m 80 |
| 75 | z="-Xmx${RAM}m" |
| 76 | z2="-Xms${RAM}m" |
| 77 | } |
| 78 | calcXmx "$@" |
| 79 | |
| 80 | synthmda() { |
| 81 | local CMD="java $EA $EOOM $z -cp $CP jgi.SynthMDA $@" |
| 82 | echo $CMD >&2 |
| 83 | eval $CMD |
| 84 | } |
| 85 | |
| 86 | synthmda "$@" |