Package pipe_control :: Module angles
[hide private]
[frames] | no frames]

Source Code for Module pipe_control.angles

  1  ############################################################################### 
  2  #                                                                             # 
  3  # Copyright (C) 2003-2014 Edward d'Auvergne                                   # 
  4  #                                                                             # 
  5  # This file is part of the program relax (http://www.nmr-relax.com).          # 
  6  #                                                                             # 
  7  # This program is free software: you can redistribute it and/or modify        # 
  8  # it under the terms of the GNU General Public License as published by        # 
  9  # the Free Software Foundation, either version 3 of the License, or           # 
 10  # (at your option) any later version.                                         # 
 11  #                                                                             # 
 12  # This program is distributed in the hope that it will be useful,             # 
 13  # but WITHOUT ANY WARRANTY; without even the implied warranty of              # 
 14  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               # 
 15  # GNU General Public License for more details.                                # 
 16  #                                                                             # 
 17  # You should have received a copy of the GNU General Public License           # 
 18  # along with this program.  If not, see <http://www.gnu.org/licenses/>.       # 
 19  #                                                                             # 
 20  ############################################################################### 
 21   
 22  # Module docstring. 
 23  """Module for the manipulation of angular information.""" 
 24   
 25  # Python module imports. 
 26  from math import acos, sin 
 27  from numpy import dot 
 28  from warnings import warn 
 29   
 30  # relax module imports. 
 31  from lib.errors import RelaxError, RelaxNoPdbError, RelaxNoSequenceError, RelaxNoTensorError 
 32  from lib.warnings import RelaxWarning 
 33  from pipe_control import pipes 
 34  from pipe_control.interatomic import interatomic_loop 
 35  from pipe_control.mol_res_spin import exists_mol_res_spin_data, generate_spin_id, spin_loop 
 36   
 37   
38 -def angle_diff_frame():
39 """Function for calculating the angle defining the XH vector in the diffusion frame.""" 40 41 # Test if the current data pipe exists. 42 pipes.test() 43 44 # Test if the PDB file has been loaded. 45 if not hasattr(cdp, 'structure'): 46 raise RelaxNoPdbError 47 48 # Test if sequence data is loaded. 49 if not exists_mol_res_spin_data(): 50 raise RelaxNoSequenceError 51 52 # Test if the diffusion tensor data is loaded. 53 if not hasattr(cdp, 'diff_tensor'): 54 raise RelaxNoTensorError('diffusion') 55 56 # Sphere. 57 if cdp.diff_tensor.type == 'sphere': 58 return 59 60 # Spheroid. 61 elif cdp.diff_tensor.type == 'spheroid': 62 spheroid_frame() 63 64 # Ellipsoid. 65 elif cdp.diff_tensor.type == 'ellipsoid': 66 raise RelaxError("No coded yet.")
67 68
69 -def ellipsoid_frame():
70 """Calculate the spherical angles of the bond vector in the ellipsoid frame.""" 71 72 # Get the unit vectors Dx, Dy, and Dz of the diffusion tensor axes. 73 Dx, Dy, Dz = diffusion_tensor.unit_axes() 74 75 # Spin loop. 76 for spin, mol_name, res_num, res_name in spin_loop(full_info=True): 77 # Test if the vector exists. 78 if not hasattr(spin, 'xh_vect'): 79 # Get the spin id string. 80 spin_id = generate_spin_id(mol_name=mol_name, res_num=res_num, res_name=res_name, spin_num=spin.num, spin_name=spin.name) 81 82 # Throw a warning. 83 warn(RelaxWarning("No angles could be calculated for the spin " + repr(spin_id) + ".")) 84 85 # Skip the spin. 86 continue 87 88 # dz and dx direction cosines. 89 dz = dot(Dz, spin.xh_vect) 90 dx = dot(Dx, spin.xh_vect) 91 92 # Calculate the polar angle theta. 93 spin.theta = acos(dz) 94 95 # Calculate the azimuthal angle phi. 96 spin.phi = acos(dx / sin(spin.theta))
97 98
99 -def spheroid_frame():
100 """Function for calculating the angle alpha of the XH vector within the spheroid frame.""" 101 102 # Loop over the interatomic info. 103 for interatom in interatomic_loop(): 104 # Test if the vector exists. 105 if not hasattr(interatom, 'vector'): 106 # Throw a warning. 107 warn(RelaxWarning("No angles could be calculated for the spin pair '%s' and '%s'." % (interatom.spin_id1, interatom.spin_id2))) 108 109 # Skip the container. 110 continue 111 112 # Calculate alpha. 113 interatom.alpha = acos(dot(cdp.diff_tensor.Dpar_unit, interatom.vector))
114