コード例 #1
0
ファイル: setup.py プロジェクト: belisario21/relax_trunk
    def mac_setup(self):
        """Mac OS X setup."""

        # The relax settings.
        self.APP = ['relax_gui_mode.py']
        self.NAME = 'relax'
        self.VERSION = version_full()
        self.OPTIONS = {}
        self.OPTIONS['py2app'] = {
            'argv_emulation': False,
            'iconfile': status.install_path + sep + 'graphics' + sep + 'ulysses_shadowless_trans_128x128.icns',
            'packages': 'wx',
            'site_packages': True,
            'includes': self.get_includes(),
            'excludes': ['build', 'dist'],
            'plist': {
                'CFBundleName':                 'relax',
                'CFBundleShortVersionString':   version_full(),
                'CFBundleGetInfoString':        'relax %s' % version_full(),
                'CFBundleIdentifier':           'com.nmr-relax.relax'
            }
        }
        self.REQUIRES = ['py2app']
コード例 #2
0
ファイル: setup.py プロジェクト: bopopescu/relax
    def mac_setup(self):
        """Mac OS X setup."""

        # The relax settings.
        self.APP = ['relax_gui_mode.py']
        self.NAME = 'relax'
        self.VERSION = version_full()
        self.OPTIONS = {}
        self.OPTIONS['py2app'] = {
            'argv_emulation': False,
            'iconfile': status.install_path + sep + 'graphics' + sep +
            'ulysses_shadowless_trans_128x128.icns',
            'packages': 'wx',
            'site_packages': True,
            'includes': self.get_includes(),
            'excludes': ['build', 'dist'],
            'plist': {
                'CFBundleName': 'relax',
                'CFBundleShortVersionString': version_full(),
                'CFBundleGetInfoString': 'relax %s' % version_full(),
                'CFBundleIdentifier': 'com.nmr-relax.relax'
            }
        }
        self.REQUIRES = ['py2app']
コード例 #3
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)
コード例 #4
0
ファイル: bmrb.py プロジェクト: belisario21/relax_trunk
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)

    # Specific results writing function.
    write_function = specific_analyses.setup.get_specific_fn('bmrb_write', ds[pipe_name].pipe_type)

    # 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.
    write_function(file, version=version)

    # Add the file to the results file list.
    if isinstance(file, str):
        add_result_file(type='text', label='BMRB', file=file)
コード例 #5
0
ファイル: exp_info.py プロジェクト: belisario21/relax_trunk
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.
    pipes.test()

    # 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)
コード例 #6
0
ファイル: relax.py プロジェクト: pombredanne/relax
    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)
コード例 #7
0
ファイル: relax.py プロジェクト: ilsacripante/relax
    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)
コード例 #8
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)