Skip to content

Io

Robust, memory-efficient SMILES string handling library.

Provides unified streaming interface for processing SMILES from various sources with comprehensive error handling, validation, and memory optimization.

SMILESProcessor(validate_smiles=True, skip_invalid=True, max_length=10000, chunk_size=1000)

Memory-efficient SMILES string processor with robust error handling.

Handles various input formats and provides streaming interface for processing large datasets without memory overflow.

Initialize SMILES processor.

PARAMETER DESCRIPTION
validate_smiles

Whether to validate SMILES syntax

TYPE: bool DEFAULT: True

skip_invalid

Skip invalid SMILES instead of raising errors

TYPE: bool DEFAULT: True

max_length

Maximum allowed SMILES length (None for no limit)

TYPE: int | None DEFAULT: 10000

chunk_size

Batch size for processing operations

TYPE: int DEFAULT: 1000

chunk_size = chunk_size

max_length = max_length

skip_invalid = skip_invalid

validate_smiles = validate_smiles

get_stats()

Get processing statistics.

stream(input_data)

Stream SMILES records from various input types.

PARAMETER DESCRIPTION
input_data

File path, single SMILES, or iterable of SMILES

TYPE: str | Iterable[str] | Iterator[str]

YIELDS DESCRIPTION
SMILESRecord

Validated SMILES records with metadata

TYPE:: SMILESRecord

RAISES DESCRIPTION
SMILESStreamError

If input cannot be processed

stream_batches(input_data, batch_size=None)

Stream SMILES records in batches for efficient processing.

PARAMETER DESCRIPTION
input_data

Input source

TYPE: str | Iterable[str]

batch_size

Size of each batch (uses instance default if None)

TYPE: int | None DEFAULT: None

YIELDS DESCRIPTION
list[SMILESRecord]

Batches of SMILES records

SMILESRecord(smiles, identifier='', source_line=None, metadata=dict())

Container for a SMILES string with metadata.

identifier = ''

metadata = field(default_factory=dict)

smiles

source_line = None

SMILESStreamError

Bases: Exception

Raised when streaming encounters an error.

SMILESValidationError

Bases: Exception

Raised when SMILES validation fails.

process_smiles_file(filepath, **kwargs)

Convenience function for processing SMILES files.

stream_smiles(input_data, **kwargs)

Convenience function for streaming SMILES.