view cooc_mutbamscan.xml @ 3:cd0484c5f9f1 draft

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/cojac commit 43a520ebfbf379e815fb2397da6bbf360666e385
author iuc
date Mon, 02 Oct 2023 19:59:25 +0000
parents d58a57db7a96
children
line wrap: on
line source

<tool id="cooc_mutbamscan" name="Cojac: mutbamscan" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@"
      profile="@PROFILE@">
    <description>
        scans an alignment file for mutation co-occurrences
    </description>
    <macros>
        <import>macros.xml</import>
    </macros>
    <expand macro="biotools"/>
    <expand macro="requirements">
        <requirement type="package" version="0.1.0">viramp-hub</requirement>
    </expand>
    <expand macro="version"/>
    <command detect_errors="exit_code"><![CDATA[
## arrange BAM inputs and index files into a V-pipe-style folder structure
## that cojac understands
sh arrange_samples.sh &&

#if $spec_layout.mode == 'separate':
  #set $voc_config = $spec_layout.voc_source
  @VOCDIR_COMMAND@
  ## prepare amplicon information
  #if $spec_layout.amplicon_definitions.choice == 'insert_scheme':
    ln -s '$spec_layout.amplicon_definitions.insert_bed' bed_cojac.bed &&
  #else if $spec_layout.amplicon_definitions.choice == 'primer_scheme':
    scheme-convert '$spec_layout.amplicon_definitions.primer_bed' -t bed -b cojac -o bed_cojac.bed &&
  #else:
    scheme-convert '$spec_layout.amplicon_definitions.primer_bed' -t bed -b cojac -a '$spec_layout.amplicon_definitions.amplicon_info' -o bed_cojac.bed &&
  #end if
#end if

## run cojac
cojac cooc-mutbamscan
    ## use a sample list file to tell cojac to look for the inputs in the
    ## V-pipe-style folder stucture we've created earlier.
    -s samples_list.tsv
    -p inputs
    -b bed_cojac.bed
    #if $spec_layout.mode == 'separate':
      -m voc/
      -A amplicons.yaml
      --cooc $spec_layout.cooc
    #else
      -Q '$spec_layout.in_amp'
    #end if
    #if 'yaml' in $out_opts.output_formats:
      -y cooc.yaml
    #end if
    #if 'json' in $out_opts.output_formats:
      -j cooc.json
    #end if
    #if 'tabular' in $out_opts.output_formats:
      -t cooc.tsv
    #end if
    ]]></command>
    <configfiles>
        <configfile filename="arrange_samples.sh"><![CDATA[#for $dataset in $mapped_input:
  #set $sample_id = $dataset.element_identifier.replace("'", '_').replace('/', '_')
mkdir -p 'inputs/$sample_id/1/alignments/' &&
ln -s '$dataset' 'inputs/$sample_id/1/alignments/REF_aln.bam' &&
ln -s '$dataset.metadata.bam_index' 'inputs/$sample_id/1/alignments/REF_aln.bam.bai' &&
#end for
#set $num_samples = len($mapped_input)
echo "Gathered $num_samples sample and index files for cojac to discover from a samples list."
        ]]></configfile>
        <configfile filename="samples_list.tsv"><![CDATA[#for $dataset in $mapped_input:
  #set $line = '\t'.join([$dataset.element_identifier.replace("'", '_').replace('/', '_'), '1', str($dataset)])
$line
#end for]]></configfile>
    </configfiles>
    <inputs>
        <param name="mapped_input" type="data" format="bam" multiple="true" label="Aligned reads input to analyze"/>
        <conditional name="spec_layout">
            <param name="mode" type="select" label="How would you like to provide amplicon and lineage information?">
                <option value="separate">Separately</option>
                <option value="combined">Combined</option>
            </param>
            <when value="separate">
                <expand macro="vocdir_input"/>
                <conditional name="amplicon_definitions">
                    <param name="choice" type="select" label="Format of amplicon definitions">
                        <option value="insert_scheme">Amplicon insert scheme (Cojac-native format)</option>
                        <option value="primer_scheme">Primer scheme (with autodetection of grouping into amplicons)</option>
                        <option value="primer_scheme_plus">Primer scheme and explicit amplicon grouping information</option>
                    </param>
                    <when value="insert_scheme">
                        <param name="insert_bed" type="data" format="bed" label="Amplicon insert scheme" help="BED dataset providing the positions of the amplicon inserts (i.e. excluding the primer sequences) on the reference sequence."/>
                    </when>
	                <when value="primer_scheme">
		                <param name="primer_bed" type="data" format="bed" label="Primer scheme" help="The tool will attempt to autodetect the relationship between primers and amplicons based on the primer names."/>
                    </when>
                    <when value="primer_scheme_plus">
                        <param name="primer_bed" type="data" format="bed" label="Primer scheme" />
                        <param name="amplicon_info" type="data" format="tabular" label="Primers to amplicons assignments" help ="This input should have one line of tab-separated primer names (as they appear in the primer scheme) per amplicon."/>
                    </when>
                </conditional>
                <param argument="--cooc" type="integer" min="1" value="2" label="Minimum number of mutations required to co-occur on an amplicon"/>
                <param name="output_cojac_ampl" type="boolean" checked="true" label="Produce combined per-amplicon lineage definition output" help="The tool can generate a YAML-formatted report of expected co-occurrences of mutations per amplicon and lineage. This output combines amplicon scheme and lineage definitions and can be used for rerunning the tool with identical configuration in 'Combined' mode. It is also a recommended input to the cojac pubmut tool so leave this option checked if you are intending to use this downstream tool."/>
            </when>
            <when value="combined">
                <param name="in_amp" type="data" format="yaml" label="Combined per-amplicon lineage definitions"
                help="YAML-formatted report of expected co-occurrences of mutations per amplicon and lineage generated by a previous run of the tool."/>
            </when>
        </conditional>
        <section name="out_opts" title="Output options" expanded="true">
            <param name="output_formats" type="select" display="checkboxes" multiple="true" label="Produce output in these formats"
            help="Please note that only yaml- and json-formatted results can be processed with the downstream pubmut and tabmut tools.">
                <option value="yaml">YAML</option>
                <option value="json" selected="true">JSON</option>
                <option value="tabular">tabular</option>
            </param>
        </section>
    </inputs>
    <outputs>
        <data name="cooc_yaml" format="yaml" from_work_dir="cooc.yaml" label="${tool.name} on ${on_string}: Mutation co-occurrence (yaml)">
            <filter>'yaml' in out_opts['output_formats']</filter>
        </data>
        <data name="cooc_json" format="json" from_work_dir="cooc.json" label="${tool.name} on ${on_string}: Mutation co-occurrence (json)">
            <filter>'json' in out_opts['output_formats']</filter>
        </data>
        <data name="cooc_tsv" format="tabular" from_work_dir="cooc.tsv" label="${tool.name} on ${on_string}: Mutation co-occurrence (tabular)">
            <filter>'tabular' in out_opts['output_formats']</filter>
        </data>
        <data name="amplicons" format="yaml" from_work_dir="amplicons.yaml" label="${tool.name} on ${on_string}: Combined per-amplicon lineage definitions">
            <filter>spec_layout['mode'] == 'separate' and spec_layout['output_cojac_ampl']</filter>
        </data>
    </outputs>
    <tests>
        <!-- Test 1: build yaml for amplicons from bed and voc/ -->
        <test expect_num_outputs="4">
            <param name="mapped_input" value="tbam11.bam"/>
            <conditional name="spec_layout">
                <conditional name="voc_source">
                    <param name="choice" value="custom"/>
                    <param name="collection">
                        <collection type="list">
                            <element name="BA.1" ftype="yaml" value="omicron_ba1_mutations.yaml" />
                        </collection>
                    </param>
                </conditional>
                <conditional name="amplicon_definitions">
                    <param name="insert_bed" value="nCoV-2019.insert.V3.bed" ftype="bed"/>
                </conditional>
            </conditional>
            <section name="out_opts">
                <param name="output_formats" value="yaml,json,tabular"/>
            </section>
            <output name="cooc_yaml" ftype="yaml">
                <assert_contents>
                    <has_text text="76_om1"/>
                    <has_text text="81_om1"/>
                </assert_contents>
            </output>
            <output name="cooc_json" ftype="json">
                <assert_contents>
                    <has_text text="76_om1"/>
                    <has_text text="81_om1"/>
                </assert_contents>
            </output>
            <output name="cooc_tsv" ftype="tabular">
                <assert_contents>
                    <has_text text="76_om1"/>
                    <has_text text="81_om1"/>
                </assert_contents>
            </output>
            <output name="amplicons" ftype="yaml">
                <assert_contents>
                    <has_text text="76_om1"/>
                    <has_text text="81_om1"/>
                </assert_contents>
            </output>
        </test>
        <!-- Test 2: configure via cojac yaml -->
        <test expect_num_outputs="2">
            <param name="mapped_input" value="tbam11.bam"/>
            <conditional name="spec_layout">
                <param name="mode" value="combined"/>
                <param name="in_amp" value="amplicons111.yaml"/>
            </conditional>
            <section name="out_opts">
                <param name="output_formats" value="yaml,tabular"/>
            </section>
            <output name="cooc_yaml" ftype="yaml">
                <assert_contents>
                    <has_text text="76_om1"/>
                    <has_text text="81_om1"/>
                </assert_contents>
            </output>
            <output name="cooc_tsv" ftype="tabular">
                <assert_contents>
                    <has_text text="76_om1"/>
                    <has_text text="81_om1"/>
                </assert_contents>
            </output>
        </test>
        <!-- Test 3: use computed cojac format amplicon definitions from 2 files -->
        <test expect_num_outputs="2">
            <param name="mapped_input" value="tbam11.bam"/>
            <conditional name="spec_layout">
                <conditional name="voc_source">
                    <param name="choice" value="builtin"/>
                </conditional>
                <conditional name="amplicon_definitions">
                    <param name="choice" value="primer_scheme_plus"/>
                    <param name="primer_bed" value="primers.bed" ftype="bed"/>
                    <param name="amplicon_info" value="ampl_info.tsv"/>
                </conditional>
                <param name="output_cojac_ampl" value="false"/>
            </conditional>
            <section name="out_opts">
                <param name="output_formats" value="yaml,tabular"/>
            </section>
            <output name="cooc_yaml" ftype="yaml">
                <assert_contents>
                    <has_text text="76_om1"/>
                    <has_text text="81_om1"/>
                </assert_contents>
            </output>
            <output name="cooc_tsv" ftype="tabular">
                <assert_contents>
                    <has_text text="76_om1"/>
                    <has_text text="81_om1"/>
                </assert_contents>
            </output>
        </test>
        <!-- Test 4: test primer scheme as input -->
        <test expect_num_outputs="2">
            <param name="mapped_input" value="tbam11.bam"/>
            <conditional name="spec_layout">
                <conditional name="voc_source">
                    <param name="choice" value="builtin"/>
                </conditional>
                <conditional name="amplicon_definitions">
                    <param name="choice" value="primer_scheme"/>
                    <param name="primer_bed" value="primers.bed" ftype="bed"/>
                </conditional>
                <param name="output_cojac_ampl" value="false"/>
            </conditional>
            <section name="out_opts">
                <param name="output_formats" value="yaml,tabular"/>
            </section>
            <output name="cooc_yaml" ftype="yaml">
                <assert_contents>
                    <has_text text="76_om1"/>
                    <has_text text="81_om1"/>
                </assert_contents>
            </output>
            <output name="cooc_tsv" ftype="tabular">
                <assert_contents>
                    <has_text text="76_om1"/>
                    <has_text text="81_om1"/>
                </assert_contents>
            </output>
        </test>
    </tests>
    <help><![CDATA[
@HELP_HEADER@

Information about **cojac cooc-mutbamscan**
===========================================

The tool scans an alignment BAM/CRAM/SAM file for mutation co-occurrences.
It can report its findings in json, yaml and/or tabular format.
    ]]></help>
    <expand macro="citations"/>
</tool>