Skip to content

Commit

Permalink
Merge pull request #7 from bio2bel/update-bio2bel-0-2-0
Browse files Browse the repository at this point in the history
Update for Bio2BEL v0.2.0
  • Loading branch information
cthoyt committed Nov 13, 2018
2 parents 2a58087 + 1608f08 commit 7db1a58
Show file tree
Hide file tree
Showing 14 changed files with 120 additions and 129 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.1.2-dev
current_version = 0.2.1-dev
commit = True
tag = False
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(?:-(?P<release>[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+(?P<build>[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?
Expand Down
1 change: 1 addition & 0 deletions .flake8
Expand Up @@ -23,6 +23,7 @@ ignore = D105,E501
# flake8-import-order
application-import-names =
bio2bel_chebi
bio2bel
tests
import-order-style = pycharm

Expand Down
40 changes: 24 additions & 16 deletions .travis.yml
Expand Up @@ -3,27 +3,35 @@ cache: pip
language: python
python:
- 3.6
matrix:
stages:
- lint
- docs
- test
jobs:
include:
- env: TOXENV=py
- env: TOXENV=docs
- env: TOXENV=manifest
- env: TOXENV=rst-lint
# lint stage
- stage: lint
env: TOXENV=manifest
- env: TOXENV=flake8
- env: TOXENV=doc8
- env: TOXENV=pylint
- env: TOXENV=pyroma
- env: TOXENV=xenon
# docs stage
- stage: docs
env: TOXENV=doc8
- env: TOXENV=readme
- env: TOXENV=docs
# test stage
- stage: test
env: TOXENV=py
matrix:
allow_failures:
- env: TOXENV=flake8
- env: TOXENV=doc8
- env: TOXENV=pylint
- env: TOXENV=flake8
- env: TOXENV=xenon
install:
- pip install tox
- pip install codecov
- pip install coverage
- sh -c 'if [ "$TOXENV" = "py" ]; then pip install tox codecov; else pip install tox; fi'
script:
- tox
- travis_wait 45 tox
after_success:
- tox -e coverage-report
- codecov
- sh -c 'if [ "$TOXENV" = "py" ]; then tox -e coverage-report; codecov; fi'
notifications:
slack: pybel:n2KbWKBum3musnBg3L76gGwq
7 changes: 3 additions & 4 deletions README.rst
Expand Up @@ -2,7 +2,6 @@ Bio2BEL ChEBI |build| |coverage| |docs| |zenodo|
================================================
Convert the ChEBI ontology and related chemical information to BEL.


Installation |pypi_version| |python_versions| |pypi_license|
------------------------------------------------------------
``bio2bel_chebi`` can be installed easily from `PyPI <https://pypi.python.org/pypi/bio2bel_chebi>`_ with
Expand All @@ -20,8 +19,8 @@ or from the latest code on `GitHub <https://github.com/bio2bel/chebi>`_ with:
Setup
-----
ChEBI can be downloaded and populated from either the Python REPL or the automatically installed command line
utility.
ChEBI can be downloaded and populated from either the Python REPL or the automatically
installed command line utility.

Python REPL
~~~~~~~~~~~
Expand Down Expand Up @@ -65,4 +64,4 @@ Command Line Utility

.. |zenodo| image:: https://zenodo.org/badge/97003706.svg
:target: https://zenodo.org/badge/latestdoi/97003706
:alt: Zenodo DOI
:alt: Zenodo DOI
2 changes: 1 addition & 1 deletion docs/source/conf.py
Expand Up @@ -20,7 +20,7 @@
copyright = '2017-2018, Charles Tapley Hoyt'
author = 'Charles Tapley Hoyt'

release = '0.1.2-dev'
release = '0.2.1-dev'

parsed_version = re.match(
'(?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(?:-(?P<release>[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+(?P<build>[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?',
Expand Down
4 changes: 0 additions & 4 deletions docs/source/enrichment.rst

This file was deleted.

1 change: 0 additions & 1 deletion docs/source/index.rst
Expand Up @@ -6,7 +6,6 @@ Bio2BEL ChEBI
:maxdepth: 2
:caption: Contents:

enrichment
manager
constants

Expand Down
20 changes: 17 additions & 3 deletions setup.py
Expand Up @@ -10,14 +10,17 @@

PACKAGES = setuptools.find_packages(where='src')
META_PATH = os.path.join('src', 'bio2bel_chebi', '__init__.py')
KEYWORDS = ['Biological Expression Language', 'BEL', 'ChEBI', 'Systems Biology', 'Networks Biology']
CLASSIFIERS = [
'Development Status :: 4 - Beta',
'Environment :: Console',
'Intended Audience :: Developers',
'Intended Audience :: Science/Research',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Programming Language :: Python :: 3 :: Only',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Topic :: Scientific/Engineering :: Bio-Informatics',
'License :: OSI Approved :: MIT License',
]
Expand All @@ -26,11 +29,20 @@
'pandas',
'sqlalchemy',
'tqdm',
'bio2bel>=0.1.4',
'pybel>=0.11.10',
'bio2bel>=0.2.0,<0.3.0',
'pybel>=0.12.0,<0.13.0',
]
EXTRAS_REQUIRE = {
'web': ['flask', 'flask-admin'],
'web': [
'flask',
'flask-admin',
],
'docs': [
'sphinx',
'sphinx-rtd-theme',
'sphinx-click',
'sphinx-autodoc-typehints',
],
}
ENTRY_POINTS = {
'bio2bel': [
Expand Down Expand Up @@ -84,9 +96,11 @@ def get_long_description():
maintainer_email=find_meta('email'),
license=find_meta('license'),
classifiers=CLASSIFIERS,
keywords=KEYWORDS,
packages=PACKAGES,
package_dir={'': 'src'},
install_requires=INSTALL_REQUIRES,
extras_require=EXTRAS_REQUIRE,
entry_points=ENTRY_POINTS,
zip_safe=False,
)
6 changes: 1 addition & 5 deletions src/bio2bel_chebi/__init__.py
Expand Up @@ -38,15 +38,11 @@
"""

from . import enrich, manager, models
from .enrich import *
from .manager import *
from .models import *
from .utils import get_version

__all__ = (manager.__all__ + enrich.__all__ + models.__all__ + ['get_version'])

__version__ = '0.1.2-dev'
__version__ = '0.2.1-dev'

__title__ = 'bio2bel_chebi'
__description__ = "A package for converting ChEBI to BEL"
Expand Down
2 changes: 1 addition & 1 deletion src/bio2bel_chebi/constants.py
Expand Up @@ -6,7 +6,7 @@

from bio2bel.utils import get_data_dir

VERSION = '0.1.2-dev'
VERSION = '0.2.1-dev'

MODULE_NAME = 'chebi'
DATA_DIR = get_data_dir(MODULE_NAME)
Expand Down
48 changes: 0 additions & 48 deletions src/bio2bel_chebi/enrich.py

This file was deleted.

4 changes: 2 additions & 2 deletions src/bio2bel_chebi/manager.py
Expand Up @@ -41,7 +41,7 @@ class Manager(AbstractManager, FlaskMixin, BELNamespaceManagerMixin):

namespace_model = Chemical
identifiers_recommended = 'ChEBI'
identifiers_pattern = '^CHEBI:\d+$'
identifiers_pattern = r'^CHEBI:\d+$'
identifiers_miriam = 'MIR:00000002'
identifiers_namespace = 'chebi'
identifiers_url = 'http://identifiers.org/chebi/'
Expand Down Expand Up @@ -413,7 +413,7 @@ def _create_namespace_entry_from_model(self, chemical: Chemical, namespace: Name
encoding=chemical.bel_encoding,
name=chemical.name,
identifier=chemical.chebi_id,
namespace=namespace
namespace=namespace,
)

@staticmethod
Expand Down
38 changes: 17 additions & 21 deletions src/bio2bel_chebi/models.py
Expand Up @@ -2,12 +2,14 @@

"""SQLAlchemy models for Bio2BEL ChEBI."""

from typing import Mapping

from sqlalchemy import Column, Date, ForeignKey, Index, Integer, String, Text
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import backref, relationship

from pybel.constants import NAME, PART_OF
from pybel.dsl import abundance
import pybel.dsl

__all__ = [
'Base',
Expand All @@ -27,7 +29,7 @@


class Chemical(Base):
"""Represents a chemical"""
"""Represents a chemical."""

__tablename__ = CHEMICAL_TABLE_NAME
id = Column(Integer, primary_key=True)
Expand Down Expand Up @@ -55,17 +57,14 @@ def __str__(self):
return self.safe_name or self.chebi_id

@property
def safe_name(self):
"""Either returns this molecule's name, or the parent name
:rtype: str
"""
def safe_name(self) -> str:
"""Either returns this molecule's name, or the parent name."""
return self.name or self.parent.name

def to_json(self, include_id=False):
"""
def to_json(self, include_id: bool = False) -> Mapping:
"""Export this chemical as dictionary.
:param bool include_id: Include the database identifier?
:rtype: dict
"""
rv = {
'chebi_id': self.chebi_id,
Expand All @@ -81,10 +80,7 @@ def to_json(self, include_id=False):
return rv

def to_bel(self) -> pybel.dsl.Abundance:
"""Makes an abundance PyBEL data dictionary
:rtype: abundance
"""
"""Make an abundance PyBEL data dictionary."""
if self.parent:
return self.parent.to_bel()

Expand All @@ -96,9 +92,9 @@ def to_bel(self) -> pybel.dsl.Abundance:


class Relation(Base):
"""Represents a relation between two chemicals"""
__tablename__ = RELATION_TABLE_NAME
"""Represents a relation between two chemicals."""

__tablename__ = RELATION_TABLE_NAME
id = Column(Integer, primary_key=True)

type = Column(String(32), nullable=False, index=True)
Expand All @@ -111,7 +107,7 @@ class Relation(Base):
target = relationship('Chemical', foreign_keys=[target_id], backref=backref('in_edges', lazy='dynamic'))

def add_to_graph(self, graph):
"""Add this relation to the graph
"""Add this relation to the graph.
:param pybel.BELGraph graph:
:rtype: Optional[str]
Expand All @@ -134,9 +130,9 @@ def add_to_graph(self, graph):


class Synonym(Base):
"""Represents synonyms of a chemical"""
__tablename__ = SYNONYM_TABLE_NAME
"""Represents synonyms of a chemical."""

__tablename__ = SYNONYM_TABLE_NAME
id = Column(Integer, primary_key=True)

chemical_id = Column(Integer, ForeignKey('{}.id'.format(CHEMICAL_TABLE_NAME)), nullable=False)
Expand All @@ -156,9 +152,9 @@ def __str__(self):


class Accession(Base):
"""Represents related accession numbers of a chemical"""
__tablename__ = ACCESSION_TABLE_NAME
"""Represents related accession numbers of a chemical."""

__tablename__ = ACCESSION_TABLE_NAME
id = Column(Integer, primary_key=True)

chemical_id = Column(Integer, ForeignKey('{}.id'.format(CHEMICAL_TABLE_NAME)), nullable=False)
Expand Down

0 comments on commit 7db1a58

Please sign in to comment.