Strategy API¶
Connection strategies are exposed as methods on Network; their implementations
live in neko.core.strategies. Most users should call the bound methods so
history snapshots are recorded automatically.
See Choosing a connection strategy for topology diagrams, biological interpretation, and a decision table.
net.connect_nodes(only_signed=True)
net.complete_connection(
maxlen=2,
path_policy="all_shortest",
reuse_policy="discovered_paths",
only_signed=True,
)
strategies ¶
Connection strategies for NeKo networks.
This module contains high-level strategies for connecting nodes in a Network object. Each function should accept a Network instance as the first argument.
Classes¶
Functions:¶
connect_nodes ¶
Basic node connections. Adds all interactions found in the resources database.
Source code in neko/core/strategies.py
connect_subgroup ¶
connect_subgroup(network, group, maxlen: int = 1, only_signed: bool = False, consensus: bool = False) -> None
Connect all nodes in a subgroup by finding paths between all pairs and adding them to the network.
Source code in neko/core/strategies.py
connect_component ¶
connect_component(network, comp_A, comp_B, maxlen: int = 2, mode: Literal['OUT', 'IN', 'ALL'] = 'OUT', only_signed: bool = False, consensus: bool = False) -> None
Connect subcomponents of a network using the specified mode and add paths to the network.
Source code in neko/core/strategies.py
connect_to_upstream_nodes ¶
connect_to_upstream_nodes(network, nodes_to_connect=None, depth: int = 1, rank: int = 1, only_signed: bool = True, consensus: bool = False) -> None
Connect provided nodes to their upstream nodes in the network.
Source code in neko/core/strategies.py
connect_genes_to_phenotype ¶
connect_genes_to_phenotype(network, phenotype: str = None, id_accession: str = None, sub_genes: list = None, maxlen: int = 2, only_signed: bool = False, compress: bool = False, taxon_id=9606, include_descendants: bool = False, exclude_automatic_assertions: bool = False) -> None
Connect a network to GO-associated genes and optionally compress them.
GO-provided UniProt identifiers are used directly. Gene-symbol mapping is retained only as a fallback for associations in another identifier space.
Source code in neko/core/strategies.py
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 | |
connect_network_radially ¶
connect_network_radially(network, max_len: int = 1, direction: Literal['OUT', 'IN', None] = None, loops: bool = False, consensus: bool = False, only_signed: bool = True) -> None
Connect all nodes of a network in a radial manner.
Source code in neko/core/strategies.py
connect_as_atopo ¶
connect_as_atopo(network, strategy: Literal['radial', 'complete', None] = None, max_len: int = 1, loops: bool = False, outputs=None, only_signed: bool = True, consensus: bool = False) -> None
Connect all nodes of a network in a topological manner.
Source code in neko/core/strategies.py
334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 | |
complete_connection ¶
complete_connection(network, maxlen: Optional[int] = 2, algorithm=UNSET, minimal=UNSET, only_signed: bool = False, consensus: bool = False, connect_with_bias=UNSET, *, path_policy: Optional[PathPolicy] = None, reuse_policy: Optional[ReusePolicy] = None, _warning_stacklevel: int = 3) -> None
Greedily complete every original seed pair in both directed orientations.
path_policy controls which resource paths are selected when the
working graph lacks a connection. reuse_policy controls whether later
searches see no additions, explicitly discovered paths, or the induced
resource subgraph over selected nodes. Legacy algorithm, minimal,
and connect_with_bias arguments remain temporarily supported through a
visible migration warning.
Source code in neko/core/strategies.py
413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 | |