mailr15921 - /branches/uf_redesign/user_functions/pipe.py


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

Header


Content

Posted by edward on May 03, 2012 - 21:30:
Author: bugman
Date: Thu May  3 21:30:27 2012
New Revision: 15921

URL: http://svn.gna.org/viewcvs/relax?rev=15921&view=rev
Log:
Converted the entire of the 'pipe' module to populate the user function data 
structure.


Modified:
    branches/uf_redesign/user_functions/pipe.py

Modified: branches/uf_redesign/user_functions/pipe.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/uf_redesign/user_functions/pipe.py?rev=15921&r1=15920&r2=15921&view=diff
==============================================================================
--- branches/uf_redesign/user_functions/pipe.py (original)
+++ branches/uf_redesign/user_functions/pipe.py Thu May  3 21:30:27 2012
@@ -1,6 +1,6 @@
 
###############################################################################
 #                                                                            
 #
-# Copyright (C) 2004-2011 Edward d'Auvergne                                  
 #
+# Copyright (C) 2004-2012 Edward d'Auvergne                                  
 #
 #                                                                            
 #
 # This file is part of the program relax.                                    
 #
 #                                                                            
 #
@@ -21,8 +21,7 @@
 
###############################################################################
 
 # Module docstring.
-"""Module containing the 'pipe' user function class."""
-__docformat__ = 'plaintext'
+"""Module containing the 'pipe' user function data."""
 
 # relax module imports.
 from base_class import User_fn_class, _build_doc
@@ -30,223 +29,124 @@
 from generic_fns import pipes
 from relax_errors import RelaxError
 from specific_fns.setup import hybrid_obj
+from user_functions.objects import Container
+from user_functions import Uf_info; uf_info = Uf_info()
 
 
-class Pipe(User_fn_class):
-    """Class for holding the functions for manipulating data pipes."""
+# The user function class.
+uf_class = uf_info.add_class('pipe')
+uf_class.title = "Class for holding the user functions for manipulating data 
pipes."
 
-    def copy(self, pipe_from=None, pipe_to=None):
-        # Function intro text.
-        if self._exec_info.intro:
-            text = self._exec_info.ps3 + "pipe.copy("
-            text = text + "pipe_from=" + repr(pipe_from)
-            text = text + ", pipe_to=" + repr(pipe_to) + ")"
-            print(text)
+# The pipe.copy user function.
+uf = uf_info.add_uf('pipe.copy')
+uf.title = "Copy a data pipe."
+uf.title_short = "Data pipe copying."
+uf.add_keyarg(name="pipe_from", default=None, py_type="str", 
desc_short="pipe from", desc="The name of the source data pipe to copy the 
data from.", can_be_none=True)
+uf.add_keyarg(name="pipe_to", default=None, py_type="str", desc_short="pipe 
to", desc="The name of the target data pipe to copy the data to.", 
can_be_none=True)
+uf.backend = 'generic_fns.pipes.copy'
+uf.desc = """
+This allows the contents of a data pipe to be copied.  If the source data 
pipe is not set, the current data pipe will be assumed.  The target data pipe 
must not yet exist.
+"""
+uf.prompt_examples = """
+To copy the contents of the 'm1' data pipe to the 'm2' data pipe, type:
 
-        # The argument checks.
-        arg_check.is_str(pipe_from, 'pipe from', can_be_none=True)
-        arg_check.is_str(pipe_to, 'pipe to', can_be_none=True)
+relax> pipe.copy('m1', 'm2')
+relax> pipe.copy(pipe_from='m1', pipe_to='m2')
 
-        # Both pipe arguments cannot be None.
-        if pipe_from == None and pipe_to == None:
-            raise RelaxError("The pipe_from and pipe_to arguments cannot 
both be set to None.")
+If the current data pipe is 'm1', then the following command can be used:
 
-        # Execute the functional code.
-        pipes.copy(pipe_from=pipe_from, pipe_to=pipe_to)
+relax> pipe.copy(pipe_to='m2')
+"""
 
-    # The function doc info.
-    copy._doc_title = "Copy a data pipe."
-    copy._doc_title_short = "Data pipe copying."
-    copy._doc_args = [
-        ["pipe_from", "The name of the source data pipe to copy the data 
from."],
-        ["pipe_to", "The name of the target data pipe to copy the data to."]
-    ]
-    copy._doc_desc = """
-        This allows the contents of a data pipe to be copied.  If the source 
data pipe is not set, the current data pipe will be assumed.  The target data 
pipe must not yet exist.
-        """
-    copy._doc_examples = """
-        To copy the contents of the 'm1' data pipe to the 'm2' data pipe, 
type:
+# The pipe.create user function.
+uf = uf_info.add_uf('pipe.create')
+uf.title = "Add a new data pipe to the relax data store."
+uf.title_short = "Data pipe creation."
+uf.add_keyarg(name="pipe_name", default=None, py_type="str", 
desc_short="data pipe name", desc="The name of the data pipe.")
+uf.add_keyarg(name="pipe_type", default=None, py_type="str", 
desc_short="data pipe type", desc="The type of data pipe.")
+uf.backend = 'generic_fns.pipes.create'
+uf.desc = """
+The data pipe name can be any string however the data pipe type can only be 
one of the following:
 
-        relax> pipe.copy('m1', 'm2')
-        relax> pipe.copy(pipe_from='m1', pipe_to='m2')
+    'ct':  Consistency testing,
+    'frame order':  The Frame Order theories,
+    'jw':  Reduced spectral density mapping,
+    'hybrid':  A special hybrid pipe,
+    'mf':  Model-free analysis,
+    'N-state':  N-state model of domain motions,
+    'noe':  Steady state NOE calculation,
+    'relax_fit':  Relaxation curve fitting,
+"""
+uf.prompt_examples = """
+To set up a model-free analysis data pipe with the name 'm5', type:
 
-        If the current data pipe is 'm1', then the following command can be 
used:
+relax> pipe.create('m5', 'mf')
+"""
 
-        relax> pipe.copy(pipe_to='m2')
-        """
-    _build_doc(copy)
+# The pipe.current user function.
+uf = uf_info.add_uf('pipe.current')
+uf.title = "Print the name of the current data pipe."
+uf.title_short = "Current data pipe printing."
+uf.backend = 'generic_fns.pipes.current'
+uf.prompt_examples = """
+To run the user function, type:
 
+relax> pipe.current()
+"""
 
-    def create(self, pipe_name=None, pipe_type=None):
-        # Function intro text.
-        if self._exec_info.intro:
-            text = self._exec_info.ps3 + "pipe.create("
-            text = text + "pipe_name=" + repr(pipe_name)
-            text = text + ", pipe_type=" + repr(pipe_type) + ")"
-            print(text)
+# The pipe.delete user function.
+uf = uf_info.add_uf('pipe.delete')
+uf.title = "Delete a data pipe from the relax data store."
+uf.title_short = "Data pipe deletion."
+uf.add_keyarg(name="pipe_name", default=None, py_type="str", 
desc_short="data pipe name", desc="The name of the data pipe to delete.", 
can_be_none=True)
+uf.backend = 'generic_fns.pipes.delete'
+uf.desc = """
+This will permanently remove the data pipe and all of its contents from the 
relax data store.  If the pipe name is not given, then all data pipes will be 
deleted.
+"""
 
-        # The argument checks.
-        arg_check.is_str(pipe_name, 'data pipe name')
-        arg_check.is_str(pipe_type, 'data pipe type')
+# The pipe.display user function.
+uf = uf_info.add_uf('pipe.display')
+uf.title = "Print a list of all the data pipes."
+uf.title_short = "Data pipe listing."
+uf.backend = 'generic_fns.pipes.display'
+uf.prompt_examples = """
+To run the user function, type:
 
-        # Execute the functional code.
-        pipes.create(pipe_name=pipe_name, pipe_type=pipe_type)
+relax> pipe.display()
+"""
 
-    # The function doc info.
-    create._doc_title = "Add a new data pipe to the relax data store."
-    create._doc_title_short = "Data pipe creation."
-    create._doc_args = [
-        ["pipe_name", "The name of the data pipe."],
-        ["pipe_type", "The type of data pipe."]
-    ]
-    create._doc_desc = """
-        The data pipe name can be any string however the data pipe type can 
only be one of the following:
+# The pipe.hybridise user function.
+uf = uf_info.add_uf('pipe.hybridise')
+uf.title = "Create a hybrid data pipe by fusing a number of other data 
pipes."
+uf.title_short = "Hybrid data pipe creation."
+uf.add_keyarg(name="hybrid", default=None, py_type="str", desc_short="hybrid 
pipe name", desc="The name of the hybrid data pipe to create.")
+uf.add_keyarg(name="pipes", default=None, py_type="str_list", 
desc_short="data pipes", desc="An array containing the names of all data 
pipes to hybridise.")
+uf.backend = 'specific_fns.setup.hybrid_obj._hybridise'
+uf.desc = """
+This user function can be used to construct hybrid models.  An example of 
the use of a hybrid model could be if the protein consists of two independent 
domains.  These two domains could be analysed separately, each having their 
own optimised diffusion tensors.  The N-terminal domain data pipe could be 
called 'N_sphere' while the C-terminal domain could be called 'C_ellipsoid'.  
These two data pipes could then be hybridised into a single data pipe.  This 
hybrid data pipe can then be compared via model selection to a data pipe 
whereby the entire protein is assumed to have a single diffusion tensor.
 
-            'ct':  Consistency testing,
-            'frame order':  The Frame Order theories,
-            'jw':  Reduced spectral density mapping,
-            'hybrid':  A special hybrid pipe,
-            'mf':  Model-free analysis,
-            'N-state':  N-state model of domain motions,
-            'noe':  Steady state NOE calculation,
-            'relax_fit':  Relaxation curve fitting,
-        """
-    create._doc_examples = """
-        To set up a model-free analysis data pipe with the name 'm5', type:
+The requirements for data pipes to be hybridised is that the molecules, 
sequences, and spin systems for all the data pipes is the same, and that no 
spin system is allowed to be selected in two or more data pipes.  The 
selections must not overlap to allow for rigorous statistical comparisons.
+"""
+uf.prompt_examples = """
+The two data pipes 'N_sphere' and 'C_ellipsoid' could be hybridised into a 
single data pipe
+called 'mixed model' by typing:
 
-        relax> pipe.create('m5', 'mf')
-        """
-    _build_doc(create)
+relax> pipe.hybridise('mixed model', ['N_sphere', 'C_ellipsoid'])
+relax> pipe.hybridise(hybrid='mixed model', pipes=['N_sphere', 
'C_ellipsoid'])
+"""
 
+# The pipe.switch user function.
+uf = uf_info.add_uf('pipe.switch')
+uf.title = "Switch between the data pipes of the relax data store."
+uf.title_short = "Data pipe switching."
+uf.add_keyarg(name="pipe_name", default=None, py_type="str", 
desc_short="data pipe name", desc="The name of the data pipe."]
+uf.backend = 'generic_fns.pipes.switch'
+uf.desc = """
+This will switch between the various data pipes within the relax data store.
+"""
+uf.prompt_examples = """
+To switch to the 'ellipsoid' data pipe, type:
 
-    def current(self):
-        # Function intro text.
-        if self._exec_info.intro:
-            text = self._exec_info.ps3 + "pipe.current()"
-            print(text)
-
-        # Execute the functional code.
-        pipes.current()
-
-    # The function doc info.
-    current._doc_title = "Print the name of the current data pipe."
-    current._doc_title_short = "Current data pipe printing."
-    current._doc_examples = """
-        To run the user function, type:
-
-        relax> pipe.current()
-        """
-    _build_doc(current)
-
-
-    def delete(self, pipe_name=None):
-        # Function intro text.
-        if self._exec_info.intro:
-            text = self._exec_info.ps3 + "pipe.delete("
-            text = text + "pipe_name=" + repr(pipe_name) + ")"
-            print(text)
-
-        # The argument checks.
-        arg_check.is_str(pipe_name, 'data pipe name', can_be_none=True)
-
-        # Execute the functional code.
-        pipes.delete(pipe_name=pipe_name)
-
-    # The function doc info.
-    delete._doc_title = "Delete a data pipe from the relax data store."
-    delete._doc_title_short = "Data pipe deletion."
-    delete._doc_args = [
-        ["pipe_name", "The name of the data pipe to delete."]
-    ]
-    delete._doc_desc = """
-        This will permanently remove the data pipe and all of its contents 
from the relax data store.  If the pipe name is not given, then all data 
pipes will be deleted.
-        """
-    _build_doc(delete)
-
-
-    def display(self):
-        # Function intro text.
-        if self._exec_info.intro:
-            text = self._exec_info.ps3 + "pipe.display()"
-            print(text)
-
-        # Execute the functional code.
-        pipes.display()
-
-    # The function doc info.
-    display._doc_title = "Print a list of all the data pipes."
-    display._doc_title_short = "Data pipe listing."
-    display._doc_examples = """
-        To run the user function, type:
-
-        relax> pipe.display()
-        """
-    _build_doc(display)
-
-
-    def hybridise(self, hybrid=None, pipes=None):
-        # Function intro text.
-        if self._exec_info.intro:
-            text = self._exec_info.ps3 + "pipe.hybridise("
-            text = text + "hybrid=" + repr(hybrid)
-            text = text + ", pipes=" + repr(pipes) + ")"
-            print(text)
-
-        # The argument checks.
-        arg_check.is_str(hybrid, 'hybrid pipe name')
-        arg_check.is_str_list(pipes, 'data pipes')
-
-        # Execute the functional code.
-        hybrid_obj._hybridise(hybrid=hybrid, pipe_list=pipes)
-
-    # The function doc info.
-    hybridise._doc_title = "Create a hybrid data pipe by fusing a number of 
other data pipes."
-    hybridise._doc_title_short = "Hybrid data pipe creation."
-    hybridise._doc_args = [
-        ["hybrid", "The name of the hybrid data pipe to create."],
-        ["pipes", "An array containing the names of all data pipes to 
hybridise."]
-    ]
-    hybridise._doc_desc = """
-        This user function can be used to construct hybrid models.  An 
example of the use of a hybrid model could be if the protein consists of two 
independent domains.  These two domains could be analysed separately, each 
having their own optimised diffusion tensors.  The N-terminal domain data 
pipe could be called 'N_sphere' while the C-terminal domain could be called 
'C_ellipsoid'.  These two data pipes could then be hybridised into a single 
data pipe.  This hybrid data pipe can then be compared via model selection to 
a data pipe whereby the entire protein is assumed to have a single diffusion 
tensor.
-
-        The requirements for data pipes to be hybridised is that the 
molecules, sequences, and spin systems for all the data pipes is the same, 
and that no spin system is allowed to be selected in two or more data pipes.  
The selections must not overlap to allow for rigorous statistical comparisons.
-        """
-    hybridise._doc_examples = """
-        The two data pipes 'N_sphere' and 'C_ellipsoid' could be hybridised 
into a single data pipe
-        called 'mixed model' by typing:
-
-        relax> pipe.hybridise('mixed model', ['N_sphere', 'C_ellipsoid'])
-        relax> pipe.hybridise(hybrid='mixed model', pipes=['N_sphere', 
'C_ellipsoid'])
-        """
-    _build_doc(hybridise)
-
-
-    def switch(self, pipe_name=None):
-        # Function intro text.
-        if self._exec_info.intro:
-            text = self._exec_info.ps3 + "pipe.switch("
-            text = text + "pipe_name=" + repr(pipe_name) + ")"
-            print(text)
-
-        # The argument checks.
-        arg_check.is_str(pipe_name, 'data pipe name')
-
-        # Execute the functional code.
-        pipes.switch(pipe_name=pipe_name)
-
-    # The function doc info.
-    switch._doc_title = "Switch between the data pipes of the relax data 
store."
-    switch._doc_title_short = "Data pipe switching."
-    switch._doc_args = [
-        ["pipe_name", "The name of the data pipe."]
-    ]
-    switch._doc_desc = """
-        This will switch between the various data pipes within the relax 
data store.
-        """
-    switch._doc_examples = """
-        To switch to the 'ellipsoid' data pipe, type:
-
-        relax> pipe.switch('ellipsoid')
-        relax> pipe.switch(pipe_name='ellipsoid')
-        """
-    _build_doc(switch)
+relax> pipe.switch('ellipsoid')
+relax> pipe.switch(pipe_name='ellipsoid')
+"""




Related Messages


Powered by MHonArc, Updated Thu May 03 21:40:02 2012