Debian Codegraph @

bloomfilter.sh

raw symbols SCIP
1 #!/bin/bash
2
3 usage(){
4 echo "
5 Written by Brian Bushnell
6 Last modified September 20, 2022
7
8 Description: Filters reads potentially sharing a kmer with a reference.
9 The more memory, the higher the accuracy. Reads going to outu are guaranteed
10 to not match the reference, but reads going to outm might may or may not
11 match the reference.
12
13 Usage: bloomfilter.sh in=<input file> out=<nonmatches> outm=<matches> ref=<reference>
14
15 Example:
16 bloomfilter.sh in=reads.fq outm=nonhuman.fq out=human.fq k=31 minhits=3 ref=human.fa
17
18 Error correction and depth filtering can be done simultaneously.
19
20 File parameters:
21 in=<file> Primary input, or read 1 input.
22 in2=<file> Read 2 input if reads are in two files.
23 outm=<file> (out) Primary matched read output.
24 outm2=<file> (out2) Matched read 2 output if reads are in two files.
25 outu=<file> Primary unmatched read output.
26 outu2=<file> Unmatched read 2 output if reads are in two files.
27 outc=<file> Optional output stream for kmer counts.
28 ref=<file> Reference sequence file, or a comma-delimited list.
29 For depth-based filtering, set this to the same as the input.
30 overwrite=t (ow) Set to false to force the program to abort rather than
31 overwrite an existing file.
32
33 Hashing parameters:
34 k=31 Kmer length.
35 hashes=2 Number of hashes per kmer. Higher generally reduces
36 false positives at the expense of speed.
37 sw=t (symmetricwrite) Increases accuracy when bits>1 and hashes>1.
38 minprob=0.5 Ignore reference kmers with probability of being correct
39 below this (affects fastq references only).
40 memmult=1.0 Fraction of free memory to use for Bloom filter. 1.0 should
41 generally work; if the program crashes with an out of memory
42 error, set this lower. Higher increases specificity.
43 cells= Option to set the number of cells manually. By default this
44 will be autoset to use all available memory. The only reason
45 to set this is to ensure deterministic output.
46 seed=0 This will change the hash function used.
47 bits= Bits per cell; it is set automatically from mincount.
48
49 Reference-matching parameters:
50 minhits=3 Consecutive kmer hits for a read to be considered matched.
51 Higher reduces false positives at the expense of sensitivity.
52 mincount=1 Minimum number of times a read kmer must occur in the
53 reference to be considered a match (or printed to outc).
54 requireboth=f Require both reads in a pair to match the ref in order to go
55 to outm. By default, pairs go to outm if either matches.
56
57 Java Parameters:
58 -Xmx This will set Java's memory usage, overriding autodetection.
59 -Xmx20g will specify 20 gigs of RAM, and -Xmx200m will
60 specify 200 megs. The max is typically 85% of physical memory.
61 -eoom This flag will cause the process to exit if an out-of-memory
62 exception occurs. Requires Java 8u92+.
63 -da Disable assertions.
64
65 Please contact Brian Bushnell at [email protected] if you encounter any problems.
66 "
67 }
68
69 #This block allows symlinked shellscripts to correctly set classpath.
70 pushd . > /dev/null
71 DIR="${BASH_SOURCE[0]}"
72 while [ -h "$DIR" ]; do
73 cd "$(dirname "$DIR")"
74 DIR="$(readlink "$(basename "$DIR")")"
75 done
76 cd "$(dirname "$DIR")"
77 DIR="$(pwd)/"
78 popd > /dev/null
79
80 #DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/"
81 CP="$DIR""current/"
82
83 z="-Xmx4g"
84 z2="-Xms4g"
85 set=0
86
87 if [ -z "$1" ] || [[ $1 == -h ]] || [[ $1 == --help ]]; then
88 usage
89 exit
90 fi
91
92 calcXmx () {
93 source "$DIR""/calcmem.sh"
94 setEnvironment
95 parseXmx "$@"
96 if [[ $set == 1 ]]; then
97 return
98 fi
99 freeRam 4000m 84
100 z="-Xmx${RAM}m"
101 z2="-Xms${RAM}m"
102 }
103 calcXmx "$@"
104
105 bloomfilter() {
106 local CMD="java $EA $EOOM $z $z2 -cp $CP bloom.BloomFilterWrapper $@"
107 echo $CMD >&2
108 eval $CMD
109 }
110
111 bloomfilter "$@"