view merqury.xml @ 4:09c589057ee8 draft

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/merqury commit 2c0e1d33bb5a462cd31bb4ad1ec4821520caccd4
author iuc
date Thu, 10 Aug 2023 22:57:52 +0000
parents f8113c25bc6b
children eb7b00ec347d
line wrap: on
line source

<tool id="merqury" name="Merqury" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@" profile="20.01">
    <description>evaluate the assembly quality</description>
    <macros>
        <import>macros.xml</import>
    </macros>
    <expand macro="bio_tools"/>
    <expand macro="requirements"/>
    <version_command>merqury --version</version_command>
    <command detect_errors="exit_code"><![CDATA[
        mkdir -p output_files
        #if $mode.options == 'default'
            && mkdir -p read-db.meryl
            && tar -zxf ${mode.meryldb_F1} -C read-db.meryl --strip-components=1
            #if $mode.assembly_options.number_assemblies == 'one'
                #if $mode.assembly_options.assembly_01.ext.endswith(".gz")
                    && gunzip -c $mode.assembly_options.assembly_01 > assembly.fasta
                #else
                    && ln -s '$mode.assembly_options.assembly_01' assembly.fasta
                #end if
                && merqury.sh read-db.meryl assembly.fasta ${label}
                #if 'log' in $output_selector
                    &> $log_file
                #end if
                && mv ${label}* output_files
                && find . -maxdepth 1 -name 'assembly_only*' -type f -print0 | xargs -0r mv -t output_files
            #else
                #if $mode.assembly_options.assembly_01.ext.endswith(".gz")
                    && gunzip -c $mode.assembly_options.assembly_01 > assembly_01.fasta
                #else
                    && ln -s '$mode.assembly_options.assembly_01' assembly_01.fasta
                #end if
                #if $mode.assembly_options.assembly_02.ext.endswith(".gz")
                    && gunzip -c $mode.assembly_options.assembly_02 > assembly_02.fasta
                #else
                    && ln -s '$mode.assembly_options.assembly_02' assembly_02.fasta
                #end if
                && merqury.sh read-db.meryl assembly_01.fasta assembly_02.fasta ${label}
                #if 'log' in $output_selector
                    &> $log_file
                #end if
                && mv ${label}* output_files
                && find . -maxdepth 1 -name 'assembly_only*' -type f -print0 | xargs -0r mv -t output_files
            #end if
        #else
            && mkdir -p read-db.meryl pat.meryl mat.meryl
            && tar -zxf ${mode.meryldb_F1} -C read-db.meryl --strip-components=1
            && tar -zxf ${mode.meryldb_PAT} -C pat.meryl --strip-components=1
            && tar -zxf ${mode.meryldb_MAT} -C mat.meryl --strip-components=1
            #if $mode.assembly_options.number_assemblies == 'one'
                #if $mode.assembly_options.assembly_01.ext.endswith(".gz")
                    && gunzip -c $mode.assembly_options.assembly_01 > assembly.fasta
                #else
                    && ln -s '$mode.assembly_options.assembly_01' assembly.fasta
                #end if
                && merqury.sh read-db.meryl pat.meryl mat.meryl assembly.fasta ${label}
                #if 'log' in $output_selector
                    &> $log_file
                #end if
                && mv ${label}* output_files
                && find . -maxdepth 1 -name 'assembly_only*' -type f -print0 | xargs -0r mv -t output_files
            #else
                #if $mode.assembly_options.assembly_01.ext.endswith(".gz")
                    && gunzip -c $mode.assembly_options.assembly_01 > assembly_01.fasta
                #else
                    && ln -s '$mode.assembly_options.assembly_01' assembly_01.fasta
                #end if
                #if $mode.assembly_options.assembly_02.ext.endswith(".gz")
                    && gunzip -c $mode.assembly_options.assembly_02 > assembly_02.fasta
                #else
                    && ln -s '$mode.assembly_options.assembly_02' assembly_02.fasta
                #end if
                && merqury.sh read-db.meryl pat.meryl mat.meryl assembly_01.fasta assembly_02.fasta ${label}
                #if 'log' in $output_selector
                    &> $log_file
                #end if
                && mv ${label}* output_files
                && find . -maxdepth 1 -name 'assembly_only*' -type f -print0 | xargs -0r mv -t output_files
            #end if
        #end if

        #if $output_add_headers:
        && sed -i '1s/^/assembly\tk-mer set\tsolid k-mers in assembly\tsolid k-mers in reads\tcompleteness %\n/'
          'output_files/${label}.completeness.stats'
        && sed -i '1s/^/assembly\tunique k-mers\tcommon k-mers\tQV\terror rate\n/'
          'output_files/${label}.qv'
        #end if

    ]]>    </command>
    <inputs>
        <conditional name="mode">
            <param name="options" type="select"
                label="Evaluation mode" help="Merqury allows two operational modes: default and trio mode.">
                <option value="default">Default mode</option>
                <option value="trio">Trio mode</option>
            </param>
            <when value="default">
                <param name="meryldb_F1" type="data" format="meryldb"
                            label="K-mer counts database"
                            help="Select the k-mer counts of the read set."/>
                <conditional name="assembly_options">
                    <param name="number_assemblies" type="select"
                        label="Number of assemblies" help="Select the number of assemblies.">
                        <option value="one">One assembly (pseudo-haplotype or mixed-haplotype)</option>
                        <option value="two">Two assemblies (diploid)</option>
                    </param>
                    <when value="one">
                        <param name="assembly_01" type="data" format="fasta,fasta.gz"
                            label="Genome assembly"
                            help="Select the assembled genome (FASTA)."/>
                    </when>
                    <when value="two">
                        <param name="assembly_01" type="data" format="fasta,fasta.gz"
                            label="First genome assembly"
                            help="Select the first assembled genome (FASTA)."/>
                        <param name="assembly_02" type="data" format="fasta,fasta.gz"
                            label="Second genome assembly"
                            help="Select the second assembled genome (FASTA)."/>
                    </when>
                </conditional>
            </when>
            <when value='trio'>
                <param name="meryldb_F1" type="data" format="meryldb"
                    label="F1 k-mer counts"
                    help="Select the k-mer counts of the read set (meryldb )."/>
                <param name="meryldb_PAT" type="data" format="meryldb"
                    label="Paternal hap-mer database"
                    help="K-mer counts of the paternal haplotype (meryldb)."/>
                <param name="meryldb_MAT" type="data" format="meryldb"
                    label="Maternal hap-mer database"
                    help="K-mer counts of the maternal haplotype (meryldb)."/>
                <conditional name="assembly_options">
                    <param name="number_assemblies" type="select"
                        label="Number of assemblies" help="Select the number of assemblies.">
                        <option value="one">One assembly (pseudo-haplotype or mixed-haplotype)</option>
                        <option value="two">Two assemblies (diploid)</option>
                    </param>
                    <when value="one">
                        <param name="assembly_01" type="data" format="fasta,fasta.gz"
                            label="Genome assembly"
                            help="Select the assembled genome (FASTA)."/>
                    </when>
                    <when value="two">
                        <param name="assembly_01" type="data" format="fasta,fasta.gz"
                            label="First genome assembly"
                            help="Select the first assembled genome (FASTA)."/>
                        <param name="assembly_02" type="data" format="fasta,fasta.gz"
                            label="Second genome assembly"
                            help="Select the second assembled genome (FASTA)."/>
                    </when>
                </conditional>
            </when>
        </conditional>
        <param name='label' type="text" value="output_merqury" label="Identification label" help="Assign an identification label.">
            <sanitizer invalid_char="">
                <valid initial="string.letters,string.digits">
                    <add value="_" />
                </valid>
            </sanitizer>
        </param>
        <param name="output_selector" type="select" display="checkboxes" multiple="true" optional="true" label="Output options">
            <option value="qv" selected="true">QV stats</option>
            <option value="plots" selected="true">Plots</option>
            <option value="sizes">Size files</option>
            <option value="stats" selected="true">Stats file</option>
            <option value="bed">BED: hap-mer tracks</option>
            <option value="wig">WIG: hap-mer tracks</option>
            <option value="hist">Histogram files</option>
            <option value="log">Log file</option>
        </param>
        <param name="output_add_headers" type="boolean" value="false" label="Add column header on tabular outputs" />
    </inputs>
    <outputs>
        <collection name="bed_files" type="list" label="${tool.name} on ${on_string}: BED files">
            <discover_datasets pattern="(?P&lt;name&gt;.+)\.bed" format="bed" directory="output_files"/>
            <filter>"bed" in output_selector</filter>
        </collection>
        <collection name="wig_files" type="list" label="${tool.name} on ${on_string}: WIG files">
            <discover_datasets pattern="(?P&lt;name&gt;.+)\.wig" format="wig" directory="output_files"/>
            <filter>"wig" in output_selector</filter>
        </collection>
        <collection name="qv_files" type="list" label="${tool.name} on ${on_string}: QV stats">
            <discover_datasets pattern="(?P&lt;name&gt;.+)\.qv" format="tabular" directory="output_files"/>
            <filter>"qv" in output_selector</filter>
        </collection>
        <collection name="png_files" type="list" label="${tool.name} on ${on_string}: plots">
            <discover_datasets pattern="(?P&lt;name&gt;.+)\.png" format="png" directory="output_files"/>
            <filter>"plots" in output_selector</filter>
        </collection>
        <collection name="sizes_files" type="list" label="${tool.name} on ${on_string}: size files">
            <discover_datasets pattern="(?P&lt;name&gt;.+)\.sizes" format="tabular" directory="output_files"/>
            <filter>"sizes" in output_selector</filter>
        </collection>
        <collection name="stats_files" type="list" label="${tool.name} on ${on_string}: stats">
            <discover_datasets pattern="(?P&lt;name&gt;.+)\.stats" format="tabular" directory="output_files"/>
            <filter>"stats" in output_selector</filter>
        </collection>
        <data name="log_file" format="txt" label="${tool.name} on ${on_string}: log file">
            <filter>"log" in output_selector</filter>
        </data>
        <collection name="hist_files" type="list" label="${tool.name} on ${on_string}: histograms">
            <discover_datasets pattern="(?P&lt;name&gt;.+)\.hist" format="tabular" directory="output_files"/>
            <filter>"hist" in output_selector</filter>
        </collection>
    </outputs>
    <tests>
        <!--Test 01: trio mode-->
        <test expect_num_outputs="1">
            <conditional name="mode">
                <param name="options" value="trio"/>
                <param name="meryldb_F1" value="child.meryldb" ftype="meryldb"/>
                <param name="meryldb_PAT" value="pat.meryldb" ftype="meryldb"/>
                <param name="meryldb_MAT" value="mat.meryldb" ftype="meryldb"/>
                <conditional name="assembly_options">
                    <param name="number_assemblies" value="one"/>
                    <param name="assembly_01" value="assembly.fasta.gz" ftype="fasta.gz"/>
                </conditional>
            </conditional>
            <param name="label" value="output_01"/>
            <param name="output_selector" value="sizes"/>
            <output_collection name="sizes_files" type="list" count="2">
                <element name="output_01.assembly.contig" file="output_01.assembly.contig.tabular" ftype="tabular"/>
            </output_collection>
        </test>
        <!--Test 02: standard mode with tabular headers -->
        <test expect_num_outputs="7">
            <conditional name="mode">
                <param name="options" value="default"/>
                <param name="meryldb_F1" value="read-db.meryldb" ftype="meryldb"/>
                <conditional name="assembly_options">
                    <param name="number_assemblies" value="one"/>
                    <param name="assembly_01" value="assembly.fasta.gz" ftype="fasta.gz"/>
                </conditional>
            </conditional>
            <param name="label" value="output_02"/>
            <param name="output_selector" value="stats,plots,bed,sizes,qv,wig,hist"/>
            <output_collection name="png_files" type="list" count="6">
                <element name="output_02.assembly.spectra-cn.fl">
                    <assert_contents>
                        <has_size value="71874" delta="100"/>
                    </assert_contents>
                </element>
                <element name="output_02.assembly.spectra-cn.ln">
                    <assert_contents>
                        <has_size value="71888" delta="100"/>
                    </assert_contents>
                </element>
                <element name="output_02.assembly.spectra-cn.st">
                    <assert_contents>
                        <has_size value="71123" delta="100"/>
                    </assert_contents>
                </element>
                <element name="output_02.spectra-asm.fl">
                    <assert_contents>
                        <has_size value="47245" delta="100"/>
                    </assert_contents>
                </element>
                <element name="output_02.spectra-asm.ln">
                    <assert_contents>
                        <has_size value="46896" delta="100"/>
                    </assert_contents>
                </element>
                <element name="output_02.spectra-asm.st">
                    <assert_contents>
                        <has_size value="45945" delta="100"/>
                    </assert_contents>
                </element>
            </output_collection>
            <output_collection name="stats_files" type="list" count="1">
                <element name="output_02.completeness" file="output_02.completeness.stats.tabular" ftype="tabular"/>
            </output_collection>
            <output_collection name="qv_files" type="list" count="2">
                <!--
                Had to remove this to pass test due to planemo errors
                <element name="output_02.assembly" ftype="tabular"/>
                -->
                <element name="output_02" file="output_02_qv.tabular" ftype="tabular"/>
            </output_collection>
            <output_collection name="wig_files" type="list" count="1">
                <element name="assembly_only" ftype="wig">
                    <assert_contents>
                        <has_size value="0"/>
                    </assert_contents>
                </element>
            </output_collection>
            <output_collection name="bed_files" type="list" count="1">
                <element name="assembly_only" ftype="bed">
                    <assert_contents>
                        <has_size value="0"/>
                    </assert_contents>
                </element>
            </output_collection>
            <output_collection name="hist_files" type="list" count="4">
                <element name="output_02.spectra-asm" file="output_02.spectra-asm.hist" ftype="tabular"/>
                <element name="output_02.dist_only" file="output_02.dist_only.hist" ftype="tabular"/>
                <element name="output_02.assembly.spectra-cn" file="output_02.assembly.spectra-cn.hist" ftype="tabular"/>
                <element name="output_02.assembly.only" file="output_02.assembly.only.hist" ftype="tabular"/>
            </output_collection>
        </test>
        <!--Test 03: Standard mode two assemblies-->
        <test expect_num_outputs="2">
            <conditional name="mode">
                <param name="options" value="default"/>
                <param name="meryldb_F1" value="read-db.meryldb" ftype="meryldb"/>
                <conditional name="assembly_options">
                    <param name="number_assemblies" value="two"/>
                    <param name="assembly_01" value="assembly.fasta.gz" ftype="fasta.gz"/>
                    <param name="assembly_02" value="assembly_02.fasta.gz" ftype="fasta.gz"/>
                </conditional>
            </conditional>
            <param name="label" value="output_03"/>
            <param name="output_selector" value="qv,stats"/>
            <output_collection name="stats_files" type="list" count="1">
                <element name="output_03.completeness" file="output_03.completeness.stats.tabular" ftype="tabular"/>
            </output_collection>
            <output_collection name="qv_files" type="list" count="3">
                <!-- Had to remove these to pass test due to planemo errors: "no file to compare"
                <element name="output_03.assembly_01" ftype="tabular"/>
                <element name="output_03.assembly_02" ftype="tabular"/>
                -->
                <element name="output_03" file="output_03_qv.tabular" ftype="tabular"/>
            </output_collection>
        </test>
        <!--Test 04: trio mode two assemblies-->
        <test expect_num_outputs="1">
            <conditional name="mode">
                <param name="options" value="trio"/>
                <param name="meryldb_F1" value="child.meryldb" ftype="meryldb"/>
                <param name="meryldb_PAT" value="pat.meryldb" ftype="meryldb"/>
                <param name="meryldb_MAT" value="mat.meryldb" ftype="meryldb"/>
                <conditional name="assembly_options">
                    <param name="number_assemblies" value="two"/>
                    <param name="assembly_01" value="assembly.fasta.gz" ftype="fasta.gz"/>
                    <param name="assembly_02" value="assembly_02.fasta.gz" ftype="fasta.gz"/>
                </conditional>
            </conditional>
            <param name="label" value="output_04"/>
            <param name="output_selector" value="qv"/>
            <output_collection name="qv_files" type="list" count="1">
                <element name="output_04" file="output_04_qv.tabular" ftype="tabular"/>
            </output_collection>
        </test>
        <!--Test 05: log file-->
        <test expect_num_outputs="2">
            <conditional name="mode">
                <param name="options" value="trio"/>
                <param name="meryldb_F1" value="child.meryldb" ftype="meryldb"/>
                <param name="meryldb_PAT" value="pat.meryldb" ftype="meryldb"/>
                <param name="meryldb_MAT" value="mat.meryldb" ftype="meryldb"/>
                <conditional name="assembly_options">
                    <param name="number_assemblies" value="two"/>
                    <param name="assembly_01" value="assembly.fasta.gz" ftype="fasta.gz"/>
                    <param name="assembly_02" value="assembly_02.fasta.gz" ftype="fasta.gz"/>
                </conditional>
            </conditional>
            <param name="label" value="output_05"/>
            <param name="output_selector" value="qv,log"/>
            <output_collection name="qv_files" type="list" count="1">
                <element name="output_05" file="output_04_qv.tabular" ftype="tabular"/>
            </output_collection>
            <output name="log_file" file="output_05_log.txt" ftype="txt" lines_diff='4'/>
        </test>
        <!--Test 06: standard mode with tabular headers -->
        <test expect_num_outputs="2">
            <conditional name="mode">
                <param name="options" value="default"/>
                <param name="meryldb_F1" value="read-db.meryldb" ftype="meryldb"/>
                <conditional name="assembly_options">
                    <param name="number_assemblies" value="one"/>
                    <param name="assembly_01" value="assembly.fasta.gz" ftype="fasta.gz"/>
                </conditional>
            </conditional>
            <param name="label" value="output_06"/>
            <param name="output_selector" value="stats,qv"/>
            <param name="output_add_headers" value="true"/>
            <output_collection name="stats_files" type="list" count="1">
                <element name="output_06.completeness" file="output_06.completeness.stats.tabular" ftype="tabular"/>
            </output_collection>
            <output_collection name="qv_files" type="list" count="2">
                <element name="output_06" file="output_06_qv.tabular" ftype="tabular"/>
            </output_collection>
        </test>
    </tests>
    <help><![CDATA[
.. class:: infomark

**Purpose**

Merqury allows a reference-free assembly evaluation based on efficient k-mer set operations. By comparing k-mers in a de novo
assembly to those found in unassembled high-accuracy reads, Merqury estimates base-level accuracy and completeness.

For trios, Merqury can also evaluate haplotype-specific accuracy, completeness, phase block continuity, and switch errors.

----

.. class:: infomark

**Input**

Merqury requires two types of inputs: meryldbs and the genome assemblies.
There is no need to run merqury per-assemblies. If two assemblies areprovided, Merqury generates stats for each and combined.

----

.. class:: infomark

**Output**

The generated metrics include consensus quality and k-mer completeness, and when parental genomic sequences are available (either assembled or unassembled), Merqury can output haplotype completeness, phase block statistics, switch error rates, and visual representations of phase consistency for the child’s genome. This includes TDF (or BED) features that can be displayed in a genome browser for visualizing the presence of k-mer classes across a genome (e.g., the k-mers inherited from a parental genome).

You can add column headers to the ``completeness`` and ``qv`` outputs by checking the option "Add column header on tabular outputs".

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