Beispiel #1
0
    def write_map_file(self):
        # output MTZ file with map coefficients
        class map_coeffs_mtz_label_manager:
            def __init__(self, amplitudes, phases):
                self._amplitudes = amplitudes
                self._phases = phases

            def amplitudes(self):
                return self._amplitudes

            def phases(self, root_label, anomalous_sign=None):
                assert anomalous_sign is None or not anomalous_sign
                return self._phases

        mtz_history_buffer = flex.std_string()
        lbl_mgr = map_coeffs_mtz_label_manager(amplitudes="FoFo",
                                               phases="PHFc")
        mtz_dataset = self.map_coeff.as_mtz_dataset(
            column_root_label=lbl_mgr.amplitudes(), label_decorator=lbl_mgr)
        mtz_history_buffer.append("> column label %s = phenix %s" %
                                  (lbl_mgr.amplitudes(), "FoFoPHFc"))
        if self.output_file is not None:
            file_name = self.output_file
        else:
            file_name = "FoFoPHFc.mtz"
        mtz_history_buffer.append("file name %s" % file_name)
        mtz_object = mtz_dataset.mtz_object()
        mtz_object.add_history(mtz_history_buffer)
        mtz_object.write(file_name=file_name)
        self.file_names = [file_name]
        if (self.peak_search):
            from mmtbx.command_line import find_peaks_holes
            from mmtbx import find_peaks
            peak_search_log = self.log
            if (self.silent): peak_search_log = null_out()
            fmodel = self.fmodel
            peaks = find_peaks.manager(fmodel=fmodel,
                                       map_type=None,
                                       map_coeffs=self.map_coeff,
                                       map_cutoff=self.map_cutoff,
                                       params=self.peak_search_params,
                                       log=peak_search_log).peaks_mapped()
            peaks.sites = fmodel.xray_structure.unit_cell().orthogonalize(
                peaks.sites)
            holes = find_peaks.manager(fmodel=fmodel,
                                       map_type=None,
                                       map_coeffs=self.map_coeff,
                                       map_cutoff=-self.map_cutoff,
                                       params=self.peak_search_params,
                                       log=peak_search_log).peaks_mapped()
            holes.sites = fmodel.xray_structure.unit_cell().orthogonalize(
                holes.sites)
            result = find_peaks_holes.peaks_holes_container(
                peaks=peaks, holes=holes, map_cutoff=self.map_cutoff)
            pdb_out = os.path.splitext(file_name)[0] + "_peaks.pdb"
            result.save_pdb_file(file_name=pdb_out,
                                 include_anom=False,
                                 include_water=False,
                                 log=peak_search_log)
            self.file_names.append(pdb_out)
        return self.file_names
 def write_map_file (self) :
 # output MTZ file with map coefficients
   class map_coeffs_mtz_label_manager:
     def __init__(self, amplitudes, phases):
       self._amplitudes = amplitudes
       self._phases = phases
     def amplitudes(self):
       return self._amplitudes
     def phases(self, root_label, anomalous_sign=None):
       assert anomalous_sign is None or not anomalous_sign
       return self._phases
   mtz_history_buffer = flex.std_string()
   lbl_mgr = map_coeffs_mtz_label_manager(amplitudes = "FoFo", phases = "PHFc")
   mtz_dataset = self.map_coeff.as_mtz_dataset(
     column_root_label=lbl_mgr.amplitudes(),
     label_decorator=lbl_mgr)
   mtz_history_buffer.append("> column label %s = phenix %s" % (
       lbl_mgr.amplitudes(), "FoFoPHFc"))
   if self.output_file is not None :
     file_name = self.output_file
   else :
     file_name = "FoFoPHFc.mtz"
   mtz_history_buffer.append("file name %s"%file_name)
   mtz_object = mtz_dataset.mtz_object()
   mtz_object.add_history(mtz_history_buffer)
   mtz_object.write(file_name=file_name)
   self.file_names = [ file_name ]
   if (self.peak_search) :
     from mmtbx.command_line import find_peaks_holes
     from mmtbx import find_peaks
     peak_search_log = self.log
     if (self.silent) : peak_search_log = null_out()
     fmodel = self.fmodel
     peaks = find_peaks.manager(
       fmodel=fmodel,
       map_type=None,
       map_coeffs=self.map_coeff,
       map_cutoff=self.map_cutoff,
       params=self.peak_search_params,
       log=peak_search_log).peaks_mapped()
     peaks.sites = fmodel.xray_structure.unit_cell().orthogonalize(peaks.sites)
     holes = find_peaks.manager(
       fmodel=fmodel,
       map_type=None,
       map_coeffs=self.map_coeff,
       map_cutoff=-self.map_cutoff,
       params=self.peak_search_params,
       log=peak_search_log).peaks_mapped()
     holes.sites = fmodel.xray_structure.unit_cell().orthogonalize(holes.sites)
     result = find_peaks_holes.peaks_holes_container(
       peaks=peaks,
       holes=holes,
       map_cutoff=self.map_cutoff)
     pdb_out = os.path.splitext(file_name)[0] + "_peaks.pdb"
     result.save_pdb_file(
       file_name=pdb_out,
       include_anom=False,
       include_water=False,
       log=peak_search_log)
     self.file_names.append(pdb_out)
   return self.file_names