Datasets:
Independent parser versus RDKit: the first run, and what every disagreement was
Measured 2026-07-28. python part2/scripts/molperceive/indep_parser.py --vs-rdkit part2/data/raw/molperceive/nci_first_5k.smi. This is the FIRST run. The parser was not
edited before it, and the two disagreements below were not edited away after it.
Summary of all three measurements
| # | set | parser state | compared | refused | disagree | rate |
|---|---|---|---|---|---|---|
| M1 | NCI as shipped (100% Kekule) | as frozen | 4,805 | 186 | 2 | 0.04% |
| M2 | NCI rewritten aromatic (67% lowercase) | as frozen | 4,610 | 381 | 3 | 0.07% |
| M3 | NCI rewritten aromatic | + aromatic N rule | 4,806 | 185 | 2 | 0.04% |
M1 is the headline first-run number. M2 and M3 exist because M1, taken alone, would have been a guard passing for the wrong reason, and the rest of this document is mostly about that. Every disagreement in all three runs is the same single cause, classified below.
Why this set
rdkit/Data/NCI/first_5K.smi ships inside the rdkit wheel: 4,999 real NCI compounds.
It was chosen because nobody on this entry wrote it, it long predates this parser, and it
is far more hostile than our own corpus (organometallics, isotopes, exotic valences). A
parser measured only against molecules its author also chose is measuring its author.
The numbers, as measured
| quantity | value |
|---|---|
| structures read | 4,999 |
| rdkit itself rejected, not comparable | 8 |
| parser REFUSED to answer | 186 |
| compared | 4,805 |
| agreed on all four fields | 4,803 |
| disagreed | 2 |
| first run disagreement rate | 0.04% |
Fields compared: element_counts, formula, heavy_atom_count, bond_count.
The Day-0 kill condition was "independent parser first run disagreement with rdkit above 15 percent: investigate and classify every disagreement before scaling". At 0.04% it is far under, and both disagreements are classified below regardless, because the threshold was never the point.
Disagreement 1 of 2
OP(O)(F)=O parser FH2O3P rdkit H2FO3P
Disagreement 2 of 2
NN.OB1OB(O1)OB2OB(O)O2 parser B4H6N2O7 rdkit H6B4N2O7
Classification: ONE root cause, and it is an RDKit convention, not a parser bug
Both are the same disagreement about Hill notation on a carbon-free formula, and the element composition is identical in both cases. Neither is an atom count error.
Strict Hill notation, as originally defined and as IUPAC states it: carbon first,
hydrogen second, remaining elements alphabetical, but when the compound contains no
carbon, every element including hydrogen is ordered alphabetically. The parser
implements that second clause, which was written into the frozen hand set before rdkit
was consulted (see hand_formulas.json, entry h14 phosphoric acid).
rdMolDescriptors.CalcMolFormula instead emits carbon's slot, then hydrogen's slot, then
the alphabetical remainder, unconditionally. The two agree on every carbon-free formula
whose other elements all sort after H, which is why the divergence is invisible on the
obvious test cases and why our own hand set failed to catch it:
rdkit OP(=O)(O)O -> H3O4P parser -> H3O4P agree (O and P sort after H)
rdkit O -> H2O parser -> H2O agree
rdkit NN -> H4N2 parser -> H4N2 agree
rdkit [B-](F)(F)(F)F -> BF4- parser -> BF4- agree (no hydrogen at all)
rdkit OP(O)(F)=O -> H2FO3P parser -> FH2O3P DISAGREE (F sorts before H)
It surfaces only when a carbon-free structure contains an element that sorts before H, which in practice means B, Ba, Be, Ag, Al, As, Au or F. Two of the 4,805 comparable NCI structures met that condition, and the parser disagreed on both. That is a 100 percent hit rate on the condition, not a flaky 0.04 percent, which is the more useful way to read it.
Honest note on the hand set. Two of the thirty hand-computed structures are carbon free (h14 phosphoric acid, h27 tetrafluoroborate) and I included them believing they tested this clause. Neither discriminates the two conventions: H sorts before O and P, and BF4- has no hydrogen. The hand set therefore did NOT catch this, and the external NCI run did. That is an argument for measuring against molecules you did not choose, and it is recorded here rather than quietly fixed.
Disposition: the parser was NOT changed
There is no criterion in this build that says fix the parser until it agrees with rdkit, and applying one here would destroy the only thing the parser is for. Instead:
- The divergence is documented in
fields.pyasRDKIT_HILL_DIVERGENCEand repeated in the CONVENTIONS clause that appears identically on every prompt for both models. - The shipped label is rdkit's, because
RDKIT_CALL_CHAIN["formula"]pinsCalcMolFormulaand the scorer recomputes from that pinned chain. - Every corpus row must contain at least one carbon atom. The gate drops carbon-free
structures and counts them, so the divergence cannot reach a label. Every scaffold in
scaffolds.pyis carbonaceous, so the expected drop count is zero and the check is there to stay zero rather than to do work.
The net effect is that the cross check covers the counting path on carbon-containing structures. The card says exactly that, in those words, rather than claiming the parser and rdkit agree everywhere.
The 186 refusals, itemised
A refusal is the parser declining to answer, and it is deliberately a third outcome distinct from both agreement and disagreement. Counting refusals as agreement would inflate the rate; counting them as disagreement would deflate it. Every one is explained:
| n | cause | example |
|---|---|---|
| 38 | element Cu | CCC1=[O+][Cu]2([O+]=C(CC)C1)[O+]=C(CC)CC(=[O+]2)CC |
| 31 | element Co | C1CN[Co]23(N1)(NCCN2)NCCN3 |
| 22 | element Hg | CO[CH]([CH]([Hg]Br)C(=O)O[CH]1C[CH]2CC[C]1(C)C2(C)C) |
| 20 | element As | C1=CC=C(C=C1)[As](C2=CC=CC=C2)C3=CC=CC=C3 |
| 14 | element Ni | C1C[N+]2=CC3=CC=CC=C3O[Ni]24OC5=CC=CC=C5C=[N+]14 |
| 13 | element Zn | CN(C)C1=[S+][Zn]2(S1)SC(=[S+]2)N(C)C |
| 8 | element Cd | |
| 8 | element Mn | |
| 6 | element Cr | |
| 4 | element Se | C1CN(CCO1)[Se][Se]N2CCOCC2 |
| 4 | element Sn | |
| 4 | element Fe | C12C3=C4C5=C1[Fe]23456789C%10C6=C7C8=C9%10 (ferrocene) |
| 3 | element Sb | |
| 2 | element Ce | |
| 1 each | Bi, Ti, Na, Mg, Th, V, Zr, Pt | |
| 1 | valence above every normal value, Cl | ...OCl(=O)(=O)=O perchloric acid, chlorine at bond order 7 |
185 of 186 are elements outside fields.SUPPORTED_ELEMENTS. In the corpus those are not
refusals at all, they are the out_of_scope: element_not_supported class, so this is the
parser behaving the way the task definition asks. The ferrocene line is the demo's sixth
default example arriving in the wild before we built it.
The remaining one is perchloric acid, whose chlorine carries bond order 7 against a normal valence of 1. Guessing a hydrogen count there would be inventing chemistry, so the parser raises instead of returning a number that looks like an answer.
M2 and M3: the first run measured the wrong thing, and here is the number that says so
The problem with M1, found by checking rather than by assuming
rdkit/Data/NCI/first_5K.smi is written 100 percent in Kekule uppercase form. Measured,
not eyeballed: 0 of 4,999 structures contain a lowercase aromatic atom outside a bracket.
So M1's 0.04 percent never executed the aromatic branch of the implicit-hydrogen model at all. That branch is the hardest part of the parser, it is where the hand set concentrated its cases, and it is what our corpus uses, because canonical rdkit output writes aromatics in lowercase. A 0.04 percent disagreement rate on a set that skips the hard path is exactly the shape HANDOFF 5.13 warns about: a check that reports success because it never touched the thing it was meant to test.
M2: rerun on the aromatic writings, parser NOT yet changed
Every NCI structure was rewritten through Chem.MolToSmiles, which produces the canonical
aromatic form. 3,355 of 4,991 (67.2 percent) then carry lowercase aromatic atoms. rdkit
wrote the strings; the parser still reads them and computes every count independently, so
the comparison stays honest, and this is exactly how molecules reach the model in the
corpus.
compared 4,610 refused 381 disagree 3 rate 0.07%
Disagreements did not move. REFUSALS did, from 186 to 381. The parser never produced a wrong number on the new path; it declined to produce one. 197 of the 195 new refusals are a single class:
197 valence above normal: N e.g. N#CCCn1c2ccccc2c2ccccc21 (carbazole)
A bare lowercase aromatic nitrogen with THREE connections. The frozen rule gave every aromatic atom one extra unit of bond order for its formal double bond, so a three-connected nitrogen came to 3 + 1 = 4 against a normal valence of 3, and the parser refused. That is the designed safe behaviour and it is why no wrong answer was ever emitted. But the class is N-substituted azoles, purines, indoles and carbazoles, 4.3 percent of the set and chemically central, so refusing it would have gutted the cross check's heteroaromatic coverage.
The third disagreement is new and unrelated:
CN(C)C[C-]12->[Fe+2]3456... parser 'SyntaxInvalid unknown_element' rdkit 'parsed'
rdkit's dative bond extension ->. Classified as a parser bug, and a dangerous one: it
filed a well-formed string as a syntax error, which in the corpus would put a valid record
into the invalid class carrying a fabricated reason code. Fixed by refusing rather than
rejecting, which is the same fix the bare wildcard already had. Every structure using the
notation in this set is a metal complex and out of scope by element anyway.
The gap was found by our own selftest, not by rdkit
score_molperceive.py --selftest prints all fields for three fixed reference molecules, and
caffeine is one of them precisely because it is where an implicit-hydrogen model is most
likely to break. It printed parser REFUSED: N at index 1 has bond order 4. No rdkit answer
was consulted to find this and none was consulted to fix it. That distinction is the whole
discipline, and it is why the third reference molecule earns its place in the selftest.
The rule, derived from chemistry
An aromatic ring needs six pi electrons. Each atom supplies them either by contributing one electron through a formal double bond or by donating a lone pair. It cannot do both, and which it does follows from how many sigma bonds it has already spent. The frozen rule 4 already said this for aromatic o and s, which is why furan and thiophene were right from the start. The omission was never extending it to nitrogen:
two connections pyridine-type, carries the double bond 2 + 1 = 3
three connections every sigma bond spent, donates the pair 3 + 0 = 3
Both land exactly on nitrogen's valence of 3 with nothing left over, so a bare lowercase
aromatic nitrogen never takes an implicit hydrogen either way. The pyrrole NH is written
[nH] and takes its hydrogen from the bracket, as it always did.
Ten new structures were hand computed and frozen with their own sha256 BEFORE that rule
was written into the parser, in hand_formulas_appendix_aromatic.json: N-methylpyrrole,
1-methylimidazole, caffeine, 1-methylpyrazole, indole, N-methylpyridinium, 3-methylthiophene,
2-pyridone, indolizine, 2-methylbenzimidazole. hand_formulas.json was NOT edited; appending
to it would have destroyed the only property that makes it worth anything.
M3: rerun after the rule
compared 4,806 refused 185 disagree 2 rate 0.04%
Refusals fell from 381 to 185. The two survivors are the same carbon-free Hill divergence as M1. And the number that actually validates the rule:
structures containing a 3-connected neutral aromatic N, now scored: 197
agree with rdkit on all four fields: 197
disagree: 0
197 of 197, on structures the rule had never seen, from a rule derived from lone-pair counting rather than from rdkit's output. That is a stronger result than the headline rate, because it is a prediction that could have failed and did not.
What goes on the card
The first-run disagreement rate is 0.04 percent (2 of 4,805), and the same sentence says that the set was entirely Kekule-written, that a rerun on aromatic writings of the same molecules left the disagreement count unchanged while raising refusals to 381, that the refused class was three-connected aromatic nitrogen, and that after a rule change frozen against ten newly hand-computed structures the rate is 0.04 percent (2 of 4,806) with the 197 formerly refused structures all agreeing. Reporting M1 alone would be true and misleading, which is the combination this project has decided is worse than a bad number.