CWL: word counting
1
1
Entering edit mode
7.4 years ago
gultagr ▴ 10

Hello there!

I am a total newbie in CWL and I'm struggling to write a simple workflow counting words in input file and writing the number (and the number only!) in output file. To remove the file name from wc output I wrote this:

file.cwl:

cwlVersion: v1.0
class: CommandLineTool
requirements:
    class: ShellCommandRequirement
inputs:
    input_file:
        type: File

outputs:
    output_file:
        type: File
        outputBinding:
            glob: output/output

stdout: output/output

baseCommand: wc
arguments:
  - valueFrom: '-w'
    shellQuote: false
    position: 1
  - valueFrom: input_file
    shellQuote: false
    position: 2
  - valueFrom: '|'
    shellQuote: false
    position: 3
  - valueFrom: 'awk'
    shellQuote: false
    position: 4
  - valueFrom: '"'
    shellQuote: false
    position: 5
  - valueFrom: '{print $1;}'
    shellQuote: false
    position: 6
  - valueFrom: '"'
    shellQuote: false
    position: 7

file.yml:
input_file:
    class: File
    path: input/input

And I got error mapSubject '%s' value '%s' is not a dict and does not have a mapPredicate

What does it mean? What am I doing wrong?

Common-Workflow-Language cwl • 3.7k views
ADD COMMENT
1
Entering edit mode

Hello gultagr,

Can you edit your question and reformat your code? There should be a button in the interface that looks like "101 010"

ADD REPLY
0
Entering edit mode

Where is the bioinformatics part of your question?

ADD REPLY
2
Entering edit mode

Hello b.nota,

BioStars is the official Q&A site for the Common Workflow Language project -- this is done with permission and approval of Istvan Albert.

http://www.commonwl.org/#Support

ADD REPLY
0
Entering edit mode

I added code markup to your post for increased readability. You can do this by selecting the text and clicking the 101010 button. When you compose or edit a post that button is in your toolbar, see image below:

101010 Button

ADD REPLY
3
Entering edit mode
7.1 years ago

Hello gultagr,

requirements:
    class: ShellCommandRequirement

should be

requirements:
    - class: ShellCommandRequirement

or

requirements:
    ShellCommandRequirement: {}

You can also write the baseCommand and arguments this way:

baseCommand: []

arguments:
  - wc
  - -w
  - $(inputs.input_file)
  - '|'
  - awk
  - '{print $1;}'

Here is a simpler version, taking advantage of how wc changes its behavior when the input is piped in via stdin

#!/usr/bin/env cwl-runner
cwlVersion: v1.0

class: CommandLineTool

inputs:
  text: File

outputs:
  number_of_words: stdout

stdin: $(inputs.text.path)

stdout: words  # optional line, but gives the output a nicer file name

baseCommand: [ wc, -w ]
ADD COMMENT
0
Entering edit mode

Thanks for the example. Just what I needed right now. Was trying to use stdin: $(inputs.text) instead of $(inputs.text.path). Also, interesting way to do a pipe using the arguments field instead of connecting wc and awk with a workflow.

ADD REPLY

Login before adding your answer.

Traffic: 1703 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6