cwlVersion: v1.2

class: CommandLineTool

requirements:
  - class: ResourceRequirement
    coresMin: 2
    ramMin: 4000
#    tmpdirMin: 4096

label: BBMap
doc: |
  Read filtering using BBMap against a (contamination) reference genome

baseCommand: [/unlock/infrastructure/binaries/BBMap_v38.86/bbmap.sh]

arguments:
  - "-Xmx$(inputs.memory)M"
  - "threads=$(inputs.threads)"
  - "minratio=0.9"
  - "maxindel=3"
  - "bwr=0.16"
  - "bw=12"
  - "fast"
  - "minhits=2"
  - "qtrim=r"
  - "trimq=10"
  - "untrim"
  - "idtag"
  - "printunmappedcount"
  - "kfilter=25" 
  - "maxsites=1"
  - "k=14"
  - "outu1=$(inputs.identifier)_filtered_1.fq.gz"
  - "outu2=$(inputs.identifier)_filtered_2.fq.gz"
  # - "path=$(inputs.reference).index"
  - "overwrite=false"
  # - "nodisk=t"
  # - "out=$(inputs.identifier).sam"
  - "statsfile=$(inputs.identifier)_contamination-filter.stats"
  - "covstats=$(inputs.identifier)_contamination-filter.covstats"
  # - "rpkm=$(inputs.identifier).rpkm"

inputs:
  identifier:
    type: string
    doc: Identifier for this dataset used in this workflow
    label: identifier used
  forward_reads:
    type: File
    inputBinding:
      position: 1
      prefix: 'in='
      separate: false
  reverse_reads:
    type: File?
    inputBinding:
      position: 2
      prefix: 'in2='
      separate: false
  reference:
    type: string
    inputBinding:
      position: 3
      prefix: 'ref='
      separate: false
  memory:
    type: int?
    doc: maximum memory usage in megabytes
    label: memory usage (mb)
    default: 4000
  threads:
    type: int?
    doc: number of threads to use for computational processes
    label: number of threads
    default: 2

outputs:
  stats:
    type: File
    outputBinding:
      glob: "$(inputs.identifier)_contamination-filter.stats"
  covstats:
    type: File
    outputBinding:
      glob: "$(inputs.identifier)_contamination-filter.covstats"
  out_forward_reads:
    type: File
    outputBinding:
      glob: "$(inputs.identifier)_filtered_1.fq.gz"
  out_reverse_reads:
    type: File
    outputBinding:
      glob: "$(inputs.identifier)_filtered_2.fq.gz"
