Mercurial > repos > lparsons > fastx_barcode_splitter_enhanced
annotate fastx_barcode_splitter_galaxy_wrapper.sh @ 4:0fb7e9130a70 draft default tip
planemo upload for repository https://github.com/lparsons/galaxy_tools/tree/master/tools/fastx_barcode_splitter_enhanced commit 460463a5406419fe8e113467bdb8bd093d21e7c5
author | lparsons |
---|---|
date | Mon, 02 May 2016 17:04:32 -0400 |
parents | 32304398ef67 |
children |
rev | line source |
---|---|
0
84bbf4fd24c3
Initial toolshed version with support for separate index reads and automatic loading of results into Galaxy history.
lparsons
parents:
diff
changeset
|
1 #!/bin/bash |
84bbf4fd24c3
Initial toolshed version with support for separate index reads and automatic loading of results into Galaxy history.
lparsons
parents:
diff
changeset
|
2 |
84bbf4fd24c3
Initial toolshed version with support for separate index reads and automatic loading of results into Galaxy history.
lparsons
parents:
diff
changeset
|
3 # FASTX-toolkit - FASTA/FASTQ preprocessing tools. |
84bbf4fd24c3
Initial toolshed version with support for separate index reads and automatic loading of results into Galaxy history.
lparsons
parents:
diff
changeset
|
4 # Copyright (C) 2009 A. Gordon (gordon@cshl.edu) |
84bbf4fd24c3
Initial toolshed version with support for separate index reads and automatic loading of results into Galaxy history.
lparsons
parents:
diff
changeset
|
5 # |
84bbf4fd24c3
Initial toolshed version with support for separate index reads and automatic loading of results into Galaxy history.
lparsons
parents:
diff
changeset
|
6 # This program is free software: you can redistribute it and/or modify |
84bbf4fd24c3
Initial toolshed version with support for separate index reads and automatic loading of results into Galaxy history.
lparsons
parents:
diff
changeset
|
7 # it under the terms of the GNU Affero General Public License as |
84bbf4fd24c3
Initial toolshed version with support for separate index reads and automatic loading of results into Galaxy history.
lparsons
parents:
diff
changeset
|
8 # published by the Free Software Foundation, either version 3 of the |
84bbf4fd24c3
Initial toolshed version with support for separate index reads and automatic loading of results into Galaxy history.
lparsons
parents:
diff
changeset
|
9 # License, or (at your option) any later version. |
84bbf4fd24c3
Initial toolshed version with support for separate index reads and automatic loading of results into Galaxy history.
lparsons
parents:
diff
changeset
|
10 # |
84bbf4fd24c3
Initial toolshed version with support for separate index reads and automatic loading of results into Galaxy history.
lparsons
parents:
diff
changeset
|
11 # This program is distributed in the hope that it will be useful, |
84bbf4fd24c3
Initial toolshed version with support for separate index reads and automatic loading of results into Galaxy history.
lparsons
parents:
diff
changeset
|
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
84bbf4fd24c3
Initial toolshed version with support for separate index reads and automatic loading of results into Galaxy history.
lparsons
parents:
diff
changeset
|
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
84bbf4fd24c3
Initial toolshed version with support for separate index reads and automatic loading of results into Galaxy history.
lparsons
parents:
diff
changeset
|
14 # GNU Affero General Public License for more details. |
84bbf4fd24c3
Initial toolshed version with support for separate index reads and automatic loading of results into Galaxy history.
lparsons
parents:
diff
changeset
|
15 # |
84bbf4fd24c3
Initial toolshed version with support for separate index reads and automatic loading of results into Galaxy history.
lparsons
parents:
diff
changeset
|
16 # You should have received a copy of the GNU Affero General Public License |
84bbf4fd24c3
Initial toolshed version with support for separate index reads and automatic loading of results into Galaxy history.
lparsons
parents:
diff
changeset
|
17 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
84bbf4fd24c3
Initial toolshed version with support for separate index reads and automatic loading of results into Galaxy history.
lparsons
parents:
diff
changeset
|
18 |
84bbf4fd24c3
Initial toolshed version with support for separate index reads and automatic loading of results into Galaxy history.
lparsons
parents:
diff
changeset
|
19 # Modified by Lance Parsons (lparsons@princeton.edu) |
4
0fb7e9130a70
planemo upload for repository https://github.com/lparsons/galaxy_tools/tree/master/tools/fastx_barcode_splitter_enhanced commit 460463a5406419fe8e113467bdb8bd093d21e7c5
lparsons
parents:
2
diff
changeset
|
20 # 2011-03-15 Adapted to allow galaxy to determine filetype |
0fb7e9130a70
planemo upload for repository https://github.com/lparsons/galaxy_tools/tree/master/tools/fastx_barcode_splitter_enhanced commit 460463a5406419fe8e113467bdb8bd093d21e7c5
lparsons
parents:
2
diff
changeset
|
21 # 2015-10-21 Updated to make compatible with OSX (BSD sed) |
0fb7e9130a70
planemo upload for repository https://github.com/lparsons/galaxy_tools/tree/master/tools/fastx_barcode_splitter_enhanced commit 460463a5406419fe8e113467bdb8bd093d21e7c5
lparsons
parents:
2
diff
changeset
|
22 # 2015-11-13 Removed LIBRARY_NAME, no longer needed |
0fb7e9130a70
planemo upload for repository https://github.com/lparsons/galaxy_tools/tree/master/tools/fastx_barcode_splitter_enhanced commit 460463a5406419fe8e113467bdb8bd093d21e7c5
lparsons
parents:
2
diff
changeset
|
23 # 2016-04-28 Output summary as simple tabular output |
2
32304398ef67
planemo upload for repository https://github.com/lparsons/galaxy_tools/tree/master/tools/fastx_barcode_splitter_enhanced commit c3b0be52079831f6ae58ff64e42d8ff54ce501e4
lparsons
parents:
1
diff
changeset
|
24 |
4
0fb7e9130a70
planemo upload for repository https://github.com/lparsons/galaxy_tools/tree/master/tools/fastx_barcode_splitter_enhanced commit 460463a5406419fe8e113467bdb8bd093d21e7c5
lparsons
parents:
2
diff
changeset
|
25 # This is a shell script wrapper for 'fastx_barcode_splitter.pl' |
0
84bbf4fd24c3
Initial toolshed version with support for separate index reads and automatic loading of results into Galaxy history.
lparsons
parents:
diff
changeset
|
26 # |
84bbf4fd24c3
Initial toolshed version with support for separate index reads and automatic loading of results into Galaxy history.
lparsons
parents:
diff
changeset
|
27 # 1. Output files are saved at the dataset's files_path directory. |
84bbf4fd24c3
Initial toolshed version with support for separate index reads and automatic loading of results into Galaxy history.
lparsons
parents:
diff
changeset
|
28 |
84bbf4fd24c3
Initial toolshed version with support for separate index reads and automatic loading of results into Galaxy history.
lparsons
parents:
diff
changeset
|
29 if [ "$1x" = "x" ]; then |
4
0fb7e9130a70
planemo upload for repository https://github.com/lparsons/galaxy_tools/tree/master/tools/fastx_barcode_splitter_enhanced commit 460463a5406419fe8e113467bdb8bd093d21e7c5
lparsons
parents:
2
diff
changeset
|
30 echo "Usage: $0 [BARCODE FILE] [FASTQ FILE] [OUTPUT_PATH] [FILETYPE]" >&2 |
0fb7e9130a70
planemo upload for repository https://github.com/lparsons/galaxy_tools/tree/master/tools/fastx_barcode_splitter_enhanced commit 460463a5406419fe8e113467bdb8bd093d21e7c5
lparsons
parents:
2
diff
changeset
|
31 exit 1 |
0
84bbf4fd24c3
Initial toolshed version with support for separate index reads and automatic loading of results into Galaxy history.
lparsons
parents:
diff
changeset
|
32 fi |
84bbf4fd24c3
Initial toolshed version with support for separate index reads and automatic loading of results into Galaxy history.
lparsons
parents:
diff
changeset
|
33 |
84bbf4fd24c3
Initial toolshed version with support for separate index reads and automatic loading of results into Galaxy history.
lparsons
parents:
diff
changeset
|
34 BARCODE_FILE="$1" |
84bbf4fd24c3
Initial toolshed version with support for separate index reads and automatic loading of results into Galaxy history.
lparsons
parents:
diff
changeset
|
35 FASTQ_FILE="$2" |
2
32304398ef67
planemo upload for repository https://github.com/lparsons/galaxy_tools/tree/master/tools/fastx_barcode_splitter_enhanced commit c3b0be52079831f6ae58ff64e42d8ff54ce501e4
lparsons
parents:
1
diff
changeset
|
36 OUTPUT_PATH="$3" |
32304398ef67
planemo upload for repository https://github.com/lparsons/galaxy_tools/tree/master/tools/fastx_barcode_splitter_enhanced commit c3b0be52079831f6ae58ff64e42d8ff54ce501e4
lparsons
parents:
1
diff
changeset
|
37 FILETYPE="$4" |
32304398ef67
planemo upload for repository https://github.com/lparsons/galaxy_tools/tree/master/tools/fastx_barcode_splitter_enhanced commit c3b0be52079831f6ae58ff64e42d8ff54ce501e4
lparsons
parents:
1
diff
changeset
|
38 shift 4 |
0
84bbf4fd24c3
Initial toolshed version with support for separate index reads and automatic loading of results into Galaxy history.
lparsons
parents:
diff
changeset
|
39 # The rest of the parameters are passed to the split program |
84bbf4fd24c3
Initial toolshed version with support for separate index reads and automatic loading of results into Galaxy history.
lparsons
parents:
diff
changeset
|
40 |
84bbf4fd24c3
Initial toolshed version with support for separate index reads and automatic loading of results into Galaxy history.
lparsons
parents:
diff
changeset
|
41 if [ "${OUTPUT_PATH}x" = "x" ]; then |
4
0fb7e9130a70
planemo upload for repository https://github.com/lparsons/galaxy_tools/tree/master/tools/fastx_barcode_splitter_enhanced commit 460463a5406419fe8e113467bdb8bd093d21e7c5
lparsons
parents:
2
diff
changeset
|
42 echo "Usage: $0 [BARCODE FILE] [FASTQ FILE] [OUTPUT_PATH] [FILETYPE]" >&2 |
0fb7e9130a70
planemo upload for repository https://github.com/lparsons/galaxy_tools/tree/master/tools/fastx_barcode_splitter_enhanced commit 460463a5406419fe8e113467bdb8bd093d21e7c5
lparsons
parents:
2
diff
changeset
|
43 exit 1 |
0
84bbf4fd24c3
Initial toolshed version with support for separate index reads and automatic loading of results into Galaxy history.
lparsons
parents:
diff
changeset
|
44 fi |
84bbf4fd24c3
Initial toolshed version with support for separate index reads and automatic loading of results into Galaxy history.
lparsons
parents:
diff
changeset
|
45 |
84bbf4fd24c3
Initial toolshed version with support for separate index reads and automatic loading of results into Galaxy history.
lparsons
parents:
diff
changeset
|
46 if [ ! -r "$FASTQ_FILE" ]; then |
4
0fb7e9130a70
planemo upload for repository https://github.com/lparsons/galaxy_tools/tree/master/tools/fastx_barcode_splitter_enhanced commit 460463a5406419fe8e113467bdb8bd093d21e7c5
lparsons
parents:
2
diff
changeset
|
47 echo "Error: Input file ($FASTQ_FILE) not found!" >&2 |
0fb7e9130a70
planemo upload for repository https://github.com/lparsons/galaxy_tools/tree/master/tools/fastx_barcode_splitter_enhanced commit 460463a5406419fe8e113467bdb8bd093d21e7c5
lparsons
parents:
2
diff
changeset
|
48 exit 1 |
0
84bbf4fd24c3
Initial toolshed version with support for separate index reads and automatic loading of results into Galaxy history.
lparsons
parents:
diff
changeset
|
49 fi |
84bbf4fd24c3
Initial toolshed version with support for separate index reads and automatic loading of results into Galaxy history.
lparsons
parents:
diff
changeset
|
50 if [ ! -r "$BARCODE_FILE" ]; then |
4
0fb7e9130a70
planemo upload for repository https://github.com/lparsons/galaxy_tools/tree/master/tools/fastx_barcode_splitter_enhanced commit 460463a5406419fe8e113467bdb8bd093d21e7c5
lparsons
parents:
2
diff
changeset
|
51 echo "Error: barcode file ($BARCODE_FILE) not found!" >&2 |
0fb7e9130a70
planemo upload for repository https://github.com/lparsons/galaxy_tools/tree/master/tools/fastx_barcode_splitter_enhanced commit 460463a5406419fe8e113467bdb8bd093d21e7c5
lparsons
parents:
2
diff
changeset
|
52 exit 1 |
0
84bbf4fd24c3
Initial toolshed version with support for separate index reads and automatic loading of results into Galaxy history.
lparsons
parents:
diff
changeset
|
53 fi |
84bbf4fd24c3
Initial toolshed version with support for separate index reads and automatic loading of results into Galaxy history.
lparsons
parents:
diff
changeset
|
54 mkdir -p "$OUTPUT_PATH" |
84bbf4fd24c3
Initial toolshed version with support for separate index reads and automatic loading of results into Galaxy history.
lparsons
parents:
diff
changeset
|
55 if [ ! -d "$OUTPUT_PATH" ]; then |
4
0fb7e9130a70
planemo upload for repository https://github.com/lparsons/galaxy_tools/tree/master/tools/fastx_barcode_splitter_enhanced commit 460463a5406419fe8e113467bdb8bd093d21e7c5
lparsons
parents:
2
diff
changeset
|
56 echo "Error: failed to create output path '$OUTPUT_PATH'" >&2 |
0fb7e9130a70
planemo upload for repository https://github.com/lparsons/galaxy_tools/tree/master/tools/fastx_barcode_splitter_enhanced commit 460463a5406419fe8e113467bdb8bd093d21e7c5
lparsons
parents:
2
diff
changeset
|
57 exit 1 |
0
84bbf4fd24c3
Initial toolshed version with support for separate index reads and automatic loading of results into Galaxy history.
lparsons
parents:
diff
changeset
|
58 fi |
84bbf4fd24c3
Initial toolshed version with support for separate index reads and automatic loading of results into Galaxy history.
lparsons
parents:
diff
changeset
|
59 |
84bbf4fd24c3
Initial toolshed version with support for separate index reads and automatic loading of results into Galaxy history.
lparsons
parents:
diff
changeset
|
60 BASEPATH="$OUTPUT_PATH/" |
2
32304398ef67
planemo upload for repository https://github.com/lparsons/galaxy_tools/tree/master/tools/fastx_barcode_splitter_enhanced commit c3b0be52079831f6ae58ff64e42d8ff54ce501e4
lparsons
parents:
1
diff
changeset
|
61 PREFIX="$BASEPATH" |
32304398ef67
planemo upload for repository https://github.com/lparsons/galaxy_tools/tree/master/tools/fastx_barcode_splitter_enhanced commit c3b0be52079831f6ae58ff64e42d8ff54ce501e4
lparsons
parents:
1
diff
changeset
|
62 SUFFIX=".$FILETYPE" |
32304398ef67
planemo upload for repository https://github.com/lparsons/galaxy_tools/tree/master/tools/fastx_barcode_splitter_enhanced commit c3b0be52079831f6ae58ff64e42d8ff54ce501e4
lparsons
parents:
1
diff
changeset
|
63 DIRECTORY="$(cd "$(dirname "$0")" && pwd)" |
0
84bbf4fd24c3
Initial toolshed version with support for separate index reads and automatic loading of results into Galaxy history.
lparsons
parents:
diff
changeset
|
64 |
2
32304398ef67
planemo upload for repository https://github.com/lparsons/galaxy_tools/tree/master/tools/fastx_barcode_splitter_enhanced commit c3b0be52079831f6ae58ff64e42d8ff54ce501e4
lparsons
parents:
1
diff
changeset
|
65 RESULTS=$(gzip -cdf "$FASTQ_FILE" | "$DIRECTORY/fastx_barcode_splitter.pl" --bcfile "$BARCODE_FILE" --prefix "$PREFIX" --suffix "$SUFFIX" "$@") |
0
84bbf4fd24c3
Initial toolshed version with support for separate index reads and automatic loading of results into Galaxy history.
lparsons
parents:
diff
changeset
|
66 if [ $? != 0 ]; then |
4
0fb7e9130a70
planemo upload for repository https://github.com/lparsons/galaxy_tools/tree/master/tools/fastx_barcode_splitter_enhanced commit 460463a5406419fe8e113467bdb8bd093d21e7c5
lparsons
parents:
2
diff
changeset
|
67 echo "error" |
0
84bbf4fd24c3
Initial toolshed version with support for separate index reads and automatic loading of results into Galaxy history.
lparsons
parents:
diff
changeset
|
68 fi |
84bbf4fd24c3
Initial toolshed version with support for separate index reads and automatic loading of results into Galaxy history.
lparsons
parents:
diff
changeset
|
69 |
4
0fb7e9130a70
planemo upload for repository https://github.com/lparsons/galaxy_tools/tree/master/tools/fastx_barcode_splitter_enhanced commit 460463a5406419fe8e113467bdb8bd093d21e7c5
lparsons
parents:
2
diff
changeset
|
70 echo "$RESULTS" |