Skip to content

Commit

Permalink
update cwl/updateCaseList.cwl to fix issues with empty string sample …
Browse files Browse the repository at this point in the history
…ids when no extra ids are passed in
  • Loading branch information
stevekm committed Apr 18, 2022
1 parent b397b7e commit d66a777
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 8 deletions.
4 changes: 2 additions & 2 deletions cwl/updateCaseList.cwl
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ baseCommand: ['bash', 'run.sh']
requirements:
InlineJavascriptRequirement: {}
DockerRequirement:
dockerPull: mskcc/helix:21.5.0
dockerPull: mskcc/helix:21.5.1
InitialWorkDirRequirement:
listing:
- entryname: run.sh
entry: |-
set -eu
# get a comma-delim string of the sample names
# get a comma-delim string of the sample names ; returns an empty string if there are no sample id's ; updateCaseList ignores empty strings
samples_arg="${ return inputs.sample_ids.join(',') ; }"
input_file="${ return inputs.case_list.path ; }"
output_file="${ return inputs.output_filename }"
Expand Down
47 changes: 41 additions & 6 deletions tests/test_updateCaseList_cwl.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,24 @@
class TestUpdateCaseList(PlutoTestCase):
cwl_file = 'updateCaseList.cwl'

def test_update_caselist_1(self):
"""
"""
def setUp(self):
super().setUp()
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:
self.input_file = os.path.join(self.tmpdir, "cases.txt")
with open(self.input_file, "w") as fout:
fout.write(case_list_str)

def test_update_caselist_1(self):
"""
Test simple case list update
"""
self.input = {
"case_list": {"class": "File", "path": input_file},
"case_list": {"class": "File", "path": self.input_file},
"sample_ids": ["Sample3", "Sample4"],
"output_filename": "cases_all.txt"
}
Expand All @@ -58,6 +61,38 @@ def test_update_caselist_1(self):
self.assertEqual(text, expected_text)


def test_update_caselist_2(self):
"""
Test update with no files passed
"""
self.input = {
"case_list": {"class": "File", "path": self.input_file},
"sample_ids": [],
"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 = 192, hash = 'f1ad64f51beac01759ae690b2f787fe3978e8882', 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
"""
self.assertEqual(text, expected_text)




if __name__ == "__main__":
Expand Down

0 comments on commit d66a777

Please sign in to comment.