<tool id="baredsc_combine_1d" name="Combine multiple 1D Models" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@" profile="20.01" license="MIT">
    <description>from baredSC</description>
    <macros>
        <import>macros.xml</import>
    </macros>
    <expand macro="edam_topics"/>
    <edam_operations>
        <edam_operation>operation_2495</edam_operation>
    </edam_operations>
    <xrefs>
        <xref type="bio.tools">baredsc</xref>
    </xrefs>
    <expand macro="requirements"/>
    <command detect_errors="exit_code"><![CDATA[
    ## Create symlinks
    #for $i, $output in enumerate($MCMC.outputs):
        ln -s '$output' '${i}.npz' &&
    #end for

    ## Run
    combineMultipleModels_1d
    ## Required inputs:
    @REQUIRED_INPUTS_1D@

    ## Filter cells
    @FILTER_CELLS@

    @COMBINE_OUTPUTS@
    ## MCMC
    @MCMC_1D@
    ## Plots
    @PLOTS@
    @PRETTYBINS_1D@
    ## Advanced
    @ADVANCED_COMMON_X@
    ## Outputs
    --figure baredSC.$plots.image_file_format &&
    mkdir output &&
    @ORDER_OUTPUTS_1D@
    ]]></command>
    <inputs>
        <expand macro="macro_input_counts"/>
        <expand macro="macro_single_gene"/>
        <expand macro="macro_filter_cells"/>
        <section name="MCMC" title="MCMC parameters">
            <expand macro="combine_outputs" d="1" />
            <expand macro="macro_MCMC_params_common_axis" axis="x" />
            <expand macro="macro_scale_seed"/>
        </section>
        <section name="plots" title="Customize plots">
            <expand macro="macro_plots"/>
            <expand macro="macro_prettybins_1d"/>
        </section>
        <section name="advanced" title="Advanced parameters" expanded="false">
            <expand macro="macro_advanced_common_axis" axis="x"/>
            <expand macro="macro_advanced_evidence"/>
        </section>
    </inputs>
    <outputs>
        <data format="tabular" name="pdf" label="${tool.name} on $getVar('input_counts.input', 'input_counts.inputAnnData') for ${geneColName}: PDF with error bar" from_work_dir="output/baredSC_pdf.txt">
            <actions>
                <action name="column_names" type="metadata" default="x,low,mean,high,median" />
            </actions>
        </data>
        <data format="png" name="plot" label="${tool.name} on $getVar('input_counts.input', 'input_counts.inputAnnData') for ${geneColName}: plot" from_work_dir="baredSC">
            <change_format>
                <when input="plots.image_file_format" value="png" format="png" />
                <when input="plots.image_file_format" value="svg" format="svg" />
                <when input="plots.image_file_format" value="pdf" format="pdf" />
            </change_format>
        </data>
        <collection type="list" name="other_outputs" label="${tool.name} on $getVar('input_counts.input', 'input_counts.inputAnnData') for ${geneColName}: plots and txt">
            <discover_datasets pattern="baredSC_(?P&lt;identifier_0&gt;\S+)\.(?P&lt;ext&gt;.*)"/>
        </collection>
    </outputs>
    <tests>
        <!-- First test -->
        <test>
            <conditional name="input_counts">
                <param name="filetype" value="tabular"/>
                <param name="input" value="nih3t3_generated_2d_2.txt"/>
            </conditional>
            <param name="geneColName" value="0.5_0_0_0.5_x"/>
            <section name="MCMC">
                <param name="outputs" value="small_1gauss.npz,small_2gauss.npz"/>
                <param name="nx" value="10"/>
            </section>
            <section name="plots">
                <param name="title" value="first gene combine 1 and 2 gauss"/>
                <param name="prettyBins" value="100"/>
            </section>
            <!--In the next output pdf means probability density function-->
            <output name="pdf" ftype="tabular">
                <assert_contents>
                    <has_text_matching expression="x\s+low\s+mean\s+high\s+median"/>
                    <has_n_lines n="101"/>
                    <has_line_matching expression="0\.0125\s+0\.12[0-9]+\s+0\.37[0-9]+\s+0\.64[0-9]+\s+0\.33[0-9]+"/>
                </assert_contents>
            </output>
            <output name="plot" ftype="png">
                <assert_contents>
                    <has_size value="244510" delta="20000"/>
                </assert_contents>
            </output>
            <output_collection name="other_outputs" count="6" type="list">
                <element name="individuals" ftype="png">
                    <assert_contents>
                        <has_size value="120034" delta="10000"/>
                    </assert_contents>
                </element>
                <element name="with_posterior" ftype="png">
                    <assert_contents>
                        <has_size value="253397" delta="20000"/>
                    </assert_contents>
                </element>
                <element name="posterior_per_cell" ftype="txt">
                    <assert_contents>
                        <has_n_lines n="2362"/>
                        <has_line_matching expression="mu\s+sd"/>
                    </assert_contents>
                </element>
                <element name="posterior_andco" ftype="png">
                    <assert_contents>
                        <has_size value="213773" delta="10000"/>
                    </assert_contents>
                </element>
                <element name="posterior_individuals" ftype="png">
                    <assert_contents>
                        <has_size value="108794" delta="10000"/>
                    </assert_contents>
                </element>
                <element name="means" ftype="txt">
                    <assert_contents>
                        <has_n_lines n="15001"/>
                    </assert_contents>
                </element>
            </output_collection>
            <assert_stdout>
                <has_text text="You have 2361 cells."/>
                <has_text text="Using 12 samples from output 0."/>
                <has_text text="Using 1 samples from output 0."/>
            </assert_stdout>
        </test>
    </tests>
    <expand macro="helpcitations"/>
</tool>