| 1 | #!/bin/bash |
| 2 | |
| 3 | usage(){ |
| 4 | echo " |
| 5 | Written by Brian Bushnell |
| 6 | Last modified Oct 11, 2023 |
| 7 | |
| 8 | Description: Scores sequences using a neural network. Only the initial Xbp |
| 9 | are used, for sequences longer than the network size. |
| 10 | |
| 11 | Usage: scoresequence.sh in=<sequences> out=<renamed sequences> net=<net file> |
| 12 | |
| 13 | Input may be fasta or fastq, compressed or uncompressed. |
| 14 | |
| 15 | Standard parameters: |
| 16 | in=<file> Sequence data. |
| 17 | out=<file> Sequences renamed with their scores. |
| 18 | net=<file> Network file to apply to the sequences. |
| 19 | hist=<file> Histogram of scores (x100, so 0-1 maps to 0-100). |
| 20 | overwrite=f (ow) Set to false to force the program to abort rather than |
| 21 | overwrite an existing file. |
| 22 | |
| 23 | Processing parameters: |
| 24 | rcomp=f Use the max score of a sequence and its reverse complement. |
| 25 | parse=f Parse sequence headers for 'result=' to determine whether |
| 26 | they are positive or negative examples. |
| 27 | annotate=t Rename output reads by appending 'score='. |
| 28 | filter=f Retain only reads above or below a cutoff. Setting the cutoff |
| 29 | or highpass flag will automatically set this to true. |
| 30 | cutoff=0.5 Score cutoff for filtering; scores mostly range from 0 to 1. |
| 31 | highpass=t Retain sequences ABOVE cutoff if true, else BELOW cutoff. |
| 32 | |
| 33 | Java Parameters: |
| 34 | -Xmx This will set Java's memory usage, overriding autodetection. |
| 35 | -Xmx20g will specify 20 gigs of RAM, and -Xmx200m will |
| 36 | specify 200 megs. The max is typically 85% of physical memory. |
| 37 | -eoom This flag will cause the process to exit if an out-of-memory |
| 38 | exception occurs. Requires Java 8u92+. |
| 39 | -da Disable assertions. |
| 40 | |
| 41 | Please contact Brian Bushnell at [email protected] if you encounter any problems. |
| 42 | " |
| 43 | } |
| 44 | |
| 45 | #This block allows symlinked shellscripts to correctly set classpath. |
| 46 | pushd . > /dev/null |
| 47 | DIR="${BASH_SOURCE[0]}" |
| 48 | while [ -h "$DIR" ]; do |
| 49 | cd "$(dirname "$DIR")" |
| 50 | DIR="$(readlink "$(basename "$DIR")")" |
| 51 | done |
| 52 | cd "$(dirname "$DIR")" |
| 53 | DIR="$(pwd)/" |
| 54 | popd > /dev/null |
| 55 | |
| 56 | #DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/" |
| 57 | CP="$DIR""current/" |
| 58 | |
| 59 | z="-Xmx1g" |
| 60 | z2="-Xms1g" |
| 61 | set=0 |
| 62 | |
| 63 | if [ -z "$1" ] || [[ $1 == -h ]] || [[ $1 == --help ]]; then |
| 64 | usage |
| 65 | exit |
| 66 | fi |
| 67 | |
| 68 | calcXmx () { |
| 69 | source "$DIR""/calcmem.sh" |
| 70 | setEnvironment |
| 71 | parseXmx "$@" |
| 72 | } |
| 73 | calcXmx "$@" |
| 74 | |
| 75 | score() { |
| 76 | local CMD="java $EA $EOOM $z $SIMD -cp $CP ml.ScoreSequence $@" |
| 77 | echo $CMD >&2 |
| 78 | eval $CMD |
| 79 | } |
| 80 | |
| 81 | score "$@" |