Skip to content

Commit

Permalink
Merge pull request #10 from UMCUGenetics/develop
Browse files Browse the repository at this point in the history
v1.1.4
  • Loading branch information
rernst authored Jan 6, 2020
2 parents 6969d19 + e2d7bdb commit 5e2bbd8
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 23 deletions.
24 changes: 15 additions & 9 deletions clarity_epp/qc/qubit.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
"""Qubit QC epp functions."""

import re

from genologics.entities import Process


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 = {}

for artifact in artifacts:
Expand All @@ -24,14 +27,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()
2 changes: 1 addition & 1 deletion clarity_epp/upload/samples.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
23 changes: 15 additions & 8 deletions clarity_epp/upload/tecan.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
"""Tecan results upload epp functions."""

import re

from genologics.entities import Process


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)']))

# Parse output file
for output in process.all_outputs(unique=True):
Expand Down Expand Up @@ -86,13 +89,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()
6 changes: 1 addition & 5 deletions clarity_epp/upload/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 5e2bbd8

Please sign in to comment.