| 1 | #!/bin/bash |
| 2 | |
| 3 | usage(){ |
| 4 | echo " |
| 5 | Written by Brian Bushnell |
| 6 | Last modified November 9, 2016 |
| 7 | |
| 8 | Description: Re-pairs reads that became disordered or had some mates eliminated. |
| 9 | Please read bbmap/docs/guides/RepairGuide.txt for more information. |
| 10 | |
| 11 | Usage: repair.sh in=<input file> out=<pair output> outs=<singleton output> |
| 12 | |
| 13 | Input may be fasta, fastq, or sam, compressed or uncompressed. |
| 14 | |
| 15 | Parameters: |
| 16 | in=<file> The 'in=' flag is needed if the input file is not the first |
| 17 | parameter. 'in=stdin' will pipe from standard in. |
| 18 | in2=<file> Use this if 2nd read of pairs are in a different file. |
| 19 | out=<file> The 'out=' flag is needed if the output file is not the second |
| 20 | parameter. 'out=stdout' will pipe to standard out. |
| 21 | out2=<file> Use this to write 2nd read of pairs to a different file. |
| 22 | outs=<file> (outsingle) Write singleton reads here. |
| 23 | overwrite=t (ow) Set to false to force the program to abort rather than |
| 24 | overwrite an existing file. |
| 25 | showspeed=t (ss) Set to 'f' to suppress display of processing speed. |
| 26 | ziplevel=2 (zl) Set to 1 (lowest) through 9 (max) to change compression |
| 27 | level; lower compression is faster. |
| 28 | fint=f (fixinterleaving) Fixes corrupted interleaved files using read |
| 29 | names. Only use on files with broken interleaving - correctly |
| 30 | interleaved files from which some reads were removed. |
| 31 | repair=t (rp) Fixes arbitrarily corrupted paired reads by using read |
| 32 | names. Uses much more memory than 'fint' mode. |
| 33 | ain=f (allowidenticalnames) When detecting pair names, allows |
| 34 | identical names, instead of requiring /1 and /2 or 1: and 2: |
| 35 | |
| 36 | Java Parameters: |
| 37 | -Xmx This will set Java's memory usage, overriding autodetection. |
| 38 | -Xmx20g will specify 20 gigs of RAM, and -Xmx200m will |
| 39 | specify 200 megs. The max is typically 85% of physical memory. |
| 40 | -eoom This flag will cause the process to exit if an out-of-memory |
| 41 | exception occurs. Requires Java 8u92+. |
| 42 | -da Disable assertions. |
| 43 | |
| 44 | Please contact Brian Bushnell at [email protected] if you encounter any problems. |
| 45 | " |
| 46 | } |
| 47 | |
| 48 | #This block allows symlinked shellscripts to correctly set classpath. |
| 49 | pushd . > /dev/null |
| 50 | DIR="${BASH_SOURCE[0]}" |
| 51 | while [ -h "$DIR" ]; do |
| 52 | cd "$(dirname "$DIR")" |
| 53 | DIR="$(readlink "$(basename "$DIR")")" |
| 54 | done |
| 55 | cd "$(dirname "$DIR")" |
| 56 | DIR="$(pwd)/" |
| 57 | popd > /dev/null |
| 58 | |
| 59 | #DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/" |
| 60 | CP="$DIR""current/" |
| 61 | |
| 62 | z="-Xmx4g" |
| 63 | z2="-Xms4g" |
| 64 | set=0 |
| 65 | |
| 66 | if [ -z "$1" ] || [[ $1 == -h ]] || [[ $1 == --help ]]; then |
| 67 | usage |
| 68 | exit |
| 69 | fi |
| 70 | |
| 71 | calcXmx () { |
| 72 | source "$DIR""/calcmem.sh" |
| 73 | setEnvironment |
| 74 | parseXmx "$@" |
| 75 | if [[ $set == 1 ]]; then |
| 76 | return |
| 77 | fi |
| 78 | freeRam 4000m 84 |
| 79 | z="-Xmx${RAM}m" |
| 80 | z2="-Xms${RAM}m" |
| 81 | } |
| 82 | calcXmx "$@" |
| 83 | |
| 84 | repair() { |
| 85 | local CMD="java $EA $EOOM $z -cp $CP jgi.SplitPairsAndSingles rp $@" |
| 86 | echo $CMD >&2 |
| 87 | eval $CMD |
| 88 | } |
| 89 | |
| 90 | repair "$@" |