ChemLog: Making MSOL Viable for Ontological Classification and Learning
Abstract
Presentation given at the Ontologies4Chem Workshop 2025. Abstract: In this talk, we presented ChemLog, a methodology that allows to use monadic second-order formalisation for ontology classification. As a case study, ChemLog has been applied to 67 peptide-related classes (including 14 current ChEBI classes). For these classes, both natural language and formalised definitions have been developed which are then used to classify both ChEBI as well as PubChem with 119 million molecules.
Full text
ChemLog: Making MSOL Viable for Ontological Classification and Learning Simon Flügel (Osnabrück University) Based on: Simon Flügel, Martin Glauer, Till Mossakowski, Fabian Neuhaus: ChemLog: Making MSOL Viable for Ontological Classification and Learning (IJCLR, 2025) Simon Flügel, Till Mossakowski, Fabian Neuhaus, Erik Pfanenstiel, Martin Glauer, Edgar Haak, Adnan Malik, Noel M. O’Boyle: Defining Peptides in ChEBI (JCI, submitted)
ChemLog / Flügel et al. / 2 Ontological Classification tripeptide zwitterion dipeptide zwitterion peptide zwitterion dipolar compound chemical entity organic molecular entity nitrogen ylide ylide ? ??? Asp-Lys zwitterion (CHEBI:229953)
ChemLog / Flügel et al. / 3 Chemical Entities of Biological Interest (ChEBI)
ChemLog / Flügel et al. / 4 Ontological Classification With Logic organooxygenCompound ⇔∃a,b :C ( a ) ∧O ( b ) ∧Bond ( a,b ) ChEBI definitions & expert knowledge
ChemLog / Flügel et al. / 7 Why Monadic Second-order Logic (MSOL)? Usual logic choices for ontologies: Description logics (e.g., OWL 2 DL) First-order logic (FOL) MSOL: FOL with quantification over subsets of the domain Problem: Reflexive, transitive closure TC of symmetric relation R not possible with FOL
ChemLog / Flügel et al. / 8 Is This an Amino Acid? Amino acid (def.): “A carboxylic acid containing one or more amino groups.” (CHEBI:33709) Implicitly: The carboxy group and amino group have to be connected. CHEBI:25017 - leucine
ChemLog / Flügel et al. / 9 Is This an Amino Acid? Amino acid (def.): “A carboxylic acid containing one or more amino groups.” (CHEBI:33709) Implicitly: The carboxy group and amino group have to be connected. Carboxy group Amino group Connection CHEBI:25017 - leucine
ChemLog / Flügel et al. / 10 Carboxy group Amino group Connection Is This an Amino Acid? CHEBI:72772 - β-leucine Amino group Carboxy group Connection Amino acid (def.): “A carboxylic acid containing one or more amino groups.” (CHEBI:33709) Implicitly: The carboxy group and amino group have to be connected. CHEBI:25017 - leucine
ChemLog / Flügel et al. / 11 CHEBI:72772 - β-leucine Amino group Carboxy group Connection Carboxy group Amino group Connection Is This an Amino Acid? Amino acid (def.): “A carboxylic acid containing one or more amino groups.” (CHEBI:33709) Implicitly: The carboxy group and amino group have to be connected. → Any chain of carbon atoms can be a valid connection. This cannot be expressed in FOL. CHEBI:73044 - lumiracoxib Amino group Connection Carboxy group CHEBI:25017 - leucine
ChemLog / Flügel et al. / 18 Peptides – What happens at the N-Terminus? Amino groups may carry acyl or alkyl substituents. CHEBI:191173 - N-acetyl-L-seryl-L-aspartic acid
ChemLog / Flügel et al. / 19 Peptides – How are amino acids connected? The amino acid residues are delimited by heteroatoms. CHEBI:191173 - Temocapril
ChemLog / Flügel et al. / 20 Peptides – How are amino acids connected? The amino acid residues are delimited by heteroatoms. CHEBI:191173 - Temocapril
ChemLog / Flügel et al. / 21 Making MSOL Viable
ChemLog / Flügel et al. / 22 FOL Structures CHEBI:15428 - glycine 1 molecule = 1 FOL structure
ChemLog / Flügel et al. / 23 Classification as a Model Checking Problem CHEBI:15428 - glycine A molecule is an amino acid iff the corresponding predicate holds for its FOL structure.
ChemLog / Flügel et al. / 24 Small Scale: MONA / QBF MONA [1]: MSOL model finder QBF: Quantified Boolean Formulas pred AminoAcid(var2 X) = ex1 A: ex1 B1: ex1 B2: ex1 B3: (AminoGroup(A) & CarboxylicAcid(B1, B2, B3) & IsConnected(A, B1)); Var 2 X; AminoAcid(X); [1] Henriksen, J.G., et al.: MONA: Monadic second-order logic in practice. In: TACAS’95. pp. 89–110. Springer LNCS 1019 (1995) Medium Scale: First-order Logic Translate FOL-able predicates automatically Implement MSOL predicates in Python pred AminoAcid(var2 X) = ex1 A: ex1 B1: ex1 B2: ex1 B3: (AminoGroup(A) & CarboxylicAcid(B1, B2, B3) & IsConnected(A, B1)); Var 2 X; AminoAcid(X); AminoAcid ( x ) ⇔∃a,b1,b2,b3: (AtomIn ( a,x ) ∧AtomIn ( b1,x ) ∧AtomIn ( b2,x ) ∧AtomIn ( b3,x ) ∧AminoGroup ( a ) ∧CarboxylicAcid ( b1,b2,b3 ) ∧IsConnected ( x ) ) Large Scale: Algorithmic def amino_acid(mol, x): for a in mol.GetAtoms(): for b_1 in mol.GetAtoms(): for b_2 in mol.GetAtoms(): for b_3 in mol.GetAtoms(): if (a in x and b_1 in x and b_2 in x and b_3 in x and amino_group(a) and carboxylic_acid(b_1, b_2, b_3) and is_connected(mol, a, b_1)): return True return False Compile FOL to Python
ChemLog / Flügel et al. / 25 Performance Dataset (small scale): 1,000 smallest peptides from ChEBI Dataset (medium scale): all molecules from ChEBI’s 3-STAR subset (45,000) Dataset (large scale): PubChem molecules (119.3 million) Dataset Method Timeout rate Time/molecule (s) 1,000 smallest MONA 61.1% 10.8 QBF 0% 832 FOL 0.4% 0.37 3-STAR FOL 2.2% 1.03 Algorithmic 0% 0.0084 PubChem Algorithmic 5.8*10-7 0.0017
ChemLog / Flügel et al. / 26 Limitations Is this a peptide? Our classification: amino acid ChEBI says: dipeptide CHEBI:71596 - mycocyclosin
ChemLog / Flügel et al. / 27 Limitations Is this a peptide? Our classification: dipeptide ChEBI says: not a peptide CHEBI:6827 - methicillin
ChemLog / Flügel et al. / 34 Large Scale: Algorithmic combine implementation of MSOL predicates with FOL-to-Python compilation optimise for performance AminoAcid ( x ) ⇔∃a,b1,b2,b3: (AtomIn ( a,x ) ∧AtomIn ( b1,x ) ∧AtomIn ( b2,x ) ∧AtomIn ( b3,x ) ∧AminoGroup ( a ) ∧CarboxylicAcid ( b1,b2,b3 ) ∧IsConnected ( x ) ) Implement MSOL part manually Translate to FOL Run in Python Compile to algorithmic def amino_acid(mol, x): for a in mol.GetAtoms(): for b_1 in mol.GetAtoms(): for b_2 in mol.GetAtoms(): for b_3 in mol.GetAtoms(): if (a in x and b_1 in x and b_2 in x and b_3 in x and amino_group(a) and carboxylic_acid(b_1, b_2, b_3) and is_connected(mol, a, b_1)): return True return False Optimise manually def is_connected(mol, a, b): graph = nx.Graph() for bond in mol.GetBonds(): graph.add_edge(bond.GetBeginAtomIdx(), bond.GetEndAtomIdx()) for comp in nx.connected_components(graph): if a in comp and b in comp: return True return False
ChemLog / Flügel et al. / 35 Large scale: Algorithmic Dataset (small scale): 1,000 smallest peptides from ChEBI Dataset (medium scale): all molecules from ChEBI’s 3-STAR subset (45,000) Dataset (large scale): PubChem molecules (119.3 million) Dataset Method Timeout rate Time/molecule (s) 1,000 smallest MONA 61.1% 10.8 QBF 0% 832 FOL 0.4% 0.37 3-STAR FOL 2.2% 1.03 Algorithmic 0% 0.0084 PubChem Algorithmic 5.8*10-7 0.0017
ChemLog / Flügel et al. / 36 Improving Deep Learning Models Goal: Ontology classification with Deep Learning models Problem: Performance limited by data quality Solution: Improve data quality with ChemLog
ChemLog / Flügel et al. / 37 Improving Deep Learning Models #Chemlog/ #ChEBI Trained on ChemLog data 1.23 41.07 Trained on ChEBI data Blue: tested on ChEBI data Orange: tested on ChemLog data 41.07 1.23
ChemLog / Flügel et al. / 38 Improving Deep Learning Models Deep Learning model: ELECTRA, trained on 14 peptide classes Train / test with labels from either ChEBI or ChemLog
ChemLog / Flügel et al. / 39 Two Amino Acids, but no Peptide? CHEBI:31176 - Adipiodone
ChemLog / Flügel et al. / 40 Four Amino acids, two dipeptides? CHEBI:17257 - bis-γ-glutamylcystine
ChemLog / Flügel et al. / 41 Amino Acid or Peptide? CHEBI:133888 - tabtoxinine-δ-lactam
ChemLog / Flügel et al. / 42 How Many Amino Acids? CHEBI:28001 - vancomycin
ChemLog / Flügel et al. / 43 New Carboxylic Acid Derivatives Venturamide A (CHEBI:66353)