Mercurial > repos > lparsons > fastx_barcode_splitter_enhanced
comparison 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 |
comparison
equal
deleted
inserted
replaced
3:e7b7cdc1834d | 4:0fb7e9130a70 |
---|---|
15 # | 15 # |
16 # You should have received a copy of the GNU Affero General Public License | 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/>. | 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 # 2015-11-13 Removed LIBRARY_NAME, no longer needed | 22 # 2015-11-13 Removed LIBRARY_NAME, no longer needed |
23 # 2016-04-28 Output summary as simple tabular output | |
23 | 24 |
24 #This is a shell script wrapper for 'fastx_barcode_splitter.pl' | 25 # This is a shell script wrapper for 'fastx_barcode_splitter.pl' |
25 # | 26 # |
26 # 1. Output files are saved at the dataset's files_path directory. | 27 # 1. Output files are saved at the dataset's files_path directory. |
27 # | |
28 # 2. 'fastx_barcode_splitter.pl' outputs a textual table. | |
29 # This script turns it into pretty HTML with working URL | |
30 # (so lazy users can just click on the URLs and get their files) | |
31 | 28 |
32 if [ "$1x" = "x" ]; then | 29 if [ "$1x" = "x" ]; then |
33 echo "Usage: $0 [BARCODE FILE] [FASTQ FILE] [OUTPUT_PATH] [FILETYPE]" >&2 | 30 echo "Usage: $0 [BARCODE FILE] [FASTQ FILE] [OUTPUT_PATH] [FILETYPE]" >&2 |
34 exit 1 | 31 exit 1 |
35 fi | 32 fi |
36 | 33 |
37 BARCODE_FILE="$1" | 34 BARCODE_FILE="$1" |
38 FASTQ_FILE="$2" | 35 FASTQ_FILE="$2" |
39 OUTPUT_PATH="$3" | 36 OUTPUT_PATH="$3" |
40 FILETYPE="$4" | 37 FILETYPE="$4" |
41 shift 4 | 38 shift 4 |
42 # The rest of the parameters are passed to the split program | 39 # The rest of the parameters are passed to the split program |
43 | 40 |
44 if [ "${OUTPUT_PATH}x" = "x" ]; then | 41 if [ "${OUTPUT_PATH}x" = "x" ]; then |
45 echo "Usage: $0 [BARCODE FILE] [FASTQ FILE] [OUTPUT_PATH] [FILETYPE]" >&2 | 42 echo "Usage: $0 [BARCODE FILE] [FASTQ FILE] [OUTPUT_PATH] [FILETYPE]" >&2 |
46 exit 1 | 43 exit 1 |
47 fi | 44 fi |
48 | 45 |
49 if [ ! -r "$FASTQ_FILE" ]; then | 46 if [ ! -r "$FASTQ_FILE" ]; then |
50 echo "Error: Input file ($FASTQ_FILE) not found!" >&2 | 47 echo "Error: Input file ($FASTQ_FILE) not found!" >&2 |
51 exit 1 | 48 exit 1 |
52 fi | 49 fi |
53 if [ ! -r "$BARCODE_FILE" ]; then | 50 if [ ! -r "$BARCODE_FILE" ]; then |
54 echo "Error: barcode file ($BARCODE_FILE) not found!" >&2 | 51 echo "Error: barcode file ($BARCODE_FILE) not found!" >&2 |
55 exit 1 | 52 exit 1 |
56 fi | 53 fi |
57 mkdir -p "$OUTPUT_PATH" | 54 mkdir -p "$OUTPUT_PATH" |
58 if [ ! -d "$OUTPUT_PATH" ]; then | 55 if [ ! -d "$OUTPUT_PATH" ]; then |
59 echo "Error: failed to create output path '$OUTPUT_PATH'" >&2 | 56 echo "Error: failed to create output path '$OUTPUT_PATH'" >&2 |
60 exit 1 | 57 exit 1 |
61 fi | 58 fi |
62 | 59 |
63 BASEPATH="$OUTPUT_PATH/" | 60 BASEPATH="$OUTPUT_PATH/" |
64 PREFIX="$BASEPATH" | 61 PREFIX="$BASEPATH" |
65 SUFFIX=".$FILETYPE" | 62 SUFFIX=".$FILETYPE" |
66 DIRECTORY="$(cd "$(dirname "$0")" && pwd)" | 63 DIRECTORY="$(cd "$(dirname "$0")" && pwd)" |
67 | 64 |
68 RESULTS=$(gzip -cdf "$FASTQ_FILE" | "$DIRECTORY/fastx_barcode_splitter.pl" --bcfile "$BARCODE_FILE" --prefix "$PREFIX" --suffix "$SUFFIX" "$@") | 65 RESULTS=$(gzip -cdf "$FASTQ_FILE" | "$DIRECTORY/fastx_barcode_splitter.pl" --bcfile "$BARCODE_FILE" --prefix "$PREFIX" --suffix "$SUFFIX" "$@") |
69 if [ $? != 0 ]; then | 66 if [ $? != 0 ]; then |
70 echo "error" | 67 echo "error" |
71 fi | 68 fi |
72 | 69 |
73 # | 70 echo "$RESULTS" |
74 # Convert the textual tab-separated table into simple HTML table | |
75 echo "<html><body><table border=1>" | |
76 echo "$RESULTS" | sed "s|$BASEPATH\\(.*\\)|\\1|" | \ | |
77 perl -n -e '$_ =~ s|\t|</td><td>|g; print "<tr><td>\n$_</td></tr>\n"' | |
78 echo "<p>" | |
79 echo "</table></body></html>" |