root/galaxy-central/tools/fastx_toolkit/fastx_barcode_splitter_galaxy_wrapper.sh

リビジョン 2, 2.4 KB (コミッタ: hatakeyama, 14 年 前)

import galaxy-central

  • 属性 svn:executable の設定値 *
行番号 
1#!/bin/sh
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#
20#This is a shell script wrapper for 'fastx_barcode_splitter.pl'
21#
22# 1. Output files are saved at the dataset's files_path directory.
23#   
24# 2. 'fastx_barcode_splitter.pl' outputs a textual table.
25#    This script turns it into pretty HTML with working URL
26#    (so lazy users can just click on the URLs and get their files)
27
28BARCODE_FILE="$1"
29FASTQ_FILE="$2"
30LIBNAME="$3"
31OUTPUT_PATH="$4"
32shift 4
33# The rest of the parameters are passed to the split program
34
35if [ "$OUTPUT_PATH" == "" ]; then
36        echo "Usage: $0 [BARCODE FILE] [FASTQ FILE] [LIBRARY_NAME] [OUTPUT_PATH]" >&2
37        exit 1
38fi
39
40#Sanitize library name, make sure we can create a file with this name
41LIBNAME=${LIBNAME//\.gz/}
42LIBNAME=${LIBNAME//\.txt/}
43LIBNAME=${LIBNAME//[^[:alnum:]]/_}
44
45if [ ! -r "$FASTQ_FILE" ]; then
46        echo "Error: Input file ($FASTQ_FILE) not found!" >&2
47        exit 1
48fi
49if [ ! -r "$BARCODE_FILE" ]; then
50        echo "Error: barcode file ($BARCODE_FILE) not found!" >&2
51        exit 1
52fi
53mkdir -p "$OUTPUT_PATH"
54if [ ! -d "$OUTPUT_PATH" ]; then
55        echo "Error: failed to create output path '$OUTPUT_PATH'" >&2
56        exit 1
57fi
58
59PUBLICURL=""
60BASEPATH="$OUTPUT_PATH/"
61#PREFIX="$BASEPATH"`date "+%Y-%m-%d_%H%M__"`"${LIBNAME}__"
62PREFIX="$BASEPATH""${LIBNAME}__"
63SUFFIX=".txt"
64
65RESULTS=`zcat -f "$FASTQ_FILE" | fastx_barcode_splitter.pl --bcfile "$BARCODE_FILE" --prefix "$PREFIX" --suffix "$SUFFIX" "$@"`
66if [ $? != 0 ]; then
67        echo "error"
68fi
69
70#
71# Convert the textual tab-separated table into simple HTML table,
72# with the local path replaces with a valid URL
73echo "<html><body><table border=1>"
74echo "$RESULTS" | sed -r "s|$BASEPATH(.*)|<a href=\"\\1\">\\1</a>|" | sed '
75i<tr><td>
76s|\t|</td><td>|g
77a<\/td><\/tr>
78'
79echo "<p>"
80echo "</table></body></html>"
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。