changeset 6:5e9171dc8244 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:25:37 -0500
parents 08192eebb47d
children 6c145a6868cc
files inspect.xml macros.xml
diffstat 2 files changed, 196 insertions(+), 118 deletions(-) [+]
line wrap: on
line diff
--- a/inspect.xml	Mon Feb 10 05:29:16 2020 -0500
+++ b/inspect.xml	Thu Feb 20 08:25:37 2020 -0500
@@ -461,13 +461,14 @@
             </when>
             <when value="pp.sqrt"/>
         </conditional>
+        <expand macro="inputs_common_advanced"/>
     </inputs>
     <outputs>
         <expand macro="anndata_outputs"/>
     </outputs>
     <tests>
         <test>
-            <!-- test 1 -->
+            <!-- test 0 -->
             <param name="adata" value="sparce_csr_matrix.h5ad" />
             <conditional name="method">
                 <param name="method" value="pp.calculate_qc_metrics"/>
@@ -476,16 +477,21 @@
                 <param name="qc_vars" value="mito,negative"/>
                 <param name="percent_top" value=""/>
             </conditional>
-            <assert_stdout>
-                <has_text_matching expression="sc.pp.calculate_qc_metrics" />
-                <has_text_matching expression="expr_type='counts'" />
-                <has_text_matching expression="var_type='genes'" />
-                <has_text_matching expression="qc_vars=\['mito', 'negative'\]" />
-            </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.calculate_qc_metrics" />
+                    <has_text_matching expression="expr_type='counts'" />
+                    <has_text_matching expression="var_type='genes'" />
+                    <has_text_matching expression="qc_vars=\['mito', 'negative'\]" />
+                </assert_contents>
+            </output>
             <output name="anndata_out" file="pp.calculate_qc_metrics.sparce_csr_matrix.h5ad" ftype="h5ad" compare="sim_size"/>
         </test>
         <test>
-            <!-- test 2 -->
+            <!-- test 1 -->
             <param name="adata" value="pp.recipe_weinreb17.paul15_subsample.h5ad" />
             <conditional name="method">
                 <param name="method" value="pp.neighbors"/>
@@ -495,14 +501,19 @@
                 <param name="pp_neighbors_method" value="umap"/>
                 <param name="metric" value="euclidean"/>
             </conditional>
-            <assert_stdout>
-                <has_text_matching expression="sc.pp.neighbors"/>
-                <has_text_matching expression="n_neighbors=15"/>
-                <has_text_matching expression="knn=True"/>
-                <has_text_matching expression="random_state=0"/>
-                <has_text_matching expression="method='umap'"/>
-                <has_text_matching expression="metric='euclidean'"/>
-            </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.neighbors"/>
+                    <has_text_matching expression="n_neighbors=15"/>
+                    <has_text_matching expression="knn=True"/>
+                    <has_text_matching expression="random_state=0"/>
+                    <has_text_matching expression="method='umap'"/>
+                    <has_text_matching expression="metric='euclidean'"/>
+                </assert_contents>
+            </output>
             <output name="anndata_out" file="pp.neighbors_umap_euclidean.recipe_weinreb17.paul15_subsample.h5ad" ftype="h5ad" compare="sim_size">
                 <assert_contents>
                     <has_h5_keys keys="X, obs, obsm, uns, var" />
@@ -510,7 +521,7 @@
             </output>
         </test>
         <test>
-            <!-- test 3 -->
+            <!-- test 2 -->
             <param name="adata" value="pp.recipe_weinreb17.paul15_subsample.h5ad" />
             <conditional name="method">
                 <param name="method" value="pp.neighbors"/>
@@ -519,18 +530,23 @@
                 <param name="pp_neighbors_method" value="gauss"/>
                 <param name="metric" value="braycurtis"/>
             </conditional>
-            <assert_stdout>
-                <has_text_matching expression="sc.pp.neighbors"/>
-                <has_text_matching expression="n_neighbors=15"/>
-                <has_text_matching expression="knn=True"/>
-                <has_text_matching expression="random_state=0"/>
-                <has_text_matching expression="method='gauss'"/>
-                <has_text_matching expression="metric='braycurtis'"/>
-            </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.neighbors"/>
+                    <has_text_matching expression="n_neighbors=15"/>
+                    <has_text_matching expression="knn=True"/>
+                    <has_text_matching expression="random_state=0"/>
+                    <has_text_matching expression="method='gauss'"/>
+                    <has_text_matching expression="metric='braycurtis'"/>
+                </assert_contents>
+            </output>
             <output name="anndata_out" file="pp.neighbors_gauss_braycurtis.recipe_weinreb17.paul15_subsample.h5ad" ftype="h5ad" compare="sim_size"/>
         </test>
         <test>
-            <!-- test 4 -->
+            <!-- test 3 -->
             <param name="adata" value="krumsiek11.h5ad" />
             <conditional name="method">
                 <param name="method" value="tl.score_genes"/>
@@ -541,20 +557,25 @@
                 <param name="use_raw" value="False"/>
                 <param name="score_name" value="score"/>
             </conditional>
-            <assert_stdout>
-                <has_text_matching expression="sc.tl.score_genes" />
-                <has_text_matching expression="gene_list=\['Gata2', 'Fog1'\]" />
-                <has_text_matching expression="ctrl_size=2" />
-                <has_text_matching expression="score_name='score'" />
-                <has_text_matching expression="n_bins=2" />
-                <has_text_matching expression="random_state=2" />
-                <has_text_matching expression="use_raw=False" />
-                <has_text_matching expression="copy=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.tl.score_genes" />
+                    <has_text_matching expression="gene_list=\['Gata2', 'Fog1'\]" />
+                    <has_text_matching expression="ctrl_size=2" />
+                    <has_text_matching expression="score_name='score'" />
+                    <has_text_matching expression="n_bins=2" />
+                    <has_text_matching expression="random_state=2" />
+                    <has_text_matching expression="use_raw=False" />
+                    <has_text_matching expression="copy=False" />
+                </assert_contents>
+            </output>
             <output name="anndata_out" file="tl.score_genes.krumsiek11.h5ad" ftype="h5ad" compare="sim_size"/>
         </test>
         <test>
-            <!-- test 5 -->
+            <!-- test 4 -->
             <param name="adata" value="krumsiek11.h5ad" />
             <conditional name="method">
                 <param name="method" value="tl.score_genes_cell_cycle"/>
@@ -570,18 +591,23 @@
                 <param name="random_state" value="1"/>
                 <param name="use_raw" value="False"/>
             </conditional>
-            <assert_stdout>
-                <has_text_matching expression="sc.tl.score_genes_cell_cycle"/>
-                <has_text_matching expression="s_genes=\['Gata2', 'Fog1', 'EgrNab'\]"/>
-                <has_text_matching expression="g2m_genes=\['Gata2', 'Fog1', 'EgrNab'\]"/>
-                <has_text_matching expression="n_bins=2"/>
-                <has_text_matching expression="random_state=1"/>
-                <has_text_matching expression="use_raw=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.tl.score_genes_cell_cycle"/>
+                    <has_text_matching expression="s_genes=\['Gata2', 'Fog1', 'EgrNab'\]"/>
+                    <has_text_matching expression="g2m_genes=\['Gata2', 'Fog1', 'EgrNab'\]"/>
+                    <has_text_matching expression="n_bins=2"/>
+                    <has_text_matching expression="random_state=1"/>
+                    <has_text_matching expression="use_raw=False"/>
+                </assert_contents>
+            </output>
             <output name="anndata_out" file="tl.score_genes_cell_cycle.krumsiek11.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="tl.rank_genes_groups"/>
@@ -596,19 +622,24 @@
                     <param name="corr_method" value="benjamini-hochberg"/>
                 </conditional>
             </conditional>
-            <assert_stdout>
-                <has_text_matching expression="sc.tl.rank_genes_groups"/>
-                <has_text_matching expression="groupby='cell_type'"/>
-                <has_text_matching expression="use_raw=True"/>
-                <has_text_matching expression="reference='rest'"/>
-                <has_text_matching expression="n_genes=100"/>
-                <has_text_matching expression="method='t-test_overestim_var'"/>
-                <has_text_matching expression="corr_method='benjamini-hochberg'"/>
-            </assert_stdout>
+            <section name="advanced_common">
+                <param name="show_log" value="true" />
+            </section>
+            <output name="hidden_output">
+                <assert_contents>
+                    <has_text_matching expression="sc.tl.rank_genes_groups"/>
+                    <has_text_matching expression="groupby='cell_type'"/>
+                    <has_text_matching expression="use_raw=True"/>
+                    <has_text_matching expression="reference='rest'"/>
+                    <has_text_matching expression="n_genes=100"/>
+                    <has_text_matching expression="method='t-test_overestim_var'"/>
+                    <has_text_matching expression="corr_method='benjamini-hochberg'"/>
+                </assert_contents>
+            </output>
             <output name="anndata_out" file="tl.rank_genes_groups.krumsiek11.h5ad" ftype="h5ad" compare="sim_size"/>
         </test>
         <test>
-            <!-- test 7 -->
+            <!-- test 6 -->
             <param name="adata" value="pbmc68k_reduced.h5ad" />
             <conditional name="method">
                 <param name="method" value="tl.rank_genes_groups"/>
@@ -630,21 +661,26 @@
                     <param name="c" value="1.0"/>
                 </conditional>
             </conditional>
-            <assert_stdout>
-                <has_text_matching expression="sc.tl.rank_genes_groups"/>
-                <has_text_matching expression="groupby='louvain'"/>
-                <has_text_matching expression="use_raw=True"/>
-                <has_text_matching expression="reference='rest'"/>
-                <has_text_matching expression="n_genes=100"/>
-                <has_text_matching expression="method='logreg'"/>
-                <has_text_matching expression="solver='newton-cg'"/>
-                <has_text_matching expression="penalty='l2'"/>
-                <has_text_matching expression="fit_intercept=True"/>
-                <has_text_matching expression="max_iter=100"/>
-                <has_text_matching expression="multi_class='auto'"/>
-                <has_text_matching expression="tol=0.0001"/>
-                <has_text_matching expression="C=1.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.tl.rank_genes_groups"/>
+                    <has_text_matching expression="groupby='louvain'"/>
+                    <has_text_matching expression="use_raw=True"/>
+                    <has_text_matching expression="reference='rest'"/>
+                    <has_text_matching expression="n_genes=100"/>
+                    <has_text_matching expression="method='logreg'"/>
+                    <has_text_matching expression="solver='newton-cg'"/>
+                    <has_text_matching expression="penalty='l2'"/>
+                    <has_text_matching expression="fit_intercept=True"/>
+                    <has_text_matching expression="max_iter=100"/>
+                    <has_text_matching expression="multi_class='auto'"/>
+                    <has_text_matching expression="tol=0.0001"/>
+                    <has_text_matching expression="C=1.0"/>
+                </assert_contents>
+            </output>
             <output name="anndata_out" file="tl.rank_genes_groups.newton-cg.pbmc68k_reduced.h5ad" ftype="h5ad" compare="sim_size">
                 <assert_contents>
                     <has_h5_keys keys="X, obs, obsm, raw.X, raw.var, uns, var" />
@@ -652,7 +688,7 @@
             </output>
         </test>
         <test>
-            <!-- test 8 -->
+            <!-- test 7 -->
             <param name="adata" value="pbmc68k_reduced.h5ad" />
             <conditional name="method">
                 <param name="method" value="tl.rank_genes_groups"/>
@@ -680,21 +716,26 @@
                     <param name="c" value="1.0"/>
                 </conditional>
             </conditional>
-            <assert_stdout>
-                <has_text_matching expression="sc.tl.rank_genes_groups"/>
-                <has_text_matching expression="groupby='louvain'"/>
-                <has_text_matching expression="use_raw=True"/>
-                <has_text_matching expression="reference='rest'"/>
-                <has_text_matching expression="n_genes=100"/>
-                <has_text_matching expression="method='logreg'"/>
-                <has_text_matching expression="solver='liblinear'"/>
-                <has_text_matching expression="penalty='l2'"/>
-                <has_text_matching expression="dual=False"/>
-                <has_text_matching expression="fit_intercept=True"/>
-                <has_text_matching expression="intercept_scaling=1.0"/>
-                <has_text_matching expression="tol=0.0001"/>
-                <has_text_matching expression="C=1.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.tl.rank_genes_groups"/>
+                    <has_text_matching expression="groupby='louvain'"/>
+                    <has_text_matching expression="use_raw=True"/>
+                    <has_text_matching expression="reference='rest'"/>
+                    <has_text_matching expression="n_genes=100"/>
+                    <has_text_matching expression="method='logreg'"/>
+                    <has_text_matching expression="solver='liblinear'"/>
+                    <has_text_matching expression="penalty='l2'"/>
+                    <has_text_matching expression="dual=False"/>
+                    <has_text_matching expression="fit_intercept=True"/>
+                    <has_text_matching expression="intercept_scaling=1.0"/>
+                    <has_text_matching expression="tol=0.0001"/>
+                    <has_text_matching expression="C=1.0"/>
+                </assert_contents>
+            </output>
             <output name="anndata_out" file="tl.rank_genes_groups.liblinear.krumsiek11.h5ad" ftype="h5ad" compare="sim_size">
                 <assert_contents>
                     <has_h5_keys keys="X, obs, obsm, raw.X, raw.var, uns, var" />
@@ -731,53 +772,73 @@
             <output name="anndata_out" file="pp.log1p.krumsiek11.h5ad" ftype="h5ad" compare="sim_size"/>
         </test>-->
         <test>
-            <!-- test 9 -->
+            <!-- test 8 -->
             <param name="adata" value="krumsiek11.h5ad" />
             <conditional name="method">
                 <param name="method" value="pp.log1p"/>
             </conditional>
-            <assert_stdout>
-                <has_text_matching expression="sc.pp.log1p"/>
-            </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.log1p"/>
+                </assert_contents>
+            </output>
             <output name="anndata_out" file="pp.log1p.krumsiek11.h5ad" ftype="h5ad" compare="sim_size"/>
         </test>
         <test>
+            <!-- test 9 -->
+            <param name="adata" value="krumsiek11.h5ad" />
+            <conditional name="method">
+                <param name="method" value="pp.scale"/>
+                <param name="zero_center" value="true"/>
+            </conditional>
+            <section name="advanced_common">
+                <param name="show_log" value="true" />
+            </section>
+            <output name="hidden_output">
+                <assert_contents>
+                    <has_text_matching expression="sc.pp.scale"/>
+                    <has_text_matching expression="zero_center=True"/>
+                </assert_contents>
+            </output>
+            <output name="anndata_out" file="pp.scale.krumsiek11.h5ad" ftype="h5ad" compare="sim_size"/>
+        </test>
+        <test>
             <!-- test 10 -->
             <param name="adata" value="krumsiek11.h5ad" />
             <conditional name="method">
                 <param name="method" value="pp.scale"/>
                 <param name="zero_center" value="true"/>
+                <param name="max_value" value="10"/>
             </conditional>
-            <assert_stdout>
-                <has_text_matching expression="sc.pp.scale"/>
-                <has_text_matching expression="zero_center=True"/>
-            </assert_stdout>
-            <output name="anndata_out" file="pp.scale.krumsiek11.h5ad" ftype="h5ad" compare="sim_size"/>
+            <section name="advanced_common">
+                <param name="show_log" value="true" />
+            </section>
+            <output name="hidden_output">
+                <assert_contents>
+                    <has_text_matching expression="sc.pp.scale"/>
+                    <has_text_matching expression="zero_center=True"/>
+                    <has_text_matching expression="max_value=10.0"/>
+                </assert_contents>
+            </output>
+            <output name="anndata_out" file="pp.scale_max_value.krumsiek11.h5ad" ftype="h5ad" compare="sim_size"/>
         </test>
         <test>
             <!-- test 11 -->
             <param name="adata" value="krumsiek11.h5ad" />
             <conditional name="method">
-                <param name="method" value="pp.scale"/>
-                <param name="zero_center" value="true"/>
-                <param name="max_value" value="10"/>
-            </conditional>
-            <assert_stdout>
-                <has_text_matching expression="sc.pp.scale"/>
-                <has_text_matching expression="zero_center=True"/>
-                <has_text_matching expression="max_value=10.0"/>
-            </assert_stdout>
-            <output name="anndata_out" file="pp.scale_max_value.krumsiek11.h5ad" ftype="h5ad" compare="sim_size"/>
-        </test>
-        <test>
-            <!-- test 12 -->
-            <param name="adata" value="krumsiek11.h5ad" />
-            <conditional name="method">
                 <param name="method" value="pp.sqrt"/>
             </conditional>
-            <assert_stdout>
-                <has_text_matching expression="sc.pp.sqrt"/>
-            </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.sqrt"/>
+                </assert_contents>
+            </output>
             <output name="anndata_out" file="pp.sqrt.krumsiek11.h5ad" ftype="h5ad" compare="sim_size"/>
         </test>
     </tests>
@@ -889,4 +950,4 @@
 `X = sqrt(X)`
     ]]></help>
     <expand macro="citations"/>
-</tool>
\ No newline at end of file
+</tool>
--- a/macros.xml	Mon Feb 10 05:29:16 2020 -0500
+++ b/macros.xml	Thu Feb 20 08:25:37 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>