From e007d64aac149cb7b6754e55053ef3ab0aa69a31 Mon Sep 17 00:00:00 2001 From: Thomas Sell Date: Wed, 31 Jan 2024 16:23:29 +0100 Subject: [PATCH 1/3] feat: Add list processing for Performer fields --- altamisa/isatab/models.py | 2 +- altamisa/isatab/parse_assay_study.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/altamisa/isatab/models.py b/altamisa/isatab/models.py index 2481d60..f5880d8 100644 --- a/altamisa/isatab/models.py +++ b/altamisa/isatab/models.py @@ -460,7 +460,7 @@ class Process: #: Process date date: Optional[Union[datetime.date, Literal[""]]] #: Performer of process - performer: Optional[str] + performer: Optional[Tuple[str]] #: Tuple of parameters values parameter_values: Tuple[ParameterValue, ...] #: Tuple of process comments diff --git a/altamisa/isatab/parse_assay_study.py b/altamisa/isatab/parse_assay_study.py index b75ec0b..142efa0 100644 --- a/altamisa/isatab/parse_assay_study.py +++ b/altamisa/isatab/parse_assay_study.py @@ -442,7 +442,7 @@ def build(self, line: List[str]) -> models.Process: else: date = None if self.performer_header: - performer = line[self.performer_header.col_no] + performer = tuple(self._token_with_escape(line[self.performer_header.col_no])) else: performer = None comments = tuple( From b15af8e6841cb21f5871185e1fdbd951f6fce446 Mon Sep 17 00:00:00 2001 From: Thomas Sell Date: Thu, 1 Feb 2024 19:31:19 +0100 Subject: [PATCH 2/3] adapt writer & tests --- altamisa/isatab/models.py | 2 +- altamisa/isatab/write_assay_study.py | 4 +++- tests/test_parse_study.py | 10 +++++----- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/altamisa/isatab/models.py b/altamisa/isatab/models.py index f5880d8..531da90 100644 --- a/altamisa/isatab/models.py +++ b/altamisa/isatab/models.py @@ -460,7 +460,7 @@ class Process: #: Process date date: Optional[Union[datetime.date, Literal[""]]] #: Performer of process - performer: Optional[Tuple[str]] + performer: Optional[Tuple[str, ...]] #: Tuple of parameters values parameter_values: Tuple[ParameterValue, ...] #: Tuple of process comments diff --git a/altamisa/isatab/write_assay_study.py b/altamisa/isatab/write_assay_study.py index d711d5d..eb0f8ce 100644 --- a/altamisa/isatab/write_assay_study.py +++ b/altamisa/isatab/write_assay_study.py @@ -411,7 +411,9 @@ def _extract_process(self, node: Process) -> dict: if node.protocol_ref != TOKEN_UNKNOWN: attributes[table_headers.PROTOCOL_REF] = node.protocol_ref if node.performer is not None: - attributes[table_headers.PERFORMER] = node.performer + attributes[table_headers.PERFORMER] = ";".join( + [p.replace(";", "\\;") if p else "" for p in node.performer] + ) if node.date is not None: attributes[table_headers.DATE] = node.date for parameter in node.parameter_values: diff --git a/tests/test_parse_study.py b/tests/test_parse_study.py index ffaaa64..b2331ac 100644 --- a/tests/test_parse_study.py +++ b/tests/test_parse_study.py @@ -257,7 +257,7 @@ def test_study_row_reader_small_study(small_investigation_file, small_study_file None, None, date(2018, 2, 2), - "John Doe", + ("John Doe",), (models.ParameterValue("instrument", ["scalpel"], None),), (), None, @@ -298,7 +298,7 @@ def test_study_row_reader_small_study(small_investigation_file, small_study_file None, None, date(2018, 2, 2), - "John Doe", + ("John Doe",), (models.ParameterValue("instrument", ["scalpel type A", "scalpel type B"], None),), (), None, @@ -507,7 +507,7 @@ def test_study_reader_small_study( None, None, date(2018, 2, 2), - "John Doe", + ("John Doe",), (models.ParameterValue("instrument", ["scalpel"], None),), (), None, @@ -522,7 +522,7 @@ def test_study_reader_small_study( None, None, date(2018, 2, 2), - "John Doe", + ("John Doe",), (models.ParameterValue("instrument", ["scalpel type A", "scalpel type B"], None),), (), None, @@ -537,7 +537,7 @@ def test_study_reader_small_study( None, None, date(2018, 2, 2), - "John Doe", + ("John Doe",), (models.ParameterValue("instrument", ["scalpel"], None),), (), None, From 643ecfe74619da691abe1ae497fb05ba00e9b54a Mon Sep 17 00:00:00 2001 From: Thomas Sell Date: Fri, 2 Feb 2024 10:43:20 +0100 Subject: [PATCH 3/3] note extension in documentation --- docs/index.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/index.rst b/docs/index.rst index 9e2d7a3..baae2e3 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -53,10 +53,10 @@ Special Extensions In addition to the original ISA-Tab format specifications, AltamISA supports the following special modifications to improve specific use cases: -- **List of values** in ``Characterics``, ``Parameter Value``, or ``Factor Value`` fields by using - semicolon-separators (";"). Note, for ontology terms the same number of - splits is expected in the associated field ``Term Source REF`` and - ``Term Accession Number``. +- **List of values** in ``Characterics``, ``Parameter Value``, ``Factor Value``, + and ``Performer`` fields by using semicolon-separators (";"). Note: For + ontology terms the same number of splits is expected in the associated field + ``Term Source REF`` and ``Term Accession Number``. - **Material name** ``Library Name`` for improved library annotation in nucleotide sequencing assays.