<?xml version="1.0"?>
<macros>
    <xml name="requirements">
        <requirements>
            <requirement type="package" version="@DADA2_VERSION@">bioconductor-dada2</requirement>
            <yield/>
        </requirements>
    </xml>

    <token name="@DADA2_VERSION@">1.10.0</token>
    <token name="@WRAPPER_VERSION@">0</token>
    
    <xml name="version_command">
        <version_command><![CDATA[
echo $(R --version | grep version | grep -v GNU)", dada2 version" $(R --vanilla --slave -e "library(dada2); cat(sessionInfo()\$otherPkgs\$dada2\$Version)" 2> /dev/null | grep -v -i "WARNING: ")
        ]]></version_command>
    </xml>

    echo $(R --version | grep version | grep -v GNU)", DESeq2 version" $(R --vanilla --slave -e "library(dada2); cat(sessionInfo()\$otherPkgs\$dada2\$Version)" 2> /dev/null | grep -v -i "WARNING: ")

    <xml name="citations">
        <citations>
            <citation type="doi">10.1038/nmeth.3869</citation>
        </citations>
    </xml>

    <token name="@DADA_UNIQUES@">dada2_derep,dada2_dada,dada2_mergepairs</token>

    <token name="@READ_FOO@"><![CDATA[
    #def read_data($dataset)
        #if $dataset.is_of_type('dada2_derep')
            readRDS(file.path('$dataset.extra_files_path', 'Rdata'))
        #else if $dataset.is_of_type('dada2_dada')
            readRDS('$dataset')
        #else if $dataset.is_of_type('dada2_sequencetable')
            as.matrix( read.table('$dataset', header=T, sep="\t", row.names=1) )
        #else if $dataset.is_of_type('dada2_mergepairs')
              read.table('$dataset', header=T, sep="\t" )
        #else if $dataset.is_of_type('tabular')
              read.table('$dataset', header=T, sep="\t", row.names=1 )
        #else
            #raise Exception("error: unknown input type")
        #end if
    #end def
    ]]></token>
    <!-- for filterAndTrim --> 
	<xml name="trimmers">
        <section name="trim" title="trimming parameters">
            <param name="truncQ" type="integer" value="2" min="0" label="Truncate reads at quality threshold" help="Truncate reads at the first instance of a quality score less than or equal to this threshold"/>
            <param name="truncLen" type="integer" value="0" min="0" label="Truncate read length" help=""/>
            <param name="trimLeft" type="integer" value="0" min="0" label="Remove nucleotides from start" help=""/>
    		<param name="trimRight" type="integer" value="0" min="0" label="Remove nucleotides from end" help=""/>
		</section>
    </xml>
    <xml name="filters">
        <section name="filter" title="filtering parameters">
            <param name="maxLen" type="integer" value="" optional="true" min="0" label="Remove reads longer than" help=""/>
            <param name="minLen" type="integer" value="20" min="0" label="Remove reads shorter than" help=""/>
            <param name="maxN" type="integer" value="0" min="0" label="Remove reads with more Ns" help=""/>
            <param name="minQ" type="integer" value="0" min="0" label="Remove reads containing quality" help=""/>
            <param name="maxEE" type="integer" value="" optional="true" min="0" label="Remove reads by expected errors" help=""/>
        </section>
    </xml>


    <xml name="errorEstimationFunction">
        <param name="errfoo" type="select" label="Error function">
            <option value="loessErrfun">loess</option>
            <option value="noqualErrfun">noqual</option>
            <option value="PacBioErrfun">PacBio</option>
        </param>
    </xml>


</macros>
