def testExecute(self): """ """ self.run() plugin = self.getPlugin() output = plugin.dataOutput reference = XSDataXdsOutput.parseFile(self.getReferenceDataOutputFile()) EDAssert.strAlmostEqual(output.marshal(), reference.marshal(), "output looks good")
def process(self, _edObject = None): EDPlugin.process(self) output = XSDataXdsOutput() # get all the file's contents, find where the info is and then # use helper functions to retrieve stuff and put it in the # data model try: f = open(self.dataInput.correct_lp.path.value, 'r') lines = f.readlines() except IOError: EDVerbose.ERROR('Could not open the specified XDS output file for reading') self.setFailure() return # look for the "big piece of information" info_begin = None info_end = None for lineno, line in enumerate(lines): if info_begin is None: if line.find('REFINEMENT OF DIFFRACTION PARAMETERS USING ALL IMAGES') != -1: info_begin = lineno else: if line.find('MEAN INTENSITY AS FUNCTION OF SPINDLE POSITION WITHIN DATA IMAGE') != -1: info_end = lineno break if info_begin is None or info_end is None: EDVerbose.ERROR('could not find the refined parameters') self.setFailure() return _extract_infos(lines[info_begin:info_end], output) # second pass, look for the interesting table info_begin = None info_end = None started = False for line_no, line in enumerate(lines): if line.find('REFLECTIONS OF TYPE H,0,0 0,K,0 0,0,L OR EXPECTED TO BE ABSENT (*)') != -1: # the table will start shortly after started = True continue if started: # look if we are at the table yet if line.find('LIMIT OBSERVED UNIQUE POSSIBLE OF DATA observed expected') != -1: # there's an empty line after the header info_begin = line_no + 2 if info_begin is not None and line.find('total') != -1: # we're at the last table line info_end = line_no if info_begin is None or info_end is None: EDVerbose.ERROR('could not find the completeness table') self.setFailure() return _extract_completeness_entries(lines[info_begin:info_end+1], output) # now for the last bit: check if we were given a path to the # gxparm file and if it exists get the space group and unit # cell constants from it if self.dataInput.gxparm is not None: gxparm_path = self.dataInput.gxparm.path.value if os.path.exists(gxparm_path): with open(gxparm_path, 'r') as f: lines = f.readlines() for line in lines: # the one we want has 7 floats chunks = line.split() if len(chunks) == 7: output.sg_number = XSDataInteger(int(chunks[0])) output.unit_cell_constants = [XSDataFloat(float(x)) for x in chunks[1:]] input_file = self.dataInput.correct_lp.path.value output.xds_run_directory = XSDataString(os.path.dirname(input_file)) self.dataOutput = output
def process(self, _edObject=None): EDPlugin.process(self) output = XSDataXdsOutput() # get all the file's contents, find where the info is and then # use helper functions to retrieve stuff and put it in the # data model try: f = open(self.dataInput.correct_lp.path.value, 'r') lines = f.readlines() except IOError: EDVerbose.ERROR( 'Could not open the specified XDS output file for reading') self.setFailure() return # look for the "big piece of information" info_begin = None info_end = None for lineno, line in enumerate(lines): if info_begin is None: if line.find( 'REFINEMENT OF DIFFRACTION PARAMETERS USING ALL IMAGES' ) != -1: info_begin = lineno else: if line.find( 'MEAN INTENSITY AS FUNCTION OF SPINDLE POSITION WITHIN DATA IMAGE' ) != -1: info_end = lineno break if info_begin is None or info_end is None: EDVerbose.ERROR('could not find the refined parameters') self.setFailure() return _extract_infos(lines[info_begin:info_end], output) # second pass, look for the interesting table info_begin = None info_end = None started = False for line_no, line in enumerate(lines): if line.find( 'REFLECTIONS OF TYPE H,0,0 0,K,0 0,0,L OR EXPECTED TO BE ABSENT (*)' ) != -1: # the table will start shortly after started = True continue if started: # look if we are at the table yet if line.find( 'LIMIT OBSERVED UNIQUE POSSIBLE OF DATA observed expected' ) != -1: # there's an empty line after the header info_begin = line_no + 2 if info_begin is not None and line.find('total') != -1: # we're at the last table line info_end = line_no if info_begin is None or info_end is None: EDVerbose.ERROR('could not find the completeness table') self.setFailure() return _extract_completeness_entries(lines[info_begin:info_end + 1], output) # now for the last bit: check if we were given a path to the # gxparm file and if it exists get the space group and unit # cell constants from it if self.dataInput.gxparm is not None: gxparm_path = self.dataInput.gxparm.path.value if os.path.exists(gxparm_path): with open(gxparm_path, 'r') as f: lines = f.readlines() for line in lines: # the one we want has 7 floats chunks = line.split() if len(chunks) == 7: output.sg_number = XSDataInteger(int(chunks[0])) output.unit_cell_constants = [ XSDataFloat(float(x)) for x in chunks[1:] ] input_file = self.dataInput.correct_lp.path.value output.xds_run_directory = XSDataString(os.path.dirname(input_file)) self.dataOutput = output