def cartoon(): """Apply the PyMOL cartoon style and colour by secondary structure.""" # Test if the current data pipe exists. pipes.test() # Test for the structure. if not hasattr(cdp, 'structure'): raise RelaxNoPdbError # Loop over the PDB files. open_files = [] for model in cdp.structure.structural_data: for mol in model.mol: # Identifier. pdb_file = mol.file_name if mol.file_path: pdb_file = mol.file_path + sep + pdb_file id = file_root(pdb_file) # Already loaded. if pdb_file in open_files: continue # Add to the open file list. open_files.append(pdb_file) # Hide everything. pymol_obj.exec_cmd("cmd.hide('everything'," + repr(id) + ")") # Show the cartoon style. pymol_obj.exec_cmd("cmd.show('cartoon'," + repr(id) + ")") # Colour by secondary structure. pymol_obj.exec_cmd("util.cbss(" + repr(id) + ", 'red', 'yellow', 'green')")
def cartoon(): """Apply the PyMOL cartoon style and colour by secondary structure.""" # Test if the current data pipe exists. check_pipe() # Test for the structure. if not hasattr(cdp, 'structure'): raise RelaxNoPdbError # Loop over the PDB files. open_files = [] for model in cdp.structure.structural_data: for mol in model.mol: # Identifier. pdb_file = mol.file_name if mol.file_path: pdb_file = mol.file_path + sep + pdb_file id = file_root(pdb_file) # Already loaded. if pdb_file in open_files: continue # Add to the open file list. open_files.append(pdb_file) # Hide everything. pymol_obj.exec_cmd("cmd.hide('everything'," + repr(id) + ")") # Show the cartoon style. pymol_obj.exec_cmd("cmd.show('cartoon'," + repr(id) + ")") # Colour by secondary structure. pymol_obj.exec_cmd("util.cbss(" + repr(id) + ", 'red', 'yellow', 'green')")
def show_apod_rmsd_to_file(file_name=None, dir=None, path_to_command='showApod', outdir=None, force=False): """Extract showApod 'Noise Std Dev' from showApod, and write to file with same filename and ending '.rmsd' @keyword file: The filename of the NMRPipe fourier transformed file. @type file: str @keyword dir: The directory where the file is located. @type dir: str @keyword path_to_command: If showApod not in PATH, then specify absolute path as: /path/to/showApod @type path_to_command: str @keyword outdir: The directory where to write the file. If 'None', then write in same directory. @type outdir: str @param force: Boolean argument which if True causes the file to be overwritten if it already exists. @type force: bool @return: Write the 'Noise Std Dev' from showApod to a file with same file filename, with ending '.rmsd'. This will be a file path. @rtype: str """ # Call extract function. apod_rmsd = show_apod_rmsd(file_name=file_name, dir=dir, path_to_command=path_to_command) # Get the filename striped of extension details. file_name_root = file_root(file_name) # Define extension. extension = ".rmsd" # Define file name for writing. file_name_out = file_name_root + extension # Define folder to write to. if outdir == None: write_outdir = dir else: write_outdir = outdir # Open file for writing, wfile, wfile_path = open_write_file(file_name=file_name_out, dir=write_outdir, force=force, verbosity=1, return_path=True) # Write to file. out_write_data = [['%s'%apod_rmsd]] # Write data write_data(out=wfile, headings=None, data=out_write_data, sep=None) # Close file. wfile.close() # Return path to file. return wfile_path
def setUp(self): """Set up for all the internal relax structural object unit tests.""" # The path to a PDB file. self.test_pdb_path = status.install_path+sep+'test_suite'+sep+'shared_data'+sep+'structures'+sep+'Ap4Aase_res1-12.pdb' expanded = path.split(self.test_pdb_path) self.test_pdb_dir = expanded[0] self.test_pdb_file_name = expanded[1] self.test_pdb_root = file_root(self.test_pdb_path) # Instantiate the structural data object. self.data = Internal() # Instantiate a MolContainer object. self.mol_cont = MolContainer()
def frame_order_geometric(root=None, path=None): """Display the frame order geometric object. @keyword root: The file root of the PDB file containing the frame order geometric object. @type root: str """ # Find all PDB files. pdb_files = find_pdb_files(path=path, file_root=root) pdb_files += find_pdb_files(path=path, file_root=root+'_A') pdb_files += find_pdb_files(path=path, file_root=root+'_B') pdb_files += find_pdb_files(path=path, file_root=root+'_sim') pdb_files += find_pdb_files(path=path, file_root=root+'_sim_A') pdb_files += find_pdb_files(path=path, file_root=root+'_sim_B') # Read in the PDB files. for file in pdb_files: # Read in the PDB file. pymol_obj.exec_cmd("load " + file) # The object ID. id = file_root(file) # First hide everything. pymol_obj.exec_cmd("select %s" % id) pymol_obj.exec_cmd("hide ('sele')") pymol_obj.exec_cmd("cmd.delete('sele')") # Set up the titles. represent_titles(id=id) # Set up the pivot points. represent_pivots(id=id) # Set up the rotor objects. represent_rotor_object(id=id) # Set up the cone axis. represent_cone_axis(id=id) # Set up the cone object. represent_cone_object(id=id) # Disable the MC simulation representation - the user can find this out for themselves. pymol_obj.exec_cmd("disable %s_sim" % root) pymol_obj.exec_cmd("disable %s_sim_A" % root) pymol_obj.exec_cmd("disable %s_sim_B" % root)
def frame_order_geometric(root=None, path=None): """Display the frame order geometric object. @keyword root: The file root of the PDB file containing the frame order geometric object. @type root: str """ # Find all PDB files. pdb_files = find_pdb_files(path=path, file_root=root) pdb_files += find_pdb_files(path=path, file_root=root + '_A') pdb_files += find_pdb_files(path=path, file_root=root + '_B') pdb_files += find_pdb_files(path=path, file_root=root + '_sim') pdb_files += find_pdb_files(path=path, file_root=root + '_sim_A') pdb_files += find_pdb_files(path=path, file_root=root + '_sim_B') # Read in the PDB files. for file in pdb_files: # Read in the PDB file. pymol_obj.exec_cmd("load " + file) # The object ID. id = file_root(file) # First hide everything. pymol_obj.exec_cmd("select %s" % id) pymol_obj.exec_cmd("hide ('sele')") pymol_obj.exec_cmd("cmd.delete('sele')") # Set up the titles. represent_titles(id=id) # Set up the pivot points. represent_pivots(id=id) # Set up the rotor objects. represent_rotor_object(id=id) # Set up the cone axis. represent_cone_axis(id=id) # Set up the cone object. represent_cone_object(id=id) # Disable the MC simulation representation - the user can find this out for themselves. pymol_obj.exec_cmd("disable %s_sim" % root) pymol_obj.exec_cmd("disable %s_sim_A" % root) pymol_obj.exec_cmd("disable %s_sim_B" % root)
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 object ID. id = file_root(file) # The cone axes. represent_cone_axis(id=id) # The cone object. represent_cone_object(id=id)
def frame_order_ave_pos(root=None, path=None): """Display the PDB structure for the frame order average domain position. @keyword root: The file root of the PDB file containing the frame order average structure. @type root: str """ # Find all PDB files. pdb_files = find_pdb_files(path=path, file_root=root) pdb_files += find_pdb_files(path=path, file_root=root+'_sim') # Read in the PDB files. for file in pdb_files: pymol_obj.exec_cmd("load " + file) # The object ID. id = file_root(file) # Disable the MC simulation representation - the user can find this out for themselves. pymol_obj.exec_cmd("disable %s_sim" % root)
def frame_order_ave_pos(root=None, path=None): """Display the PDB structure for the frame order average domain position. @keyword root: The file root of the PDB file containing the frame order average structure. @type root: str """ # Find all PDB files. pdb_files = find_pdb_files(path=path, file_root=root) pdb_files += find_pdb_files(path=path, file_root=root + '_sim') # Read in the PDB files. for file in pdb_files: pymol_obj.exec_cmd("load " + file) # The object ID. id = file_root(file) # Disable the MC simulation representation - the user can find this out for themselves. pymol_obj.exec_cmd("disable %s_sim" % root)
def vector_dist(file=None): """Display the XH bond vector distribution. @keyword file: The vector distribution PDB file. @type file: str """ # Test if the current data pipe exists. check_pipe() # The file root. id = file_root(file) # Read in the vector distribution PDB file. pymol_obj.exec_cmd("load " + file) # Create a surface. ################### # Select the vector distribution. pymol_obj.exec_cmd("cmd.show('surface', " + repr(id) + ")")
def vector_dist(file=None): """Display the XH bond vector distribution. @keyword file: The vector distribution PDB file. @type file: str """ # Test if the current data pipe exists. pipes.test() # The file root. id = file_root(file) # Read in the vector distribution PDB file. pymol_obj.exec_cmd("load " + file) # Create a surface. ################### # Select the vector distribution. pymol_obj.exec_cmd("cmd.show('surface', " + repr(id) + ")")
def correlation_matrix(matrix=None, labels=None, file=None, dir=None, force=False): """Gnuplot plotting function for representing correlation matrices. @keyword matrix: The correlation matrix. This must be a square matrix. @type matrix: numpy rank-2 array. @keyword labels: The labels for each element of the matrix. The same label is assumed for each [i, i] pair in the matrix. @type labels: list of str @keyword file: The name of the file to create. @type file: str @keyword dir: The directory where the PDB file will be placed. If set to None, then the file will be placed in the current directory. @type dir: str or None """ # The dimensions. n = len(matrix) # Generate the text file for loading into gnuplot. text.correlation_matrix(matrix=matrix, labels=labels, file=file, dir=dir, force=force) # The script file name with the extension swapped. file_name = swap_extension(file=file, ext='gnu') # Open the script file for writing. output = open_write_file(file_name, dir=dir, force=force) # Gnuplot script setup. output.write("#!/usr/bin/env gnuplot\n\n") # Set up the terminal type and make the plot square. output.write("# Set up the terminal type and make the plot square.\n") output.write("set terminal postscript eps size 10,10 enhanced color font 'Helvetica,20' linewidth 0.1\n") output.write("set size square\n") # The colour map. output.write("\n# Blue-red colour map.\n") output.write("set palette model RGB\n") output.write("set palette defined\n") # The labels. if labels != None: output.write("\n# Labels.\n") for axis in ['x', 'y']: output.write("set %stics out " % axis) if axis == 'x': output.write("rotate ") output.write("font \",8\" (") for i in range(n): if i != 0: output.write(", ") output.write("\"%s\" %s" % (format_enhanced(labels[i]), i)) output.write(")\n") # Output to EPS. output.write("\n# Output to EPS.\n") output.write("set output \"%s.eps\"\n" % file_root(file)) # Load and show the text data. output.write("\n# Load and show the text data\n") output.write("plot \"%s\" matrix with image\n" % file) # Close the file. output.close() # Make the script executable. chmod(get_file_path(file_name=file_name, dir=dir), S_IRWXU|S_IRGRP|S_IROTH)
def correlation_matrix(matrix=None, labels=None, file=None, dir=None, force=False): """Gnuplot plotting function for representing correlation matrices. @keyword matrix: The correlation matrix. This must be a square matrix. @type matrix: numpy rank-2 array. @keyword labels: The labels for each element of the matrix. The same label is assumed for each [i, i] pair in the matrix. @type labels: list of str @keyword file: The name of the file to create. @type file: str @keyword dir: The directory where the PDB file will be placed. If set to None, then the file will be placed in the current directory. @type dir: str or None """ # The dimensions. n = len(matrix) # Generate the text file for loading into gnuplot. text.correlation_matrix(matrix=matrix, labels=labels, file=file, dir=dir, force=force) # The script file name with the extension swapped. file_name = swap_extension(file=file, ext='gnu') # Open the script file for writing. output = open_write_file(file_name, dir=dir, force=force) # Gnuplot script setup. output.write("#!/usr/bin/env gnuplot\n\n") # Set up the terminal type and make the plot square. output.write("# Set up the terminal type and make the plot square.\n") output.write( "set terminal postscript eps size 10,10 enhanced color font 'Helvetica,20' linewidth 0.1\n" ) output.write("set size square\n") # The colour map. output.write("\n# Blue-red colour map.\n") output.write("set palette model RGB\n") output.write("set palette defined\n") # The labels. if labels != None: output.write("\n# Labels.\n") for axis in ['x', 'y']: output.write("set %stics out " % axis) if axis == 'x': output.write("rotate ") output.write("font \",8\" (") for i in range(n): if i != 0: output.write(", ") output.write("\"%s\" %s" % (format_enhanced(labels[i]), i)) output.write(")\n") # Output to EPS. output.write("\n# Output to EPS.\n") output.write("set output \"%s.eps\"\n" % file_root(file)) # Load and show the text data. output.write("\n# Load and show the text data\n") output.write("plot \"%s\" matrix with image\n" % file) # Close the file. output.close() # Make the script executable. chmod(get_file_path(file_name=file_name, dir=dir), S_IRWXU | S_IRGRP | S_IROTH)