nextflow-io / nextflow

A DSL for data-driven computational pipelines
http://nextflow.io
Apache License 2.0
2.76k stars 629 forks source link

Experimental CWL task support #545

Closed pditommaso closed 4 years ago

pditommaso commented 6 years ago

The goal of this enhancement is to add to Nextflow the ability to execute CWL CommandLineTool definitions in a native manner ie. the CWL descriptor is mapped to NF internal data structure and execute as NF process.

This idea was envisioned by @skptic and @viklund during the September NF hackathon.

A first prototypal implementation is available in the cwl-task branch.

It allows to import a basic CWL CommonLineTool YAML definition file and to execute it a a NF process. For example, given the following CWL definition named samtools.cwl as shown below:

cwlVersion: v1.0
class: CommandLineTool
baseCommand: samtools
arguments: [index]

requirements:
  - class: InitialWorkDirRequirement
    listing:
      - $(inputs.bamfile)

hints:
  - class: ResourceRequirement
    coresMin: 2
    outdirMin: 2048
    ramMin: 4096

inputs:
  bamfile:
    type: File
    inputBinding:
      position: 1
  outbam:
    type: string
    default: test.bai
    inputBinding:
      position: 2

outputs:
  indexout:
    type: File[]
    outputBinding:
      glob: "*.bam"

In the NF script it's possible to import it and execute as shown below:

samtools = cwlTask('samtools.cwl')
out = samtools(bamfile: bamfile_ch, outbam: baifile_ch) 
out.indexout.println()
KevinSayers commented 6 years ago

The baseCommand should also be able to take a list

cwlVersion: v1.0
class: CommandLineTool
baseCommand: [tar, xf]
inputs:
  tarfile:
    type: File
    inputBinding:
      position: 1
  extractfile:
    type: string
    inputBinding:
      position: 2
outputs:
  example_out:
    type: File
    outputBinding:
      glob: $(inputs.extractfile)

Results in

Command executed:

  [tar, xf] hello.tar Hello.java

I'll try to take a look at this too.

KevinSayers commented 6 years ago

Modifying the previous code. The prefix tag should also be supported.

cwlVersion: v1.0
class: CommandLineTool
baseCommand: tar
inputs:
  tarfile:
    type: File
    inputBinding:
      prefix: xf
      position: 1
  extractfile:
    type: string
    inputBinding:
      position: 2
outputs:
  example_out:
    type: File
    outputBinding:
      glob: $(inputs.extractfile)
pditommaso commented 6 years ago

well, it's veeeery experimental :)

KevinSayers commented 6 years ago
stevekm commented 6 years ago

Is this feature still being developed?

pditommaso commented 6 years ago

In the hands of contributors.

KevinSayers commented 6 years ago

I personally plan on continuing to work on it once I have more time.

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

pditommaso commented 2 years ago

In the case this may resurrect, now there's Java "client" for CWL https://github.com/common-workflow-language/cwljava