jpayne@69: #!/bin/bash jpayne@69: jpayne@69: usage(){ jpayne@69: echo " jpayne@69: Written by Brian Bushnell jpayne@69: Last modified March 6, 2015 jpayne@69: jpayne@69: Description: Splits Nextera LMP libraries into subsets based on linker orientation: jpayne@69: LMP, fragment, unknown, and singleton. jpayne@69: Please read bbmap/docs/guides/SplitNexteraGuide.txt for more information. jpayne@69: jpayne@69: Usage: splitnextera.sh in= out= outf= outu= outs= jpayne@69: jpayne@69: For pairs in two files, use in1, in2, out1, out2, etc. jpayne@69: jpayne@69: *** Note *** jpayne@69: For maximal speed, before running splitnextera, the linkers can be replaced with a constant first. jpayne@69: jpayne@69: In other words, you can either do this (which is slightly faster): jpayne@69: bbduk.sh in=reads.fq out=replaced.fq ktmask=J k=19 hdist=1 mink=11 hdist2=0 literal=CTGTCTCTTATACACATCTAGATGTGTATAAGAGACAG jpayne@69: splitnextera.sh in=replaced.fq out=longmate.fq outf=frag.fq outu=unknown.fq outs=singleton.fq jpayne@69: jpayne@69: Or this: jpayne@69: splitnextera.sh in=reads.fq out=longmate.fq outf=frag.fq outu=unknown.fq outs=singleton.fq mask=t jpayne@69: jpayne@69: jpayne@69: I/O parameters: jpayne@69: in= Input reads. Set to 'stdin.fq' to read from stdin. jpayne@69: out= Output for pairs with LMP orientation. jpayne@69: outf= Output for pairs with fragment orientation. jpayne@69: outu= Pairs with unknown orientation. jpayne@69: outs= Singleton output. jpayne@69: ow=f (overwrite) Overwrites files that already exist. jpayne@69: app=f (append) Append to files that already exist. jpayne@69: zl=4 (ziplevel) Set compression level, 1 (low) to 9 (max). jpayne@69: int=f (interleaved) Determines whether INPUT file is considered interleaved. jpayne@69: qin=auto ASCII offset for input quality. May be 33 (Sanger), 64 (Illumina), or auto. jpayne@69: qout=auto ASCII offset for output quality. May be 33 (Sanger), 64 (Illumina), or auto (same as input). jpayne@69: jpayne@69: Processing Parameters: jpayne@69: mask=f Set to true if you did not already convert junctions to some symbol, and it will be done automatically. jpayne@69: junction=J Look for this symbol to designate the junction bases. jpayne@69: innerlmp=f Generate long mate pairs from the inner pair also, when the junction is found in both reads. jpayne@69: rename=t Rename read 2 of output when using single-ended input. jpayne@69: minlength=40 (ml) Do not output reads shorter than this. jpayne@69: merge=f Attempt to merge overlapping reads before looking for junctions. jpayne@69: testmerge=0.0 If nonzero, only merge reads if at least the fraction of input reads are mergable. jpayne@69: jpayne@69: Sampling parameters: jpayne@69: jpayne@69: reads=-1 Set to a positive number to only process this many INPUT reads (or pairs), then quit. jpayne@69: samplerate=1 Randomly output only this fraction of reads; 1 means sampling is disabled. jpayne@69: sampleseed=-1 Set to a positive number to use that prng seed for sampling (allowing deterministic sampling). jpayne@69: jpayne@69: Java Parameters: jpayne@69: -Xmx This will set Java's memory usage, overriding autodetection. jpayne@69: -Xmx20g will specify 20 gigs of RAM, and -Xmx200m will specify 200 megs. jpayne@69: The max is typically 85% of physical memory. jpayne@69: -eoom This flag will cause the process to exit if an out-of-memory jpayne@69: exception occurs. Requires Java 8u92+. jpayne@69: -da Disable assertions. jpayne@69: jpayne@69: Please contact Brian Bushnell at bbushnell@lbl.gov if you encounter any problems. jpayne@69: " jpayne@69: } jpayne@69: jpayne@69: #This block allows symlinked shellscripts to correctly set classpath. jpayne@69: pushd . > /dev/null jpayne@69: DIR="${BASH_SOURCE[0]}" jpayne@69: while [ -h "$DIR" ]; do jpayne@69: cd "$(dirname "$DIR")" jpayne@69: DIR="$(readlink "$(basename "$DIR")")" jpayne@69: done jpayne@69: cd "$(dirname "$DIR")" jpayne@69: DIR="$(pwd)/" jpayne@69: popd > /dev/null jpayne@69: jpayne@69: #DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/" jpayne@69: CP="$DIR""current/" jpayne@69: jpayne@69: z="-Xmx200m" jpayne@69: set=0 jpayne@69: jpayne@69: if [ -z "$1" ] || [[ $1 == -h ]] || [[ $1 == --help ]]; then jpayne@69: usage jpayne@69: exit jpayne@69: fi jpayne@69: jpayne@69: calcXmx () { jpayne@69: source "$DIR""/calcmem.sh" jpayne@69: setEnvironment jpayne@69: parseXmx "$@" jpayne@69: } jpayne@69: calcXmx "$@" jpayne@69: jpayne@69: function splitnextera() { jpayne@69: local CMD="java $EA $EOOM $z -cp $CP jgi.SplitNexteraLMP $@" jpayne@69: echo $CMD >&2 jpayne@69: eval $CMD jpayne@69: } jpayne@69: jpayne@69: splitnextera "$@"