| 1 | #!/bin/bash |
| 2 | |
| 3 | usage(){ |
| 4 | 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/null # save current dir in directory stack |
| 22 | DIR="${BASH_SOURCE[0]}" # script file, even by source (vs $0) |
| 23 | |
| 24 | while [ -h "$DIR" ]; do # if a link, follow the link to path |
| 25 | cd "$(dirname "$DIR")" |
| 26 | DIR="$(readlink "$(basename "$DIR")")" |
| 27 | done |
| 28 | |
| 29 | cd "$(dirname "$DIR")" # obtain the abspath of where the script live |
| 30 | DIR="$(pwd)" |
| 31 | |
| 32 | popd > /dev/null # move back to invocation dir |
| 33 | |
| 34 | PYDIR="$DIR/pytools" # abs path to pytools |
| 35 | |
| 36 | set=0 #? |
| 37 | |
| 38 | if [ $# -ne 2 ] || [ -z "$1" ] || [[ $1 == -h ]] || [[ $1 == --help ]]; then # -z tells if null |
| 39 | usage |
| 40 | exit |
| 41 | fi |
| 42 | |
| 43 | fastq="" |
| 44 | out="" |
| 45 | |
| 46 | parse_arg() { |
| 47 | IFS='=' read -ra toks <<< "$1" #Convert string to array |
| 48 | if [ ${#toks[@]} -eq 2 ]; then |
| 49 | if [ ${toks[0]} == "in" ]; then |
| 50 | fastq=${toks[1]} |
| 51 | elif [ ${toks[0]} == "out" ]; then |
| 52 | out=${toks[1]} |
| 53 | fi |
| 54 | fi |
| 55 | } |
| 56 | |
| 57 | parse_arg $1 |
| 58 | parse_arg $2 |
| 59 | |
| 60 | if [ -z $fastq ] || [ -z $out ]; then |
| 61 | usage |
| 62 | exit |
| 63 | fi |
| 64 | |
| 65 | if [ ! -e $fastq ]; then |
| 66 | 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 | echo "$CMD" |
| 72 | eval $CMD |