view bam_bed_gff_to_bigwig.xml @ 3:3899b3091d4a draft

planemo upload for repository https://www.encodeproject.org/software/bedgraphtobigwig/
author fubar
date Fri, 14 Jun 2024 23:46:14 +0000
parents 460f523c8ff4
children f132065ac170
line wrap: on
line source

<tool id="bbgtobigwig_dev" name="BAM BED GFF coverage bigWigs" version="0.1" profile="22.05"> 
    <xrefs>
        <xref type="bio.tools">UCSC_Genome_Browser_Utilities</xref>
    </xrefs>
    <requirements>
        <requirement type="package" version="455">ucsc-bedgraphtobigwig</requirement>
        <requirement type="package" version="2.31.1">bedtools</requirement>
        <requirement type="package" version="9.5">coreutils</requirement> 
        <requirement type="package" version="3.12.3">python</requirement>
    </requirements>
    <required_files>
        <include path="gff_to_bed_converter.py"/>
    </required_files>
    <command detect_errors="aggressive"><![CDATA[
#if $hist_or_builtin.genosrc == "indexed":
    ln -s '$hist_or_builtin.chromfile.fields.len_path' ./CHROMFILE &&
#else:
    ln -s '$chromfile' ./CHROMFILE &&
#end if
#if $input1.ext in ['gff', 'gff3']:
    python '$__tool_directory__/gff_to_bed_converter.py' < '$input1' > input2 && 
#else:
    ln -s '$input1' input2 &&
#end if
#if $input1.ext == "bam":
    bedtools genomecov -bg -split -ibam input2 | 
#else
    bedtools genomecov -bg -i input2 -g ./CHROMFILE |
#end if
LC_COLLATE=C sort -k1,1 -k2,2n > temp.bg &&
bedGraphToBigWig temp.bg ./CHROMFILE '$output'
    ]]></command>
    <inputs>
        <conditional name="hist_or_builtin">
            <param name="genosrc" type="select" label="Is the input assigned to a built-in or custom reference genome?" 
                help="If the input has no dbkey, supply a chromosome lengths file">
                <option selected="True" value="indexed">Input data was made with a built-in genome or already has a custom genome dbkey</option>
                <option value="history">Input data mapped on a genome from the current history. The chromosome lengths file is also in the history</option>
            </param>
            <when value="indexed">
                <param name="input1" type="data" format="bam,unsorted.bam,bed,gff,gff3" label="bam/bed/gff to convert">
                    <validator type="unspecified_build" />
                </param>
                <param name="chromfile" type="select" label="Source Genome Build">
                    <options from_data_table="__dbkeys__">
                        <filter type="data_meta" column="0" key="dbkey" ref="input1"/>
                    </options>
                    <validator type="no_options" message="The chosen genome build is not available."/>
                </param>
            </when>
            <when value="history">
                <param name="input1" type="data" format="bam,unsorted.bam,bed,gff,gff3" label="bam/bed/gff to convert"/>
                <param name="chromfile" type="data" format="len,txt,tabular" label="Chromosome length file" 
                   help="Sequence lengths for the history reference are required to make a bigwig. Compute sequence length tool makes these from fasta files"/>
            </when>
        </conditional>
    </inputs>
    <outputs>
        <data name="output" format="bigwig"/>
    </outputs>
    <tests>
        <test expect_num_outputs="1">
            <conditional name="hist_or_builtin">
                <param name="genosrc" value="indexed"/>
                <param name="input1" value="featureCounts_input1.bam" dbkey="hg38"/>
                <param name="chromfile" value="hg38"/>
            </conditional>
            <output name="output" value="featureCounts_input1.bigwig" compare="sim_size"/>
        </test>
        <test expect_num_outputs="1">
            <conditional name="hist_or_builtin">
                <param name="genosrc" value="history"/>
                <param name="input1" value="srma_out2.bam"/>
                <param name="chromfile" value="testing.len"/>
            </conditional>
            <output name="output" value="srma_out2.bigwig" compare="sim_size"/>
        </test>
        <test expect_num_outputs="1">
            <conditional name="hist_or_builtin">
                <param name="genosrc" value="history"/>
                <param name="input1" value="test5.gff3"/>
                <param name="chromfile" value="testing.len"/>
            </conditional>
            <output name="output" value="test5.gff.bigwig" compare="sim_size"/>
        </test>
        <test expect_num_outputs="1">
            <conditional name="hist_or_builtin">
                <param name="genosrc" value="history"/>
                <param name="input1" value="test5.bed"/>
                <param name="chromfile" value="testing.len"/>
            </conditional>
            <output name="output" value="test5.bed.bigwig" compare="sim_size"/>
        </test>
    </tests>
    <help>

   Estimates coverage of a reference genome for bam, bed or gff as a bigwig, suitable for viewing in JBrowse2 or other browser.
 
   A chromosome lengths file must be provided if the input has a missing dbkey='?' on the pencil (edit attributes) tab. 
   
   The actual reference is not needed. The Compute sequence length tool can generate the lengths file.
 
   This can be useful in workflows with assemblies in progress before a stable reference is available for a custom or built in reference dbkey.

    </help>    
    <citations>
        <citation type="doi">10.1093/bioinformatics/btq351</citation>
    </citations>
</tool>