Author: bugman Date: Thu Oct 8 18:45:55 2009 New Revision: 9667 URL: http://svn.gna.org/viewcvs/relax?rev=9667&view=rev Log: Wrote add() methods for the Relaxation_v3_1 and Relaxation_v3_2 classes. This defined a stable API abstracting the saveframe structure from the user of bmrblib. Modified: branches/bmrb/bmrblib/kinetics/relaxation.py Modified: branches/bmrb/bmrblib/kinetics/relaxation.py URL: http://svn.gna.org/viewcvs/relax/branches/bmrb/bmrblib/kinetics/relaxation.py?rev=9667&r1=9666&r2=9667&view=diff ============================================================================== --- branches/bmrb/bmrblib/kinetics/relaxation.py (original) +++ branches/bmrb/bmrblib/kinetics/relaxation.py Thu Oct 8 18:45:55 2009 @@ -92,6 +92,35 @@ self.__heteronucl_T2_relaxation = HeteronuclT2Saveframe_v3_1(self.__datanodes) + def add(self, data_type=None, frq=None, res_nums=None, res_names=None, atom_names=None, isotope=None, data=None, errors=None): + """Add relaxation data to the data nodes. + + @keyword data_type: The relaxation data type (one of 'NOE', 'R1', or 'R2'). + @type data_type: str + @keyword frq: The spectrometer proton frequency, in Hz. + @type frq: float + @keyword res_nums: The residue number list. + @type res_nums: list of int + @keyword res_names: The residue name list. + @type res_names: list of str + @keyword atom_names: The atom name list. + @type atom_names: list of str + @keyword isotope: The isotope type list, ie 15 for '15N'. + @type isotope: list of int + @keyword data: The relaxation data. + @type data: list of float + @keyword errors: The errors associated with the relaxation data. + @type errors: list of float + """ + + # Pack specific the data. + if data_type == 'R1': + self.__heteronucl_T1_relaxation.add(frq=frq, res_nums=res_nums, res_names=res_names, atom_names=atom_names, isotope=isotope, data=data, errors=errors) + elif data_type == 'R2': + star.__heteronucl_T2_relaxation.add(frq=frq, res_nums=res_nums, res_names=res_names, atom_names=atom_names, isotope=isotope, data=data, errors=errors) + elif data_type == 'NOE': + star.__heteronucl_NOEs.add(frq=frq, res_nums=res_nums, res_names=res_names, atom_names=atom_names, isotope=isotope, data=data, errors=errors) + class Relaxation_v3_2(Relaxation_v3_1): """Class for the relaxation data part of the BMRB API (v3.2).""" @@ -108,3 +137,33 @@ # Initialise the kinetic saveframe supergroups. self.__general_relaxation = GeneralRelaxationSaveframe(self.__datanodes) + + + def add(self, data_type=None, frq=None, res_nums=None, res_names=None, atom_names=None, isotope=None, data=None, errors=None): + """Add relaxation data to the data nodes. + + @keyword data_type: The relaxation data type (one of 'NOE', 'R1', or 'R2'). + @type data_type: str + @keyword frq: The spectrometer proton frequency, in Hz. + @type frq: float + @keyword res_nums: The residue number list. + @type res_nums: list of int + @keyword res_names: The residue name list. + @type res_names: list of str + @keyword atom_names: The atom name list. + @type atom_names: list of str + @keyword isotope: The isotope type list, ie 15 for '15N'. + @type isotope: list of int + @keyword data: The relaxation data. + @type data: list of float + @keyword errors: The errors associated with the relaxation data. + @type errors: list of float + """ + + # Pack specific the data. + if data_type in ['R1', 'R2']: + self.__general_relaxation.add(data_type=data_type, frq=frq, res_nums=res_nums, res_names=res_names, atom_names=atom_names, isotope=isotope, data=data, errors=errors) + elif data_type == 'NOE': + star.__heteronucl_NOEs.add(frq=frq, res_nums=res_nums, res_names=res_names, atom_names=atom_names, isotope=isotope, data=data, errors=errors) + +