def test_getTables(self):
     dictDnaTables = UtilsDnaTables.getDict(
         self.dataPath / "indexingTwoImagesDnaTables.xml")
     listTables = UtilsDnaTables.getTables(dictDnaTables,
                                           "autoindex_solutions")
     # logger.info(pprint.pformat(listTables))
     self.assertGreaterEqual(len(list(listTables)), 1)
示例#2
0
 def test_getListParam(self):
     dictDnaTables = UtilsDnaTables.getDict(
         self.dataPath / 'indexingTwoImagesDnaTables.xml')
     listTables = UtilsDnaTables.getTables(dictDnaTables,
                                           'autoindex_solutions')
     listParameter = UtilsDnaTables.getListParam(listTables[0])
     # logger.info(pprint.pformat(listParameter))
     self.assertGreaterEqual(len(listParameter), 1)
 def test_getListValue(self):
     # Mosaicity
     dictDnaTables = UtilsDnaTables.getDict(
         self.dataPath / "indexingTwoImagesDnaTables.xml")
     listTables = UtilsDnaTables.getTables(dictDnaTables,
                                           "mosaicity_estimation")
     listParameter = UtilsDnaTables.getListParam(listTables[0])
     # logger.info(pprint.pformat(listParameter))
     self.assertEqual(
         UtilsDnaTables.getListValue(listParameter, "mosaicity", "value"),
         0.1)
     # Refinement
     listTablesRefinement = UtilsDnaTables.getTables(
         dictDnaTables, "refinement")
     tableRefinement = listTablesRefinement[0]
     listParamRefinement = UtilsDnaTables.getListParam(tableRefinement)
     # logger.info(pprint.pformat(listParamRefinement))
     self.assertEqual(
         UtilsDnaTables.getListValue(listParamRefinement, "parameters",
                                     "used"), 204)
     self.assertEqual(
         UtilsDnaTables.getListValue(listParamRefinement, "results",
                                     "detector_distance"),
         305.222015,
     )
     self.assertEqual(
         UtilsDnaTables.getListValue(listParamRefinement, "deviations",
                                     "positional"),
         1.351692,
     )
示例#4
0
 def test_getListValue(self):
     # Mosaicity
     dictDnaTables = UtilsDnaTables.getDict(
         self.dataPath / 'indexingTwoImagesDnaTables.xml')
     listTables = UtilsDnaTables.getTables(dictDnaTables,
                                           'mosaicity_estimation')
     listParameter = UtilsDnaTables.getListParam(listTables[0])
     # logger.info(pprint.pformat(listParameter))
     self.assertEqual(
         UtilsDnaTables.getListValue(listParameter, 'mosaicity', 'value'),
         0.1)
     # Refinement
     listTablesRefinement = UtilsDnaTables.getTables(
         dictDnaTables, 'refinement')
     tableRefinement = listTablesRefinement[0]
     listParamRefinement = UtilsDnaTables.getListParam(tableRefinement)
     # logger.info(pprint.pformat(listParamRefinement))
     self.assertEqual(
         UtilsDnaTables.getListValue(listParamRefinement, 'parameters',
                                     'used'), 204)
     self.assertEqual(
         UtilsDnaTables.getListValue(listParamRefinement, 'results',
                                     'detector_distance'), 305.222015)
     self.assertEqual(
         UtilsDnaTables.getListValue(listParamRefinement, 'deviations',
                                     'positional'), 1.351692)
 def test_getItemValue(self):
     dictDnaTables = UtilsDnaTables.getDict(
         self.dataPath / "indexingTwoImagesDnaTables.xml")
     listTables = UtilsDnaTables.getTables(dictDnaTables,
                                           "autoindex_solutions")
     listParameter = UtilsDnaTables.getListParam(listTables[0])
     dictParam = listParameter[0]
     # logger.info(pprint.pformat(dictParam))
     self.assertEqual(UtilsDnaTables.getItemValue(dictParam, "penalty"),
                      999)
     self.assertEqual(UtilsDnaTables.getItemValue(dictParam, "lattice"),
                      "cI")
     self.assertEqual(UtilsDnaTables.getItemValue(dictParam, "a"),
                      121.869148)
示例#6
0
 def test_getItemValue(self):
     dictDnaTables = UtilsDnaTables.getDict(
         self.dataPath / 'indexingTwoImagesDnaTables.xml')
     listTables = UtilsDnaTables.getTables(dictDnaTables,
                                           'autoindex_solutions')
     listParameter = UtilsDnaTables.getListParam(listTables[0])
     dictParam = listParameter[0]
     # logger.info(pprint.pformat(dictParam))
     self.assertEqual(UtilsDnaTables.getItemValue(dictParam, 'penalty'),
                      999)
     self.assertEqual(UtilsDnaTables.getItemValue(dictParam, 'lattice'),
                      'cI')
     self.assertEqual(UtilsDnaTables.getItemValue(dictParam, 'a'),
                      121.869148)
 def test_getDict(self):
     dictDnaTables = UtilsDnaTables.getDict(
         self.dataPath / "indexingTwoImagesDnaTables.xml")
     # logger.info(pprint.pformat(dictDnaTables))
     self.assertTrue(dictDnaTables is not None)
示例#8
0
 def parseIndexingMosflmOutput(self, newMatFilePath, dnaTablesFilePath):
     outData = {}
     # Read Newmat file
     newmat = self.getNewmat(newMatFilePath)
     if newmat is None:
         errorMessage = "MOSFLM indexing error : No solution was obtained!"
         logger.error(errorMessage)
         self.setFailure()
     else:
         outData['newmat'] = self.getNewmat(newMatFilePath)
         # Then read the XML file
         dictDnaTables = UtilsDnaTables.getDict(dnaTablesFilePath)
         # Mosaicity estimation
         listTablesMosaicity = UtilsDnaTables.getTables(
             dictDnaTables, 'mosaicity_estimation')
         mosaicityValueSum = 0.0
         nValues = 0
         for table in listTablesMosaicity:
             listParam = UtilsDnaTables.getListParam(table)
             mosaicityValue = UtilsDnaTables.getListValue(
                 listParam, 'mosaicity', 'value')
             mosaicityValueSum += mosaicityValue
             nValues += 1
         outData['mosaicityEstimation'] = mosaicityValueSum / nValues
         # Refinement
         listTablesRefinement = UtilsDnaTables.getTables(
             dictDnaTables, 'refinement')
         tableRefinement = listTablesRefinement[0]
         listParamRefinement = UtilsDnaTables.getListParam(tableRefinement)
         outData['deviationAngular'] = UtilsDnaTables.getListValue(
             listParamRefinement, 'deviations', 'angular')
         outData['refinedDistance'] = UtilsDnaTables.getListValue(
             listParamRefinement, 'results', 'detector_distance')
         outData['spotsUsed'] = UtilsDnaTables.getListValue(
             listParamRefinement, 'parameters', 'used')
         outData['spotsTotal'] = UtilsDnaTables.getListValue(
             listParamRefinement, 'parameters', 'out_of')
         # Solution refinement
         listTablesSolutionRefinement = UtilsDnaTables.getTables(
             dictDnaTables, 'solution_refinement')
         tableSolutionRefinement = listTablesSolutionRefinement[0]
         listSolutionRefinement = UtilsDnaTables.getListParam(
             tableSolutionRefinement)
         outData['selectedSolutionNumber'] = UtilsDnaTables.getListValue(
             listSolutionRefinement, 'selection', 'number')
         outData[
             'selectedSolutionSpaceGroup'] = UtilsDnaTables.getListValue(
                 listSolutionRefinement, 'selection', 'spacegroup')
         outData[
             'selectedSolutionSpaceGroupNumber'] = UtilsDnaTables.getListValue(
                 listSolutionRefinement, 'selection', 'spacegroup_number')
         # Autoindex solutions
         listTablesAutoIndexSolution = UtilsDnaTables.getTables(
             dictDnaTables, 'autoindex_solutions')
         listIndexingSolution = []
         tablesAutoIndexSolution = listTablesAutoIndexSolution[0]
         listAutoindexSolutions = UtilsDnaTables.getListParam(
             tablesAutoIndexSolution)
         for autoIndexSolution in listAutoindexSolutions:
             indexingSolution = {
                 'index':
                 UtilsDnaTables.getItemValue(autoIndexSolution, 'index'),
                 'penalty':
                 UtilsDnaTables.getItemValue(autoIndexSolution, 'penalty'),
                 'lattice':
                 UtilsDnaTables.getItemValue(autoIndexSolution, 'lattice'),
                 'a':
                 UtilsDnaTables.getItemValue(autoIndexSolution, 'a'),
                 'b':
                 UtilsDnaTables.getItemValue(autoIndexSolution, 'b'),
                 'c':
                 UtilsDnaTables.getItemValue(autoIndexSolution, 'c'),
                 'alpha':
                 UtilsDnaTables.getItemValue(autoIndexSolution, 'alpha'),
                 'beta':
                 UtilsDnaTables.getItemValue(autoIndexSolution, 'beta'),
                 'gamma':
                 UtilsDnaTables.getItemValue(autoIndexSolution, 'gamma')
             }
             listIndexingSolution.append(indexingSolution)
         outData['indexingSolution'] = listIndexingSolution
         #  Beam refinement
         listTablesBeamRefinement = UtilsDnaTables.getTables(
             dictDnaTables, 'beam_refinement')
         tableBeamRefinement = listTablesBeamRefinement[0]
         listRefinedBeam = UtilsDnaTables.getListParam(tableBeamRefinement)
         initialBeamPositionX = UtilsDnaTables.getListValue(
             listRefinedBeam, 'initial_beam', 'x')
         initialBeamPositionY = UtilsDnaTables.getListValue(
             listRefinedBeam, 'initial_beam', 'y')
         refinedBeamPositionX = UtilsDnaTables.getListValue(
             listRefinedBeam, 'refined_beam', 'x')
         refinedBeamPositionY = UtilsDnaTables.getListValue(
             listRefinedBeam, 'refined_beam', 'y')
         beamPositionRefined = {
             'x': refinedBeamPositionX,
             'y': refinedBeamPositionY
         }
         outData['refinedBeam'] = beamPositionRefined
         beamPositionShift = {
             'x': initialBeamPositionX - refinedBeamPositionX,
             'y': initialBeamPositionY - refinedBeamPositionY,
         }
         outData['beamShift'] = beamPositionShift
     return outData