view plink.xml @ 1:b8e3d957c0f5 draft

"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/plink commit 69a1f535817d0fe0406a448d885aafb8c0cce396"
author iuc
date Wed, 23 Sep 2020 08:05:17 +0000
parents a98caf1d69ab
children 0d43871f45ac
line wrap: on
line source

<tool id='plink' name='plink' version='@TOOL_VERSION@+galaxy@VERSION_SUFFIX@'>
    <macros>
        <token name='@TOOL_VERSION@'>1.9.b618</token>
        <token name='@VERSION_SUFFIX@'>0</token>
        <xml name='template_sanitizer'>
            <sanitizer>
                <valid initial='default'>
                    <add value='#' />
                    <add value='@' />
                    <add value='$'/>
                    <add value='['/>
                    <add value=']'/>
                    <add value='\'/>
                    <remove value='&#34;'/>
                    <remove value='&#39;'/>
                </valid>
            </sanitizer>
        </xml>
        <xml name='chr_sanitizer'>
            <sanitizer>
                <valid initial='string.digits'>
                    <add value='X' />
                    <add value='Y' />
                    <add value=' ' />
                </valid>
            </sanitizer>
        </xml>
        <xml name='snp_sanitizer'>
            <sanitizer>
                <valid initial='string.ascii_letters + string.digits'/>
            </sanitizer>
        </xml>
        <xml name='snp_space_sanitizer'>
            <sanitizer>
                <valid initial='string.ascii_letters + string.digits'>
                    <add value=' '/>
                </valid>
            </sanitizer>
        </xml>
    </macros>
    <requirements>
        <requirement type='package' version='1.90b6.18'>plink</requirement>
    </requirements>
    <command detect_errors='exit_code'><![CDATA[

    ## Create Plink folder for any inputs
    mkdir ./plink_output
    && mkdir ./plink_input
    #if $inputs.inputs.filetype == 'bfile':
        && ln -s '$inputs.inputs.bed' plink_input/plink_input.bed
        && ln -s '$inputs.inputs.bim' plink_input/plink_input.bim
        && ln -s '$inputs.inputs.fam' plink_input/plink_input.fam
    #elif $inputs.inputs.filetype == 'vcf':
        #if $inputs.inputs.input.is_of_type('vcf'):
            && plink --vcf '$inputs.inputs.input' 
        #else:
            && plink --bcf '$inputs.inputs.input' 
        #end if
        --out plink_input/plink_input
    #end if

    ## If bmerge is set, create folder for merged files
    #if $functions.func == 'data_manage':
        #if $functions.bmerge.set == 'Yes':
            && mkdir bmerge_files
            && ln -s '$functions.bmerge.bed' bmerge_files/bmerge_input.bed
            && ln -s '$functions.bmerge.bim' bmerge_files/bmerge_input.bim
            && ln -s '$functions.bmerge.fam' bmerge_files/bmerge_input.fam
        #end if
    #end if

    ## Plink commands by section

    && plink --bfile plink_input/plink_input
    #if $inputs.covar_input:
            --covar '$inputs.covar_input'
    #end if
    #if $inputs.pheno:
        --pheno $inputs.pheno
    #end if
    #if $functions.func == 'filtering':
        ##ID list functions
            #if $functions.id_list.func == 'keep':
                --keep '$functions.id_list.file'
            #elif $functions.id_list.func == 'keep-fam':
                --keep-fam '$functions.id_list.file'
            #elif $functions.id_list.func == 'remove':
                --remove '$functions.id_list.file'
            #elif $functions.id_list.func == 'remove-fam':
                --remove-fam '$functions.id_list.file'
            #end if

        ##Extraction 
            #if $functions.extraction.ex_func == 'extract':
                --extract $functions.extraction.range $functions.extraction.file
            #elif $functions.extraction.ex_func == 'exclude':
                --exclude $functions.extraction.range $functions.extraction.file
            #end if

        ##Chromosome-specificity
            #if $functions.chromosome:
                --chr $functions.chromosome
            #end if

            #if $functions.excluded_chromosome:
                --not-chr $functions.excluded_chromosome
            #end if

            $functions.extra_chromosomes

            #if $functions.autosome != 'none'
                $functions.autosome
            #end if

        ##SNP specificity
            #if $functions.snps_exclusives != 'No':
                --snps-only
                #if $functions.snps_exclusives == 'acgt':
                 'just-acgt'
                 #end if
            #end if

        ##Variant windows
            #if $functions.ranges.single_multi == 'single':
                #if $functions.ranges.window.type == 'variant':
                    #if $functions.ranges.window.from:
                        --from $functions.ranges.window.from
                    #end if
                    #if $functions.ranges.window.to:
                        --to $functions.ranges.window.to
                    #end if
                #elif $functions.ranges.window.type == 'window':
                    #if $functions.ranges.window.snp:
                        --snp $functions.ranges.window.snp
                    #end if
                    #if $functions.ranges.window.exclude_snp:
                        --exclude-snp $functions.ranges.window.exclude_snp
                    #end if
                    #if $functions.ranges.window.window:
                        --window $functions.ranges.window.window
                    #end if
                #else:
                    #if $functions.ranges.window.from_bp:
                        --from-bp $functions.ranges.window.from_bp
                    #end if
                    #if $functions.ranges.window.to_bp:
                        --to-bp $functions.ranges.window.to_bp
                    #end if
                #end if
            #elif $functions.ranges.single_multi == 'multi':
                $functions.ranges.force_intersect
                #if $functions.ranges.snps:
                    --snps $functions.ranges.snps
                #end if
                #if $functions.ranges.exclude_snps:
                    --exclude-snps $functions.ranges.exclude_snps
                #end if
            #end if
        
        ##Thinning
            #if $functions.thinning.thinning == 'Yes':
                #if $functions.thinning.thin:
                    --thin $functions.thinning.thin
                #end if
                #if $functions.thinning.thin_count:
                    --thin-count $functions.thinning.thin_count
                #end if
                #if $functions.thinning.bp_space:
                    --bp-space $functions.thinning.bp_space
                #end if
                #if $functions.thinning.thin_indiv:
                    --thin-indiv $functions.thinning.thin_indiv
                #end if
                #if $functions.thinning.thin_indiv_count:
                    --thin-indiv-count $functions.thinning.thin_indiv_count
                #end if
            #end if

        ##Pheno/covariate
            ###########
        
            ###########

        ##Missing genotype rates
            #if $functions.geno_rates.geno:
                --geno $functions.geno_rates.geno
            #end if
            #if $functions.geno_rates.mind:
                --mind $functions.geno_rates.mind
            #end if

        ##Allele Frequencies
            #if $functions.allele_freq.maf:
                --maf $functions.allele_freq.maf
            #end if
            #if $functions.allele_freq.max_maf:
                --max-maf $functions.allele_freq.max_maf
            #end if
            #if $functions.allele_freq.mac:
                --mac $functions.allele_freq.mac
            #end if
            #if $functions.allele_freq.max_mac:
                --max-mac $functions.allele_freq.max_mac
            #end if
        
        ## Hardy-Weinberg
            #if $functions.hwe.hwe == 'Yes':
                --hwe $functions.hwe.hwe_val
                #for $type in $functions.hwe.modifiers:
                    $type
                #end for
            #end if

        ##Sex and Founder filter
            #if $functions.sex_founder_filter.filter == 'Yes'
                $functions.sex_founder_filter.sex_select
                #if $functions.sex_founder_filter.no_sex_select:
                    $functions.sex_founder_filter.no_sex_select
                #end if
                $functions.sex_founder_filter.nonfounders
            #end if

    #elif $functions.func == 'data_manage':

        #if $functions.bmerge.set == 'Yes':
            --bmerge bmerge_files/bmerge_input
        #end if
        
        #if $functions.template:
            --set-missing-var-ids  $functions.template
        #end if

        $functions.recode

        #if $functions.flip:
            --flip $functions.flip
        #end if
        
        #if $functions.length:
            --new-id-max-allele-len $functions.length
        #end if

        #if $functions.update_cols.set == 'update_map':
            --update-map $functions.update_cols.input $functions.update_cols.col_num $functions.update_cols.old_col $functions.update_cols.skip
        #elif $functions.update_cols.set == 'update_name':
            --update-name $functions.update_cols.input $functions.update_cols.col_num $functions.update_cols.var_col $functions.update_cols.skip
        #end if
        #if $functions.ref_allele.set == 'yes':
            --reference-allele $functions.ref_allele.file $functions.ref_allele.column $functions.ref_allele.var_id $functions.ref_allele.skip
        #end if
        #if $functions.a2_allele.set == 'yes':
            --a2-allele $functions.a2_allele.file $functions.a2_allele.column $functions.a2_allele.var_id  $functions.a2_allele.skip
        #end if
    #elif $functions.func == 'stats':
        $functions.freq
        $functions.hardy
        $functions.missing
        $functions.het
        #if $functions.sex.sex_stats:
            $functions.sex.sex_stats
            #if $functions.sex.mode:
                $functions.sex.mode.mode
                #if $functions.sex.mode.mode == 'ycount'
                    $functions.sex.mode.female_max
                    $functions.sex.mode.male_min
                    $functions.sex.mode.female_max_obvs
                    $functions.sex.mode.male_min_obvs
                #elif $functions.sex.mode.mode == 'y-only'
                    $functions.sex.mode.female_max_obvs
                    $functions.sex.mode.male_min_obvs
                #else:
                    $functions.sex.mode.female_max
                    $functions.sex.mode.male_min
                #end if
            #end if
        #end if


    #elif $functions.func == 'link':
        #if $functions.set_indep.choice == 'Yes':
            --indep-pairwise $functions.set_indep.window $functions.set_indep.step $functions.set_indep.r2
        #end if
##    #elif $functions.func == 'pair_compare':
##
##    #elif $functions.func == 'dist_sim':
##
    #elif $functions.func == 'stratification':
        #if $functions.read_genome:
            --read-genome $functions.read_genome
        #end if
        #if $functions.cluster.cluster == 'Yes':
            --cluster
            #for $type in $functions.cluster.modifiers
                $type
            #end for
            #if $functions.cluster.mds.mds_scaling == 'Yes':
                --mds-plot $functions.cluster.mds.dimensions
                #for $type in $functions.cluster.mds.modifiers
                    $type
                #end for
            #end if
        #end if

    #elif $functions.func == 'association':
        #if $functions.assoc.assoc == 'Yes':
            --assoc
            #if $functions.assoc.perm.perm == 'perm':
                perm
            #elif $functions.assoc.perm.perm == 'mperm':
                mperm='$functions.assoc.perm.value'
            #end if
            $functions.assoc.genedrop
            $functions.assoc.perm_count
            $functions.assoc.fisher
            $functions.assoc.count
        #end if
        #if $functions.adjust.adjust == 'Yes':
            --adjust 
            #for $type in $functions.adjust.tests:
                    $type
            #end for
        #end if
##        #if $functions.linear.linear == 'Yes':
##            --linear
##            #if $functions.linear.perm == 'perm':
##                perm
##            #elif $functions.linear.perm == 'mperm':
##                mperm='$functions.linear.perm.value'
##            #end if
##            $functions.linear.genedrop
##            $functions.linear.perm_count
##            $functions.linear.dominance
##            $functions.linear.hide_covar
##            $functions.linear.sex_covar
##            $functions.linear.interaction
##            $functions.linear.beta
##            $functions.linear.standard_beta
##            $functions.linear.intercept
##        #end if
        #if $functions.logistic.logistic == 'Yes':
            --logistic
            #if $functions.logistic.perm.perm == 'perm':
                perm
            #elif $functions.logistic.perm.perm == 'mperm':
                mperm='$functions.logistic.perm.value'
            #end if
            $functions.logistic.genedrop
            $functions.logistic.perm_count
            $functions.logistic.dominance
            $functions.logistic.hide_covar
            $functions.logistic.sex_covar
            $functions.logistic.interaction
            $functions.logistic.beta
            $functions.logistic.intercept
        #end if

    #elif $functions.func == 'ibd':
        #if $functions.genome.output_genome:
            --genome
            #for $type in $functions.genome.modifiers
                $type
            #end for
            #if $functions.genome.min:
                --min $functions.genome.min
            #end if
            #if $functions.genome.max:
                --max $functions.genome.max
            #end if
            #if $functions.genome.ppc:
                --ppc-gap $functions.genome.ppc
            #end if
        #end if

##    #elif $functions.func == 'scoring':
##
##    #else:
##        --rerun $functions.logfile
##      
    #end if

    --make-bed
    --out plink_output/plink_output
    ]]></command>
    <inputs>
        <section name='inputs' title='Data inputs' expanded='true'>
            <conditional name='inputs'>
                <param name='filetype' type='select' label='Main input data type'>
                    <option value='bfile'>plink file</option>
                    <option value='vcf'>VCF input file</option>
                </param>
                <when value='bfile'>
                    <param format='binary' name='bed' type='data' label='plink bed file'/>
                    <param format='tabular,tsv' name='bim' type='data' label='plink bim file'/>
                    <param format='txt' name='fam' type='data' label='plink fam file'/>
                </when>
                <when value='vcf'>
                    <param name='input' format='vcf,bcf' type='data' label='VCF/BCF Input file'/>
                </when>
            </conditional>
            <param name='pheno' type='data' format='txt,tabular' label='Phenotype file' help='Read phenotype values from the 3rd column of the specified space- or tab-delimited file, instead of the .fam or .ped file.' optional='true'/> 
            <param name='covar_input' type='data' format='tabular,tsv' label='Input covariate file' optional='true'/>
        </section>
        <conditional name='functions'>
            <param name='func' type='select' label='Plink functions'>
                <option value='filtering'>Filtering</option>
                <option value='data_manage'>Data Management</option>
                <option value='stats'>Basic statistics</option>
                <option value='link'>Linkage disequalibrium</option>
                <option value='stratification'>Population stratification</option>
                <option value='association'>Association analysis</option>
                <option value='ibd'>Identity-by-descent</option>
                <!-- <option value='rerun'>Rerun</option> -->
            </param>
            <when value='filtering'>
                <conditional name='id_list'>
                    <param name='func' type='select' label='ID list functions'>
                        <option value='none'/>
                        <option value='keep'/>
                        <option value='keep-fam'/>
                        <option value='remove'/>
                        <option value='remove-fam'/>
                    </param>
                    <when value='none'/>
                    <when value='keep'>
                        <param format='tabular,tsv' name='file' type='data' label='Keep file.' help='Accepts one or more space/tab-delimited text files with sample IDs, and removes all unlisted samples from the current analysis;'/>
                    </when>
                    <when value='keep-fam'>
                        <param format='tabular,tsv' name='file' type='data' label='Keep-fam file' help='Accepts text files with family IDs in the first column, and keeps entire families.'/>
                    </when>
                    <when value='remove'>
                        <param format='tabular,tsv' name='file' type='data' label='Remove file' help='Accepts one or more space/tab-delimited text files with sample IDs, and removes all listed samples from the current analysis'/>
                    </when>
                    <when value='remove-fam'>
                        <param format='tabular,tsv' name='file' type='data' label='Remove-fam file' help='Acceptz text files with family IDs in the first column, and removes entire families.'/>
                    </when>
                </conditional>
                <conditional name='extraction'>
                    <param name='ex_func' type='select' label='ID extraction functions'>
                        <option value='none'/>
                        <option value='extract'/>
                        <option value='exclude'/>
                    </param>
                    <when value='none'/>
                    <when value='extract'>
                        <param format='txt' name='file' type='data' label='Extract' help='Accepts one or more text file(s) with variant IDs , and removes all unlisted variants from the current analysis'/>
                        <param type='boolean' name='range' truevalue='range' falsevalue='' help='Input file is input in set range format.'/>
                    </when>
                    <when value='exclude'>
                        <param format='txt' name='file' type='data' label='Exclude' help='Accepts one or more text file(s) with variant IDs , and removes all listed variants from the current analysis'/>
                        <param type='boolean' name='range' truevalue='range' falsevalue='' help='Input file is input in set range format.'/>
                    </when>
                </conditional>
                <!-- <param name='border' type='integer' label='Bed border bp' help='Extends all the intervals in an input BED file (for e.g. extract bed0) by the given number of base-pairs on both sides.' optional='true'/> -->
                <!-- <conditional name='col-cond'>
                    <param name='func' type='select' label='ID list functions'>
                        <option value='none'/>
                        <option value='extract-col-cond'/>
                        <option value='extract-col-cond-match'/>
                        <option value='extract-col-cond-mismatch'/>
                        <option value='extract-col-cond-substr'/>
                        <option value='extract-col-cond-min'/>
                        <option value='extract-col-cond-max'/>
                    </param>
                    <when value='none'/>
                    <when value='extract-col-cond'>
                    </when>
                    <when value='extract-col-cond-match'>
                    </when>
                    <when value='extract-col-cond-mismatch'>
                    </when>
                    <when value='extract-col-cond-substr'>
                    </when>
                    <when value='extract-col-cond-min'>
                    </when>
                    <when value='extract-col-cond-max'>
                    </when>
                </conditional> -->
                <param name='chromosome' type='text' label='Chromosome(s)' help='Excludes all variants not on the listed chromosome(s). Can be listed as single chromsome, a hyphenated range, or comma separated list.' optional='true'>
                    <expand macro='chr_sanitizer'/>
                </param>
                <param name='excluded_chromosome' type='text' label='Exclude Chromosome(s)' help='Excludes all variants on the listed chromosome(s). Can be listed as single chromsome, a hyphenated range, or comma separated list.' optional='true'>
                    <expand macro='chr_sanitizer'/>
                </param>
                <param name='extra_chromosomes' type='boolean' truevalue='--aec' falsevalue='' checked='false' label='Allow extra chromosomes' help='Allows specified extra chromosomes/scaffolds not normally listed. ex. chr1_gl000191_random.'/>
                <param name='autosome' type='select' label='Autosome/unplaced exclusion'>
                    <option value='none'>None</option>
                    <option value='--autosome'>Exclude all unplaced and non-autosomal variants</option>
                    <option value='--autosome-par'>Excludes all unplaced and non-autosomal variants, but keep XY/PAR1/PAR2. Can be combined with exclude-chromosmes.</option>
                </param>
                <param name='snps_exclusives' type='select' label='SNP exclusive'>
                    <option value='No'>No</option>
                    <option value='--snps-only'>Only return SNPs</option>
                    <option value='acgt'>Return SNPs, excluding any other than {'A', 'C', 'G', 'T', 'a', 'c', 'g', 't', missing}</option>
                </param>
                <conditional name='ranges'>
                    <param name='single_multi' type='select' label='Single or multiple variant-based range window?'>
                        <option value=''>No range specified</option>
                        <option value='single'>Single variants</option>
                        <option value='multi'>Multiple variants</option>
                    </param>
                    <when value=''/>
                    <when value='single'>
                        <conditional name='window'>
                            <param name='type' type='select' label='Specify range for variants'>
                                <option value='variant'>Around/between specific variant(s)</option>
                                <option value='window'>Around a specific variant</option>
                                <option value='range'>Within a specific area (Must also specify a single chromosome in above input)</option>
                            </param>
                            <when value='variant'>
                                <param name='from' type='text' label='From' help='Variant ID. Excludes all variants on different chromosomes than the named variant, as well as those with smaller base-pair position values. If they are used together but the --from variant is after the --to variant, they are automatically swapped.' optional='true'/>
                                <param name='to' type='text' label='To' help='Variant ID. Excludes all variants on different chromosomes than the named variant, as well as those with larger base-pair position values. If they are used together but the --from variant is after the --to variant, they are automatically swapped.' optional='true'/>
                            </when>
                            <when value='window'>
                                <param name='snp' type='text' label='SNP variant id to include' help='Use this OR SNP variant to exclude' optional='true'>
                                    <expand macro='snp_sanitizer'/>
                                </param>
                                <param name='exclude_snp' type='text' label='SNP variant id to exclude' help='Use this OR SNP variant to include' optional='true'>
                                    <expand macro='snp_sanitizer'/>
                                </param>
                                <param name='window' type='integer' label='Window' help='All variants with physical position no more than half the specified kb distance (decimal permitted) from the named variant are loaded as well' optional='true'/>
                            </when>
                            <when value='range'>
                                <param name='from_bp' type='integer' label='from-bp' help='These flags let you use physical positions to specify a variant range to load. Must also have specified a chromosome in above settings.' optional='true'/>
                                <param name='to_bp' type='integer' label='to-bp' help='These flags let you use physical positions to specify a variant range to load. Must also have specified a chromosome in above settings.' optional='true'/>
                            </when>
                        </conditional>
                    </when>
                    <when value='multi'>
                        <param name='force_intersect' type='boolean' truevalue='--force-intersect' falsevalue='' label='Force intersect'  help='To reduce the potential for confusion, PLINK 2 normally errors out when multiple variant-inclusion filters 
                        (--extract[-intersect], --extract-col-cond, --from/--to, --from-bp/--to-bp, --snp, --snps) are specified, since it may not be obvious whether the intersection or union will be taken. 
                        --force-intersect allows the run to proceed; the set intersection will be taken.'/>
                        <param name='snps' type='text' label='List of SNP variant ids to include' optional='true'>
                            <expand macro='snp_space_sanitizer'/>
                        </param>
                        <param name='exclude_snps' type='text' label='List of SNP variant ids to exclude' optional='true'>
                            <expand macro='snp_space_sanitizer'/>
                        </param>
                    </when>
                </conditional>
                <conditional name='thinning'>
                    <param name='thinning' type='select' label='Arbitrary thinning'>
                        <option value='No'/>
                        <option value='Yes'/>
                    </param>
                    <when value='No'/>
                    <when value='Yes'>
                        <param name='thin' type='float' label='Thin' min='0' max='1.0' help='Removes variants at random by retaining each variant with probability p' optional='true'/>
                        <param name='thin_count' type='integer' label='Thin Count' help='Removes variants at random until only n remain' min='1' optional='true'/>
                        <param name='bp_space' type='integer' label='BP space' help='Excludes one variant from each pair closer than the given bp count' optional='true'/>
                        <param name='thin_indiv' type='float' label='Thin Individual' min='0' max='1.0' help='Removes samples at random by retaining each sample with probability p' optional='true'/>
                        <param name='thin_indiv_count' type='integer' label='Thin Individual count' min='1' help='Removes samples at random until only n remain.' optional='true'/>
                    </when>
                </conditional>
                <!-- <conditional name='pheno_cov_based'>
                    <param name='pheno_cov' type='select' label='Phenotype/Covariate-based'>
                        <option value='No' selected='true'/>
                        <option value='phenotype'/>
                        <option value='Covariate'/>
                    </param>
                    <when value='No'/>
                    <when value='phenotype'> -->
                        <!-- keep-if <phenotype/covariate name> <operator> <value>
                        remove-if <phenotype/covariate name> <operator> <value>
                        require-pheno [phenotype name(s)...]
                        keep-cats <filename>
                        keep-cat-names <name(s)...>
                        remove-cats <filename>
                        remove-cat-names <name(s)...>
                        keep-cat-pheno <phenotype/covariate name>
                        remove-cat-pheno <phenotype/covariate name>
                    </when> 
                    <when value='Covariate'>
                        keep-if <phenotype/covariate name> <operator> <value>
                        remove-if <phenotype/covariate name> <operator> <value>
                        require-covar [covariate name(s)...]
                        keep-cats <filename>
                        keep-cat-names <name(s)...>
                        remove-cats <filename>
                        remove-cat-names <name(s)...> 
                    </when>
                </conditional> -->
                <section name='geno_rates' title='Missing Genotype Rates' expanded='true'>
                    <param name='geno' type='float' min='0' max='1' label='Set Geno'  help='filters out all variants with missing call rates exceeding the provided value (default 0.1) to be removed' optional='true'/>
                    <param name='mind' type='float' min='0' max='1' label='Set Mind' help='filters out all samples with missing call rates exceeding the provided value (default 0.1) to be removed' optional='true'/>
                </section>
                <section name='allele_freq' title='Allele Frequencies' expanded='true'>
                    <param name='maf' type='float' label='Minimum allele frequency' min='0' max='1.0' help='Filters out all variants with allele frequency below the provided threshold' optional='true'/>
                    <param name='max_maf' type='float' label='Maximum allele frequency' min='0' max='1.0' help='Filters out all variants with allele frequency above the provided threshold' optional='true'/>
                    <param name='mac' type='integer' label='Minimum allele count' min='1' help='Filters out all variants with allele counts below the provided threshold' optional='true'/>
                    <param name='max_mac' type='integer' label='Maximum allele count' min='0' help='filters out all variants with allele counts above the provided threshold' optional='true'/>
                </section>
                <conditional name='hwe'>
                    <param  name='hwe' type='select' help='Set Hardy-Weinberg equilibrium tests'>
                        <option value='No'/>
                        <option value='Yes'/>
                    </param>
                    <when value='No'/>
                    <when value='Yes'>
                        <param name='hwe_val' type='float' label='Hardy-Weinberg Equilibrium' help='Filters out all variants which have Hardy-Weinberg equilibrium exact test 
                        p-value below the provided threshold. It is recommended setting a low threshold—serious genotyping errors often yield extreme p-values like 1e-501 which 
                        are detected by any reasonable configuration of this test, while genuine SNP-trait associations can be expected to deviate slightly from Hardy-Weinberg 
                        equilibrium (so it is dangerous to choose a threshold that filters out too many variants).' value='1e-50' min='0' max='1'/>
                        <param name='modifiers' type='select' label='Test modifiers' multiple='true' display='checkboxes' optional='true'>
                            <option value='midp'>Apply the mid-p adjustment described in Graffelman J, Moreno V (2013) The mid p-value in exact tests for Hardy-Weinberg equilibrium</option>
                            <option value='include-nonctrl'>Don't ignore cases and missing phenotypes'</option>
                        </param>
                    </when>
                </conditional>
                <conditional name='sex_founder_filter'>
                    <param name='filter' type='select' label='Filter on sex and/or founders'>
                        <option value='No'/>
                        <option value='Yes'/>
                    </param>
                    <when value='No'/>
                    <when value='Yes'>
                        <param name='sex_select' type='select' label='Sex select' help='Filter by phenotypes, experiment, and founder state.'>
                            <option value='--filter-cases'>Only include cases</option>
                            <option value='--filter-controls'>Only include controls</option>
                            <option value='--filter-males'>Only include males</option>
                            <option value='--filter-females'>Only include females</option>
                            <option value='--filter-founders'>Exclude all samples with at least one known parental ID</option>
                            <option value='--filter-nonfounders'>Only include samples with at least one known parental ID</option>
                        </param>
                        <param name='no_sex_select' type='select' label='No sex settings' optional='true' help='How to deal with ambiguous sex phenotypes'>
                            <option value='--allow-no-sex'>Prevent samples with ambiguous sex frim having their phenotypes set to missing when analysis commands are run</option>
                            <option value='--must-have-sex'>Force phenotypes of ambiguous-sex samples to missing in output</option>
                        </param>
                        <param name='nonfounders' type='boolean' label='Nonfouders' truevalue='--nonfounders' falsevalue='' checked='false' help='Include nonfounders in --freq[x] or --maf/--max-maf/--hwe calculations'/>                   
                    </when>
                </conditional>
            </when>
            <when value='data_manage'>
                <conditional name='bmerge'>
                    <param name='set' type='select' label='Merge plink tilesets'>
                        <option value='No'/>
                        <option value='Yes'/>
                    </param>
                    <when value='No'/>
                    <when value='Yes'>
                        <param format='binary' name='bed' type='data' label='plink bed file'/>
                        <param format='tabular,tsv' name='bim' type='data' label='plink bim file'/>
                        <param format='tabular,tsv' name='fam' type='data' label='plink fam file'/>
                    </when>
                </conditional>
                <param name='recode' type='boolean' label='Recode' truevalue='--recode' falsevalue='' checked='false' help='Create a new text fileset, after applying sample/variant filters and other operations'/>
                <param format='tsv,tabular' name='flip' type='data' label='Flip DNA strand for SNPs' help='Given a file containing a list of SNPs with A/C/G/T alleles, --flip swaps A↔T and C↔G.' optional='true'/>
                <param name='template' type='text' label='Update Variant Info: Template String' help='Replaces missing IDs. The parameter taken by these flags is a special template string, with a @ where the chromosome code should go, and a # where the base-pair position belongs.'>
                    <expand macro='template_sanitizer'/>
                </param>
                <param name='length' type='integer' label='Max allele length' help='Length threshold to rename alleles. Recommended default is 23' optional='true'/>
                <conditional name='update_cols'>
                    <param name='set' type='select' label='Update variant columns'>
                        <option value='No'>No</option>
                        <option value='update_map'>update-map</option>
                        <option value='update_name'>update-name</option>
                    </param>
                    <when value='No'/>
                    <when value='update_map'>
                        <param name='input' type='data' format='tabular,tsv' help='By default, the new value is read from column 2 and the (old) variant ID from column 1, but you can adjust these positions with the second and third parameters.'/>
                        <param name='col_num' type='integer' min='0' label='New ID column number' value='2'/>
                        <param name='old_col' type='integer' min='0' label='Old ID column' value='1'/>
                        <param name='skip' type='text' label='Skip' optional='true' help='Either a nonnegative integer, in which case it indicates the number of lines to skip at the top of the file, or a single nonnumeric character, which causes each line with that leading character to be skipped.'/>
                    </when>
                    <when value='update_name'>
                        <param name='input' type='data' format='tabular,tsv' help='By default, the new value is read from column 2 and the (old) variant ID from column 1, but you can adjust these positions with the second and third parameters.'/>
                        <param name='col_num' type='integer' min='0' label='BP column number' value='2'/>
                        <param name='var_col' type='integer' min='0' label='Variant ID column' value='1'/>
                        <param name='skip' type='text' label='Skip' optional='true' help='Either a nonnegative integer, in which case it indicates the number of lines to skip at the top of the file, or a single nonnumeric character, which causes each line with that leading character to be skipped.'/>
                    </when>
                </conditional>
                <conditional name='ref_allele'>
                    <param name='set' type='select' label='Set REF alleles' help='These cannot be used with any other commands.'>
                        <option value='no'>No</option>
                        <option value='yes'>Yes</option>
                    </param>
                    <when value='no'/>
                    <when value='yes'>
                        <param name='file' type='data' format='vcf' label='Set all alleles specified in the file to REF'/>
                        <param name='column' type='integer' optional='true' min='1' label='Reference column number'/>
                        <param name='var_id' type='integer' optional='true' min='1' label='Variant id column in file'/>
                        <param name='skip' label='Skip' type='text' help='Either a nonnegative integer, in which case it indicates the number of lines to skip at the top of the file, or a single nonnumeric character, which causes each line with that leading character to be skipped.'/>
                    </when>
                </conditional>
                <conditional name='a2_allele'>
                    <param name='set' type='select' label='Set a2 alleles' help='These cannot be used with any other commands.'>
                        <option value='no'>No</option>
                        <option value='yes'>Yes</option>
                    </param>
                    <when value='no'/>
                    <when value='yes'>
                        <param name='file' type='data' format='vcf' label='Set all alleles specified in the file to first ALT allele'/>
                        <param name='column' type='integer' value='4' optional='true' label='Alt column number'/>
                        <param name='var_id' type='integer' value='3' optional='true' label='Variant id column in file'/>
                        <param name='skip' label='Skip' type='boolean' truevalue='skip' falsevalue='' checked='false' help='Either a nonnegative integer, in which case it indicates the number of lines to skip at the top of the file, or a single nonnumeric character, which causes each line with that leading character to be skipped.'/>
                    </when>
                </conditional>
            </when>
            <when value='stats'>
                <param name='freq' label='Return allele frequency file' type='boolean' truevalue='--freq' falsevalue=''/>
                <param name='hardy' label='Return  Hardy-Weinberg statistics file' type='boolean' truevalue='--hardy' falsevalue='' help='Writes out writes autosomal Hardy-Weinberg equilibrium exact test statistics'/>
                <param name='missing' label='Missing Data' type='boolean' truevalue='--missing' falsevalue='' help='produces sample-based and variant-based missing data reports'/>
                <param name='het' label='Inbreeding' type='boolean' truevalue='--het' falsevalue='' help='Compute observed and expected homozygous/heterozygous genotype counts for each sample, and reports method-of-moments F coefficient estimates'/>
                <conditional name='sex'>
                    <param name='sex_stats' label='Sex imputation' type='select'>
                        <option value=''>No</option>
                        <option value='--check-sex'>Compare sex assignments in input dataset with those imputed from X chromosome inbreeding coefficients</option>
                        <option value='--impute-sex'> Changes sex assignments to the imputed values. Cannot be set with any other flags.</option>
                    </param>
                    <when value=''/>
                    <when value='--check-sex'>
                        <conditional name='mode'>
                            <param name='mode' type='select' label='Mode select'>
                                <option value=''>Base</option>
                                <option value='ycount'>ycount</option>
                                <option value='y-only'>y-only</option>
                            </param>
                            <when value=''>
                                <param name='female_max' type='float' label='Female max proportion' min='0' max='1' optional='true'/>
                                <param name='male_min' type='float' label='Male min proportion' min='0' max='1' optional='true'/>
                            </when>
                            <when value='ycount'>
                                <param name='female_max' type='float' label='Female max proportion' min='0' max='1' optional='true'/>
                                <param name='male_min' type='float' label='Male min proportion' min='0' max='1' optional='true'/>
                                <param name='female_max_obvs' type='integer' label='Female max count' min='0' optional='true'/>
                                <param name='male_min_obvs' type='integer' label='Male min count' min='0' optional='true'/>
                            </when>
                            <when value='y-only'>
                                <param name='female_max_obvs' type='integer' label='Female max count' min='0' optional='true'/>
                                <param name='male_min_obvs' type='integer' label='Male mincountn' min='0' optional='true'/>
                            </when>
                        </conditional>
                    </when>
                    <when value='--impute-sex'>
                        <conditional name='mode'>
                            <param name='mode' type='select' label='Mode select'>
                                <option value=''>Base</option>
                                <option value='ycount'>ycount</option>
                                <option value='y-only'>y-only</option>
                            </param>
                            <when value=''>
                                <param name='female_max' type='float' label='Female max proportion' min='0' max='1' optional='true'/>
                                <param name='male_min' type='float' label='Male min proportion' min='0' max='1' optional='true'/>
                            </when>
                            <when value='ycount'>
                                <param name='female_max' type='float' label='Female max proportion' min='0' max='1' optional='true'/>
                                <param name='male_min' type='float' label='Male min proportion' min='0' max='1' optional='true'/>
                                <param name='female_max_obvs' type='integer' label='Female max count' min='0' optional='true'/>
                                <param name='male_min_obvs' type='integer' label='Male min count' min='0' optional='true'/>
                            </when>
                            <when value='y-only'>
                                <param name='female_max_obvs' type='integer' label='Female max count' min='0' optional='true'/>
                                <param name='male_min_obvs' type='integer' label='Male min count' min='0' optional='true'/>
                            </when>
                        </conditional>
                    </when>
                </conditional>
            </when>
            <when value='link'>
                <conditional name='set_indep'>
                    <param name='choice' label='Variant pruning' type='select' help='Since two-variant r2 only makes sense for biallelic variants, these collapse multiallelic variants down to most common allele vs. the rest.'>
                        <option value='Yes'>Yes</option>
                        <option value='No'>No</option>
                    </param>
                    <when value='No'/>
                    <when value='Yes'>
                        <param name='window' type='integer' label='Window size in bp' value='50' help='Window size'/>
                        <param name='step' type='integer' label='Step size (variant ct)' value='5'/>
                        <param name='r2' type='float' label='Unphased Hardcall r^2 Threshold' value='0.2' />
                    </when>
                </conditional>

            </when>
            <when value='stratification'>
                <param name='read_genome' label='Reusing an IBS/IBD calculation' format='tabular,tsv' type='data' optional='true'/>
                <conditional name='cluster'>
                    <param name='cluster' type='select' help='Use IBS values calculated via --genome to perform complete linkage clustering'>
                        <option value='No'/>
                        <option value='Yes'/>
                    </param>
                    <when value='No'/>
                    <when value='Yes'>
                        <param name='modifiers' type='select' label='Cluster flag modifiers' multiple='true' display='checkboxes' optional='true'>
                            <option value='cc'>Prevent two all-case or two all-control clusters from being merged.</option>
                            <option value='group-avg'>By default, the distance between two clusters is defined as the maximum pairwise distance between a member of the first cluster and a member of the second cluster. Cause average pairwise distance to be used instead.</option>
                            <option value='missing'>Cause clustering to be based on identity-by-missingness</option>
                        </param>
                        <conditional name='mds'>
                            <param name='mds_scaling' type='select' help='Return a Haploview-friendly multidimensional scaling report'>
                                <option value='No'/>
                                <option value='Yes'/>
                            </param>
                            <when value='No'/>
                            <when value='Yes'>
                                <param name='dimensions' type='integer' label='Dimension count' value='10'/>
                                <param name='modifiers' type='select' label='mds-plot flag modifiers' multiple='true' display='checkboxes' optional='true'>
                                    <option value='by-cluster'>Perform mds scaling on an inter-cluster distance matrix</option>
                                    <option value='eigendecomp'>Request faster eigendocomposition-based algorithm, yielding slightly different results</option>
                                    <option value='eigvals'>Write out top eigenvalues to separate file</option>
                                </param>
                            </when>
                        </conditional>
                    </when>
                </conditional>
            </when>
            <when value='association'>
                <conditional name='assoc'>
                    <param name='assoc' label='Perform 1df chi-square allelic test' type='select'>
                        <option value=''>No</option>
                        <option value='Yes'/>
                    </param>
                    <when value=''/>
                    <when value='Yes'>
                        <conditional name='perm'>
                            <param name='perm' type='select' help='Request an adaptive or max(T) permutation test on the additive effect.'>
                                <option value='No'>No</option>
                                <option value='perm'>Perform Monte Carlo permutation test</option>
                                <option value='mperm'>Perform a max(T) permutation test with specified number of replications</option>
                            </param>
                            <when value='No'/>
                            <when value='perm'/>
                            <when value='mperm'>
                                <param name='value' label='Replications' type='integer' min='0' value='10000'/>
                            </when>
                        </conditional>
                        <param name='genedrop' label='genedrop' type='boolean' truevalue='genedrop' falsevalue='' checked='false' help='Cause offspring genotypes to be regenerated via gene-dropping in the permutation test.'/>
                        <param name='perm_count' label='Perm-count' type='boolean' truevalue='perm-count' falsevalue='' checked='false' help='Cause the permutation test report to include permutation counts instead of frequencies.'/>
                        <param name='fisher' label='Fisher tests' type='select'>
                            <option value=''>Don't specify</option>
                            <option value='fisher'>Use fisher's exact test</option>
                            <option value='fisher-midp'>User Fisher's exact test with Lancaster's mid-p adjustment</option>                  
                        </param>
                        <param name='count' label='Counts' type='boolean' truevalue='counts' falsevalue='' checked='false' help='Report allele counts instead of frequencies'/>
                    </when>
                </conditional>
                <conditional name='adjust'>
                    <param name='adjust' label='Report basic multiple testing corrections for the raw p-values' type='select'>
                        <option value='No'/>
                        <option value='Yes'/>
                    </param>
                    <when value='No'/>
                    <when value='Yes'>
                        <param name='tests' label='Testing modifiers' type='select' multiple='true' display='checkboxes' optional='true'>
                            <option value='gc'>Use genomic-controlled p-values in the formulas</option>
                            <option value='log10'>Replace the p-values in the .adjusted file with their negative base 10 logarithms.</option>                 
                            <option value='qq-plot'>Add a quantile column to simplify QQ plotting.</option>
                        </param>
                    </when>
                </conditional>
                <!-- <conditional name='linear'>
                    <param name='linear' type='select' label='Perform linenar regression and return report'>
                        <option value='No'/>
                        <option value='Yes'/>
                    </param>
                    <when value='No'/>
                    <when value='Yes'>
                        <conditional name='perm'>
                            <param name='perm' type='select' help='Request an adaptive or max(T) permutation test on the additive effect.'>
                                <option value='No'>No</option>
                                <option value='perm'>Perform Monte Carlo permutation test</option>
                                <option value='mperm'>Perform a max(T) permutation test with specified number of replications</option>
                            </param>
                            <when value='No'/>
                            <when value='perm'/>
                            <when value='mperm'>
                                <param name='value' label='Replications' type='integer' min='0' value='10000'/>
                            </when>
                        </conditional>
                        <param name='genedrop' label='genedrop' type='boolean' truevalue='genedrop' falsevalue='' checked='false' help='Cause offspring genotypes to be regenerated via gene-dropping in the permutation test.'/>
                        <param name='perm_count' label='Perm-count' type='boolean' truevalue='perm-count' falsevalue='' checked='false' help='Cause the permutation test report to include permutation counts instead of frequencies.'/>
                        <param name='set_test' label='set_test' type='boolean' truevalue='set-test' falsevalue='' checked='false' help='Test the significance of variant sets'/>
                        <param name='dominance' label='Set dominance model' type='select'>
                            <option value=''>Don't specify</option>
                            <option value='genotypic'>Add an additive effect/dominance deviation 2df joint test (with two genotype-dependent variables in the regression, one with 0/1/2 coding and the second with 0/1/0</option>
                            <option value='hethom'>Add an additive effect/dominance deviation 2df joint test (with two genotype-dependent variables in the regression, one with 0/0/1 coding and the second with 0/1/0</option>
                            <option value='dominant'>Assume full dominance in A1 allele</option>
                            <option value='recessive'>Assume full recessiveness in A1 allele</option> 
                            <option value='no-snp'>Request a regression only on the phenotype and the covariates, without reference to genomic data</option>                    
                        </param>
                        <param name='hide_covar' label='hide_covar' type='boolean' truevalue='hide-covar' falsevalue='' checked='false' help='Remove covariate-specific lines from the main report'/>
                        <param name='sex_covar' label='Sex as a covariate' type='select'>
                            <option value=''>Only used where specified</option>
                            <option value='sex'>By default, when at least one male and one female is present, sex (male = 1, female = 0) is automatically added as a covariate on X chromosome SNPs, and nowhere else. The 'sex' modifier causes it to be added everywhere.</option>
                            <option value='no-x-sex'>By default, when at least one male and one female is present, sex (male = 1, female = 0) is automatically added as a covariate on X chromosome SNPs, and nowhere else. The 'no-x-sex' modifier causes it to be excluded everywhere</option>              
                        </param>
                        <param name='interaction' label='interaction' type='boolean' truevalue='interaction' falsevalue='' checked='false' help='Add genotype x covariate interactions to the model.'/>
                        <param name='beta' label='beta' type='boolean' truevalue='beta' falsevalue='' checked='false' help=''/>
                        <param name='standard_beta' label='standard-beta' type='boolean' truevalue='standard-beta' falsevalue='' checked='false' help=''/>
                        <param name='intercept' label='intercept' type='boolean' truevalue='intercept' falsevalue='' checked='false' help=''/>
                    </when>
                </conditional> -->
                <conditional name='logistic'>
                    <param name='logistic' type='select' label='Perform logistic regression and return report'>
                        <option value='No'/>
                        <option value='Yes'/>
                    </param>
                    <when value='No'/>
                    <when value='Yes'>
                        <conditional name='perm'>
                            <param name='perm' type='select' help='Request an adaptive or max(T) permutation test on the additive effect.'>
                                <option value='No'>No</option>
                                <option value='perm'>Perform Monte Carlo permutation test</option>
                                <option value='mperm'>Perform a max(T) permutation test with specified number of replications</option>
                            </param>
                            <when value='No'/>
                            <when value='perm'/>
                            <when value='mperm'>
                                <param name='value' label='Replications' type='integer' min='0' value='10000'/>
                            </when>
                        </conditional>
                        <param name='genedrop' label='genedrop' type='boolean' truevalue='genedrop' falsevalue='' checked='false' help='Cause offspring genotypes to be regenerated via gene-dropping in the permutation test.'/>
                        <param name='perm_count' label='Perm-count' type='boolean' truevalue='perm-count' falsevalue='' checked='false' help='Cause the permutation test report to include permutation counts instead of frequencies.'/>
                        <param name='dominance' label='Set dominance model' type='select'>
                            <option value=''>Don't specify</option>
                            <option value='genotypic'>Add an additive effect/dominance deviation 2df joint test (with two genotype-dependent variables in the regression, one with 0/1/2 coding and the second with 0/1/0</option>
                            <option value='hethom'>Add an additive effect/dominance deviation 2df joint test (with two genotype-dependent variables in the regression, one with 0/0/1 coding and the second with 0/1/0</option>
                            <option value='dominant'>Assume full dominance in A1 allele</option>
                            <option value='recessive'>Assume full recessiveness in A1 allele</option> 
                            <option value='no-snp'>Request a regression only on the phenotype and the covariates, without reference to genomic data</option>                    
                        </param>
                        <param name='hide_covar' label='Hide covar' type='boolean' truevalue='hide-covar' falsevalue='' checked='false' help='Remove covariate-specific lines from the main report'/>
                        <param name='sex_covar' label='Sex as a covariate' type='select'>
                            <option value=''>Only used where specified</option>
                            <option value='sex'>By default, when at least one male and one female is present, sex (male = 1, female = 0) is automatically added as a covariate on X chromosome SNPs, and nowhere else. The 'sex' modifier causes it to be added everywhere.</option>
                            <option value='no-x-sex'>By default, when at least one male and one female is present, sex (male = 1, female = 0) is automatically added as a covariate on X chromosome SNPs, and nowhere else. The 'no-x-sex' modifier causes it to be excluded everywhere</option>              
                        </param>
                        <param name='interaction' label='Interaction' type='boolean' truevalue='interaction' falsevalue='' checked='false' help='Add genotype x covariate interactions to the model.'/>
                        <param name='beta' label='Beta' type='boolean' truevalue='beta' falsevalue='' checked='false' help=''/>
                        <param name='intercept' label='Intercept' type='boolean' truevalue='intercept' falsevalue='' checked='false' help=''/>
                    </when>
                </conditional>
                <param name='lambda' type='float' label='Lambda value' optional='true'/>
            </when>
            <!-- <when value='scoring'>
            </when> -->
            <when value='ibd'>
                <conditional name='genome'>
                    <param name='output_genome' type='select' help='Perform and return results of IBS/IBD computation'>
                        <option value=''>No</option>
                        <option value='Yes'/>
                    </param>
                    <when value=''/>
                    <when value='Yes'>
                        <param name='min' type='float' label='min' min='0' max='1.0' help='Minimum PI_HAT value' optional='true'/>
                        <param name='max' type='float' label='max' min='0' max='1.0' help='Maximum PI_HAT value' optional='true'/>
                        <param name='ppc' type='integer' label='PPC-gap' min='0' help='Minimum distance between informative pairs of SNPs used in the pairwise population concordance (PPC) inn kbs' value='500' optional='true'/>
                        <param name='modifiers' type='select' label='Genome flag modifiers' multiple='true' display='checkboxes' optional='true'>
                            <option value='rel-check'>Remove pairs of samples with different FIDs</option>
                            <option value='full'>Add IBS , HOMHOM and HETHET fields to output</option>
                            <option value='unbounded'>Turn off clipping due to IBD estimator</option>
                            <option value='nudge'>If PI_HAT2 greater than P(IBD=2), adjusts the final estimates to P(IBD=0) := (1-p2), P(IBD=1) := 2p(1-p), and P(IBD=2) := p2, where p is the current PI_HAT</option>
                        </param>
                    </when>
                </conditional>
            </when>
            <!-- <when value='rerun'>
                <param type='data' name='logfile' format='binary' label='Plink Log File'/>
            </when> -->
        </conditional>
    </inputs>
    <outputs>
        <!--Main-->
        <collection name='plink_out' type='list' label='Plink main outputs'>
            <data name='plink_bed' format='binary' from_work_dir='plink_output/plink_output.bed'/>
            <data name='plink_bim' format='tabular' from_work_dir='plink_output/plink_output.bim'/>
            <data name='plink_fam' format='tabular' from_work_dir='plink_output/plink_output.fam'/>
            <data name='plink_log' format='txt' from_work_dir='plink_output/plink_output.log'/>
        </collection>

        <!--Data Manage-->
        <data name='plink_ped' format='txt' from_work_dir='plink_output/plink_output.ped' label='${tool.name}: Recode ped'>
            <filter>functions['func'] == 'data_manage' and functions['recode']</filter>
        </data>
        <data name='plink_map' format='txt' from_work_dir='plink_output/plink_output.map' label='${tool.name}: Recode map'>
            <filter>functions['func'] == 'data_manage' and functions['recode']</filter>
        </data>

        <!--Stats-->
        <data name='frequency' format='tabular' from_work_dir='plink_output/plink_output.frq' label='${tool.name}: freq out'>
            <filter>functions['func'] == 'stats' and functions['freq']</filter>
        </data>
        <data name='hardy_out' format='tabular' from_work_dir='plink_output/plink_output.hwe' label='${tool.name}: Hardy-Weinberg equilibrium'>
            <filter>functions['func'] == 'stats' and functions['hardy']</filter>
        </data>
        <data name='missing_1' format='tabular' from_work_dir='plink_output/plink_output.imiss' label='${tool.name}: imiss'>
            <filter>functions['func'] == 'stats' and functions['missing']</filter>
        </data>
        <data name='missing_2' format='tabular' from_work_dir='plink_output/plink_output.lmiss' label='${tool.name}: lmiss'>
            <filter>functions['func'] == 'stats' and functions['missing']</filter>
        </data>
        <data name='het' format='tabular' from_work_dir='plink_output/plink_output.het' label='${tool.name}: Het'>
            <filter>functions['func'] == 'stats' and functions['het']</filter>
        </data>
        <data name='sex_check' format='tabular' from_work_dir='plink_output/plink_output.sexcheck' label='${tool.name}: Sex check'>
            <filter>functions['func'] == 'stats' and functions['sex']['sex_stats']</filter>
        </data>
        
        <!--Association-->
           <!--assoc-->
        <data name='assoc' format='tabular' from_work_dir='plink_output/plink_output.assoc' label='${tool.name}: Association'>
            <filter>functions['func'] == 'association' and functions['assoc']['assoc'] == 'Yes' and not functions['assoc']['fisher']</filter>         
        </data>
        <data name='perm' format='tabular' from_work_dir='plink_output/plink_output.assoc.perm' label='${tool.name}: Association Monte Carlo'>
            <filter>functions['func'] == 'association' and functions['assoc']['assoc'] == 'Yes' and functions['assoc']['perm']['perm'] == 'perm' and not functions['assoc']['fisher']</filter>
        </data>
        <data name='mperm' format='tabular' from_work_dir='plink_output/plink_output.assoc.mperm' label='${tool.name}: Association Max(T) permutation test'>
            <filter>functions['func'] == 'association' and functions['assoc']['assoc'] == 'Yes' and functions['assoc']['perm']['perm'] == 'mperm' and not functions['assoc']['fisher']</filter>
        </data>
        <data name='fisher' format='tabular' from_work_dir='plink_output/plink_output.assoc.fisher' label='${tool.name}: Association Fisher'>
            <filter>functions['func'] == 'association' and functions['assoc']['assoc'] == 'Yes' and functions['assoc']['assoc'] == 'Yes' and functions['assoc']['fisher']</filter>
        </data>
        <data name='fisher_perm' format='tabular' from_work_dir='plink_output/plink_output.assoc.fisher.perm' label='${tool.name}: Association Fisher perm'>
            <filter>functions['func'] == 'association' and functions['assoc']['assoc'] == 'Yes' and functions['assoc']['perm']['perm'] == 'perm' and functions['assoc']['fisher']</filter>
        </data>
        <data name='fisher_mperm' format='tabular' from_work_dir='plink_output/plink_output.assoc.fisher.mperm' label='${tool.name}: Association Fisher mperm'>
            <filter>functions['func'] == 'association' and functions['assoc']['assoc'] == 'Yes' and functions['assoc']['perm']['perm'] == 'mperm' and functions['assoc']['fisher']</filter>
        </data>

           <!--adjust-->
        <data name='adjust' format='tabular' from_work_dir='plink_output/plink_output.assoc.adjusted' label='${tool.name}: Adjusted'>
            <filter>functions['func'] == 'association' and functions['assoc']['assoc'] == 'Yes' and functions['adjust']['adjust'] == 'Yes' and not functions['assoc']['fisher']</filter>
        </data>
        <data name='adjust_fisher' format='tabular' from_work_dir='plink_output/plink_output.assoc.fisher.adjusted' label='${tool.name}: Fisher Adjusted'>
            <filter>functions['func'] == 'association' and functions['assoc']['assoc'] == 'Yes' and functions['adjust']['adjust'] == 'Yes' and functions['assoc']['fisher']</filter>
        </data>
        <data name='adjust_logistic' format='tabular' from_work_dir='plink_output/plink_output.assoc.logistic.adjusted' label='${tool.name}: Logistic Adjusted'>
            <filter>functions['func'] == 'association' and functions['adjust']['adjust'] == 'Yes' and functions['logistic']['logistic'] == 'Yes'</filter>
        </data>

        <!-- <data name='linear' format='tabular' from_work_dir='plink_output/plink_output.assoc.linenar' label='${tool.name}: Linear Regression'>
            <filter>functions['func'] == 'association' and functions.func.association.linear['linear'] == 'Yes'</filter>
        </data> -->

            <!--Logistic-->
        <data name='logistic' format='tabular' from_work_dir='plink_output/plink_output.assoc.logistic' label='${tool.name}: Logistic Regression'>
            <filter>functions['func'] == 'association' and functions['logistic']['logistic'] == 'Yes'</filter>
        </data>
        <data name='logistic_perm' format='tabular' from_work_dir='plink_output/plink_output.assoc.logistic.perm' label='${tool.name}: Logistic Association Monte Carlo'>
            <filter>functions['func'] == 'association' and functions['logistic']['logistic'] == 'Yes' and  functions['logistic']['perm']['perm'] == 'perm'</filter>
        </data>
        <data name='logistic_mperm' format='tabular' from_work_dir='plink_output/plink_output.assoc.logistic.mperm' label='${tool.name}: Logistic Association Max(T) permutation test'>
            <filter>functions['func'] == 'association' and functions['logistic']['logistic'] == 'Yes' and  functions['logistic']['perm']['perm'] == 'mperm'</filter>
        </data>
        
        <!--Link-->
        <data name='prune_in' format='tabular' from_work_dir='plink_output/plink_output.prune.in' label='${tool.name}: Prune In'>
            <filter>functions['func'] == 'link' and functions['set_indep']['choice'] == 'Yes'</filter>
        </data>
        <data name='prune_out' format='tabular' from_work_dir='plink_output/plink_output.prune.out' label='${tool.name}: Prune Out'>
            <filter>functions['func'] == 'link' and functions['set_indep']['choice'] == 'Yes'</filter>
        </data>

        <!--IBD-->
        <data name='genome' format='tabular' from_work_dir='plink_output/plink_output.genome' label='${tool.name}: Genome'>
            <filter>functions['func'] == 'ibd' and functions['genome']['output_genome']</filter>
        </data>
        
        <!--Stratifiction-->
        <data name='mds' format='txt' from_work_dir='plink_output/plink_output.mds' label='${tool.name}: MDS'>
            <filter>functions['func'] == 'stratification' and functions['cluster']['cluster'] == 'Yes' and functions['cluster']['mds']['mds_scaling'] == 'Yes'</filter>
        </data>
        <data name='cluster1' format='tabular' from_work_dir='plink_output/plink_output.cluster1' label='${tool.name}: Cluster 1'>
            <filter>functions['func'] == 'stratification' and functions['cluster']['cluster'] == 'Yes'</filter>
        </data>
        <data name='cluster2' format='tabular' from_work_dir='plink_output/plink_output.cluster2' label='${tool.name}: Cluster 2'>
            <filter>functions['func'] == 'stratification' and functions['cluster']['cluster'] == 'Yes'</filter>
        </data>
        <data name='cluster3' format='tabular' from_work_dir='plink_output/plink_output.cluster3' label='${tool.name}: Cluster 3'>
            <filter>functions['func'] == 'stratification' and functions['cluster']['cluster'] == 'Yes' and 'missing' not in functions['cluster']['modifiers']</filter>
        </data>
        <data name='cluster3missing' format='tabular' from_work_dir='plink_output/plink_output.cluster3.missing' label='${tool.name}: Cluster 3 missing'>
            <filter>functions['func'] == 'stratification' and functions['cluster']['cluster'] == 'Yes' and functions['cluster']['modifiers'] and 'missing' in functions['cluster']['modifiers']</filter>
        </data>
        <data name='mds_miss' format='tabular' from_work_dir='plink_output/plink_output.mdist.missing' label='${tool.name}: Mdist missing'>
            <filter>functions['func'] == 'stratification' and functions['cluster']['cluster'] == 'Yes' and functions['cluster']['modifiers'] and 'missing' in functions['cluster']['modifiers']</filter>
        </data>
        <data name='eigenvals' format='txt' from_work_dir='plink_output/plink_output.mds.eigvals' label='${tool.name}: Eigenvals'>
            <filter>functions['func'] == 'stratification' and functions['cluster']['cluster'] == 'Yes' and functions['cluster']['mds']['mds_scaling'] == 'Yes' and functions['cluster']['mds']['modifiers'] and 'eigvals' in functions['cluster']['mds']['modifiers']</filter>
        </data>
    </outputs>
    <tests>
        <test expect_num_outputs='5'>
            <section name='inputs'>
                <conditional name='inputs'>
                    <param name='filetype' value='bfile'/>
                    <param name='bed' value='plink.bed'/>
                    <param name='bim' value='plink.bim'/>
                    <param name='fam' value='plink.fam'/>
                </conditional>
            </section>
            <conditional name='functions'>
                <param name='func' value='filtering'/>
                <conditional name='id_list'>
                    <param name='func' value='remove'/>
                    <param name='file' value='1.tabular'/>
                </conditional>
                <conditional name='extraction'>
                    <param name='ex_func' value='exclude'/>
                    <param name='file' value='testing.txt'/>
                    <param name='range' value='true'/>
                </conditional>
                <param name='snps_exclusives' value='--snps-only'/>
                <conditional name='ranges'>
                    <param name='single_multi' value='single'/>
                    <conditional name='window'>
                        <param name='type' value='variant'/>
                        <param name='from' value='snp0'/>
                        <param name='to' value='snp3'/>
                    </conditional>
                </conditional>
                <conditional name='thinning'>
                    <param name='thinning' value='Yes'/>
                    <param name='thin_count' value='4'/>
                </conditional>
                <section name='geno_rates'>
                    <param name='geno' value='0.02'/>
                    <param name='mind' value='0.02'/>
                </section>
                <section name='allele_freq'>
                    <param name='maf' value='0.01'/>
                </section>
                <conditional name='hwe'>
                    <param name='hwe' value='Yes'/>
                    <param name='hwe_val' value='1e-50'/>
                    <param name='modifiers' value='midp,include-nonctrl'/>
                </conditional>
                <conditional name='sex_founder_filter'>
                    <param name='filter' value='Yes'/>
                    <param name='sex_select' value='--filter-cases'/>
                    <param name='no_sex_select' value='--allow-no-sex'/>
                    <param name='nonfounders' value='--nonfounders'/>
                </conditional>
            </conditional>
            <output_collection name='plink_out' type='list'>
                <element name='plink_bed' file='test1_out.bed' compare='sim_size'/>
                <element name='plink_bim' file='test1_out.bim'/>
                <element name='plink_fam' file='test1_out.fam'/>
            </output_collection>
        </test>

        <test expect_num_outputs='7'>
            <section name='inputs'>
                <conditional name='inputs'>
                    <param name='filetype' value='bfile'/>
                    <param name='bed' value='plink.bed'/>
                    <param name='bim' value='plink.bim'/>
                    <param name='fam' value='plink.fam'/>
                </conditional>
            </section>
            <conditional name='functions'>
                <param name='func' value='data_manage'/>
                <conditional name='bmerge'>
                    <param name='set' value='Yes'/>
                    <param name='bed' value='plink_2.bed'/>
                    <param name='bim' value='plink_2.bim'/>
                    <param name='fam' value='plink_2.fam'/>
                </conditional>
                <param name='recode' value='--recode'/>
                <param name='template' value='@asd#123'/>
                <param name='length' value='23'/>
                <conditional name='update_cols'>
                    <param name='set' value='update_name'/>
                    <param name='input' value='update_cols.txt'/>
                    <param name='col_num' value='1'/>
                    <param name='var_col' value='2'/>
                    <param name='skip' value='a'/>
                </conditional>
            </conditional>
            <output_collection name='plink_out' type='list'>
                <element name='plink_bed' file='test2_out.bed' compare='sim_size'/>
                <element name='plink_bim' file='test2_out.bim'/>
                <element name='plink_fam' file='test2_out.fam'/>
            </output_collection>
            <output name='plink_ped' file='out.ped'/>
            <output name='plink_map' file='out.map'/>
        </test>

        <test expect_num_outputs='5'>
            <section name='inputs'>
                <conditional name='inputs'>
                    <param name='filetype' value='vcf'/>
                    <param name='input' value='test.vcf'/>
                </conditional>
            </section>
            <output_collection name='plink_out' type='list'>
                <element name='plink_bed' file='vcf_out.bed'/>
                <element name='plink_bim' file='vcf_out.bim'/>
                <element name='plink_fam' file='vcf_out.fam'/>
            </output_collection>
        </test>

        <test expect_num_outputs='11'>
            <section name='inputs'>
                <conditional name='inputs'>
                    <param name='filetype' value='bfile'/>
                    <param name='bed' value='plink.bed'/>
                    <param name='bim' value='x_plink.bim'/>
                    <param name='fam' value='plink.fam'/>
                </conditional>
            </section>
            <conditional name='functions'>
                <param name='func' value='stats'/>
                <param name='freq' value='--freq'/>
                <param name='hardy' value='--hardy'/>
                <param name='missing' value='--missing'/>
                <param name='het' value='--het'/>
                <conditional name='sex'>
                    <param name='sex_stats' value='--check-sex'/>
                    <conditional name='mode'>
                        <param name='mode' value='ycount'/>
                        <param name='female_max' value='0.2'/>
                        <param name='male_min' value='0.8'/>
                        <param name='female_max_obvs' value='10'/>
                        <param name='male_min_obvs' value='200'/>
                    </conditional>
                </conditional>
            </conditional>
            <output_collection name='plink_out' type='list'>
                <element name='plink_bed' file='stats.bed'/>
                <element name='plink_bim' file='stats.bim'/>
                <element name='plink_fam' file='stats.fam'/>
                <element name='plink_fam' file='stats.fam'/>
            </output_collection>
            <output name='frequency' file='out.freq'/>
            <output name='hardy_out' file='out.hardy'/>
            <output name='missing_1' file='out.imiss'/>
            <output name='missing_2' file='out.lmiss'/>
            <output name='het' file='out.het'/>
            <output name='sex_check' file='out.sexcheck'/>
        </test>

        <test expect_num_outputs='7'>
            <section name='inputs'>
                <conditional name='inputs'>
                    <param name='filetype' value='bfile'/>
                    <param name='bed' value='plink.bed'/>
                    <param name='bim' value='plink.bim'/>
                    <param name='fam' value='plink.fam'/>
                </conditional>
            </section>
            <conditional name='functions'>
                <param name='func' value='link'/>
                <conditional name='set_indep'>
                    <param name='choice' value='Yes'/>
                    <param name='window' value='51'/>
                    <param name='step' value='6'/>
                    <param name='r2' value='0.3'/>
                </conditional>
            </conditional>
            <output_collection name='plink_out' type='list'>
                <element name='plink_bed' file='test5_out.bed' compare='sim_size'/>
                <element name='plink_bim' file='test5_out.bim'/>
                <element name='plink_fam' file='test5_out.fam'/>
            </output_collection>
            <output name='prune_in' file='plink.prune.in'/>
        </test>
        
        <test expect_num_outputs='10'>
            <section name='inputs'>
                <conditional name='inputs'>
                    <param name='filetype' value='bfile'/>
                    <param name='bed' value='plink.bed'/>
                    <param name='bim' value='plink.bim'/>
                    <param name='fam' value='plink.fam'/>
                </conditional>
            </section>
            <conditional name='functions'>
                <param name='func' value='stratification'/>
                <param name='read_genome' value='plink.genome'/>
                <conditional name='cluster'>
                    <param name='cluster' value='Yes'/>
                    <param name='modifiers' value='cc,group-avg'/>
                    <conditional name='mds'>
                        <param name='mds_scaling' value='Yes'/>
                        <param name='dimensions' value='10'/>
                        <param name='modifiers' value='eigendecomp,eigvals'/>
                    </conditional>
                </conditional>
            </conditional>
            <output_collection name='plink_out' type='list'>
                <element name='plink_bed' file='test6_out.bed' compare='sim_size'/>
                <element name='plink_bim' file='test6_out.bim'/>
                <element name='plink_fam' file='test6_out.fam'/>
            </output_collection>
            <output name='mds' value='plink.mds' compare='sim_size'/>
            <output name='cluster1' value='plink.cluster1' compare='sim_size'/>
            <output name='cluster2' value='plink.cluster2' compare='sim_size'/>
            <output name='cluster3' value='plink.cluster3' compare='sim_size'/>
            <output name='eigenvals' value='plink.mds.eigenval' compare='sim_size'/>
        </test>

        <test expect_num_outputs='11'>
            <section name='inputs'>
                <conditional name='inputs'>
                    <param name='filetype' value='bfile'/>
                    <param name='bed' value='plink.bed'/>
                    <param name='bim' value='plink.bim'/>
                    <param name='fam' value='plink.fam'/>
                </conditional>
            </section>
            <conditional name='functions'>
                <param name='func' value='association'/>
                <conditional name='assoc'>
                    <param name='assoc' value='Yes'/>
                    <conditional name='perm'>
                        <param name='perm' value='mperm'/>
                        <param name='value' value='10000'/>
                    </conditional>
                    <param name='fisher' value='fisher-midp'/>
                </conditional>
                <conditional name='adjust'>
                    <param name='adjust' value='Yes'/>
                    <param name='tests' value='gc,log10,qq-plot'/>
                </conditional>
                <conditional name='logistic'>
                    <param name='logistic' value='Yes'/>
                    <conditional name='perm'>
                        <param name='perm' value='perm'/>
                    </conditional>
                    <param name='genedrop' value='genedrop'/>
                    <param name='perm_count' value='perm-count'/>
                    <param name='dominance' value='dominant'/>
                    <param name='hide_covar' value='hide-covar'/>
                    <param name='beta' value='beta'/>
                    <param name='intercept' value='intercept'/>
                </conditional>
                <param name='lambda' value='1.0'/>
            </conditional>
            <output_collection name='plink_out' type='list'>
                <element name='plink_bed' file='out.assoc.bed' compare='sim_size'/>
                <element name='plink_bim' file='out.assoc.bim'/>
                <element name='plink_fam' file='out.assoc.fam'/>
            </output_collection>
            <output name='fisher' value="out.assoc.fisher"/>
            <output name='adjust_fisher' value="out.assoc.fisher.adjusted" sort="True" />
            <output name='fisher_mperm' value="out.assoc.fisher.mperm" compare='sim_size'/>
            <output name='logistic' value="out.assoc.logistic"/>
            <output name='adjust_logistic' value="out.assoc.logistic.adjusted"/>
            <output name='logistic_perm' value="out.assoc.logistic.perm" compare='sim_size'/>
        </test>

        <test expect_num_outputs='6'>
            <section name='inputs'>
                <conditional name='inputs'>
                    <param name='filetype' value='bfile'/>
                    <param name='bed' value='plink.bed'/>
                    <param name='bim' value='plink.bim'/>
                    <param name='fam' value='plink.fam'/>
                </conditional>
            </section>
            <conditional name='functions'>
                <param name='func' value='ibd'/>
                <conditional name='genome'>
                    <param name='output_genome' value='Yes'/>
                    <param name='min' value='0.1'/>
                    <param name='max' value='0.9'/>
                    <param name='modifiers' value='full,unbounded,nudge'/>
                </conditional>
            </conditional>
            <output name='genome' file='out.genome'/>
        </test>
    </tests>
    <help><![CDATA[
        PLINK is a free, open-source whole genome association analysis toolset, designed to perform a range of basic, large-scale analyses in a computationally efficient manner.

        For detailed usage notes, visit http://www.cog-genomics.org/plink/2.0/
    ]]></help>
    <citations>
        <citation type='doi'>10.1186/s13742-015-0047-8</citation>
    </citations>
</tool>