From 27da35233846ccf95ad9d2e56a953f6f5fc5bc89 Mon Sep 17 00:00:00 2001 From: glrs <5999366+glrs@users.noreply.github.com> Date: Wed, 20 Nov 2024 11:02:04 +0100 Subject: [PATCH] Update to interact with YggDB and follow AbstractProject changes --- lib/realms/tenx/run_sample.py | 7 ++++--- lib/realms/tenx/tenx_project.py | 7 +++++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/realms/tenx/run_sample.py b/lib/realms/tenx/run_sample.py index 30d5564..c6eff85 100644 --- a/lib/realms/tenx/run_sample.py +++ b/lib/realms/tenx/run_sample.py @@ -39,6 +39,8 @@ def __init__( self.run_sample_id: str = sample_id self.lab_samples: List[Any] = lab_samples self.project_info: Dict[str, Any] = project_info or {} + # TODO: ensure project_id is always available + self.project_id = self.project_info.get("project_id", "") self.config: Mapping[str, Any] = config or {} self.ydm: Any = yggdrasil_db_manager @@ -93,9 +95,8 @@ def status(self, value: str) -> None: value (str): The new status value. """ self._status = value - # self.ydm.update_sample_status( - # self.project_info.get("project_id", ""), self.id, value - # ) + # Update the status in the database + self.ydm.update_sample_status(self.project_id, self.id, value) def collect_reference_genomes(self) -> Optional[Dict[str, str]]: """Collect reference genomes from lab samples and ensure consistency. diff --git a/lib/realms/tenx/tenx_project.py b/lib/realms/tenx/tenx_project.py index 9242ac2..17757e2 100644 --- a/lib/realms/tenx/tenx_project.py +++ b/lib/realms/tenx/tenx_project.py @@ -31,9 +31,10 @@ def __init__(self, doc: Dict[str, Any], yggdrasil_db_manager: Any) -> None: self.ydm: Any = yggdrasil_db_manager # TODO: Might need to check required fields for each different method, if they differ - self.proceed: bool = self._check_required_fields() + self.proceed: bool = self.check_required_fields() if self.proceed: + self.initialize_project_in_db() # Extract metadata from project document self.project_info: Dict[str, Any] = self._extract_project_info() @@ -152,7 +153,7 @@ def is_supported_organism(self, organism: str) -> bool: gex_organisms = reference_mapping.get("gex", {}).keys() return organism in gex_organisms - def _check_required_fields(self) -> bool: + def check_required_fields(self) -> bool: """Check if the document contains all required fields. Returns: @@ -411,6 +412,8 @@ async def launch(self): logging.warning("No samples found for processing. Returning...") return + self.add_samples_to_project_in_db() + logging.info(f"Considered samples: {[sample.id for sample in self.samples]}") logging.info(f"Sample features: {[sample.features for sample in self.samples]}")