Migrate tools to tool shed: addValue, ChangeCase, Condense characters1, Convert characters1, Cut1, mergeCols1, Remove beginning1, Show beginning1, Show tail1, trimmer

This commit is contained in:
Dave Bouvier
2012-12-07 16:08:40 -05:00
parent 0a0500dbb4
commit de7cb21382
27 changed files with 58 additions and 1439 deletions
@@ -0,0 +1,21 @@
"""
The following tools have been eliminated from the distribution:
Add column to an existing dataset, Change Case of selected columns,
Condense consecutive characters, Convert delimiters to TAB,
Cut columns from a table, Merge Columns together, Remove beginning of a file,
Select first lines from a dataset, Select last lines from a dataset,
and Trim leading or trailing characters. The tools are now available in the
repositories named add_value, change_case, condense_characters,
convert_characters, cut_columns, merge_cols, remove_beginning,
show_beginning, show_tail, and trimmer from the main Galaxy tool shed at
http://toolshed.g2.bx.psu.edu, and will be installed into your
local Galaxy instance at the location discussed above by running
the following command.
"""
import sys
def upgrade():
print __doc__
def downgrade():
pass
+4
View File
@@ -0,0 +1,4 @@
#!/bin/sh
cd `dirname $0`/../..
python ./scripts/migrate_tools/migrate_tools.py 0008_tools.xml $@
+33
View File
@@ -0,0 +1,33 @@
<?xml version="1.0"?>
<toolshed name="toolshed.g2.bx.psu.edu">
<repository name="add_value" description="Add a value as a new column." changeset_revision="181dd378275c">
<tool id="addValue" version="1.0.0" file="fixedValueColumn.xml" />
</repository>
<repository name="change_case" description="Change the case of a column." changeset_revision="e6f966602870">
<tool id="ChangeCase" version="1.0.0" file="changeCase.xml" />
</repository>
<repository name="condense_characters" description="Condense repeated characters." changeset_revision="2c08781560de">
<tool id="Condense characters1" version="1.0.0" file="condense_characters.xml" />
</repository>
<repository name="convert_characters" description="Convert delimiters to TAB." changeset_revision="64d46676a13e">
<tool id="Convert characters1" version="1.0.0" file="convert_characters.xml" />
</repository>
<repository name="cut_columns" description="Remove or rearrange columns." changeset_revision="34c29e183ef7">
<tool id="Cut1" version="1.0.1" file="cutWrapper.xml" />
</repository>
<repository name="merge_cols" description="Merge columns together." changeset_revision="28ca7552e884">
<tool id="mergeCols1" version="1.0.1" file="mergeCols.xml" />
</repository>
<repository name="remove_beginning" description="Remove lines from the beginning of a file." changeset_revision="d9b82504a321">
<tool id="Remove beginning1" version="1.0.0" file="remove_beginning.xml" />
</repository>
<repository name="show_beginning" description="Select lines from the beginning of a file." changeset_revision="ecca14446e6a">
<tool id="Show beginning1" version="1.0.0" file="headWrapper.xml" />
</repository>
<repository name="show_tail" description="Select lines from the end of a file." changeset_revision="8bb4d908a523">
<tool id="Show tail1" version="1.0.0" file="tailWrapper.xml" />
</repository>
<repository name="trimmer" description="Trim trailing characters from each line or column." changeset_revision="f862a6e4d096">
<tool id="trimmer" version="0.0.1" file="trimmer.xml" />
</repository>
</toolshed>
-15
View File
@@ -1,15 +0,0 @@
CHR SNP BP A1 TEST NMISS BETA STAT P
1 rs1181876 3671541 T DOMDEV 958 -1.415 -3.326 0.0009161
1 rs10492923 5092886 C ADD 1007 5.105 4.368 1.382e-05
1 rs10492923 5092886 C DOMDEV 1007 -5.612 -4.249 2.35e-05
1 rs10492923 5092886 C GENO_2DF 1007 NA 19.9 4.775e-05
1 rs1801133 11778965 T ADD 1022 1.23 3.97 7.682e-05
1 rs1801133 11778965 T GENO_2DF 1022 NA 16.07 0.0003233
1 rs1361912 12663121 A ADD 1021 12.69 4.093 4.596e-05
1 rs1361912 12663121 A DOMDEV 1021 -12.37 -3.945 8.533e-05
1 rs1361912 12663121 A GENO_2DF 1021 NA 17.05 0.0001982
1 rs1009806 19373138 G ADD 1021 -1.334 -3.756 0.0001826
1 rs1009806 19373138 G GENO_2DF 1021 NA 19.36 6.244e-05
1 rs873654 29550948 A DOMDEV 1012 1.526 3.6 0.0003339
1 rs10489527 36800027 C ADD 1016 12.67 4.114 4.211e-05
1 rs10489527 36800027 C DOMDEV 1016 -13.05 -4.02 6.249e-05
-65
View File
@@ -1,65 +0,0 @@
chr1 147962192 147962580 CCDS989.1_cds_0_0_chr1_147962193_r 0 -
chr1 147984545 147984630 CCDS990.1_cds_0_0_chr1_147984546_f 0 +
chr1 148078400 148078582 CCDS993.1_cds_0_0_chr1_148078401_r 0 -
chr1 148185136 148185276 CCDS996.1_cds_0_0_chr1_148185137_f 0 +
chr10 55251623 55253124 CCDS7248.1_cds_0_0_chr10_55251624_r 0 -
chr11 116124407 116124501 CCDS8374.1_cds_0_0_chr11_116124408_r 0 -
chr11 116206508 116206563 CCDS8377.1_cds_0_0_chr11_116206509_f 0 +
chr11 116211733 116212337 CCDS8378.1_cds_0_0_chr11_116211734_r 0 -
chr11 1812377 1812407 CCDS7726.1_cds_0_0_chr11_1812378_f 0 +
chr12 38440094 38440321 CCDS8736.1_cds_0_0_chr12_38440095_r 0 -
chr13 112381694 112381953 CCDS9526.1_cds_0_0_chr13_112381695_f 0 +
chr14 98710240 98712285 CCDS9949.1_cds_0_0_chr14_98710241_r 0 -
chr15 41486872 41487060 CCDS10096.1_cds_0_0_chr15_41486873_r 0 -
chr15 41673708 41673857 CCDS10097.1_cds_0_0_chr15_41673709_f 0 +
chr15 41679161 41679250 CCDS10098.1_cds_0_0_chr15_41679162_r 0 -
chr15 41826029 41826196 CCDS10101.1_cds_0_0_chr15_41826030_f 0 +
chr16 142908 143003 CCDS10397.1_cds_0_0_chr16_142909_f 0 +
chr16 179963 180135 CCDS10401.1_cds_0_0_chr16_179964_r 0 -
chr16 244413 244681 CCDS10402.1_cds_0_0_chr16_244414_f 0 +
chr16 259268 259383 CCDS10403.1_cds_0_0_chr16_259269_r 0 -
chr18 23786114 23786321 CCDS11891.1_cds_0_0_chr18_23786115_r 0 -
chr18 59406881 59407046 CCDS11985.1_cds_0_0_chr18_59406882_f 0 +
chr18 59455932 59456337 CCDS11986.1_cds_0_0_chr18_59455933_r 0 -
chr18 59600586 59600754 CCDS11988.1_cds_0_0_chr18_59600587_f 0 +
chr19 59068595 59069564 CCDS12866.1_cds_0_0_chr19_59068596_f 0 +
chr19 59236026 59236146 CCDS12872.1_cds_0_0_chr19_59236027_r 0 -
chr19 59297998 59298008 CCDS12877.1_cds_0_0_chr19_59297999_f 0 +
chr19 59302168 59302288 CCDS12878.1_cds_0_0_chr19_59302169_r 0 -
chr2 118288583 118288668 CCDS2120.1_cds_0_0_chr2_118288584_f 0 +
chr2 118394148 118394202 CCDS2121.1_cds_0_0_chr2_118394149_r 0 -
chr2 220190202 220190242 CCDS2441.1_cds_0_0_chr2_220190203_f 0 +
chr2 220229609 220230869 CCDS2443.1_cds_0_0_chr2_220229610_r 0 -
chr20 33330413 33330423 CCDS13249.1_cds_0_0_chr20_33330414_r 0 -
chr20 33513606 33513792 CCDS13255.1_cds_0_0_chr20_33513607_f 0 +
chr20 33579500 33579527 CCDS13256.1_cds_0_0_chr20_33579501_r 0 -
chr20 33593260 33593348 CCDS13257.1_cds_0_0_chr20_33593261_f 0 +
chr21 32707032 32707192 CCDS13614.1_cds_0_0_chr21_32707033_f 0 +
chr21 32869641 32870022 CCDS13615.1_cds_0_0_chr21_32869642_r 0 -
chr21 33321040 33322012 CCDS13620.1_cds_0_0_chr21_33321041_f 0 +
chr21 33744994 33745040 CCDS13625.1_cds_0_0_chr21_33744995_r 0 -
chr22 30120223 30120265 CCDS13897.1_cds_0_0_chr22_30120224_f 0 +
chr22 30160419 30160661 CCDS13898.1_cds_0_0_chr22_30160420_r 0 -
chr22 30665273 30665360 CCDS13901.1_cds_0_0_chr22_30665274_f 0 +
chr22 30939054 30939266 CCDS13903.1_cds_0_0_chr22_30939055_r 0 -
chr5 131424298 131424460 CCDS4149.1_cds_0_0_chr5_131424299_f 0 +
chr5 131556601 131556672 CCDS4151.1_cds_0_0_chr5_131556602_r 0 -
chr5 131621326 131621419 CCDS4152.1_cds_0_0_chr5_131621327_f 0 +
chr5 131847541 131847666 CCDS4155.1_cds_0_0_chr5_131847542_r 0 -
chr6 108299600 108299744 CCDS5061.1_cds_0_0_chr6_108299601_r 0 -
chr6 108594662 108594687 CCDS5063.1_cds_0_0_chr6_108594663_f 0 +
chr6 108640045 108640151 CCDS5064.1_cds_0_0_chr6_108640046_r 0 -
chr6 108722976 108723115 CCDS5067.1_cds_0_0_chr6_108722977_f 0 +
chr7 113660517 113660685 CCDS5760.1_cds_0_0_chr7_113660518_f 0 +
chr7 116512159 116512389 CCDS5771.1_cds_0_0_chr7_116512160_r 0 -
chr7 116714099 116714152 CCDS5773.1_cds_0_0_chr7_116714100_f 0 +
chr7 116945541 116945787 CCDS5774.1_cds_0_0_chr7_116945542_r 0 -
chr8 118881131 118881317 CCDS6324.1_cds_0_0_chr8_118881132_r 0 -
chr9 128764156 128764189 CCDS6914.1_cds_0_0_chr9_128764157_f 0 +
chr9 128787519 128789136 CCDS6915.1_cds_0_0_chr9_128787520_r 0 -
chr9 128882427 128882523 CCDS6917.1_cds_0_0_chr9_128882428_f 0 +
chr9 128937229 128937445 CCDS6919.1_cds_0_0_chr9_128937230_r 0 -
chrX 122745047 122745924 CCDS14606.1_cds_0_0_chrX_122745048_f 0 +
chrX 152648964 152649196 CCDS14733.1_cds_0_0_chrX_152648965_r 0 -
chrX 152691446 152691471 CCDS14735.1_cds_0_0_chrX_152691447_f 0 +
chrX 152694029 152694263 CCDS14736.1_cds_0_0_chrX_152694030_r 0 -
-65
View File
@@ -1,65 +0,0 @@
chr1 147962192 147962580 CCDS989.1_cds_0_0_chr1_147962193_r 0 -
chr1 147984545 147984630 CCDS990.1_cds_0_0_chr1_147984546_f 0 +
chr1 148078400 148078582 CCDS993.1_cds_0_0_chr1_148078401_r 0 -
chr1 148185136 148185276 CCDS996.1_cds_0_0_chr1_148185137_f 0 +
chr10 55251623 55253124 CCDS7248.1_cds_0_0_chr10_55251624_r 0 -
chr11 116124407 116124501 CCDS8374.1_cds_0_0_chr11_116124408_r 0 -
chr11 116206508 116206563 CCDS8377.1_cds_0_0_chr11_116206509_f 0 +
chr11 116211733 116212337 CCDS8378.1_cds_0_0_chr11_116211734_r 0 -
chr11 1812377 1812407 CCDS7726.1_cds_0_0_chr11_1812378_f 0 +
chr12 38440094 38440321 CCDS8736.1_cds_0_0_chr12_38440095_r 0 -
chr13 112381694 112381953 CCDS9526.1_cds_0_0_chr13_112381695_f 0 +
chr14 98710240 98712285 CCDS9949.1_cds_0_0_chr14_98710241_r 0 -
chr15 41486872 41487060 CCDS10096.1_cds_0_0_chr15_41486873_r 0 -
chr15 41673708 41673857 CCDS10097.1_cds_0_0_chr15_41673709_f 0 +
chr15 41679161 41679250 CCDS10098.1_cds_0_0_chr15_41679162_r 0 -
chr15 41826029 41826196 CCDS10101.1_cds_0_0_chr15_41826030_f 0 +
chr16 142908 143003 CCDS10397.1_cds_0_0_chr16_142909_f 0 +
chr16 179963 180135 CCDS10401.1_cds_0_0_chr16_179964_r 0 -
chr16 244413 244681 CCDS10402.1_cds_0_0_chr16_244414_f 0 +
chr16 259268 259383 CCDS10403.1_cds_0_0_chr16_259269_r 0 -
chr18 23786114 23786321 CCDS11891.1_cds_0_0_chr18_23786115_r 0 -
chr18 59406881 59407046 CCDS11985.1_cds_0_0_chr18_59406882_f 0 +
chr18 59455932 59456337 CCDS11986.1_cds_0_0_chr18_59455933_r 0 -
chr18 59600586 59600754 CCDS11988.1_cds_0_0_chr18_59600587_f 0 +
chr19 59068595 59069564 CCDS12866.1_cds_0_0_chr19_59068596_f 0 +
chr19 59236026 59236146 CCDS12872.1_cds_0_0_chr19_59236027_r 0 -
chr19 59297998 59298008 CCDS12877.1_cds_0_0_chr19_59297999_f 0 +
chr19 59302168 59302288 CCDS12878.1_cds_0_0_chr19_59302169_r 0 -
chr2 118288583 118288668 CCDS2120.1_cds_0_0_chr2_118288584_f 0 +
chr2 118394148 118394202 CCDS2121.1_cds_0_0_chr2_118394149_r 0 -
chr2 220190202 220190242 CCDS2441.1_cds_0_0_chr2_220190203_f 0 +
chr2 220229609 220230869 CCDS2443.1_cds_0_0_chr2_220229610_r 0 -
chr20 33330413 33330423 CCDS13249.1_cds_0_0_chr20_33330414_r 0 -
chr20 33513606 33513792 CCDS13255.1_cds_0_0_chr20_33513607_f 0 +
chr20 33579500 33579527 CCDS13256.1_cds_0_0_chr20_33579501_r 0 -
chr20 33593260 33593348 CCDS13257.1_cds_0_0_chr20_33593261_f 0 +
chr21 32707032 32707192 CCDS13614.1_cds_0_0_chr21_32707033_f 0 +
chr21 32869641 32870022 CCDS13615.1_cds_0_0_chr21_32869642_r 0 -
chr21 33321040 33322012 CCDS13620.1_cds_0_0_chr21_33321041_f 0 +
chr21 33744994 33745040 CCDS13625.1_cds_0_0_chr21_33744995_r 0 -
chr22 30120223 30120265 CCDS13897.1_cds_0_0_chr22_30120224_f 0 +
chr22 30160419 30160661 CCDS13898.1_cds_0_0_chr22_30160420_r 0 -
chr22 30665273 30665360 CCDS13901.1_cds_0_0_chr22_30665274_f 0 +
chr22 30939054 30939266 CCDS13903.1_cds_0_0_chr22_30939055_r 0 -
chr5 131424298 131424460 CCDS4149.1_cds_0_0_chr5_131424299_f 0 +
chr5 131556601 131556672 CCDS4151.1_cds_0_0_chr5_131556602_r 0 -
chr5 131621326 131621419 CCDS4152.1_cds_0_0_chr5_131621327_f 0 +
chr5 131847541 131847666 CCDS4155.1_cds_0_0_chr5_131847542_r 0 -
chr6 108299600 108299744 CCDS5061.1_cds_0_0_chr6_108299601_r 0 -
chr6 108594662 108594687 CCDS5063.1_cds_0_0_chr6_108594663_f 0 +
chr6 108640045 108640151 CCDS5064.1_cds_0_0_chr6_108640046_r 0 -
chr6 108722976 108723115 CCDS5067.1_cds_0_0_chr6_108722977_f 0 +
chr7 113660517 113660685 CCDS5760.1_cds_0_0_chr7_113660518_f 0 +
chr7 116512159 116512389 CCDS5771.1_cds_0_0_chr7_116512160_r 0 -
chr7 116714099 116714152 CCDS5773.1_cds_0_0_chr7_116714100_f 0 +
chr7 116945541 116945787 CCDS5774.1_cds_0_0_chr7_116945542_r 0 -
chr8 118881131 118881317 CCDS6324.1_cds_0_0_chr8_118881132_r 0 -
chr9 128764156 128764189 CCDS6914.1_cds_0_0_chr9_128764157_f 0 +
chr9 128787519 128789136 CCDS6915.1_cds_0_0_chr9_128787520_r 0 -
chr9 128882427 128882523 CCDS6917.1_cds_0_0_chr9_128882428_f 0 +
chr9 128937229 128937445 CCDS6919.1_cds_0_0_chr9_128937230_r 0 -
chrX 122745047 122745924 CCDS14606.1_cds_0_0_chrX_122745048_f 0 +
chrX 152648964 152649196 CCDS14733.1_cds_0_0_chrX_152648965_r 0 -
chrX 152691446 152691471 CCDS14735.1_cds_0_0_chrX_152691447_f 0 +
chrX 152694029 152694263 CCDS14736.1_cds_0_0_chrX_152694030_r 0 -
-9
View File
@@ -44,21 +44,12 @@
<tool file="extract/liftOver_wrapper.xml" />
</section>
<section name="Text Manipulation" id="textutil">
<tool file="filters/fixedValueColumn.xml" />
<tool file="stats/column_maker.xml" />
<tool file="filters/catWrapper.xml" />
<tool file="filters/cutWrapper.xml" />
<tool file="filters/mergeCols.xml" />
<tool file="filters/convert_characters.xml" />
<tool file="filters/CreateInterval.xml" />
<tool file="filters/cutWrapper.xml" />
<tool file="filters/changeCase.xml" />
<tool file="filters/pasteWrapper.xml" />
<tool file="filters/remove_beginning.xml" />
<tool file="filters/randomlines.xml" />
<tool file="filters/headWrapper.xml" />
<tool file="filters/tailWrapper.xml" />
<tool file="filters/trimmer.xml" />
<tool file="filters/wc_gnu.xml" />
<tool file="filters/secure_hash_message_digest.xml" />
<tool file="stats/dna_filtering.xml" />
-58
View File
@@ -1,58 +0,0 @@
#! /usr/bin/perl -w
use strict;
use warnings;
my $columns = {};
my $del = "";
my @in = ();
my @out = ();
my $command = "";
my $field = 0;
# a wrapper for changing the case of columns from within galaxy
# isaChangeCase.pl [filename] [columns] [delim] [casing] [output]
die "Check arguments: $0 [filename] [columns] [delim] [casing] [output]\n" unless @ARGV == 5;
# process column input
$ARGV[1] =~ s/\s+//g;
foreach ( split /,/, $ARGV[1] ) {
if (m/^c\d{1,}$/i) {
s/c//ig;
$columns->{$_} = --$_;
}
}
die "No columns specified, columns are not preceeded with 'c', or commas are not used to separate column numbers: $ARGV[1]\n" if keys %$columns == 0;
my $column_delimiters_href = {
'TAB' => q{\t},
'COMMA' => ",",
'DASH' => "-",
'UNDERSCORE' => "_",
'PIPE' => q{\|},
'DOT' => q{\.},
'SPACE' => q{\s+}
};
$del = $column_delimiters_href->{$ARGV[2]};
open (OUT, ">$ARGV[4]") or die "Cannot create $ARGV[4]:$!\n";
open (IN, "<$ARGV[0]") or die "Cannot open $ARGV[0]:$!\n";
while (<IN>) {
chop;
@in = split /$del/;
for ( my $i = 0; $i <= $#in; ++$i) {
if (exists $columns->{$i}) {
push(@out, $ARGV[3] eq 'up' ? uc($in[$i]) : lc($in[$i]));
} else {
push(@out, $in[$i]);
}
}
print OUT join("\t",@out), "\n";
@out = ();
}
close IN;
close OUT;
-77
View File
@@ -1,77 +0,0 @@
<tool id="ChangeCase" name="Change Case">
<description> of selected columns</description>
<stdio>
<exit_code range="1:" err_level="fatal" />
</stdio>
<command interpreter="perl">changeCase.pl $input "$cols" $delimiter $casing $out_file1</command>
<inputs>
<param name="input" format="txt" type="data" label="From"/>
<param name="cols" size="10" type="text" value="c1,c2" label="Change case of columns"/>
<param name="delimiter" type="select" label="Delimited by">
<option value="TAB">Tab</option>
<option value="SPACE">Whitespace</option>
<option value="DOT">Dot</option>
<option value="COMMA">Comma</option>
<option value="DASH">Dash</option>
<option value="UNDERSCORE">Underscore</option>
<option value="PIPE">Pipe</option>
</param>
<param name="casing" type="select" label="To">
<option value="up">Upper case</option>
<option value="lo">Lower case</option>
</param>
</inputs>
<outputs>
<data format="tabular" name="out_file1" />
</outputs>
<tests>
<test>
<param name="input" value="1.txt" ftype="txt"/>
<param name="cols" value="c1"/>
<param name="delimiter" value="SPACE"/>
<param name="casing" value="up"/>
<output name="out_file1" file="changeCase_out1.tabular"/>
</test>
<test>
<param name="input" value="1.bed" ftype="bed"/>
<param name="cols" value="c1"/>
<param name="delimiter" value="TAB"/>
<param name="casing" value="up"/>
<output name="out_file1" file="changeCase_out2.tabular"/>
</test>
</tests>
<help>
.. class:: warningmark
**This tool breaks column assignments.** To re-establish column assignments run the tool and click on the pencil icon in the resulting history item.
.. class:: warningmark
The format of the resulting dataset from this tool is always tabular.
-----
**What it does**
This tool selects specified columns from a dataset and converts the values of those columns to upper or lower case.
- Columns are specified as **c1**, **c2**, and so on.
- Columns can be specified in any order (e.g., **c2,c1,c6**)
-----
**Example**
Changing columns 1 and 3 ( delimited by Comma ) to upper case in::
apple,is,good
windows,is,bad
will result in::
APPLE is GOOD
WINDOWS is BAD
</help>
</tool>
-105
View File
@@ -1,105 +0,0 @@
#! /usr/bin/perl -w
use strict;
use warnings;
# condenses all consecutive characters of one type
# convert_characters.pl [input] [character] [output]
die "Check arguments" unless @ARGV == 3;
my $inputfile = $ARGV[0];
my $character = $ARGV[1];
my $outputfile = $ARGV[2];
my $convert_from;
my $convert_to;
if ($character eq "s")
{
$convert_from = '\s';
}
elsif ($character eq "T")
{
$convert_from = '\t';
}
elsif ($character eq "Sp")
{
$convert_from = " ";
}
elsif ($character eq "Dt")
{
$convert_from = '\.';
}
elsif ($character eq "C")
{
$convert_from = ",";
}
elsif ($character eq "D")
{
$convert_from = "-";
}
elsif ($character eq "U")
{
$convert_from = "_";
}
elsif ($character eq "P")
{
$convert_from = '\|';
}
else
{
die "Invalid value specified for convert from\n";
}
if ($character eq "T")
{
$convert_to = "\t";
}
elsif ($character eq "Sp")
{
$convert_to = " ";
}
elsif ($character eq "Dt")
{
$convert_to = "\.";
}
elsif ($character eq "C")
{
$convert_to = ",";
}
elsif ($character eq "D")
{
$convert_to = "-";
}
elsif ($character eq "U")
{
$convert_to = "_";
}
elsif ($character eq "P")
{
$convert_to = "|";
}
else
{
die "Invalid value specified for Convert to\n";
}
my $fhIn;
open ($fhIn, "< $inputfile") or die "Cannot open source file";
my $fhOut;
open ($fhOut, "> $outputfile");
while (<$fhIn>)
{
my $thisLine = $_;
chomp $thisLine;
$thisLine =~ s/${convert_from}+/$convert_to/g;
print $fhOut $thisLine,"\n";
}
close ($fhIn) or die "Cannot close source file";
close ($fhOut) or die "Cannot close output file";
-48
View File
@@ -1,48 +0,0 @@
<tool id="Condense characters1" name="Condense">
<description>consecutive characters</description>
<command interpreter="perl">condense_characters.pl $input $character $out_file1</command>
<inputs>
<!-- <display>condense all consecutive $character from $input</display> -->
<param name="character" type="select" label="Condense all consecutive">
<option value="T">Tabs</option>
<option value="Sp">Spaces</option>
<option value="Dt">Dots</option>
<option value="C">Commas</option>
<option value="D">Dashes</option>
<option value="U">Underscores</option>
<option value="P">Pipes</option>
</param>
<param format="txt" name="input" type="data" label="in this Query"/>
</inputs>
<outputs>
<data format="input" name="out_file1" metadata_source="input" />
</outputs>
<tests>
<test>
<param name="character" value="T"/>
<param name="input" value="1.bed"/>
<output name="out_file1" file="eq-condense.dat"/>
</test>
</tests>
<help>
**What it does**
This tool condenses all consecutive characters of a specified type.
-----
**Example**
- Input file::
geneX,,,10,,,,,20
geneY,,5,,,,,12,15,9,
- Condense all consecutive commas. The above file will be converted into::
geneX,10,20
geneY,5,12,15,9
</help>
</tool>
-42
View File
@@ -1,42 +0,0 @@
#!/usr/bin/env python
#By, Guruprasad Ananda.
from galaxy import eggs
import sys, re
def stop_err(msg):
sys.stderr.write(msg)
sys.exit()
def main():
if len(sys.argv) != 4:
stop_err("usage: convert_characters infile from_char outfile")
try:
fin = open(sys.argv[1],'r')
except:
stop_err("Input file cannot be opened for reading.")
from_char = sys.argv[2]
try:
fout = open(sys.argv[3],'w')
except:
stop_err("Output file cannot be opened for writing.")
char_dict = {'T':'\t','s':'\s','Dt':'\.','C':',','D':'-','U':'_','P':'\|','Co':':'}
from_ch = char_dict[from_char] + '+' #making an RE to match 1 or more occurences.
skipped = 0
for line in fin:
line = line.strip()
try:
fout.write("%s\n" %(re.sub(from_ch,'\t',line)))
except:
skipped += 1
if skipped:
print "Skipped %d lines as invalid." %skipped
if __name__ == "__main__":
main()
-58
View File
@@ -1,58 +0,0 @@
<tool id="Convert characters1" name="Convert">
<description>delimiters to TAB</description>
<command interpreter="python">convert_characters.py $input $convert_from $out_file1</command>
<inputs>
<param name="convert_from" type="select" label="Convert all">
<option value="s">Whitespaces</option>
<option value="T">Tabs</option>
<!--<option value="Sp">Spaces</option>-->
<option value="Dt">Dots</option>
<option value="C">Commas</option>
<option value="D">Dashes</option>
<option value="U">Underscores</option>
<option value="P">Pipes</option>
<option value="Co">Colons</option>
</param>
<param format="txt" name="input" type="data" label="in Query"/>
</inputs>
<outputs>
<data format="tabular" name="out_file1" />
</outputs>
<tests>
<test>
<param name="convert_from" value="s"/>
<param name="input" value="1.bed"/>
<output name="out_file1" file="eq-convert.dat"/>
</test>
<test>
<param name="convert_from" value="s"/>
<param name="input" value="a.txt"/>
<output name="out_file1" file="a.tab"/>
</test>
</tests>
<help>
**What it does**
Converts all delimiters of a specified type into TABs. Consecutive characters are condensed. For example, if columns are separated by 5 spaces they will converted into 1 tab.
-----
**Example**
- Input file::
chrX||151283558|151283724|NM_000808_exon_8_0_chrX_151283559_r|0|-
chrX|151370273|151370486|NM_000808_exon_9_0_chrX_151370274_r|0|-
chrX|151559494|151559583|NM_018558_exon_1_0_chrX_151559495_f|0|+
chrX|151564643|151564711|NM_018558_exon_2_0_chrX_151564644_f||||0|+
- Converting all pipe delimiters of the above file to TABs will get::
chrX 151283558 151283724 NM_000808_exon_8_0_chrX_151283559_r 0 -
chrX 151370273 151370486 NM_000808_exon_9_0_chrX_151370274_r 0 -
chrX 151559494 151559583 NM_018558_exon_1_0_chrX_151559495_f 0 +
chrX 151564643 151564711 NM_018558_exon_2_0_chrX_151564644_f 0 +
</help>
</tool>
-77
View File
@@ -1,77 +0,0 @@
#!/usr/bin/perl -w
use strict;
use warnings;
my @columns = ();
my $del = "";
my @in = ();
my @out = ();
my $command = "";
my $field = 0;
# a wrapper for cut for use in galaxy
# cutWrapper.pl [filename] [columns] [delim] [output]
die "Check arguments\n" unless @ARGV == 4;
$ARGV[1] =~ s/\s+//g;
foreach ( split /,/, $ARGV[1] ) {
if (m/^c\d{1,}$/i) {
push (@columns, $_);
$columns[@columns-1] =~s/c//ig;
}
}
die "No columns specified, columns are not preceded with 'c', or commas are not used to separate column numbers: $ARGV[1]\n" if @columns == 0;
my $column_delimiters_href = {
'T' => q{\t},
'C' => ",",
'D' => "-",
'U' => "_",
'P' => q{\|},
'Dt' => q{\.},
'Sp' => q{\s+}
};
$del = $column_delimiters_href->{$ARGV[2]};
open (OUT, ">$ARGV[3]") or die "Cannot create $ARGV[2]:$!\n";
open (IN, "<$ARGV[0]") or die "Cannot open $ARGV[0]:$!\n";
while (my $line=<IN>) {
if ($line =~ /^#/) {
#Ignore comment lines
} else {
chop($line);
@in = split(/$del/, $line);
foreach $field (@columns) {
if (defined($in[$field-1])) {
push(@out, $in[$field-1]);
} else {
push(@out, ".");
}
}
print OUT join("\t",@out), "\n";
@out = ();
}
}
#while (<IN>) {
# chop;
# @in = split /$del/;
# foreach $field (@columns) {
# if (defined($in[$field-1])) {
# push(@out, $in[$field-1]);
# } else {
# push(@out, ".");
# }
# }
# print OUT join("\t",@out), "\n";
# @out = ();
#}
close IN;
close OUT;
-202
View File
@@ -1,202 +0,0 @@
<tool id="Cut1" name="Cut" version="1.0.1">
<description>columns from a table</description>
<command interpreter="perl">cutWrapper.pl $input "$columnList" $delimiter $out_file1</command>
<inputs>
<param name="columnList" size="10" type="text" value="c1,c2" label="Cut columns"/>
<param name="delimiter" type="select" label="Delimited by">
<option value="T">Tab</option>
<option value="Sp">Whitespace</option>
<option value="Dt">Dot</option>
<option value="C">Comma</option>
<option value="D">Dash</option>
<option value="U">Underscore</option>
<option value="P">Pipe</option>
</param>
<param format="txt" name="input" type="data" label="From"/>
</inputs>
<outputs>
<data format="tabular" name="out_file1" >
<actions>
<conditional name="delimiter">
<when value="T">
<conditional name="input">
<when datatype_isinstance="interval">
<action type="format" default="tabular">
<option type="from_param" name="columnList" column="0" offset="0"> <!-- chromCol is 1-->
<filter type="insert_column" column="0" value="interval"/>
<filter type="insert_column" ref="columnList" /> <!-- startCol -->
<filter type="insert_column" ref="columnList" /> <!-- endCol -->
<filter type="multiple_splitter" column="1" separator=","/>
<filter type="column_strip" column="1"/> <!-- get rid of all external whitespace -->
<filter type="string_function" column="1" name="lower" />
<filter type="param_value" column="1" value="^c\d{1,}$" compare="re_search" keep="True"/>
<filter type="column_strip" column="1" strip="c"/> <!-- get rid of c's -->
<filter type="boolean" column="1" cast="int" />
<filter type="multiple_splitter" column="2" separator=","/>
<filter type="column_strip" column="2"/> <!-- get rid of all external whitespace -->
<filter type="string_function" column="2" name="lower" />
<filter type="param_value" column="2" value="^c\d{1,}$" compare="re_search" keep="True"/>
<filter type="column_strip" column="2" strip="c"/> <!-- get rid of c's -->
<filter type="boolean" column="2" cast="int" />
<filter type="multiple_splitter" column="3" separator=","/>
<filter type="column_strip" column="3"/> <!-- get rid of all external whitespace -->
<filter type="string_function" column="3" name="lower" />
<filter type="param_value" column="3" value="^c\d{1,}$" compare="re_search" keep="True"/>
<filter type="column_strip" column="3" strip="c"/> <!-- get rid of c's -->
<filter type="boolean" column="3" cast="int" />
<filter type="metadata_value" ref="input" name="chromCol" column="1" />
<filter type="metadata_value" ref="input" name="startCol" column="2" />
<filter type="metadata_value" ref="input" name="endCol" column="3" />
</option>
</action>
<conditional name="out_file1">
<when datatype_isinstance="interval">
<action type="metadata" name="chromCol">
<option type="from_param" name="columnList" column="0" offset="0"> <!-- chromCol is 0-->
<filter type="multiple_splitter" column="0" separator=","/>
<filter type="column_strip" column="0"/> <!-- get rid of all external whitespace -->
<filter type="string_function" column="0" name="lower" />
<filter type="param_value" column="0" value="^c\d{1,}$" compare="re_search" keep="True"/>
<filter type="column_strip" column="0" strip="c"/> <!-- get rid of c's -->
<filter type="insert_column" value="1" iterate="True" column="0"/>
<filter type="boolean" column="1" cast="int" />
<filter type="metadata_value" ref="input" name="chromCol" column="1" />
</option>
</action>
<action type="metadata" name="startCol">
<option type="from_param" name="columnList" column="0" offset="0"> <!-- startCol is 0-->
<filter type="multiple_splitter" column="0" separator=","/>
<filter type="column_strip" column="0"/> <!-- get rid of all external whitespace -->
<filter type="string_function" column="0" name="lower" />
<filter type="param_value" column="0" value="^c\d{1,}$" compare="re_search" keep="True"/>
<filter type="column_strip" column="0" strip="c"/> <!-- get rid of c's -->
<filter type="insert_column" value="1" iterate="True" column="0"/>
<filter type="boolean" column="1" cast="int" />
<filter type="metadata_value" ref="input" name="startCol" column="1" />
</option>
</action>
<action type="metadata" name="endCol">
<option type="from_param" name="columnList" column="0" offset="0"> <!-- endCol is 0-->
<filter type="multiple_splitter" column="0" separator=","/>
<filter type="column_strip" column="0"/> <!-- get rid of all external whitespace -->
<filter type="string_function" column="0" name="lower" />
<filter type="param_value" column="0" value="^c\d{1,}$" compare="re_search" keep="True"/>
<filter type="column_strip" column="0" strip="c"/> <!-- get rid of c's -->
<filter type="insert_column" value="1" iterate="True" column="0"/>
<filter type="boolean" column="1" cast="int" />
<filter type="metadata_value" ref="input" name="endCol" column="1" />
</option>
</action>
<action type="metadata" name="nameCol" default="0">
<option type="from_param" name="columnList" column="0" offset="0"> <!-- nameCol is 0-->
<filter type="multiple_splitter" column="0" separator=","/>
<filter type="column_strip" column="0"/> <!-- get rid of all external whitespace -->
<filter type="string_function" column="0" name="lower" />
<filter type="param_value" column="0" value="^c\d{1,}$" compare="re_search" keep="True"/>
<filter type="column_strip" column="0" strip="c"/> <!-- get rid of c's -->
<filter type="insert_column" value="1" iterate="True" column="0"/>
<filter type="boolean" column="1" cast="int" />
<filter type="metadata_value" ref="input" name="nameCol" column="1" />
</option>
</action>
<action type="metadata" name="strandCol" default="0">
<option type="from_param" name="columnList" column="0" offset="0"> <!-- strandCol is 0-->
<filter type="multiple_splitter" column="0" separator=","/>
<filter type="column_strip" column="0"/> <!-- get rid of all external whitespace -->
<filter type="string_function" column="0" name="lower" />
<filter type="param_value" column="0" value="^c\d{1,}$" compare="re_search" keep="True"/>
<filter type="column_strip" column="0" strip="c"/> <!-- get rid of c's -->
<filter type="insert_column" value="1" iterate="True" column="0"/>
<filter type="boolean" column="1" cast="int" />
<filter type="metadata_value" ref="input" name="strandCol" column="1" />
</option>
</action>
</when>
</conditional>
</when>
</conditional>
</when>
</conditional>
</actions>
</data>
</outputs>
<tests>
<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>
.. class:: warningmark
**WARNING: This tool breaks column assignments.** To re-establish column assignments run the tools and click on the pencil icon in the latest history item.
.. class:: infomark
The output of this tool is always in tabular format (e.g., if your original delimiters are commas, they will be replaced with tabs). For example:
Cutting columns 1 and 3 from::
apple,is,good
windows,is,bad
will give::
apple good
windows bad
-----
**What it does**
This tool selects (cuts out) specified columns from the dataset.
- Columns are specified as **c1**, **c2**, and so on. Column count begins with **1**
- Columns can be specified in any order (e.g., **c2,c1,c6**)
- If you specify more columns than actually present - empty spaces will be filled with dots
-----
**Example**
Input dataset (six columns: c1, c2, c3, c4, c5, and c6)::
chr1 10 1000 gene1 0 +
chr2 100 1500 gene2 0 +
**cut** on columns "**c1,c4,c6**" will return::
chr1 gene1 +
chr2 gene2 +
**cut** on columns "**c6,c5,c4,c1**" will return::
+ 0 gene1 chr1
+ 0 gene2 chr2
**cut** on columns "**c8,c7,c4**" will return::
. . gene1
. . gene2
</help>
</tool>
-34
View File
@@ -1,34 +0,0 @@
#! /usr/bin/perl -w
use strict;
use warnings;
# fixedValueColumn.pl $input $out_file1 "expression" "iterate [yes|no]"
my ($input, $out_file1, $expression, $iterate) = @ARGV;
my $i = 0;
my $numeric = 0;
die "Check arguments\n" unless @ARGV == 4;
open (DATA, "<$input") or die "Cannot open $input:$!\n";
open (OUT, ">$out_file1") or die "Cannot create $out_file1:$!\n";
if ($expression =~ m/^\d+$/) {
$numeric = 1;
$i = $expression;
}
while (<DATA>) {
chop;
if ($iterate eq "no") {
print OUT "$_\t$expression\n";
} else {
print OUT "$_\t$i\n" if $numeric == 1;
print OUT "$_\t$expression-$i\n" if $numeric == 0;
++$i;
}
}
close DATA;
close OUT;
-61
View File
@@ -1,61 +0,0 @@
<tool id="addValue" name="Add column">
<description>to an existing dataset</description>
<command interpreter="perl">fixedValueColumn.pl $input $out_file1 "$exp" $iterate</command>
<inputs>
<param name="exp" size="20" type="text" value="1" label="Add this value"/>
<param format="tabular" name="input" type="data" label="to Dataset" help="Dataset missing? See TIP below" />
<param name="iterate" type="select" label="Iterate?">
<option value="no">NO</option>
<option value="yes">YES</option>
</param>
</inputs>
<outputs>
<data format="input" name="out_file1" metadata_source="input"/>
</outputs>
<tests>
<test>
<param name="exp" value="1"/>
<param name="input" value="1.bed"/>
<param name="iterate" value="no"/>
<output name="out_file1" file="eq-addvalue.dat"/>
</test>
</tests>
<help>
.. class:: infomark
**TIP:** If your data is not TAB delimited, use *Text Manipulation-&gt;Convert*
-----
**What it does**
You can enter any value and it will be added as a new column to your dataset
-----
**Example**
If you original data looks like this::
chr1 10 100 geneA
chr2 200 300 geneB
chr2 400 500 geneC
Typing **+** in the text box will generate::
chr1 10 100 geneA +
chr2 200 300 geneB +
chr2 400 500 geneC +
You can also add line numbers by selecting **Iterate: YES**. In this case if you enter **1** in the text box you will get::
chr1 10 100 geneA 1
chr2 200 300 geneB 2
chr2 400 500 geneC 3
</help>
</tool>
-19
View File
@@ -1,19 +0,0 @@
#! /usr/bin/perl -w
use strict;
use warnings;
# a wrapper for head for use in galaxy
# headWrapper.pl [filename] [# lines to show] [output]
die "Check arguments" unless @ARGV == 3;
die "Line number must be an integer\n" unless $ARGV[1]=~ m/^\d+$/;
open (OUT, ">$ARGV[2]") or die "Cannot create $ARGV[2]:$!\n";
open (HEAD, "head -n $ARGV[1] $ARGV[0]|") or die "Cannot run head:$!\n";
while (<HEAD>) {
print OUT;
}
close OUT;
close HEAD;
-42
View File
@@ -1,42 +0,0 @@
<tool id="Show beginning1" name="Select first">
<description>lines from a dataset</description>
<command interpreter="perl">headWrapper.pl $input $lineNum $out_file1</command>
<inputs>
<param name="lineNum" size="5" type="integer" value="10" label="Select first" help="lines"/>
<param format="txt" name="input" type="data" label="from"/>
</inputs>
<outputs>
<data format="input" name="out_file1" metadata_source="input"/>
</outputs>
<tests>
<test>
<param name="lineNum" value="10"/>
<param name="input" value="1.bed"/>
<output name="out_file1" file="eq-showbeginning.dat"/>
</test>
</tests>
<help>
**What it does**
This tool outputs specified number of lines from the **beginning** of a dataset
-----
**Example**
Selecting 2 lines from this::
chr7 56632 56652 D17003_CTCF_R6 310 +
chr7 56736 56756 D17003_CTCF_R7 354 +
chr7 56761 56781 D17003_CTCF_R4 220 +
chr7 56772 56792 D17003_CTCF_R7 372 +
chr7 56775 56795 D17003_CTCF_R4 207 +
will produce::
chr7 56632 56652 D17003_CTCF_R6 310 +
chr7 56736 56756 D17003_CTCF_R7 354 +
</help>
</tool>
-37
View File
@@ -1,37 +0,0 @@
import sys, re
def stop_err( msg ):
sys.stderr.write( msg )
sys.exit()
def __main__():
try:
infile = open ( sys.argv[1], 'r')
outfile = open ( sys.argv[2], 'w')
except:
stop_err( 'Cannot open or create a file\n' )
if len( sys.argv ) < 4:
stop_err( 'No columns to merge' )
else:
cols = sys.argv[3:]
skipped_lines = 0
for line in infile:
line = line.rstrip( '\r\n' )
if line and not line.startswith( '#' ):
fields = line.split( '\t' )
line += '\t'
for col in cols:
try:
line += fields[ int( col ) -1 ]
except:
skipped_lines += 1
print >>outfile, line
if skipped_lines > 0:
print 'Skipped %d invalid lines' % skipped_lines
if __name__ == "__main__" : __main__()
-63
View File
@@ -1,63 +0,0 @@
<tool id="mergeCols1" name="Merge Columns" version="1.0.1">
<description>together</description>
<command interpreter="python">
mergeCols.py
$input1
$out_file1
$col1
$col2
#for $col in $columns
${col.datacol}
#end for
</command>
<inputs>
<param format="tabular" name="input1" type="data" label="Select data" help="Dataset missing? See TIP below."/>
<param name="col1" label="Merge column" type="data_column" data_ref="input1" />
<param name="col2" label="with column" type="data_column" data_ref="input1" help="Need to add more columns? Use controls below."/>
<repeat name="columns" title="Columns">
<param name="datacol" label="Add column" type="data_column" data_ref="input1" />
</repeat>
</inputs>
<outputs>
<data format="tabular" name="out_file1" />
</outputs>
<tests>
<test>
<param name="input1" value="1.bed"/>
<param name="col1" value="4" />
<param name="col2" value="1" />
<param name="datacol" value="6" />
<output name="out_file1" file="mergeCols.dat"/>
</test>
</tests>
<help>
.. class:: infomark
**TIP:** If your data is not TAB delimited, use *Text Manipulation-&gt;Convert*
-----
**What it does**
This tool merges columns together. Any number of valid columns can be merged in any order.
-----
**Example**
Input dataset (five columns: c1, c2, c3, c4, and c5)::
1 10 1000 gene1 chr
2 100 1500 gene2 chr
merging columns "**c5,c1**" will return::
1 10 1000 gene1 chr chr1
2 100 1500 gene2 chr chr2
.. class:: warningmark
Note that all original columns are preserved and the result of merge is added as the rightmost column.
</help>
</tool>
-33
View File
@@ -1,33 +0,0 @@
#! /usr/bin/perl -w
use strict;
use warnings;
# Removes the specified number of lines from the beginning of the file.
# remove_beginning.pl [input] [num_lines] [output]
die "Check arguments" unless @ARGV == 3;
my $inputfile = $ARGV[0];
my $num_lines = $ARGV[1];
my $outputfile = $ARGV[2];
my $curCount=0;
my $fhIn;
open ($fhIn, "< $inputfile") or die "Cannot open source file";
my $fhOut;
open ($fhOut, "> $outputfile");
while (<$fhIn>)
{
$curCount++;
if ($curCount<=$num_lines)
{
next;
}
print $fhOut $_;
}
close ($fhIn) or die "Cannot close source file";
close ($fhOut) or die "Cannot close output file";
-42
View File
@@ -1,42 +0,0 @@
<tool id="Remove beginning1" name="Remove beginning">
<description>of a file</description>
<command interpreter="perl">remove_beginning.pl $input $num_lines $out_file1</command>
<inputs>
<param name="num_lines" size="5" type="integer" value="1" label="Remove first" help="lines"/>
<param format="txt" name="input" type="data" label="from"/>
</inputs>
<outputs>
<data format="input" name="out_file1" metadata_source="input"/>
</outputs>
<tests>
<test>
<param name="num_lines" value="5"/>
<param name="input" value="1.bed"/>
<output name="out_file1" file="eq-removebeginning.dat"/>
</test>
</tests>
<help>
**What it does**
This tool removes a specified number of lines from the beginning of a dataset.
-----
**Example**
Input File::
chr7 56632 56652 D17003_CTCF_R6 310 +
chr7 56736 56756 D17003_CTCF_R7 354 +
chr7 56761 56781 D17003_CTCF_R4 220 +
chr7 56772 56792 D17003_CTCF_R7 372 +
chr7 56775 56795 D17003_CTCF_R4 207 +
After removing the first 3 lines the dataset will look like this::
chr7 56772 56792 D17003_CTCF_R7 372 +
chr7 56775 56795 D17003_CTCF_R4 207 +
</help>
</tool>
-19
View File
@@ -1,19 +0,0 @@
#! /usr/bin/perl -w
use strict;
use warnings;
# a wrapper for tail for use in galaxy
# lessWrapper.pl [filename] [# lines to show] [output]
die "Check arguments" unless @ARGV == 3;
die "Line number should be an integer\n" unless $ARGV[1]=~ m/^\d+$/;
open (OUT, ">$ARGV[2]") or die "Cannot create $ARGV[2]:$!\n";
open (TAIL, "tail -n $ARGV[1] $ARGV[0]|") or die "Cannot run tail:$!\n";
while (<TAIL>) {
print OUT;
}
close OUT;
close TAIL;
-42
View File
@@ -1,42 +0,0 @@
<tool id="Show tail1" name="Select last">
<description>lines from a dataset</description>
<command interpreter="perl">tailWrapper.pl $input $lineNum $out_file1</command>
<inputs>
<param name="lineNum" size="5" type="integer" value="10" label="Select last" help="lines"/>
<param format="txt" name="input" type="data" label="from"/>
</inputs>
<outputs>
<data format="input" name="out_file1" metadata_source="input"/>
</outputs>
<tests>
<test>
<param name="lineNum" value="10"/>
<param name="input" value="1.bed"/>
<output name="out_file1" file="eq-showtail.dat"/>
</test>
</tests>
<help>
**What it does**
This tool outputs specified number of lines from the **end** of a dataset
-----
**Example**
- Input File::
chr7 57134 57154 D17003_CTCF_R7 356 -
chr7 57247 57267 D17003_CTCF_R4 207 +
chr7 57314 57334 D17003_CTCF_R5 269 +
chr7 57341 57361 D17003_CTCF_R7 375 +
chr7 57457 57477 D17003_CTCF_R3 188 +
- Show last two lines of above file. The result is::
chr7 57341 57361 D17003_CTCF_R7 375 +
chr7 57457 57477 D17003_CTCF_R3 188 +
</help>
</tool>
-106
View File
@@ -1,106 +0,0 @@
#!/usr/bin/env python
import sys
import optparse
def stop_err( msg ):
sys.stderr.write( msg )
sys.exit()
def main():
usage = """%prog [options]
options (listed below) default to 'None' if omitted
"""
parser = optparse.OptionParser(usage=usage)
parser.add_option(
'-a','--ascii',
dest='ascii',
action='store_true',
default = False,
help='Use ascii codes to defined ignored beginnings instead of raw characters')
parser.add_option(
'-q','--fastq',
dest='fastq',
action='store_true',
default = False,
help='The input data in fastq format. It selected the script skips every even line since they contain sequence ids')
parser.add_option(
'-i','--ignore',
dest='ignore',
help='A comma separated list on ignored beginnings (e.g., ">,@"), or its ascii codes (e.g., "60,42") if option -a is enabled')
parser.add_option(
'-s','--start',
dest='start',
default = '0',
help='Trim from beginning to here (1-based)')
parser.add_option(
'-e','--end',
dest='end',
default = '0',
help='Trim from here to the ned (1-based)')
parser.add_option(
'-f','--file',
dest='input_txt',
default = False,
help='Name of file to be chopped. STDIN is default')
parser.add_option(
'-c','--column',
dest='col',
default = '0',
help='Column to chop. If 0 = chop the whole line')
options, args = parser.parse_args()
invalid_starts = []
if options.input_txt:
infile = open ( options.input_txt, 'r')
else:
infile = sys.stdin
if options.ignore and options.ignore != "None":
invalid_starts = options.ignore.split(',')
if options.ascii and options.ignore and options.ignore != "None":
for i, item in enumerate( invalid_starts ):
invalid_starts[i] = chr( int( item ) )
col = int( options.col )
for i, line in enumerate( infile ):
line = line.rstrip( '\r\n' )
if line:
if options.fastq and i % 2 == 0:
print line
continue
if line[0] not in invalid_starts:
if col == 0:
if int( options.end ) > 0:
line = line[ int( options.start )-1 : int( options.end ) ]
else:
line = line[ int( options.start )-1 : ]
else:
fields = line.split( '\t' )
if col-1 > len( fields ):
stop_err('Column %d does not exist. Check input parameters\n' % col)
if int( options.end ) > 0:
fields[col - 1] = fields[col - 1][ int( options.start )-1 : int( options.end ) ]
else:
fields[col - 1] = fields[col - 1][ int( options.start )-1 : ]
line = '\t'.join(fields)
print line
if __name__ == "__main__": main()
-120
View File
@@ -1,120 +0,0 @@
<tool id="trimmer" name="Trim" version="0.0.1">
<description>leading or trailing characters</description>
<command interpreter="python">
trimmer.py -a -f $input1 -c $col -s $start -e $end -i $ignore $fastq > $out_file1
</command>
<inputs>
<param format="tabular,txt" name="input1" type="data" label="this dataset"/>
<param name="col" type="integer" value="0" label="Trim this column only" help="0 = process entire line" />
<param name="start" type="integer" size="10" value="1" label="Trim from the beginning to this position" help="1 = do not trim the beginning"/>
<param name="end" type="integer" size="10" value="0" label="Remove everything from this position to the end" help="0 = do not trim the end"/>
<param name="fastq" type="select" label="Is input dataset in fastq format?" help="If set to YES, the tool will not trim evenly numbered lines (0, 2, 4, etc...)">
<option selected="true" value="">No</option>
<option value="-q">Yes</option>
</param>
<param name="ignore" type="select" display="checkboxes" multiple="True" label="Ignore lines beginning with these characters" help="lines beginning with these are not trimmed">
<option value="62">&gt;</option>
<option value="64">@</option>
<option value="43">+</option>
<option value="60">&lt;</option>
<option value="42">*</option>
<option value="45">-</option>
<option value="61">=</option>
<option value="124">|</option>
<option value="63">?</option>
<option value="36">$</option>
<option value="46">.</option>
<option value="58">:</option>
<option value="38">&amp;</option>
<option value="37">%</option>
<option value="94">^</option>
<option value="35">&#35;</option>
</param>
</inputs>
<outputs>
<data name="out_file1" format="input" metadata_source="input1"/>
</outputs>
<tests>
<test>
<param name="input1" value="trimmer_tab_delimited.dat"/>
<param name="col" value="0"/>
<param name="start" value="1"/>
<param name="end" value="13"/>
<param name="ignore" value="62"/>
<param name="fastq" value="No"/>
<output name="out_file1" file="trimmer_a_f_c0_s1_e13_i62.dat"/>
</test>
<test>
<param name="input1" value="trimmer_tab_delimited.dat"/>
<param name="col" value="2"/>
<param name="start" value="1"/>
<param name="end" value="2"/>
<param name="ignore" value="62"/>
<param name="fastq" value="No"/>
<output name="out_file1" file="trimmer_a_f_c2_s1_e2_i62.dat"/>
</test>
</tests>
<help>
**What it does**
Trims specified number of characters from a dataset or its field (if dataset is tab-delimited).
-----
**Example 1**
Trimming this dataset::
1234567890
abcdefghijk
by setting **Trim from the beginning to this position** to *2* and **Remove everything from this position to the end** to *6* will produce::
23456
bcdef
-----
**Example 2**
Trimming column 2 of this dataset::
abcde 12345 fghij 67890
fghij 67890 abcde 12345
by setting **Trim content of this column only** to *2*, **Trim from the beginning to this position** to *2*, and **Remove everything from this position to the end** to *4* will produce::
abcde 234 fghij 67890
fghij 789 abcde 12345
-----
**Trimming FASTQ datasets**
This tool can be used to trim sequences and quality strings in fastq datasets. This is done by selected *Yes* from the **Is input dataset in fastq format?** dropdown. If set to *Yes*, the tool will skip all even numbered lines (see warning below). For example, trimming last 5 bases of this dataset::
@081017-and-081020:1:1:1715:1759
GGACTCAGATAGTAATCCACGCTCCTTTAAAATATC
+
II#IIIIIII$5+.(9IIIIIII$%*$G$A31I&amp;&amp;B
cab done by setting **Remove everything from this position to the end** to 31::
@081017-and-081020:1:1:1715:1759
GGACTCAGATAGTAATCCACGCTCCTTTAAA
+
II#IIIIIII$5+.(9IIIIIII$%*$G$A3
**Note** that headers are skipped.
.. class:: warningmark
**WARNING:** This tool will only work on properly formatted fastq datasets where (1) each read and quality string occupy one line and (2) '@' (read header) and "+" (quality header) lines are evenly numbered like in the above example.
</help>
</tool>