view export.xml @ 11:e1c3c2f2a834 draft

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/anndata/ commit 656ce7ff596a8870b77848469e85b406c7bd9344
author iuc
date Sun, 12 Nov 2023 16:43:28 +0000
parents 0cb889db0910
children cfaf5a405371
line wrap: on
line source

<tool id="anndata_export" name="Export AnnData and loom files" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@">
    <description>Interconvert AnnData and Loom formats</description>
    <macros>
        <import>macros.xml</import>
    </macros>
    <expand macro="requirements"/>
    <expand macro="version_command"/>
    <command detect_errors="exit_code"><![CDATA[
#if $hd5_format.filetype == 'anndata':
    @CMD@
#else:
    @LOOMCMD@
#end if
      ]]></command>
    <configfiles>
        <configfile name="script_file"><![CDATA[
@CMD_imports@
#if $hd5_format.filetype == 'anndata':
adata = ad.read_h5ad('$hd5_format.input')
    #if $hd5_format.output_format == 'loom':
adata.write_loom('anndata.loom')
    #else if $hd5_format.output_format == 'tabular':
adata.write_csvs('.', sep="\t", skip_data = False)
    #end if
#end if
    ]]></configfile>
</configfiles>
    <inputs>
        <conditional name="hd5_format">
            <param name="filetype" type="select" label="hd5 format">
                <option value="anndata" selected="true">Anndata file</option>
                <option value="loom">Loom file</option>
            </param>
            <when value="anndata">
                <param name="input" type="data" format="h5ad" label="Annotated data matrix"/>
                <param name="output_format" type="select" label="Format to write the annotated data matrix">
                    <option value="loom">loom</option>
                    <option value="tabular">Tabular</option>
                </param>
            </when>
            <when value="loom">
                <param name="input" type="data" format="loom" label="Loom file to be exported to a series of tabular files."/>
            </when>
        </conditional>
    </inputs>
    <outputs>
        <data name="loom_output" format="loom" from_work_dir="anndata.loom" label="${tool.name} on ${on_string}: Annotated data matrix">
            <filter>hd5_format['filetype'] == 'anndata' and hd5_format['output_format'] == 'loom'</filter>
        </data>
        <data name="tabular_x" format="tabular" from_work_dir="X.csv" label="${tool.name} on ${on_string}: Matrix table (X)">
            <filter>hd5_format['filetype'] == 'anndata' and hd5_format['output_format'] == 'tabular'</filter>
        </data>
        <data name="tabular_obs" format="tabular" from_work_dir="obs.csv" label="${tool.name} on ${on_string}: Key-indexed one-dimensional observations annotation (obs)">
            <filter>hd5_format['filetype'] == 'anndata' and hd5_format['output_format'] == 'tabular'</filter>
        </data>
        <data name="tabular_obsm" format="tabular" from_work_dir="obsm.csv" label="${tool.name} on ${on_string}: Key-indexed multi-dimensional observations annotation (obsm)">
            <filter>hd5_format['filetype'] == 'anndata' and hd5_format['output_format'] == 'tabular'</filter>
        </data>
        <data name="tabular_var" format="tabular" from_work_dir="var.csv" label="${tool.name} on ${on_string}: Key-indexed one-dimensional variables annotation (var)">
            <filter>hd5_format['filetype'] == 'anndata' and hd5_format['output_format'] == 'tabular'</filter>
        </data>
        <data name="tabular_varm" format="tabular" from_work_dir="varm.csv" label="${tool.name} on ${on_string}: Key-indexed multi-dimensional variables annotation (varm)">
            <filter>hd5_format['filetype'] == 'anndata' and hd5_format['output_format'] == 'tabular'</filter>
        </data>
        <collection name="layer_tsvs" type="list" label="Layer matrices" >
            <filter>hd5_format['filetype'] == 'loom'</filter>
            <discover_datasets pattern="__designation__" format="tabular" directory="output" visible="false" />
        </collection>
        <collection name="attribute_tsvs" type="list" label="Attribute matrices" >
            <filter>hd5_format['filetype'] == 'loom'</filter>
            <discover_datasets pattern="__designation__" format="tabular" directory="attributes" visible="false" />
        </collection>
    </outputs>
    <tests>
        <test expect_num_outputs="1">
            <param name="filetype" value="anndata"/>
            <param name="input" value="krumsiek11.h5ad"/>
            <param name="output_format" value="loom"/>
            <assert_stdout>
                <has_text_matching expression="adata.write_loom"/>
            </assert_stdout>
            <output name="loom_output" value="export.krumsiek11.loom" ftype="loom" compare="sim_size"/>
        </test>
        <test expect_num_outputs="5">
            <param name="filetype" value="anndata"/>
            <param name="input" value="krumsiek11.h5ad"/>
            <param name="output_format" value="tabular"/>
            <assert_stdout>
                <has_text_matching expression="adata.write_csvs"/>
            </assert_stdout>
            <output name="tabular_x" value="export.krumsiek11.X.tabular" ftype="tabular"/>
            <output name="tabular_obs" value="export.krumsiek11.obs.tabular" ftype="tabular"/>
            <output name="tabular_obsm" value="export.krumsiek11.obsm.tabular" ftype="tabular"/>
            <output name="tabular_var" value="export.krumsiek11.var.tabular" ftype="tabular"/>
            <output name="tabular_varm" value="export.krumsiek11.varm.tabular" ftype="tabular"/>
        </test>
        <test expect_num_outputs="2">
            <param name="filetype" value="loom"/>
            <param name="input" value="loomtest.loom"/>
            <output_collection name="layer_tsvs" type="list">
                <element name="mainmatrix.tsv" value="firstlayer.tsv" ftype="tabular"/>
                <element name="extralayer.tsv" value="secondlayer.tsv" ftype="tabular"/>
                <element name="thirdlayer.tsv" value="finallayer.tsv" ftype="tabular"/>
            </output_collection>
            <output_collection name="attribute_tsvs" type="list">
                <element name="row_attr.tsv" value="rows.tsv" ftype="tabular"/>
                <element name="col_attr.tsv" value="cols.tsv" ftype="tabular"/>
            </output_collection>
        </test>
    </tests>
    <help><![CDATA[
This tool exports an AnnData dataset to a Loom file
(`write_loom method <https://anndata.readthedocs.io/en/latest/generated/anndata.AnnData.write_loom.html>`__)
or a Tabular file (`write_csvs method <https://anndata.readthedocs.io/en/latest/generated/anndata.AnnData.write_csvs.html>`__)

It can also create a series of tabular files from an input loom dataset.

@HELP@
    ]]></help>
    <expand macro="citations"/>
</tool>