Debian Codegraph @

microalign.sh

raw symbols SCIP
1 #!/bin/bash
2
3 usage(){
4 echo "
5 Written by Brian Bushnell
6 Last modified March 21, 2025
7
8 Description: Wrapper for MicroAligner.
9 Can align reads to a small, single-contig reference like PhiX.
10 Probably faster than BBMap. Produces most of the same histograms,
11 like idhist, mhist, etc.
12 Not currently designed for reference with multiple sequences,
13 or duplicate kmers of length used for indexing.
14
15 Usage: microalign.sh in=<input file> out=<output file> ref=<reference>
16
17 Input may be fasta or fastq, compressed or uncompressed.
18
19 Standard parameters:
20 in=<file> Primary input, or read 1 input.
21 in2=<file> Read 2 input if reads are in two files.
22 out=<file> Primary output, or read 1 output.
23 out2=<file> Read 2 output if reads are in two files.
24 outu=<file> Optional unmapped read output.
25 outu2=<file> Optional unmapped read 2 output.
26
27 Processing parameters:
28 k=17 Main kmer length.
29 k2=13 Sub-kmer length for paired reads only.
30 minid=0.66 Minimum alignment identity.
31 minid2=0.56 Minimum alignment identity if the mate is mapped.
32 mm=1 Middle mask length; the index uses gapped kmers.
33
34 Java Parameters:
35 -Xmx This will set Java's memory usage, overriding autodetection.
36 -Xmx20g will specify 20 gigs of RAM, and -Xmx200m will
37 specify 200 megs. The max is typically 85% of physical memory.
38 -eoom This flag will cause the process to exit if an out-of-memory
39 exception occurs. Requires Java 8u92+.
40 -da Disable assertions.
41
42 Please contact Brian Bushnell at [email protected] if you encounter any problems.
43 "
44 }
45
46 #This block allows symlinked shellscripts to correctly set classpath.
47 pushd . > /dev/null
48 DIR="${BASH_SOURCE[0]}"
49 while [ -h "$DIR" ]; do
50 cd "$(dirname "$DIR")"
51 DIR="$(readlink "$(basename "$DIR")")"
52 done
53 cd "$(dirname "$DIR")"
54 DIR="$(pwd)/"
55 popd > /dev/null
56
57 #DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/"
58 CP="$DIR""current/"
59
60 z="-Xmx4g"
61 z2="-Xms4g"
62 set=0
63
64 if [ -z "$1" ] || [[ $1 == -h ]] || [[ $1 == --help ]]; then
65 usage
66 exit
67 fi
68
69 calcXmx () {
70 source "$DIR""/calcmem.sh"
71 setEnvironment
72 parseXmx "$@"
73 if [[ $set == 1 ]]; then
74 return
75 fi
76 freeRam 4000m 84
77 z="-Xmx${RAM}m"
78 z2="-Xms${RAM}m"
79 }
80 calcXmx "$@"
81
82 align() {
83 local CMD="java $EA $EOOM $z -cp $CP aligner.MicroWrapper $@"
84 echo $CMD >&2
85 eval $CMD
86 }
87
88 align "$@"