def get(self): plate_ids = self.get_arguments('plate_id') process_id = self.get_argument('process_id', None) gdna_plate = None epmotion = None epmotion_tm300 = None epmotion_tm50 = None primer_plate = None master_mix = None water_lot = None volume = None prep_date = None if process_id is not None: try: process = LibraryPrep16SProcess(process_id) except LabControlUnknownIdError: raise HTTPError(404, reason="Amplicon process %s doesn't exist" % process_id) gdna_plate = process.gdna_plate.id epmotion = process.epmotion.id epmotion_tm300 = process.epmotion_tm300_tool.id epmotion_tm50 = process.epmotion_tm50_tool.id master_mix = process.mastermix.external_lot_id water_lot = process.water_lot.external_lot_id primer_plate = process.primer_plate.id volume = process.volume prep_date = process.date.strftime(process.get_date_format()) robots = Equipment.list_equipment('EpMotion') tools_tm300_8 = Equipment.list_equipment( 'tm 300 8 channel pipette head') tools_tm50_8 = Equipment.list_equipment('tm 50 8 channel pipette head') primer_plates = [] for pp in Plate.list_plates(['primer']): plate = Plate(pp['plate_id']) if plate.process.primer_set.target_name == 'Amplicon': primer_plates.append(pp) self.render('library_prep_16S.html', plate_ids=plate_ids, robots=robots, tools_tm300_8=tools_tm300_8, tools_tm50_8=tools_tm50_8, primer_plates=primer_plates, process_id=process_id, gdna_plate=gdna_plate, epmotion=epmotion, epmotion_tm300=epmotion_tm300, epmotion_tm50=epmotion_tm50, master_mix=master_mix, water_lot=water_lot, primer_plate=primer_plate, preparationDate=prep_date, volume=volume)
def get(self): plate_ids = self.get_arguments('plate_id') process_id = self.get_argument('process_id', None) input_plate = None pool_func_data = None pool_values = [] pool_blanks = [] plate_names = [] plate_type = None if process_id is not None: try: process = PoolingProcess(process_id) except LabControlUnknownIdError: raise HTTPError(404, reason="Pooling process %s doesn't exist" % process_id) plate = process.components[0][0].container.plate input_plate = plate.id pool_func_data = process.pooling_function_data _, pool_values, pool_blanks, plate_names = \ make_2D_arrays(plate, process.quantification_process) pool_values = pool_values.tolist() pool_blanks = pool_blanks.tolist() plate_names = plate_names.tolist() elif len(plate_ids) > 0: content_types = { type(Plate(pid).get_well(1, 1).composition) for pid in plate_ids } if len(content_types) > 1: raise HTTPError(400, reason='Plates contain different types ' 'of compositions') plate_type = ('16S library prep' if content_types.pop() == LibraryPrep16SComposition else 'shotgun library prep') robots = (Equipment.list_equipment('EpMotion') + Equipment.list_equipment('echo')) self.render('library_pooling.html', plate_ids=plate_ids, robots=robots, pool_params=HTML_POOL_PARAMS, input_plate=input_plate, pool_func_data=pool_func_data, process_id=process_id, pool_values=pool_values, plate_type=plate_type, pool_blanks=pool_blanks, plate_names=plate_names)
def get(self): plate_ids = self.get_arguments('plate_id') process_id = self.get_argument('process_id', None) kingfisher = None epmotion = None epmotion_tool = None extraction_kit = None sample_plate = None externally_extracted = False volume = None ext_date = None notes = None if process_id is not None: try: process = GDNAExtractionProcess(process_id) except LabControlUnknownIdError: raise HTTPError(404, reason="Extraction process %s doesn't exist" % process_id) kingfisher = process.kingfisher.id epmotion = process.epmotion.id epmotion_tool = process.epmotion_tool.id extraction_kit = process.extraction_kit.external_lot_id sample_plate = process.sample_plate.id externally_extracted = process.externally_extracted volume = process.volume ext_date = process.date.strftime(process.get_date_format()) notes = process.notes ep_robots = Equipment.list_equipment('EpMotion') kf_robots = Equipment.list_equipment('King Fisher') tools = Equipment.list_equipment('tm 1000 8 channel pipette head') self.render('extraction.html', plate_ids=plate_ids, kf_robots=kf_robots, ep_robots=ep_robots, tools=tools, process_id=process_id, kingfisher=kingfisher, epmotion=epmotion, epmotion_tool=epmotion_tool, extraction_kit=extraction_kit, sample_plate=sample_plate, externally_extracted=externally_extracted, volume=volume, extraction_date=ext_date, notes=notes)
def get(self, allowed_pools_type): sequencers = [] allowed_pools_name = allowed_pools_type.split("_")[0].title() for model, lanes in SequencingProcess.sequencer_lanes.items(): for sequencer in Equipment.list_equipment(model): sequencer['lanes'] = lanes sequencers.append(sequencer) self.render('sequencing.html', users=User.list_users(), sequencers=sequencers, allowed_pools_type=allowed_pools_type, allowed_pools_name=allowed_pools_name)
def post(self): plates_info = self.get_argument('plates_info') extraction_date = self.get_argument('extraction_date') volume = self.get_argument('volume') month, day, year = map(int, extraction_date.split('/')) extraction_date = date(year, month, day) # We create one process per plate processes = [] for pid, ee, kf, ep, ept, kit, p_name, nt in json_decode(plates_info): # Check whether plate was externally extracted if ee is True: # find the id of null things eq_no = \ Equipment.list_equipment('Not applicable')[0]['equipment_id'] ep = ept = kf = Equipment(eq_no) kit = ReagentComposition.from_external_id('Not applicable') else: kf = Equipment(kf) ep = Equipment(ep) ept = Equipment(ept) kit = ReagentComposition.from_external_id(kit) processes.append( GDNAExtractionProcess.create(self.current_user, Plate(pid), kf, ep, ept, kit, volume, p_name, externally_extracted=ee, extraction_date=extraction_date, notes=nt).id) self.write({'processes': processes})
def get(self): plate_ids = self.get_arguments('plate_id') process_id = self.get_argument('process_id', None) plate_name = None robot = None gdna_plates = [] if process_id is not None: try: process = GDNAPlateCompressionProcess(process_id) except LabControlUnknownIdError: raise HTTPError(404, reason="Compression process %s doesn't " "exist" % process_id) plate_name = process.plates[0].external_id robot = process.robot.id gdna_plates = [p.id for p in process.gdna_plates] robots = Equipment.list_equipment('EpMotion') self.render('compression.html', plate_ids=plate_ids, robots=robots, plate_name=plate_name, robot=robot, gdna_plates=gdna_plates, process_id=process_id)
def get(self): pool_type = 'shotgun_plate' plate_ids = self.get_arguments('plate_id') process_id = self.get_argument('process_id', None) input_plate = None pool_func_data = None pool_values = [] pool_blanks = [] plate_names = [] if process_id is not None: try: process = PoolingProcess(process_id) except LabControlUnknownIdError: raise HTTPError(404, reason="Pooling process %s doesn't exist" % process_id) plate = process.components[0][0].container.plate input_plate = plate.id pool_func_data = process.pooling_function_data content_type = type(plate.get_well(1, 1).composition) id_plate_type = PLATE_TYPES[content_type] plate_type_mapped = PLATE_TYPE_TO_POOL_TYPE[id_plate_type] if plate_type_mapped != pool_type: raise HTTPError(400, reason='Pooling process type does not ' 'match pooling type') _, pool_values, pool_blanks, plate_names = \ make_2D_arrays(plate, process.quantification_process) pool_values = pool_values.tolist() pool_blanks = pool_blanks.tolist() plate_names = plate_names.tolist() elif len(plate_ids) > 0: content_types = {type(Plate(pid).get_well(1, 1).composition) for pid in plate_ids} if len(content_types) > 1: raise HTTPError(400, reason='Plates contain different types ' 'of compositions') # check if the observed plates are the same type as the pooling # type (i.e., no shotgun plates for 16S pooling) content_type = content_types.pop() id_plate_type = PLATE_TYPES[content_type] plate_type_mapped = PLATE_TYPE_TO_POOL_TYPE[id_plate_type] if plate_type_mapped != pool_type: raise HTTPError(400, reason='Plate type does not match ' 'pooling type') pool_type_stripped = POOL_TYPE_PARAMS[pool_type]['abbreviation'] plate_type = POOL_TYPE_TO_PLATE_TYPE[pool_type] robots = (Equipment.list_equipment('EpMotion') + Equipment.list_equipment('echo')) template = POOL_TYPE_PARAMS[pool_type]['template'] self.render(template, plate_ids=plate_ids, robots=robots, pool_params=HTML_POOL_PARAMS, input_plate=input_plate, pool_func_data=pool_func_data, process_id=process_id, pool_values=pool_values, plate_type=plate_type, pool_blanks=pool_blanks, plate_names=plate_names, pool_type=pool_type_stripped)
def test_list_equipment(self): obs = Equipment.list_equipment() exp = [{ 'equipment_id': 15, 'external_id': '108379Z' }, { 'equipment_id': 16, 'external_id': '109375A' }, { 'equipment_id': 17, 'external_id': '311411B' }, { 'equipment_id': 2, 'external_id': 'BUZZ' }, { 'equipment_id': 10, 'external_id': 'Carmen' }, { 'equipment_id': 1, 'external_id': 'Echo550' }, { 'equipment_id': 9, 'external_id': 'HOWE' }, { 'equipment_id': 19, 'external_id': 'IGM-HiSeq4000' }, { 'equipment_id': 8, 'external_id': 'JER-E' }, { 'equipment_id': 11, 'external_id': 'KF1' }, { 'equipment_id': 12, 'external_id': 'KF2' }, { 'equipment_id': 13, 'external_id': 'KF3' }, { 'equipment_id': 14, 'external_id': 'KF4' }, { 'equipment_id': 18, 'external_id': 'KL-MiSeq' }, { 'equipment_id': 5, 'external_id': 'LUCY' }, { 'equipment_id': 20, 'external_id': 'Not applicable' }, { 'equipment_id': 4, 'external_id': 'PRICKLY' }, { 'equipment_id': 7, 'external_id': 'RIK-E' }, { 'equipment_id': 6, 'external_id': 'ROB-E' }] self.assertEqual(obs[:-1], exp) obs = Equipment.list_equipment('echo') exp = [{'equipment_id': 1, 'external_id': 'Echo550'}] self.assertEqual(obs, exp) obs = Equipment.list_equipment('mosquito') exp = [{ 'equipment_id': 2, 'external_id': 'BUZZ' }, { 'equipment_id': 4, 'external_id': 'PRICKLY' }, { 'equipment_id': 3, 'external_id': 'STINGER' }] self.assertEqual(obs, exp)