Mercurial > repos > mvdbeek > damidseq_average_scores
changeset 0:427f5dda8854 draft
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_average_score commit 3f1b0838d9fd6256d61490c3b2b52936b9ce2123
author | mvdbeek |
---|---|
date | Fri, 27 Apr 2018 14:54:05 -0400 |
parents | |
children | 7fd65542efc2 |
files | average_scores.xml test-data/1.bed test-data/2.bed test-data/averaged.bed |
diffstat | 4 files changed, 109 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/average_scores.xml Fri Apr 27 14:54:05 2018 -0400 @@ -0,0 +1,49 @@ +<tool id="average_score" name="Calculate average scores" version="0.1.3"> + <description>for fixed step interval files</description> + <requirements> + <requirement type="package" version="0.22">pandas</requirement> + </requirements> + <command detect_errors="exit_code"><![CDATA[ +python '$average_script' + ]]></command> +<configfiles> + <configfile name="average_script"> +import pandas as pd + +#set files = [str(f) for f in $input_files] +#set column = 3 if $input_files[0].ext in ['bed', 'bedgraph'] else 5 +d = {} +#for f in $files: +d['$f'] = pd.read_csv('$f', usecols=[$column], sep="\t", skiprows=$skiprows, header=None, squeeze=True) +#end for +df = pd.DataFrame.from_dict(d) +mean = df.mean(axis=1) +with open('$averaged_output', 'w') as out, open('$files[0]') as first_file: + for i, line in enumerate(first_file): + fields = line.strip().split("\t") + if i >= $skiprows: + fields[$column] = str(mean[i - $skiprows]) + out.write("%s\n" % "\t".join(fields)) + </configfile> +</configfiles> + <inputs> + <param name="input_files" type="data" multiple="true" format="bed,bedgraph,gff" label="Select the files for which to average the score"/> + <param name="skiprows" type="integer" min="0" value="0" label="Skip the first N rows" help="To skip comments and track definition lines"/> + </inputs> + <outputs> + <data name="averaged_output" format_source="input_files" label="${tool.name} on ${on_string}"/> + </outputs> + <tests> + <test> + <param name="input_files" value="1.bed,2.bed" ftype="bed"/> + <output name="averaged_output" value="averaged.bed" ftype="bed"/> + </test> + </tests> + <help><![CDATA[ +What it does +------------ + +This tool calculates the average value for the score column across many datasets. + + ]]></help> +</tool>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test-data/1.bed Fri Apr 27 14:54:05 2018 -0400 @@ -0,0 +1,20 @@ +X 23522161 23522595 0 +X 23522595 23522617 0 +X 23522617 23522667 0 +X 23522667 23522718 0 +X 23522718 23523060 0 +X 23523060 23523689 0 +X 23523689 23523745 0 +X 23523745 23524267 0 +X 23524267 23524356 -0.104752855109578 +X 23524356 23524568 -0.293877189116431 +X 23524568 23524641 -1.53013740012243 +X 23524641 23525198 -1.58606530197667 +X 23525198 23525317 -0.0307134820917063 +X 23525317 23525617 -0.00619522786809301 +X 23525617 23525880 -0.0548220080355809 +X 23525880 23525964 -0.154408546338667 +X 23525964 23526598 -0.0690303255876258 +X 23526598 23526813 -0.0154384717774205 +X 23526813 23526834 0 +X 23526834 23527211 0
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test-data/2.bed Fri Apr 27 14:54:05 2018 -0400 @@ -0,0 +1,20 @@ +X 23522161 23522595 0 +X 23522595 23522617 0 +X 23522617 23522667 0 +X 23522667 23522718 0 +X 23522718 23523060 0 +X 23523060 23523689 0 +X 23523689 23523745 0 +X 23523745 23524267 0 +X 23524267 23524356 -0.0146345659674355 +X 23524356 23524568 -0.0422122702539344 +X 23524568 23524641 -0.192452892061725 +X 23524641 23525198 -0.200392807926829 +X 23525198 23525317 -0.0178237930863262 +X 23525317 23525617 -0.0110608256166981 +X 23525617 23525880 -0.0703964912539701 +X 23525880 23525964 -0.301695035600013 +X 23525964 23526598 -0.0461899200637665 +X 23526598 23526813 0 +X 23526813 23526834 0 +X 23526834 23527211 0
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test-data/averaged.bed Fri Apr 27 14:54:05 2018 -0400 @@ -0,0 +1,20 @@ +X 23522161 23522595 0.0 +X 23522595 23522617 0.0 +X 23522617 23522667 0.0 +X 23522667 23522718 0.0 +X 23522718 23523060 0.0 +X 23523060 23523689 0.0 +X 23523689 23523745 0.0 +X 23523745 23524267 0.0 +X 23524267 23524356 -0.05969371053850675 +X 23524356 23524568 -0.1680447296851827 +X 23524568 23524641 -0.8612951460920775 +X 23524641 23525198 -0.8932290549517494 +X 23525198 23525317 -0.024268637589016248 +X 23525317 23525617 -0.008628026742395555 +X 23525617 23525880 -0.0626092496447755 +X 23525880 23525964 -0.22805179096933997 +X 23525964 23526598 -0.05761012282569615 +X 23526598 23526813 -0.00771923588871025 +X 23526813 23526834 0.0 +X 23526834 23527211 0.0