rush.convert

Conversion utilities for molecular structure file formats.

This module provides functions to convert between PDB, mmCIF, SDF, and QDX’s TRC JSON formats.

rush.convert.from_json(json_content)[source]

Load TRC structures from JSON.

Parameters:

json_content (str | Path | tuple[str | Path, str | Path, str | Path] | dict | list[dict] | tuple[Path, ...]) – JSON string content

Returns:

TRC structure or list of TRC structures

Return type:

TRC | list[TRC]

rush.convert.from_mmcif(mmcif_content)[source]

Parse mmCIF file contents into TRC structures.

Parameters:

mmcif_content (str) – String contents of an mmCIF file

Returns:

TRC structure or list of TRC structures

Return type:

TRC | list[TRC]

rush.convert.from_pdb(pdb_content)[source]

Parse PDB file content into TRC structures.

Parameters:

pdb_content (str) – String content of a PDB file

Returns:

TRC structure or list of TRC structures (one per model in multi-model files)

Return type:

TRC | list[TRC]

rush.convert.from_sdf(sdf_content)[source]

Parse SDF file contents into TRC structures.

Parameters:

sdf_content (str) – SDF file content as string

Returns:

TRC structure or list of TRC structures (one per molecule in the SDF file)

Raises:

ValueError – If SDF parsing fails

Return type:

TRC | list[TRC]

rush.convert.load_structure(file_path)[source]

Load structure from PDB, mmCIF, or JSON file.

Parameters:

file_path (str | Path) – Path to structure file

Returns:

TRC structure or list of TRC structures

Return type:

TRC | list[TRC]

rush.convert.merge_trcs(*trcs, output_file=None, skip_validation=False)[source]

Merge TRC objects into a single TRC.

A TRC (Topology-Residues-Chains) object contains: - topology: atom information (symbols, geometry, bonds, charges, etc.) - residues: residue information (which atoms belong to which residues) - chains: chain information (which residues belong to which chains)

When merging, atom indices, residue indices, and chain indices are renumbered to ensure uniqueness in the merged structure.

Parameters:
  • trcs (TRC | str | Path | list[TRC | str | Path] | tuple[TRC | str | Path, ...]) – TRC objects or file paths. If a single list/tuple is provided, it is treated as the full set of inputs.

  • output_file (str | Path | None) – Optional path to write the merged TRC JSON.

  • skip_validation (bool) – If True, skip validation of the merged TRC.

Returns:

Merged TRC object.

Raises:
  • ValueError – If no inputs are provided or validation fails.

  • FileNotFoundError – If file paths are provided but files don’t exist.

Return type:

TRC

rush.convert.save_structure(trcs, file_path, format=None)[source]

Save TRC structures to file.

Parameters:
  • trcs (TRC | list[TRC]) – TRC structure or list of TRC structures

  • file_path (str | Path) – Output file path

  • format (str | None) – Output format (‘pdb’, ‘json’, or None for auto-detect from extension)

rush.convert.to_json(trcs)[source]

Convert TRC structures to JSON.

Parameters:

trcs (TRC | list[TRC]) – TRC structure or list of TRC structures

Returns:

JSON-compatible dict or list of dicts

Return type:

dict[str, object] | list[dict[str, object]]

rush.convert.to_pdb(trc)[source]

Convert TRC structure to PDB format string.

Parameters:

trc (TRC) – TRC structure to convert

Returns:

PDB format string

Return type:

str