Skip to content

Commit

Permalink
Update bio2bel and override populate function in CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
cthoyt committed May 9, 2018
1 parent f894708 commit be1b232
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pybel[deployment]>=0.11.1
bio2bel>=0.0.9
bio2bel>=0.0.10
tqdm
sqlalchemy
click
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
META_PATH = os.path.join('src', 'bio2bel_hgnc', '__init__.py')
INSTALL_REQUIRES = [
'pybel[deployment]>=0.11.1',
'bio2bel>=0.0.9',
'bio2bel>=0.0.10',
'tqdm',
'sqlalchemy',
'click',
Expand Down
24 changes: 23 additions & 1 deletion src/bio2bel_hgnc/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
import time
from collections import Counter

import click
from tqdm import tqdm

from bio2bel.abstractmanager import AbstractManager
from bio2bel import AbstractManager
from pybel import BELGraph, to_bel
from pybel.constants import FUNCTION, GENE, IDENTIFIER, IS_A, NAME, NAMESPACE, NAMESPACE_DOMAIN_GENE, PROTEIN, RNA
from pybel.dsl import gene as gene_dsl, protein as protein_dsl, rna as rna_dsl
Expand Down Expand Up @@ -809,3 +810,24 @@ def upload_bel_namespace(self):
self._update_namespace(ns)

return ns

@staticmethod
def _cli_add_populate(main):
"""Overrides default method to make it possible to add more flags"""

@main.command()
@click.option('--reset', is_flag=True)
@click.option('--skip-hcop', is_flag=True)
@click.pass_obj
def populate(manager, reset, skip_hcop):
"""Populates the database"""

if reset:
log.info('Deleting the previous instance of the database')
manager.drop_all()
log.info('Creating new models')
manager.create_all()

manager.populate(use_hcop=(not skip_hcop))

return main

0 comments on commit be1b232

Please sign in to comment.