Exemple #1
0
 def __init__(self,
              pdb_hierarchy,
              geometry_restraints_manager,
              outliers_only=True):
     rna_geometry.__init__(self)
     self.n_triaged = self.n_incomplete = self.n_suites = 0
     self.average_suiteness = None
     total_suiteness = 0
     suitename = "phenix.suitename -report -pointIDfields 7 -altIDfield 6  -"
     backbone_dihedrals = utils.get_rna_backbone_dihedrals(
         processed_pdb_file=None,
         pdb_hierarchy=pdb_hierarchy,
         geometry=geometry_restraints_manager)
     suitename_out = easy_run.fully_buffered(
         suitename, stdin_lines=backbone_dihedrals).stdout_lines
     for line in suitename_out:
         if line.startswith(' :'):
             temp = line.split(":")
             altloc = temp[5]
             chain_id = temp[2]
             resname = temp[6][0:3]
             resseq = temp[3]
             icode = temp[4]
             key = temp[5] + temp[6][0:3] + temp[2] + temp[3] + temp[
                 4]  # ewwwww....
             suite = temp[6][9:11]
             suiteness = temp[6][12:17]
             temp2 = temp[6].split(" ")
             triaged_angle = None
             is_outlier = False
             self.n_total += 1
             if ('!!' in line):
                 if (temp2[3] == 'trig'):
                     triaged_angle = temp2[6]
                     self.n_triaged += 1
                 is_outlier = True
                 self.n_outliers += 1
             if (is_outlier or not outliers_only):
                 self.results.append(
                     rna_suite(altloc=temp[5],
                               chain_id=temp[2],
                               resname=temp[6][0:3],
                               resseq=temp[3],
                               icode=temp[4],
                               suite=temp[6][9:11],
                               suite_id=key,
                               suiteness=suiteness,
                               triaged_angle=triaged_angle,
                               outlier=is_outlier))
             if (triaged_angle is None):
                 try:
                     total_suiteness += float(suiteness)
                     self.n_suites += 1
                 except ValueError:
                     self.n_incomplete += 1
     if (self.n_suites > 0):
         self.average_suiteness = total_suiteness / self.n_suites
 def __init__ (self, pdb_hierarchy, geometry_restraints_manager,
     outliers_only=True) :
   rna_geometry.__init__(self)
   self.n_triaged = self.n_incomplete = self.n_suites = 0
   self.average_suiteness = None
   total_suiteness = 0
   suitename = "phenix.suitename -report -pointIDfields 7 -altIDfield 6  -"
   backbone_dihedrals = utils.get_rna_backbone_dihedrals(
     processed_pdb_file=None,
     pdb_hierarchy=pdb_hierarchy,
     geometry=geometry_restraints_manager)
   suitename_out = easy_run.fully_buffered(suitename,
                        stdin_lines=backbone_dihedrals).stdout_lines
   for line in suitename_out:
     if line.startswith(' :'):
       temp = line.split(":")
       altloc = temp[5]
       chain_id = temp[2]
       resname = temp[6][0:3]
       resseq = temp[3]
       icode = temp[4]
       key = temp[5]+temp[6][0:3]+temp[2]+temp[3]+temp[4] # ewwwww....
       suite = temp[6][9:11]
       suiteness = temp[6][12:17]
       temp2 = temp[6].split(" ")
       triaged_angle = None
       is_outlier = False
       self.n_total += 1
       if ('!!' in line) :
         if (temp2[3] == 'trig'):
           triaged_angle = temp2[6]
           self.n_triaged += 1
         is_outlier = True
         self.n_outliers += 1
       if (is_outlier or not outliers_only) :
         self.results.append(rna_suite(
           altloc = temp[5],
           chain_id = temp[2],
           resname = temp[6][0:3],
           resseq = temp[3],
           icode = temp[4],
           suite = temp[6][9:11],
           suite_id = key,
           suiteness = suiteness,
           triaged_angle=triaged_angle,
           outlier=is_outlier))
       if (triaged_angle is None) :
         try :
           total_suiteness += float(suiteness)
           self.n_suites += 1
         except ValueError :
           self.n_incomplete += 1
   if (self.n_suites > 0) :
     self.average_suiteness = total_suiteness / self.n_suites
Exemple #3
0
def run(args):
    """
  I suggest adding here:
  cctbx_project/mmtbx/validation/regression/tst_mp_geo.py
  test cases with just .pdb, without arguments, etc.
  """
    master_phil = get_master_phil()
    import iotbx.phil
    input_objects = iotbx.phil.process_command_line_with_files(
        args=args, master_phil=master_phil, pdb_file_def="mp_geo.pdb")
    work_params = input_objects.work.extract()
    assert len(work_params.mp_geo.pdb) == 1, "Need a model file to run"
    file_name = work_params.mp_geo.pdb[0]
    out_file = None
    if work_params.mp_geo.out_file != None:
        out_file = work_params.mp_geo.out_file
    do_bonds_and_angles = work_params.mp_geo.bonds_and_angles
    do_kinemage = work_params.mp_geo.kinemage
    do_rna_backbone = work_params.mp_geo.rna_backbone
    outliers_only = work_params.mp_geo.outliers_only
    use_cdl = work_params.mp_geo.cdl
    log = StringIO()
    basename = os.path.basename(file_name)
    if out_file == None:
        import sys
        out = sys.stdout
    else:
        if do_bonds_and_angles:
            out = file(out_file, 'w')
        elif do_kinemage:
            out = file(out_file, 'a')
        elif do_rna_backbone:
            out = file(out_file, 'w')
    restraints_loading_flags = {}
    restraints_loading_flags["use_neutron_distances"] = False
    from mmtbx.validation import utils
    params = pdb_interpretation.master_params.extract()
    params.restraints_library.cdl = use_cdl
    params.clash_guard.nonbonded_distance_threshold = None
    processed_pdb_file = pdb_interpretation.process(
        params=params,
        mon_lib_srv=server.server(),
        ener_lib=server.ener_lib(),
        file_name=file_name,
        strict_conflict_handling=True,
        restraints_loading_flags=restraints_loading_flags,
        force_symmetry=True,
        substitute_non_crystallographic_unit_cell_if_necessary=True,
        log=log)
    grm = processed_pdb_file.geometry_restraints_manager()
    use_segids = utils.use_segids_in_place_of_chainids(
        hierarchy=processed_pdb_file.all_chain_proxies.pdb_hierarchy)
    if do_bonds_and_angles or do_kinemage:
        rc = get_bond_and_angle_outliers(
            pdb_hierarchy=processed_pdb_file.all_chain_proxies.pdb_hierarchy,
            xray_structure=processed_pdb_file.xray_structure(),
            geometry_restraints_manager=grm,
            use_segids=use_segids,
            outliers_only=outliers_only)
        #get chain types
        chain_types = {}
        for chain in processed_pdb_file.all_chain_proxies.\
                       pdb_hierarchy.models()[0].chains():
            if use_segids:
                chain_id = utils.get_segid_as_chainid(chain=chain)
            else:
                chain_id = chain.id
            main_conf = chain.conformers()[0]
            if chain_types.get(chain_id) not in ["NA", "PROTEIN"]:
                if (main_conf.is_na()):
                    chain_types[chain_id] = "NA"
                elif (main_conf.is_protein()):
                    chain_types[chain_id] = "PROTEIN"
                else:
                    chain_types[chain_id] = "UNK"
        outliers = []
        #bonds
        #for result in rc.bonds.results:
        for result in sorted(
                rc.bonds.results,
                key=lambda x:
            (x.atoms_info[0].resseq, get_altloc(atoms_info=x.atoms_info),
             get_atoms_str(atoms_info=x.atoms_info))):
            atom_info = result.atoms_info[0]
            # label:chain:number:ins:alt:type:measure:value:sigmas:class
            atoms_str = get_atoms_str(atoms_info=result.atoms_info)
            altloc = get_altloc(atoms_info=result.atoms_info)
            chain_id = atom_info.chain_id
            outliers.append([
                chain_id, atom_info.resseq, atom_info.icode, altloc,
                atom_info.resname, atoms_str, result.model, result.score,
                chain_types[atom_info.chain_id]
            ])
        #angles
        #for result in rc.angles.results:
        for result in sorted(
                rc.angles.results,
                key=lambda x:
            (x.atoms_info[0].resseq, get_altloc(atoms_info=x.atoms_info),
             get_atoms_str(atoms_info=x.atoms_info))):
            atom_info = result.atoms_info[0]
            # label:chain:number:ins:alt:type:measure:value:sigmas:class
            atoms_str = get_atoms_str(atoms_info=result.atoms_info)
            altloc = get_altloc(atoms_info=result.atoms_info)
            chain_id = atom_info.chain_id
            outliers.append([
                chain_id, atom_info.resseq, atom_info.icode, altloc,
                atom_info.resname, atoms_str, result.model, result.score,
                chain_types[atom_info.chain_id]
            ])

        if do_bonds_and_angles:
            for outlier in outliers:
                print >> out, "%s:%2s:%s:%s:%s:%s:%s:%.3f:%.3f:%s" % (
                    basename, outlier[0], outlier[1], outlier[2], outlier[3],
                    outlier[4], outlier[5], outlier[6], outlier[7], outlier[8])
        elif do_kinemage:
            print >> out, rc.bonds.kinemage_header
            for result in rc.bonds.results:
                print >> out, result.as_kinemage()
            print >> out, rc.angles.kinemage_header
            for result in rc.angles.results:
                print >> out, result.as_kinemage()
        out.close()
    elif do_rna_backbone:
        from mmtbx.validation import utils
        rna_bb = utils.get_rna_backbone_dihedrals(processed_pdb_file)
        print >> out, rna_bb
        if out_file is not None:
            out.close()