Debian Codegraph @

filterqc.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 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/nullscip-shell filesystem . . `/dev/null`. # save current dir in directory stack
24 DIR="${BASH_SOURCE[0]}" # script file, even by source (vs $0)
25
26 while [scip-shell system . . `[`. -h "$DIR" ]; do # if a link, follow the link to path
27 cd "$(dirnamescip-shell system . . dirname. "$DIR")"
28 DIR="$(readlinkscip-shell system . . readlink. "$(basenamescip-shell system . . basename. "$DIR")")"
29 done
30
31 cd "$(dirnamescip-shell system . . dirname. "$DIR")" # obtain the abspath of where the script live
32 DIR="$(pwdscip-shell system . . pwd.)"
33
34 popd > /dev/nullscip-shell filesystem . . `/dev/null`. # move back to invocation dir
35
36 PYDIR="$DIR/pytools" # abs path to pytools
37
38 set=0 #?
39
40 if [scip-shell system . . `[`. $# -lt 2 ] || [scip-shell system . . `[`. -z "$1" ] || [[ $1 == -h ]] || [[ $1 == --help ]]; then # -z tells if null
41 usagescip-shell shell bbmap 39.20+dfsg-3 usage().
42 exit
43 fi
44
45 fastq=""
46 out=""
47 doqc=""
48 rqcfilterdata=""
49 parse_argscip-shell shell bbmap 39.20+dfsg-3 parse_arg().() {
50 IFS='=' read -ra toks <<< "$1" #Convert string to array
51 if [scip-shell system . . `[`. ${#toks[@]} -gt 1 ]; then
52 if [scip-shell system . . `[`. ${toks[0]} == "in" ]; then
53 fastq=${toks[1]}
54 elif [scip-shell system . . `[`. ${toks[0]} == "out" ]; then
55 out=${toks[1]}
56 elif [scip-shell system . . `[`. ${toks[0]} == "rqcfilterdata" ]; then
57 rqcfilterdata=${toks[1]}
58 fi
59 elif [scip-shell system . . `[`. ${#toks[@]} -eq 1 ]; then
60 if [scip-shell system . . `[`. ${toks[0]} == "qc" ]; then
61 doqc="doqc"
62 fi
63 fi
64 }
65
66 parse_argscip-shell shell bbmap 39.20+dfsg-3 parse_arg(). $1
67 parse_argscip-shell shell bbmap 39.20+dfsg-3 parse_arg(). $2
68 parse_argscip-shell shell bbmap 39.20+dfsg-3 parse_arg(). $3
69
70 if [scip-shell system . . `[`. -z $fastq ] || [scip-shell system . . `[`. -z $out ]; then
71 usagescip-shell shell bbmap 39.20+dfsg-3 usage().
72 exit
73 fi
74
75 if [scip-shell system . . `[`. ! -e $fastq ]; then
76 echoscip-shell system . . 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 [scip-shell system . . `[`. ! -z $doqc ]; then
82 CMD="$CMD --qc"
83 fi
84 echoscip-shell system . . echo. "$CMD"
85 eval $CMD