Debian Codegraph @

filtersam.sh

raw symbols SCIP
1 #!/bin/bash
2
3 usage(){
4 echo "
5 Written by Brian Bushnell
6 Last modified September 20, 2022
7
8 Description: Filters a sam file to remove reads with variations unsupported
9 by other reads (bad vars, aka bad subs). For particularly bad data,
10 it may be advisable to iteratively re-call variants and re-run FilterSam.
11 Calling variants may be performed like this:
12
13 callvariants.sh in=mapped.sam ref=ref.fa out=vars.vcf clearfilters minreads=2
14
15 Usage: filtersam.sh in=<file> out=<file> vcf=<file>
16
17 Parameters:
18 in=<file> Input sam or bam file.
19 ref=<file> Optional fasta reference file.
20 out=<file> Output file for good reads.
21 outb=<file> Output file for bad reads.
22 vcf=<file> VCF file of variants called from these reads.
23 vars=<file> Alternatively, variants can be provided in CallVariants'
24 native output format.
25 mbv=2 (maxbadvars) Discarded reads with more bad vars than this.
26 mbad=2 (maxbadalleledepth) A var is bad if the allele depth is at
27 most this much.
28 mbaf=0.01 (maxbadalleledepth) A var is bad if the allele fraction is at
29 most this much. The more stringent of mbad or mbaf is used,
30 so in low depth regions mbad is dominant while in high depth
31 regions mbaf is more important. Vars are considered bad if
32 they fail either threshold (meaning ad<=mbad or af<=mbaf).
33 mbrd=2 (minbadreaddepth) Substitutions may only be considered
34 bad if the total read depth spanning the variant is
35 at least this much.
36 border=5 (minenddist) Ignore vars within this distance of read ends.
37 sub=t Consider bad substitutions.
38 ins=f Consider bad insertions.
39 del=f Consider bad deletions.
40
41 Please contact Brian Bushnell at [email protected] if you encounter any problems.
42 "
43 }
44
45 #This block allows symlinked shellscripts to correctly set classpath.
46 pushd . > /dev/null
47 DIR="${BASH_SOURCE[0]}"
48 while [ -h "$DIR" ]; do
49 cd "$(dirname "$DIR")"
50 DIR="$(readlink "$(basename "$DIR")")"
51 done
52 cd "$(dirname "$DIR")"
53 DIR="$(pwd)/"
54 popd > /dev/null
55
56 #DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/"
57 CP="$DIR""current/"
58
59 z="-Xmx8g"
60 z2="-Xms8g"
61 set=0
62
63 if [ -z "$1" ] || [[ $1 == -h ]] || [[ $1 == --help ]]; then
64 usage
65 exit
66 fi
67
68 calcXmx () {
69 source "$DIR""/calcmem.sh"
70 setEnvironment
71 parseXmx "$@"
72 if [[ $set == 1 ]]; then
73 return
74 fi
75 freeRam 3200m 84
76 z="-Xmx${RAM}m"
77 z2="-Xms${RAM}m"
78 }
79 calcXmx "$@"
80
81 filtersam() {
82 local CMD="java $EA $EOOM $z $z2 -cp $CP var2.FilterSam $@"
83 # echo $CMD >&2
84 eval $CMD
85 }
86
87 filtersam "$@"