Debian Codegraph @

bin/abyss-bowtie

raw
1 #!/bin/bash
2 set -eu
3
4 case $1 in
5 --help)
6 cat <<EOF
7 Usage: abyss-bowtie [OPTION]... QUERY... TARGET
8 Align the sequences of the files QUERY to those of the file
9 TARGET using bowtie.
10 EOF
11 exit
12 ;;
13 --version)
14 cat <<EOF
15 abyss-bowtie (ABySS)
16 Written by Shaun Jackman.
17
18 EOF
19 bowtie --version
20 exit
21 ;;
22 esac
23
24 # Parse the command line.
25 bowtie='bowtie -S'
26 while getopts :j:l:v opt; do
27 case $opt in
28 j) bowtie="$bowtie -p$OPTARG";;
29 l) ;;
30 v) ;;
31 \?) echo >&2 "abyss-bowtie: invalid option: $OPTARG"; exit 1;;
32 esac
33 done
34 shift $((OPTIND-1))
35
36 query=("$@")
37 target=${query[${#query[@]}-1]}
38 unset query[${#query[@]}-1]
39 index=$target.1.ebwt
40
41 # Build the index.
42 if [ ! -r $index ]; then
43 echo >&2 "Building the index $index..."
44 echo >&2 bowtie-build $target $target
45 bowtie-build $target $target 1>&2
46 elif [ $index -ot $target ]; then
47 echo >&2 "The index $index is stale. Rebuilding the index..."
48 echo >&2 bowtie-build $target $target
49 bowtie-build $target $target 1>&2
50 else
51 echo >&2 "The index $index is up to date."
52 fi
53
54 # Map the reads.
55 echo >&2 $bowtie $target "${query[@]}"
56 exec abyss-tofastq -i "${query[@]}" |$bowtie $target -