#!/usr/bin/env cwl-runner

cwlVersion: v1.2
class: Workflow
requirements:
   - class: StepInputExpressionRequirement
   - class: InlineJavascriptRequirement
   - class: MultipleInputFeatureRequirement

label: Genome conversion and annotation
doc: Workflow for genome annotation from EMBL format

inputs:
  embl:
    type: File?
    doc: Genome sequence in EMBL format
    label: EMBL input file
  fasta:
    type: File?
    doc: Genome sequence in FASTA format
    label: EMBL input file
  identifier:
    type: string
    doc: Identifier of the sample being converted
    label: Sample name
  codon:
    type: int
    doc: Codon table used for gene prediction
    label: Codon table
    # default: 11
  single:
    type: boolean?
    doc: Input is a single genome
    label: single genome
  meta:
    type: boolean?
    doc: Input is a meta-genome
    label: meta-genome
  genome:
    type: boolean?
    doc: FASTA to RDF conversion with genome data
    # default: true
  threads:
    type: int?
    doc: number of threads to use for computational processes
    label: number of threads
    default: 2

steps:
  conversion:
    run: ../sapp/conversion.cwl
    in:
      identifier: identifier
      embl: embl
      fasta: fasta
      codon: codon
      genome: genome
    out: [output]
############################
  prodigal:
    run: ../sapp/prodigal.cwl
    in:
      identifier: identifier
      input: conversion/output
      codon: codon
      single: single
      meta: meta
    out: [output]
############################
  interproscan:
    run: ../sapp/interproscan.cwl
    in:
      identifier: identifier
      input: prodigal/output
      cpu: threads
    out: [output]
############################
  tohdt:
    run: ../sapp/toHDT.cwl
    in:
      identifier: identifier
      output: 
        valueFrom: $(inputs.identifier).hdt
      input: interproscan/output
    out: [output]
  #########################################
  #
  compress:
    run: ../bash/compress.cwl
    in:
      infile: tohdt/output
    out: [output]

outputs:
  output:
    type: File
    outputSource: compress/output
  
s:author:
  - class: s:Person
    s:identifier: https://orcid.org/0000-0001-8172-8981
    s:email: mailto:jasper.koehorst@wur.nl
    s:name: Jasper Koehorst
  - class: s:Person
    s:identifier: https://orcid.org/0000-0001-9524-5964
    s:email: mailto:bart.nijsse@wur.nl
    s:name: Bart Nijsse

s:citation: https://m-unlock.nl
s:codeRepository: https://gitlab.com/m-unlock/cwl
s:dateCreated: "2020-00-00"
s:license: https://spdx.org/licenses/Apache-2.0 
s:copyrightHolder: "UNLOCK - Unlocking Microbial Potential"


$namespaces:
  s: https://schema.org/
  edam: http://edamontology.org/

$schemas:
 - http://edamontology.org/EDAM_1.18.owl