Question: CWL: word counting
1
gravatar for gultagr
2.2 years 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.4k views
ADD COMMENTlink modified 23 months ago by Michael R. Crusoe1.7k • written 2.2 years 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 2.2 years ago by Michael R. Crusoe1.7k

Where is the bioinformatics part of your question?

ADD REPLYlink written 2.2 years ago by Benn7.7k
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 2.2 years ago by Michael R. Crusoe1.7k

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 2.2 years ago by WouterDeCoster40k
3
gravatar for Michael R. Crusoe
23 months ago by
Common Workflow Language project
Michael R. Crusoe1.7k 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 23 months ago • written 23 months ago by Michael R. Crusoe1.7k

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 21 months ago by karl.sebby70
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: 961 users visited in the last hour