Beispiel #1
0
 def molprobity_score(self):
     """
 Compute overall measure of (protein!) structure quality based on an
 empirical formula combining clashscore, rotamer outliers, and Ramachandran
 favored statistics.  The result is on approximately the same scale as
 resolution.
 """
     if (None in [self.ramalyze, self.rotalyze, self.clashes]):
         return None
     from mmtbx.validation import utils
     return utils.molprobity_score(clashscore=self.clashes.get_clashscore(),
                                   rota_out=self.rotalyze.out_percent,
                                   rama_fav=self.ramalyze.fav_percent)
 def molprobity_score (self) :
   """
   Compute overall measure of (protein!) structure quality based on an
   empirical formula combining clashscore, rotamer outliers, and Ramachandran
   favored statistics.  The result is on approximately the same scale as
   resolution.
   """
   if (None in [self.ramalyze, self.rotalyze, self.clashes]) :
     return None
   from mmtbx.validation import utils
   return utils.molprobity_score(
     clashscore=self.clashes.get_clashscore(),
     rota_out=self.rotalyze.out_percent,
     rama_fav=self.ramalyze.fav_percent)
 def __init__(
     self,
     pdb_hierarchy,
     molprobity_scores=False,
     ):
   self.pdb_hierarchy = pdb_hierarchy
   self.clashscore            = None
   self.ramachandran_outliers = None
   self.ramachandran_allowed  = None
   self.ramachandran_favored  = None
   self.rotamer_outliers      = None
   self.c_beta_dev            = None
   self.mpscore               = None
   self.omglz = None
   self.n_cis_proline = None
   self.n_cis_general = None
   self.n_twisted_proline = None
   self.n_twisted_general = None
   if(molprobity_scores):
     self.ramalyze_obj = ramalyze(pdb_hierarchy=pdb_hierarchy, outliers_only=False)
     self.ramachandran_outliers = self.ramalyze_obj.percent_outliers
     self.ramachandran_allowed  = self.ramalyze_obj.percent_allowed
     self.ramachandran_favored  = self.ramalyze_obj.percent_favored
     self.rotalyze_obj = rotalyze(pdb_hierarchy=pdb_hierarchy, outliers_only=False)
     self.rotamer_outliers = self.rotalyze_obj.percent_outliers
     self.cbetadev_obj = cbetadev(
       pdb_hierarchy = pdb_hierarchy,
       outliers_only = True,
       out           = null_out())
     self.c_beta_dev = self.cbetadev_obj.get_outlier_count()
     self.clashscore = clashscore(pdb_hierarchy=pdb_hierarchy).get_clashscore()
     self.mpscore = molprobity_score(
       clashscore = self.clashscore,
       rota_out   = self.rotamer_outliers,
       rama_fav   = self.ramachandran_favored)
     self.omglz = omegalyze.omegalyze(
       pdb_hierarchy=self.pdb_hierarchy, quiet=True)
     self.n_cis_proline = self.omglz.n_cis_proline()
     self.n_cis_general = self.omglz.n_cis_general()
     self.n_twisted_proline = self.omglz.n_twisted_proline()
     self.n_twisted_general = self.omglz.n_twisted_general()
 def __init__(
     self,
     pdb_hierarchy,
     molprobity_scores=False,
     ):
   self.pdb_hierarchy = pdb_hierarchy
   self.clashscore            = None
   self.ramachandran_outliers = None
   self.ramachandran_allowed  = None
   self.ramachandran_favored  = None
   self.rotamer_outliers      = None
   self.c_beta_dev            = None
   self.mpscore               = None
   self.omglz = None
   self.n_cis_proline = None
   self.n_cis_general = None
   self.n_twisted_proline = None
   self.n_twisted_general = None
   if(molprobity_scores):
     self.ramalyze_obj = ramalyze(pdb_hierarchy=pdb_hierarchy, outliers_only=False)
     self.ramachandran_outliers = self.ramalyze_obj.percent_outliers
     self.ramachandran_allowed  = self.ramalyze_obj.percent_allowed
     self.ramachandran_favored  = self.ramalyze_obj.percent_favored
     self.rotalyze_obj = rotalyze(pdb_hierarchy=pdb_hierarchy, outliers_only=False)
     self.rotamer_outliers = self.rotalyze_obj.percent_outliers
     self.cbetadev_obj = cbetadev(
       pdb_hierarchy = pdb_hierarchy,
       outliers_only = True,
       out           = null_out())
     self.c_beta_dev = self.cbetadev_obj.get_outlier_count()
     self.clashscore = clashscore(pdb_hierarchy=pdb_hierarchy).get_clashscore()
     self.mpscore = molprobity_score(
       clashscore = self.clashscore,
       rota_out   = self.rotamer_outliers,
       rama_fav   = self.ramachandran_favored)
     self.omglz = omegalyze.omegalyze(
       pdb_hierarchy=self.pdb_hierarchy, quiet=True)
     self.n_cis_proline = self.omglz.n_cis_proline()
     self.n_cis_general = self.omglz.n_cis_general()
     self.n_twisted_proline = self.omglz.n_twisted_proline()
     self.n_twisted_general = self.omglz.n_twisted_general()
Beispiel #5
0
 def mp_score(self):
   return molprobity_score(
     clashscore = self.clash().score,
     rota_out   = self.rotamer().outliers,
     rama_fav   = self.ramachandran().favored)
Beispiel #6
0
def get_model_stat(file_name):
    pdb_inp = iotbx.pdb.input(file_name=file_name)
    atoms = pdb_inp.atoms()
    box = uctbx.non_crystallographic_unit_cell_with_the_sites_in_its_center(
        sites_cart=atoms.extract_xyz(), buffer_layer=5)
    atoms.set_xyz(new_xyz=box.sites_cart)
    ph = pdb_inp.construct_hierarchy()
    if (all_single_atom_residues(ph=ph)): return None
    raw_recs = ph.as_pdb_string(
        crystal_symmetry=box.crystal_symmetry()).splitlines()
    #
    params = monomer_library.pdb_interpretation.master_params.extract()
    params.clash_guard.nonbonded_distance_threshold = None
    params.disable_uc_volume_vs_n_atoms_check = False
    params.use_neutron_distances = True
    params.restraints_library.cdl = False
    processed_pdb_file = monomer_library.pdb_interpretation.process(
        mon_lib_srv=mon_lib_srv,
        ener_lib=ener_lib,
        raw_records=raw_recs,
        params=params,
        log=null_out())
    xrs = processed_pdb_file.xray_structure()
    sctr_keys = xrs.scattering_type_registry().type_count_dict().keys()
    has_hd = "H" in sctr_keys or "D" in sctr_keys
    restraints_manager = processed_pdb_file.geometry_restraints_manager(
        show_energies=False,
        assume_hydrogens_all_missing=not has_hd,
        plain_pairs_radius=5.0)
    a_mean, b_mean = get_bonds_angles_rmsd(
        restraints_manager=restraints_manager, xrs=xrs)
    energies_sites = \
      restraints_manager.energies_sites(
        sites_cart        = xrs.sites_cart(),
        compute_gradients = False)
    nonbonded_distances = energies_sites.nonbonded_distances()
    number_of_worst_clashes = (nonbonded_distances < 0.5).count(True)
    #
    ramalyze_obj = ramalyze(pdb_hierarchy=ph, outliers_only=False)
    ramachandran_outliers = ramalyze_obj.percent_outliers
    rotamer_outliers = rotalyze(pdb_hierarchy=ph,
                                outliers_only=False).percent_outliers
    c_beta_dev = cbetadev(pdb_hierarchy=ph, outliers_only=True,
                          out=null_out()).get_outlier_count()
    omglz = omegalyze.omegalyze(pdb_hierarchy=ph, quiet=True)
    n_cis_proline = omglz.n_cis_proline()
    n_cis_general = omglz.n_cis_general()
    n_twisted_proline = omglz.n_twisted_proline()
    n_twisted_general = omglz.n_twisted_general()
    #
    clsc = clashscore(pdb_hierarchy=ph).get_clashscore()
    mpscore = molprobity_score(clashscore=clsc,
                               rota_out=rotamer_outliers,
                               rama_fav=ramalyze_obj.percent_favored)
    #
    occ = atoms.extract_occ()
    bs = atoms.extract_b()
    #
    return group_args(b_mean=b_mean,
                      a_mean=a_mean,
                      number_of_worst_clashes=number_of_worst_clashes,
                      ramachandran_outliers=ramachandran_outliers,
                      rotamer_outliers=rotamer_outliers,
                      c_beta_dev=c_beta_dev,
                      n_cis_proline=n_cis_proline,
                      n_cis_general=n_cis_general,
                      n_twisted_proline=n_twisted_proline,
                      n_twisted_general=n_twisted_general,
                      o=occ.min_max_mean().as_tuple(),
                      b=bs.min_max_mean().as_tuple(),
                      mpscore=mpscore,
                      clsc=clsc,
                      n_atoms=atoms.size())
Beispiel #7
0
 def __init__(
     self,
     pdb_hierarchy,
     molprobity_scores=False,
     ):
   """ This class is being pickled. Try not to introduce huge members, e.g.
   self.hierarchy, etc. This is the reason ramalyze_obj, rotalyze_obj etc
   are not members of the class (not self.ramalyze_obj). """
   self.clashscore            = None
   self.ramachandran_outliers = None
   self.ramachandran_allowed  = None
   self.ramachandran_favored  = None
   self.rotamer_outliers      = None
   self.c_beta_dev            = None
   self.mpscore               = None
   self.omglz = None
   self.n_cis_proline = None
   self.n_cis_general = None
   self.n_twisted_proline = None
   self.n_twisted_general = None
   if(molprobity_scores):
     ramalyze_obj = ramalyze(pdb_hierarchy=pdb_hierarchy, outliers_only=False)
     self.ramachandran_outliers = ramalyze_obj.percent_outliers
     self.ramachandran_outliers_cf = ramalyze_obj.get_outliers_count_and_fraction()
     self.ramachandran_allowed  = ramalyze_obj.percent_allowed
     self.ramachandran_allowed_cf  = ramalyze_obj.get_allowed_count_and_fraction()
     self.ramachandran_favored  = ramalyze_obj.percent_favored
     self.ramachandran_favored_cf  = ramalyze_obj.get_favored_count_and_fraction()
     rotalyze_obj = rotalyze(pdb_hierarchy=pdb_hierarchy, outliers_only=False)
     self.rotamer_outliers = rotalyze_obj.percent_outliers
     self.rotamer_cf = rotalyze_obj.get_outliers_count_and_fraction()
     cbetadev_obj = cbetadev(
       pdb_hierarchy = pdb_hierarchy,
       outliers_only = True,
       out           = null_out())
     self.c_beta_dev = cbetadev_obj.get_outlier_count()
     self.c_beta_dev_percent = cbetadev_obj.get_weighted_outlier_percent()
     self.clashscore = clashscore(pdb_hierarchy=pdb_hierarchy).get_clashscore()
     self.mpscore = molprobity_score(
       clashscore = self.clashscore,
       rota_out   = self.rotamer_outliers,
       rama_fav   = self.ramachandran_favored)
     omglz = omegalyze.omegalyze(
       pdb_hierarchy=pdb_hierarchy, quiet=True)
     self.n_proline = omglz.n_proline()
     self.n_general = omglz.n_general()
     self.n_cis_proline = omglz.n_cis_proline()
     self.n_cis_general = omglz.n_cis_general()
     self.n_twisted_proline = omglz.n_twisted_proline()
     self.n_twisted_general = omglz.n_twisted_general()
     self.cis_general = 0
     self.twisted_general = 0
     self.cis_proline = 0
     self.twisted_proline = 0
     if self.n_proline != 0:
       self.cis_proline = self.n_cis_proline*100./self.n_proline
       self.twisted_proline = self.n_twisted_proline*100./self.n_proline
     if self.n_general != 0:
       self.cis_general = self.n_cis_general*100./self.n_general
       self.twisted_general = self.n_twisted_general*100./self.n_general
     self.cablam_outliers=None
     self.cablam_disfavored=None
     self.cablam_ca_outliers=None
     try:
       cablam_results = cablam.cablamalyze(pdb_hierarchy, outliers_only=False,
         out=null_out(), quiet=True)
       self.cablam_outliers = cablam_results.percent_outliers()
       self.cablam_disfavored = cablam_results.percent_disfavored()
       self.cablam_ca_outliers = cablam_results.percent_ca_outliers()
     except Exception as e:
       print "CaBLAM failed with exception:"
       print "  %s" % str(e)
       pass
  def __init__(
        self,
        pdb_hierarchy,
        restraints_manager,
        molprobity_scores=False,
        n_histogram_slots=10,
        cdl_restraints=False,
        ignore_hydrogens=False,  #only used by amber
        ):
    self.cdl_restraints=cdl_restraints
    sites_cart = pdb_hierarchy.atoms().extract_xyz()
    energies_sites = \
      restraints_manager.energies_sites(
        sites_cart        = sites_cart,
        compute_gradients = False)
    # molprobity scores
    self.clashscore            = None
    self.ramachandran_outliers = None
    self.ramachandran_allowed  = None
    self.ramachandran_favored  = None
    self.rotamer_outliers      = None
    self.c_beta_dev            = None
    self.mpscore               = None
    if(molprobity_scores):
      self.ramalyze_obj = ramalyze(pdb_hierarchy=pdb_hierarchy, outliers_only=False)
      self.ramachandran_outliers = self.ramalyze_obj.percent_outliers
      self.ramachandran_allowed  = self.ramalyze_obj.percent_allowed
      self.ramachandran_favored  = self.ramalyze_obj.percent_favored
      self.rotalyze_obj = rotalyze(pdb_hierarchy=pdb_hierarchy, outliers_only=False)
      self.rotamer_outliers = self.rotalyze_obj.percent_outliers
      self.cbetadev_obj = cbetadev(
        pdb_hierarchy = pdb_hierarchy,
        outliers_only = True,
        out           = null_out())
      self.c_beta_dev = self.cbetadev_obj.get_outlier_count()
      self.clashscore = clashscore(pdb_hierarchy=pdb_hierarchy).get_clashscore()
      self.mpscore = molprobity_score(
        clashscore = self.clashscore,
        rota_out   = self.rotamer_outliers,
        rama_fav   = self.ramachandran_favored)
    #
    if(hasattr(energies_sites, "geometry")):
      esg = energies_sites.geometry
    else: esg = energies_sites
    self.a = None
    self.b = None
    if not hasattr(esg, "angle_deviations"): return
    if hasattr(esg, "amber"):
      amber_parm = restraints_manager.amber_structs.parm
      self.a, angle_deltas = esg.angle_deviations(sites_cart, amber_parm,
                                        ignore_hd=ignore_hydrogens,
                                        get_deltas=True)
      self.b, bond_deltas = esg.bond_deviations(sites_cart, amber_parm,
                                        ignore_hd=ignore_hydrogens,
                                        get_deltas=True)
      self.a_number = esg.n_angle_proxies(amber_parm,
                                          ignore_hd=ignore_hydrogens)
      self.b_number = esg.n_bond_proxies(amber_parm,
                                         ignore_hd=ignore_hydrogens)
      self.c, self.p, self.ll, self.d, self.n = None, None, None, None, None
      self.c_number=0
      self.p_number=0
      self.d_number=0

      self.bond_deltas_histogram = \
        flex.histogram(data = flex.abs(bond_deltas), n_slots = n_histogram_slots)
      self.angle_deltas_histogram = \
        flex.histogram(data = flex.abs(angle_deltas), n_slots = n_histogram_slots)
      # nonbonded_distances = esg.nonbonded_distances()
      # self.nonbonded_distances_histogram = flex.histogram(
      #   data = flex.abs(nonbonded_distances), n_slots = n_histogram_slots)
      for restraint_type in ["b", "a", "c", "p", "ll", "d", "n"] :
        for value_type in [("mean",2), ("max",1), ("min",0)] :
          name = "%s_%s" % (restraint_type, value_type[0])
          if getattr(self, restraint_type) is None:
            setattr(self, name, None)
            continue
          setattr(self, name, getattr(self, restraint_type)[value_type[1]])
      return
    self.a = esg.angle_deviations()
    self.b = esg.bond_deviations()
    self.a_number = esg.get_filtered_n_angle_proxies()
    self.b_number = esg.get_filtered_n_bond_proxies()
    self.c = esg.chirality_deviations()
    self.d = esg.dihedral_deviations()
    self.p = esg.planarity_deviations()
    self.ll = esg.parallelity_deviations()
    self.n = esg.nonbonded_deviations()
    self.c_number = esg.n_chirality_proxies
    self.d_number = esg.n_dihedral_proxies
    self.p_number = esg.n_planarity_proxies
    self.n_number = esg.n_nonbonded_proxies
    #
    for restraint_type in ["b", "a", "c", "p", "ll", "d", "n"] :
      for value_type in [("mean",2), ("max",1), ("min",0)] :
        name = "%s_%s" % (restraint_type, value_type[0])
        if getattr(self, restraint_type) is None: continue
        setattr(self, name, getattr(self, restraint_type)[value_type[1]])
    #
    if(hasattr(restraints_manager, "geometry")):
      rmg = restraints_manager.geometry
    else: rmg = restraints_manager
    bond_deltas = geometry_restraints.bond_deltas(
      sites_cart         = sites_cart,
      sorted_asu_proxies = rmg.pair_proxies().bond_proxies)
    angle_deltas = geometry_restraints.angle_deltas(
      sites_cart = sites_cart,
      proxies    = rmg.angle_proxies)
    nonbonded_distances = esg.nonbonded_distances()
    self.bond_deltas_histogram = \
      flex.histogram(data = flex.abs(bond_deltas), n_slots = n_histogram_slots)
    self.angle_deltas_histogram = \
      flex.histogram(data = flex.abs(angle_deltas), n_slots = n_histogram_slots)
    self.nonbonded_distances_histogram = flex.histogram(
      data = flex.abs(nonbonded_distances), n_slots = n_histogram_slots)
    #
    assert approx_equal(
      esg.target,
      esg.angle_residual_sum+
      esg.bond_residual_sum+
      esg.chirality_residual_sum+
      esg.dihedral_residual_sum+
      esg.nonbonded_residual_sum+
      esg.planarity_residual_sum+
      esg.parallelity_residual_sum+
      esg.reference_coordinate_residual_sum+
      esg.reference_dihedral_residual_sum+
      esg.ncs_dihedral_residual_sum+
      esg.den_residual_sum+
      esg.ramachandran_residual_sum)
    del energies_sites, esg # we accumulate this object, so make it clean asap