view dada2_filterAndTrim.xml @ 1:c16bf57d089a draft

planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/tree/topic/dada2/tools/dada2 commit d63c84012410608b3b5d23e130f0beff475ce1f8-dirty
author matthias
date Fri, 08 Mar 2019 08:36:35 -0500
parents 1d6e206b8291
children ea3c356bff55
line wrap: on
line source

<tool id="dada2_filterAndTrim" name="dada2: filterAndTrim" version="@DADA2_VERSION@">
    <description>Filters and trims an short read data</description>
    <macros>
        <import>macros.xml</import>
    </macros>
    <expand macro="requirements"/>
    <expand macro="version_command"/>
    <command detect_errors="exit_code"><![CDATA[
Rscript '$dada2_script'
sed -i '1!b;s/^/#dataset/' $outtab
    ]]></command>
    <configfiles>
        <configfile name="dada2_script"><![CDATA[
truncQ <- c($trim.truncQ)
truncLen <- c($trim.truncLen)
trimLeft <- c($trim.trimLeft)
trimRight <- c($trim.trimRight)
#if str($filter.maxLen) == ""
    maxLen <- c(Inf)
#else:
    maxLen <- c($filter.maxLen)
#end if
minLen <- c($filter.minLen)
maxN <- c($filter.maxN)
minQ <- c($filter.minQ)
#if str($filter.maxEE) == ""
    maxEE <- c(Inf)
#else:
    maxEE <- c($filter.maxEE)
#end if
#if $paired_cond.paired_select == "TRUE" and $seprev_cond.seprev_select == "yes"
    truncQ <- c(truncQ,$seprev_cond.trim.truncQ)
    truncLen <- c(truncLen,$seprev_cond.trim.truncLen)
    trimLeft <- c(trimLeft,$seprev_cond.trim.trimLeft)
    trimRight <- c(trimRight,$seprev_cond.trim.trimRight)
    #if str($seprev_cond.filter.maxLen) == ""
        maxLen <- c(maxLen,Inf)
    #else:
        maxLen <- c(maxLen,$seprev_cond.filter.maxLen)
    #end if
    minLen <- c(minLen,$seprev_cond.filter.minLen)
    maxN <- c(maxN,$seprev_cond.filter.maxN)
    minQ <- c(minQ,$seprev_cond.filter.minQ)
    #if str($seprev_cond.filter.maxEE) == ""
        maxEE <- c(maxEE,Inf)
    #else:
        maxEE <- c(maxEE,$seprev_cond.filter.maxEE)
    #end if
#end if

fwd <- NULL
rev <- NULL
filt.fwd <- NULL
filt.rev <- NULL
#if $paired_cond.paired_select == "TRUE"
    fwd <- c(fwd, '$paired_cond.reads.forward')
	rev <- c(rev, '$paired_cond.reads.reverse')
    filt.fwd <- c(filt.fwd, '$paired_output.forward')
	filt.rev <- c(filt.rev, '$paired_output.reverse')
#else
    fwd <- c(fwd, '$paired_cond.reads')
    filt.fwd <- c(filt.fwd, '$output')
#end if

library(dada2, quietly=T)

ftout <- filterAndTrim(fwd, filt.fwd, rev = rev, filt.rev,  compress = TRUE,
    truncQ = truncQ, truncLen = truncLen, trimLeft = trimLeft, trimRight = trimRight, maxLen = maxLen,
    minLen = minLen, maxN = maxN, minQ = minQ, maxEE = maxEE, rm.phix = $rmPhiX, orient.fwd = '$orientFwd')
    
rownames(ftout) <- c( '$paired_cond.reads.element_identifier' )

write.table(ftout, "$outtab", quote=F, sep="\t", col.names=NA)
    ]]></configfile>
    </configfiles>
    <inputs>
        <conditional name="paired_cond">
            <param name="paired_select" type="select" label="Paired reads">
                <option value="TRUE">yes</option>
                <option value="FALSE">no</option>
            </param>
            <when value="TRUE">
                <param name="reads" type="data_collection" collection_type="paired" format="fastqsanger,fastqsanger.gz" label="Paired short read data"/>
            </when>
            <when value="FALSE">
                <param name="reads" type="data" format="fastqsanger,fastqsanger.gz" label="Short read data"/>
            </when>
        </conditional>
        <expand macro="trimmers"/>
        <expand macro="filters"/>
        <conditional name="seprev_cond">
            <param name="seprev_select" type="select" label="Separate filters and trimmers for reverse reads" help="only applies to paired end data">
                <option value="no">no</option>
                <option value="yes">yes</option>
            </param>
            <when value="no"/>
            <when value="yes">
                <expand macro="trimmers"/>
                <expand macro="filters"/>
            </when> 
        </conditional>
        <param name="rmPhiX" truevalue="TRUE" falsevalue="FALSE" type="boolean" checked="true" label="Discard reads matching PhiX" />
        <param name="orientFwd" type="text" value="" optional="true" label="String present at the start of valid reads" />
    </inputs>
    <outputs>
        <collection name="paired_output" type="paired">
            <data name="forward" format="fastqsanger.gz" from_work_dir="filt_forward.fastq.gz" />
            <data name="reverse" format="fastqsanger.gz" from_work_dir="filt_reverse.fastq.gz" />
            <filter>paired_cond['paired_select'] == 'TRUE'</filter>
        </collection>   
        <data name="output" format="fastqsanger.gz" from_work_dir="filt_forward.fastq.gz">
            <filter>paired_cond['paired_select'] == 'FALSE'</filter>
        </data>
        <data name="outtab" format="tabular" label="${tool.name} on ${on_string}: Statistics"/>
    </outputs>
	<tests>
        <!-- paired data -->
        <test>
            <conditional name="paired_cond">
                <param name="paired_select" value="TRUE"/>
    			<param name="reads">
                    <collection type="paired">
                        <element name="forward" value="F3D0_S188_L001_R1_001.fastq" ftype="fastqsanger"/>
                        <element name="reverse" value="F3D0_S188_L001_R2_001.fastq" ftype="fastqsanger"/>
                    </collection>
    			</param>
    		</conditional>
            <output_collection name="paired_output" count="2">
                <element name="forward" value="filterAndTrim_paired_F3D0_R1.fq.gz" ftype="fastqsanger.gz" />
                <element name="reverse" value="filterAndTrim_paired_F3D0_R2.fq.gz" ftype="fastqsanger.gz" />
            </output_collection>
        </test>
        <!-- paired data -->
        <test>
            <conditional name="paired_cond">
                <param name="paired_select" value="FALSE"/>
    			<param name="reads" value="F3D0_S188_L001_R1_001.fastq" ftype="fastqsanger"/>
    		</conditional>
            <output name="output" value="filterAndTrim_single_F3D0_R1.fq.gz" ftype="fastqsanger.gz" />
	    </test>
		<!-- TODO parameter tests -->
    </tests>

    <help><![CDATA[
        TODO: Fill in help.
    ]]></help>
    <expand macro="citations"/>
</tool>