diff --git a/.travis.yml b/.travis.yml index b26dcf4..6ea41df 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,7 +6,7 @@ python: - "3.5" - "3.6" install: - - pip install .[test] + - pip install ".[test]" - python setup.py sdist bdist_wheel script: - py.test @@ -16,11 +16,11 @@ deploy: secure: wk1yDPq/hfKjvWtmBegLE8BnqjosbGjkCahFWOrtpiUG/lFW+7RRuQG9yQEUNkXjJ3ClIvRIPTXhGxywlQb1OXChhRXw5owykJxbBGDubSqnQGdGrX9nYVQa0pF70i5Lq6leabTLlSqJklxIYp8Ccv+qAlc7tP1cYI9SxKrdieU1Hq7mXC21YMsyjFWNMG+p8FH+srp3DhC1XfyNyrMJFDwFKbFyty0q1HUobD6rT8mjVmTJanlPBMNTiAkJNiZZ+Je4WEUXkrvFf85HRnUYMKg8MPPfz+sDGaV8WOHsApS0BJNX+bCPYzNITykLLdt2YzaFf6zkxDXTPvgWKuyrKanDavA+j06+vQCWRyiOzNWSSJg4ccr+UC8c64hy0T/dkKc6xaDLjXJRMCpHeBHa6h2RgJAHq8m8lH+OkHR33MXq5TTyRg88wHn2nzI6oLbNkiJhWr9IANREAKmpG5MjfUT3ogi4myxeGcVnGw1B9UJmxOOWAHTDhUtxw8nIGzgtrx4oUxQLDqds90hkH0vpFLbiAZ14rdZYaqcFFmEIp5yDw1pJu8bf3tUfQzNz0+EuoKzGwfjyH8UjlW7//PH7aAukMpa664bNlQ4p3bJZA0tYNdmwTYebf98N4vmv+zHFaEMu57rzlFtwxiltIciLP2on1Qvdfd65ukVipS3Q9Vo= file_glob: true file: - - dist/hetio-*.tar.gz - - dist/hetio-*.whl + - dist/hetnetpy-*.tar.gz + - dist/hetnetpy-*.whl on: python: '3.6' - repo: hetio/hetio + repo: hetio/hetnetpy tags: true - provider: pypi user: dhimmel @@ -28,6 +28,6 @@ deploy: secure: i6dHe2W+ynK81i/yjdCNqhXZ39rGJcdA+Nmp1W4Qg4NjizN3lozKmS9vHObdXRrobyn+AbCXPJ6GqyXPlT5+MbOtiTYWfvWm2Yd5zJff9GYyKkh4RBvmYrFgpkUJrb6mxmn+Gdo2yRA2aU2P+IBdY8aqx7/wvCBB6Z1e1xelOaZgOamCI8yfwsjXjuim8lP1IM6ayHjhTtejj8zHw14QhUoqBM6aKV2igJtv7CgwSZr6iAeOhruuyI3QgnlY3uM1f6I2YpsA/V0MnZDtVtvJ2ddk6sU6pIR1uUj5TCrJVBcFYI/z5jgJdo5kh2CLKRaD+k/luE+m0KV8K+GkRcC6+fYhLc+tF9gDw2F8TT2nnAmfHt8UYIn29sAyZsR8MifG6zhGTLZC4KpVRQP7eREr57GeQKEzEJiA/C4Fz2Fr47BMusO029EmB/OWsm8HqXz0IwsyWBp58shpgrP9xZUZBnDHe92pQNNfOfNzWuC1ATOs7LkbqB8Ml5vUT2vOePxkh7Bt3MR0ZEqNct7ZqwgOWrh2yFjoQ8BGDwPx1DNAQhQSGKBiea4kgWUGQIVTZw/IwwM7reWNY6Yvh8TA/5jlonVuCFBAXs0v1hwXn/suHGRk64yG2cS49h2lvltG379qp9gx6FI5WViszFvbwBZSONtIOr7lhGFw1IFRLRmeVkI= on: python: '3.6' - repo: hetio/hetio + repo: hetio/hetnetpy tags: true distributions: sdist bdist_wheel diff --git a/README.md b/README.md index 2c50b53..b61d3bd 100644 --- a/README.md +++ b/README.md @@ -1,18 +1,25 @@ # Hetnets in Python [![Latest DOI](https://zenodo.org/badge/14475/dhimmel/hetio.svg)](https://zenodo.org/badge/latestdoi/14475/dhimmel/hetio) -[![GitHub issues](https://img.shields.io/github/issues/hetio/hetio.svg)](https://github.com/hetio/hetio/issues) -[![Build Status](https://travis-ci.com/hetio/hetio.svg?branch=master)](https://travis-ci.com/hetio/hetio) +[![GitHub issues](https://img.shields.io/github/issues/hetio/hetnetpy.svg)](https://github.com/hetio/hetnetpy/issues) +[![Build Status](https://travis-ci.com/hetio/hetnetpy.svg?branch=master)](https://travis-ci.com/hetio/hetnetpy) + +## Overview + +Hetnetpy is a Python 3 package for creating, querying, and operating on hetnets. +This software provides convenient data structures for hetnets, as well as algorithms for edge prediction. +It is specifically tailored and streamlined for hetnets compared to other more generic network software. +See https://het.io/software for additional software packages designed specifically for hetnets. ## Package relocation -**Critical**: -This is the final release before the package name [changes](https://github.com/hetio/hetio/issues/40) to `hetnetpy` from `hetio`. -Future development will occur in the `hetio/hetnetpy` [repository](https://github.com/hetio/hetnetpy). -PyPI releases will be available at . +Note that this package was previousely named `hetio`, available at the following repositories: + +- (current) +- (former) +- (former) -Users of v0.2.11 will see a warning when importing `hetio`. -These users should either switch to using `hetnetpy` or downgrade to `hetio<=0.2.10` to avoid the warning. +In July 2019, the package was [renamed](https://github.com/hetio/hetnetpy/issues/40) to `hetnetpy` to more clearly represent its functionality and disambiguiate it from other products. ## Background @@ -22,22 +29,22 @@ These users should either switch to using `hetnetpy` or downgrade to `hetio<=0.2 **Impetus**: Development originated with a [study](https://doi.org/10.1371/journal.pcbi.1004259 "Heterogeneous Network Edge Prediction: A Data Integration Approach to Prioritize Disease-Associated Genes") to predict disease-associated genes and continues with a successive [study](https://doi.org/10.7554/eLife.26726 "Systematic integration of biomedical knowledge prioritizes drugs for repurposing") to repurpose drugs. -**Caution**: Documentation is currently spotty, testing coverage is moderate, and the API is not fully stable. Contributions are welcome. Please use [GitHub Issues](https://github.com/hetio/hetio/issues) for feedback, questions, or troubleshooting. +**Caution**: Documentation is currently spotty, testing coverage is moderate, and the API is not fully stable. Contributions are welcome. Please use [GitHub Issues](https://github.com/hetio/hetnetpy/issues) for feedback, questions, or troubleshooting. ## Installation -[![PyPI](https://img.shields.io/pypi/v/hetio.svg)](https://pypi.org/project/hetio/) +[![PyPI](https://img.shields.io/pypi/v/hetnetpy.svg)](https://pypi.org/project/hetnetpy/) Please use Python 3.4 or higher. To install the current PyPI version (recommended), run: ```sh -pip install hetio +pip install hetnetpy ``` For the latest GitHub version, run: ```sh -pip install git+https://github.com/hetio/hetio.git#egg=hetio +pip install git+https://github.com/hetio/hetnetpy.git#egg=hetnetpy ``` For development, clone or download-and-extract the repository. Then run `pip install --editable .` from the repository's root directory. The `--editable` flag specifies [editable](https://pythonhosted.org/setuptools/setuptools.html#development-mode) mode, so updating the source updates your installation. @@ -56,10 +63,10 @@ A Graph object stores a heterogeneous network and relies on the following classe ## Release instructions This section is only relevant for project maintainers. -Travis CI deployments are used to upload releases to [PyPI](https://pypi.org/project/hetio) and [GitHub releases](https://github.com/hetio/hetio/releases). +Travis CI deployments are used to upload releases to [PyPI](https://pypi.org/project/hetnetpy) and [GitHub releases](https://github.com/hetio/hetnetpy/releases). To create a new release, do the following: -1. Bump the version in [`__init__.py`](hetio/__init__.py). +1. Bump the version in [`__init__.py`](hetnetpy/__init__.py). 2. Add a release notes file in [`release-notes`](release-notes). Format as a commit message that will be used as the GitHub release description. @@ -68,7 +75,7 @@ To create a new release, do the following: ```sh TAG=v`python setup.py --version` - git add hetio/__init__.py release-notes/$TAG.* + git add hetnetpy/__init__.py release-notes/$TAG.* git commit --message "Prepare $TAG release" git push git tag --annotate $TAG --file release-notes/$TAG.* diff --git a/hetio b/hetio new file mode 120000 index 0000000..e38e7a7 --- /dev/null +++ b/hetio @@ -0,0 +1 @@ +hetnetpy \ No newline at end of file diff --git a/hetio/__init__.py b/hetio/__init__.py deleted file mode 100644 index 4414483..0000000 --- a/hetio/__init__.py +++ /dev/null @@ -1,11 +0,0 @@ -import warnings - -__version__ = "0.2.11" - -message = ''' -PACKAGE HAS BEEN RELOCATED: -v0.2.11 is the last release before the hetio package is renamed to hetnetpy. -Consider switching to the hetnetpy package or specifying hetio<=0.2.10 to silence this warning. -Future releases and development will only occur for the hetnetpy package. -''' -warnings.warn(message, FutureWarning) diff --git a/hetnetpy/__init__.py b/hetnetpy/__init__.py new file mode 100644 index 0000000..0ac5bcc --- /dev/null +++ b/hetnetpy/__init__.py @@ -0,0 +1,11 @@ +__version__ = "0.3.0" + +if __name__ == "hetio": + # https://github.com/hetio/hetnetpy/issues/40 + import warnings + message = ( + "The 'hetio' package has been renamed to 'hetnetpy'. " + "Future versions will remove the ability to 'import hetio'. " + "Switch to 'import hetnetpy'." + ) + warnings.warn(message, FutureWarning) diff --git a/hetio/abbreviation.py b/hetnetpy/abbreviation.py similarity index 97% rename from hetio/abbreviation.py rename to hetnetpy/abbreviation.py index bd20489..5eb4d6c 100644 --- a/hetio/abbreviation.py +++ b/hetnetpy/abbreviation.py @@ -2,7 +2,7 @@ import regex -import hetio.hetnet +import hetnetpy.hetnet def validate_abbreviations(metagraph): @@ -113,12 +113,12 @@ def create_abbreviations(metagraph): def metaedges_from_metapath(abbreviation, standardize_by=None): """ Get the abbreviated metaedges for an abbreviated metapath. - Pass a hetio.MetaGraph object to `standardize_by` to standardize metaedge + Pass a hetnetpy.MetaGraph object to `standardize_by` to standardize metaedge abbreviations based on the non-inverted orietatation. Pass `text` to standardize by alphabetical/forward-direction arrangment of the abbreviation. Default (`None`) does not standardize. """ - if isinstance(standardize_by, hetio.hetnet.MetaGraph): + if isinstance(standardize_by, hetnetpy.hetnet.MetaGraph): metapath = standardize_by.metapath_from_abbrev(abbreviation) return [metaedge.get_standard_abbrev() for metaedge in metapath] # Note that this is a valid regex module pattern but will not work in the diff --git a/hetio/hetnet.py b/hetnetpy/hetnet.py similarity index 97% rename from hetio/hetnet.py rename to hetnetpy/hetnet.py index b6a4570..dbd4129 100644 --- a/hetio/hetnet.py +++ b/hetnetpy/hetnet.py @@ -2,7 +2,7 @@ import functools import re -import hetio.abbreviation +import hetnetpy.abbreviation direction_to_inverse = { 'forward': 'backward', @@ -255,7 +255,7 @@ def get_metaedge(self, metaedge): raise ValueError('Cannot interpret object of type {}'.format(type(metaedge).__name__)) if metaedge in self.neo4j_to_metaedge: return self.neo4j_to_metaedge[metaedge] - metaedge_id = hetio.abbreviation.metaedge_id_from_abbreviation(self, metaedge) + metaedge_id = hetnetpy.abbreviation.metaedge_id_from_abbreviation(self, metaedge) return self.get_edge(metaedge_id) def get_metapath(self, metapath): @@ -302,10 +302,10 @@ def from_edge_tuples(metaedge_tuples, kind_to_abbrev=None): metagraph.add_edge(edge_tuple) if kind_to_abbrev is None: - kind_to_abbrev = hetio.abbreviation.create_abbreviations(metagraph) + kind_to_abbrev = hetnetpy.abbreviation.create_abbreviations(metagraph) metagraph.set_abbreviations(kind_to_abbrev) - assert hetio.abbreviation.validate_abbreviations(metagraph) + assert hetnetpy.abbreviation.validate_abbreviations(metagraph) return metagraph @@ -441,9 +441,9 @@ def get_metapath_from_edges(self, edges): def metapath_from_abbrev(self, abbrev): """Retrieve a metapath from its abbreviation""" metaedges = list() - metaedge_abbrevs = hetio.abbreviation.metaedges_from_metapath(abbrev) + metaedge_abbrevs = hetnetpy.abbreviation.metaedges_from_metapath(abbrev) for metaedge_abbrev in metaedge_abbrevs: - metaedge_id = hetio.abbreviation.metaedge_id_from_abbreviation( + metaedge_id = hetnetpy.abbreviation.metaedge_id_from_abbreviation( self, metaedge_abbrev) metaedges.append(self.get_edge(metaedge_id)) return self.get_metapath_from_edges(tuple(metaedges)) @@ -561,7 +561,7 @@ def __init__(self, metagraph, data=dict()): Parameters ---------- - metagraph : hetio.hetnet.MetaGraph + metagraph : hetnetpy.hetnet.MetaGraph metagraph with the potential types of nodes and relationships """ BaseGraph.__init__(self) @@ -574,7 +574,7 @@ def add_node(self, kind, identifier, name=None, data={}): Parameters ---------- - metagraph : hetio.hetnet.MetaGraph + metagraph : hetnetpy.hetnet.MetaGraph metagraph with the potential types of nodes and relationships kind : str metanode kind @@ -601,9 +601,9 @@ def add_edge(self, source_id, target_id, kind, direction, data=dict()): Parameters ---------- - source_id : hetio.hetnet.Node or tuple of (metanode, node) identifiers + source_id : hetnetpy.hetnet.Node or tuple of (metanode, node) identifiers the source node for the edge - target_id : hetio.hetnet.Node or tuple of (metanode, node) identifiers + target_id : hetnetpy.hetnet.Node or tuple of (metanode, node) identifiers the target node for the edge kind : str the metaedge kind diff --git a/hetio/matrix.py b/hetnetpy/matrix.py similarity index 97% rename from hetio/matrix.py rename to hetnetpy/matrix.py index 1cdac5f..9b34480 100644 --- a/hetio/matrix.py +++ b/hetnetpy/matrix.py @@ -40,8 +40,8 @@ def metaedge_to_adjacency_matrix( Parameters ========== - graph : hetio.hetnet.graph - metaedge : hetio.hetnet.MetaEdge or an alternative metaedge specification + graph : hetnetpy.hetnet.graph + metaedge : hetnetpy.hetnet.MetaEdge or an alternative metaedge specification dtype : type dense_threshold : float (0 ≤ dense_threshold ≤ 1) minimum proportion of nonzero values at which to output a dense matrix. diff --git a/hetio/neo4j.py b/hetnetpy/neo4j.py similarity index 98% rename from hetio/neo4j.py rename to hetnetpy/neo4j.py index c4263be..f114d96 100644 --- a/hetio/neo4j.py +++ b/hetnetpy/neo4j.py @@ -2,7 +2,7 @@ import itertools import textwrap -import hetio.hetnet +import hetnetpy.hetnet @functools.lru_cache() @@ -119,7 +119,7 @@ def as_label(metanode): """ import warnings warnings.warn( - "hetio.neo4j.as_label is deprecated. Use metanode.neo4j_label instead.", + "hetnetpy.neo4j.as_label is deprecated. Use metanode.neo4j_label instead.", DeprecationWarning, ) return metanode.neo4j_label @@ -131,10 +131,10 @@ def as_type(metaedge): """ import warnings warnings.warn( - "hetio.neo4j.as_type is deprecated. Use metaedge.neo4j_rel_type instead.", + "hetnetpy.neo4j.as_type is deprecated. Use metaedge.neo4j_rel_type instead.", DeprecationWarning, ) - assert isinstance(metaedge, hetio.hetnet.MetaEdge) + assert isinstance(metaedge, hetnetpy.hetnet.MetaEdge) return metaedge.neo4j_rel_type @@ -168,7 +168,7 @@ def cypher_path(metarels): Format a metapath for cypher. """ # Convert metapath to metarels - if isinstance(metarels, hetio.hetnet.MetaPath): + if isinstance(metarels, hetnetpy.hetnet.MetaPath): metarels = metapath_to_metarels(metarels) # Create cypher query @@ -357,7 +357,7 @@ def construct_dwpc_query(metarels, property='name', join_hint='midpoint', index_ which is the default, uses the `labeled` method. """ # Convert metapath to metarels - if isinstance(metarels, hetio.hetnet.MetaPath): + if isinstance(metarels, hetnetpy.hetnet.MetaPath): metarels = metapath_to_metarels(metarels) # create cypher path query @@ -435,7 +435,7 @@ def construct_pdp_query(metarels, dwpc=None, path_style='list', return_property= which is the default, uses the `labeled` method. """ # Convert metapath to metarels - if isinstance(metarels, hetio.hetnet.MetaPath): + if isinstance(metarels, hetnetpy.hetnet.MetaPath): metarels = metapath_to_metarels(metarels) # create cypher path query diff --git a/hetio/pathtools.py b/hetnetpy/pathtools.py similarity index 99% rename from hetio/pathtools.py rename to hetnetpy/pathtools.py index 09403ef..a634bbe 100644 --- a/hetio/pathtools.py +++ b/hetnetpy/pathtools.py @@ -2,7 +2,7 @@ import functools import operator -from hetio.hetnet import Node, Path +from hetnetpy.hetnet import Node, Path def DWPC(paths, damping_exponent, exclude_edges=set(), exclude_masked=True): diff --git a/hetio/permute.py b/hetnetpy/permute.py similarity index 98% rename from hetio/permute.py rename to hetnetpy/permute.py index e6f9296..722a2e0 100644 --- a/hetio/permute.py +++ b/hetnetpy/permute.py @@ -2,7 +2,7 @@ import random import logging -from hetio.hetnet import Graph +from hetnetpy.hetnet import Graph def permute_graph(graph, multiplier=10, seed=0, metaedge_to_excluded=dict(), log=False): @@ -19,7 +19,7 @@ def permute_graph(graph, multiplier=10, seed=0, metaedge_to_excluded=dict(), log Parameters ---------- - graph : hetio.hetnet.Graph + graph : hetnetpy.hetnet.Graph Input hetnet to create a permuted derivative from multiplier : int or float This is multiplied by the number of edges for each metaedge to @@ -36,7 +36,7 @@ def permute_graph(graph, multiplier=10, seed=0, metaedge_to_excluded=dict(), log Returns ------- - permuted_graph : hetio.hetnet.Graph + permuted_graph : hetnetpy.hetnet.Graph A permuted hetnet derived from the input graph. stats : list of dicts A list where each item is a dictionary of permutation statistics at a diff --git a/hetio/readwrite.py b/hetnetpy/readwrite.py similarity index 99% rename from hetio/readwrite.py rename to hetnetpy/readwrite.py index 684889a..066c8aa 100644 --- a/hetio/readwrite.py +++ b/hetnetpy/readwrite.py @@ -16,7 +16,7 @@ except ImportError: fspath = str -from hetio.hetnet import Graph, MetaGraph +from hetnetpy.hetnet import Graph, MetaGraph def read_graph(path, formatting=None): diff --git a/hetio/stats.py b/hetnetpy/stats.py similarity index 100% rename from hetio/stats.py rename to hetnetpy/stats.py diff --git a/release-notes/v0.3.0.txt b/release-notes/v0.3.0.txt new file mode 100644 index 0000000..adfd4c6 --- /dev/null +++ b/release-notes/v0.3.0.txt @@ -0,0 +1,6 @@ +hetio/hetnetpy v0.3.0 +===================== + +This release is the first with the new package name `hetnetpy`. +Users should now use `pip install hetnetpy` and `import hetnetpy`. +`import hetio` will still work but will trigger a FutureWarning. diff --git a/setup.py b/setup.py index 17cc7a6..54817e2 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ directory = pathlib.Path(__file__).parent.absolute() # version -init_path = directory.joinpath('hetio', '__init__.py') +init_path = directory.joinpath('hetnetpy', '__init__.py') with init_path.open() as read_file: text = read_file.read() pattern = re.compile(r"^__version__ = ['\"]([^'\"]*)['\"]", re.MULTILINE) @@ -30,9 +30,9 @@ setuptools.setup( # Package details - name='hetio', + name='hetnetpy', version=version, - url='https://github.com/hetio/hetio', + url='https://github.com/hetio/hetnetpy', description='Hetnets in Python', long_description_content_type='text/markdown', long_description=long_description, @@ -43,7 +43,7 @@ author_email='daniel.himmelstein@gmail.com', # Package topics - keywords='hetnet graph heterogeneous network neo4j hetio', + keywords='hetnet graph heterogeneous network neo4j hetio hetnetpy', classifiers=[ 'Intended Audience :: Science/Research', 'Topic :: Scientific/Engineering :: Bio-Informatics', @@ -56,7 +56,7 @@ 'Programming Language :: Python :: 3.6', ], - packages=['hetio'], + packages=['hetnetpy', 'hetio'], # Specify python version python_requires='>=3.4', diff --git a/test/abbreviation_test.py b/test/abbreviation_test.py index aa94742..62a474a 100644 --- a/test/abbreviation_test.py +++ b/test/abbreviation_test.py @@ -1,8 +1,8 @@ -import hetio.abbreviation +import hetnetpy.abbreviation def test__get_duplicates(): - get_duplicates = hetio.abbreviation.get_duplicates + get_duplicates = hetnetpy.abbreviation.get_duplicates assert get_duplicates(range(5)) == set() assert get_duplicates('abcd') == set() assert get_duplicates('abbccd') == {'b', 'c'} @@ -50,7 +50,7 @@ def test__find_abbrevs(): 'paIn': 'pa', }, ] - find_abbrevs = hetio.abbreviation.find_abbrevs + find_abbrevs = hetnetpy.abbreviation.find_abbrevs for kind_to_abbrev in kind_to_abbrevs: assert kind_to_abbrev == find_abbrevs(kind_to_abbrev.keys()) @@ -67,5 +67,5 @@ def test__metaedges_from_metapath(): } for metapath in metapath_to_metaedge: - result = hetio.abbreviation.metaedges_from_metapath(metapath) + result = hetnetpy.abbreviation.metaedges_from_metapath(metapath) assert result == metapath_to_metaedge[metapath] diff --git a/test/data/create-subgraphs.ipynb b/test/data/create-subgraphs.ipynb index 703e842..e65d43b 100644 --- a/test/data/create-subgraphs.ipynb +++ b/test/data/create-subgraphs.ipynb @@ -17,9 +17,9 @@ "source": [ "import random\n", "\n", - "import hetio.readwrite\n", - "import hetio.pathtools\n", - "import hetio.stats" + "import hetnetpy.readwrite\n", + "import hetnetpy.pathtools\n", + "import hetnetpy.stats" ] }, { @@ -31,11 +31,11 @@ "outputs": [], "source": [ "# Read Hetionet v1.0\n", - "url = 'https://github.com/dhimmel/hetionet/raw/{}/{}'.format(\n", + "url = 'https://github.com/hetio/hetionet/raw/{}/{}'.format(\n", " '00bf0b6f8886821d91cfdf00eadad145a7a1b6da',\n", " 'hetnet/json/hetionet-v1.0.json.bz2',\n", ")\n", - "graph = hetio.readwrite.read_graph(url)\n", + "graph = hetnetpy.readwrite.read_graph(url)\n", "metagraph = graph.metagraph" ] }, @@ -69,7 +69,7 @@ "outputs": [], "source": [ "# Extract walks from compound to disease\n", - "paths = hetio.pathtools.paths_between(\n", + "paths = hetnetpy.pathtools.paths_between(\n", " graph, \n", " source=graph.node_dict[compound_id],\n", " target=graph.node_dict[disease_id],\n", @@ -230,7 +230,7 @@ ], "source": [ "# Metanode info\n", - "hetio.stats.get_metanode_df(subgraph)" + "hetnetpy.stats.get_metanode_df(subgraph)" ] }, { @@ -324,7 +324,7 @@ ], "source": [ "# Metaedge info\n", - "hetio.stats.get_metaedge_df(subgraph)" + "hetnetpy.stats.get_metaedge_df(subgraph)" ] }, { @@ -336,7 +336,7 @@ "outputs": [], "source": [ "# Export as JSON\n", - "hetio.readwrite.write_graph(subgraph, 'bupropion-CbGpPWpGaD-subgraph.json.xz')" + "hetnetpy.readwrite.write_graph(subgraph, 'bupropion-CbGpPWpGaD-subgraph.json.xz')" ] }, { @@ -567,7 +567,7 @@ ], "source": [ "# Metanode info\n", - "hetio.stats.get_metanode_df(subgraph)" + "hetnetpy.stats.get_metanode_df(subgraph)" ] }, { @@ -861,7 +861,7 @@ ], "source": [ "# Metaedge info\n", - "hetio.stats.get_metaedge_df(subgraph)" + "hetnetpy.stats.get_metaedge_df(subgraph)" ] }, { @@ -873,7 +873,7 @@ "outputs": [], "source": [ "# Export as JSON\n", - "hetio.readwrite.write_graph(subgraph, 'random-subgraph.json.xz')" + "hetnetpy.readwrite.write_graph(subgraph, 'random-subgraph.json.xz')" ] } ], diff --git a/test/extract_metapaths_test.py b/test/extract_metapaths_test.py index 3925b66..5709c48 100644 --- a/test/extract_metapaths_test.py +++ b/test/extract_metapaths_test.py @@ -2,7 +2,7 @@ import pytest -import hetio.readwrite +import hetnetpy.readwrite def get_hetionet_metagraph(): @@ -11,7 +11,7 @@ def get_hetionet_metagraph(): """ directory = pathlib.Path(__file__).parent.absolute() path = directory.joinpath('data/hetionet-v1.0-metagraph.json') - return hetio.readwrite.read_metagraph(path) + return hetnetpy.readwrite.read_metagraph(path) def test_extract_metapaths(): diff --git a/test/graph_test.py b/test/graph_test.py index e7b67ee..f6d9dcc 100644 --- a/test/graph_test.py +++ b/test/graph_test.py @@ -3,8 +3,8 @@ import pytest -import hetio.hetnet -import hetio.readwrite +import hetnetpy.hetnet +import hetnetpy.readwrite from .readwrite_test import formats, extensions @@ -22,12 +22,12 @@ def test_creation(tmpdir): ('gene', 'gene', 'transcribes', 'forward'), ] metanode_ids = 'compound', 'disease', 'gene' - metagraph = hetio.hetnet.MetaGraph.from_edge_tuples(metaedge_tuples) + metagraph = hetnetpy.hetnet.MetaGraph.from_edge_tuples(metaedge_tuples) # check that nodes got added to metagraph_node_dict assert frozenset(metagraph.node_dict) == frozenset(metanode_ids) for metanode in metagraph.node_dict.values(): - assert isinstance(metanode, hetio.hetnet.MetaNode) + assert isinstance(metanode, hetnetpy.hetnet.MetaNode) # check that metanode.get_id() and hash(metanode) are working as expected for metanode_id in metanode_ids: @@ -42,7 +42,7 @@ def test_creation(tmpdir): assert metagraph.n_inverts == 4 # Create a graph - graph = hetio.hetnet.Graph(metagraph) + graph = hetnetpy.hetnet.Graph(metagraph) # Create a node for multiple sclerosis ms = graph.add_node('disease', 'DOID:2377', 'multiple sclerosis') @@ -93,12 +93,12 @@ def test_creation(tmpdir): ext = '.{}{}'.format(format_, extension) # Write metagraph path = os.path.join(tmpdir, 'metagraph' + ext) - hetio.readwrite.write_metagraph(metagraph, path) - hetio.readwrite.read_metagraph(path) + hetnetpy.readwrite.write_metagraph(metagraph, path) + hetnetpy.readwrite.read_metagraph(path) # Write graph path = os.path.join(tmpdir, 'graph' + ext) - hetio.readwrite.write_graph(graph, path) - hetio.readwrite.read_graph(path) + hetnetpy.readwrite.write_graph(graph, path) + hetnetpy.readwrite.read_graph(path) def test_disase_gene_example(): @@ -112,7 +112,7 @@ def test_disase_gene_example(): ('Disease', 'Tissue', 'localization', 'both'), ('Gene', 'Gene', 'interaction', 'both'), ] - metagraph = hetio.hetnet.MetaGraph.from_edge_tuples(metaedge_tuples) + metagraph = hetnetpy.hetnet.MetaGraph.from_edge_tuples(metaedge_tuples) # Test metagraph getter methods gene_metanode = metagraph.node_dict['Gene'] @@ -145,7 +145,7 @@ def test_disase_gene_example(): assert metapath.abbrev == metapath_abbrev # Create graph - graph = hetio.hetnet.Graph(metagraph) + graph = hetnetpy.hetnet.Graph(metagraph) nodes = dict() # Add gene nodes @@ -199,7 +199,7 @@ def get_hetionet_metagraph(): Return the Hetionet v1.0 metagraph """ path = pathlib.Path(__file__).parent / 'data/hetionet-v1.0-metagraph.json' - return hetio.readwrite.read_metagraph(path) + return hetnetpy.readwrite.read_metagraph(path) @pytest.mark.parametrize(['metapath', 'symmetry'], [ @@ -218,12 +218,12 @@ def get_hetionet_metagraph(): ]) def test_metapath_symmetry(metapath, symmetry): """ - https://github.com/hetio/hetio/issues/38 + https://github.com/hetio/hetnetpy/issues/38 """ metagraph = get_hetionet_metagraph() metapath = metagraph.get_metapath(metapath) assert metapath.is_symmetric() == symmetry if symmetry: # Test only single metapath object is created - # https://github.com/hetio/hetio/issues/38 + # https://github.com/hetio/hetnetpy/issues/38 assert metapath is metapath.inverse diff --git a/test/matrix_test.py b/test/matrix_test.py index 8247251..a6910b1 100644 --- a/test/matrix_test.py +++ b/test/matrix_test.py @@ -4,11 +4,11 @@ import pytest import scipy.sparse -from hetio.matrix import ( +from hetnetpy.matrix import ( metaedge_to_adjacency_matrix, sparsify_or_densify, ) -import hetio.readwrite +import hetnetpy.readwrite directory = os.path.dirname(os.path.abspath(__file__)) @@ -59,7 +59,7 @@ def test_metaedge_to_adjacency_matrix(test_edge, dtype, dense_threshold): https://doi.org/10.1371/journal.pcbi.1004259.g002 """ path = os.path.join(directory, 'data', 'disease-gene-example-graph.json') - graph = hetio.readwrite.read_graph(path) + graph = hetnetpy.readwrite.read_graph(path) row_names, col_names, adj_mat = metaedge_to_adjacency_matrix( graph, test_edge, dtype=dtype, dense_threshold=dense_threshold) exp_row, exp_col, exp_adj = get_arrays(test_edge, dtype, dense_threshold) diff --git a/test/neo4j_test.py b/test/neo4j_test.py index 1a4a203..96294d0 100644 --- a/test/neo4j_test.py +++ b/test/neo4j_test.py @@ -1,7 +1,7 @@ import pathlib from neo4j.v1 import GraphDatabase -import hetio.readwrite -import hetio.neo4j +import hetnetpy.readwrite +import hetnetpy.neo4j import pytest import textwrap @@ -19,7 +19,7 @@ def test_construct_pdp_query(): directory = pathlib.Path(__file__).parent.absolute() path = directory.joinpath('data/hetionet-v1.0-metagraph.json') - metagraph = hetio.readwrite.read_metagraph(path) + metagraph = hetnetpy.readwrite.read_metagraph(path) compound = 'DB01156' # Bupropion disease = 'DOID:0050742' # nicotine dependency @@ -28,7 +28,7 @@ def test_construct_pdp_query(): metapath = metagraph.metapath_from_abbrev('CbGpPWpGaD') # Calculate the pdp without being provided with the dwpc - pdp_query = hetio.neo4j.construct_pdp_query(metapath, path_style='string', property='identifier', unique_nodes=True) + pdp_query = hetnetpy.neo4j.construct_pdp_query(metapath, path_style='string', property='identifier', unique_nodes=True) assert len(pdp_query) > 0 driver = GraphDatabase.driver("bolt://neo4j.het.io") @@ -51,7 +51,7 @@ def test_construct_pdp_query(): old_pdp_query = pdp_query # Calculate the pdp with the provided dwpc - pdp_query = hetio.neo4j.construct_pdp_query(metapath, dwpc, path_style='list', property='identifier', unique_nodes=True) + pdp_query = hetnetpy.neo4j.construct_pdp_query(metapath, dwpc, path_style='list', property='identifier', unique_nodes=True) assert len(pdp_query) > 0 assert old_pdp_query != pdp_query @@ -136,14 +136,14 @@ def test_construct_pdp_query_return_values(): # Set up the graph for querying directory = pathlib.Path(__file__).parent.absolute() path = directory.joinpath('data/hetionet-v1.0-metagraph.json') - metagraph = hetio.readwrite.read_metagraph(path) + metagraph = hetnetpy.readwrite.read_metagraph(path) metapath = metagraph.metapath_from_abbrev('CbGpPWpGaD') - DWPCless_query = hetio.neo4j.construct_pdp_query(metapath, path_style='string', property='identifier', unique_nodes=True) + DWPCless_query = hetnetpy.neo4j.construct_pdp_query(metapath, path_style='string', property='identifier', unique_nodes=True) assert DWPCless_query == q1 - DWPC_query = hetio.neo4j.construct_pdp_query(metapath, dwpc, path_style='string', property='identifier', unique_nodes=True) + DWPC_query = hetnetpy.neo4j.construct_pdp_query(metapath, dwpc, path_style='string', property='identifier', unique_nodes=True) assert DWPC_query == q2 @@ -156,7 +156,7 @@ def test_construct_dwpc_query(): directory = pathlib.Path(__file__).parent.absolute() path = directory.joinpath('data/hetionet-v1.0-metagraph.json') - metagraph = hetio.readwrite.read_metagraph(path) + metagraph = hetnetpy.readwrite.read_metagraph(path) compound = 'DB01156' # Bupropion disease = 'DOID:0050742' # nicotine dependency @@ -164,7 +164,7 @@ def test_construct_dwpc_query(): metapath = metagraph.metapath_from_abbrev('CbGpPWpGaD') - query = hetio.neo4j.construct_dwpc_query(metapath, property='identifier', unique_nodes=True) + query = hetnetpy.neo4j.construct_dwpc_query(metapath, property='identifier', unique_nodes=True) assert len(query) > 0 driver = GraphDatabase.driver("bolt://neo4j.het.io") @@ -193,11 +193,11 @@ def test_construct_path_return_clause_returns(style, identifier, expected_output ''' Test the results of construct_path_return_clause with different parameters ''' - assert hetio.neo4j.create_path_return_clause(style, identifier) == expected_output + assert hetnetpy.neo4j.create_path_return_clause(style, identifier) == expected_output def test_construct_path_return_clause_error(): ''' Ensure that construct_path_return_clause throwns a ValueError when given an invalid style ''' with pytest.raises(ValueError): - hetio.neo4j.create_path_return_clause('invalid_style') + hetnetpy.neo4j.create_path_return_clause('invalid_style') diff --git a/test/pathtools_test.py b/test/pathtools_test.py index 0a3561b..1bc7a0b 100644 --- a/test/pathtools_test.py +++ b/test/pathtools_test.py @@ -2,8 +2,8 @@ import pytest -import hetio.readwrite -from hetio.pathtools import paths_between, DWPC +import hetnetpy.readwrite +from hetnetpy.pathtools import paths_between, DWPC directory = os.path.dirname(os.path.abspath(__file__)) @@ -14,7 +14,7 @@ def test_disease_gene_example_dwpc(): https://doi.org/10.1371/journal.pcbi.1004259.g002 """ path = os.path.join(directory, 'data', 'disease-gene-example-graph.json') - graph = hetio.readwrite.read_graph(path) + graph = hetnetpy.readwrite.read_graph(path) metagraph = graph.metagraph # Define source and target nodes @@ -51,7 +51,7 @@ def test_bupropion_CbGpPWpGaD_traversal(): # Read Hetionet v1.0 subgraph path = os.path.join( directory, 'data', 'bupropion-CbGpPWpGaD-subgraph.json.xz') - graph = hetio.readwrite.read_graph(path) + graph = hetnetpy.readwrite.read_graph(path) metagraph = graph.metagraph # Define traversal diff --git a/test/permute_test.py b/test/permute_test.py index 224cdbe..77a0923 100644 --- a/test/permute_test.py +++ b/test/permute_test.py @@ -1,6 +1,6 @@ import pytest -import hetio.permute +import hetnetpy.permute @pytest.mark.parametrize('edges,inplace', [ @@ -9,7 +9,7 @@ ]) def test_permute_inplace(edges, inplace): old_edges = edges.copy() - new_edges, stats = hetio.permute.permute_pair_list(edges, inplace=inplace) + new_edges, stats = hetnetpy.permute.permute_pair_list(edges, inplace=inplace) assert old_edges != new_edges if inplace: diff --git a/test/readwrite_test.py b/test/readwrite_test.py index 8403491..cb0b3cc 100644 --- a/test/readwrite_test.py +++ b/test/readwrite_test.py @@ -1,6 +1,6 @@ import os -import hetio.readwrite +import hetnetpy.readwrite directory = os.path.dirname(os.path.abspath(__file__)) @@ -25,7 +25,7 @@ def read_hetionet_v1_0_metagraph(path, extensions=None): if extensions is None: extensions = [''] for ext in extensions: - metagraph = hetio.readwrite.read_metagraph(path + ext) + metagraph = hetnetpy.readwrite.read_metagraph(path + ext) assert metagraph.n_nodes == 11 assert metagraph.n_edges == 24 @@ -35,7 +35,7 @@ def test_metagraph_reading_from_urls(): Test reading metagraphs from URLs. """ url = 'https://github.com/{repo}/raw/{commit}/{path}'.format( - repo='hetio/hetio', + repo='hetio/hetnetpy', commit='master', path='test/data/hetionet-v1.0-metagraph.json', ) diff --git a/test/relocation_test.py b/test/relocation_test.py index 4d5fd90..d10f74e 100644 --- a/test/relocation_test.py +++ b/test/relocation_test.py @@ -5,9 +5,19 @@ def test_relocation_warning(): """ - https://github.com/hetio/hetio/issues/40 + https://github.com/hetio/hetnetpy/issues/40 """ - with pytest.warns(FutureWarning, match='PACKAGE HAS BEEN RELOCATED'): + with pytest.warns(FutureWarning, match="package has been renamed to 'hetnetpy'"): import hetio # Reload module to ensure warning tiggers importlib.reload(hetio) + + +@pytest.mark.filterwarnings('error') +def test_no_relocation_warning(): + """ + https://github.com/hetio/hetnetpy/issues/40 + """ + import hetnetpy + # Reload module to ensure warning tiggers + importlib.reload(hetnetpy) diff --git a/test/subgraph_test.py b/test/subgraph_test.py index 1bb3e09..b889bd6 100644 --- a/test/subgraph_test.py +++ b/test/subgraph_test.py @@ -1,6 +1,6 @@ import os -import hetio.readwrite +import hetnetpy.readwrite directory = os.path.dirname(os.path.abspath(__file__)) @@ -11,7 +11,7 @@ def get_disease_gene_example_hetnet(): https://doi.org/10.1371/journal.pcbi.1004259.g002 """ path = os.path.join(directory, 'data', 'disease-gene-example-graph.json') - graph = hetio.readwrite.read_graph(path) + graph = hetnetpy.readwrite.read_graph(path) return graph