Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

This commit fixes the duplicate variant issue in the find_subject_dx_… #95

Merged
merged 2 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading