示例#1
0
 def __init__(self,pdb_file,hklmtz_file,
              detail,high_resolution=None,mdb_document=None,pdb_code=None,
              do_flips=False) :
   assert detail in ['file','residue'],detail
   assert type(do_flips) == bool
   self.pdb_file = pdb_file
   self.hklmtz_file = hklmtz_file
   self.detail = detail
   self.pdb_code = pdb_code
   self.high_resolution = high_resolution
   self.do_flips = do_flips
   if not pdb_code : self.pdb_code = 'N/A'
   pdb_in = file_reader.any_file(pdb_file)
   self.hierarchy = pdb_in.file_object.hierarchy
   args = [self.pdb_file]
   if self.hklmtz_file : args.append(self.hklmtz_file)
   self.cmdline = load_model_and_data(
     args=args,
     master_phil=generate_master_phil_with_inputs(""),
     require_data=False,
     create_fmodel=True,
     process_pdb_file=True,
     prefer_anomalous=True)
   # keys are res ids and values are MDBResidue objects.
   if self.detail == 'residue' :
     self.initiate_residues()
   self.set_mdb_document(mdb_document)
示例#2
0
def _main(args, out=sys.stdout):
    """
  Main entry point to this script.

  Parameters
  ----------
  args : list of str
      List of arguments, should not include the first argument with the
      executable name.
  out : file, optional
  """
    usage_string = """\
phenix.python -m mmtbx.ions.svm.dump_sites model.pdb data.mtz [options ...]

Utility to dump information about the properties of water and ion sites in a
model. This properties include local environment, electron density maps, and
atomic properties.
"""
    cmdline = load_model_and_data(
        args=args,
        master_phil=master_phil(),
        out=out,
        process_pdb_file=True,
        create_fmodel=True,
        prefer_anomalous=True,
        set_wavelength_from_model_header=True,
        set_inelastic_form_factors="sasaki",
        usage_string=usage_string,
    )

    params = cmdline.params
    params.use_svm = True

    make_header("Inspecting sites", out=out)

    manager = ions.identify.create_manager(
        pdb_hierarchy=cmdline.pdb_hierarchy,
        fmodel=cmdline.fmodel,
        geometry_restraints_manager=cmdline.geometry,
        wavelength=params.input.wavelength,
        params=params,
        verbose=params.debug,
        nproc=params.nproc,
        log=out,
    )

    manager.show_current_scattering_statistics(out=out)

    sites = dump_sites(manager)

    out_name = os.path.splitext(
        params.input.pdb.file_name[0])[0] + "_sites.pkl"
    print("Dumping to", out_name, file=out)
    easy_pickle.dump(out_name, sites)
示例#3
0
def _main(args, out=sys.stdout):
  """
  Main entry point to this script.

  Parameters
  ----------
  args : list of str
      List of arguments, should not include the first argument with the
      executable name.
  out : file, optional
  """
  usage_string = """\
phenix.python -m mmtbx.ions.svm.dump_sites model.pdb data.mtz [options ...]

Utility to dump information about the properties of water and ion sites in a
model. This properties include local environment, electron density maps, and
atomic properties.
"""
  cmdline = load_model_and_data(
    args=args,
    master_phil=master_phil(),
    out=out,
    process_pdb_file=True,
    create_fmodel=True,
    prefer_anomalous=True,
    set_wavelength_from_model_header=True,
    set_inelastic_form_factors="sasaki",
    usage_string=usage_string,
    )

  params = cmdline.params
  params.use_svm = True

  make_header("Inspecting sites", out=out)

  manager = ions.identify.create_manager(
    pdb_hierarchy=cmdline.pdb_hierarchy,
    fmodel=cmdline.fmodel,
    geometry_restraints_manager=cmdline.geometry,
    wavelength=params.input.wavelength,
    params=params,
    verbose=params.debug,
    nproc=params.nproc,
    log=out,
    )

  manager.show_current_scattering_statistics(out=out)

  sites = dump_sites(manager)

  out_name = os.path.splitext(params.input.pdb.file_name[0])[0] + "_sites.pkl"
  print >> out, "Dumping to", out_name
  easy_pickle.dump(out_name, sites)
示例#4
0
def run (args, out=None) :
  if (out is None) : out = sys.stdout
  usage_string = """\
mmtbx.prune_model model.pdb data.mtz [options...]

Filters protein residues based on CC to 2mFo-DFc map and absolute
(sigma-scaled) values in 2mFo-DFc and mFo-DFc maps.  For fast automatic
correction of MR solutions after initial refinement (ideally with rotamer
correction) to remove spurious loops and sidechains.
"""
  from mmtbx.command_line import load_model_and_data
  cmdline = load_model_and_data(
    args=args,
    master_phil=get_master_phil(),
    out=out,
    process_pdb_file=False,
    create_fmodel=True)
  params = cmdline.params
  fmodel = cmdline.fmodel
  if (params.output.file_name is None) :
    base_name = os.path.basename(params.input.pdb.file_name[0])
    params.output.file_name = os.path.splitext(base_name)[0] + "_pruned.pdb"
  log_file = os.path.splitext(os.path.basename(params.output.file_name))[0] + \
    ".log"
  log = open(log_file, "w")
  out2 = multi_out()
  out2.register("out", out)
  out2.register("log", log)
  map_helper = fmodel.electron_density_map()
  f_map_coeffs = map_helper.map_coefficients(map_type="2mFo-DFc")
  diff_map_coeffs = map_helper.map_coefficients(map_type="mFo-DFc")
  model_map_coeffs = map_helper.map_coefficients(map_type="Fc")
  result = prune_model(
    f_map_coeffs=f_map_coeffs,
    diff_map_coeffs=diff_map_coeffs,
    model_map_coeffs=model_map_coeffs,
    pdb_hierarchy=cmdline.pdb_hierarchy,
    params=params.prune).process_residues(out=out2)
  f = open(params.output.file_name, "w")
  f.write("REMARK edited by mmtbx.prune_model\n")
  f.write(cmdline.pdb_hierarchy.as_pdb_string(
    crystal_symmetry=fmodel.xray_structure))
  f.close()
  log.close()
  print >> out, "Wrote %s" % params.output.file_name
  return params.output.file_name
示例#5
0
def run(args, out=None):
    if (out is None): out = sys.stdout
    usage_string = """\
mmtbx.prune_model model.pdb data.mtz [options...]

Filters protein residues based on CC to 2mFo-DFc map and absolute
(sigma-scaled) values in 2mFo-DFc and mFo-DFc maps.  For fast automatic
correction of MR solutions after initial refinement (ideally with rotamer
correction) to remove spurious loops and sidechains.
"""
    from mmtbx.command_line import load_model_and_data
    cmdline = load_model_and_data(args=args,
                                  master_phil=get_master_phil(),
                                  out=out,
                                  process_pdb_file=False,
                                  create_fmodel=True)
    params = cmdline.params
    fmodel = cmdline.fmodel
    if (params.output.file_name is None):
        base_name = os.path.basename(params.input.pdb.file_name[0])
        params.output.file_name = os.path.splitext(
            base_name)[0] + "_pruned.pdb"
    log_file = os.path.splitext(os.path.basename(params.output.file_name))[0] + \
      ".log"
    log = open(log_file, "w")
    out2 = multi_out()
    out2.register("out", out)
    out2.register("log", log)
    map_helper = fmodel.electron_density_map()
    f_map_coeffs = map_helper.map_coefficients(map_type="2mFo-DFc")
    diff_map_coeffs = map_helper.map_coefficients(map_type="mFo-DFc")
    model_map_coeffs = map_helper.map_coefficients(map_type="Fc")
    result = prune_model(f_map_coeffs=f_map_coeffs,
                         diff_map_coeffs=diff_map_coeffs,
                         model_map_coeffs=model_map_coeffs,
                         pdb_hierarchy=cmdline.pdb_hierarchy,
                         params=params.prune).process_residues(out=out2)
    f = open(params.output.file_name, "w")
    f.write("REMARK edited by mmtbx.prune_model\n")
    f.write(
        cmdline.pdb_hierarchy.as_pdb_string(
            crystal_symmetry=fmodel.xray_structure))
    f.close()
    log.close()
    print >> out, "Wrote %s" % params.output.file_name
    return params.output.file_name
def run (args, out=sys.stdout) :
  from mmtbx.command_line import load_model_and_data
  import mmtbx.ncs.ligands
  cmdline = load_model_and_data(
    args=args,
    master_phil=master_phil_str % mmtbx.ncs.ligands.ncs_ligand_phil,
    out=out,
    process_pdb_file=True,
    generate_input_phil=True,
    usage_string="""\
mmtbx.apply_ncs_to_ligand model.pdb data.mtz ligand_code=LIG ...

Given a multi-chain PDB file and a ligand residue name, find copies of the
ligand in the input file, identify NCS operators relating macromolecule chains,
and search for additional ligand sites by applying these operators.  Used to
complete ligand placement in cases where LigandFit (etc.) is only partially
successful.
""")
  pdb_hierarchy = cmdline.pdb_hierarchy
  fmodel = cmdline.fmodel
  params = cmdline.params
  if (params.output_file is None) :
    params.output_file = "ncs_ligands.pdb"
  if (params.output_map is None) :
    params.output_map = "ncs_ligands.mtz"
  make_header("Finding ligands by NCS operators", out=out)
  result = mmtbx.ncs.ligands.apply_ligand_ncs(
    pdb_hierarchy=pdb_hierarchy,
    fmodel=fmodel,
    params=params,
    ligand_code=params.ligand_code,
    atom_selection=None,
    add_new_ligands_to_pdb=params.add_to_model,
    log=out)
  result.write_pdb(params.output_file)
  result.write_maps(params.output_map)
  return result
def run (args, out=sys.stdout) :
  usage_string = """\
mmtbx.show_suspicious_residues [model] [data] [options...]

Flag bad residues based on fit to electron density.  By default, only HETATM
records will be inspected.
"""
  from mmtbx import real_space_correlation
  from mmtbx.command_line import load_model_and_data
  cmdline = load_model_and_data(
    args=args,
    master_phil=master_phil(),
    out=out,
    process_pdb_file=False,
    usage_string=usage_string)
  params = cmdline.params
  ignore_list = []
  if (params.skip_xtal_solution_mols) :
    ignore_list = common_xtal_mols
  outliers = real_space_correlation.find_suspicious_residues(
    fmodel=cmdline.fmodel,
    pdb_hierarchy=cmdline.pdb_hierarchy,
    hetatms_only=params.hetatms_only,
    skip_single_atoms=params.skip_single_atoms,
    skip_alt_confs=params.skip_alt_confs,
    ignore_resnames=ignore_list,
    min_acceptable_cc=params.min_acceptable_cc,
    min_acceptable_2fofc=params.min_acceptable_2fofc,
    max_frac_atoms_below_min=params.max_frac_atoms_below_min,
    log=out)
  map_file = None
  if ((params.write_maps == True) or
      ((len(outliers) > 0) and (params.write_maps in [Auto, True]))) :
    import mmtbx.maps.utils
    import iotbx.map_tools
    f_map, diff_map = mmtbx.maps.utils.get_maps_from_fmodel(cmdline.fmodel)
    anom_map = None
    if (cmdline.fmodel.f_obs().anomalous_flag()) :
      anom_map = mmtbx.maps.utils.get_anomalous_map(cmdline.fmodel)
    base_name = os.path.basename(
      os.path.splitext(params.input.xray_data.file_name)[0])
    map_file = base_name + "_maps.mtz"
    iotbx.map_tools.write_map_coeffs(
      fwt_coeffs=f_map,
      delfwt_coeffs=diff_map,
      file_name=map_file,
      anom_coeffs=anom_map)
    print "Wrote maps to %s" % map_file
  if (len(outliers) > 0) and (params.write_coot_script) :
    zoom_list_base = libtbx.env.find_in_repositories(
      relative_path="cctbx_project/cootbx/simple_zoom_list.py",
      test=os.path.isfile)
    script = open("coot_bad_residues.py", "w")
    script.write(open(zoom_list_base).read())
    script.write("\n")
    for file_name in params.input.pdb.file_name :
      script.write("""read_pdb("%s")\n""" % file_name)
    if (map_file is not None) :
      script.write("auto_read_make_and_draw_maps(\"%s\")\n" % map_file)
    script.write("""
draw_simple_zoom_list(
  title="Residues in suspicious density",
  items=%s)
""" % str(outliers))
    script.close()
    print "Coot script is coot_bad_residues.py"
def run(args, out=sys.stdout):
    usage_string = """\
mmtbx.show_suspicious_residues [model] [data] [options...]

Flag bad residues based on fit to electron density.  By default, only HETATM
records will be inspected.
"""
    from mmtbx import real_space_correlation
    from mmtbx.command_line import load_model_and_data
    cmdline = load_model_and_data(args=args,
                                  master_phil=master_phil(),
                                  out=out,
                                  process_pdb_file=False,
                                  usage_string=usage_string)
    params = cmdline.params
    ignore_list = []
    if (params.skip_xtal_solution_mols):
        ignore_list = common_xtal_mols
    outliers = real_space_correlation.find_suspicious_residues(
        fmodel=cmdline.fmodel,
        pdb_hierarchy=cmdline.pdb_hierarchy,
        hetatms_only=params.hetatms_only,
        skip_single_atoms=params.skip_single_atoms,
        skip_alt_confs=params.skip_alt_confs,
        ignore_resnames=ignore_list,
        min_acceptable_cc=params.min_acceptable_cc,
        min_acceptable_2fofc=params.min_acceptable_2fofc,
        max_frac_atoms_below_min=params.max_frac_atoms_below_min,
        log=out)
    map_file = None
    if ((params.write_maps == True)
            or ((len(outliers) > 0) and (params.write_maps in [Auto, True]))):
        import mmtbx.maps.utils
        import iotbx.map_tools
        f_map, diff_map = mmtbx.maps.utils.get_maps_from_fmodel(cmdline.fmodel)
        anom_map = None
        if (cmdline.fmodel.f_obs().anomalous_flag()):
            anom_map = mmtbx.maps.utils.get_anomalous_map(cmdline.fmodel)
        base_name = os.path.basename(
            os.path.splitext(params.input.xray_data.file_name)[0])
        map_file = base_name + "_maps.mtz"
        iotbx.map_tools.write_map_coeffs(fwt_coeffs=f_map,
                                         delfwt_coeffs=diff_map,
                                         file_name=map_file,
                                         anom_coeffs=anom_map)
        print "Wrote maps to %s" % map_file
    if (len(outliers) > 0) and (params.write_coot_script):
        zoom_list_base = libtbx.env.find_in_repositories(
            relative_path="cctbx_project/cootbx/simple_zoom_list.py",
            test=os.path.isfile)
        script = open("coot_bad_residues.py", "w")
        script.write(open(zoom_list_base).read())
        script.write("\n")
        for file_name in params.input.pdb.file_name:
            script.write("""read_pdb("%s")\n""" % file_name)
        if (map_file is not None):
            script.write("auto_read_make_and_draw_maps(\"%s\")\n" % map_file)
        script.write("""
draw_simple_zoom_list(
  title="Residues in suspicious density",
  items=%s)
""" % str(outliers))
        script.close()
        print "Coot script is coot_bad_residues.py"