| 1 | #!/bin/bash |
| 2 | |
| 3 | usage(){ |
| 4 | echo " |
| 5 | Last modified February 13, 2020 |
| 6 | |
| 7 | Description: Wrapper for BBMap to allow multiple input and output files for the same reference. |
| 8 | |
| 9 | To index: bbwrap.sh ref=<reference fasta> |
| 10 | To map: bbwrap.sh in=<file,file,...> out=<file,file,...> |
| 11 | To map without an index: bbwrap.sh ref=<reference fasta> in=<file,file,...> out=<file,file,...> nodisk |
| 12 | To map pairs and singletons and output them into the same file: |
| 13 | bbwrap.sh in1=read1.fq,singleton.fq in2=read2.fq,null out=mapped.sam append |
| 14 | |
| 15 | BBWrap will not work with stdin and stdout, or histogram output. |
| 16 | |
| 17 | Other Parameters: |
| 18 | |
| 19 | in=<file,file> Input sequences to map. |
| 20 | inlist=<fofn> Alternately, input and output can be a file of filenames, |
| 21 | one line per file, using the flag inlist, outlist, outmlist, |
| 22 | in2list, etc. |
| 23 | mapper=bbmap Select mapper. May be BBMap, BBMapPacBio, |
| 24 | or BBMapPacBioSkimmer. |
| 25 | append=f Append to files rather than overwriting them. |
| 26 | If append is enabled, and there is exactly one output file, |
| 27 | all output will be written to that file. |
| 28 | |
| 29 | ***** All BBMap parameters can be used; see bbmap.sh for more details. ***** |
| 30 | " |
| 31 | } |
| 32 | |
| 33 | #This block allows symlinked shellscripts to correctly set classpath. |
| 34 | pushd . > /dev/null |
| 35 | DIR="${BASH_SOURCE[0]}" |
| 36 | while [ -h "$DIR" ]; do |
| 37 | cd "$(dirname "$DIR")" |
| 38 | DIR="$(readlink "$(basename "$DIR")")" |
| 39 | done |
| 40 | cd "$(dirname "$DIR")" |
| 41 | DIR="$(pwd)/" |
| 42 | popd > /dev/null |
| 43 | |
| 44 | #DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/" |
| 45 | CP="$DIR""current/" |
| 46 | JNI="-Djava.library.path=""$DIR""jni/" |
| 47 | JNI="" |
| 48 | |
| 49 | z="-Xmx1g" |
| 50 | z2="-Xms1g" |
| 51 | set=0 |
| 52 | |
| 53 | if [ -z "$1" ] || [[ $1 == -h ]] || [[ $1 == --help ]]; then |
| 54 | usage |
| 55 | exit |
| 56 | fi |
| 57 | |
| 58 | calcXmx () { |
| 59 | source "$DIR""/calcmem.sh" |
| 60 | setEnvironment |
| 61 | parseXmx "$@" |
| 62 | if [[ $set == 1 ]]; then |
| 63 | return |
| 64 | fi |
| 65 | freeRam 3200m 84 |
| 66 | z="-Xmx${RAM}m" |
| 67 | z2="-Xms${RAM}m" |
| 68 | } |
| 69 | calcXmx "$@" |
| 70 | |
| 71 | bbwrap() { |
| 72 | local CMD="java $EA $EOOM $z $z2 $JNI -cp $CP align2.BBWrap build=1 overwrite=true fastareadlen=500 $@" |
| 73 | echo $CMD >&2 |
| 74 | eval $CMD |
| 75 | } |
| 76 | |
| 77 | bbwrap "$@" |