Ejemplo n.º 1
0
def start(mode=None, profile_flag=False):
    """Execute relax.

    @keyword mode:          Force a relax mode, overriding the command line.
    @type mode:             str
    @keyword profile_flag:  Change this flag to True for code profiling.
    @type profile_flag:     bool
    """

    # Normal relax operation.
    relax = Relax()

    # Override normal operation.
    if mode:
        # Override the mode.
        relax.mode = mode

        # Some defaults.
        relax.script_file = None
        relax.log_file = None
        relax.tee_file = None
        relax.multiprocessor_type = 'uni'
        relax.n_processors = 1

    # Process the command line arguments.
    else:
        relax.arguments()

    # Store some start up info in the status object.
    status.relax_mode = relax.mode

    # Set up the multi-processor elements.
    callbacks = Application_callback(master=relax)
    verbosity = 0
    if status.debug:
        verbosity = 1
    processor = load_multiprocessor(relax.multiprocessor_type, callbacks, processor_size=relax.n_processors, verbosity=verbosity)

    # Place the processor fabric intro string into the info box.
    info = Info_box()
    info.multi_processor_string = processor.get_intro_string()

    # Normal relax operation.
    if not profile_flag:
        # Execute relax in multi-processor mode (this includes the uni-processor for normal operation).
        processor.run()

    # relax in profiling mode.
    else:
        def print_stats(stats, status=0):
            pstats.Stats(stats).sort_stats('time', 'name').print_stats()

        # No profile module.
        if not dep_check.profile_module:
            sys.stderr.write("The profile module is not available, please install the Python development packages for profiling.\n\n")
            sys.exit()

        # Run relax in profiling mode.
        profile.Profile.print_stats = print_stats
        profile.runctx('processor.run()', globals(), locals())
Ejemplo n.º 2
0
    def __init__(self, show_script=True, quit=True, raise_relax_error=False):
        """The interpreter class.

        @param show_script:         If true, the relax will print the script contents prior to
                                    executing the script.
        @type show_script:          bool
        @param quit:                If true, the default, then relax will exit after running the
                                    run() method.
        @type quit:                 bool
        @param raise_relax_error:   If false, the default, then relax will print a nice error
                                    message to STDERR, without a traceback, when a RelaxError
                                    occurs.  This is to make things nicer for the user.
        @type raise_relax_error:    bool
        """

        # Place the arguments in the class namespace.
        self.__show_script = show_script
        self.__quit_flag = quit
        self.__raise_relax_error = raise_relax_error

        # Build the intro string.
        info = Info_box()
        self.__intro_string = info.intro_text()

        # The prompts (change the Python prompt, as well as the function printouts).
        if ansi.enable_control_chars(stream=1):
            self.prompt_colour_on()
        else:
            self.prompt_colour_off()

        # Set up the interpreter objects.
        self._locals = self._setup()
Ejemplo n.º 3
0
    def __init__(self,
                 locals=None,
                 rawin=None,
                 stdin=sys.stdin,
                 stdout=sys.stdout,
                 stderr=sys.stderr,
                 showInterpIntro=True):
        """Redefine the interpreter."""

        # Execute the base class __init__() method.
        wx.py.interpreter.Interpreter.__init__(self,
                                               locals=locals,
                                               rawin=rawin,
                                               stdin=stdin,
                                               stdout=stdout,
                                               stderr=stderr,
                                               showInterpIntro=showInterpIntro)

        # The introductory text.
        info = Info_box()
        self.introText = info.intro_text()

        # The relax interpreter.
        interp = interpreter.Interpreter(show_script=False,
                                         raise_relax_error=True)

        # The locals.
        self.locals = interp._locals
Ejemplo n.º 4
0
    def __init__(self, show_script=True, raise_relax_error=False):
        """The interpreter class.

        @param show_script:         If true, the relax will print the script contents prior to
                                    executing the script.
        @type show_script:          bool
        @param raise_relax_error:   If false, the default, then relax will print a nice error
                                    message to STDERR, without a traceback, when a RelaxError
                                    occurs.  This is to make things nicer for the user.
        @type raise_relax_error:    bool
        """

        # Place the arguments in the class namespace.
        self.__show_script = show_script
        self.__raise_relax_error = raise_relax_error

        # Build the intro string.
        info = Info_box()
        self.__intro_string = info.intro_text()

        # The prompts (change the Python prompt, as well as the function printouts).
        if ansi.enable_control_chars(stream=1) and not status.show_gui:
            self.prompt_colour_on()
        else:
            self.prompt_colour_off()

        # Set up the interpreter objects.
        self._locals = self._setup()
Ejemplo n.º 5
0
    def __init__(self, locals=None, rawin=None, stdin=sys.stdin, stdout=sys.stdout, stderr=sys.stderr, showInterpIntro=True):
        """Redefine the interpreter."""

        # Execute the base class __init__() method.
        wx.py.interpreter.Interpreter.__init__(self, locals=locals, rawin=rawin, stdin=stdin, stdout=stdout, stderr=stderr, showInterpIntro=showInterpIntro)

        # The introductory text.
        info = Info_box()
        self.introText = info.intro_text()

        # The relax interpreter.
        interp = interpreter.Interpreter(show_script=False, quit=False, raise_relax_error=True)

        # The locals.
        self.locals = interp._locals
Ejemplo n.º 6
0
def copyright_file(target, source, env):
    """Builder action for creating the LaTeX copyright notice file."""

    # Print out.
    print('')
    print("##################################################")
    print("# Creating the LaTeX relax copyright notice file #")
    print("##################################################")

    # The LaTeX file.
    file = open(env['LATEX_DIR'] + sep + 'copyright.tex', 'w')

    # Initialise the info box.
    info = Info_box()

    # The notice.
    file.write("\\noindent %s\n\n" % info.copyright_latex)
    file.write("\\vspace{5px}\n\n")

    # The text.
    file.write("\\noindent Permission is granted to copy, distribute and/or modify this document under the terms of the GNU General Public License (GPL), Version 3 or any later version published by the Free Software Foundation.\n")
    file.write("\\vspace{5px}\n\n")
    file.write("\\noindent The Oxygen Icons used herein are licensed under the terms of the GNU Lesser General Public License (GPL), Version 3 or any later version published by the Free Software Foundation.\n")

    # Close the file.
    file.close()

    # Final printout.
    print("\n\n\n")
Ejemplo n.º 7
0
    def __init__(self, parent=None, id=-1, title="About relax"):
        """Build the dialog."""

        # Initialise the program information container.
        self.info = Info_box()

        # Execute the base class __init__() method.
        super(About_relax, self).__init__(parent=parent, id=id, title=title)
Ejemplo n.º 8
0
    def front_page(self):
        """The main reference page."""

        # Initialise the program information container.
        info = Info_box()

        # The HTML header.
        text = HTML_HEADER

        # The reference header.
        text = text + "<center>"
        text = text + "<img src=%s%s></img>" % (
            IMAGE_PATH, 'ulysses_shadowless_400x168.png')
        text = text + "<h1>relax references</h1>"
        text = text + "</center>"

        # Main refs.
        text = text + "<h2>The program relax</h2>"
        text = text + "<p>%s</p>" % info.bib['dAuvergneGooley08a'].cite_html()
        text = text + "<p>%s</p>" % info.bib['dAuvergneGooley08b'].cite_html()

        # GUI refs.
        text = text + "<h3><i>The relax GUI</i></h3>"
        text = text + "<p>%s</p>" % info.bib['Bieri11'].cite_html()

        # Model-free refs.
        text = text + "<h2>Model-free analysis</h2>"
        text = text + "<p>For a model-free analysis, all of the following should be cited!</p>"
        text = text + "<h3><i>Original Lipari-Szabo theory</i></h3>"
        text = text + "<p>%s</p>" % info.bib['LipariSzabo82a'].cite_html()
        text = text + "<p>%s</p>" % info.bib['LipariSzabo82b'].cite_html()
        text = text + "<h3><i>Extended model-free theory</i></h3>"
        text = text + "<p>%s</p>" % info.bib['Clore90'].cite_html()
        text = text + "<h3><i>Model-free model selection</i></h3>"
        text = text + "<p>%s</p>" % info.bib['dAuvergneGooley03'].cite_html()
        text = text + "<h3><i>Model-free model elimination</i></h3>"
        text = text + "<p>%s</p>" % info.bib['dAuvergneGooley06'].cite_html()
        text = text + "<h3><i>Model-free minimisation</i></h3>"
        text = text + "<p>%s</p>" % info.bib['dAuvergneGooley08a'].cite_html()
        text = text + "<h3><i>The new model-free analysis protocol</i></h3>"
        text = text + "<p>%s</p>" % info.bib['dAuvergneGooley07'].cite_html()
        text = text + "<p>%s</p>" % info.bib['dAuvergneGooley08b'].cite_html()
        text = text + "<h3><i>Comprehensive reference</i></h3>"
        text = text + "<p>This PhD thesis expands on all of the d'Auvergne and Gooley references and describes model-free analysis and the program relax in more detail:</p>"
        text = text + "<p>%s</p>" % info.bib['dAuvergne06'].cite_html()

        # The footer.
        text = text + HTML_FOOTER
        self.html.SetPage(text)
Ejemplo n.º 9
0
def write(file=None, dir=None, version='3.1', force=False):
    """Create a BMRB NMR-STAR formatted file.

    @keyword file:      The name of the file to create or a file object.
    @type file:         str or file object
    @keyword dir:       The optional directory to place the file into.  If set to 'pipe_name', then it will be placed in a directory with the same name as the current data pipe.
    @type dir:          str or None
    @keyword version:   The NMR-STAR version to create.  This can be either '2.1', '3.0', or '3.1'.
    @type version:      str
    @keyword force:     A flag which if True will allow a currently existing file to be overwritten.
    @type force:        bool
    """

    # Test if bmrblib is installed.
    if not dep_check.bmrblib_module:
        raise RelaxNoModuleInstallError('BMRB library', 'bmrblib')

    # Test if the current data pipe exists.
    pipe_name = cdp_name()
    if not pipe_name:
        raise RelaxNoPipeError

    # Check the file name.
    if file == None:
        raise RelaxError("The file name must be specified.")

    # A file object.
    if isinstance(file, str):
        # The special data pipe name directory.
        if dir == 'pipe_name':
            dir = pipe_name

        # Get the full file path.
        file = get_file_path(file, dir)

        # Fail if the file already exists and the force flag is False.
        if access(file, F_OK) and not force:
            raise RelaxFileOverwriteError(file, 'force flag')

        # Print out.
        print("Opening the file '%s' for writing." % file)

        # Create the directories.
        mkdir_nofail(dir, verbosity=0)

    # Get the info box.
    info = Info_box()

    # Add the relax citations.
    for id, key in zip(['relax_ref1', 'relax_ref2'],
                       ['dAuvergneGooley08a', 'dAuvergneGooley08b']):
        # Alias the bib entry.
        bib = info.bib[key]

        # Add.
        exp_info.citation(cite_id=id,
                          authors=bib.author2,
                          doi=bib.doi,
                          pubmed_id=bib.pubmed_id,
                          full_citation=bib.cite_short(doi=False, url=False),
                          title=bib.title,
                          status=bib.status,
                          type=bib.type,
                          journal_abbrev=bib.journal,
                          journal_full=bib.journal_full,
                          volume=bib.volume,
                          issue=bib.number,
                          page_first=bib.page_first,
                          page_last=bib.page_last,
                          year=bib.year)

    # Add the relax software package.
    exp_info.software(name=exp_info.SOFTWARE['relax'].name,
                      version=version_full(),
                      vendor_name=exp_info.SOFTWARE['relax'].authors,
                      url=exp_info.SOFTWARE['relax'].url,
                      cite_ids=['relax_ref1', 'relax_ref2'],
                      tasks=exp_info.SOFTWARE['relax'].tasks)

    # Execute the specific BMRB writing code.
    api = return_api(pipe_name=pipe_name)
    api.bmrb_write(file, version=version)

    # Add the file to the results file list.
    if isinstance(file, str):
        add_result_file(type='text', label='BMRB', file=file)
Ejemplo n.º 10
0
    def run(self):
        """Execute relax.

        This is the application callback method executed by the multi-processor framework.
        """

        # Set up the warning system.
        lib.warnings.setup()

        # Logging.
        if self.log_file:
            io_streams_log(self.log_file)

        # Tee.
        elif self.tee_file:
            io_streams_tee(self.tee_file)

        # Show the version number and exit.
        if self.mode == 'version':
            print('relax ' + version.version_full())
            return

        # Show the relax info and exit.
        if self.mode == 'info':
            # Initialise the information box.
            info = Info_box()

            # Print the program intro.
            print(info.intro_text())

            # Print the system info.
            print(info.sys_info())

            # Stop execution.
            return

        # Run the interpreter for the prompt or script modes.
        if self.mode == 'prompt' or self.mode == 'script':
            # Run the interpreter.
            self.interpreter = interpreter.Interpreter()
            self.interpreter.run(self.script_file)

        # Execute the relax GUI.
        elif self.mode == 'gui':
            # Dependency check.
            if not dep_check.wx_module:
                sys.stderr.write("Please install the wx Python module to access the relax GUI.\n\n")
                return

            # Only import the module in this mode (to improve program start up speeds).
            import gui

            # Set the GUI flag in the status object.
            status.show_gui = True

            # Start the relax GUI wx application.
            app = gui.App(script_file=self.script_file)
            app.MainLoop()

        # Execute the relax test suite
        elif self.mode == 'test suite':
            # Only import the module in the test modes (to improve program start up speeds).
            from test_suite.test_suite_runner import Test_suite_runner

            # Load the interpreter and turn intros on.
            self.interpreter = interpreter.Interpreter(show_script=False, raise_relax_error=True)
            self.interpreter.on()

            # Run the tests.
            runner = Test_suite_runner(self.tests, timing=self.test_timings)
            runner.run_all_tests()

        # Execute the relax system tests.
        elif self.mode == 'system tests':
            # Only import the module in the test modes (to improve program start up speeds).
            from test_suite.test_suite_runner import Test_suite_runner

            # Load the interpreter and turn intros on.
            self.interpreter = interpreter.Interpreter(show_script=False, raise_relax_error=True)
            self.interpreter.on()

            # Run the tests.
            runner = Test_suite_runner(self.tests, timing=self.test_timings)
            runner.run_system_tests()

        # Execute the relax unit tests.
        elif self.mode == 'unit tests':
            # Only import the module in the test modes (to improve program start up speeds).
            from test_suite.test_suite_runner import Test_suite_runner

            # Run the tests.
            runner = Test_suite_runner(self.tests, timing=self.test_timings)
            runner.run_unit_tests()

        # Execute the relax GUI tests.
        elif self.mode == 'GUI tests':
            # Only import the module in the test modes (to improve program start up speeds).
            from test_suite.test_suite_runner import Test_suite_runner

            # Run the tests.
            runner = Test_suite_runner(self.tests, timing=self.test_timings)
            runner.run_gui_tests()

        # Execute the relax verification tests.
        elif self.mode == 'verification tests':
            # Only import the module in the test modes (to improve program start up speeds).
            from test_suite.test_suite_runner import Test_suite_runner

            # Run the tests.
            runner = Test_suite_runner(self.tests, timing=self.test_timings)
            runner.run_verification_tests()

        # Test mode.
        elif self.mode == 'test':
            self.test_mode()

        # Licence mode.
        elif self.mode == 'licence':
            self.licence()

        # Unknown mode.
        else:
            raise lib.errors.RelaxError("The '%s' mode is unknown." % self.mode)
Ejemplo n.º 11
0
def start(mode=None, profile_flag=False):
    """Execute relax.

    @keyword mode:          Force a relax mode, overriding the command line.
    @type mode:             str
    @keyword profile_flag:  Change this flag to True for code profiling.
    @type profile_flag:     bool
    """

    # Normal relax operation.
    relax = Relax()

    # Override normal operation.
    if mode:
        # Override the mode.
        relax.mode = mode

        # Some defaults.
        relax.script_file = None
        relax.log_file = None
        relax.tee_file = None
        relax.multiprocessor_type = 'uni'
        relax.n_processors = 1

    # Process the command line arguments.
    else:
        relax.arguments()

    # Store some start up info in the status object.
    status.relax_mode = relax.mode

    # Set up the multi-processor elements.
    callbacks = Application_callback(master=relax)
    verbosity = 0
    if status.debug:
        verbosity = 1
    processor = load_multiprocessor(relax.multiprocessor_type,
                                    callbacks,
                                    processor_size=relax.n_processors,
                                    verbosity=verbosity)

    # Place the processor fabric intro string into the info box.
    info = Info_box()
    info.multi_processor_string = processor.get_intro_string()

    # Normal relax operation.
    if not profile_flag:
        # Execute relax in multi-processor mode (this includes the uni-processor for normal operation).
        processor.run()

    # relax in profiling mode.
    else:

        def print_stats(stats, status=0):
            pstats.Stats(stats).sort_stats('time', 'name').print_stats()

        # No profile module.
        if not dep_check.profile_module:
            sys.stderr.write(
                "The profile module is not available, please install the Python development packages for profiling.\n\n"
            )
            sys.exit()

        # Run relax in profiling mode.
        profile.Profile.print_stats = print_stats
        profile.runctx('processor.run()', globals(), locals())
Ejemplo n.º 12
0
    def run(self):
        """Execute relax.

        This is the application callback method executed by the multi-processor framework.
        """

        # Set up the warning system.
        lib.warnings.setup()

        # Logging.
        if self.log_file:
            io_streams_log(self.log_file)

        # Tee.
        elif self.tee_file:
            io_streams_tee(self.tee_file)

        # Show the version number and exit.
        if self.mode == 'version':
            print('relax ' + version.version_full())
            return

        # Show the relax info and exit.
        if self.mode == 'info':
            # Initialise the information box.
            info = Info_box()

            # Print the program intro.
            print(info.intro_text())

            # Print the system info.
            print(info.sys_info())

            # Stop execution.
            return

        # Run the interpreter for the prompt or script modes.
        if self.mode == 'prompt' or self.mode == 'script':
            # Run the interpreter.
            self.interpreter = interpreter.Interpreter()
            self.interpreter.run(self.script_file)

        # Execute the relax GUI.
        elif self.mode == 'gui':
            # Dependency check.
            if not dep_check.wx_module:
                sys.stderr.write(
                    "Please install the wx Python module to access the relax GUI.\n\n"
                )
                return

            # Only import the module in this mode (to improve program start up speeds).
            import gui

            # Set the GUI flag in the status object.
            status.show_gui = True

            # Start the relax GUI wx application.
            app = gui.App(script_file=self.script_file)
            app.MainLoop()

        # Execute the relax test suite
        elif self.mode == 'test suite':
            # Only import the module in the test modes (to improve program start up speeds).
            from test_suite.test_suite_runner import Test_suite_runner

            # Load the interpreter and turn intros on.
            self.interpreter = interpreter.Interpreter(show_script=False,
                                                       raise_relax_error=True)
            self.interpreter.on()

            # Run the tests.
            runner = Test_suite_runner(self.tests, timing=self.test_timings)
            runner.run_all_tests()

        # Execute the relax system tests.
        elif self.mode == 'system tests':
            # Only import the module in the test modes (to improve program start up speeds).
            from test_suite.test_suite_runner import Test_suite_runner

            # Load the interpreter and turn intros on.
            self.interpreter = interpreter.Interpreter(show_script=False,
                                                       raise_relax_error=True)
            self.interpreter.on()

            # Run the tests.
            runner = Test_suite_runner(self.tests, timing=self.test_timings)
            runner.run_system_tests()

        # Execute the relax unit tests.
        elif self.mode == 'unit tests':
            # Only import the module in the test modes (to improve program start up speeds).
            from test_suite.test_suite_runner import Test_suite_runner

            # Run the tests.
            runner = Test_suite_runner(self.tests, timing=self.test_timings)
            runner.run_unit_tests()

        # Execute the relax GUI tests.
        elif self.mode == 'GUI tests':
            # Only import the module in the test modes (to improve program start up speeds).
            from test_suite.test_suite_runner import Test_suite_runner

            # Run the tests.
            runner = Test_suite_runner(self.tests, timing=self.test_timings)
            runner.run_gui_tests()

        # Execute the relax verification tests.
        elif self.mode == 'verification tests':
            # Only import the module in the test modes (to improve program start up speeds).
            from test_suite.test_suite_runner import Test_suite_runner

            # Run the tests.
            runner = Test_suite_runner(self.tests, timing=self.test_timings)
            runner.run_verification_tests()

        # Test mode.
        elif self.mode == 'test':
            self.test_mode()

        # Licence mode.
        elif self.mode == 'licence':
            self.licence()

        # Unknown mode.
        else:
            raise lib.errors.RelaxError("The '%s' mode is unknown." %
                                        self.mode)
Ejemplo n.º 13
0
    def __init__(self, gui):
        """Set up the relax controller frame.

        @param gui:     The GUI object.
        @type gui:      wx.Frame instance
        """

        # Store the args.
        self.gui = gui

        # Initialise the base class.
        super(Controller, self).__init__(self.gui,
                                         -1,
                                         style=wx.DEFAULT_FRAME_STYLE)

        # Some default values.
        self.size_x = 800
        self.size_y = 700
        self.border = 5
        self.spacer = 10

        # Set up the frame.
        sizer = self.setup_frame()

        # Add the relax logo.
        self.add_relax_logo(sizer)

        # Spacing.
        sizer.AddSpacer(20)

        # Add the current analysis info.
        self.name = self.add_text(self.main_panel, sizer,
                                  "Current GUI analysis:")

        # Add the current data pipe info.
        self.cdp = self.add_text(self.main_panel, sizer, "Current data pipe:")

        # Create the relaxation curve-fitting specific panel.
        self.create_rx(sizer)

        # Create the model-free specific panel.
        self.create_mf(sizer)

        # Add the main execution gauge.
        self.main_gauge = self.add_gauge(
            self.main_panel,
            sizer,
            "Execution progress:",
            tooltip=
            "This gauge will pulse while relax is executing an auto-analysis (when the execution lock is turned on) and will be set to 100% once the analysis is complete."
        )

        # Initialise a queue for log messages.
        self.log_queue = Queue()

        # Add the log panel.
        self.log_panel = LogCtrl(self.main_panel,
                                 self,
                                 log_queue=self.log_queue,
                                 id=-1)
        sizer.Add(self.log_panel, 1, wx.EXPAND | wx.ALL, 0)

        # IO redirection for STDOUT (with splitting if logging or teeing modes are set).
        out = Redirect_text(self.log_panel,
                            self.log_queue,
                            orig_io=sys.stdout,
                            stream=0)
        if sys.stdout == sys.__stdout__ or status.relax_mode in [
                'test suite', 'system tests', 'unit tests', 'GUI tests'
        ]:
            sys.stdout = out
        else:
            split_stdout = SplitIO()
            split_stdout.split(sys.stdout, out)
            sys.stdout = split_stdout

        # IO redirection for STDERR (with splitting if logging or teeing modes are set).
        err = Redirect_text(self.log_panel,
                            self.log_queue,
                            orig_io=sys.stderr,
                            stream=1)
        if sys.stderr == sys.__stderr__ or status.relax_mode in [
                'test suite', 'system tests', 'unit tests', 'GUI tests'
        ]:
            sys.stderr = err
        else:
            split_stderr = SplitIO()
            split_stderr.split(sys.stderr, err)
            sys.stderr = split_stderr

        # Initial update of the controller.
        self.update_controller()

        # Create a timer for updating the controller elements.
        self.timer = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self.handler_timer, self.timer)

        # The relax intro printout, to mimic the prompt/script interface.
        if not status.test_mode:
            info = Info_box()
            sys.stdout.write(info.intro_text())
            sys.stdout.write("\n")
            sys.stdout.flush()

        # Set the focus on the log control.
        self.log_panel.SetFocus()

        # Register functions with the observer objects.
        status.observers.pipe_alteration.register(
            'controller',
            self.update_controller,
            method_name='update_controller')
        status.observers.auto_analyses.register(
            'controller',
            self.update_controller,
            method_name='update_controller')
        status.observers.gui_analysis.register('controller',
                                               self.update_controller,
                                               method_name='update_controller')
        status.observers.exec_lock.register('controller',
                                            self.update_gauge,
                                            method_name='update_gauge')
Ejemplo n.º 14
0
    def __init__(self, gui):
        """Set up the relax controller frame.

        @param gui:     The GUI object.
        @type gui:      wx.Frame instance
        """

        # Store the args.
        self.gui = gui

        # Initialise the base class.
        super(Controller, self).__init__(self.gui, -1, style=wx.DEFAULT_FRAME_STYLE)

        # Some default values.
        self.size_x = 800
        self.size_y = 700
        self.border = 5
        self.spacer = 10

        # Set up the frame.
        sizer = self.setup_frame()

        # Add the relax logo.
        self.add_relax_logo(sizer)

        # Spacing.
        sizer.AddSpacer(20)

        # Add the current analysis info.
        self.name = self.add_text(self.main_panel, sizer, "Current GUI analysis:")

        # Add the current data pipe info.
        self.cdp = self.add_text(self.main_panel, sizer, "Current data pipe:")

        # Create the relaxation curve-fitting specific panel.
        self.create_rx(sizer)

        # Create the model-free specific panel.
        self.create_mf(sizer)

        # Add the main execution gauge.
        self.main_gauge = self.add_gauge(self.main_panel, sizer, "Execution progress:", tooltip="This gauge will pulse while relax is executing an auto-analysis (when the execution lock is turned on) and will be set to 100% once the analysis is complete.")

        # Initialise a queue for log messages.
        self.log_queue = Queue()

        # Add the log panel.
        self.log_panel = LogCtrl(self.main_panel, self, log_queue=self.log_queue, id=-1)
        sizer.Add(self.log_panel, 1, wx.EXPAND|wx.ALL, 0)

        # IO redirection for STDOUT (with splitting if logging or teeing modes are set).
        out = Redirect_text(self.log_panel, self.log_queue, orig_io=sys.stdout, stream=0)
        if sys.stdout == sys.__stdout__ or status.relax_mode in ['test suite', 'system tests', 'unit tests', 'GUI tests']:
            sys.stdout = out
        else:
            split_stdout = SplitIO()
            split_stdout.split(sys.stdout, out)
            sys.stdout = split_stdout

        # IO redirection for STDERR (with splitting if logging or teeing modes are set).
        err = Redirect_text(self.log_panel, self.log_queue, orig_io=sys.stderr, stream=1)
        if sys.stderr == sys.__stderr__ or status.relax_mode in ['test suite', 'system tests', 'unit tests', 'GUI tests']:
            sys.stderr = err
        else:
            split_stderr = SplitIO()
            split_stderr.split(sys.stderr, err)
            sys.stderr = split_stderr

        # Initial update of the controller.
        self.update_controller()

        # Create a timer for updating the gauges.
        self.timer = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self.handler_timer, self.timer)

        # The relax intro printout, to mimic the prompt/script interface.
        if not status.test_mode:
            info = Info_box()
            print(info.intro_text())

        # Register functions with the observer objects.
        status.observers.pipe_alteration.register('controller', self.update_controller, method_name='update_controller')
        status.observers.auto_analyses.register('controller', self.update_controller, method_name='update_controller')
        status.observers.gui_analysis.register('controller', self.update_controller, method_name='update_controller')
        status.observers.exec_lock.register('controller', self.update_gauge, method_name='update_gauge')
Ejemplo n.º 15
0
def software_select(name, version=None):
    """Select by name the software used in the analysis.

    @param name:        The name of the software program.
    @type name:         str
    @keyword version:   The program version.
    @type version:      None or str
    """

    # Test if the current pipe exists.
    check_pipe()

    # Unknown program.
    if name not in ['relax', 'NMRPipe', 'Sparky', 'Bruker DC']:
        raise RelaxError("The software '%s' is unknown.  Please use the user function for manually specifying software details instead." % name)

    # Set up the experimental info data container, if needed.
    if not hasattr(cdp, 'exp_info'):
        cdp.exp_info = ExpInfo()

    # Init.
    cite_ids = []
    keys = []
    software_keys = []
    versions = []

    # relax.
    if name == 'relax':
        # The info.
        cite_ids.append(['relax_ref1', 'relax_ref2'])
        keys.append(['dAuvergneGooley08a', 'dAuvergneGooley08b'])
        software_keys.append('relax')
        versions.append(version_full())

    # NMRPipe.
    elif name == 'NMRPipe':
        # The info.
        cite_ids.append(['nmrpipe_ref'])
        keys.append(['Delaglio95'])
        software_keys.append('NMRPipe')
        versions.append(version)

    # Sparky.
    elif name == 'Sparky':
        # Check if the version information has been supplied.
        if not version:
            raise RelaxError("The Sparky version number has not been supplied.")

        # The info.
        cite_ids.append(['sparky_ref'])
        keys.append(['GoddardKneller'])
        software_keys.append('Sparky')
        versions.append(version)

    # Bruker Dynamics Center.
    elif name == 'Bruker DC':
        # The info.
        software_keys.append('DC')
        versions.append(version)

    # Get the info box.
    info = Info_box()

    # Loop over the citations.
    for i in range(len(cite_ids)):
        for j in range(len(cite_ids[i])):
            # Alias the bib entry.
            bib = info.bib[keys[i][j]]

            # Add the citations.
            cdp.exp_info.add_citation(cite_id=cite_ids[i][j], authors=bib.author2, doi=bib.doi, pubmed_id=bib.pubmed_id, full_citation=bib.cite_short(doi=False, url=False), title=bib.title, status=bib.status, type=bib.type, journal_abbrev=bib.journal, journal_full=bib.journal_full, volume=bib.volume, issue=bib.number, page_first=bib.page_first, page_last=bib.page_last, year=bib.year)

        # Add the software info.
        cdp.exp_info.software_setup(name=SOFTWARE[software_keys[i]].name, version=versions[i], vendor_name=SOFTWARE[software_keys[i]].authors, url=SOFTWARE[software_keys[i]].url, cite_ids=cite_ids, tasks=SOFTWARE[software_keys[i]].tasks)
Ejemplo n.º 16
0
def script(file=None, dir=None, analysis_type=None, model_selection=None, engine=None, model_elim=False, universal_solution=False):
    """Specify the scripts used in the analysis.

    @keyword file:                  The name of the file to open.
    @type file:                     str
    @keyword dir:                   The directory containing the file (defaults to the current directory if None).
    @type dir:                      None or str
    @keyword analysis_type:         The type of analysis performed.
    @type analysis_type:            str
    @keyword model_selection:       The model selection technique used, if relevant.
    @type model_selection:          None or str
    @keyword engine:                The software engine used in the analysis.
    @type engine:                   str
    @keyword model_elim:            A model-free specific flag specifying if model elimination was performed.
    @type model_elim:               bool
    @keyword universal_solution:    A model-free specific flag specifying if the universal solution was sought after.
    @type universal_solution:       bool
    """

    # Test if the current pipe exists.
    check_pipe()

    # Check.
    allowed = ['frame order',
               'jw',
               'mf',
               'N-state',
               'noe',
               'relax_fit'
    ]
    if analysis_type not in allowed:
        raise RelaxError("The analysis type '%s' should be one of %s." % (analysis_type, allowed))

    # Set up the experimental info data container, if needed.
    if not hasattr(cdp, 'exp_info'):
        cdp.exp_info = ExpInfo()

    # Extract the text.
    f = open_read_file(file, dir)
    text = f.read()
    f.close()

    # Init the citation structures.
    cite_id = []
    cite_key = []

    # Model selection.
    if model_selection in ['AIC', 'AICc', 'BIC', 'Bootstrap', 'CV', 'Expect', 'Overall']:
        cite_id.append('model-free model selection')
        cite_key.append('dAuvergneGooley03')

    # Model-free model elimination.
    if model_elim:
        cite_id.append('model-free model elimination')
        cite_key.append('dAuvergneGooley06')

    # Universal solution citation.
    if universal_solution:
        cite_id.append('model-free set theory')
        cite_key.append('dAuvergneGooley07')

    # Get the info box.
    info = Info_box()

    # Loop over all citations.
    for id, key in zip(cite_id, cite_key):
        # Alias the bib entry.
        bib = info.bib[key]

        # Add the citation.
        cdp.exp_info.add_citation(cite_id=id, authors=bib.author2, doi=bib.doi, pubmed_id=bib.pubmed_id, full_citation=bib.cite_short(doi=False, url=False), title=bib.title, status=bib.status, type=bib.type, journal_abbrev=bib.journal, journal_full=bib.journal_full, volume=bib.volume, page_first=bib.page_first, page_last=bib.page_last, year=bib.year)

    # Place the data in the container.
    cdp.exp_info.setup_script(file=file, dir=dir, text=text, cite_ids=cite_id, analysis_type=analysis_type, model_selection=model_selection, engine=engine, model_elim=model_elim, universal_solution=universal_solution)