Skip to content

Commit

Permalink
fix empty file name updating (#2017)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikkonie committed Sep 27, 2024
1 parent 29a8904 commit 0a73fa9
Show file tree
Hide file tree
Showing 9 changed files with 59 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ Fixed

- **Samplesheets**
- Timeline event status not updated in ``SheetDeleteVieW`` with iRODS collections enabled (#1798)
- Assay plugin ``update_row()`` updating links for empty material names (#2017)

Removed
-------
Expand Down
2 changes: 2 additions & 0 deletions samplesheets/assayapps/cytof/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ def update_row(self, row, table, assay, index):
and header['value'].lower() == 'name'
and top_header['value'].lower()
in ['raw data file', 'derived data file']
and row[i]['value']
and isinstance(row[i]['value'], str)
):
row[i]['link'] = (
base_url + '/' + mc_assay_name + '/' + row[i]['value']
Expand Down
20 changes: 19 additions & 1 deletion samplesheets/assayapps/cytof/tests/test_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,25 @@ def test_update_row_barcode(self):
)
self.assertEqual(row, row_ex)

# TODO: Test with empty file names after fixing #2017
def test_update_row_barcode_empty_file_names(self):
"""Test update_row() with filled barcode key and empty file names"""
# Rename header
self.assay_table['field_header'][15]['value'] = 'Barcode Key'
self.assay_table['table_data'][0][15]['value'] = PANEL_NAME
self.assay_table['table_data'][0][20]['value'] = ASSAY_NAME
self.assertEqual(self.assay_table['table_data'][0][26]['value'], '')
self.assertEqual(self.assay_table['table_data'][0][31]['value'], '')
self.assertEqual(self.assay_table['table_data'][0][36]['value'], '')
row_ex = deepcopy(self.assay_table['table_data'][0])
row_ex[15]['value'] = SIMPLE_LINK_TEMPLATE.format(
label=PANEL_NAME,
url=os.path.join(self.base_url, MISC_FILES_COLL, PANEL_NAME),
)
# File names should not be updated
row = self.plugin.update_row(
self.assay_table['table_data'][0], self.assay_table, self.assay, 0
)
self.assertEqual(row, row_ex)

def test_update_row_default(self):
"""Test update_row() with default template values"""
Expand Down
2 changes: 2 additions & 0 deletions samplesheets/assayapps/generic_raw/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ def update_row(self, row, table, assay, index):
and header['item_type'] == 'DATA'
and header['value'].lower() == 'name'
and top_header['value'].lower() == 'raw data file'
and row[i]['value']
and isinstance(row[i]['value'], str)
):
row[i]['link'] = (
base_url + '/' + RAW_DATA_COLL + '/' + row[i]['value']
Expand Down
12 changes: 10 additions & 2 deletions samplesheets/assayapps/generic_raw/tests/test_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,16 @@ def test_update_row(self):
)
self.assertEqual(row, row_ex)

def test_update_row_empty_file_name(self):
"""Test update_row() with empty file name"""
self.assay_table['top_header'][7]['value'] = 'Raw Data File'
self.assertEqual(self.assay_table['table_data'][0][44]['value'], '')
row_ex = deepcopy(self.assay_table['table_data'][0])
row = self.plugin.update_row(
self.assay_table['table_data'][0], self.assay_table, self.assay, 0
)
self.assertEqual(row, row_ex)

def test_update_row_default(self):
"""Test update_row()"""
row_ex = deepcopy(self.assay_table['table_data'][0])
Expand All @@ -61,8 +71,6 @@ def test_update_row_default(self):
)
self.assertEqual(row, row_ex)

# TODO: Test with empty file name for renamed field after fixing #2017

def test_get_shortcuts(self):
"""Test get_shortcuts()"""
expected = {
Expand Down
2 changes: 2 additions & 0 deletions samplesheets/assayapps/meta_ms/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ def update_row(self, row, table, assay, index):
and header['value'].lower() == 'name'
and top_header['value'].lower()
in ['metabolite assignment file', 'raw spectral data file']
and row[i]['value']
and isinstance(row[i]['value'], str)
):
if top_header['value'].lower() == 'metabolite assignment file':
coll_name = MISC_FILES_COLL
Expand Down
15 changes: 14 additions & 1 deletion samplesheets/assayapps/meta_ms/tests/test_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,20 @@ def test_update_row(self):
)
self.assertEqual(row, row_ex)

# TODO: Test with empty file names after fixing #2017
def test_update_row_empty_file_names(self):
"""Test update_row() with empty file names"""
self.assertEqual(self.assay_table['table_data'][0][44]['value'], '')
self.assertEqual(self.assay_table['table_data'][0][51]['value'], '')
self.assay_table['table_data'][0][55]['value'] = REPORT_NAME
row_ex = deepcopy(self.assay_table['table_data'][0])
row_ex[55]['value'] = SIMPLE_LINK_TEMPLATE.format(
label=REPORT_NAME,
url=os.path.join(self.base_url, RESULTS_COLL, REPORT_NAME),
)
row = self.plugin.update_row(
self.assay_table['table_data'][0], self.assay_table, self.assay, 0
)
self.assertEqual(row, row_ex)

def test_get_shortcuts(self):
"""Test get_shortcuts()"""
Expand Down
2 changes: 2 additions & 0 deletions samplesheets/assayapps/pep_ms/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ def update_row(self, row, table, assay, index):
header['obj_cls'] == 'GenericMaterial'
and header['item_type'] == 'DATA'
and header['value'].lower() == 'name'
and row[i]['value']
and isinstance(row[i]['value'], str)
):
# We assume all files to be in RawData
row[i]['link'] = (
Expand Down
8 changes: 7 additions & 1 deletion samplesheets/assayapps/pep_ms/tests/test_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,13 @@ def test_update_row(self):
)
self.assertEqual(row, row_ex)

# TODO: Test with empty file names after fixing #2017
def test_update_row_empty_file_names(self):
"""Test update_row() with empty file names"""
row_ex = deepcopy(self.assay_table['table_data'][0])
row = self.plugin.update_row(
self.assay_table['table_data'][0], self.assay_table, self.assay, 0
)
self.assertEqual(row, row_ex)

def test_get_shortcuts(self):
"""Test get_shortcuts()"""
Expand Down

0 comments on commit 0a73fa9

Please sign in to comment.