#!/usr/bin/env cwl-runner
cwlVersion: v1.2
class: Workflow
requirements:
  StepInputExpressionRequirement: {}
  InlineJavascriptRequirement: {}
  MultipleInputFeatureRequirement: {}
  SubworkflowFeatureRequirement: {}
  ScatterFeatureRequirement: {}

label: Metagenomics workflow
doc: |
    Workflow for Metagenomics from bins to annotated bins.
    Steps:
      - MetaBat2 (binning) input
      - SAPP
        - Conversion to RDF
        - Prodigal gene prediction
        - InterProScan annotation


outputs:
  sapp_output:
    label: SAPP Genomes
    type: Directory
    doc: Folder containing genomes annotated by SAPP 
    outputSource: sapp_files_to_folder/results

inputs:
  fasta:
    type: File[]
    doc: List of binned fasta files
    label: bin .fa files
  threads:
    type: int?
    doc: number of threads to use for computational processes
    label: number of threads
    default: 4


steps:
  #########################################
  # bin annotation using SAPP
  workflow_sapp:
    doc: Semantic Annotation Platform with Provenance to annotate each bin obtained from metabat2
    label: Semantic Annotation Platform with Provenance
    run: workflow_sapp_microbes.cwl
    scatter: [fasta]
    in:
      fasta: fasta
      codon:
        valueFrom: ${ return 11; }
      identifier:
        valueFrom: ${ return inputs.fasta.nameroot; }
      single:
        default: true
      threads: threads
    out: [conversion, prodigal, interproscan]
  sapp_files_to_folder:
    doc: Preparation of sapp output files to a specific output folder
    label: SAPP output
    run: ../expressions/files_to_folder.cwl
    in:
      files: 
        source: [workflow_sapp/conversion, workflow_sapp/prodigal , workflow_sapp/interproscan]
        linkMerge: merge_flattened
      destination: 
        valueFrom: $("8_SAPP")
    out:
      [results]
#############################################

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
