Package prompt :: Module deselect
[hide private]
[frames] | no frames]

Source Code for Module prompt.deselect

  1  ############################################################################### 
  2  #                                                                             # 
  3  # Copyright (C) 2003-2011 Edward d'Auvergne                                   # 
  4  #                                                                             # 
  5  # This file is part of the program relax.                                     # 
  6  #                                                                             # 
  7  # relax 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 2 of the License, or           # 
 10  # (at your option) any later version.                                         # 
 11  #                                                                             # 
 12  # relax 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 relax; if not, write to the Free Software                        # 
 19  # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA   # 
 20  #                                                                             # 
 21  ############################################################################### 
 22   
 23  # Module docstring. 
 24  """Module containing the 'deselect' user function class.""" 
 25  __docformat__ = 'plaintext' 
 26   
 27  # Python module imports. 
 28  from select import boolean_doc 
 29   
 30  # relax module imports. 
 31  from base_class import User_fn_class, _build_doc 
 32  import arg_check 
 33  from generic_fns import selection 
 34   
 35   
36 -class Deselect(User_fn_class):
37 """Class for deselecting spins.""" 38
39 - def all(self):
40 # Function intro test. 41 if self._exec_info.intro: 42 text = self._exec_info.ps3 + "deselect.all()" 43 print(text) 44 45 # Execute the functional code. 46 selection.desel_all()
47 48 # The function doc info. 49 all._doc_title = "Deselect all spins." 50 all._doc_desc = """ 51 This will deselect all spins, irregardless of their current state. 52 """ 53 all._doc_examples = """ 54 To deselect all spins, simply type: 55 56 relax> deselect.all() 57 """ 58 _build_doc(all) 59 60
61 - def read(self, file=None, dir=None, spin_id_col=None, mol_name_col=None, res_num_col=None, res_name_col=None, spin_num_col=None, spin_name_col=None, sep=None, spin_id=None, boolean='AND', change_all=False):
62 # Function intro test. 63 if self._exec_info.intro: 64 text = self._exec_info.ps3 + "deselect.read(" 65 text = text + "file=" + repr(file) 66 text = text + ", dir=" + repr(dir) 67 text = text + ", spin_id_col=" + repr(spin_id_col) 68 text = text + ", mol_name_col=" + repr(mol_name_col) 69 text = text + ", res_num_col=" + repr(res_num_col) 70 text = text + ", res_name_col=" + repr(res_name_col) 71 text = text + ", spin_num_col=" + repr(spin_num_col) 72 text = text + ", spin_name_col=" + repr(spin_name_col) 73 text = text + ", sep=" + repr(sep) 74 text = text + ", spin_id=" + repr(spin_id) 75 text = text + ", boolean=" + repr(boolean) 76 text = text + ", change_all=" + repr(change_all) + ")" 77 print(text) 78 79 # The argument checks. 80 arg_check.is_str_or_inst(file, 'file name') 81 arg_check.is_str(dir, 'directory name', can_be_none=True) 82 arg_check.is_int(spin_id_col, 'spin ID string column', can_be_none=True) 83 arg_check.is_int(mol_name_col, 'molecule name column', can_be_none=True) 84 arg_check.is_int(res_num_col, 'residue number column', can_be_none=True) 85 arg_check.is_int(res_name_col, 'residue name column', can_be_none=True) 86 arg_check.is_int(spin_num_col, 'spin number column', can_be_none=True) 87 arg_check.is_int(spin_name_col, 'spin name column', can_be_none=True) 88 arg_check.is_str(sep, 'column separator', can_be_none=True) 89 arg_check.is_str(spin_id, 'spin ID string', can_be_none=True) 90 arg_check.is_str(boolean, 'boolean operator') 91 arg_check.is_bool(change_all, 'change all') 92 93 # Execute the functional code. 94 selection.desel_read(file=file, dir=dir, spin_id_col=spin_id_col, mol_name_col=mol_name_col, res_num_col=res_num_col, res_name_col=res_name_col, spin_num_col=spin_num_col, spin_name_col=spin_name_col, sep=sep, spin_id=spin_id, boolean=boolean, change_all=change_all)
95 96 # The function doc info. 97 read._doc_title = "Deselect the spins contained in a file." 98 read._doc_title_short = "Deselecting spins from file." 99 read._doc_args = [ 100 ["file", "The name of the file containing the list of spins to deselect."], 101 ["dir", "The directory where the file is located."], 102 ["spin_id_col", "The spin ID string column (an alternative to the mol, res, and spin name and number columns)."], 103 ["mol_name_col", "The molecule name column (alternative to the spin_id_col)."], 104 ["res_num_col", "The residue number column (alternative to the spin_id_col)."], 105 ["res_name_col", "The residue name column (alternative to the spin_id_col)."], 106 ["spin_num_col", "The spin number column (alternative to the spin_id_col)."], 107 ["spin_name_col", "The spin name column (alternative to the spin_id_col)."], 108 ["data_col", "The RDC data column."], 109 ["error_col", "The experimental error column."], 110 ["sep", "The column separator (the default is white space)."], 111 ["spin_id", "The spin ID string to restrict the loading of data to certain spin subsets."], 112 ["boolean", "The boolean operator specifying how spins should be selected."], 113 ["change_all", "A flag specifying if all other spins should be changed."] 114 ] 115 read._doc_desc = """ 116 The spin system can be identified in the file using two different formats. The first is the spin ID string column which can include the molecule name, the residue name and number, and the spin name and number. Alternatively the molecule name, residue number, residue name, spin number and/or spin name columns can be supplied allowing this information to be in separate columns. Note that the numbering of columns starts at one. The spin ID string can be used to restrict the reading to certain spin types, for example only 15N spins when only residue information is in the file. 117 118 Empty lines and lines beginning with a hash are ignored. 119 120 The 'change all' flag default is False meaning that all spins currently either selected or deselected will remain that way. Setting this to True will cause all spins not specified in the file to be selected. 121 """ 122 read._doc_examples = """ 123 To deselect all overlapped residues listed with residue numbers in the first column of the 124 file 'unresolved', type one of: 125 126 relax> deselect.read('unresolved', res_num_col=1) 127 relax> deselect.read(file='unresolved', res_num_col=1) 128 129 To deselect the spins in the second column of the relaxation data file 'r1.600' while 130 selecting all other spins, for example type: 131 132 relax> deselect.read('r1.600', spin_num_col=2, change_all=True) 133 relax> deselect.read(file='r1.600', spin_num_col=2, change_all=True) 134 """ 135 read._doc_additional = [boolean_doc] 136 _build_doc(read) 137 138
139 - def reverse(self, spin_id=None):
140 # Function intro test. 141 if self._exec_info.intro: 142 text = self._exec_info.ps3 + "deselect.reverse(" 143 text = text + "spin_id=" + repr(spin_id) + ")" 144 print(text) 145 146 # The argument checks. 147 arg_check.is_str(spin_id, 'spin ID string', can_be_none=True) 148 149 # Execute the functional code. 150 selection.reverse(spin_id=spin_id)
151 152 # The function doc info. 153 reverse._doc_title = "Reversal of the spin selection for the given spins." 154 reverse._doc_title_short = "Spin selection reversal." 155 reverse._doc_args = [ 156 ["spin_id", "The spin ID string."] 157 ] 158 reverse._doc_desc = """ 159 By supplying the spin ID string, a subset of spins can have their selection status reversed. 160 """ 161 reverse._doc_examples = """ 162 To deselect all currently selected spins and select those which are deselected type: 163 164 relax> deselect.reverse() 165 """ 166 _build_doc(reverse) 167 168
169 - def spin(self, spin_id=None, change_all=False):
170 # Function intro test. 171 if self._exec_info.intro: 172 text = self._exec_info.ps3 + "deselect.spin(" 173 text = text + "spin_id=" + repr(spin_id) 174 text = text + ", change_all=" + repr(change_all) + ")" 175 print(text) 176 177 # The argument checks. 178 arg_check.is_str(spin_id, 'spin ID string', can_be_none=True) 179 arg_check.is_bool(change_all, 'change all') 180 181 # Execute the functional code. 182 selection.desel_spin(spin_id=spin_id, change_all=change_all)
183 184 # The function doc info. 185 spin._doc_title = "Deselect specific spins." 186 spin._doc_args = [ 187 ["spin_id", "The spin ID string."], 188 ["change_all", "A flag specifying if all other spins should be changed."] 189 ] 190 spin._doc_desc = """ 191 The 'change all' flag default is False meaning that all spins currently either selected or deselected will remain that way. Setting this to True will cause all spins not specified by the spin ID string to be selected. 192 """ 193 spin._doc_examples = """ 194 To deselect all glycines and alanines, type: 195 196 relax> deselect.spin(spin_id=':GLY|:ALA') 197 198 To deselect residue 12 MET type: 199 200 relax> deselect.spin(':12') 201 relax> deselect.spin(spin_id=':12') 202 relax> deselect.spin(spin_id=':12&:MET') 203 """ 204 _build_doc(spin)
205