Skip to content

Commit b05ea8c

Browse files
authored
Merge pull request #15 from CanDIG/daisieh/biosamples
DIG-2209: Changing /experiments to /biosamples
2 parents a6715da + a0147e4 commit b05ea8c

File tree

3 files changed

+59
-48
lines changed

3 files changed

+59
-48
lines changed

drs_server/drs_database.py

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ def delete_program(program_id, tries=1):
370370
return None
371371

372372

373-
def list_experiments(program_ids=None, submitter_sample_ids=None):
373+
def list_biosamples(program_ids=None, submitter_sample_ids=None):
374374
experiment_obj = aliased(DrsObject)
375375
analysis_obj = aliased(DrsObject)
376376
stmt = select(experiment_obj.name, experiment_obj.id, experiment_obj.program_id, experiment_obj.description, analysis_obj.name, analysis_obj.description, ContentsObject)
@@ -388,24 +388,22 @@ def list_experiments(program_ids=None, submitter_sample_ids=None):
388388
result = row._mapping
389389
if result["name"] not in results_dict:
390390
results_dict[result["name"]] = {
391-
"experiment_id": result["name"],
391+
"biosample_id": result["name"],
392392
"program": result["program_id"],
393-
"genomes": [],
394-
"transcriptomes": [],
395-
"variants": [],
396-
"reads": [],
397-
"expressions": []
393+
"experiments": {
394+
"wgs": [],
395+
"wts": []
396+
},
397+
"runs": [],
398+
"analyses": {}
398399
}
399-
this_result = results_dict[result["name"]]
400-
if result["description"] == "wgs" and result["id"] not in this_result["genomes"]:
401-
results_dict[result["name"]]["genomes"].append(result["id"])
402-
elif result["description"] == "wts" and result["id"] not in this_result["transcriptomes"]:
403-
results_dict[result["name"]]["transcriptomes"].append(result["id"])
404-
if result["description_1"] == "sequence_variation" and result["name_1"] not in this_result["variants"]:
405-
results_dict[result["name"]]["variants"].append(result["name_1"])
406-
elif result["description_1"] == "reference_alignment" and result["name_1"] not in this_result["reads"]:
407-
results_dict[result["name"]]["reads"].append(result["name_1"])
408-
elif result["description_1"] == "sequence_annotation" and result["name_1"] not in this_result["expressions"]:
409-
results_dict[result["name"]]["expressions"].append(result["name_1"])
400+
if result["description"] in ["wgs", "wts"] and result["id"] not in results_dict[result["name"]]["experiments"][result["description"]]:
401+
results_dict[result["name"]]["experiments"][result["description"]].append(result["id"])
402+
if result["description_1"] == "raw_reads":
403+
results_dict[result["name"]]["runs"].append(result["name_1"])
404+
else:
405+
if result["description_1"] not in results_dict[result["name"]]["analyses"]:
406+
results_dict[result["name"]]["analyses"][result["description_1"]] = []
407+
results_dict[result["name"]]["analyses"][result["description_1"]].append(result["name_1"])
410408
return list(results_dict.values())
411409
return None

drs_server/drs_openapi.yaml

Lines changed: 40 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -139,14 +139,14 @@ paths:
139139
description: array of strings that need to be passed with the URL to get bytes
140140
tags:
141141
- Objects
142-
/experiments:
142+
/biosamples:
143143
parameters:
144144
- $ref: '#/components/parameters/BearerAuth'
145145
post:
146146
summary: List all DRS Experiment objects matching an array of submitter_sample_ids. Only authorized for site admins and authzed services.
147-
operationId: drs_operations.list_experiments
147+
operationId: drs_operations.list_biosamples
148148
requestBody:
149-
$ref: '#/components/requestBodies/ExperimentsRequest'
149+
$ref: '#/components/requestBodies/BiosamplesRequest'
150150
responses:
151151
200:
152152
description: The `DrsObjects` were found successfully
@@ -156,7 +156,7 @@ paths:
156156
type: array
157157
items:
158158
anyOf:
159-
- $ref: '#/components/schemas/ExperimentTicket'
159+
- $ref: '#/components/schemas/BiosampleTicket'
160160
tags:
161161
- Objects
162162
/programs:
@@ -314,7 +314,7 @@ components:
314314
'application/json':
315315
schema:
316316
$ref: '#/components/schemas/Program'
317-
ExperimentsRequest:
317+
BiosamplesRequest:
318318
description: list of submitter sample ids requested
319319
required: false
320320
content:
@@ -372,35 +372,48 @@ components:
372372
DrsUri:
373373
type: string
374374
description: a DRS object's self_uri
375-
ExperimentTicket:
375+
BiosampleTicket:
376376
type: object
377377
properties:
378-
experiment_id:
379-
type: string
380-
description: MoH submitter_sample_id from a Sample Registration associated with a specimen.
381-
program:
382-
type: string
383-
description: MoH program ID
384-
genomes:
378+
biosample_id:
379+
type: string
380+
description: MoH submitter_sample_id from a Sample Registration associated with a specimen.
381+
program:
382+
type: string
383+
description: MoH program ID
384+
experiments:
385+
type: object
386+
description: Arrays of associated experiment IDs derived from the biosample, keyed by type.
387+
properties:
388+
wgs:
385389
type: array
386-
description: An array of associated AnalysisDrsObjects that describe reads, e.g. fastqs.
387390
items:
388-
type: string
389-
transcriptomes:
391+
type: string
392+
wts:
390393
type: array
391-
description: An array of associated AnalysisDrsObjects that describe transcriptome data.
392394
items:
393-
type: string
394-
variants:
395+
type: string
396+
runs:
397+
type: array
398+
description: An array of associated run IDs that describe raw reads derived from biosample.
399+
items:
400+
type: string
401+
analyses:
402+
type: object
403+
description: Arrays of associated analysis IDs based on the biosample, keyed by analysis type.
404+
properties:
405+
reference_alignment:
395406
type: array
396-
description: An array of associated DataDrsObjects that describe variant files.
397407
items:
398-
type: string
399-
reads:
408+
type: string
409+
sequence_variation:
400410
type: array
401-
description: An array of associated DataDrsObjects that describe read files, e.g. bams.
402411
items:
403-
type: string
412+
type: string
413+
sequence_annotation:
414+
type: array
415+
items:
416+
type: string
404417
ExperimentDrsObject:
405418
type: object
406419
description: A DrsObject that describes the sequencing experiment.
@@ -413,10 +426,10 @@ components:
413426
properties:
414427
name:
415428
type: string
416-
description: The specimen identifier for the experiment, as defined in sample_registration in the MOHCCN data model.
429+
description: The biosample identifier for the experiment.
417430
id:
418431
type: string
419-
description: The alias for the experiment, as defined by the sequencing center
432+
description: A unique ID for the experiment. Often the alias for the experiment, as defined by the sequencing center
420433
contents:
421434
type: array
422435
description: The specific analysis contents objects that were generated from this experiment.
@@ -479,7 +492,7 @@ components:
479492
$ref: '#/components/schemas/Checksum'
480493
AnalysisDrsObject:
481494
type: object
482-
description: A DrsObject that describes a sequencing analysis. It usually will consist of a data file, e.g. a variant or read file, and its associated index file. Its contents should also include any associated Experiments (as ExperimentContentObjects), ordered in order of appearance in the associated variant/read files.
495+
description: A DrsObject that describes a sequencing analysis. It usually will consist of a data file, e.g. a variant or read file, and its associated index file. Its contents should also include any associated Experiments (as ContentObjects), ordered in order of appearance in the associated variant/read files.
483496
required:
484497
- name
485498
- id

drs_server/drs_operations.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def list_objects(program_id=None, submitter_sample_id=None):
8484
return drs_database.list_drs_objects(program_id=program_id, submitter_sample_id=submitter_sample_id), 200
8585

8686

87-
async def list_experiments():
87+
async def list_biosamples():
8888
if not authz.has_full_authz(connexion.request):
8989
return {"message": f"Not authorized to list all objects"}, 403
9090
req = await connexion.request.json()
@@ -95,8 +95,8 @@ async def list_experiments():
9595
submitter_sample_ids = req["submitter_sample_ids"]
9696
if "program_ids" in req:
9797
program_ids = req["program_ids"]
98-
experiments = drs_database.list_experiments(program_ids=program_ids, submitter_sample_ids=submitter_sample_ids)
99-
return experiments, 200
98+
biosamples = drs_database.list_biosamples(program_ids=program_ids, submitter_sample_ids=submitter_sample_ids)
99+
return biosamples, 200
100100

101101

102102
@app.route('/ga4gh/drs/v1/objects/<object_id>/access_url/<path:access_id>')

0 commit comments

Comments
 (0)