<tool id="pdaug_peptide_sequence_analysis" name="PDAUG Peptide Sequence Analysis" version="0.1.0">
  <description>Peptide sequence analysis</description>

  <requirements>
    <requirement type="package" version="4.2.1">modlamp</requirement> 
    <requirement type="package" version="1.0.5">pandas</requirement>
    <requirement type="package" version="4.10.0">plotly</requirement> 
  </requirements>
  <stdio>
    <exit_code range="1" level="fatal" />
  </stdio>
    <command detect_errors="exit_code"><![CDATA[


        python '$__tool_directory__/PDAUG_Peptide_Sequence_Analysis.py'  '$SelAnalysis.Analysis'

                        #if $SelAnalysis.Analysis == 'CalcAAFreq'
                            --InFile '$SelAnalysis.input1'
                            --PlotFile '$output2'
                            --OutFile '$output1'
                        #end if 

                        #if $SelAnalysis.Analysis == 'H'
                            --InFile '$SelAnalysis.input1'
                            --Scale '$SelAnalysis.scale'
                            --OutFile '$output1'                            
                        #end if 

                        #if $SelAnalysis.Analysis == 'uH'
                            --InFile '$SelAnalysis.input1'
                            --Scale '$SelAnalysis.Scale'
                            --Window '$SelAnalysis.Window'
                            --Angle '$SelAnalysis.Angle'
                            --Modality '$SelAnalysis.Modality'
                            --OutFile '$output1'
                        #end if 

                        #if $SelAnalysis.Analysis == 'charge'
                            --InFile '$SelAnalysis.input1'
                            --ph '$SelAnalysis.ph'
                            --Amide '$SelAnalysis.amide'
                            --OutFile '$output1'

                        #end if 

                        #if $SelAnalysis.Analysis == 'Len'
                            --InFile '$SelAnalysis.input1'
                            --OutFile '$output1'
                        #end if 

                        #if $SelAnalysis.Analysis == 'PlotSummary'
                            --InFile1 '$SelAnalysis.input1'
                            --InFile2 '$SelAnalysis.input2'
                            --First_lib_name '$SelAnalysis.Pep1name'
                            --Second_lib_name '$SelAnalysis.Pep2name'
                            --htmlOutDir '$output2.extra_files_path'
                            --htmlFname '$output2' 
                        #end if  

                    
    ]]></command>


  <inputs>

    <conditional name='SelAnalysis' >

        <param name="Analysis" type="select" label="Analysis options" argument="">
          <option value="CalcAAFreq">Calculate Amino Acid frequency</option>
          <option value="H">Calculate Global Hydrophobicity</option>
          <option value="uH">Calculating Hydrophobic Moments</option>
          <option value="charge">Calculate Total Molecular Charge</option>
          <option value="Len">Calculate Sequence Length</option>
          <option value="PlotSummary">Summary Plot</option>
        </param>

        <when value="CalcAAFreq">
            <param name="input1" type="data" format="fasta" label="Input file" argument= "--InFile" help="Input fasta file with Peptides"/>
        </when>

        <when value="H">
            <param name="input1" type="data" format="fasta" argument= "--InFile" label="Input file" help="Input fasta file with Peptides"/>
            <param name="scale" type="text" value="eisenberg" label="Hydrophobicity scale" help="Hydrophobicity scale"/>
        </when>

        <when value="uH">
            <param name="input1" type="data" format="fasta" argument= "--InFile" label="Input file" help="Input fasta file with Peptides"/>
            <param name="Scale" type="text" value="eisenberg" label="hydrophobicity scale" argument="--Scale" help="Hydrophobicity scale"/>
            <param name="Window" type="integer" label="Window" value="1000" argument="--Window" help="Amino acid window in which to calculate the moment" />
            <param name="Angle" type="integer" label="Angle" value="100" argument="--Angle" help="Angle in which to calculate the moment. 100 for alpha helices, 180 for beta sheets."/>
            <param name="Modality" type="select"  label="hydrophobicity scale" argument="--modality" help="Calculate respectively maximum or mean hydrophobic moment.">
                <option value="max" >Max</option> 
                <option value="mean">Mean</option> 
            </param>

        </when>

        <when value="charge">
            <param name="input1" type="data" format="fasta" label="Input " argument= "--InFile" help="Input fasta file with Peptides"/>
            <param name="ph" type="float" label="ph" value="7.0"  help="--ph" />
            <param name="amide" type="boolean" label="amide" value="true" help="--Amide" />
        </when>

        <when value="Len">
            <param name="input1" type="data" format="fasta" argument= "--InFile" label="Input file" help="Input fasta file with Peptides"/>
        </when>

        <when value="PlotSummary">
            <param name="input1" type="data" format="fasta"  argument= "--InFile1" label="First input file" help="Input fasta file with Peptides"/>
            <param name="input2" type="data" format="fasta" argument= "--InFile2" label="Second input file" help="Input fasta file with Peptides"/>
            <param name="Pep1name" type="text" value="First data set" label="Name of the first dataset" help="Input fasta file with Peptides"/>
            <param name="Pep2name" type="text" value="Second data set"  label="Name of the second dataset" help="Input fasta file with Peptides"/>
        </when>
    </conditional>
  </inputs>


  <outputs>
        <data name='output1' format='tabular' label="${tool.name} on $on_string - ${SelAnalysis.Analysis} (tabular)" > 

            <filter>SelAnalysis['Analysis'] != "PlotSummary"</filter>
        </data>


         <data name='output2' format='html' label="${tool.name} on $on_string - ${SelAnalysis.Analysis} (webpage)" > 
             <filter>SelAnalysis['Analysis'] != "H"</filter>
             <filter>SelAnalysis['Analysis'] != "uH"</filter>
             <filter>SelAnalysis['Analysis'] != "charge"</filter>
             <filter>SelAnalysis['Analysis'] != "Len"</filter>
             <filter>SelAnalysis['Analysis'] != "CalcAAFreq"</filter>
        </data>

  </outputs>
  
  <tests>


    <test>
      <param name="Analysis" value="CalcAAFreq" />
      <param name="input1" value="test1.fasta"/>
      <output name="output1" file="test1/out.tsv"/>
    </test>

    <test>
      <param name="Analysis" value="H" />
      <param name="input1" value="test1.fasta"/>
      <param name="scale" value="eisenberg"/>
      <output name="output1" file="test2/out2.tsv"/>
    </test>

    <test>
      <param name="Analysis" value="uH" />
      <param name="input1" value="test1.fasta"/>
      <param name="scale" value="eisenberg"/>
      <param name="Window" value="1000"/>
      <output name="output1" file="test3/out3.tsv"/>
    </test>


    <test>
      <param name="Analysis" value="Len" />
      <param name="input1" value="test1.fasta"/>
      <output name="output1" file="test5/out5.tsv"/>
    </test>


    <test>
      <param name="Analysis" value="charge" />
      <param name="input1" value="test1.fasta"/>
      <param name="ph" value="7.0" />
      <param name="amide" value="false" />
      <output name="output1" file="test6/out.tsv"/>
    </test>

    <test>
      <param name="Analysis" value="PlotSummary" />
      <param name="input1" value="non_ACPs.fasta"/>
      <param name="input2" value="ACPs.fasta"/>
      <param name="Pep1name" value="Non_ACP"/>
      <param name="Pep2name" value="ACP" />
      <output name="output2" file="test4/report_dir/report.html.re" ftype="html" compare="re_match_multiline" />
    </test>

  </tests>
    <help><![CDATA[
.. class:: infomark

**What it does**

This module can be used for the diverse analysis of given peptide libraries and equiped with 6 different options.

  * **Calculate the amino acid frequency** Method to get the frequency of every amino acid in the library. If the library consists of sub-libraries, the frequencies of these are calculated independently.
  * **Calculate the global hydrophobicity** Method for calculating global hydrophobicity (Eisenberg scale) of all sequences in the library.
  * **Calculating hydrophobic moments** Method for calculating hydrophobic moments (Eisenberg scale) for all sequences in the library.
  * **Calculate the total molecular charge** Method to calculate the total molecular charge at a given pH for all sequences in the library.
  * **Calculate the sequence length** Method to get the sequence length of all sequences in the library.
  * **Plot Summary** Method to generate a visual summary of different characteristics of the given library. The class methods are used with their standard options.


-----

**Inputs**
    **1** Calculate the amino acid frequency
       * **--InFile** Input fasta file with peptide sequences.

    **2** Calculate the global hydrophobicity    
       * **--InFile** Input fasta file with peptide sequences.
       * **--Scale** Hydrophobicity scale to use. For available scales, see modlamp.descriptors.PeptideDescriptor. 

    **3** Calculating hydrophobic moments
       * **--InFile** Input fasta file with peptide sequences. 
       * **--Scale** Hydrophobicity scale to use. For available scales, see modlamp.descriptors.PeptideDescriptor. 
       * **--Window** amino acid window in which to calculate the moment. If the sequence is shorter than the window, the length of the sequence is taken. So if the default window of 1000 is chosen, for all sequences shorter than 1000, the global hydrophobic moment will be calculated. Otherwise, the maximal hydrophiobic moment for the chosen window size found in the sequence will be returned.
       * **--Angle** angle in which to calculate the moment. 100 for alpha helices, 180 for beta sheets 
       * **--Modality** calculate respectively maximum or mean hydrophobic moment.

    **4** Calculate the total molecular charge
       * **----InFile** Input fasta file with peptide sequences. 
       * **--ph** Input fasta file with peptide sequences. 
       * **--Amide** Whether the sequences have an amidated C-terminus (-> charge += 1). 

    **5** Calculate the sequence length
       * **--Infile** Input fasta file with peptides.  

    **6** Plot Summary
       * **--InFile1** First fasta file with peptide sequences.  
       * **--InFile2** Second Fasta file with peptides sequences.

-----

**Outputs**
  * **Calculate Amino Acid Frequency** Returns tabular file with html report file. 
  * **Calculate Global Hydrophobicity** Returns tabular file.
  * **Calculating Hydrophobic Moments** Returns tabular file.
  * **Calculate Total Molecular Charge** Returns tabular file.
  * **Calculate Sequence Length** Returns tabular file.
  * **Summary Plot** Return html report file.

]]></help>
<citations>
  <citation type="bibtex">
    @misc{PDAUGGITHUB, 
      author = {Joshi, Jayadev  and Blankenberg, Daniel}, 
      year = {2020}, 
      title ={PDAUG - a Galaxy based toolset for peptide library analysis, visualization, and machine learning modeling}, 
      publisher = {GitHub}, 
      journal = {GitHub repository}, 
      url =
      {https://github.com/jaidevjoshi83/pdaug.git}, 
    }
</citation>

<citation type="bibtex">
    @article{müller_gabernet_hiss_schneider_2017, 
      title={modlAMP: Python for antimicrobial peptides}, 
      volume={33}, 
      DOI={10.1093/bioinformatics/btx285}, 
      number={17}, 
      journal={Bioinformatics}, 
      author={Müller, Alex T and Gabernet, Gisela and Hiss, Jan A and Schneider, Gisbert}, 
      year={2017}, 
      pages={2753–2755}
    }
  </citation>
</citations>
</tool>



