Author: bugman Date: Thu Oct 8 18:05:53 2009 New Revision: 9666 URL: http://svn.gna.org/viewcvs/relax?rev=9666&view=rev Log: Added better versioning support to be able to switch to NMR-STAR v3.2 in the future. This will be easier for completing the general relaxation saveframe without breakage. Added: branches/bmrb/bmrblib/nmr_star_dict_v3_2.py - copied, changed from r9658, branches/bmrb/bmrblib/nmr_star_dict_v3_1.py Modified: branches/bmrb/generic_fns/bmrb.py branches/bmrb/generic_fns/mol_res_spin.py branches/bmrb/generic_fns/relax_data.py branches/bmrb/specific_fns/model_free/bmrb.py Copied: branches/bmrb/bmrblib/nmr_star_dict_v3_2.py (from r9658, branches/bmrb/bmrblib/nmr_star_dict_v3_1.py) URL: http://svn.gna.org/viewcvs/relax/branches/bmrb/bmrblib/nmr_star_dict_v3_2.py?p2=branches/bmrb/bmrblib/nmr_star_dict_v3_2.py&p1=branches/bmrb/bmrblib/nmr_star_dict_v3_1.py&r1=9658&r2=9666&rev=9666&view=diff ============================================================================== --- branches/bmrb/bmrblib/nmr_star_dict_v3_1.py (original) +++ branches/bmrb/bmrblib/nmr_star_dict_v3_2.py Thu Oct 8 18:05:53 2009 @@ -21,22 +21,22 @@ ############################################################################### # Module docstring. -"""The NMR-STAR dictionary API for version 3.1. +"""The NMR-STAR dictionary API for version 3.2. -The v3.1 NMR-STAR dictionary is documented at -http://www.bmrb.wisc.edu/dictionary/3.1html/SuperGroupPage.html. +The v3.2 NMR-STAR dictionary is documented at +http://www.bmrb.wisc.edu/dictionary/3.2html/SuperGroupPage.html. """ # relax module imports. from bmrblib.assembly_supercategory.entity_v3_1 import EntitySaveframe_v3_1 -from bmrblib.kinetics.relaxation import Relaxation_v3_1 +from bmrblib.kinetics.relaxation import Relaxation_v3_2 from bmrblib.NMR_parameters.chem_shift_anisotropy_v3_1 import ChemShiftAnisotropySaveframe_v3_1 from bmrblib.thermodynamics.order_parameters_v3_1 import OrderParameterSaveframe_v3_1 from bmrblib.nmr_star_dict import NMR_STAR -class NMR_STAR_v3_1(NMR_STAR): - """The v3.1 NMR-STAR dictionary.""" +class NMR_STAR_v3_2(NMR_STAR): + """The v3.2 NMR-STAR dictionary.""" # Class extension string. ext = '' Modified: branches/bmrb/generic_fns/bmrb.py URL: http://svn.gna.org/viewcvs/relax/branches/bmrb/generic_fns/bmrb.py?rev=9666&r1=9665&r2=9666&view=diff ============================================================================== --- branches/bmrb/generic_fns/bmrb.py (original) +++ branches/bmrb/generic_fns/bmrb.py Thu Oct 8 18:05:53 2009 @@ -100,4 +100,4 @@ mkdir_nofail(directory, verbosity=0) # Execute the specific BMRB writing code. - write_function(file_path) + write_function(file_path, version='3.1') Modified: branches/bmrb/generic_fns/mol_res_spin.py URL: http://svn.gna.org/viewcvs/relax/branches/bmrb/generic_fns/mol_res_spin.py?rev=9666&r1=9665&r2=9666&view=diff ============================================================================== --- branches/bmrb/generic_fns/mol_res_spin.py (original) +++ branches/bmrb/generic_fns/mol_res_spin.py Thu Oct 8 18:05:53 2009 @@ -535,11 +535,13 @@ create_residue(res_nums[i], res_names[i], mol_name=mol_name) -def bmrb_write_entity(star): +def bmrb_write_entity(star, version=None): """Generate the entity saveframe records for the NMR-STAR dictionary object. - @param star: The NMR-STAR dictionary object. - @type star: NMR_STAR instance + @param star: The NMR-STAR dictionary object. + @type star: NMR_STAR instance + @keyword version: The BMRB NMR-STAR dictionary format to output to. + @type version: str """ # Can't handle multiple molecules yet. Modified: branches/bmrb/generic_fns/relax_data.py URL: http://svn.gna.org/viewcvs/relax/branches/bmrb/generic_fns/relax_data.py?rev=9666&r1=9665&r2=9666&view=diff ============================================================================== --- branches/bmrb/generic_fns/relax_data.py (original) +++ branches/bmrb/generic_fns/relax_data.py Thu Oct 8 18:05:53 2009 @@ -228,11 +228,13 @@ -def bmrb_write(star): +def bmrb_write(star, version='3.1'): """Generate the relaxation data saveframes for the NMR-STAR dictionary object. - @param star: The NMR-STAR dictionary object. - @type star: NMR_STAR instance + @param star: The NMR-STAR dictionary object. + @type star: NMR_STAR instance + @keyword version: The BMRB NMR-STAR dictionary format to output to. + @type version: str """ # Get the current data pipe. @@ -294,13 +296,21 @@ # Add the relaxation data. for i in range(cdp.num_ri): - star.relaxation.add(operator_pair=operator_pair[i], frq=cdp.frq[cdp.remap_table[i]], res_nums=res_num_list, res_names=res_name_list, atom_names=atom_name_list, isotope=isotope_list, data=relax_data_list[i], errors=relax_error_list[i]) - #if cdp.ri_labels[i] == 'R1': - # star.heteronucl_T1_relaxation.add(frq=cdp.frq[cdp.remap_table[i]], res_nums=res_num_list, res_names=res_name_list, atom_names=atom_name_list, isotope=isotope_list, data=relax_data_list[i], errors=relax_error_list[i]) - #elif cdp.ri_labels[i] == 'R2': - # star.heteronucl_T2_relaxation.add(frq=cdp.frq[cdp.remap_table[i]], res_nums=res_num_list, res_names=res_name_list, atom_names=atom_name_list, isotope=isotope_list, data=relax_data_list[i], errors=relax_error_list[i]) - #elif cdp.ri_labels[i] == 'NOE': - # star.heteronucl_NOEs.add(frq=cdp.frq[cdp.remap_table[i]], res_nums=res_num_list, res_names=res_name_list, atom_names=atom_name_list, isotope=isotope_list, data=relax_data_list[i], errors=relax_error_list[i]) + # The general relaxation saveframe versions. + if version in ['3.2']: + if cdp.ri_labels[i] in ['R1', 'R2']: + star.relaxation.add(operator_pair=operator_pair[i], frq=cdp.frq[cdp.remap_table[i]], res_nums=res_num_list, res_names=res_name_list, atom_names=atom_name_list, isotope=isotope_list, data=relax_data_list[i], errors=relax_error_list[i]) + elif cdp.ri_labels[i] == 'NOE': + star.heteronucl_NOEs.add(frq=cdp.frq[cdp.remap_table[i]], res_nums=res_num_list, res_names=res_name_list, atom_names=atom_name_list, isotope=isotope_list, data=relax_data_list[i], errors=relax_error_list[i]) + + # Older versions. + if version in ['3.0', '3.1']: + if cdp.ri_labels[i] == 'R1': + star.heteronucl_T1_relaxation.add(frq=cdp.frq[cdp.remap_table[i]], res_nums=res_num_list, res_names=res_name_list, atom_names=atom_name_list, isotope=isotope_list, data=relax_data_list[i], errors=relax_error_list[i]) + elif cdp.ri_labels[i] == 'R2': + star.heteronucl_T2_relaxation.add(frq=cdp.frq[cdp.remap_table[i]], res_nums=res_num_list, res_names=res_name_list, atom_names=atom_name_list, isotope=isotope_list, data=relax_data_list[i], errors=relax_error_list[i]) + elif cdp.ri_labels[i] == 'NOE': + star.heteronucl_NOEs.add(frq=cdp.frq[cdp.remap_table[i]], res_nums=res_num_list, res_names=res_name_list, atom_names=atom_name_list, isotope=isotope_list, data=relax_data_list[i], errors=relax_error_list[i]) def copy(pipe_from=None, pipe_to=None, ri_label=None, frq_label=None): Modified: branches/bmrb/specific_fns/model_free/bmrb.py URL: http://svn.gna.org/viewcvs/relax/branches/bmrb/specific_fns/model_free/bmrb.py?rev=9666&r1=9665&r2=9666&view=diff ============================================================================== --- branches/bmrb/specific_fns/model_free/bmrb.py (original) +++ branches/bmrb/specific_fns/model_free/bmrb.py Thu Oct 8 18:05:53 2009 @@ -26,6 +26,7 @@ # relax module imports. from bmrblib.nmr_star_dict_v3_1 import NMR_STAR_v3_1 +from bmrblib.nmr_star_dict_v3_2 import NMR_STAR_v3_2 from generic_fns import mol_res_spin, pipes, relax_data from generic_fns.mol_res_spin import spin_loop @@ -33,7 +34,7 @@ class Bmrb: """Class containing methods related to BMRB STAR file reading and writing.""" - def bmrb_read(self, file_path): + def bmrb_read(self, file_path, version='3.1'): """Read the model-free results from a BMRB NMR-STAR v3.1 formatted file. @param file_path: The full file path. @@ -41,7 +42,10 @@ """ # Initialise the NMR-STAR data object. - star = NMR_STAR_v3_1('relax_model_free_results', file_path) + if version == '3.2': + star = NMR_STAR_v3_2('relax_model_free_results', file_path) + elif version == '3.1': + star = NMR_STAR_v3_1('relax_model_free_results', file_path) # Read the contents of the STAR formatted file. star.read() @@ -53,24 +57,29 @@ relax_data.bmrb_read(star) - def bmrb_write(self, file_path): + def bmrb_write(self, file_path, version=None): """Write the model-free results to a BMRB NMR-STAR v3.1 formatted file. @param file_path: The full file path. @type file_path: str + @keyword version: The BMRB NMR-STAR dictionary format to output to. + @type version: str """ # Alias the current data pipe. cdp = pipes.get_pipe() # Initialise the NMR-STAR data object. - star = NMR_STAR_v3_1('relax_model_free_results', file_path) + if version == '3.2': + star = NMR_STAR_v3_2('relax_model_free_results', file_path) + elif version == '3.1': + star = NMR_STAR_v3_1('relax_model_free_results', file_path) # Generate the entity saveframe. - mol_res_spin.bmrb_write_entity(star) + mol_res_spin.bmrb_write_entity(star, version=version) # Generate the relaxation data saveframes. - relax_data.bmrb_write(star) + relax_data.bmrb_write(star, version=version) # Rex frq. rex_frq = cdp.frq[0]