name        "SeqKit grep - Extract sequences from a FASTQ/FASTA"
tip    "SeqKit grep - given a list of names, extract either matching or non-matching reads"
       
var "in1"
    type        tempfile
    direction   in
    format      tsv
    save        true

var "out1"
    type        tempfile
    direction   out
    format      tsv
    save        false
    overwrite   true
    content     canvas

var "hitfile"
    type        file
    label       "file of read names to match"

var "outfile"
    type        text
    label       "name for output file"


var "matching"
    type        chooser
    label       "Send to output:"
    default     0
    choices
        "matching reads" ""
        "mismatching reads" "-v"

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

var "email"
    type        chooser
    label       "Notify of completion by email"
    default     1
    choices
        "Yes" "bl_email.py --recipient %ADDRESS% --subject 'SeqKit grep completed' --message %in1%.tsv;"
        "No" ""

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

panel
    var "Run"
        type        button
        label       "Run"
        shell       "bltsv2name.py %in1% %in1%.nam; cat %HITFILE% | grep -v '#' | cut -f1 > %in1%.hits; FILES=`cat %in1%.nam`; seqkit grep -j %THREADS% -f %in1%.hits %MATCHING% -o %OUTFILE% $FILES; rm %in1% %in1%.hits %in1%.nam; %EMAIL% bldirtab.py %out1%"
        close       true
    var "Hints"
        type        button
        label       "Hints"
        shell       "$BIRCH/script/chooseviewer.py $BIRCH/doc/bioLegato/blreads/seqkit-grep.hints.html"
        close       false
    var "Manual"
        type        button
        label       "Manual"
        shell       "chooseviewer.py $BIRCH/doc/seqkit/seqkit_grep.man"
        close       false
