Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
cthoyt committed Jan 26, 2018
1 parent 5236521 commit e69a6f2
Show file tree
Hide file tree
Showing 11 changed files with 181 additions and 2 deletions.
20 changes: 20 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = sphinx-build
SPHINXPROJ = Bio2BELCHEBI
SOURCEDIR = source
BUILDDIR = build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
64 changes: 64 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# -*- coding: utf-8 -*-

import os
import re
import sys

sys.path.insert(0, os.path.abspath('../../src'))

extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.intersphinx',
'sphinx.ext.todo',
'sphinx.ext.coverage',
'sphinx.ext.viewcode'
]
templates_path = ['_templates']
source_suffix = '.rst'
master_doc = 'index'
project = 'Bio2BEL ChEBI'
copyright = '2017-2018, Charles Tapley Hoyt'
author = 'Charles Tapley Hoyt'

release = '0.0.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-]+)*))?',
release
)
version = parsed_version.expand('\g<major>.\g<minor>.\g<patch>')

if parsed_version.group('release'):
tags.add('prerelease')

language = None
exclude_patterns = []
pygments_style = 'sphinx'
todo_include_todos = True
html_theme = 'sphinx_rtd_theme'
html_static_path = []
htmlhelp_basename = 'bioebel_chebidoc'
latex_elements = {}
latex_documents = [
(master_doc, 'bio2bel_chebi.tex', 'Bio2BEL ChEBI Documentation', 'Charles Tapley Hoyt', 'manual'),
]
man_pages = [
(master_doc, 'Bio2BEL ChEBI', 'Bio2BEL ChEBI Documentation', [author], 1)
]
texinfo_documents = [
(master_doc, 'Bio2BEL ChEBI', 'Bio2BEL ChEBI Documentation', author, 'Bio2BEL ChEBI', 'Serialize ChEBI to BEL', 'Miscellaneous'),
]

# Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {
'python': ('https://docs.python.org/3', None),
'networkx': ('https://networkx.github.io/', None),
'sqlalchemy': ('https://docs.sqlalchemy.org/en/latest', None),
'pybel': ('https://pybel.readthedocs.io/en/latest/', None),
}

autodoc_member_order = 'bysource'
autoclass_content = 'both'

if os.environ.get('READTHEDOCS'):
tags.add('readthedocs')
4 changes: 4 additions & 0 deletions docs/source/constants.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Constants
=========
.. automodule:: bio2bel_chebi.constants
:members:
4 changes: 4 additions & 0 deletions docs/source/enrichment.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Enrichment
==========
.. automodule:: bio2bel_chebi.enrich
:members:
18 changes: 18 additions & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Bio2BEL ChEBI
=============
.. automodule:: bio2bel_chebi

.. toctree::
:maxdepth: 2
:caption: Contents:

enrichment
manager
constants

Indices and tables
==================

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
4 changes: 4 additions & 0 deletions docs/source/manager.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Manager
==========
.. automodule:: bio2bel_chebi.manager
:members:
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ tqdm
pybel>=0.9.5
pybel_tools>=0.4.5
bio2bel
flask[web]
flask_admin[web]
8 changes: 6 additions & 2 deletions src/bio2bel_chebi/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
# -*- coding: utf-8 -*-

from . import models
from .manager import Manager
from . import enrich, manager, models
from .enrich import *
from .manager import *
from .models import *

__all__ = (manager.__all__ + enrich.__all__ + models.__all__)

__version__ = '0.0.1'

Expand Down
46 changes: 46 additions & 0 deletions src/bio2bel_chebi/enrich.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# -*- coding: utf-8 -*-

import logging

from pybel import to_database
from .manager import Manager

__all__ = [
'enrich_chemical_hierarchy',
'to_bel',
'upload_bel'
]

log = logging.getLogger(__name__)


def enrich_chemical_hierarchy(graph, manager=None):
"""Enriches the biological processses in a BEL graph
:type graph: pybel.BELGraph
:type manager: Optional[bio2bel_chebi.Manager]
"""
manager = manager or Manager()
manager.enrich_chemical_hierarchy(graph)


def to_bel(manager=None):
"""Creates a BEL graph from the Gene Ontology
:type manager: Optional[bio2bel_chebi.Manager]
"""
manager = manager or Manager()
return manager.to_bel()


def upload_bel(manager=None, pybel_manager=None):
"""Creates a BEL graph from the Gene Ontology and uplopads it to the PyBEL edge store
:type manager: Optional[bio2bel_chebi.Manager]
:type pybel_manager: Optional[pybel.Manager]
:rtype: pybel.manager.models.Network
"""
log.info('converting bel')
graph = to_bel(manager=manager)
log.info('storing')
return to_database(graph, connection=pybel_manager)
5 changes: 5 additions & 0 deletions src/bio2bel_chebi/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
from .parser.inchis import get_inchis_df
from .parser.names import get_names_df

__all__ = ['Manager']

log = logging.getLogger(__name__)


Expand Down Expand Up @@ -222,3 +224,6 @@ def enrich_chemical_hierarchy(self, graph):
parent.as_bel(),
IS_A
)

def to_bel(self):
raise NotImplementedError
8 changes: 8 additions & 0 deletions src/bio2bel_chebi/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,16 @@
from sqlalchemy import Column, ForeignKey, Integer, String, Text
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import backref, relationship

from pybel.dsl import abundance

__all__ = [
'Base',
'Chemical',
'Synonym',
'Accession',
]

Base = declarative_base()

TABLE_PREFIX = 'chebi'
Expand Down

0 comments on commit e69a6f2

Please sign in to comment.