From 3721713684f65055679be0c3c5c62f169dcffa9b Mon Sep 17 00:00:00 2001 From: Sujay Patil Date: Mon, 11 Jul 2022 01:09:46 -0700 Subject: [PATCH] add methods to filter by analysis ids --- sample_annotator/clients/gold_client.py | 34 ++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/sample_annotator/clients/gold_client.py b/sample_annotator/clients/gold_client.py index 702e550..a29cad8 100644 --- a/sample_annotator/clients/gold_client.py +++ b/sample_annotator/clients/gold_client.py @@ -272,7 +272,39 @@ def fetch_study_by_project(self, id: str) -> List[SampleDict]: id = self._normalize_id(id) results = self._call("studies", {"projectGoldId": id}) return results - + + def fetch_study_by_analysis_id(self, id: str) -> List[SampleDict]: + """Fetch the study id for which the informatics processing + of a sequencing project was performed. + + :param id: GOLD Analysis id. Ex.: Ga0466468 + :return: List of SampleDict objects + """ + id = self._normalize_id(id) + results = self._call("studies", {"analysisGoldId": id}) + return results + + def fetch_biosample_by_analysis_id(self, id: str) -> List[SampleDict]: + """Fetch the biosample id for which the informatics processing + of a sequencing project was performed. + + :param id: GOLD Analysis id. Ex.: Ga0466468 + :return: List of SampleDict objects + """ + id = self._normalize_id(id) + results = self._call("biosamples", {"analysisGoldId": id}) + return results + + def fetch_project_by_analysis_id(self, id: str) -> List[SampleDict]: + """Fetch the project id for which the informatics processing + of a sequencing project was performed. + + :param id: GOLD Analysis id. Ex.: Ga0466468 + :return: List of SampleDict objects + """ + id = self._normalize_id(id) + results = self._call("projects", {"analysisGoldId": id}) + return results @click.group() @click.option("-v", "--verbose", count=True)