name        "trim_galore - trim sequencing reads"
icon    "$BIRCH/dat/Babraham_icon.png"
tip    "removes adapters and low quality nucleotides from sequencing reads"
       
var "in1"
    type        tempfile
    direction   in
    format      tsv
    save        false

var "quality"
    type        number
    label       "Min. Phred quality score to trim"
    min         10
    max         40
    default     20

var "fastqc"
    type        chooser
    label       "Run FASTQC on trimmed reads?"
    default     0
    choices
        "Yes" "--fastqc --fqcthreads %FQCTHREADS%"
        "No (default)" ""

var "fqcthreads"
    type        number
    label       "    Number of threads to use for fastqc"
    min         1
    max         $BL_CORES_MAX
    default     $BL_CORES_DEFAULT


var "trim1"
    type        chooser
    label       "trim 1 nt from 3' end? (for use with Bowtie)"
    default     1
    choices
        "Yes" "--trim1"
        "No (default)" ""

# Enclose %ADAPTERSEQ1% in single quotes, which prevents
# an error if no custom adaptor sequence is specified.
var "adapter"
    type        combobox
    label       "Adapter to be trimmed from 5' ends"
    default     0
    choices
        "Illumina (default)" "--adapter illumina"
        "Nextera" "--adapter nextera"
        "Small RNA" "--adapter small_rna"
        "Custom" "--adapter '%ADAPTERSEQ1%'"

var "adapterseq1"
    type        text
    label       "    custom adapter to be trimmed"
    default     ""

# Enclose %ADAPTERSEQ2% in single quotes, which prevents
# an error if no custom adaptor sequence is specified.
var "adapter2"
    type        chooser
    label       "Optional adapter to be trimmed from 3' ends"
    default     1
    choices
        "Yes" "--adapter2 '%ADAPTERSEQ2%'"
        "No" ""

var "adapterseq2"
    type        text
    label       "    2nd custom adapter to be trimmed"
    default     ""

var "stringency"
    type        number
    label       "nucleotides to trim from overlap with adapter"
    min         0
    max         40
    default     1

# The PCD parser seems to be able to handle the decimal type, but
# it fails to insert the default value into what appears to be a
# text box in the menu. We'll use a plain old text box
# until we can figure out how to get decimal to work.
# This is documented on the BIRCH Wiki.
#var "errorrate"
#    type        decimal
#    label       "Max. allowed errors"
#    min         0.0
#    max         0.5
#    default     0.1

var "errorrate"
    type        text
    label       "Max. allowed errors"
    default     "0.1"

var "gzip"
    type        chooser
    label       "compress output files using gzip?"
    default     1
    choices
        "Yes" "--gzip"
        "No (default)" "--dont_gzip"

var "length"
    type        number
    label       "discard reads shorter than"
    min         0
    max         100
    default     20

var "outdir"
    type        text
    label       "Name for output directory"
    default     "../reads.trim_galore"

# Enclose %ADDRESS% in single quotes, which prevents
# an error if no custom adaptor sequence is specified.
var "email"
    type        chooser
    label       "Notify of completion by email"
    default     1
    choices
        "Yes" "--email '%ADDRESS%'"
        "No" ""

var "address"
    type        text
    label       "    email address"
    default     "$BL_EMAIL"

panel
    var "Run"
        type        button
        label       "Run"
        shell       "nice bl_trim_galore.py --tsv %in1% --quality %QUALITY% %FASTQC% %TRIM1% %ADAPTER% %ADAPTER2% --stringency %STRINGENCY% -e %ERRORRATE% %GZIP% --length %LENGTH% --output_dir %OUTDIR% %EMAIL%; cd %OUTDIR%; blreads"
        close       true
    var "Guide"
        type        button
        label       "User's Guide"
        shell       "chooseviewer.py $BIRCH/pkg/trim_galore/Docs/Trim_Galore_User_Guide.pdf"
        close       false
    var "Manual"
        type        button
        label       "Manual"
        shell       "chooseviewer.py $BIRCH/pkg/trim_galore/Docs/trim_galore.man"
        close       false
