def testGenerateMOSFLMCommands(self):
        """
        """
        pluginGeneratePrediction = self.createPlugin()
        pluginGeneratePrediction.setScriptExecutable("cat")
        pluginGeneratePrediction.configure()
        xsDataMOSFLMInputGeneratePrediction = self.generateDataMOSFLMInputGeneratePrediction(
        )
        pluginGeneratePrediction.setDataInput(
            xsDataMOSFLMInputGeneratePrediction)
        pluginGeneratePrediction.generateMOSFLMCommands()
        listCommandsReference = [
            'WAVELENGTH 0.934', 'DISTANCE 198.4', 'BEAM 102.5 104.7',
            'DETECTOR ADSC', 'DIRECTORY ' + self.strDataImagePath,
            'TEMPLATE ref-testscale_1_###.img', 'XGUI ON',
            'IMAGE 1 PHI 0.000000 TO 1.000000', 'GO', 'PREDICT_SPOTS',
            'CREATE_IMAGE PREDICTION ON BINARY TRUE FILENAME ' +
            pluginGeneratePrediction.getPredictionImageFileName(), 'RETURN',
            'EXIT'
        ]
        listCommands = pluginGeneratePrediction.getListCommandExecution()
        #print listCommandsReference
        #print listCommands
        EDAssert.equal(listCommandsReference, listCommands)

        self.cleanUp(pluginGeneratePrediction)
    def testExecute(self):
        """
        """
        plugin = self.getPlugin()
        plugin.__class__.dictHPLC = {}
        self.run()

################################################################################
# Compare XSDataResults
################################################################################

        strExpectedOutput = self.readAndParseFile (self.getReferenceDataOutputFile())
        EDVerbose.DEBUG("Checking obtained result...")
        xsDataResultReference = XSDataResultBioSaxsHPLCv1_0.parseString(strExpectedOutput)
        xsDataResultObtained = plugin.getDataOutput()
        EDAssert.strAlmostEqual(xsDataResultReference.marshal(), xsDataResultObtained.marshal(), "XSDataResult output are the same", _strExcluded="bioSaxs")


################################################################################
# Compare Ascii files
################################################################################
        asciiObt = os.linesep.join([i.strip() for i in  open(xsDataResultObtained.integratedCurve.path.value) if "Raster" not in i])
        asciiRef = os.linesep.join([i.strip() for i in  open(os.path.join(self.getTestsDataImagesHome(), "bioSaxsProcessIntegrated1_2.dat")) if "Raster" not in i])

        EDAssert.strAlmostEqual(asciiRef, asciiObt, _strComment="3 column ascii files are the same", _fRelError=0.1, _strExcluded=os.environ["USER"])
        EDVerbose.screen("Execution time for %s: %.3fs" % (plugin.getClassName(), plugin.getRunTime()))
 def testParseMosflmScriptsOutput(self):
     """
     This method tests the parsing of the MOSFLM script generated by Labelit.
     """
     edPluginLabelitv10 = self.createPlugin()
     # First file from version 1000rc11
     strPathToMOSFLMScript = os.path.join(self.getPluginTestsDataHome(), "integration05_csh_v1000rc11.txt")
     strMOSFLMScript = self.readAndParseFile(strPathToMOSFLMScript)
     xsDataLabelitMosflmScriptsOutput = edPluginLabelitv10.parseMosflmScriptsOutput(strMOSFLMScript)
     xsDataLabelitMosflmScriptsOutput.exportToFile("XSDataLabelitMosflmScriptsOutput_reference.xml")
     strLabelitMosflmScriptsOutputFile = os.path.join(self.getPluginTestsDataHome(), "XSDataLabelitMosflmScriptsOutput_reference.xml")
     strLabelitMosflmScriptsOutputXML = self.readAndParseFile(strLabelitMosflmScriptsOutputFile)
     from XSDataLabelitv10 import XSDataLabelitMosflmScriptsOutput
     xsDataLabelitMosflmScriptsOutputReference = XSDataLabelitMosflmScriptsOutput.parseString(strLabelitMosflmScriptsOutputXML)
     EDAssert.equal(xsDataLabelitMosflmScriptsOutputReference.marshal(), xsDataLabelitMosflmScriptsOutput.marshal())
     # Second file from version 1000b1
     strPathToMOSFLMScript = os.path.join(self.getPluginTestsDataHome(), "integration05_csh_v1000b1.txt")
     strMOSFLMScript = self.readAndParseFile(strPathToMOSFLMScript)
     xsDataLabelitMosflmScriptsOutput = edPluginLabelitv10.parseMosflmScriptsOutput(strMOSFLMScript)
     xsDataLabelitMosflmScriptsOutput.exportToFile("XSDataLabelitMosflmScriptsOutput_v1000b1_reference.xml")
     strLabelitMosflmScriptsOutputFile = os.path.join(self.getPluginTestsDataHome(), "XSDataLabelitMosflmScriptsOutput_v1000b1_reference.xml")
     strLabelitMosflmScriptsOutputXML = self.readAndParseFile(strLabelitMosflmScriptsOutputFile)
     from XSDataLabelitv10 import XSDataLabelitMosflmScriptsOutput
     xsDataLabelitMosflmScriptsOutputReference = XSDataLabelitMosflmScriptsOutput.parseString(strLabelitMosflmScriptsOutputXML)
     EDAssert.equal(xsDataLabelitMosflmScriptsOutputReference.marshal(), xsDataLabelitMosflmScriptsOutput.marshal())
 def testCopyHTMLFilesAndDir(self):
     if not os.path.exists(EDUtilsPath.getEdnaUserTempFolder()):
         os.mkdir(EDUtilsPath.getEdnaUserTempFolder())
     strTestFromDir = os.path.join(EDUtilsPath.getEdnaUserTempFolder(), "TestFromDir")
     shutil.rmtree(strTestFromDir, ignore_errors=True)
     os.mkdir(strTestFromDir)
     strTestHtmlFilePath = os.path.join(strTestFromDir, "index.html")
     strTestHtmlDirPath = os.path.join(strTestFromDir, "index")
     EDUtilsFile.writeFile(strTestHtmlFilePath, "Test content")
     if not os.path.exists(strTestHtmlDirPath):
         os.mkdir(strTestHtmlDirPath)
     strTestHtmlDirFilePath = os.path.join(strTestHtmlDirPath, "test.txt")
     EDUtilsFile.writeFile(strTestHtmlDirFilePath, "Test content")
     #
     strTestToDir = os.path.join(EDUtilsPath.getEdnaUserTempFolder(), "TestToDir")
     shutil.rmtree(strTestToDir, ignore_errors=True)
     os.mkdir(strTestToDir)
     EDHandlerESRFPyarchv1_0.copyHTMLDir(strTestFromDir, strTestToDir)
     #
     # Check that files exist in strTestToDir:
     EDAssert.isFile(os.path.join(strTestToDir, "index", "index.html"))
     EDAssert.isFile(os.path.join(strTestToDir, "index", "index", "test.txt"))
     #
     shutil.rmtree(strTestFromDir, ignore_errors=True)
     shutil.rmtree(strTestToDir, ignore_errors=True)
 def testGenerateExecutableScript(self):
     listCommands = ['COMMAND1', 'COMMAND2 BANANA']
     edPluginExecProcessScript = EDPluginExecProcessScript()
     edPluginExecProcessScript.setScriptShell("/bin/bash")
     edPluginExecProcessScript.setScriptBaseName("TestCaseGenerateScript")
     edPluginExecProcessScript.setListCommandExecution(listCommands)
     edPluginExecProcessScript.setRequireCCP4(True)
     edPluginExecProcessScript.setSetupCCP4("/usr/local/xtal/ccp4-6.0.2/include/ccp4.setup-bash")
     edPluginExecProcessScript.setScriptExecutable("cat")
     edPluginExecProcessScript.configure()
     strScript = edPluginExecProcessScript.prepareScript()
     edPluginExecProcessScript.writeExecutableScript(strScript)
     strScriptFileName = edPluginExecProcessScript.getScriptFileName()
     strScriptFromFile = edPluginExecProcessScript.readProcessFile(strScriptFileName)
     lstScriptReference = ["#!/bin/bash",
                          "cd %s" % edPluginExecProcessScript.getWorkingDirectory(),
                          ". /usr/local/xtal/ccp4-6.0.2/include/ccp4.setup-bash",
                          "cat  > TestCaseGenerateScript.log 2> TestCaseGenerateScript.err << EOF-EDPluginExecProcessScript &",
                          "COMMAND1",
                          "COMMAND2 BANANA",
                          "EOF-EDPluginExecProcessScript",
                          "ednaJobPid=$!",
                          "ednaJobHostName=$(hostname)",
                          'echo "$ednaJobHostName $ednaJobPid" > %s' % edPluginExecProcessScript.getPathToHostNamePidFile(),
                          "wait $ednaJobPid",
                          ""]
     strScriptReference = EDUtilsPlatform.linesep.join(lstScriptReference)
     EDAssert.equal(strScriptFromFile, strScriptReference)
    def testExecute(self):
        self.run()

        # Checks that there are no error messages

        plugin = self.getPlugin()

        # Checks the expected result
        strExpectedOutput = self.readAndParseFile(self.strReferenceDataOutputFile)
        # Check that all the paths in the prediction results actaully exists
        from XSDataMXv1 import XSDataIndexingResult
        xsDataIndexingResultObtained = plugin.getDataOutput()
        xsDataIndexingResultExpected = XSDataIndexingResult.parseString(strExpectedOutput)
        xsDataGeneratePredictionResult = xsDataIndexingResultObtained.getPredictionResult()
        for predictionImage in xsDataGeneratePredictionResult.getPredictionImage():
            strImagePath = predictionImage.getPath().getValue()
            bImageExists = os.path.exists(strImagePath)
            EDAssert.equal(True, bImageExists)
        # Check that we found the right space group
        xsDataIndexingSolutionSelectedObtained = xsDataIndexingResultObtained.getSelectedSolution()
        xsDataIndexingSolutionSelectedExpected = xsDataIndexingResultExpected.getSelectedSolution()

        xsDataCrystalObtained = xsDataIndexingSolutionSelectedObtained.getCrystal()
        xsDataCrystalExpected = xsDataIndexingSolutionSelectedExpected.getCrystal()

        xsDataSpaceGroupObtained = xsDataCrystalObtained.getSpaceGroup()
        xsDataSpaceGroupExpected = xsDataCrystalExpected.getSpaceGroup()

        strSpacegroupNameObtained = xsDataSpaceGroupObtained.getName().getValue()
        strSpacegroupNameExpected = xsDataSpaceGroupExpected.getName().getValue()

        EDAssert.equal(strSpacegroupNameExpected, strSpacegroupNameObtained)
示例#7
0
    def testExecute(self):
        """
        """
        self.run()
        #        plugin = self.getPlugin()

        strExpectedOutput = self.readAndParseFile(
            self.getReferenceDataOutputFile())
        strObtainedOutput = self.readAndParseFile(
            self.m_edObtainedOutputDataFile)
        EDVerbose.DEBUG("Checking obtained result...")
        xsDataResultReference = XSDataResultNormalize.parseString(
            strExpectedOutput)
        xsDataResultObtained = XSDataResultNormalize.parseString(
            strObtainedOutput)

        #EDAssert.strAlmostEqual(xsDataResultReference.marshal(), xsDataResultObtained.marshal(), "Result XML are the same")

        npaReference = EDUtilsArray.getArray(xsDataResultReference.output)
        npaObtained = EDUtilsArray.getArray(xsDataResultObtained.output)
        EDAssert.arraySimilar(npaReference,
                              npaObtained,
                              "Arrays are the same",
                              _fAbsMaxDelta=1e-6)
        EDAssert.equal(npaReference.dtype, npaObtained.dtype,
                       "Datatypes are the same")
    def testDefaultChemicalComposition(self):
        edPluginStrategy = self.createPlugin()

        from XSDataCommon import XSDataAngle
        from XSDataCommon import XSDataLength
        from XSDataMXv1 import XSDataSampleCrystalMM
        from XSDataMXv1 import XSDataCrystal
        from XSDataMXv1 import XSDataCell


        xsDataSampleCrystalMM = XSDataSampleCrystalMM()
        xsDataCrystal = XSDataCrystal()
        xsDataCell = XSDataCell(XSDataAngle(90.0),
                                 XSDataAngle(90.0),
                                 XSDataAngle(90.0),
                                 XSDataLength(78.9),
                                 XSDataLength(95.162),
                                 XSDataLength(104.087))
        xsDataCrystal.setCell(xsDataCell)
        xsDataSampleCrystalMM.setCrystal(xsDataCrystal)
        inumOperators = 4

        xsDataSample2 = edPluginStrategy.getDefaultChemicalComposition(xsDataSampleCrystalMM, inumOperators)
        strChainType = xsDataSample2.getStructure().getChain()[0].getType()
        EDAssert.equal("protein", strChainType.getValue())
示例#9
0
    def testParseLabelitDistlOutput(self):
        """
        This method test the parsing of the distl.signal_strength results in the log file.
        """
        edPluginDistlSignalStrengthv1_1 = self.createPlugin()
        strPathToLabelitLogText = os.path.join(self.getPluginTestsDataHome(),
                                               "dstl.signal_strength.log")
        strLabelitLogText = self.readAndParseFile(strPathToLabelitLogText)
        xsDataImageQualityIndicators = edPluginDistlSignalStrengthv1_1.parseLabelitDistlOutput(
            strLabelitLogText)
        xmlInput1 = self.readAndParseFile(self.__strReferenceInputFile1)
        xsDataInputDistlSignalStrength = XSDataInputDistlSignalStrength.parseString(
            xmlInput1)
        xsDataImageQualityIndicators.setImage(
            xsDataInputDistlSignalStrength.getReferenceImage())

        strResultDistlSignalStrengthFile = os.path.join(
            self.getPluginTestsDataHome(),
            "XSDataResultDistlSignalStrength_reference.xml")
        strResultDistlSignalStrength = self.readAndParseFile(
            strResultDistlSignalStrengthFile)
        xsDataResultDistlSignalStrength = XSDataResultDistlSignalStrength.parseString(
            strResultDistlSignalStrength)
        xsDataImageQualityIndicatorsReference = xsDataResultDistlSignalStrength.getImageQualityIndicators(
        )
        EDAssert.equal(xsDataImageQualityIndicatorsReference.marshal(),
                       xsDataImageQualityIndicators.marshal())
    def preProcess(self, _edObject=None):
        EDPluginHDF5.preProcess(self)
        self.DEBUG("EDPluginHDF5StackImagesv10test.preProcess")

        for onefile in self.dataInput.inputImageFile:
            if onefile.path is not None:
                self.listImageFilenames.append(onefile.path.value)
            if onefile.date is not None:
                self.listImageDates.append(onefile.date.value)
            if onefile.number is not None:
                self.listForcedPositions.append(onefile.number.value)
            self.listArray.append(EDUtilsArray.getArray(onefile))

        for oneArray in self.dataInput.getInputArray():
            self.listArray.append(EDUtilsArray.xsDataToArray(oneArray))

        if self.dataInput.index != []:
            self.listForcedPositions = [i.value for i in self.dataInput.index]

        if self.dataInput.getDeleteInputImage() is not None:
            self.bDeleteImage = bool(self.dataInput.deleteInputImage.value)

        if self.listForcedPositions != []:
            EDAssert.equal(len(self.listForcedPositions), max(len(self.listImageFilenames), len(self.listArray)), "Forced position list has a good length")
        if self.listImageDates != []:
            EDAssert.equal(len(self.listImageDates) , len(self.listImageFilenames), "listImageDates has the same size as listImageFilenames")
    def testExecute(self):
        """
        """
        self.run()

        # Checks that there are no error messages

        plugin = self.getPlugin()

        # Checks the expected result
        strExpectedOutput = self.readAndParseFile (self.getReferenceDataOutputFile())
#        strObtainedOutput = plugin.getDataOutput().marshal() # EDUtilsTest.readAndParseFile ( self.m_edObtainedOutputDataFile )    
        EDVerbose.DEBUG("Checking obtained result...")


        xsDataResultReference = XSDataResultDiffractionCT.parseString(strExpectedOutput)
        xsDataResultObtained = plugin.getDataOutput()# XSDataResultDiffractionCT.parseString(strObtainedOutput)

        EDAssert.equal(xsDataResultReference.marshal(), xsDataResultObtained.marshal())

        ref = self.readAndParseFile(os.path.join(self.getTestsDataImagesHome(), "DCT2011March.chi"))
        obt = self.readAndParseFile(xsDataResultObtained.getIntegratedIntensities().getPath().getValue())
        EDAssert.strAlmostEqual(ref, obt, "Chi files are the same", 0.001)

# clean up SPD when finished
        EDFactoryPluginStatic.loadPlugin("EDPluginSPDCorrectv10").killAllWorkers()
示例#12
0
    def testExecute(self):
        """
        """
        self.run()
        plugin = self.getPlugin()

        strExpectedOutput = self.readAndParseFile(
            self.getReferenceDataOutputFile())
        xsDataResultReference = XSDataResultSPDCake.parseString(
            strExpectedOutput)
        xsDataResultObtained = plugin.getDataOutput()
        #        EDVerbose.DEBUG("Reference XML:%s" + xsDataResultReference.marshal())
        #        EDVerbose.DEBUG("Obtained XML:%s" + xsDataResultObtained.marshal())
        EDAssert.strAlmostEqual(xsDataResultReference.marshal(),
                                xsDataResultObtained.marshal(),
                                "XSDataResult output are the same")

        # Checking obtained results
        xsDataResultsSPDCake = plugin.getDataOutput()
        strPathToChiOutput = xsDataResultsSPDCake.getCakedFile().getPath(
        ).getValue()
        strDataObtained = EDUtilsFile.readFile(strPathToChiOutput)
        strDataReference = EDUtilsFile.readFile(
            os.path.join(self.getTestsDataImagesHome(),
                         "EDPluginSPDCakev1_1.cif"))
        EDAssert.strAlmostEqual(strDataReference,
                                strDataObtained,
                                "Comparing PowderCIF output",
                                _fAbsError=2e-3)
    def preProcess(self, _edObject=None):
        EDPluginHDF5.preProcess(self)
        self.DEBUG("EDPluginHDF5StackImagesv10.preProcess")

        for onefile in self.dataInput.inputImageFile:
            if onefile is None:
                self.ERROR("Please investigate why  EDPluginHDF5StackImagesv10.dataInput.inputImageFile is a list containing None !!!!")
                self.setFailure()
                continue
            if onefile.path is not None:
                self.listImageFilenames.append(onefile.path.value)
            if onefile.date is not None:
                self.listImageDates.append(onefile.date.value)
            if onefile.number is not None:
                self.listForcedPositions.append(onefile.number.value)
            self.listArray.append(EDUtilsArray.getArray(onefile))

        for oneArray in self.dataInput.inputArray:
            self.listArray.append(EDUtilsArray.xsDataToArray(oneArray))

        if self.dataInput.index != []:
            self.listForcedPositions = [i.value for i in self.dataInput.index]

        if self.dataInput.getDeleteInputImage() is not None:
            self.bDeleteImage = bool(self.dataInput.deleteInputImage.value)

        if self.listForcedPositions != []:
            EDAssert.equal(len(self.listForcedPositions), max(len(self.listImageFilenames), len(self.listArray)), "Forced position list has a good length")
        if self.listImageDates != []:
            EDAssert.equal(len(self.listImageDates) , len(self.listImageFilenames), "listImageDates has the same size as listImageFilenames")

        self.hdf5group = EDPluginHDF5.createStructure(self.strHDF5Filename, self.strHDF5Path, self.dictExtraAttributes)
    def testDropFileCreation( self ):
        """
        This test will check to make sure the dropfile is created correctly and saved properly
        """
        
        try :
            os.remove("../data/out/test2.drop")
        except :
            print "nothing to delete"
        
        try :
            os.rename("../data/create-ds.xml.icat","../data/create-ds.xml")
        except :
            print "nothing to delete"          
        
        # Create the plugin instance
        edPluginExecSRBRegister = self.createPlugin()
        # Read in the data from the XML, for the big xml 
        edStringInputExecSRBRegisterv10XML  = EDUtilsTest.readAndParseFile( self.m_edStringReferenceDataInputFile )

        # gives the data to the plugin
        edPluginExecSRBRegister.setDataInput( edStringInputExecSRBRegisterv10XML )
        
        # call the method
        edPluginExecSRBRegister.createDropFile();
        
        # finalise the process
        edPluginExecSRBRegister.moveGeneratedFiles()
        
        # check that the file has been created
        EDAssert.equal(True, os.path.isfile("../data/out/test2.drop"))
        EDAssert.equal(True, os.path.isfile("../data/create-ds.xml.icat"))
 def testSetDataOutput(self):
     """
     Test the setDataOutput method with different arguments
     """
     # Test 1: default output
     edPlugin = EDPlugin()
     xsDataStringTest = XSDataString("Test")
     edPlugin.setDataOutput(xsDataStringTest)
     EDAssert.equal(xsDataStringTest.marshal(), edPlugin.getDataOutput().marshal(), "Test 1: default output")
     # Test 2: named output
     edPlugin = EDPlugin()
     xsDataStringTest = XSDataString("Test")
     edPlugin.setDataOutput(xsDataStringTest, "testData")
     EDAssert.equal(xsDataStringTest.marshal(), edPlugin.getDataOutput("testData")[0].marshal(), "Test 2: named output")
     # Test 3: several inputs with the same name
     edPlugin = EDPlugin()
     xsDataStringTest1 = XSDataString("Test1")
     xsDataStringTest2 = XSDataString("Test2")
     edPlugin.setDataOutput(xsDataStringTest1, "testData")
     edPlugin.setDataOutput(xsDataStringTest2, "testData")
     pyListDataOutput = edPlugin.getDataOutput("testData")
     EDAssert.equal(xsDataStringTest1.marshal(), pyListDataOutput[0].marshal(), "Test 3: several inputs with the same name, 1")
     EDAssert.equal(xsDataStringTest2.marshal(), pyListDataOutput[1].marshal(), "Test 3: several inputs with the same name, 2")
     # Test 6: test of delDataOutput
     edPlugin = EDPlugin()
     xsDataStringTest = XSDataString("Test")
     edPlugin.setDataOutput(xsDataStringTest.marshal())
     edPlugin.delDataOutput()
     EDAssert.equal(None, edPlugin.getDataOutput(), "Test 6: test of delDataOutput")
    def testFileNameExtraction( self ):
        """
        This method should test to make sure that the plugin is extracting the correct file 
        list from the xml ingest file
        """
        
        try :
            os.rename("../data/create-ds.xml.icat","../data/create-ds.xml")
        except :
            print "nothing to delete"     
            
        # Create the plugin instance
        edPluginExecSRBRegister = self.createPlugin()
        # Read in the data from the XML 
        edStringInputExecSRBRegisterv10XML  = EDUtilsTest.readAndParseFile( self.m_edStringReferenceDataInputFile )

        # gives the data to the plugin
        edPluginExecSRBRegister.setDataInput( edStringInputExecSRBRegisterv10XML )
        
        edPluginExecSRBRegister.openXMLTree()
        
        edFilelist = edPluginExecSRBRegister.processFileList()
        
        # assert that the filelist is correct
        edTestlist = ["EDPluginExecSRBRegisterv10_output.xml\n"]
        
        EDAssert.equal(edFilelist,edTestlist)
 def testCreateBaseName(self):
     # Test 1 : naming of working directory
     edPlugin = EDPlugin()
     edPlugin.setBaseName("EDPlugin_testCreateBaseName")
     edPlugin.configure()
     strWorkingDir = edPlugin.getWorkingDirectory()
     EDAssert.equal(True, os.path.exists(strWorkingDir), "Test 1 : naming of working directory")
    def testExecute(self):
        """
        """
        self.run()

        # Checks that there are no error messages

        plugin = self.getPlugin()
        edPlugin = self.getPlugin()

        strBestVersion = self.getPlugin().getStringVersion()

        if strBestVersion.find("3.1.0") != -1 :
            self.setReferenceDataOutputFile(os.path.join(self.getPluginTestsDataHome(), "XSDataResultBest_reference.xml"))
        elif strBestVersion.find("3.2.0") != -1 :
            self.setReferenceDataOutputFile(os.path.join(self.getPluginTestsDataHome(), "XSDataResultBest_reference_BESTv320.xml"))

        # Checks the expected result
        strExpectedOutput = self.readAndParseFile(self.getReferenceDataOutputFile())

        from XSDataBestv1_1 import XSDataResultBest
        xsDataOutputExpected = XSDataResultBest.parseString(strExpectedOutput)
        xsDataOutputObtained = edPlugin.getDataOutput()

        EDAssert.equal(xsDataOutputExpected.marshal(), xsDataOutputObtained.marshal())
 def testRasterConfiguration(self):
     strPathToTestConfigFile = os.path.join(self.strUnitTestDataHome, "XSConfiguration_raster.xml")
     edConfiguration = EDConfiguration(strPathToTestConfigFile)
     edConfiguration.load()
     xsPluginItem = edConfiguration.getPluginItem("EDPluginMOSFLMv10")
     xsDataMOSFLMInput = XSDataMOSFLMInput()
     xsDataMOSFLMBeam = XSDataMOSFLMBeamPosition()
     xsDataMOSFLMBeam.setX(XSDataLength(1.0))
     xsDataMOSFLMBeam.setY(XSDataLength(2.0))
     xsDataMOSFLMInput.setBeam(xsDataMOSFLMBeam)
     xsDataMOSFLMDetector = XSDataMOSFLMDetector()
     xsDataMOSFLMDetector.setType(XSDataString("ADSC"))
     xsDataMOSFLMInput.setDetector(xsDataMOSFLMDetector)
     xsDataMOSFLMInput.setDirectory(XSDataString("/tmp"))
     xsDataMOSFLMInput.setTemplate(XSDataString("testdata_1_###.img"))
     xsDataMOSFLMInput.setWavelength(XSDataWavelength(1.1111))
     xsDataMOSFLMInput.setDistance(XSDataLength(222.22))
     edPluginMOSFLMv10 = self.createPlugin()
     edPluginMOSFLMv10.setScriptExecutable("cat")
     edPluginMOSFLMv10.setConfiguration(xsPluginItem)
     edPluginMOSFLMv10.configure()
     edPluginMOSFLMv10.setXSDataInputClass(XSDataMOSFLMInput)
     edPluginMOSFLMv10.setDataInput(xsDataMOSFLMInput)
     edPluginMOSFLMv10.generateMOSFLMCommands()
     edListCommands = edPluginMOSFLMv10.getListCommandExecution()
     edListCommandsReference = ['WAVELENGTH 1.1111', 'DISTANCE 222.22', 'BEAM 1.0 2.0', 'DETECTOR ADSC', 'DIRECTORY /tmp', 'TEMPLATE testdata_1_###.img', 'RASTER 15 15 3 3 3']
     EDAssert.equal(edListCommandsReference, edListCommands, "MOSFLM commands with ratser configured")
    def testExecute(self):
        """
        """
        self.run()
        plugin = self.getPlugin()
        ################################################################################
        # Compare XSDataResults
        ################################################################################
        strExpectedOutput = self.readAndParseFile(
            self.getReferenceDataOutputFile())
        EDVerbose.DEBUG("Checking obtained result...")

        xsDataResultObtained = plugin.getDataOutput()
        EDAssert.strAlmostEqual(self.xsDataResultReference.marshal(),
                                xsDataResultObtained.marshal(),
                                "XSDataResult output are the same")
        ################################################################################
        # Compare image Files
        ################################################################################
        outputData = Image.open(self.outputFile)
        referenceData = Image.open(
            os.path.join(self.getTestsDataImagesHome(),
                         os.path.basename(self.outputFile)))
        delta = ImageChops.difference(outputData, referenceData)
        deltaColor = delta.getextrema()
        i = 0
        for color in deltaColor:
            EDAssert.lowerThan(
                color[1], 12, "Maximum tone variation is %s for channel %s" %
                (color[1], "RGBA"[i]))
            i += 1
示例#21
0
    def testExecute(self):
        self.run()

        plugin = self.getPlugin()
        output = plugin.dataOutput
        EDAssert.equal(output.succeeded.value, True,
                       "HDF5 processing succeeded.")
    def testSpatialDistortion(self):
        strRefX = "spline-3-18x.edf"
        strRefY = "spline-3-18y.edf"
        self.loadTestImage([strRefX, strRefY])
        edPluginSPD = self.createPlugin()
        strXMLInput = EDUtilsFile.readFileAndParseVariables(self.strReferenceInputFileName)
        xsDataInputSPDCake = XSDataInputSPDCake.parseString(strXMLInput)
        edPluginSPD.setDataInput(xsDataInputSPDCake)
        edPluginSPD.configure()
        edPluginSPD.getInputParameter()
        ########################################################################
        # Enforce some values
        ########################################################################
        edPluginSPD.dictGeometry["SpatialDistortionFile"] = os.path.join(self.getTestsDataImagesHome(), "frelon_spline_file_to_correct_SPD.spline")
        edPluginSPD.dictGeometry["TiltRotation"] = 18
        edPluginSPD.dictGeometry["AngleOfTilt"] = 3
        spline = Spline()
        spline.read(edPluginSPD.dictGeometry["SpatialDistortionFile"])
        edPluginSPD.dictGeometry["PixelSizeX"], edPluginSPD.dictGeometry["PixelSizeY"] = spline.getPixelSize()
        edPluginSPD.createDisplacementMatrix(spline)
        edPluginSPD.cleanDispMat(edPluginSPD.getWorkingDirectory())

        refX = fabio.openimage.openimage(os.path.join(self.getTestsDataImagesHome(), strRefX)).data
        obtX = fabio.openimage.openimage(os.path.join(edPluginSPD.getWorkingDirectory(), "frelon_spline_file_to_correct_SPD-tilted-x.edf")).data
        refY = fabio.openimage.openimage(os.path.join(self.getTestsDataImagesHome(), strRefY)).data
        obtY = fabio.openimage.openimage(os.path.join(edPluginSPD.getWorkingDirectory(), "frelon_spline_file_to_correct_SPD-tilted-y.edf")).data

#        print edPluginSPD.dictGeometry
        EDAssert.arraySimilar(obtX, refX , _fAbsMaxDelta=0.1, _strComment="X displacement Matrix is the same")
        EDAssert.arraySimilar(obtY, refY , _fAbsMaxDelta=0.1, _strComment="Y displacement Matrix is the same")
 def test_createHtmlPage(self):
     strDimpleOutput = os.path.join(self.strDataPath, "dimple",
                                    "Dimplev1_0_dataOutput.xml")
     strResultDimple = self.readAndParseFile(strDimpleOutput)
     xsDataResultDimple = XSDataResultDimple.parseString(strResultDimple)
     strPdfPath = os.path.join(
         xsDataResultDimple.resultsDirectory.path.value, "DIMPLE.pdf")
     edPlugin = self.getPlugin()
     strPyarchRootDir = tempfile.mkdtemp(prefix="html_",
                                         dir=os.path.join(
                                             self.strDataPath, "dimple"))
     strPrefix = "xtal5w1_1"
     strProposal = "mx415"
     strSessionDate = "2015-02-23"
     strBeamline = "id29"
     strResultsDirectory = strPyarchRootDir
     listPath = edPlugin.copyResults(strPrefix, strPyarchRootDir,
                                     xsDataResultDimple, strPdfPath)
     listPathHtml = edPlugin.createHtmlPage(strPrefix, xsDataResultDimple,
                                            strResultsDirectory,
                                            strPyarchRootDir, strProposal,
                                            strSessionDate, strBeamline)
     for pathHtml in listPathHtml:
         EDAssert.equal(True, os.path.exists(pathHtml),
                        "HTML page generated")
     shutil.rmtree(strPyarchRootDir)
    def testExecute(self):
        """
        """
        self.run()

        # Checks that there are no error messages

        plugin = self.getPlugin()
        plugin.killAllWorkers()
#        if EDVerbose.isVerboseDebug():
#             plugin.cleanDispMat(plugin.getWorkingDirectory())
#        else:
#            plugin.cleanDispMat()

        # Checking obtained results
        xsDataResultSPD = plugin.getDataOutput()
        outputData = EDF(xsDataResultSPD.getCakedFile().getPath().getValue()).GetData(0)
        referenceData = EDF(os.path.join(self.getTestsDataImagesHome(), self.refOutput)).GetData(0)
#        print outputData.shape
#        print referenceData.shape
        relError = 100 * (abs(outputData - referenceData).max() - referenceData.min()) / (referenceData.max() - referenceData.min())
        absError = abs(outputData - referenceData).max()
        if relError > 5:
            EDAssert.lowerThan(relError, 5, "Maximum relative error = %.2f%%, Maximum Absolute Error %.2f" % (relError, absError))
        else:
            EDAssert.lowerThan(absError, 5, "Maximum relative error = %.2f%%, Maximum Absolute Error %.2f " % (relError, absError))
 def test_extractFinalResultsFromRefmac5RestrLog(self):
     strRefmacLogFilePath = os.path.join(self.strDataPath, "dimple",
                                         "08-refmac5_restr.log")
     edPlugin = self.getPlugin()
     strResults = edPlugin.extractFinalResultsFromRefmac5RestrLog(
         strRefmacLogFilePath)
     EDAssert.equal(True, strResults != "", "Read Refmac5restr log")
 def testGetParamItem(self):
     """
     Testing the XSParamItem inside an XSPluginItem
     """
     xsPluginItem = self.___edConfiguration.getPluginItem("indexingMosflm")
     xsParamItem = self.___edConfiguration.getParamItem(xsPluginItem, "workingDir")
     EDAssert.equal("workingDir", xsParamItem.getName())
    def testGenerateMOSFLMCommands(self):
        """
        """
        pluginGeneratePrediction = self.createPlugin()
        pluginGeneratePrediction.setScriptExecutable("cat")
        pluginGeneratePrediction.configure()
        xsDataMOSFLMInputGeneratePrediction = self.generateDataMOSFLMInputGeneratePrediction()
        pluginGeneratePrediction.setDataInput(xsDataMOSFLMInputGeneratePrediction)
        pluginGeneratePrediction.generateMOSFLMCommands()
        listCommandsReference = [
            "WAVELENGTH 0.934",
            "DISTANCE 198.4",
            "BEAM 102.5 104.7",
            "DETECTOR ADSC",
            "DIRECTORY " + self.strDataImagePath,
            "TEMPLATE ref-testscale_1_###.img",
            "XGUI ON",
            "IMAGE 1 PHI 0.000000 TO 1.000000",
            "GO",
            "PREDICT_SPOTS",
            "CREATE_IMAGE PREDICTION ON BINARY TRUE FILENAME " + pluginGeneratePrediction.getPredictionImageFileName(),
            "RETURN",
            "EXIT",
        ]
        listCommands = pluginGeneratePrediction.getListCommandExecution()
        # print listCommandsReference
        # print listCommands
        EDAssert.equal(listCommandsReference, listCommands)

        self.cleanUp(pluginGeneratePrediction)
    def testExecute(self):
        """
        """
        self.run()

        plugin = self.getPlugin()

        strExpectedOutput = self.readAndParseFile(
            self.getReferenceDataOutputFile())
        #        strObtainedOutput = self.readAndParseFile (self.m_edObtainedOutputDataFile)
        EDVerbose.DEBUG("Checking obtained result...")
        xsDataResultReference = XSDataResultSaxsMacv1_0.parseString(
            strExpectedOutput)
        xsDataResultObtained = plugin.getDataOutput()
        EDAssert.strAlmostEqual(xsDataResultReference.marshal(),
                                xsDataResultObtained.marshal(),
                                "XSDataResult output are the same")

        outputData = openimage(
            xsDataResultObtained.getOutputImage().getPath().getValue()).data
        referenceData = openimage(
            os.path.join(self.getTestsDataImagesHome(), "moke.edf")).data
        EDAssert.arraySimilar(outputData,
                              referenceData,
                              _fAbsMaxDelta=0.8,
                              _fScaledMaxDelta=0.05,
                              _fRfactor=5,
                              _fRelMaxDelta=1.5,
                              _strComment="Images are the same")
示例#29
0
 def testExecute(self):
     """
     """
     plugin = self.getPlugin()
     plugin.emptyItems()
     plugin.emptyQueries()
     plugin.addItem("data1")
     plugin.addItem("data2")
     plugin.addItem("data3")
     plugin.addItem("data4")
     plugin.addItem("data5")
     self.run()
     # Checking obtained results
     #        print plugin.getDataInput().marshal()
     #        print plugin.getDataOutput().marshal()
     xsDataResult = plugin.getDataOutput()
     strXMLRef = XSDataResultAccumulator.parseString(
         EDUtilsFile.readFile(self.getReferenceDataOutputFile())).marshal()
     EDAssert.equal(xsDataResult.marshal(), strXMLRef,
                    "XML results are conform")
     #        print plugin.getItems()
     EDAssert.equal(plugin.getItems(),
                    ['data1', 'data2', 'data3', 'data4', 'data5'],
                    "Remaining items are the same")
     plugin.emptyItems()
示例#30
0
 def testGenerateMOSFLMIntegrationCommands(self):
     strPathToTestConfigFile = os.path.join(self.strUnitTestDataHome,
                                            "XSConfiguration_unitTest.xml")
     edConfiguration = EDConfiguration(strPathToTestConfigFile)
     xsPluginItem = edConfiguration.getXSConfigurationItem(
         "EDPluginMOSFLMIntegrationv10")
     pluginIntegration = self.createPlugin()
     pluginIntegration.setScriptExecutable("cat")
     pluginIntegration.setConfiguration(xsPluginItem)
     pluginIntegration.configure()
     strXMLInputData = self.readAndParseFile(self.strReferenceDataInputFile)
     pluginIntegration.setDataInput(strXMLInputData)
     pluginIntegration.generateMOSFLMCommands()
     listCommandExecution = pluginIntegration.getListCommandExecution()
     listCommandReference = [
         'WAVELENGTH 0.934', 'DISTANCE 198.440994',
         'BEAM 102.478996 104.8862', 'DETECTOR ADSC',
         'DIRECTORY ' + self.strDataImagePath,
         'TEMPLATE ref-testscale_1_###.img', 'SYMMETRY P222',
         'MATRIX ' + pluginIntegration.getScriptBaseName() + '_matrix.mat',
         'MOSAIC 0.75', 'HKLOUT process_1_1.mtz',
         'PROCESS 1 TO 1 START 0.000000 ANGLE 1.000000', 'BEST ON', 'GO',
         'BEST OFF'
     ]
     EDAssert.equal(listCommandReference, listCommandExecution)
示例#31
0
 def testStartServer(self):
     """
     check the status after a job creation
     """
     edServer = EDServerXMLRCP.getInstance()
     if not edServer:
         EDAssert.equal(not None, edServer, "Server instance None")
 def testSetDataInput( self ):
     """
     This method test the setDataInput method of the SRBRegister plugin by providing an XML string
     and then retriving an XSDataInputLabelit object.  It checks both inputs
     """
     #Create the plugin instance
     edPluginExecSRBRegister = self.createPlugin()
     # create an object which contains the test information
     edStringInputExecSRBRegisterv10XML  = EDUtilsTest.readAndParseFile( self.m_edStringReferenceDataInputFile )
     # gives the data to the plugin
     edPluginExecSRBRegister.setDataInput( edStringInputExecSRBRegisterv10XML )
     # get the data from the plugin
     xsDataInputPluginExecSRBRegister = edPluginExecSRBRegister.getDataInput()
     # get the string of the path
     edStringPath = EDString( xsDataInputPluginExecSRBRegister.getSrbDropFileName().getPath().getValue() )
     # create the test path 
     edStringPathReference = EDString( "../data/out/test2.drop" )
     # Actually test the data.
     EDAssert.equal( edStringPathReference, edStringPath )
     
     # test the reading of the other data
     edStringPath = EDString( xsDataInputPluginExecSRBRegister.getXmlIngestFileName().getPath().getValue() )
     # create the test path 
     edStringPathReference = EDString( "../data/create-ds.xml" )
     # Actually test the data.
     EDAssert.equal( edStringPathReference, edStringPath )
 def testGenerateMOSFLMCommands(self):
     xsDataMOSFLMInput = XSDataMOSFLMInput()
     xsDataMOSFLMBeam = XSDataMOSFLMBeamPosition()
     xsDataMOSFLMBeam.setX(XSDataLength(1.0))
     xsDataMOSFLMBeam.setY(XSDataLength(2.0))
     xsDataMOSFLMInput.setBeam(xsDataMOSFLMBeam)
     xsDataMOSFLMDetector = XSDataMOSFLMDetector()
     xsDataMOSFLMDetector.setType(XSDataString("ADSC"))
     xsDataMOSFLMInput.setDetector(xsDataMOSFLMDetector)
     xsDataMOSFLMInput.setDirectory(XSDataString("/tmp"))
     xsDataMOSFLMInput.setTemplate(XSDataString("testdata_1_###.img"))
     xsDataMOSFLMInput.setWavelength(XSDataWavelength(1.1111))
     xsDataMOSFLMInput.setDistance(XSDataLength(222.22))
     edPluginMOSFLMv10 = self.createPlugin()
     edPluginMOSFLMv10.setScriptExecutable("cat")
     edPluginMOSFLMv10.configure()
     edPluginMOSFLMv10.setXSDataInputClass(XSDataMOSFLMInput)
     edPluginMOSFLMv10.setDataInput(xsDataMOSFLMInput)
     edPluginMOSFLMv10.generateMOSFLMCommands()
     edListCommands = edPluginMOSFLMv10.getListCommandExecution()
     edListCommandsReference = [
         'WAVELENGTH 1.1111', 'DISTANCE 222.22', 'BEAM 1.0 2.0',
         'DETECTOR ADSC', 'DIRECTORY /tmp', 'TEMPLATE testdata_1_###.img'
     ]
     EDAssert.equal(edListCommandsReference, edListCommands,
                    "MOSFLM commands")
     self.cleanUp(edPluginMOSFLMv10)
    def testExecute(self):
        """
        """
        self.run()
        plugin = self.getPlugin()

################################################################################
# Compare XSDataResults
################################################################################

        strExpectedOutput = self.readAndParseFile (self.getReferenceDataOutputFile())
#        strObtainedOutput = self.readAndParseFile (self.m_edObtainedOutputDataFile)
        EDVerbose.DEBUG("Checking obtained result...")
        xsDataResultReference = XSDataResultBioSaxsAsciiExportv1_0.parseString(strExpectedOutput)
        xsDataResultObtained = plugin.getDataOutput()
        EDAssert.strAlmostEqual(xsDataResultReference.marshal(), xsDataResultObtained.marshal(), "XSDataResult output are the same", _strExcluded="bioSaxs")

################################################################################
# Compare spectrum ascii Files
################################################################################

        outputData = open(xsDataResultObtained.getIntegratedCurve().getPath().value, "rb").read()
        referenceData = open(os.path.join(self.getTestsDataImagesHome(), "bioSaxsAsciiExportv1_1.dat"), "rb").read()

        EDAssert.strAlmostEqual(referenceData, outputData, _strComment="3-column ascii spectra files are the same", _fRelError=0.1, _fAbsError=0.1, _strExcluded="bioSaxs")
 def testRasterConfiguration(self):
     strPathToTestConfigFile = os.path.join(self.strUnitTestDataHome,
                                            "XSConfiguration_raster.xml")
     edConfiguration = EDConfiguration(strPathToTestConfigFile)
     xsPluginItem = edConfiguration.getXSConfigurationItem(
         "EDPluginMOSFLMv10")
     xsDataMOSFLMInput = XSDataMOSFLMInput()
     xsDataMOSFLMBeam = XSDataMOSFLMBeamPosition()
     xsDataMOSFLMBeam.setX(XSDataLength(1.0))
     xsDataMOSFLMBeam.setY(XSDataLength(2.0))
     xsDataMOSFLMInput.setBeam(xsDataMOSFLMBeam)
     xsDataMOSFLMDetector = XSDataMOSFLMDetector()
     xsDataMOSFLMDetector.setType(XSDataString("ADSC"))
     xsDataMOSFLMInput.setDetector(xsDataMOSFLMDetector)
     xsDataMOSFLMInput.setDirectory(XSDataString("/tmp"))
     xsDataMOSFLMInput.setTemplate(XSDataString("testdata_1_###.img"))
     xsDataMOSFLMInput.setWavelength(XSDataWavelength(1.1111))
     xsDataMOSFLMInput.setDistance(XSDataLength(222.22))
     edPluginMOSFLMv10 = self.createPlugin()
     edPluginMOSFLMv10.setScriptExecutable("cat")
     edPluginMOSFLMv10.setConfiguration(xsPluginItem)
     edPluginMOSFLMv10.configure()
     edPluginMOSFLMv10.setXSDataInputClass(XSDataMOSFLMInput)
     edPluginMOSFLMv10.setDataInput(xsDataMOSFLMInput)
     edPluginMOSFLMv10.generateMOSFLMCommands()
     edListCommands = edPluginMOSFLMv10.getListCommandExecution()
     edListCommandsReference = [
         'WAVELENGTH 1.1111', 'DISTANCE 222.22', 'BEAM 1.0 2.0',
         'DETECTOR ADSC', 'DIRECTORY /tmp', 'TEMPLATE testdata_1_###.img',
         'RASTER 15 15 3 3 3'
     ]
     EDAssert.equal(edListCommandsReference, edListCommands,
                    "MOSFLM commands with ratser configured")
    def testExecute(self):
        """
        """
        self.run()

        # Checks that there are no error messages

        plugin = self.getPlugin()
        edPlugin = self.getPlugin()

        strBestVersion = self.getPlugin().getStringVersion()

        if strBestVersion.find("3.1.0") != -1:
            self.setReferenceDataOutputFile(
                os.path.join(self.getPluginTestsDataHome(),
                             "XSDataResultBest_reference.xml"))
        elif strBestVersion.find("3.2.0") != -1:
            self.setReferenceDataOutputFile(
                os.path.join(self.getPluginTestsDataHome(),
                             "XSDataResultBest_reference_BESTv320.xml"))

        # Checks the expected result
        strExpectedOutput = self.readAndParseFile(
            self.getReferenceDataOutputFile())

        from XSDataBestv1_1 import XSDataResultBest
        xsDataOutputExpected = XSDataResultBest.parseString(strExpectedOutput)
        xsDataOutputObtained = edPlugin.getDataOutput()

        EDAssert.equal(xsDataOutputExpected.marshal(),
                       xsDataOutputObtained.marshal())
示例#37
0
 def unitTestLineSep(self):
     """
     Test os.linesep
     """
     EDVerbose.DEBUG("EDTestCaseEDUtilsPlatform.unitTestLineSep")
     EDAssert.equal(os.linesep, EDUtilsPlatform.linesep,
                    "os.linesep equivalent")
    def testExecute(self):
        """
        """
        self.run()

        plugin = self.getPlugin()

        EDVerbose.DEBUG("Checking obtained result...")
        strExpectedOutput = self.readAndParseFile (self.getReferenceDataOutputFile())
        xsDataResultReference = XSDataResultSPDCake.parseString(strExpectedOutput)
        xsDataResultObtained = plugin.getDataOutput()
#        EDVerbose.DEBUG("Reference XML:%s" + xsDataResultReference.marshal())
#        EDVerbose.DEBUG("Obtained XML:%s" + xsDataResultObtained.marshal())
        EDAssert.strAlmostEqual(xsDataResultReference.marshal(), xsDataResultObtained.marshal(), "XSDataResult output are the same")

        # Checking obtained results
        xsDataResultsSPDCake = plugin.getDataOutput()
        strPathToChiOutput = xsDataResultsSPDCake.getCakedFile().getPath().getValue()
        strPathToChiReference = os.path.join(self.getTestsDataImagesHome(), "EDPluginSPDCakev1_0.chi")
        Xref, Yref = readChiPlot(strPathToChiReference)
        Xobt, Yobt = readChiPlot(strPathToChiOutput)
        EDVerbose.DEBUG("Output File: %s, Reference file: %s" % (strPathToChiOutput, strPathToChiReference))
        bigX = Xref + Xobt
        bigX.sort()
        bigYobt = numpy.interp(bigX, Xobt, Yobt)
        bigYref = numpy.interp(bigX, Xref, Yref)
        EDVerbose.DEBUG("ref.shape= %s, obt.shape=%s" % (bigYobt.shape, bigYref.shape))
        EDVerbose.DEBUG("Type of object ref= %s, obt=%s" % (bigYobt.__class__, bigYref.__class__))
        EDAssert.arraySimilar(bigYobt, bigYref, _fAbsMaxDelta=0.1, _fScaledMaxDelta=0.1, _strComment="Comparing ChiPlot files")
 def testMergeTwoSubWedgesAdjascentInRotationAxis(self):
     # First check two sub wedges which shouldn't be merged
     edPluginSubWedgeMergev1_1 = self.createPlugin()
     edPluginSubWedgeMergev1_1.configure()
     xsDataInputSubWedgeMerge = XSDataInputSubWedgeMerge.parseFile(
         self.strPathToReferenceInput)
     xsDataSubWedge1 = xsDataInputSubWedgeMerge.getSubWedge()[0]
     xsDataSubWedge2 = xsDataInputSubWedgeMerge.getSubWedge()[1]
     xsDataSubWedgeMerged = edPluginSubWedgeMergev1_1.mergeTwoSubWedgesAdjascentInRotationAxis(
         xsDataSubWedge1, xsDataSubWedge2)
     EDAssert.equal(xsDataSubWedgeMerged, None)
     # Then check two adjascent images
     strPathToInputTwoAdjascentImages = os.path.join(
         self.getPluginTestsDataHome(),
         "XSDataInputSubWedgeMerge_twoAdjascentImages.xml")
     xsDataInputSubWedgeMerge2 = XSDataInputSubWedgeMerge.parseFile(
         strPathToInputTwoAdjascentImages)
     xsDataSubWedge1 = xsDataInputSubWedgeMerge2.getSubWedge()[0]
     xsDataSubWedge2 = xsDataInputSubWedgeMerge2.getSubWedge()[1]
     xsDataSubWedgeMerged = edPluginSubWedgeMergev1_1.mergeTwoSubWedgesAdjascentInRotationAxis(
         xsDataSubWedge1, xsDataSubWedge2)
     xsDataSubWedgeMergedReference = XSDataSubWedge.parseFile(
         os.path.join(self.getPluginTestsDataHome(),
                      "XSDataSubWedgeMerged_twoImages.xml"))
     EDAssert.equal(xsDataSubWedgeMerged.marshal(),
                    xsDataSubWedgeMergedReference.marshal())
    def test_generateCommandLine(self):
        edPlugin = self.getPlugin()
        strInputXML = EDUtilsFile.readFile(os.path.join(self.strDataPath, "XSDataInputXia2DIALS_reference.xml"))
        xsDataInput = XSDataInputXia2DIALS.parseString(strInputXML)
        strCommandLine = edPlugin.generateCommandLine(xsDataInput)
#        print(strCommandLine)
        EDAssert.equal("-dials -ispyb_xml_out ispyb.xml image=/scisoft/pxsoft/data/AUTO_PROCESSING/id29/20130301/RAW_DATA/GaelleB/xtal5/xtal5w1_1_0001.cbf", strCommandLine, "Reference data input")
示例#41
0
 def testCopyHTMLFilesAndDir(self):
     if not os.path.exists(EDUtilsPath.getEdnaUserTempFolder()):
         os.mkdir(EDUtilsPath.getEdnaUserTempFolder())
     strTestFromDir = os.path.join(EDUtilsPath.getEdnaUserTempFolder(), "TestFromDir")
     shutil.rmtree(strTestFromDir, ignore_errors=True)
     os.mkdir(strTestFromDir)
     strTestHtmlFilePath = os.path.join(strTestFromDir, "index.html")
     strTestHtmlDirPath = os.path.join(strTestFromDir, "index")
     EDUtilsFile.writeFile(strTestHtmlFilePath, "Test content")
     if not os.path.exists(strTestHtmlDirPath):
         os.mkdir(strTestHtmlDirPath)
     strTestHtmlDirFilePath = os.path.join(strTestHtmlDirPath, "test.txt")
     EDUtilsFile.writeFile(strTestHtmlDirFilePath, "Test content")
     #
     strTestToDir = os.path.join(EDUtilsPath.getEdnaUserTempFolder(), "TestToDir")
     shutil.rmtree(strTestToDir, ignore_errors=True)
     os.mkdir(strTestToDir)
     EDHandlerESRFPyarchv1_0.copyHTMLDir(strTestFromDir, strTestToDir)
     #
     # Check that files exist in strTestToDir:
     EDAssert.isFile(os.path.join(strTestToDir, "index", "index.html"))
     EDAssert.isFile(os.path.join(strTestToDir, "index", "index", "test.txt"))
     #
     shutil.rmtree(strTestFromDir, ignore_errors=True)
     shutil.rmtree(strTestToDir, ignore_errors=True)
 def testSortIdenticalObjects(self):
     edListObjects = []
     edPluginSubWedgeMergev10 = self.createPlugin()
     edListSorted = edPluginSubWedgeMergev10.sortIdenticalObjects(
         edListObjects, edPluginSubWedgeMergev10.compareTwoValues)
     EDAssert.equal(edListSorted, [])
     edListObjects = [1]
     edPluginSubWedgeMergev10 = self.createPlugin()
     edListSorted = edPluginSubWedgeMergev10.sortIdenticalObjects(
         edListObjects, edPluginSubWedgeMergev10.compareTwoValues)
     EDAssert.equal(edListSorted, [[1]])
     edListObjects = [1, 2]
     edPluginSubWedgeMergev10 = self.createPlugin()
     edListSorted = edPluginSubWedgeMergev10.sortIdenticalObjects(
         edListObjects, edPluginSubWedgeMergev10.compareTwoValues)
     EDAssert.equal(edListSorted, [[1], [2]])
     edListObjects = [1, 1]
     edPluginSubWedgeMergev10 = self.createPlugin()
     edListSorted = edPluginSubWedgeMergev10.sortIdenticalObjects(
         edListObjects, edPluginSubWedgeMergev10.compareTwoValues)
     EDAssert.equal(edListSorted, [[1, 1]])
     edListObjects = [1, 2, 1, 3, 4, 1, 5, 2, 2, 9, 3, 2]
     edPluginSubWedgeMergev10 = self.createPlugin()
     edListSorted = edPluginSubWedgeMergev10.sortIdenticalObjects(
         edListObjects, edPluginSubWedgeMergev10.compareTwoValues)
     EDAssert.equal(edListSorted,
                    [[1, 1, 1], [2, 2, 2, 2], [3, 3], [4], [5], [9]])
示例#43
0
 def unitTestGetValueSILength(self):
     """
     Test sub method specific to length: GetValueLength
     """
     EDVerbose.DEBUG("EDTestCaseEDUtilsUnit.unitTestGetValueSILength")
     EDAssert.equal(1.54E-10, EDUtilsUnit.getValueLength(1.54, "A"),
                    "Length Conversion A -> m ")
 def testCreateDict(self):
     pathToReferenceInput = os.path.join(self.getPluginTestsDataHome(), \
                                         "XSDataInputControlDozor_reference.xml")
     xsDataInputControlDozor = XSDataInputControlDozor.parseFile(pathToReferenceInput)
     edPluginControlDozor = self.createPlugin()
     dictImage = edPluginControlDozor.createImageDict(xsDataInputControlDozor)
     EDAssert.equal(True, type(dictImage) == dict)
示例#45
0
 def unitTestGetValueSIAngle(self):
     """
     Test sub method specific to length: GetValueLength
     """
     EDVerbose.DEBUG("EDTestCaseEDUtilsUnit.unitTestGetValueSIAngle")
     EDAssert.equal(math.pi / 2.0, EDUtilsUnit.getValueAngle(90, "deg"),
                    "Angle Conversion deg -> rad ")
    def testSetDataModelInput(self):
        """
        """
        edPluginBest = self.createPlugin()
        xsPluginItemGood01 = self.getPluginConfiguration(os.path.join(self.strDataPath, "XSConfiguration.xml"))
        edPluginBest.setConfiguration(xsPluginItemGood01)
        edPluginBest.setScriptExecutable("cat")
        edPluginBest.configure()

        from XSDataBestv1_1 import XSDataInputBest

        xsDataInputBest = XSDataInputBest()

        from XSDataCommon import XSDataAbsorbedDoseRate
        from XSDataCommon import XSDataDouble
        from XSDataCommon import XSDataTime
        from XSDataCommon import XSDataSpeed
        from XSDataCommon import XSDataString
        from XSDataCommon import XSDataAngle
        from XSDataCommon import XSDataBoolean

        xsDataInputBest.setCrystalAbsorbedDoseRate(XSDataAbsorbedDoseRate(0.22e06))
        xsDataInputBest.setCrystalShape(XSDataDouble(1))
        xsDataInputBest.setCrystalSusceptibility(XSDataDouble(1.5))
        xsDataInputBest.setDetectorType(XSDataString("q210-2x"))
        xsDataInputBest.setBeamExposureTime(XSDataTime(1))
        xsDataInputBest.setBeamMaxExposureTime(XSDataTime(10000))
        xsDataInputBest.setBeamMinExposureTime(XSDataTime(0.1))
        xsDataInputBest.setGoniostatMinRotationWidth(XSDataAngle(0.1))
        xsDataInputBest.setGoniostatMaxRotationSpeed(XSDataSpeed(10))
        xsDataInputBest.setAimedResolution(XSDataDouble(2))
        xsDataInputBest.setAimedRedundancy(XSDataDouble(6.5))
        xsDataInputBest.setAimedCompleteness(XSDataDouble(0.9))
        xsDataInputBest.setAimedIOverSigma(XSDataDouble(3))
        xsDataInputBest.setComplexity(XSDataString("min"))
        xsDataInputBest.setAnomalousData(XSDataBoolean(True))

        bestFileContentDat = EDUtilsFile.readFile(os.path.join(self.strDataPath, "bestfile.dat"))
        xsDataInputBest.setBestFileContentDat(XSDataString(bestFileContentDat))

        bestFileContentPar = EDUtilsFile.readFile(os.path.join(self.strDataPath, "bestfile.par"))
        xsDataInputBest.setBestFileContentPar(XSDataString(bestFileContentPar))

        bestFileContentHKL = EDUtilsFile.readFile(os.path.join(self.strDataPath, "bestfile1.hkl"))
        listBestFileContentHKL = []
        listBestFileContentHKL.append(XSDataString(bestFileContentHKL))
        xsDataInputBest.setBestFileContentHKL(listBestFileContentHKL)

        xsDataInputBest.outputFile(self.strObtainedInputFile)

        strExpectedInput = self.readAndParseFile(self.strReferenceInputFile)
        strObtainedInput = self.readAndParseFile(self.strObtainedInputFile)

        xsDataInputExpected = XSDataInputBest.parseString(strExpectedInput)
        xsDataInputObtained = XSDataInputBest.parseString(strObtainedInput)

        EDAssert.equal(xsDataInputExpected.marshal(), xsDataInputObtained.marshal())
        os.remove(self.strObtainedInputFile)

        self.cleanUp(edPluginBest)
示例#47
0
 def unitTestGetValueSITime(self):
     """
     Test sub method specific to length: GetValueTime
     """
     EDVerbose.DEBUG("EDTestCaseEDUtilsUnit.unitTestGetValueSITime")
     EDAssert.equal(1800, EDUtilsUnit.getValueTime(30, "mn"),
                    "Length Conversion mn -> s ")
 def testGenerateMosflmScriptName(self):
     """
     This method tests the generateMosflmScriptName method of the Labelit plugin.
     """
     edPluginLabelitv10 = self.createPlugin()
     EDAssert.equal("integration01.csh", edPluginLabelitv10.generateMosflmScriptName(1))
     EDAssert.equal("integration10.csh", edPluginLabelitv10.generateMosflmScriptName(10))
示例#49
0
    def testExecute(self):
        """
        """
        self.run()
        plugin = self.getPlugin()

        # Checking obtained results
        xsDataResult = plugin.getDataOutput()
        xsDataRef = XSDataResult1DPowderEDF.parseString(
            self.readAndParseFile(self.getReferenceDataOutputFile()))
        #        EDAssert.strAlmostEqual(XSDataResult1DPowderEDF.parseString(self.readAndParseFile(self.getReferenceDataOutputFile())).marshal(), xsDataResult.marshal(), _strComment="XML structures are the same")
        tthref = EDUtilsArray.xsDataToArray(xsDataRef.getTwoTheta(),
                                            _bCheckMd5sum=False)
        tthobt = EDUtilsArray.xsDataToArray(xsDataResult.getTwoTheta(),
                                            _bCheckMd5sum=False)

        Iref = EDUtilsArray.xsDataToArray(xsDataRef.getIntensity(),
                                          _bCheckMd5sum=False)
        Iobt = EDUtilsArray.xsDataToArray(xsDataResult.getIntensity(),
                                          _bCheckMd5sum=False)

        EDAssert.arraySimilar(_npaValue=tthobt,
                              _npaRef=tthref,
                              _fAbsMaxDelta=0.1,
                              _strComment="2theta arrays are the same")
        EDAssert.arraySimilar(_npaValue=Iobt,
                              _npaRef=Iref,
                              _fAbsMaxDelta=0.1,
                              _strComment="Intensity arrays are the same")
 def test_generateCommandLine(self):
     edPlugin = self.getPlugin()
     strInputXML = EDUtilsFile.readFile(os.path.join(self.strDataPath, "XSDataInputAutoPROC_reference.xml"))
     xsDataInput = XSDataInputAutoPROC.parseString(strInputXML)
     strCommandLine = edPlugin.generateCommandLine(xsDataInput)
     print(strCommandLine)
     EDAssert.equal("-B -xml -I /scisoft/pxsoft/data/AUTO_PROCESSING/id29/20130301/RAW_DATA/GaelleB/xtal5 -Id 1088454,/scisoft/pxsoft/data/AUTO_PROCESSING/id29/20130301/RAW_DATA/GaelleB/xtal5,xtal5w1_1_####.cbf,1,100 -R 5.0 2.0 -ANO", strCommandLine, "Reference data input")
    def testExecute(self):
        self.run()

        # Checks that there are no error messages

        plugin = self.getPlugin()

        # Checks the expected result

        xsDataResultCharacterisationv2_0 = plugin.getDataOutput()

        #        EDAssert.equal(True, xsDataResultCharacterisationv2_0.getMxv1ResultCharacterisation_Reference()    is not None)
        EDAssert.equal(
            True,
            xsDataResultCharacterisationv2_0.getMxv1ResultCharacterisation()
            is not None)
        EDAssert.equal(
            True,
            xsDataResultCharacterisationv2_0.getSuggestedStrategy()
            is not None)
        #        EDAssert.equal(True, xsDataResultCharacterisationv2_0.getPossibleOrientations()    is not None)

        xsDataResultCharacterisation = xsDataResultCharacterisationv2_0.getMxv1ResultCharacterisation(
        )

        # There should be indexing results, integration results and strategy results
        EDAssert.equal(
            True,
            xsDataResultCharacterisation.getIndexingResult() is not None)
        EDAssert.equal(
            True,
            xsDataResultCharacterisation.getIntegrationResult() is not None)
        EDAssert.equal(
            True,
            xsDataResultCharacterisation.getStrategyResult() is not None)
示例#52
0
 def testGetOutputDataFromDNATableFile(self):
     edPluginRdfit = self.createPlugin()
     strPathToTableFile = os.path.join(self.strDataPath, "rdfit.xml")
     xsDataResultRdfit = edPluginRdfit.getOutputDataFromDNATableFile(strPathToTableFile)
     strPathToReference = os.path.join(self.strDataPath, "XSDataResultRdfit_reference.xml")
     xsDataResultRdfitReference = XSDataResultRdfit.parseFile(strPathToReference)
     EDAssert.equal(xsDataResultRdfitReference.marshal(), xsDataResultRdfit.marshal(), "Test parsing result 'DNA' xml file")
    def testExecute(self):
        """
        """
        self.run()
        plugin = self.getPlugin()

################################################################################
# Compare XSDataResults
################################################################################

        strExpectedOutput = self.readAndParseFile (self.getReferenceDataOutputFile())
#        strObtainedOutput = self.readAndParseFile (self.m_edObtainedOutputDataFile)
        EDVerbose.DEBUG("Checking obtained result...")
        xsDataResultReference = XSDataResultBioSaxsAzimutIntv1_0.parseString(strExpectedOutput)
        xsDataResultObtained = plugin.getDataOutput()
        EDAssert.strAlmostEqual(xsDataResultReference.marshal(), xsDataResultObtained.marshal(), "XSDataResult output are the same", _strExcluded="bioSaxs")

################################################################################
# Compare spectrum ascii Files
################################################################################

        outputData = open(xsDataResultObtained.getIntegratedCurve().getPath().value, "rb").read().split(os.linesep)
        referenceData = EDUtilsFile.readFileAndParseVariables(os.path.join(self.getTestsDataImagesHome(), "bioSaxsIntegratedv1_3.dat"), EDUtilsPath.getDictOfPaths()).split(os.linesep)
        outputData = os.linesep.join([i for i in outputData if not i.startswith("# History")])
        referenceData = os.linesep.join([i for i in referenceData if not i.startswith("# History")])
        EDAssert.strAlmostEqual(referenceData, outputData, _strComment="3column ascii spectra files are the same", _fRelError=0.1, _fAbsError=0.1, _strExcluded="bioSaxs")