How to stop removing last slash of directory parameter in cwl?
1
0
Entering edit mode
4.9 years ago
sshinya ▴ 10

Does anyone know how to stop deleting a backslash at the end of the Directory parameter by a cwl engine?


I'm now trying to make cwl script, which merge the contents of multiple directories. This can be done in Linux system:

rsync -a a/ b/ c/ d

, but please notice here that this has different results than the following script:

rsync -a a b c d

If we have files such like

.
├── a
│   └── a.csv
├── b
│   └── b.csv
└── c
    └── c.csv

The script with last slash gives

d
├── a.csv
├── b.csv
└── c.csv

, but without lash slash it gives

d
├── a
│   └── a.csv
├── b
│   └── b.csv
└── c
    └── c.csv

As I want to include this merging procedure into workflow, I wrote the following cwl CLI script.

#!/usr/bin/env cwl-runner

cwlVersion: v1.0
class: CommandLineTool
baseCommand: ["-a"]
hints:
    DockerRequirement:
        dockerImageId: ajhjhaf/rsync
        dockerFile:
            $include: Dockerfile
inputs:
    "dirs":
        type: Directory[]
        inputBinding:
            position: 1
    "outdir":
        type: string
        inputBinding:
            position: 2
outputs:
    "output_dir":
        type: Directory
        outputBinding:
            glob: $(inputs.outdir)

The docker file is simple one.

FROM ubuntu:18.04

RUN apt-get update && \
    apt-get install -y --no-install-recommends rsync && \
    rm -rf /var/lib/apt/lists/*

ENTRYPOINT ["rsync"]
CMD ["--help"]

However, this cwl script automatically delete the last slash when I run.

$cwl-runner merge_dir.cwl --dirs a/ --dirs b/ --dirs c/ --outdir d
/Users/suzukishinya/.pyenv/versions/3.6.2_general/bin/cwl-runner 1.0.20170828135420
Resolved 'merge_dir.cwl' to 'file:///Users/suzukishinya/Desktop/test/merge_dir.cwl'
[job merge_dir.cwl] /var/folders/c4/zjz37f4x75l00wrft57xj2400000gn/T/tmpd1_gf4xq$ docker \
    run \
    -i \
    --volume=/private/var/folders/c4/zjz37f4x75l00wrft57xj2400000gn/T/tmpd1_gf4xq:/private/var/spool/cwl:rw \
    --volume=/private/var/folders/c4/zjz37f4x75l00wrft57xj2400000gn/T/tmpdqb5efvd:/tmp:rw \
    --volume=/Users/suzukishinya/Desktop/test/a:/private/var/lib/cwl/stg12f613c3-13ea-408d-8c1a-7c5c5ff25e01/a:ro \
    --volume=/Users/suzukishinya/Desktop/test/b:/private/var/lib/cwl/stg2098fb65-ea5d-4809-9d71-1c9c9cc60cea/b:ro \
    --volume=/Users/suzukishinya/Desktop/test/c:/private/var/lib/cwl/stgbc375ae9-e371-42ae-a816-edceacd9ec05/c:ro \
    --workdir=/private/var/spool/cwl \
    --read-only=true \
    --user=501:20 \
    --rm \
    --env=TMPDIR=/tmp \
    --env=HOME=/private/var/spool/cwl \
    ajhjhaf/rsync \
    -a \
    /private/var/lib/cwl/stg12f613c3-13ea-408d-8c1a-7c5c5ff25e01/a \
    /private/var/lib/cwl/stg2098fb65-ea5d-4809-9d71-1c9c9cc60cea/b \
    /private/var/lib/cwl/stgbc375ae9-e371-42ae-a816-edceacd9ec05/c \
    d

This doesn't give me the desired result. Does anyone know the solution? It is also helpful if you provide solution without rsync, but to work with cwl, it must be single command and output dir must be placed automatically.

cwl cwltool • 1.0k views
ADD COMMENT
1
Entering edit mode
4.9 years ago
sshinya ▴ 10

Self-solving. Using InlineJavascript solve this problem. Here is cwl script example for someone who faces with same problem.

#!/usr/bin/env cwl-runner

cwlVersion: v1.0
class: CommandLineTool
baseCommand: ["-a"]
requirements:
    InlineJavascriptRequirement: {}
hints:
    DockerRequirement:
        dockerImageId: ajhjhaf/rsync
        dockerFile:
            $include: Dockerfile
inputs:
    "dirs":
        type: Directory[]
    "outdir":
        type: string
        inputBinding:
            position: 2

arguments:
    - position: 1
      valueFrom: |
        ${
            return inputs.dirs.map(x => x["path"] + "/") ;
        }
outputs:
    "output_dir":
        type: Directory
        outputBinding:
            glob: $(inputs.outdir)
ADD COMMENT

Login before adding your answer.

Traffic: 1942 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