diff --git a/networkcommons/_data/omics/_moon.py b/networkcommons/_data/omics/_moon.py index 12c61e8..733d043 100644 --- a/networkcommons/_data/omics/_moon.py +++ b/networkcommons/_data/omics/_moon.py @@ -21,7 +21,7 @@ import pandas as pd -from . import _common +from . import common __all__ = ['moon'] diff --git a/networkcommons/_methods/moon.py b/networkcommons/_methods/moon.py index 09ddcd5..133209a 100644 --- a/networkcommons/_methods/moon.py +++ b/networkcommons/_methods/moon.py @@ -25,7 +25,7 @@ import decoupler as dc import numpy as np -from networkcommons._methods import graph +from networkcommons._methods import graph as _graph from networkcommons._session import _log __all__ = [ @@ -233,7 +233,7 @@ def keep_controllable_neighbours(source_dict, graph): - A dictionary of source nodes that are observable from the graph. """ - return graph.run_reachability_filter(graph, source_dict) + return _graph.run_reachability_filter(graph, source_dict) def keep_observable_neighbours(target_dict, graph): @@ -249,7 +249,7 @@ def keep_observable_neighbours(target_dict, graph): - A dictionary of target nodes that are observable from the graph. """ - subnetwork = graph.run_reachability_filter(graph.reverse(), target_dict) + subnetwork = _graph.run_reachability_filter(graph.reverse(), target_dict) return subnetwork.reverse() diff --git a/tests/test_eval_graph.py b/tests/test_eval_graph.py index f03069d..ac59d74 100644 --- a/tests/test_eval_graph.py +++ b/tests/test_eval_graph.py @@ -3,7 +3,7 @@ import networkx as nx import pandas as pd -import networkcommons._eval.metrics as metrics +import networkcommons._eval.metrics as _metrics @pytest.fixture @@ -23,40 +23,40 @@ def network(): def test_get_number_nodes(): - assert metrics.get_number_nodes(nx.Graph()) == 0 - assert metrics.get_number_nodes(nx.Graph([(1, 2)])) == 2 - assert metrics.get_number_nodes(nx.Graph([(1, 2), (2, 3)])) == 3 + assert _metrics.get_number_nodes(nx.Graph()) == 0 + assert _metrics.get_number_nodes(nx.Graph([(1, 2)])) == 2 + assert _metrics.get_number_nodes(nx.Graph([(1, 2), (2, 3)])) == 3 def test_get_number_edges(): - assert metrics.get_number_edges(nx.Graph()) == 0 - assert metrics.get_number_edges(nx.Graph([(1, 2)])) == 1 - assert metrics.get_number_edges(nx.Graph([(1, 2), (2, 3)])) == 2 + assert _metrics.get_number_edges(nx.Graph()) == 0 + assert _metrics.get_number_edges(nx.Graph([(1, 2)])) == 1 + assert _metrics.get_number_edges(nx.Graph([(1, 2), (2, 3)])) == 2 def test_get_mean_degree(network): - assert metrics.get_mean_degree(network) == 7/3 + assert _metrics.get_mean_degree(network) == 7/3 def test_get_mean_betweenness(network): - assert metrics.get_mean_betweenness(network) == 0.05833333333333334 + assert _metrics.get_mean_betweenness(network) == 0.05833333333333334 def test_get_mean_closeness(network): - assert metrics.get_mean_closeness(network) == 0.29444444444444445 + assert _metrics.get_mean_closeness(network) == 0.29444444444444445 def test_get_connected_targets(network): target_dict = {'D': 1, 'F': 1, 'W': 1} - assert metrics.get_connected_targets(network, target_dict) == 2 + assert _metrics.get_connected_targets(network, target_dict) == 2 assert ( - metrics.get_connected_targets(network, target_dict, percent=True) == + _metrics.get_connected_targets(network, target_dict, percent=True) == 2 / 3 * 100 ) @@ -65,9 +65,9 @@ def test_get_recovered_offtargets(network): offtargets = ['B', 'D', 'W'] - assert metrics.get_recovered_offtargets(network, offtargets) == 2 + assert _metrics.get_recovered_offtargets(network, offtargets) == 2 assert ( - metrics.get_recovered_offtargets(network, offtargets, percent=True) == + _metrics.get_recovered_offtargets(network, offtargets, percent=True) == 2 / 3 * 100 )# noqa: E501 @@ -85,4 +85,4 @@ def test_get_graph_metrics(network): 'Connected targets': 2 }, index=[0]) - assert metrics.get_graph_metrics(network, target_dict).equals(metrics) + assert _metrics.get_graph_metrics(network, target_dict).equals(metrics) diff --git a/tests/test_omics.py b/tests/test_omics.py index 784cbd7..d19af3a 100644 --- a/tests/test_omics.py +++ b/tests/test_omics.py @@ -7,7 +7,7 @@ def test_datasets(): - dsets = omics._common._datasets() + dsets = omics.common._datasets() assert 'baseurl' in dsets assert isinstance(dsets['datasets'], dict) @@ -16,23 +16,23 @@ def test_datasets(): def test_datasets_2(): - dsets = omics._common.datasets() + dsets = omics.common.datasets() assert 'decryptm' in dsets def test_commons_url(): - url = omics._common._commons_url('test', table = 'meta') + url = omics.common._commons_url('test', table = 'meta') assert 'metadata' in url def test_download(tmp_path): - url = omics._common._commons_url('test', table = 'meta') + url = omics.common._commons_url('test', table = 'meta') path = tmp_path / 'test_download.tsv' - omics._common._download(url, path) + omics.common._download(url, path) assert path.exists() @@ -45,9 +45,9 @@ def test_download(tmp_path): def test_open(): - url = omics._common._commons_url('test', table = 'meta') + url = omics.common._commons_url('test', table = 'meta') - with omics._common._open(url) as fp: + with omics.common._open(url) as fp: line = next(fp) @@ -56,8 +56,8 @@ def test_open(): def test_open_df(): - url = omics._common._commons_url('test', table = 'meta') - df = omics._common._open(url, df = {'sep': '\t'}) + url = omics.common._commons_url('test', table = 'meta') + df = omics.common._open(url, df = {'sep': '\t'}) assert isinstance(df, pd.DataFrame) assert df.shape == (4, 2) @@ -78,9 +78,9 @@ def decryptm_args(): return 'KDAC_Inhibitors', 'Acetylome', 'curves_CUDC101.txt' -def test_decryptm(decryptm_args): +def test_decryptm_table(decryptm_args): - df = omics.decryptm.decryptm(*decryptm_args) + df = omics.decryptm.decryptm_table(*decryptm_args) assert isinstance(df, pd.DataFrame) assert df.shape == (18007, 65) @@ -100,7 +100,7 @@ def test_decryptm_experiment(decryptm_args): def test_panacea(): - dfs = omics.panacea.panacea() + dfs = omics.panacea() assert isinstance(dfs, tuple) assert len(dfs) == 2