SingleMolecule

class specatalog.models.molecules.SingleMolecule(**kwargs)[source]

Single-molecule entry in the molecular hierarchy.

This subclass of Molecule represents an individual, well-defined molecular species without further structural partitioning. While the base Molecule class already provides universal molecular attributes (name, molecular formula, structural representation), this class allows the addition of optional, molecule-specific descriptive information.

The model participates in the polymorphic SQLAlchemy hierarchy using the "single" polymorphic_identity. Any row in molecules where group='single' will therefore be loaded as a SingleMolecule instance.

id

Primary key linked to molecules.id with cascading delete.

Type:

int

Notes

  • The table name is single.

  • Inherits all mandatory molecular attributes from Molecule (name, molecular_formula, structural_formula, timestamps, relationships).

  • id maps directly to the base molecules table through joined-table inheritance.

  • additional_info is optional and may remain empty.

  • All molecules that do not fit to an other class should be from SingleMolecule.

Examples

Creating a single molecule:

>>> from models import SingleMolecule
>>> s = SingleMolecule(
...     name="Anthracene",
...     molecular_formula="C14H10",
...     structural_formula="...",
...     group="single",
...     additional_info="Highly fluorescent.",
... )
>>> session.add(s)
>>> session.commit()

Loading via polymorphism:

>>> mol = session.query(Molecule).filter_by(id=s.id).one()
>>> type(mol)
<class 'models.SingleMolecule'>