def delete_prep_template(self, study, user, callback): """Delete the selected prep template Parameters ---------- study : Study The current study object user : User The current user object callback : function The callback function to call with the results once the processing is done """ prep_template_id = int(self.get_argument('prep_template_id')) prep_id = PrepTemplate(prep_template_id).raw_data try: PrepTemplate.delete(prep_template_id) msg = ("Prep template %d has been deleted" % prep_template_id) msg_level = "success" prep_id = None except Exception as e: msg = ("Couldn't remove prep template: %s" % str(e)) msg_level = "danger" callback((msg, msg_level, 'prep_template_tab', prep_id, None))
def delete_prep_template(self, study, user, callback): """Delete the selected prep template Parameters ---------- study : Study The current study object user : User The current user object callback : function The callback function to call with the results once the processing is done """ prep_template_id = int(self.get_argument('prep_template_id')) prep_id = PrepTemplate(prep_template_id).raw_data try: PrepTemplate.delete(prep_template_id) msg = ("Prep template %d has been deleted" % prep_template_id) msg_level = "success" prep_id = None except Exception as e: msg = ("Couldn't remove prep template: %s" % str(e)) msg_level = "danger" callback((msg, msg_level, 'raw_data_tab', prep_id, None))
def remove_add_study_template(self, raw_data, study_id, fp_rsp): """Replace prep templates, raw data, and sample template with a new one """ for rd in raw_data(): rd = RawData(rd) for pt in rd.prep_templates: if PrepTemplate.exists(pt): PrepTemplate.delete(pt) if SampleTemplate.exists(study_id): SampleTemplate.delete(study_id) SampleTemplate.create(load_template_to_dataframe(fp_rsp), Study(study_id)) remove(fp_rsp)
def remove_add_study_template(self, raw_data, study_id, fp_rsp): """Replace prep templates, raw data, and sample template with a new one """ for rd in raw_data(): rd = RawData(rd) for pt in rd.prep_templates: if PrepTemplate.exists(pt): PrepTemplate.delete(pt) if SampleTemplate.exists(study_id): SampleTemplate.delete(study_id) SampleTemplate.create(load_template_to_dataframe(fp_rsp), Study(study_id)) remove(fp_rsp)
def remove_add_study_template(self, raw_data, study_id, fp_rsp, data_type, is_mapping_file): """Replace prep templates, raw data, and sample template with a new one """ if is_mapping_file and data_type == "": raise ValueError("Please, choose a data type if uploading a QIIME " "mapping file") for rd in raw_data(): rd = RawData(rd) for pt in rd.prep_templates: if PrepTemplate.exists(pt): PrepTemplate.delete(pt) if SampleTemplate.exists(study_id): SampleTemplate.delete(study_id) if is_mapping_file: create_templates_from_qiime_mapping_file(fp_rsp, Study(study_id), int(data_type)) else: SampleTemplate.create(load_template_to_dataframe(fp_rsp), Study(study_id)) remove(fp_rsp)