diff --git a/docs_manual/source/metadata_advanced.rst b/docs_manual/source/metadata_advanced.rst index 5b70a885..1f5eac6e 100644 --- a/docs_manual/source/metadata_advanced.rst +++ b/docs_manual/source/metadata_advanced.rst @@ -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: diff --git a/samplesheets/assayapps/generic/plugins.py b/samplesheets/assayapps/generic/plugins.py index 1eec422c..8f517ac6 100644 --- a/samplesheets/assayapps/generic/plugins.py +++ b/samplesheets/assayapps/generic/plugins.py @@ -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' @@ -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 @@ -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 @@ -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): """