Skip to content
Open
Show file tree
Hide file tree
Changes from 72 commits
Commits
Show all changes
85 commits
Select commit Hold shift + click to select a range
7d521ce
Merge branch 'property-expe' into config-args
tristan-f-r Jul 14, 2025
9c85c56
Merge branch 'config-pydantic' into config-args
tristan-f-r Jul 14, 2025
647f947
feat: rough draft of args design
tristan-f-r Jul 14, 2025
76011e0
feat: type oi1/oi2, rwr/strwr
tristan-f-r Jul 14, 2025
94b50c8
refactor: meo, mcf, pl types
tristan-f-r Jul 14, 2025
09fa1ba
chore: begin slowly updating
tristan-f-r Jul 14, 2025
32d4b5c
refactor: moving more tests
tristan-f-r Jul 14, 2025
9b539e9
fix: correct params
tristan-f-r Jul 14, 2025
da67711
fix: specify default args out of run
tristan-f-r Jul 14, 2025
45cfe87
fix: more defaults
tristan-f-r Jul 14, 2025
a6406e2
Merge branch 'umain' into config-args
tristan-f-r Jul 14, 2025
cf93cec
Merge branch 'no-globals' into config-args
tristan-f-r Jul 14, 2025
e080857
feat: begin algorithm parsing
tristan-f-r Jul 14, 2025
53f55e2
fix: clean up type errors, begin nondetermnism
tristan-f-r Jul 14, 2025
7c2454b
Merge branch 'config-pydantic' into config-args
tristan-f-r Jul 14, 2025
a4e265d
chore: begin little utility
tristan-f-r Jul 14, 2025
145b2ec
chore: mv container schema changes over
tristan-f-r Jul 14, 2025
5effe69
feat: initial schema
tristan-f-r Jul 15, 2025
398350e
feat: more algs schema handling
tristan-f-r Jul 15, 2025
72c4cbd
feat: default runs for default algorithms
tristan-f-r Jul 15, 2025
2ef2672
feat: function running
tristan-f-r Jul 15, 2025
9442b64
chore: drop play
tristan-f-r Jul 15, 2025
60b562f
fix(config): don't try to parse in config.py
tristan-f-r Jul 15, 2025
c1947e6
fix: subscriptability
tristan-f-r Jul 15, 2025
8beaf72
fix: auto-discriminator mapping & forbid
tristan-f-r Jul 15, 2025
b07a7ef
style: fmt
tristan-f-r Jul 15, 2025
0bcd1d1
fix: coerce fields to validate default
tristan-f-r Jul 15, 2025
1cb5d17
fix: test
tristan-f-r Jul 15, 2025
c93244f
fix: correct all algorithm usage
tristan-f-r Jul 15, 2025
69268f4
chore: talk about resumability
tristan-f-r Jul 15, 2025
5ce01db
chore: drop seeds changes
tristan-f-r Jul 17, 2025
126d99f
fix: correct dummy file
tristan-f-r Jul 17, 2025
0cfa9ae
Merge branch 'umain' into config-args
tristan-f-r Jul 18, 2025
d4e4fa7
Merge branch 'umain' into config-args
tristan-f-r Jul 24, 2025
bbabbb5
Merge branch 'config-pydantic' into config-args
tristan-f-r Jul 24, 2025
c705ef7
feat: add responsenet params
tristan-f-r Jul 24, 2025
34719d8
style: fmt
tristan-f-r Jul 24, 2025
5220a79
Merge branch 'main' into config-args
tristan-f-r Aug 14, 2025
1976c4d
fix: all configs
tristan-f-r Aug 15, 2025
b31b857
refactor: the central validate_required_run_args
tristan-f-r Aug 15, 2025
2d0c3ec
test: use correct raises err for btb
tristan-f-r Aug 15, 2025
b8ee227
better err handling for too many keys
tristan-f-r Aug 15, 2025
b617825
chore: drop schema
tristan-f-r Sep 6, 2025
9992013
Merge branch 'main' into config-args
tristan-f-r Sep 6, 2025
a77263f
test: fix
tristan-f-r Sep 6, 2025
05e40c4
Update spras/config/algorithms.py
tristan-f-r Oct 28, 2025
5892445
Merge branch 'container-schema-use' into config-args
tristan-f-r Oct 29, 2025
cea83b2
test(btb): correct tests
tristan-f-r Oct 29, 2025
d9f251d
style: fmt
tristan-f-r Oct 29, 2025
dbe6971
test: correct other mishaps
tristan-f-r Oct 29, 2025
647907a
fix(mcf): correct types
tristan-f-r Oct 29, 2025
25a0796
fix(oi1): correct dummy node handling
tristan-f-r Oct 29, 2025
554e7ae
test: correct misc artifacts
tristan-f-r Oct 29, 2025
105b72d
fix: allow yaml safe dump of case insensitive enums
tristan-f-r Oct 29, 2025
eaecd33
docs: give credit to prev. commit
tristan-f-r Oct 29, 2025
6933fe4
fix: correctly write enum
tristan-f-r Oct 29, 2025
8fa7ca5
test(domino): don't unlink file before reading
tristan-f-r Nov 1, 2025
f321f79
fix: correct other alg parameters, summary test update
tristan-f-r Nov 1, 2025
ef02ac5
fix(summary): drop _spras_run_name
tristan-f-r Nov 1, 2025
fb3fa0e
Merge branch 'container-schema-use' into config-args
tristan-f-r Nov 7, 2025
313fac2
Merge branch 'umain' into config-args
tristan-f-r Nov 8, 2025
a50c181
Merge remote-tracking branch 'upstream/main' into config-args
tristan-f-r Nov 8, 2025
c3be550
docs: update contributing
tristan-f-r Nov 8, 2025
830b07c
chore: drop directed info
tristan-f-r Nov 10, 2025
b2d4239
Merge branch 'config-args' of https://github.com/tristan-f-r/spras in…
tristan-f-r Nov 10, 2025
3b84e8f
docs: typo?
tristan-f-r Nov 21, 2025
33a85d8
chore: apply suggestions, fix meo param
tristan-f-r Nov 21, 2025
81a16fe
docs: move domino cmt
tristan-f-r Nov 21, 2025
25e8b67
docs: more suggestions
tristan-f-r Nov 21, 2025
dce8e42
docs: more cmts
tristan-f-r Nov 21, 2025
790cab9
docs: add comment to is_numpy_friendly
tristan-f-r Nov 21, 2025
27e6109
docs: fix cmt
tristan-f-r Nov 21, 2025
893b80d
docs: typo
tristan-f-r Dec 6, 2025
630f5c7
docs: grammar
tristan-f-r Dec 6, 2025
3d7cc6d
docs: rephrasing, contributing update
tristan-f-r Dec 6, 2025
22c0120
Merge branch 'config-args' of https://github.com/tristan-f-r/spras in…
tristan-f-r Dec 6, 2025
fe93bd0
docs: clearer pydantic and reflection calls
tristan-f-r Dec 6, 2025
5911e59
fix: pass less objects in runner.py
tristan-f-r Dec 6, 2025
ee41575
docs: better algorithm fail message
tristan-f-r Dec 6, 2025
a5832ee
docs: more PRA#run documentation
tristan-f-r Dec 6, 2025
9fd5b0e
docs: add generate inputs info
tristan-f-r Dec 6, 2025
75c2035
docs: drop unused cmt
tristan-f-r Dec 6, 2025
87bf6f0
Merge branch 'umain' into config-args
tristan-f-r Dec 6, 2025
70175c8
docs(contributing): defer to pathlinker for dockerfile
tristan-f-r Dec 21, 2025
569a49b
docs(oi2): mention weight to cost transformation
tristan-f-r Dec 21, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 6 additions & 11 deletions Snakefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ _config.init_global(config)

out_dir = _config.config.out_dir
algorithm_params = _config.config.algorithm_params
algorithm_directed = _config.config.algorithm_directed
pca_params = _config.config.pca_params
hac_params = _config.config.hac_params
container_settings = _config.config.container_settings
Expand Down Expand Up @@ -273,16 +272,12 @@ rule reconstruct:
run:
# Create a copy so that the updates are not written to the parameters logfile
params = reconstruction_params(wildcards.algorithm, wildcards.params).copy()
# Add the input files
params.update(dict(zip(runner.get_required_inputs(wildcards.algorithm), *{input}, strict=True)))
# Add the output file
# All run functions can accept a relative path to the output file that should be written that is called 'output_file'
params['output_file'] = output.pathway_file
# Remove the default placeholder parameter added for algorithms that have no parameters
if 'spras_placeholder' in params:
params.pop('spras_placeholder')
params['container_settings'] = container_settings
runner.run(wildcards.algorithm, params)
# Declare the input files as a dictionary.
inputs = dict(zip(runner.get_required_inputs(wildcards.algorithm), *{input}, strict=True))
# Remove the _spras_run_name parameter added for keeping track of the run name for parameters.yml
if '_spras_run_name' in params:
params.pop('_spras_run_name')
runner.run(wildcards.algorithm, inputs, output.pathway_file, params, container_settings)

# Original pathway reconstruction output to universal output
# Use PRRunner as a wrapper to call the algorithm-specific parse_output
Expand Down
47 changes: 23 additions & 24 deletions config/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# The length of the hash used to identify a parameter combination
hash_length: 7

# Collection of container options
containers:
# Specify the container framework used by each PRM wrapper. Valid options include:
# - docker (default if not specified)
Expand Down Expand Up @@ -60,23 +61,23 @@ containers:

algorithms:
- name: "pathlinker"
params:
include: true
include: true
runs:
run1:
k: range(100,201,100)

- name: "omicsintegrator1"
params:
include: true
include: true
runs:
run1:
b: [5, 6]
w: np.linspace(0,5,2)
d: 10
dummy_mode: "file" # Or "terminals", "all", "others"

- name: "omicsintegrator2"
params:
include: true
include: true
runs:
run1:
b: 4
g: 0
Expand All @@ -85,52 +86,50 @@ algorithms:
g: 3

- name: "meo"
params:
include: true
include: true
runs:
run1:
max_path_length: 3
local_search: "Yes"
local_search: true
rand_restarts: 10

- name: "mincostflow"
params:
include: true
include: true
runs:
run1:
flow: 1 # The flow must be an int
flow: 1
capacity: 1

- name: "allpairs"
params:
include: true
include: true

- name: "domino"
params:
include: true
include: true
runs:
run1:
slice_threshold: 0.3
module_threshold: 0.05

- name: "strwr"
params:
include: true
include: true
runs:
run1:
alpha: [0.85]
threshold: [100, 200]

- name: "rwr"
params:
include: true
include: true
runs:
run1:
alpha: [0.85]
threshold: [100, 200]

- name: "bowtiebuilder"
params:
include: true
include: true

- name: "responsenet"
params:
include: true
include: true
runs:
run1:
gamma: [10]

Expand Down
108 changes: 41 additions & 67 deletions config/egfr.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# The length of the hash used to identify a parameter combination
hash_length: 7

containers:
Expand Down Expand Up @@ -29,108 +28,83 @@ containers:

algorithms:
- name: pathlinker
params:
include: true
include: true
runs:
run1:
k:
- 10
- 20
- 70
- name: omicsintegrator1
params:
include: true
include: true
runs:
run1:
b:
- 0.55
- 2
- 10
d:
- 10
g:
- 1e-3
r:
- 0.01
w:
- 0.1
mu:
- 0.008
d: 10
g: 1e-3
r: 0.01
w: 0.1
mu: 0.008
dummy_mode: ["file"]
- name: omicsintegrator2
params:
include: true
include: true
runs:
run1:
b:
- 4
g:
- 0
b: 4
g: 0
run2:
b:
- 2
g:
- 3
b: 2
g: 3
- name: meo
params:
include: true
include: true
runs:
run1:
local_search:
- "Yes"
max_path_length:
- 3
rand_restarts:
- 10
local_search: true
max_path_length: 3
rand_restarts: 10
run2:
local_search:
- "No"
max_path_length:
- 2
rand_restarts:
- 10
local_search: false
max_path_length: 2
rand_restarts: 10
- name: allpairs
params:
include: true
include: true
- name: domino
params:
include: true
include: true
runs:
run1:
slice_threshold:
- 0.3
module_threshold:
- 0.05
slice_threshold: 0.3
module_threshold: 0.05
- name: mincostflow
params:
include: true
include: true
runs:
run1:
capacity:
- 15
flow:
- 80
capacity: 15
flow: 80
run2:
capacity:
- 1
flow:
- 6
capacity: 1
flow: 6
run3:
capacity:
- 5
flow:
- 60
capacity: 5
flow: 60
- name: "strwr"
params:
include: true
include: true
runs:
run1:
alpha: [0.85]
threshold: [100, 200]

- name: "rwr"
params:
include: true
include: true
runs:
run1:
alpha: [0.85]
threshold: [100, 200]

- name: "bowtiebuilder"
params:
include: false
include: false
datasets:
- data_dir: input
edge_files:
Expand Down
2 changes: 1 addition & 1 deletion docker-wrappers/SPRAS/example_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ algorithms:
include: true
run1:
max_path_length: [3]
local_search: ["Yes"]
local_search: [true]
rand_restarts: [10]

- name: "mincostflow"
Expand Down
2 changes: 1 addition & 1 deletion docs/_static/config/intermediate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ algorithms:
params:
include: true
run1:
local_search: ["Yes", "No"]
local_search: [true, false]
max_path_length: [2, 3]
rand_restarts: 10
- name: allpairs
Expand Down
4 changes: 3 additions & 1 deletion docs/contributing/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,8 @@ wrapper functions for the Local Neighborhood algorithm. Use
Call the new class within ``local_neighborhood.py``
``LocalNeighborhood`` and set ``__all__`` so the class can be
`imported <https://docs.python.org/3/tutorial/modules.html#importing-from-a-package>`__.
Make sure to specify the type of parameters passed in to ``LocalNeighborhood`` as ``Empty``
(see ``AllPairs`` for an example of this.)
Specify the list of ``required_input`` files to be ``network`` and
``nodes``, and set the ``dois`` property to be an empty list. These
entries are used to tell Snakemake what input files should be present
Expand Down Expand Up @@ -242,7 +244,7 @@ the format ``<vertex1>|<vertex2>``, which also differs from the
``omicsintegrator1.py`` example. ``spras/dataset.py`` provides functions
that provide access to node information and the interactome (edge list).

Implement the ``run`` function, following the PathLinker example. The
Implement the ``run`` function, following the AllPairs example. The
``prepare_volume`` utility function is needed to prepare the network and
nodes input files to be mounted and used inside the container. It is
also used to prepare the path for the output file, which is different
Expand Down
4 changes: 2 additions & 2 deletions docs/prms/meo.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ MEO takes in three optional parameters:

* max_path_length: The maximal path (from any source to any target) lengths to return when orienting the graph (note: paths
may contain duplicate vertices, but never duplicate edges.)
* local_search: a "Yes"/"No" parameter that enables MEO's local search functionality. See "Improving approximations with local search" in
the associated paper for more information. This should almost always be yes.
* local_search: a boolean parameter that enables MEO's local search functionality. See "Improving approximations with local search" in
the associated paper for more information. This should almost always be true.
* rand_restarts: the number (int) of random restarts to use.
21 changes: 7 additions & 14 deletions spras/allpairs.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from pathlib import Path

from spras.config.container_schema import ProcessedContainerSettings
from spras.config.util import Empty
from spras.containers import prepare_volume, run_container_and_log
from spras.dataset import Dataset
from spras.interactome import (
Expand All @@ -15,7 +16,7 @@
__all__ = ['AllPairs']


class AllPairs(PRM):
class AllPairs(PRM[Empty]):
required_inputs = ['nodetypes', 'network', 'directed_flag']
dois = []

Expand Down Expand Up @@ -70,27 +71,19 @@ def generate_inputs(data: Dataset, filename_map):
header=["#Interactor1", "Interactor2", "Weight"])

@staticmethod
def run(nodetypes=None, network=None, directed_flag=None, output_file=None, container_settings=None):
"""
Run All Pairs Shortest Paths with Docker
@param nodetypes: input node types with sources and targets (required)
@param network: input network file (required)
@param container_settings: configure the container runtime
@param output_file: path to the output pathway file (required)
"""
def run(inputs, output_file, args=None, container_settings=None):
if not container_settings: container_settings = ProcessedContainerSettings()
if not nodetypes or not network or not output_file or not directed_flag:
raise ValueError('Required All Pairs Shortest Paths arguments are missing')
AllPairs.validate_required_run_args(inputs)

work_dir = '/apsp'

# Each volume is a tuple (src, dest)
volumes = list()

bind_path, node_file = prepare_volume(nodetypes, work_dir, container_settings)
bind_path, node_file = prepare_volume(inputs["nodetypes"], work_dir, container_settings)
volumes.append(bind_path)

bind_path, network_file = prepare_volume(network, work_dir, container_settings)
bind_path, network_file = prepare_volume(inputs["network"], work_dir, container_settings)
volumes.append(bind_path)

# Create the parent directories for the output file if needed
Expand All @@ -104,7 +97,7 @@ def run(nodetypes=None, network=None, directed_flag=None, output_file=None, cont
'--network', network_file,
'--nodes', node_file,
'--output', mapped_out_file]
if Path(directed_flag).read_text().strip() == "true":
if Path(inputs["directed_flag"]).read_text().strip() == "true":
command.append("--directed")

container_suffix = "allpairs:v4"
Expand Down
Loading
Loading