From 434a9647181578976a8cf53bd195046846380f34 Mon Sep 17 00:00:00 2001 From: strasserle Date: Sat, 11 Jan 2025 00:05:58 +0100 Subject: [PATCH] query /alternativeSplicing/getPsiValue/ now also by dataset --- app/controllers/alternativeSplicing.py | 18 ++++++++++++++++-- swagger.yml | 19 +++++++++++++++++++ 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/app/controllers/alternativeSplicing.py b/app/controllers/alternativeSplicing.py index c824c9e..a033f45 100644 --- a/app/controllers/alternativeSplicing.py +++ b/app/controllers/alternativeSplicing.py @@ -1,7 +1,9 @@ from flask import abort +from sqlalchemy import or_ +from app.controllers.dataset import _dataset_query import app.models as models from flask import Response -from app.config import db +from app.config import db, LATEST def get_transcript_events(enst_number): """ @@ -93,16 +95,26 @@ def get_exons_for_position(start_pos: int, end_pos: int): abort(404, "No data found that satisfies the given filters") -def get_psi_values(transcript_ID: str = None, enst_number: str =None, psivec_ID: int = None, alternative_splicing_event_transcripts_ID: str = None, sample_ID: str = None, limit=100): +def get_psi_values(dataset_ID: str = None, disease_name: str = None, data_origin: str = None, transcript_ID: str = None, enst_number: str =None, psivec_ID: int = None, alternative_splicing_event_transcripts_ID: str = None, sample_ID: str = None, limit=100, sponge_db_version: int = LATEST): """ This function response for the request: /alternativeSplicing/getPsiValue/ with the possibility to filter by psivec_ID, alternative splicing event transcripts ID and sample ID + :param disease_name: name of the disease + :param dataset_ID: ID of the dataset :param psivec_ID: ID of the psivec :param alternative_splicing_event_transcripts_ID: ID of the alternative splicing event transcripts :param sample_ID: ID of the sample :return: psi value for the given parameters, ordered by psi value """ + + # Get the dataset + if dataset_ID or disease_name or data_origin: + data = _dataset_query(sponge_db_version=sponge_db_version, dataset_ID=dataset_ID, disease_name=disease_name, data_origin=data_origin) + data = [d.disease_name for d in data] + else: + data = None + # Build the transcript query transcript_query = db.select(models.Transcript.transcript_ID) if transcript_ID: @@ -127,6 +139,8 @@ def get_psi_values(transcript_ID: str = None, enst_number: str =None, psivec_ID: psi_query = psi_query.where(models.PsiVec.psivec_ID == psivec_ID) if sample_ID: psi_query = psi_query.where(models.PsiVec.sample_ID == sample_ID) + if data: + psi_query = psi_query.where(or_(*[models.PsiVec.sample_ID.like(d.replace(" ", "_") + "%") for d in data])) # Apply limit and sort results psi_query = psi_query.order_by(models.PsiVec.psi_value.desc()).limit(limit) diff --git a/swagger.yml b/swagger.yml index ebd56c5..5094fc9 100644 --- a/swagger.yml +++ b/swagger.yml @@ -3953,6 +3953,24 @@ paths: summary: Retrieve all psi values for a specific event type of a transcript of interest. description: Retrieve all psi values for a specific event type of a transcript of interest. parameters: + - name: dataset_ID + in: query + description: Internal database ID of the cancer type/dataset. + required: false + schema: + type: integer + - name: disease_name + in: query + description: Name of the specific cancer type/dataset. Fuzzy search is available (e.g. "kidney clear cell carcinoma" or just "kidney"). + required: false + schema: + type: string + - name: data_origin + in: query + description: Origin of the data (e.g. TCGA, GTEx, ...) + required: false + schema: + type: string - name: transcript_ID in: query description: Internal database ID of the transcript of interest. @@ -3989,6 +4007,7 @@ paths: schema: type: integer required: false + - $ref: '#/components/parameters/VersionParam' responses: "200": description: Retrieve all psi values for a specific event type of a transcript of interest.