Skip to content

Commit

Permalink
Merge pull request #25 from PathwayMerger/ppi-exporter
Browse files Browse the repository at this point in the history
Ppi exporter
  • Loading branch information
ddomingof committed Jan 14, 2020
2 parents 29c5691 + 264f16f commit bb7b390
Show file tree
Hide file tree
Showing 24 changed files with 155 additions and 159 deletions.
19 changes: 0 additions & 19 deletions .coveragerc

This file was deleted.

13 changes: 7 additions & 6 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@
#########################

[flake8]
ignore =
E501
I100 # Import statements are in the wrong order
I101 # Imported names are in the wrong order
ignore =
E501 # Line too long
F405 # Stars import
F403 # imports not used in init
F401 # imports not used in init
Expand All @@ -25,7 +23,10 @@ exclude =
*.egg-info,
.cache,
.eggs
max-complexity = 10
max-complexity = 20
max-line-length = 120
import-order-style = pycharm
application-import-names = pathme
application-import-names =
pathme
tests
format = ${cyan}%(path)s${reset}:${yellow_bold}%(row)d${reset}:${green_bold}%(col)d${reset}: ${red_bold}%(code)s${reset} %(text)s
6 changes: 2 additions & 4 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# See: https://docs.readthedocs.io/en/latest/yaml-config.html
build:
image: latest
python:
version: 3.6
version: 3
pip_install: true
extra_requirements:
- docs
- docs
22 changes: 5 additions & 17 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
sudo: false
cache: pip

language: python
python:
- 3.6
- 3.7
stages:
- lint
- docs
Expand All @@ -13,9 +14,6 @@ jobs:
- stage: lint
env: TOXENV=manifest
- env: TOXENV=flake8
- env: TOXENV=flake8-kegg
- env: TOXENV=xenon
- env: TOXENV=vulture
- env: TOXENV=pyroma
# docs stage
- stage: docs
Expand All @@ -25,21 +23,11 @@ jobs:
# test stage
- stage: test
env: TOXENV=py
- env: TOXENV=py PATHME_TESTS=tests/test_kegg/
matrix:
allow_failures:
- env: TOXENV=flake8
- env: TOXENV=xenon
- env: TOXENV=vulture
install:
- pip install --upgrade pip
- 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
- tox
after_success:
- tox -e coverage-report
- codecov
- sh -c 'if [ "$TOXENV" = "py" ]; then tox -e coverage-report; codecov; fi'
notifications:
slack: pybel:n2KbWKBum3musnBg3L76gGwq
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright 2018-2019 Daniel Domingo-Fernandez
Copyright 2018-2020 Daniel Domingo-Fernández

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 0 additions & 2 deletions doc8.ini

This file was deleted.

6 changes: 3 additions & 3 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
source_suffix = '.rst'
master_doc = 'index'
project = 'PathMe'
copyright = '2018, Daniel Domingo-Fernández, Sarah Mubeen, and Josep Marin Llao'
author = 'Daniel Domingo-Fernández, Sarah Mubeen, and Josep Marin Llao'
copyright = '2020, Daniel Domingo-Fernández, Sarah Mubeen, Josep Marin Llao, and Charles Tapley Hoyt'
author = 'Daniel Domingo-Fernández, Sarah Mubeen, Josep Marin Llao, and Charles Tapley Hoyt'

release = '0.1.12-dev'

Expand All @@ -44,7 +44,7 @@
latex_elements = {}
latex_documents = [
(master_doc, 'pathme.tex', 'PathMe Documentation',
'Sarah Mubeen, Josep Marin Llao, and Daniel Domingo-Fernández', 'manual'),
'Daniel Domingo-Fernández, Sarah Mubeen, Josep Marin Llao, and Charles Tapley Hoyt', 'manual'),
]
man_pages = [
(master_doc, 'pathme', 'PathMe Documentation', [author], 1)
Expand Down
13 changes: 11 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ classifiers =
Operating System :: OS Independent
Programming Language :: Python
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.6
Programming Language :: Python :: 3 :: Only
Topic :: Scientific/Engineering :: Bio-Informatics

Expand Down Expand Up @@ -65,7 +64,7 @@ install_requires =
# Random options
zip_safe = false
include_package_data = True
python_requires = >=3.6
python_requires = >=3.7

# Where is my code
packages = find:
Expand Down Expand Up @@ -100,6 +99,16 @@ max-line-length = 120
[coverage:run]
branch = True
source = pathme
omit =
src/pathme/__main__.py
src/pathme/cli.py
tests/*
docs/*

[coverage:paths]
source =
src/pathme
.tox/*/lib/python*/site-packages/pathme

[coverage:report]
show_missing = True
Expand Down
33 changes: 25 additions & 8 deletions src/pathme/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
import pathme.kegg.cli
import pathme.reactome.cli
import pathme.wikipathways.cli
from .constants import CX_DIR, KEGG_BEL, REACTOME_BEL, SPIA_DIR, UNIVERSE_DIR, WIKIPATHWAYS_BEL
from .export_utils import get_universe_graph, iterate_universe_graphs, spia_export_helper
from .constants import CX_DIR, KEGG_BEL, PPI_DIR, REACTOME_BEL, SPIA_DIR, UNIVERSE_DIR, WIKIPATHWAYS_BEL
from .export_utils import export_helper, get_universe_graph, iterate_universe_graphs

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -69,14 +69,31 @@ def export():
def spia(kegg_path, reactome_path, wikipathways_path, output):
"""Export BEL Pickles to SPIA Excel."""
click.echo(f'Results will be exported to {output}')
spia_export_helper(
export_helper(
kegg_path=kegg_path,
reactome_path=reactome_path,
wikipathways_path=wikipathways_path,
output=output,
)


@export.command()
@kegg_path_option
@reactome_path_option
@wikipathways_path_option
@click.option('-o', '--output', help='Output directory', default=PPI_DIR, show_default=True)
def ppi(kegg_path, reactome_path, wikipathways_path, output):
"""Export BEL Pickles to PPI-like tsv file."""
click.echo(f'Results will be exported to {output}')
export_helper(
kegg_path=kegg_path,
reactome_path=reactome_path,
wikipathways_path=wikipathways_path,
output=output,
format='ppi',
)


@export.command()
@kegg_path_option
@reactome_path_option
Expand All @@ -94,11 +111,11 @@ def cx(kegg_path, reactome_path, wikipathways_path, output, no_flatten, no_norma

click.echo(f'Results will be exported to {output}')
for source, path, graph in iterate_universe_graphs(
kegg_path=kegg_path,
reactome_path=reactome_path,
wikipathways_path=wikipathways_path,
flatten=(not no_flatten),
normalize_names=(not no_normalize_names),
kegg_path=kegg_path,
reactome_path=reactome_path,
wikipathways_path=wikipathways_path,
flatten=(not no_flatten),
normalize_names=(not no_normalize_names),
):
with open(os.path.join(output, f"{path.strip('.pickle')}.cx.json"), 'w') as file:
to_cx_file(graph, file)
Expand Down
5 changes: 4 additions & 1 deletion src/pathme/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,19 @@ def get_data_dir() -> str:

SPIA_DIR = os.path.join(DATA_DIR, 'spia')
CX_DIR = os.path.join(DATA_DIR, 'cx')
PPI_DIR = os.path.join(DATA_DIR, 'ppi')
UNIVERSE_DIR = os.path.join(DATA_DIR, 'universe')


def ensure_pathme_folders(): # TODO why is this a function?
def ensure_pathme_folders():
"""Ensure data folders are created."""
os.makedirs(KEGG_DIR, exist_ok=True)
os.makedirs(REACTOME_DIR, exist_ok=True)
os.makedirs(WIKIPATHWAYS_DIR, exist_ok=True)
os.makedirs(KEGG_CACHE, exist_ok=True)
os.makedirs(SPIA_DIR, exist_ok=True)
os.makedirs(CX_DIR, exist_ok=True)
os.makedirs(PPI_DIR, exist_ok=True)
os.makedirs(UNIVERSE_DIR, exist_ok=True)

os.makedirs(KEGG_BEL, exist_ok=True)
Expand Down

0 comments on commit bb7b390

Please sign in to comment.