Debian Codegraph @

netfilter.sh

raw symbols SCIP
1 #!/bin/bash
2
3 usage(){
4 echo "
5 Written by Brian Bushnell
6 Last modified Oct 30, 2023
7
8 Description: Scores sequences using a neural network. This is similar
9 to scoresequence.sh but multithreaded and with more filtering options.
10
11 Usage: netfilter.sh in=<sequences> out=<pass> outu=<fail> net=<net file>
12
13 Input may be fasta or fastq, compressed or uncompressed.
14
15 Standard parameters:
16 in=<file> Input sequences.
17 out=<file> Sequences passing the filter.
18 outu=<file> Sequences failing the filter.
19 net=<file> Network file to apply to the sequences.
20 hist=<file> Histogram of scores (x100, so 0-1 maps to 0-100).
21 overwrite=f (ow) Set to false to force the program to abort rather than
22 overwrite an existing file.
23
24 Processing parameters:
25 rcomp=f Use the max score of a sequence and its reverse complement.
26 parse=f Parse sequence headers for 'result=' to determine whether
27 they are positive or negative examples. Positive examples
28 should be annotated with result=1, and negative with result=0.
29 annotate=f Rename output sequences by appending 'score='.
30 filter=t Retain only reads above or below a cutoff. Setting the cutoff
31 or highpass flag will automatically set this to true.
32 cutoff=auto Score cutoff for filtering; scores mostly range from 0 to 1.
33 'auto' will use the cutoff embedded in the network.
34 highpass=t Retain sequences ABOVE cutoff if true, else BELOW cutoff.
35 scoremode= single (default): Apply the network once to each sequence.
36 If the sequence is longer than the network's inputs, use the
37 first X bases.
38 average: Apply the network to the sequence once every
39 'stepsize' bases, and use the average. May be slow.
40 max: Like average, but uses the maximum score.
41 min: Like average, but uses the minimum score.
42 pairmode= average (default): For paired reads, average the two scores.
43 max: Use the higher of the two scores.
44 min: Use the lower of the two scores.
45 stepsize=1 If scoremode is other than 'single', score a window every
46 this many bases. The window width is defined by the network.
47 Higher values of stepsize are faster.
48 overlap= This can be set instead of stepsize; if either flag is used it
49 will override the other. Setting overlap will make windows
50 overlap that much, so 'overlap=0' is equivalent to 'stepsize=W'
51 where W is the width of the network in bases.
52
53 Java Parameters:
54 -Xmx This will set Java's memory usage, overriding autodetection.
55 -Xmx20g will specify 20 gigs of RAM, and -Xmx200m will
56 specify 200 megs. The max is typically 85% of physical memory.
57 -eoom This flag will cause the process to exit if an out-of-memory
58 exception occurs. Requires Java 8u92+.
59 -da Disable assertions.
60
61 Please contact Brian Bushnell at [email protected] if you encounter any problems.
62 "
63 }
64
65 #This block allows symlinked shellscripts to correctly set classpath.
66 pushd . > /dev/null
67 DIR="${BASH_SOURCE[0]}"
68 while [ -h "$DIR" ]; do
69 cd "$(dirname "$DIR")"
70 DIR="$(readlink "$(basename "$DIR")")"
71 done
72 cd "$(dirname "$DIR")"
73 DIR="$(pwd)/"
74 popd > /dev/null
75
76 #DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/"
77 CP="$DIR""current/"
78
79 z="-Xmx2g"
80 z2="-Xms2g"
81 set=0
82
83 if [ -z "$1" ] || [[ $1 == -h ]] || [[ $1 == --help ]]; then
84 usage
85 exit
86 fi
87
88 calcXmx () {
89 source "$DIR""/calcmem.sh"
90 setEnvironment
91 parseXmx "$@"
92 if [[ $set == 1 ]]; then
93 return
94 fi
95 freeRam 2000m 20
96 z="-Xmx${RAM}m"
97 z2="-Xms${RAM}m"
98 }
99 calcXmx "$@"
100
101 score() {
102 local CMD="java $EA $EOOM $z $z2 $SIMD -cp $CP ml.NetFilter $@"
103 echo $CMD >&2
104 eval $CMD
105 }
106
107 score "$@"