changeset 0:20823bce09e7 draft

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/downsample commit dd00e60bdbb1fb45d395bb59dd60795e39867624
author dave
date Tue, 24 Sep 2019 16:20:27 -0400
parents
children 03aeb837e398
files downsample.xml
diffstat 1 files changed, 33 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/downsample.xml	Tue Sep 24 16:20:27 2019 -0400
@@ -0,0 +1,33 @@
+<?xml version="1.0"?>
+<tool id="dynamic_downsample" name="Dynamically downsample" version="1.0.0">
+    <description>reads to desired coverage</description>
+    <requirements>
+        <requirement type="package" version="1.9">samtools</requirement>
+        <requirement type="package" version="5.0.1">gawk</requirement>
+    </requirements>
+    <command><![CDATA[
+        if FACTOR=\$(samtools depth '$reads' | awk '{ a[i++]=\$3; } END { x=int((i+1)/2); if (x < (i+1)/2) y=(a[x-1]+a[x])/2; else y=a[x-1]; f = 1/(y/$coverage) ; if (f >= 1) exit 1 ; else print f }') ;
+            then samtools view '$reads' -s \$FACTOR -O $reads.datatype -o '$output' ;
+        else ;
+            cp '$reads' '$output'
+        fi
+        ]]>
+    </command>
+    <inputs>
+        <param name="reads" type="data" format="sam,bam" label="Reads to downsample" />
+        <param name="coverage" type="integer" value="1000" label="Target coverage" />
+    </inputs>
+    <outputs>
+        <data format="bam" name="output" label="${tool.name} on ${on_string} (Downsampled to ${coverage}x coverage)">
+            <change_format>
+                <when input="reads" value="sam" format="sam" />
+            </change_format>
+        </data>
+    </outputs>
+    <tests>
+    </tests>
+    <help>
+    </help>
+    <citations>
+    </citations>
+</tool>