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

Source Code for Module pipe_control.grace

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