risk-network 0.0.13b5__py3-none-any.whl → 0.0.14b0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
risk/__init__.py CHANGED
@@ -5,7 +5,7 @@ risk
5
5
  RISK: Regional Inference of Significant Kinships
6
6
  """
7
7
 
8
- from .risk import RISK
8
+ from ._risk import RISK
9
9
 
10
10
  __all__ = ["RISK"]
11
- __version__ = "0.0.13-beta.5"
11
+ __version__ = "0.0.14-beta.0"
@@ -7,4 +7,4 @@ from ._annotation import (
7
7
  define_top_annotation,
8
8
  get_weighted_description,
9
9
  )
10
- from ._io import AnnotationIO
10
+ from ._io import AnnotationHandler
risk/_annotation/_io.py CHANGED
@@ -13,11 +13,11 @@ from .._log import log_header, logger, params
13
13
  from ._annotation import load_annotation
14
14
 
15
15
 
16
- class AnnotationIO:
16
+ class AnnotationHandler:
17
17
  """
18
18
  Handles the loading and exporting of annotation in various file formats.
19
19
 
20
- The AnnotationIO class provides methods to load annotation from different file types (JSON, CSV, Excel, etc.)
20
+ The AnnotationHandler class provides methods to load annotation from different file types (JSON, CSV, Excel, etc.)
21
21
  and to export parameter data to various formats like JSON, CSV, and text files.
22
22
  """
23
23
 
risk/_network/__init__.py CHANGED
@@ -4,5 +4,5 @@ risk/_network
4
4
  """
5
5
 
6
6
  from ._graph import GraphAPI
7
- from ._io import NetworkIO
7
+ from ._io import NetworkAPI
8
8
  from ._plotter import PlotterAPI
risk/_network/_io.py CHANGED
@@ -18,12 +18,10 @@ import pandas as pd
18
18
  from .._log import log_header, logger, params
19
19
 
20
20
 
21
- class NetworkIO:
21
+ class NetworkAPI:
22
22
  """
23
- A class for loading, processing, and managing network data.
24
-
25
- The NetworkIO class provides methods to load network data from various formats (e.g., GPickle, NetworkX)
26
- and process the network by adjusting node coordinates, calculating edge lengths, and validating graph structure.
23
+ Public-facing interface for loading and initializing network data.
24
+ Delegates to the NetworkIO worker class for actual I/O and processing.
27
25
  """
28
26
 
29
27
  def __init__(
@@ -33,22 +31,16 @@ class NetworkIO:
33
31
  min_edges_per_node: int = 0,
34
32
  ):
35
33
  """
36
- Initialize the NetworkIO class.
34
+ Initialize the NetworkAPI.
37
35
 
38
36
  Args:
39
- compute_sphere (bool, optional): Whether to map nodes to a sphere. Defaults to True.
40
- surface_depth (float, optional): Surface depth for the sphere. Defaults to 0.0.
41
- min_edges_per_node (int, optional): Minimum number of edges per node. Defaults to 0.
37
+ compute_sphere (bool): Whether to map nodes to a sphere. Defaults to True.
38
+ surface_depth (float): Surface depth for the sphere. Defaults to 0.0.
39
+ min_edges_per_node (int): Minimum number of edges per node. Defaults to 0.
42
40
  """
43
41
  self.compute_sphere = compute_sphere
44
42
  self.surface_depth = surface_depth
45
43
  self.min_edges_per_node = min_edges_per_node
46
- # Log the initialization of the NetworkIO class
47
- params.log_network(
48
- compute_sphere=compute_sphere,
49
- surface_depth=surface_depth,
50
- min_edges_per_node=min_edges_per_node,
51
- )
52
44
 
53
45
  def load_network_gpickle(
54
46
  self,
@@ -58,44 +50,22 @@ class NetworkIO:
58
50
  min_edges_per_node: int = 0,
59
51
  ) -> nx.Graph:
60
52
  """
61
- Load a network from a GPickle file.
53
+ Load a network from a GPickle file via NetworkIO.
62
54
 
63
55
  Args:
64
56
  filepath (str): Path to the GPickle file.
65
- compute_sphere (bool, optional): Whether to map nodes to a sphere. Defaults to True.
66
- surface_depth (float, optional): Surface depth for the sphere. Defaults to 0.0.
67
- min_edges_per_node (int, optional): Minimum number of edges per node. Defaults to 0.
68
-
57
+ compute_sphere (bool, optional): Override or use API default. Defaults to True.
58
+ surface_depth (float, optional): Override or use API default. Defaults to 0.0.
59
+ min_edges_per_node (int, optional): Override or use API default. Defaults to 0.
69
60
  Returns:
70
61
  nx.Graph: Loaded and processed network.
71
62
  """
72
- networkio = NetworkIO(
63
+ io = NetworkIO(
73
64
  compute_sphere=compute_sphere,
74
65
  surface_depth=surface_depth,
75
66
  min_edges_per_node=min_edges_per_node,
76
67
  )
77
- return networkio._load_network_gpickle(filepath=filepath)
78
-
79
- def _load_network_gpickle(self, filepath: str) -> nx.Graph:
80
- """
81
- Private method to load a network from a GPickle file.
82
-
83
- Args:
84
- filepath (str): Path to the GPickle file.
85
-
86
- Returns:
87
- nx.Graph: Loaded and processed network.
88
- """
89
- filetype = "GPickle"
90
- # Log the loading of the GPickle file
91
- params.log_network(filetype=filetype, filepath=filepath)
92
- self._log_loading_network(filetype, filepath=filepath)
93
-
94
- with open(filepath, "rb") as f:
95
- G = pickle.load(f)
96
-
97
- # Initialize the graph
98
- return self._initialize_graph(G)
68
+ return io.load_network_gpickle(filepath=filepath)
99
69
 
100
70
  def load_network_networkx(
101
71
  self,
@@ -105,82 +75,167 @@ class NetworkIO:
105
75
  min_edges_per_node: int = 0,
106
76
  ) -> nx.Graph:
107
77
  """
108
- Load a NetworkX graph.
78
+ Load a NetworkX graph via NetworkIO.
109
79
 
110
80
  Args:
111
81
  network (nx.Graph): A NetworkX graph object.
112
- compute_sphere (bool, optional): Whether to map nodes to a sphere. Defaults to True.
113
- surface_depth (float, optional): Surface depth for the sphere. Defaults to 0.0.
114
- min_edges_per_node (int, optional): Minimum number of edges per node. Defaults to 0.
115
-
82
+ compute_sphere (bool, optional): Override or use API default. Defaults to True.
83
+ surface_depth (float, optional): Override or use API default. Defaults to 0.0.
84
+ min_edges_per_node (int, optional): Override or use API default. Defaults to 0.
116
85
  Returns:
117
- nx.Graph: Loaded and processed network.
86
+ nx.Graph: Processed network.
118
87
  """
119
- networkio = NetworkIO(
88
+ io = NetworkIO(
120
89
  compute_sphere=compute_sphere,
121
90
  surface_depth=surface_depth,
122
91
  min_edges_per_node=min_edges_per_node,
123
92
  )
124
- return networkio._load_network_networkx(network=network)
93
+ return io.load_network_networkx(network=network)
125
94
 
126
- def _load_network_networkx(self, network: nx.Graph) -> nx.Graph:
95
+ def load_network_cytoscape(
96
+ self,
97
+ filepath: str,
98
+ source_label: str = "source",
99
+ target_label: str = "target",
100
+ view_name: str = "",
101
+ compute_sphere: bool = True,
102
+ surface_depth: float = 0.0,
103
+ min_edges_per_node: int = 0,
104
+ ) -> nx.Graph:
127
105
  """
128
- Private method to load a NetworkX graph.
106
+ Load a network from a Cytoscape file via NetworkIO.
129
107
 
130
108
  Args:
131
- network (nx.Graph): A NetworkX graph object.
132
-
109
+ filepath (str): Path to the Cytoscape file.
110
+ source_label (str, optional): Source node label. Defaults to "source".
111
+ target_label (str, optional): Target node label. Defaults to "target".
112
+ view_name (str, optional): Specific view name to load. Defaults to "".
113
+ compute_sphere (bool, optional): Override or use API default. Defaults to True.
114
+ surface_depth (float, optional): Override or use API default. Defaults to 0.0.
115
+ min_edges_per_node (int, optional): Override or use API default. Defaults to 0.
133
116
  Returns:
134
- nx.Graph: Processed network.
117
+ nx.Graph: Loaded and processed network.
135
118
  """
136
- filetype = "NetworkX"
137
- # Log the loading of the NetworkX graph
138
- params.log_network(filetype=filetype)
139
- self._log_loading_network(filetype)
140
-
141
- # Important: Make a copy of the network to avoid modifying the original
142
- network_copy = copy.deepcopy(network)
143
- # Initialize the graph
144
- return self._initialize_graph(network_copy)
119
+ io = NetworkIO(
120
+ compute_sphere=compute_sphere,
121
+ surface_depth=surface_depth,
122
+ min_edges_per_node=min_edges_per_node,
123
+ )
124
+ return io.load_network_cytoscape(
125
+ filepath=filepath,
126
+ source_label=source_label,
127
+ target_label=target_label,
128
+ view_name=view_name,
129
+ )
145
130
 
146
- def load_network_cytoscape(
131
+ def load_network_cyjs(
147
132
  self,
148
133
  filepath: str,
149
134
  source_label: str = "source",
150
135
  target_label: str = "target",
151
- view_name: str = "",
152
136
  compute_sphere: bool = True,
153
137
  surface_depth: float = 0.0,
154
138
  min_edges_per_node: int = 0,
155
139
  ) -> nx.Graph:
156
140
  """
157
- Load a network from a Cytoscape file.
141
+ Load a network from a Cytoscape JSON (.cyjs) file via NetworkIO.
158
142
 
159
143
  Args:
160
- filepath (str): Path to the Cytoscape file.
144
+ filepath (str): Path to the Cytoscape JSON file.
161
145
  source_label (str, optional): Source node label. Defaults to "source".
162
146
  target_label (str, optional): Target node label. Defaults to "target".
163
- view_name (str, optional): Specific view name to load. Defaults to "".
164
- compute_sphere (bool, optional): Whether to map nodes to a sphere. Defaults to True.
165
- surface_depth (float, optional): Surface depth for the sphere. Defaults to 0.0.
166
- min_edges_per_node (int, optional): Minimum number of edges per node. Defaults to 0.
167
-
147
+ compute_sphere (bool, optional): Override or use API default. Defaults to True.
148
+ surface_depth (float, optional): Override or use API default. Defaults to 0.0.
149
+ min_edges_per_node (int, optional): Override or use API default. Defaults to 0.
168
150
  Returns:
169
151
  nx.Graph: Loaded and processed network.
170
152
  """
171
- networkio = NetworkIO(
153
+ io = NetworkIO(
172
154
  compute_sphere=compute_sphere,
173
155
  surface_depth=surface_depth,
174
156
  min_edges_per_node=min_edges_per_node,
175
157
  )
176
- return networkio._load_network_cytoscape(
158
+ return io.load_network_cyjs(
177
159
  filepath=filepath,
178
160
  source_label=source_label,
179
161
  target_label=target_label,
180
- view_name=view_name,
181
162
  )
182
163
 
183
- def _load_network_cytoscape(
164
+
165
+ class NetworkIO:
166
+ """
167
+ A class for loading, processing, and managing network data.
168
+
169
+ The NetworkIO class provides methods to load network data from various formats (e.g., GPickle, NetworkX)
170
+ and process the network by adjusting node coordinates, calculating edge lengths, and validating graph structure.
171
+ """
172
+
173
+ def __init__(
174
+ self,
175
+ compute_sphere: bool = True,
176
+ surface_depth: float = 0.0,
177
+ min_edges_per_node: int = 0,
178
+ ):
179
+ """
180
+ Initialize the NetworkIO class.
181
+
182
+ Args:
183
+ compute_sphere (bool, optional): Whether to map nodes to a sphere. Defaults to True.
184
+ surface_depth (float, optional): Surface depth for the sphere. Defaults to 0.0.
185
+ min_edges_per_node (int, optional): Minimum number of edges per node. Defaults to 0.
186
+ """
187
+ self.compute_sphere = compute_sphere
188
+ self.surface_depth = surface_depth
189
+ self.min_edges_per_node = min_edges_per_node
190
+ # Log the initialization of the NetworkIO class
191
+ params.log_network(
192
+ compute_sphere=compute_sphere,
193
+ surface_depth=surface_depth,
194
+ min_edges_per_node=min_edges_per_node,
195
+ )
196
+
197
+ def load_network_gpickle(self, filepath: str) -> nx.Graph:
198
+ """
199
+ Load a network from a GPickle file.
200
+
201
+ Args:
202
+ filepath (str): Path to the GPickle file.
203
+
204
+ Returns:
205
+ nx.Graph: Loaded and processed network.
206
+ """
207
+ filetype = "GPickle"
208
+ # Log the loading of the GPickle file
209
+ params.log_network(filetype=filetype, filepath=filepath)
210
+ self._log_loading_network(filetype, filepath=filepath)
211
+
212
+ with open(filepath, "rb") as f:
213
+ G = pickle.load(f)
214
+
215
+ # Initialize the graph
216
+ return self._initialize_graph(G)
217
+
218
+ def load_network_networkx(self, network: nx.Graph) -> nx.Graph:
219
+ """
220
+ Load a NetworkX graph.
221
+
222
+ Args:
223
+ network (nx.Graph): A NetworkX graph object.
224
+
225
+ Returns:
226
+ nx.Graph: Processed network.
227
+ """
228
+ filetype = "NetworkX"
229
+ # Log the loading of the NetworkX graph
230
+ params.log_network(filetype=filetype)
231
+ self._log_loading_network(filetype)
232
+
233
+ # Important: Make a copy of the network to avoid modifying the original
234
+ network_copy = copy.deepcopy(network)
235
+ # Initialize the graph
236
+ return self._initialize_graph(network_copy)
237
+
238
+ def load_network_cytoscape(
184
239
  self,
185
240
  filepath: str,
186
241
  source_label: str = "source",
@@ -188,7 +243,7 @@ class NetworkIO:
188
243
  view_name: str = "",
189
244
  ) -> nx.Graph:
190
245
  """
191
- Private method to load a network from a Cytoscape file.
246
+ Load a network from a Cytoscape file.
192
247
 
193
248
  Args:
194
249
  filepath (str): Path to the Cytoscape file.
@@ -315,44 +370,10 @@ class NetworkIO:
315
370
  if os.path.exists(tmp_dir):
316
371
  shutil.rmtree(tmp_dir)
317
372
 
318
- def load_network_cyjs(
319
- self,
320
- filepath: str,
321
- source_label: str = "source",
322
- target_label: str = "target",
323
- compute_sphere: bool = True,
324
- surface_depth: float = 0.0,
325
- min_edges_per_node: int = 0,
326
- ) -> nx.Graph:
373
+ def load_network_cyjs(self, filepath, source_label="source", target_label="target"):
327
374
  """
328
375
  Load a network from a Cytoscape JSON (.cyjs) file.
329
376
 
330
- Args:
331
- filepath (str): Path to the Cytoscape JSON file.
332
- source_label (str, optional): Source node label. Default is "source".
333
- target_label (str, optional): Target node label. Default is "target".
334
- compute_sphere (bool, optional): Whether to map nodes to a sphere. Defaults to True.
335
- surface_depth (float, optional): Surface depth for the sphere. Defaults to 0.0.
336
- min_edges_per_node (int, optional): Minimum number of edges per node. Defaults to 0.
337
-
338
- Returns:
339
- NetworkX graph: Loaded and processed network.
340
- """
341
- networkio = NetworkIO(
342
- compute_sphere=compute_sphere,
343
- surface_depth=surface_depth,
344
- min_edges_per_node=min_edges_per_node,
345
- )
346
- return networkio._load_network_cyjs(
347
- filepath=filepath,
348
- source_label=source_label,
349
- target_label=target_label,
350
- )
351
-
352
- def _load_network_cyjs(self, filepath, source_label="source", target_label="target"):
353
- """
354
- Private method to load a network from a Cytoscape JSON (.cyjs) file.
355
-
356
377
  Args:
357
378
  filepath (str): Path to the Cytoscape JSON file.
358
379
  source_label (str, optional): Source node label. Default is "source".
@@ -1,15 +1,15 @@
1
1
  """
2
- risk/risk
3
- ~~~~~~~~~
2
+ risk/_risk
3
+ ~~~~~~~~~~
4
4
  """
5
5
 
6
- from ._annotation import AnnotationIO
6
+ from ._annotation import AnnotationHandler
7
7
  from ._log import params, set_global_verbosity
8
8
  from ._neighborhoods import NeighborhoodsAPI
9
- from ._network import GraphAPI, NetworkIO, PlotterAPI
9
+ from ._network import GraphAPI, NetworkAPI, PlotterAPI
10
10
 
11
11
 
12
- class RISK(NetworkIO, AnnotationIO, NeighborhoodsAPI, GraphAPI, PlotterAPI):
12
+ class RISK(NetworkAPI, AnnotationHandler, NeighborhoodsAPI, GraphAPI, PlotterAPI):
13
13
  """
14
14
  RISK: A class for network analysis and visualization.
15
15
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: risk-network
3
- Version: 0.0.13b5
3
+ Version: 0.0.14b0
4
4
  Summary: A Python package for scalable network analysis and high-quality visualization.
5
5
  Author-email: Ira Horecka <ira89@icloud.com>
6
6
  License: GPL-3.0-or-later
@@ -1,8 +1,8 @@
1
- risk/__init__.py,sha256=lyhdzjETYJ9Jg8da35gncJ_u2_QrElRsW5t1c69OIJY,142
2
- risk/risk.py,sha256=l7Btltgd-K00rmUV4_jTgJTwikSmMb-9A2IUQN5PnY8,1040
3
- risk/_annotation/__init__.py,sha256=LBLL5P_MdfwWaxkHBQHfQTPY-FF8hIGoUGKyHF1Wg4s,159
1
+ risk/__init__.py,sha256=4gUMRlMdNJ2feLptoxyeWymcTnqlyoExMrazTwzyfrs,143
2
+ risk/_risk.py,sha256=VULCdM41BlWKM1ou4Qc579ffZ9dMZkfhAwKYgbaEeKM,1054
3
+ risk/_annotation/__init__.py,sha256=zr7w1DHkmvrkKFGKdPhrcvZHV-xsfd5TZOaWtFiP4Dc,164
4
4
  risk/_annotation/_annotation.py,sha256=03vcnkdi4HGH5UUyokUyOdyyjXOLoKSmLFuK7VAl41c,15174
5
- risk/_annotation/_io.py,sha256=gEq6STSWFIFjSWoGXJfwxTME4GDJZTOgPeXZABgSdXc,12447
5
+ risk/_annotation/_io.py,sha256=xic3dkEA54X82HbyWfCiXrUpAhPWFPBZ69R8jw31omQ,12457
6
6
  risk/_annotation/_nltk_setup.py,sha256=aHHnElLOKiouVDrZ3uON0CSFmBxvzmYfjYPi07v2rJM,3584
7
7
  risk/_log/__init__.py,sha256=LX6BsfcGOH0RbAdQaUmIU-LVMmArDdKwn0jFtj45FYo,205
8
8
  risk/_log/_console.py,sha256=1jSFzY3w0-vVqIBCgc-IhyJPNT6vRg8GSGxhyw_D9MI,4653
@@ -17,8 +17,8 @@ risk/_neighborhoods/_stats/_tests.py,sha256=-ioHdyrsgW63YnypKFpanatauuKrF3LT7aMZ
17
17
  risk/_neighborhoods/_stats/_permutation/__init__.py,sha256=nfTaW29CK8OZCdFnpMVlHnFaqr1E4AZp6mvhlUazHXM,140
18
18
  risk/_neighborhoods/_stats/_permutation/_permutation.py,sha256=e5qVuYWGhiAn5Jv8VILk-WYMOO4km48cGdRYTOl355M,10661
19
19
  risk/_neighborhoods/_stats/_permutation/_test_functions.py,sha256=lGI_MkdbW4UHI0jWN_T1OattRjXrq_qmzAmOfels670,3165
20
- risk/_network/__init__.py,sha256=LbXsJGU2-ydDMw5_qgwizE6YHMljGDuOGc6TO-jk4Pk,126
21
- risk/_network/_io.py,sha256=vOSfAWnj1Q4jQSVo9BqY-nwQIoEG-CYZ_Cv2clopVw0,28090
20
+ risk/_network/__init__.py,sha256=YrAMfhL0CMWQb3sY-mn1VxK44zZAWeFAvHrBONH9I-A,127
21
+ risk/_network/_io.py,sha256=uiYmbKVsSRr4-TsY9KvRggDghtZv8qoxXac3QYs1lTI,28750
22
22
  risk/_network/_graph/__init__.py,sha256=SFgxgxUiZK4vvw6bdQ04DSMXEr8xjMaQV-Wne6wAIqM,104
23
23
  risk/_network/_graph/_api.py,sha256=zH7n-ulqLcbgHdAfLu1yWErdR5G4LgSqR7DcN2qApco,8520
24
24
  risk/_network/_graph/_graph.py,sha256=x2EWT_ZVwxh7m9a01yG4WMdmAxBxiaxX3CvkqP9QAXE,12486
@@ -34,8 +34,8 @@ risk/_network/_plotter/_plotter.py,sha256=F2hw-spUdsXjvuG36o0YFR3Pnd-CZOHYUq4vW0
34
34
  risk/_network/_plotter/_utils/__init__.py,sha256=JXgjKiBWvXx0X2IeFnrOh5YZQGQoELbhJZ0Zh2mFEOo,211
35
35
  risk/_network/_plotter/_utils/_colors.py,sha256=JCliSvz8_-TsjilaRHSEsqdXFBUYlzhXKOSRGdCm9Kw,19177
36
36
  risk/_network/_plotter/_utils/_layout.py,sha256=GyGLc2U1WWUVL1Te9uPi_CLqlW_E4TImXRAL5TeA5D8,3633
37
- risk_network-0.0.13b5.dist-info/licenses/LICENSE,sha256=jOtLnuWt7d5Hsx6XXB2QxzrSe2sWWh3NgMfFRetluQM,35147
38
- risk_network-0.0.13b5.dist-info/METADATA,sha256=dkYs8JCdMr945DZ-7bJ95MX0zuxfbkw1VpOhuLtCE_U,6853
39
- risk_network-0.0.13b5.dist-info/WHEEL,sha256=0CuiUZ_p9E4cD6NyLD6UG80LBXYyiSYZOKDm5lp32xk,91
40
- risk_network-0.0.13b5.dist-info/top_level.txt,sha256=NX7C2PFKTvC1JhVKv14DFlFAIFnKc6Lpsu1ZfxvQwVw,5
41
- risk_network-0.0.13b5.dist-info/RECORD,,
37
+ risk_network-0.0.14b0.dist-info/licenses/LICENSE,sha256=jOtLnuWt7d5Hsx6XXB2QxzrSe2sWWh3NgMfFRetluQM,35147
38
+ risk_network-0.0.14b0.dist-info/METADATA,sha256=rshHTAf4wXudUsCwUIQpK8VZzmb5-f_c9_fYfrYXdm0,6853
39
+ risk_network-0.0.14b0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
40
+ risk_network-0.0.14b0.dist-info/top_level.txt,sha256=NX7C2PFKTvC1JhVKv14DFlFAIFnKc6Lpsu1ZfxvQwVw,5
41
+ risk_network-0.0.14b0.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (80.3.1)
2
+ Generator: setuptools (80.9.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5