Exemple #1
0
  def run_validation(self) :
    rsc = rscc_utils.get_rscc_diff(
      pdb_file=self.pdb_file,
      reflection_file=self.hklmtz_file,
      high_resolution=self.high_resolution)

    # self.mdb_residues have MDBRes.get_residue_key() keys and values are lists
    # of MDBAtom[s].
    self.mdb_residues = {}
    atomd = None
    broadcastdetail = True
    for i, result_ in enumerate(rsc) :
      resd = {'pdb_id'     : self.pdb_code,
              'model_id'   : None, 
              'chain_id'   : result_.chain_id,
              'icode'      : result_.ins_code,
              'resseq'     : result_.res_num,
              'altloc'     : result_.alt_loc,
              'resname'    : result_.res_name}
      if 'residue' in dir(result_) :
        if broadcastdetail :
          utils.broadcast('detail : residue')
          broadcastdetail = False
        detail = 'residue'
      elif 'atom' in dir(result_) :
        if broadcastdetail :
          utils.broadcast('detail : atom')
          broadcastdetail = False
        detail = 'atom'
        # map_value_1 = Fc
        # map_value_2 = 2mFo-DFc
        # map_value_3 = mFo-DFc
        atomd = {'name':result_.atom.name,
                 'adp':result_.atom.b,
                 'xyz':result_.atom.xyz,
                 'rscc':result_.cc,
                 'twoFo_DFc_value':result_.map_value_2,
                 'Fo_DFc_value':result_.map_value_3,
                 'occ':result_.atom.occ}
      else :
        raise RuntimeError("Could not resolve detail")
      MDBRes = mdb_utils.MDBResidue(**resd)
      reskey = MDBRes.get_residue_key()
      if reskey not in self.mdb_residues.keys() :
        #self.mdb_residues[reskey] = MDBRes
        self.mdb_residues[reskey] = []
      if detail == 'atom' :
        #self.mdb_residues[reskey].deposit_atom(mdb_utils.MDBAtom(**atomd))
        self.mdb_residues[reskey].append(atomd)
Exemple #2
0
def get_rscc_diff(pdb_file,reflection_file,high_resolution,log=None) :
  if not log : log = sys.stderr
  print >> log, '*' * 20 + '  rscc  ' + '*' * 20
  print >> log, 'pdb file : %s' % pdb_file
  print >> log, 'hkl mtz : %s' % reflection_file
  print >> log, 'high_resolution : %.2f' % high_resolution
  pdb_in = any_file(pdb_file)
  hierarchy = pdb_in.file_object.hierarchy
  inputs = mmtbx.utils.process_command_line_args([pdb_file,reflection_file])

  # try to get data labels
  data_labels = get_data_labels(reflection_file)
  parameters = mmtbx.utils.data_and_flags_master_params().extract()
  parameters.force_anomalous_flag_to_be_equal_to = False
  if data_labels : parameters.labels = [data_labels]
  if high_resolution : parameters.high_resolution = high_resolution
  data_and_flags = mmtbx.utils.determine_data_and_flags(
    reflection_file_server = inputs.get_reflection_file_server(),
    keep_going             = True, # don't stop if free flags are not present
    parameters             = parameters,
    log                    = StringIO())
  f_obs = data_and_flags.f_obs
  r_free_flags = data_and_flags.f_obs.array(
        data = flex.bool(data_and_flags.f_obs.size(), False))
  pdb_lines = excise_unk_get_lines(inputs.pdb_file_names[0])
  xrs = iotbx.pdb.input(
    lines = pdb_lines).xray_structure_simple()
    #file_name=inputs.pdb_file_names[0]).xray_structure_simple()
  fmodel = mmtbx.utils.fmodel_simple(
    f_obs=f_obs,
    r_free_flags=r_free_flags,
    scattering_table="n_gaussian",
    xray_structures=[xrs],
    bulk_solvent_correction=True,
    skip_twin_detection=True)

  e_map_obj = fmodel.electron_density_map()
  coeffs_1 = e_map_obj.map_coefficients(
    map_type     = 'Fc',
    fill_missing = False,
    isotropize   = False)
  coeffs_2 = e_map_obj.map_coefficients(
    map_type     = '2mFo-DFc',
    fill_missing = True,
    isotropize   = True)
  coeffs_3 = e_map_obj.map_coefficients(
    map_type     = 'mFo-DFc',
    fill_missing = False,
    isotropize   = True)
  # compute maps
  fft_map_1 = coeffs_1.fft_map(resolution_factor = 1./4)
  fft_map_1.apply_sigma_scaling()
  map_1 = fft_map_1.real_map_unpadded()
  fft_map_2 = miller.fft_map(
    crystal_gridding     = fft_map_1,
    fourier_coefficients = coeffs_2)
  fft_map_2.apply_sigma_scaling()
  map_2 = fft_map_2.real_map_unpadded()
  fft_map_3 = miller.fft_map(
    crystal_gridding     = fft_map_1,
    fourier_coefficients = coeffs_3)
  fft_map_3.apply_sigma_scaling()
  map_3 = fft_map_3.real_map_unpadded()
  # compute cc
  utils.broadcast(m="Map correlation and map values", log=log)
  overall_cc = flex.linear_correlation(x = map_1.as_1d(),
    y = map_2.as_1d()).coefficient()
  print >> log, "  Overall map cc(%s,%s): %6.4f"%('Fc','2mFo-DFc',overall_cc)

  detail='atom'
  atom_radius = set_radius(d_min=fmodel.f_obs().d_min())
  print >> sys.stderr, 'radius : %.3f' % atom_radius
  results = compute(
    pdb_hierarchy        = hierarchy,
    unit_cell            = fmodel.xray_structure.unit_cell(),
    map_1                = map_1,
    map_2                = map_2,
    map_3                = map_3,
    detail               = detail,
    atom_radius          = atom_radius)
  return results