| 1 | #!/bin/bash |
| 2 | |
| 3 | usage(){ |
| 4 | echo " |
| 5 | Written by Brian Bushnell |
| 6 | Last modified June 22, 2016 |
| 7 | |
| 8 | Description: Multiplexes reads from multiple files after renaming them based on their initial file. |
| 9 | Opposite of demuxbyname. |
| 10 | |
| 11 | Usage: muxbyname.sh in=<file,file,file...> out=<output file> |
| 12 | Input files may also be given without an in= prefix, so that you can use wildcards: |
| 13 | muxbyname.sh *.fastq out=muxed.fastq |
| 14 | |
| 15 | |
| 16 | Standard parameters: |
| 17 | in=<file,file> A list of input files. |
| 18 | in2=<file,file> Read 2 input if reads are in paired files. |
| 19 | out=<file> Primary output, or read 1 output. |
| 20 | out2=<file> Read 2 output if reads are in paired files. |
| 21 | overwrite=f (ow) Set to false to force the program to abort rather than |
| 22 | overwrite an existing file. |
| 23 | showspeed=t (ss) Set to 'f' to suppress display of processing speed. |
| 24 | ziplevel=2 (zl) Set to 1 (lowest) through 9 (max) to change compression |
| 25 | level; lower compression is faster. |
| 26 | |
| 27 | Processing parameters: |
| 28 | None yet! |
| 29 | |
| 30 | Java Parameters: |
| 31 | -Xmx This will set Java's memory usage, overriding autodetection. |
| 32 | -Xmx20g will specify 20 gigs of RAM, and -Xmx200m will |
| 33 | specify 200 megs. The max is typically 85% of physical memory. |
| 34 | -eoom This flag will cause the process to exit if an out-of-memory |
| 35 | exception occurs. Requires Java 8u92+. |
| 36 | -da Disable assertions. |
| 37 | |
| 38 | Please contact Brian Bushnell at [email protected] if you encounter any problems. |
| 39 | " |
| 40 | } |
| 41 | |
| 42 | #This block allows symlinked shellscripts to correctly set classpath. |
| 43 | pushd . > /dev/null |
| 44 | DIR="${BASH_SOURCE[0]}" |
| 45 | while [ -h "$DIR" ]; do |
| 46 | cd "$(dirname "$DIR")" |
| 47 | DIR="$(readlink "$(basename "$DIR")")" |
| 48 | done |
| 49 | cd "$(dirname "$DIR")" |
| 50 | DIR="$(pwd)/" |
| 51 | popd > /dev/null |
| 52 | |
| 53 | #DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/" |
| 54 | CP="$DIR""current/" |
| 55 | |
| 56 | z="-Xmx400m" |
| 57 | z2="-Xms400m" |
| 58 | set=0 |
| 59 | |
| 60 | if [ -z "$1" ] || [[ $1 == -h ]] || [[ $1 == --help ]]; then |
| 61 | usage |
| 62 | exit |
| 63 | fi |
| 64 | |
| 65 | calcXmx () { |
| 66 | source "$DIR""/calcmem.sh" |
| 67 | setEnvironment |
| 68 | parseXmx "$@" |
| 69 | } |
| 70 | calcXmx "$@" |
| 71 | |
| 72 | muxbyname() { |
| 73 | local CMD="java $EA $EOOM $z -cp $CP driver.RenameAndMux $@" |
| 74 | echo $CMD >&2 |
| 75 | eval $CMD |
| 76 | } |
| 77 | |
| 78 | muxbyname "$@" |