-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rewrite add_assay for 'bare assay' format
- Loading branch information
Showing
1 changed file
with
22 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,9 @@ | |
|
||
from altamisa.isatab import InvestigationReader | ||
|
||
__author__ = ( | ||
"Thomas Sell <[email protected]>" | ||
) | ||
|
||
class InvestigationForge: | ||
""" | ||
|
@@ -55,28 +58,30 @@ def add_assay(self, input_path: Union[str, Path]): | |
Add assay to investigation file. | ||
:type input_path: str | Path | ||
:param input_path: Location of investigation to modify. | ||
:param input_path: Location of bare assay definition to add. | ||
:rtype: models.InvestigationInfo | ||
:returns: Investigation model including all information from the investigation file. | ||
""" | ||
i_file = Path(input_path).expanduser().resolve() | ||
with i_file.open("rt") as f: | ||
investigation2 = InvestigationReader.from_stream(f).read() | ||
new_assay = Path(input_path).expanduser().resolve() | ||
with new_assay.open("rt") as f: | ||
reader = InvestigationReader(f) | ||
new_assays = tuple(a for a in reader._read_study_assays()) | ||
new_protocols = {p.name: p for p in reader._read_study_protocols()} | ||
|
||
if len(investigation2.studies) != 1: | ||
# TODO: add support for multiple studies | ||
raise IndexError("Only single study investigations are supported.") | ||
|
||
protocols = self.investigation.studies[0].protocols | ||
# the following will also update the investigation object | ||
protocols = self._join_protocols( | ||
protocols, | ||
investigation2.studies[0].protocols, | ||
old_protocols = self.investigation.studies[0].protocols | ||
joined_protocols = self._join_protocols( | ||
old_protocols, | ||
new_protocols, | ||
) | ||
|
||
# the following will NOT update the investigation object (?) | ||
assays = self.investigation.studies[0].assays | ||
assays += investigation2.studies[0].assays | ||
assays += new_assays | ||
|
||
updated_study = attr.evolve(self.investigation.studies[0], protocols=joined_protocols, assays=assays) | ||
self.investigation = attr.evolve(self.investigation, studies=(updated_study,)) | ||
|
||
def add_protocol(self): | ||
raise NotImplementedError | ||
|
||
new_study = attr.evolve(self.investigation.studies[0], protocols=protocols, assays=assays) | ||
self.investigation = attr.evolve(self.investigation, studies=(new_study,)) | ||
def remove_protocol(self): | ||
raise NotImplementedError |