MHCXGraph.utils.preprocessing

exception MHCXGraph.utils.preprocessing.LogicError[source]

Bases: Exception

Raised 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.

Parameters:

manifest (dict) – Manifest configuration dictionary.

Returns:

selected_files – List of dictionaries describing selected input files.

Return type:

list[dict]

MHCXGraph.utils.preprocessing.create_graphs(manifest: dict) list[tuple][source]

Construct filtered graphs from the manifest input structures.

The function loads structure files, builds graph representations, applies residue selection filters, and stores intermediate outputs.

Parameters:

manifest (dict) – Manifest configuration dictionary containing runtime settings and input selection rules.

Returns:

graphs – List of tuples containing the filtered graph, original file path, and base structure name.

Return type:

list[tuple]

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.

  • extensions (list[str]) – Allowed file extensions.

Returns:

files – Sorted list of structure file paths.

Return type:

list[pathlib.Path]

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.

  • manifest (dict[str, Any]) – Manifest configuration.

Returns:

params – Combined selector parameters applied to the file.

Return type:

dict[str, Any]

Functions

collect_selected_files_from_manifest(manifest)

Collect structure files defined in the manifest input rules.

create_graphs(manifest)

Construct filtered graphs from the manifest input structures.

get_exposed_residues(graph, rsa_filter, ...)

Generate a filtered subgraph containing exposed residues.

list_struct_files(folder, extensions)

Recursively list structure files inside a directory.

resolve_selection_params_for_file(file_path, ...)

Resolve selection parameters for a specific input file.

Exceptions

LogicError

Raised when a logical selection expression cannot be evaluated.