Skip to content

Commit

Permalink
Merge pull request #95 from AkRampersad/subject_tx_dx_implication_par…
Browse files Browse the repository at this point in the history
…ameter

This commit fixes the duplicate variant issue in the find_subject_dx_…
  • Loading branch information
mihaitodor authored Oct 17, 2024
2 parents 43b3ce5 + 8f34104 commit 81c9e68
Show file tree
Hide file tree
Showing 10 changed files with 11,912 additions and 73,787 deletions.
29 changes: 29 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Debug app",
"type": "debugpy",
"request": "launch",
"program": "${workspaceFolder}/run.py",
"console": "integratedTerminal",
"justMyCode": false
},
{
"name": "Debug Unit Test",
"type": "debugpy",
"request": "launch",
"justMyCode": false,
},
{
"name": "Debug File",
"type": "debugpy",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal"
}
]
}
65 changes: 39 additions & 26 deletions app/endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -847,6 +847,7 @@ def find_subject_tx_implications(
result = OrderedDict()
result["resourceType"] = "Parameters"
result["parameter"] = []
list_variants = []

if normalized_variants:
if not ranges:
Expand Down Expand Up @@ -880,11 +881,13 @@ def find_subject_tx_implications(
resource = common.create_fhir_variant_resource(
res, ref_seq, subject)

variant_param = {
"name": "variant",
"resource": resource
}
result["parameter"].append(variant_param)
if resource['id'] not in list_variants:
list_variants.append(resource['id'])
variant_param = {
"name": "variant",
"resource": resource
}
result["parameter"].append(variant_param)

if not result["parameter"]:
result.pop("parameter")
Expand Down Expand Up @@ -1000,11 +1003,13 @@ def find_subject_tx_implications(
variant_fhir_profiles = sorted(variant_fhir_profiles, key=lambda d: d['id'])

for resource in variant_fhir_profiles:
variant_param = {
"name": "variant",
"resource": resource
}
result["parameter"].append(variant_param)
if resource['id'] not in list_variants:
list_variants.append(resource['id'])
variant_param = {
"name": "variant",
"resource": resource
}
result["parameter"].append(variant_param)

if not result["parameter"]:
result.pop("parameter")
Expand Down Expand Up @@ -1038,11 +1043,13 @@ def find_subject_tx_implications(
variant_fhir_profiles = sorted(variant_fhir_profiles, key=lambda d: d['id'])

for resource in variant_fhir_profiles:
variant_param = {
"name": "variant",
"resource": resource
}
result["parameter"].append(variant_param)
if resource['id'] not in list_variants:
list_variants.append(resource['id'])
variant_param = {
"name": "variant",
"resource": resource
}
result["parameter"].append(variant_param)

if not result["parameter"]:
result.pop("parameter")
Expand Down Expand Up @@ -1113,7 +1120,7 @@ def find_subject_dx_implications(
result = OrderedDict()
result["resourceType"] = "Parameters"
result["parameter"] = []

list_variants = []
if normalized_variants:
if not ranges:
genomics_build_presence = common.get_genomics_build_presence(query)
Expand Down Expand Up @@ -1146,11 +1153,14 @@ def find_subject_dx_implications(

resource = common.create_fhir_variant_resource(
res, ref_seq, subject)
variant_param = {
"name": "variant",
"resource": resource
}
result["parameter"].append(variant_param)

if resource['id'] not in list_variants:
list_variants.append(resource['id'])
variant_param = {
"name": "variant",
"resource": resource
}
result["parameter"].append(variant_param)

if not result["parameter"]:
result.pop("parameter")
Expand Down Expand Up @@ -1180,11 +1190,14 @@ def find_subject_dx_implications(
ref_seq = common.get_ref_seq_by_chrom_and_build(varItem['genomicBuild'], varItem['CHROM'])
resource = common.create_fhir_variant_resource(varItem, ref_seq, subject)

variant_param = {
"name": "variant",
"resource": resource
}
result["parameter"].append(variant_param)
if resource['id'] not in list_variants:
list_variants.append(resource['id'])

variant_param = {
"name": "variant",
"resource": resource
}
result["parameter"].append(variant_param)

if not result["parameter"]:
result.pop("parameter")
Expand Down
Loading

0 comments on commit 81c9e68

Please sign in to comment.