Mercurial > repos > lparsons > fastx_barcode_splitter_enhanced
comparison fastx_barcode_splitter_galaxy_wrapper.sh @ 2:32304398ef67 draft
planemo upload for repository https://github.com/lparsons/galaxy_tools/tree/master/tools/fastx_barcode_splitter_enhanced commit c3b0be52079831f6ae58ff64e42d8ff54ce501e4
author | lparsons |
---|---|
date | Fri, 13 Nov 2015 12:43:14 -0500 |
parents | b7b3d008e2d3 |
children | 0fb7e9130a70 |
comparison
equal
deleted
inserted
replaced
1:b7b3d008e2d3 | 2:32304398ef67 |
---|---|
17 # along with this program. If not, see <http://www.gnu.org/licenses/>. | 17 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
18 | 18 |
19 # Modified by Lance Parsons (lparsons@princeton.edu) | 19 # Modified by Lance Parsons (lparsons@princeton.edu) |
20 # 2011-03-15 Adapted to allow galaxy to determine filetype | 20 # 2011-03-15 Adapted to allow galaxy to determine filetype |
21 # 2015-10-21 Updated to make compatible with OSX (BSD sed) | 21 # 2015-10-21 Updated to make compatible with OSX (BSD sed) |
22 # | 22 # 2015-11-13 Removed LIBRARY_NAME, no longer needed |
23 | |
23 #This is a shell script wrapper for 'fastx_barcode_splitter.pl' | 24 #This is a shell script wrapper for 'fastx_barcode_splitter.pl' |
24 # | 25 # |
25 # 1. Output files are saved at the dataset's files_path directory. | 26 # 1. Output files are saved at the dataset's files_path directory. |
26 # | 27 # |
27 # 2. 'fastx_barcode_splitter.pl' outputs a textual table. | 28 # 2. 'fastx_barcode_splitter.pl' outputs a textual table. |
28 # This script turns it into pretty HTML with working URL | 29 # 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 # (so lazy users can just click on the URLs and get their files) |
30 | 31 |
31 if [ "$1x" = "x" ]; then | 32 if [ "$1x" = "x" ]; then |
32 echo "Usage: $0 [BARCODE FILE] [FASTQ FILE] [LIBRARY_NAME] [OUTPUT_PATH] [FILETYPE]" >&2 | 33 echo "Usage: $0 [BARCODE FILE] [FASTQ FILE] [OUTPUT_PATH] [FILETYPE]" >&2 |
33 exit 1 | 34 exit 1 |
34 fi | 35 fi |
35 | 36 |
36 BARCODE_FILE="$1" | 37 BARCODE_FILE="$1" |
37 FASTQ_FILE="$2" | 38 FASTQ_FILE="$2" |
38 LIBNAME="$3" | 39 OUTPUT_PATH="$3" |
39 OUTPUT_PATH="$4" | 40 FILETYPE="$4" |
40 FILETYPE="$5" | 41 shift 4 |
41 shift 5 | |
42 # The rest of the parameters are passed to the split program | 42 # The rest of the parameters are passed to the split program |
43 | 43 |
44 if [ "${OUTPUT_PATH}x" = "x" ]; then | 44 if [ "${OUTPUT_PATH}x" = "x" ]; then |
45 echo "Usage: $0 [BARCODE FILE] [FASTQ FILE] [LIBRARY_NAME] [OUTPUT_PATH] [FILETYPE]" >&2 | 45 echo "Usage: $0 [BARCODE FILE] [FASTQ FILE] [OUTPUT_PATH] [FILETYPE]" >&2 |
46 exit 1 | 46 exit 1 |
47 fi | 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 | 48 |
54 if [ ! -r "$FASTQ_FILE" ]; then | 49 if [ ! -r "$FASTQ_FILE" ]; then |
55 echo "Error: Input file ($FASTQ_FILE) not found!" >&2 | 50 echo "Error: Input file ($FASTQ_FILE) not found!" >&2 |
56 exit 1 | 51 exit 1 |
57 fi | 52 fi |
63 if [ ! -d "$OUTPUT_PATH" ]; then | 58 if [ ! -d "$OUTPUT_PATH" ]; then |
64 echo "Error: failed to create output path '$OUTPUT_PATH'" >&2 | 59 echo "Error: failed to create output path '$OUTPUT_PATH'" >&2 |
65 exit 1 | 60 exit 1 |
66 fi | 61 fi |
67 | 62 |
68 PUBLICURL="" | |
69 BASEPATH="$OUTPUT_PATH/" | 63 BASEPATH="$OUTPUT_PATH/" |
70 #PREFIX="$BASEPATH"`date "+%Y-%m-%d_%H%M__"`"${LIBNAME}__" | 64 PREFIX="$BASEPATH" |
71 PREFIX="$BASEPATH""${LIBNAME}_" | 65 SUFFIX=".$FILETYPE" |
72 SUFFIX="_visible.$FILETYPE" | 66 DIRECTORY="$(cd "$(dirname "$0")" && pwd)" |
73 DIRECTORY=$(cd `dirname $0` && pwd) | |
74 | 67 |
75 RESULTS=`gzip -cdf "$FASTQ_FILE" | $DIRECTORY/fastx_barcode_splitter.pl --bcfile "$BARCODE_FILE" --prefix "$PREFIX" --suffix "$SUFFIX" "$@"` | 68 RESULTS=$(gzip -cdf "$FASTQ_FILE" | "$DIRECTORY/fastx_barcode_splitter.pl" --bcfile "$BARCODE_FILE" --prefix "$PREFIX" --suffix "$SUFFIX" "$@") |
76 if [ $? != 0 ]; then | 69 if [ $? != 0 ]; then |
77 echo "error" | 70 echo "error" |
78 fi | 71 fi |
79 | 72 |
80 # | 73 # |
81 # Convert the textual tab-separated table into simple HTML table, | 74 # 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 | |
84 echo "<html><body><table border=1>" | 75 echo "<html><body><table border=1>" |
85 echo "$RESULTS" | sed "s|$BASEPATH\\(.*\\)|<a href=\"\\1\">\\1</a>|" | \ | 76 echo "$RESULTS" | sed "s|$BASEPATH\\(.*\\)|\\1|" | \ |
86 perl -n -e '$_ =~ s|\t|</td><td>|g; print "<tr><td>\n$_</td></tr>\n"' | 77 perl -n -e '$_ =~ s|\t|</td><td>|g; print "<tr><td>\n$_</td></tr>\n"' |
87 echo "<p>" | 78 echo "<p>" |
88 echo "</table></body></html>" | 79 echo "</table></body></html>" |