Example #1
0
    def transform(self):
        """Transform the domain to the average position."""

        # Switch back to the main data pipe.
        self._execute_uf(uf_name='pipe.switch', pipe_name='frame order')

        # The rotation matrix.
        R = zeros((3, 3), float64)
        if hasattr(cdp, 'ave_pos_alpha'):
            euler_to_R_zyz(cdp.ave_pos_alpha, cdp.ave_pos_beta, cdp.ave_pos_gamma, R)
        else:
            euler_to_R_zyz(0.0, cdp.ave_pos_beta, cdp.ave_pos_gamma, R)
        print("Rotation matrix:\n%s\n" % R)
        R = transpose(R)
        print("Inverted rotation:\n%s\n" % R)
        pivot = cdp.pivot

        # Delete the data pipe (if a loaded state has been used).
        if self.load_state:
            self._execute_uf(uf_name='pipe.delete', pipe_name='ave pos')

        # Create a special data pipe for the average rigid body position.
        self._execute_uf(uf_name='pipe.create', pipe_name='ave pos', pipe_type='frame order')

        # Load the structure.
        self._execute_uf(uf_name='structure.read_pdb', file='1J7P_1st_NH_rot.pdb', dir=BASE_PATH)

        # Rotate all atoms.
        self._execute_uf(uf_name='structure.rotate', R=R, origin=pivot)

        # Write out the new PDB.
        self._execute_uf(uf_name='structure.write_pdb', file='devnull')
Example #2
0
    def get_ellipsoid(self):
        """Return all the diffusion tensor info about the {Dx, Dy, Dz, alpha, beta, gamma} = {1e7, 2e7, 3e7, 1, 2, 0.5} ellipsoid tensor."""

        # The tensor info.
        Dx = 1e7
        Dy = 2e7
        Dz = 3e7
        Diso = 2e7
        Da = 1.5e7
        Dr = 1.0/3.0
        alpha = 1.0
        beta = 2.0
        gamma = 0.5

        # The actual tensor in the PDB frame.
        D = array([[ 22758858.4088357,  -7267400.1700938,   6272205.75829415],
                   [ -7267400.1700938,  17923072.3436445,   1284270.53726401],
                   [  6272205.75829415,   1284270.53726401,  19318069.2475198 ]], float64)

        # The tensor in the eigenframe.
        D_prime = zeros((3, 3), float64)
        D_prime[0, 0] = Dx
        D_prime[1, 1] = Dy
        D_prime[2, 2] = Dz

        # The rotation matrix.
        R = zeros((3, 3), float64)
        euler_to_R_zyz(gamma, beta, alpha, R)
        R = transpose(R)

        # Return the data.
        return Dx, Dy, Dz, Diso, Da, Dr, alpha, beta, gamma, D, D_prime, R
Example #3
0
    def transform(self):
        """Transform the domain to the average position."""

        # Switch back to the main data pipe.
        pipe.switch('frame order')

        # The rotation matrix.
        R = zeros((3, 3), float64)
        euler_to_R_zyz(cdp.ave_pos_alpha, cdp.ave_pos_beta, cdp.ave_pos_gamma, R)
        print("Rotation matrix:\n%s\n" % R)
        R = transpose(R)
        print("Inverted rotation:\n%s\n" % R)
        pivot = cdp.pivot

        # Create a special data pipe for the average rigid body position.
        pipe.create(pipe_name='ave pos', pipe_type='frame order')

        # Load the structure.
        structure.read_pdb('1J7P_1st_NH_rot.pdb', dir='..')

        # Rotate all atoms.
        structure.rotate(R=R, origin=pivot)

        # Write out the new PDB.
        structure.write_pdb('ave_pos', force=True)
    def transform(self):
        """Transform the domain to the average position."""

        # Switch back to the main data pipe.
        pipe.switch('frame order')

        # The rotation matrix.
        R = zeros((3, 3), float64)
        euler_to_R_zyz(0.0, cdp.ave_pos_beta, cdp.ave_pos_gamma, R)
        print("Rotation matrix:\n%s\n" % R)
        R = transpose(R)
        print("Inverted rotation:\n%s\n" % R)
        pivot = cdp.pivot

        # Create a special data pipe for the average rigid body position.
        pipe.create(pipe_name='ave pos', pipe_type='frame order')

        # Load the structure.
        structure.read_pdb('1J7P_1st_NH_rot.pdb', dir='..')

        # Rotate all atoms.
        structure.rotate(R=R, origin=pivot)

        # Write out the new PDB.
        structure.write_pdb('ave_pos_pseudo_ellipse', force=True)
Example #5
0
    def get_ellipsoid(self):
        """Return all the diffusion tensor info about the {Dx, Dy, Dz, alpha, beta, gamma} = {1e7, 2e7, 3e7, 1, 2, 0.5} ellipsoid tensor."""

        # The tensor info.
        Dx = 1e7
        Dy = 2e7
        Dz = 3e7
        Diso = 2e7
        Da = 1.5e7
        Dr = 1.0/3.0
        alpha = 1.0
        beta = 2.0
        gamma = 0.5

        # The actual tensor in the PDB frame.
        D = array([[ 22758858.4088357,  -7267400.1700938,   6272205.75829415],
                   [ -7267400.1700938,  17923072.3436445,   1284270.53726401],
                   [  6272205.75829415,   1284270.53726401,  19318069.2475198 ]], float64)

        # The tensor in the eigenframe.
        D_prime = zeros((3, 3), float64)
        D_prime[0, 0] = Dx
        D_prime[1, 1] = Dy
        D_prime[2, 2] = Dz

        # The rotation matrix.
        R = zeros((3, 3), float64)
        euler_to_R_zyz(gamma, beta, alpha, R)
        R = transpose(R)

        # Return the data.
        return Dx, Dy, Dz, Diso, Da, Dr, alpha, beta, gamma, D, D_prime, R
Example #6
0
    def calc_Rx2_eigen_full(self, eigen_alpha, eigen_beta, eigen_gamma):
        """Calculate the Kronecker product of the eigenframe rotation for the full eigenframe."""

        # Average position rotation.
        euler_to_R_zyz(eigen_alpha, eigen_beta, eigen_gamma, self.R_temp)

        # The Kronecker product of the eigenframe rotation.
        return kron_prod(self.R_temp, self.R_temp)
Example #7
0
    def calc_Rx2_eigen_full(self, eigen_alpha, eigen_beta, eigen_gamma):
        """Calculate the Kronecker product of the eigenframe rotation for the full eigenframe."""

        # Average position rotation.
        euler_to_R_zyz(eigen_alpha, eigen_beta, eigen_gamma, self.R_temp)

        # The Kronecker product of the eigenframe rotation.
        return kron_prod(self.R_temp, self.R_temp)
Example #8
0
def generate_axis_system(sim_index=None):
    """Generate and return the full 3D axis system for the current frame order model.

    @keyword sim_index: The optional MC simulation index to obtain the frame for a given simulation.
    @type sim_index:    None or int
    @return:            The full 3D axis system for the model.
    @rtype:             numpy rank-2, 3D float64 array
    """

    # Initialise.
    axis = zeros(3, float64)
    frame = zeros((3, 3), float64)

    # The 1st pivot point.
    pivot = generate_pivot(order=1, sim_index=sim_index, pdb_limit=True)

    # The CoM of the system.
    com = pipe_centre_of_mass(verbosity=0, missing_error=False)

    # The system for the rotor models.
    if cdp.model in [MODEL_ROTOR, MODEL_FREE_ROTOR]:
        # Generate the axis.
        if sim_index == None:
            axis = create_rotor_axis_alpha(alpha=cdp.axis_alpha, pivot=pivot, point=com)
        else:
            axis = create_rotor_axis_alpha(alpha=cdp.axis_alpha_sim[sim_index], pivot=pivot, point=com)

        # Create a full normalised axis system.
        frame_from_axis(axis, frame)

    # The system for the isotropic cones.
    elif cdp.model in MODEL_LIST_ISO_CONE:
        # Generate the axis.
        if sim_index == None:
            axis = create_rotor_axis_spherical(theta=cdp.axis_theta, phi=cdp.axis_phi)
        else:
            axis = create_rotor_axis_spherical(theta=cdp.axis_theta_sim[sim_index], phi=cdp.axis_phi_sim[sim_index])

        # Create a full normalised axis system.
        frame_from_axis(axis, frame)

    # The system for the pseudo-ellipses and double rotor.
    elif cdp.model in MODEL_LIST_PSEUDO_ELLIPSE + MODEL_LIST_DOUBLE:
        # Generate the eigenframe of the motion.
        if sim_index == None:
            euler_to_R_zyz(cdp.eigen_alpha, cdp.eigen_beta, cdp.eigen_gamma, frame)
        else:
            euler_to_R_zyz(cdp.eigen_alpha_sim[sim_index], cdp.eigen_beta_sim[sim_index], cdp.eigen_gamma_sim[sim_index], frame)

    # Unknown model.
    else:
        raise RelaxFault

    # Return the full eigenframe.
    return frame
Example #9
0
def tensor_setup(Dx=None, Dy=None, Dz=None, alpha=None, beta=None, gamma=None):
    """Set up the diffusion tensor according to the correct Euler angle convention."""

    # Print out.
    print("\n\n")
    print("# Angles to diff tensor.")
    print("########################")

    # Init.
    ROT = False

    # The rotation matrix (in the rotating axis system).
    R = zeros((3, 3), float64)
    R_rev = zeros((3, 3), float64)
    euler_to_R_zyz(gamma, beta, alpha, R)
    R_rev = transpose(R)
    print("\nEuler angels: [%s, %s, %s]" % (alpha, beta, gamma))
    print("R:\n%s" % R)
    print("R_rev:\n%s" % R_rev)
    print("X x Y: %s" % cross(R[:, 0], R[:, 1]))

    # Axis rotations.
    if ROT:
        R_x180 = zeros((3, 3), float64)
        R_y180 = zeros((3, 3), float64)
        R_z180 = zeros((3, 3), float64)
        axis_angle_to_R(R_rev[:, 0], pi, R_x180)
        axis_angle_to_R(R_rev[:, 1], pi, R_y180)
        axis_angle_to_R(R_rev[:, 2], pi, R_z180)
        print("\nR (x 180):\n%s" % R_x180)
        print("\nR (y 180):\n%s" % R_y180)
        print("\nR (z 180):\n%s" % R_z180)

    # A test vector.
    mu = array([1, 2, -3], float64)
    mu = mu / norm(mu)

    # Tensor in eigenframe.
    D_prime = zeros((3, 3), float64)
    D_prime[0, 0] = Dx
    D_prime[1, 1] = Dy
    D_prime[2, 2] = Dz
    print("\nD':\n%s" % D_prime)

    # Rotate tensor from the eigenframe to the ref frame.
    D = dot(R_rev, dot(D_prime, transpose(R_rev)))
    print("\nD:\n%s" % D)
    print("\n\n")

    # Return the forward and reverse rotation, and the diffusion tensors.
    return R, R_rev, D_prime, D
Example #10
0
def tensor_setup(Dx=None, Dy=None, Dz=None, alpha=None, beta=None, gamma=None):
    """Set up the diffusion tensor according to the correct Euler angle convention."""

    # Print out.
    print("\n\n")
    print("# Angles to diff tensor.")
    print("########################")

    # Init.
    ROT = False

    # The rotation matrix (in the rotating axis system).
    R = zeros((3, 3), float64)
    R_rev = zeros((3, 3), float64)
    euler_to_R_zyz(gamma, beta, alpha, R)
    R_rev = transpose(R)
    print("\nEuler angels: [%s, %s, %s]" % (alpha, beta, gamma))
    print("R:\n%s" % R)
    print("R_rev:\n%s" % R_rev)
    print("X x Y: %s" % cross(R[:, 0], R[:, 1]))

    # Axis rotations.
    if ROT:
        R_x180 = zeros((3, 3), float64)
        R_y180 = zeros((3, 3), float64)
        R_z180 = zeros((3, 3), float64)
        axis_angle_to_R(R_rev[:, 0], pi, R_x180)
        axis_angle_to_R(R_rev[:, 1], pi, R_y180)
        axis_angle_to_R(R_rev[:, 2], pi, R_z180)
        print("\nR (x 180):\n%s" % R_x180)
        print("\nR (y 180):\n%s" % R_y180)
        print("\nR (z 180):\n%s" % R_z180)

    # A test vector.
    mu = array([1, 2, -3], float64)
    mu = mu / norm(mu)

    # Tensor in eigenframe.
    D_prime = zeros((3, 3), float64)
    D_prime[0, 0] = Dx
    D_prime[1, 1] = Dy
    D_prime[2, 2] = Dz
    print("\nD':\n%s" % D_prime)

    # Rotate tensor from the eigenframe to the ref frame.
    D = dot(R_rev, dot(D_prime, transpose(R_rev)))
    print("\nD:\n%s" % D)
    print("\n\n")

    # Return the forward and reverse rotation, and the diffusion tensors.
    return R, R_rev, D_prime, D
Example #11
0
def create_rotor_axis_euler(alpha=None, beta=None, gamma=None):
    """Create the rotor axis from the Euler angles.

    @keyword alpha: The alpha Euler angle in the zyz notation.
    @type alpha:    float
    @keyword beta:  The beta Euler angle in the zyz notation.
    @type beta:     float
    @keyword gamma: The gamma Euler angle in the zyz notation.
    @type gamma:    float
    @return:        The rotor axis as a unit vector.
    @rtype:         numpy rank-1 3D float64 array
    """

    # Initialise the 3D frame.
    frame = zeros((3, 3), float64)

    # Euler angle to rotation matrix conversion.
    euler_to_R_zyz(alpha, beta, gamma, frame)

    # Return the z-axis component.
    return frame[:, 2]
Example #12
0
def create_rotor_axis_euler(alpha=None, beta=None, gamma=None):
    """Create the rotor axis from the Euler angles.

    @keyword alpha: The alpha Euler angle in the zyz notation.
    @type alpha:    float
    @keyword beta:  The beta Euler angle in the zyz notation.
    @type beta:     float
    @keyword gamma: The gamma Euler angle in the zyz notation.
    @type gamma:    float
    @return:        The rotor axis as a unit vector.
    @rtype:         numpy rank-1 3D float64 array
    """

    # Initialise the 3D frame.
    frame = zeros((3, 3), float64)

    # Euler angle to rotation matrix conversion.
    euler_to_R_zyz(alpha, beta, gamma, frame)

    # Return the z-axis component.
    return frame[:, 2]
Example #13
0
def average_position(structure=None, models=None, sim=None):
    """Shift the given structural object to the average position.

    @keyword structure: The structural object to operate on.
    @type structure:    lib.structure.internal.object.Internal instance
    @keyword models:    The list of models to shift.
    @type models:       list of int
    @keyword sim:       A flag which if True will use the Monte Carlo simulation results.  In this case, the model list should be set to the simulation indices plus 1 and the structural object should have one model per simulation already set up.
    @type sim:          bool
    """

    # The selection object.
    selection = structure.selection(atom_id=domain_moving())

    # Loop over each model.
    for i in range(len(models)):
        # First rotate the moving domain to the average position.
        R = zeros((3, 3), float64)
        if hasattr(cdp, 'ave_pos_alpha'):
            if sim:
                euler_to_R_zyz(cdp.ave_pos_alpha_sim[i],
                               cdp.ave_pos_beta_sim[i],
                               cdp.ave_pos_gamma_sim[i], R)
            else:
                euler_to_R_zyz(cdp.ave_pos_alpha, cdp.ave_pos_beta,
                               cdp.ave_pos_gamma, R)
        else:
            if sim:
                euler_to_R_zyz(0.0, cdp.ave_pos_beta_sim[i],
                               cdp.ave_pos_gamma_sim[i], R)
            else:
                euler_to_R_zyz(0.0, cdp.ave_pos_beta, cdp.ave_pos_gamma, R)
        origin = pipe_centre_of_mass(atom_id=domain_moving(),
                                     verbosity=0,
                                     missing_error=False)
        structure.rotate(R=R,
                         origin=origin,
                         model=models[i],
                         selection=selection)

        # Then translate the moving domain.
        if sim:
            T = [
                cdp.ave_pos_x_sim[i], cdp.ave_pos_y_sim[i],
                cdp.ave_pos_z_sim[i]
            ]
        else:
            T = [cdp.ave_pos_x, cdp.ave_pos_y, cdp.ave_pos_z]
        structure.translate(T=T, model=models[i], selection=selection)
Example #14
0
def average_position(structure=None, models=None, sim=None):
    """Shift the given structural object to the average position.

    @keyword structure: The structural object to operate on.
    @type structure:    lib.structure.internal.object.Internal instance
    @keyword models:    The list of models to shift.
    @type models:       list of int
    @keyword sim:       A flag which if True will use the Monte Carlo simulation results.  In this case, the model list should be set to the simulation indices plus 1 and the structural object should have one model per simulation already set up.
    @type sim:          bool
    """

    # The selection object.
    selection = structure.selection(atom_id=domain_moving())

    # Loop over each model.
    for i in range(len(models)):
        # First rotate the moving domain to the average position.
        R = zeros((3, 3), float64)
        if hasattr(cdp, 'ave_pos_alpha'):
            if sim:
                euler_to_R_zyz(cdp.ave_pos_alpha_sim[i], cdp.ave_pos_beta_sim[i], cdp.ave_pos_gamma_sim[i], R)
            else:
                euler_to_R_zyz(cdp.ave_pos_alpha, cdp.ave_pos_beta, cdp.ave_pos_gamma, R)
        else:
            if sim:
                euler_to_R_zyz(0.0, cdp.ave_pos_beta_sim[i], cdp.ave_pos_gamma_sim[i], R)
            else:
                euler_to_R_zyz(0.0, cdp.ave_pos_beta, cdp.ave_pos_gamma, R)
        origin = pipe_centre_of_mass(atom_id=domain_moving(), verbosity=0, missing_error=False)
        structure.rotate(R=R, origin=origin, model=models[i], selection=selection)

        # Then translate the moving domain.
        if sim:
            T = [cdp.ave_pos_x_sim[i], cdp.ave_pos_y_sim[i], cdp.ave_pos_z_sim[i]]
        else:
            T = [cdp.ave_pos_x, cdp.ave_pos_y, cdp.ave_pos_z]
        structure.translate(T=T, model=models[i], selection=selection)
Example #15
0
def generate_pivot(order=1, sim_index=None, pipe_name=None, pdb_limit=False):
    """Create and return the given pivot.

    @keyword order:     The pivot number with 1 corresponding to the first pivot, 2 to the second, etc.
    @type order:        int
    @keyword sim_index: The optional Monte Carlo simulation index.  If provided, the pivot for the given simulation will be returned instead.
    @type sim_index:    None or int
    @keyword pipe_name: The data pipe 
    @type pipe_name:    str
    @keyword pdb_limit: A flag which if True will cause the coordinate to be between -1000 and 1000.
    @type pdb_limit:    bool
    @return:            The give pivot point.
    @rtype:             numpy 3D rank-1 float64 array
    """

    # Checks.
    check_pipe(pipe_name)
    check_pivot(pipe_name=pipe_name)
    check_model(pipe_name=pipe_name)

    # The data pipe.
    if pipe_name == None:
        pipe_name = pipes.cdp_name()

    # Get the data pipe.
    dp = pipes.get_pipe(pipe_name)

    # Initialise.
    pivot = None

    # The double rotor parameterisation.
    if dp.model in [MODEL_DOUBLE_ROTOR]:
        # The 2nd pivot point (the centre of the frame).
        if sim_index != None and hasattr(dp, 'pivot_x_sim'):
            pivot_2nd = array([
                dp.pivot_x_sim[sim_index], dp.pivot_y_sim[sim_index],
                dp.pivot_z_sim[sim_index]
            ], float64)
        else:
            pivot_2nd = array([dp.pivot_x, dp.pivot_y, dp.pivot_z], float64)

        # Generate the first pivot.
        if order == 1:
            # The eigenframe.
            frame = zeros((3, 3), float64)
            if sim_index != None and hasattr(dp, 'pivot_disp_sim'):
                euler_to_R_zyz(dp.eigen_alpha_sim[sim_index],
                               dp.eigen_beta_sim[sim_index],
                               dp.eigen_gamma_sim[sim_index], frame)
                pivot_disp = dp.pivot_disp_sim[sim_index]
            else:
                euler_to_R_zyz(dp.eigen_alpha, dp.eigen_beta, dp.eigen_gamma,
                               frame)
                pivot_disp = dp.pivot_disp

            # The 1st pivot.
            pivot = pivot_2nd + frame[:, 2] * pivot_disp

        # Alias the 2nd pivot.
        elif order == 2:
            pivot = pivot_2nd

    # All other models.
    elif order == 1:
        if sim_index != None and hasattr(dp, 'pivot_x_sim'):
            pivot = array([
                dp.pivot_x_sim[sim_index], dp.pivot_y_sim[sim_index],
                dp.pivot_z_sim[sim_index]
            ], float64)
        else:
            pivot = array([dp.pivot_x, dp.pivot_y, dp.pivot_z], float64)

    # PDB limits.
    if pivot is not None and pdb_limit:
        # The original pivot, as text.
        orig_pivot = "[%.3f, %.3f, %.3f]" % (pivot[0], pivot[1], pivot[2])

        # Check each coordinate.
        out = False
        for i in range(3):
            if pivot[i] <= -900.0:
                pivot[i] = -900.0
                out = True
            elif pivot[i] > 9900.0:
                pivot[i] = 9900.0
                out = True

        # Failure.
        if out:
            new_pivot = "[%.3f, %.3f, %.3f]" % (pivot[0], pivot[1], pivot[2])
            warn(
                RelaxWarning(
                    "The pivot point %s is outside of the PDB coordinate limits of [-999.999, 9999.999], less a 100 Angstrom buffer, shifting to %s."
                    % (orig_pivot, new_pivot)))

    # Return the pivot.
    return pivot
Example #16
0
File: uf.py Project: tlinnet/relax
def CoM(pivot_point=None, centre=None):
    """Centre of mass analysis.

    This function does an analysis of the centre of mass (CoM) of the N states.  This includes
    calculating the order parameter associated with the pivot-CoM vector, and the associated
    cone of motions.  The pivot_point argument must be supplied.  If centre is None, then the
    CoM will be calculated from the selected parts of the loaded structure.  Otherwise it will
    be set to the centre arg.

    @param pivot_point: The pivot point in the structural file(s).
    @type pivot_point:  list of float of length 3
    @param centre:      The optional centre of mass vector.
    @type centre:       list of float of length 3
    """

    # Test if the current data pipe exists.
    check_pipe()

    # Set the pivot point.
    cdp.pivot_point = pivot_point

    # The centre has been supplied.
    if centre:
        cdp.CoM = centre

    # Calculate from the structure file.
    else:
        cdp.CoM = centre_of_mass()

    # Calculate the vector between the pivot and CoM points.
    cdp.pivot_CoM = array(cdp.CoM, float64) - array(cdp.pivot_point, float64)

    # Calculate the unit vector between the pivot and CoM points.
    unit_vect = cdp.pivot_CoM / norm(cdp.pivot_CoM)

    # Initilise some data structures.
    R = zeros((3, 3), float64)
    vectors = zeros((cdp.N, 3), float64)

    # Loop over the N states.
    for c in range(cdp.N):
        # Generate the rotation matrix.
        euler_to_R_zyz(cdp.alpha[c], cdp.beta[c], cdp.gamma[c], R)

        # Rotate the unit vector.
        vectors[c] = dot(R, unit_vect)

        # Multiply by the probability.
        vectors[c] = vectors[c] * cdp.probs[c]

    # Average of the unit vectors.
    cdp.ave_unit_pivot_CoM = sum(vectors)

    # The length reduction.
    cdp.ave_pivot_CoM_red = norm(cdp.ave_unit_pivot_CoM)

    # The aveage pivot-CoM vector.
    cdp.ave_pivot_CoM = norm(cdp.pivot_CoM) * cdp.ave_unit_pivot_CoM

    # The full length rotated pivot-CoM vector.
    cdp.full_ave_pivot_CoM = cdp.ave_pivot_CoM / cdp.ave_pivot_CoM_red

    # The cone angle for diffusion on an axially symmetric cone.
    cdp.theta_diff_on_cone = acos(cdp.ave_pivot_CoM_red)
    cdp.S_diff_on_cone = (3.0 * cos(cdp.theta_diff_on_cone)**2 - 1.0) / 2.0

    # The cone angle and order parameter for diffusion in an axially symmetric cone.
    cdp.theta_diff_in_cone = acos(2. * cdp.ave_pivot_CoM_red - 1.)
    cdp.S_diff_in_cone = cos(
        cdp.theta_diff_in_cone) * (1 + cos(cdp.theta_diff_in_cone)) / 2.0

    # Print out.
    print("\n%-40s %-20s" % ("Pivot point:", repr(cdp.pivot_point)))
    print("%-40s %-20s" %
          ("Moving domain CoM (prior to rotation):", repr(cdp.CoM)))
    print("%-40s %-20s" % ("Pivot-CoM vector", repr(cdp.pivot_CoM)))
    print("%-40s %-20s" % ("Pivot-CoM unit vector:", repr(unit_vect)))
    print("%-40s %-20s" % ("Average of the unit pivot-CoM vectors:",
                           repr(cdp.ave_unit_pivot_CoM)))
    print("%-40s %-20s" %
          ("Average of the pivot-CoM vector:", repr(cdp.ave_pivot_CoM)))
    print("%-40s %-20s" % ("Full length rotated pivot-CoM vector:",
                           repr(cdp.full_ave_pivot_CoM)))
    print("%-40s %-20s" %
          ("Length reduction from unity:", repr(cdp.ave_pivot_CoM_red)))
    print("%-40s %.5f rad (%.5f deg)" %
          ("Cone angle (diffusion on a cone)", cdp.theta_diff_on_cone,
           cdp.theta_diff_on_cone / (2 * pi) * 360.))
    print("%-40s S_cone = %.5f (S^2 = %.5f)" %
          ("S_cone (diffusion on a cone)", cdp.S_diff_on_cone,
           cdp.S_diff_on_cone**2))
    print("%-40s %.5f rad (%.5f deg)" %
          ("Cone angle (diffusion in a cone)", cdp.theta_diff_in_cone,
           cdp.theta_diff_in_cone / (2 * pi) * 360.))
    print("%-40s S_cone = %.5f (S^2 = %.5f)" %
          ("S_cone (diffusion in a cone)", cdp.S_diff_in_cone,
           cdp.S_diff_in_cone**2))
    print("\n\n")
Example #17
0
# relax module imports.
from lib.geometry.rotations import euler_to_R_zyz


# Create the data pipe.
pipe.create(pipe_name='frame order', pipe_type='frame order')

# Select the model.
frame_order.select_model('pseudo-ellipse, torsionless')

# The eigenframe.
eigen_alpha = 0.0
eigen_beta = 0.0
eigen_gamma = 0.0
R = zeros((3, 3), float64)
euler_to_R_zyz(eigen_alpha, eigen_beta, eigen_gamma, R)
print("Motional eigenframe:\n%s" % R)

# Set the average domain position translation parameters.
value.set(param='ave_pos_x', val=0.0)
value.set(param='ave_pos_y', val=0.0)
value.set(param='ave_pos_z', val=0.0)
value.set(param='ave_pos_alpha', val=0.0)
value.set(param='ave_pos_beta', val=0.0)
value.set(param='ave_pos_gamma', val=0.0)
value.set(param='eigen_alpha', val=eigen_alpha)
value.set(param='eigen_beta', val=eigen_beta)
value.set(param='eigen_gamma', val=eigen_gamma)
value.set(param='cone_theta_x', val=2.0)
value.set(param='cone_theta_y', val=0.1)
Example #18
0
def cone_pdb(file=None):
    """Display the cone geometric object.

    @keyword file:  The name of the file containing the cone geometric object.
    @type file:     str
    """

    # Read in the cone PDB file.
    pymol_obj.exec_cmd("load " + file)


    # The cone axes.
    ################

    # Select the AVE, AXE, and SIM residues.
    pymol_obj.exec_cmd("select (resn AVE,AXE,SIM)")

    # Show the vector as a stick.
    pymol_obj.exec_cmd("show stick, 'sele'")

    # Colour it blue.
    pymol_obj.exec_cmd("color cyan, 'sele'")

    # Select the atom used for labelling.
    pymol_obj.exec_cmd("select (resn AVE,AXE,SIM and symbol N)")

    # Hide the atom.
    pymol_obj.exec_cmd("hide ('sele')")

    # Label using the atom name.
    pymol_obj.exec_cmd("cmd.label(\"sele\",\"name\")")


    # The cone object.
    ##################

    # Select the CON residue.
    pymol_obj.exec_cmd("select (resn CON,EDG)")

    # Hide everything.
    pymol_obj.exec_cmd("hide ('sele')")

    # Show as 'sticks'.
    pymol_obj.exec_cmd("show sticks, 'sele'")

    # Colour it white.
    pymol_obj.exec_cmd("color white, 'sele'")

    # Shorten the stick width from 0.25 to 0.15.
    pymol_obj.exec_cmd("set stick_radius,0.15000")

    # Set a bit of transparency.
    pymol_obj.exec_cmd("set stick_transparency, 0.3")


    # Clean up.
    ###########

    # Remove the selection.
    pymol_obj.exec_cmd("cmd.delete('sele')")


    # Rotate to the average position.
    #################################

    # Check if there is an average position.
    if hasattr(cdp, 'ave_pos_beta'):
        # The average position rotation.
        ave_pos_R = zeros((3, 3), float64)
        ave_pos_alpha = 0.0
        if hasattr(cdp, 'ave_pos_alpha') and cdp.ave_pos_alpha != None:
            ave_pos_alpha = cdp.ave_pos_alpha
        euler_to_R_zyz(ave_pos_alpha, cdp.ave_pos_beta, cdp.ave_pos_gamma, ave_pos_R)

        # The rotation is passive (need to rotated the moving domain back into the average position defined in the non-moving domain PDB frame).
        R = transpose(ave_pos_R)

        # Convert to axis-angle notation.
        axis, angle = R_to_axis_angle(R)

        # The PDB file to rotate.
        for i in range(len(cdp.domain_to_pdb)):
            if cdp.domain_to_pdb[i][0] != cdp.ref_domain:
                pdb = cdp.domain_to_pdb[i][1]

        # Execute the pymol command to rotate.
        pymol_obj.exec_cmd("cmd.rotate([%s, %s, %s], %s, '%s', origin=[%s, %s, %s])" % (axis[0], axis[1], axis[2], angle/pi*180.0, pdb, cdp.pivot[0], cdp.pivot[1], cdp.pivot[2]))
Example #19
0
    def setup_full(self):
        """Set up the frame order model data from scratch."""

        # Create the data pipe.
        self._execute_uf(uf_name='pipe.create', pipe_name='frame order', pipe_type='frame order')

        # Read the structures.
        self._execute_uf(uf_name='structure.read_pdb', file='1J7O_1st_NH.pdb', dir=BASE_PATH, set_mol_name='N-dom')
        self._execute_uf(uf_name='structure.read_pdb', file='1J7P_1st_NH_rot.pdb', dir=BASE_PATH, set_mol_name='C-dom')

        # Solve the {a, b, g} -> {0, b', g'} angle conversion problem in the rotor models by pre-rotating the domain!
        if self.model in ['free rotor', 'iso cone, free rotor']:
            # The rotation matrix.
            R = zeros((3, 3), float64)
            euler_to_R_zyz(self.ave_pos_alpha, self.ave_pos_beta, self.ave_pos_gamma, R)

            # Rotate.
            self._execute_uf(uf_name='structure.rotate', R=R, atom_id='#C-dom')

        # Set up the 15N and 1H spins.
        self._execute_uf(uf_name='structure.load_spins', spin_id='@N', ave_pos=False)
        self._execute_uf(uf_name='structure.load_spins', spin_id='@H', ave_pos=False)
        self._execute_uf(uf_name='spin.isotope', isotope='15N', spin_id='@N')
        self._execute_uf(uf_name='spin.isotope', isotope='1H', spin_id='@H')

        # Define the magnetic dipole-dipole relaxation interaction.
        self._execute_uf(uf_name='interatom.define', spin_id1='@N', spin_id2='@H', direct_bond=True)
        self._execute_uf(uf_name='interatom.set_dist', spin_id1='@N', spin_id2='@H', ave_dist=1.041 * 1e-10)
        self._execute_uf(uf_name='interatom.unit_vectors')

        # Loop over the alignments.
        ln = ['dy', 'tb', 'tm', 'er']
        for i in range(len(ln)):
            # Load the RDCs (if present).
            if (not hasattr(status, 'flag_rdc') or status.flag_rdc) and access(self.data_path+sep+'rdc_%s.txt'%ln[i], F_OK):
                self._execute_uf(uf_name='rdc.read', align_id=ln[i], file='rdc_%s.txt'%ln[i], dir=self.data_path, spin_id1_col=1, spin_id2_col=2, data_col=3, error_col=4)

            # The PCS (if present).
            if not hasattr(status, 'flag_pcs') or status.flag_pcs and access(self.data_path+sep+'pcs_%s.txt'%ln[i], F_OK):
                self._execute_uf(uf_name='pcs.read', align_id=ln[i], file='pcs_%s_subset.txt'%ln[i], dir=self.data_path, mol_name_col=1, res_num_col=2, spin_name_col=5, data_col=6, error_col=7)

            # The temperature and field strength.
            self._execute_uf(uf_name='spectrometer.temperature', id=ln[i], temp=303)
            self._execute_uf(uf_name='spectrometer.frequency', id=ln[i], frq=900e6)

        # Load the N-domain tensors (the full tensors).
        self._execute_uf(uf_name='script', file=BASE_PATH + 'tensors.py')

        # Define the domains.
        self._execute_uf(uf_name='domain', id='N', spin_id=":1-78")
        self._execute_uf(uf_name='domain', id='C', spin_id=":80-148")

        # The tensor domains and reductions.
        full = ['Dy N-dom', 'Tb N-dom', 'Tm N-dom', 'Er N-dom']
        red =  ['Dy C-dom', 'Tb C-dom', 'Tm C-dom', 'Er C-dom']
        ids =  ['dy', 'tb', 'tm', 'er']
        for i in range(len(full)):
            # Initialise the reduced tensor.
            self._execute_uf(uf_name='align_tensor.init', tensor=red[i], align_id=ids[i], params=(0, 0, 0, 0, 0))

            # Set the domain info.
            self._execute_uf(uf_name='align_tensor.set_domain', tensor=full[i], domain='N')
            self._execute_uf(uf_name='align_tensor.set_domain', tensor=red[i], domain='C')

            # Specify which tensor is reduced.
            self._execute_uf(uf_name='align_tensor.reduction', full_tensor=full[i], red_tensor=red[i])

        # Select the model.
        self._execute_uf(uf_name='frame_order.select_model', model=self.model)

        # Set up the mechanics of the displacement to the average domain position.
        self._execute_uf(uf_name='frame_order.average_position', pivot='motional', translation=False)

        # Set the reference domain.
        self._execute_uf(uf_name='frame_order.ref_domain', ref='N')

        # Set the initial pivot point.
        pivot = array([ 37.254, 0.5, 16.7465])
        self._execute_uf(uf_name='frame_order.pivot', pivot=pivot, fix=True)

        # Set the paramagnetic centre.
        self._execute_uf(uf_name='paramag.centre', pos=[35.934, 12.194, -4.206])
Example #20
0
from lib.geometry.rotations import euler_to_R_zyz


# Create the data pipe.
pipe.create(pipe_name='frame order', pipe_type='frame order')

# Select the model.
frame_order.select_model('pseudo-ellipse')

# The eigenframe.
eigen_alpha = 0.0
eigen_beta = -pi/4.0
eigen_gamma = 0.0
R = zeros((3, 3), float64)
euler_to_R_zyz(eigen_alpha, eigen_beta, eigen_gamma, R)
print("Motional eigenframe:\n%s" % R)

# Set the average domain position translation parameters.
value.set(param='ave_pos_x', val=0.0)
value.set(param='ave_pos_y', val=0.0)
value.set(param='ave_pos_z', val=0.0)
value.set(param='ave_pos_alpha', val=0.0)
value.set(param='ave_pos_beta', val=0.0)
value.set(param='ave_pos_gamma', val=0.0)
value.set(param='eigen_alpha', val=eigen_alpha)
value.set(param='eigen_beta', val=eigen_beta)
value.set(param='eigen_gamma', val=eigen_gamma)
value.set(param='cone_theta_x', val=2.0)
value.set(param='cone_theta_y', val=0.1)
value.set(param='cone_sigma_max', val=0.0)
Example #21
0
# Python module imports.
from numpy import array, float64, transpose, zeros

# relax module imports.
from lib.geometry.rotations import euler_to_R_zyz, R_to_euler_zyz


# Create a data pipe for the data.
pipe.create('displace', 'N-state')

# Load the structure.
structure.read_pdb('fancy_mol.pdb')

# First rotate.
R = zeros((3, 3), float64)
euler_to_R_zyz(1, 2, 3, R)
origin = array([1, 1, 1], float64)
structure.rotate(R=R, origin=origin)

# Then translate.
T = array([1, 2, 3], float64)
structure.translate(T=T)

# Write out the new structure.
structure.write_pdb('displaced.pdb', force=True)

# Printout of the inverted Euler angles of rotation (the solution).
a, b, g = R_to_euler_zyz(transpose(R))
print("alpha: %s" % a)
print("beta:  %s" % b)
print("gamma: %s" % g)
Example #22
0
# Python module imports.
from numpy import array, float64, transpose, zeros

# relax module imports.
from lib.geometry.rotations import euler_to_R_zyz, R_to_euler_zyz

# Create a data pipe for the data.
pipe.create('displace', 'N-state')

# Load the structure.
structure.read_pdb('fancy_mol.pdb')

# First rotate.
R = zeros((3, 3), float64)
euler_to_R_zyz(1, 2, 3, R)
origin = array([1, 1, 1], float64)
structure.rotate(R=R, origin=origin)

# Then translate.
T = array([1, 2, 3], float64)
structure.translate(T=T)

# Write out the new structure.
structure.write_pdb('displaced.pdb', force=True)

# Printout of the inverted Euler angles of rotation (the solution).
a, b, g = R_to_euler_zyz(transpose(R))
print("alpha: %s" % a)
print("beta:  %s" % b)
print("gamma: %s" % g)
Example #23
0
def generate_pivot(order=1, sim_index=None, pipe_name=None, pdb_limit=False):
    """Create and return the given pivot.

    @keyword order:     The pivot number with 1 corresponding to the first pivot, 2 to the second, etc.
    @type order:        int
    @keyword sim_index: The optional Monte Carlo simulation index.  If provided, the pivot for the given simulation will be returned instead.
    @type sim_index:    None or int
    @keyword pipe_name: The data pipe 
    @type pipe_name:    str
    @keyword pdb_limit: A flag which if True will cause the coordinate to be between -1000 and 1000.
    @type pdb_limit:    bool
    @return:            The give pivot point.
    @rtype:             numpy 3D rank-1 float64 array
    """

    # Checks.
    check_pipe(pipe_name)
    check_pivot(pipe_name=pipe_name)
    check_model(pipe_name=pipe_name)

    # The data pipe.
    if pipe_name == None:
        pipe_name = pipes.cdp_name()

    # Get the data pipe.
    dp = pipes.get_pipe(pipe_name)

    # Initialise.
    pivot = None

    # The double rotor parameterisation.
    if dp.model in [MODEL_DOUBLE_ROTOR]:
        # The 2nd pivot point (the centre of the frame).
        if sim_index != None and hasattr(dp, 'pivot_x_sim'):
            pivot_2nd = array([dp.pivot_x_sim[sim_index], dp.pivot_y_sim[sim_index], dp.pivot_z_sim[sim_index]], float64)
        else:
            pivot_2nd = array([dp.pivot_x, dp.pivot_y, dp.pivot_z], float64)

        # Generate the first pivot.
        if order == 1:
            # The eigenframe.
            frame = zeros((3, 3), float64)
            if sim_index != None and hasattr(dp, 'pivot_disp_sim'):
                euler_to_R_zyz(dp.eigen_alpha_sim[sim_index], dp.eigen_beta_sim[sim_index], dp.eigen_gamma_sim[sim_index], frame)
                pivot_disp = dp.pivot_disp_sim[sim_index]
            else:
                euler_to_R_zyz(dp.eigen_alpha, dp.eigen_beta, dp.eigen_gamma, frame)
                pivot_disp = dp.pivot_disp

            # The 1st pivot.
            pivot = pivot_2nd + frame[:, 2] * pivot_disp

        # Alias the 2nd pivot.
        elif order == 2:
            pivot = pivot_2nd

    # All other models.
    elif order == 1:
        if sim_index != None and hasattr(dp, 'pivot_x_sim'):
            pivot = array([dp.pivot_x_sim[sim_index], dp.pivot_y_sim[sim_index], dp.pivot_z_sim[sim_index]], float64)
        else:
            pivot = array([dp.pivot_x, dp.pivot_y, dp.pivot_z], float64)

    # PDB limits.
    if pivot is not None and pdb_limit:
        # The original pivot, as text.
        orig_pivot = "[%.3f, %.3f, %.3f]" % (pivot[0], pivot[1], pivot[2])

        # Check each coordinate.
        out = False
        for i in range(3):
            if pivot[i] <= -900.0:
                pivot[i] = -900.0
                out = True
            elif pivot[i] > 9900.0:
                pivot[i] = 9900.0
                out = True

        # Failure.
        if out:
            new_pivot = "[%.3f, %.3f, %.3f]" % (pivot[0], pivot[1], pivot[2])
            warn(RelaxWarning("The pivot point %s is outside of the PDB coordinate limits of [-999.999, 9999.999], less a 100 Angstrom buffer, shifting to %s." % (orig_pivot, new_pivot)))

    # Return the pivot.
    return pivot
Example #24
0
    for i in range(N):
        d = dot(R, tensordot(Ri, RT, axes=1))
        d = swapaxes(d, 0, 1)
    if verb:
        print("\n2nd rotation - dot of tensordot, and axis swap.")
        print("Rotations:\n%s" % d[:2])


# Some 200 3D matrices.
Ri = array([[1, 2, 3], [2, 3, 4], [3, 4, 5]], float64)
Ri = tile(Ri, (100, 1, 1))
if __name__ == '__main__':
    print("Original matrices:\n%s\nShape: %s" % (Ri[:2], Ri.shape))

# The rotation matrix.
R = zeros((3, 3), float64)
RT = transpose(R)
euler_to_R_zyz(1, 1, 0.5, R)
if __name__ == '__main__':
    print("\nR:\n%s\n" % R)

# Projections.
N = 1000
M = 100
if __name__ == '__main__':
    rot1(Ri=Ri, R=R, RT=RT, N=1, verb=True)
    print("Timing (s): %s" % timeit("rot1(Ri=Ri, R=R, RT=RT, N=N, verb=False)", setup="from frame_rotations import rot1, Ri, R, RT, N", number=M))

    rot2(Ri=Ri, R=R, RT=RT, N=1, verb=True)
    print("Timing (s): %s" % timeit("rot2(Ri=Ri, R=R, RT=RT, N=N, verb=False)", setup="from frame_rotations import rot2, Ri, R, RT, N", number=M))
Example #25
0
def generate_axis_system(sim_index=None):
    """Generate and return the full 3D axis system for the current frame order model.

    @keyword sim_index: The optional MC simulation index to obtain the frame for a given simulation.
    @type sim_index:    None or int
    @return:            The full 3D axis system for the model.
    @rtype:             numpy rank-2, 3D float64 array
    """

    # Initialise.
    axis = zeros(3, float64)
    frame = zeros((3, 3), float64)

    # The 1st pivot point.
    pivot = generate_pivot(order=1, sim_index=sim_index, pdb_limit=True)

    # The CoM of the system.
    com = pipe_centre_of_mass(verbosity=0, missing_error=False)

    # The system for the rotor models.
    if cdp.model in [MODEL_ROTOR, MODEL_FREE_ROTOR]:
        # Generate the axis.
        if sim_index == None:
            axis = create_rotor_axis_alpha(alpha=cdp.axis_alpha,
                                           pivot=pivot,
                                           point=com)
        else:
            axis = create_rotor_axis_alpha(alpha=cdp.axis_alpha_sim[sim_index],
                                           pivot=pivot,
                                           point=com)

        # Create a full normalised axis system.
        frame_from_axis(axis, frame)

    # The system for the isotropic cones.
    elif cdp.model in MODEL_LIST_ISO_CONE:
        # Generate the axis.
        if sim_index == None:
            axis = create_rotor_axis_spherical(theta=cdp.axis_theta,
                                               phi=cdp.axis_phi)
        else:
            axis = create_rotor_axis_spherical(
                theta=cdp.axis_theta_sim[sim_index],
                phi=cdp.axis_phi_sim[sim_index])

        # Create a full normalised axis system.
        frame_from_axis(axis, frame)

    # The system for the pseudo-ellipses and double rotor.
    elif cdp.model in MODEL_LIST_PSEUDO_ELLIPSE + MODEL_LIST_DOUBLE:
        # Generate the eigenframe of the motion.
        if sim_index == None:
            euler_to_R_zyz(cdp.eigen_alpha, cdp.eigen_beta, cdp.eigen_gamma,
                           frame)
        else:
            euler_to_R_zyz(cdp.eigen_alpha_sim[sim_index],
                           cdp.eigen_beta_sim[sim_index],
                           cdp.eigen_gamma_sim[sim_index], frame)

    # Unknown model.
    else:
        raise RelaxFault

    # Return the full eigenframe.
    return frame
Example #26
0
        d = swapaxes(d, 0, 1)
    if verb:
        print("\n2nd rotation - dot of tensordot, and axis swap.")
        print("Rotations:\n%s" % d[:2])


# Some 200 3D matrices.
Ri = array([[1, 2, 3], [2, 3, 4], [3, 4, 5]], float64)
Ri = tile(Ri, (100, 1, 1))
if __name__ == '__main__':
    print("Original matrices:\n%s\nShape: %s" % (Ri[:2], Ri.shape))

# The rotation matrix.
R = zeros((3, 3), float64)
RT = transpose(R)
euler_to_R_zyz(1, 1, 0.5, R)
if __name__ == '__main__':
    print("\nR:\n%s\n" % R)

# Projections.
N = 1000
M = 100
if __name__ == '__main__':
    rot1(Ri=Ri, R=R, RT=RT, N=1, verb=True)
    print("Timing (s): %s" %
          timeit("rot1(Ri=Ri, R=R, RT=RT, N=N, verb=False)",
                 setup="from frame_rotations import rot1, Ri, R, RT, N",
                 number=M))

    rot2(Ri=Ri, R=R, RT=RT, N=1, verb=True)
    print("Timing (s): %s" %
Example #27
0
def CoM(pivot_point=None, centre=None):
    """Centre of mass analysis.

    This function does an analysis of the centre of mass (CoM) of the N states.  This includes
    calculating the order parameter associated with the pivot-CoM vector, and the associated
    cone of motions.  The pivot_point argument must be supplied.  If centre is None, then the
    CoM will be calculated from the selected parts of the loaded structure.  Otherwise it will
    be set to the centre arg.

    @param pivot_point: The pivot point in the structural file(s).
    @type pivot_point:  list of float of length 3
    @param centre:      The optional centre of mass vector.
    @type centre:       list of float of length 3
    """

    # Test if the current data pipe exists.
    check_pipe()

    # Set the pivot point.
    cdp.pivot_point = pivot_point

    # The centre has been supplied.
    if centre:
        cdp.CoM = centre

    # Calculate from the structure file.
    else:
        cdp.CoM = centre_of_mass()

    # Calculate the vector between the pivot and CoM points.
    cdp.pivot_CoM = array(cdp.CoM, float64) - array(cdp.pivot_point, float64)

    # Calculate the unit vector between the pivot and CoM points.
    unit_vect = cdp.pivot_CoM / norm(cdp.pivot_CoM)

    # Initilise some data structures.
    R = zeros((3, 3), float64)
    vectors = zeros((cdp.N, 3), float64)

    # Loop over the N states.
    for c in range(cdp.N):
        # Generate the rotation matrix.
        euler_to_R_zyz(cdp.alpha[c], cdp.beta[c], cdp.gamma[c], R)

        # Rotate the unit vector.
        vectors[c] = dot(R, unit_vect)

        # Multiply by the probability.
        vectors[c] = vectors[c] * cdp.probs[c]

    # Average of the unit vectors.
    cdp.ave_unit_pivot_CoM = sum(vectors)

    # The length reduction.
    cdp.ave_pivot_CoM_red = norm(cdp.ave_unit_pivot_CoM)

    # The aveage pivot-CoM vector.
    cdp.ave_pivot_CoM = norm(cdp.pivot_CoM) * cdp.ave_unit_pivot_CoM

    # The full length rotated pivot-CoM vector.
    cdp.full_ave_pivot_CoM = cdp.ave_pivot_CoM / cdp.ave_pivot_CoM_red

    # The cone angle for diffusion on an axially symmetric cone.
    cdp.theta_diff_on_cone = acos(cdp.ave_pivot_CoM_red)
    cdp.S_diff_on_cone = (3.0*cos(cdp.theta_diff_on_cone)**2 - 1.0) / 2.0

    # The cone angle and order parameter for diffusion in an axially symmetric cone.
    cdp.theta_diff_in_cone = acos(2.*cdp.ave_pivot_CoM_red - 1.)
    cdp.S_diff_in_cone = cos(cdp.theta_diff_in_cone) * (1 + cos(cdp.theta_diff_in_cone)) / 2.0

    # Print out.
    print("\n%-40s %-20s" % ("Pivot point:", repr(cdp.pivot_point)))
    print("%-40s %-20s" % ("Moving domain CoM (prior to rotation):", repr(cdp.CoM)))
    print("%-40s %-20s" % ("Pivot-CoM vector", repr(cdp.pivot_CoM)))
    print("%-40s %-20s" % ("Pivot-CoM unit vector:", repr(unit_vect)))
    print("%-40s %-20s" % ("Average of the unit pivot-CoM vectors:", repr(cdp.ave_unit_pivot_CoM)))
    print("%-40s %-20s" % ("Average of the pivot-CoM vector:", repr(cdp.ave_pivot_CoM)))
    print("%-40s %-20s" % ("Full length rotated pivot-CoM vector:", repr(cdp.full_ave_pivot_CoM)))
    print("%-40s %-20s" % ("Length reduction from unity:", repr(cdp.ave_pivot_CoM_red)))
    print("%-40s %.5f rad (%.5f deg)" % ("Cone angle (diffusion on a cone)", cdp.theta_diff_on_cone, cdp.theta_diff_on_cone / (2*pi) *360.))
    print("%-40s S_cone = %.5f (S^2 = %.5f)" % ("S_cone (diffusion on a cone)", cdp.S_diff_on_cone, cdp.S_diff_on_cone**2))
    print("%-40s %.5f rad (%.5f deg)" % ("Cone angle (diffusion in a cone)", cdp.theta_diff_in_cone, cdp.theta_diff_in_cone / (2*pi) *360.))
    print("%-40s S_cone = %.5f (S^2 = %.5f)" % ("S_cone (diffusion in a cone)", cdp.S_diff_in_cone, cdp.S_diff_in_cone**2))
    print("\n\n")