#!/bin/bash set -eu case $1 in --help) cat <&1 |head -n4 exit ;; esac # Parse the command line. bwa_aln='bwa aln' bwa_index='bwa index -a bwtsw' while getopts :j:l:v opt; do case $opt in j) bwa_aln="$bwa_aln -t$OPTARG";; l) ;; v) ;; \?) echo >&2 "abyss-bwa: invalid option: $OPTARG"; exit 1;; esac done shift $((OPTIND-1)) query=("$@") target=${query[${#query[@]}-1]} unset query[${#query[@]}-1] index=$target.bwt # Build the index. if [ ! -r $index ]; then echo >&2 "Building the index $index..." echo >&2 $bwa_index $target $target $bwa_index $target $target 1>&2 elif [ $index -ot $target ]; then echo >&2 "The index $index is stale. Rebuilding the index..." echo >&2 $bwa_index $target $target $bwa_index $target $target 1>&2 else echo >&2 "The index $index is up to date." fi # Map the reads. echo >&2 $bwa_aln $target "${query[@]}" exec abyss-tofastq -i "${query[@]}" \ |$bwa_aln $target - \ |bwa samse $target - <(abyss-tofastq -i "${query[@]}")