Skip to content

Commit

Permalink
Merge pull request #102 from eastgenomics/DI-286_Gemini_Rcode_matching
Browse files Browse the repository at this point in the history
minor fixes for v2.0.1 (#102)
  • Loading branch information
mattgarner authored May 17, 2023
2 parents e6345c4 + 9751594 commit 9ee9ba5
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
5 changes: 3 additions & 2 deletions cnvreports.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,9 @@ def run_cnvreports(
panels.append(CI)
else:
clinical_indication = next(
(key for key in CI2panels_dict.keys() if key == CI),
None)
(key for key in CI2panels_dict.keys()
if key.split("_")[0] == CI.split("_")[0]), None
)
if clinical_indication is None:
# skip sample if CI not found
skip_sample = True
Expand Down
19 changes: 12 additions & 7 deletions general_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -750,15 +750,20 @@ def parse_Gemini_manifest(manifest_file): # reports
)
sample_identifier = record[0] # X number
clinical_indications = record[-1].split(",")
CIs = list(set(
[CI for CI in clinical_indications if CI.startswith("R") or CI.startswith("_")]
# expecting Test Codes to be comma-separated
# handle R###.# and C##.# test codes and _HGNC IDs
# strip whitespaces in case they get through somehow
test_codes = list(set(
[CI.strip(" ") for CI in clinical_indications if
re.search(r"^[RC][0-9]+\.[0-9]+", CI.strip(" ")) or
re.search(r"^_HGNC", CI.strip(" "))]
))
# if sample is already assigned to a list of CIs, extend the list
# if sample is already assigned to a list of test_codes, extend the list
if sample_identifier in data.keys():
data[sample_identifier]["CIs"].append(CIs)
# if sample has no CIs yet, save the list
data[sample_identifier]["test_codes"].extend(test_codes)
# if sample has no test_codes yet, save the list
else:
data[sample_identifier] = {"test_codes": CIs}
data[sample_identifier] = {"test_codes": test_codes}

return data

Expand Down Expand Up @@ -898,7 +903,7 @@ def create_job_report_file(job__report_dict):
)
for sample, test in job__report_dict["invalid_tests"]:
f.write(
" * {}: {}".format(sample, test)
"{}\t{}\n".format(sample, test)
)

return job_report_file
5 changes: 3 additions & 2 deletions reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,9 @@ def run_reports(
panels.append(CI)
else:
clinical_indication = next(
(key for key in CI2panels_dict.keys() if key == CI),
None)
(key for key in CI2panels_dict.keys()
if key.split("_")[0] == CI.split("_")[0]), None
)
if clinical_indication is None:
# skip sample if CI not found
skip_sample = True
Expand Down

0 comments on commit 9ee9ba5

Please sign in to comment.