Mercurial > repos > lparsons > fastx_barcode_splitter_enhanced
annotate fastx_barcode_splitter_galaxy_wrapper.sh @ 6:51e098891465 draft
planemo upload for repository https://github.com/lparsons/galaxy_tools/tree/master/tools/fastx_barcode_splitter_enhanced commit e6a486662201362134119c0ddc7151b8dd181ebd
| author | lparsons |
|---|---|
| date | Tue, 27 Oct 2015 11:46:21 -0400 |
| parents | 80e84db1c392 |
| children | 06ebd94d80ae |
| rev | line source |
|---|---|
| 4 | 1 #!/bin/bash |
| 2 | |
| 3 # FASTX-toolkit - FASTA/FASTQ preprocessing tools. | |
| 4 # Copyright (C) 2009 A. Gordon (gordon@cshl.edu) | |
| 5 # | |
| 6 # This program is free software: you can redistribute it and/or modify | |
| 7 # it under the terms of the GNU Affero General Public License as | |
| 8 # published by the Free Software Foundation, either version 3 of the | |
| 9 # License, or (at your option) any later version. | |
| 10 # | |
| 11 # This program is distributed in the hope that it will be useful, | |
| 12 # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 14 # GNU Affero General Public License for more details. | |
| 15 # | |
| 16 # You should have received a copy of the GNU Affero General Public License | |
| 17 # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
| 18 | |
| 19 # Modified by Lance Parsons (lparsons@princeton.edu) | |
| 20 # 2011-03-15 Adapted to allow galaxy to determine filetype | |
|
5
80e84db1c392
planemo upload for repository https://github.com/lparsons/galaxy_tools/tree/master/tools/fastx_barcode_splitter_enhanced commit 9ece31c748369db47d9817066cb91e6f3e8428c8-dirty
lparsons
parents:
4
diff
changeset
|
21 # 2015-10-21 Updated to make compatible with OSX (BSD sed) |
| 4 | 22 # |
| 23 #This is a shell script wrapper for 'fastx_barcode_splitter.pl' | |
| 24 # | |
| 25 # 1. Output files are saved at the dataset's files_path directory. | |
|
5
80e84db1c392
planemo upload for repository https://github.com/lparsons/galaxy_tools/tree/master/tools/fastx_barcode_splitter_enhanced commit 9ece31c748369db47d9817066cb91e6f3e8428c8-dirty
lparsons
parents:
4
diff
changeset
|
26 # |
| 4 | 27 # 2. 'fastx_barcode_splitter.pl' outputs a textual table. |
| 28 # This script turns it into pretty HTML with working URL | |
| 29 # (so lazy users can just click on the URLs and get their files) | |
| 30 | |
| 31 if [ "$1x" = "x" ]; then | |
| 32 echo "Usage: $0 [BARCODE FILE] [FASTQ FILE] [LIBRARY_NAME] [OUTPUT_PATH] [FILETYPE]" >&2 | |
| 33 exit 1 | |
| 34 fi | |
| 35 | |
| 36 BARCODE_FILE="$1" | |
| 37 FASTQ_FILE="$2" | |
| 38 LIBNAME="$3" | |
| 39 OUTPUT_PATH="$4" | |
| 40 FILETYPE="$5" | |
| 41 shift 5 | |
| 42 # The rest of the parameters are passed to the split program | |
| 43 | |
| 44 if [ "${OUTPUT_PATH}x" = "x" ]; then | |
| 45 echo "Usage: $0 [BARCODE FILE] [FASTQ FILE] [LIBRARY_NAME] [OUTPUT_PATH] [FILETYPE]" >&2 | |
| 46 exit 1 | |
| 47 fi | |
| 48 | |
| 49 #Sanitize library name, make sure we can create a file with this name | |
| 50 LIBNAME=${LIBNAME%.gz} | |
| 51 LIBNAME=${LIBNAME%.txt} | |
| 52 LIBNAME=$(echo "$LIBNAME" | tr -cd '[:alnum:]_') | |
| 53 | |
| 54 if [ ! -r "$FASTQ_FILE" ]; then | |
| 55 echo "Error: Input file ($FASTQ_FILE) not found!" >&2 | |
| 56 exit 1 | |
| 57 fi | |
| 58 if [ ! -r "$BARCODE_FILE" ]; then | |
| 59 echo "Error: barcode file ($BARCODE_FILE) not found!" >&2 | |
| 60 exit 1 | |
| 61 fi | |
| 62 mkdir -p "$OUTPUT_PATH" | |
| 63 if [ ! -d "$OUTPUT_PATH" ]; then | |
| 64 echo "Error: failed to create output path '$OUTPUT_PATH'" >&2 | |
| 65 exit 1 | |
| 66 fi | |
| 67 | |
| 68 PUBLICURL="" | |
| 69 BASEPATH="$OUTPUT_PATH/" | |
| 70 #PREFIX="$BASEPATH"`date "+%Y-%m-%d_%H%M__"`"${LIBNAME}__" | |
| 71 PREFIX="$BASEPATH""${LIBNAME}_" | |
|
5
80e84db1c392
planemo upload for repository https://github.com/lparsons/galaxy_tools/tree/master/tools/fastx_barcode_splitter_enhanced commit 9ece31c748369db47d9817066cb91e6f3e8428c8-dirty
lparsons
parents:
4
diff
changeset
|
72 SUFFIX="_visible.$FILETYPE" |
| 4 | 73 DIRECTORY=$(cd `dirname $0` && pwd) |
| 74 | |
| 75 RESULTS=`gzip -cdf "$FASTQ_FILE" | $DIRECTORY/fastx_barcode_splitter.pl --bcfile "$BARCODE_FILE" --prefix "$PREFIX" --suffix "$SUFFIX" "$@"` | |
| 76 if [ $? != 0 ]; then | |
| 77 echo "error" | |
| 78 fi | |
| 79 | |
| 80 # | |
| 81 # Convert the textual tab-separated table into simple HTML table, | |
| 82 # with the local path replaces with a valid URL | |
| 83 #HTMLSUMMARY=${PREFIX}stats_visible_html | |
|
5
80e84db1c392
planemo upload for repository https://github.com/lparsons/galaxy_tools/tree/master/tools/fastx_barcode_splitter_enhanced commit 9ece31c748369db47d9817066cb91e6f3e8428c8-dirty
lparsons
parents:
4
diff
changeset
|
84 echo "<html><body><table border=1>" |
|
6
51e098891465
planemo upload for repository https://github.com/lparsons/galaxy_tools/tree/master/tools/fastx_barcode_splitter_enhanced commit e6a486662201362134119c0ddc7151b8dd181ebd
lparsons
parents:
5
diff
changeset
|
85 echo "$RESULTS" | sed "s|$BASEPATH\\(.*\\)|<a href=\"\\1\">\\1</a>|" | \ |
|
51e098891465
planemo upload for repository https://github.com/lparsons/galaxy_tools/tree/master/tools/fastx_barcode_splitter_enhanced commit e6a486662201362134119c0ddc7151b8dd181ebd
lparsons
parents:
5
diff
changeset
|
86 perl -n -e '$_ =~ s|\t|</td><td>|g; print "<tr><td>\n$_</td></tr>\n"' |
| 4 | 87 echo "<p>" |
| 88 echo "</table></body></html>" |
