def make_default_setup(date, plan, project=None): if not project: project = get_validation_project() plan_name = plan.get('name', None) or plate_layouts[plan['plate_layout']][1] plate_setup = PlateSetup(project_id=project.id, name=plan_name) plate_setup.locked = False plate_setup.completed = False if type(plan['execution_order']) == type([]): execution_order = plan['execution_order'] else: execution_order = execution_orders[plan['execution_order']] # TODO add status steps setup = dict(consumable=consumable_layouts[plan['consumable']], execution_order=execution_order, plate_layout=plate_layouts[plan['plate_layout']], progress=progress(num_readers=len(execution_order))) plate_setup.time_updated = datetime.now() plate_setup.author_id = plan['operator'].id plate_setup.setup = json.dumps(setup) plate_setup.dr_oil = 22 plate_setup.dg_oil = 14 plate_setup.master_mix = 12 plate_setup.droplet_generation_method = 201 plate_setup.thermal_cycler_id = plan.get('thermal_cycler', None) plate_setup.prefix = make_setup_name(plate_setup) return plate_setup
def __update_groove_record(self, record=None): new_record = False errors = {} if not record: new_record = True plate_type = Session.query(PlateType).get(self.form_result["plate_type"]) person = Session.query(Person).get(self.form_result["droplet_maker"]) if self.form_result["droplet_generator"]: dg = Session.query(DropletGenerator).get(self.form_result["droplet_generator"]) else: dg = None if not plate_type: errors["plate_type"] = "Unknown plate type." else: qlt_paths = self.__get_layout_qlts(plate_type, self.form_result["runs"]) if not qlt_paths: errors["runs"] = "Invalid layout for this plate type." else: # create the name setup = [] for i, path in enumerate(qlt_paths): name = self.__name_for_groove_plate( plate_type, self.form_result["droplet_type"], person, self.form_result["creation_date"], self.form_result["identifier"], i, ) setup.append((name, path)) plate_setup = PlateSetup( name=name[:-2], prefix=name[:-2], setup=json.dumps(setup), time_updated=self.form_result["creation_date"], project_id=Session.query(Project).filter_by(name="GrooveTest").first().id, author_id=person.id, droplet_maker_id=person.id, dr_oil=22, plate_type_id=plate_type.id, droplet_generator_id=dg.id if dg else None, notes=self.form_result["notes"], ) dt = self.form_result["droplet_type"] if dt == 1: # TODO LITERALS plate_setup.skin_type = Plate.SKIN_TYPE_SKINNED plate_setup.dg_oil = 14 plate_setup.master_mix = 12 else: plate_setup.skin_type = Plate.SKIN_TYPE_SKINLESS plate_setup.dg_oil = 31 if dt == 2: plate_setup.chemistry_type = Plate.CHEMISTRY_TYPE_GREEN plate_setup.master_mix = 205 else: plate_setup.chemistry_type = Plate.CHEMISTRY_TYPE_TAQMAN if dt == 3: plate_setup.master_mix = 501 Session.add(plate_setup) Session.commit() return plate_setup, None else: record.notes = self.form_result["notes"] record.droplet_generator_id = self.form_result["droplet_generator"] Session.commit() return record, None if errors: return None, errors