Debian Codegraph @

gradebins.sh

raw symbols SCIP
1 #!/bin/bash
2
3 usage(){
4 echo "
5 Written by Brian Bushnell
6 Last modified March 26, 2025
7
8 Description: Grades metagenome bins for completeness and contamination.
9 The contigs can be labeled with their taxID; in which case the header should
10 contain 'tid_X' somewhere where X is a number unique to their proper genome.
11 Alternately, CheckM2 and/or EukCC output can be fed to it.
12 Do not include a 'chaff' file (for unbinned contigs) when grading.
13 Completeness Score is (sum of completeness*size)/(total size) for all bins.
14 Contamination Score is (sum of contam*size)/(total size) for all bins.
15 Total Score is (sum of (completeness-5*contam)^2) for all bins.
16 Bin Definitions:
17 UHQ: >=99% complete and <=1% contam
18 VHQ: >=95% complete and <=2% contam
19 HQ: >=90% complete and <=5% contam
20 MQ: >=50% complete and <=10% contam, but not HQ
21 LQ: <50% complete or >10% contam
22 VLQ: <20% complete or >5% contam
23
24
25 Usage: gradebins.sh ref=assembly bin*.fa
26 or
27 gradebins.sh ref=assembly.fa in=bin_directory
28 or
29 gradebins.sh taxin=tax.txt in=bins
30
31 File parameters:
32 ref=<file> The original assembly that was binned.
33 in=<directory> Location of bin fastas.
34 checkm=<file> Optional CheckM2 quality_report.tsv file or directory.
35 eukcc=<file> Optional EukCC eukcc.csv file or directory.
36 hist=<file> Histogram output.
37 taxin=<file> Optional file with taxIDs and sizes (instead of loading ref).
38 Does not need to include taxIDs. The tax file loads faster.
39 taxout=<file> Generate a tax file from the reference.
40 loadmt=t Load bins multithreaded.
41
42 Java Parameters:
43 -Xmx This will set Java's memory usage, overriding autodetection.
44 -Xmx20g will specify 20 gigs of RAM, and -Xmx200m will
45 specify 200 megs. The max is typically 85% of physical memory.
46 -eoom This flag will cause the process to exit if an out-of-memory
47 exception occurs. Requires Java 8u92+.
48 -da Disable assertions.
49
50 Please contact Brian Bushnell at [email protected] if you encounter any problems.
51 "
52 }
53
54 #This block allows symlinked shellscripts to correctly set classpath.
55 pushd . > /dev/null
56 DIR="${BASH_SOURCE[0]}"
57 while [ -h "$DIR" ]; do
58 cd "$(dirname "$DIR")"
59 DIR="$(readlink "$(basename "$DIR")")"
60 done
61 cd "$(dirname "$DIR")"
62 DIR="$(pwd)/"
63 popd > /dev/null
64
65 #DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/"
66 CP="$DIR""current/"
67
68 z="-Xmx2g"
69 z2="-Xms2g"
70 set=0
71
72 if [ -z "$1" ] || [[ $1 == -h ]] || [[ $1 == --help ]]; then
73 usage
74 exit
75 fi
76
77 calcXmx () {
78 source "$DIR""/calcmem.sh"
79 setEnvironment
80 parseXmx "$@"
81 }
82 calcXmx "$@"
83
84 gradeBins() {
85 local CMD="java $EA $EOOM $z -cp $CP bin.GradeBins $@"
86 echo $CMD >&2
87 eval $CMD
88 }
89
90 gradeBins "$@"