view gemini_macros.xml @ 6:d5ec6384a3be draft

"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gemini commit 251c6024b4ff643a63e17fbfe2590998c2bae3a7"
author iuc
date Fri, 24 Jan 2020 17:39:03 -0500
parents c63b7eefb07a
children 9551b3da9f5d
line wrap: on
line source

<macros>
    <!-- gemini version to be used -->
    <token name="@VERSION@">0.20.1</token>
    <!-- minimal annotation files version required by this version of gemini -->
    <token name="@DB_VERSION@">200</token>

    <xml name="requirements">
        <requirements>
            <requirement type="package" version="@VERSION@">gemini</requirement>
            <yield />
        </requirements>
    </xml>

    <xml name="version_command">
        <version_command>gemini --version</version_command>
    </xml>

    <xml name="stdio">
        <stdio>
            <exit_code range="1:" />
            <exit_code range=":-1" />
            <regex match="Error:" />
            <regex match="Exception:" />
            <yield />
        </stdio>
    </xml>

    <xml name="citations">
        <citations>
            <citation type="doi">10.1371/journal.pcbi.1003153</citation>
            <yield />
        </citations>
    </xml>

    <xml name="annotation_dir">
        <param name="annotation_databases" type="select" label="Choose a gemini annotation source">
            <options from_data_table="gemini_versioned_databases">
                <filter type="sort_by" column="0" />
                <filter type="static_value" column="2" value="@DB_VERSION@" />
            </options>
        </param>
    </xml>

    <xml name="infile">
        <param name="infile" type="data" format="gemini.sqlite" label="GEMINI database" help="Only files with version @VERSION@ are accepted." >
            <options options_filter_attribute="metadata.gemini_version" >
                <filter type="add_value" value="@VERSION@" />
            </options>
        </param>
    </xml>

    <xml name="add_header_column">
        <param argument="--header" name="header" type="boolean" truevalue="--header" falsevalue="" checked="True" 
        label="Add a header of column names to the output" />
    </xml>

    <xml name="column_filter" token_help="" token_minimalset="variant_id, gene">
        <conditional name="report">
            <param name="report_selector" type="select"
            label="Set of columns to include in the variant report table"
            help="@HELP@">
                <option value="minimal">Minimal (report only a preconfigured minimal set of columns)</option>
                <option value="full">Full (report all columns defined in the GEMINI database variants table)</option>
                <option value="custom">Custom (report user-specified columns)</option>
            </param>
            <when value="full" />
            <when value="minimal">
                <param name="columns" type="hidden" value="@MINIMALSET@" />
                <param name="extra_cols" type="hidden" value="" />
            </when>
            <when value="custom">
                <param name="columns" type="select" display="checkboxes" multiple="true" optional="true"
                label="Choose columns to include in the report" help="(--columns)">
                    <option value="gene">gene</option>
                    <option value="chrom">chrom</option>
                    <option value="start">start</option>
                    <option value="end">end</option>
                    <option value="ref">ref</option>
                    <option value="alt">alt</option>
                    <option value="impact">impact</option>
                    <option value="impact_severity">impact_severity</option>
                    <option value="max_aaf_all">alternative allele frequency (max_aaf_all)</option>
                </param>
                <param name="extra_cols" type="text"
                label="Additional columns (comma-separated)"
                help="Column must be specified by the exact name they have in the GEMINI database, e.g., is_exonic or num_hom_alt, but, for genotype columns, GEMINI wildcard syntax is supported. The order of columns in the list is maintained in the output.">
                    <expand macro="sanitize_query" />
                </param>
            </when>
        </conditional>
    </xml>

    <xml name="filter" token_argument="--filter">
        <param argument="@ARGUMENT@" name="filter" type="text"
        label="Additional constraints expressed in SQL syntax"
        help="Constraints defined here will become the WHERE clause of the SQL query issued to the GEMINI database. E.g. alt='G' or impact_severity = 'HIGH'.">
            <expand macro="sanitize_query" />
        </param>
    </xml>

    <xml name="sanitize_query">
        <sanitizer invalid_char="">
            <valid initial="string.printable">
                <remove value="&apos;" />
            </valid>
            <mapping initial="none">
                <add source="&apos;" target="&apos;&quot;&apos;&quot;&apos;" />
            </mapping>
       </sanitizer>
    </xml>

    <xml name="lenient" token_argument="--lenient" token_truevalue="--lenient" token_help="The exact consequence of this setting depends on the type of inheritance pattern you are looking for (see the tool help below).">
        <param argument="@ARGUMENT@" name="lenient" type="boolean" truevalue="@TRUEVALUE@" falsevalue="" checked="False"
        label="Include hits with less convincing inheritance patterns"
        help= "@HELP@" />
    </xml>

    <xml name="unaffected">
        <param argument="--allow-unaffected" name="allow_unaffected" type="boolean" truevalue="--allow-unaffected" falsevalue="" checked="False"
        label="Report candidates shared by unaffected samples"
        help="Activating this option will enable the reporting of variants as candidate causative even if they are shared by unaffected samples in the family tree. The default will only report variants that are unique to affected samples."/>
    </xml>

    <xml name="min_kindreds" token_label="Minimum number of families with a candidate variant for a gene to be reported" token_help="This is the number of families required to have a variant fitting the inheritance model in the same gene in order for the gene and its variants to be reported. For example, we may only be interested in candidates where at least 4 families have a variant (with a fitting inheritance pattern) in that gene.">
        <param argument="--min-kindreds" name="min_kindreds" type="integer" value="1" min="1"
        label="@LABEL@"
        help="@HELP@" />
    </xml>

    <xml name="insert_constraint" token_max_repeat="1">
        <repeat name="constraint" title="Additional constraints on variants" default="0" max="@MAX_REPEAT@">
            <expand macro="filter" />
            <yield />
        </repeat>
    </xml>

    <xml name="overwritable_where_default" token_default_where="">
        <param name="overwrite_default_filter" type="boolean" checked="false"
        label="Overwrite the default constraint of this tool"
        help="By default, this tool restricts its analysis to @DEFAULT_WHERE@ and this constraint is applied on top of any constraint expressed above. With this option here selected, your custom constraint, if given, will overwrite the default instead." />
    </xml>

    <xml name="gt_filter" token_default_repeat="0" token_min_repeat="0" token_max_repeat="1">
        <repeat name="filter_by_genotype" title="Genotype filter expression" default="@DEFAULT_REPEAT@" min="@MIN_REPEAT@" max="@MAX_REPEAT@">
            <param argument="--gt-filter" name="gt_filter" type="text" value="" area="True" size="5x50"
            label="Restrictions to apply to genotype values" help="">
                <expand macro="sanitize_query" />
                <validator type="expression" message="Genotype filter expression cannot be empty">value.strip()</validator>
            </param>
            <yield />
        </repeat>
    </xml>

    <xml name="sample_filter">
        <repeat name="filter_by_sample" title="Sample filter expression" default="0" max="1">
            <param argument="--sample-filter" name="sample_filter" type="text" area="True" size="5x50"
            label="SQL filter to use to filter the sample table" help="">
                <expand macro="sanitize_query" />
                <validator type="expression" message="Sample filter expression cannot be empty">value.strip()</validator>
            </param>
            <param argument="--in" name="in" type="select"
            label="A variant must be in either all, none or any samples passing the sample-query filter"
            help="">
                <option value="">Return a variant if it is found in any sample passing the sample filter. (default) </option>
                <option value="--in all">Return a variant if it is found in ALL samples passing the sample filter. (all)</option>
                <option value="--in none">Return a variant if it is found in NO sample passing the sample filter. (none)</option>
                <option value="--in only">Return a variant if it is found in any sample passing the sample filter, and in NO sample NOT passing it. (only)</option>
                <option value="--in only all">Return a variant if is found in ALL samples passing the sample filter, and in NO sample NOT passing it. (only all)</option>
            </param>
            <expand macro="min_kindreds"
            label="Minimum number of families in which a variant must pass the sample filter" help=""/>
            <param argument="--family-wise" name="family_wise" type="boolean" truevalue="--family-wise" falsevalue="" checked="False"
            label="Apply the sample-filter on a family-wise basis" help="If a variant passes the sample filter in at least the minimum number of families specified above it is retained." />
        </repeat>
    </xml>

    <xml name="region_filter">
        <repeat name="regions" title="Region Filter" default="0" min="0"
        help="Filter variant sites by their position in the genome. If multiple Region Filters are specified, all variants that fall in ONE of the regions are reported.">
            <param name="chrom" type="text" label="Chromosome">
                <validator type="expression" message="A chromosome identifier is required when specifying a region filter">value.strip()</validator>
            </param>
            <param name="start" type="text" label="Region Start">
                <validator type="expression" message="an integer number is required">not value or value.isdigit()</validator>
            </param>
            <param name="stop" type="text" label="Region End">
                <validator type="expression" message="an integer number is required">not value or value.isdigit()</validator>
            </param>
        </repeat>
    </xml>

    <token name="@PROVIDE_ANNO_DATA@"><![CDATA[
        mkdir gemini &&
        ln -s '${annotation_databases.fields.path}/gemini/data' gemini/data &&
        export GEMINI_CONFIG='${annotation_databases.fields.path}' &&
    ]]></token>

    <token name="@MULTILN_SQL_EXPR_TO_CMDLN@">
        #set $sql_expr = str($multiline_sql_expr).strip()
        #if str($sql_expr):
            #set $sql_expr = $sql_expr.replace('\r\n', '\n')
            #set $sql_expr = $sql_expr.replace('\r', '\n')
            #set $sql_expr = $sql_expr.replace('\\\n', ' ')
            $cmdln_param '$sql_expr'
        #end if
    </token>

    <token name="@SET_COLS@">
        #if str($report.report_selector) == 'full':
            #set cols = "*"
        #else:
            #if $report.columns and str($report.columns) != '':
                #set $cols = str($report.columns)
            #else
                #set $cols = ''
            #end if
            #if str($report.extra_cols).strip():
                #if $cols:
                    #set $cols = $cols + ', ' + str($report.extra_cols)
                #else:
                    #set $cols = str($report.extra_cols)
                #end if
            #end if
            #if not $cols:
                #set $cols = "variant_id, gene"
            #end if
        #end if
    </token>

    <token name="@COLUMN_SELECT@">
        @SET_COLS@
        #if $cols != "*"
            --columns '$cols'
        #end if
    </token>

    <token name="@PARSE_REGION_ELEMENTS@"><![CDATA[
        #set $region_elements = []
        #for $r in $regions:
            ## The actual chromosome name needs to be single-quoted
            ## in SQL, so we need to quote the single quotes like the
            ## sanitize_query macro would if the whole was a parameter.
            #set $r_elements = ["chrom = '\"'\"'%s'\"'\"'" % str($r.chrom).strip()]
            #if str($r.start).strip():
                #silent $r_elements.append("start >= %d" % int($r.start))
            #end if
            #if str($r.stop).strip():
                #silent $r_elements.append("end <= %d" % int($r.stop))
            #end if
            #silent $region_elements.append("(%s)" % " AND ".join($r_elements))
        #end for
    ]]>
    </token>
</macros>