def calculateRTI(self, autorg, scatterfile): if scatterfile is not None and\ autorg.rg and autorg.rgStdev and autorg.i0.value > 0 and autorg.i0Stdev: #self.screen("Trying to calculate RTI") dictRTI = RamboTainerInvariant(numpy.loadtxt(scatterfile), autorg.rg.value, autorg.rgStdev.value, autorg.i0.value, autorg.i0Stdev.value, autorg.firstPointUsed.value) Vc = dictRTI.get("Vc") Vc_Stdev = dictRTI.get("dVc") Qr = dictRTI.get("Qr") Qr_Stdev = dictRTI.get("dQ") mass = dictRTI.get("mass") mass_Stdev = dictRTI.get("dmass") else: Vc = Vc_Stdev = Qr = Qr_Stdev = mass = mass_Stdev = 0.0 xsdRTI = XSDataRamboTainer(vc=XSDataDouble(Vc), qr=XSDataDouble(Qr), mass=XSDataDouble(mass), dvc=XSDataDouble(Vc_Stdev), dqr=XSDataDouble(Qr_Stdev), dmass=XSDataDouble(mass_Stdev)) self.rti = xsdRTI
def doSuccessAutoRg(self, _edPlugin=None): self.DEBUG("EDPluginBioSaxsHPLCv1_2.doSuccessAutoRg") self.retrieveSuccessMessages( _edPlugin, "EDPluginBioSaxsHPLCv1_2.doSuccessAutoRg") if _edPlugin and _edPlugin.dataOutput and _edPlugin.dataOutput.status and _edPlugin.dataOutput.status.executiveSummary: self.lstExecutiveSummary.append( _edPlugin.dataOutput.status.executiveSummary.value) try: rg = _edPlugin.dataOutput.autoRgOut[0] except: self.ERROR("AutoRg returned nothing !") else: if rg.rg: self.frame.Rg = rg.rg.value if rg.rgStdev: self.frame.Rg_Stdev = rg.rgStdev.value if rg.i0: self.frame.I0 = rg.i0.value if rg.i0Stdev: self.frame.I0_Stdev = rg.i0Stdev.value if rg.quality: self.frame.quality = rg.quality.value self.xsDataResult.autoRg = rg """ Calculate the invariants Vc and Qr from the Rambo&Tainer 2013 Paper, also the the mass estimate based on Qr for proteins """ if self.subtracted and os.path.exists(self.subtracted): self.subtracted_data = numpy.loadtxt(self.subtracted) if self.subtracted_data is not None and\ self.frame.Rg and self.frame.Rg_Stdev and self.frame.I0 and self.frame.I0_Stdev: dictRTI = RamboTainerInvariant(self.subtracted_data, self.frame.Rg, self.frame.Rg_Stdev, self.frame.I0, self.frame.I0_Stdev, rg.firstPointUsed.value) # {'Vc': vc[0], 'dVc': vc[1], 'Qr': qr, 'dQr': dqr, 'mass': mass, 'dmass': dmass} self.frame.Vc = dictRTI.get("Vc") self.frame.Vc_Stdev = dictRTI.get("dVc") self.frame.Qr = dictRTI.get("Qr") self.frame.Qr_Stdev = dictRTI.get("dQ") self.frame.mass = dictRTI.get("mass") self.frame.mass_Stdev = dictRTI.get("dmass") xsdRTI = XSDataRamboTainer( vc=XSDataDouble(self.frame.Vc), qr=XSDataDouble(self.frame.Qr), mass=XSDataDouble(self.frame.mass), dvc=XSDataDouble(self.frame.Vc_Stdev), dqr=XSDataDouble(self.frame.Qr_Stdev), dmass=XSDataDouble(self.frame.mass_Stdev)) self.xsDataResult.rti = xsdRTI
def process(self, _edObject=None): EDPluginControl.process(self) self.DEBUG("EDPluginBioSaxsHPLCv1_5.process") xsdIn = XSDataInputBioSaxsProcessOneFilev1_0(rawImage=self.dataInput.rawImage, sample=self.dataInput.sample, experimentSetup=self.dataInput.experimentSetup, rawImageSize=self.dataInput.rawImageSize, normalizedImage=self.dataInput.normalizedImage, integratedCurve=self.dataInput.integratedCurve, runId=self.dataInput.runId, frameId=self.dataInput.frameId) self.edPluginProcessOneFile = self.loadPlugin(self.strControlledPluginProcessOneFile) self.edPluginProcessOneFile.dataInput = xsdIn self.edPluginProcessOneFile.connectSUCCESS(self.doSuccessProcessOneFile) self.edPluginProcessOneFile.connectFAILURE(self.doFailureProcessOneFile) self.edPluginProcessOneFile.executeSynchronous() if self.isFailure(): return if self.hplc_run.first_curve == self.curve: return # xsdIn = XSDataInputDatcmp(inputCurve=[XSDataFile(XSDataString(self.hplc_run.first_curve)), # XSDataFile(XSDataString(self.curve))]) # self.edPluginDatCmp = self.loadPlugin(self.strControlledPluginDatCmp) # self.edPluginDatCmp.dataInput = xsdIn # self.edPluginDatCmp.connectSUCCESS(self.doSuccessDatCmp) # self.edPluginDatCmp.connectFAILURE(self.doFailureDatCmp) # self.edPluginDatCmp.executeSynchronous() self.datcmp(self.hplc_run.firstCurveIntensity, self.intensity) if self.isFailure() or self.isBuffer: return ####################### # # DatOp subtraction ## ####################### if self.dataInput.subtractedCurve is not None: self.subtracted = self.dataInput.subtractedCurve.path.value else: self.subtracted = os.path.splitext(self.curve)[0] + "_sub.dat" Isub = self.intensity - self.hplc_run.buffer_I StdErr = numpy.sqrt(self.stdError * self.stdError + \ self.hplc_run.buffer_Stdev * self.hplc_run.buffer_Stdev) self.SAXSdata= numpy.vstack((self.hplc_run.q, Isub, StdErr)).T with open(self.subtracted, "w") as outfile: #print "Writing file" numpy.savetxt(outfile, self.SAXSdata) self.xsDataResult.subtractedCurve = XSDataFile(XSDataString(self.subtracted)) self.frame.subtracted = self.subtracted if self.subtracted and os.path.exists(self.subtracted) and self.ATSASRg: self.edPluginAutoRg = self.loadPlugin(self.strControlledPluginAutoRg) self.edPluginAutoRg.dataInput = XSDataInputAutoRg(inputCurve=[XSDataFile(XSDataString(self.subtracted))]) self.edPluginAutoRg.connectSUCCESS(self.doSuccessAutoRg) self.edPluginAutoRg.connectFAILURE(self.doFailureAutoRg) self.edPluginAutoRg.executeSynchronous() try: #print self.subtracted, autoRg(self.SAXSdata) rg_result = autoRg(self.SAXSdata) self.frame.RgF, self.frame.Rg_StdevF, self.frame.I0F, self.frame.I0_StdevF, self.frame.Rg_imin, self.frame.Rg_imax = rg_result[:6] except InsufficientDataError: print "Not enough usable data to run autorg" except SystemError as SE: print "System Error" print SE except Exception as Err: print Err raise else: if self.ATSASRg == False: self.frame.Rg = max(0,self.frame.RgF) self.frame.Rg_Stdev = max(0,self.frame.Rg_StdevF) self.frame.I0 = max(0,self.frame.I0F) self.frame.I0_Stdev = max(0,self.frame.I0_StdevF) self.frame.quality = 0 """ Calculate the invariants Vc and Qr from the Rambo&Tainer 2013 Paper, also the the mass estimate based on Qr for proteins """ if self.subtracted and os.path.exists(self.subtracted): self.subtracted_data = numpy.loadtxt(self.subtracted) if self.subtracted_data is not None and\ self.frame.RgF and self.frame.Rg_StdevF and self.frame.I0F and self.frame.I0_StdevF: dictRTI = RamboTainerInvariant(self.subtracted_data, self.frame.RgF, self.frame.Rg_StdevF, self.frame.I0F, self.frame.I0_StdevF, self.frame.Rg_imin) # {'Vc': vc[0], 'dVc': vc[1], 'Qr': qr, 'dQr': dqr, 'mass': mass, 'dmass': dmass} self.frame.Vc = dictRTI.get("Vc") self.frame.Vc_Stdev = dictRTI.get("dVc") self.frame.Qr = dictRTI.get("Qr") self.frame.Qr_Stdev = dictRTI.get("dQ") self.frame.mass = dictRTI.get("mass") self.frame.mass_Stdev = dictRTI.get("dmass") xsdRTI = XSDataRamboTainer(vc=XSDataDouble(self.frame.Vc), qr=XSDataDouble(self.frame.Qr), mass=XSDataDouble(self.frame.mass), dvc=XSDataDouble(self.frame.Vc_Stdev), dqr=XSDataDouble(self.frame.Qr_Stdev), dmass=XSDataDouble(self.frame.mass_Stdev)) self.xsDataResult.rti = xsdRTI