def validateStep(self): self.validationErrors.pop(SavePlanFieldNames.NO_BARCODE, None) self.validationErrors.pop(SavePlanFieldNames.BAD_BARCODES, None) samplesTable = json.loads(self.savedFields['samplesTable']) barcodeSet = self.savedFields[SavePlanFieldNames.BARCODE_SET] selectedBarcodes = [] for row in samplesTable: sample_name = row.get(SavePlanFieldNames.SAMPLE_NAME, '').strip() if sample_name: if barcodeSet: selectedBarcodes.append(row.get('barcodeId')) 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", "") self.prepopulatedFields['fireValidation'] = "0"
def validateStep(self): self.validationErrors.pop(SavePlanFieldNames.NO_BARCODE,None) self.validationErrors.pop(SavePlanFieldNames.BAD_BARCODES,None) samplesTable = json.loads(self.savedFields['samplesTable']) barcodeSet = self.savedFields[SavePlanFieldNames.BARCODE_SET] selectedBarcodes = [] for row in samplesTable: sample_name = row.get(SavePlanFieldNames.SAMPLE_NAME,'').strip() if sample_name: if barcodeSet: selectedBarcodes.append(row.get('barcodeId')) 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", "") self.prepopulatedFields['fireValidation'] = "0"
def updateSavedFieldsForSamples(self): #logger.debug("ENTER barcode_by_sample_step_data.updateSavedFieldsForSamples() self.savedFields[SavePlanFieldNames.BARCODE_SET]=%s" %(self.savedFields[SavePlanFieldNames.BARCODE_SET])) if self.savedFields[SavePlanFieldNames.BARCODE_SET]: #convert tuple to string planReference = str( self.prepopulatedFields[SavePlanFieldNames.PLAN_REFERENCE]) planHotSptRegionBedFile = str(self.prepopulatedFields[ SavePlanFieldNames.PLAN_HOTSPOT_REGION_BED_FILE]) planTargetRegionBedFile = str(self.prepopulatedFields[ SavePlanFieldNames.PLAN_TARGET_REGION_BED_FILE]) #logger.debug("barcode_by_sample_step_data.updateSavedFieldsForSamples() type(self.prepopulatedFields[SavePlanFieldNames.PLAN_REFERENCE])=%s; self.prepopulatedFields[SavePlanFieldNames.PLAN_REFERENCE]=%s" %(type(self.prepopulatedFields[SavePlanFieldNames.PLAN_REFERENCE]), self.prepopulatedFields[SavePlanFieldNames.PLAN_REFERENCE])) hasAnyChanges = False myTable = json.loads(self.savedFields['samplesTable']) #convert unicode to str myTable = convert(myTable) for index, row in enumerate(myTable): #logger.debug("barcode_by_sample_step_data.updateSavedFieldsForSamples() B4 CHANGES... BARCODE_SET LOOP row=%s" %(row)) 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, "") sampleHotSpotRegionBedFile = row.get( SavePlanFieldNames. BARCODE_SAMPLE_HOTSPOT_REGION_BED_FILE, "") sampleTargetRegionBedFile = row.get( SavePlanFieldNames. BARCODE_SAMPLE_TARGET_REGION_BED_FILE, "") runType = self.prepopulatedFields[ SavePlanFieldNames.RUN_TYPE] if runType == "AMPS_DNA_RNA" and sample_nucleotideType == "RNA": newSampleReference = sampleReference newSampleHotspotRegionBedFile = sampleHotSpotRegionBedFile newSampleTargetRegionBedFile = sampleTargetRegionBedFile else: newSampleReference = planReference newSampleHotspotRegionBedFile = planHotSptRegionBedFile newSampleTargetRegionBedFile = planTargetRegionBedFile #logger.debug("barcode_by_sample_step_data.updateSavedFieldsForSamples() BARCODE_SET LOOP planReference=%s; type(newSampleReference)=%s; newSampleReference=%s;" %(planReference, type(newSampleReference), newSampleReference)) #cascade the reference and BED file info to sample if none specified at the sample level if runType != "AMPS_DNA_RNA": if not sampleReference: newSampleReference = planReference newSampleHotspotRegionBedFile = planHotSptRegionBedFile newSampleTargetRegionBedFile = planTargetRegionBedFile hasChanged = False if newSampleReference != sampleReference: row[SavePlanFieldNames. BARCODE_SAMPLE_REFERENCE] = newSampleReference hasChanged = True if newSampleHotspotRegionBedFile != sampleHotSpotRegionBedFile: row[SavePlanFieldNames. BARCODE_SAMPLE_HOTSPOT_REGION_BED_FILE] = newSampleHotspotRegionBedFile hasChanged = True if newSampleTargetRegionBedFile != sampleTargetRegionBedFile: row[SavePlanFieldNames. BARCODE_SAMPLE_TARGET_REGION_BED_FILE] = newSampleTargetRegionBedFile hasChanged = True #logger.debug("barcode_by_sample_step_data.updateSavedFieldsForSamples() hasChanged=%s; row=%s" %(hasChanged, row)) if hasChanged: myTable[index] = row #logger.debug("barcode_by_sample_step_data.updateSavedFieldsForSamples() AFTER CHANGES BARCODE_SET LOOP myTable[index]=%s" %(myTable[index])) hasAnyChanges = True if hasAnyChanges: #logger.debug("barcode_by_sample_step_data.updateSavedFieldsForSamples() hasAnyChanges AFTER CHANGES... type=%s; myTable=%s" %(type(myTable), myTable)) #convert list with single quotes to str with double quotes. Then convert it to be unicode self.savedFields['samplesTable'] = unicode(json.dumps(myTable)) #logger.debug("barcode_by_sample_step_data.updateSavedFieldsForSamples() hasAnyChanges AFTER unicode(json.dumps)... type=%s; self.savedFields[samplesTable]=%s" %(type(self.savedFields['samplesTable']), self.savedFields['samplesTable'])) self.savedObjects['samplesTableList'] = json.loads( self.savedFields['samplesTable']) self.updateSavedObjectsFromSavedFields()
def updateSavedFieldsForSamples(self): #logger.debug("ENTER barcode_by_sample_step_data.updateSavedFieldsForSamples() self.savedFields[SavePlanFieldNames.BARCODE_SET]=%s" %(self.savedFields[SavePlanFieldNames.BARCODE_SET])) if self.savedFields[SavePlanFieldNames.BARCODE_SET]: #convert tuple to string planReference = str(self.prepopulatedFields[SavePlanFieldNames.PLAN_REFERENCE]) planHotSptRegionBedFile = str(self.prepopulatedFields[SavePlanFieldNames.PLAN_HOTSPOT_REGION_BED_FILE]) planTargetRegionBedFile = str(self.prepopulatedFields[SavePlanFieldNames.PLAN_TARGET_REGION_BED_FILE]) #logger.debug("barcode_by_sample_step_data.updateSavedFieldsForSamples() type(self.prepopulatedFields[SavePlanFieldNames.PLAN_REFERENCE])=%s; self.prepopulatedFields[SavePlanFieldNames.PLAN_REFERENCE]=%s" %(type(self.prepopulatedFields[SavePlanFieldNames.PLAN_REFERENCE]), self.prepopulatedFields[SavePlanFieldNames.PLAN_REFERENCE])) hasAnyChanges = False myTable = json.loads(self.savedFields['samplesTable']) #convert unicode to str myTable = convert(myTable) for index, row in enumerate(myTable): #logger.debug("barcode_by_sample_step_data.updateSavedFieldsForSamples() B4 CHANGES... BARCODE_SET LOOP row=%s" %(row)) 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, "") sampleHotSpotRegionBedFile = row.get(SavePlanFieldNames.BARCODE_SAMPLE_HOTSPOT_REGION_BED_FILE, "") sampleTargetRegionBedFile = row.get(SavePlanFieldNames.BARCODE_SAMPLE_TARGET_REGION_BED_FILE, "") runType = self.prepopulatedFields[SavePlanFieldNames.RUN_TYPE] if runType == "AMPS_DNA_RNA" and sample_nucleotideType == "RNA": newSampleReference = sampleReference newSampleHotspotRegionBedFile = sampleHotSpotRegionBedFile newSampleTargetRegionBedFile = sampleTargetRegionBedFile else: newSampleReference = planReference newSampleHotspotRegionBedFile = planHotSptRegionBedFile newSampleTargetRegionBedFile = planTargetRegionBedFile #logger.debug("barcode_by_sample_step_data.updateSavedFieldsForSamples() BARCODE_SET LOOP planReference=%s; type(newSampleReference)=%s; newSampleReference=%s;" %(planReference, type(newSampleReference), newSampleReference)) #cascade the reference and BED file info to sample if none specified at the sample level if runType != "AMPS_DNA_RNA": if not sampleReference: newSampleReference = planReference newSampleHotspotRegionBedFile = planHotSptRegionBedFile newSampleTargetRegionBedFile = planTargetRegionBedFile hasChanged = False if newSampleReference != sampleReference: row[SavePlanFieldNames.BARCODE_SAMPLE_REFERENCE] = newSampleReference hasChanged = True if newSampleHotspotRegionBedFile != sampleHotSpotRegionBedFile: row[SavePlanFieldNames.BARCODE_SAMPLE_HOTSPOT_REGION_BED_FILE] = newSampleHotspotRegionBedFile hasChanged = True if newSampleTargetRegionBedFile != sampleTargetRegionBedFile: row[SavePlanFieldNames.BARCODE_SAMPLE_TARGET_REGION_BED_FILE] = newSampleTargetRegionBedFile hasChanged = True #logger.debug("barcode_by_sample_step_data.updateSavedFieldsForSamples() hasChanged=%s; row=%s" %(hasChanged, row)) if hasChanged: myTable[index] = row #logger.debug("barcode_by_sample_step_data.updateSavedFieldsForSamples() AFTER CHANGES BARCODE_SET LOOP myTable[index]=%s" %(myTable[index])) hasAnyChanges = True if hasAnyChanges: #logger.debug("barcode_by_sample_step_data.updateSavedFieldsForSamples() hasAnyChanges AFTER CHANGES... type=%s; myTable=%s" %(type(myTable), myTable)) #convert list with single quotes to str with double quotes. Then convert it to be unicode self.savedFields['samplesTable'] = unicode(json.dumps(myTable)) #logger.debug("barcode_by_sample_step_data.updateSavedFieldsForSamples() hasAnyChanges AFTER unicode(json.dumps)... type=%s; self.savedFields[samplesTable]=%s" %(type(self.savedFields['samplesTable']), self.savedFields['samplesTable'])) self.savedObjects['samplesTableList'] = json.loads(self.savedFields['samplesTable']) self.updateSavedObjectsFromSavedFields()
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_IR_SET_ID] = [] self.validationErrors.pop(SavePlanFieldNames.NO_BARCODE,None) self.validationErrors.pop(SavePlanFieldNames.BAD_BARCODES,None) barcodeSet = self.savedFields[SavePlanFieldNames.BARCODE_SET] selectedBarcodes = [] samplesTable = json.loads(self.savedFields['samplesTable']) #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) if barcodeSet: selectedBarcodes.append(row.get('barcodeId')) 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_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) 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", "")