<macros>
    <token name="@TOOL_VERSION@">0.3.2</token>
    <token name="@VERSION_SUFFIX@">1</token>
    <token name="@PROFILE@">21.01</token>
    <xml name="requirements">
        <requirements>
            <requirement type="package" version="@TOOL_VERSION@">episcanpy</requirement>
            <requirement type="package" version="1.0.8">bzip2</requirement>
            <requirement type="package" version="1.11">tabix</requirement>
            <requirement type="package" version="0.7.5">anndata</requirement>
            <requirement type="package" version="0.8.3">leidenalg</requirement>
            <requirement type="package" version="0.8.0">louvain</requirement>
            <yield />
        </requirements>
    </xml>
    <xml name="bio_tools">
        <xrefs>
            <xref type="bio.tools">episcanpy</xref>
        </xrefs>
    </xml>
    <xml name="citations">
        <citations>
            <citation type="doi">10.1038/s41467-021-25131-3</citation>
        </citations>
    </xml>
    <xml name="version_command">
        <version_command><![CDATA[python -c "import episcanpy as esc; print(f'{esc.__version__}')"]]></version_command>
    </xml>
    <token name="@CMD@"><![CDATA[
cp '$adata' 'anndata.h5ad' &&
cat '$script_file' > '$hidden_output' &&
python '$script_file' >> '$hidden_output' &&
touch 'anndata_info.txt' &&
cat 'anndata_info.txt' @CMD_prettify_stdout@
    ]]>
    </token>
    <token name="@CMD_imports@"><![CDATA[
import episcanpy as esc
import pandas as pd
import numpy as np
    ]]>
    </token>
    <xml name="sanitize_query" token_validinitial="string.printable">
        <sanitizer>
            <valid initial="@VALIDINITIAL@">
                <remove value="&apos;" />
            </valid>
       </sanitizer>
    </xml>
    <xml name="sanitize_vectors" token_validinitial="string.digits">
        <sanitizer>
            <valid initial="@VALIDINITIAL@">
                <add value=","/>
            </valid>
        </sanitizer>
    </xml>
    <xml name="inputs_anndata">
        <param name="adata" type="data" format="h5ad" label="Annotated data matrix"/>
    </xml>
    <token name="@CMD_read_inputs@"><![CDATA[
adata = esc.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" hidden="true">
            <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="coverage_params">
        <param argument="binary" type="boolean" truevalue="True" falsevalue="False" checked="false" 
            label="Binarized matrix?" help="To reduce computing time, you can specify if the matrix is already binary" />
        <param argument="log" type="boolean" truevalue="True" falsevalue="False" checked="false"
            label="Log transform?" />
        <param argument="threshold" type="float" min="0" value="" label="Minimum number of cells or minimumn number of features to be indicated in the plot"
            help="For coverage cells, please use min number of features and for coverage features, use min number of cells."/>
        <param argument="bins" type="integer" min="0" value="50" label="Number of bins in the output histogram plot"/>
    </xml>
    <xml name="param_plot_format">
        <param name="format" type="select" label="Format for saving figures">
            <option value="png">png</option>
            <option value="pdf">pdf</option>
            <option value="svg">svg</option>
        </param>
    </xml>
</macros>
