Пример #1
0
 def run(self, in_data):
     outData = {}
     # First get the list of subWedges
     if "subWedge" in in_data:
         list_sub_wedge = in_data["subWedge"]
     else:
         list_sub_wedge = self.getListSubWedge(in_data)
     # # Get list of spots from Dozor
     # listOutDataControlDozor = self.runControlDozor(listSubWedge)
     # listDozorSpotFile = []
     # for outDataControlDozor in listOutDataControlDozor:
     #     if "dozorSpotFile" in outDataControlDozor["imageQualityIndicators"][0]:
     #         dozorSpotFile = outDataControlDozor["imageQualityIndicators"][0][
     #             "dozorSpotFile"
     #         ]
     #         listDozorSpotFile.append(dozorSpotFile)
     # imageDict = listSubWedge[0]
     # Run XDS indexing
     xds_indexin_in_data = {
         "subWedge": list_sub_wedge
         # "dozorSpotFile": listDozorSpotFile,
     }
     xds_indexing_task = XDSIndexing(
         inData=xds_indexin_in_data
         # workingDirectorySuffix=UtilsImage.getPrefix(imageDict["image"][0]["path"]),
     )
     xds_indexing_task.execute()
     resultIndexing = None
     xparm_path = None
     spot_path = None
     if xds_indexing_task.isSuccess():
         xdsIndexingOutData = xds_indexing_task.outData
         if os.path.exists(xdsIndexingOutData["xparmXdsPath"]):
             xparm_path = xdsIndexingOutData["xparmXdsPath"]
         if os.path.exists(xdsIndexingOutData["spotXdsPath"]):
             spot_path = xdsIndexingOutData["spotXdsPath"]
         resultIndexing = ControlIndexing.getResultIndexingFromXds(
             xdsIndexingOutData)
     outData = {
         "resultIndexing": resultIndexing,
         "xparmXdsPath": xparm_path,
         "spotXdsPath": spot_path
     }
     return outData
Пример #2
0
 def run(self, inData):
     outData = {}
     # First get the list of subWedges
     if "subWedge" in inData:
         listSubWedge = inData["subWedge"]
     else:
         listSubWedge = self.getListSubWedge(inData)
     # Get list of spots from Dozor
     listOutDataControlDozor = self.runControlDozor(listSubWedge)
     listDozorSpotFile = []
     for outDataControlDozor in listOutDataControlDozor:
         if "dozorSpotFile" in outDataControlDozor["imageQualityIndicators"][0]:
             dozorSpotFile = outDataControlDozor["imageQualityIndicators"][0]["dozorSpotFile"]
             listDozorSpotFile.append(dozorSpotFile)
     imageDict = listSubWedge[0]
     listXdsIndexingTask = []
     listResult = []
     listSpaceGroup = []
     # Run XDS indexing
     xdsIndexinInData = {
         "subWedge": listSubWedge,
         "dozorSpotFile": listDozorSpotFile
     }
     xdsIndexingTask = XDSIndexing(
         inData=xdsIndexinInData,
         workingDirectorySuffix=UtilsImage.getPrefix(imageDict["image"][0]["path"])
     )
     xdsIndexingTask.execute()
     xparmXdsPath = None
     if xdsIndexingTask.isSuccess():
         xdsIndexingOutData = xdsIndexingTask.outData
         xparmXdsPath = xdsIndexingOutData["xparmXdsPath"]
         resultIndexing = ControlIndexing.getResultIndexingFromXds(xdsIndexingOutData)
     outData = {
         "resultIndexing": resultIndexing,
         "resultDozor": listOutDataControlDozor,
         "xparmXdsPath": xparmXdsPath
     }
     return outData
Пример #3
0
    def getResultIndexingFromXds(xdsIndexingOutData):
        idxref = xdsIndexingOutData["idxref"]
        xparamDict = xdsIndexingOutData["xparm"]
        if "A" in xparamDict:
            # Calculate MOSFLM UB matrix
            A = np.array(xparamDict["A"])
            B = np.array(xparamDict["B"])
            C = np.array(xparamDict["C"])

            volum = np.cross(A, B).dot(C)
            Ar = np.cross(B, C) / volum
            Br = np.cross(C, A) / volum
            Cr = np.cross(A, B) / volum
            UBxds = np.array([Ar, Br, Cr]).transpose()

            BEAM = np.array(xparamDict["beam"])
            ROT = np.array(xparamDict["rot"])
            wavelength = 1 / np.linalg.norm(BEAM)

            xparamDict["cell_volum"] = volum
            xparamDict["wavelength"] = wavelength
            xparamDict["Ar"] = Ar.tolist()
            xparamDict["Br"] = Br.tolist()
            xparamDict["Cr"] = Cr.tolist()
            xparamDict["UB"] = UBxds.tolist()

            normROT = float(np.linalg.norm(ROT))
            CAMERA_z = np.true_divide(ROT, normROT)
            CAMERA_y = np.cross(CAMERA_z, BEAM)
            normCAMERA_y = float(np.linalg.norm(CAMERA_y))
            CAMERA_y = np.true_divide(CAMERA_y, normCAMERA_y)
            CAMERA_x = np.cross(CAMERA_y, CAMERA_z)
            CAMERA = np.transpose(np.array([CAMERA_x, CAMERA_y, CAMERA_z]))

            mosflmUB = CAMERA.dot(UBxds) * xparamDict["wavelength"]
            # mosflmUB = UBxds*xparamDict["wavelength"]
            # xparamDict["mosflmUB"] = mosflmUB.tolist()

            reciprocCell = XDSIndexing.reciprocal(xparamDict["cell"])
            B = XDSIndexing.BusingLevy(reciprocCell)
            mosflmU = np.dot(mosflmUB,
                             np.linalg.inv(B)) / xparamDict["wavelength"]
            # xparamDict[

            resultIndexing = {
                "spaceGroupNumber": idxref["spaceGroupNumber"],
                "cell": {
                    "a": idxref["a"],
                    "b": idxref["b"],
                    "c": idxref["c"],
                    "alpha": idxref["alpha"],
                    "beta": idxref["beta"],
                    "gamma": idxref["gamma"],
                },
                "xBeam": idxref["xBeam"],
                "yBeam": idxref["yBeam"],
                "distance": idxref["distance"],
                "qualityOfFit": idxref["qualityOfFit"],
                "mosaicity": idxref["mosaicity"],
                "XDS_xparm": xparamDict,
                "mosflmB": mosflmU.tolist(),
                "mosflmU": mosflmU.tolist(),
            }
        else:
            resultIndexing = {}
        return resultIndexing
Пример #4
0
 def test_parseXparm(self):
     xparmPath = self.dataPath / 'XPARM.XDS'
     xparmDict = XDSIndexing.parseXparm(xparmPath)
     self.assertIsNotNone(xparmDict)
Пример #5
0
 def test_readIdxrefLp(self):
     idxRefLpPath = self.dataPath / 'IDXREF.LP_TRYP'
     resultXDSIndexing = XDSIndexing.readIdxrefLp(idxRefLpPath)
Пример #6
0
 def test_execute_XDSIndexing(self):
     referenceDataPath = self.dataPath / 'inDataXDSIndexing.json'
     inData = UtilsTest.loadAndSubstitueTestData(referenceDataPath)
     xdsIndexing = XDSIndexing(inData=inData)
     xdsIndexing.execute()
     self.assertTrue(xdsIndexing.isSuccess())