From 2782110003c5baae9fba34ca08e1cdee564e5bb5 Mon Sep 17 00:00:00 2001 From: Robert Ernst Date: Wed, 16 Oct 2019 15:04:45 +0200 Subject: [PATCH 1/7] Fix bone marrow import, resolves #8. --- clarity_epp/upload/samples.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clarity_epp/upload/samples.py b/clarity_epp/upload/samples.py index fe4c47a..44fa140 100644 --- a/clarity_epp/upload/samples.py +++ b/clarity_epp/upload/samples.py @@ -101,7 +101,7 @@ def from_helix(lims, email_settings, input_file): sample_name = udf_data['Dx Monsternummer'] # Set 'Dx Handmatig' udf - if udf_data['Dx Foetus'] or udf_data['Dx Overleden'] or udf_data['Dx Materiaal type'] != 'BL': + if udf_data['Dx Foetus'] or udf_data['Dx Overleden'] or udf_data['Dx Materiaal type'] not in ['BL', 'BLHEP', 'BM', 'BMEDTA']: udf_data['Dx Handmatig'] = True else: udf_data['Dx Handmatig'] = False From 00f44d7a81ffbaacab6e0cd553ce1213a72e914b Mon Sep 17 00:00:00 2001 From: Robert Ernst Date: Wed, 13 Nov 2019 17:00:10 +0100 Subject: [PATCH 2/7] Fix legacy sample imports, resolves #9. --- clarity_epp/upload/utils.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/clarity_epp/upload/utils.py b/clarity_epp/upload/utils.py index 678c54e..d5012f2 100644 --- a/clarity_epp/upload/utils.py +++ b/clarity_epp/upload/utils.py @@ -35,11 +35,7 @@ def transform_sex(value): def transform_sample_name(value): """Transform legacy name to new sample name.""" if '/' in value: - match = re.search("D(\d\d)/(.+)", value) - sample_name = '{year}D{sample_id}'.format( - year=datetime.strptime(match.group(1), '%y').year, - sample_id=match.group(2).zfill(5) - ) + sample_name = ''.join(value.split('/')) return sample_name else: return value From d3cfc9c011f8a50e0b3096dc083989978fbc8d49 Mon Sep 17 00:00:00 2001 From: Robert Ernst Date: Fri, 15 Nov 2019 14:40:58 +0100 Subject: [PATCH 3/7] Check concentration range. --- clarity_epp/qc/qubit.py | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/clarity_epp/qc/qubit.py b/clarity_epp/qc/qubit.py index 866295d..3dfe348 100644 --- a/clarity_epp/qc/qubit.py +++ b/clarity_epp/qc/qubit.py @@ -1,5 +1,7 @@ """Qubit QC epp functions.""" +import re + from genologics.entities import Process @@ -9,6 +11,8 @@ def set_qc_flag(lims, process_id, cutoff=10): artifacts = process.result_files() samples_measurements = {} + concentration_range = map(int, re.findall('[\d]+', process.udf['Concentratiebereik (ng/ul)'])) + for artifact in artifacts: sample = artifact.name.rstrip('Qubit').rstrip() measurement = artifact.udf['Dx Conc. goedgekeurde meting (ng/ul)'] @@ -24,14 +28,17 @@ def set_qc_flag(lims, process_id, cutoff=10): sample_measurements_average = sum(sample_measurements) / float(len(sample_measurements)) artifact.udf['Dx Concentratie fluorescentie (ng/ul)'] = sample_measurements_average - if len(sample_measurements) == 1: - artifact.qc_flag = 'PASSED' - elif len(sample_measurements) == 2: - sample_measurements_difference = abs(sample_measurements[0] - sample_measurements[1]) - sample_measurements_deviation = sample_measurements_difference / sample_measurements_average - - if sample_measurements_deviation <= 0.1: + if concentration_range[0] <= sample_measurements_average <= concentration_range[1]: + if len(sample_measurements) == 1: artifact.qc_flag = 'PASSED' - else: - artifact.qc_flag = 'FAILED' + elif len(sample_measurements) == 2: + sample_measurements_difference = abs(sample_measurements[0] - sample_measurements[1]) + sample_measurements_deviation = sample_measurements_difference / sample_measurements_average + if sample_measurements_deviation <= 0.1: + artifact.qc_flag = 'PASSED' + else: + artifact.qc_flag = 'FAILED' + else: + artifact.qc_flag = 'FAILED' + artifact.put() From e5e1a3b37634aaa37e9d369cdf276ad799d8c493 Mon Sep 17 00:00:00 2001 From: Robert Ernst Date: Tue, 19 Nov 2019 13:45:02 +0100 Subject: [PATCH 4/7] Check concentration ragen. --- clarity_epp/upload/tecan.py | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/clarity_epp/upload/tecan.py b/clarity_epp/upload/tecan.py index 40062f8..ba60581 100644 --- a/clarity_epp/upload/tecan.py +++ b/clarity_epp/upload/tecan.py @@ -6,6 +6,7 @@ def results(lims, process_id): """Upload tecan results to artifacts.""" process = Process(lims, id=process_id) + concentration_range = map(int, re.findall('[\d]+', process.udf['Concentratiebereik (ng/ul)'])) # Parse output file for output in process.all_outputs(unique=True): @@ -86,13 +87,17 @@ def results(lims, process_id): artifact.udf['Dx Concentratie fluorescentie (ng/ul)'] = ng_values[std_number - 1] else: # Calculate measurement deviation from average. - if len(sample_measurements[artifact.name]) == 1: - artifact.qc_flag = 'PASSED' - elif len(sample_measurements[artifact.name]) == 2: - artifact_fluorescence_difference = abs(sample_measurements[artifact.name][0] - sample_measurements[artifact.name][1]) - artifact_fluorescence_deviation = artifact_fluorescence_difference / sample_fluorescence - if artifact_fluorescence_deviation <= 0.1: + if concentration_range[0] <= sample_concentration <= concentration_range[1]: + if len(sample_measurements[artifact.name]) == 1: artifact.qc_flag = 'PASSED' - else: - artifact.qc_flag = 'FAILED' + elif len(sample_measurements[artifact.name]) == 2: + artifact_fluorescence_difference = abs(sample_measurements[artifact.name][0] - sample_measurements[artifact.name][1]) + artifact_fluorescence_deviation = artifact_fluorescence_difference / sample_fluorescence + if artifact_fluorescence_deviation <= 0.1: + artifact.qc_flag = 'PASSED' + else: + artifact.qc_flag = 'FAILED' + else: + artifact.qc_flag = 'FAILED' + artifact.put() From 4adfd8f7b3c9d780dd988e2cba3b39b0191f3640 Mon Sep 17 00:00:00 2001 From: Robert Ernst Date: Tue, 19 Nov 2019 14:18:11 +0100 Subject: [PATCH 5/7] Import re. --- clarity_epp/upload/tecan.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/clarity_epp/upload/tecan.py b/clarity_epp/upload/tecan.py index ba60581..c7df089 100644 --- a/clarity_epp/upload/tecan.py +++ b/clarity_epp/upload/tecan.py @@ -1,5 +1,7 @@ """Tecan results upload epp functions.""" +import re + from genologics.entities import Process From 3a3d9f33faa8682f7dfd6e5e35c34a38ff42d389 Mon Sep 17 00:00:00 2001 From: Robert Ernst Date: Tue, 26 Nov 2019 12:14:11 +0100 Subject: [PATCH 6/7] Map concentration range values to flaot. --- clarity_epp/qc/qubit.py | 2 +- clarity_epp/upload/tecan.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/clarity_epp/qc/qubit.py b/clarity_epp/qc/qubit.py index 3dfe348..355afd4 100644 --- a/clarity_epp/qc/qubit.py +++ b/clarity_epp/qc/qubit.py @@ -11,7 +11,7 @@ def set_qc_flag(lims, process_id, cutoff=10): artifacts = process.result_files() samples_measurements = {} - concentration_range = map(int, re.findall('[\d]+', process.udf['Concentratiebereik (ng/ul)'])) + concentration_range = map(float, re.findall('[\d]+', process.udf['Concentratiebereik (ng/ul)'])) for artifact in artifacts: sample = artifact.name.rstrip('Qubit').rstrip() diff --git a/clarity_epp/upload/tecan.py b/clarity_epp/upload/tecan.py index c7df089..6413962 100644 --- a/clarity_epp/upload/tecan.py +++ b/clarity_epp/upload/tecan.py @@ -8,7 +8,7 @@ def results(lims, process_id): """Upload tecan results to artifacts.""" process = Process(lims, id=process_id) - concentration_range = map(int, re.findall('[\d]+', process.udf['Concentratiebereik (ng/ul)'])) + concentration_range = map(float, re.findall('[\d]+', process.udf['Concentratiebereik (ng/ul)'])) # Parse output file for output in process.all_outputs(unique=True): From e2d7bdb7526308c8d98eaad89d59d94f3f935f00 Mon Sep 17 00:00:00 2001 From: Robert Ernst Date: Tue, 26 Nov 2019 12:38:33 +0100 Subject: [PATCH 7/7] Fix list split for floats. --- clarity_epp/qc/qubit.py | 3 +-- clarity_epp/upload/tecan.py | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/clarity_epp/qc/qubit.py b/clarity_epp/qc/qubit.py index 355afd4..4c5fb2e 100644 --- a/clarity_epp/qc/qubit.py +++ b/clarity_epp/qc/qubit.py @@ -9,10 +9,9 @@ def set_qc_flag(lims, process_id, cutoff=10): """Set qubit qc flags based on Dx Concentratie fluorescentie (ng/ul) values.""" process = Process(lims, id=process_id) artifacts = process.result_files() + concentration_range = map(float, re.findall('[\d\.]+', process.udf['Concentratiebereik (ng/ul)'])) samples_measurements = {} - concentration_range = map(float, re.findall('[\d]+', process.udf['Concentratiebereik (ng/ul)'])) - for artifact in artifacts: sample = artifact.name.rstrip('Qubit').rstrip() measurement = artifact.udf['Dx Conc. goedgekeurde meting (ng/ul)'] diff --git a/clarity_epp/upload/tecan.py b/clarity_epp/upload/tecan.py index 6413962..a67d506 100644 --- a/clarity_epp/upload/tecan.py +++ b/clarity_epp/upload/tecan.py @@ -8,7 +8,7 @@ def results(lims, process_id): """Upload tecan results to artifacts.""" process = Process(lims, id=process_id) - concentration_range = map(float, re.findall('[\d]+', process.udf['Concentratiebereik (ng/ul)'])) + concentration_range = map(float, re.findall('[\d\.]+', process.udf['Concentratiebereik (ng/ul)'])) # Parse output file for output in process.all_outputs(unique=True):