Author: bugman Date: Thu Jul 31 11:29:45 2008 New Revision: 7043 URL: http://svn.gna.org/viewcvs/relax?rev=7043&view=rev Log: Initial support for the bmrb user functions. The following BNMRB related user functions now exist (the back end does not yet exist): bmrb.display() bmrb.read() bmrb.write() Added: branches/bmrb/prompt/bmrb.py - copied, changed from r7041, branches/bmrb/prompt/results.py Modified: branches/bmrb/prompt/__init__.py Modified: branches/bmrb/prompt/__init__.py URL: http://svn.gna.org/viewcvs/relax/branches/bmrb/prompt/__init__.py?rev=7043&r1=7042&r2=7043&view=diff ============================================================================== --- branches/bmrb/prompt/__init__.py (original) +++ branches/bmrb/prompt/__init__.py Thu Jul 31 11:29:45 2008 @@ -1,6 +1,6 @@ ############################################################################### # # -# Copyright (C) 2003-2005 Edward d'Auvergne # +# Copyright (C) 2003-2008 Edward d'Auvergne # # # # This file is part of the program relax. # # # @@ -22,6 +22,7 @@ __all__ = ['angles', + 'bmrb', 'command', 'consistency_tests', 'dasha', Copied: branches/bmrb/prompt/bmrb.py (from r7041, branches/bmrb/prompt/results.py) URL: http://svn.gna.org/viewcvs/relax/branches/bmrb/prompt/bmrb.py?p2=branches/bmrb/prompt/bmrb.py&p1=branches/bmrb/prompt/results.py&r1=7041&r2=7043&rev=7043&view=diff ============================================================================== --- branches/bmrb/prompt/results.py (original) +++ branches/bmrb/prompt/bmrb.py Thu Jul 31 11:29:45 2008 @@ -25,15 +25,15 @@ # relax module imports. import help -from generic_fns import results +from generic_fns import bmrb from relax_errors import RelaxBoolError, RelaxIntError, RelaxNoneStrError, RelaxStrError, RelaxStrFileError -class Results: +class BMRB: def __init__(self, relax): # Help. self.__relax_help__ = \ - """Class for manipulating results.""" + """Class for interfacing with the BMRB (http://www.bmrb.wisc.edu/).""" # Add the generic help string. self.__relax_help__ = self.__relax_help__ + "\n" + help.relax_class_help @@ -42,32 +42,26 @@ self.__relax__ = relax - def display(self, format='xml'): - """Function for displaying the results. + def display(self): + """Display the BMRB data in NMR-STAR v3.1 format.""" + + # Function intro text. + if self.__relax__.interpreter.intro: + text = sys.ps3 + "bmrb.display(" + text = text + "format=" + `format` + ")" + print text + + # Execute the functional code. + bmrb.display(format=format) + + + def read(self, file=None, dir=None): + """Read BMRB files in the NMR-STAR v3.1 format. Keyword Arguments ~~~~~~~~~~~~~~~~~ - format: The format of the output. - """ - - # Function intro text. - if self.__relax__.interpreter.intro: - text = sys.ps3 + "results.display(" - text = text + "format=" + `format` + ")" - print text - - # Execute the functional code. - results.display(format=format) - - - def read(self, file='results', dir=None): - """Function for reading results from a file. - - Keyword Arguments - ~~~~~~~~~~~~~~~~~ - - file: The name of the file to read results from. + file: The name of the BMRB STAR formatted file. dir: The directory where the file is located. @@ -85,7 +79,7 @@ # Function intro text. if self.__relax__.interpreter.intro: - text = sys.ps3 + "results.read(" + text = sys.ps3 + "bmrb.read(" text = text + "file=" + `file` text = text + ", dir=" + `dir` + ")" print text @@ -99,23 +93,21 @@ raise RelaxNoneStrError, ('directory name', dir) # Execute the functional code. - results.read(file=file, directory=dir) + bmrb.read(file=file, directory=dir) - def write(self, file='results', dir='pipe_name', force=False, format='xml', compress_type=1): - """Function for writing results to a file. + def write(self, file=None, dir='pipe_name', force=False, compress_type=0): + """Write the results to a BMRB NMR-STAR v3.1 formatted file. Keyword Arguments ~~~~~~~~~~~~~~~~~ - file: The name of the file to output results to. The default is 'results'. Optionally - this can be a file object, or any object with a write() method. + file: The name of the BMRB file to output results to. Optionally this can be a file + object, or any object with a write() method. dir: The directory name. - force: A flag which if True will cause the results file to be overwritten. - - format: The format of the output. + force: A flag which if True will cause the any pre-existing file to be overwritten. compress_type: The type of compression to use when creating the file. @@ -123,14 +115,13 @@ Description ~~~~~~~~~~~ - To place the results file in the current working directory, set dir to None. If dir is set + To place the BMRB file in the current working directory, set dir to None. If dir is set to the special name 'pipe_name', then the results file will be placed into a directory with the same name as the current data pipe. - The default behaviour of this function is to compress the file using bzip2 compression. If - the extension '.bz2' is not included in the file name, it will be added. The compression - can, however, be changed to either no compression or gzip compression. This is controlled - by the compress_type argument which can be set to + The default behaviour of this function is to create an uncompressed BMRB file. The file can + however be saved in compressed format. This is controlled by the compress_type argument + which can be set to one of: 0: No compression (no file extension), 1: bzip2 compression ('.bz2' file extension), @@ -141,11 +132,10 @@ # Function intro text. if self.__relax__.interpreter.intro: - text = sys.ps3 + "results.write(" + text = sys.ps3 + "bmrb.write(" text = text + "file=" + `file` text = text + ", dir=" + `dir` text = text + ", force=" + `force` - text = text + ", format=" + `format` text = text + ", compress_type=" + `compress_type` + ")" print text @@ -161,13 +151,9 @@ if type(force) != bool: raise RelaxBoolError, ('force flag', force) - # Format. - if type(format) != str: - raise RelaxStrError, ('format', format) - # Compression type. if type(compress_type) != int: raise RelaxIntError, ('compression type', compress_type) # Execute the functional code. - results.write(file=file, directory=dir, force=force, format=format, compress_type=compress_type) + bmrb.write(file=file, directory=dir, force=force, compress_type=compress_type)