<commit_before><tool id="multiqc" name="MultiQC" version="@WRAPPER_VERSION@.0">
    <description>aggregate results from bioinformatics analyses into a single report</description>
    <macros>
        <token name="@WRAPPER_VERSION@">1.2</token>
        <token name="@LN_FILES@">
<![CDATA[
#for $file in $repeat.software_cond.input
    grep -q "$pattern" $file || die "'$pattern' not found in the file" &&
    ln -s '$file' '$software_dir/${file.element_identifier}' &&
#end for
        ]]></token>
        <token name="@LN_2_FILES@">
<![CDATA[
#for $file in $repeat2.input:
    grep -q "$pattern" $file || die "'$pattern' not found in the file" &&
    ln -s '$file' '$software_dir/${repeat2.type}_${j}_${file.element_identifier}' &&
#end for
        ]]></token>
        <token name="@LN_3_FILES@">
<![CDATA[
#for $file in $repeat2.type.input:
    grep -q "$pattern" $file || die "'$pattern' not found in the file" &&
    ln -s '$file' '$repeat_dir/${file.element_identifier}' &&
#end for
        ]]></token>
    </macros>
    <requirements>
       <requirement type="package" version="@WRAPPER_VERSION@">multiqc</requirement>
    </requirements>
    <version_command>multiqc --version</version_command>
    <command detect_errors="aggressive">
<![CDATA[
die() { echo "$@" 1>&2 ; exit 1; } &&

mkdir multiqc_WDir &&

#set $configfile="F"

#for $i, $repeat in enumerate( $results )
    #set software_dir = 'multiqc_WDir/' + str($repeat.software_cond.software) + '_' + str($i)
    mkdir $software_dir &&

    #if str($repeat.software_cond.software) == "bamtools"
        #set $pattern = "Stats for BAM file(s)"
        @LN_FILES@
    #elif str($repeat.software_cond.software) == "bcftools"
        #set $pattern = "This file was produced by bcftools stats"
        @LN_FILES@
    #elif str($repeat.software_cond.software) == "bismark"
        #for $j, $repeat2 in enumerate( $repeat.software_cond.output )
            #set file_prefix = $software_dir + '/' + str($repeat2.type) + '_' + str($j)
            #if str($repeat2.type) == "align"
                #for $file in $repeat2.input
                    ln -s '$file' '${file_prefix}_${file.element_identifier}_SE_report.txt' &&
                #end for
            #elif str($repeat2.type) == "dedup"
                #for $file in $repeat2.input
                    ln -s '$file' '${file_prefix}_${file.element_identifier}_deduplication_report.txt' &&
                #end for
            #elif str($repeat2.type) == "meth_extract"
                #for $file in $repeat2.input
                    ln -s '$file' '${file_prefix}_${file.element_identifier}_splitting_report.txt' &&
                #end for
            #elif str($repeat2.type) == "m_bias"
                #for $file in $repeat2.input
                    ln -s '$file' '${file_prefix}_${file.element_identifier}_M-bias.txt' &&
                #end for
            #elif str($repeat2.type) == "bam2nuc"
                #for $file in $repeat2.input
                    ln -s '$file' '${file_prefix}_${file.element_identifier}.nucleotide_stats.txt' &&
                #end for
            #end if
        #end for
    #elif str($repeat.software_cond.software) == "bowtie2"
        #set $pattern = "reads; of these:"
        @LN_FILES@
    #elif str($repeat.software_cond.software) == "busco"
        ## Searches for files "short_summary_[samplename].txt"
        #for $file in $repeat.software_cond.input
            ln -s '$file' '$software_dir/short_summary_${file.element_identifier}' &&
        #end for
    #elif str($repeat.software_cond.software) == "cutadapt"
        #set $pattern = "This is cutadapt"
        #for $file in $repeat.software_cond.input
            #set file_path = $software_dir + '/' + str($file.element_identifier) + '.txt'
            ln -s '$file' '$file_path' &&
            ## replace header for old cutadapt release
            sed -i.old 's/You are running/This is/' '$file_path' &&
            grep -q "$pattern" '$file_path' || die "'$pattern' or 'You are running cutadapt' not found in the file" &&
        #end for
    #elif str($repeat.software_cond.software) == "fastqc"
        #for $j, $repeat2 in enumerate( $repeat.software_cond.output )
            #set repeat_dir = $software_dir + '/' + str($repeat2.type) + '_' + str($j)
            mkdir '$repeat_dir' &&
            #if str($repeat2.type) == "data"
                #for $k, $file in enumerate($repeat2.input)
                    #set file_dir = $repeat_dir + '/file_' + str($k)
                    mkdir '$file_dir' &&
                    ln -s '$file' '$file_dir/fastqc_data.txt' &&
                #end for
            #elif str($repeat2.type) == "theoretical_gc"
                #for $file in $repeat2.input
                    ln -s '$file' '$repeat_dir/${file.element_identifier}_fastqc_theoretical_gc' &&
                #end for
            #end if
        #end for
    #elif str($repeat.software_cond.software) == "featureCounts"
        #for $file in $repeat.software_cond.input
            #set file_prefix = $software_dir + '/' + str($file.element_identifier)
            #if $file.metadata.column_names and $file.metadata.column_names.find(',') != -1
                echo '$file.metadata.column_names.replace(',','\t').replace('__ob__u','').replace('u__sq__','').replace('__sq__','').replace('__cb__','')' >> '${file_prefix}.summary' &&
                cat '$file' >> '${file_prefix}.summary' &&
            #else
                ln -s '$file' '${file_prefix}.summary' &&
            #end if
        #end for
    #elif str($repeat.software_cond.software) == "flexbar"
        #set $pattern = "flexible barcode and adapter removal"
        @LN_FILES@
    #elif str($repeat.software_cond.software) == "gatk"
        #for $j, $repeat2 in enumerate( $repeat.software_cond.output )
            #if str($repeat2.type) == "varianteval"
                #set $pattern = "#:GATKTable:TiTvVariantEvaluator"
                @LN_2_FILES@<commit_msg>Fix #1581, bump multiqc wrapper version<commit_after><tool id="multiqc" name="MultiQC" version="@WRAPPER_VERSION@.0">
    <description>aggregate results from bioinformatics analyses into a single report</description>
    <macros>
        <token name="@WRAPPER_VERSION@">1.2.1</token>
        <token name="@LN_FILES@">
<![CDATA[
#for $file in $repeat.software_cond.input
    grep -q "$pattern" $file || die "'$pattern' not found in the file" &&
    ln -s '$file' '$software_dir/${file.element_identifier}' &&
#end for
        ]]></token>
        <token name="@LN_2_FILES@">
<![CDATA[
#for $file in $repeat2.input:
    grep -q "$pattern" $file || die "'$pattern' not found in the file" &&
    ln -s '$file' '$software_dir/${repeat2.type}_${j}_${file.element_identifier}' &&
#end for
        ]]></token>
        <token name="@LN_3_FILES@">
<![CDATA[
#for $file in $repeat2.type.input:
    grep -q "$pattern" $file || die "'$pattern' not found in the file" &&
    ln -s '$file' '$repeat_dir/${file.element_identifier}' &&
#end for
        ]]></token>
    </macros>
    <requirements>
       <requirement type="package" version="@WRAPPER_VERSION@">multiqc</requirement>
    </requirements>
    <version_command>multiqc --version</version_command>
    <command detect_errors="aggressive">
<![CDATA[
die() { echo "$@" 1>&2 ; exit 1; } &&

mkdir multiqc_WDir &&

#set $configfile="F"

#for $i, $repeat in enumerate( $results )
    #set software_dir = 'multiqc_WDir/' + str($repeat.software_cond.software) + '_' + str($i)
    mkdir $software_dir &&

    #if str($repeat.software_cond.software) == "bamtools"
        #set $pattern = "Stats for BAM file(s)"
        @LN_FILES@
    #elif str($repeat.software_cond.software) == "bcftools"
        #set $pattern = "This file was produced by bcftools stats"
        @LN_FILES@
    #elif str($repeat.software_cond.software) == "bismark"
        #for $j, $repeat2 in enumerate( $repeat.software_cond.output )
            #set file_prefix = $software_dir + '/' + str($repeat2.type) + '_' + str($j)
            #if str($repeat2.type) == "align"
                #for $file in $repeat2.input
                    ln -s '$file' '${file_prefix}_${file.element_identifier}_SE_report.txt' &&
                #end for
            #elif str($repeat2.type) == "dedup"
                #for $file in $repeat2.input
                    ln -s '$file' '${file_prefix}_${file.element_identifier}_deduplication_report.txt' &&
                #end for
            #elif str($repeat2.type) == "meth_extract"
                #for $file in $repeat2.input
                    ln -s '$file' '${file_prefix}_${file.element_identifier}_splitting_report.txt' &&
                #end for
            #elif str($repeat2.type) == "m_bias"
                #for $file in $repeat2.input
                    ln -s '$file' '${file_prefix}_${file.element_identifier}_M-bias.txt' &&
                #end for
            #elif str($repeat2.type) == "bam2nuc"
                #for $file in $repeat2.input
                    ln -s '$file' '${file_prefix}_${file.element_identifier}.nucleotide_stats.txt' &&
                #end for
            #end if
        #end for
    #elif str($repeat.software_cond.software) == "bowtie2"
        #set $pattern = "reads; of these:"
        @LN_FILES@
    #elif str($repeat.software_cond.software) == "busco"
        ## Searches for files "short_summary_[samplename].txt"
        #for $file in $repeat.software_cond.input
            ln -s '$file' '$software_dir/short_summary_${file.element_identifier}' &&
        #end for
    #elif str($repeat.software_cond.software) == "cutadapt"
        #set $pattern = "This is cutadapt"
        #for $file in $repeat.software_cond.input
            #set file_path = $software_dir + '/' + str($file.element_identifier) + '.txt'
            ln -s '$file' '$file_path' &&
            ## replace header for old cutadapt release
            sed -i.old 's/You are running/This is/' '$file_path' &&
            grep -q "$pattern" '$file_path' || die "'$pattern' or 'You are running cutadapt' not found in the file" &&
        #end for
    #elif str($repeat.software_cond.software) == "fastqc"
        #for $j, $repeat2 in enumerate( $repeat.software_cond.output )
            #set repeat_dir = $software_dir + '/' + str($repeat2.type) + '_' + str($j)
            mkdir '$repeat_dir' &&
            #if str($repeat2.type) == "data"
                #for $k, $file in enumerate($repeat2.input)
                    #set file_dir = $repeat_dir + '/file_' + str($k)
                    mkdir '$file_dir' &&
                    ln -s '$file' '$file_dir/fastqc_data.txt' &&
                #end for
            #elif str($repeat2.type) == "theoretical_gc"
                #for $file in $repeat2.input
                    ln -s '$file' '$repeat_dir/${file.element_identifier}_fastqc_theoretical_gc' &&
                #end for
            #end if
        #end for
    #elif str($repeat.software_cond.software) == "featureCounts"
        #for $file in $repeat.software_cond.input
            #set file_prefix = $software_dir + '/' + str($file.element_identifier)
            if grep -qw Status '$file'; then
                ln -s '$file' '${file_prefix}.summary';
            else
                echo -e 'Status\t$file.element_identifier' > '${file_prefix}.summary';
                cat '$file' >> '${file_prefix}.summary';
            fi &&
        #end for
    #elif str($repeat.software_cond.software) == "flexbar"
        #set $pattern = "flexible barcode and adapter removal"
        @LN_FILES@
    #elif str($repeat.software_cond.software) == "gatk"
        #for $j, $repeat2 in enumerate( $repeat.software_cond.output )
            #if str($repeat2.type) == "varianteval"
                #set $pattern = "#:GATKTable:TiTvVariantEvaluator"
                @LN_2_FILES@
{'fraction_non_alphanumeric': 0.15587611370386084, 'fraction_numerical': 0.006279168434450573, 'mean_word_length': 2.364544675992007, 'pattern_counts': {'":': 0, '<': 51, '<?xml version=': 0, '>': 58, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '892090', 'n_tokens_mistral': 3938, 'n_tokens_neox': 3644, 'n_words': 845}