def validateField(self, field_name, new_field_value): self.validationErrors.pop(field_name, None) errors = None if field_name == SavePlanFieldNames.CHIP_BARCODE_LABEL: errors = validate_chipBarcode(new_field_value) if errors: self.validationErrors[field_name] = '\n'.join(errors) if field_name == SavePlanFieldNames.BARCODE_SAMPLE_TUBE_LABEL: errors = validate_sample_tube_label(new_field_value) if errors: self.validationErrors[field_name] = '\n'.join(errors) # if the plan has been sequenced, do not enforce the target bed file to be selected planStatus = self.getDefaultSectionPrepopulatedFieldDict().get("planStatus", "") if field_name == SavePlanFieldNames.SAMPLES_TABLE: sample_table_list = json.loads(new_field_value) samples_errors = [] applProduct = self.savedObjects[SavePlanFieldNames.APPL_PRODUCT] # applProduct object is not saved yet if applProduct: isTargetRegionSelectionRequired = applProduct.isTargetRegionBEDFileSelectionRequiredForRefSelection else: isTargetRegionSelectionRequired = False applicationGroupName = self.prepopulatedFields[SavePlanFieldNames.APPLICATION_GROUP_NAME] for row in sample_table_list: sample_name = row.get(SavePlanFieldNames.SAMPLE_NAME, '').strip() if sample_name: sample_nucleotideType = row.get(SavePlanFieldNames.BARCODE_SAMPLE_NUCLEOTIDE_TYPE, "") sampleReference = row.get(SavePlanFieldNames.BARCODE_SAMPLE_REFERENCE, "") sampleTargetRegionBedFile = row.get(SavePlanFieldNames.BARCODE_SAMPLE_TARGET_REGION_BED_FILE, "") runType = self.prepopulatedFields[SavePlanFieldNames.RUN_TYPE] logger.debug("barcode_by_sample_step_data.validateField()() runType=%s; sample_nucleotideType=%s; sampleReference=%s; sampleTargetRegionBedFile=%s" % (runType, sample_nucleotideType, sampleReference, sampleTargetRegionBedFile)) errors = [] # if the plan has been sequenced, do not enforce the target bed file to be selected if planStatus != "run": errors = validate_targetRegionBedFile_for_runType(sampleTargetRegionBedFile, runType, sampleReference, sample_nucleotideType, applicationGroupName, "Target Regions BED File for " + sample_name) if errors: samples_errors.append('\n'.join(errors)) if samples_errors: logger.debug("barcode_by_sample_step_data.validateField()() samples_errors=%s" % (samples_errors)) self.validationErrors[field_name] = '\n'.join(samples_errors)
def validateStep(self): any_samples = False self.validationErrors[SavePlanFieldNames.BAD_SAMPLE_NAME] = [] self.validationErrors[SavePlanFieldNames.BAD_SAMPLE_EXTERNAL_ID] = [] self.validationErrors[SavePlanFieldNames.BAD_SAMPLE_DESCRIPTION] = [] self.validationErrors[SavePlanFieldNames.BAD_TUBE_LABEL] = [] self.validationErrors[SavePlanFieldNames.BAD_CHIP_BARCODE] = [] self.validationErrors[SavePlanFieldNames.BAD_IR_SET_ID] = [] self.validationErrors.pop(SavePlanFieldNames.NO_BARCODE, None) self.validationErrors.pop(SavePlanFieldNames.BAD_BARCODES, None) barcodeSet = self.savedFields[SavePlanFieldNames.BARCODE_SET] selectedBarcodes = [] endBarcodeSet = self.savedFields[SavePlanFieldNames.END_BARCODE_SET] selectedEndBarcodes = [] samplesTable = json.loads(self.savedFields[SavePlanFieldNames.SAMPLES_TABLE]) # logger.debug("save_plan_step_data - anySamples? samplesTable=%s" %(samplesTable)) for row in samplesTable: sample_name = row.get(SavePlanFieldNames.SAMPLE_NAME, '').strip() # logger.debug("save_plan_step_data - anySamples? sampleName=%s" %(sample_name)) if sample_name: any_samples = True if validate_sample_name(sample_name): self.validationErrors[SavePlanFieldNames.BAD_SAMPLE_NAME].append(sample_name) external_id = row.get(SavePlanFieldNames.SAMPLE_EXTERNAL_ID, '') if external_id: self.validate_field(external_id, self.validationErrors[SavePlanFieldNames.BAD_SAMPLE_EXTERNAL_ID]) description = row.get(SavePlanFieldNames.SAMPLE_DESCRIPTION, '') if description: self.validate_field(description, self.validationErrors[SavePlanFieldNames.BAD_SAMPLE_DESCRIPTION], False, MAX_LENGTH_SAMPLE_DESCRIPTION) ir_set_id = row.get('irSetId', '') if ir_set_id and not (str(ir_set_id).isdigit()): self.validationErrors[SavePlanFieldNames.BAD_IR_SET_ID].append(ir_set_id) tube_label = row.get('tubeLabel', '') if validate_sample_tube_label(tube_label): self.validationErrors[SavePlanFieldNames.BAD_TUBE_LABEL].append(tube_label) chip_barcode = row.get('chipBarcode', '') if validate_chipBarcode(chip_barcode): self.validationErrors[SavePlanFieldNames.BAD_CHIP_BARCODE].append(chip_barcode) if barcodeSet: selectedBarcodes.append(row.get(SavePlanFieldNames.BARCODE_SAMPLE_BARCODE_ID_UI_KEY)) if endBarcodeSet: endBarcode_id_value = row.get(SavePlanFieldNames.BARCODE_SAMPLE_END_BARCODE_ID_UI_KEY) if endBarcode_id_value: selectedEndBarcodes.append(endBarcode_id_value) if any_samples: self.validationErrors.pop(SavePlanFieldNames.NO_SAMPLES, None) else: self.validationErrors[SavePlanFieldNames.NO_SAMPLES] = "You must enter at least one sample" if not self.validationErrors[SavePlanFieldNames.BAD_SAMPLE_NAME]: self.validationErrors.pop(SavePlanFieldNames.BAD_SAMPLE_NAME, None) if not self.validationErrors[SavePlanFieldNames.BAD_TUBE_LABEL]: self.validationErrors.pop(SavePlanFieldNames.BAD_TUBE_LABEL, None) if not self.validationErrors[SavePlanFieldNames.BAD_CHIP_BARCODE]: self.validationErrors.pop(SavePlanFieldNames.BAD_CHIP_BARCODE, None) if not self.validationErrors[SavePlanFieldNames.BAD_SAMPLE_EXTERNAL_ID]: self.validationErrors.pop(SavePlanFieldNames.BAD_SAMPLE_EXTERNAL_ID, None) if not self.validationErrors[SavePlanFieldNames.BAD_SAMPLE_DESCRIPTION]: self.validationErrors.pop(SavePlanFieldNames.BAD_SAMPLE_DESCRIPTION, None) if not self.validationErrors[SavePlanFieldNames.BAD_IR_SET_ID]: self.validationErrors.pop(SavePlanFieldNames.BAD_IR_SET_ID, None) #20170928-TODO-WIP if barcodeSet: errors = validate_barcode_sample_association(selectedBarcodes, barcodeSet) myErrors = convert(errors) if myErrors.get("MISSING_BARCODE", ""): self.validationErrors[SavePlanFieldNames.NO_BARCODE] = myErrors.get("MISSING_BARCODE", "") if myErrors.get("DUPLICATE_BARCODE", ""): self.validationErrors[SavePlanFieldNames.BAD_BARCODES] = myErrors.get("DUPLICATE_BARCODE", "") if selectedEndBarcodes: applProduct = self.savedObjects[SavePlanFieldNames.APPL_PRODUCT] if applProduct and applProduct.dualBarcodingRule == "no_reuse": errors = validate_barcode_sample_association(selectedEndBarcodes, endBarcodeSet, isEndBarcodeExists = True) myErrors = convert(errors) if myErrors.get("DUPLICATE_BARCODE", ""): self.validationErrors[SavePlanFieldNames.BAD_BARCODES] = myErrors.get("DUPLICATE_BARCODE", "")
def validateField(self, field_name, new_field_value): self.validationErrors.pop(field_name, None) # if the plan has been sequenced, do not enforce the target bed file to be selected planStatus = self.getDefaultSectionPrepopulatedFieldDict().get("planStatus", "") if field_name == SavePlanFieldNames.PLAN_NAME: errors = validate_plan_name(new_field_value, 'Plan Name') if errors: self.validationErrors[field_name] = '\n'.join(errors) elif field_name == SavePlanFieldNames.NOTE: errors = validate_notes(new_field_value) if errors: self.validationErrors[field_name] = '\n'.join(errors) elif field_name == SavePlanFieldNames.BARCODE_SAMPLE_TUBE_LABEL: errors = validate_sample_tube_label(new_field_value) if errors: self.validationErrors[field_name] = '\n'.join(errors) elif field_name == SavePlanFieldNames.CHIP_BARCODE_LABEL: errors = validate_chipBarcode(new_field_value) if errors: self.validationErrors[field_name] = '\n'.join(errors) elif field_name in self.qcNames: ''' All qc thresholds must be positive integers ''' errors = validate_QC(new_field_value, field_name) if errors: self.validationErrors[field_name] = errors[0] else: self.validationErrors.pop(field_name, None) elif field_name == SavePlanFieldNames.SAMPLES_TABLE: sample_table_list = json.loads(new_field_value) samples_errors = [] applProduct = self.savedObjects[SavePlanFieldNames.APPL_PRODUCT] # applProduct object is not saved yet if applProduct: isTargetRegionSelectionRequired = applProduct.isTargetRegionBEDFileSelectionRequiredForRefSelection else: isTargetRegionSelectionRequired = False applicationGroupName = self.prepopulatedFields[SavePlanFieldNames.APPLICATION_GROUP_NAME] for row in sample_table_list: sample_name = row.get(SavePlanFieldNames.SAMPLE_NAME, '').strip() if sample_name: sample_nucleotideType = row.get(SavePlanFieldNames.BARCODE_SAMPLE_NUCLEOTIDE_TYPE, "") sampleReference = row.get(SavePlanFieldNames.BARCODE_SAMPLE_REFERENCE, "") sampleTargetRegionBedFile = row.get(SavePlanFieldNames.BARCODE_SAMPLE_TARGET_REGION_BED_FILE, "") runType = self.prepopulatedFields[SavePlanFieldNames.RUN_TYPE] errors = [] # if the plan has been sequenced, do not enforce the target bed file to be selected isMainBEDFileValidated = "default_targetBedFile" in self.validationErrors if not isMainBEDFileValidated and planStatus != "run" and (self.sh_type not in StepHelperType.TEMPLATE_TYPES): errors = validate_targetRegionBedFile_for_runType(sampleTargetRegionBedFile, runType, sampleReference, sample_nucleotideType, applicationGroupName, "Target Regions BED File for " + sample_name) if errors: samples_errors.append('\n'.join(errors)) if samples_errors: self.validationErrors[field_name] = '\n'.join(samples_errors)