Skip to content

Commit b7f0b7b

Browse files
committed
Adding docstings to most important functions
1 parent 42f0930 commit b7f0b7b

6 files changed

Lines changed: 1069 additions & 127 deletions

File tree

MHCXGraph/app.py

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,28 @@
1111

1212

1313
def setup_trackers(output_dir, settings):
14+
"""
15+
Initialize runtime tracking utilities.
16+
17+
This function configures the global tracking system used to store
18+
intermediate artifacts produced during execution and optionally
19+
creates a :class:`ResidueTracker` to monitor selected residues.
20+
21+
Parameters
22+
----------
23+
output_dir : pathlib.Path
24+
Directory where tracking artifacts and debug files will be stored.
25+
26+
settings : dict[str, Any]
27+
Runtime configuration dictionary loaded from the manifest.
28+
Relevant keys include ``watch_residues`` and ``debug_tracking``.
29+
30+
Returns
31+
-------
32+
tracker_residues : ResidueTracker or None
33+
Residue tracker instance if residue monitoring is enabled,
34+
otherwise ``None``.
35+
"""
1436
tracker_residues = (
1537
ResidueTracker(settings.get("watch_residues"))
1638
) if settings.get("watch_residues") else None
@@ -27,6 +49,34 @@ def setup_trackers(output_dir, settings):
2749

2850

2951
def run_all_mode(graphs, base_output, run_name, config, log):
52+
"""
53+
Execute the association workflow in all-graphs mode.
54+
55+
In this mode all graphs are processed together in a single
56+
association task.
57+
58+
Parameters
59+
----------
60+
graphs : list
61+
Collection of graph objects produced by the preprocessing stage.
62+
63+
base_output : pathlib.Path
64+
Base directory where output results are written.
65+
66+
run_name : str
67+
Identifier for the current execution run.
68+
69+
config : dict[str, Any]
70+
Association configuration dictionary controlling the
71+
graph association algorithm.
72+
73+
log : logging.Logger
74+
Logger instance used to record runtime messages.
75+
76+
Returns
77+
-------
78+
None
79+
"""
3080
target_dir = base_output / "ALL"
3181

3282
run_association_task(
@@ -45,6 +95,34 @@ def clean_graph_name(graph):
4595

4696

4797
def run_pair_mode(graphs, base_output, run_name, config, log):
98+
"""
99+
Execute the association workflow in pairwise mode.
100+
101+
Each unique pair of graphs is processed independently and
102+
written to a dedicated output directory.
103+
104+
Parameters
105+
----------
106+
graphs : list
107+
Collection of graph objects produced by preprocessing.
108+
109+
base_output : pathlib.Path
110+
Root directory where pairwise comparison results will be saved.
111+
112+
run_name : str
113+
Base identifier for the run.
114+
115+
config : dict[str, Any]
116+
Association configuration dictionary controlling the
117+
graph association algorithm.
118+
119+
log : logging.Logger
120+
Logger instance used to record runtime messages.
121+
122+
Returns
123+
-------
124+
None
125+
"""
48126
pair_base_dir = base_output / "PAIR"
49127

50128
for g1, g2 in combinations(graphs, 2):
@@ -64,6 +142,34 @@ def run_pair_mode(graphs, base_output, run_name, config, log):
64142

65143

66144
def main():
145+
"""
146+
Run the MHCXGraph command-line pipeline.
147+
148+
This function orchestrates the full workflow:
149+
150+
1. Parse command-line arguments.
151+
2. Load the execution manifest.
152+
3. Configure logging and runtime tracking.
153+
4. Generate graph representations from input structures.
154+
5. Execute the association workflow.
155+
156+
The workflow can operate in two modes defined in the manifest:
157+
158+
``all``
159+
Process all graphs together in a single association task.
160+
161+
``pair``
162+
Perform pairwise comparisons between all graph combinations.
163+
164+
Returns
165+
-------
166+
None
167+
168+
Raises
169+
------
170+
ValueError
171+
If the configured ``run_mode`` is not ``"all"`` or ``"pair"``.
172+
"""
67173
args = parse_args()
68174
manifest = load_manifest(args.manifest)
69175
settings = manifest["settings"]

0 commit comments

Comments
 (0)