コード例 #1
0
def exercise_3():
    pdb_raw = """\
ATOM      1  CA  GLY A   1      -0.227   9.888 -15.197  1.00 54.04           C
ATOM      2  CA  GLY A   2      -0.227   9.888 -15.197  1.00 54.04           C
ATOM      3  CA  GLY A   3      -0.227   9.888 -15.197  1.00 54.04           C
ATOM      4  CA  GLY A   4      -0.227   9.888 -15.197  1.00 54.04           C
ATOM      5  CA  GLY A   5      -0.227   9.888 -15.197  1.00 54.04           C
ATOM      6  CA  GLY A   6      -0.227   9.888 -15.197  1.00 54.04           C
ATOM      7  CA  GLY A   7      -0.227   9.888 -15.197  1.00 54.04           C
ATOM      8  CA  GLY A   8      -0.227   9.888 -15.197  1.00 54.04           C
ATOM      9  CA  GLY A   9      -0.227   9.888 -15.197  1.00 54.04           C
ATOM     10  CA  GLY A  10      -0.227   9.888 -15.197  1.00 54.04           C
HETATM   11  N   SEP A  11      -2.112   0.368  -0.991  1.00 20.00      A    N
HETATM   12  CA  SEP A  11      -0.692   0.284  -0.951  1.00 20.00      A    C
HETATM   13  CB  SEP A  11      -0.234   0.166   0.485  1.00 20.00      A    C
HETATM   14  OG  SEP A  11       1.130  -0.184   0.515  1.00 20.00      A    O
HETATM   15  C   SEP A  11      -0.237  -0.930  -1.727  1.00 20.00      A    C
HETATM   16  O   SEP A  11      -0.767  -2.051  -1.509  1.00 20.00      A    O
HETATM   18  P   SEP A  11       1.922  -0.008   1.871  1.00 20.00      A    P
HETATM   19  O1P SEP A  11       2.139   1.462   2.140  1.00 20.00      A    O
HETATM   20  O2P SEP A  11       3.259  -0.703   1.767  1.00 20.00      A    O-1
HETATM   21  O3P SEP A  11       1.127  -0.614   3.002  1.00 20.00      A    O-1
END"""
    mon_lib_srv = server.server()
    ener_lib = server.ener_lib()
    pdb_in = iotbx.pdb.hierarchy.input(pdb_string=pdb_raw)
    xrs = pdb_in.input.xray_structure_simple()
    processed_pdb_file = pdb_interpretation.process(
        mon_lib_srv=mon_lib_srv,
        ener_lib=ener_lib,
        raw_records=pdb_in.hierarchy.as_pdb_string(crystal_symmetry=xrs),
        crystal_symmetry=xrs,
        log=null_out())
    pdb_in.hierarchy.atoms().reset_i_seq()
    ligand_sel = pdb_in.hierarchy.atom_selection_cache().selection(
        "resname SEP")
    mstats = model_properties.model_statistics(
        pdb_hierarchy=pdb_in.hierarchy,
        xray_structure=xrs,
        all_chain_proxies=processed_pdb_file.all_chain_proxies,
        ligand_selection=ligand_sel,
        ignore_hd=True)
    out = StringIO()
    mstats.show(out=out)
    assert (mstats.n_protein == 10)
    assert ("Ligands:" in out.getvalue())
    assert approx_equal(mstats.macromolecules.b_mean, 54.04)
    # now with just the raw selection string
    mstats = model_properties.model_statistics(
        pdb_hierarchy=pdb_in.hierarchy,
        xray_structure=xrs,
        all_chain_proxies=processed_pdb_file.all_chain_proxies,
        ligand_selection="resname SEP",
        ignore_hd=True)
    out = StringIO()
    mstats.show(out=out)
    assert (mstats.n_protein == 10)
    assert ("Ligands:" in out.getvalue())
コード例 #2
0
def exercise_3 () :
  pdb_raw = """\
ATOM      1  CA  GLY A   1      -0.227   9.888 -15.197  1.00 54.04           C
ATOM      2  CA  GLY A   2      -0.227   9.888 -15.197  1.00 54.04           C
ATOM      3  CA  GLY A   3      -0.227   9.888 -15.197  1.00 54.04           C
ATOM      4  CA  GLY A   4      -0.227   9.888 -15.197  1.00 54.04           C
ATOM      5  CA  GLY A   5      -0.227   9.888 -15.197  1.00 54.04           C
ATOM      6  CA  GLY A   6      -0.227   9.888 -15.197  1.00 54.04           C
ATOM      7  CA  GLY A   7      -0.227   9.888 -15.197  1.00 54.04           C
ATOM      8  CA  GLY A   8      -0.227   9.888 -15.197  1.00 54.04           C
ATOM      9  CA  GLY A   9      -0.227   9.888 -15.197  1.00 54.04           C
ATOM     10  CA  GLY A  10      -0.227   9.888 -15.197  1.00 54.04           C
HETATM   11  N   SEP A  11      -2.112   0.368  -0.991  1.00 20.00      A    N
HETATM   12  CA  SEP A  11      -0.692   0.284  -0.951  1.00 20.00      A    C
HETATM   13  CB  SEP A  11      -0.234   0.166   0.485  1.00 20.00      A    C
HETATM   14  OG  SEP A  11       1.130  -0.184   0.515  1.00 20.00      A    O
HETATM   15  C   SEP A  11      -0.237  -0.930  -1.727  1.00 20.00      A    C
HETATM   16  O   SEP A  11      -0.767  -2.051  -1.509  1.00 20.00      A    O
HETATM   18  P   SEP A  11       1.922  -0.008   1.871  1.00 20.00      A    P
HETATM   19  O1P SEP A  11       2.139   1.462   2.140  1.00 20.00      A    O
HETATM   20  O2P SEP A  11       3.259  -0.703   1.767  1.00 20.00      A    O-1
HETATM   21  O3P SEP A  11       1.127  -0.614   3.002  1.00 20.00      A    O-1
END"""
  mon_lib_srv = server.server()
  ener_lib = server.ener_lib()
  pdb_in = iotbx.pdb.hierarchy.input(pdb_string=pdb_raw)
  xrs = pdb_in.input.xray_structure_simple()
  processed_pdb_file = pdb_interpretation.process(
    mon_lib_srv=mon_lib_srv,
    ener_lib=ener_lib,
    raw_records=pdb_in.hierarchy.as_pdb_string(crystal_symmetry=xrs),
    crystal_symmetry=xrs,
    log=null_out())
  pdb_in.hierarchy.atoms().reset_i_seq()
  ligand_sel = pdb_in.hierarchy.atom_selection_cache().selection("resname SEP")
  mstats = model_properties.model_statistics(
    pdb_hierarchy=pdb_in.hierarchy,
    xray_structure=xrs,
    all_chain_proxies=processed_pdb_file.all_chain_proxies,
    ligand_selection=ligand_sel,
    ignore_hd=True)
  out = StringIO()
  mstats.show(out=out)
  assert (mstats.n_protein == 10)
  assert ("Ligands:" in out.getvalue())
  assert approx_equal(mstats.macromolecules.b_mean, 54.04)
  # now with just the raw selection string
  mstats = model_properties.model_statistics(
    pdb_hierarchy=pdb_in.hierarchy,
    xray_structure=xrs,
    all_chain_proxies=processed_pdb_file.all_chain_proxies,
    ligand_selection="resname SEP",
    ignore_hd=True)
  out = StringIO()
  mstats.show(out=out)
  assert (mstats.n_protein == 10)
  assert ("Ligands:" in out.getvalue())
コード例 #3
0
def get_mstats(pdb_raw):
    mon_lib_srv = server.server()
    ener_lib = server.ener_lib()
    pdb_in = iotbx.pdb.hierarchy.input(pdb_string=pdb_raw)
    xrs = pdb_in.input.xray_structure_simple()
    processed_pdb_file = pdb_interpretation.process(
        mon_lib_srv=mon_lib_srv,
        ener_lib=ener_lib,
        raw_records=pdb_in.hierarchy.as_pdb_string(crystal_symmetry=xrs),
        crystal_symmetry=xrs,
        log=null_out())
    pdb_in.hierarchy.atoms().reset_i_seq()
    mstats = model_properties.model_statistics(
        pdb_hierarchy=pdb_in.hierarchy,
        xray_structure=xrs,
        all_chain_proxies=processed_pdb_file.all_chain_proxies,
        ignore_hd=True)
    return mstats
コード例 #4
0
def exercise_2 () :
  pdb_raw = """\
ATOM   6407  N   GLY A 388      -0.783   9.368 -16.436  1.00 51.96           N
ATOM   6408  CA  GLY A 388      -0.227   9.888 -15.197  1.00 54.04           C
ATOM   6409  C   GLY A 388      -0.637  11.320 -14.897  1.00 55.86           C
ATOM   6410  O   GLY A 388      -1.728  11.738 -15.347  1.00 56.70           O
ATOM   6411  OXT GLY A 388       0.129  12.024 -14.203  1.00 56.98           O
ATOM   6412  D   GLY A 388      -0.460   9.727 -17.309  1.00 51.44           D
ATOM   6413  HA2 GLY A 388      -0.561   9.258 -14.385  1.00 54.07           H
ATOM   6414  HA3 GLY A 388       0.843   9.835 -15.243  1.00 54.13           H
TER    6415      GLY A 388
HETATM 6416  D   D8U A 401     -12.236 -13.695 -42.992  1.00 15.23           D
HETATM 6417  O   DOD A1001      -4.151  -5.107 -38.592  1.00 13.40           O
HETATM 6418  D1  DOD A1001      -4.760  -5.026 -39.326  1.00 15.45           D
HETATM 6419  D2  DOD A1001      -4.625  -4.741 -37.845  1.00 14.81           D
"""
  mon_lib_srv = server.server()
  ener_lib = server.ener_lib()
  pdb_in = iotbx.pdb.hierarchy.input(pdb_string=pdb_raw)
  xrs = pdb_in.input.xray_structure_simple()
  processed_pdb_file = pdb_interpretation.process(
    mon_lib_srv=mon_lib_srv,
    ener_lib=ener_lib,
    raw_records=pdb_in.hierarchy.as_pdb_string(crystal_symmetry=xrs),
    crystal_symmetry=xrs,
    log=null_out())
  pdb_in.hierarchy.atoms().reset_i_seq()
  mstats = model_properties.model_statistics(
    pdb_hierarchy=pdb_in.hierarchy,
    xray_structure=xrs,
    all_chain_proxies=processed_pdb_file.all_chain_proxies,
    ignore_hd=True)
  out = StringIO()
  mstats.show(out=out)
  assert ("Ligands:" in out.getvalue())
  assert ("B_iso: mean =  15.2  max =  15.2  min =  15.2" in out.getvalue())
コード例 #5
0
    def __init__(self,
                 pdb_hierarchy,
                 xray_structure=None,
                 fmodel=None,
                 fmodel_neutron=None,
                 geometry_restraints_manager=None,
                 crystal_symmetry=None,
                 sequences=None,
                 flags=None,
                 header_info=None,
                 raw_data=None,
                 unmerged_data=None,
                 all_chain_proxies=None,
                 keep_hydrogens=True,
                 nuclear=False,
                 save_probe_unformatted_file=None,
                 show_hydrogen_outliers=False,
                 min_cc_two_fofc=0.8,
                 n_bins_data=10,
                 count_anomalous_pairs_separately=False,
                 use_internal_variance=True,
                 outliers_only=True,
                 use_pdb_header_resolution_cutoffs=False,
                 file_name=None,
                 ligand_selection=None,
                 rotamer_library="8000",
                 map_params=None):
        assert rotamer_library == "8000", "data_version given to RotamerEval not recognized."
        for name in self.__slots__:
            setattr(self, name, None)
        # very important - the i_seq attributes may be extracted later
        pdb_hierarchy.atoms().reset_i_seq()
        self.pdb_hierarchy = pdb_hierarchy
        if (xray_structure is None):
            if (fmodel is not None):
                xray_structure = fmodel.xray_structure
            elif (crystal_symmetry is not None):
                xray_structure = pdb_hierarchy.extract_xray_structure(
                    crystal_symmetry=crystal_symmetry)
        self.crystal_symmetry = crystal_symmetry
        if (crystal_symmetry is None) and (fmodel is not None):
            self.crystal_symmetry = fmodel.f_obs().crystal_symmetry()

        # use maps (fmodel is not used)
        # run earlier since pdb_hierarchy gets modified
        use_maps = False
        if (map_params is not None):
            use_maps = ((map_params.input.maps.map_file_name) or
                        ((map_params.input.maps.map_coefficients_file_name) and
                         (map_params.input.maps.map_coefficients_label)))
        if (use_maps):
            if (flags.real_space):
                self.real_space = experimental.real_space(
                    fmodel=None,
                    pdb_hierarchy=pdb_hierarchy,
                    crystal_symmetry=self.crystal_symmetry,
                    cc_min=min_cc_two_fofc,
                    molprobity_map_params=map_params.input.maps)
            if (flags.waters):
                self.waters = waters.waters(
                    pdb_hierarchy=pdb_hierarchy,
                    xray_structure=xray_structure,
                    fmodel=None,
                    collect_all=True,
                    molprobity_map_params=map_params.input.maps)

        self.header_info = header_info
        if (flags is None):
            flags = molprobity_flags()
        import mmtbx.model.statistics
        self.model_statistics_geometry = mmtbx.model.statistics.geometry(
            pdb_hierarchy=pdb_hierarchy,
            geometry_restraints_manager=geometry_restraints_manager,
            use_hydrogens=keep_hydrogens,
            use_nuclear=nuclear)
        self.model_statistics_geometry_result = \
          self.model_statistics_geometry.result()
        self.ramalyze = self.model_statistics_geometry_result.ramachandran.ramalyze
        self.omegalyze = self.model_statistics_geometry_result.omega.omegalyze
        self.rotalyze = self.model_statistics_geometry_result.rotamer.rotalyze
        self.cbetadev = self.model_statistics_geometry_result.c_beta.cbetadev
        self.clashes = self.model_statistics_geometry_result.clash.clashes
        if pdb_hierarchy.contains_protein():
            self.find_missing_atoms(out=null_out())
            if (flags.nqh):
                self.nqh_flips = clashscore.nqh_flips(
                    pdb_hierarchy=pdb_hierarchy)
        if (pdb_hierarchy.contains_rna() and flags.rna
                and libtbx.env.has_module(name="suitename")):
            if (geometry_restraints_manager is not None):
                self.rna = rna_validate.rna_validation(
                    pdb_hierarchy=pdb_hierarchy,
                    geometry_restraints_manager=geometry_restraints_manager,
                    outliers_only=outliers_only,
                    params=None)
        if (flags.model_stats) and (xray_structure is not None):
            self.model_stats = model_properties.model_statistics(
                pdb_hierarchy=pdb_hierarchy,
                xray_structure=xray_structure,
                all_chain_proxies=all_chain_proxies,
                ignore_hd=(not nuclear),
                ligand_selection=ligand_selection)
        if (geometry_restraints_manager is not None) and (flags.restraints):
            assert (xray_structure is not None)
            self.restraints = restraints.combined(
                pdb_hierarchy=pdb_hierarchy,
                xray_structure=xray_structure,
                geometry_restraints_manager=geometry_restraints_manager,
                ignore_hd=(not nuclear),
                cdl=getattr(all_chain_proxies, "use_cdl", None))
        if (sequences is not None) and (flags.seq):
            self.sequence = sequence.validation(
                pdb_hierarchy=pdb_hierarchy,
                sequences=sequences,
                log=null_out(),
                include_secondary_structure=True,
                extract_coordinates=True)

        if (fmodel is not None):
            if (use_pdb_header_resolution_cutoffs) and (header_info
                                                        is not None):
                fmodel = fmodel.resolution_filter(d_min=header_info.d_min,
                                                  d_max=header_info.d_max)
            if (flags.rfactors):
                self.data_stats = experimental.data_statistics(
                    fmodel,
                    raw_data=raw_data,
                    n_bins=n_bins_data,
                    count_anomalous_pairs_separately=
                    count_anomalous_pairs_separately)

            if (not use_maps):  # if maps are used, keep previous results
                if (flags.real_space):
                    self.real_space = experimental.real_space(
                        fmodel=fmodel,
                        pdb_hierarchy=pdb_hierarchy,
                        cc_min=min_cc_two_fofc)
                if (flags.waters):
                    self.waters = waters.waters(pdb_hierarchy=pdb_hierarchy,
                                                xray_structure=xray_structure,
                                                fmodel=fmodel,
                                                collect_all=True)

            if (unmerged_data is not None):
                self.merging = experimental.merging_and_model_statistics(
                    f_obs=fmodel.f_obs(),
                    f_model=fmodel.f_model(),
                    r_free_flags=fmodel.r_free_flags(),
                    unmerged_i_obs=unmerged_data,
                    anomalous=count_anomalous_pairs_separately,
                    use_internal_variance=use_internal_variance,
                    n_bins=n_bins_data)
            if (flags.xtriage):
                import mmtbx.scaling.xtriage
                f_model = abs(
                    fmodel.f_model()).set_observation_type_xray_amplitude()
                if (raw_data is not None):
                    f_model, obs = f_model.common_sets(other=raw_data)
                else:
                    obs = fmodel.f_obs()
                self.xtriage = mmtbx.scaling.xtriage.xtriage_analyses(
                    miller_obs=obs,
                    miller_calc=f_model,
                    unmerged_obs=unmerged_data,  # XXX some redundancy here...
                    text_out=null_out())
        if (fmodel_neutron is not None) and (flags.rfactors):
            self.neutron_stats = experimental.data_statistics(
                fmodel_neutron,
                n_bins=n_bins_data,
                count_anomalous_pairs_separately=False)
        if (pdb_hierarchy.models_size() == 1):
            self._multi_criterion = multi_criterion_view(pdb_hierarchy)

        # wilson B
        self.wilson_b = None
        if (fmodel is not None):
            self.wilson_b = fmodel.wilson_b()
        elif (fmodel_neutron is not None):
            self.wilson_b = fmodel_neutron.wilson_b()
コード例 #6
0
  def __init__ (self,
      pdb_hierarchy,
      xray_structure=None,
      fmodel=None,
      fmodel_neutron=None,
      geometry_restraints_manager=None,
      crystal_symmetry=None,
      sequences=None,
      flags=None,
      header_info=None,
      raw_data=None,
      unmerged_data=None,
      all_chain_proxies=None,
      keep_hydrogens=True,
      nuclear=False,
      save_probe_unformatted_file=None,
      show_hydrogen_outliers=False,
      min_cc_two_fofc=0.8,
      n_bins_data=10,
      count_anomalous_pairs_separately=False,
      use_internal_variance=True,
      outliers_only=True,
      use_pdb_header_resolution_cutoffs=False,
      file_name=None,
      ligand_selection=None,
      rotamer_library="8000",
      map_params=None) :
    assert rotamer_library == "8000", "data_version given to RotamerEval not recognized."
    for name in self.__slots__ :
      setattr(self, name, None)
    # very important - the i_seq attributes may be extracted later
    pdb_hierarchy.atoms().reset_i_seq()
    self.pdb_hierarchy = pdb_hierarchy
    if (xray_structure is None) :
      if (fmodel is not None) :
        xray_structure = fmodel.xray_structure
      elif (crystal_symmetry is not None) :
        xray_structure = pdb_hierarchy.extract_xray_structure(
          crystal_symmetry=crystal_symmetry)
    self.crystal_symmetry = crystal_symmetry
    if (crystal_symmetry is None) and (fmodel is not None) :
      self.crystal_symmetry = fmodel.f_obs().crystal_symmetry()
    self.header_info = header_info
    if (flags is None) :
      flags = molprobity_flags()
    if pdb_hierarchy.contains_protein() :
      if (flags.ramalyze) :
        self.ramalyze = ramalyze.ramalyze(
          pdb_hierarchy=pdb_hierarchy,
          outliers_only=outliers_only,
          out=null_out(),
          quiet=True)
##### omegalyze ################################################################
      if (flags.omegalyze) :
        self.omegalyze = omegalyze.omegalyze(
          pdb_hierarchy=pdb_hierarchy,
          nontrans_only=outliers_only,
          out=null_out(),
          quiet=True)
##### omegalyze ################################################################
      if (flags.rotalyze) :
        self.rotalyze = rotalyze.rotalyze(
          pdb_hierarchy=pdb_hierarchy,
          data_version=rotamer_library,
          outliers_only=outliers_only,
          out=null_out(),
          quiet=True)
      if (flags.cbetadev) :
        self.cbetadev = cbetadev.cbetadev(
          pdb_hierarchy=pdb_hierarchy,
          outliers_only=outliers_only,
          out=null_out(),
          quiet=True)
      if (flags.nqh) :
        self.nqh_flips = clashscore.nqh_flips(
          pdb_hierarchy=pdb_hierarchy)
    if (pdb_hierarchy.contains_rna() and flags.rna and
        libtbx.env.has_module(name="suitename")) :
      if (geometry_restraints_manager is not None) :
        self.rna = rna_validate.rna_validation(
          pdb_hierarchy=pdb_hierarchy,
          geometry_restraints_manager=geometry_restraints_manager,
          outliers_only=outliers_only,
          params=None)
    if (flags.clashscore) :
      self.clashes = clashscore.clashscore(
        pdb_hierarchy=pdb_hierarchy,
        save_probe_unformatted_file=save_probe_unformatted_file,
        nuclear=nuclear,
        keep_hydrogens=keep_hydrogens,
        out=null_out(),
        verbose=False)
    if (flags.model_stats) and (xray_structure is not None) :
      self.model_stats = model_properties.model_statistics(
        pdb_hierarchy=pdb_hierarchy,
        xray_structure=xray_structure,
        all_chain_proxies=all_chain_proxies,
        ignore_hd=(not nuclear),
        ligand_selection=ligand_selection)
    if (geometry_restraints_manager is not None) and (flags.restraints) :
      assert (xray_structure is not None)
      self.restraints = restraints.combined(
        pdb_hierarchy=pdb_hierarchy,
        xray_structure=xray_structure,
        geometry_restraints_manager=geometry_restraints_manager,
        ignore_hd=(not nuclear),
        cdl=getattr(all_chain_proxies, "use_cdl", None))
    if (sequences is not None) and (flags.seq) :
      self.sequence = sequence.validation(
        pdb_hierarchy=pdb_hierarchy,
        sequences=sequences,
        log=null_out(),
        include_secondary_structure=True,
        extract_coordinates=True)

    # use maps (fmodel is not used)
    use_maps = False
    if (map_params is not None):
      use_maps = ( (map_params.input.maps.map_file_name) or
                   ( (map_params.input.maps.map_coefficients_file_name) and
                     (map_params.input.maps.map_coefficients_label) ) )
    if (use_maps):
      if (flags.real_space):
        self.real_space = experimental.real_space(
          fmodel=None,
          pdb_hierarchy=pdb_hierarchy,
          cc_min=min_cc_two_fofc,
          molprobity_map_params=map_params.input.maps)
      if (flags.waters):
        self.waters = waters.waters(
          pdb_hierarchy=pdb_hierarchy,
          xray_structure=xray_structure,
          fmodel=None,
          collect_all=True,
          molprobity_map_params=map_params.input.maps)

    if (fmodel is not None) :
      if (use_pdb_header_resolution_cutoffs) and (header_info is not None) :
        fmodel = fmodel.resolution_filter(
          d_min=header_info.d_min,
          d_max=header_info.d_max)
      if (flags.rfactors) :
        self.data_stats = experimental.data_statistics(fmodel,
          raw_data=raw_data,
          n_bins=n_bins_data,
          count_anomalous_pairs_separately=count_anomalous_pairs_separately)

      if (not use_maps): # if maps are used, keep previous results
        if (flags.real_space):
          self.real_space = experimental.real_space(
            fmodel=fmodel,
            pdb_hierarchy=pdb_hierarchy,
            cc_min=min_cc_two_fofc)
        if (flags.waters) :
          self.waters = waters.waters(
            pdb_hierarchy=pdb_hierarchy,
            xray_structure=xray_structure,
            fmodel=fmodel,
            collect_all=True)

      if (unmerged_data is not None) :
        self.merging = experimental.merging_and_model_statistics(
          f_obs=fmodel.f_obs(),
          f_model=fmodel.f_model(),
          r_free_flags=fmodel.r_free_flags(),
          unmerged_i_obs=unmerged_data,
          anomalous=count_anomalous_pairs_separately,
          use_internal_variance=use_internal_variance,
          n_bins=n_bins_data)
      if (flags.xtriage) :
        import mmtbx.scaling.xtriage
        f_model = abs(fmodel.f_model()).set_observation_type_xray_amplitude()
        if (raw_data is not None) :
          f_model, obs = f_model.common_sets(other=raw_data)
        else :
          obs = fmodel.f_obs()
        self.xtriage = mmtbx.scaling.xtriage.xtriage_analyses(
          miller_obs=obs,
          miller_calc=f_model,
          unmerged_obs=unmerged_data, # XXX some redundancy here...
          text_out=null_out())
    if (fmodel_neutron is not None) and (flags.rfactors) :
      self.neutron_stats = experimental.data_statistics(fmodel_neutron,
        n_bins=n_bins_data,
        count_anomalous_pairs_separately=False)
    if (pdb_hierarchy.models_size() == 1) :
      self._multi_criterion = multi_criterion_view(pdb_hierarchy)
コード例 #7
0
def exercise_1 () :
  pdb_raw = """\
ATOM   1134  N   LYS A  82       5.933  36.285  21.572  1.00 70.94           N
ATOM   1135  CA  LYS A  82       6.564  37.423  20.931  1.00 76.69           C
ATOM   1136  C   LYS A  82       5.553  38.547  20.756  1.00 78.75           C
ATOM   1137  O   LYS A  82       5.325  39.038  19.654  1.00 86.47           O
ATOM   1138  CB  LYS A  82       7.179  37.024  19.583  1.00 82.32           C
ATOM   1139  CG  LYS A  82       8.190  38.035  19.048  0.00 70.34           C
ATOM   1140  CD  LYS A  82       9.429  38.129  19.944  0.00 67.69           C
ATOM   1141  CE  LYS A  82       9.983  39.545  20.014  0.00 64.44           C
ATOM   1142  NZ  LYS A  82      10.933  39.832  18.908  0.00 61.45           N
ATOM   1143  H   LYS A  82       5.139  36.115  21.291  1.00 85.12           H
ATOM   1144  HA  LYS A  82       7.279  37.749  21.501  1.00 92.03           H
ATOM   1145  HB2 LYS A  82       6.469  36.939  18.928  1.00 98.78           H
ATOM   1146  HB3 LYS A  82       7.636  36.175  19.687  1.00 98.78           H
ATOM   1147  HG2 LYS A  82       8.476  37.762  18.163  0.00 84.41           H
ATOM   1148  HG3 LYS A  82       7.775  38.912  19.011  0.00 84.41           H
ATOM   1149  HD2 LYS A  82       9.193  37.853  20.843  0.00 81.23           H
ATOM   1150  HD3 LYS A  82      10.122  37.551  19.589  0.00 81.23           H
ATOM   1151  HE2 LYS A  82       9.249  40.177  19.952  0.00 77.33           H
ATOM   1152  HE3 LYS A  82      10.453  39.662  20.854  0.00 77.33           H
ATOM   1153  HZ1 LYS A  82      11.237  40.666  18.977  0.00 73.75           H
ATOM   1154  HZ2 LYS A  82      10.523  39.738  18.123  0.00 73.75           H
ATOM   1155  HZ3 LYS A  82      11.621  39.269  18.944  0.00 73.75           H
ATOM   1156  N   LYS A  83       4.936  38.927  21.866  1.00 75.79           N
ATOM   1157  CA  LYS A  83       4.177  40.172  21.966  1.00 82.80           C
ATOM   1158  C   LYS A  83       4.081  40.508  23.460  1.00 86.23           C
ATOM   1159  O   LYS A  83       2.978  40.521  24.017  1.00 79.81           O
ATOM   1160  CB  LYS A  83       2.790  40.044  21.332  1.00 79.16           C
ATOM   1161  CG  LYS A  83       2.038  41.342  21.175  0.00 70.42           C
ATOM   1162  CD  LYS A  83       2.072  41.803  19.735  0.00 66.90           C
ATOM   1163  CE  LYS A  83       1.295  43.089  19.552  0.00 62.46           C
ATOM   1164  NZ  LYS A  83       1.004  43.350  18.118  0.00 60.73           N
ATOM   1165  H   LYS A  83       4.940  38.470  22.594  1.00 90.95           H
ATOM   1166  HA  LYS A  83       4.658  40.885  21.518  1.00 99.36           H
ATOM   1167  HB2 LYS A  83       2.251  39.459  21.887  1.00 95.00           H
ATOM   1168  HB3 LYS A  83       2.890  39.655  20.449  1.00 95.00           H
ATOM   1169  HG2 LYS A  83       1.113  41.213  21.435  0.00 84.51           H
ATOM   1170  HG3 LYS A  83       2.453  42.024  21.726  0.00 84.51           H
ATOM   1171  HD2 LYS A  83       2.992  41.962  19.471  0.00 80.28           H
ATOM   1172  HD3 LYS A  83       1.672  41.123  19.171  0.00 80.28           H
ATOM   1173  HE2 LYS A  83       0.452  43.024  20.027  0.00 74.95           H
ATOM   1174  HE3 LYS A  83       1.818  43.830  19.896  0.00 74.95           H
ATOM   1175  HZ1 LYS A  83       0.521  42.683  17.780  0.00 72.87           H
ATOM   1176  HZ2 LYS A  83       1.764  43.417  17.661  0.00 72.87           H
ATOM   1177  HZ3 LYS A  83       0.548  44.109  18.034  0.00 72.87           H
ATOM   3630  N   ASN A 242      -5.454  -3.027   1.145  0.00 67.69           N
ATOM   3631  CA  ASN A 242      -4.759  -2.535  -0.037  0.00 65.44           C
ATOM   3632  C   ASN A 242      -5.734  -2.397  -1.208  0.00 63.57           C
ATOM   3633  O   ASN A 242      -6.425  -3.357  -1.552  0.00 63.94           O
ATOM   3634  CB  ASN A 242      -3.626  -3.503  -0.392  0.00 63.13           C
ATOM   3635  CG  ASN A 242      -2.802  -3.044  -1.576  0.00 63.58           C
ATOM   3636  OD1 ASN A 242      -2.524  -1.862  -1.731  0.00 65.52           O
ATOM   3637  ND2 ASN A 242      -2.399  -3.988  -2.416  0.00 62.17           N
ATOM   3638  H   ASN A 242      -5.562  -3.880   1.129  0.00 81.22           H
ATOM   3639  HA  ASN A 242      -4.375  -1.665   0.151  0.00 78.53           H
ATOM   3640  HB2 ASN A 242      -3.032  -3.587   0.370  0.00 75.76           H
ATOM   3641  HB3 ASN A 242      -4.007  -4.368  -0.611  0.00 75.76           H
ATOM   3642 HD21 ASN A 242      -1.929  -3.779  -3.104  0.00 74.60           H
ATOM   3643 HD22 ASN A 242      -2.609  -4.810  -2.272  0.00 74.60           H
ATOM      2  CA ALYS A  32      10.574   8.177  11.768  0.40 71.49           C
ATOM      3  CB ALYS A  32       9.197   8.686  12.246  0.40 74.71           C
ATOM      2  CA BLYS A  32      10.574   8.177  11.768  0.40 71.49           C
ATOM      3  CB BLYS A  32       9.197   8.686  12.246  0.40 74.71           C
ATOM      5  CA AVAL A  33      11.708   5.617  14.332  0.50 71.42           C
ATOM      6  CB AVAL A  33      11.101   4.227  14.591  0.50 71.47           C
ATOM      5  CA BVAL A  33      11.708   5.617  14.332  0.40 71.42           C
ATOM      6  CB BVAL A  33      11.101   4.227  14.591  0.40 71.47           C
TER
ATOM      1  N   GLU X  18     -13.959  12.159  -6.598  1.00260.08           N
ATOM      2  CA  GLU X  18     -13.297  13.465  -6.628  1.00269.83           C
ATOM      3  C   GLU X  18     -11.946  13.282  -7.309  1.00269.18           C
ATOM      4  CB  GLU X  18     -13.128  14.035  -5.210  1.00261.96           C
ATOM      5  CG  GLU X  18     -14.455  14.401  -4.522  1.00263.56           C
ATOM      6  CD  GLU X  18     -14.291  15.239  -3.242  1.00264.89           C
ATOM      7  OE1 GLU X  18     -14.172  14.646  -2.143  1.00264.24           O
ATOM      8  OE2 GLU X  18     -14.309  16.498  -3.306  1.00264.37           O1-
HETATM  614  S   SO4 B 101      14.994  20.601  10.862  0.00  7.02           S
HETATM  615  O1  SO4 B 101      14.234  20.194  12.077  0.00  7.69           O
HETATM  616  O2  SO4 B 101      14.048  21.062   9.850  0.00  9.28           O
HETATM  617  O3  SO4 B 101      15.905  21.686  11.261  0.00  8.01           O
HETATM  618  O4  SO4 B 101      15.772  19.454  10.371  0.00  8.18           O
TER
HETATM  122  O   HOH S   1       5.334   8.357   8.032  1.00  0.00           O
HETATM  123  O   HOH S   2       5.396  15.243  10.734  1.00202.95           O
HETATM  124  O   HOH S   3     -25.334  18.357  18.032  0.00 20.00           O
"""
  mon_lib_srv = server.server()
  ener_lib = server.ener_lib()
  pdb_in = iotbx.pdb.hierarchy.input(pdb_string=pdb_raw)
  xrs = pdb_in.input.xray_structure_simple()
  processed_pdb_file = pdb_interpretation.process(
    mon_lib_srv=mon_lib_srv,
    ener_lib=ener_lib,
    raw_records=pdb_in.hierarchy.as_pdb_string(crystal_symmetry=xrs),
    crystal_symmetry=xrs,
    log=null_out())
  pdb_in.hierarchy.atoms().reset_i_seq()
  mstats = model_properties.model_statistics(
    pdb_hierarchy=pdb_in.hierarchy,
    xray_structure=xrs,
    all_chain_proxies=processed_pdb_file.all_chain_proxies,
    ignore_hd=True)
  out = StringIO()
  mstats.show(out=out)
  #print out.getvalue()
  assert not show_diff(out.getvalue(), """\
Overall:
  Number of atoms = 50  (anisotropic = 0)
  B_iso: mean =  96.0  max = 269.8  min =   0.0
  Occupancy: mean = 0.47  max = 1.00  min = 0.00
    warning: 22 atoms with zero occupancy
  67 total B-factor or occupancy problem(s) detected
  Atoms or residues with zero occupancy:
   LYS A  82   CG    occ=0.00
   LYS A  82   CD    occ=0.00
   LYS A  82   CE    occ=0.00
   LYS A  82   NZ    occ=0.00
   LYS A  83   CG    occ=0.00
   LYS A  83   CD    occ=0.00
   LYS A  83   CE    occ=0.00
   LYS A  83   NZ    occ=0.00
   ASN A 242  (all)  occ=0.00
   SO4 B 101  (all)  occ=0.00
   HOH S   3   O     occ=0.00
Macromolecules:
  Number of atoms = 42  (anisotropic = 0)
  B_iso: mean = 108.0  max = 269.8  min =  60.7
  Occupancy: mean = 0.51  max = 1.00  min = 0.00
    warning: 16 atoms with zero occupancy
  57 total B-factor or occupancy problem(s) detected
Ligands:
  Number of atoms = 5  (anisotropic = 0)
  B_iso: mean =   8.0  max =   9.3  min =   7.0
  Occupancy: mean = 0.00  max = 0.00  min = 0.00
    warning: 5 atoms with zero occupancy
  6 total B-factor or occupancy problem(s) detected
Waters:
  Number of atoms = 3  (anisotropic = 0)
  B_iso: mean =  74.3  max = 202.9  min =   0.0
  Occupancy: mean = 0.67  max = 1.00  min = 0.00
    warning: 1 atoms with zero occupancy
  4 total B-factor or occupancy problem(s) detected
(Hydrogen atoms not included in overall counts.)
""")
  assert (len(mstats.all.bad_adps) == 1)
  assert (mstats.all.n_zero_b == 1)
  mstats2 = loads(dumps(mstats))
  out1 = StringIO()
  out2 = StringIO()
  mstats.show(out=out1)
  mstats2.show(out=out2)
  assert (out1.getvalue() == out2.getvalue())
  # now with ignore_hd=False
  mstats3 = model_properties.model_statistics(
    pdb_hierarchy=pdb_in.hierarchy,
    xray_structure=xrs,
    all_chain_proxies=processed_pdb_file.all_chain_proxies,
    ignore_hd=False)
  out2 = StringIO()
  mstats3.show(out=out2)
  assert (out2.getvalue() != out.getvalue())
  assert ("""   LYS A  83   HZ3   occ=0.00""" in out2.getvalue())
  outliers = mstats3.all.as_gui_table_data(include_zoom=True)
  assert (len(outliers) == 84)
  # test with all_chain_proxies undefined
  mstats4 = model_properties.model_statistics(
    pdb_hierarchy=pdb_in.hierarchy,
    xray_structure=xrs,
    all_chain_proxies=None,
    ignore_hd=False)
  outliers = mstats4.all.as_gui_table_data(include_zoom=True)
  assert (len(outliers) == 84)
コード例 #8
0
ファイル: __init__.py プロジェクト: jongablop/cctbx_project
  def __init__(self,
      model,
      fmodel=None,
      fmodel_neutron=None,
      sequences=None,
      flags=None,
      header_info=None,
      raw_data=None,
      unmerged_data=None,
      keep_hydrogens=True,
      nuclear=False,
      save_probe_unformatted_file=None,
      show_hydrogen_outliers=False,
      min_cc_two_fofc=0.8,
      n_bins_data=10,
      count_anomalous_pairs_separately=False,
      use_internal_variance=True,
      outliers_only=True,
      use_pdb_header_resolution_cutoffs=False,
      file_name=None,
      ligand_selection=None,
      rotamer_library="8000",
      map_params=None):
    assert rotamer_library == "8000", "data_version given to RotamerEval not recognized."
    for name in self.__slots__ :
      setattr(self, name, None)

    # use objects from model
    self.model = model
    if(not self.model.processed()):
      self.model.process(make_restraints=True)
    if(self.model is None and pdb_hierarchy is not None):
      import mmtbx.model
      self.model = mmtbx.model.manager(
        model_input = pdb_hierarchy.as_pdb_input())
      self.model.process(make_restraints=True)

    pdb_hierarchy = self.model.get_hierarchy()
    if(nuclear):
      self.model.setup_scattering_dictionaries(scattering_table="neutron")

    if (self.model is not None):
      if(self.model.get_restraints_manager() is None):
        self.model.process(make_restraints=True)
      pdb_hierarchy = self.model.get_hierarchy()
      xray_structure = self.model.get_xray_structure()
      geometry_restraints_manager = self.model.get_restraints_manager().geometry
      crystal_symmetry = self.model.crystal_symmetry()
      all_chain_proxies = None
    else:
      assert (pdb_hierarchy is not None)
      xray_structure = None
      geometry_restraints_manager = None
      crystal_symmetry = None
      all_chain_proxies = None

    # very important - the i_seq attributes may be extracted later
    pdb_hierarchy.atoms().reset_i_seq()
    self.pdb_hierarchy = pdb_hierarchy
    if (xray_structure is None):
      if (fmodel is not None):
        xray_structure = fmodel.xray_structure
      elif (crystal_symmetry is not None):
        xray_structure = pdb_hierarchy.extract_xray_structure(
          crystal_symmetry=crystal_symmetry)
    self.crystal_symmetry = crystal_symmetry
    if (crystal_symmetry is None) and (fmodel is not None):
      self.crystal_symmetry = fmodel.f_obs().crystal_symmetry()

    # use maps (fmodel is not used)
    # run earlier since pdb_hierarchy gets modified
    use_maps = False
    if (map_params is not None):
      use_maps = ( (map_params.input.maps.map_file_name) or
                   ( (map_params.input.maps.map_coefficients_file_name) and
                     (map_params.input.maps.map_coefficients_label) ) )
    if (use_maps):
      if (flags.real_space):
        self.real_space = experimental.real_space(
          fmodel=None,
          model=self.model,
          cc_min=min_cc_two_fofc,
          molprobity_map_params=map_params.input.maps)
      if (flags.waters):
        self.waters = waters.waters(
          pdb_hierarchy=pdb_hierarchy,
          xray_structure=xray_structure,
          fmodel=None,
          collect_all=True,
          molprobity_map_params=map_params.input.maps)

    self.header_info = header_info
    if (flags is None):
      flags = molprobity_flags()

    self.model_statistics_geometry = self.model.geometry_statistics(
      use_hydrogens=keep_hydrogens, condensed_probe=False, fast_clash=False)
    self.model_statistics_geometry_result = \
      self.model_statistics_geometry.result()
    self.ramalyze  = self.model_statistics_geometry_result.ramachandran.ramalyze
    self.omegalyze = self.model_statistics_geometry_result.omega.omegalyze
    self.rotalyze  = self.model_statistics_geometry_result.rotamer.rotalyze
    self.cbetadev  = self.model_statistics_geometry_result.c_beta.cbetadev
    self.clashes   = self.model_statistics_geometry_result.clash.clashes
    if pdb_hierarchy.contains_protein():
      self.find_missing_atoms(out=null_out())
      if (flags.nqh):
        self.nqh_flips = clashscore.nqh_flips(
          pdb_hierarchy=pdb_hierarchy)
    if (pdb_hierarchy.contains_rna() and flags.rna and
        libtbx.env.has_module(name="suitename")):
      if (geometry_restraints_manager is not None):
        self.rna = rna_validate.rna_validation(
          pdb_hierarchy=pdb_hierarchy,
          geometry_restraints_manager=geometry_restraints_manager,
          outliers_only=outliers_only,
          params=None)
    if (flags.model_stats) and (self.model is not None):
      # keep for backwards compatibility
      self.model_stats = model_properties.model_statistics(
        pdb_hierarchy=pdb_hierarchy,
        xray_structure=xray_structure,
        all_chain_proxies=all_chain_proxies,
        ignore_hd=(not nuclear),
        ligand_selection=ligand_selection)
      # ligand_selection is no longer available
      self.model_stats_new = self.model.composition()
      self.adp_stats = self.model.adp_statistics()
    if (geometry_restraints_manager is not None) and (flags.restraints):
      assert (xray_structure is not None)
      self.restraints = restraints.combined(
        pdb_hierarchy=pdb_hierarchy,
        xray_structure=xray_structure,
        geometry_restraints_manager=geometry_restraints_manager,
        ignore_hd=(not nuclear),
        cdl=getattr(all_chain_proxies, "use_cdl", None))
    if (sequences is not None) and (flags.seq):
      self.sequence = sequence.validation(
        pdb_hierarchy=pdb_hierarchy,
        sequences=sequences,
        log=null_out(),
        include_secondary_structure=True,
        extract_coordinates=True)

    if (fmodel is not None):
      if (use_pdb_header_resolution_cutoffs) and (header_info is not None):
        fmodel = fmodel.resolution_filter(
          d_min=header_info.d_min,
          d_max=header_info.d_max)
        fmodel.update_all_scales()
      if (flags.rfactors):
        self.data_stats = experimental.data_statistics(fmodel,
          raw_data=raw_data,
          n_bins=n_bins_data,
          count_anomalous_pairs_separately=count_anomalous_pairs_separately)

      if (not use_maps): # if maps are used, keep previous results
        if (flags.real_space):
          self.real_space = experimental.real_space(
            model=model,
            fmodel=fmodel,
            cc_min=min_cc_two_fofc)
        if (flags.waters):
          self.waters = waters.waters(
            pdb_hierarchy=pdb_hierarchy,
            xray_structure=xray_structure,
            fmodel=fmodel,
            collect_all=True)

      if (unmerged_data is not None):
        self.merging = experimental.merging_and_model_statistics(
          f_obs=fmodel.f_obs(),
          f_model=fmodel.f_model(),
          r_free_flags=fmodel.r_free_flags(),
          unmerged_i_obs=unmerged_data,
          anomalous=count_anomalous_pairs_separately,
          use_internal_variance=use_internal_variance,
          n_bins=n_bins_data)
      if (flags.xtriage):
        import mmtbx.scaling.xtriage
        f_model = abs(fmodel.f_model()).set_observation_type_xray_amplitude()
        if (raw_data is not None):
          f_model, obs = f_model.common_sets(other=raw_data)
        else :
          obs = fmodel.f_obs()
        self.xtriage = mmtbx.scaling.xtriage.xtriage_analyses(
          miller_obs=obs,
          miller_calc=f_model,
          unmerged_obs=unmerged_data, # XXX some redundancy here...
          text_out=null_out())
    if (fmodel_neutron is not None) and (flags.rfactors):
      self.neutron_stats = experimental.data_statistics(fmodel_neutron,
        n_bins=n_bins_data,
        count_anomalous_pairs_separately=False)
    if (pdb_hierarchy.models_size() == 1):
      self._multi_criterion = multi_criterion_view(pdb_hierarchy)

    # wilson B
    self.wilson_b = None
    if (fmodel is not None):
      self.wilson_b = fmodel.wilson_b()
    elif (fmodel_neutron is not None):
      self.wilson_b = fmodel_neutron.wilson_b()

    # validate hydrogens
    self.hydrogens = None
    if self.model is not None and self.model.has_hd():
      # import here to avoid circular import issues
      from mmtbx.hydrogens.validate_H import validate_H, validate_H_results
      hydrogens = validate_H(model, nuclear)
      hydrogens.validate_inputs()
      hydrogens.run()
      self.hydrogens = validate_H_results(hydrogens.get_results())

    # write probe file if needed (CLI and GUI)
    if (save_probe_unformatted_file is not None):
      pcm = self.clashes.probe_clashscore_manager
      try:
        with open(save_probe_unformatted_file, 'w') as f:
          f.write(pcm.probe_unformatted)
        self.clashes.probe_file = save_probe_unformatted_file
      except IOError as err:
        raise Sorry('%s could not be written correctly.\n%s' %
                    (save_probe_unformatted_file, err))
コード例 #9
0
def exercise_1():
    pdb_raw = """\
ATOM   1134  N   LYS A  82       5.933  36.285  21.572  1.00 70.94           N
ATOM   1135  CA  LYS A  82       6.564  37.423  20.931  1.00 76.69           C
ATOM   1136  C   LYS A  82       5.553  38.547  20.756  1.00 78.75           C
ATOM   1137  O   LYS A  82       5.325  39.038  19.654  1.00 86.47           O
ATOM   1138  CB  LYS A  82       7.179  37.024  19.583  1.00 82.32           C
ATOM   1139  CG  LYS A  82       8.190  38.035  19.048  0.00 70.34           C
ATOM   1140  CD  LYS A  82       9.429  38.129  19.944  0.00 67.69           C
ATOM   1141  CE  LYS A  82       9.983  39.545  20.014  0.00 64.44           C
ATOM   1142  NZ  LYS A  82      10.933  39.832  18.908  0.00 61.45           N
ATOM   1143  H   LYS A  82       5.139  36.115  21.291  1.00 85.12           H
ATOM   1144  HA  LYS A  82       7.279  37.749  21.501  1.00 92.03           H
ATOM   1145  HB2 LYS A  82       6.469  36.939  18.928  1.00 98.78           H
ATOM   1146  HB3 LYS A  82       7.636  36.175  19.687  1.00 98.78           H
ATOM   1147  HG2 LYS A  82       8.476  37.762  18.163  0.00 84.41           H
ATOM   1148  HG3 LYS A  82       7.775  38.912  19.011  0.00 84.41           H
ATOM   1149  HD2 LYS A  82       9.193  37.853  20.843  0.00 81.23           H
ATOM   1150  HD3 LYS A  82      10.122  37.551  19.589  0.00 81.23           H
ATOM   1151  HE2 LYS A  82       9.249  40.177  19.952  0.00 77.33           H
ATOM   1152  HE3 LYS A  82      10.453  39.662  20.854  0.00 77.33           H
ATOM   1153  HZ1 LYS A  82      11.237  40.666  18.977  0.00 73.75           H
ATOM   1154  HZ2 LYS A  82      10.523  39.738  18.123  0.00 73.75           H
ATOM   1155  HZ3 LYS A  82      11.621  39.269  18.944  0.00 73.75           H
ATOM   1156  N   LYS A  83       4.936  38.927  21.866  1.00 75.79           N
ATOM   1157  CA  LYS A  83       4.177  40.172  21.966  1.00 82.80           C
ATOM   1158  C   LYS A  83       4.081  40.508  23.460  1.00 86.23           C
ATOM   1159  O   LYS A  83       2.978  40.521  24.017  1.00 79.81           O
ATOM   1160  CB  LYS A  83       2.790  40.044  21.332  1.00 79.16           C
ATOM   1161  CG  LYS A  83       2.038  41.342  21.175  0.00 70.42           C
ATOM   1162  CD  LYS A  83       2.072  41.803  19.735  0.00 66.90           C
ATOM   1163  CE  LYS A  83       1.295  43.089  19.552  0.00 62.46           C
ATOM   1164  NZ  LYS A  83       1.004  43.350  18.118  0.00 60.73           N
ATOM   1165  H   LYS A  83       4.940  38.470  22.594  1.00 90.95           H
ATOM   1166  HA  LYS A  83       4.658  40.885  21.518  1.00 99.36           H
ATOM   1167  HB2 LYS A  83       2.251  39.459  21.887  1.00 95.00           H
ATOM   1168  HB3 LYS A  83       2.890  39.655  20.449  1.00 95.00           H
ATOM   1169  HG2 LYS A  83       1.113  41.213  21.435  0.00 84.51           H
ATOM   1170  HG3 LYS A  83       2.453  42.024  21.726  0.00 84.51           H
ATOM   1171  HD2 LYS A  83       2.992  41.962  19.471  0.00 80.28           H
ATOM   1172  HD3 LYS A  83       1.672  41.123  19.171  0.00 80.28           H
ATOM   1173  HE2 LYS A  83       0.452  43.024  20.027  0.00 74.95           H
ATOM   1174  HE3 LYS A  83       1.818  43.830  19.896  0.00 74.95           H
ATOM   1175  HZ1 LYS A  83       0.521  42.683  17.780  0.00 72.87           H
ATOM   1176  HZ2 LYS A  83       1.764  43.417  17.661  0.00 72.87           H
ATOM   1177  HZ3 LYS A  83       0.548  44.109  18.034  0.00 72.87           H
ATOM   3630  N   ASN A 242      -5.454  -3.027   1.145  0.00 67.69           N
ATOM   3631  CA  ASN A 242      -4.759  -2.535  -0.037  0.00 65.44           C
ATOM   3632  C   ASN A 242      -5.734  -2.397  -1.208  0.00 63.57           C
ATOM   3633  O   ASN A 242      -6.425  -3.357  -1.552  0.00 63.94           O
ATOM   3634  CB  ASN A 242      -3.626  -3.503  -0.392  0.00 63.13           C
ATOM   3635  CG  ASN A 242      -2.802  -3.044  -1.576  0.00 63.58           C
ATOM   3636  OD1 ASN A 242      -2.524  -1.862  -1.731  0.00 65.52           O
ATOM   3637  ND2 ASN A 242      -2.399  -3.988  -2.416  0.00 62.17           N
ATOM   3638  H   ASN A 242      -5.562  -3.880   1.129  0.00 81.22           H
ATOM   3639  HA  ASN A 242      -4.375  -1.665   0.151  0.00 78.53           H
ATOM   3640  HB2 ASN A 242      -3.032  -3.587   0.370  0.00 75.76           H
ATOM   3641  HB3 ASN A 242      -4.007  -4.368  -0.611  0.00 75.76           H
ATOM   3642 HD21 ASN A 242      -1.929  -3.779  -3.104  0.00 74.60           H
ATOM   3643 HD22 ASN A 242      -2.609  -4.810  -2.272  0.00 74.60           H
ATOM      2  CA ALYS A  32      10.574   8.177  11.768  0.40 71.49           C
ATOM      3  CB ALYS A  32       9.197   8.686  12.246  0.40 74.71           C
ATOM      2  CA BLYS A  32      10.574   8.177  11.768  0.40 71.49           C
ATOM      3  CB BLYS A  32       9.197   8.686  12.246  0.40 74.71           C
ATOM      5  CA AVAL A  33      11.708   5.617  14.332  0.50 71.42           C
ATOM      6  CB AVAL A  33      11.101   4.227  14.591  0.50 71.47           C
ATOM      5  CA BVAL A  33      11.708   5.617  14.332  0.40 71.42           C
ATOM      6  CB BVAL A  33      11.101   4.227  14.591  0.40 71.47           C
TER
ATOM      1  N   GLU X  18     -13.959  12.159  -6.598  1.00260.08           N
ATOM      2  CA  GLU X  18     -13.297  13.465  -6.628  1.00269.83           C
ATOM      3  C   GLU X  18     -11.946  13.282  -7.309  1.00269.18           C
ATOM      4  CB  GLU X  18     -13.128  14.035  -5.210  1.00261.96           C
ATOM      5  CG  GLU X  18     -14.455  14.401  -4.522  1.00263.56           C
ATOM      6  CD  GLU X  18     -14.291  15.239  -3.242  1.00264.89           C
ATOM      7  OE1 GLU X  18     -14.172  14.646  -2.143  1.00264.24           O
ATOM      8  OE2 GLU X  18     -14.309  16.498  -3.306  1.00264.37           O1-
HETATM  614  S   SO4 B 101      14.994  20.601  10.862  0.00  7.02           S
HETATM  615  O1  SO4 B 101      14.234  20.194  12.077  0.00  7.69           O
HETATM  616  O2  SO4 B 101      14.048  21.062   9.850  0.00  9.28           O
HETATM  617  O3  SO4 B 101      15.905  21.686  11.261  0.00  8.01           O
HETATM  618  O4  SO4 B 101      15.772  19.454  10.371  0.00  8.18           O
TER
HETATM  122  O   HOH S   1       5.334   8.357   8.032  1.00  0.00           O
HETATM  123  O   HOH S   2       5.396  15.243  10.734  1.00202.95           O
HETATM  124  O   HOH S   3     -25.334  18.357  18.032  0.00 20.00           O
"""
    mon_lib_srv = server.server()
    ener_lib = server.ener_lib()
    pdb_in = iotbx.pdb.hierarchy.input(pdb_string=pdb_raw)
    xrs = pdb_in.input.xray_structure_simple()
    processed_pdb_file = pdb_interpretation.process(
        mon_lib_srv=mon_lib_srv,
        ener_lib=ener_lib,
        raw_records=pdb_in.hierarchy.as_pdb_string(crystal_symmetry=xrs),
        crystal_symmetry=xrs,
        log=null_out())
    pdb_in.hierarchy.atoms().reset_i_seq()
    mstats = model_properties.model_statistics(
        pdb_hierarchy=pdb_in.hierarchy,
        xray_structure=xrs,
        all_chain_proxies=processed_pdb_file.all_chain_proxies,
        ignore_hd=True)
    out = StringIO()
    mstats.show(out=out)
    #print out.getvalue()
    assert not show_diff(
        out.getvalue(), """\
Overall:
  Number of atoms = 50  (anisotropic = 0)
  B_iso: mean =  96.0  max = 269.8  min =   0.0
  Occupancy: mean = 0.47  max = 1.00  min = 0.00
    warning: 22 atoms with zero occupancy
  69 total B-factor or occupancy problem(s) detected
  Atoms or residues with zero occupancy:
   LYS A  82   CG    occ=0.00
   LYS A  82   CD    occ=0.00
   LYS A  82   CE    occ=0.00
   LYS A  82   NZ    occ=0.00
   LYS A  83   CG    occ=0.00
   LYS A  83   CD    occ=0.00
   LYS A  83   CE    occ=0.00
   LYS A  83   NZ    occ=0.00
   ASN A 242  (all)  occ=0.00
   SO4 B 101  (all)  occ=0.00
   HOH S   3   O     occ=0.00
Macromolecules:
  Number of atoms = 42  (anisotropic = 0)
  B_iso: mean = 108.0  max = 269.8  min =  60.7
  Occupancy: mean = 0.51  max = 1.00  min = 0.00
    warning: 16 atoms with zero occupancy
  59 total B-factor or occupancy problem(s) detected
Ligands:
  Number of atoms = 5  (anisotropic = 0)
  B_iso: mean =   8.0  max =   9.3  min =   7.0
  Occupancy: mean = 0.00  max = 0.00  min = 0.00
    warning: 5 atoms with zero occupancy
  6 total B-factor or occupancy problem(s) detected
Waters:
  Number of atoms = 3  (anisotropic = 0)
  B_iso: mean =  74.3  max = 202.9  min =   0.0
  Occupancy: mean = 0.67  max = 1.00  min = 0.00
    warning: 1 atoms with zero occupancy
  4 total B-factor or occupancy problem(s) detected
(Hydrogen atoms not included in overall counts.)
""")
    assert (len(mstats.all.bad_adps) == 1)
    assert (mstats.all.n_zero_b == 1)
    mstats2 = loads(dumps(mstats))
    out1 = StringIO()
    out2 = StringIO()
    mstats.show(out=out1)
    mstats2.show(out=out2)
    assert (out1.getvalue() == out2.getvalue())
    # now with ignore_hd=False
    mstats3 = model_properties.model_statistics(
        pdb_hierarchy=pdb_in.hierarchy,
        xray_structure=xrs,
        all_chain_proxies=processed_pdb_file.all_chain_proxies,
        ignore_hd=False)
    out2 = StringIO()
    mstats3.show(out=out2)
    assert (out2.getvalue() != out.getvalue())
    assert ("""   LYS A  83   HZ3   occ=0.00""" in out2.getvalue())
    outliers = mstats3.all.as_gui_table_data(include_zoom=True)
    assert (len(outliers) == 86)
    # test with all_chain_proxies undefined
    mstats4 = model_properties.model_statistics(pdb_hierarchy=pdb_in.hierarchy,
                                                xray_structure=xrs,
                                                all_chain_proxies=None,
                                                ignore_hd=False)
    outliers = mstats4.all.as_gui_table_data(include_zoom=True)
    assert (len(outliers) == 86)