| 1 | #!/bin/bash |
| 2 | |
| 3 | usage(){ |
| 4 | echo " |
| 5 | Written by Brian Bushnell |
| 6 | Last modified February 17, 2015 |
| 7 | |
| 8 | Description: Concatenates barcodes and quality onto read names. |
| 9 | |
| 10 | Usage: mergebarcodes.sh in=<file> out=<file> barcode=<file> |
| 11 | |
| 12 | Input may be stdin or a fasta or fastq file, raw or gzipped. |
| 13 | If you pipe via stdin/stdout, please include the file type; e.g. for gzipped fasta input, set in=stdin.fa.gz |
| 14 | |
| 15 | Optional parameters (and their defaults) |
| 16 | |
| 17 | Input parameters: |
| 18 | in=<file> Input reads. 'in=stdin.fq' will pipe from standard in. |
| 19 | bar=<file> File containing barcodes. |
| 20 | int=auto (interleaved) If true, forces fastq input to be paired and interleaved. |
| 21 | qin=auto ASCII offset for input quality. May be 33 (Sanger), 64 (Illumina), or auto. |
| 22 | |
| 23 | Output parameters: |
| 24 | out=<file> Write muxed sequences here. 'out=stdout.fa' will pipe to standard out. |
| 25 | overwrite=t (ow) Set to false to force the program to abort rather than overwrite an existing file. |
| 26 | ziplevel=2 (zl) Set to 1 (lowest) through 9 (max) to change compression level; lower compression is faster. |
| 27 | qout=auto ASCII offset for output quality. May be 33 (Sanger), 64 (Illumina), or auto (same as input). |
| 28 | |
| 29 | Other parameters: |
| 30 | pigz=t Use pigz to compress. If argument is a number, that will set the number of pigz threads. |
| 31 | unpigz=t Use pigz to decompress. |
| 32 | |
| 33 | Java Parameters: |
| 34 | -Xmx This will set Java's memory usage, overriding autodetection. |
| 35 | -Xmx20g will specify 20 gigs of RAM, and -Xmx200m will specify 200 megs. |
| 36 | The max is typically 85% of physical memory. |
| 37 | -eoom This flag will cause the process to exit if an out-of-memory |
| 38 | exception occurs. Requires Java 8u92+. |
| 39 | -da Disable assertions. |
| 40 | |
| 41 | Please contact Brian Bushnell at [email protected] if you encounter any problems. |
| 42 | " |
| 43 | } |
| 44 | |
| 45 | #This block allows symlinked shellscripts to correctly set classpath. |
| 46 | pushd . > /dev/null |
| 47 | DIR="${BASH_SOURCE[0]}" |
| 48 | while [ -h "$DIR" ]; do |
| 49 | cd "$(dirname "$DIR")" |
| 50 | DIR="$(readlink "$(basename "$DIR")")" |
| 51 | done |
| 52 | cd "$(dirname "$DIR")" |
| 53 | DIR="$(pwd)/" |
| 54 | popd > /dev/null |
| 55 | |
| 56 | #DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/" |
| 57 | CP="$DIR""current/" |
| 58 | |
| 59 | z="-Xmx1g" |
| 60 | z2="-Xms1g" |
| 61 | set=0 |
| 62 | |
| 63 | if [ -z "$1" ] || [[ $1 == -h ]] || [[ $1 == --help ]]; then |
| 64 | usage |
| 65 | exit |
| 66 | fi |
| 67 | |
| 68 | calcXmx () { |
| 69 | source "$DIR""/calcmem.sh" |
| 70 | setEnvironment |
| 71 | parseXmx "$@" |
| 72 | if [[ $set == 1 ]]; then |
| 73 | return |
| 74 | fi |
| 75 | freeRam 3200m 84 |
| 76 | z="-Xmx${RAM}m" |
| 77 | z2="-Xms${RAM}m" |
| 78 | } |
| 79 | calcXmx "$@" |
| 80 | |
| 81 | mergebarcodes() { |
| 82 | local CMD="java $EA $EOOM $z -cp $CP jgi.MergeBarcodes $@" |
| 83 | echo $CMD >&2 |
| 84 | eval $CMD |
| 85 | } |
| 86 | |
| 87 | mergebarcodes "$@" |