Skip to content

Commit

Permalink
Merge pull request #293 from CanDIG/daisieh/query-sample
Browse files Browse the repository at this point in the history
  • Loading branch information
daisieh authored Mar 4, 2024
2 parents c5f4b33 + 07b09fa commit b25e0e7
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
11 changes: 11 additions & 0 deletions htsget_server/htsget_openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -865,6 +865,17 @@ components:
description: An array of associated GenomicDrsObjects that describe transcriptome data.
items:
type: string
variants:
type: array
description: An array of associated GenomicDataDrsObjects that describe variant files.
items:
type: string
reads:
type: array
description: An array of associated GenomicDataDrsObjects that describe read files.
items:
type: string


# ERROR SCHEMAS
Error:
Expand Down
11 changes: 10 additions & 1 deletion htsget_server/htsget_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,9 @@ def get_sample(id_=None):
result = {
"sample_id": id_,
"genomes": [],
"transcriptomes": []
"transcriptomes": [],
"variants": [],
"reads": []
}

# Get the SampleDrsObject. It will have a contents array of GenomicContentsObjects > GenomicDrsObjects.
Expand All @@ -252,6 +254,13 @@ def get_sample(id_=None):
result["genomes"].append(drs_obj["id"])
elif drs_obj["description"] == "wts":
result["transcriptomes"].append(drs_obj["id"])
# check the contents of this genomic drs object and see if it contains variants or reads
if "contents" in drs_obj:
for content in drs_obj["contents"]:
if content["id"] == "variant":
result["variants"].append(drs_obj["id"])
elif content["id"] == "read":
result["reads"].append(drs_obj["id"])
return result, 200
return {"message": f"Could not find sample {id_}"}, 404

Expand Down

0 comments on commit b25e0e7

Please sign in to comment.