mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
Add support for column ranges to Cut tool. Thank to John Chilton for this code.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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::
|
||||
|
||||
|
||||
Reference in New Issue
Block a user