<commit_before><tool profile="16.07" id="mothur_make_group" name="Make.group" version="@WRAPPER_VERSION@.0">
    <description>Make a group file</description>
    <macros>
        <import>macros.xml</import>
    </macros>
    <expand macro="requirements"/>
    <expand macro="stdio"/>
    <expand macro="version_command"/>
    <command><![CDATA[
@SHELL_OPTIONS@

#set fastas = ''
#set groups = ''
#set count = 0

#if $method.how == 'collection':
    #for $i in $method.fasta_collection:
        ln -s '$i' fasta_${i.element_identifier}.dat &&
        #set fastas+='fasta_'+$i.element_identifier+'.dat-'
        #set groups+=$i.element_identifier+'-'
    #end for
#else
    #for $i in $method.inputs:
        ln -s '$i.fasta' fasta_${count}.dat &&
        #set fastas+='fasta_'+str($count)+'.dat-'
        #set groups+=str($i.group)+'-'
        #set count+=1
    #end for
#end if

echo 'make.group(
    fasta=${ str($fastas).rstrip('-') },
    groups=${ str($groups).rstrip('-') }
)'
| sed 's/ //g'  ## mothur trips over whitespace
| mothur
| tee mothur.out.log
    ]]></command>
    <inputs>
        <conditional name="method">
            <param name="how" type="select" label="Method to create group file">
                <option value="collection"> Automatically from collection </option>
                <option value="manually"> Manually specify fasta files and group names</option>
            </param>
            <when value="collection">
                <param name="fasta_collection" type="data_collection" collection_type="list" format="fasta" label="Collection with fasta files to group" help="group names will be named after the collection element names"/>
            </when>
            <when value="manually">
                <repeat name="inputs" title="Additional">
                    <param name="fasta" type="data" format="fasta" label="fasta - Fasta to group"/>
                    <param name="group" type="text" label="group - Group name"/>
                </repeat>
            </when>
        </conditional>
        <expand macro="param-savelog"/>
    </inputs>
    <outputs>
        <expand macro="logfile-output"/>
        <data name="output" format="mothur.groups" from_work_dir="*groups" label="${tool.name} on ${on_string}: group"/>
    </outputs>
    <tests>
        <test> <!-- test manual groups creation -->
            <param name="how" value="manually"/>
            <repeat name="inputs">
                <param name="fasta" value="Mock_S280_L001_R1_001_small.trim.contigs.good.align_head"/>
                <param name="group" value="testgroup"/>
            </repeat>
            <repeat name="inputs">
                <param name="fasta" value="Mock_S280_L001_R1_001_small.trim.contigs.good.align_head"/>
                <param name="group" value="testgroup2"/>
            </repeat>
            <output name="output" file="Mock_S280_L001_R1_001_small.trim.contigs.good.Mock_S280_L001_R1_001_small.trim.contigs.good.groups"/>
            <param name="savelog" value="true"/>
            <expand macro="logfile-test"/>
        </test>
        <test> <!-- test auto-creation from collection -->
            <param name="how" value="collection"/>
            <param name="fasta_collection">
               <collection type="list">
                   <element name="testgroup" ftype="fasta" value="Mock_S280_L001_R1_001_small.trim.contigs.good.align_head" />
                   <element name="testgroup2" ftype="fasta" value="Mock_S280_L001_R1_001_small.trim.contigs.good.align_head" />
              </collection>
           </param>
           <output name="output" file="Mock_S280_L001_R1_001_small.trim.contigs.good.Mock_S280_L001_R1_001_small.trim.contigs.good.groups"/>
           <param name="savelog" value="true"/>
            <expand macro="logfile-test"/>
        </test>
    </tests>
    <help><![CDATA[

@MOTHUR_OVERVIEW@

**Command Documentation**

The make.group_ command reads a fasta file or series of fasta files and creates a group_ file.

.. _group: https://www.mothur.org/wiki/Group_file
.. _make.group: https://www.mothur.org/wiki/Make.group<commit_msg>fix for datasets containing spaces or dashes<commit_after><tool profile="16.07" id="mothur_make_group" name="Make.group" version="@WRAPPER_VERSION@.0">
    <description>Make a group file</description>
    <macros>
        <import>macros.xml</import>
    </macros>
    <expand macro="requirements"/>
    <expand macro="stdio"/>
    <expand macro="version_command"/>
    <command><![CDATA[
@SHELL_OPTIONS@

#import re

#set fastas = ''
#set groups = ''
#set count = 0

#if $method.how == 'collection':
    #for $i in $method.fasta_collection:
        #set $identifier=re.sub('[^\w_]', '_', str($i.element_identifier))
        ln -s '$i' 'fasta_${identifier}.dat' &&
        #set fastas+='fasta_'+$identifier+'.dat-'
        #set groups+=$identifier+'-'
    #end for
#else
    #for $i in $method.inputs:
        ln -s '$i.fasta' fasta_${count}.dat &&
        #set fastas+='fasta_'+str($count)+'.dat-'
        #set groups+=str($i.group)+'-'
        #set count+=1
    #end for
#end if

echo 'make.group(
    fasta=${ str($fastas).rstrip('-') },
    groups=${ str($groups).rstrip('-') }
)'
| sed 's/ //g'  ## mothur trips over whitespace
| mothur
| tee mothur.out.log
    ]]></command>
    <inputs>
        <conditional name="method">
            <param name="how" type="select" label="Method to create group file">
                <option value="collection"> Automatically from collection </option>
                <option value="manually"> Manually specify fasta files and group names</option>
            </param>
            <when value="collection">
                <param name="fasta_collection" type="data_collection" collection_type="list" format="fasta" label="Collection with fasta files to group"
                    help="group names will be derived from the dataset names of the collection elements, please make sure these are meaningful names"/>
            </when>
            <when value="manually">
                <repeat name="inputs" title="Additional">
                    <param name="fasta" type="data" format="fasta" label="fasta - Fasta to group"/>
                    <param name="group" type="text" label="group - Group name"/>
                </repeat>
            </when>
        </conditional>
        <expand macro="param-savelog"/>
    </inputs>
    <outputs>
        <expand macro="logfile-output"/>
        <data name="output" format="mothur.groups" from_work_dir="*groups" label="${tool.name} on ${on_string}: group"/>
    </outputs>
    <tests>
        <test> <!-- test manual groups creation -->
            <param name="how" value="manually"/>
            <repeat name="inputs">
                <param name="fasta" value="Mock_S280_L001_R1_001_small.trim.contigs.good.align_head"/>
                <param name="group" value="testgroup"/>
            </repeat>
            <repeat name="inputs">
                <param name="fasta" value="Mock_S280_L001_R1_001_small.trim.contigs.good.align_head"/>
                <param name="group" value="testgroup2"/>
            </repeat>
            <output name="output" file="Mock_S280_L001_R1_001_small.trim.contigs.good.Mock_S280_L001_R1_001_small.trim.contigs.good.groups"/>
            <param name="savelog" value="true"/>
            <expand macro="logfile-test"/>
        </test>
        <test> <!-- test auto-creation from collection -->
            <param name="how" value="collection"/>
            <param name="fasta_collection">
               <collection type="list">
                   <element name="testgroup" ftype="fasta" value="Mock_S280_L001_R1_001_small.trim.contigs.good.align_head" />
                   <element name="testgroup2" ftype="fasta" value="Mock_S280_L001_R1_001_small.trim.contigs.good.align_head" />
              </collection>
           </param>
           <output name="output" file="Mock_S280_L001_R1_001_small.trim.contigs.good.Mock_S280_L001_R1_001_small.trim.contigs.good.groups"/>
           <param name="savelog" value="true"/>
            <expand macro="logfile-test"/>
        </test>
        <test> <!-- test with spaces or hyphens in element identifier -->
            <param name="how" value="collection"/>
            <param name="fasta_collection">
               <collection type="list">
                   <element name="test group" ftype="fasta" value="Mock_S280_L001_R1_001_small.trim.contigs.good.align_head" />
                   <element name="test-group2" ftype="fasta" value="Mock_S280_L001_R1_001_small.trim.contigs.good.align_head" />
              </collection>
           </param>
           <output name="output" file="make_group_collection.groups"/>
           <param name="savelog" value="true"/>
            <expand macro="logfile-test"/>
        </test>

    </tests>
    <help><![CDATA[

@MOTHUR_OVERVIEW@

**Command Documentation**

The make.group_ command reads a fasta file or series of fasta files and creates a group_ file.

.. _group: https://www.mothur.org/wiki/Group_file
.. _make.group: https://www.mothur.org/wiki/Make.group
{'fraction_non_alphanumeric': 0.15370227747827045, 'fraction_numerical': 0.021894597865551767, 'mean_word_length': 2.552168815943728, 'pattern_counts': {'":': 0, '<': 154, '<?xml version=': 0, '>': 152, 'https://': 4, 'lorem ipsum': 0, 'www.': 4, 'xml': 2}, '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': '6316120', 'n_tokens_mistral': 2938, 'n_tokens_neox': 2755, 'n_words': 578}