def runChange(self, objId, labelToChange, category): self.experiment = self.readExperiment(self.inputExperiment.get().fnPKPD) currentUnit = self.experiment.getVarUnits(self.labelToChange.get()) newUnit = unitFromString(self._getNewUnit()) K=convertUnits(1.0,currentUnit,newUnit) variable = self.experiment.variables[self.labelToChange.get()] for sampleName, sample in self.experiment.samples.iteritems(): if variable.varName == "dose": pass else: if variable.role == PKPDVariable.ROLE_LABEL: varValue = float(sample.descriptors[variable.varName]) sample.descriptors[variable.varName] = K*varValue elif variable.role == PKPDVariable.ROLE_MEASUREMENT: newValues = [] for x in sample.getValues(variable.varName): if x=="NA" or x=="LLOQ" or x=="ULOQ": newValues.append(x) else: newValues.append(str(K*float(x))) sample.setValues(variable.varName,newValues) elif variable.role == PKPDVariable.ROLE_TIME: newValues = [] for x in sample.getValues(variable.varName): newValues.append(str(K*float(x))) sample.setValues(variable.varName,newValues) variable.units = PKPDUnit() variable.units.unit = newUnit self.writeExperiment(self.experiment,self._getPath("experiment.pkpd"))
def calculateParameterUnits(self,sample): xunits = unitFromString("min") yunits = self.experiment.getVarUnits(self.yName[0]) Vunits = divideUnits(self.Dunits,yunits) Clunits = divideUnits(Vunits,xunits) self.parameterUnits = [Clunits,Vunits,PKPDUnit.UNIT_NONE] return self.parameterUnits
def runChange(self, objId, labelToChange, category): self.experiment = self.readExperiment( self.inputExperiment.get().fnPKPD) currentUnit = self.experiment.getVarUnits(self.labelToChange.get()) newUnit = unitFromString(self._getNewUnit()) K = convertUnits(1.0, currentUnit, newUnit) variable = self.experiment.variables[self.labelToChange.get()] for sampleName, sample in self.experiment.samples.iteritems(): if variable.varName == "dose": pass else: if variable.role == PKPDVariable.ROLE_LABEL: varValue = float(sample.descriptors[variable.varName]) sample.descriptors[variable.varName] = K * varValue elif variable.role == PKPDVariable.ROLE_MEASUREMENT: newValues = [] for x in sample.getValues(variable.varName): if x == "NA" or x == "LLOQ" or x == "ULOQ": newValues.append(x) else: newValues.append(str(K * float(x))) sample.setValues(variable.varName, newValues) elif variable.role == PKPDVariable.ROLE_TIME: newValues = [] for x in sample.getValues(variable.varName): newValues.append(str(K * float(x))) sample.setValues(variable.varName, newValues) variable.units = PKPDUnit() variable.units.unit = newUnit self.writeExperiment(self.experiment, self._getPath("experiment.pkpd"))
def calculateParameterUnits(self,sample): xunits = unitFromString("min") yunits = self.experiment.getVarUnits(self.yName[0]) Vunits = divideUnits(self.Dunits,yunits) Clunits = divideUnits(Vunits,xunits) Vmaxunits = multiplyUnits(Clunits,yunits) self.parameterUnits = [Vmaxunits,yunits,Vunits,Clunits,Vunits,Clunits,Vunits] return self.parameterUnits
def _validate(self): errors=[] experiment = self.readExperiment(self.inputExperiment.get().fnPKPD, False) if not self.labelToChange.get() in experiment.variables: errors.append("Cannot find %s as variable"%self.labelToChange) else: variable = experiment.variables[self.labelToChange.get()] if variable.varType!=PKPDVariable.TYPE_NUMERIC: errors.append("%s is not a numeric variable"%variable.varName) else: currentUnit = experiment.getVarUnits(self.labelToChange.get()) newUnit = unitFromString(self._getNewUnit()) try: K=convertUnits(1,currentUnit,newUnit) if K==None: errors.append("Unknown conversion from %s to %s. If it makes sense and it is not implemented you may contact [email protected]"%\ (strUnit(currentUnit),strUnit(newUnit))) except: errors.append("Unknown conversion from %s to %s. If it makes sense and it is not implemented you may contact [email protected]"%(currentUnit,newUnit)) return errors
def _validate(self): errors = [] experiment = self.readExperiment(self.inputExperiment.get().fnPKPD, False) if not self.labelToChange.get() in experiment.variables: errors.append("Cannot find %s as variable" % self.labelToChange) else: variable = experiment.variables[self.labelToChange.get()] if variable.varType != PKPDVariable.TYPE_NUMERIC: errors.append("%s is not a numeric variable" % variable.varName) else: currentUnit = experiment.getVarUnits(self.labelToChange.get()) newUnit = unitFromString(self._getNewUnit()) try: K = convertUnits(1, currentUnit, newUnit) if K == None: errors.append("Unknown conversion from %s to %s. If it makes sense and it is not implemented you may contact [email protected]"%\ (strUnit(currentUnit),strUnit(newUnit))) except: errors.append( "Unknown conversion from %s to %s. If it makes sense and it is not implemented you may contact [email protected]" % (currentUnit, newUnit)) return errors