SingleMolecule
- class specatalog.models.molecules.SingleMolecule(**kwargs)[source]
Single-molecule entry in the molecular hierarchy.
This subclass of
Moleculerepresents an individual, well-defined molecular species without further structural partitioning. While the baseMoleculeclass 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 inmoleculeswheregroup='single'will therefore be loaded as aSingleMoleculeinstance.- id
Primary key linked to
molecules.idwith cascading delete.- Type:
int
Notes
The table name is
single.Inherits all mandatory molecular attributes from
Molecule(name, molecular_formula, structural_formula, timestamps, relationships).idmaps directly to the basemoleculestable through joined-table inheritance.additional_infois 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'>