示例#1
0
 def process(self, _edObject=None):
     """
     Stores the contents of the AutoProcContainer in ISPyB.
     """
     EDPluginExec.process(self)
     self.DEBUG("EDPluginISPyBStoreScreeningv1_4.process")
     xsDataInputISPyBStoreScreening = self.getDataInput()
     httpAuthenticatedToolsForAutoprocessingWebService1 = HttpAuthenticated(
         username=self.strUserName, password=self.strPassWord)
     clientToolsForBLSampleWebServiceWsdl = Client(
         self.strToolsForBLSampleWebServiceWsdl,
         transport=httpAuthenticatedToolsForAutoprocessingWebService1)
     httpAuthenticatedToolsForAutoprocessingWebService2 = HttpAuthenticated(
         username=self.strUserName, password=self.strPassWord)
     clientToolsForScreeningEDNAWebServiceWsdl = Client(
         self.strToolsForScreeningEDNAWebServiceWsdl,
         transport=httpAuthenticatedToolsForAutoprocessingWebService2)
     self.bContinue = True
     # DiffractionPlan
     xsDataISPyBDiffractionPlan = xsDataInputISPyBStoreScreening.diffractionPlan
     iDiffractionPlanId = self.storeOrUpdateDiffractionPlan(
         clientToolsForBLSampleWebServiceWsdl, xsDataISPyBDiffractionPlan)
     if iDiffractionPlanId is None:
         self.ERROR("Couldn't create entry for diffraction plan in ISPyB!")
         self.setFailure()
         self.bContinue = False
     # Screening
     xsDataISPyBScreening = xsDataInputISPyBStoreScreening.screening
     self.iScreeningId = self.storeOrUpdateScreening(
         clientToolsForScreeningEDNAWebServiceWsdl, xsDataISPyBScreening,
         iDiffractionPlanId)
     if self.iScreeningId is None:
         self.ERROR("Couldn't create entry for screening in ISPyB!")
         self.setFailure()
         self.bContinue = False
     # Screening Output Container
     for xsDataISPyBScreeningOutputContainer in xsDataInputISPyBStoreScreening.screeningOutputContainer:
         xsDataISPyBScreeningOutput = xsDataISPyBScreeningOutputContainer.screeningOutput
         iScreeningOutputId = self.storeOrUpdateScreeningOutput(
             clientToolsForScreeningEDNAWebServiceWsdl,
             xsDataISPyBScreeningOutput, self.iScreeningId)
         if iScreeningOutputId is None:
             self.ERROR("Couldn't create entry for screening in ISPyB!")
             self.setFailure()
             self.bContinue = False
         for xsDataISPyBScreeningOutputLattice in xsDataISPyBScreeningOutputContainer.screeningOutputLattice:
             iScreeningOutputLatticeId = self.storeOrUpdateScreeningOutputLattice(
                 clientToolsForScreeningEDNAWebServiceWsdl,
                 xsDataISPyBScreeningOutputLattice, iScreeningOutputId)
             if iScreeningOutputLatticeId is None:
                 self.ERROR(
                     "Couldn't create entry for screening lattice in ISPyB!"
                 )
                 self.setFailure()
                 self.bContinue = False
         for xsDataISPyBScreeningStrategyContainer in xsDataISPyBScreeningOutputContainer.screeningStrategyContainer:
             # Create an empty object of type XSDataISPyBScreeningStrategy
             xsDataISPyBScreeningStrategy = XSDataISPyBScreeningStrategy()
             iScreeningStrategyId = self.storeOrUpdateScreeningStrategy(
                 clientToolsForScreeningEDNAWebServiceWsdl,
                 xsDataISPyBScreeningStrategy, iScreeningOutputId)
             if iScreeningStrategyId is None:
                 self.ERROR(
                     "Couldn't create entry for screening strategy in ISPyB!"
                 )
                 self.setFailure()
                 self.bContinue = False
             for xsDataISPyBScreeningStrategyWedgeContainer in xsDataISPyBScreeningStrategyContainer.screeningStrategyWedgeContainer:
                 xsDataISPyBScreeningStrategyWedge = xsDataISPyBScreeningStrategyWedgeContainer.screeningStrategyWedge
                 iScreeningStrategyWedgeId = self.storeOrUpdateScreeningStrategyWedge(
                     clientToolsForScreeningEDNAWebServiceWsdl,
                     xsDataISPyBScreeningStrategyWedge,
                     iScreeningStrategyId)
                 if iScreeningStrategyWedgeId is None:
                     self.ERROR(
                         "Couldn't create entry for screening strategy in ISPyB!"
                     )
                     self.setFailure()
                     self.bContinue = False
                 for xsDataISPyBScreeningStrategySubWedge in xsDataISPyBScreeningStrategyWedgeContainer.screeningStrategySubWedge:
                     iScreeningStrategySubWedgeId = self.storeOrUpdateScreeningStrategySubWedge(
                         clientToolsForScreeningEDNAWebServiceWsdl,
                         xsDataISPyBScreeningStrategySubWedge,
                         iScreeningStrategyWedgeId)
                     if iScreeningStrategySubWedgeId is None:
                         self.ERROR(
                             "Couldn't create entry for screening strategy in ISPyB!"
                         )
                         self.setFailure()
                         self.bContinue = False
 def generateLegacyXSDataISPyBStrategy(_xsDataResultCharacterisation, _xsDataISPyBScreeningOutputContainer):
     # Anomalus data
     bAnomalousData = False
     xsDataCollection = _xsDataResultCharacterisation.dataCollection
     if xsDataCollection is not None:
         xsDataDiffractionPlan = xsDataCollection.diffractionPlan
         if xsDataDiffractionPlan is not None:
             if xsDataDiffractionPlan.anomalousData is not None:
                 bAnomalousData = xsDataDiffractionPlan.getAnomalousData().getValue()
     # Use the existing xsDataISPyBScreeningStrategy in the _xsDataISPyBScreeningOutputContainer for the first sub wedge:
     if len(_xsDataISPyBScreeningOutputContainer.screeningStrategyContainer) > 0:
         xsDataISPyBScreeningStrategyContainerFirst = _xsDataISPyBScreeningOutputContainer.screeningStrategyContainer[0]
         xsDataISPyBScreeningStrategyFirst = xsDataISPyBScreeningStrategyContainerFirst.screeningStrategy
         # Strategy information
         bFirstStrategy = True
         xsDataResultStrategy = _xsDataResultCharacterisation.getStrategyResult()
         if (xsDataResultStrategy is not None):
             pyListXSDataCollectionPlan = xsDataResultStrategy.getCollectionPlan()
             if (pyListXSDataCollectionPlan is not None):
                 for xsDataCollectionPlan in pyListXSDataCollectionPlan:
                     iCollectionPlanNumber = xsDataCollectionPlan.getCollectionPlanNumber().getValue()
                     pyStrCollectionPlanComment = None
                     if (xsDataCollectionPlan.getComment() is not None):
                         pyStrCollectionPlanComment = xsDataCollectionPlan.getComment().getValue()
                     fCompleteness = None
                     fMultiplicity = None
                     fResolution = None
                     fRankingResolution = None
                     fTransmission = None
                     xsDataStrategySummary = xsDataCollectionPlan.getStrategySummary()
                     if (xsDataStrategySummary is not None):
                         if (xsDataStrategySummary.getCompleteness() is not None):
                             fCompleteness = xsDataStrategySummary.getCompleteness().getValue()
                         if (xsDataStrategySummary.getRedundancy() is not None):
                             fMultiplicity = xsDataStrategySummary.getRedundancy().getValue()
                         if (xsDataStrategySummary.getResolution() is not None):
                             fResolution = xsDataStrategySummary.getResolution().getValue()
                         if (xsDataStrategySummary.getRankingResolution() is not None):
                             fRankingResolution = xsDataStrategySummary.getRankingResolution().getValue()
                     xsDataCollectionStrategy = xsDataCollectionPlan.getCollectionStrategy()
                     if (xsDataCollectionStrategy is not None):
                         pyListXSDataSubWedge = xsDataCollectionStrategy.getSubWedge()
                         if (pyListXSDataSubWedge is not None):
                             for xsDataSubWedge in pyListXSDataSubWedge:
                                 iSubWedgeNumber = xsDataSubWedge.getSubWedgeNumber().getValue()
                                 if bFirstStrategy:
                                     xsDataISPyBScreeningStrategy = xsDataISPyBScreeningStrategyFirst
                                 else:
                                     xsDataISPyBScreeningStrategy = XSDataISPyBScreeningStrategy()
                                     xsDataISPyBScreeningStrategyContainer = XSDataISPyBScreeningStrategyContainer()
                                     xsDataISPyBScreeningStrategyContainer.screeningStrategy = xsDataISPyBScreeningStrategy
                                 fPhiStart = xsDataSubWedge.getExperimentalCondition().getGoniostat().getRotationAxisStart().getValue()
                                 fPhiEnd = xsDataSubWedge.getExperimentalCondition().getGoniostat().getRotationAxisEnd().getValue()
                                 fRotation = xsDataSubWedge.getExperimentalCondition().getGoniostat().getOscillationWidth().getValue()
                                 fExposureTime = xsDataSubWedge.getExperimentalCondition().getBeam().getExposureTime().getValue()
                                 fTransmission = None
                                 if xsDataSubWedge.experimentalCondition.beam.transmission:
                                     fTransmission = xsDataSubWedge.experimentalCondition.beam.transmission.value
                                 pyStrProgram = "BEST: Wedge no %d," % iCollectionPlanNumber
                                 if (pyStrCollectionPlanComment is not None):
                                     pyStrProgram += " ( %s )" % pyStrCollectionPlanComment
                                 pyStrProgram += " sub wedge no %d" % iSubWedgeNumber
                                 xsDataISPyBScreeningStrategy.setPhiStart(XSDataDouble(fPhiStart))
                                 xsDataISPyBScreeningStrategy.setPhiEnd(XSDataDouble(fPhiEnd))
                                 xsDataISPyBScreeningStrategy.setRotation(XSDataDouble(fRotation))
                                 xsDataISPyBScreeningStrategy.setExposureTime(XSDataDouble(fExposureTime))
                                 if fTransmission is not None:
                                     xsDataISPyBScreeningStrategy.transmission = XSDataDouble(fTransmission)
                                 if (fCompleteness is not None):
                                     xsDataISPyBScreeningStrategy.setCompleteness(XSDataDouble(fCompleteness))
                                 if (fMultiplicity is not None):
                                     xsDataISPyBScreeningStrategy.setMultiplicity(XSDataDouble(fMultiplicity))
                                 if (fResolution is not None):
                                     xsDataISPyBScreeningStrategy.setResolution(XSDataDouble(fResolution))
                                 if (fRankingResolution is not None):
                                     xsDataISPyBScreeningStrategy.setRankingResolution(XSDataDouble(fRankingResolution))
                                 if (bAnomalousData is not None):
                                     xsDataISPyBScreeningStrategy.setAnomalous(XSDataBoolean(bAnomalousData))
                                 else:
                                     xsDataISPyBScreeningStrategy.setAnomalous(XSDataBoolean(False))
                                 xsDataISPyBScreeningStrategy.setProgram(XSDataString(pyStrProgram))
                                 if bFirstStrategy:
                                     bFirstStrategy = False
                                 else:
                                     _xsDataISPyBScreeningOutputContainer.addScreeningStrategyContainer(xsDataISPyBScreeningStrategyContainer)
示例#3
0
    def generateXSDataISPyBScreeningOutputContainer(_xsDataResultCharacterisation, _strStatusMessage):
        xsDataISPyBScreeningOutput = XSDataISPyBScreeningOutput()
        xsDataISPyBScreeningOutputLattice = None
        # Indexing information
        bSuccessfulIndexing = False
        xsDataIndexingResult = _xsDataResultCharacterisation.getIndexingResult()
        if xsDataIndexingResult is not None:
            xsDataIndexingSolutionSelected = xsDataIndexingResult.getSelectedSolution()
            if xsDataIndexingSolutionSelected is not None:
                xsDataISPyBScreeningOutputLattice = XSDataISPyBScreeningOutputLattice()
                bSuccessfulIndexing = True
                xsDataStatisticsIndexing = xsDataIndexingSolutionSelected.getStatistics()
                if xsDataStatisticsIndexing is not None:
                    xsDataISPyBScreeningOutput.beamShiftX = xsDataStatisticsIndexing.beamPositionShiftX
                    xsDataISPyBScreeningOutput.beamShiftY = xsDataStatisticsIndexing.beamPositionShiftY
                    xsDataISPyBScreeningOutput.spotDeviationR = xsDataStatisticsIndexing.spotDeviationPositional
                    xsDataISPyBScreeningOutput.spotDeviationTheta = xsDataStatisticsIndexing.spotDeviationAngular
                    if (xsDataStatisticsIndexing.spotsTotal is not None) and (
                        xsDataStatisticsIndexing.spotsUsed is not None
                    ):
                        iSpotsTotal = xsDataStatisticsIndexing.spotsTotal.value
                        iSpotsUsed = xsDataStatisticsIndexing.spotsUsed.value
                        xsDataISPyBScreeningOutput.numSpotsFound = xsDataStatisticsIndexing.spotsTotal
                        xsDataISPyBScreeningOutput.numSpotsUsed = xsDataStatisticsIndexing.spotsUsed
                        xsDataISPyBScreeningOutput.numSpotsRejected = XSDataInteger(iSpotsTotal - iSpotsUsed)
                xsDataCrystal = xsDataIndexingSolutionSelected.crystal
                xsDataISPyBScreeningOutput.mosaicityEstimated = XSDataBoolean(False)
                if xsDataCrystal is not None:
                    if xsDataCrystal.mosaicity is not None:
                        xsDataISPyBScreeningOutput.mosaicity = xsDataCrystal.mosaicity
                        xsDataISPyBScreeningOutput.mosaicityEstimated = XSDataBoolean(True)
                    xsDataCell = xsDataCrystal.cell
                    if xsDataCell is not None:
                        xsDataISPyBScreeningOutputLattice.unitCell_a = xsDataCell.length_a
                        xsDataISPyBScreeningOutputLattice.unitCell_b = xsDataCell.length_b
                        xsDataISPyBScreeningOutputLattice.unitCell_c = xsDataCell.length_c
                        xsDataISPyBScreeningOutputLattice.unitCell_alpha = xsDataCell.angle_alpha
                        xsDataISPyBScreeningOutputLattice.unitCell_beta = xsDataCell.angle_beta
                        xsDataISPyBScreeningOutputLattice.unitCell_gamma = xsDataCell.angle_gamma
                    xsDataSpaceGroup = xsDataCrystal.spaceGroup
                    if xsDataSpaceGroup is not None:
                        xsDataISPyBScreeningOutputLattice.spaceGroup = xsDataSpaceGroup.name
        if bSuccessfulIndexing:
            xsDataISPyBScreeningOutput.setIndexingSuccess(XSDataBoolean(True))
            if _strStatusMessage:
                xsDataISPyBScreeningOutput.setStatusDescription(XSDataString(_strStatusMessage))
            else:
                xsDataISPyBScreeningOutput.setStatusDescription(XSDataString("Indexing successful"))
        else:
            xsDataISPyBScreeningOutput.setIndexingSuccess(XSDataBoolean(False))
            if _strStatusMessage:
                xsDataISPyBScreeningOutput.setStatusDescription(XSDataString(_strStatusMessage))
            else:
                xsDataISPyBScreeningOutput.setStatusDescription(XSDataString("Indexing failed"))

        # Strategy information
        xsDataResultStrategy = _xsDataResultCharacterisation.strategyResult
        xsDataISPyBScreeningStrategyContainer = None
        xsDataISPyBScreeningStrategyWedgeContainer = None
        if xsDataResultStrategy is None:
            xsDataISPyBScreeningOutput.setStrategySuccess(XSDataBoolean(False))
        else:
            xsDataISPyBScreeningOutput.setStrategySuccess(XSDataBoolean(True))
            xsDataISPyBScreeningStrategyContainer = XSDataISPyBScreeningStrategyContainer()
            xsDataISPyBScreeningStrategy = XSDataISPyBScreeningStrategy()
            listXSDataCollectionPlan = xsDataResultStrategy.collectionPlan
            for xsDataCollectionPlan in listXSDataCollectionPlan:
                numberOfImagesWedge = None
                xsDataISPyBScreeningStrategyWedge = XSDataISPyBScreeningStrategyWedge()
                xsDataISPyBScreeningStrategyWedgeContainer = XSDataISPyBScreeningStrategyWedgeContainer()
                xsDataISPyBScreeningStrategyWedge.wedgeNumber = xsDataCollectionPlan.collectionPlanNumber
                strCollectionPlanComment = None
                if xsDataCollectionPlan.getComment() is not None:
                    strCollectionPlanComment = xsDataCollectionPlan.getComment().getValue()
                xsDataStrategySummary = xsDataCollectionPlan.strategySummary
                if xsDataStrategySummary is not None:
                    xsDataISPyBScreeningStrategyWedge.completeness = xsDataStrategySummary.completeness
                    xsDataISPyBScreeningStrategyWedge.resolution = xsDataStrategySummary.resolution
                    xsDataISPyBScreeningStrategyWedge.multiplicity = xsDataStrategySummary.redundancy
                    xsDataISPyBScreeningStrategy.rankingResolution = xsDataStrategySummary.rankingResolution
                xsDataCollectionStrategy = xsDataCollectionPlan.collectionStrategy
                if xsDataCollectionStrategy is not None:
                    for xsDataSubWedge in xsDataCollectionStrategy.subWedge:
                        numberOfImagesSubWedge = None
                        xsDataISPyBScreeningStrategySubWedge = XSDataISPyBScreeningStrategySubWedge()
                        xsDataISPyBScreeningStrategySubWedge.subWedgeNumber = xsDataSubWedge.subWedgeNumber
                        xsDataISPyBScreeningStrategySubWedge.axisStart = (
                            xsDataSubWedge.experimentalCondition.goniostat.rotationAxisStart
                        )
                        xsDataISPyBScreeningStrategySubWedge.axisEnd = (
                            xsDataSubWedge.experimentalCondition.goniostat.rotationAxisEnd
                        )
                        xsDataISPyBScreeningStrategySubWedge.oscillationRange = (
                            xsDataSubWedge.experimentalCondition.goniostat.oscillationWidth
                        )
                        # Number of images
                        if (
                            (xsDataSubWedge.experimentalCondition.goniostat.rotationAxisStart is not None)
                            and (xsDataSubWedge.experimentalCondition.goniostat.rotationAxisEnd is not None)
                            and (xsDataSubWedge.experimentalCondition.goniostat.oscillationWidth is not None)
                        ):
                            numberOfImagesSubWedge = int(
                                (
                                    xsDataSubWedge.experimentalCondition.goniostat.rotationAxisEnd.value
                                    - xsDataSubWedge.experimentalCondition.goniostat.rotationAxisStart.value
                                )
                                / xsDataSubWedge.experimentalCondition.goniostat.oscillationWidth.value
                                + 0.5
                            )
                            xsDataISPyBScreeningStrategySubWedge.numberOfImages = XSDataInteger(numberOfImagesSubWedge)
                            if numberOfImagesWedge is None:
                                numberOfImagesWedge = numberOfImagesSubWedge
                            else:
                                numberOfImagesWedge += numberOfImagesSubWedge
                        xsDataISPyBScreeningStrategySubWedge.exposureTime = (
                            xsDataSubWedge.experimentalCondition.beam.exposureTime
                        )
                        xsDataISPyBScreeningStrategySubWedge.transmission = (
                            xsDataSubWedge.experimentalCondition.beam.transmission
                        )
                        xsDataISPyBScreeningStrategyWedgeContainer.addScreeningStrategySubWedge(
                            xsDataISPyBScreeningStrategySubWedge
                        )
                if numberOfImagesWedge is not None:
                    xsDataISPyBScreeningStrategyWedge.numberOfImages = XSDataInteger(numberOfImagesWedge)
                xsDataISPyBScreeningStrategyWedgeContainer.screeningStrategyWedge = xsDataISPyBScreeningStrategyWedge
                xsDataISPyBScreeningStrategyContainer.addScreeningStrategyWedgeContainer(
                    xsDataISPyBScreeningStrategyWedgeContainer
                )
            xsDataISPyBScreeningStrategyContainer.screeningStrategy = xsDataISPyBScreeningStrategy
        # Assembly
        xsDataISPyBScreeningOutputContainer = XSDataISPyBScreeningOutputContainer()
        xsDataISPyBScreeningOutputContainer.screeningOutput = xsDataISPyBScreeningOutput
        if xsDataISPyBScreeningOutputLattice is not None:
            xsDataISPyBScreeningOutputContainer.addScreeningOutputLattice(xsDataISPyBScreeningOutputLattice)
        if xsDataISPyBScreeningStrategyContainer is not None:
            xsDataISPyBScreeningOutputContainer.addScreeningStrategyContainer(xsDataISPyBScreeningStrategyContainer)

        return xsDataISPyBScreeningOutputContainer
 def generateLegacyXSDataISPyBStrategy(
         _xsDataResultCharacterisation,
         _xsDataISPyBScreeningOutputContainer):
     # Anomalus data
     bAnomalousData = False
     xsDataCollection = _xsDataResultCharacterisation.dataCollection
     if xsDataCollection is not None:
         xsDataDiffractionPlan = xsDataCollection.diffractionPlan
         if xsDataDiffractionPlan is not None:
             if xsDataDiffractionPlan.anomalousData is not None:
                 bAnomalousData = xsDataDiffractionPlan.getAnomalousData(
                 ).getValue()
     # Use the existing xsDataISPyBScreeningStrategy in the _xsDataISPyBScreeningOutputContainer for the first sub wedge:
     if len(_xsDataISPyBScreeningOutputContainer.screeningStrategyContainer
            ) > 0:
         xsDataISPyBScreeningStrategyContainerFirst = _xsDataISPyBScreeningOutputContainer.screeningStrategyContainer[
             0]
         xsDataISPyBScreeningStrategyFirst = xsDataISPyBScreeningStrategyContainerFirst.screeningStrategy
         # Strategy information
         bFirstStrategy = True
         xsDataResultStrategy = _xsDataResultCharacterisation.getStrategyResult(
         )
         if (xsDataResultStrategy is not None):
             pyListXSDataCollectionPlan = xsDataResultStrategy.getCollectionPlan(
             )
             if (pyListXSDataCollectionPlan is not None):
                 for xsDataCollectionPlan in pyListXSDataCollectionPlan:
                     iCollectionPlanNumber = xsDataCollectionPlan.getCollectionPlanNumber(
                     ).getValue()
                     pyStrCollectionPlanComment = None
                     if (xsDataCollectionPlan.getComment() is not None):
                         pyStrCollectionPlanComment = xsDataCollectionPlan.getComment(
                         ).getValue()
                     fCompleteness = None
                     fMultiplicity = None
                     fResolution = None
                     fRankingResolution = None
                     fTransmission = None
                     xsDataStrategySummary = xsDataCollectionPlan.getStrategySummary(
                     )
                     if (xsDataStrategySummary is not None):
                         if (xsDataStrategySummary.getCompleteness()
                                 is not None):
                             fCompleteness = xsDataStrategySummary.getCompleteness(
                             ).getValue()
                         if (xsDataStrategySummary.getRedundancy()
                                 is not None):
                             fMultiplicity = xsDataStrategySummary.getRedundancy(
                             ).getValue()
                         if (xsDataStrategySummary.getResolution()
                                 is not None):
                             fResolution = xsDataStrategySummary.getResolution(
                             ).getValue()
                         if (xsDataStrategySummary.getRankingResolution()
                                 is not None):
                             fRankingResolution = xsDataStrategySummary.getRankingResolution(
                             ).getValue()
                     xsDataCollectionStrategy = xsDataCollectionPlan.getCollectionStrategy(
                     )
                     if (xsDataCollectionStrategy is not None):
                         pyListXSDataSubWedge = xsDataCollectionStrategy.getSubWedge(
                         )
                         if (pyListXSDataSubWedge is not None):
                             for xsDataSubWedge in pyListXSDataSubWedge:
                                 iSubWedgeNumber = xsDataSubWedge.getSubWedgeNumber(
                                 ).getValue()
                                 if bFirstStrategy:
                                     xsDataISPyBScreeningStrategy = xsDataISPyBScreeningStrategyFirst
                                 else:
                                     xsDataISPyBScreeningStrategy = XSDataISPyBScreeningStrategy(
                                     )
                                     xsDataISPyBScreeningStrategyContainer = XSDataISPyBScreeningStrategyContainer(
                                     )
                                     xsDataISPyBScreeningStrategyContainer.screeningStrategy = xsDataISPyBScreeningStrategy
                                 fPhiStart = xsDataSubWedge.getExperimentalCondition(
                                 ).getGoniostat().getRotationAxisStart(
                                 ).getValue()
                                 fPhiEnd = xsDataSubWedge.getExperimentalCondition(
                                 ).getGoniostat().getRotationAxisEnd(
                                 ).getValue()
                                 fRotation = xsDataSubWedge.getExperimentalCondition(
                                 ).getGoniostat().getOscillationWidth(
                                 ).getValue()
                                 fExposureTime = xsDataSubWedge.getExperimentalCondition(
                                 ).getBeam().getExposureTime().getValue()
                                 fTransmission = None
                                 if xsDataSubWedge.experimentalCondition.beam.transmission:
                                     fTransmission = xsDataSubWedge.experimentalCondition.beam.transmission.value
                                 pyStrProgram = "BEST: Wedge no %d," % iCollectionPlanNumber
                                 if (pyStrCollectionPlanComment
                                         is not None):
                                     pyStrProgram += " ( %s )" % pyStrCollectionPlanComment
                                 pyStrProgram += " sub wedge no %d" % iSubWedgeNumber
                                 xsDataISPyBScreeningStrategy.setPhiStart(
                                     XSDataDouble(fPhiStart))
                                 xsDataISPyBScreeningStrategy.setPhiEnd(
                                     XSDataDouble(fPhiEnd))
                                 xsDataISPyBScreeningStrategy.setRotation(
                                     XSDataDouble(fRotation))
                                 xsDataISPyBScreeningStrategy.setExposureTime(
                                     XSDataDouble(fExposureTime))
                                 if fTransmission is not None:
                                     xsDataISPyBScreeningStrategy.transmission = XSDataDouble(
                                         fTransmission)
                                 if (fCompleteness is not None):
                                     xsDataISPyBScreeningStrategy.setCompleteness(
                                         XSDataDouble(fCompleteness))
                                 if (fMultiplicity is not None):
                                     xsDataISPyBScreeningStrategy.setMultiplicity(
                                         XSDataDouble(fMultiplicity))
                                 if (fResolution is not None):
                                     xsDataISPyBScreeningStrategy.setResolution(
                                         XSDataDouble(fResolution))
                                 if (fRankingResolution is not None):
                                     xsDataISPyBScreeningStrategy.setRankingResolution(
                                         XSDataDouble(fRankingResolution))
                                 if (bAnomalousData is not None):
                                     xsDataISPyBScreeningStrategy.setAnomalous(
                                         XSDataBoolean(bAnomalousData))
                                 else:
                                     xsDataISPyBScreeningStrategy.setAnomalous(
                                         XSDataBoolean(False))
                                 xsDataISPyBScreeningStrategy.setProgram(
                                     XSDataString(pyStrProgram))
                                 if bFirstStrategy:
                                     bFirstStrategy = False
                                 else:
                                     _xsDataISPyBScreeningOutputContainer.addScreeningStrategyContainer(
                                         xsDataISPyBScreeningStrategyContainer
                                     )
    def generateXSDataISPyBScreeningOutputContainer(
            _xsDataResultCharacterisation, _strStatusMessage, _fKappa, _fPhi):
        xsDataISPyBScreeningOutput = XSDataISPyBScreeningOutput()
        xsDataISPyBScreeningOutput.program = XSDataString("EDNA MXv1")
        xsDataISPyBScreeningOutputLattice = None
        # Indexing information
        bSuccessfulIndexing = False
        xsDataIndexingResult = _xsDataResultCharacterisation.getIndexingResult(
        )
        if (xsDataIndexingResult is not None):
            xsDataIndexingSolutionSelected = xsDataIndexingResult.getSelectedSolution(
            )
            if (xsDataIndexingSolutionSelected is not None):
                xsDataISPyBScreeningOutputLattice = XSDataISPyBScreeningOutputLattice(
                )
                bSuccessfulIndexing = True
                xsDataStatisticsIndexing = xsDataIndexingSolutionSelected.getStatistics(
                )
                if (xsDataStatisticsIndexing is not None):
                    xsDataISPyBScreeningOutput.beamShiftX = xsDataStatisticsIndexing.beamPositionShiftX
                    xsDataISPyBScreeningOutput.beamShiftY = xsDataStatisticsIndexing.beamPositionShiftY
                    xsDataISPyBScreeningOutput.spotDeviationR = xsDataStatisticsIndexing.spotDeviationPositional
                    xsDataISPyBScreeningOutput.spotDeviationTheta = xsDataStatisticsIndexing.spotDeviationAngular
                    if ((xsDataStatisticsIndexing.spotsTotal is not None) and
                        (xsDataStatisticsIndexing.spotsUsed is not None)):
                        iSpotsTotal = xsDataStatisticsIndexing.spotsTotal.value
                        iSpotsUsed = xsDataStatisticsIndexing.spotsUsed.value
                        xsDataISPyBScreeningOutput.numSpotsFound = xsDataStatisticsIndexing.spotsTotal
                        xsDataISPyBScreeningOutput.numSpotsUsed = xsDataStatisticsIndexing.spotsUsed
                        xsDataISPyBScreeningOutput.numSpotsRejected = XSDataInteger(
                            iSpotsTotal - iSpotsUsed)
                xsDataCrystal = xsDataIndexingSolutionSelected.crystal
                xsDataISPyBScreeningOutput.mosaicityEstimated = XSDataBoolean(
                    False)
                if (xsDataCrystal is not None):
                    if xsDataCrystal.mosaicity is not None:
                        xsDataISPyBScreeningOutput.mosaicity = xsDataCrystal.mosaicity
                        xsDataISPyBScreeningOutput.mosaicityEstimated = XSDataBoolean(
                            True)
                    xsDataCell = xsDataCrystal.cell
                    if xsDataCell is not None:
                        xsDataISPyBScreeningOutputLattice.unitCell_a = xsDataCell.length_a
                        xsDataISPyBScreeningOutputLattice.unitCell_b = xsDataCell.length_b
                        xsDataISPyBScreeningOutputLattice.unitCell_c = xsDataCell.length_c
                        xsDataISPyBScreeningOutputLattice.unitCell_alpha = xsDataCell.angle_alpha
                        xsDataISPyBScreeningOutputLattice.unitCell_beta = xsDataCell.angle_beta
                        xsDataISPyBScreeningOutputLattice.unitCell_gamma = xsDataCell.angle_gamma
                    xsDataSpaceGroup = xsDataCrystal.spaceGroup
                    if xsDataSpaceGroup is not None:
                        xsDataISPyBScreeningOutputLattice.spaceGroup = xsDataSpaceGroup.name
        if (bSuccessfulIndexing):
            xsDataISPyBScreeningOutput.setIndexingSuccess(XSDataBoolean(True))
            if _strStatusMessage:
                xsDataISPyBScreeningOutput.setStatusDescription(
                    XSDataString(_strStatusMessage))
            else:
                xsDataISPyBScreeningOutput.setStatusDescription(
                    XSDataString("Indexing successful"))
        else:
            xsDataISPyBScreeningOutput.setIndexingSuccess(XSDataBoolean(False))
            if _strStatusMessage:
                xsDataISPyBScreeningOutput.setStatusDescription(
                    XSDataString(_strStatusMessage))
            else:
                xsDataISPyBScreeningOutput.setStatusDescription(
                    XSDataString("Indexing failed"))

        # Strategy information
        xsDataResultStrategy = _xsDataResultCharacterisation.strategyResult
        xsDataISPyBScreeningStrategyContainer = None
        xsDataISPyBScreeningStrategyWedgeContainer = None
        if xsDataResultStrategy is None:
            xsDataISPyBScreeningOutput.setStrategySuccess(XSDataBoolean(False))
        else:
            if xsDataResultStrategy.collectionPlan == []:
                xsDataISPyBScreeningOutput.setStrategySuccess(
                    XSDataBoolean(False))
            else:
                xsDataISPyBScreeningOutput.setStrategySuccess(
                    XSDataBoolean(True))
                xsDataISPyBScreeningStrategyContainer = XSDataISPyBScreeningStrategyContainer(
                )
                xsDataISPyBScreeningStrategy = XSDataISPyBScreeningStrategy()
                listXSDataCollectionPlan = xsDataResultStrategy.collectionPlan
                fTotalExposureTime = 0.0
                iTotalNumberOfImages = 0
                fTotalRotationRange = 0.0
                for xsDataCollectionPlan in listXSDataCollectionPlan:
                    numberOfImagesWedge = None
                    xsDataISPyBScreeningStrategyWedge = XSDataISPyBScreeningStrategyWedge(
                    )
                    xsDataISPyBScreeningStrategyWedgeContainer = XSDataISPyBScreeningStrategyWedgeContainer(
                    )
                    xsDataISPyBScreeningStrategyWedge.wedgeNumber = xsDataCollectionPlan.collectionPlanNumber
                    fWavelength = _xsDataResultCharacterisation.dataCollection.subWedge[
                        0].experimentalCondition.beam.wavelength.value
                    xsDataISPyBScreeningStrategyWedge.wavelength = XSDataDouble(
                        fWavelength)
                    if _fKappa is not None:
                        xsDataISPyBScreeningStrategyWedge.kappa = XSDataDouble(
                            _fKappa)
                    if _fPhi is not None:
                        xsDataISPyBScreeningStrategyWedge.phi = XSDataDouble(
                            _fPhi)
                    if (xsDataCollectionPlan.getComment() is not None):
                        strCollectionPlanComment = xsDataCollectionPlan.getComment(
                        ).getValue()
                        xsDataISPyBScreeningStrategyWedge.comments = strCollectionPlanComment
                    xsDataStrategySummary = xsDataCollectionPlan.strategySummary
                    if xsDataStrategySummary is not None:
                        xsDataISPyBScreeningStrategyWedge.completeness = xsDataStrategySummary.completeness
                        xsDataISPyBScreeningStrategyWedge.resolution = xsDataStrategySummary.resolution
                        xsDataISPyBScreeningStrategyWedge.multiplicity = xsDataStrategySummary.redundancy
                        xsDataISPyBScreeningOutput.rankingResolution = xsDataStrategySummary.rankingResolution
                        if xsDataStrategySummary.totalExposureTime is not None:
                            fTotalExposureTime += xsDataStrategySummary.totalExposureTime.value
                    xsDataCollectionStrategy = xsDataCollectionPlan.collectionStrategy
                    if xsDataCollectionStrategy is not None:
                        for xsDataSubWedge in xsDataCollectionStrategy.subWedge:
                            numberOfImagesSubWedge = None
                            xsDataISPyBScreeningStrategySubWedge = XSDataISPyBScreeningStrategySubWedge(
                            )
                            xsDataISPyBScreeningStrategySubWedge.subWedgeNumber = xsDataSubWedge.subWedgeNumber
                            xsDataISPyBScreeningStrategySubWedge.axisStart = xsDataSubWedge.experimentalCondition.goniostat.rotationAxisStart
                            xsDataISPyBScreeningStrategySubWedge.axisEnd = xsDataSubWedge.experimentalCondition.goniostat.rotationAxisEnd
                            xsDataISPyBScreeningStrategySubWedge.oscillationRange = xsDataSubWedge.experimentalCondition.goniostat.oscillationWidth
                            # Number of images
                            if  (xsDataSubWedge.experimentalCondition.goniostat.rotationAxisStart is not None) and \
                                (xsDataSubWedge.experimentalCondition.goniostat.rotationAxisEnd is not None) and \
                                (xsDataSubWedge.experimentalCondition.goniostat.oscillationWidth is not None):
                                numberOfImagesSubWedge = int((xsDataSubWedge.experimentalCondition.goniostat.rotationAxisEnd.value - \
                                                 xsDataSubWedge.experimentalCondition.goniostat.rotationAxisStart.value) / \
                                                 xsDataSubWedge.experimentalCondition.goniostat.oscillationWidth.value + 0.5)
                                xsDataISPyBScreeningStrategySubWedge.numberOfImages = XSDataInteger(
                                    numberOfImagesSubWedge)
                                if numberOfImagesWedge is None:
                                    numberOfImagesWedge = numberOfImagesSubWedge
                                else:
                                    numberOfImagesWedge += numberOfImagesSubWedge
                                fTotalRotationRange += xsDataSubWedge.experimentalCondition.goniostat.oscillationWidth.value * numberOfImagesSubWedge
                            xsDataISPyBScreeningStrategySubWedge.exposureTime = xsDataSubWedge.experimentalCondition.beam.exposureTime
                            xsDataISPyBScreeningStrategySubWedge.transmission = xsDataSubWedge.experimentalCondition.beam.transmission
                            xsDataISPyBScreeningStrategyWedgeContainer.addScreeningStrategySubWedge(
                                xsDataISPyBScreeningStrategySubWedge)
                    if numberOfImagesWedge is not None:
                        xsDataISPyBScreeningStrategyWedge.numberOfImages = XSDataInteger(
                            numberOfImagesWedge)
                        iTotalNumberOfImages += numberOfImagesWedge
                    xsDataISPyBScreeningStrategyWedgeContainer.screeningStrategyWedge = xsDataISPyBScreeningStrategyWedge
                    xsDataISPyBScreeningStrategyContainer.addScreeningStrategyWedgeContainer(
                        xsDataISPyBScreeningStrategyWedgeContainer)
                xsDataISPyBScreeningOutput.totalExposureTime = XSDataDouble(
                    fTotalExposureTime)
                xsDataISPyBScreeningOutput.totalNumberOfImages = XSDataInteger(
                    iTotalNumberOfImages)
                xsDataISPyBScreeningOutput.totalRotationRange = XSDataDouble(
                    fTotalRotationRange)
                xsDataISPyBScreeningStrategyContainer.screeningStrategy = xsDataISPyBScreeningStrategy
        # Assembly
        xsDataISPyBScreeningOutputContainer = XSDataISPyBScreeningOutputContainer(
        )
        xsDataISPyBScreeningOutputContainer.screeningOutput = xsDataISPyBScreeningOutput
        if xsDataISPyBScreeningOutputLattice is not None:
            xsDataISPyBScreeningOutputContainer.addScreeningOutputLattice(
                xsDataISPyBScreeningOutputLattice)
        if xsDataISPyBScreeningStrategyContainer is not None:
            xsDataISPyBScreeningOutputContainer.addScreeningStrategyContainer(
                xsDataISPyBScreeningStrategyContainer)

        return xsDataISPyBScreeningOutputContainer
示例#6
0
 def process(self, _edObject=None):
     """
     Stores the contents of the AutoProcContainer in ISPyB.
     """
     EDPluginISPyBv1_4.process(self)
     self.DEBUG("EDPluginISPyBStoreScreeningv1_4.process")
     xsDataInputISPyBStoreScreening = self.getDataInput()
     httpAuthenticatedToolsForAutoprocessingWebService1 = HttpAuthenticated(
         username=self.strUserName, password=self.strPassWord)
     clientToolsForBLSampleWebServiceWsdl = Client(
         self.strToolsForBLSampleWebServiceWsdl,
         transport=httpAuthenticatedToolsForAutoprocessingWebService1,
         cache=None)
     httpAuthenticatedToolsForAutoprocessingWebService2 = HttpAuthenticated(
         username=self.strUserName, password=self.strPassWord)
     clientToolsForScreeningEDNAWebServiceWsdl = Client(
         self.strToolsForScreeningEDNAWebServiceWsdl,
         transport=httpAuthenticatedToolsForAutoprocessingWebService2,
         cache=None)
     self.bContinue = True
     # Data collection Id
     if xsDataInputISPyBStoreScreening.screening.dataCollectionGroupId is None:
         xsDataISPyBImage = xsDataInputISPyBStoreScreening.image
         if xsDataISPyBImage is not None:
             httpAuthenticatedToolsForAutoprocessingWebService3 = HttpAuthenticated(
                 username=self.strUserName, password=self.strPassWord)
             clientToolsForCollectionWebService = Client(
                 self.strToolsForCollectionWebServiceWsdl,
                 transport=
                 httpAuthenticatedToolsForAutoprocessingWebService3,
                 cache=None)
             self.iDataCollectionGroupId = self.findDataCollectionFromFileLocationAndFileName(
                 clientToolsForCollectionWebService,
                 xsDataISPyBImage.fileLocation.value,
                 xsDataISPyBImage.fileName.value)
             if self.iDataCollectionGroupId is None:
                 self.ERROR("Couldn't obtain data collection id!")
                 self.setFailure()
             else:
                 xsDataInputISPyBStoreScreening.screening.dataCollectionGroupId = XSDataInteger(
                     self.iDataCollectionGroupId)
     else:
         self.iDataCollectionGroupId = xsDataInputISPyBStoreScreening.screening.dataCollectionGroupId.value
     if not self.isFailure():
         # DiffractionPlan
         xsDataISPyBDiffractionPlan = xsDataInputISPyBStoreScreening.diffractionPlan
         iDiffractionPlanId = self.storeOrUpdateDiffractionPlan(
             clientToolsForBLSampleWebServiceWsdl,
             xsDataISPyBDiffractionPlan)
         if iDiffractionPlanId is None:
             self.ERROR(
                 "Couldn't create entry for diffraction plan in ISPyB!")
             self.setFailure()
             self.bContinue = False
         # Screening
         xsDataISPyBScreening = xsDataInputISPyBStoreScreening.screening
         self.iScreeningId = self.storeOrUpdateScreening(
             clientToolsForScreeningEDNAWebServiceWsdl,
             xsDataISPyBScreening, iDiffractionPlanId)
         if self.iScreeningId is None:
             self.ERROR("Couldn't create entry for screening in ISPyB!")
             self.setFailure()
             self.bContinue = False
         # Screening Output Container
         for xsDataISPyBScreeningOutputContainer in xsDataInputISPyBStoreScreening.screeningOutputContainer:
             xsDataISPyBScreeningOutput = xsDataISPyBScreeningOutputContainer.screeningOutput
             iScreeningOutputId = self.storeOrUpdateScreeningOutput(
                 clientToolsForScreeningEDNAWebServiceWsdl,
                 xsDataISPyBScreeningOutput, self.iScreeningId)
             if iScreeningOutputId is None:
                 self.ERROR("Couldn't create entry for screening in ISPyB!")
                 self.setFailure()
                 self.bContinue = False
             for xsDataISPyBScreeningOutputLattice in xsDataISPyBScreeningOutputContainer.screeningOutputLattice:
                 iScreeningOutputLatticeId = self.storeOrUpdateScreeningOutputLattice(
                     clientToolsForScreeningEDNAWebServiceWsdl,
                     xsDataISPyBScreeningOutputLattice, iScreeningOutputId)
                 if iScreeningOutputLatticeId is None:
                     self.ERROR(
                         "Couldn't create entry for screening lattice in ISPyB!"
                     )
                     self.setFailure()
                     self.bContinue = False
             for xsDataISPyBScreeningStrategyContainer in xsDataISPyBScreeningOutputContainer.screeningStrategyContainer:
                 # Create an empty object of type XSDataISPyBScreeningStrategy
                 xsDataISPyBScreeningStrategy = XSDataISPyBScreeningStrategy(
                 )
                 iScreeningStrategyId = self.storeOrUpdateScreeningStrategy(
                     clientToolsForScreeningEDNAWebServiceWsdl,
                     xsDataISPyBScreeningStrategy, iScreeningOutputId)
                 if iScreeningStrategyId is None:
                     self.ERROR(
                         "Couldn't create entry for screening strategy in ISPyB!"
                     )
                     self.setFailure()
                     self.bContinue = False
                 for xsDataISPyBScreeningStrategyWedgeContainer in xsDataISPyBScreeningStrategyContainer.screeningStrategyWedgeContainer:
                     xsDataISPyBScreeningStrategyWedge = xsDataISPyBScreeningStrategyWedgeContainer.screeningStrategyWedge
                     iScreeningStrategyWedgeId = self.storeOrUpdateScreeningStrategyWedge(
                         clientToolsForScreeningEDNAWebServiceWsdl,
                         xsDataISPyBScreeningStrategyWedge,
                         iScreeningStrategyId)
                     if iScreeningStrategyWedgeId is None:
                         self.ERROR(
                             "Couldn't create entry for screening strategy in ISPyB!"
                         )
                         self.setFailure()
                         self.bContinue = False
                     for xsDataISPyBScreeningStrategySubWedge in xsDataISPyBScreeningStrategyWedgeContainer.screeningStrategySubWedge:
                         iScreeningStrategySubWedgeId = self.storeOrUpdateScreeningStrategySubWedge(
                             clientToolsForScreeningEDNAWebServiceWsdl,
                             xsDataISPyBScreeningStrategySubWedge,
                             iScreeningStrategyWedgeId)
                         if iScreeningStrategySubWedgeId is None:
                             self.ERROR(
                                 "Couldn't create entry for screening strategy in ISPyB!"
                             )
                             self.setFailure()
                             self.bContinue = False