示例#1
0
文件: cli.py 项目: ComPath/ComPath
def drop_databases(debug, yes, connection):
    """Drop all databases."""
    set_debug_param(debug)

    if yes or click.confirm(
            'Do you really want to delete the databases for {}?'.format(
                ', '.join(managers))):
        for name, Manager in managers.items():
            m = Manager(connection=connection)
            click.echo('deleting {}'.format(name))
            m.drop_all()
示例#2
0
    def setUp(self):
        """Create temporary file."""

        self.fd, self.path = tempfile.mkstemp()
        self.connection = 'sqlite:///' + self.path

        # create temporary database
        self.manager = Manager.from_connection(connection=self.connection)
示例#3
0
文件: cli.py 项目: ComPath/ComPath
def drop(debug, yes, connection):
    """Drop ComPath DB."""
    set_debug_param(debug)

    if yes or click.confirm('Do you really want to delete the ComPath DB'):
        m = Manager.from_connection(connection=connection)
        click.echo('Deleting ComPath DB')
        m.drop_all()
        m.create_all()
示例#4
0
文件: cli.py 项目: ComPath/ComPath
def populate(debug, connection, delete_first):
    """Populate all registered Bio2BEL pathway packages."""
    set_debug_param(debug)

    for name, Manager in managers.items():
        m = Manager(connection=connection)
        log.info('populating %s at %s', name, m.engine.url)

        if delete_first:
            click.echo('deleting {}'.format(name))
            m.drop_all()
            m.create_all()

        click.echo('populating {}'.format(name))
        m.populate()
示例#5
0
def load_hierarchy(*, connection=None, curator_email=None):
    """Load the hierarchical relationships for the managers containing them.

    :param Optional[str] connection:
    :param Optional[str] curator_email: email of the admin
    """
    compath_manager = Manager.from_connection(connection)

    curator = compath_manager.get_user_by_email(
        email=curator_email if curator_email else ADMIN_EMAIL)

    if not curator:
        raise EnvironmentError(
            'There is no user with the email "{}". Please create it with the "make_user" command using '
            'the command line interface of Compath')

    for pathway_database, ExternalManager in managers.items():

        pathway_db_manager = ExternalManager()

        if not hasattr(pathway_db_manager, 'has_hierarchy'):
            continue

        log.info("Loading hierarchies for {}".format(pathway_database))

        pathways = pathway_db_manager.get_all_pathways()

        if pathway_database == 'reactome':
            pathways = _reactome_wrapper(pathways)

        log.info("Searching for hierarchical relationships in {} {} pathways".
                 format(len(pathways), pathway_database))

        counter_mappings_created = create_hierarchical_mappings(
            pathways, compath_manager, pathway_database, curator)

        log.info("{} hierarchical mappings created in {}".format(
            counter_mappings_created, pathway_database))
示例#6
0
文件: web.py 项目: ComPath/ComPath
 def init_app(self, app):
     """Overwrite init app method."""
     super().init_app(app)
     self.manager = Manager(engine=self.engine, session=self.session)
示例#7
0
文件: cli.py 项目: ComPath/ComPath
def manage(ctx, connection):
    """Manage the database."""
    ctx.obj = Manager.from_connection(connection)
    Base.metadata.bind = ctx.obj.engine
    Base.query = ctx.obj.session.query_property()
    ctx.obj.create_all()