Esempio n. 1
0
def main(
    port: str,
    host: str,
    sql: bool,
    sql_uri: str,
    sql_refs_table: str,
    sql_alts_table: str,
    data: Optional[str],
    test: bool,
    with_gunicorn: bool,
    lazy: bool,
    workers: int,
):
    """Run the resolver app."""
    if test and lazy:
        click.secho('Can not run in --test and --lazy mode at the same time', fg='red')
        sys.exit(0)

    if test:
        data = [
            (prefix, identifier, name)
            for prefix in ['hgnc', 'chebi', 'doid', 'go']
            for identifier, name in pyobo.get_id_name_mapping(prefix).items()
        ]
        data = pd.DataFrame(data, columns=['prefix', 'identifier', 'name'])

    app = get_app(
        data,
        lazy=lazy,
        sql=sql,
        uri=sql_uri,
        refs_table=sql_refs_table,
        alts_table=sql_alts_table,
    )
    run_app(app=app, host=host, port=port, with_gunicorn=with_gunicorn, workers=workers)
Esempio n. 2
0
def main(prefix: str, host: str, port: str, with_gunicorn: bool, workers: int):
    """Run the Gilda service for this database."""
    from .app import get_app
    app = get_app(prefix)
    run_app(app,
            host=host,
            port=port,
            with_gunicorn=with_gunicorn,
            workers=workers)
Esempio n. 3
0
def main(mappings_file, host: str, port: str, with_gunicorn: bool):
    """Run the mappings app."""
    from .mapper import get_app

    app = get_app(mappings_file)
    run_app(app=app, host=host, port=port, with_gunicorn=with_gunicorn)
Esempio n. 4
0
def main(
    port: str,
    host: str,
    sql: bool,
    sql_uri: str,
    sql_refs_table: str,
    sql_alts_table: str,
    sql_defs_table: str,
    name_data: Optional[str],
    alts_data: Optional[str],
    defs_data: Optional[str],
    test: bool,
    with_gunicorn: bool,
    lazy: bool,
    workers: int,
):
    """Run the resolver app."""
    if test and lazy:
        click.secho('Can not run in --test and --lazy mode at the same time', fg='red')
        sys.exit(0)

    from .resolver import get_app

    if test:
        from pyobo import get_id_name_mapping, get_alts_to_id, get_id_definition_mapping
        import pandas as pd
        prefixes = ['hgnc', 'chebi', 'doid', 'go']
        name_data = pd.DataFrame(
            [
                (prefix, identifier, name)
                for prefix in prefixes
                for identifier, name in get_id_name_mapping(prefix).items()
            ],
            columns=['prefix', 'identifier', 'name'],
        )
        alts_data = pd.DataFrame(
            [
                (prefix, alt, identifier)
                for prefix in prefixes
                for alt, identifier in get_alts_to_id(prefix).items()
            ],
            columns=['prefix', 'alt', 'identifier'],
        )
        defs_data = pd.DataFrame(
            [
                (prefix, identifier, definition)
                for prefix in prefixes
                for identifier, definition in get_id_definition_mapping(prefix).items()
            ],
            columns=['prefix', 'identifier', 'definition'],
        )

    app = get_app(
        name_data=name_data,
        alts_data=alts_data,
        defs_data=defs_data,
        lazy=lazy,
        sql=sql,
        uri=sql_uri,
        refs_table=sql_refs_table,
        alts_table=sql_alts_table,
        defs_table=sql_defs_table,
    )
    run_app(app=app, host=host, port=port, with_gunicorn=with_gunicorn, workers=workers)