mailr9687 - in /branches/bmrb: generic_fns/bmrb.py prompt/bmrb.py


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by edward on October 09, 2009 - 13:00:
Author: bugman
Date: Fri Oct  9 13:00:28 2009
New Revision: 9687

URL: http://svn.gna.org/viewcvs/relax?rev=9687&view=rev
Log:
Significant updates to the BMRB user function module, including the addition 
of the version arg.


Modified:
    branches/bmrb/generic_fns/bmrb.py
    branches/bmrb/prompt/bmrb.py

Modified: branches/bmrb/generic_fns/bmrb.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/bmrb/generic_fns/bmrb.py?rev=9687&r1=9686&r2=9687&view=diff
==============================================================================
--- branches/bmrb/generic_fns/bmrb.py (original)
+++ branches/bmrb/generic_fns/bmrb.py Fri Oct  9 13:00:28 2009
@@ -33,8 +33,8 @@
 from specific_fns.setup import get_specific_fn
 
 
-def display():
-    """Display the results in the BMRB NMR-STAR v3.1 format."""
+def display(version='3.1'):
+    """Display the results in the BMRB NMR-STAR format."""
 
     # Test if the current data pipe exists.
     if not ds.current_pipe:
@@ -44,7 +44,7 @@
     write_function = get_specific_fn('bmrb_write', 
ds[ds.current_pipe].pipe_type, raise_error=False)
 
     # Write the results.
-    write_function(sys.stdout)
+    write_function(sys.stdout, version=version)
 
 
 def read(file=None, directory=None):
@@ -72,7 +72,7 @@
     read_function(file_path)
 
 
-def write(file=None, directory=None, force=False):
+def write(file=None, directory=None, version='3.1', force=False):
     """Create a BMRB NMR-STAR v3.1 formatted file."""
 
     # Test if the current data pipe exists.
@@ -100,4 +100,4 @@
     mkdir_nofail(directory, verbosity=0)
 
     # Execute the specific BMRB writing code.
-    write_function(file_path, version='3.1')
+    write_function(file_path, version=version)

Modified: branches/bmrb/prompt/bmrb.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/bmrb/prompt/bmrb.py?rev=9687&r1=9686&r2=9687&view=diff
==============================================================================
--- branches/bmrb/prompt/bmrb.py (original)
+++ branches/bmrb/prompt/bmrb.py Fri Oct  9 13:00:28 2009
@@ -20,39 +20,34 @@
 #                                                                            
 #
 
###############################################################################
 
+# Module docstring.
+"""Module containing the BMRB user function class."""
+__docformat__ = 'plaintext'
+
 # Python module imports.
 import sys
 
 # relax module imports.
-import help
+from base_class import User_fn_class
+import check
 from generic_fns import bmrb
 from relax_errors import RelaxBoolError, RelaxIntError, RelaxNoneStrError, 
RelaxStrError, RelaxStrFileError
 
 
-class BMRB:
-    def __init__(self, relax):
-        # Help.
-        self.__relax_help__ = \
-        """Class for interfacing with the BMRB 
(http://www.bmrb.wisc.edu/)."""
+class BMRB(User_fn_class):
+    """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
-
-        # Place relax in the class namespace.
-        self.__relax__ = relax
-
-
-    def display(self):
-        """Display the BMRB data in NMR-STAR v3.1 format."""
+    def display(self, version='3.1'):
+        """Display the BMRB data in NMR-STAR format."""
 
         # Function intro text.
         if self.__relax__.interpreter.intro:
             text = sys.ps3 + "bmrb.display("
-            text = text + "format=" + repr(format) + ")"
+            text = text + "version=" + repr(version) + ")"
             print(text)
 
         # Execute the functional code.
-        bmrb.display(format=format)
+        bmrb.display(version=version)
 
 
     def read(self, file=None, dir=None):
@@ -79,20 +74,16 @@
             text = text + ", dir=" + repr(dir) + ")"
             print(text)
 
-        # File.
-        if not isinstance(file, str):
-            raise RelaxStrError('file name', file)
-
-        # Directory.
-        if dir != None and not isinstance(dir, str):
-            raise RelaxNoneStrError('directory name', dir)
+        # The argument checks.
+        check.is_str(file, 'file name')
+        check.is_str(dir, 'directory name', can_be_none=True)
 
         # Execute the functional code.
         bmrb.read(file=file, directory=dir)
 
 
-    def write(self, file=None, dir='pipe_name', force=False):
-        """Write the results to a BMRB NMR-STAR v3.1 formatted file.
+    def write(self, file=None, dir='pipe_name', version='3.1', force=False):
+        """Write the results to a BMRB NMR-STAR formatted file.
 
         Keyword Arguments
         ~~~~~~~~~~~~~~~~~
@@ -102,6 +93,8 @@
 
         dir:  The directory name.
 
+        version:  The NMR-STAR dictionary format version to use.
+.sconsign.dblite
         force:  A flag which if True will cause the any pre-existing file to 
be overwritten.
 
 
@@ -118,20 +111,15 @@
             text = sys.ps3 + "bmrb.write("
             text = text + "file=" + repr(file)
             text = text + ", dir=" + repr(dir)
+            text = text + ", version=" + repr(version)
             text = text + ", force=" + repr(force) + ")"
             print(text)
 
-        # File.
-        if not isinstance(file, str) and not hasattr(file, 'write'):
-            raise RelaxStrFileError('file name', file)
-
-        # Directory.
-        if dir != None and not isinstance(dir, str):
-            raise RelaxNoneStrError('directory name', dir)
-
-        # The force flag.
-        if not isinstance(force, bool):
-            raise RelaxBoolError('force flag', force)
+        # The argument checks.
+        check.is_str(file, 'file name')
+        check.is_str(dir, 'directory name', can_be_none=True)
+        check.is_str(version, 'NMR-STAR dictionary version')
+        check.is_bool(force, 'force flag')
 
         # Execute the functional code.
-        bmrb.write(file=file, directory=dir, force=force)
+        bmrb.write(file=file, directory=dir, version=version, force=force)




Related Messages


Powered by MHonArc, Updated Fri Oct 09 13:20:02 2009