| 1 | #!/bin/bash |
| 2 | |
| 3 | usage(){ |
| 4 | echo " |
| 5 | Written by Brian Bushnell |
| 6 | Last modified March 6, 2015 |
| 7 | |
| 8 | Description: Splits Nextera LMP libraries into subsets based on linker orientation: |
| 9 | LMP, fragment, unknown, and singleton. |
| 10 | Please read bbmap/docs/guides/SplitNexteraGuide.txt for more information. |
| 11 | |
| 12 | Usage: splitnextera.sh in=<file> out=<file> outf=<file> outu=<file> outs=<file> |
| 13 | |
| 14 | For pairs in two files, use in1, in2, out1, out2, etc. |
| 15 | |
| 16 | *** Note *** |
| 17 | For maximal speed, before running splitnextera, the linkers can be replaced with a constant first. |
| 18 | |
| 19 | In other words, you can either do this (which is slightly faster): |
| 20 | bbduk.sh in=reads.fq out=replaced.fq ktmask=J k=19 hdist=1 mink=11 hdist2=0 literal=CTGTCTCTTATACACATCTAGATGTGTATAAGAGACAG |
| 21 | splitnextera.sh in=replaced.fq out=longmate.fq outf=frag.fq outu=unknown.fq outs=singleton.fq |
| 22 | |
| 23 | Or this: |
| 24 | splitnextera.sh in=reads.fq out=longmate.fq outf=frag.fq outu=unknown.fq outs=singleton.fq mask=t |
| 25 | |
| 26 | |
| 27 | I/O parameters: |
| 28 | in=<file> Input reads. Set to 'stdin.fq' to read from stdin. |
| 29 | out=<file> Output for pairs with LMP orientation. |
| 30 | outf=<file> Output for pairs with fragment orientation. |
| 31 | outu=<file> Pairs with unknown orientation. |
| 32 | outs=<file> Singleton output. |
| 33 | ow=f (overwrite) Overwrites files that already exist. |
| 34 | app=f (append) Append to files that already exist. |
| 35 | zl=4 (ziplevel) Set compression level, 1 (low) to 9 (max). |
| 36 | int=f (interleaved) Determines whether INPUT file is considered interleaved. |
| 37 | qin=auto ASCII offset for input quality. May be 33 (Sanger), 64 (Illumina), or auto. |
| 38 | qout=auto ASCII offset for output quality. May be 33 (Sanger), 64 (Illumina), or auto (same as input). |
| 39 | |
| 40 | Processing Parameters: |
| 41 | mask=f Set to true if you did not already convert junctions to some symbol, and it will be done automatically. |
| 42 | junction=J Look for this symbol to designate the junction bases. |
| 43 | innerlmp=f Generate long mate pairs from the inner pair also, when the junction is found in both reads. |
| 44 | rename=t Rename read 2 of output when using single-ended input. |
| 45 | minlength=40 (ml) Do not output reads shorter than this. |
| 46 | merge=f Attempt to merge overlapping reads before looking for junctions. |
| 47 | testmerge=0.0 If nonzero, only merge reads if at least the fraction of input reads are mergable. |
| 48 | |
| 49 | Sampling parameters: |
| 50 | |
| 51 | reads=-1 Set to a positive number to only process this many INPUT reads (or pairs), then quit. |
| 52 | samplerate=1 Randomly output only this fraction of reads; 1 means sampling is disabled. |
| 53 | sampleseed=-1 Set to a positive number to use that prng seed for sampling (allowing deterministic sampling). |
| 54 | |
| 55 | Java Parameters: |
| 56 | -Xmx This will set Java's memory usage, overriding autodetection. |
| 57 | -Xmx20g will specify 20 gigs of RAM, and -Xmx200m will specify 200 megs. |
| 58 | The max is typically 85% of physical memory. |
| 59 | -eoom This flag will cause the process to exit if an out-of-memory |
| 60 | exception occurs. Requires Java 8u92+. |
| 61 | -da Disable assertions. |
| 62 | |
| 63 | Please contact Brian Bushnell at [email protected] if you encounter any problems. |
| 64 | " |
| 65 | } |
| 66 | |
| 67 | #This block allows symlinked shellscripts to correctly set classpath. |
| 68 | pushd . > /dev/null |
| 69 | DIR="${BASH_SOURCE[0]}" |
| 70 | while [ -h "$DIR" ]; do |
| 71 | cd "$(dirname "$DIR")" |
| 72 | DIR="$(readlink "$(basename "$DIR")")" |
| 73 | done |
| 74 | cd "$(dirname "$DIR")" |
| 75 | DIR="$(pwd)/" |
| 76 | popd > /dev/null |
| 77 | |
| 78 | #DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/" |
| 79 | CP="$DIR""current/" |
| 80 | |
| 81 | z="-Xmx200m" |
| 82 | set=0 |
| 83 | |
| 84 | if [ -z "$1" ] || [[ $1 == -h ]] || [[ $1 == --help ]]; then |
| 85 | usage |
| 86 | exit |
| 87 | fi |
| 88 | |
| 89 | calcXmx () { |
| 90 | source "$DIR""/calcmem.sh" |
| 91 | setEnvironment |
| 92 | parseXmx "$@" |
| 93 | } |
| 94 | calcXmx "$@" |
| 95 | |
| 96 | function splitnextera() { |
| 97 | local CMD="java $EA $EOOM $z -cp $CP jgi.SplitNexteraLMP $@" |
| 98 | echo $CMD >&2 |
| 99 | eval $CMD |
| 100 | } |
| 101 | |
| 102 | splitnextera "$@" |