annotate fastx_barcode_splitter_galaxy_wrapper.sh @ 3:8abdedf55101 draft

planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/fastx_toolkit/fastx_barcode_splitter commit a1517c9d22029095120643bbe2c8fa53754dd2b7
author devteam
date Wed, 11 Nov 2015 12:38:37 -0500
parents a12850d0559b
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a12850d0559b Uploaded tool tarball.
devteam
parents:
diff changeset
1 #!/bin/bash
a12850d0559b Uploaded tool tarball.
devteam
parents:
diff changeset
2
a12850d0559b Uploaded tool tarball.
devteam
parents:
diff changeset
3 # FASTX-toolkit - FASTA/FASTQ preprocessing tools.
a12850d0559b Uploaded tool tarball.
devteam
parents:
diff changeset
4 # Copyright (C) 2009 A. Gordon (gordon@cshl.edu)
a12850d0559b Uploaded tool tarball.
devteam
parents:
diff changeset
5 #
a12850d0559b Uploaded tool tarball.
devteam
parents:
diff changeset
6 # This program is free software: you can redistribute it and/or modify
a12850d0559b Uploaded tool tarball.
devteam
parents:
diff changeset
7 # it under the terms of the GNU Affero General Public License as
a12850d0559b Uploaded tool tarball.
devteam
parents:
diff changeset
8 # published by the Free Software Foundation, either version 3 of the
a12850d0559b Uploaded tool tarball.
devteam
parents:
diff changeset
9 # License, or (at your option) any later version.
a12850d0559b Uploaded tool tarball.
devteam
parents:
diff changeset
10 #
a12850d0559b Uploaded tool tarball.
devteam
parents:
diff changeset
11 # This program is distributed in the hope that it will be useful,
a12850d0559b Uploaded tool tarball.
devteam
parents:
diff changeset
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
a12850d0559b Uploaded tool tarball.
devteam
parents:
diff changeset
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
a12850d0559b Uploaded tool tarball.
devteam
parents:
diff changeset
14 # GNU Affero General Public License for more details.
a12850d0559b Uploaded tool tarball.
devteam
parents:
diff changeset
15 #
a12850d0559b Uploaded tool tarball.
devteam
parents:
diff changeset
16 # You should have received a copy of the GNU Affero General Public License
a12850d0559b Uploaded tool tarball.
devteam
parents:
diff changeset
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
a12850d0559b Uploaded tool tarball.
devteam
parents:
diff changeset
18
a12850d0559b Uploaded tool tarball.
devteam
parents:
diff changeset
19 #
a12850d0559b Uploaded tool tarball.
devteam
parents:
diff changeset
20 #This is a shell script wrapper for 'fastx_barcode_splitter.pl'
a12850d0559b Uploaded tool tarball.
devteam
parents:
diff changeset
21 #
a12850d0559b Uploaded tool tarball.
devteam
parents:
diff changeset
22 # 1. Output files are saved at the dataset's files_path directory.
a12850d0559b Uploaded tool tarball.
devteam
parents:
diff changeset
23 #
a12850d0559b Uploaded tool tarball.
devteam
parents:
diff changeset
24 # 2. 'fastx_barcode_splitter.pl' outputs a textual table.
a12850d0559b Uploaded tool tarball.
devteam
parents:
diff changeset
25 # This script turns it into pretty HTML with working URL
a12850d0559b Uploaded tool tarball.
devteam
parents:
diff changeset
26 # (so lazy users can just click on the URLs and get their files)
a12850d0559b Uploaded tool tarball.
devteam
parents:
diff changeset
27
a12850d0559b Uploaded tool tarball.
devteam
parents:
diff changeset
28 BARCODE_FILE="$1"
a12850d0559b Uploaded tool tarball.
devteam
parents:
diff changeset
29 FASTQ_FILE="$2"
a12850d0559b Uploaded tool tarball.
devteam
parents:
diff changeset
30 LIBNAME="$3"
a12850d0559b Uploaded tool tarball.
devteam
parents:
diff changeset
31 OUTPUT_PATH="$4"
a12850d0559b Uploaded tool tarball.
devteam
parents:
diff changeset
32 shift 4
a12850d0559b Uploaded tool tarball.
devteam
parents:
diff changeset
33 # The rest of the parameters are passed to the split program
a12850d0559b Uploaded tool tarball.
devteam
parents:
diff changeset
34
a12850d0559b Uploaded tool tarball.
devteam
parents:
diff changeset
35 if [ "$OUTPUT_PATH" == "" ]; then
a12850d0559b Uploaded tool tarball.
devteam
parents:
diff changeset
36 echo "Usage: $0 [BARCODE FILE] [FASTQ FILE] [LIBRARY_NAME] [OUTPUT_PATH]" >&2
a12850d0559b Uploaded tool tarball.
devteam
parents:
diff changeset
37 exit 1
a12850d0559b Uploaded tool tarball.
devteam
parents:
diff changeset
38 fi
a12850d0559b Uploaded tool tarball.
devteam
parents:
diff changeset
39
a12850d0559b Uploaded tool tarball.
devteam
parents:
diff changeset
40 #Sanitize library name, make sure we can create a file with this name
a12850d0559b Uploaded tool tarball.
devteam
parents:
diff changeset
41 LIBNAME=${LIBNAME//\.gz/}
a12850d0559b Uploaded tool tarball.
devteam
parents:
diff changeset
42 LIBNAME=${LIBNAME//\.txt/}
a12850d0559b Uploaded tool tarball.
devteam
parents:
diff changeset
43 LIBNAME=${LIBNAME//[^[:alnum:]]/_}
a12850d0559b Uploaded tool tarball.
devteam
parents:
diff changeset
44
a12850d0559b Uploaded tool tarball.
devteam
parents:
diff changeset
45 if [ ! -r "$FASTQ_FILE" ]; then
a12850d0559b Uploaded tool tarball.
devteam
parents:
diff changeset
46 echo "Error: Input file ($FASTQ_FILE) not found!" >&2
a12850d0559b Uploaded tool tarball.
devteam
parents:
diff changeset
47 exit 1
a12850d0559b Uploaded tool tarball.
devteam
parents:
diff changeset
48 fi
a12850d0559b Uploaded tool tarball.
devteam
parents:
diff changeset
49 if [ ! -r "$BARCODE_FILE" ]; then
a12850d0559b Uploaded tool tarball.
devteam
parents:
diff changeset
50 echo "Error: barcode file ($BARCODE_FILE) not found!" >&2
a12850d0559b Uploaded tool tarball.
devteam
parents:
diff changeset
51 exit 1
a12850d0559b Uploaded tool tarball.
devteam
parents:
diff changeset
52 fi
a12850d0559b Uploaded tool tarball.
devteam
parents:
diff changeset
53 mkdir -p "$OUTPUT_PATH"
a12850d0559b Uploaded tool tarball.
devteam
parents:
diff changeset
54 if [ ! -d "$OUTPUT_PATH" ]; then
a12850d0559b Uploaded tool tarball.
devteam
parents:
diff changeset
55 echo "Error: failed to create output path '$OUTPUT_PATH'" >&2
a12850d0559b Uploaded tool tarball.
devteam
parents:
diff changeset
56 exit 1
a12850d0559b Uploaded tool tarball.
devteam
parents:
diff changeset
57 fi
a12850d0559b Uploaded tool tarball.
devteam
parents:
diff changeset
58
a12850d0559b Uploaded tool tarball.
devteam
parents:
diff changeset
59 PUBLICURL=""
a12850d0559b Uploaded tool tarball.
devteam
parents:
diff changeset
60 BASEPATH="$OUTPUT_PATH/"
a12850d0559b Uploaded tool tarball.
devteam
parents:
diff changeset
61 #PREFIX="$BASEPATH"`date "+%Y-%m-%d_%H%M__"`"${LIBNAME}__"
a12850d0559b Uploaded tool tarball.
devteam
parents:
diff changeset
62 PREFIX="$BASEPATH""${LIBNAME}__"
a12850d0559b Uploaded tool tarball.
devteam
parents:
diff changeset
63 SUFFIX=".txt"
a12850d0559b Uploaded tool tarball.
devteam
parents:
diff changeset
64
3
8abdedf55101 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/fastx_toolkit/fastx_barcode_splitter commit a1517c9d22029095120643bbe2c8fa53754dd2b7
devteam
parents: 0
diff changeset
65 RESULTS=`zcat -f < "$FASTQ_FILE" | fastx_barcode_splitter.pl --bcfile "$BARCODE_FILE" --prefix "$PREFIX" --suffix "$SUFFIX" "$@"`
0
a12850d0559b Uploaded tool tarball.
devteam
parents:
diff changeset
66 if [ $? != 0 ]; then
a12850d0559b Uploaded tool tarball.
devteam
parents:
diff changeset
67 echo "error"
a12850d0559b Uploaded tool tarball.
devteam
parents:
diff changeset
68 fi
a12850d0559b Uploaded tool tarball.
devteam
parents:
diff changeset
69
a12850d0559b Uploaded tool tarball.
devteam
parents:
diff changeset
70 #
a12850d0559b Uploaded tool tarball.
devteam
parents:
diff changeset
71 # Convert the textual tab-separated table into simple HTML table,
a12850d0559b Uploaded tool tarball.
devteam
parents:
diff changeset
72 # with the local path replaces with a valid URL
a12850d0559b Uploaded tool tarball.
devteam
parents:
diff changeset
73 echo "<html><body><table border=1>"
a12850d0559b Uploaded tool tarball.
devteam
parents:
diff changeset
74 echo "$RESULTS" | sed -r "s|$BASEPATH(.*)|<a href=\"\\1\">\\1</a>|" | sed '
a12850d0559b Uploaded tool tarball.
devteam
parents:
diff changeset
75 i<tr><td>
a12850d0559b Uploaded tool tarball.
devteam
parents:
diff changeset
76 s|\t|</td><td>|g
a12850d0559b Uploaded tool tarball.
devteam
parents:
diff changeset
77 a<\/td><\/tr>
a12850d0559b Uploaded tool tarball.
devteam
parents:
diff changeset
78 '
a12850d0559b Uploaded tool tarball.
devteam
parents:
diff changeset
79 echo "<p>"
a12850d0559b Uploaded tool tarball.
devteam
parents:
diff changeset
80 echo "</table></body></html>"