The following cwl is valid, completed with “Final process status is success”, however the input collected_statistics_md
(underlying file) does not have the new data line concatenated as expected by the bash script (at line 35).
cwltool version 3.1.20210816212154
cwlVersion: v1.0
class: CommandLineTool
requirements:
- class: ShellCommandRequirement
- class: InlineJavascriptRequirement
- class: InitialWorkDirRequirement
listing:
- entry: $(inputs.collected_statistics_md)
writable: true
hints:
- class: DockerRequirement
dockerPull: biowardrobe2/samtools:v1.4
inputs:
script:
type: string?
default: |
#!/bin/bash
printf "$(date)\nLog file for calc_frip function in collect-statistics-frip.cwl tool:\n\n" > "calc_frip.log"
bam="$0"; bed="$1"; md="$2"; tsv="$3"; yaml="$4";
# count of total aligned reads
tar=$(samtools view -cF0x4 "$bam" 2>> "calc_frip.log")
# counts of reads in peak
rip=$(samtools view -c "$bam" -L "$bed" 2>> "calc_frip.log")
# frip=rip/tar
frip=$(printf "$tar" | awk -v rip="$rip" '{printf("%.3f",rip/$0)}' 2>> "calc_frip.log")
printf "$tar, $rip, $frip\n" >> "calc_frip.log"
# concatenate frip onto md, tsv, and yaml files
printf "fraction of (aligned) reads in peaks: $frip\n" >> $md 2>> "calc_frip.log"
# printf "fraction of (aligned) reads in peaks: $frip\n" >> "$md"
# printf "fraction of (aligned) reads in peaks: $frip\n" >> "$tsv"
# printf "fraction of (aligned) reads in peaks: $frip\n" >> "$yaml"
inputBinding:
position: 4
bam_file:
type: File
label: "Input BAM file"
inputBinding:
position: 5
doc: "Input BAM file, does not have to be coordinates sorted"
seacr_called_peaks:
type: File
inputBinding:
position: 11
collected_statistics_md:
type: File
inputBinding:
position: 20
collected_statistics_tsv:
type: File
inputBinding:
position: 21
collected_statistics_yaml:
type: File
inputBinding:
position: 22
outputs:
log_file:
type: File
outputBinding:
glob: "calc_frip.log"
baseCommand: ["bash", "-c"]