Question: String editing for output file name
0
gravatar for ttom
17 months ago by
ttom210
ttom210 wrote:

This is a question related to String concatenation for output

This shell script outputs a file named R1_001_fastqc.results this is what I want to capture in the cwl. How could this be done ? The following code does not work

cat test.cwl

cwlVersion: v1.0
class: CommandLineTool
baseCommand: [sh, fastqc_check.sh]

requirements:
  - class: InlineJavascriptRequirement

inputs:
 fq1_zips:
  type: File
  inputBinding:
   position: 1

outputs:
 fastqc_check_out:
  type: File
  outputBinding:
   glob: $(inputs.fq1_zips.basename.split(".").slice(0)).results

cat test.yml

fq1_zips:
        class: File
        path: R1_001_fastqc.zip

fastqc_check_script:
 class: File
 path: fastqc_check.sh
cwl • 543 views
ADD COMMENTlink modified 17 months ago • written 17 months ago by ttom210

Does the answer I posted in the other post not do what you need? This seems like you want to do the same thing as that post, what is different about it?

ADD REPLYlink written 17 months ago by biokcb170

The user did indeed indicate that it worked: C: String concatenation for output

Can you clarify, ttom?

ADD REPLYlink written 17 months ago by Kevin Blighe51k

This time the output is R1_001_fastqc.results, I want to strip off the .zip from the output file. In the previous post the output was R1_001_fastqc.zip.results

The glob command below was tried to achieve the output filename as R1_001_fastqc.results

glob: $(inputs.fq1_zips.basename.split(".").slice(0)).results

Basically a part of the input file is used to name the outputfile name

Hope I am clear this time

ADD REPLYlink modified 17 months ago • written 17 months ago by ttom210
3
gravatar for biokcb
17 months ago by
biokcb170
biokcb170 wrote:

Oh, in that case use glob: $(inputs.fq1_zips.nameroot).results and remove the InlineJavascriptRequirement as it also isn't needed here.

edit to clarify: For future reference with File types nameroot refers to the filename without the extension and basename includes the extension.

ADD COMMENTlink modified 17 months ago • written 17 months ago by biokcb170

Yes, it worked. Thanks !!

ADD REPLYlink written 17 months ago by ttom210

You should mark it as accepted if it answered your question.

ADD REPLYlink written 17 months ago by drkennetz440
1
gravatar for ttom
17 months ago by
ttom210
ttom210 wrote:

What if the output file should be named SampleA_fastqc.summary according to the inputs/sample as shown below

cat test.cwl cwlVersion: v1.0 class: CommandLineTool baseCommand: [sh, fastqc_check.sh]

inputs:
 sample:
  type: string
  inputBinding:
   position: 1
 fq1_zips:
  type: File
  inputBinding:
   position: 2

outputs:
 fastqc_check_out:
  type: File
  outputBinding:
   glob: $(inputs.sample.basename)_fastqc.summary

cat test.yml

sample: SampleA
fq1_zips:
        class: File
        path: R1_001_fastqc.zip

fastqc_check_script:
 class: File
 path: fastqc_check.sh
ADD COMMENTlink written 17 months ago by ttom210
2

Since sample is a string type, you don't need basename, as that is a File type attribute. Just use glob: $(inputs.sample)_fastqc.summary

ADD REPLYlink written 17 months ago by biokcb170

This works...Thank you

ADD REPLYlink written 17 months ago by ttom210
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: 1318 users visited in the last hour