Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
stevekm committed Apr 15, 2022
2 parents 3bc4fab + 40bbea8 commit 2a88d5c
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 1 deletion.
32 changes: 32 additions & 0 deletions cwl/updateCaseList.cwl
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env cwl-runner

cwlVersion: v1.2
class: CommandLineTool
baseCommand: ['bash', 'run.sh']
requirements:
InlineJavascriptRequirement: {}
DockerRequirement:
dockerPull: mskcc/helix:21.4.2
InitialWorkDirRequirement:
listing:
- entryname: run.sh
entry: |-
set -eu
# get a comma-delim string of the sample names
samples_arg="${ return inputs.sample_ids.join(',') ; }"
input_file="${ return inputs.case_list.path ; }"
output_file="${ return inputs.output_filename }"

updateCaseList "\${input_file}" "\${samples_arg}" > "\${output_file}"

inputs:
sample_ids: string[]
case_list: File
output_filename:
type: string
default: "cases.txt"
outputs:
output_file:
type: File
outputBinding:
glob: $(inputs.output_filename)
2 changes: 1 addition & 1 deletion pluto
Submodule pluto updated 1 files
+19 −0 tools.py
64 changes: 64 additions & 0 deletions tests/test_updateCaseList_cwl.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
"""
import os
import sys
import unittest

THIS_DIR = os.path.dirname(os.path.realpath(__file__))
PARENT_DIR = os.path.dirname(THIS_DIR)
sys.path.insert(0, PARENT_DIR)
from pluto.tools import PlutoTestCase
from pluto.serializer import OFile
sys.path.pop(0)


class TestUpdateCaseList(PlutoTestCase):
cwl_file = 'updateCaseList.cwl'

def test_update_caselist_1(self):
"""
"""
case_list_str = """case_list_category: all_cases_in_study
stable_id: pi_123_all
case_list_name: All Tumors
case_list_description: All tumor samples
cancer_study_identifier: pi_123
case_list_ids: Sample1\tSample2"""
input_file = os.path.join(self.tmpdir, "cases.txt")
with open(input_file, "w") as fout:
fout.write(case_list_str)

self.input = {
"case_list": {"class": "File", "path": input_file},
"sample_ids": ["Sample3", "Sample4"],
"output_filename": "cases_all.txt"
}
output_json, output_dir = self.run_cwl()

output_file = os.path.join(output_dir, 'cases_all.txt')

expected_output = {
"output_file": OFile(name = 'cases_all.txt', size = 208, hash = '59aa4b6b6695b7adfd4493390edd4038808a018f', dir = output_dir)
}

self.assertCWLDictEqual(output_json, expected_output)

with open(output_file) as fin:
text = fin.read()

expected_text = """case_list_category: all_cases_in_study
stable_id: pi_123_all
case_list_name: All Tumors
case_list_description: All tumor samples
cancer_study_identifier: pi_123
case_list_ids: Sample1\tSample2\tSample3\tSample4
"""
self.assertEqual(text, expected_text)




if __name__ == "__main__":
unittest.main()

0 comments on commit 2a88d5c

Please sign in to comment.