<tool id="pdaug_basic_plots" name="PDAUG Basic Plots" version="0.1.0" python_template_version="3.6">
  <description>Basic Plots</description>

  <requirements>
      <requirement type="package" version="0.25.3">pandas</requirement>
      <requirement type="package" version="4.10.0">plotly</requirement> 
      <requirement type="package" version="1.8.0">wordcloud</requirement>
      <requirement type="package" version="3.1.2">matplotlib</requirement>
  </requirements>
  <stdio>
    <exit_code range="1" level="fatal" />
  </stdio>
    <command detect_errors="exit_code"><![CDATA[


        python '$__tool_directory__/PDAUG_Basic_Plots.py'  '$SelPlotting.Plot' 

                #if $SelPlotting.Plot == 'HeatMap'
                    --InFile '$SelPlotting.InFile'
                    --IndexColumn '$SelPlotting.IndexColumn'
                    --x_label '$SelPlotting.x_label'
                    --y_label '$SelPlotting.y_label'
                #end if 

                #if $SelPlotting.Plot == 'BoxPlot'
                    --InFile '$SelPlotting.InFile'
                    --Feature '$SelPlotting.Feature'  
                    --Label '$SelPlotting.Label'           
                #end if 

                #if $SelPlotting.Plot == 'ScatterPlot'
                  --PlotType '$SelPlotting.PlotType.SelectPlot'
                    #if $SelPlotting.PlotType.SelectPlot == '2D'
                      -F1 '$SelPlotting.PlotType.Features1'
                      -F2 '$SelPlotting.PlotType.Features2'
                    #end if

                    #if $SelPlotting.PlotType.SelectPlot == '3D'
                      -F1 '$SelPlotting.PlotType.Features1'
                      -F2 '$SelPlotting.PlotType.Features2'
                      -F3 '$SelPlotting.PlotType.Features3'
                    #end if

                    -I '$SelPlotting.InFile' 
                    -L '$SelPlotting.Label'

                #end if 

                #if $SelPlotting.Plot == 'WordCloud'
                  -I '$SelPlotting.InFile'
                  -D '$SelPlotting.d'
                #end if 

                --htmlOutDir '$output.extra_files_path'
                --htmlFname '$output'
                      
    ]]></command>

  <inputs>

    <conditional name='SelPlotting' >

        <param name="Plot" type="select" label="Data plotting method" argument="" help="Data plotting method">
          <option value="HeatMap">Heat Map</option>
          <option value="BoxPlot">Box Plot</option>
          <option value="ScatterPlot">Scatter Plot</option>
          <option value="WordCloud">Word Cloud</option>
        </param>

        <when value="HeatMap">
            <param name="InFile" type="data" format="tabular" label="Input file" argument= "--InFile" help="Tabular data file"/>
            <param name="IndexColumn" type="text" value="Index"  label="Index Column" argument= "--IndexColumn" help="Column name that contains index as row/sample names "/>
            <param name="x_label" type="text" value="x-axis" label="Label for x-axis" argument= "--x_label" help="A label that describes x axis"/>
            <param name="y_label" type="text" value="y-axis" label="Label for y-axis" argument= "--y_label" help="A label that describes y axis"/>
        </when>

        <when value="BoxPlot">
            <param name="InFile" type="data" label="Input file" format="tabular" argument= "--InFile" help="Tabular data file"/>
            <param name="Feature" type="text" value="Feature" label="Feature name" argument= "--Features" help="Name of the feature (column name)"/>
            <param name="Label" type="text" value="class label" label="Class label column" argument="--Label" help="Name of the column that contains class label" />
        </when>

        <when value="ScatterPlot">

          <param name="InFile"    label="Input file" type="data" format="tabular" argument= "--InFile" help="Tabular data file"/>

          <conditional name='PlotType' >

              <param name="SelectPlot" type="select" label="Scatter Plot type" argument="" help="Scatter Plot type 2D or 3D.">
                  <option value="2D">2D</option>
                  <option value="3D">3D</option>
              </param>
              
              <when value="2D">
                <param name="Features1" type="text"   value="feature1" label="First feature" argument= "--RotationX" help="Feature column name"/>
                <param name="Features2" type="text"  value="feature2" label="Second feature"   argument= "--RotationY" help="Feature column name"/>
              </when>

              <when value="3D">
                <param name="Features1" type="text" value="feature1"  label="First feature"   argument= "--RotationX" help="Feature column name"/>
                <param name="Features2" type="text"  value="feature2" label="Second feature"   argument= "--RotationY" help="Feature column name"/>
                <param name="Features3" type="text"  value="feature3" label="Third feature"   argument= "--FigHight" help="Feature column name"/>                 
              </when>

        </conditional>
          
          <param name="Label" type="text" value="class label" label="Class label column" argument="--Label" help="Name of the column that contains class label" />

        </when>

        <when value="WordCloud" >
          <param name="InFile"  type="data" format="fasta" label="Input file" argument= "--InFile" help="Fasta file with peptides"/>
          <param name="d"  type="integer" value="4" argument= "--FragSize" label="Size of ngrams" help="Size of ngrams"/>
        </when>

    </conditional>
  </inputs>

  <outputs>
      <data name='output' format='html' label="${tool.name} on $on_string - ${SelPlotting.Plot} (webpage)" >
            <filter>SelPlotting['Plot'] != "WordCloud"</filter>
      </data>

      <data name='output1' format='png' label="${tool.name} on $on_string - ${SelPlotting.Plot} (PNG)" from_work_dir="out.png" >
          <filter>SelPlotting['Plot'] != "HeatMap"</filter>
          <filter>SelPlotting['Plot'] != "BoxPlot"</filter>
          <filter>SelPlotting['Plot'] != "ScatterPlot"</filter>
      </data>

  </outputs>
  
  <tests>

    <test>
      <param name="Plot" value="HeatMap" />
      <param name="InFile" value="test1.tsv"/>
      <param name="IndexColumn" value="Algo"/>
      <param name="x_label" value="Performance"/>
      <param name="y_label" value="Algorithms"/>
      <output name="output" file="test1/report_dir/report.html.re" ftype="html" compare="re_match_multiline"/>
    </test>

    <test>
      <param name="Plot" value="BoxPlot" />
      <param name="InFile" value="test2.tsv"/>
      <param name="Feature" value="a1"/>
      <param name="Label" value="class"/>
      <output name="output" file="test2/report_dir/report.html.re" ftype="html" compare="re_match_multiline"/>
    </test>

    <test>
      <param name="Plot" value="ScatterPlot" />
      <param name="InFile" value="test2.tsv"/>
      <param name="SelectPlot" value="2D" />
      <param name="Features1" value="a1"/>
      <param name="Features2" value="a2"/>
      <param name="Label" value="class"/>
      <output name="output" file="test3/report_dir/report.html.re" ftype="html" compare="re_match_multiline"/>
    </test>

  <test>
    <param name="Plot" value="ScatterPlot" />
    <param name="SelectPlot" value="3D" />
    <param name="InFile" value="test2.tsv"/>
    <param name="Features1" value="a1"/>
    <param name="Features2" value="a2"/>
    <param name="Features3" value="a3"/>
    <param name="Label" value="class"/>
    <output name="output" file="test4/report_dir/report.html.re" ftype="html" compare="re_match_multiline"/>

  </test>

  <test>
      <param name="Plot" value="WordCloud" />
      <param name="InFile" value="positive.fasta"/>
      <param name="d" value="4" />
      <output name="output" value="test5/out.png" ftype="png" compare="sim_size" delta="10000" />
  </test>

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

**What it does**

This tool generates four different types of plots. 

   * **HeatMap** Takes a data frame as input and returns heatmap. 
   * **BoxPlot** Takes a descriptor data frame as input and returns a box plot based on the class label. 
   * **ScatterPlot** Takes a descriptor data frame with the class label as input and compares the scatteredness based on 2D or 3D scatter plot. 
   * **WordCloud** Calculates the ngrams from the peptide data set and plot a word cloud for ngrams to assess frequency of ngrams visually. 

-----

**Inputs**
    **1**  HeatMap    
       * **--Infile** Input data frame as a tabular file.
       * **--IndexColumn**  Number of sequence to be generated.  
       * **--x_label** Peptide minimum length. 
       * **--y_label_s** Peptide maximum length. 

    **2** BoxPlot
       * **--Infile** Input data frame as a tabular file. 
       * **--Feature** Feature(column name) to be assessed. 
       * **--Label** Class label column name. 

    **3** ScatterPlot
       * **--Infile** Input data frame as a tabular file.  
       * **--PlotType** 2D or 3D scatter plot. 
       * **--Feature1** First feature column name. 
       * **--Feature2** Second feature column name.
       * **--Feature3** Third feature column name if 3D scatter plot option selected.
       * **--Label** CLass label column name.

    **4** WordCloud
       * **--Infile** Input fasta file with peptides.  
       * **--FragSize** ngram size to be calculated.

-----

**Outputs**
    * Return report html file with the respective graph]]></help>

<citations>
  <citation type="bibtex">


    @article{joshi_j_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},
        author = {Joshi J. and Blankenberg D.},
        year = {2020},
    }

  </citation>

</citations>
</tool>







