Debian Codegraph @

filterqc.sh

raw symbols SCIP
1 #!/bin/bash
2
3 usage(){
4 echo "
5 Written by Shijie Yao
6 Last modified March 22, 2018
7
8 Description: Fastq Filter pipeline
9
10 Usage: filterqc.sh in=<file> out=<dir>
11
12 Parameters:
13 in=file Specify the input fastq or fastq.gz file
14 out=dir The output directory
15 rqcfilterdata=dir Path to RQCFilterData dir
16 [qc] do read qc on filtered output
17
18 Please contact Shijie Yao at syao @lbl.gov if you encounter any problems.
19 "
20 }
21
22
23 pushd . > /dev/null # save current dir in directory stack
24 DIR="${BASH_SOURCE[0]}" # script file, even by source (vs $0)
25
26 while [ -h "$DIR" ]; do # if a link, follow the link to path
27 cd "$(dirname "$DIR")"
28 DIR="$(readlink "$(basename "$DIR")")"
29 done
30
31 cd "$(dirname "$DIR")" # obtain the abspath of where the script live
32 DIR="$(pwd)"
33
34 popd > /dev/null # move back to invocation dir
35
36 PYDIR="$DIR/pytools" # abs path to pytools
37
38 set=0 #?
39
40 if [ $# -lt 2 ] || [ -z "$1" ] || [[ $1 == -h ]] || [[ $1 == --help ]]; then # -z tells if null
41 usage
42 exit
43 fi
44
45 fastq=""
46 out=""
47 doqc=""
48 rqcfilterdata=""
49 parse_arg() {
50 IFS='=' read -ra toks <<< "$1" #Convert string to array
51 if [ ${#toks[@]} -gt 1 ]; then
52 if [ ${toks[0]} == "in" ]; then
53 fastq=${toks[1]}
54 elif [ ${toks[0]} == "out" ]; then
55 out=${toks[1]}
56 elif [ ${toks[0]} == "rqcfilterdata" ]; then
57 rqcfilterdata=${toks[1]}
58 fi
59 elif [ ${#toks[@]} -eq 1 ]; then
60 if [ ${toks[0]} == "qc" ]; then
61 doqc="doqc"
62 fi
63 fi
64 }
65
66 parse_arg $1
67 parse_arg $2
68 parse_arg $3
69
70 if [ -z $fastq ] || [ -z $out ]; then
71 usage
72 exit
73 fi
74
75 if [ ! -e $fastq ]; then
76 echo "ERROR - The file not found : $fastq !!"
77 exit
78 fi
79
80 CMD="$PYDIR/filter.py -f $fastq -o $out -rdb $rqcfilterdata --prod-type DNA --skip-blast"
81 if [ ! -z $doqc ]; then
82 CMD="$CMD --qc"
83 fi
84 echo "$CMD"
85 eval $CMD