view insect_phenology_model.xml @ 49:1b6864c5b50a draft

Uploaded
author greg
date Tue, 05 Jun 2018 07:52:59 -0400
parents 99e1c1300fcd
children 927321ed0322
line wrap: on
line source

<tool id="insect_phenology_model" name="Insect phenology model" version="1.1.0">
    <description>expressing stage-specific phenology and population dynamics</description>
    <requirements>
        <requirement type="package" version="1.4.4">r-optparse</requirement>
    </requirements>
    <command detect_errors="exit_code"><![CDATA[
#import os
#set output_data_dir = "output_data_dir"
#set output_plots_dir = "output_plots_dir"
#set error_file = $os.path.join($output_data_dir, "04_combined_generations.csv")
#set custom_date_interval = $custom_date_interval_cond.custom_date_interval
#set life_stages = list()
#set plot_adult_life_stage = $plot_adult_life_stage_cond.plot_adult_life_stage
#set plot_nymph_life_stage = $plot_nymph_life_stage_cond.plot_nymph_life_stage
#if str($plot_egg_life_stage) == "yes":
    $life_stages.append("Egg")
#end if
#if str($plot_nymph_life_stage) == "yes":
    $life_stages.append("Nymph")
#end if
#if str($plot_adult_life_stage) == "yes":
    $life_stages.append("Adult")
#end if
#if str($plot_egg_life_stage) == "yes" and str($plot_nymph_life_stage) == "yes" and str($plot_adult_life_stage) == "yes":
    $life_stages.append("Total")
#end if
#set life_stages = ",".join($life_stages)
mkdir output_data_dir &&
mkdir output_plots_dir &&
Rscript '$__tool_directory__/insect_phenology_model.R'
--adult_mortality $adult_mortality
--adult_accumulation $adult_accumulation
--egg_mortality $egg_mortality
#if str($merge_ytd_temperature_data_cond.merge_ytd_temperature_data) == "yes":
    --input_ytd '$merge_ytd_temperature_data_cond.input_ytd'
    --location '$merge_ytd_temperature_data_cond.location'
    --num_days_ytd $merge_ytd_temperature_data_cond.input_ytd.metadata.data_lines
#end if
--input_norm '$input_norm'
--insect '$insect'
--insects_per_replication $insects_per_replication
--life_stages '$life_stages'
#if str($plot_adult_life_stage) == "yes":
    --life_stages_adult '$plot_adult_life_stage_cond.life_stages_adult'
#end if
#if str($plot_nymph_life_stage) == "yes":
    --life_stages_nymph '$plot_nymph_life_stage_cond.life_stages_nymph'
#end if
--max_clutch_size $max_clutch_size
--min_clutch_size $min_clutch_size
--nymph_mortality $nymph_mortality
--old_nymph_accumulation $old_nymph_accumulation
--oviposition $oviposition
--photoperiod $photoperiod
--plot_generations_separately $plot_generations_separately
--plot_std_error $plot_std_error
--replications $replications
#if str($custom_date_interval) == "yes":
    --start_date '$custom_date_interval_cond.start_date'
    --end_date '$custom_date_interval_cond.end_date'
#end if
--young_nymph_accumulation $young_nymph_accumulation
&>ipm_log.txt;
if [[ $? -ne 0 ]]; then
    cp ipm_log.txt '$error_file';
    exit 1;
fi]]></command>
    <inputs>
        <param name="input_norm" type="data" format="csv" label="30 year normals temperature data">
            <validator type="expression" message="30 year normals temperature data must have 10 columns and 366 rows">value is not None and value.metadata.columns==10 and value.metadata.data_lines==366</validator>
        </param>
        <conditional name="merge_ytd_temperature_data_cond">
            <param name="merge_ytd_temperature_data" type="select" label="Merge year-to-date temperature data with 30 year normals temperature data?">
                <option value="yes" selected="true">Yes</option>
                <option value="no">No</option>
            </param>
            <when value="yes">
                <param name="input_ytd" type="data" format="csv" label="Year-to-date temperature data">
                    <validator type="expression" message="Year-to-date temperature data must have 6 columns">value is not None and value.metadata.columns==6</validator>
                </param>
                <param name="location" type="text" value="" optional="true" label="Location" help="Enter the location or leave blank to use the station name from 30 year normals data."/>
            </when>
            <when value="no"/>
        </conditional>
        <param name="insect" type="select" label="Select insect">
            <option value="BMSB" selected="True">Brown Marmorated Stink Bug</option>
        </param>
        <param name="replications" type="integer" value="10" min="2" label="Number of replications"/>
        <param name="insects_per_replication" type="integer" value="1000" min="1" label="Number of insects with which to start each replication"/>
        <param name="photoperiod" type="float" value="13.5" min="0" label="Critical photoperiod for diapause induction/termination"/>
        <param name="egg_mortality" type="integer" value="1" min="0" label="Adjustment rate for egg mortality"/>
        <param name="nymph_mortality" type="integer" value="1" min="0" label="Adjustment rate for nymph mortality"/>
        <param name="adult_mortality" type="integer" value="1" min="0" label="Adjustment rate for adult mortality"/>
        <param name="oviposition" type="integer" value="1" min="0" label="Adjustment oviposition rate"/>
        <param name="min_clutch_size" type="integer" value="0" min="0" label="Adjustment of minimum clutch size"/>
        <param name="max_clutch_size" type="integer" value="0" min="0" label="Adjustment of maximum clutch size"/>
        <param name="young_nymph_accumulation" type="integer" value="0" min="0" label="Adjustment of degree-days accumulation (egg->young nymph)"/>
        <param name="old_nymph_accumulation" type="integer" value="0" min="0" label="Adjustment of degree-days accumulation (young nymph->old nymph)"/>
        <param name="adult_accumulation" type="integer" value="0" min="0" label="Adjustment of degree-days accumulation (old nymph->adult)"/>
        <conditional name="custom_date_interval_cond">
            <param name="custom_date_interval" type="select" label="Set date interval for plots?" help="Scales the x axis in plots from weeks to days">
                <option value="no" selected="true">No</option>
                <option value="yes">Yes</option>
            </param>
            <when value="no"/>
            <when value="yes">
                <param name="start_date" type="text" value="" label="Start date" help="Format must be yyyy-mm-dd">
                    <validator type="expression" message="Date must have the format yyyy-mm-dd">len(value.split('-')[0])==4 and int(value.split('-')[0]) and len(value.split('-')[1])==2 and int(value.split('-')[1]) and len(value.split('-')[2])==2 and int(value.split('-')[2])</validator>
                </param>
                <param name="end_date" type="text" value="" label="End date" help="Format must be yyyy-mm-dd">
                    <validator type="expression" message="Date must have the format yyyy-mm-dd">len(value.split('-')[0])==4 and int(value.split('-')[0]) and len(value.split('-')[1])==2 and int(value.split('-')[1]) and len(value.split('-')[2])==2 and int(value.split('-')[2])</validator>
                </param>
            </when>
        </conditional>
        <param name="plot_generations_separately" type="select" label="Plot generations separately?">
            <option value="yes" selected="True">Yes</option>
            <option value="no">No</option>
        </param>
        <param name="plot_egg_life_stage" type="select" label="Plot egg life stage?">
            <option value="yes" selected="true">Yes</option>
            <option value="no">No</option>
        </param>
        <conditional name="plot_nymph_life_stage_cond">
            <param name="plot_nymph_life_stage" type="select" label="Plot nymph life stage?">
                <option value="yes" selected="true">Yes</option>
                <option value="no">No</option>
            </param>
            <when value="yes">
                <param name="life_stages_nymph" type="select" multiple="true" label="Select nymph life stage">
                    <option value="Total" selected="true">All</option>
                    <option value="Young">Young</option>
                    <option value="Old">Old</option>
                </param>
            </when>
            <when value="no"/>
        </conditional>
        <conditional name="plot_adult_life_stage_cond">
            <param name="plot_adult_life_stage" type="select" label="Plot adult life stage?">
                <option value="yes" selected="true">Yes</option>
                <option value="no">No</option>
            </param>
            <when value="yes">
                <param name="life_stages_adult" type="select" multiple="true" label="Select adult life stage">
                    <option value="Total" selected="true">All</option>
                    <option value="Pre-vittelogenic">Pre-vittelogenic</option>
                    <option value="Vittelogenic">Vittelogenic</option>
                    <option value="Diapausing">Diapausing</option>
                </param>
            </when>
            <when value="no"/>
        </conditional>
        <param name="plot_std_error" type="select" label="Plot standard error?">
            <option value="yes" selected="True">Yes</option>
            <option value="no">No</option>
        </param>
    </inputs>
    <outputs>
        <collection name="output_data_collection" type="list" label="${tool.name} (data), on ${on_string}">
            <discover_datasets pattern="__name__" directory="output_data_dir" format="csv"/>
        </collection>
        <collection name="output_plots_collection" type="list" label="${tool.name} (plots), on ${on_string}">
            <discover_datasets pattern="__name__" directory="output_plots_dir" format="pdf"/>
        </collection>
    </outputs>
    <tests>
        <test>
            <param name="input_norm" value="30_year_normals.csv" ftype="csv"/>
            <param name="merge_ytd_temperature_data" value="no"/>
            <param name="replications" value="2"/>
            <param name="plot_generations_separately" value="no"/>
            <param name="plot_egg_life_stage" value="no"/>
            <param name="life_stages_nymph" value="Young"/>
            <param name="life_stages_adult" value="Pre-vittelogenic"/>
            <output_collection name="output_data_collection" type="list">
                <element name="04_combined_generations.csv" file="output_combined1.csv" ftype="csv" compare="contains"/>
            </output_collection>
            <output_collection name="output_plots_collection" type="list">
                <element name="02_young_nymph_pop.pdf" file="plot.pdf" ftype="pdf" compare="contains"/>
                <element name="05_pre-vittelogenic_adult_pop.pdf" file="plot.pdf" ftype="pdf" compare="contains"/>
            </output_collection>
        </test>
        <test>
            <param name="input_norm" value="30_year_normals.csv" ftype="csv"/>
            <param name="input_ytd" value="state_college_partial.csv" ftype="csv"/>
            <param name="location" value="State College PA"/>
            <param name="replications" value="2"/>
            <param name="plot_generations_separately" value="no"/>
            <param name="plot_egg_life_stage" value="no"/>
            <param name="life_stages_nymph" value="Young"/>
            <param name="life_stages_adult" value="Pre-vittelogenic"/>
            <output_collection name="output_data_collection" type="list">
                <element name="04_combined_generations.csv" file="output_combined1.csv" ftype="csv" compare="contains"/>
            </output_collection>
            <output_collection name="output_plots_collection" type="list">
                <element name="02_young_nymph_pop.pdf" file="plot.pdf" ftype="pdf" compare="contains"/>
                <element name="05_pre-vittelogenic_adult_pop.pdf" file="plot.pdf" ftype="pdf" compare="contains"/>
            </output_collection>
        </test>
        <test>
            <param name="input_norm" value="30_year_normals.csv" ftype="csv"/>
            <param name="input_ytd" value="state_college_ytd.csv" ftype="csv"/>
            <param name="location" value="State College PA"/>
            <param name="replications" value="2"/>
            <param name="plot_generations_separately" value="no"/>
            <output_collection name="output_data_collection" type="list">
                <element name="04_combined_generations.csv" file="output_combined2.csv" ftype="csv" compare="contains"/>
            </output_collection>
            <output_collection name="output_plots_collection" type="list">
                <element name="01_egg_pop.pdf" file="plot.pdf" ftype="pdf" compare="contains"/>
                <element name="04_total_nymph_pop.pdf" file="plot.pdf" ftype="pdf" compare="contains"/>
                <element name="08_total_adult_pop.pdf" file="plot.pdf" ftype="pdf" compare="contains"/>
                <element name="09_total_pop.pdf" file="plot.pdf" ftype="pdf" compare="contains"/>
            </output_collection>
        </test>
        <test>
            <param name="input_norm" value="30_year_normals.csv" ftype="csv"/>
            <param name="input_ytd" value="state_college_partial.csv" ftype="csv"/>
            <param name="location" value="State College PA"/>
            <param name="replications" value="2"/>
            <param name="plot_egg_life_stage" value="no"/>
            <param name="life_stages_nymph" value="Old"/>
            <param name="plot_adult_life_stage" value="no"/>
            <output_collection name="output_data_collection" type="list">
                <element name="01_generation_P.csv" file="output_p_3.csv" ftype="csv" compare="contains"/>
                <element name="02_generation_F1.csv" file="output_f1_3.csv" ftype="csv" compare="contains"/>
                <element name="03_generation_F2.csv" file="output_f2_3.csv" ftype="csv" compare="contains"/>
                <element name="04_combined_generations.csv" file="output_combined3.csv" ftype="csv" compare="contains"/>
            </output_collection>
            <output_collection name="output_plots_collection" type="list">
                <element name="03_old_nymph_pop_by_generation.pdf" file="plot.pdf" ftype="pdf" compare="contains"/>
            </output_collection>
        </test>
        <test>
            <param name="input_norm" value="30_year_normals.csv" ftype="csv"/>
            <param name="input_ytd" value="state_college_ytd.csv" ftype="csv"/>
            <param name="location" value="State College PA"/>
            <param name="replications" value="2"/>
            <output_collection name="output_data_collection" type="list">
                <element name="01_generation_P.csv" file="output_p_4.csv" ftype="csv" compare="contains"/>
                <element name="02_generation_F1.csv" file="output_f1_4.csv" ftype="csv" compare="contains"/>
                <element name="03_generation_F2.csv" file="output_f2_4.csv" ftype="csv" compare="contains"/>
                <element name="04_combined_generations.csv" file="output_combined4.csv" ftype="csv" compare="contains"/>
            </output_collection>
            <output_collection name="output_plots_collection" type="list">
                <element name="01_egg_pop_by_generation.pdf" file="plot.pdf" ftype="pdf" compare="contains"/>
                <element name="04_total_nymph_pop_by_generation.pdf" file="plot.pdf" ftype="pdf" compare="contains"/>
                <element name="08_total_adult_pop_by_generation.pdf" file="plot.pdf" ftype="pdf" compare="contains"/>
                <element name="09_total_pop_by_generation.pdf" file="plot.pdf" ftype="pdf" compare="contains"/>
            </output_collection>
        </test>
    </tests>
    <help>
**What it does**

Provides an agent-based stochastic model expressing stage-specific phenology and population dynamics for an insect species across geographic regions.

-----

**Required options**

 * **30 year normals temperature data** - the dataset from your history containing the 30-year normals temperature data (available at http://pestwatch.psu.edu/ghcn).
 * **Merge year-to-date temperature data with 30 year normals temperature data** - select Yes to merge a year-to-date temperature dataset from your history into the selected 30 year normals temperature data.

  * **Year-to-date temperature data** - the dataset from your history containing the year-to-date temperature data (available at http://pestwatch.psu.edu/minmax).

 * **Location** - the location associated with the selected temperature data.
 * **Select insect** - currently only the Brown Marmorated Stink Bug can be analyzed.
 * **Number of replications** - number of replications.
 * **Number of insects with which to start each replication** - the analysis for each replication will start with this number of insects.
 * **Critical photoperiod for diapause induction/termination** - critical photoperiod for diapause induction/termination.
 * **Adjustment rate for egg mortality** - adjustment rate for egg mortality.
 * **Adjustment rate for nymph mortality** - adjustment rate for nymph mortality.
 * **Adjustment rate for adult mortality** - adjustment rate for adult mortality.
 * **Adjustment oviposition rate** - adjustment oviposition rate.
 * **Adjustment of minimum clutch size** - adjustment of minimum clutch size.
 * **Adjustment of maximum clutch size** - adjustment of maximum clutch size
 * **Adjustment of degree-days accumulation (egg->young nymph)** - adjustment of degree-days accumulation (egg->young nymph).
 * **Adjustment of degree-days accumulation (young nymph->old nymph)** - adjustment of degree-days accumulation (young nymph->old nymph).
 * **Adjustment of degree-days accumulation (old nymph->adult)** - adjustment of degree-days accumulation (old nymph->adult).
 * **Plot generations separately** - select "Yes" to plot P, F1 and F2 as separate lines or "no" to pool across generations, resulting in a total for the selected life states.
 * **Plot egg life stage** - select "Yes" to plot the egg life stage.  If all life stages (egg, nymph and adult) are selected for plotting, one output for the total will be produced.
 * **Plot nymph life stage** - select "Yes" to plot the nymph life stage.  If all life stages (egg, nymph and adult) are selected for plotting, one output for the total will be produced.

  * **Select nymph life stage** - select the nymph life stage for plotting.

 * **Plot adult life stage** - select "Yes" to plot the adult life stage.  If all life stages (egg, nymph and adult) are selected for plotting, one output for the total will be produced.

  * **Select adult life stage** - select the adult life stage for plotting.

 * **Plot standard error** - add standard error lines to plot.
    </help>
    <citations>
        <citation type="doi">10.3389/fphys.2016.00165</citation>
        <citation type="doi">10.1175/JTECH-D-11-00103.1</citation>
        <citation type="doi">10.7289/V5D21VHZ</citation>
    </citations>
</tool>