Skip to content

get_xyz_pdb_jsonizsed_from_sdf

esta.lib_xyz.get_xyz_pdb_jsonizsed_from_sdf

SDF Converter Class

Converts SDF molecular structure data into:

  1. XYZ file
  2. PDB file
  3. JSON storage of XYZ coordinates
Features:
  • Parses atomic coordinates
  • Extracts atom labels
  • Supports simple SDF V2000 files
  • Beginner-friendly
  • Suitable for PubChem structures

SDFConverter

A class for converting SDF molecular files into: - XYZ - PDB - JSON

__init__(sdf_input: str, is_file: bool = True)

Initialize the SDFConverter with either:

Parameters: sdf_input (str): - Raw SDF text content OR - Path to SDF file

is_file (bool):
    - False → sdf_input is treated as raw SDF text
    - True  → sdf_input is treated as file path

Example: # Raw SDF data converter = SDFConverter(raw_sdf_string)

# From SDF file
converter = SDFConverter("HCl.sdf", is_file=True)

to_xyz() -> str

Returns XYZ format string.

read_sdf_file(file_path: str) -> str

Reads an SDF file and returns its full text content.

Parameters: file_path (str): Path to the SDF file

Returns: str: Raw SDF file content

to_pdb() -> str

Returns PDB format string.

to_json() -> str

Returns JSON string of molecular coordinates.