changeset 6:a97abb8cd15b draft

"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scanpy/ commit 5a90fd345b43ca12366f4475f4cfd88ef197e452"
author iuc
date Thu, 20 Feb 2020 08:26:18 -0500
parents 8b9610ab366a
children 3c86f71498bc
files filter.xml macros.xml
diffstat 2 files changed, 142 insertions(+), 78 deletions(-) [+]
line wrap: on
line diff
--- a/filter.xml	Mon Feb 10 05:29:59 2020 -0500
+++ b/filter.xml	Thu Feb 20 08:26:18 2020 -0500
@@ -215,13 +215,14 @@
                 <param argument="replace" type="boolean" truevalue="True" falsevalue="False" checked="false" label="Sample the counts with replacement?"/>
             </when>
         </conditional>
+        <expand macro="inputs_common_advanced"/>
     </inputs>
     <outputs>
         <expand macro="anndata_outputs"/>
     </outputs>
     <tests>
         <test>
-            <!-- test 1 -->
+            <!-- test 0 -->
             <param name="adata" value="krumsiek11.h5ad" />
             <conditional name="method">
                 <param name="method" value="pp.filter_cells"/>
@@ -231,13 +232,21 @@
                 </conditional>
             </conditional>
             <assert_stdout>
-                <has_text_matching expression="sc.pp.filter_cells"/>
-                <has_text_matching expression="min_counts=3"/>
+                <has_text_matching expression="336 × 11"/>
             </assert_stdout>
+            <section name="advanced_common">
+                <param name="show_log" value="true" />
+            </section>
+            <output name="hidden_output">
+                <assert_contents>
+                    <has_text_matching expression="sc.pp.filter_cells"/>
+                    <has_text_matching expression="min_counts=3"/>
+                </assert_contents>
+            </output>
             <output name="anndata_out" file="pp.filter_cells.krumsiek11-min_counts.h5ad" ftype="h5ad" compare="sim_size"/>
         </test>
         <test>
-            <!-- test 2 -->
+            <!-- test 1 -->
             <param name="adata" value="krumsiek11.h5ad" />
             <conditional name="method">
                 <param name="method" value="pp.filter_cells"/>
@@ -246,15 +255,20 @@
                     <param name="max_genes" value="100"/>
                 </conditional>
             </conditional>
-            <assert_stdout>
-                <has_text_matching expression="sc.pp.filter_cells"/>
-                <has_text_matching expression="adata"/>
-                <has_text_matching expression="max_genes=100"/>
-            </assert_stdout>
+            <section name="advanced_common">
+                <param name="show_log" value="true" />
+            </section>
+            <output name="hidden_output">
+                <assert_contents>
+                    <has_text_matching expression="sc.pp.filter_cells"/>
+                    <has_text_matching expression="adata"/>
+                    <has_text_matching expression="max_genes=100"/>
+                </assert_contents>
+            </output>
             <output name="anndata_out" file="pp.filter_cells.krumsiek11-max_genes.h5ad" ftype="h5ad" compare="sim_size"/>
         </test>
         <test>
-            <!-- test 3 -->
+            <!-- test 2 -->
             <param name="adata" value="krumsiek11.h5ad" />
             <conditional name="method">
                 <param name="method" value="pp.filter_genes"/>
@@ -263,39 +277,47 @@
                     <param name="min_counts" value="3"/>
                 </conditional>
             </conditional>
-            <assert_stdout>
-                <has_text_matching expression="sc.pp.filter_genes"/>
-                <has_text_matching expression="min_counts=3"/>
-            </assert_stdout>
+            <section name="advanced_common">
+                <param name="show_log" value="true" />
+            </section>
+            <output name="hidden_output">
+                <assert_contents>
+                    <has_text_matching expression="sc.pp.filter_genes"/>
+                    <has_text_matching expression="min_counts=3"/>
+                </assert_contents>
+            </output>
             <output name="anndata_out" file="pp.filter_genes.krumsiek11-min_counts.h5ad" ftype="h5ad" compare="sim_size"/>
         </test>
+        <!-- <test> -->
+        <!--     <!-\- test 3 -\-> -->
+        <!--     <!-\- Input dataset appears to be missing rank_genes_groups key... -\-> -->
+        <!--     <param name="adata" value="tl.rank_genes_groups.krumsiek11.h5ad" /> -->
+        <!--     <conditional name="method"> -->
+        <!--         <param name="method" value="tl.filter_rank_genes_groups"/> -->
+        <!--         <param name="key" value="rank_genes_groups"/> -->
+        <!--         <param name="use_raw" value="False"/> -->
+        <!--         <param name="log" value="False"/> -->
+        <!--         <param name="key_added" value="rank_genes_groups_filtered"/> -->
+        <!--         <param name="min_in_group_fraction" value="0.25"/> -->
+        <!--         <param name="max_out_group_fraction" value="0.5"/> -->
+        <!--         <param name="min_fold_change" value="3"/> -->
+        <!--     </conditional> -->
+        <!--     <output name="hidden_output"> -->
+        <!--         <assert_contents> -->
+        <!--             <has_text_matching expression="tl.filter_rank_genes_groups"/> -->
+        <!--             <has_text_matching expression="key='rank_genes_groups'"/> -->
+        <!--             <has_text_matching expression="use_raw=False"/> -->
+        <!--             <has_text_matching expression="log=False"/> -->
+        <!--             <has_text_matching expression="key_added='rank_genes_groups_filtered'"/> -->
+        <!--             <has_text_matching expression="min_in_group_fraction=0.25"/> -->
+        <!--             <has_text_matching expression="max_out_group_fraction=0.5"/> -->
+        <!--             <has_text_matching expression="min_fold_change=3"/> -->
+        <!--         </assert_contents> -->
+        <!--     </output> -->
+        <!--     <output name="anndata_out" file="pp.filter_rank_genes_groups.h5ad" ftype="h5ad" compare="sim_size"/> -->
+        <!-- </test> -->
         <test>
             <!-- test 4 -->
-            <param name="adata" value="tl.rank_genes_groups.krumsiek11.h5ad" />
-            <conditional name="method">
-                <param name="method" value="tl.filter_rank_genes_groups"/>
-                <param name="key" value="rank_genes_groups"/>
-                <param name="use_raw" value="False"/>
-                <param name="log" value="False"/>
-                <param name="key_added" value="rank_genes_groups_filtered"/>
-                <param name="min_in_group_fraction" value="0.25"/>
-                <param name="max_out_group_fraction" value="0.5"/>
-                <param name="min_fold_change" value="3"/>
-            </conditional>
-            <assert_stdout>
-                <has_text_matching expression="tl.filter_rank_genes_groups"/>
-                <has_text_matching expression="key='rank_genes_groups'"/>
-                <has_text_matching expression="use_raw=False"/>
-                <has_text_matching expression="log=False"/>
-                <has_text_matching expression="key_added='rank_genes_groups_filtered'"/>
-                <has_text_matching expression="min_in_group_fraction=0.25"/>
-                <has_text_matching expression="max_out_group_fraction=0.5"/>
-                <has_text_matching expression="min_fold_change=3"/>
-            </assert_stdout>
-            <output name="anndata_out" file="pp.filter_rank_genes_groups.h5ad" ftype="h5ad" compare="sim_size"/>
-        </test>
-        <test>
-            <!-- test 5 -->
             <param name="adata" value="blobs.h5ad"/>
             <conditional name="method">
                 <param name="method" value="pp.highly_variable_genes"/>
@@ -308,19 +330,24 @@
                 <param name="n_bins" value="20"/>
                 <param name="subset" value="false"/>
             </conditional>
-            <assert_stdout>
-                <has_text_matching expression="sc.pp.highly_variable_genes"/>
-                <has_text_matching expression="flavor='seurat'"/>
-                <has_text_matching expression="min_mean=0.0125"/>
-                <has_text_matching expression="max_mean=3"/>
-                <has_text_matching expression="min_disp=0.5"/>
-                <has_text_matching expression="n_bins=20"/>
-                <has_text_matching expression="subset=False"/>
-            </assert_stdout>
+            <section name="advanced_common">
+                <param name="show_log" value="true" />
+            </section>
+            <output name="hidden_output">
+                <assert_contents>
+                    <has_text_matching expression="sc.pp.highly_variable_genes"/>
+                    <has_text_matching expression="flavor='seurat'"/>
+                    <has_text_matching expression="min_mean=0.0125"/>
+                    <has_text_matching expression="max_mean=3"/>
+                    <has_text_matching expression="min_disp=0.5"/>
+                    <has_text_matching expression="n_bins=20"/>
+                    <has_text_matching expression="subset=False"/>
+                </assert_contents>
+            </output>
             <output name="anndata_out" file="pp.highly_variable_genes.seurat.blobs.h5ad" ftype="h5ad" compare="sim_size"/>
         </test>
         <test>
-            <!-- test 6 -->
+            <!-- test 5 -->
             <param name="adata" value="krumsiek11.h5ad" />
             <conditional name="method">
                 <param name="method" value="pp.highly_variable_genes"/>
@@ -331,17 +358,22 @@
                 <param name="n_bins" value="20"/>
                 <param name="subset" value="true"/>
             </conditional>
-            <assert_stdout>
-                <has_text_matching expression="sc.pp.highly_variable_genes"/>
-                <has_text_matching expression="flavor='cell_ranger'"/>
-                <has_text_matching expression="n_top_genes=2"/>
-                <has_text_matching expression="n_bins=20"/>
-                <has_text_matching expression="subset=True"/>
-            </assert_stdout>
+            <section name="advanced_common">
+                <param name="show_log" value="true" />
+            </section>
+            <output name="hidden_output">
+                <assert_contents>
+                    <has_text_matching expression="sc.pp.highly_variable_genes"/>
+                    <has_text_matching expression="flavor='cell_ranger'"/>
+                    <has_text_matching expression="n_top_genes=2"/>
+                    <has_text_matching expression="n_bins=20"/>
+                    <has_text_matching expression="subset=True"/>
+                </assert_contents>
+            </output>
             <output name="anndata_out" file="pp.highly_variable_genes.krumsiek11-cell_ranger.h5ad" ftype="h5ad" compare="sim_size"/>
         </test>
         <test>
-            <!-- test 7 -->
+            <!-- test 6 -->
             <param name="adata" value="krumsiek11.h5ad" />
             <conditional name="method">
                 <param name="method" value="pp.subsample"/>
@@ -351,15 +383,20 @@
                 </conditional>
                 <param name="random_state" value="0"/>
             </conditional>
-            <assert_stdout>
-                <has_text_matching expression="sc.pp.subsample"/>
-                <has_text_matching expression="fraction=0.5"/>
-                <has_text_matching expression="random_state=0"/>
-            </assert_stdout>
+            <section name="advanced_common">
+                <param name="show_log" value="true" />
+            </section>
+            <output name="hidden_output">
+                <assert_contents>
+                    <has_text_matching expression="sc.pp.subsample"/>
+                    <has_text_matching expression="fraction=0.5"/>
+                    <has_text_matching expression="random_state=0"/>
+                </assert_contents>
+            </output>
             <output name="anndata_out" file="pp.subsample.krumsiek11_fraction.h5ad" ftype="h5ad" compare="sim_size"/>
         </test>
         <test>
-            <!-- test 8 -->
+            <!-- test 7 -->
             <param name="adata" value="krumsiek11.h5ad" />
             <conditional name="method">
                 <param name="method" value="pp.subsample"/>
@@ -369,15 +406,20 @@
                 </conditional>
                 <param name="random_state" value="0"/>
             </conditional>
-            <assert_stdout>
-                <has_text_matching expression="sc.pp.subsample"/>
-                <has_text_matching expression="n_obs=10"/>
-                <has_text_matching expression="random_state=0"/>
-            </assert_stdout>
+            <section name="advanced_common">
+                <param name="show_log" value="true" />
+            </section>
+            <output name="hidden_output">
+                <assert_contents>
+                    <has_text_matching expression="sc.pp.subsample"/>
+                    <has_text_matching expression="n_obs=10"/>
+                    <has_text_matching expression="random_state=0"/>
+                </assert_contents>
+            </output>
             <output name="anndata_out" file="pp.subsample.krumsiek11_n_obs.h5ad" ftype="h5ad" compare="sim_size"/>
         </test>
         <test>
-            <!-- test 9 -->
+            <!-- test 8 -->
             <param name="adata" value="random-randint.h5ad" />
             <conditional name="method">
                 <param name="method" value="pp.downsample_counts"/>
@@ -385,12 +427,17 @@
                 <param name="random_state" value="0"/>
                 <param name="replace" value="false"/>
             </conditional>
-            <assert_stdout>
-                <has_text_matching expression="sc.pp.downsample_counts"/>
-                <has_text_matching expression="total_counts=20000"/>
-                <has_text_matching expression="random_state=0"/>
-                <has_text_matching expression="replace=False"/>
-            </assert_stdout>
+            <section name="advanced_common">
+                <param name="show_log" value="true" />
+            </section>
+            <output name="hidden_output">
+                <assert_contents>
+                    <has_text_matching expression="sc.pp.downsample_counts"/>
+                    <has_text_matching expression="total_counts=20000"/>
+                    <has_text_matching expression="random_state=0"/>
+                    <has_text_matching expression="replace=False"/>
+                </assert_contents>
+            </output>
             <output name="anndata_out" file="pp.downsample_counts.random-randint.h5ad" ftype="h5ad" compare="sim_size"/>
         </test>
     </tests>
--- a/macros.xml	Mon Feb 10 05:29:59 2020 -0500
+++ b/macros.xml	Thu Feb 20 08:26:18 2020 -0500
@@ -21,12 +21,17 @@
     </xml>
     <token name="@CMD@"><![CDATA[
 cp '$adata' 'anndata.h5ad' &&
-cat '$script_file' &&
-python '$script_file' &&
-ls .
+cat '$script_file' > '$hidden_output' &&
+python '$script_file' >> '$hidden_output' &&
+ls . >> '$hidden_output' &&
+touch 'anndata_info.txt' &&
+cat 'anndata_info.txt' @CMD_prettify_stdout@
     ]]>
     </token>
     <token name="@CMD_imports@"><![CDATA[
+import sys
+sys.stderr = open('$hidden_output', 'a')
+
 import scanpy as sc
 import pandas as pd
 import numpy as np
@@ -39,13 +44,25 @@
 adata = sc.read('anndata.h5ad')
 ]]>
     </token>
+    <xml name="inputs_common_advanced">
+        <section name="advanced_common" title="Advanced Options" expanded="false">
+            <param name="show_log" type="boolean" checked="false" label="Output Log?" />
+        </section>
+    </xml>
     <xml name="anndata_outputs">
         <data name="anndata_out" format="h5ad" from_work_dir="anndata.h5ad" label="${tool.name} (${method.method}) on ${on_string}: Annotated data matrix"/>
+        <data name="hidden_output" format="txt" label="Log file" >
+            <filter>advanced_common['show_log']</filter>
+        </data>
     </xml>
     <token name="@CMD_anndata_write_outputs@"><![CDATA[
 adata.write('anndata.h5ad')
+with open('anndata_info.txt','w', encoding='utf-8') as ainfo:
+    print(adata, file=ainfo)
 ]]>
     </token>
+    <token name="@CMD_prettify_stdout@"><![CDATA[ | sed -r '1 s|AnnData object with (.+) = (.*)\s*|\1: \2|g' | sed "s|'||g"  | sed -r 's|^\s*(.*):\s(.*)|[\1]\n-    \2|g' | sed 's|, |\n-    |g'
+    ]]></token>
     <xml name="svd_solver">
         <param name="svd_solver" type="select" label="SVD solver to use" help="">
             <option value="auto">Automatically chosen depending on the size of the problem</option>