Add support for column ranges to Cut tool. Thank to John Chilton for this code.

This commit is contained in:
Jeremy Goecks
2013-03-21 12:19:14 -04:00
parent a7095dd420
commit bacf200965
2 changed files with 22 additions and 1 deletions
+10
View File
@@ -9,6 +9,9 @@ my @in = ();
my @out = ();
my $command = "";
my $field = 0;
my $start = 0;
my $end = 0;
my $i = 0;
# a wrapper for cut for use in galaxy
# cutWrapper.pl [filename] [columns] [delim] [output]
@@ -20,6 +23,13 @@ foreach ( split /,/, $ARGV[1] ) {
if (m/^c\d{1,}$/i) {
push (@columns, $_);
$columns[@columns-1] =~s/c//ig;
} elsif (m/^c\d{1,}-c\d{1,}$/i) {
($start, $end) = split(/-/, $_);
$start =~ s/c//ig;
$end =~ s/c//ig;
for $i ($start .. $end) {
push (@columns, $i);
}
}
}
+12 -1
View File
@@ -1,4 +1,4 @@
<tool id="Cut1" name="Cut" version="1.0.1">
<tool id="Cut1" name="Cut" version="1.0.2">
<description>columns from a table</description>
<command interpreter="perl">cutWrapper.pl $input "$columnList" $delimiter $out_file1</command>
<inputs>
@@ -141,6 +141,12 @@
<param name="input" value="1.bed"/>
<output name="out_file1" file="eq-cut.dat"/>
</test>
<test>
<param name="columnList" value="c1,c4,c2-c3" />
<param name="delimiter" value="T" />
<param name="input" value="1.bed" />
<output name="out_file1" file="eq-cut.dat" />
</test>
</tests>
<help>
@@ -191,6 +197,11 @@ Input dataset (six columns: c1, c2, c3, c4, c5, and c6)::
+ 0 gene1 chr1
+ 0 gene2 chr2
**cut** on columns "**c1-c3**" will return::
chr1 10 1000
chr2 100 1500
**cut** on columns "**c8,c7,c4**" will return::