neurosnap.chemistry package#

Public chemistry package exports.

class neurosnap.chemistry.CharacterizationReport(diversity, network, islands, frontier=<factory>, counts=<factory>, metadata=<factory>)[source]#

Bases: object

Everything the engine can say about a library.

counts: dict#
diversity: DiversityMetrics#
frontier: list#
islands: IslandResult#
metadata: dict#
network: NetworkMetrics#
summary()[source]#

Human-readable answer to ‘does this library contain real diversity?’

Return type:

str

to_dict()[source]#
Return type:

dict

class neurosnap.chemistry.ChemicalGraph(node_type, smiles, compound_id, level, frequency, n_atoms, n_rings, mw, method, murcko, src, dst, edge_type, weight)[source]#

Bases: object

Column-store heterogeneous chemical graph.

Nodes: compounds, scaffolds, fragments. Edges: compound-scaffold, compound-fragment, similarity, scaffold hierarchy, fragment sharing. Flat NumPy arrays plus a cached SciPy CSR adjacency for graph algorithms.

adjacency(edge_types=None)[source]#

Unweighted undirected CSR adjacency, optionally restricted to types.

Return type:

csr_matrix

average_path_length(sources)[source]#

Average shortest-path length estimated from BFS trees of sources.

connected_components(edge_types=None)[source]#
Return type:

ndarray

count_edges(edge_type)[source]#
Return type:

int

count_nodes(node_type)[source]#
Return type:

int

degrees(edge_types=None)[source]#
Return type:

ndarray

edges_of_type(edge_type)[source]#
Return type:

ndarray

classmethod from_dict(data)[source]#
Return type:

ChemicalGraph

label(node)[source]#
Return type:

str

property n_edges: int#
property n_nodes: int#
neighborhood(node, radius=1, edge_types=None)[source]#
Return type:

ndarray

neighbors(node, edge_types=None)[source]#
Return type:

ndarray

node_id_of_compound(compound_id)[source]#
Return type:

int

node_id_of_smiles(smiles, node_type)[source]#
Return type:

int

nodes_of_type(node_type)[source]#
Return type:

ndarray

pagerank(damping=0.85, n_iter=100, tol=1e-08, edge_types=None)[source]#
Return type:

ndarray

shortest_path(source, target, edge_types=None)[source]#

One shortest hop path source -> target (empty if none).

Return type:

ndarray

to_dict()[source]#
Return type:

dict

weighted_adjacency(edge_types=None)[source]#

Undirected CSR with edge weights (used by community detection).

Return type:

csr_matrix

class neurosnap.chemistry.ChemicalLandscape(source=None, smiles_column='smiles', id_column=None, config=None, *, compound_ids=None, **overrides)[source]#

Bases: object

A molecular library and the chemical landscape built from it.

The source may be a path or an in-memory SMILES sequence:

landscape = ChemicalLandscape(“library.csv”, smiles_column=”smiles”) landscape.build_all() report = landscape.characterize() print(report.summary()) landscape.save(“out/”) reloaded = ChemicalLandscape.from_store(“out/”)

Parameters:
  • source (Union[str, Path, Sequence[str], None]) – Input path or in-memory SMILES sequence.

  • smiles_column (str) – SMILES column for delimited input files.

  • id_column (Optional[str]) – Optional compound identifier column.

  • config (Optional[LandscapeConfig]) – Optional complete landscape configuration.

  • compound_ids (Optional[Sequence[str]]) – IDs corresponding to an in-memory SMILES sequence.

  • **overrides (Any) – Configuration field overrides.

build_all()[source]#

Run every stage.

Return type:

ChemicalLandscape

build_fragments()[source]#

Fragment every compound (BRICS, rotatable bonds, linkers).

When FragmentConfig.reversible is enabled, each compound also keeps a ReverseFragmentRecord (attachment points + cut orders) so it can be rebuilt with reassemble().

Return type:

ChemicalLandscape

build_scaffolds()[source]#

Annotate Bemis-Murcko scaffolds and build the scaffold network.

Return type:

ChemicalLandscape

build_similarity_graph()[source]#

Build the sparse compound-compound similarity graph.

Return type:

ChemicalLandscape

characterize(n_samples=512, seed=0, resolution=1.0)[source]#

Run the full characterization and cache the report.

Return type:

CharacterizationReport

common_cores(n=10)[source]#

Return the most frequently shared scaffold SMILES.

Parameters:

n (int) – Maximum number of scaffold SMILES.

Return type:

list[str]

Returns:

Scaffold SMILES ordered by support.

property compound_ids: list[str]#

Canonical compound identifiers in library order.

decompose(core_smiles=None, *, params=None)[source]#

Decompose the library into a core + per-position R-groups.

If core_smiles is omitted, the most frequent scaffold is used.

Parameters:
  • core_smiles (Optional[str]) – Optional labeled or unlabeled core SMILES.

  • params (Any) – Optional RDKit R-group decomposition parameters.

Return type:

RGroupDecompositionResult

Returns:

Per-molecule R-group decomposition.

enumerate(core_smiles, rgroups_by_label, *, max_products=100000)[source]#

Enumerate all products of a labeled core with R-groups per position.

rgroups_by_label maps an attachment label to a list of R-group SMILES (each carrying a matching labeled dummy, e.g. CO[*:1]).

Parameters:
  • core_smiles (str) – Labeled core SMILES.

  • rgroups_by_label (Mapping[int, Sequence[str]]) – R-group choices keyed by attachment label.

  • max_products (int) – Maximum products to return.

Return type:

list[str]

Returns:

Enumerated product SMILES.

export_graphml(path, **kwargs)[source]#

Export the assembled graph as GraphML.

Return type:

Path

export_json(path, **kwargs)[source]#

Export the assembled graph as node-link JSON.

Return type:

Path

property failures: list[tuple[str, str]]#

(compound_id, smiles) pairs RDKit could not parse.

property fingerprints: FingerprintBlock | None#

Packed Morgan fingerprints, if the library has been loaded.

classmethod from_store(path)[source]#

Load a previously persisted landscape.

Parameters:

path (Union[str, Path]) – Landscape directory created by save().

Return type:

ChemicalLandscape

Returns:

Restored ChemicalLandscape instance.

property graph: ChemicalGraph#

The heterogeneous chemical graph (assembled on first access).

island_of(compound_id)[source]#

Island id of a compound (-1 if it was not part of the analysis).

Return type:

int

load()[source]#

Parse the input, canonicalize SMILES and build fingerprints.

Return type:

ChemicalLandscape

neighbors(compound_id, edge_types=None)[source]#

Return labels of the direct neighbours of a compound.

Parameters:
Return type:

list[str]

Returns:

Labels of directly connected nodes.

node_of(compound_id)[source]#

Return the graph node ID for a compound identifier.

Return type:

int

path_between(compound_a, compound_b)[source]#

Return a traversal path between two compounds.

Parameters:
  • compound_a (str) – First compound identifier.

  • compound_b (str) – Second compound identifier.

Return type:

list[str]

Returns:

Labels along the shortest graph path.

plot(outdir)[source]#

Write the scaffold map, island plot, and diversity report.

Parameters:

outdir (Union[str, Path]) – Destination directory for the three image files.

Return type:

list[Path]

Returns:

Paths to the generated image files.

reassemble(compound_id)[source]#

Rebuild a compound’s canonical SMILES from its fragments.

Uses the reversible fragment record (attachment points + cut orders) captured during build_fragments(). Returns "" if the compound was not fragmented reversibly.

Return type:

str

property report: CharacterizationReport#

Return the cached characterization report, building it if needed.

rgroups_at(compound_id, core_smiles=None)[source]#

Return one compound’s R-groups for a core.

Parameters:
  • compound_id (str) – Compound identifier to decompose.

  • core_smiles (Optional[str]) – Optional labeled or unlabeled core SMILES.

Return type:

dict[str, str]

Returns:

Mapping of R-group labels to SMILES.

save(path)[source]#

Persist the landscape as JSON plus an optional NPZ fingerprint store.

Return type:

Path

property smiles: list[str]#

Canonical SMILES in library order.

swap_rgroup(compound_id, position, new_rgroup, core_smiles=None)[source]#

Replace an R-group at position and return the new molecule.

new_rgroup should carry a dummy labeled for position (e.g. CO[*:1] for position 1). The compound is decomposed against a core, the labelled position is substituted, and the product is reassembled with the other R-groups left in place.

Return type:

str

class neurosnap.chemistry.EdgeType(*values)[source]#

Bases: IntEnum

Edge types of the heterogeneous chemical graph.

COMPOUND_FRAGMENT = 2#
COMPOUND_SCAFFOLD = 1#
COMPOUND_SIMILARITY = 3#
FRAGMENT_SHARED = 5#
SCAFFOLD_HIERARCHY = 4#
class neurosnap.chemistry.FingerprintConfig(radii=(2, 3), n_bits=2048, use_chirality=False, use_features=False)[source]#

Bases: object

Morgan fingerprint settings.

radii may hold several radii; bits of all radii are OR-ed into one packed vector, which keeps one fingerprint per compound while still covering multiple resolutions (radius 2 and 3 by default).

n_bits: int = 2048#
property n_words: int#
radii: tuple = (2, 3)#
use_chirality: bool = False#
use_features: bool = False#
class neurosnap.chemistry.FragmentConfig(use_brics=True, use_rotatable_bonds=True, use_linkers=True, min_fragment_atoms=3, max_fragments_per_molecule=32, max_rotatable_cuts=8, shared_links_per_fragment=4, reversible=True)[source]#

Bases: object

Fragmentation settings, in priority order.

max_fragments_per_molecule: int = 32#
max_rotatable_cuts: int = 8#
min_fragment_atoms: int = 3#
reversible: bool = True#
use_brics: bool = True#
use_linkers: bool = True#
use_rotatable_bonds: bool = True#
class neurosnap.chemistry.FragmentMethod(*values)[source]#

Bases: IntEnum

Provenance of a fragment node.

BRICS = 1#
LINKER = 3#
ROTATABLE_BOND = 2#
UNKNOWN = 0#
class neurosnap.chemistry.LandscapeConfig(smiles_column='smiles', id_column=None, delimiter=None, chunk_size=20000, workers=1, limit=None, fingerprints=<factory>, scaffolds=<factory>, fragments=<factory>, similarity=<factory>)[source]#

Bases: object

Top-level build settings.

chunk_size: int = 20000#
delimiter: Optional[str] = None#
fingerprints: FingerprintConfig#
fragments: FragmentConfig#
classmethod from_dict(data)[source]#
Return type:

LandscapeConfig

id_column: Optional[str] = None#
limit: Optional[int] = None#
scaffolds: ScaffoldConfig#
similarity: SimilarityConfig#
smiles_column: str = 'smiles'#
to_dict()[source]#
Return type:

dict

workers: int = 1#
class neurosnap.chemistry.NodeType(*values)[source]#

Bases: IntEnum

Node types of the heterogeneous chemical graph.

COMPOUND = 0#
FRAGMENT = 2#
SCAFFOLD = 1#
class neurosnap.chemistry.RGroupDecompositionResult(core_smiles='', rows=<factory>, n_failed=0)[source]#

Bases: object

A library decomposed into a core plus per-position R-groups.

rows is a list of per-molecule dicts keyed by R-group label ('Core', 'R1', 'R2', …) mapping to the group SMILES.

core_smiles: str = ''#
n_failed: int = 0#
property positions#

Sorted integer attachment labels present (excluding the core).

rows: list#
to_dict()[source]#
Return type:

dict

class neurosnap.chemistry.ReverseFragmentRecord(pieces=None, cut_orders=None, methods=None)[source]#

Bases: object

A compound’s fragments kept with their attachment points so the molecule can be rebuilt.

Cutting a set of bonds produces pieces whose cut ends are capped with dummy atoms carrying a unique cut-id isotope. pieces stores those reactive SMILES; cut_orders[k] is the bond order of the cut that produced the k-th isotope pair. Reassembly matches the two dummies of each cut id and reconnects their neighbours with the recorded bond order.

classmethod from_dict(data)[source]#
Return type:

ReverseFragmentRecord

property n_cuts: int#
to_dict()[source]#
Return type:

dict

class neurosnap.chemistry.ScaffoldConfig(max_level=6, include_generic=False, flatten_chirality=True, keep_only_first_fragment=True, strip_attachments=True, max_nodes_per_molecule=64)[source]#

Bases: object

Scaffold network settings (Bemis-Murcko is only the entry point).

flatten_chirality: bool = True#
include_generic: bool = False#
keep_only_first_fragment: bool = True#
max_level: int = 6#
max_nodes_per_molecule: int = 64#
strip_attachments: bool = True#
class neurosnap.chemistry.SimilarityConfig(threshold=0.55, k=8, n_permutations=128, n_bands=32, bucket_cap=64, max_candidate_pairs=20000000, mutual_only=False, seed=12648430, metric='tanimoto', exact_below=2000)[source]#

Bases: object

Sparse similarity graph settings (never all-vs-all above a size cap).

bucket_cap: int = 64#
exact_below: int = 2000#
k: int = 8#
max_candidate_pairs: int = 20000000#
metric: str = 'tanimoto'#
mutual_only: bool = False#
n_bands: int = 32#
n_permutations: int = 128#
seed: int = 12648430#
threshold: float = 0.55#
neurosnap.chemistry.align_molecule_to_reference(mol, ref_mol)[source]#

Aligns a molecule to a reference molecule and returns the aligned copy.

The alignment is performed using RDKit’s coordinate-based molecular alignment routine. The input molecule is copied before alignment, so the original object remains unchanged.

Parameters:
  • mol (Chem.Mol) – Molecule to align, with at least one conformer.

  • ref_mol (Chem.Mol) – Reference molecule defining the target orientation.

Returns:

A copy of mol aligned to ref_mol.

Return type:

Chem.Mol

Raises:

ValueError – If either molecule is None or lacks conformers.

neurosnap.chemistry.attach_rgroup(core_smiles, rgroup_smiles, label)[source]#

Connect an R-group onto a core at the labeled attachment point.

Both the core and the R-group carry a matching labeled dummy (isotope or map-number form). The two dummies are removed and a single bond joins their neighbours. Returns the product SMILES (still carrying any other labels).

Parameters:
  • core_smiles (str) – Core containing the labeled attachment point.

  • rgroup_smiles (str) – R-group containing the matching label.

  • label (int) – Attachment-point label.

Return type:

str

Returns:

Product SMILES, or "" if the attachment is invalid.

neurosnap.chemistry.calculate_distance_matrix(mol)[source]#

Calculates the pairwise 3D distance matrix for a molecule.

Distances are computed from the atomic coordinates stored in the molecule’s active conformer. The returned matrix is square with one row and column per atom.

Parameters:

mol (Chem.Mol) – Input RDKit molecule with at least one conformer.

Returns:

A square NumPy array of shape (n_atoms, n_atoms)

containing pairwise Euclidean distances in Angstroms.

Return type:

np.ndarray

Raises:

ValueError – If the input molecule is None or has no conformers.

neurosnap.chemistry.calculate_rmsd(mol_a, mol_b)[source]#

Calculates the best-fit RMSD between two molecules.

This function uses RDKit’s alignment-based RMSD calculation, meaning the molecules are optimally superimposed before the RMSD value is reported. As a result, pure rigid-body translations and rotations do not by themselves increase the returned RMSD.

Parameters:
  • mol_a (Chem.Mol) – First RDKit molecule with at least one conformer.

  • mol_b (Chem.Mol) – Second RDKit molecule with at least one conformer.

Returns:

Best-fit root-mean-square deviation between the two molecules.

Return type:

float

Raises:

ValueError – If either molecule is None or lacks conformers.

neurosnap.chemistry.canonicalize_smiles(smiles)[source]#

Converts a SMILES string into its canonical RDKit representation.

This is useful for normalizing equivalent SMILES strings into a stable text form for storage, comparison, or deduplication.

Parameters:

smiles (str) – Input SMILES string to canonicalize.

Returns:

Canonical SMILES string produced by RDKit.

Return type:

str

Raises:

ValueError – If the input string cannot be parsed as a valid SMILES.

neurosnap.chemistry.decompose_molecules(mol_smiles, core_smiles, *, params=None)[source]#

Decompose a set of molecules into a core + R-groups (R-group linkage).

core_smiles may be labeled ([*:1], [*:2], …) or unlabeled; an unlabeled core is matched and its attachment points detected automatically.

Parameters:
  • mol_smiles (Sequence[str]) – Molecules to decompose.

  • core_smiles (str) – Labeled or unlabeled core SMILES.

  • params (Any) – Optional RDKit R-group decomposition parameters.

Return type:

RGroupDecompositionResult

Returns:

Decomposition rows and the matched core SMILES.

neurosnap.chemistry.enumerate_core(core_smiles, rgroups_by_label, *, max_products=100000, dedupe=True)[source]#

Enumerate all products of a labeled core with lists of R-groups per label.

rgroups_by_label maps an attachment label to a list of R-group SMILES (each carrying a matching dummy). Returns the cartesian product as SMILES.

Parameters:
  • core_smiles (str) – Core containing labeled attachment points.

  • rgroups_by_label (Mapping[int, Sequence[str]]) – R-group choices keyed by attachment label.

  • max_products (int) – Maximum number of products to return.

  • dedupe (bool) – Whether to remove duplicate canonical products.

Return type:

list[str]

Returns:

Enumerated product SMILES.

neurosnap.chemistry.find_LCS(mol)[source]#

Find the largest common substructure (LCS) between a set of conformers and aligns all conformers to the LCS.

Parameters:

mol (Mol) – Input RDkit molecule object, must already have conformers present

Return type:

Mol

Returns:

Resultant molecule object with all conformers aligned to the LCS

Raises:

Exception – if no LCS is detected

neurosnap.chemistry.generate(input_mol, output_name='unique_conformers', write_multi=False, num_confs=1000, min_method='auto', max_atoms=500)[source]#

Generate conformers for an input molecule.

Performs the following actions in order: 1. Generate conformers using ETKDG method 2. Minimize energy of all conformers and remove those below a dynamic threshold 3. Align & create RMSD matrix of all conformers 4. Clusters using Butina method to remove structurally redundant conformers 5. Return most energetically favorable conformers in each cluster

Parameters:
  • input_mol (Any) – Input molecule can be a path to a molecule file, a SMILES string, or an instance of rdkit.Chem.rdchem.Mol

  • output_name (str) – Output to write SDF files of passing conformers

  • write_multi (bool) – If True will write all unique conformers to a single SDF file, if False will write all unique conformers in separate SDF files in output_name

  • num_confs (int) – Number of conformers to generate

  • min_method (Optional[str]) – Method for minimization, can be either “auto”, “UFF”, “MMFF94”, “MMFF94s”, or None for no minimization

  • max_atoms (int) – Maximum number of atoms allowed for the input molecule

Return type:

DataFrame

Returns:

A dataframe with all conformer statistics. Note if energy minimization is disabled or fails then energy column will consist of None values.

neurosnap.chemistry.get_mol_center(mol, use_mass=False)[source]#

Computes the geometric center or center of mass of a molecule.

Parameters:
  • mol (Mol) – An RDKit molecule object with 3D coordinates.

  • use_mass (bool, optional) – If True, computes the center of mass using atomic masses. If False, computes the simple geometric center. Defaults to False.

Returns:

A NumPy array of shape (3,) representing the [x, y, z] center coordinates.

Returns None if the molecule has no conformers.

Return type:

np.ndarray

Raises:

ValueError – If no conformer is found in the molecule.

neurosnap.chemistry.largest_fragment(mol)[source]#

Selects the largest fragment from a multi-component molecule.

This is typically useful for salts, mixtures, or counterion-containing inputs where only the primary chemical component should be retained.

Parameters:

mol (Chem.Mol) – Input RDKit molecule, which may contain multiple fragments.

Returns:

A copy containing only the largest fragment.

Return type:

Chem.Mol

Raises:

ValueError – If the input molecule is None.

neurosnap.chemistry.minimize(mol, method='MMFF94', percentile=100.0)[source]#

Minimize conformer energy (kcal/mol) using RDkit and filter out conformers based on energy percentile.

Parameters:
  • mol (Mol) – RDkit mol object containing the conformers you want to minimize. (rdkit.Chem.rdchem.Mol)

  • method (str) – Can be either UFF, MMFF94, or MMFF94s (str)

  • percentile (float) – Filters out conformers above a given energy percentile (0 to 100). For example, 10.0 will retain conformers within the lowest 10% energy. (float)

Return type:

Tuple[float, Dict[int, float]]

Returns:

A tuple of the form (mol_filtered, energies) - mol_filtered: Molecule object with filtered conformers. - energies: Dictionary where keys are conformer IDs and values are calculated energies in kcal/mol.

neurosnap.chemistry.move_ligand_to_center(ligand_sdf_path, receptor_pdb_path, output_sdf_path, use_mass=False)[source]#

Moves the center of a ligand in an SDF file to match the center of a receptor in a PDB file.

This function reads a ligand from an SDF file and a receptor from a PDB file, calculates their respective centers (center of mass or geometric center), and translates the ligand such that its center aligns with the receptor’s center. The modified ligand is then saved to a new SDF file.

Parameters:
  • ligand_sdf_path (str) – Path to the input ligand SDF file.

  • receptor_pdb_path (str) – Path to the input receptor PDB file.

  • output_sdf_path (str) – Path where the adjusted ligand SDF will be saved.

  • use_mass (bool, optional) – If True, compute center of mass; otherwise use geometric center. Defaults to False.

Returns:

Path to the output SDF file with the translated ligand.

Return type:

str

Raises:

ValueError – If the ligand cannot be parsed from the input SDF file.

neurosnap.chemistry.neutralize_molecule(mol)[source]#

Neutralizes formal charges in a molecule where chemically supported.

This function uses RDKit’s uncharging logic to neutralize ionized atoms when a valid neutral form can be produced. Charges that cannot be safely neutralized are preserved.

Parameters:

mol (Chem.Mol) – Input RDKit molecule to neutralize.

Returns:

A copy of the molecule with reducible charges neutralized.

Return type:

Chem.Mol

Raises:

ValueError – If the input molecule is None.

neurosnap.chemistry.reassemble_fragments(pieces, cut_orders)[source]#

Join reactive fragment pieces back into the original molecule.

Two dummies sharing a cut-id isotope are reconnected with the recorded bond order, then all dummies are removed and the result is sanitized.

Parameters:
  • pieces (Sequence[str]) – Reactive fragment SMILES.

  • cut_orders (Sequence[int]) – Original bond-order values, indexed by cut isotope.

Return type:

str

Returns:

The reassembled canonical SMILES, or "" if reassembly fails.

neurosnap.chemistry.remove_salts(mol)[source]#

Removes common salt fragments while retaining the main molecular component.

The function first strips recognized salts and small counterions using RDKit’s salt remover, then selects the largest remaining fragment to produce a single primary molecule.

Parameters:

mol (Chem.Mol) – Input RDKit molecule that may contain salts or counterions.

Returns:

A desalted copy of the molecule.

Return type:

Chem.Mol

Raises:

ValueError – If the input molecule is None.

neurosnap.chemistry.reversible_fragment_record(smiles, cfg=None)[source]#

Fragment a molecule reversibly.

Parameters:
  • smiles (Union[str, Mol]) – SMILES string or RDKit molecule to fragment.

  • cfg (Optional[FragmentConfig]) – Optional fragmentation settings.

Return type:

Optional[ReverseFragmentRecord]

Returns:

A reversible fragment record, or None when no reversible cut applies.

neurosnap.chemistry.sdf_to_smiles(fpath)[source]#

Converts molecules in an SDF file to SMILES strings.

Reads an input SDF file and extracts SMILES strings from its molecules. Invalid or unreadable molecules are skipped, with warnings logged.

Parameters:

fpath (str) – Path to the input SDF file.

Returns:

A list of SMILES strings corresponding to valid molecules in the SDF file.

Return type:

List[str]

Raises:
neurosnap.chemistry.smiles_to_sdf(smiles, output_path)[source]#

Converts a SMILES string to an sdf file. Will overwrite existing results.

NOTE: This function does the bare minimum in terms of generating the SDF molecule. The neurosnap.chemistry.conformers module should be used in most cases.

Parameters:
  • smiles (str) – Smiles string to parse and convert

  • output_path (str) – Path to output SDF file, should end with .sdf

Return type:

None

neurosnap.chemistry.standardize_molecule(mol)[source]#

Standardizes a molecule using RDKit’s cleanup workflow.

The standardization process applies RDKit’s built-in molecular cleanup rules, which can normalize representations such as functional groups, charges, and related valence patterns into a more consistent form.

Parameters:

mol (Chem.Mol) – Input RDKit molecule to standardize.

Returns:

A standardized copy of the input molecule.

Return type:

Chem.Mol

Raises:

ValueError – If the input molecule is None.

neurosnap.chemistry.translate_molecule(mol, vector)[source]#

Translates all atomic coordinates in a molecule by a vector.

The input molecule is not modified in place. Instead, a copy is made and every atom position in the first conformer is shifted by the provided [x, y, z] vector.

Parameters:
  • mol (Chem.Mol) – Input RDKit molecule with at least one conformer.

  • vector – Translation vector of length 3 containing the x, y, and z shifts.

Returns:

A translated copy of the input molecule.

Return type:

Chem.Mol

Raises:

ValueError – If the molecule is None, has no conformers, or the translation vector is not length 3.

neurosnap.chemistry.validate_smiles(smiles)[source]#

Validates a SMILES (Simplified Molecular Input Line Entry System) string.

Parameters:

smiles (str) – The SMILES string to validate.

Returns:

True if the SMILES string is valid, False otherwise.

Return type:

bool

Raises:

Exception – Logs any exception encountered during validation.

Submodules#