Debian Codegraph @

findrepeats.sh

raw symbols SCIP
1 #!/bin/bash
2
3 usage(){
4 echo "
5 Written by Brian Bushnell
6 Last modified July 5, 2023
7
8 Description: Finds repeats in a genome.
9
10 No alignment is done; a sequence is considered to be a repeat of depth D if
11 all kmers within it have a depth of at least D. Gaps of up to length G
12 consecutive kmers with lower counts may be allowed, which typically finds
13 far more and substantially longer repeats even with a small G.
14
15 Usage: findrepeats.sh in=<input file> out=<output file>
16
17 Standard parameters:
18 in=<file> Primary input (the genome fasta).
19 out=<file> Primary output (list of repeats as TSV). If no file is
20 given this will be printed to screen; to suppress printing,
21 use 'out=null'.
22 outs=<file> (outsequence) Optional sequence output, for printing or
23 masking repeats.
24 overwrite=f (ow) False ('f') forces the program to abort rather than
25 overwrite an existing file.
26 showspeed=t (ss) Set to 'f' to suppress display of processing speed.
27 ziplevel=2 (zl) Set to 1 (lowest) through 9 (max) to change compression
28 level; lower compression is faster.
29
30 Processing parameters:
31 k=31 Kmer length to use (range is 1-31; 31 is recommended).
32 gap=0 Maximum allowed gap length within a repeat, in kmers.
33 This allows inexact repeats. Note that a 1bp mismatch
34 will spawn a length K gap.
35 qhdist=0 Hamming distance within a kmer; allows inexact repeats.
36 Values above 0 become exponentially slower.
37 minrepeat=0 Minimum repeat length to report, in bases. Nothing shorter
38 than kmer length will be found regardless of this value.
39 mindepth=2 Ignore copy counts below mindepth.
40 maxdepth=-1 If positive, copy counts greater than this will be reported
41 as this number. This can greatly increase speed in rare
42 cases of thousand+ copy repeats.
43 preview=27 Print this many characters of the repeat per line. Set to 0
44 to suppress (may save memory).
45 mask=f Write sequence with masked repeats to 'outs'. Possible values:
46 f: Do not mask.
47 t: Mask (by default, 't' or 'true' are the same as 'soft').
48 soft: Convert masked bases to lower case.
49 hard: Convert masked bases to 'N'.
50 Other characters: Convert masked bases to that character.
51 print=t (printrepeats) Print repeat sequence to outs. 'print' and
52 'mask' are mutually exclusive so enabling one will disable
53 the other.
54 weak=f (weaksubsumes) Ignore repeats that are weakly subsumed by
55 other repeats. A repeat is subsumed if there is another repeat
56 with greater depth at the same coordinates. Since a 3-copy
57 repeat is also a 2-copy repeat, only the 3-copy repeat will be
58 reported. However, in the case that the 3-copy repeat is
59 inexact (has gaps) and the 2-copy repeat is perfect, both will
60 be reported when 'weak=f' as per default. If you set the
61 'weak=t' flag, only the highest-depth version will be reported
62 even if it has more gaps. In either case all 3 repeats would
63 be reported, but with 'weak=f' some copies would be reported
64 twice for the same coordinates, once as a depth-2 perfect
65 repeat and again as a depth-3 imperfect repeat.
66
67 Java Parameters:
68 -Xmx This will set Java's memory usage, overriding autodetection.
69 -Xmx20g will specify 20 gigs of RAM, and -Xmx200m will
70 specify 200 megs. The max is typically 85% of physical memory.
71 -eoom This flag will cause the process to exit if an out-of-memory
72 exception occurs. Requires Java 8u92+.
73 -da Disable assertions.
74
75 Please contact Brian Bushnell at [email protected] if you encounter any problems.
76 "
77 }
78
79 #This block allows symlinked shellscripts to correctly set classpath.
80 pushd . > /dev/null
81 DIR="${BASH_SOURCE[0]}"
82 while [ -h "$DIR" ]; do
83 cd "$(dirname "$DIR")"
84 DIR="$(readlink "$(basename "$DIR")")"
85 done
86 cd "$(dirname "$DIR")"
87 DIR="$(pwd)/"
88 popd > /dev/null
89
90 #DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/"
91 CP="$DIR""current/"
92
93 z="-Xmx4g"
94 z2="-Xms4g"
95 set=0
96
97 if [ -z "$1" ] || [[ $1 == -h ]] || [[ $1 == --help ]]; then
98 usage
99 exit
100 fi
101
102 calcXmx () {
103 source "$DIR""/calcmem.sh"
104 setEnvironment
105 parseXmx "$@"
106 if [[ $set == 1 ]]; then
107 return
108 fi
109 freeRam 4000m 84
110 z="-Xmx${RAM}m"
111 z2="-Xms${RAM}m"
112 }
113 calcXmx "$@"
114
115 findrepeats() {
116 local CMD="java $EA $EOOM $z -cp $CP repeat.RepeatFinder $@"
117 echo $CMD >&2
118 eval $CMD
119 }
120
121 findrepeats "$@"