コード例 #1
0
def set_rama_angles(moving_h, angles):
  """
  angles = [(phi, psi), (phi, psi), ... (phi, psi)]
  phi or psi == None means we don't change this angle
  returns deep-copied hierarchy with new angles. Change occurs from first to
  last angle so starting point would be in the same place.
  This function should produce up to all possible favored conformations.
  This function doesn't change moving_h

  """
  # print "angles", angles
  # STOP()
  result_h = moving_h.deep_copy()
  result_h.reset_atom_i_seqs()
  phi_psi_atoms = utils.get_phi_psi_atoms(moving_h)
  assert len(phi_psi_atoms) == len(angles)
  for ps_atoms, target_angle_pair in zip(phi_psi_atoms, angles):
    phi_psi_pair = ps_atoms[0]
    phi_psi_angles = utils.get_pair_angles(phi_psi_pair)
    # phi
    if target_angle_pair[0] is not None:
      utils.rotate_atoms_around_bond(
          result_h,
          phi_psi_pair[0][1],
          phi_psi_pair[0][2],
          angle=-phi_psi_angles[0]+target_angle_pair[0])
    # psi
    if target_angle_pair[1] is not None:
      utils.rotate_atoms_around_bond(
          result_h,
          phi_psi_pair[1][1],
          phi_psi_pair[1][2],
          angle=-phi_psi_angles[1]+target_angle_pair[1])
  return result_h
コード例 #2
0
ファイル: ss_validation.py プロジェクト: dials/cctbx
    def __call__(self, hsh_tuple):
        temp_annot = iotbx.pdb.secondary_structure.annotation(
            helices=hsh_tuple[0], sheets=hsh_tuple[1])
        helix = len(hsh_tuple[0]) > 0
        # print temp_annot.as_pdb_str().replace('\n',' '),
        ss_params = mmtbx.secondary_structure.manager.get_default_ss_params()
        ss_params.secondary_structure.enabled = True
        ss_params.secondary_structure.protein.remove_outliers = False
        ss_params.secondary_structure.protein.helix = []
        ss_params.secondary_structure.protein.sheet = []
        ss_params.secondary_structure.nucleic_acid.enabled = False
        ss_m_log = StringIO()

        ss_manager = mmtbx.secondary_structure.manager(
            pdb_hierarchy=self.pdb_h,
            atom_selection_cache=self.asc,
            sec_str_from_pdb_file=temp_annot,
            params=ss_params.secondary_structure,
            show_summary_on=False,
            log=ss_m_log)
        h_bond_proxies, hb_angles = ss_manager.create_protein_hbond_proxies(
            log=ss_m_log)

        cutoff_bad = self.bad_hbond_cutoff
        cutoff_mediocre = self.mediocre_hbond_cutoff
        n_hbonds = 0
        n_bad_hbonds = 0
        n_mediocre_hbonds = 0
        hb_lens = []
        for hb_p in h_bond_proxies:
            # print dir(hb_p)
            n_hbonds += 1
            hb_len = self.atoms[hb_p.i_seqs[0]].distance(
                self.atoms[hb_p.i_seqs[1]])
            hb_lens.append(hb_len)
            if hb_len > cutoff_bad:
                n_bad_hbonds += 1
            elif hb_len > cutoff_mediocre:
                n_mediocre_hbonds += 1

        # Ramachandran outliers and wrong areas
        sele = self.asc.selection(temp_annot.as_atom_selections()[0])
        ss_h = self.pdb_h.select(sele)
        phi_psi_atoms = get_phi_psi_atoms(ss_h)

        n_outliers = 0
        n_wrong_region = 0
        for phi_psi_pair, rama_key in phi_psi_atoms:
            phi, psi = get_pair_angles(phi_psi_pair)
            r_eval = self.r.evaluate_angles(rama_key, phi, psi)
            if r_eval == ramalyze.RAMALYZE_OUTLIER:
                n_outliers += 1
            else:
                reg = pp2_helix_sheet_rama_region(phi, psi, self.pp2m)
                if (helix and reg != 'A') or (not helix and reg != 'B'):
                    n_wrong_region += 1
                    # print "  Wrong region:", phi_psi_pair[0][2].id_str(), reg, helix
        del ss_manager
        del ss_params
        return n_hbonds, n_bad_hbonds, n_mediocre_hbonds, hb_lens, n_outliers, n_wrong_region
コード例 #3
0
def set_rama_angles(moving_h, angles):
  """
  angles = [(phi, psi), (phi, psi), ... (phi, psi)]
  phi or psi == None means we don't change this angle
  returns deep-copied hierarchy with new angles. Change occurs from first to
  last angle so starting point would be in the same place.
  This function should produce up to all possible favored conformations.
  This function doesn't change moving_h
  """
  # print "angles", angles
  # STOP()
  result_h = moving_h.deep_copy()
  result_h.reset_atom_i_seqs()
  phi_psi_atoms = utils.get_phi_psi_atoms(moving_h)
  assert len(phi_psi_atoms) == len(angles)
  for ps_atoms, target_angle_pair in zip(phi_psi_atoms, angles):
    phi_psi_pair = ps_atoms[0]
    phi_psi_angles = utils.get_pair_angles(phi_psi_pair)
    # phi
    if target_angle_pair[0] is not None:
      utils.rotate_atoms_around_bond(
          result_h,
          phi_psi_pair[0][1],
          phi_psi_pair[0][2],
          angle=-phi_psi_angles[0]+target_angle_pair[0])
    # psi
    if target_angle_pair[1] is not None:
      utils.rotate_atoms_around_bond(
          result_h,
          phi_psi_pair[1][1],
          phi_psi_pair[1][2],
          angle=-phi_psi_angles[1]+target_angle_pair[1])
  return result_h
コード例 #4
0
 def helix_sheet_rama_region(cls, phi_psi_pair):
     # result 1 - helix, 2 - sheet, 0 - other
     # cutoff: phi < 70 - helix, phi>=70 - sheet
     phi_psi_angles = get_pair_angles(phi_psi_pair, round_coords=False)
     if phi_psi_angles[1] < 70:
         return 1
     else:
         return 2
コード例 #5
0
def set_rama_angles(moving_h,
                    angles,
                    direction_forward=True,
                    check_omega=False):
    """
  angles = [(phi, psi), (phi, psi), ... (phi, psi)]
  phi or psi == None means we don't change this angle
  returns deep-copied hierarchy with new angles. Change occurs from first to
  last angle so starting point would be in the same place.
  This function should produce up to all possible favored conformations.
  This function doesn't change moving_h
  direction_forward==True - set from beginning to end - the end residue moves
  direction_forward==False - set from end to beginning, the first residue moves
  """
    # print "angles", angles
    # STOP()
    result_h = moving_h.deep_copy()
    result_h.reset_atom_i_seqs()
    fixed_omega = False
    phi_psi_atoms = utils.get_phi_psi_atoms(moving_h, omega=True)
    assert len(phi_psi_atoms) == len(angles), "%d != %d" % (len(phi_psi_atoms),
                                                            len(angles))
    if not direction_forward:
        phi_psi_atoms.reverse()
        angles.reverse()
    for ps_atoms, target_angle_pair in zip(phi_psi_atoms, angles):
        phi_psi_pair = ps_atoms[0]
        # print "phi_psi_pair", phi_psi_pair
        omega = ps_atoms[2]
        phi_psi_angles = utils.get_pair_angles(phi_psi_pair)
        # print "ps_atoms, target_angle_pair", phi_psi_angles, target_angle_pair
        # phi
        if target_angle_pair[0] is not None and phi_psi_angles[0] is not None:
            rotation_angle = -phi_psi_angles[0] + target_angle_pair[0]
            # print "rot angle", rotation_angle
            # if not direction_forward:
            #   rotation_angle = -rotation_angle
            utils.rotate_atoms_around_bond(result_h,
                                           phi_psi_pair[0][1],
                                           phi_psi_pair[0][2],
                                           angle=rotation_angle,
                                           direction_forward=direction_forward)
        # psi
        if target_angle_pair[1] is not None and phi_psi_angles[1] is not None:
            rotation_angle = -phi_psi_angles[1] + target_angle_pair[1]
            # print "rot angle", rotation_angle
            # if not direction_forward:
            #   rotation_angle = -rotation_angle
            utils.rotate_atoms_around_bond(result_h,
                                           phi_psi_pair[1][1],
                                           phi_psi_pair[1][2],
                                           angle=rotation_angle,
                                           direction_forward=direction_forward)
        # omega
        if omega is not None and abs(abs(omega) - 180) > 10 and check_omega:
            rotation_angle = -omega + 180
            # print "Omega rotation:", omega, rotation_angle
            utils.rotate_atoms_around_bond(result_h,
                                           phi_psi_pair[0][0],
                                           phi_psi_pair[0][1],
                                           angle=rotation_angle,
                                           direction_forward=direction_forward)
            fixed_omega = True
    # print utils.list_rama_outliers_h(result_h)
    # result_h.write_pdb_file(file_name="variant_%s.pdb" % direction_forward)
    # STOP()
    return result_h, fixed_omega