Пример #1
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
Пример #2
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
Пример #3
0
def add_axes(structure=None, representation=None, size=None, sims=False):
    """Add the axis system for the current frame order model to the structural object.

    @keyword structure:         The internal structural object to add the rotor objects to.
    @type structure:            lib.structure.internal.object.Internal instance
    @keyword representation:    The representation to create.  If this is set to None or 'A', the standard representation will be created.  If set to 'B', the axis system will be inverted.
    @type representation:       None or str
    @keyword size:              The size of the geometric object in Angstroms.
    @type size:                 float
    @keyword sims:              A flag which if True will add the Monte Carlo simulation rotors to the structural object.  There must be one model for each Monte Carlo simulation already present in the structural object.
    @type sims:                 bool
    """

    # Create the molecule.
    mol_name = 'axes'
    structure.add_molecule(name=mol_name)

    # The transformation matrix (identity matrix or inversion matrix).
    if representation == 'B':
        T = -eye(3)
    else:
        T = eye(3)

    # The models to loop over.
    model_nums = [None]
    sim_indices = [None]
    if sims:
        model_nums = [i+1 for i in range(cdp.sim_number)]
        sim_indices = list(range(cdp.sim_number))

    # Loop over the models.
    for i in range(len(model_nums)):
        # Alias the molecule.
        mol = structure.get_molecule(mol_name, model=model_nums[i])

        # The pivot points.
        pivot1 = generate_pivot(order=1, sim_index=sim_indices[i], pdb_limit=True)
        pivot2 = generate_pivot(order=2, sim_index=sim_indices[i], pdb_limit=True)

        # A single z-axis, when no rotor object is present.
        if cdp.model in [MODEL_ISO_CONE_TORSIONLESS]:
            # Print out.
            print("\nGenerating the z-axis system.")

            # The axis.
            if sims:
                axis = create_rotor_axis_spherical(theta=cdp.axis_theta_sim[sim_indices[i]], phi=cdp.axis_phi_sim[sim_indices[i]])
            else:
                axis = create_rotor_axis_spherical(theta=cdp.axis_theta, phi=cdp.axis_phi)
            print(("Central axis: %s." % axis))

            # Transform the central axis.
            axis = dot(T, axis)

            # Generate the axis vectors.
            print("\nGenerating the axis vectors.")
            res_num = generate_vector_residues(mol=mol, vector=axis, atom_name='z-ax', res_name_vect='AXE', res_num=2, origin=pivot1, scale=size)

        # The z-axis connecting two motional modes.
        elif cdp.model in [MODEL_DOUBLE_ROTOR]:
            # Printout.
            print("\nGenerating the z-axis linking the two pivot points.")

            # The axis.
            axis = pivot1 - pivot2
            print(("Interconnecting axis: %s." % axis))

            # Generate the axis vectors.
            print("\nGenerating the axis vectors.")
            res_num = generate_vector_residues(mol=mol, vector=axis, atom_name='z-ax', res_name_vect='AXE', res_num=1, origin=pivot2)

        # The full axis system.
        elif cdp.model in MODEL_LIST_PSEUDO_ELLIPSE:
            # Print out.
            print("\nGenerating the full axis system.")

            # Add the pivot point.
            mol.atom_add(atom_num=1, atom_name='R', res_name='AXE', res_num=1, pos=pivot1, element='C', pdb_record='HETATM')

            # The axis system.
            axes = generate_axis_system(sim_index=sim_indices[i])

            # Rotations and inversions.
            axes = dot(T, axes)

            # The axes to create.
            label = ['x', 'y']
            if cdp.model in [MODEL_PSEUDO_ELLIPSE_TORSIONLESS]:
                label = ['x', 'y', 'z']

            # Generate the axis vectors.
            print("\nGenerating the axis vectors.")
            for j in range(len(label)):
                res_num = generate_vector_residues(mol=mol, vector=axes[:, j], atom_name='%s-ax'%label[j], res_name_vect='AXE', res_num=2, origin=pivot1, scale=size)
Пример #4
0
def add_axes(structure=None, representation=None, size=None, sims=False):
    """Add the axis system for the current frame order model to the structural object.

    @keyword structure:         The internal structural object to add the rotor objects to.
    @type structure:            lib.structure.internal.object.Internal instance
    @keyword representation:    The representation to create.  If this is set to None or 'A', the standard representation will be created.  If set to 'B', the axis system will be inverted.
    @type representation:       None or str
    @keyword size:              The size of the geometric object in Angstroms.
    @type size:                 float
    @keyword sims:              A flag which if True will add the Monte Carlo simulation rotors to the structural object.  There must be one model for each Monte Carlo simulation already present in the structural object.
    @type sims:                 bool
    """

    # Create the molecule.
    mol_name = 'axes'
    structure.add_molecule(name=mol_name)

    # The transformation matrix (identity matrix or inversion matrix).
    if representation == 'B':
        T = -eye(3)
    else:
        T = eye(3)

    # The models to loop over.
    model_nums = [None]
    sim_indices = [None]
    if sims:
        model_nums = [i + 1 for i in range(cdp.sim_number)]
        sim_indices = list(range(cdp.sim_number))

    # Loop over the models.
    for i in range(len(model_nums)):
        # Alias the molecule.
        mol = structure.get_molecule(mol_name, model=model_nums[i])

        # The pivot points.
        pivot1 = generate_pivot(order=1,
                                sim_index=sim_indices[i],
                                pdb_limit=True)
        pivot2 = generate_pivot(order=2,
                                sim_index=sim_indices[i],
                                pdb_limit=True)

        # A single z-axis, when no rotor object is present.
        if cdp.model in [MODEL_ISO_CONE_TORSIONLESS]:
            # Print out.
            print("\nGenerating the z-axis system.")

            # The axis.
            if sims:
                axis = create_rotor_axis_spherical(
                    theta=cdp.axis_theta_sim[sim_indices[i]],
                    phi=cdp.axis_phi_sim[sim_indices[i]])
            else:
                axis = create_rotor_axis_spherical(theta=cdp.axis_theta,
                                                   phi=cdp.axis_phi)
            print(("Central axis: %s." % axis))

            # Transform the central axis.
            axis = dot(T, axis)

            # Generate the axis vectors.
            print("\nGenerating the axis vectors.")
            res_num = generate_vector_residues(mol=mol,
                                               vector=axis,
                                               atom_name='z-ax',
                                               res_name_vect='AXE',
                                               res_num=2,
                                               origin=pivot1,
                                               scale=size)

        # The z-axis connecting two motional modes.
        elif cdp.model in [MODEL_DOUBLE_ROTOR]:
            # Printout.
            print("\nGenerating the z-axis linking the two pivot points.")

            # The axis.
            axis = pivot1 - pivot2
            print(("Interconnecting axis: %s." % axis))

            # Generate the axis vectors.
            print("\nGenerating the axis vectors.")
            res_num = generate_vector_residues(mol=mol,
                                               vector=axis,
                                               atom_name='z-ax',
                                               res_name_vect='AXE',
                                               res_num=1,
                                               origin=pivot2)

        # The full axis system.
        elif cdp.model in MODEL_LIST_PSEUDO_ELLIPSE:
            # Print out.
            print("\nGenerating the full axis system.")

            # Add the pivot point.
            mol.atom_add(atom_num=1,
                         atom_name='R',
                         res_name='AXE',
                         res_num=1,
                         pos=pivot1,
                         element='C',
                         pdb_record='HETATM')

            # The axis system.
            axes = generate_axis_system(sim_index=sim_indices[i])

            # Rotations and inversions.
            axes = dot(T, axes)

            # The axes to create.
            label = ['x', 'y']
            if cdp.model in [MODEL_PSEUDO_ELLIPSE_TORSIONLESS]:
                label = ['x', 'y', 'z']

            # Generate the axis vectors.
            print("\nGenerating the axis vectors.")
            for j in range(len(label)):
                res_num = generate_vector_residues(mol=mol,
                                                   vector=axes[:, j],
                                                   atom_name='%s-ax' %
                                                   label[j],
                                                   res_name_vect='AXE',
                                                   res_num=2,
                                                   origin=pivot1,
                                                   scale=size)