view reheader.xml @ 0:aa82b2e54055 draft

planemo upload for repository https://github.com/wm75/mimodd_galaxy_wrappers commit b36048cd608ede0ec6f6559648525c9350caae34-dirty
author wolma
date Sat, 11 Nov 2017 18:19:22 -0500
parents
children 1425ea794026
line wrap: on
line source

<tool id="mimodd_reheader" name="MiModD Reheader" version="@MIMODD_WRAPPER_VERSION@">
    <description>
    takes a BAM file and generates a copy with the original header (if any) replaced or modified by that found in a template SAM file
    </description>
    <macros>
        <import>macros.xml</import>
        <macro name="getreadgroupinfo">
            <conditional name="rginfo">
                <param name="source" type="select"
                label="source of new read-group information">
                    <option value="from_file">existing SAM file</option>
                    <option value="from_form">input form</option>
                </param>
                <when value="from_file">
                    <param name="data" type="data" format="sam"
                    label="read-group template file in SAM format"
                    help="use the read group information found in this file" />
                    <repeat name="rg" title="custom read-group mapping" default="0" min="0"
                    help="read-group information found in the input file, by default, gets updated / replaced with information from template file read-groups with matching IDs. Alternatively, you may specify explicit read-group mappings below.">
                        <param name="source_id" type="text"
                        label="modify input file information for read-group ID (will create the read-group if it does not exist)" />
                        <param name="rg_id" type="text"
                        label="with template file information for read-group ID" />
                    </repeat>
                </when>
                <when value="from_form">
                    <repeat name="rg" title="new read-group info" default="1" min="1">
                        <param name="source_id" type="text"
                        label="read-group ID (will create the read-group if it does not exist)"
                        help="required field">
                            <validator type="empty_field" />
                        </param>
                        <param name="rg_id" type="hidden" value="" />
                        <param name="rg_sm" type="text" label="sample name"
                        help="required field">
                            <validator type="empty_field" />
                        </param>
                        <param name="rg_ds" type="text" label="description" />
                        <param name="rg_date" type="text"
                        label="date (YY-MM-DD format) the run was produced" />
                        <param name="rg_cn" type="text"
                        label="name of sequencing center" />
                        <param name="rg_lb" type="text" label="read-group library" />
                        <param name="rg_pl" type="text"
                        label="platform/technology used to produce the reads" />
                        <param name="rg_pi" type="text"
                        label="predicted median insert size" />
                        <param name="rg_pu" type="text" 
                        label="platform unit; unique identifier" />
                    </repeat>    
                </when>
            </conditional>
        </macro>
    </macros>
    <expand macro="requirements" />
    <expand macro="stdio" />
    <expand macro="version_command" />
    <command><![CDATA[
    #if ($str($rg.treat_rg) != "ignore" and $str($rg.rginfo.source) == "from_form") or $str($co.treat_co) != "ignore":
      mimodd header
      #if $str($rg.treat_rg) != "ignore" and $str($rg.rginfo.source) == "from_form":
        #for $rginfo in $rg.rginfo.rg
      	  #if $str($rginfo.source_id):
            --rg-id '${rginfo.source_id}'
          #end if
          #if $str($rginfo.rg_sm):
      	    --rg-sm '${rginfo.rg_sm}'
          #end if
	      #if $str($rginfo.rg_cn):
		    --rg-cn '${rginfo.rg_cn}'
		  #else:
		    --rg-cn ""
	      #end if
	      #if $str($rginfo.rg_ds):
		    --rg-ds '${rginfo.rg_ds}'
		  #else:
		    --rg-ds ""
	      #end if	
	      #if $str($rginfo.rg_date):
		    --rg-dt '${rginfo.rg_date}'
		  #else:
		    --rg-dt ""
	      #end if
	      #if $str($rginfo.rg_lb):
		    --rg-lb '${rginfo.rg_lb}'
		  #else:
		    --rg-lb ""
	      #end if
	      #if $str($rginfo.rg_pl):
		    --rg-pl '${rginfo.rg_pl}'
		  #else:
		    --rg-pl ""
	      #end if
	      #if $str($rginfo.rg_pi):
		    --rg-pi '${rginfo.rg_pi}'
		  #else:
		    --rg-pi ""
	      #end if
	      #if $str($rginfo.rg_pu):
		    --rg-pu '${rginfo.rg_pu}'
		  #else:
		    --rg-pu ""
	      #end if
	    #end for
	  #end if
	  #if $str($co.treat_co) != "ignore":
	    --co
	    #for $comment in $co.coinfo
          #if $str($comment.line):
	        '${comment.line}'
	      #end if
	    #end for
	  #end if
      | 
    #end if
    mimodd reheader '$inputfile' --sq ignore --rg ${rg.treat_rg}
    #if $str($rg.treat_rg) != "ignore":
      #if $str($rg.rginfo.source) == "from_file":
        '${rg.rginfo.data}'
      #else:
        - 
      #end if
      #for $rgmapping in $rg.rginfo.rg
        #if $str($rgmapping.source_id) and $str($rgmapping.rg_id):
          '$str($rgmapping.source_id)' : '$str($rgmapping.rg_id)'
        #end if
      #end for     
    #end if
    
    --co ${co.treat_co}
    #if $str($co.treat_co) != "ignore":
      -
    #end if

    #set $restr = ""
    #for $rename in $rg_renaming
      #set $restr = $restr + ($str($rename.from) and $str($rename.to) and "'" + $str($rename.from) + "' : '" + $str($rename.to) + "' ")
    #end for
    #if $restr
      --rgm $restr
    #end if
 
    #set $restr = ""
    #for $rename in $sq_renaming
      #set $restr = $restr + ($str($rename.from) and $str($rename.to) and "'" + $str($rename.from) + "' : '" + $str($rename.to) + "' ")
    #end for
    #if $restr
      --sqm $restr
    #end if

    -o '$output'  
    ]]></command>
    
    <inputs>
        <param name="inputfile" type="data" format="bam"
        label="input dataset in BAM format" help="the file to reheader." />
        <conditional name="rg">
            <param name="treat_rg" type="select"
            label="modify read-group information?"
            help="Replace mode will ignore ALL existing read group information in the input file and use ONLY template information, Update mode will COPY existing input file information and UPDATE it with template information; choose No, ... to leave read-group information alone.">
                <option value="ignore">No, do not change read-groups.</option>
                <option value="update">Yes, update existing information</option>
                <option value="replace">Yes, replace existing information</option>
            </param>
            <when value="update">
                <expand macro="getreadgroupinfo" />
            </when>
            <when value="replace">
                <expand macro="getreadgroupinfo" />
            </when>
            <when value="ignore">
            </when>
        </conditional>
        <conditional name="co">
            <param name="treat_co" type="select"
            label="modify comments in the input file?">
                <option value="ignore">No, do not change comments.</option>
                <option value="update">Yes, append new comments to existing ones</option>
                <option value="replace">Yes, replace all existing comments</option>
            </param>
            <when value="update">
                <repeat name="coinfo" title="comment line" default="0" min="0">
                    <param name="line" type="text" size="80" />
                </repeat>
            </when>
            <when value="replace">
                <repeat name="coinfo" title="comment line" default="0" min="0">
                    <param name="line" type="text" size="80" />
                </repeat>
            </when>
            <when value="ignore">
            </when>
        </conditional>
        <repeat name="rg_renaming" title="rename read-group" default="0" min="0"
        help="Warning: changing read-group IDs may increase job runtime substantially.">
            <param name="from" type="text" size="30" label="old name"
            help="as it appears in the current input file header"/>
            <param name="to" type="text" size="30" label="new name" />
        </repeat>
        <repeat name="sq_renaming" title="rename sequence" default="0" min="0"
        help="Warning: changing sequence names may increase job runtime substantially.">
            <param name="from" type="text" size="30" label="old name"
            help="as it appears in the current input file header"/>
            <param name="to" type="text" size="30" label="new name" />
        </repeat>
    </inputs>
  
    <outputs>
        <data name="output" format="bam"
        label="(Re)headered bam file from MiModd ${tool.name} on ${on_string}" />
    </outputs>

    <tests>
        <test>
            <param name="inputfile" value="a.bam" />
            <conditional name="co">
                <param name="treat_co" value="update" />
                <repeat name="coinfo">
                    <param name="line" value="ceterum censeo ..." />
                </repeat>
            </conditional>
            <output name="output" file="a.bam" ftype="bam" lines_diff="1" />
        </test>
        <test>
            <param name="inputfile" value="header_only.bam" />
            <conditional name="rg">
                <param name="treat_rg" value="update" />
                <conditional name="rginfo">
                    <param name="source" value="from_form" />
                    <repeat name="rg">
                        <param name="source_id" value="000" />
                        <param name="rg_sm" value="Bristol" />
                    </repeat>
                </conditional>
            </conditional>
            <output name="output" file="header_only.bam" ftype="bam" lines_diff="2" />
        </test>
        <test>
            <param name="inputfile" value="header_only.bam" />
            <conditional name="rg">
                <param name="treat_rg" value="update" />
                <conditional name="rginfo">
                    <param name="source" value="from_form" />
                    <repeat name="rg">
                        <param name="source_id" value="001" />
                        <param name="rg_sm" value="Hawaiian" />
                    </repeat>
                </conditional>
            </conditional>
            <output name="output" file="header_only.bam" ftype="bam" lines_diff="1" />
        </test>        
    </tests>
    
    <help><![CDATA[
.. class:: infomark

   **What it does**

The tool generates a copy of the BAM input file with a modified header (i.e., metadata). 

It can update or replace read-group information (i.e., information about the samples in the file), add or replace comment lines, and rename reference sequences declared in the header.

The tool ensures that the resulting BAM file is valid and can be further processed by other MiModD tools and standard software like samtools. It aborts with an error message if a valid BAM file cannot be generated with the user-specified settings.
 
The template information used to modify or replace the input file metadata is provided through forms or, in the case of read-group information, can be taken from an existing SAM file as can be generated, for example, with the *NGS Run Annotation* tool.

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