mailr8850 - in /branches/bmrb: bmrblib/__init__.py 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 February 22, 2009 - 14:53:
Author: bugman
Date: Sun Feb 22 14:53:45 2009
New Revision: 8850

URL: http://svn.gna.org/viewcvs/relax?rev=8850&view=rev
Log:
Code rearrangement. 

The BMRB read(), write(), and display() methods called by the user functions 
has been shifted to
generic_fns.  This allows bmrblib to be purely a package providing an API for 
the NMR-STAR
dictionaries, with reading and writing done by pystarlib.


Added:
    branches/bmrb/generic_fns/bmrb.py
      - copied, changed from r8834, branches/bmrb/bmrblib/__init__.py
Modified:
    branches/bmrb/bmrblib/__init__.py
    branches/bmrb/prompt/bmrb.py

Modified: branches/bmrb/bmrblib/__init__.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/bmrb/bmrblib/__init__.py?rev=8850&r1=8849&r2=8850&view=diff
==============================================================================
--- branches/bmrb/bmrblib/__init__.py (original)
+++ branches/bmrb/bmrblib/__init__.py Sun Feb 22 14:53:45 2009
@@ -23,85 +23,5 @@
 # Module docstring.
 """Package for interfacing with the BMRB (http://www.bmrb.wisc.edu/) by 
handling NMR-STAR formatted 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
-import specific_fns
-
 
 __all__ = ['nmr_star_dict']
-
-
-
-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 = specific_fns.setup.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 = specific_fns.setup.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 = 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)
-
-    # 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)

Copied: branches/bmrb/generic_fns/bmrb.py (from r8834, 
branches/bmrb/bmrblib/__init__.py)
URL: 
http://svn.gna.org/viewcvs/relax/branches/bmrb/generic_fns/bmrb.py?p2=branches/bmrb/generic_fns/bmrb.py&p1=branches/bmrb/bmrblib/__init__.py&r1=8834&r2=8850&rev=8850&view=diff
==============================================================================
--- branches/bmrb/bmrblib/__init__.py (original)
+++ branches/bmrb/generic_fns/bmrb.py Sun Feb 22 14:53:45 2009
@@ -21,7 +21,7 @@
 
###############################################################################
 
 # Module docstring.
-"""Package for interfacing with the BMRB (http://www.bmrb.wisc.edu/) by 
handling NMR-STAR formatted files."""
+"""Module containing functions for BMRB support."""
 
 # Python module imports.
 from os import F_OK, access
@@ -30,11 +30,7 @@
 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
-import specific_fns
-
-
-__all__ = ['nmr_star_dict']
-
+from specific_fns.setup import get_specific_fn
 
 
 def display():
@@ -45,7 +41,7 @@
         raise RelaxNoPipeError
 
     # Specific results writing function.
-    write_function = specific_fns.setup.get_specific_fn('bmrb_write', 
ds[ds.current_pipe].pipe_type, raise_error=False)
+    write_function = get_specific_fn('bmrb_write', 
ds[ds.current_pipe].pipe_type, raise_error=False)
 
     # Write the results.
     write_function(sys.stdout)
@@ -70,7 +66,7 @@
         raise RelaxFileError, file_path
 
     # Specific results reading function.
-    read_function = specific_fns.setup.get_specific_fn('bmrb_read', 
ds[ds.current_pipe].pipe_type)
+    read_function = get_specific_fn('bmrb_read', 
ds[ds.current_pipe].pipe_type)
 
     # Read the results.
     read_function(file_path)
@@ -88,7 +84,7 @@
         directory = ds.current_pipe
 
     # Specific results writing function.
-    write_function = specific_fns.setup.get_specific_fn('bmrb_write', 
ds[ds.current_pipe].pipe_type)
+    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)

Modified: branches/bmrb/prompt/bmrb.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/bmrb/prompt/bmrb.py?rev=8850&r1=8849&r2=8850&view=diff
==============================================================================
--- branches/bmrb/prompt/bmrb.py (original)
+++ branches/bmrb/prompt/bmrb.py Sun Feb 22 14:53:45 2009
@@ -25,7 +25,7 @@
 
 # relax module imports.
 import help
-import bmrblib
+from generic_fns import bmrb
 from relax_errors import RelaxBoolError, RelaxIntError, RelaxNoneStrError, 
RelaxStrError, RelaxStrFileError
 
 
@@ -52,7 +52,7 @@
             print text
 
         # Execute the functional code.
-        bmrblib.display(format=format)
+        bmrb.display(format=format)
 
 
     def read(self, file=None, dir=None):
@@ -88,7 +88,7 @@
             raise RelaxNoneStrError, ('directory name', dir)
 
         # Execute the functional code.
-        bmrblib.read(file=file, directory=dir)
+        bmrb.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.
-        bmrblib.write(file=file, directory=dir, force=force)
+        bmrb.write(file=file, directory=dir, force=force)




Related Messages


Powered by MHonArc, Updated Sun Feb 22 15:20:08 2009