Package bmrblib :: Package kinetics :: Module relaxation
[hide private]
[frames] | no frames]

Source Code for Module bmrblib.kinetics.relaxation

  1  ############################################################################# 
  2  #                                                                           # 
  3  # The BMRB library.                                                         # 
  4  #                                                                           # 
  5  # Copyright (C) 2009-2011 Edward d'Auvergne                                 # 
  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  """The relaxation data BMRB API interface.""" 
 24   
 25   
 26  # relax module imports. 
 27  from bmrblib.kinetics.auto_relaxation_v3_1 import AutoRelaxationSaveframe_v3_1 
 28  from bmrblib.kinetics.heteronucl_NOEs_v2_1 import HeteronuclNOESaveframe_v2_1 
 29  from bmrblib.kinetics.heteronucl_NOEs_v3_1 import HeteronuclNOESaveframe_v3_1 
 30  from bmrblib.kinetics.heteronucl_T1_relaxation_v2_1 import HeteronuclT1Saveframe_v2_1 
 31  from bmrblib.kinetics.heteronucl_T1_relaxation_v3_1 import HeteronuclT1Saveframe_v3_1 
 32  from bmrblib.kinetics.heteronucl_T2_relaxation_v2_1 import HeteronuclT2Saveframe_v2_1 
 33  from bmrblib.kinetics.heteronucl_T2_relaxation_v3_1 import HeteronuclT2Saveframe_v3_1 
 34   
 35   
36 -class Relaxation_v2_1:
37 """Class for the relaxation data part of the BMRB API.""" 38
39 - def __init__(self, datanodes):
40 """Initialise the class, placing the pystarlib data nodes into the namespace. 41 42 @param datanodes: The pystarlib data nodes object. 43 @type datanodes: list 44 """ 45 46 # Initialise the kinetic saveframe supergroups. 47 self.heteronucl_NOEs = HeteronuclNOESaveframe_v2_1(datanodes) 48 self.heteronucl_T1_relaxation = HeteronuclT1Saveframe_v2_1(datanodes) 49 self.heteronucl_T2_relaxation = HeteronuclT2Saveframe_v2_1(datanodes)
50 51
52 - def add(self, **keywords):
53 """Distribute the relaxation data to the appropriate saveframes. 54 55 @keyword data_type: The relaxation data type (one of 'NOE', 'R1', or 'R2'). 56 @type data_type: str 57 @keyword sample_cond_list_id: The sample conditions list ID number. 58 @type sample_cond_list_id: str 59 @keyword sample_cond_list_label: The sample conditions list label. 60 @type sample_cond_list_label: str 61 @keyword temp_calibration: The temperature calibration method (unused). 62 @type temp_calibration: str 63 @keyword temp_control: The temperature control method (unused). 64 @type temp_control: str 65 @keyword peak_intensity_type: The peak intensity type - one of 'height' or 'volume'. 66 @type peak_intensity_type: str 67 @keyword frq: The spectrometer proton frequency, in Hz. 68 @type frq: float 69 @keyword details: The details tag. 70 @type details: None or str 71 @keyword assembly_atom_ids: The assembly atom ID numbers. 72 @type assembly_atom_ids: list of int 73 @keyword entity_assembly_ids: The entity assembly ID numbers. 74 @type entity_assembly_ids: list of int 75 @keyword entity_ids: The entity ID numbers. 76 @type entity_ids: int 77 @keyword res_nums: The residue number list. 78 @type res_nums: list of int 79 @keyword res_names: The residue name list. 80 @type res_names: list of str 81 @keyword atom_names: The atom name list. 82 @type atom_names: list of str 83 @keyword atom_types: The atom types as IUPAC element abbreviations. 84 @type atom_types: list of str 85 @keyword isotope: The isotope type list, ie 15 for '15N'. 86 @type isotope: list of int 87 @keyword assembly_atom_ids_2: The assembly atom ID numbers. This is for the second atom used in the heteronuclear NOE. 88 @type assembly_atom_ids_2: list of int 89 @keyword entity_assembly_ids_2: The entity assembly ID numbers. This is for the second atom used in the heteronuclear NOE. 90 @type entity_assembly_ids_2: list of int 91 @keyword entity_ids_2: The entity ID numbers. This is for the second atom used in the heteronuclear NOE. 92 @type entity_ids_2: int 93 @keyword res_nums_2: The residue number list. This is for the second atom used in the heteronuclear NOE. 94 @type res_nums_2: list of int 95 @keyword res_names_2: The residue name list. This is for the second atom used in the heteronuclear NOE. 96 @type res_names_2: list of str 97 @keyword atom_names_2: The atom name list. This is for the second atom used in the heteronuclear NOE. 98 @type atom_names_2: list of str 99 @keyword atom_types_2: The atom types as IUPAC element abbreviations. This is for the second atom used in the heteronuclear NOE. 100 @type atom_types_2: list of str 101 @keyword isotope_2: The isotope type list, ie 1 for '1H'. This is for the second atom used in the heteronuclear NOE. 102 @type isotope_2: list of int 103 @keyword data: The relaxation data. 104 @type data: list of float 105 @keyword errors: The errors associated with the relaxation data. 106 @type errors: list of float 107 """ 108 109 # Pack specific the data. 110 if keywords['data_type'] == 'R1': 111 self.heteronucl_T1_relaxation.add(**keywords) 112 elif keywords['data_type'] == 'R2': 113 self.heteronucl_T2_relaxation.add(**keywords) 114 elif keywords['data_type'] == 'NOE': 115 self.heteronucl_NOEs.add(**keywords)
116 117
118 - def loop(self):
119 """Generator method for looping over and returning all relaxation data.""" 120 121 # The NOE data. 122 for data in self.heteronucl_NOEs.loop(): 123 data['data_type'] = 'NOE' 124 yield data 125 126 # The R1 data. 127 for data in self.heteronucl_T1_relaxation.loop(): 128 data['data_type'] = 'R1' 129 yield data 130 131 # The R2 data. 132 for data in self.heteronucl_T2_relaxation.loop(): 133 data['data_type'] = 'R2' 134 yield data
135 136 137
138 -class Relaxation_v3_0(Relaxation_v2_1):
139 """Class for the relaxation data part of the BMRB API (v3.0).""" 140
141 - def __init__(self, datanodes):
142 """Initialise the class, placing the pystarlib data nodes into the namespace. 143 144 @param datanodes: The pystarlib data nodes object. 145 @type datanodes: list 146 """ 147 148 # Execute the base class __init__() method. 149 Relaxation_v2_1.__init__(self, datanodes)
150 151 152
153 -class Relaxation_v3_1(Relaxation_v3_0):
154 """Class for the relaxation data part of the BMRB API (v3.1).""" 155
156 - def __init__(self, datanodes):
157 """Initialise the class, placing the pystarlib data nodes into the namespace. 158 159 @param datanodes: The pystarlib data nodes object. 160 @type datanodes: list 161 """ 162 163 # Execute the base class __init__() method. 164 Relaxation_v3_0.__init__(self, datanodes) 165 166 # Initialise the kinetic saveframe supergroups. 167 self.heteronucl_NOEs = HeteronuclNOESaveframe_v3_1(datanodes) 168 self.heteronucl_T1_relaxation = HeteronuclT1Saveframe_v3_1(datanodes) 169 self.heteronucl_T2_relaxation = HeteronuclT2Saveframe_v3_1(datanodes) 170 self.auto_relaxation = AutoRelaxationSaveframe_v3_1(datanodes)
171 172
173 - def add(self, **keywords):
174 """Add relaxation data to the data nodes. 175 176 @keyword data_type: The relaxation data type (one of 'NOE', 'R1', or 'R2'). 177 @type data_type: str 178 @keyword sample_cond_list_id: The sample conditions list ID number. 179 @type sample_cond_list_id: str 180 @keyword sample_cond_list_label: The sample conditions list label. 181 @type sample_cond_list_label: str 182 @keyword temp_calibration: The temperature calibration method. 183 @type temp_calibration: str 184 @keyword temp_control: The temperature control method. 185 @type temp_control: str 186 @keyword peak_intensity_type: The peak intensity type - one of 'height' or 'volume'. 187 @type peak_intensity_type: str 188 @keyword frq: The spectrometer proton frequency, in Hz. 189 @type frq: float 190 @keyword details: The details tag. 191 @type details: None or str 192 @keyword assembly_atom_ids: The assembly atom ID numbers. 193 @type assembly_atom_ids: list of int 194 @keyword entity_assembly_ids: The entity assembly ID numbers. 195 @type entity_assembly_ids: list of int 196 @keyword entity_ids: The entity ID numbers. 197 @type entity_ids: int 198 @keyword res_nums: The residue number list. 199 @type res_nums: list of int 200 @keyword res_names: The residue name list. 201 @type res_names: list of str 202 @keyword atom_names: The atom name list. 203 @type atom_names: list of str 204 @keyword atom_types: The atom types as IUPAC element abbreviations. 205 @type atom_types: list of str 206 @keyword isotope: The isotope type list, ie 15 for '15N'. 207 @type isotope: list of int 208 @keyword assembly_atom_ids_2: The assembly atom ID numbers. This is for the second atom used in the heteronuclear NOE. 209 @type assembly_atom_ids_2: list of int 210 @keyword entity_assembly_ids_2: The entity assembly ID numbers. This is for the second atom used in the heteronuclear NOE. 211 @type entity_assembly_ids_2: list of int 212 @keyword entity_ids_2: The entity ID numbers. This is for the second atom used in the heteronuclear NOE. 213 @type entity_ids_2: int 214 @keyword res_nums_2: The residue number list. This is for the second atom used in the heteronuclear NOE. 215 @type res_nums_2: list of int 216 @keyword res_names_2: The residue name list. This is for the second atom used in the heteronuclear NOE. 217 @type res_names_2: list of str 218 @keyword atom_names_2: The atom name list. This is for the second atom used in the heteronuclear NOE. 219 @type atom_names_2: list of str 220 @keyword atom_types_2: The atom types as IUPAC element abbreviations. This is for the second atom used in the heteronuclear NOE. 221 @type atom_types_2: list of str 222 @keyword isotope_2: The isotope type list, ie 1 for '1H'. This is for the second atom used in the heteronuclear NOE. 223 @type isotope_2: list of int 224 @keyword data: The relaxation data. 225 @type data: list of float 226 @keyword errors: The errors associated with the relaxation data. 227 @type errors: list of float 228 """ 229 230 # Pack specific the data. 231 if keywords['data_type'] in ['R1', 'R2']: 232 self.auto_relaxation.add(**keywords) 233 elif keywords['data_type'] == 'NOE': 234 self.heteronucl_NOEs.add(**keywords)
235 236
237 - def loop(self):
238 """Generator method for looping over and returning all relaxation data.""" 239 240 # The NOE data. 241 for data in self.heteronucl_NOEs.loop(): 242 data['data_type'] = 'NOE' 243 yield data 244 245 # The R1 data. 246 for data in self.heteronucl_T1_relaxation.loop(): 247 data['data_type'] = 'R1' 248 yield data 249 250 # The R2 data. 251 for data in self.heteronucl_T2_relaxation.loop(): 252 data['data_type'] = 'R2' 253 yield data 254 255 256 # The auto-relaxation data. 257 for data in self.auto_relaxation.loop(): 258 data['data_type'] = data['coherence_common_name'] 259 yield data
260