Example #1
0
def create_rotor_pdb(file=None, dir=None, rotor_angle=None, axis=None, axis_pt=True, centre=None, span=2e-9, blade_length=5e-10, force=False, staggered=False):
    """Create a PDB representation of a rotor motional model.

    @keyword file:          The name of the PDB file to create.
    @type file:             str
    @keyword dir:           The name of the directory to place the PDB file into.
    @type dir:              str
    @keyword rotor_angle:   The angle of the rotor motion in degrees.
    @type rotor_angle:      float
    @keyword axis:          The vector defining the rotor axis.
    @type axis:             numpy rank-1, 3D array
    @keyword axis_pt:       A point lying anywhere on the rotor axis.  This is used to define the position of the axis in 3D space.
    @type axis_pt:          numpy rank-1, 3D array
    @keyword centre:        The central point of the representation.  If this point is not on the rotor axis, then the closest point on the axis will be used for the centre.
    @type centre:           numpy rank-1, 3D array
    @keyword span:          The distance from the central point to the rotor blades (meters).
    @type span:             float
    @keyword blade_length:  The length of the representative rotor blades.
    @type blade_length:     float
    @keyword force:         A flag which if set will overwrite any pre-existing file.
    @type force:            bool
    @keyword staggered:     A flag which if True will cause the rotor blades to be staggered.  This is used to avoid blade overlap.
    @type staggered:        bool
    """

    # Test if the current pipe exists.
    check_pipe()

    # Convert the angle to radians.
    rotor_angle = rotor_angle / 360.0 * 2.0 * pi

    # Create the structural object.
    structure = Internal()

    # Generate the rotor object.
    rotor(structure=structure, rotor_angle=rotor_angle, axis=axis, axis_pt=axis_pt, centre=centre, span=span, blade_length=blade_length, staggered=staggered)

    # Print out.
    print("\nGenerating the PDB file.")

    # Open the PDB file for writing.
    tensor_pdb_file = open_write_file(file, dir, force=force)

    # Write the data.
    structure.write_pdb(tensor_pdb_file)

    # Close the file.
    tensor_pdb_file.close()

    # Add the file to the results file list.
    if not hasattr(cdp, 'result_files'):
        cdp.result_files = []
    if dir == None:
        dir = getcwd()
    cdp.result_files.append(['rotor_pdb', 'Rotor PDB', get_file_path(file, dir)])
    status.observers.result_file.notify()
Example #2
0
axis2 = axis2 / norm(axis2)

# The 3D positions 10 Angstrom away.
pos1 = axis1 * 10.0 + COM_N 
pos2 = axis2 * 10.0 + COM_C 

# A storage data pipe.
pipe.create('system', 'N-state')

# Create the CoM central piece.
structure.add_atom(atom_name='CN', res_name='SYS', res_num=1, pos=COM_N, element='C', pdb_record='HETATM')
structure.add_atom(atom_name='CC', res_name='SYS', res_num=1, pos=COM_C, element='C', pdb_record='HETATM')
structure.connect_atom(index1=0, index2=1)

# Create a PDB representation of the rotors.
rotor(structure=cdp.structure, rotor_angle=radians(10.5), axis=axis1, axis_pt=pos1, centre=COM_N, span=2e-9, blade_length=5e-10, staggered=False)
rotor(structure=cdp.structure, rotor_angle=radians(11.5), axis=axis2, axis_pt=pos2, centre=COM_C, span=2e-9, blade_length=5e-10, staggered=False)

# Write out the system.
state.save('system', force=True)
structure.write_pdb(file='system.pdb', force=True)

# Save the state.
state.save('system', force=True)

# Printouts.
print("\n")
print("N-domain COM: %s" % COM_N)
print("C-domain COM: %s" % COM_C)
print("Axis 1:       %s" % repr(axis1))
print("Axis 2:       %s" % repr(axis2))
Example #3
0
axis2 = axis2 / norm(axis2)

# The 3D positions 10 Angstrom away.
pos1 = axis1 * 10.0 + COM_N 
pos2 = axis2 * 10.0 + COM_C 

# A storage data pipe.
pipe.create('system', 'N-state')

# Create the CoM central piece.
structure.add_atom(atom_name='CN', res_name='SYS', res_num=1, pos=COM_N, element='C', pdb_record='HETATM')
structure.add_atom(atom_name='CC', res_name='SYS', res_num=1, pos=COM_C, element='C', pdb_record='HETATM')
structure.connect_atom(index1=0, index2=1)

# Create a PDB representation of the rotors.
rotor(structure=cdp.structure, rotor_angle=radians(10.5), axis=axis1, axis_pt=pos1, centre=COM_N, span=2e-9, blade_length=5e-10, staggered=False)
rotor(structure=cdp.structure, rotor_angle=radians(11.5), axis=axis2, axis_pt=pos2, centre=COM_C, span=2e-9, blade_length=5e-10, staggered=False)

# Write out the system.
state.save('system', force=True)
structure.write_pdb(file='system.pdb', force=True)

# Save the state.
state.save('system', force=True)

# Printouts.
print("\n")
print("N-domain COM: %s" % COM_N)
print("C-domain COM: %s" % COM_C)
print("Axis 1:       %s" % repr(axis1))
print("Axis 2:       %s" % repr(axis2))
Example #4
0
def create_rotor_pdb(file=None,
                     dir=None,
                     rotor_angle=None,
                     axis=None,
                     axis_pt=True,
                     centre=None,
                     span=2e-9,
                     blade_length=5e-10,
                     force=False,
                     staggered=False):
    """Create a PDB representation of a rotor motional model.

    @keyword file:          The name of the PDB file to create.
    @type file:             str
    @keyword dir:           The name of the directory to place the PDB file into.
    @type dir:              str
    @keyword rotor_angle:   The angle of the rotor motion in degrees.
    @type rotor_angle:      float
    @keyword axis:          The vector defining the rotor axis.
    @type axis:             numpy rank-1, 3D array
    @keyword axis_pt:       A point lying anywhere on the rotor axis.  This is used to define the position of the axis in 3D space.
    @type axis_pt:          numpy rank-1, 3D array
    @keyword centre:        The central point of the representation.  If this point is not on the rotor axis, then the closest point on the axis will be used for the centre.
    @type centre:           numpy rank-1, 3D array
    @keyword span:          The distance from the central point to the rotor blades (meters).
    @type span:             float
    @keyword blade_length:  The length of the representative rotor blades.
    @type blade_length:     float
    @keyword force:         A flag which if set will overwrite any pre-existing file.
    @type force:            bool
    @keyword staggered:     A flag which if True will cause the rotor blades to be staggered.  This is used to avoid blade overlap.
    @type staggered:        bool
    """

    # Test if the current pipe exists.
    check_pipe()

    # Convert the angle to radians.
    rotor_angle = rotor_angle / 360.0 * 2.0 * pi

    # Create the structural object.
    structure = Internal()

    # Generate the rotor object.
    rotor(structure=structure,
          rotor_angle=rotor_angle,
          axis=axis,
          axis_pt=axis_pt,
          centre=centre,
          span=span,
          blade_length=blade_length,
          staggered=staggered)

    # Print out.
    print("\nGenerating the PDB file.")

    # Open the PDB file for writing.
    tensor_pdb_file = open_write_file(file, dir, force=force)

    # Write the data.
    structure.write_pdb(tensor_pdb_file)

    # Close the file.
    tensor_pdb_file.close()

    # Add the file to the results file list.
    if not hasattr(cdp, 'result_files'):
        cdp.result_files = []
    if dir == None:
        dir = getcwd()
    cdp.result_files.append(
        ['rotor_pdb', 'Rotor PDB',
         get_file_path(file, dir)])
    status.observers.result_file.notify()
Example #5
0
def add_rotors(structure=None, representation=None, size=None, sims=False):
    """Add all rotor objects 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, the rotor will be dumbbell shaped with propellers at both ends.  If set to 'A' or 'B', only half of the rotor will be shown.
    @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
    """

    # Initialise the list structures for the rotor data.
    axis = []
    span = []
    staggered = []
    pivot = []
    rotor_angle = []
    com = []
    label = []
    models = []

    # The half-rotor flag.
    half_rotor = True
    if representation == None:
        half_rotor = False

    # 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)):
        # 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)

        # The single rotor models.
        if cdp.model in [MODEL_ROTOR, MODEL_FREE_ROTOR, MODEL_ISO_CONE, MODEL_ISO_CONE_FREE_ROTOR, MODEL_PSEUDO_ELLIPSE, MODEL_PSEUDO_ELLIPSE_FREE_ROTOR]:
            # The rotor angle.
            if cdp.model in MODEL_LIST_FREE_ROTORS:
                rotor_angle.append(pi)
            else:
                if sims:
                    rotor_angle.append(cdp.cone_sigma_max_sim[sim_indices[i]])
                else:
                    rotor_angle.append(cdp.cone_sigma_max)

            # Get the CoM of the entire molecule to use as the centre of the rotor.
            if cdp.model in [MODEL_ROTOR, MODEL_FREE_ROTOR]:
                com.append(pipe_centre_of_mass(verbosity=0, missing_error=False))
            else:
                com.append(pivot1)

            # Generate the rotor axis.
            axes = generate_axis_system(sim_index=sim_indices[i])
            axis.append(axes[:, 2])

            # The size of the rotor (Angstrom), taking the cone representation into account by adding 5 Angstrom.
            if cdp.model in [MODEL_ROTOR, MODEL_FREE_ROTOR]:
                span.append(size)
            else:
                span.append(size + 5.0)

            # Stagger the propeller blades.
            if cdp.model in MODEL_LIST_FREE_ROTORS:
                staggered.append(False)
            else:
                staggered.append(True)

            # The pivot.
            pivot.append(pivot1)

            # The label.
            label.append('z-ax')

            # The models.
            if sims:
                models.append(model_nums[i])
            else:
                models.append(None)

        # The double rotor models.
        elif cdp.model in [MODEL_DOUBLE_ROTOR]:
            # Add both rotor angles (the 2nd must come first).
            if sims:
                rotor_angle.append(cdp.cone_sigma_max_2_sim[sim_indices[i]])
                rotor_angle.append(cdp.cone_sigma_max_sim[sim_indices[i]])
            else:
                rotor_angle.append(cdp.cone_sigma_max_2)
                rotor_angle.append(cdp.cone_sigma_max)

            # Set the com to the pivot points.
            com.append(pivot2)
            com.append(pivot1)

            # Generate the eigenframe of the motion.
            frame = generate_axis_system(sim_index=sim_indices[i])

            # Add the x and y axes.
            axis.append(frame[:, 0])
            axis.append(frame[:, 1])

            # The rotor size (Angstrom).
            span.append(size)
            span.append(size)

            # Stagger the propeller blades.
            staggered.append(True)
            staggered.append(True)

            # The pivot points.
            pivot.append(pivot2)
            pivot.append(pivot1)

            # The labels.
            label.append('x-ax')
            label.append('y-ax')

            # The models.
            if sims:
                models.append(model_nums[i])
                models.append(model_nums[i])
            else:
                models.append(None)
                models.append(None)

    # Add each rotor to the structure as a new molecule.
    for i in range(len(axis)):
        rotor(structure=structure, rotor_angle=rotor_angle[i], axis=dot(T, axis[i]), axis_pt=pivot[i], label=label[i], centre=com[i], span=span[i]/1e10, blade_length=5e-10, model_num=models[i], staggered=staggered[i], half_rotor=half_rotor)
Example #6
0
def add_rotors(structure=None, representation=None, size=None, sims=False):
    """Add all rotor objects 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, the rotor will be dumbbell shaped with propellers at both ends.  If set to 'A' or 'B', only half of the rotor will be shown.
    @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
    """

    # Initialise the list structures for the rotor data.
    axis = []
    span = []
    staggered = []
    pivot = []
    rotor_angle = []
    com = []
    label = []
    models = []

    # The half-rotor flag.
    half_rotor = True
    if representation == None:
        half_rotor = False

    # 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)):
        # 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)

        # The single rotor models.
        if cdp.model in [
                MODEL_ROTOR, MODEL_FREE_ROTOR, MODEL_ISO_CONE,
                MODEL_ISO_CONE_FREE_ROTOR, MODEL_PSEUDO_ELLIPSE,
                MODEL_PSEUDO_ELLIPSE_FREE_ROTOR
        ]:
            # The rotor angle.
            if cdp.model in MODEL_LIST_FREE_ROTORS:
                rotor_angle.append(pi)
            else:
                if sims:
                    rotor_angle.append(cdp.cone_sigma_max_sim[sim_indices[i]])
                else:
                    rotor_angle.append(cdp.cone_sigma_max)

            # Get the CoM of the entire molecule to use as the centre of the rotor.
            if cdp.model in [MODEL_ROTOR, MODEL_FREE_ROTOR]:
                com.append(
                    pipe_centre_of_mass(verbosity=0, missing_error=False))
            else:
                com.append(pivot1)

            # Generate the rotor axis.
            axes = generate_axis_system(sim_index=sim_indices[i])
            axis.append(axes[:, 2])

            # The size of the rotor (Angstrom), taking the cone representation into account by adding 5 Angstrom.
            if cdp.model in [MODEL_ROTOR, MODEL_FREE_ROTOR]:
                span.append(size)
            else:
                span.append(size + 5.0)

            # Stagger the propeller blades.
            if cdp.model in MODEL_LIST_FREE_ROTORS:
                staggered.append(False)
            else:
                staggered.append(True)

            # The pivot.
            pivot.append(pivot1)

            # The label.
            label.append('z-ax')

            # The models.
            if sims:
                models.append(model_nums[i])
            else:
                models.append(None)

        # The double rotor models.
        elif cdp.model in [MODEL_DOUBLE_ROTOR]:
            # Add both rotor angles (the 2nd must come first).
            if sims:
                rotor_angle.append(cdp.cone_sigma_max_2_sim[sim_indices[i]])
                rotor_angle.append(cdp.cone_sigma_max_sim[sim_indices[i]])
            else:
                rotor_angle.append(cdp.cone_sigma_max_2)
                rotor_angle.append(cdp.cone_sigma_max)

            # Set the com to the pivot points.
            com.append(pivot2)
            com.append(pivot1)

            # Generate the eigenframe of the motion.
            frame = generate_axis_system(sim_index=sim_indices[i])

            # Add the x and y axes.
            axis.append(frame[:, 0])
            axis.append(frame[:, 1])

            # The rotor size (Angstrom).
            span.append(size)
            span.append(size)

            # Stagger the propeller blades.
            staggered.append(True)
            staggered.append(True)

            # The pivot points.
            pivot.append(pivot2)
            pivot.append(pivot1)

            # The labels.
            label.append('x-ax')
            label.append('y-ax')

            # The models.
            if sims:
                models.append(model_nums[i])
                models.append(model_nums[i])
            else:
                models.append(None)
                models.append(None)

    # Add each rotor to the structure as a new molecule.
    for i in range(len(axis)):
        rotor(structure=structure,
              rotor_angle=rotor_angle[i],
              axis=dot(T, axis[i]),
              axis_pt=pivot[i],
              label=label[i],
              centre=com[i],
              span=span[i] / 1e10,
              blade_length=5e-10,
              model_num=models[i],
              staggered=staggered[i],
              half_rotor=half_rotor)