def mosflm_mtz_to_list(mtz): '''Run pointless to convert mtz to list of h k l ... and give the unit cell, then convert this to a list as necessary before returning.''' hklout = tempfile.mktemp('.hkl', '', os.environ['CCP4_SCR']) p = Pointless() p.set_hklin(mtz) cell = p.sum_mtz(hklout) hkl = pointless_summedlist_to_list(hklout, cell) os.remove(hklout) return hkl
def find_blank(hklin): # first dump to temp. file hklout = tempfile.mktemp('.hkl', '', os.environ['CCP4_SCR']) p = Pointless() p.set_hklin(hklin) cell = p.sum_mtz(hklout) if not os.path.isfile(hklout): Debug.write('Pointless failed:') Debug.write(''.join(p.get_all_output())) raise RuntimeError('Pointless failed: %s does not exist' %hklout) isig = { } for record in open(hklout, 'r'): lst = record.split() if not lst: continue batch = int(lst[3]) i, sig = float(lst[4]), float(lst[5]) if not sig: continue if not batch in isig: isig[batch] = [] isig[batch].append(i / sig) # look at the mean and sd blank = [] good = [] for batch in sorted(isig): m, s = meansd(isig[batch]) if m < 1: blank.append(batch) else: good.append(batch) # finally delete temp file os.remove(hklout) return blank, good
def mosflm_mtz_to_list(mtz): """Run pointless to convert mtz to list of h k l ... and give the unit cell, then convert this to a list as necessary before returning.""" try: with tempfile.NamedTemporaryFile(suffix=".hkl", dir=os.environ["CCP4_SCR"], delete=False) as fh: hklout = fh.name p = Pointless() p.set_hklin(mtz) cell = p.sum_mtz(hklout) hkl = pointless_summedlist_to_list(hklout, cell) finally: os.remove(hklout) return hkl
def find_blank(hklin): try: # first dump to temp. file with tempfile.NamedTemporaryFile(suffix=".hkl", dir=os.environ["CCP4_SCR"], delete=False) as fh: hklout = fh.name p = Pointless() p.set_hklin(hklin) _ = p.sum_mtz(hklout) if os.path.getsize(hklout) == 0: Debug.write("Pointless failed:") Debug.write("".join(p.get_all_output())) raise RuntimeError("Pointless failed: no output file written") isig = {} with open(hklout, "r") as fh: for record in fh: lst = record.split() if not lst: continue batch = int(lst[3]) i, sig = float(lst[4]), float(lst[5]) if not sig: continue if not batch in isig: isig[batch] = [] isig[batch].append(i / sig) finally: os.remove(hklout) # look at the mean and sd blank = [] good = [] for batch in sorted(isig): m, s = meansd(isig[batch]) if m < 1: blank.append(batch) else: good.append(batch) return blank, good
def _decide_space_group_pointless(self): logger.debug('Deciding space group with pointless') symmetry = Pointless() auto_logfiler(symmetry) self._sorted_mtz = '%i_sorted.mtz' % symmetry.get_xpid() self._experiments_filename = '%i_experiments_reindexed.json' % symmetry.get_xpid( ) self._reflections_filename = '%i_reflections_reindexed.pickle' % symmetry.get_xpid( ) symmetry.set_hklin(self._integrated_combined_mtz) symmetry.set_hklout(self._sorted_mtz) symmetry.set_allow_out_of_sequence_files(allow=True) symmetry.decide_pointgroup() space_group = sgtbx.space_group_info( symbol=str(symmetry.get_pointgroup())).group() cb_op = sgtbx.change_of_basis_op(symmetry.get_reindex_operator()) # reindex to correct bravais setting self._data_manager.reindex(cb_op=cb_op, space_group=space_group) self._data_manager.export_experiments(self._experiments_filename) self._data_manager.export_reflections(self._reflections_filename) logger.info('Space group determined by pointless: %s' % space_group.info()) return space_group, cb_op