view dada2_removeBimeraDenovo.xml @ 1:222c6944a310 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:38:39 -0500
parents 01159d734fc9
children 8b1355f37137
line wrap: on
line source

<tool id="dada2_removeBimeraDenovo" name="dada2: removeBimeraDenovo" version="@DADA2_VERSION@">
    <description>Remove bimeras from collections of unique sequences</description>
    <macros>
        <import>macros.xml</import>
    </macros>
    <expand macro="requirements"/>
    <expand macro="version_command"/>
    <command detect_errors="exit_code"><![CDATA[
    #if $unqs.is_of_type('dada.derep') or $unqs.is_of_type('dada2_dada')
        mkdir '$stable_uniques.extra_files_path' &&
    #end if
    Rscript '$dada2_script'
    ]]></command>
    <configfiles>
        <configfile name="dada2_script"><![CDATA[
library(dada2, quietly=T)
#if $unqs.is_of_type('dada2_derep') or $unqs.is_of_type('dada2_dada')
    unqs <- readRDS(file.path('$unqs.extra_files_path', 'Rdata'))
#else if $unqs.is_of_type('dada2_sequencetable')
    unqs <- as.matrix( read.table('$unqs', header=T, sep="\t", row.names=1) )
#else if $unqs.is_of_type('dada2_mergepairs')
    unqs <- read.table('$unqs', header=T, sep="\t" )
#else
    write("error: unknown input type", stderr())
    quit(1)
#end if

nonchim <- removeBimeraDenovo(unqs, method = "$method")

## - output is data.frame (mergepairs) or sequencetable (if this was the input)
## - otherwise uniques-vector

#if $unqs.is_of_type('dada.derep') or $unqs.is_of_type('dada2_dada')
    write.table(nonchim, file = '$stable_uniques', quote = F, sep = "\t", row.names = T, col.names = F)
    saveRDS(nonchim, file=file.path('$stable_uniques.extra_files_path',"Rdata"))
#else if $unqs.is_of_type('dada2_sequencetable')
    write.table(nonchim, "$stable_sequencetable", quote=F, sep="\t", row.names = T, col.names = NA)
#else if $unqs.is_of_type('dada2_mergepairs')
    write.table(nonchim, "$stable_mergepairs", quote=F, sep="\t")
#end if

## dada input
if(class(unqs)=="list"){
    unqssum<-lapply(lapply(unqs, getUniques),sum)
    nonchimsum<-lapply(nonchim,sum)
    mapply(function(X,Y) { 100*X/Y }, X=nonchimsum, Y=unqssum)
}else{
    cat("remaining nonchimeric: ", 100*sum(getUniques(nonchim))/sum(getUniques(unqs)), "%")
}
    ]]></configfile>
    </configfiles>
    <inputs>
        <param name="unqs" type="data" format="@DADA_UNIQUES@,dada2_sequencetable" label="sequence table" help=""/>
        <param name="method" type="select" label="Method">
            <option value="consensus">check samples independently for bimeras and make a consensus decision on each sequence variant</option>
            <option value="pooled">pool samples for bimera identification</option>
            <option value="per-sample">check samples independently for bimeras and remove (0-out) sequence variants from samples independently</option>
        </param>
   </inputs>
   <outputs>
        <!-- fix output filters in a later release https://github.com/galaxyproject/galaxy/issues/7464 -->
        <data name="stable_uniques" format="dada2_uniques" label="${tool.name} on ${on_string}" from_work_dir="nonchim.uniques">
            <filter>unqs.ext == "dada2_derep" or unqs.ext == "dada2_dada"</filter>
	</data>
        <data name="stable_mergepairs" format="dada2_mergepairs" label="${tool.name} on ${on_string}" from_work_dir="nonchim.mergepairs">
            <filter>unqs.ext == "dada2_mergepairs"</filter>
	</data>
        <data name="stable_sequencetable" format="dada2_sequencetable" label="${tool.name} on ${on_string}" from_work_dir="nonchim.mergepairs">
            <filter>unqs.ext == "dada2_sequencetable"</filter>
	</data>
    </outputs>
    <help><![CDATA[
        TODO: Fill in help.
    ]]></help>
    <expand macro="citations"/>
</tool>