| 1 | #!/bin/bash |
| 2 | |
| 3 | usage(){ |
| 4 | echo " |
| 5 | Written by Brian Bushnell |
| 6 | Last modified December 22, 2021 |
| 7 | This script requires at least 52GB RAM. |
| 8 | It is designed for NERSC and uses hard-coded paths. |
| 9 | |
| 10 | Description: Removes all reads that map to the cat, dog, mouse, or human genome with at least 95% identity after quality trimming. |
| 11 | Removes approximately 98.6% of human 2x150bp reads, with zero false-positives to non-animals. |
| 12 | NOTE! This program uses hard-coded paths and will only run on Nersc systems. |
| 13 | |
| 14 | Usage: removecatdogmousehuman.sh in=<input file> outu=<clean output file> |
| 15 | |
| 16 | Input may be fasta or fastq, compressed or uncompressed. |
| 17 | |
| 18 | Parameters: |
| 19 | threads=auto (t) Set number of threads to use; default is number of logical processors. |
| 20 | overwrite=t (ow) Set to false to force the program to abort rather than overwrite an existing file. |
| 21 | interleaved=auto (int) If true, forces fastq input to be paired and interleaved. |
| 22 | trim=t Trim read ends to remove bases with quality below minq. |
| 23 | Values: t (trim both ends), f (neither end), r (right end only), l (left end only). |
| 24 | untrim=t Undo the trimming after mapping. |
| 25 | minq=4 Trim quality threshold. |
| 26 | ziplevel=2 (zl) Set to 1 (lowest) through 9 (max) to change compression level; lower compression is faster. |
| 27 | outm=<file> File to output the reads that mapped to human. |
| 28 | |
| 29 | ***** All BBMap parameters can be used; run bbmap.sh for more details. ***** |
| 30 | |
| 31 | Please contact Brian Bushnell at [email protected] if you encounter any problems. |
| 32 | " |
| 33 | } |
| 34 | |
| 35 | #This block allows symlinked shellscripts to correctly set classpath. |
| 36 | pushd . > /dev/null |
| 37 | DIR="${BASH_SOURCE[0]}" |
| 38 | while [ -h "$DIR" ]; do |
| 39 | cd "$(dirname "$DIR")" |
| 40 | DIR="$(readlink "$(basename "$DIR")")" |
| 41 | done |
| 42 | cd "$(dirname "$DIR")" |
| 43 | DIR="$(pwd)/" |
| 44 | popd > /dev/null |
| 45 | |
| 46 | #DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/" |
| 47 | CP="$DIR""current/" |
| 48 | JNI="-Djava.library.path=""$DIR""jni/" |
| 49 | JNI="" |
| 50 | |
| 51 | z="-Xmx50g" |
| 52 | z2="-Xms50g" |
| 53 | set=0 |
| 54 | |
| 55 | if [ -z "$1" ] || [[ $1 == -h ]] || [[ $1 == --help ]]; then |
| 56 | usage |
| 57 | exit |
| 58 | fi |
| 59 | |
| 60 | calcXmx () { |
| 61 | source "$DIR""/calcmem.sh" |
| 62 | setEnvironment |
| 63 | parseXmx "$@" |
| 64 | if [[ $set == 1 ]]; then |
| 65 | return |
| 66 | fi |
| 67 | } |
| 68 | calcXmx "$@" |
| 69 | |
| 70 | function removecatdogmousehuman() { |
| 71 | local CMD="java $EA $EOOM $z $z2 $JNI -cp $CP align2.BBMap minratio=0.9 maxindel=3 bwr=0.16 bw=12 quickmatch fast minhits=2 path=/global/cfs/cdirs/bbtools/mousecatdoghuman/ pigz unpigz zl=6 qtrim=r trimq=10 untrim idtag usemodulo printunmappedcount ztd=2 kfilter=25 maxsites=1 k=14 bloomfilter $@" |
| 72 | echo $CMD >&2 |
| 73 | eval $CMD |
| 74 | } |
| 75 | |
| 76 | removecatdogmousehuman "$@" |