Hi Troels, This looks good. However there might be a failure point here that can be caught with a simple system test:
- Create a data pipe. - Load spectral data with nmrglue. - Save the relax state (into ds.tmpdir). - Reset relax. - Load the relax state. This would be a good sanity check to make sure that relax state files will never be corrupted by the nmrglue data. I highly recommend that you create such a test for your own benefit. Cheers, Edward On 27 November 2014 at 16:43, <tlin...@nmr-relax.com> wrote: > Author: tlinnet > Date: Thu Nov 27 16:43:19 2014 > New Revision: 26785 > > URL: http://svn.gna.org/viewcvs/relax?rev=26785&view=rev > Log: > Added the initial pipe_control and lib.software modules, for the wrapper > functions to nmrglue. > > Task #7873 (https://gna.org/task/index.php?7873): Write wrapper function to > nmrglue, to read .ft2 files and process them. > Homepage: http://www.nmrglue.com/ > Link to nmrglue discussion: > https://groups.google.com/forum/#!forum/nmrglue-discuss > The code is develop at Github: https://github.com/jjhelmus/nmrglue/ > Google code: https://code.google.com/p/nmrglue/ > Documentation: http://nmrglue.readthedocs.org/en/latest/index.html > > Added: > branches/nmrglue/lib/software/nmrglue.py > - copied, changed from r26781, branches/nmrglue/pipe_control/__init__.py > branches/nmrglue/pipe_control/nmrglue.py > Modified: > branches/nmrglue/lib/software/__init__.py > branches/nmrglue/pipe_control/__init__.py > > Modified: branches/nmrglue/lib/software/__init__.py > URL: > http://svn.gna.org/viewcvs/relax/branches/nmrglue/lib/software/__init__.py?rev=26785&r1=26784&r2=26785&view=diff > ============================================================================== > --- branches/nmrglue/lib/software/__init__.py (original) > +++ branches/nmrglue/lib/software/__init__.py Thu Nov 27 16:43:19 2014 > @@ -25,6 +25,7 @@ > __all__ = [ > 'bruker_dc', > 'grace', > + 'nmrglue', > 'opendx', > 'xplor' > ] > > Copied: branches/nmrglue/lib/software/nmrglue.py (from r26781, > branches/nmrglue/pipe_control/__init__.py) > URL: > http://svn.gna.org/viewcvs/relax/branches/nmrglue/lib/software/nmrglue.py?p2=branches/nmrglue/lib/software/nmrglue.py&p1=branches/nmrglue/pipe_control/__init__.py&r1=26781&r2=26785&rev=26785&view=diff > ============================================================================== > --- branches/nmrglue/pipe_control/__init__.py (original) > +++ branches/nmrglue/lib/software/nmrglue.py Thu Nov 27 16:43:19 2014 > @@ -1,6 +1,6 @@ > > ############################################################################### > # > # > -# Copyright (C) 2004-2014 Edward d'Auvergne > # > +# Copyright (C) 2014 Troels E. Linnet > # > # > # > # This file is part of the program relax (http://www.nmr-relax.com). > # > # > # > @@ -19,49 +19,42 @@ > # > # > > ############################################################################### > > -# Package docstring. > -"""Package of analysis independent code.""" > +# Module docstring. > +"""Module for the wrapper functions around the nmrglue module.""" > > -# The available modules. > -__all__ = [ 'align_tensor', > - 'angles', > - 'bmrb', > - 'bruker', > - 'chemical_shift', > - 'dasha', > - 'diffusion_tensor', > - 'domain', > - 'eliminate', > - 'error_analysis', > - 'exp_info', > - 'fix', > - 'grace', > - 'interatomic', > - 'j_coupling', > - 'minimise', > - 'model_selection', > - 'mol_res_spin', > - 'molmol', > - 'noesy', > - 'opendx', > - 'palmer', > - 'paramag', > - 'pcs', > - 'pipes', > - 'plotting', > - 'pymol_control', > - 'rdc', > - 'relax_data', > - 'reset', > - 'result_files', > - 'results', > - 'script', > - 'selection', > - 'sequence', > - 'spectrometer', > - 'spectrum', > - 'state', > - 'structure', > - 'value', > - 'vmd' > -] > +# Python module imports. > +from re import search, split > + > +# relax module imports. > +from extern import nmrglue > +from lib.errors import RelaxError > +from lib.io import get_file_path > +from lib.spectrum.objects import Nmrglue_data > + > + > +def read_spectrum(file=None, dir=None): > + """Read the spectrum data. > + > + @keyword file: The name of the file containing the spectrum. > + @type file: str > + @keyword dir: The directory where the file is located. > + @type dir: str > + @return: The nmrglue data object containing all relevant > data in the spectrum. > + @rtype: lib.spectrum.objects.Nmrglue_data instance > + """ > + > + # File path. > + file_path = get_file_path(file, dir) > + > + # Open file > + dic, data = nmrglue.pipe.read(file_path) > + udic = nmrglue.pipe.guess_udic(dic, data) > + > + # Initialise the nmrglue data object. > + nmrglue_data = Nmrglue_data() > + > + # Add the data. > + nmrglue_data.add(file_path=file_path, dic=dic, udic=udic, data=data) > + > + # Return the nmrglue data object. > + return nmrglue_data > > Modified: branches/nmrglue/pipe_control/__init__.py > URL: > http://svn.gna.org/viewcvs/relax/branches/nmrglue/pipe_control/__init__.py?rev=26785&r1=26784&r2=26785&view=diff > ============================================================================== > --- branches/nmrglue/pipe_control/__init__.py (original) > +++ branches/nmrglue/pipe_control/__init__.py Thu Nov 27 16:43:19 2014 > @@ -42,6 +42,7 @@ > 'model_selection', > 'mol_res_spin', > 'molmol', > + 'nmrglue', > 'noesy', > 'opendx', > 'palmer', > > Added: branches/nmrglue/pipe_control/nmrglue.py > URL: > http://svn.gna.org/viewcvs/relax/branches/nmrglue/pipe_control/nmrglue.py?rev=26785&view=auto > ============================================================================== > --- branches/nmrglue/pipe_control/nmrglue.py (added) > +++ branches/nmrglue/pipe_control/nmrglue.py Thu Nov 27 16:43:19 2014 > @@ -0,0 +1,74 @@ > +############################################################################### > +# > # > +# Copyright (C) 2014 Troels E. Linnet > # > +# > # > +# This file is part of the program relax (http://www.nmr-relax.com). > # > +# > # > +# This program 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 3 of the License, or > # > +# (at your option) any later version. > # > +# > # > +# This program 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 this program. If not, see <http://www.gnu.org/licenses/>. > # > +# > # > +############################################################################### > + > +# Module docstring. > +"""Module for the using of nmrglue.""" > + > +# relax module imports. > +from lib.errors import RelaxError > +from lib.software.nmrglue import read_spectrum > +from pipe_control.pipes import check_pipe > +from pipe_control.spectrum import add_spectrum_id, check_spectrum_id, delete > + > + > +def add_nmrglue_data(spectrum_id=None, nmrglue_data=None): > + """Add the nmrglue_data to the data store. > + > + @keyword spectrum_id: The spectrum ID string. > + @type spectrum_id: str > + @keyword nmrglue_data: The nmrglue data as class instance object. > + @type nmrglue_data: lib.spectrum.objects.Nmrglue_data instance > + """ > + > + # Initialise the structure, if needed. > + if not hasattr(cdp, 'ngdata'): > + cdp.ngdata = {} > + > + # Add the data under the spectrum ID. > + cdp.ngdata[spectrum_id] = nmrglue_data[0] > + > + > +def read(file=None, dir=None, spectrum_id=None): > + """Read the spectrum file. > + > + @keyword file: The name of the file(s) containing the spectrum. > + @type file: str or list of str > + @keyword dir: The directory where the file is located. > + @type dir: str > + @keyword spectrum_id: The spectrum identification string. > + @type spectrum_id: str or list of str > + """ > + > + # Data checks. > + check_pipe() > + > + # Check the file name. > + if file == None: > + raise RelaxError("The file name must be supplied.") > + > + # Add spectrum ID. > + add_spectrum_id(spectrum_id) > + > + # Read the spectrum, and get it back as a class instance object. > + nmrglue_data = read_spectrum(file=file, dir=dir) > + > + # Store the data. > + add_nmrglue_data(spectrum_id=spectrum_id, nmrglue_data=nmrglue_data) > > > _______________________________________________ > relax (http://www.nmr-relax.com) > > This is the relax-commits mailing list > relax-comm...@gna.org > > To unsubscribe from this list, get a password > reminder, or change your subscription options, > visit the list information page at > https://mail.gna.org/listinfo/relax-commits _______________________________________________ relax (http://www.nmr-relax.com) This is the relax-devel mailing list relax-devel@gna.org To unsubscribe from this list, get a password reminder, or change your subscription options, visit the list information page at https://mail.gna.org/listinfo/relax-devel