Author: bugman Date: Sat Feb 19 14:41:53 2011 New Revision: 12580 URL: http://svn.gna.org/viewcvs/relax?rev=12580&view=rev Log: Merged revisions 8392-8393,8427,8567-8573 via svnmerge from svn+ssh://bugman@xxxxxxxxxxx/svn/relax/branches/bmrb ........ r8392 | bugman | 2009-01-11 19:05:40 +0100 (Sun, 11 Jan 2009) | 5 lines Started to dump the relaxation data into the BMRB file. Much work is still required and the spin specific values are still not there. ........ r8393 | bugman | 2009-01-11 19:22:44 +0100 (Sun, 11 Jan 2009) | 3 lines The spectrometer frequency in the BMRB is now a float. ........ r8427 | bugman | 2009-01-12 22:20:30 +0100 (Mon, 12 Jan 2009) | 3 lines All relaxation data is now placed in the BMRB STAR formatted file. ........ r8567 | bugman | 2009-01-21 21:02:14 +0100 (Wed, 21 Jan 2009) | 6 lines Added a directory for the creation of the 'bmrb' package. This will include translation tables of the various BMRB NMR-STAR format version, and many BMRB format related functions. ........ r8568 | bugman | 2009-01-21 21:03:14 +0100 (Wed, 21 Jan 2009) | 3 lines Converted generic_fns.bmrb into the bmrb package initialisation module. ........ r8569 | bugman | 2009-01-21 21:03:42 +0100 (Wed, 21 Jan 2009) | 3 lines Copyright update. ........ r8570 | bugman | 2009-01-21 21:04:50 +0100 (Wed, 21 Jan 2009) | 3 lines Updated the module docstring and added an empty __all__ list. ........ r8571 | bugman | 2009-01-21 21:06:37 +0100 (Wed, 21 Jan 2009) | 3 lines Import fix and copyright update. ........ r8572 | bugman | 2009-01-21 21:17:17 +0100 (Wed, 21 Jan 2009) | 5 lines Renamed the bmrb package to bmrblib. This is to avoid any future (and current) name clashes. ........ r8573 | bugman | 2009-01-21 21:18:35 +0100 (Wed, 21 Jan 2009) | 3 lines Updates for the renaming to bmrblib. ........ Added: 1.3/bmrblib/ - copied from r8573, branches/bmrb/bmrblib/ Removed: 1.3/generic_fns/bmrb.py Modified: 1.3/ (props changed) 1.3/prompt/bmrb.py 1.3/specific_fns/model_free/bmrb.py Propchange: 1.3/ ------------------------------------------------------------------------------ --- svnmerge-integrated (original) +++ svnmerge-integrated Sat Feb 19 14:41:53 2011 @@ -1,1 +1,1 @@ -/branches/bmrb:1-7041,7043-7046,8153-8388 +/branches/bmrb:1-7041,7043-7046,8153-8388,8392-8573 Removed: 1.3/generic_fns/bmrb.py URL: http://svn.gna.org/viewcvs/relax/1.3/generic_fns/bmrb.py?rev=12579&view=auto ============================================================================== --- 1.3/generic_fns/bmrb.py (original) +++ 1.3/generic_fns/bmrb.py (removed) @@ -1,103 +1,0 @@ -############################################################################### -# # -# Copyright (C) 2008 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. -"""Module for interfacing with the BMRB (http://www.bmrb.wisc.edu/) by handling NMR-STAR v3.1 files.""" - -# Python module imports. -from os import F_OK, access - -# relax module imports. -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 - - -def display(): - """Display the results in the BMRB NMR-STAR v3.1 format.""" - - # Test if the current data pipe exists. - if not ds.current_pipe: - raise RelaxNoPipeError - - # Specific results writing function. - write_function = get_specific_fn('bmrb_write', ds[ds.current_pipe].pipe_type, raise_error=False) - - # Write the results. - write_function(sys.stdout) - - -def read(file=None, directory=None): - """Read the contents of a BMRB NMR-STAR v3.1 formatted file.""" - - # Test if the current data pipe exists. - if not ds.current_pipe: - raise RelaxNoPipeError - - # Make sure that the data pipe is empty. - if not ds[ds.current_pipe].is_empty(): - raise RelaxError, "The current data pipe is not empty." - - # Get the full file path. - file_path = get_file_path(file_name=file, dir=directory) - - # Fail if the file does not exist. - if not access(file_path, F_OK): - raise RelaxFileError, file_path - - # Specific results reading function. - read_function = get_specific_fn('bmrb_read', ds[ds.current_pipe].pipe_type) - - # Read the results. - read_function(file_path) - - -def write(file=None, directory=None, force=False): - """Create a BMRB NMR-STAR v3.1 formatted file.""" - - # Test if the current data pipe exists. - if not ds.current_pipe: - raise RelaxNoPipeError - - # The special data pipe name directory. - if directory == 'pipe_name': - directory = ds.current_pipe - - # Specific results writing function. - write_function = get_specific_fn('bmrb_write', ds[ds.current_pipe].pipe_type) - - # Get the full file path. - file_path = get_file_path(file, directory) - - # Fail if the file already exists and the force flag is False. - if access(file_path, F_OK) and not force: - raise RelaxFileOverwriteError, (file_path, 'force flag') - - # Print out. - print "Opening the file '%s' for writing." % file_path - - # Create the directories. - mkdir_nofail(directory, verbosity=0) - - # Execute the specific BMRB writing code. - write_function(file_path) Modified: 1.3/prompt/bmrb.py URL: http://svn.gna.org/viewcvs/relax/1.3/prompt/bmrb.py?rev=12580&r1=12579&r2=12580&view=diff ============================================================================== --- 1.3/prompt/bmrb.py (original) +++ 1.3/prompt/bmrb.py Sat Feb 19 14:41:53 2011 @@ -1,6 +1,6 @@ ############################################################################### # # -# Copyright (C) 2003-2005,2008 Edward d'Auvergne # +# Copyright (C) 2003-2005,2008-2009 Edward d'Auvergne # # # # This file is part of the program relax. # # # @@ -25,7 +25,7 @@ # relax module imports. import help -from generic_fns import bmrb +import bmrblib from relax_errors import RelaxBoolError, RelaxIntError, RelaxNoneStrError, RelaxStrError, RelaxStrFileError @@ -52,7 +52,7 @@ print text # Execute the functional code. - bmrb.display(format=format) + bmrblib.display(format=format) def read(self, file=None, dir=None): @@ -88,7 +88,7 @@ raise RelaxNoneStrError, ('directory name', dir) # Execute the functional code. - bmrb.read(file=file, directory=dir) + bmrblib.read(file=file, directory=dir) def write(self, file=None, dir='pipe_name', force=False): @@ -134,4 +134,4 @@ raise RelaxBoolError, ('force flag', force) # Execute the functional code. - bmrb.write(file=file, directory=dir, force=force) + bmrblib.write(file=file, directory=dir, force=force) Modified: 1.3/specific_fns/model_free/bmrb.py URL: http://svn.gna.org/viewcvs/relax/1.3/specific_fns/model_free/bmrb.py?rev=12580&r1=12579&r2=12580&view=diff ============================================================================== --- 1.3/specific_fns/model_free/bmrb.py (original) +++ 1.3/specific_fns/model_free/bmrb.py Sat Feb 19 14:41:53 2011 @@ -21,7 +21,11 @@ ############################################################################### # relax module imports. +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 class Bmrb: @@ -51,5 +55,83 @@ # Initialise the pystarlib File object. file = File(title='relax_model_free_results', filename=file_path) + # Get the current data pipe. + cdp = get_pipe() + + # Initialise the spin specific data lists. + res_num_list = [] + res_name_list = [] + atom_name_list = [] + relax_data_list = [] + relax_error_list = [] + for i in range(cdp.num_ri): + relax_data_list.append([]) + relax_error_list.append([]) + + # Store the spin specific data in lists for later use. + for spin, mol_name, res_num, res_name in spin_loop(full_info=True): + # Skip deselected spins. + if not spin.select: + continue + + # The residue/spin info. + res_num_list.append(str(res_num)) + res_name_list.append(str(res_name)) + atom_name_list.append(str(spin.name)) + + # The relaxation data. + for i in range(cdp.num_ri): + relax_data_list[i].append(str(spin.relax_data[i])) + relax_error_list[i].append(str(spin.relax_error[i])) + + # Relaxation data save frames. + r1_inc = 0 + r2_inc = 0 + noe_inc = 0 + for i in range(cdp.num_ri): + # Data type labels. + if cdp.ri_labels[i] == 'R1': + r1_inc = r1_inc + 1 + ri_inc = r1_inc + ri_label = 'T1' + coherence = 'Nz' + elif cdp.ri_labels[i] == 'R2': + r2_inc = r2_inc + 1 + ri_inc = r2_inc + ri_label = 'T2' + coherence = 'Ny' + elif cdp.ri_labels[i] == 'NOE': + noe_inc = noe_inc + 1 + ri_inc = noe_inc + ri_label = 'NOE' + + # Initialise the save frame. + frame = SaveFrame(title='heteronuclear_'+ri_label+'_list_'+`ri_inc`) + + # The save frame category. + frame.tagtables.append(TagTable(free=True, tagnames=['_Saveframe_category'], tagvalues=[[ri_label+'_relaxation']])) + + # Sample info. + frame.tagtables.append(TagTable(free=True, tagnames=['_Sample_label'], tagvalues=[['$sample_1']])) + frame.tagtables.append(TagTable(free=True, tagnames=['_Sample_conditions_label'], tagvalues=[['$conditions_1']])) + + # NMR info. + frame.tagtables.append(TagTable(free=True, tagnames=['_Spectrometer_frequency_1H'], tagvalues=[[str(cdp.frq[cdp.remap_table[i]]/1e6)]])) + if ri_label in ['T1', 'T2']: + frame.tagtables.append(TagTable(free=True, tagnames=['_'+ri_label+'_coherence_type'], tagvalues=[[coherence]])) + frame.tagtables.append(TagTable(free=True, tagnames=['_'+ri_label+'_value_units'], tagvalues=[['1/s']])) + + # The relaxation tag names. + tag_names = ['_Residue_seq_code', '_Residue_label', '_Atom_name', '_'+ri_label+'_value', '_'+ri_label+'_value_error'] + + # Add the data. + table = TagTable(tagnames=tag_names, tagvalues=[res_num_list, res_name_list, atom_name_list, relax_data_list[i], relax_error_list[i]]) + + # Add the tag table to the save frame. + frame.tagtables.append(table) + + # Add the relaxation data save frame. + file.datanodes.append(frame) + # Write the contents to the STAR formatted file. file.write()