Author: bugman Date: Sat Feb 21 23:50:56 2009 New Revision: 8834 URL: http://svn.gna.org/viewcvs/relax?rev=8834&view=rev Log: Started to create the NMR-STAR dictionary object. The object is in bmrblib.nmr_star_dict and acts as an abstraction layer between pystarlib and the specific analysis types. It also will translate the NMR-STAR dictionary subset used by relax for different versions of the definition. The object is far from complete though. Added: branches/bmrb/bmrblib/nmr_star_dict.py Modified: branches/bmrb/bmrblib/__init__.py branches/bmrb/specific_fns/model_free/bmrb.py Modified: branches/bmrb/bmrblib/__init__.py URL: http://svn.gna.org/viewcvs/relax/branches/bmrb/bmrblib/__init__.py?rev=8834&r1=8833&r2=8834&view=diff ============================================================================== --- branches/bmrb/bmrblib/__init__.py (original) +++ branches/bmrb/bmrblib/__init__.py Sat Feb 21 23:50:56 2009 @@ -30,10 +30,10 @@ from data import Relax_data_store; ds = Relax_data_store() from relax_errors import RelaxError, RelaxFileError, RelaxFileOverwriteError, RelaxNoPipeError from relax_io import get_file_path, mkdir_nofail -from specific_fns.setup import get_specific_fn +import specific_fns -__all__ = [] +__all__ = ['nmr_star_dict'] @@ -45,7 +45,7 @@ raise RelaxNoPipeError # Specific results writing function. - write_function = get_specific_fn('bmrb_write', ds[ds.current_pipe].pipe_type, raise_error=False) + write_function = specific_fns.setup.get_specific_fn('bmrb_write', ds[ds.current_pipe].pipe_type, raise_error=False) # Write the results. write_function(sys.stdout) @@ -70,7 +70,7 @@ raise RelaxFileError, file_path # Specific results reading function. - read_function = get_specific_fn('bmrb_read', ds[ds.current_pipe].pipe_type) + read_function = specific_fns.setup.get_specific_fn('bmrb_read', ds[ds.current_pipe].pipe_type) # Read the results. read_function(file_path) @@ -88,7 +88,7 @@ directory = ds.current_pipe # Specific results writing function. - write_function = get_specific_fn('bmrb_write', ds[ds.current_pipe].pipe_type) + write_function = specific_fns.setup.get_specific_fn('bmrb_write', ds[ds.current_pipe].pipe_type) # Get the full file path. file_path = get_file_path(file, directory) Added: branches/bmrb/bmrblib/nmr_star_dict.py URL: http://svn.gna.org/viewcvs/relax/branches/bmrb/bmrblib/nmr_star_dict.py?rev=8834&view=auto ============================================================================== --- branches/bmrb/bmrblib/nmr_star_dict.py (added) +++ branches/bmrb/bmrblib/nmr_star_dict.py Sat Feb 21 23:50:56 2009 @@ -1,0 +1,60 @@ +############################################################################### +# # +# Copyright (C) 2009 Edward d'Auvergne # +# # +# This file is part of the program relax. # +# # +# relax is free software; you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation; either version 2 of the License, or # +# (at your option) any later version. # +# # +# relax is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with relax; if not, write to the Free Software # +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # +# # +############################################################################### + +# Module docstring. +"""The base classes for the NMR-STAR dictionary support within relax. + +The most up to date NMR-STAR dictionary relax uses is the v3.1 version documented at +http://www.bmrb.wisc.edu/dictionary/3.1html/SuperGroupPage.html. +""" + +# relax module imports. +from pystarlib.File import File + + +class NMR_STAR: + """The base object for the NMR-STAR dictionary.""" + + def __init__(self, title, file_path): + """Initialise the NMR-STAR dictionary object. + + @param title: The title of the NMR-STAR data. + @type title: str + @param file_path: The full file path. + @type file_path: str + """ + + # Initialise the pystarlib File object. + self.file = File(title='relax_model_free_results', filename=file_path) + + + def read(self): + """Read the data from a BMRB NMR-STAR formatted file.""" + + self.file.read() + + + def write(self): + """Write the data to a BMRB NMR-STAR formatted file.""" + + # Write the contents to the STAR formatted file. + self.file.write() 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=8834&r1=8833&r2=8834&view=diff ============================================================================== --- branches/bmrb/specific_fns/model_free/bmrb.py (original) +++ branches/bmrb/specific_fns/model_free/bmrb.py Sat Feb 21 23:50:56 2009 @@ -21,9 +21,9 @@ ############################################################################### # relax module imports. +from bmrblib.nmr_star_dict import NMR_STAR from generic_fns.mol_res_spin import spin_loop from generic_fns.pipes import get_pipe -from pystarlib.File import File from pystarlib.SaveFrame import SaveFrame from pystarlib.TagTable import TagTable @@ -38,11 +38,11 @@ @type file_path: str """ - # Initialise the pystarlib File object. - file = File(title='relax_model_free_results', filename=file_path) + # Initialise the NMR-STAR data object. + star = NMR_STAR('relax_model_free_results', file_path) # Read the contents of the STAR formatted file. - file.read() + star.read() def bmrb_write(self, file_path): @@ -52,8 +52,8 @@ @type file_path: str """ - # Initialise the pystarlib File object. - file = File(title='relax_model_free_results', filename=file_path) + # Initialise the NMR-STAR data object. + star = NMR_STAR('relax_model_free_results', file_path) # Get the current data pipe. cdp = get_pipe() @@ -131,7 +131,7 @@ frame.tagtables.append(table) # Add the relaxation data save frame. - file.datanodes.append(frame) + star.file.datanodes.append(frame) # Write the contents to the STAR formatted file. - file.write() + star.write()