Skip to content

Commit

Permalink
Merge pull request #1 from UMCUGenetics/develop
Browse files Browse the repository at this point in the history
v1.1.0
  • Loading branch information
rernst authored Jan 31, 2019
2 parents 23ca297 + 6b52edd commit 9195a7b
Show file tree
Hide file tree
Showing 25 changed files with 924 additions and 323 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,6 @@ ENV/

# mypy
.mypy_cache/

# Mac OS
.DS_Store
55 changes: 47 additions & 8 deletions clarity_epp.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,24 +45,35 @@ def export_illumina(args):

def export_labels(args):
"""Export container labels."""
clarity_epp.export.labels.containers(lims, args.process_id, args.output_file)
if args.type == 'container':
clarity_epp.export.labels.container(lims, args.process_id, args.output_file, args.description)
elif args.type == 'container_sample':
clarity_epp.export.labels.container_sample(lims, args.process_id, args.output_file)
elif args.type == 'storage_location':
clarity_epp.export.labels.storage_location(lims, args.process_id, args.output_file)


def export_manual_pipetting(args):
"""Export samplesheets for manual pipetting."""
if args.type == 'purify':
clarity_epp.export.manual_pipetting.samplesheet_purify(lims, args.process_id, args.output_file)
elif args.type == 'sequencing_pool':
clarity_epp.export.manual_pipetting.samplesheet_sequencing_pool(lims, args.process_id, args.output_file)
elif args.type == 'multiplex':
clarity_epp.export.manual_pipetting.samplesheet_multiplex(lims, args.process_id, args.output_file)

elif args.type == 'dilute_library_pool':
clarity_epp.export.manual_pipetting.samplesheet_dilute_library_pool(lims, args.process_id, args.output_file)
elif args.type == 'multiplex_library_pool':
clarity_epp.export.manual_pipetting.samplesheet_multiplex_library_pool(lims, args.process_id, args.output_file)
elif args.type == 'multiplex_sequence_pool':
clarity_epp.export.manual_pipetting.samplesheet_multiplex_sequence_pool(lims, args.process_id, args.output_file)

def export_ped_file(args):
"""Export ped file."""
clarity_epp.export.ped.create_file(lims, args.process_id, args.output_file)


def export_samplelist(args):
"""Generate samplelist."""
clarity_epp.export.samplelist.removed_samples(lims, args.output_file)


def export_tapestation(args):
"""Export samplesheets for Tapestation machine."""
clarity_epp.export.tapestation.samplesheet(lims, args.process_id, args.output_file)
Expand All @@ -75,7 +86,10 @@ def export_tecan(args):

def export_workflow(args):
"""Export workflow overview files."""
clarity_epp.export.workflow.helix(lims, args.process_id, args.output_file)
if args.type == 'lab':
clarity_epp.export.workflow.helix_lab(lims, args.process_id, args.output_file)
elif args.type == 'data_analysis':
clarity_epp.export.workflow.helix_data_analysis(lims, args.process_id, args.output_file)


# Upload Functions
Expand Down Expand Up @@ -135,6 +149,16 @@ def placement_barcode(args):
clarity_epp.placement.barcode.check_family(lims, args.process_id)


def placement_unpooling(args):
"""Pool unpooling."""
clarity_epp.placement.pool.unpooling(lims, args.process_id)


def placement_complete_step(args):
"""Complete protocol step (Dx Mark protocol complete)."""
clarity_epp.placement.step.finish_protocol_complete(lims, args.process_id)


if __name__ == "__main__":
parser = argparse.ArgumentParser()
subparser = parser.add_subparsers()
Expand All @@ -156,7 +180,7 @@ def placement_barcode(args):
parser_export_tecan.set_defaults(func=export_tecan)

parser_export_manual_pipetting = subparser_export.add_parser('manual', help='Create manual pipetting _exports', parents=[output_parser])
parser_export_manual_pipetting.add_argument('type', choices=['purify', 'sequencing_pool', 'multiplex'], help='Samplesheet type')
parser_export_manual_pipetting.add_argument('type', choices=['purify', 'dilute_library_pool', 'multiplex_library_pool', 'multiplex_sequence_pool'], help='Samplesheet type')
parser_export_manual_pipetting.add_argument('process_id', help='Clarity lims process id')
parser_export_manual_pipetting.set_defaults(func=export_manual_pipetting)

Expand All @@ -174,14 +198,18 @@ def placement_barcode(args):
parser_export_bioanalyzer.set_defaults(func=export_bioanalyzer)

parser_export_labels = subparser_export.add_parser('labels', help='Export container labels.', parents=[output_parser])
parser_export_labels.add_argument('type', choices=['container', 'container_sample', 'storage_location'], help='Label type')
parser_export_labels.add_argument('process_id', help='Clarity lims process id')
parser_export_labels.add_argument('-d', '--description', nargs='?', help='Container name description')

parser_export_labels.set_defaults(func=export_labels)

parser_export_ped = subparser_export.add_parser('ped', help='Export ped file.', parents=[output_parser])
parser_export_ped.add_argument('process_id', help='Clarity lims process id')
parser_export_ped.set_defaults(func=export_ped_file)

parser_export_workflow = subparser_export.add_parser('workflow', help='Export workflow result file.', parents=[output_parser])
parser_export_workflow.add_argument('type', choices=['lab', 'data_analysis'], help='Workflow type')
parser_export_workflow.add_argument('process_id', help='Clarity lims process id')
parser_export_workflow.set_defaults(func=export_workflow)

Expand All @@ -190,6 +218,9 @@ def placement_barcode(args):
parser_export_illumina.add_argument('artifact_id', help='Clarity lims samplesheet artifact id')
parser_export_illumina.set_defaults(func=export_illumina)

parser_export_samplelist = subparser_export.add_parser('samplelist', help='Export samplelist.', parents=[output_parser])
parser_export_samplelist.set_defaults(func=export_samplelist)

# Sample upload
parser_upload = subparser.add_parser('upload', help='Upload samples or results to clarity lims')
subparser_upload = parser_upload.add_subparsers()
Expand Down Expand Up @@ -244,5 +275,13 @@ def placement_barcode(args):
parser_placement_barcode.add_argument('process_id', help='Clarity lims process id')
parser_placement_barcode.set_defaults(func=placement_barcode)

parser_placement_unpooling = subparser_placement.add_parser('unpooling', help='Unpooling of sequencing pool.')
parser_placement_unpooling.add_argument('process_id', help='Clarity lims process id')
parser_placement_unpooling.set_defaults(func=placement_unpooling)

parser_placement_complete_step = subparser_placement.add_parser('complete_step', help='Complete step Dx Mark protocol complete.')
parser_placement_complete_step.add_argument('process_id', help='Clarity lims process id')
parser_placement_complete_step.set_defaults(func=placement_complete_step)

args = parser.parse_args()
args.func(args)
41 changes: 22 additions & 19 deletions clarity_epp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,29 @@

def get_sequence_name(sample):
"""Generate sequence name."""
# Set fam_status
if sample.udf['Dx Familie status'] == 'Kind':
fam_status = 'C'
elif sample.udf['Dx Familie status'] == 'Ouder':
fam_status = 'P'
try:
# Set fam_status
if sample.udf['Dx Familie status'] == 'Kind':
fam_status = 'C'
elif sample.udf['Dx Familie status'] == 'Ouder':
fam_status = 'P'

# Set sex
if sample.udf['Dx Geslacht'] == 'Man':
sex = 'M'
elif sample.udf['Dx Geslacht'] == 'Vrouw':
sex = 'F'
elif sample.udf['Dx Geslacht'] == 'Onbekend':
sex = 'O'

sequence_name = '{familienummer}{fam_status}{sex}{monsternummer}'.format(
familienummer=sample.udf['Dx Familienummer'],
fam_status=fam_status,
sex=sex,
monsternummer=sample.udf['Dx Monsternummer']
)
# Set sex
if sample.udf['Dx Geslacht'] == 'Man':
sex = 'M'
elif sample.udf['Dx Geslacht'] == 'Vrouw':
sex = 'F'
elif sample.udf['Dx Geslacht'] == 'Onbekend':
sex = 'O'
except KeyError: # None DX sample, use sample.name as sequence name.
sequence_name = sample.name
else:
sequence_name = '{familienummer}{fam_status}{sex}{monsternummer}'.format(
familienummer=sample.udf['Dx Familienummer'],
fam_status=fam_status,
sex=sex,
monsternummer=sample.udf['Dx Monsternummer']
)

return sequence_name

Expand Down
1 change: 1 addition & 0 deletions clarity_epp/export/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import labels
import manual_pipetting
import ped
import samplelist
import tapestation
import tecan
import workflow
142 changes: 88 additions & 54 deletions clarity_epp/export/caliper.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Caliper export functions."""

from genologics.entities import Process
from genologics.entities import Processtype

import utils

Expand All @@ -9,79 +10,112 @@ def samplesheet_normalise(lims, process_id, output_file):
"""Create Caliper samplesheet for normalising 96 well plate."""
output_file.write('Monsternummer\tPlate_Id_input\tWell\tPlate_Id_output\tPipetteervolume DNA (ul)\tPipetteervolume H2O (ul)\n')
process = Process(lims, id=process_id)
parent_process = []
parent_process = process.parent_processes()
parent_process = list(set(parent_process))
for p in parent_process:
if p.type.name == 'Dx Hamilton zuiveren':
parent_process_barcode = p.output_containers()[0].name
output_plate_barcode = process.output_containers()[0].name
monsternummer = {}
conc = {}
conc_measured = {}
volume_DNA = {}
volume_H2O = {}
output_ng = process.udf['Output genormaliseerd gDNA']
output_ul = process.udf['Eindvolume (ul) genormaliseerd gDNA']
parent_processes = []
parent_process_barcode_manual = 'None'
parent_process_barcode_hamilton = 'None'
for p in process.parent_processes():
if 'Dx manueel gezuiverd placement' in p.type.name:
for pp in p.parent_processes():
parent_processes.append(pp)
parent_process_barcode_manual = p.output_containers()[0].name
if 'Dx Hamilton zuiveren' in p.type.name:
parent_processes.append(p)
parent_process_barcode_hamilton = p.output_containers()[0].name
if 'Dx Zuiveren gDNA manueel' in p.type.name:
parent_processes.append(p)
if parent_process_barcode_hamilton != 'None':
parent_process_barcode = parent_process_barcode_hamilton
else:
parent_process_barcode = parent_process_barcode_manual
parent_processes = list(set(parent_processes))
process_types = []
types = []
process_types = lims.get_process_types()
for pt in process_types:
if 'Dx Qubit QC' in pt.name:
types.append(pt.name)
elif 'Dx Tecan Spark 10M QC' in pt.name:
types.append(pt.name)
input_artifact_ids = []
for p in parent_process:
for p in parent_processes:
for analyte in p.all_outputs():
input_artifact_ids.append(analyte.id)
input_artifact_ids = list(set(input_artifact_ids))
qc_processes = lims.get_processes(
type=['Dx Qubit QC', 'Dx Tecan Spark 10M QC'],
type=[types],
inputartifactlimsid=input_artifact_ids
)
qc_processes = list(set(qc_processes))
samples_measurements_qubit = {}
sample_concentration = {}
samples_measurements_tecan = {}
samples_measurements_qubit = {}
filled_wells = []
order = [
'A1', 'B1', 'C1', 'D1', 'E1', 'F1', 'G1', 'H1', 'A2', 'B2', 'C2', 'D2', 'E2', 'F2', 'G2', 'H2', 'A3', 'B3', 'C3', 'D3', 'E3', 'F3', 'G3',
'H3', 'A4', 'B4', 'C4', 'D4', 'E4', 'F4', 'G4', 'H4', 'A5', 'B5', 'C5', 'D5', 'E5', 'F5', 'G5', 'H5', 'A6', 'B6', 'C6', 'D6', 'E6', 'F6',
'G6', 'H6', 'A7', 'B7', 'C7', 'D7', 'E7', 'F7', 'G7', 'H7', 'A8', 'B8', 'C8', 'D8', 'E8', 'F8', 'G8', 'H8', 'A9', 'B9', 'C9', 'D9', 'E9',
'F9', 'G9', 'H9', 'A10', 'B10', 'C10', 'D10', 'E10', 'F10', 'G10', 'H10', 'A11', 'B11', 'C11', 'D11', 'E11', 'F11', 'G11', 'H11', 'A12',
'B12', 'C12', 'D12', 'E12', 'F12', 'G12', 'H12'
'A1', 'B1', 'C1', 'D1', 'E1', 'F1', 'G1', 'H1', 'A2', 'B2', 'C2', 'D2', 'E2', 'F2', 'G2', 'H2',
'A3', 'B3', 'C3', 'D3', 'E3', 'F3', 'G3', 'H3', 'A4', 'B4', 'C4', 'D4', 'E4', 'F4', 'G4', 'H4',
'A5', 'B5', 'C5', 'D5', 'E5', 'F5', 'G5', 'H5', 'A6', 'B6', 'C6', 'D6', 'E6', 'F6', 'G6', 'H6',
'A7', 'B7', 'C7', 'D7', 'E7', 'F7', 'G7', 'H7', 'A8', 'B8', 'C8', 'D8', 'E8', 'F8', 'G8', 'H8',
'A9', 'B9', 'C9', 'D9', 'E9', 'F9', 'G9', 'H9', 'A10', 'B10', 'C10', 'D10', 'E10', 'F10', 'G10', 'H10',
'A11', 'B11', 'C11', 'D11', 'E11', 'F11', 'G11', 'H11', 'A12', 'B12', 'C12', 'D12', 'E12', 'F12', 'G12', 'H12'
]
order = dict(zip(order, range(len(order))))
last_filled_well = 0
x = 0
monsternummer = {}
volume_DNA = {}
volume_H2O = {}
conc_measured = {}
output_ng = process.udf['Output genormaliseerd gDNA']
conc = {}
output_ul = process.udf['Eindvolume (ul) genormaliseerd gDNA']
output_plate_barcode = process.output_containers()[0].name

for p in qc_processes:
for a in p.all_outputs():
if 'Dx Concentratie fluorescentie (ng/ul)' in a.udf:
if 'Tecan' in a.parent_process.type.name:
machine = 'Tecan'
sample = a.samples[0].name
measurement = a.udf['Dx Concentratie fluorescentie (ng/ul)']
qcflag = a.qc_flag
if qcflag == 'UNKNOWN' or 'PASSED':
if sample in samples_measurements_tecan:
samples_measurements_tecan[sample].append(measurement)
else:
samples_measurements_tecan[sample] = [measurement]
if 'Qubit' in a.parent_process.type.name:
machine = 'Qubit'
sample = a.samples[0].name
measurement = a.udf['Dx Concentratie fluorescentie (ng/ul)']
qcflag = a.qc_flag
if qcflag == 'PASSED':
if sample in samples_measurements_qubit:
samples_measurements_qubit[sample].append(measurement)
else:
samples_measurements_qubit[sample] = [measurement]
elif 'Tecan' not in a.name and 'check' not in a.name:
sample = a.samples[0].name
sample_concentration[sample] = 'geen'
if 'Dx Qubit QC' in p.type.name:
for a in p.all_outputs():
if 'Tecan' not in a.name and 'check' not in a.name:
if 'Dx Conc. goedgekeurde meting (ng/ul)' in a.udf:
machine = 'Qubit'
sample = a.samples[0].name
measurement = a.udf['Dx Conc. goedgekeurde meting (ng/ul)']
qcflag = a.qc_flag
if qcflag == 'PASSED':
if sample in samples_measurements_qubit:
samples_measurements_qubit[sample].append(measurement)
else:
samples_measurements_qubit[sample] = [measurement]
else:
sample = a.samples[0].name
if sample not in sample_concentration:
sample_concentration[sample] = 'geen'
elif 'Dx Tecan Spark 10M QC' in p.type.name:
for a in p.all_outputs():
if 'Tecan' not in a.name and 'check' not in a.name:
if 'Dx Conc. goedgekeurde meting (ng/ul)' in a.udf:
machine = 'Tecan'
sample = a.samples[0].name
measurement = a.udf['Dx Conc. goedgekeurde meting (ng/ul)']
qcflag = a.qc_flag
if qcflag == 'UNKNOWN' or 'PASSED':
if sample in samples_measurements_tecan:
samples_measurements_tecan[sample].append(measurement)
else:
samples_measurements_tecan[sample] = [measurement]
else:
sample = a.samples[0].name
if sample not in sample_concentration:
sample_concentration[sample] = 'geen'

for p in qc_processes:
for a in p.all_outputs():
if 'Dx Concentratie fluorescentie (ng/ul)' in a.udf:
if 'Tecan' in a.parent_process.type.name:
machine = 'Tecan'
if 'Qubit' in a.parent_process.type.name:
machine = 'Qubit'
sample = a.samples[0].name
if 'Tecan' not in a.name and 'check' not in a.name:
if 'Dx Tecan Spark 10M QC' in p.type.name:
if 'Dx Conc. goedgekeurde meting (ng/ul)' in a.udf:
machine = 'Tecan'
sample = a.samples[0].name
elif 'Dx Qubit QC' in p.type.name:
if 'Dx Conc. goedgekeurde meting (ng/ul)' in a.udf:
machine = 'Qubit'
sample = a.samples[0].name
if sample not in sample_concentration or machine == 'Qubit':
if machine == 'Tecan':
sample_measurements = samples_measurements_tecan[sample]
Expand Down
Loading

0 comments on commit 9195a7b

Please sign in to comment.