annotate tools/unix_tools/join_tool.sh @ 0:9071e359b9a3

Uploaded
author xuebing
date Fri, 09 Mar 2012 19:37:19 -0500
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1 #!/bin/sh
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
3 #
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
4 # NOTE:
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
5 # This is a wrapper for GNU's join under galaxy
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
6 # not ment to be used from command line (if you're using the command line, simply run 'join' directly...)
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
7 #
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
8 # All parameters must be supplied.
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
9 # the join_tool.xml file takes care of that.
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
10
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
11 JOINTYPE="$1"
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
12 OUTPUT_FORMAT="$2"
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
13 EMPTY_STRING="$3"
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
14 DELIMITER="$4"
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
15 IGNORE_CASE="$5"
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
16
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
17 INPUT1="$6"
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
18 COLUMN1="$7"
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
19 INPUT2="$8"
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
20 COLUMN2="$9"
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
21 OUTPUT="${10}"
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
22
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
23 if [ "$OUTPUT" == "" ]; then
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
24 echo "This script is part of galaxy. Don't run it manually.\n" >&2
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
25 exit 1;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
26 fi
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
27
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
28 #This a TAB hack for galaxy (which can't transfer a "\t" as a parameter)
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
29 [ "$DELIMITER" == "tab" ] && DELIMITER=" "
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
30
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
31 #Remove spaces from the output format (if the user entered any)
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
32 OUTPUT_FORMAT=${OUTPUT_FORMAT// /}
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
33 [ "$OUTPUT_FORMAT" != "" ] && OUTPUT_FORMAT="-o $OUTPUT_FORMAT"
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
34
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
35 echo join $OUTPUT_FORMAT -t "$DELIMITER" -e "$EMPTY_STRING" $IGNORE_CASE $JOINTYPE -1 "$COLUMN1" -2 "$COLUMN2"
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
36 #echo join $OUTPUT_FORMAT -t "$DELIMITER" -e "$EMPTY_STRING" $IGNORE_CASE $JOINTYPE -1 "$COLUMN1" -2 "$COLUMN2" "$INPUT1" "$INPUT2" \> "$OUTPUT"
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
37 join $OUTPUT_FORMAT -t "$DELIMITER" -e "$EMPTY_STRING" $JOINTYPE -1 "$COLUMN1" -2 "$COLUMN2" "$INPUT1" "$INPUT2" > "$OUTPUT" || exit 1