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

Source Code for Module pipe_control.grace

  1  ############################################################################### 
  2  #                                                                             # 
  3  # Copyright (C) 2003-2015 Edward d'Auvergne                                   # 
  4  #                                                                             # 
  5  # This file is part of the program relax (http://www.nmr-relax.com).          # 
  6  #                                                                             # 
  7  # This program is free software: you can redistribute it and/or modify        # 
  8  # it under the terms of the GNU General Public License as published by        # 
  9  # the Free Software Foundation, either version 3 of the License, or           # 
 10  # (at your option) any later version.                                         # 
 11  #                                                                             # 
 12  # This program is distributed in the hope that it will be useful,             # 
 13  # but WITHOUT ANY WARRANTY; without even the implied warranty of              # 
 14  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               # 
 15  # GNU General Public License for more details.                                # 
 16  #                                                                             # 
 17  # You should have received a copy of the GNU General Public License           # 
 18  # along with this program.  If not, see <http://www.gnu.org/licenses/>.       # 
 19  #                                                                             # 
 20  ############################################################################### 
 21   
 22  # Module docstring. 
 23  """Module for interfacing with Grace (also known as Xmgrace, Xmgr, and ace).""" 
 24   
 25  # Python module imports. 
 26  from os import system 
 27   
 28  # relax module imports. 
 29  from lib.io import get_file_path, test_binary 
 30  from pipe_control.mol_res_spin import count_molecules, count_residues, count_spins 
 31  from specific_analyses.api import return_api 
 32  from status import Status; status = Status() 
 33   
 34   
35 -def determine_seq_type(spin_id=None):
36 """Determine the spin sequence data type. 37 38 The purpose is to identify systems whereby only spins or only residues exist. 39 40 @keyword spin_id: The spin identification string. 41 @type spin_id: str 42 @return: The spin sequence data type. This can be one of 'spin', 'res,' or 'mixed'. 43 @rtype: str 44 """ 45 46 # Count the molecules, residues, and spins. 47 num_mol = count_molecules(spin_id) 48 num_res = count_residues(spin_id) 49 num_spin = count_spins(spin_id) 50 51 # Only residues. 52 if num_mol == 1 and num_spin == 1: 53 return 'res' 54 55 # Only spins. 56 if num_mol == 1 and num_res == 1: 57 return 'spin' 58 59 # Mixed. 60 return 'mixed'
61 62
63 -def get_data_types():
64 """Get all of the data types to plot for the current data pipe. 65 66 @return: A list of lists of all the allowable data type descriptions and their values. 67 @rtype: list of list of str 68 """ 69 70 # The specific analysis API object. 71 api = return_api() 72 73 # Return an empty list if the required functions are absent. 74 if not hasattr(api, 'data_names') or not hasattr(api, 'return_data_desc'): 75 return [] 76 77 # The data names, if they exist. 78 names = api.data_names(set='params') 79 80 # Initialise the list and then add the sequence data. 81 data = [] 82 data.append(["Spin sequence", 'spin']) 83 84 # Loop over the parameters. 85 for name in (api.data_names(set='params') + api.data_names(set='generic') + api.data_names(set='min')): 86 # Get the description. 87 try: 88 desc = api.return_data_desc(name) 89 except: 90 return [] 91 92 # No description. 93 if not desc: 94 text = name 95 96 # The text. 97 else: 98 text = "'%s': %s" % (name, desc) 99 100 # Append the description. 101 data.append([text, name]) 102 103 # Return the data. 104 return data
105 106
107 -def view(file=None, dir=None, grace_exe='xmgrace'):
108 """Execute Grace. 109 110 @keyword file: The name of the file to open in Grace. 111 @type file: str 112 @keyword dir: The optional directory containing the file. 113 @type dir: str 114 @keyword grace_exe: The name of the Grace executable file. This should be located within the 115 system path. 116 @type grace_exe: str 117 """ 118 119 # Test the binary file string corresponds to a valid executable. 120 test_binary(grace_exe) 121 122 # File path. 123 file_path = get_file_path(file, dir) 124 125 # Run Grace. 126 system(grace_exe + " \"" + file_path + "\" &")
127