diff vsnp_statistics.xml @ 4:2d6c6b01319e draft

Uploaded
author greg
date Sun, 03 Jan 2021 15:47:28 +0000
parents 7fe0cbb8c894
children d0fbdeaaa488
line wrap: on
line diff
--- a/vsnp_statistics.xml	Thu Apr 30 11:01:40 2020 -0400
+++ b/vsnp_statistics.xml	Sun Jan 03 15:47:28 2021 +0000
@@ -1,5 +1,8 @@
-<tool id="vsnp_statistics" name="vSNP: statistics" version="1.0.0">
+<tool id="vsnp_statistics" name="vSNP: statistics" version="@WRAPPER_VERSION@.1" profile="@PROFILE@">
     <description></description>
+    <macros>
+        <import>macros.xml</import>
+    </macros>
     <requirements>
         <requirement type="package" version="1.16.5">numpy</requirement>
         <requirement type="package" version="0.25.3">pandas</requirement>
@@ -7,102 +10,113 @@
         <requirement type="package" version="1.2.8">xlsxwriter</requirement>
     </requirements>
     <command detect_errors="exit_code"><![CDATA[
-#import os
 #import re
-#set gzipped = 'false'
-#set input_type = $input_type_cond.input_type
 #set input_idxstats_dir = 'input_idxstats'
 #set input_metrics_dir = 'input_metrics'
 #set input_reads_dir = 'input_reads'
 mkdir -p $input_idxstats_dir &&
 mkdir -p $input_metrics_dir &&
 mkdir -p $input_reads_dir &&
-#if str($input_type) == "single":
-    #set read_type_cond = $input_type_cond.read_type_cond
-    #set read1 = $read_type_cond.read1
+
+#if $input_type_cond.input_type  == 'single_files':
+    #set read1 = $input_type_cond.read_type_cond.read1
     #set read1_identifier = re.sub('[^\s\w\-]', '_', str($read1.element_identifier))
-    #if str($read_type_cond.read_type) == "single":
-        ln -s '${read1}' '${read1_identifier}' &&
-        #if $read1.is_of_type('fastqsanger.gz'):
-            #set gzipped = 'true'
-        #end if
+    ln -s '${read1}' '${read1_identifier}' &&
+    #if $input_type_cond.read_type_cond.read_type == 'pair':
+        #set read2 = $input_type_cond.read_type_cond.read2
+        #set read2_identifier = re.sub('[^\s\w\-]', '_', str($read2.element_identifier))
+        ln -s '${read2}' '${read2_identifier}' &&
     #else:
-        #set read2 = $read_type_cond.read2
-        #set read2_identifier = re.sub('[^\s\w\-]', '_', str($read2.element_identifier))
-        ln -s '${read1}' '${read1_identifier}' &&
-        ln -s '${read2}' '${read2_identifier}' &&
-        #if $read1.is_of_type('fastqsanger.gz') and $read2.is_of_type('fastqsanger.gz'):
-            #set gzipped = 'true'
-        #end if
+        #set read2 = None
     #end if
-    #set dbkey = $input_type_cond.vsnp_azc.metadata.dbkey
 #else:
-    #for $i in $input_type_cond.reads_collection:
-        #if $i.is_of_type('fastqsanger.gz'):
-            #set gzipped = 'true'
-        #end if
-        #set filename = $i.file_name
+    #if $input_type_cond.collection_type_cond.collection_type == 'single':
+        #for $i in $input_type_cond.collection_type_cond.reads_collection:
+            #set identifier = re.sub('[^\s\w\-]', '_', str($i.element_identifier))
+            ln -s '${i.file_name}' '$input_reads_dir/${identifier}' &&
+        #end for
+    #else:
+        #set read1 = $input_type_cond.collection_type_cond.reads_collection['forward']
+        #set read1_identifier = re.sub('[^\s\w\-]', '_', str($read1.name))
+        ln -s '${read1}' '$input_reads_dir/${read1_identifier}' &&
+        #set read2 = $input_type_cond.collection_type_cond.reads_collection['reverse']
+        #set read2_identifier = re.sub('[^\s\w\-]', '_', str($read2.name))
+        ln -s '${read2}' '$input_reads_dir/${read2_identifier}' &&
+    #end if
+    #for $i in $input_type_cond.samtools_idxstats:
         #set identifier = re.sub('[^\s\w\-]', '_', str($i.element_identifier))
-        ln -s '$filename' '$input_reads_dir/$identifier' &&
+        ln -s '${i.file_name}' '$input_idxstats_dir/${identifier}' &&
     #end for
-    #for $i in $input_type_cond.samtools_idxstats_collection:
-        #set filename = $i.file_name
+    #for $i in $input_type_cond.vsnp_azc:
         #set identifier = re.sub('[^\s\w\-]', '_', str($i.element_identifier))
-        ln -s '$filename' '$input_idxstats_dir/$identifier' &&
-    #end for
-    #for $i in $input_type_cond.azc_metrics_collection:
-        #set dbkey = $i.metadata.dbkey
-        #set filename = $i.file_name
-        #set identifier = re.sub('[^\s\w\-]', '_', str($i.element_identifier))
-        ln -s '$filename' '$input_metrics_dir/$identifier' &&
+        ln -s '${i.file_name}' '$input_metrics_dir/${identifier}' &&
     #end for
 #end if
+
 python '$__tool_directory__/vsnp_statistics.py'
---dbkey '$dbkey'
---gzipped '$gzipped'
-#if str($input_type) == "single":
-    #if str($read_type_cond.read_type) == "single":
-        --read1 '${read1_identifier}'
-    #else:
-        --read1 '${read1_identifier}'
-        --read2 '${read2_identifier}'
+#if $input_type_cond.input_type == 'single_files':
+    --dbkey '$input_type_cond.samtools_idxstats.metadata.dbkey'
+    #if $input_type_cond.read_type_cond.read1.is_of_type('fastqsanger.gz'):
+        --gzipped
+    #end if
+    --read1 '${read1_identifier}'
+    #if $input_type_cond.read_type_cond.read_type == 'pair':
+      --read2 '${read2_identifier}'
     #end if
-    --samtools_idxstats '$samtools_idxstats'
-    --vsnp_azc '$vsnp_azc'
+    --samtools_idxstats '$input_type_cond.samtools_idxstats'
+    --vsnp_azc '$input_type_cond.vsnp_azc'
+#else:
+    --dbkey '$input_type_cond.samtools_idxstats[0].metadata.dbkey'
+    #if $input_type_cond.collection_type_cond.reads_collection[0].is_of_type('fastqsanger.gz'):
+        --gzipped
+    #end if
+    #if $input_type_cond.collection_type_cond.collection_type == 'paired':
+        --list_paired
+    #end if
+    --input_idxstats_dir '$input_idxstats_dir'
+    --input_metrics_dir '$input_metrics_dir'
+    --input_reads_dir '$input_reads_dir'
 #end if
 --output '$output'
 ]]></command>
     <inputs>
         <conditional name="input_type_cond">
             <param name="input_type" type="select" label="Choose the category of the files to be analyzed">
-                <option value="single" selected="true">Single files</option>
-                <option value="collection">Collections of files</option>
+                <option value="single_files" selected="true">Single files</option>
+                <option value="collections">Collections of files</option>
             </param>
-            <when value="single">
+            <when value="single_files">
                 <conditional name="read_type_cond">
                     <param name="read_type" type="select" label="Choose the read type">
-                        <option value="paired" selected="true">Paired</option>
-                        <option value="single">Single</option>
+                        <option value="single" selected="true">Single reads</option>
+                         <option value="pair">Paired reads</option>
                     </param>
-                    <when value="paired">
+                     <when value="single">
+                        <param name="read1" type="data" format="fastqsanger.gz,fastqsanger" label="Read1 fastq file"/>
+                    </when>
+                    <when value="pair">
                         <param name="read1" type="data" format="fastqsanger.gz,fastqsanger" label="Read1 fastq file"/>
                         <param name="read2" type="data" format="fastqsanger.gz,fastqsanger" label="Read2 fastq file"/>
                     </when>
+                </conditional>
+                <param name="samtools_idxstats" type="data" format="tabular" label="Samtools idxstats file"/>
+                <param name="vsnp_azc" type="data" format="tabular" label="vSNP: add zero coverage metrics file"/>
+            </when>
+            <when value="collections">
+                <conditional name="collection_type_cond">
+                    <param name="collection_type" type="select" label="Collections of single reads or paired reads?">
+                        <option value="single" selected="true">Single reads</option>
+                        <option value="paired">Paired reads in separate datasets</option>
+                    </param>
                     <when value="single">
-                        <param name="read1" type="data" format="fastqsanger.gz,fastqsanger" label="Read1 fastq file"/>
+                        <param name="reads_collection" type="data_collection" format="fastqsanger,fastqsanger.gz" collection_type="list" label="Collection of fastqsanger files"/>
+                    </when>
+                    <when value="paired">
+                        <param name="reads_collection" type="data_collection" format="fastqsanger,fastqsanger.gz" collection_type="paired" label="Collection of fastqsanger paired read files"/>
                     </when>
                 </conditional>
-                <param name="samtools_idxstats" type="data" format="tabular" label="Samtools idxstats file">
-                    <validator type="unspecified_build"/>
-                </param>
-                <param name="vsnp_azc" type="data" format="tabular" label="vSNP zero coverage metrics file">
-                    <validator type="unspecified_build"/>
-                </param>
-            </when>
-            <when value="collection">
-                <param name="reads_collection" type="data_collection" format="fastqsanger,fastqsanger.gz" collection_type="list" label="Collection of fastqsanger files"/>
-                <param name="samtools_idxstats_collection" type="data_collection" format="tabular" collection_type="list" label="Collection of samtools idxstats files"/>
-                <param name="azc_metrics_collection" type="data_collection" format="tabular" collection_type="list" label="Collection of vSNP zero-coverage metrics files"/>
+                <param name="samtools_idxstats" type="data_collection" format="tabular" collection_type="list" label="Collection of samtools idxstats files"/>
+                <param name="vsnp_azc" type="data_collection" format="tabular" collection_type="list" label="Collection of vSNP: add zero coverage metrics files"/>
             </when>
         </conditional>
     </inputs>
@@ -110,36 +124,81 @@
         <data name="output" format="xlsx"/>
     </outputs>
     <tests>
-        <test>
+        <!-- A single fastq file -->
+        <test expect_num_outputs="1">
+            <param name="input_type" value="single_files"/>
+            <param name="read_type" value="single"/>
+            <param name="read1" value="Mcap_Deer_DE_SRR650221.fastq.gz" ftype="fastqsanger.gz" dbkey="89"/>
+            <param name="samtools_idxstats" value="samtools_idxstats1.tabular" ftype="tabular" dbkey="89"/>
+            <param name="vsnp_azc" value="add_zc_metrics1.tabular" ftype="tabular" dbkey="89"/>
+            <output name="output" file="vsnp_statistics1.xlsx" ftype="xlsx" compare="sim_size"/>
+        </test>
+        <!-- A set of paired fastq files -->
+        <test expect_num_outputs="1">
+            <param name="input_type" value="single_files"/>
+            <param name="read_type" value="pair"/>
             <param name="read1" value="13-1941-6_S4_L001_R1_600000.fastq.gz" ftype="fastqsanger.gz" dbkey="89"/>
             <param name="read2" value="13-1941-6_S4_L001_R2_600000.fastq.gz" ftype="fastqsanger.gz" dbkey="89"/>
-            <param name="samtools_idxstats" value="samtools_idxstats.tabular" ftype="tabular" dbkey="89"/>
-            <param name="vsnp_azc" value="add_zc_metrics.tabular" ftype="tabular" dbkey="89"/>
-            <output name="output" file="vsnp_statistics.xlsx" ftype="xlsx" compare="sim_size"/>
+            <param name="samtools_idxstats" value="samtools_idxstats2.tabular" ftype="tabular" dbkey="89"/>
+            <param name="vsnp_azc" value="add_zc_metrics2.tabular" ftype="tabular" dbkey="89"/>
+            <output name="output" file="vsnp_statistics2.xlsx" ftype="xlsx" compare="sim_size"/>
+        </test>
+        <!-- A collection of SE fastq files -->
+        <test expect_num_outputs="1">
+            <param name="input_type" value="collections"/>
+            <param name="read_type" value="single"/>
+            <param name="reads_collection">
+                <collection type="list">
+                    <element name="Mcap_Deer_DE_SRR650221.fastq.gz" value="Mcap_Deer_DE_SRR650221.fastq.gz" dbkey="89"/>
+                    <element name="13-1941-6_S4_L001_R1_600000.fastq.gz" value="13-1941-6_S4_L001_R1_600000.fastq.gz" dbkey="89"/>
+                </collection>
+            </param>
+            <param name="samtools_idxstats">
+                <collection type="list">
+                    <element name="13-1941-6_S4_L001_R1_600000.fastq.gz" value="samtools_idxstats3.tabular" dbkey="89"/>
+                    <element name="Mcap_Deer_DE_SRR650221.fastq.gz" value="samtools_idxstats4.tabular" dbkey="89"/>
+                </collection>
+            </param>
+            <param name="vsnp_azc">
+                <collection type="list">
+                    <element name="13-1941-6_S4_L001_R1_600000.fastq.gz" value="add_zc_metrics3.tabular" dbkey="89"/>
+                    <element name="Mcap_Deer_DE_SRR650221.fastq.gz" value="add_zc_metrics4.tabular" dbkey="89"/>
+                </collection>
+            </param>
+            <output name="output" file="vsnp_statistics3.xlsx" ftype="xlsx" compare="sim_size"/>
+        </test>
+        <!-- A collection of PE fastq files -->
+        <test expect_num_outputs="1">
+            <param name="input_type" value="collections"/>
+            <param name="collection_type" value="paired"/>
+            <param name="reads_collection">
+                <collection type="paired">
+                    <element name="forward" value="13-1941-6_S4_L001_R1_600000.fastq.gz" ftype="fastqsanger.gz"/>
+                    <element name="reverse" value="13-1941-6_S4_L001_R2_600000.fastq.gz" ftype="fastqsanger.gz"/>
+                </collection>
+            </param>
+            <param name="samtools_idxstats">
+                <collection type="list">
+                    <element name="13-1941-6_S4_L001_R1_600000.fastq" value="samtools_idxstats5.tabular" dbkey="89"/>
+                </collection>
+            </param>
+            <param name="vsnp_azc">
+                <collection type="list">
+                    <element name="13-1941-6_S4_L001_R1_600000.fastq" value="add_zc_metrics5.tabular" dbkey="89"/>
+                </collection>
+            </param>
+            <output name="output" file="vsnp_statistics4.xlsx" ftype="xlsx" compare="sim_size"/>
         </test>
     </tests>
     <help>
 **What it does**
 
-Accepts a single fastqsanger sample, a set of paired read samples, or a collections of samples along with associated
-SAMtools idxstats and vSNP zero coverage metrics files and extracts information from them to produce an Excel
-spreadsheet containing statistics for each sample.  Statistics include reference, file size, mean read length, mean
-read quality, reads passing Q30, total reads, all mapped reads, unmapped reads, unmapped reads percentage of total,
-reference with coverage, average depth of coverage and good SNP count.
-
-**Required options**
-
- * **Choose the type for files to be analyzed** - select "Single files" or "Collections of files", then select the appropriate history items (single or paired fastqsanger reads or collections of fastqsanger reads and associated idxstats and vSNP zero coverage metrics files) based on the selected option..
+Accepts associated fastq files, SAMtools idxstats files and **vSNP: add zero coverage** metrics files and extracts information from them
+to produce an Excel spreadsheet containing statistics for each sample.  The samples can be single or paired reads, and all associated inputs
+can be either single files or collections of files.  The output statistics include reference, file size, mean read length, mean read quality,
+reads passing Q30, total reads, all mapped reads, unmapped reads, unmapped reads percentage of total, reference with coverage, average depth
+of coverage and good SNP count.
     </help>
-    <citations>
-        <citation type="bibtex">
-            @misc{None,
-            journal = {None},
-            author = {1. Stuber T},
-            title = {Manuscript in preparation},
-            year = {None},
-            url = {https://github.com/USDA-VS/vSNP},}
-        </citation>
-    </citations>
+    <expand macro="citations"/>
 </tool>