annotate tools/filters/pasteWrapper.pl @ 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 #! /usr/bin/perl -w
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
3 use strict;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
4 use warnings;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
5 my $command = "";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
6 # a wrapper for paste for use in galaxy
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
7 # pasteWrapper.pl [filename1] [filename2] [delimiter] [output]
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
8
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
9 die "Check arguments" unless @ARGV == 4;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
10
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
11 if ($ARGV[2] eq 'T') {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
12 $command = "paste $ARGV[0] $ARGV[1]";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
13 } elsif ($ARGV[2] eq 'C') {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
14 $command = "paste -d \",\" $ARGV[0] $ARGV[1]";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
15 } elsif ($ARGV[2] eq 'D') {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
16 $command = "paste -d \"-\" $ARGV[0] $ARGV[1]";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
17 } elsif ($ARGV[2] eq 'U') {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
18 $command = "paste -d \"_\" $ARGV[0] $ARGV[1]";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
19 } elsif ($ARGV[2] eq 'P') {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
20 $command = "paste -d \"|\" $ARGV[0] $ARGV[1]";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
21 } elsif ($ARGV[2] eq 'Dt') {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
22 $command = "paste -d \".\" $ARGV[0] $ARGV[1]";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
23 } elsif ($ARGV[2] eq 'Sp') {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
24 $command = "paste -d \" \" $ARGV[0] $ARGV[1]";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
25 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
26
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
27 open (OUT, ">$ARGV[3]") or die "Cannot create $ARGV[2]:$!\n";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
28 open (PASTE, "$command |") or die "Cannot run paste:$!\n";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
29
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
30 while (<PASTE>) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
31 print OUT;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
32 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
33 close OUT;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
34 close PASTE;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
35