msaexplorer.cli

A script to provide minimal argument parsing for displaying the version or launching the MSAexplorer app. Not needed for usage as a python module.

This module defines functions to parse command-line arguments and either display the version information or start the MSAexplorer application. It primarily serves as an entry point for launching the application or retrieving its version.

 1"""
 2A script to provide minimal argument parsing for displaying the version or
 3launching the MSAexplorer app. Not needed for usage as a python module.
 4
 5This module defines functions to parse command-line arguments and either display
 6the version information or start the MSAexplorer application. It primarily serves
 7as an entry point for launching the application or retrieving its version.
 8"""
 9
10import sys
11import argparse
12from msaexplorer import __version__
13
14
15def parse_args(sysargs):
16    """
17    Minimal argument parser for displaying the version or launching the app.
18    """
19    parser = argparse.ArgumentParser(
20        description='The MSAexplorer app is an interactive visualization tool designed for exploring multiple sequence alignments (MSAs).',
21        usage='''\tmsaexplorer --run'''
22    )
23
24    parser.add_argument(
25         '--run',
26        action='store_true',
27        help='Start the MSAexplorer app'
28    )
29
30    parser.add_argument(
31        '--version',
32        action='version',
33        version=f'MSAexplorer {__version__}'
34    )
35
36    if not sysargs:
37        parser.print_help()
38        sys.exit(0)
39
40    return parser.parse_args(sysargs)
41
42
43def main(sysargs=sys.argv[1:]):
44    args = parse_args(sysargs)
45
46    if args.run:
47        try:
48            from shiny import run_app
49            from shiny import App
50            from app_src.shiny_user_interface import shiny_ui
51            from app_src.shiny_server import server
52            from importlib.resources import files
53        except ImportError:
54            sys.exit(
55                "Please install the MSAexplorer front end app via 'pip install msaexplorer[app]' or 'pip install msaexplorer[app-plus]'."
56            )
57
58        css_path = files("app_src").joinpath("www/css/styles.css")
59        js_path = files("app_src").joinpath("www/js/helper_functions.js")
60        img_path = files("app_src").joinpath("www/img")
61        # same code as in root/app.py
62        run_app(
63            App(
64                shiny_ui(
65                    css_file=css_path,
66                    js_file=js_path
67                ),
68                server,
69                static_assets={'/img': str(img_path)}
70            )
71        )
72
73
74if __name__ == "__main__":
75    main()
def parse_args(sysargs):
16def parse_args(sysargs):
17    """
18    Minimal argument parser for displaying the version or launching the app.
19    """
20    parser = argparse.ArgumentParser(
21        description='The MSAexplorer app is an interactive visualization tool designed for exploring multiple sequence alignments (MSAs).',
22        usage='''\tmsaexplorer --run'''
23    )
24
25    parser.add_argument(
26         '--run',
27        action='store_true',
28        help='Start the MSAexplorer app'
29    )
30
31    parser.add_argument(
32        '--version',
33        action='version',
34        version=f'MSAexplorer {__version__}'
35    )
36
37    if not sysargs:
38        parser.print_help()
39        sys.exit(0)
40
41    return parser.parse_args(sysargs)

Minimal argument parser for displaying the version or launching the app.

def main(sysargs=['./msaexplorer', '--logo', '../logo.svg', '-o', 'docs/']):
44def main(sysargs=sys.argv[1:]):
45    args = parse_args(sysargs)
46
47    if args.run:
48        try:
49            from shiny import run_app
50            from shiny import App
51            from app_src.shiny_user_interface import shiny_ui
52            from app_src.shiny_server import server
53            from importlib.resources import files
54        except ImportError:
55            sys.exit(
56                "Please install the MSAexplorer front end app via 'pip install msaexplorer[app]' or 'pip install msaexplorer[app-plus]'."
57            )
58
59        css_path = files("app_src").joinpath("www/css/styles.css")
60        js_path = files("app_src").joinpath("www/js/helper_functions.js")
61        img_path = files("app_src").joinpath("www/img")
62        # same code as in root/app.py
63        run_app(
64            App(
65                shiny_ui(
66                    css_file=css_path,
67                    js_file=js_path
68                ),
69                server,
70                static_assets={'/img': str(img_path)}
71            )
72        )