annotate CSP2/CSP2_env/env-d9b9114564458d9d-741b3de822f2aaca6c6caa4325c4afce/opt/bbmap-39.01-1/calctruequality.sh @ 69:33d812a61356

planemo upload commit 2e9511a184a1ca667c7be0c6321a36dc4e3d116d
author jpayne
date Tue, 18 Mar 2025 17:55:14 -0400
parents
children
rev   line source
jpayne@69 1 #!/bin/bash
jpayne@69 2
jpayne@69 3 usage(){
jpayne@69 4 echo "
jpayne@69 5 Written by Brian Bushnell
jpayne@69 6 Last modified March 21, 2019
jpayne@69 7
jpayne@69 8 Description: Calculates observed quality scores from mapped sam/bam files.
jpayne@69 9 Generates matrices for use in recalibrating quality scores. By default,
jpayne@69 10 the matrices are written to /ref/qual/ in the current directory.
jpayne@69 11
jpayne@69 12 If you have multiple sam/bam files demultiplexed from a single sequencing run,
jpayne@69 13 it is recommended to use all of them as input for increased statistical power.
jpayne@69 14 Once the matrices are generated, recalibration can be done on mapped or
jpayne@69 15 unmapped reads; you may get better results by recalibrating the fastq and
jpayne@69 16 remapping the calibrated reads.
jpayne@69 17
jpayne@69 18 Note! Diploid organisms with a high heterozygousity rate will induce
jpayne@69 19 inaccurate recalibration at the high end of the quality scale unless SNP
jpayne@69 20 locations are masked or variations are called. For example, recalibrating
jpayne@69 21 human reads mapped to an unmasked human reference would generate an
jpayne@69 22 expected maximal Q-score of roughly 30 due to the human 1/1000 SNP rate.
jpayne@69 23 Variations can be ignored by using the callvars flag or providing
jpayne@69 24 a file of variations.
jpayne@69 25
jpayne@69 26 Usage:
jpayne@69 27
jpayne@69 28 Step 1. Generate matrices (from mapped sam or bam files):
jpayne@69 29 calctruequality.sh in=<file,file,...file> path=<directory>
jpayne@69 30
jpayne@69 31 Step 2. Recalibrate reads (any kind of files):
jpayne@69 32 bbduk.sh in=<file> out=<file> recalibrate
jpayne@69 33
jpayne@69 34
jpayne@69 35 Parameters (and their defaults)
jpayne@69 36
jpayne@69 37 Input parameters:
jpayne@69 38 in=<file,file> Sam file or comma-delimited list of files. Alignments
jpayne@69 39 must use = and X cigar symbols, or have MD tags, or
jpayne@69 40 ref must be specified.
jpayne@69 41 reads=-1 Stop after processing this many reads (if positive).
jpayne@69 42 samstreamer=t (ss) Load reads multithreaded to increase speed.
jpayne@69 43 unpigz=t Use pigz to decompress.
jpayne@69 44
jpayne@69 45 Output parameters:
jpayne@69 46 overwrite=t (ow) Set to true to allow overwriting of existing files.
jpayne@69 47 path=. Directory to write quality matrices (within /ref subdir).
jpayne@69 48 write=t Write matrices.
jpayne@69 49 showstats=t Print a summary.
jpayne@69 50 pigz=f Use pigz to compress.
jpayne@69 51
jpayne@69 52 Other parameters:
jpayne@69 53 t=auto Number of worker threads.
jpayne@69 54 passes=2 Recalibration passes, 1 or 2. 2 is slower but gives more
jpayne@69 55 accurate quality scores.
jpayne@69 56 recalqmax=42 Adjust max quality scores tracked. The actual highest
jpayne@69 57 quality score allowed is recalqmax-1.
jpayne@69 58 trackall=f Track all available quality metrics and produce all
jpayne@69 59 matrices, including the ones that are not selected for
jpayne@69 60 quality adjustment. Reduces speed, but allows testing the
jpayne@69 61 effects of different recalibration matrices.
jpayne@69 62 indels=t Include indels in quality calculations.
jpayne@69 63
jpayne@69 64 Variation calling:
jpayne@69 65 varfile=<file> Use the variants in this var file, instead of calling
jpayne@69 66 variants. The format can be produced by CallVariants.
jpayne@69 67 vcf=<file> Use the variants in this VCF file, instead of
jpayne@69 68 calling variants.
jpayne@69 69 callvars=f Call SNPs, and do not count them as errors.
jpayne@69 70 ploidy=1 Set the organism's ploidy.
jpayne@69 71 ref= Required for variation-calling.
jpayne@69 72
jpayne@69 73 *** 'Variant-Calling Cutoffs' flags in callvariants.sh are also supported ***
jpayne@69 74
jpayne@69 75 Selecting matrices:
jpayne@69 76 loadq102= For each recalibration matrix, enable or disable that matrix with t/f.
jpayne@69 77 You can specify pass1 or pass2 like this: loadq102_p1=f loadq102_p2=t.
jpayne@69 78 The default is loadqbp_p1=t loadqbp_p2=t loadqb123_p=t.
jpayne@69 79 clearmatrices=f If true, clear all the existing matrix selections. For example:
jpayne@69 80 'clearmatrices loadqbp_p1'
jpayne@69 81 This would ignore defaults and select only qbp for the first pass.
jpayne@69 82
jpayne@69 83 Available matrices:
jpayne@69 84 q102 Quality, leading quality, trailing quality.
jpayne@69 85 qap Quality, average quality, position.
jpayne@69 86 qbp Quality, current base, position.
jpayne@69 87 q10 Quality, leading quality.
jpayne@69 88 q12 Quality, trailing quality.
jpayne@69 89 qb12 Quality, leading base, current base.
jpayne@69 90 qb012 Quality, two leading bases, current base.
jpayne@69 91 qb123 Quality, leading base, current base, trailing base.
jpayne@69 92 qb234 Quality, current base, two trailing bases.
jpayne@69 93 q12b12 Quality, trailing quality, leading base, current base.
jpayne@69 94 qp Quality, position.
jpayne@69 95 q Current quality score only.
jpayne@69 96
jpayne@69 97
jpayne@69 98 Java Parameters:
jpayne@69 99 -Xmx This will set Java's memory usage, overriding autodetection.
jpayne@69 100 -Xmx20g will specify 20 gigs of RAM, and -Xmx200m will specify 200 megs.
jpayne@69 101 The max is typically 85% of physical memory.
jpayne@69 102 -eoom This flag will cause the process to exit if an
jpayne@69 103 out-of-memory exception occurs. Requires Java 8u92+.
jpayne@69 104 -da Disable assertions.
jpayne@69 105
jpayne@69 106 Please contact Brian Bushnell at bbushnell@lbl.gov if you encounter any problems.
jpayne@69 107 "
jpayne@69 108 }
jpayne@69 109
jpayne@69 110 #This block allows symlinked shellscripts to correctly set classpath.
jpayne@69 111 pushd . > /dev/null
jpayne@69 112 DIR="${BASH_SOURCE[0]}"
jpayne@69 113 while [ -h "$DIR" ]; do
jpayne@69 114 cd "$(dirname "$DIR")"
jpayne@69 115 DIR="$(readlink "$(basename "$DIR")")"
jpayne@69 116 done
jpayne@69 117 cd "$(dirname "$DIR")"
jpayne@69 118 DIR="$(pwd)/"
jpayne@69 119 popd > /dev/null
jpayne@69 120
jpayne@69 121 #DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/"
jpayne@69 122 CP="$DIR""current/"
jpayne@69 123
jpayne@69 124 z="-Xmx2g"
jpayne@69 125 z2="-Xms2g"
jpayne@69 126 set=0
jpayne@69 127
jpayne@69 128 if [ -z "$1" ] || [[ $1 == -h ]] || [[ $1 == --help ]]; then
jpayne@69 129 usage
jpayne@69 130 exit
jpayne@69 131 fi
jpayne@69 132
jpayne@69 133 calcXmx () {
jpayne@69 134 source "$DIR""/calcmem.sh"
jpayne@69 135 setEnvironment
jpayne@69 136 parseXmx "$@"
jpayne@69 137 if [[ $set == 1 ]]; then
jpayne@69 138 return
jpayne@69 139 fi
jpayne@69 140 freeRam 3200m 84
jpayne@69 141 z="-Xmx${RAM}m"
jpayne@69 142 z2="-Xms${RAM}m"
jpayne@69 143 }
jpayne@69 144 calcXmx "$@"
jpayne@69 145
jpayne@69 146 calctruequality() {
jpayne@69 147 local CMD="java $EA $EOOM $z $z2 -cp $CP jgi.CalcTrueQuality $@"
jpayne@69 148 echo $CMD >&2
jpayne@69 149 eval $CMD
jpayne@69 150 }
jpayne@69 151
jpayne@69 152 calctruequality "$@"