Question: CWL: word counting
1
gravatar for gultagr
21 months ago by
gultagr10
gultagr10 wrote:

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 dictand does not have a mapPredicate" What does it mean? What am I doing wrong?

cwl common workflow language • 1.2k views
ADD COMMENTlink modified 17 months ago by Michael R. Crusoe1.2k • written 21 months ago by gultagr10
1

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 REPLYlink written 20 months ago by Michael R. Crusoe1.2k

Where is the bioinformatics part of your question?

ADD REPLYlink written 21 months ago by b.nota6.2k
2

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 REPLYlink written 20 months ago by Michael R. Crusoe1.2k

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 REPLYlink written 20 months ago by WouterDeCoster37k
2
gravatar for Michael R. Crusoe
17 months ago by
currently based out of Vilnius, Lithuania / Common Workflow Language project
Michael R. Crusoe1.2k wrote:

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 COMMENTlink modified 17 months ago • written 17 months ago by Michael R. Crusoe1.2k

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 REPLYlink written 15 months ago by karl.sebby50
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 2124 users visited in the last hour