def runXscale(self, _workingDirectory, merged=False, anom=False):
     strPathXscaleLp = None
     if os.path.exists(os.path.join(_workingDirectory, "XDS_ASCII.HKL")):
         if merged:
             strMerged = "merged"
         else:
             strMerged = "unmerged"
         if anom:
             strAnom = "anom"
         else:
             strAnom = "noanom"
         strXscaleInp = "OUTPUT_FILE= {0}_{1}_XSCALE.hkl\n".format(strMerged, strAnom)
         strXscaleInp += "INPUT_FILE= XDS_ASCII.HKL\n"
         strXscaleInp += "MERGE= {0}\n".format(str(merged).upper())
         strXscaleInp += "FRIEDEL'S_LAW= {0}\n".format(str(not anom).upper())
         EDUtilsFile.writeFile(os.path.join(_workingDirectory, "XSCALE.INP"), strXscaleInp)
         xscaleLog = os.path.join(_workingDirectory, "xscale.log")
         pipe1 = subprocess.Popen("/opt/pxsoft/bin/xscale",
                                  shell=True,
                                  stdout=subprocess.PIPE,
                                  close_fds=True,
                                  cwd=_workingDirectory)
         xdsInp = pipe1.communicate()[0]
         with open(xscaleLog, "w") as f:
             f.write(str(xdsInp))
         # Find path to XSCALE.LP file
         strPathXscaleLp = os.path.join(_workingDirectory, "XSCALE.LP")
     return strPathXscaleLp
 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 testDetermineImageType(self):
     edPluginControlReadImageHeaderv10 = self.createPlugin()
     # Test 1 : ADSC 
     self.loadTestImage([ "testscale_1_001.img" ])
     strImage1 = os.path.join(self.getTestsDataImagesHome(), "testscale_1_001.img")
     strType1 = edPluginControlReadImageHeaderv10.determineImageType(strImage1)
     EDAssert.equal(strType1, "ADSC", "ADSC")
     # Test 2 : MAR CCD with .mccd suffix
     self.loadTestImage([ "ref-screentest-crystal1_1_001.mccd" ])
     strImage2 = os.path.join(self.getTestsDataImagesHome(), "ref-screentest-crystal1_1_001.mccd")
     strType2 = edPluginControlReadImageHeaderv10.determineImageType(strImage2)
     EDAssert.equal(strType2, "MARCCD", "MARCCD 1")
     # Test 3 : MAR CCD with .marccd suffix - copied from ref-screentest-crystal1_1_001.mccd
     strImage3 = tempfile.mktemp(suffix="_1_001.marccd", prefix="ref-screentest-crystal1_")
     shutil.copyfile(strImage2, strImage3)
     strType3 = edPluginControlReadImageHeaderv10.determineImageType(strImage3)
     EDAssert.equal(strType3, "MARCCD", "MARCCD 2")
     os.remove(strImage3)
     # Test 4 : Pilatus 2M CBF image
     self.loadTestImage([ "ref-2m_RNASE_1_0001.cbf" ])
     strImage1 = os.path.join(self.getTestsDataImagesHome(), "ref-2m_RNASE_1_0001.cbf")
     strType1 = edPluginControlReadImageHeaderv10.determineImageType(strImage1)
     EDAssert.equal(strType1, "Pilatus2M", "Pilatus2M")
     # Test 5 : Pilatus 6M CBF image
     self.loadTestImage([ "FAE_1_1_00001.cbf" ])
     strImage1 = os.path.join(self.getTestsDataImagesHome(), "FAE_1_1_00001.cbf")
     strType1 = edPluginControlReadImageHeaderv10.determineImageType(strImage1)
     EDAssert.equal(strType1, "Pilatus6M", "Pilatus6M")
     # Test 6 : Unknown image - created by the test
     strImage4 = tempfile.mktemp(suffix="_1_001.unknown", prefix="zeroes_")
     EDUtilsFile.writeFile(strImage4, "Dummy text string for EDTestCasePluginUnitPluginControlReadImageHeaderv10.testDetermineImageType")
     strType4 = edPluginControlReadImageHeaderv10.determineImageType(strImage4)
     EDAssert.equal(True, edPluginControlReadImageHeaderv10.isFailure(), "Not recognized format")
     os.remove(strImage4)
Example #4
0
 def writeBestfilePar(self, fname, content):
     '''
     Writing a bestfile.par for STAC to describe the xtal (orinetation,spacegroup,etc.)
     '''
     #version reusing a pregenerated bestfile.par
     #EDUtilsFile.writeFile( EDDiskExplorer.mergePath( self.getWorkingDirectory(), "bestfile.par" ), self.m_xsDataInput.getBestFileContentPar().getValue())
     EDUtilsFile.writeFile(fname, content)
 def preProcess(self, _edObject=None):
     EDPlugin.preProcess(self, _edObject)
     EDVerbose.DEBUG("EDPluginWrapperForJobScheduler.preProcess")
     # Construct python script for executing the plugin
     strPythonWrapper = self.preparePythonWrapperScript()
     self.__strPathToPythonWrapper = os.path.join(self.getWorkingDirectory(), self.__strPythonWrapperScriptName)
     EDUtilsFile.writeFile(self.__strPathToPythonWrapper, strPythonWrapper)
 def process(self, _edPlugin=None):
     EDPluginExec.process(self, _edPlugin)
     self.DEBUG("EDPluginExecSimpleHTMLPagev1_0.process...")
     if self.xsDataResultCharacterisation is not None:
         # Create the simple characterisation result page
         self.page = markupv1_7.page(mode='loose_html')
         self.page.init( title="Characterisation Results", 
                    footer="Generated on %s" % time.asctime())
         self.page.div( align_="CENTER")
         self.page.h1()
         if self.xsDataResultCharacterisation is not None:
             self.page.strong( "Characterisation Results " )
         else:
             self.page.strong( "No Characterisation Results! " )
         # Link to the EDNA log file
         strPathToLogFile = self.findEDNALogFile()
         if strPathToLogFile is not None:
             self.page.strong("(")
             self.strPageEDNALog = os.path.join(self.getWorkingDirectory(), "edna_log.html")
             pageEDNALog = markupv1_7.page()
             pageEDNALog.h1("EDNA Log")
             pageEDNALog.a("Back to previous page", href_=self.strHtmlFileName)
             pageEDNALog.pre(cgi.escape(EDUtilsFile.readFile(strPathToLogFile)))
             pageEDNALog.a("Back to previous page", href_=self.strHtmlFileName)
             EDUtilsFile.writeFile(self.strPageEDNALog, str(pageEDNALog))
             self.page.a("EDNA log file", href_="edna_log.html")
             self.page.strong(")")
         self.page.h1.close()
         self.page.div.close()
         self.diffractionPlan()
         self.strategyResults()
         self.graphs()
         self.indexingResults()
         self.integrationResults()
         self.imageQualityIndicatorResults()
Example #7
0
    def writeKappaSettings(self):
        '''
        # future version for getting motor positions related to images under processing
        # checking in order:
        # - value got as input
        # - mosflm.descr file in process subdir (if BCM (like mxcube) registered it)
        # - {imageTemplate}_kappa_settings.xml file (if BCM (like DNA) registered it)
        # - read it now (and try to register as {imageTemplate}_kappa_settings.xml)
        # - just use the datum (0,0,0)
        '''

        #code for using a predefined datum (0;0;0)
        #EDUtilsFile.writeFile( EDDiskExplorer.mergePath( self.getWorkingDirectory(), "DNA_STAC_Kappa_Settings" ), "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?><kappa_collect_settings><motorSettings><motorName>Omega</motorName><motorValue>0</motorValue></motorSettings><motorSettings><motorName>Kappa</motorName><motorValue>0.000000</motorValue></motorSettings><motorSettings><motorName>Phi</motorName><motorValue>0</motorValue></motorSettings><motorSettings><motorName>X</motorName><motorValue>0.261444</motorValue></motorSettings><motorSettings><motorName>Y</motorName><motorValue>-0.085559</motorValue></motorSettings><motorSettings><motorName>Z</motorName><motorValue>0.659333</motorValue></motorSettings><comment>BCM query performed by STAC</comment></kappa_collect_settings>")

        # gonio settings from DC descriptor object
        EDFactoryPluginStatic.loadModule("XSDataMXv2")
        #import XSDataMXv2
        #dc = XSDataMXv2.XSDataCollection()
        from XSDataMXv2 import XSDataCollection
        dc = XSDataCollection()
        dc = self.getDataInput("dataCollection")[0]
        omega = dc.getXSSubWedge()[0].getXSRotationalGoniostatSetting().getBaseaxissetting()
        [kappa, phi] = dc.getXSSubWedge()[0].getXSRotationalGoniostatSetting().getAxissetting()
        EDUtilsFile.writeFile(os.path.join(self.getWorkingDirectory(), "DNA_STAC_Kappa_Settings"), "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?><kappa_collect_settings><motorSettings><motorName>Omega</motorName><motorValue>%e</motorValue></motorSettings><motorSettings><motorName>Kappa</motorName><motorValue>%e</motorValue></motorSettings><motorSettings><motorName>Phi</motorName><motorValue>%e</motorValue></motorSettings><motorSettings><motorName>X</motorName><motorValue>0.261444</motorValue></motorSettings><motorSettings><motorName>Y</motorName><motorValue>-0.085559</motorValue></motorSettings><motorSettings><motorName>Z</motorName><motorValue>0.659333</motorValue></motorSettings><comment>BCM query performed by STAC</comment></kappa_collect_settings>" % (omega.getValue(), kappa.getValue(), phi.getValue()))

        '''
 def postProcess(self, _edObject=None):
     EDPluginExec.postProcess(self)
     EDVerbose.DEBUG("EDPluginExecOutputHTMLv1_0.postProcess")
     if self.__strWorkingDir != None:
         xsDataFileHTMLFile = XSDataFile()
         xsDataFileHTMLDir = XSDataFile()
         
         if self.strBasename is None:
             strHTMLFilePath = os.path.join(self.__strWorkingDir, "edna.html")
             strHTMLDirPath = os.path.join(self.__strWorkingDir, "edna_html")
         else:
             strHTMLFilePath = os.path.join(self.strBasename, "edna.html")
             strHTMLDirPath = os.path.join(self.strBasename, "edna_html")
         
         if os.path.exists(strHTMLFilePath):
             strFileContent = EDUtilsFile.readFile(strHTMLFilePath)
             strFileContent = strFileContent.replace("table,td,th { border-style: none;", "div.edna table,td,th { border-style: none;")
             strFileContent = strFileContent.replace("td,th { border-style: solid;", "div.edna td,th { border-style: solid;")
             strFileContent = strFileContent.replace("th { background-color: gray;", "div.edna th { background-color: gray;")
             strFileContent = strFileContent.replace("<body onload=\"initTable('strategyData',false,false);\">", "<body onload=\"initTable('strategyData',false,false);\"><div class = 'edna'> ")
             strFileContent = strFileContent.replace("</body>", "</div></body>")
             EDUtilsFile.writeFile(strHTMLFilePath, strFileContent)
             xsDataFileHTMLFile.setPath(XSDataString(strHTMLFilePath))
             xsDataFileHTMLDir.setPath(XSDataString(strHTMLDirPath))
             self.setDataOutput(xsDataFileHTMLFile, "htmlFile")
             self.setDataOutput(xsDataFileHTMLDir, "htmlDir")
         else:
             EDVerbose.ERROR("EDPluginExecOutputHTMLv1_0.postProcess: file doesn't exist: " + strHTMLFilePath)
 def createHtmlPage(self, strImagePrefix, xsDataResultDimple, strResultsDirectory, strHtmlPath, strProposal, strSessionDate, strBeamline):
     """Create an HTML page with the results"""
     if not os.path.exists(strHtmlPath):
         os.makedirs(strHtmlPath, 0o755)
     strSample = "_".join(strImagePrefix.split("_")[0:-1])
     strHtmlFileName = "ep_%s_index.html" % strImagePrefix
     strPath = os.path.join(strHtmlPath, strHtmlFileName)
     page = markupv1_10.page(mode='loose_html')
     # Title and footer
     page.init(title="Dimple Results",
                footer="Generated on %s" % time.asctime())
     page.div(align_="LEFT")
     page.h1()
     page.strong("Dimple Results for sample {0} from proposal {1}".format(strSample, strProposal))
     page.h1.close()
     page.h3("Session date: {0}-{1}-{2}".format(strSessionDate[0:4], strSessionDate[4:6], strSessionDate[6:]))
     page.h3("Beamline: {0}".format(strBeamline))
     page.h3("Dimple output files can be found in :")
     page.strong(strResultsDirectory)
     page.div.close()
     # Results of REFMAC 5
     page.h3("Final results of Recmac 5:")
     page.pre(self.extractFinalResultsFromRefmac5RestrLog(xsDataResultDimple.refmac5restrLog.path.value))
     # Results of findblobs
     page.h3("Findblobs log:")
     page.pre(open(xsDataResultDimple.findBlobsLog.path.value).read())
     # Blobs
     page.br()
     listImageHTML = []
     for xsDataFileBlob in xsDataResultDimple.blob:
         # Copy blob file to html directory
         strBlobName = os.path.basename(xsDataFileBlob.path.value).split(".")[0]
         strBlobImage = "ep_%s_%s_dimple.png" % (strImagePrefix, strBlobName)
         strTargetPath = os.path.join(strHtmlPath, strBlobImage)
         shutil.copyfile(xsDataFileBlob.path.value, strTargetPath)
         strPageBlobPath = os.path.join(strHtmlPath, "ep_%s_%s_dimple.html" % (strImagePrefix, strBlobName))
         pageBlob = markupv1_10.page()
         pageBlob.init(title=strBlobName,
                        footer="Generated on %s" % time.asctime())
         pageBlob.h1(strBlobName)
         pageBlob.div(align_="LEFT")
         pageBlob.img(src=strBlobImage, title=strBlobName)
         pageBlob.div.close()
         pageBlob.br()
         pageBlob.div(align_="LEFT")
         pageBlob.a("Back to previous page", href_=os.path.basename(strPath))
         pageBlob.div.close()
         EDUtilsFile.writeFile(strPageBlobPath, str(pageBlob))
         listImageHTML.append(strPageBlobPath)
         page.a(href=os.path.basename(strPageBlobPath))
         page.img(src=strBlobImage, width=200, height=200, title=strBlobName)
         page.a.close()
         if strBlobName == "blob1v3":
             page.br()
     page.br()
     # FInalise html page
     strHTML = str(page)
     EDUtilsFile.writeFile(strPath, strHTML)
     listHTML = [strPath] + listImageHTML
     return listHTML
    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)
    def __init__(self,):
        """
        """
        self.EPSILON_REL = 0.01 #1 percent error
        self.EPSILON_ABS = 0.0001 #1 percent error
        EDTestCasePluginExecute.__init__(self, "EDPluginFIT2DCakev1_1", "EDPluginControlFIT2D-v1.0")

        self.setConfigurationFile(self.getRefConfigFile())

        self.setDataInputFile(os.path.join(self.getPluginTestsDataHome(), \
                                                      "XSDataInputFIT2DCake_reference.xml"))

        self.setReferenceDataOutputFile(os.path.join(self.getPluginTestsDataHome(), \
                                                                "XSDataResultFIT2DCake_reference.xml"))

        self.m_edObtainedOutputDataFile = self.getPluginName() + "_output.xml"

        strSplineFileName = "frelon_spline_file_to_correct_SPD.spline"
        strPathToSplineFile = os.path.join(self.getTestsDataImagesHome(), strSplineFileName)
        if (not os.path.exists(strPathToSplineFile)):
            EDUtilsFile.copyFile(os.path.join(self.getPluginTestsDataHome(), strSplineFileName), \
                                  strPathToSplineFile)

        self.m_iNoErrorMessages = 0
        self.m_iNoWarningMessages = 0
 def preProcess(self, _oedObject=None):
     EDPluginSTACv2_0.preProcess(self)
     EDVerbose.DEBUG("EDPluginSTACAlignmentv2_0.preProcess")
     #bestfile.par
     #EDUtilsFile.writeFile( EDDiskExplorer.mergePath( self.getWorkingDirectory(), "bestfile.par" ), self.m_xsDataInput.getBestFileContentPar().getValue())
     #self.writeBestfilePar( EDDiskExplorer.mergePath( self.getWorkingDirectory(), "bestfile.par" ), self.getDataInput()[0].getBestFileContentPar().getValue() )
     self.writeBestfilePar(
         os.path.join(self.getWorkingDirectory(), "bestfile.par"),
         self.getDataInput("inputBest")[0].getBestFileContentPar().
         getValue())
     #self.writeAlignmentRequest() - for now use a predefined request
     if (self.getDataInput("kappa_alignment_request") is not None):
         EDUtilsFile.writeFile(
             os.path.join(self.getWorkingDirectory(),
                          "DNA_kappa_alignment_request"),
             self.getDataInput("kappa_alignment_request")[0].marshal())
     else:
         EDUtilsFile.writeFile(
             os.path.join(self.getWorkingDirectory(),
                          "DNA_kappa_alignment_request"),
             "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?><kappa_alignment_request><desired_orientation><v1>a*</v1><v2>b*</v2><close>false</close><comment></comment></desired_orientation><desired_orientation><v1>a*</v1><v2>c*</v2><close>false</close><comment></comment></desired_orientation><desired_orientation><v1>b*</v1><v2>a*</v2><close>false</close><comment></comment></desired_orientation><desired_orientation><v1>b*</v1><v2>c*</v2><close>false</close><comment></comment></desired_orientation><desired_orientation><v1>c*</v1><v2>a*</v2><close>true</close><comment></comment></desired_orientation><desired_orientation><v1>c*</v1><v2>b*</v2><close>false</close><comment></comment></desired_orientation><comment>First test parameter passed</comment></kappa_alignment_request>"
         )
     #self.writeKappaSettings() - for now use a predefined datum (0;0;0)
     #EDUtilsFile.writeFile( os.path.join( self.getWorkingDirectory(), "DNA_STAC_Kappa_Settings" ), "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?><kappa_collect_settings><motorSettings><motorName>Omega</motorName><motorValue>0</motorValue></motorSettings><motorSettings><motorName>Kappa</motorName><motorValue>0.000000</motorValue></motorSettings><motorSettings><motorName>Phi</motorName><motorValue>0</motorValue></motorSettings><motorSettings><motorName>X</motorName><motorValue>0.261444</motorValue></motorSettings><motorSettings><motorName>Y</motorName><motorValue>-0.085559</motorValue></motorSettings><motorSettings><motorName>Z</motorName><motorValue>0.659333</motorValue></motorSettings><comment>BCM query performed by STAC</comment></kappa_collect_settings>")
     self.writeKappaSettings()
Example #13
0
    def testSetDataModelInput(self):
        edPluginBest = self.createPlugin()
        edConfigurationGood01 = EDConfiguration(os.path.join(self.m_pyStrDataPath, "XSConfiguration.xml"))
        dictItemGood01 = edConfigurationGood01.get(self.getPluginName())
        edPluginBest.setConfig(dictItemGood01, _bLocal = True)
        edPluginBest.setScriptExecutable("cat")
        edPluginBest.configure()

        from XSDataBestv1_2 import XSDataInputBest
        xsDataInputBest = XSDataInputBest()

        from XSDataCommon import XSDataAbsorbedDoseRate
        from XSDataCommon import XSDataDouble
        from XSDataCommon import XSDataString
        from XSDataCommon import XSDataTime
        from XSDataCommon import XSDataFile
        from XSDataCommon import XSDataAngularSpeed
        from XSDataCommon import XSDataString
        from XSDataCommon import XSDataAngle
        from XSDataCommon import XSDataBoolean

        xsDataInputBest.setCrystalAbsorbedDoseRate(XSDataAbsorbedDoseRate(0.22E+06))
        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(XSDataAngularSpeed(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(False))
        fileDirectory = edPluginBest.getWorkingDirectory()

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

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

        bestFileContentHKL = EDUtilsFile.readFile(os.path.join(self.m_pyStrDataPath, "bestfile1.hkl"))
        xsDataInputBest.addBestFileContentHKL(XSDataString(bestFileContentHKL))

        xsDataInputBest.exportToFile(self.m_edObtainedInputFile)

        pyStrExpectedInput = self.readAndParseFile (self.m_edReferenceInputFile)
        pyStrObtainedInput = self.readAndParseFile (self.m_edObtainedInputFile)

        xsDataInputExpected = XSDataInputBest.parseString(pyStrExpectedInput)
        xsDataInputObtained = XSDataInputBest.parseString(pyStrObtainedInput)

        EDAssert.equal(xsDataInputExpected.marshal(), xsDataInputObtained.marshal())
        EDUtilsFile.deleteFile(self.m_edObtainedInputFile)

        self.cleanUp(edPluginBest)
 def writeExecutableScript(self, _strScript):
     """
     Writes the script to the script file.
     """
     self.DEBUG("EDPluginExecProcessScript.writeScriptToFile")
     EDUtilsFile.writeFile(self.getScriptFilePath(), _strScript)
     self.setExecutable(self.getScriptExecutor())
     self.setCommandline(self.getScriptFilePath())
 def preProcess(self, _edObject=None):
     EDPluginExecProcessScript.preProcess(self)
     self.DEBUG("EDPluginBackground3Dv1_0.preProcess")
     xsDataInputBackground3D = self.getDataInput()
     self.setScriptCommandline("background.dat")
     strCommands = self.generateCommands(xsDataInputBackground3D)
     self.createImageLinks(xsDataInputBackground3D)
     EDUtilsFile.writeFile(os.path.join(self.getWorkingDirectory(), "background.dat"), strCommands)
 def writeProcessFile(self, _strFileName, _strContent):
     """
     Main method to write a file in the plugin working directory
     Such a file is called process file
     """
     EDVerbose.DEBUG("EDPluginExecProcessXIA2CORE.writeProcessFile")
     strFilePath = os.path.join(self.getWorkingDirectory(), _strFileName)
     EDUtilsFile.writeFile(strFilePath, _strContent)
 def doSuccessActionInterface(self, _edPlugin=None):
     self.DEBUG("EDPluginControlInterfaceToMXCuBEv1_3.doSuccessActionInterface...")
     self.retrieveSuccessMessages(self.edPluginControlInterface, "EDPluginControlInterfaceToMXCuBEv1_3.doSuccessActionInterface")
     xsDataResultCharacterisation = self.edPluginControlInterface.getDataOutput().getResultCharacterisation()
     self.xsDataResultMXCuBE.setCharacterisationResult(xsDataResultCharacterisation)
     xsDataResultControlISPyB = self.edPluginControlInterface.getDataOutput().getResultControlISPyB()
     if xsDataResultControlISPyB != None:
         self.xsDataResultMXCuBE.setScreeningId(xsDataResultControlISPyB.getScreeningId())
     if xsDataResultCharacterisation != None:
         strPathCharacterisationResult = os.path.join(self.getWorkingDirectory(), "CharacterisationResult.xml")
         xsDataResultCharacterisation.exportToFile(strPathCharacterisationResult)
         self.xsDataResultMXCuBE.setListOfOutputFiles(XSDataString(strPathCharacterisationResult))
         # For the moment, create "DNA" style output directory
         strPathToDNAFileDirectory = self.createDNAFileDirectoryPath(xsDataResultCharacterisation)
         xsDataDictionaryLogFile = None
         if (self.createDNAFileDirectory(strPathToDNAFileDirectory)):
             xsDataDictionaryLogFile = self.createOutputFileDictionary(xsDataResultCharacterisation, strPathToDNAFileDirectory)
         strPyArchPathToDNAFileDirectory = self.createPyArchDNAFilePath(strPathToDNAFileDirectory)
         if (self.createDNAFileDirectory(strPyArchPathToDNAFileDirectory)):
             xsDataDictionaryLogFile = self.createOutputFileDictionary(xsDataResultCharacterisation, strPyArchPathToDNAFileDirectory)
         self.xsDataResultMXCuBE.setOutputFileDictionary(xsDataDictionaryLogFile)
         # Send success email message (MXSUP-183):
         self.tStop = time.time()
         strSubject = "%s : SUCCESS! (%.1f s)" % (EDUtilsPath.getEdnaSite(), self.tStop-self.tStart)
         strMessage = "Characterisation success!"
         if xsDataResultCharacterisation.getStatusMessage():
             strMessage += "\n\n"
             strMessage += xsDataResultCharacterisation.getStatusMessage().getValue()
         if xsDataResultCharacterisation.getShortSummary():
             strMessage += "\n\n"
             strMessage += xsDataResultCharacterisation.getShortSummary().getValue()
         self.sendEmail(strSubject, strMessage)
         # Fix for bug EDNA-55 : If burning strategy EDNA2html shouldn't be run
         bRunExecOutputHTML = False
         xsDataInputMXCuBE = self.getDataInput()
         xsDataDiffractionPlan = xsDataInputMXCuBE.getDiffractionPlan()
         if xsDataDiffractionPlan.getStrategyOption() is not None:
             strStrategyOption = xsDataDiffractionPlan.getStrategyOption().getValue()
             if strStrategyOption.find("-DamPar") != -1:
                 bRunExecOutputHTML = False
         if (self.edPluginExecOutputHTML is not None) and bRunExecOutputHTML:
             self.edPluginExecOutputHTML.setDataInput(XSDataFile(XSDataString(strPathToDNAFileDirectory)), "dnaFileDirectory")
             self.edPluginExecOutputHTML.execute()
         # Fix for bug MXSUP-251: Put the BEST .par file in the EDNA characterisation root directory
         xsDataIntegrationResult = xsDataResultCharacterisation.getIntegrationResult()
         if xsDataIntegrationResult:
             listXSDataIntegrationSubWedgeResult = xsDataIntegrationResult.getIntegrationSubWedgeResult()
             if listXSDataIntegrationSubWedgeResult:
                 if listXSDataIntegrationSubWedgeResult != []:
                     strBestfilePar = listXSDataIntegrationSubWedgeResult[0].getBestfilePar().getValue()
                     # Put the file one directory above the mxCuBE v1.3 plugin working directory:
                     strDir = os.path.dirname(self.getWorkingDirectory())
                     strPath = os.path.join(strDir, "bestfile.par")
                     EDUtilsFile.writeFile(strPath, strBestfilePar)
         # Execute plugin which creates a simple HTML page
         self.executeSimpleHTML(xsDataResultCharacterisation)    
    def __generateIfeffitInputFile(self):
        xsExperimentalDataEnergy = self.getDataInput().getExperimentalDataEnergy()
        xsExperimentalDataLnI0It = self.getDataInput().getExperimentalDataLnI0It()

        strLines = "# energy    ln(I0/It)\n"
        for i, dataEnergy in enumerate(xsExperimentalDataEnergy):
            strLines += " ".join([str(dataEnergy.getValue()), str(xsExperimentalDataLnI0It[i].getValue())]) + "\n"
        tmpInputFileName = os.path.join(self.getWorkingDirectory(), self.__strIfeffitDataName)
        EDUtilsFile.writeFile(tmpInputFileName, strLines)
        return tmpInputFileName
    def doSuccessActionCharacterisation(self, _edPlugin):
        """
        retrieve the potential warning messages
        """
        EDPluginControlInterfacev1_1.doSuccessActionCharacterisation(self, _edPlugin)

        # Generate file with executive summary...
        pyStrCharacterisationExecutiveSummary = ""
        pyListExecutiveSummaryLines = self.getPluginCharacterisation().getListExecutiveSummaryLines()
        for pyStrLine in pyListExecutiveSummaryLines:
            pyStrCharacterisationExecutiveSummary += pyStrLine + "\n"
        pyStrSummaryDirectory = self.getWorkingDirectory()
        pyStrSummaryPath = os.path.join(pyStrSummaryDirectory, "CharacterisationExecutiveSummary.txt")
        EDUtilsFile.writeFile(pyStrSummaryPath, pyStrCharacterisationExecutiveSummary)

        xsDataResultCCP4i = XSDataResultCCP4i()
        # Construct the listOfOutputFiles string...

        pyStrListOfOutputFiles = '\n'
        pyStrListOfOutputFiles = pyStrListOfOutputFiles + self.getBaseDirectory() + '\n'
        xsDataOutput = self.getPluginCharacterisation().getDataOutput()
        pyListPredictionImages = xsDataOutput.getIndexingResult().getPredictionResult().getPredictionImage()
        for xsDataImagePrediction in pyListPredictionImages:
            strImagePath = xsDataImagePrediction.getPath().getValue()
            pyStrListOfOutputFiles = pyStrListOfOutputFiles + strImagePath + '\n'

        pyStrCharacterisationDirectory = os.path.join(self.getWorkingDirectory(), "Characterisation")
        # "Hack" for determining if we use version 1.1 or 1.2 of the BEST plugin...
        pyStrBestWorkingDirectory = os.path.join(pyStrCharacterisationDirectory, "Strategy")
        pyStrBestPlotFilePath = None
        pyStrBestLogFilePath = None
        if (os.path.exists(os.path.join(pyStrBestWorkingDirectory, "Bestv1_1"))):
            pyStrBestWorkingDirectory = os.path.join(pyStrBestWorkingDirectory, "Bestv1_1")
            pyStrBestPlotFilePath = os.path.join(pyStrBestWorkingDirectory, "Bestv1_1_plots.mtv")
            pyStrBestLogFilePath = os.path.join(pyStrBestWorkingDirectory, "Bestv1_1.log")
        elif (os.path.exists(os.path.join(pyStrBestWorkingDirectory, "Bestv1_2"))):
            pyStrBestWorkingDirectory = os.path.join(pyStrBestWorkingDirectory, "Bestv1_2")
            pyStrBestPlotFilePath = os.path.join(pyStrBestWorkingDirectory, "Bestv1_2_plots.mtv")
            pyStrBestLogFilePath = os.path.join(pyStrBestWorkingDirectory, "best.log")
        pyStrCharacterisationOutput = None
        if self.getPluginCharacterisation().getClassName() == "EDPluginControlCharacterisationv1_1":
            pyStrCharacterisationOutput = os.path.join(pyStrCharacterisationDirectory, "ControlCharacterisationv1_1_dataOutput.xml")
        elif self.getPluginCharacterisation().getClassName() == "EDPluginControlCharacterisationv1_2":
            pyStrCharacterisationOutput = os.path.join(pyStrCharacterisationDirectory, "ControlCharacterisationv1_2_dataOutput.xml")

        pyStrListOfOutputFiles = pyStrListOfOutputFiles + pyStrCharacterisationOutput + '\n'
        if (pyStrBestLogFilePath is not None):
            pyStrListOfOutputFiles = pyStrListOfOutputFiles + pyStrBestLogFilePath + '\n'
            pyStrListOfOutputFiles = pyStrListOfOutputFiles + pyStrBestPlotFilePath + '\n'
        pyStrListOfOutputFiles = pyStrListOfOutputFiles + pyStrSummaryPath + '\n'

        xsDataStringListOfOutputFiles = XSDataString(pyStrListOfOutputFiles)
        xsDataResultCCP4i.setListOfOutputFiles(xsDataStringListOfOutputFiles)

        self.setDataOutput(xsDataResultCCP4i)
    def __generateIfeffitInputFile(self, dataset):
        _xsExperimentalDataEnergy = dataset.getExperimentalDataEnergy()
        _xsExperimentalDataLnI0It = dataset.getExperimentalDataLnI0It()
        _label = self.__getDatasetLabel(dataset)

        strLines = '# energy    ln(I0/It)\n'
        for i, dataEnergy in enumerate(_xsExperimentalDataEnergy):
            strLines += ' '.join([str(dataEnergy.getValue()), str(_xsExperimentalDataLnI0It[i].getValue())]) + '\n'
        tmpInputFileName = os.path.join(self.getWorkingDirectory(), _label + self.__strIfeffitDataName)
        EDUtilsFile.writeFile(tmpInputFileName, strLines)
        return tmpInputFileName
 def testGetEdnaUserTempFolder(self):
     # Test that we can access the user temp folder
     strUserTempFolder = EDUtilsPath.getEdnaUserTempFolder()
     EDAssert.equal(True, os.path.exists(strUserTempFolder), "Checking that user temp folder exists")
     # Test if we can write to the temp folder
     strTest = "This is a test string."
     strPathTestFile = os.path.join(strUserTempFolder, "EDTestCaseEDUtilsPath_testFile.txt")
     EDUtilsFile.writeFile(strPathTestFile, strTest)
     EDAssert.equal(True, os.path.exists(strPathTestFile), "Checking that new temp file exists")
     # Delete the test file
     os.remove(strPathTestFile)
Example #22
0
 def createHtmlPage(self):
     page = markupv1_7.page(mode='loose_html')
     page.init( title="Burn Strategy Results", 
                     footer="Generated on %s" % time.asctime())
     page.div( align_="CENTER")
     page.h1()
     page.strong("Burn Strategy  Results")
     page.h1.close()
     page.img(src=self.strScaleIntensityPlot, title=self.strScaleIntensityPlot)
     page.div.close()
     strHTML = str(page)
     EDUtilsFile.writeFile(os.path.join(self.getWorkingDirectory(), self.strHtmlPath), strHTML)
    def parseIfeffitFiles(self, f, strIfeffitResultName, dictDatasets, _groupLabel, _xLabel):
        dataLabels = []
        xResults = []
        yResults = []
        for (idx,label) in enumerate(sorted(self.__xsIfeffitPlugin.iterkeys())):
            dataLabels.append(label)
            yResults.append({})
            logLines = EDUtilsFile.readFile(os.path.join(self.__xsIfeffitPlugin[label].getWorkingDirectory(), \
                                                         label + strIfeffitResultName)).split('\n')[4:]
            xResults.append([float(dataLine.split()[0]) for dataLine in logLines if dataLine])
            for (col, param) in dictDatasets.iteritems():
                yResults[idx][param] = [float(dataLine.split()[col]) for dataLine in logLines if dataLine]
            
        _lenData = min([len(tmp) for tmp in xResults]) 
        dEntry = f['/entry1']
        dProcessing = dEntry.create_group(_groupLabel)
        dProcessing.attrs["NX_class"] = "NXdata"
        dx = dProcessing.create_dataset(_xLabel, (_lenData,), '=f8')
        dx.attrs["target"] = "/".join(['','entry1',_groupLabel,_xLabel])
        dx.attrs["axis"] = 2
        dx.attrs["primary"] = 1
        dx[:] = xResults[0][:_lenData] 
        
        #str_type = h5py.new_vlen(str)
        #dz = dProcessing.create_dataset('dataLabels', (len(dataLabels),), str_type)
        dz = dProcessing.create_dataset('scanID', (len(dataLabels),), "i")
        dz.attrs["target"] = "/".join(['','entry1',_groupLabel,'scanID'])
        dz.attrs["axis"] = 1
        dz.attrs["primary"] = 2
        dz[:] = [int(tmpLabel.split('_')[-1]) for tmpLabel in dataLabels]
        
        for tmpName in dictDatasets.itervalues():
            tmpLines = ['  '.join(['#',_xLabel,''] + dataLabels)]
            for idx in range(_lenData):
                tmpLines.append(str(xResults[0][idx]) + '  ' + '  '.join([str(yResults[idxDataLabel][tmpName][idx]) for idxDataLabel in range(len(dataLabels))]))
                
            EDUtilsFile.writeFile(os.path.join(self.getWorkingDirectory(), ''.join(['results_',tmpName,'.dat'])), '\n'.join(tmpLines))
        
        
            #dTmp = dProcessing.create_dataset(tmpName, (_lenData,len(dataLabels)), '=f8')
            #dTmp.attrs["target"] = "/".join(['','entry1',_groupLabel,tmpName])
            #for idxDataLabel in  range(len(dataLabels)):
            #    dTmp[:,idxDataLabel] = yResults[idxDataLabel][tmpName][:_lenData]
                
            dTmp = dProcessing.create_dataset(tmpName, (len(dataLabels),_lenData), '=f8')
            dTmp.attrs["target"] = "/".join(['','entry1',_groupLabel,tmpName])
            dTmp.attrs["signal"] = 1
            dTmp.attrs["axes"] = ':'.join(["scanID", _xLabel])
            

            for idxDataLabel in  range(len(dataLabels)):
                dTmp[idxDataLabel,:] = yResults[idxDataLabel][tmpName][:_lenData]
Example #24
0
 def run(self):
     """
     Executes the plugin and checks that the data output is not None
     """
     EDVerbose.DEBUG("EDTestCasePluginExecute: Executing " + self.getPluginName())
     self._edPlugin.executeSynchronous()
     # Check that the plugin didn't end in failure
     EDAssert.equal(self._bAcceptPluginFailure , self._edPlugin.isFailure(), \
                    "Plugin failure assert: should be %r, was %r" % (self._bAcceptPluginFailure , self._edPlugin.isFailure()))
     # Checks the number of error messages
     EDAssert.equal(self._iNoExpectedErrorMessages, len(self._edPlugin.getListOfErrorMessages()), \
                        "Number of error messages: expected %d, got %d" % (self._iNoExpectedErrorMessages, len(self._edPlugin.getListOfErrorMessages())))
     # Checks the number of warning messages
     EDAssert.equal(self._iNoExpectedWarningMessages, len(self._edPlugin.getListOfWarningMessages()), \
                        "Number of warning messages: expected %d, got %d" % (self._iNoExpectedWarningMessages, len(self._edPlugin.getListOfWarningMessages())))
     # Check the output data
     listOfDataOutputKeys = self._edPlugin.getListOfDataOutputKeys()
     for strReferenceOutputDataKey in self._dictStrReferenceDataOutputFiles.keys():
         # Only check the reference data keys
         if (strReferenceOutputDataKey in listOfDataOutputKeys):
             EDVerbose.unitTest("Testing data output for %s" % strReferenceOutputDataKey)
             listReferenceFile = self._dictStrReferenceDataOutputFiles[ strReferenceOutputDataKey ]
             if (type(listReferenceFile) != types.ListType):
                 listReferenceFile = [ listReferenceFile ]
             listReferenceOutput = []
             for strReferenceFile in listReferenceFile:
                 listReferenceOutput.append(self.readAndParseFile(strReferenceFile))
             # Obtained output
             listObtainedOutputXML = []
             pyObjectObtainedDataOutput = self._edPlugin.getDataOutput(strReferenceOutputDataKey)
             listObtainedOutput = None
             if (type(pyObjectObtainedDataOutput) == types.ListType):
                 listObtainedOutput = pyObjectObtainedDataOutput
             else:
                 listObtainedOutput = [ pyObjectObtainedDataOutput ]
             for xsDataOutput in listObtainedOutput:
                 listObtainedOutputXML.append(xsDataOutput.marshal())
             # Compare the lists, sort them first
             listReferenceOutput.sort()
             listObtainedOutputXML.sort()
             for iIndex in range(len(listReferenceOutput)):
                 # Check of deprecated tests - if default data key only warn
                 if (strReferenceOutputDataKey == self._strDefaultOutputDataKey):
                     if (listReferenceOutput[ iIndex ] != listObtainedOutputXML[ iIndex ]):
                         EDVerbose.unitTest("WARNING! Expected output is not corresponding to obtained output.")
                 else:
                     EDAssert.equal(listReferenceOutput[ iIndex ], listObtainedOutputXML[ iIndex ])
             # Legacy - save output data
             if (strReferenceOutputDataKey == self._strDefaultOutputDataKey):
                 if (self.m_edObtainedOutputDataFile is None):
                     self.m_edObtainedOutputDataFile = self.getPluginName() + "_output.xml"
                 EDUtilsFile.writeFile(self.m_edObtainedOutputDataFile, self._edPlugin.getDataOutput().marshal())
 def testInitaliseLabelitCommandLine(self):
     """
     This method tests the initaliseLabelitCommandLine method of the Labelit plugin.
     """
     edPluginLabelitv1_1 = self.createPlugin()
     xmlInput1 = EDUtilsFile.readFile(self.__strReferenceInputFile1)
     edPluginLabelitv1_1.setDataInput(xmlInput1, "referenceImage")
     xmlInput2 = EDUtilsFile.readFile(self.__strReferenceInputFile2)
     edPluginLabelitv1_1.setDataInput(xmlInput2, "referenceImage")
     edPluginLabelitv1_1.initaliseLabelitCommandLine()
     strScriptCommandLine = edPluginLabelitv1_1.getScriptCommandline()
     strCommandLineExpected = "--index_only ${EDNA_TESTIMAGES}/images/ref-testscale_1_001.img ${EDNA_TESTIMAGES}/images/ref-testscale_1_002.img"
     EDAssert.equal(strCommandLineExpected, strScriptCommandLine)
 def testGenerateXSDataInputISPyB(self):
     """
     This method is testing the generation of the XSDataInputISPyB object given a XSDataIndexingInput object.
     """
     strReferenceInputControlISPyBFile = EDUtilsPath.mergePath(self.strDataPath, "XSDataInputControlISPyB_reference.xml")
     strPath = os.path.join(self.strDataPath, strReferenceInputControlISPyBFile)
     strXMLIndexingInput = EDUtilsFile.readFileAndParseVariables(strPath, self.dictReplace)
     xsDataInputControlISPyB = XSDataInputControlISPyB.parseString(strXMLIndexingInput)
     xsDataInputISPyB = EDHandlerXSDataISPyBv1_4.generateXSDataInputISPyBStoreScreening(xsDataInputControlISPyB)
     strReferenceInputISPyBFile = EDUtilsPath.mergePath(self.strDataPath, "XSDataInputISPyB_reference.xml")
     strReferencePath = os.path.join(self.strDataPath, strReferenceInputISPyBFile)
     strXMLInputISPyBReference = EDUtilsFile.readFileAndParseVariables(strReferencePath, self.dictReplace)
     EDFactoryPluginStatic.loadModule("XSDataISPyBv1_4")
Example #27
0
 def finallyProcess(self, _edObject=None):
     EDPluginExecProcessScript.finallyProcess(self)
     self.DEBUG("EDPluginBestv1_2.finallyProcess")
     xsDataResultBest = self.getOutputDataFromDNATableFile(
         os.path.join(self.getWorkingDirectory(), self.getScriptBaseName() + "_dnaTables.xml")
     )
     xsDataFilePathToLog = XSDataFile(
         XSDataString(os.path.join(self.getWorkingDirectory(), self.getScriptLogFileName()))
     )
     xsDataResultBest.setPathToLogFile(xsDataFilePathToLog)
     strError = self.readProcessErrorLogFile()
     if (strError is not None) and (strError != ""):
         strErrorMessage = EDMessage.ERROR_EXECUTION_03 % (
             "EDPluginBestv1_2.finallyProcess",
             "EDPluginBestv1_2",
             strError,
         )
         self.error(strErrorMessage)
         self.addErrorMessage(strErrorMessage)
         # Append error message to best log
         strLog = self.readProcessLogFile()
         strLog += "\n" + strError
         EDUtilsFile.writeFile(os.path.join(self.getWorkingDirectory(), self.getScriptLogFileName()), strLog)
         self.setDataOutput(xsDataResultBest)
         self.setFailure()
     else:
         strPathToPlotMtv = os.path.join(self.getWorkingDirectory(), self.getScriptBaseName() + "_plots.mtv")
         if os.path.exists(strPathToPlotMtv):
             xsDataFilePathToPlotMtv = XSDataFile(XSDataString(strPathToPlotMtv))
             xsDataResultBest.setPathToPlotMtvFile(xsDataFilePathToPlotMtv)
         # Check for .gle files
         for strPath in os.listdir(self.getWorkingDirectory()):
             if strPath.endswith(".gle"):
                 xsDataBestGlePlot = XSDataBestGlePlot()
                 xsDataBestGlePlot.script = XSDataFile(
                     XSDataString(os.path.join(self.getWorkingDirectory(), strPath))
                 )
                 strDataPath = strPath[:-4] + ".dat"
                 if os.path.exists(os.path.join(self.getWorkingDirectory(), strDataPath)):
                     xsDataBestGlePlot.data = XSDataFile(
                         XSDataString(os.path.join(self.getWorkingDirectory(), strDataPath))
                     )
                 else:
                     strDataPath = strPath[:-4] + ".data"
                     if os.path.exists(os.path.join(self.getWorkingDirectory(), strDataPath)):
                         xsDataBestGlePlot.data = XSDataFile(
                             XSDataString(os.path.join(self.getWorkingDirectory(), strDataPath))
                         )
                 xsDataResultBest.addGlePlot(xsDataBestGlePlot)
         self.setDataOutput(xsDataResultBest)
Example #28
0
 def preProcess(self, _edObject=None):
     EDPluginExecProcessScript.preProcess(self)
     self.DEBUG("EDPluginDozorv1_0.preProcess")
     xsDataInputDozor = self.getDataInput()
     # First image number and osc range for output angle calculations
     self.firstImageNumber = xsDataInputDozor.firstImageNumber.value
     self.oscillationRange = xsDataInputDozor.oscillationRange.value
     if xsDataInputDozor.overlap is not None:
         self.overlap = xsDataInputDozor.overlap.value
     if xsDataInputDozor.radiationDamage is not None and xsDataInputDozor.radiationDamage.value:
         self.setScriptCommandline("-rd dozor.dat")
     else:
         self.setScriptCommandline("-p dozor.dat")
     strCommands = self.generateCommands(xsDataInputDozor)
     EDUtilsFile.writeFile(os.path.join(self.getWorkingDirectory(), "dozor.dat"), strCommands)
    def testExecute(self):
        """
        """
        self.run()

        # Checks that there are no error messages

        plugin = self.getPlugin()

        EDVerbose.DEBUG("Checking error messages...")
        EDAssert.equal(self.m_iNoErrorMessages, self.getErrorMessages().getNumberObjects())

        EDVerbose.DEBUG("Checking warning messages...")
        EDAssert.equal(self.m_iNoWarningMessages, self.getWarningMessages().getNumberObjects())

        # Checking obtained results
        # For the moment, just check if the output file exists

        xsDataResultsFIT2DCake = plugin.getDataOutput()
        strPathToOutputFile = xsDataResultsFIT2DCake.getResultFile().getPath().getValue()
        strDataObtained = EDUtilsFile.readFile(strPathToOutputFile)
        strDataReference = EDUtilsFile.readFile(os.path.join(self.getPluginTestsDataHome(), \
                                                                             "EDPluginFIT2DCakev1_1.chi"))
        EDAssert.equal(strDataReference, strDataObtained)

        EDAssert.equal(True, os.path.exists(strPathToOutputFile))
        bEqual = (strDataReference == strDataObtained)
        if not bEqual:
            lstDataReference = strDataReference.split()
            lstDataObtained = strDataObtained.split()
            if len(lstDataReference) == len(lstDataObtained):
                EDVerbose.DEBUG("Checking for small numerical error...Relative:%s Absolute: %s" % (self.EPSILON_REL, self.EPSILON_ABS))
                bEqual = True
                for i in xrange(len(lstDataReference)):
                    if lstDataReference[i] != lstDataObtained[i]:
                        try:
                            r = float(lstDataReference[i])
                            o = float(lstDataObtained[i])
                        except Exception:
                            bEqual = False
                            break
                        if (2 * abs(r - o) / (o + r) > self.EPSILON_REL) and abs(r - o) > self.EPSILON_ABS:
#                            EDVerbose.setVerboseDebugOn()
                            EDVerbose.DEBUG("MisMatch: %s,%s" % (r, o))
                            bEqual = False
                            break

        EDAssert.equal(bEqual, True)
 def preProcess(self, _edObject=None):
     EDPluginExec.preProcess(self)
     self.DEBUG("EDPluginExecPlotGlev1_1.preProcess")
     FileGle = None
     # Check if we have a plotmtv input file
     xsDataInput = self.getDataInput()
     for xsDataGlePlot in xsDataInput.glePlot:
         dictPlot = {}
         dictPlot["script"] = xsDataGlePlot.script.path.value
         dictPlot["data"] = [xsDataGlePlot.data.path.value]
         self.listPlot.append(dictPlot)
     if xsDataInput.filePlotMtv is not None:
         strPlotMtvPath = xsDataInput.filePlotMtv.path.value
         if os.path.exists(strPlotMtvPath):
             strPlotMtv = EDUtilsFile.readFile(strPlotMtvPath)
             xsDataPlotSet = self.readPlotMtv(strPlotMtv)
         else:
             self.ERROR("Path to plt mtv file does not exist: %s" % strPlotMtvPath)
             self.setFailure()
             return
     else:
         xsDataPlotSet = xsDataInput.plotSet
     # Prepare input script
     iIndex = 1
     if xsDataPlotSet is not None:
         for xsDataPlot in xsDataPlotSet.plot:
             if xsDataPlot.xsize is None:
                 xsDataPlot.xsize = 10
             if xsDataPlot.ysize is None:
                 xsDataPlot.ysize = 10
             if iIndex in [1, 5, 8]:
                 xsDataPlot.keypos = "tl"
             elif iIndex in [2, 4, 6]:
                 xsDataPlot.keypos = "tr"
             elif iIndex in [3]:
                 xsDataPlot.keypos = "br"
             elif iIndex in [7]:
                 xsDataPlot.keypos = "bl"
             if iIndex == 4:
                 xsDataPlot.xmax = 500
             strPlotFile = os.path.join(self.getWorkingDirectory(), "plot%d" % iIndex)
             (strGle, listDataFiles) = self.prepareGleGraph(xsDataPlot)
             EDUtilsFile.writeFile(strPlotFile + ".gle", strGle)
             dictPlot = {}
             dictPlot["script"] = strPlotFile + ".gle"
             dictPlot["data"] = listDataFiles
             self.listPlot.append(dictPlot)
             iIndex += 1
Example #31
0
 def preProcess(self, _edObject=None):
     EDPluginExec.preProcess(self)
     self.DEBUG("EDPluginExecPlotGlev1_0.preProcess")
     # Check if we have a plotmtv input file
     xsDataInput = self.getDataInput()
     if xsDataInput.filePlotMtv is not None:
         strPlotMtvPath = xsDataInput.filePlotMtv.path.value
         if os.path.exists(strPlotMtvPath):
             strPlotMtv = EDUtilsFile.readFile(strPlotMtvPath)
             xsDataPlotSet = self.readPlotMtv(strPlotMtv)
         else:
             self.ERROR("Path to plt mtv file does not exist: %s" %
                        strPlotMtvPath)
             self.setFailure()
             return
     else:
         xsDataPlotSet = xsDataInput.plotSet
     # Prepare input script
     iIndex = 1
     for xsDataPlot in xsDataPlotSet.plot:
         if xsDataPlot.xsize is None:
             xsDataPlot.xsize = 10
         if xsDataPlot.ysize is None:
             xsDataPlot.ysize = 10
         if iIndex in [1, 5, 8]:
             xsDataPlot.keypos = "tl"
         elif iIndex in [2, 4, 6]:
             xsDataPlot.keypos = "tr"
         elif iIndex in [3]:
             xsDataPlot.keypos = "br"
         elif iIndex in [7]:
             xsDataPlot.keypos = "bl"
         if iIndex == 4:
             xsDataPlot.xmax = 500
         strPlotFile = os.path.join(self.getWorkingDirectory(),
                                    "plot%d" % iIndex)
         strGle = self.prepareGleGraph(xsDataPlot)
         EDUtilsFile.writeFile(strPlotFile + ".gle", strGle)
         self.listPlot.append(strPlotFile)
         iIndex += 1
Example #32
0
    def postProcess(self, _edObject=None):
        EDPluginExec.postProcess(self)
        EDVerbose.DEBUG("EDPluginExecOutputHTMLv1_0.postProcess")
        if self.strWorkingDir != None:
            xsDataFileHTMLFile = XSDataFile()
            xsDataFileHTMLDir = XSDataFile()

            if self.strBasename is None:
                strHTMLFilePath = os.path.join(self.strWorkingDir, "edna.html")
                strHTMLDirPath = os.path.join(self.strWorkingDir, "edna_html")
            else:
                strHTMLFilePath = os.path.join(self.strBasename, "edna.html")
                strHTMLDirPath = os.path.join(self.strBasename, "edna_html")

            if os.path.exists(strHTMLFilePath):
                strFileContent = EDUtilsFile.readFile(strHTMLFilePath)
                strFileContent = strFileContent.replace(
                    "table,td,th { border-style: none;",
                    "div.edna table,td,th { border-style: none;")
                strFileContent = strFileContent.replace(
                    "td,th { border-style: solid;",
                    "div.edna td,th { border-style: solid;")
                strFileContent = strFileContent.replace(
                    "th { background-color: gray;",
                    "div.edna th { background-color: gray;")
                strFileContent = strFileContent.replace(
                    "<body onload=\"initTable('strategyData',false,false);\">",
                    "<body onload=\"initTable('strategyData',false,false);\"><div class = 'edna'> "
                )
                strFileContent = strFileContent.replace(
                    "</body>", "</div></body>")
                EDUtilsFile.writeFile(strHTMLFilePath, strFileContent)
                xsDataFileHTMLFile.setPath(XSDataString(strHTMLFilePath))
                xsDataFileHTMLDir.setPath(XSDataString(strHTMLDirPath))
                self.setDataOutput(xsDataFileHTMLFile, "htmlFile")
                self.setDataOutput(xsDataFileHTMLDir, "htmlDir")
            else:
                EDVerbose.ERROR(
                    "EDPluginExecOutputHTMLv1_0.postProcess: file doesn't exist: "
                    + strHTMLFilePath)
Example #33
0
    def preProcess(self, _edObject=None):
        """
        """
        EDPluginExecProcessScript.preProcess(self)

        self.setFileBestDat(
            os.path.join(self.getWorkingDirectory(), "bestfile.dat"))
        self.setFileBestPar(
            os.path.join(self.getWorkingDirectory(), "bestfile.par"))

        EDUtilsFile.writeFile(
            self.getFileBestDat(),
            self.getDataInput().getBestFileContentDat().getValue())
        EDUtilsFile.writeFile(
            self.getFileBestPar(),
            self.getDataInput().getBestFileContentPar().getValue())

        listBestFileContentHKL = self.getDataInput().getBestFileContentHKL()

        iterator = 0
        for bestFileContentHKL in listBestFileContentHKL:
            iterator = iterator + 1
            bestFileHKL = os.path.join(self.getWorkingDirectory(),
                                       "bestfile" + str(iterator) + ".hkl")
            self.listFileBestHKL.append(bestFileHKL)
            EDUtilsFile.writeFile(bestFileHKL, bestFileContentHKL.getValue())

        if (self.getDataInput().getComplexity() is not None):
            self.setComplexity(self.getDataInput().getComplexity().getValue())

        self.initializeCommands()
 def process(self, _edPlugin=None):
     EDPluginExec.process(self, _edPlugin)
     self.DEBUG("EDPluginExecSimpleHTMLPagev1_0.process...")
     if self.xsDataResultCharacterisation is not None:
         # Create the simple characterisation result page
         self.page = markupv1_7.page(mode='loose_html')
         self.page.init(title="Characterisation Results",
                        footer="Generated on %s" % time.asctime())
         self.page.div(align_="CENTER")
         self.page.h1()
         if self.xsDataResultCharacterisation is not None:
             self.page.strong("Characterisation Results ")
         else:
             self.page.strong("No Characterisation Results! ")
         # Link to the EDNA log file
         strPathToLogFile = self.findEDNALogFile()
         if strPathToLogFile is not None:
             self.page.strong("(")
             self.strPageEDNALog = os.path.join(self.getWorkingDirectory(),
                                                "edna_log.html")
             pageEDNALog = markupv1_7.page()
             pageEDNALog.h1("EDNA Log")
             pageEDNALog.a("Back to previous page",
                           href_=self.strHtmlFileName)
             pageEDNALog.pre(
                 cgi.escape(EDUtilsFile.readFile(strPathToLogFile)))
             pageEDNALog.a("Back to previous page",
                           href_=self.strHtmlFileName)
             EDUtilsFile.writeFile(self.strPageEDNALog, str(pageEDNALog))
             self.page.a("EDNA log file", href_="edna_log.html")
             self.page.strong(")")
         self.page.h1.close()
         self.page.div.close()
         self.dataCollectionInfo()
         self.diffractionPlan()
         self.strategyResults()
         self.graphs()
         self.indexingResults()
         self.integrationResults()
         self.imageQualityIndicatorResults()
Example #35
0
    def preProcess(self, _edObject=None):
        EDPluginExecProcessScript.preProcess(self)
        self.DEBUG("EDPluginBestv1_3.preProcess")

        self.setScriptLogFileName("best.log")

        self.setFileBestDat(
            os.path.join(self.getWorkingDirectory(), "bestfile.dat"))
        self.setFileBestPar(
            os.path.join(self.getWorkingDirectory(), "bestfile.par"))

        EDUtilsFile.writeFile(self.getFileBestDat(),
                              self.dataInput.bestFileContentDat.value)
        EDUtilsFile.writeFile(self.getFileBestPar(),
                              self.dataInput.bestFileContentPar.value)

        listBestFileContentHKL = self.dataInput.getBestFileContentHKL()

        iterator = 0
        for bestFileContentHKL in listBestFileContentHKL:
            iterator = iterator + 1
            bestFileHKL = os.path.join(self.getWorkingDirectory(),
                                       "bestfile" + str(iterator) + ".hkl")
            self.listFileBestHKL.append(bestFileHKL)
            EDUtilsFile.writeFile(bestFileHKL, bestFileContentHKL.value)

        if self.dataInput.complexity is not None:
            self.setComplexity(self.dataInput.complexity.value)

        self.initializeCommands()
Example #36
0
 def writeDataInput(self, _edObject=None):
     """
     Writes the input data object(s) into a working dir xml file 
     """
     self.DEBUG("EDPlugin.writeDataInput")
     strBasename = os.path.join(
         self.getWorkingDirectory(),
         self.compactPluginName(self.getPluginName()))
     for strKey in self.__dictXSDataInput.keys():
         if (strKey == self.__strDefaultInputDataKey):  # "Old" style
             xsDataInput = self.__dictXSDataInput[
                 self.__strDefaultInputDataKey]
             self.strPathDataInput = strBasename + "_dataInput.xml"
             EDUtilsFile.writeFile(self.strPathDataInput,
                                   xsDataInput.marshal())
         else:  # We have a list of objects
             listXSDataInput = self.__dictXSDataInput[strKey]
             for iIndex, xsDataInput in enumerate(listXSDataInput):
                 strPathDataInput = "%s_%s_%d_dataInput.xml" % (
                     strBasename, strKey, iIndex)
                 EDUtilsFile.writeFile(strPathDataInput,
                                       xsDataInput.marshal())
    def __init__(self, _edStringTestName=None):
        """
        """
        self.refInput = "MokeImage-2th21-tilt3-rot30.edf"
        self.refOutput = "MokeImage-2th21-tilt3-rot30.azim"
        EDTestCasePluginExecute.__init__(self, "EDPluginSPDCakev1_5",
                                         _edStringTestName)
        self.setConfigurationFile(self.getRefConfigFile())
        self.setDataInputFile(os.path.join(self.getPluginTestsDataHome(), \
                                                      "XSDataInputSPDCakev1_5_MokeImage.xml"))

        self.setReferenceDataOutputFile(os.path.join(self.getPluginTestsDataHome(), \
                                                                "XSDataResultSPDCakev1_5_MokeImage.xml"))

        self.m_edObtainedOutputDataFile = self.getPluginName() + "_output.xml"

        strSplineFileName = "frelon_spline_file_to_correct_SPD.spline"
        strPathToSplineFile = os.path.join(self.getTestsDataImagesHome(),
                                           strSplineFileName)
        if (not os.path.isfile(strPathToSplineFile)):
            EDUtilsFile.copyFile(os.path.join(self.getPluginTestsDataHome(), strSplineFileName), \
                                  strPathToSplineFile)
    def __init__(self):
        """
        """
        EDTestCasePluginExecute.__init__(self, "EDPluginSPDCakev1_1",
                                         "EDPluginControlSPD-v1.1")

        self.setConfigurationFile(self.getRefConfigFile())

        self.setDataInputFile(os.path.join(self.getPluginTestsDataHome(), \
                                                      "XSDataInputSPDCake_reference.xml"))

        self.setReferenceDataOutputFile(os.path.join(self.getPluginTestsDataHome(), \
                                                                "XSDataResultSPDCake_reference.xml"))

        self.m_edObtainedOutputDataFile = self.getPluginName() + "_output.xml"

        edStringSplineFileName = "frelon_spline_file_to_correct_SPD.spline"
        edStringPathToSplineFile = os.path.join(self.getTestsDataImagesHome(),
                                                edStringSplineFileName)
        if (not os.path.exists(edStringPathToSplineFile)):
            EDUtilsFile.copyFile(os.path.join(self.getPluginTestsDataHome(), edStringSplineFileName), \
                                  edStringPathToSplineFile)
    def readGnomDataFile(self, fileName):
        tmpExperimentalDataQ = []
        tmpExperimentalDataValues = []

        dataLines = EDUtilsFile.readFile(fileName).splitlines()[1:]
        for line in dataLines:
            lineList = line.split()
            if len(lineList) > 0:
                tmpExperimentalDataQ.append(XSDataDouble(float(lineList[0])))
                tmpExperimentalDataValues.append(XSDataDouble(float(lineList[1])))
        dataInput = self.plugin.dataInput
        dataInput.setExperimentalDataQ(tmpExperimentalDataQ)
        dataInput.setExperimentalDataValues(tmpExperimentalDataValues)
        dataInput.exportToFile("XSDataInputGnom_reference_list.xml")
Example #40
0
    def generateGnomInputFile(self):
        xsExperimentalDataQ = self.getDataInput().getExperimentalDataQ()
        xsExperimentalDataValues = self.getDataInput(
        ).getExperimentalDataValues()
        xsExperimentalDataStdDev = None
        if self.getDataInput().getExperimentalDataStdDev() is not None:
            xsExperimentalDataStdDev = self.getDataInput(
            ).getExperimentalDataStdDev()

        strLines = 'Gnom data file\n'
        for i, dataQ in enumerate(xsExperimentalDataQ):
            if xsExperimentalDataStdDev:
                strStdDev = str(xsExperimentalDataStdDev[i].getValue())
            else:
                strStdDev = ''
            strLines += ' '.join([
                str(dataQ.getValue()),
                str(xsExperimentalDataValues[i].getValue()), strStdDev
            ]) + '\n'
        tmpInputFileName = os.path.join(self.getWorkingDirectory(),
                                        "gnom_tmp.dat")
        EDUtilsFile.writeFile(tmpInputFileName, strLines)
        return tmpInputFileName
Example #41
0
 def finallyProcess(self, _edPlugin=None):
     EDPluginExec.finallyProcess(self, _edPlugin)
     self.DEBUG("EDPluginExecSimpleHTMLPagev1_0.finallyProcess...")
     # Render the page
     strHTML = str(self.page)
     EDUtilsFile.writeFile(self.strPath, strHTML)
     xsDataResultSimpleHTMLPage = XSDataResultSimpleHTMLPage()
     xsDataResultSimpleHTMLPage.setPathToHTMLFile(
         XSDataFile(XSDataString(self.strPath)))
     xsDataResultSimpleHTMLPage.setPathToHTMLDirectory(
         XSDataFile(XSDataString(os.path.dirname(self.strPath))))
     self.setDataOutput(xsDataResultSimpleHTMLPage)
     # Store in Pyarch
     strPyarchPath = None
     if self.xsDataResultCharacterisation is not None:
         strPyarchPath = EDHandlerESRFPyarchv1_0.createPyarchHtmlDirectoryPath(
             self.xsDataResultCharacterisation.getDataCollection())
     if strPyarchPath is None:
         # For debugging purposes
         strPyarchPath = EDUtilsPath.getEdnaUserTempFolder()
     EDHandlerESRFPyarchv1_0.copyHTMLDir(
         _strPathToHTMLDir=os.path.dirname(self.strPath),
         _strPathToPyarchDirectory=strPyarchPath)
Example #42
0
    def readAndParseFile(self, _strFileName):
        """
        Reads a file and parses potential existing environment variables such as:
         - EDNA_TESTS_DATA_HOME
         - EDNA_PLUGIN_TESTS_DATA_HOME
         - EDNA_HOME
         - USER
         - TMPDIR

        All those key are defined in a class dictionary

        Returns the content of this file as a string
        """
        return  str(EDUtilsFile.readFileAndParseVariables(_strFileName, self.dictReplace))
Example #43
0
 def readProcessFile(self, _strFileName):
     """
     Returns the file content of a process file
     """
     self.DEBUG("EDPluginExecProcessScript.readProcessFile")
     if _strFileName.startswith("/"):
         strFilePath = _strFileName
     else:
         strFilePath = os.path.join(self.getWorkingDirectory(),
                                    _strFileName)
     strFileContent = None
     if os.path.exists(strFilePath):
         strFileContent = EDUtilsFile.readFile(strFilePath)
     return strFileContent
    def testExecute(self):
        """
        """
        self.run()

        # Checks that there are no error messages

        plugin = self.getPlugin()

        EDVerbose.DEBUG("Checking error messages...")
        EDAssert.equal(self.m_iNoErrorMessages,
                       self.getErrorMessages().getNumberObjects())

        EDVerbose.DEBUG("Checking warning messages...")
        EDAssert.equal(self.m_iNoWarningMessages,
                       self.getWarningMessages().getNumberObjects())
        # Checking obtained results
        xsDataResults = plugin.getDataOutput()
        edStringPathToOutput = xsDataResults.getIntegratedIntensities(
        ).getPath().getValue()
        edStringDataObtained = EDUtilsFile.readFile(edStringPathToOutput)
        edStringDataReference = EDUtilsFile.readFile( os.path.join( self.getPluginTestsDataHome(), \
                                                                             "Reference_powder_diffraction.cif" ) )
Example #45
0
    def preProcess(self):
        """
        Creates the application working directory (log dir)
        Initializes the configuration
        retrieves the plugin xml data to be passed to the plugin
        """
        EDVerbose.DEBUG("EDApplication.preProcess")
        self.processCommandline()
        if (not self._bIsFailure):
            # Check that the plugin can be located
            strPluginLocation = EDFactoryPluginStatic.getFactoryPlugin().getModuleLocation(self._strPluginName)
            if (strPluginLocation is None):
                EDVerbose.error("Plugin  %s cannot be loaded!" % self._strPluginName)
                self._bIsFailure = True
            # Check that the input file can be read
            if (self.getDataInputFilePath() is not None) and (not os.path.exists(self._strDataInputFilePath)):
                EDVerbose.error("Input XML file not found : %s" % self._strDataInputFilePath)
                self._bIsFailure = True
            # Check that the output file can be created
            if (self._strDataOutputFilePath is not None):
                strOutputDirectory = os.path.dirname(self._strDataOutputFilePath)
                if (strOutputDirectory is None or strOutputDirectory == ""):
                    strOutputDirectory = os.getcwd()
                    self._strDataOutputFilePath = os.path.join(strOutputDirectory, self._strDataOutputFilePath)
                if (not os.access(strOutputDirectory, os.W_OK)):
                    EDVerbose.error("Output directory not writable: %s" % strOutputDirectory)
                    self._bIsFailure = True
                elif (os.path.exists(self._strDataOutputFilePath)):
                    if (not os.access(self._strDataOutputFilePath, os.W_OK)):
                        EDVerbose.error("Output file not writable: %s" % self._strDataOutputFilePath)
                        self._bIsFailure = True
        if (not self._bIsFailure):
            EDVerbose.DEBUG("EDApplication.PLUGIN_PARAM_LABEL: " + EDApplication.PLUGIN_PARAM_LABEL)

            if self._strConfigurationFileName is not None:
                # Load the configuration file
                if (os.path.exists(self._strConfigurationFileName)):
                    EDVerbose.screen("Loading Configuration file: %s" % self._strConfigurationFileName)
                    EDConfigurationStatic.addConfigurationFile(self._strConfigurationFileName, _bReplace=True)
                else:
                    EDVerbose.warning("Cannot find configuration file: %s" % self._strConfigurationFileName)
            pyDictionary = {}
            pyDictionary[ "${EDNA_HOME}" ] = EDUtilsPath.getEdnaHome()
            if self.getDataInputFilePath() is not None:
                self._strXMLData = EDUtilsFile.readFileAndParseVariables(self.getDataInputFilePath(), pyDictionary)
            # Create the application working directory    
            if(self._strWorkingDir is None):
                self._strWorkingDir = self._strApplicationInstanceName
            self.createApplicationWorkingDirectory()
 def testGetBestWilsonPlotPath(self):
     strReferenceInputControlISPyBFile = EDUtilsPath.mergePath(
         self.strDataPath, "XSDataInputControlISPyB_reference.xml")
     strPath = os.path.join(self.strDataPath,
                            strReferenceInputControlISPyBFile)
     strXMLIndexingInput = EDUtilsFile.readFileAndParseVariables(
         strPath, self.dictReplace)
     xsDataInputControlISPyB = XSDataInputControlISPyB.parseString(
         strXMLIndexingInput)
     xsDataCharacterisationResult = xsDataInputControlISPyB.characterisationResult
     strPath = EDHandlerXSDataISPyBv1_4.getBestWilsonPlotPath(
         xsDataCharacterisationResult)
     EDAssert.equal(
         True, strPath.endswith("B.jpg"),
         "Wilson plot path extracted from characterisation results")
    def parsePointlessOutput(self, _outputFile):

        sgre = re.compile(
            """ \* Space group = '(?P<sgstr>.*)' \(number\s+(?P<sgnumber>\d+)\)"""
        )

        sgnumber = sgstr = None

        res = XSDataPointlessOut()
        status = XSDataStatus()
        status.isSuccess = XSDataBoolean(False)
        if os.path.exists(_outputFile):
            res.status = status

            strLog = EDUtilsFile.readFile(_outputFile)
            if strLog is not None:
                # we'll apply the regexp to the whole file contents which
                # hopefully won't be that long.
                m = sgre.search(strLog)
                if m is not None:
                    d = m.groupdict()
                    sgnumber = d['sgnumber']
                    sgstr = d['sgstr']

                    res.sgnumber = XSDataInteger(sgnumber)
                    res.sgstr = XSDataString(sgstr)
                    status.isSuccess = XSDataBoolean(True)
                    # Search first for unit cell after the Laue group...
                    unitCellRe = re.compile(
                        """  Laue group confidence.+\\n\\n\s+Unit cell:(.+)""")
                    m2 = unitCellRe.search(strLog)
                    if m2 is None:
                        # Then search it from the end...
                        unitCellRe = re.compile(
                            """ \* Cell Dimensions : \(obsolete \- refer to dataset cell dimensions above\)\\n\\n(.+)"""
                        )
                        m2 = unitCellRe.search(strLog)
                    if m2 is not None:
                        listCell = m2.groups()[0].split()
                        xsDataCCP4Cell = XSDataCCP4Cell()
                        xsDataCCP4Cell.length_a = XSDataLength(listCell[0])
                        xsDataCCP4Cell.length_b = XSDataLength(listCell[1])
                        xsDataCCP4Cell.length_c = XSDataLength(listCell[2])
                        xsDataCCP4Cell.angle_alpha = XSDataAngle(listCell[3])
                        xsDataCCP4Cell.angle_beta = XSDataAngle(listCell[4])
                        xsDataCCP4Cell.angle_gamma = XSDataAngle(listCell[5])
                        res.cell = xsDataCCP4Cell
        return res
Example #48
0
    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")
Example #49
0
 def getXSDataResultBest(self, _strPathToLogFile):
     """Parse the BEST log file"""
     xsDataResultBest = None
     if os.path.exists(_strPathToLogFile):
         strBestLog = EDUtilsFile.readFile(_strPathToLogFile)
         xsDataStringStrategyOption = self.dataInput.strategyOption
         # Check if -DamPar or -Bonly strategy options have been used
         if xsDataStringStrategyOption is not None:
             strStrategyOption = xsDataStringStrategyOption.value
             if strStrategyOption.find("-Bonly") != -1:
                 xsDataResultBest = self.getBonlyOutputFromLog(strBestLog)
         if xsDataResultBest is None:
             # Neither the -DamPar nor the -Bonly strategy option has been used
             xsDataResultBest = self.getDataCollectionOutputDataFromLog(
                 strBestLog)
     return xsDataResultBest
 def testExecute(self):
     """
     """
     plugin = self.getPlugin()
     plugin.emptyItems()
     plugin.emptyQueries()
     self.run()
     # Checking obtained results
     xsDataResult = plugin.getDataOutput()
     strXMLRef = XSDataResultAccumulator.parseString(
         EDUtilsFile.readFile(self.getReferenceDataOutputFile())).marshal()
     EDAssert.equal(xsDataResult.marshal(), strXMLRef,
                    "XML results are conform")
     EDAssert.equal(plugin.getItems(),
                    [u'data1', u'data2', u'data3', u'data4', u'data5'],
                    "Remaining items are the same")
     plugin.emptyItems()
Example #51
0
    def preProcess(self, _edObject=None):
        EDPluginExecProcessScript.preProcess(self)
        self.DEBUG("EDPluginBestv1_2.preProcess")

        self.setScriptLogFileName("best.log")

        if self.dataInput.bestFileContentPar is not None:
            self.setFileBestDat(
                os.path.join(self.getWorkingDirectory(), "bestfile.dat"))
            self.setFileBestPar(
                os.path.join(self.getWorkingDirectory(), "bestfile.par"))

            EDUtilsFile.writeFile(self.getFileBestDat(),
                                  self.dataInput.bestFileContentDat.value)
            EDUtilsFile.writeFile(self.getFileBestPar(),
                                  self.dataInput.bestFileContentPar.value)

            listBestFileContentHKL = self.dataInput.bestFileContentHKL

            iterator = 0
            for bestFileContentHKL in listBestFileContentHKL:
                iterator = iterator + 1
                bestFileHKL = os.path.join(self.getWorkingDirectory(),
                                           "bestfile" + str(iterator) + ".hkl")
                self.listFileBestHKL.append(bestFileHKL)
                EDUtilsFile.writeFile(bestFileHKL, bestFileContentHKL.value)

        elif self.dataInput.xdsCorrectLp is not None:
            self.strPathToCorrectLp = os.path.join(self.getWorkingDirectory(),
                                                   "CORRECT.LP")
            shutil.copyFile(self.dataInput.xdsCorrectLp.path.value,
                            self.strPathToCorrectLp)

            self.strPathToBkgpixCbf = os.path.join(self.getWorkingDirectory(),
                                                   "BKGPIX.cbf")
            shutil.copyFile(self.dataInput.xdsBkgpixCbf.path.value,
                            self.strPathToBkgpixCbf)

            self.strListFileXdsAsciiHkl = ""
            index = 1
            for xdsAsciiHkl in self.dataInput.xdsAsciiHkl:
                strPathToXdsAsciiHkl = os.path.join(
                    self.getWorkingDirectory(),
                    "XDS_ASCII_{0}.HKL".format(index))
                shutil.copyFile(xdsAsciiHkl.path.value, strPathToXdsAsciiHkl)
                self.strListFileXdsAsciiHkl += " " + strPathToXdsAsciiHkl
                index += 1

        if self.dataInput.complexity is not None:
            self.strComplexity = self.dataInput.complexity.value

        self.initializeCommands()
Example #52
0
 def testGenerateSPDCommand(self):
     edPluginSPD = self.createPlugin()
     strXMLInput = EDUtilsFile.readFileAndParseVariables(
         self.strReferenceInputFileName, EDUtilsPath.getDictOfPaths())
     xsDataInputSPDCake = XSDataInputSPDCake.parseString(strXMLInput)
     edPluginSPD.setDataInput(xsDataInputSPDCake)
     edPluginSPD.configure()
     edPluginSPD.getInputParameter()
     #edPluginSPD.preProcess()
     edPluginSPD.generateSPDCommand()
     EDVerbose.screen("SPD configuration:\n%s" % edPluginSPD.getSPDConfig())
     if EDVerbose.isVerboseDebug():
         expected = """off_1=0 off_2=0 verbose=2 src_ext=.edf cor_ext=.cor wvl=1.000000e-10 cen_1=1.050000e+03 cen_2=1.000000e+03 dis=1.000000e-01 pix_1=4.722440e-05 pix_2=4.683150e-05 do_distortion=0 do_dark=0"""
         #"do_distortion=2 off_1=0 off_2=0  verbose=2 src_ext=.edf cor_ext=.cor wvl=1.000000e-10 cen_1=1.050000e+03 cen_2=1.000000e+03 dis=1.000000e-01 pix_1=4.722440e-05 pix_2=4.683150e-05 do_dark=0"
     else:
         expected = """off_1=0 off_2=0 verbose=0 src_ext=.edf cor_ext=.cor wvl=1.000000e-10 cen_1=1.050000e+03 cen_2=1.000000e+03 dis=1.000000e-01 pix_1=4.722440e-05 pix_2=4.683150e-05 do_distortion=0 do_dark=0"""
         #do_distortion=2 off_1=0 off_2=0  verbose=0 src_ext=.edf cor_ext=.cor wvl=1.000000e-10 cen_1=1.050000e+03 cen_2=1.000000e+03 dis=1.000000e-01 pix_1=4.722440e-05 pix_2=4.683150e-05 do_dark=0"
     EDAssert.equal(edPluginSPD.getSPDConfig(), expected)
    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")
Example #54
0
 def doSuccessIntegration(self, _edPlugin=None):
     self.DEBUG("EDPluginControlGridScreeningv1_0.doSuccessIntegration")
     self.retrieveSuccessMessages(_edPlugin, "EDPluginControlGridScreeningv1_0.doSuccessIntegration")
     self.addStatusMessage("Integration successful.")
     self.xsDataIntegrationOutput = self.edPluginControlIntegration.getDataOutput()
     # Integration short summary
     if self.edPluginControlIntegration.hasDataOutput("integrationShortSummary"):
         self.strCharacterisationShortSummary += self.edPluginControlIntegration.getDataOutput("integrationShortSummary")[0].getValue()
     # self.DEBUG( self.xsDataExperimentCharacterisation.marshal() )
     if self.bDoOnlyIntegrationWithXMLOutput:
         # Run mtz2various
         xsDataInputMtz2Various = XSDataInputMtz2Various()
         xsDataInputMtz2Various.setMtzfile(self.edPluginControlIntegration.getDataOutput().getIntegrationSubWedgeResult()[0].getGeneratedMTZFile())
         xsDataInputMtz2Various.addLabin(XSDataString("I=I"))
         xsDataInputMtz2Various.addLabin(XSDataString("SIGI=SIGI"))
         xsDataInputMtz2Various.setOutput(XSDataString("USER '(3I4,2F10.1)'"))
         self.edPluginExecMtz2Various.setDataInput(xsDataInputMtz2Various)
         self.edPluginExecMtz2Various.executeSynchronous()
         strHklFilePath = self.edPluginExecMtz2Various.getDataOutput().getHklfile().getPath().getValue()
         strIntegration = EDUtilsFile.readFile(strHklFilePath)
         # Output the result in XML format
         self.xsDataGridScreeningResultIntegration = XSDataGridScreeningResultIntegration()
         self.xsDataGridScreeningResultIntegration.setFileName(os.path.basename(self.strImageFile))
         self.xsDataGridScreeningResultIntegration.setFileDirectory(os.path.dirname(self.strImageFile))
         self.xsDataGridScreeningResultIntegration.setIntegratedData(strIntegration)
     else:
         # We continue with the strategy calculation
         xsDataInputStrategy = XSDataInputStrategy()
         xsDataSolutionSelected = self.xsDataIndexingResult.getSelectedSolution()
         xsDataInputStrategy.setCrystalRefined(xsDataSolutionSelected.getCrystal())
         xsDataInputStrategy.setSample(self.xsDataCollection.getSample())
         xsDataIntegrationSubWedgeResultList = self.xsDataIntegrationOutput.getIntegrationSubWedgeResult()
         xsDataInputStrategy.setBestFileContentDat(xsDataIntegrationSubWedgeResultList[0].getBestfileDat())
         xsDataInputStrategy.setBestFileContentPar(xsDataIntegrationSubWedgeResultList[0].getBestfilePar())
         xsDataInputStrategy.setExperimentalCondition(xsDataIntegrationSubWedgeResultList[0].getExperimentalConditionRefined())
         xsDataInputStrategy.setDataCollection(self.xsDataCollection)
         for xsDataIntegrationSubWedgeResult in xsDataIntegrationSubWedgeResultList:
             xsDataInputStrategy.addBestFileContentHKL(xsDataIntegrationSubWedgeResult.getBestfileHKL())
         xsDataInputStrategy.setDiffractionPlan(self.xsDataDiffractionPlan)
         self.edPluginControlStrategy.connectSUCCESS(self.doSuccessStrategy)
         self.edPluginControlStrategy.connectFAILURE(self.doFailureStrategy)
         self.edPluginControlStrategy.setDataInput(xsDataInputStrategy)
         self.executePluginSynchronous(self.edPluginControlStrategy)
Example #55
0
 def parseParameterFiles(self, _strPath):
     """
     parses Configuration file
     """
     self.DEBUG("EDPluginControlID11v1_0.parseParameterFiles")
     self.__dictID11 = {}
     dictSub = {
         "${TEST_DATA_IMAGES_HOME}": EDUtilsTest.getTestsDataImagesHome()
     }
     for linefile in EDUtilsFile.readFileAndParseVariables(
             _strPath, dictSub).split("\n"):
         strLineData = linefile.strip()
         #discard comment lines
         if not strLineData.startswith('#'):
             #  discard end line carriage return
             splited = strLineData.split("=", 1)
             if len(splited) == 2:
                 self.__dictID11[splited[0].strip()] = splited[1].strip()
     return self.__dictID11
Example #56
0
    def parseGnomOutputFile(self):
        logFile = EDUtilsFile.readFile(
            os.path.join(self.getWorkingDirectory(), "gnom.out"))
        logLines = logFile.splitlines()

        xsRadiusOfGyration = self.parseRadiusOfGyration(logLines[-1])
        #xsRadiusOfCrossSection = parseCrossSection(logFile)
        for idx, line in enumerate(logLines):
            if (line.find("Total  estimate") != -1):
                xsFitQuality = self.parseFitQuality(line)
            if (line.find("I REG") != -1):
                idx_start = idx + 2
            if (line.find("Distance distribution") != -1):
                idx_stop = idx - 1
            if (line.find("P(R)") != -1):
                idx_pr_start = idx + 2
            if (line.find("Reciprocal space:") != -1):
                idx_pr_stop = idx - 1

        xsScatteringFitQ = []
        xsScatteringFitValues = []
        self.parseScatteringFitData(idx_start, idx_stop, logLines,
                                    xsScatteringFitQ, xsScatteringFitValues)

        xsDistributionR = []
        xsDistributionPr = []
        xsDistributionErr = []
        self.parseDistributionData(idx_pr_start, idx_pr_stop, logLines, \
                                   xsDistributionR, xsDistributionPr, xsDistributionErr)

        xsDataResult = XSDataResultGnom()
        xsDataResult.setFitQuality(xsFitQuality)
        xsDataResult.setRadiusOfGyration(xsRadiusOfGyration)
        #xsDataResult.setRadiusOfCrossSection(xsRadiusOfCrossSection)
        xsDataResult.setScatteringFitQ(xsScatteringFitQ)
        xsDataResult.setScatteringFitValues(xsScatteringFitValues)

        xsDataResult.setDistributionR(xsDistributionR)
        xsDataResult.setDistributionPr(xsDistributionPr)
        xsDataResult.setDistributionErr(xsDistributionErr)

        return xsDataResult
 def parseOutput(self, _strFileName):
     """
     This method parses the output of background3D
     """
     xsDataResultBackground3D = XSDataResultBackground3D()
     strOutput = EDUtilsFile.readFile(_strFileName)
     # Skip the four first lines
     listOutput = strOutput.split("\n")[4:]
     for strLine in listOutput:
         xsDataImageBackground3D = XSDataImageBackground3D()
         # Remove empty strings ""
         listLine = list(filter(None, strLine.split(" ")))
         if listLine != []:
             xsDataImageBackground3D.number = XSDataInteger(listLine[0])
             if listLine[1].startswith("-"):
                 xsDataImageBackground3D.b_coef = self.parseDouble(
                     listLine[4])
                 xsDataImageBackground3D.b_cryst = self.parseDouble(
                     listLine[5])
                 xsDataImageBackground3D.estimate = self.parseDouble(
                     listLine[6])
             else:
                 xsDataImageBackground3D.scale = self.parseDouble(
                     listLine[1])
                 xsDataImageBackground3D.bfactor = self.parseDouble(
                     listLine[2])
                 xsDataImageBackground3D.resolution = self.parseDouble(
                     listLine[3])
                 xsDataImageBackground3D.correlation = self.parseDouble(
                     listLine[4])
                 xsDataImageBackground3D.rfactor = self.parseDouble(
                     listLine[5])
                 xsDataImageBackground3D.b_coef = self.parseDouble(
                     listLine[6])
                 xsDataImageBackground3D.b_cryst = self.parseDouble(
                     listLine[7])
                 xsDataImageBackground3D.estimate = self.parseDouble(
                     listLine[8])
             xsDataResultBackground3D.addImageBackground(
                 xsDataImageBackground3D)
     return xsDataResultBackground3D
Example #58
0
    def determineImageType(self, _strImagePath):
        """
        This method determines the type of an image, i.e. ADSC, MAR CCD etc.
        """
        strImageType = None
        bUnknownImageType = False
        self.DEBUG("EDPluginControlReadImageHeaderv10.determineImageType")
        # First look at the image extension, then try to distinguish between MARCCD and ADSC based on header information
        strImageSuffix = EDUtilsFile.getFileExtension(_strImagePath)
        if strImageSuffix in self.dictSuffixToImageType.keys():
            # find out image type depending on the content of the respective image header
            if self.isMarccdImageFormat(_strImagePath):
                strImageType = self.strMARCCD
            elif self.isAdscImageFormat(_strImagePath):
                strImageType = self.strADSC
            elif self.isPilatus2MImageFormat(_strImagePath):
                strImageType = self.strPilatus2M
            elif self.isPilatus6MImageFormat(_strImagePath):
                strImageType = self.strPilatus6M
            elif self.isEiger4MImageFormat(_strImagePath):
                strImageType = self.strEiger4M
            elif self.isEiger9MImageFormat(_strImagePath):
                strImageType = self.strEiger9M
            elif self.isEiger16MImageFormat(_strImagePath):
                strImageType = self.strEiger16M
            elif self.isEiger2_16MImageFormat(_strImagePath):
                strImageType = self.strEiger2_16M
            else:
                bUnknownImageType = True
        else:
            bUnknownImageType = True

        if bUnknownImageType:
            strErrorMessage = "EDPluginControlReadImageHeaderv10.determineImageType: Unknown image type for image %s " % _strImagePath
            self.error(strErrorMessage)
            self.addErrorMessage(strErrorMessage)
            self.setFailure()
        else:
            self.DEBUG("EDPluginControlReadImageHeaderv10.determineImageType: file: " + _strImagePath + \
                             ", type: " + strImageType)
        return strImageType
Example #59
0
    def testTableListItem(self):
        xsItem = None
        xsItem2 = None
        strDnaTablesXML = EDUtilsFile.readFile(self.__strFilePath)
        xsDataDnaTables = dna_tables.parseString(strDnaTablesXML)
        xsTable = EDUtilsTable.getTableFromTables(xsDataDnaTables, "input")
        xsLists = EDUtilsTable.getListsFromTable(xsTable, "select_task")
        for xsList in xsLists:
            xsItem = EDUtilsTable.getItemFromList(xsList, "task")
            xsItem2 = EDUtilsTable.getItemFromList(xsList, "tata")
        EDAssert.equal("optimize", xsItem.getValueOf_())

        EDAssert.equal(None, xsItem2)

        xsLists = EDUtilsTable.getListsFromTable(xsTable, "select_tata")
        EDAssert.equal([], xsLists)

        xsTable = EDUtilsTable.getTableFromTables(xsDataDnaTables, "toto")
        EDAssert.equal(None, xsTable)

        EDVerbose.DEBUG("Test done...")
    def parseOutput(self, _strFileName):
        """
        This method parses the output of dozor
        """
        xsDataResultDozor = XSDataResultDozor()
        strOutput = EDUtilsFile.readFile(_strFileName)
        # Skip the four first lines
        self.DEBUG('***** Dozor raw output ***** ')
        self.DEBUG(strOutput)
        listOutput = strOutput.split("\n")[14:]
        for strLine in listOutput:
            xsDataImageDozor = XSDataImageDozor()
            # Remove "|" 
            listLine = shlex.split(strLine.replace("|", " "))
            #print listLine
            if listLine != [] and not listLine[0].startswith("-"):
                xsDataImageDozor.number = XSDataInteger(listLine[0])
                # Fix for xaloc-ALBA
                #if listLine[5].startswith("-") or len(listLine) < 11:
                if len(listLine) < 11:
                    xsDataImageDozor.spots_num_of = XSDataInteger(listLine[1])
                    xsDataImageDozor.spots_int_aver = self.parseDouble(listLine[2])
                    try:
                        xsDataImageDozor.spots_resolution = self.parseDouble(listLine[3])
                    except IndexError as e:
                        xsDataImageDozor.spots_resolution = XSDataDouble(0.0)
                    xsDataImageDozor.score = XSDataDouble(0.0) #self.parseDouble(listLine[4])
                else:
                    xsDataImageDozor.spots_num_of = XSDataInteger(listLine[1])
                    xsDataImageDozor.spots_int_aver = self.parseDouble(listLine[2])
                    xsDataImageDozor.spots_resolution = self.parseDouble(listLine[3])
                    xsDataImageDozor.powder_wilson_scale = self.parseDouble(listLine[4])
                    xsDataImageDozor.powder_wilson_bfactor = self.parseDouble(listLine[5])
                    xsDataImageDozor.powder_wilson_resolution = self.parseDouble(listLine[6])
                    xsDataImageDozor.powder_wilson_correlation = self.parseDouble(listLine[7])
                    xsDataImageDozor.powder_wilson_rfactor = self.parseDouble(listLine[8])
                    xsDataImageDozor.score = self.parseDouble(listLine[9])
#                print xsDataImageDozor.marshal()
                xsDataResultDozor.addImageDozor(xsDataImageDozor)
        return xsDataResultDozor