| 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: Read QC pipeline |
| 9 | |
| 10 | Usage: readqc.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 | |
| 16 | Please contact Shijie Yao at syao @lbl.gov if you encounter any problems. |
| 17 | " |
| 18 | } |
| 19 | |
| 20 | |
| 21 | pushd . > /dev/nullscip-shell filesystem . . `/dev/null`. # save current dir in directory stack |
| 22 | DIR="${BASH_SOURCE[0]}" # script file, even by source (vs $0) |
| 23 | |
| 24 | while [scip-shell system . . `[`. -h "$DIR" ]; do # if a link, follow the link to path |
| 25 | cd "$(dirnamescip-shell system . . dirname. "$DIR")" |
| 26 | DIR="$(readlinkscip-shell system . . readlink. "$(basenamescip-shell system . . basename. "$DIR")")" |
| 27 | done |
| 28 | |
| 29 | cd "$(dirnamescip-shell system . . dirname. "$DIR")" # obtain the abspath of where the script live |
| 30 | DIR="$(pwdscip-shell system . . pwd.)" |
| 31 | |
| 32 | popd > /dev/nullscip-shell filesystem . . `/dev/null`. # move back to invocation dir |
| 33 | |
| 34 | PYDIR="$DIR/pytools" # abs path to pytools |
| 35 | |
| 36 | set=0 #? |
| 37 | |
| 38 | if [scip-shell system . . `[`. $# -ne 2 ] || [scip-shell system . . `[`. -z "$1" ] || [[ $1 == -h ]] || [[ $1 == --help ]]; then # -z tells if null |
| 39 | usagescip-shell shell bbmap 39.20+dfsg-3 usage(). |
| 40 | exit |
| 41 | fi |
| 42 | |
| 43 | fastq="" |
| 44 | out="" |
| 45 | |
| 46 | parse_argscip-shell shell bbmap 39.20+dfsg-3 parse_arg().() { |
| 47 | IFS='=' read -ra toks <<< "$1" #Convert string to array |
| 48 | if [scip-shell system . . `[`. ${#toks[@]} -eq 2 ]; then |
| 49 | if [scip-shell system . . `[`. ${toks[0]} == "in" ]; then |
| 50 | fastq=${toks[1]} |
| 51 | elif [scip-shell system . . `[`. ${toks[0]} == "out" ]; then |
| 52 | out=${toks[1]} |
| 53 | fi |
| 54 | fi |
| 55 | } |
| 56 | |
| 57 | parse_argscip-shell shell bbmap 39.20+dfsg-3 parse_arg(). $1 |
| 58 | parse_argscip-shell shell bbmap 39.20+dfsg-3 parse_arg(). $2 |
| 59 | |
| 60 | if [scip-shell system . . `[`. -z $fastq ] || [scip-shell system . . `[`. -z $out ]; then |
| 61 | usagescip-shell shell bbmap 39.20+dfsg-3 usage(). |
| 62 | exit |
| 63 | fi |
| 64 | |
| 65 | if [scip-shell system . . `[`. ! -e $fastq ]; then |
| 66 | echoscip-shell system . . echo. "ERROR - The file not found : $fastq !!" |
| 67 | exit |
| 68 | fi |
| 69 | |
| 70 | CMD="$PYDIR/readqc.py -f $fastq -o $out --html --skip-blast" |
| 71 | echoscip-shell system . . echo. "$CMD" |
| 72 | eval $CMD |