Skip to content

Commit

Permalink
Merge pull request #58 from daisybio/psivec_dataset
Browse files Browse the repository at this point in the history
psivec dataset query
  • Loading branch information
strasserle authored Jan 10, 2025
2 parents d89e101 + 434a964 commit a32d171
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
18 changes: 16 additions & 2 deletions app/controllers/alternativeSplicing.py
Original file line number Diff line number Diff line change
@@ -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):
"""
Expand Down Expand Up @@ -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:
Expand All @@ -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)
Expand Down
19 changes: 19 additions & 0 deletions swagger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit a32d171

Please sign in to comment.