Debian Codegraph @

renamebymapping.sh

raw symbols SCIP
1 #!/bin/bashscip-shell filesystem . . `/bin/bash`.
2
3 usagescip-shell shell bbmap 39.20+dfsg-3 usage().(){
4 echoscip-shell system . . echo. "
5 Written by Brian Bushnell
6 Last modified February 21, 2025
7
8 Description: Renames contigs based on mapping information.
9 Appends coverage and optionally taxID from parsing sam line headers.
10 For taxID renaming, read headers should contain a term like 'tid_1234';
11 output will be named as 'original tid_1234 cov_45.67' with potentially
12 multiple coverage entries (if there are multiple sam files) but
13 only one tid entry based on the highest-coverage sam file.
14 Designed for metagenome binning evaluation and synthetic read generation.
15
16 Usage: renamebymapping.sh in=contigs.fa out=renamed.fa *.sam
17
18 Parameters:
19 in=<file> Assembly to rename.
20 out=<file> Renamed assembly.
21 sam=<file> This can be a file, directory, or comma-delimited list.
22 Unrecognized arguments that are existing files will also
23 be treated as sam files. Bam is acceptable too.
24 delimiter=space Delimiter between appended fields.
25 wipe=f Replace the original header with contig_#.
26 depth=t Add a depth field.
27 tid=t Add a tid field (if not already present).
28
29 Java Parameters:
30 -Xmx This will set Java's memory usage, overriding autodetection.
31 -Xmx20g will specify 20 gigs of RAM, and -Xmx200m will
32 specify 200 megs. The max is typically 85% of physical memory.
33 -eoom This flag will cause the process to exit if an out-of-memory
34 exception occurs. Requires Java 8u92+.
35 -da Disable assertions.
36
37 Please contact Brian Bushnell at [email protected] if you encounter any problems.
38 "
39 }
40
41 #This block allows symlinked shellscripts to correctly set classpath.
42 pushd . > /dev/nullscip-shell filesystem . . `/dev/null`.
43 DIR="${BASH_SOURCE[0]}"
44 while [scip-shell system . . `[`. -h "$DIR" ]; do
45 cd "$(dirnamescip-shell system . . dirname. "$DIR")"
46 DIR="$(readlinkscip-shell system . . readlink. "$(basenamescip-shell system . . basename. "$DIR")")"
47 done
48 cd "$(dirnamescip-shell system . . dirname. "$DIR")"
49 DIR="$(pwdscip-shell system . . pwd.)/"
50 popd > /dev/nullscip-shell filesystem . . `/dev/null`.
51
52 #DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/"
53 CP="$DIR""current/"
54
55 z="-Xmx4g"
56 z2="-Xms4g"
57 set=0
58
59 if [scip-shell system . . `[`. -z "$1" ] || [[ $1 == -h ]] || [[ $1 == --help ]]; then
60 usagescip-shell shell bbmap 39.20+dfsg-3 usage().
61 exit
62 fi
63
64 calcXmxscip-shell shell bbmap 39.20+dfsg-3 calcXmx(). () {
65 source "$DIR""/calcmem.sh"
66 setEnvironment
67 parseXmx "$@"
68 if [[ $set == 1 ]]; then
69 return
70 fi
71 freeRam 4000m 84
72 z="-Xmx${RAM}m"
73 z2="-Xms${RAM}m"
74 }
75 calcXmxscip-shell shell bbmap 39.20+dfsg-3 calcXmx(). "$@"
76
77 renamescip-shell shell bbmap 39.20+dfsg-3 rename().() {
78 local CMD="java $EA $EOOM $z -cp $CP bin.ContigRenamer $@"
79 echoscip-shell system . . echo. $CMD >&2
80 eval $CMD
81 }
82
83 renamescip-shell shell bbmap 39.20+dfsg-3 rename(). "$@"