MHCXGraph.utils.preprocessing¶
- class MHCXGraph.utils.preprocessing.GraphSpec(orig_path, base_name, graph_config, settings, output_path, selection_params)[source]¶
Bases:
objectA deferred subgraph build.
Carries everything needed to materialize one filtered subgraph, but builds nothing until .build() is called. Exposes .path/.name so callers can identify a protein without paying its construction cost.
Indexing mirrors the old (subgraph, path, base_name) tuple after build, so clean_graph_name(spec) and spec[1] keep working unchanged.
- exception MHCXGraph.utils.preprocessing.LogicError[source]¶
Bases:
ExceptionRaised when a logical selection expression cannot be evaluated.
- MHCXGraph.utils.preprocessing.collect_selected_files_from_manifest(manifest)[source]¶
Collect structure files defined in the manifest input rules.
- MHCXGraph.utils.preprocessing.create_graphs(manifest: dict) list[GraphSpec][source]¶
Construct deferred subgraph builders from the manifest input structures.
Rather than building every subgraph up front (which makes resident memory grow linearly with the number of proteins), this returns one GraphSpec per file. Callers decide when to materialize: ‘multiple’ builds all of them, ‘pairwise’/’screening’ build one or two at a time.
- MHCXGraph.utils.preprocessing.get_exposed_residues(graph: Graph, rsa_filter: float, asa_filter: float, selection_params=None) Graph[source]¶
Generate a filtered subgraph containing exposed residues.
The function creates a residue subgraph based on solvent exposure criteria and optional structural or logical filters defined in the manifest.
- Parameters:
graph (Graph) – Graph representation of the protein structure.
rsa_filter (float) – Relative solvent accessibility threshold.
asa_filter (float) – Absolute solvent accessibility threshold.
selection_params (dict[str, Any], optional) – Additional selection constraints such as chains, residues, secondary structure elements, or logical expressions.
- Returns:
subgraph – Filtered graph containing the selected residues.
- Return type:
networkx.Graph
- Raises:
Exception – If no residues satisfy the filtering conditions.
- MHCXGraph.utils.preprocessing.list_struct_files(folder: Path, extensions: list[str]) list[Path][source]¶
Recursively list structure files inside a directory.
- Parameters:
folder (pathlib.Path) – Root directory to search.
- Returns:
files – Sorted list of structure file paths.
- Return type:
- MHCXGraph.utils.preprocessing.resolve_selection_params_for_file(file_path: Path, manifest: dict[str, Any]) dict[str, Any][source]¶
Resolve selection parameters for a specific input file.
- Parameters:
file_path (pathlib.Path) – Path to the structure file.
- Returns:
params – Combined selector parameters applied to the file.
- Return type:
Classes¶
|
A deferred subgraph build. |
Functions¶
|
Collect structure files defined in the manifest input rules. |
|
Construct deferred subgraph builders from the manifest input structures. |
|
Generate a filtered subgraph containing exposed residues. |
|
Recursively list structure files inside a directory. |
|
Resolve selection parameters for a specific input file. |
Exceptions¶
Raised when a logical selection expression cannot be evaluated. |