Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
cthoyt committed Aug 1, 2018
2 parents 2c8aab1 + 37b8894 commit 6f0f9e2
Show file tree
Hide file tree
Showing 85 changed files with 1,157 additions and 3,658 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.5.3
current_version = 0.6.1
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
24 changes: 24 additions & 0 deletions .flake8
@@ -0,0 +1,24 @@
#########################
# Flake8 Configuration #
# (.flake8) #
# (formerly in tox.ini) #
#########################

[flake8]
ignore = E501
exclude =
.tox,
.git,
__pycache__,
docs/source/conf.py,
build,
dist,
tests/fixtures/*,
*.pyc,
*.egg-info,
.cache,
.eggs
max-complexity = 10
import-order-style = google
application-import-names = flake8
format = ${cyan}%(path)s${reset}:${yellow_bold}%(row)d${reset}:${green_bold}%(col)d${reset}: ${red_bold}%(code)s${reset} %(text)s
28 changes: 20 additions & 8 deletions .travis.yml
Expand Up @@ -6,21 +6,33 @@ language: python
python:
- 3.6
- 3.4

stages:
- lint
- docs
- test

env:
- TOXENV=py

matrix:
jobs:
include:
- 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

# docs stage
- stage: docs
env: TOXENV=doc8
- env: TOXENV=readme
- env: TOXENV=docs

matrix:
allow_failures:
- env: TOXENV=flake8
- env: TOXENV=doc8
- env: TOXENV=pylint
- env: TOXENV=flake8
- env: TOXENV=pylint

before_install:
- pip install codecov coverage
Expand Down
2 changes: 1 addition & 1 deletion MANIFEST.in
Expand Up @@ -9,4 +9,4 @@ global-exclude docs/*
global-exclude *.py[cod] __pycache__ *.so *.dylib .DS_Store

exclude .bumpversion.cfg
include *.rst *.txt LICENSE tox.ini *.yml docs/Makefile .coveragerc .codecov.yml .codeclimate.yml
include *.rst *.txt *.ini *.yml LICENSE docs/Makefile .coveragerc .codecov.yml .codeclimate.yml .flake8
2 changes: 1 addition & 1 deletion README.rst
Expand Up @@ -88,4 +88,4 @@ Links
:alt: Apache 2.0 License

.. |zenodo| image:: https://zenodo.org/badge/70473008.svg
:target: https://zenodo.org/badge/latestdoi/70473008
:target: https://zenodo.org/badge/latestdoi/70473008
2 changes: 2 additions & 0 deletions doc8.ini
@@ -0,0 +1,2 @@
[doc8]
max-line-length = 120
21 changes: 21 additions & 0 deletions docs/source/algorithms.rst
@@ -0,0 +1,21 @@
Algorithms
==========
NeuroMMSig
----------
.. automodule:: pybel_tools.analysis.neurommsig.algorithm
:members:

EpiCom
------
.. automodule:: pybel_tools.analysis.epicom.algorithm
:members:

Reverse Causal Reasoning
------------------------
.. automodule:: pybel_tools.analysis.rcr
:members:

Sample of Spanning Trees
------------------------
.. automodule:: pybel_tools.analysis.sst
:members:
2 changes: 1 addition & 1 deletion docs/source/conf.py
Expand Up @@ -47,7 +47,7 @@
#

# The full version, including alpha/beta/rc tags.
release = '0.5.3'
release = '0.6.1'

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
11 changes: 3 additions & 8 deletions docs/source/index.rst
Expand Up @@ -40,13 +40,7 @@ Links
integration
mutation
visualization

.. toctree::
:maxdepth: 2
:caption: Graph Queries
:name: graphquery

pipeline
query

.. toctree::
:caption: Workflows
Expand All @@ -56,6 +50,7 @@ Links
expansion
generation
heat
algorithms

.. toctree::
:caption: Other Utilities
Expand All @@ -73,4 +68,4 @@ Indices and tables
* :ref:`modindex`
* :ref:`search`

.. _PyPI: https://pypi.python.org/pypi/pybel_tools
.. _PyPI: https://pypi.python.org/pypi/pybel_tools
5 changes: 0 additions & 5 deletions docs/source/pipeline.rst

This file was deleted.

4 changes: 4 additions & 0 deletions docs/source/query.rst
@@ -0,0 +1,4 @@
Query Builder
=============
.. automodule:: pybel_tools.query
:members:
1 change: 0 additions & 1 deletion docs/source/visualization.rst
@@ -1,5 +1,4 @@
Visualization
=============

.. automodule:: pybel_tools.visualization
:members:
5 changes: 2 additions & 3 deletions requirements.txt
@@ -1,11 +1,10 @@
pybel>=0.11.2
pybel>=0.11.11
pybel-artifactory
pandas==0.20.3
pandas
networkx==1.11
sqlalchemy
requests
click
scipy
numpy
jinja2
tqdm
2 changes: 1 addition & 1 deletion setup.cfg
@@ -1,5 +1,5 @@
[bdist_wheel]
universal = 1
universal = 0

[metadata]
license_file = LICENSE
13 changes: 5 additions & 8 deletions setup.py
@@ -1,5 +1,7 @@
# -*- coding: utf-8 -*-

"""Setup.py for PyBEL-Tools."""

import codecs
import os
import re
Expand All @@ -24,24 +26,19 @@
'Topic :: Scientific/Engineering :: Bio-Informatics'
]
INSTALL_REQUIRES = [
'pybel>=0.11.2',
'pybel>=0.11.11',
'pybel-artifactory',
'pandas==0.20.3',
'pandas',
'networkx==1.11',
'requests',
'sqlalchemy',
'click',
'scipy',
'numpy',
'jinja2',
'tqdm',
]

EXTRAS_REQUIRE = {
'ipython': [
'ipython', # Enable inline viewing in Jupyter notebooks
],
}
EXTRAS_REQUIRE = {}
TESTS_REQUIRE = []
ENTRY_POINTS = {
'console_scripts': [
Expand Down
5 changes: 3 additions & 2 deletions src/pybel_tools/__init__.py
Expand Up @@ -46,10 +46,11 @@

from . import io, utils
from .io import *
from .utils import get_version

__all__ = io.__all__
__all__ = io.__all__ + ['get_version']

__version__ = '0.5.3'
__version__ = '0.6.1'

__title__ = 'pybel_tools'
__description__ = 'Tools for using BEL documents in Python'
Expand Down
19 changes: 9 additions & 10 deletions src/pybel_tools/analysis/concordance.py
Expand Up @@ -2,22 +2,20 @@

"""Performs concordance analysis"""

from collections import defaultdict

import enum
import logging
from collections import defaultdict
from functools import partial

from pybel.constants import (
CAUSAL_DECREASE_RELATIONS, CAUSAL_INCREASE_RELATIONS, CAUSES_NO_CHANGE, NEGATIVE_CORRELATION, POSITIVE_CORRELATION,
RELATION,
CAUSAL_DECREASE_RELATIONS,
CAUSAL_INCREASE_RELATIONS,
CAUSES_NO_CHANGE,
POSITIVE_CORRELATION,
NEGATIVE_CORRELATION,
)
from ..mutation import collapse_all_variants, collapse_by_central_dogma_to_genes_out_place
from ..mutation.random import random_by_edges, shuffle_relations, shuffle_node_data
from ..grouping import get_subgraphs_by_annotation
from pybel.struct import get_subgraphs_by_annotation
from pybel.struct.mutation import collapse_to_genes
from ..mutation import collapse_all_variants
from ..mutation.random import random_by_edges, shuffle_node_data, shuffle_relations

__all__ = [
'Concordance',
Expand Down Expand Up @@ -221,7 +219,8 @@ def calculate_concordance_probability(graph, key, cutoff=None, permutations=None
else:
raise ValueError

graph = collapse_by_central_dogma_to_genes_out_place(graph)
graph = graph.copy()
collapse_to_genes(graph)
collapse_all_variants(graph)

score = calculate_concordance(graph, key, cutoff=cutoff)
Expand Down
18 changes: 11 additions & 7 deletions src/pybel_tools/analysis/epicom/algorithm.py
@@ -1,36 +1,40 @@
# -*- coding: utf-8 -*-

"""This algorithm has multiple steps
"""An implementation of chemical-based mechanism enrichment with NeuroMMSig [HoytDomingoFernandez2018]_.
This algorithm has multiple steps:
1. Select NeuroMMSig networks for AD, PD, and epilepsy
2. Select drugs from DrugBank, and their targets
3. Run NeuroMMSig algorithm on target list for each network and each mechanism
4. Store in database
.. [HoytDomingoFernandez2018] Charles Tapley Hoyt, Daniel Domingo-Fernández, Nora Balzer, Anka Güldenpfennig,
Martin Hofmann-Apitius; `A systematic approach for identifying shared mechanisms in epilepsy and its comorbidities
<https://doi.org/10.1093/database/bay050>`_, Database, Volume 2018, 1 January 2018, bay050
"""

import itertools as itt
import logging
import os

import bio2bel_drugbank
from bio2bel_drugbank.constants import DATA_DIR as DRUGBANK_DATA_DIR
from tqdm import tqdm

from pybel.dsl import gene as gene_dsl
from pybel.struct.grouping import get_subgraphs_by_annotation
from pybel.struct.summary import get_annotation_values
from pybel_tools.analysis.neurommsig import get_neurommsig_score, neurommsig_graph_preprocessor
from pybel_tools.grouping import get_subgraphs_by_annotation
from pybel_tools.summary import get_annotation_values

log = logging.getLogger(__name__)

_dti_cache_path = os.path.join(DRUGBANK_DATA_DIR, 'drug_to_gene_symbols.json')


def _get_drug_target_interactions():
"""Gets a mapping from drugs to their list of gene
:rtype: dict[str,list[str]]
"""
import bio2bel_drugbank

drugbank_manager = bio2bel_drugbank.Manager()
if not drugbank_manager.is_populated():
drugbank_manager.populate()
Expand Down

0 comments on commit 6f0f9e2

Please sign in to comment.