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