Skip to content

Commit

Permalink
fix generic assay plugin issues (#1982, #1984)
Browse files Browse the repository at this point in the history
  • Loading branch information
sellth authored Sep 5, 2024
1 parent da73314 commit dae87a6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
2 changes: 1 addition & 1 deletion docs_manual/source/metadata_advanced.rst
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ investigation file.
- Inline links
* Comments define semicolon-separated lists of columns to be linked to
collections.
* *SODAR Assay Link Results* |rarr| ``ResultsReports``
* *SODAR Assay Link ResultsReports* |rarr| ``ResultsReports``
* *SODAR Assay Link MiscFiles* |rarr| ``MiscFiles``
* *SODAR Assay Link Row* |rarr| ``RowPath``
* For example:
Expand Down
23 changes: 16 additions & 7 deletions samplesheets/assayapps/generic/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

# Local constants
APP_NAME = 'samplesheets.assayapps.generic'
RESULTS_COMMENT = 'SODAR Assay Link Results'
RESULTS_COMMENT = 'SODAR Assay Link ResultsReports'
MISC_FILES_COMMENT = 'SODAR Assay Link MiscFiles'
DATA_COMMENT_PREFIX = 'SODAR Assay Row Path'
DATA_LINK_COMMENT = 'SODAR Assay Link Row'
Expand Down Expand Up @@ -65,9 +65,13 @@ def _link_from_comment(cell, header, top_header, target_cols, url):
return True
# Special case for Material Names
if (
top_header['value']
in th.DATA_FILE_HEADERS + th.MATERIAL_NAME_HEADERS
) and (header['value'] == 'Name'):
(
top_header['value']
in th.DATA_FILE_HEADERS + th.MATERIAL_NAME_HEADERS
)
and top_header['value'].lower() in target_cols
and (header['value'] == 'Name')
):
cell['link'] = f"{url}/{cell['value']}"
return True
# Handle everything else
Expand All @@ -83,11 +87,11 @@ def _get_col_value(cls, target_col, row, table):
"""
Return value of last matched column.
:param target_col: Column name to look for
:param target_col: Column name string to look for.
:param row: List of dicts (a row returned by SampleSheetTableBuilder)
:param table: Full table with headers (dict returned by
SampleSheetTableBuilder)
:return: String with cell value of last matched column
:return: String with cell value of last matched column.
"""
# Returns last match of row
value = None
Expand All @@ -96,7 +100,12 @@ def _get_col_value(cls, target_col, row, table):
header = table['field_header'][i]
if header['value'].lower() == target_col.lower():
value = row[i]['value']
return value

if isinstance(value, str):
return value
elif isinstance(value, list) and len(value) == 1: # OntologyTermRefs
return value[0]['name']
return None

def get_row_path(self, row, table, assay, assay_path):
"""
Expand Down

0 comments on commit dae87a6

Please sign in to comment.