Mercurial > repos > mir-bioinf > column_range_string_generator
changeset 0:358c9e0b9154 draft default tip
Initial upload
author | mir-bioinf |
---|---|
date | Fri, 24 Apr 2015 10:56:37 -0400 |
parents | |
children | |
files | ColRangeGenerator/ColRangeGenerator.pl ColRangeGenerator/ColRangeGenerator.xml ColRangeGenerator/test-data/ColRangeGenerator_out.csv |
diffstat | 3 files changed, 55 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ColRangeGenerator/ColRangeGenerator.pl Fri Apr 24 10:56:37 2015 -0400 @@ -0,0 +1,31 @@ +#! /usr/bin/perl -w + +use strict; +use warnings; +use Text::ParseWords; + +##Args are col range and output file name ONLY. no spaces!! + +die "Please check arguments, probably spaces in column range!\n" unless @ARGV == 2; + +my $colrange = $ARGV[0]; +my $outputfile = $ARGV[1]; + +my @cols = split(/-/,$colrange); +die "Improper range format: probably missing - (hyphen) or it's at the end.\n" unless exists($cols[1]); + +my @start = split('C',uc($cols[0]),2); +my @stop = split('C',uc($cols[1]),2); +die "Improper column format: missing preceding C for col number.\n" unless (exists($start[1]) && exists($stop[1])); + +my $begin = $start[1]; +my $end = $stop[1]; + +my $fhOut; +open ($fhOut, "> $outputfile"); +for (my $i=$begin; $i<$end; $i++) { + print $fhOut "c$i,"; +} +print $fhOut "c$end\n"; + +close ($fhOut) or die "Cannot close output file\n";
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ColRangeGenerator/ColRangeGenerator.xml Fri Apr 24 10:56:37 2015 -0400 @@ -0,0 +1,23 @@ +<tool id="ColRangeGenerator" name="Generate Column Range String"> + <description>for cut or remove large ranges of columns</description> + <command interpreter="perl">ColRangeGenerator.pl $cols $coldelim</command> + <inputs> + <param name="cols" type="text" size="10" value="C1-C100" label="Columns (range) WITHOUT SPACES PLEASE" + help="Enter column range with hyphen, use default as format guide."/> + </inputs> + <outputs> + <!--<data format="txt" name="coldelim" label="Columns"/>--> + <data format="csv" name="coldelim" label="Columns"/> + </outputs> + <tests> + <test> + <param name="cols" value="C1:C17"/> + <output name="coldelim" file="ColRangeGenerator_out.csv"/> + </test> + </tests> + <help> + Use this tool to generate a string that can be copied to the buffer then pasted into the Cut Column tool to save time (rather than needing to individually type out c1,c2,c3..... etc.). +</help> + + +</tool>