コード例 #1
0
ファイル: ramalyze.py プロジェクト: cctbx/cctbx-playground
def get_cas_from_three(three):
  cas = []
  for residue in three:
    for atom in residue.atoms():
      if atom.name == " CA ":
        cas.append(atom)
        break
    else:
      cas.append(None)
  return cas
コード例 #2
0
ファイル: cbetadev.py プロジェクト: cctbx/cctbx-playground
 def __init__ (self, pdb_hierarchy,
     outliers_only=False,
     out=sys.stdout,
     collect_ideal=False,
     quiet=False) :
   validation.__init__(self)
   self._outlier_i_seqs = flex.size_t()
   self.beta_ideal = {}
   relevant_atom_names = {
     " CA ": None, " N  ": None, " C  ": None, " CB ": None} # FUTURE: set
   output_list = []
   from mmtbx.validation import utils
   use_segids = utils.use_segids_in_place_of_chainids(
     hierarchy=pdb_hierarchy)
   for model in pdb_hierarchy.models():
     for chain in model.chains():
       if use_segids:
         chain_id = utils.get_segid_as_chainid(chain=chain)
       else:
         chain_id = chain.id
       for rg in chain.residue_groups():
         for i_cf,cf in enumerate(rg.conformers()):
           for i_residue,residue in enumerate(cf.residues()):
             if (residue.resname == "GLY") :
               continue
             is_first = (i_cf == 0)
             is_alt_conf = False
             relevant_atoms = {}
             for atom in residue.atoms():
               if (atom.name in relevant_atom_names):
                 relevant_atoms[atom.name] = atom
                 if (len(atom.parent().altloc) != 0):
                   is_alt_conf = True
             if ((is_first or is_alt_conf) and len(relevant_atoms) == 4):
               result = calculate_ideal_and_deviation(
                 relevant_atoms=relevant_atoms,
                 resname=residue.resname)
               dev = result.deviation
               dihedralNABB = result.dihedral
               betaxyz = result.ideal
               if (dev is None) : continue
               if(dev >=0.25 or outliers_only==False):
                 if(dev >=0.25):
                   self.n_outliers+=1
                   self._outlier_i_seqs.append(atom.i_seq)
                 if (is_alt_conf):
                   altchar = cf.altloc
                 else:
                   altchar = " "
                 res=residue.resname.lower()
                 sub=chain.id
                 if(len(sub)==1):
                   sub=" "+sub
                 resCB = relevant_atoms[" CB "]
                 result = cbeta(
                   chain_id=chain_id,
                   resname=residue.resname,
                   resseq=residue.resseq,
                   icode=residue.icode,
                   altloc=altchar,
                   xyz=resCB.xyz,
                   occupancy=resCB.occ,
                   deviation=dev,
                   dihedral_NABB=dihedralNABB,
                   ideal_xyz=betaxyz,
                   outlier=(dev >= 0.25))
                 self.results.append(result)
                 key = result.id_str()
                 if (collect_ideal) :
                   self.beta_ideal[key] = betaxyz
コード例 #3
0
ファイル: rotalyze.py プロジェクト: cctbx-xfel/cctbx_project
def get_center (residue):
  for atom in residue.atoms():
    if atom.name == " CA ":
      return atom.xyz
  return residue.atoms().extract_xyz().mean()
コード例 #4
0
ファイル: cbetadev.py プロジェクト: cctbx-xfel/cctbx_project
 def __init__(self,
              pdb_hierarchy,
              outliers_only=False,
              out=sys.stdout,
              collect_ideal=False,
              quiet=False):
     validation.__init__(self)
     self._outlier_i_seqs = flex.size_t()
     self.beta_ideal = {}
     relevant_atom_names = {
         " CA ": None,
         " N  ": None,
         " C  ": None,
         " CB ": None
     }  # FUTURE: set
     output_list = []
     self.stats = group_args(n_results=0,
                             n_weighted_results=0,
                             n_weighted_outliers=0)
     from mmtbx.validation import utils
     use_segids = utils.use_segids_in_place_of_chainids(
         hierarchy=pdb_hierarchy)
     for model in pdb_hierarchy.models():
         for chain in model.chains():
             if use_segids:
                 chain_id = utils.get_segid_as_chainid(chain=chain)
             else:
                 chain_id = chain.id
             for rg in chain.residue_groups():
                 for i_cf, cf in enumerate(rg.conformers()):
                     for i_residue, residue in enumerate(cf.residues()):
                         if (residue.resname == "GLY"):
                             continue
                         is_first = (i_cf == 0)
                         is_alt_conf = False
                         relevant_atoms = {}
                         for atom in residue.atoms():
                             if (atom.name in relevant_atom_names):
                                 relevant_atoms[atom.name] = atom
                                 if (len(atom.parent().altloc) != 0):
                                     is_alt_conf = True
                         if ((is_first or is_alt_conf)
                                 and len(relevant_atoms) == 4):
                             result = calculate_ideal_and_deviation(
                                 relevant_atoms=relevant_atoms,
                                 resname=residue.resname)
                             dev = result.deviation
                             dihedralNABB = result.dihedral
                             betaxyz = result.ideal
                             if (dev is None): continue
                             resCB = relevant_atoms[" CB "]
                             self.stats.n_results += 1
                             self.stats.n_weighted_results += resCB.occ
                             if (dev >= 0.25 or outliers_only == False):
                                 if (dev >= 0.25):
                                     self.n_outliers += 1
                                     self.stats.n_weighted_outliers += resCB.occ
                                     self._outlier_i_seqs.append(atom.i_seq)
                                 if (is_alt_conf):
                                     altchar = cf.altloc
                                 else:
                                     altchar = " "
                                 res = residue.resname.lower()
                                 sub = chain.id
                                 if (len(sub) == 1):
                                     sub = " " + sub
                                 result = cbeta(chain_id=chain_id,
                                                resname=residue.resname,
                                                resseq=residue.resseq,
                                                icode=residue.icode,
                                                altloc=altchar,
                                                xyz=resCB.xyz,
                                                occupancy=resCB.occ,
                                                deviation=dev,
                                                dihedral_NABB=dihedralNABB,
                                                ideal_xyz=betaxyz,
                                                outlier=(dev >= 0.25))
                                 self.results.append(result)
                                 key = result.id_str()
                                 if (collect_ideal):
                                     self.beta_ideal[key] = betaxyz
コード例 #5
0
ファイル: cbetadev.py プロジェクト: TheApacheCats/cctbx
   def __init__(self,
                pdb_hierarchy,
                outliers_only=False,
                out=sys.stdout,
                collect_ideal=False,
                apply_phi_psi_correction=False,
                display_phi_psi_correction=False,
                quiet=False):
       validation.__init__(self)
       self._outlier_i_seqs = flex.size_t()
       self.beta_ideal = {}
       output_list = []
       self.stats = group_args(n_results=0,
                               n_weighted_results=0,
                               n_weighted_outliers=0)
       if apply_phi_psi_correction:
           phi_psi_angles = get_phi_psi_dict(pdb_hierarchy)
           new_outliers = 0
           outliers_removed = 0
           total_residues = 0
       from mmtbx.validation import utils
       use_segids = utils.use_segids_in_place_of_chainids(
           hierarchy=pdb_hierarchy)
       for model in pdb_hierarchy.models():
           for chain in model.chains():
               if use_segids:
                   chain_id = utils.get_segid_as_chainid(chain=chain)
               else:
                   chain_id = chain.id
               for rg in chain.residue_groups():
                   for i_cf, cf in enumerate(rg.conformers()):
                       for i_residue, residue in enumerate(cf.residues()):
                           if (residue.resname == "GLY"):
                               continue
                           is_first = (i_cf == 0)
                           is_alt_conf = False
                           relevant_atoms = {}
                           for atom in residue.atoms():
                               if (atom.name in relevant_atom_names):
                                   relevant_atoms[atom.name] = atom
                                   if (len(atom.parent().altloc) != 0):
                                       is_alt_conf = True
                           if ((is_first or is_alt_conf)
                                   and len(relevant_atoms) == 4):
                               result = calculate_ideal_and_deviation(
                                   relevant_atoms=relevant_atoms,
                                   resname=residue.resname)
                               dev = result.deviation
                               dihedralNABB = result.dihedral
                               betaxyz = result.ideal
                               if (dev is None): continue
                               resCB = relevant_atoms[" CB "]
                               self.stats.n_results += 1
                               self.stats.n_weighted_results += resCB.occ
                               if (is_alt_conf):
                                   altchar = cf.altloc
                               else:
                                   altchar = " "
                               if apply_phi_psi_correction:
                                   total_residues += 1
                                   id_str = '|%s:%s|' % (residue.id_str(),
                                                         altchar)
                                   phi_psi = phi_psi_angles.get(id_str, None)
                                   if phi_psi:
                                       rc = cbd_utils.get_phi_psi_correction(
                                           result,
                                           residue,
                                           phi_psi,
                                           display_phi_psi_correction=
                                           display_phi_psi_correction,
                                       )
                                       if rc:
                                           dev, dihedralNABB, start, finish = rc
                                           if start and not finish:
                                               outliers_removed += 1
                                           elif not start and finish:
                                               new_outliers += 1
                               if (dev >= 0.25 or outliers_only == False):
                                   if (dev >= 0.25):
                                       self.n_outliers += 1
                                       self.stats.n_weighted_outliers += resCB.occ
                                       self._outlier_i_seqs.append(atom.i_seq)
                                   res = residue.resname.lower()
                                   sub = chain.id
                                   if (len(sub) == 1):
                                       sub = " " + sub
                                   result = cbeta(chain_id=chain_id,
                                                  resname=residue.resname,
                                                  resseq=residue.resseq,
                                                  icode=residue.icode,
                                                  altloc=altchar,
                                                  xyz=resCB.xyz,
                                                  occupancy=resCB.occ,
                                                  deviation=dev,
                                                  dihedral_NABB=dihedralNABB,
                                                  ideal_xyz=betaxyz,
                                                  outlier=(dev >= 0.25))
                                   self.results.append(result)
                                   key = result.id_str()
                                   if (collect_ideal):
                                       self.beta_ideal[key] = betaxyz
           if apply_phi_psi_correction:
               print('''
 Outliers removed : %5d
 New outliers     : %5d
 Num. of outliers : %5d
 Num. of residues : %5d
 ''' % (
                   outliers_removed,
                   new_outliers,
                   self.n_outliers,
                   total_residues,
               ))
コード例 #6
0
ファイル: rotalyze.py プロジェクト: keitaroyam/cctbx_fork
def get_center(residue):
    for atom in residue.atoms():
        if atom.name == " CA ":
            return atom.xyz
    return None
コード例 #7
0
def get_center(residue):
    for atom in residue.atoms():
        if atom.name == " CA ":
            return atom.xyz
    return None