|
142 | 142 | retained_fused_base_templates, |
143 | 143 | retained_fused_graph_templates, |
144 | 144 | retained_fused_template_from_data, |
| 145 | + retained_parent_metadata, |
145 | 146 | template_molecule, |
146 | 147 | ) |
147 | 148 | from openclatura.retained_specs import retained_parent_spec |
@@ -2968,6 +2969,40 @@ def test_retained_fused_base_skeletons_are_loaded_from_the_graph_template_table( |
2968 | 2969 | assert base_templates["purinoid_9"]["mancude_double_bonds"] == 4 |
2969 | 2970 |
|
2970 | 2971 |
|
| 2972 | +def test_no_bare_retained_alias_infers_a_canonical_hydride_tautomer(): |
| 2973 | + templates = retained_fused_graph_templates(include_disabled=True) |
| 2974 | + bare_hydride_aliases = { |
| 2975 | + alias |
| 2976 | + for template in templates |
| 2977 | + if template.default_indicated_h |
| 2978 | + for alias in template.aliases |
| 2979 | + if "H-" not in alias |
| 2980 | + } |
| 2981 | + |
| 2982 | + # This registry-wide invariant automatically covers future retained |
| 2983 | + # hydrides whose bare alias omits the tautomer-defining H locant. |
| 2984 | + assert {"phenalene", "perimidine", "isoindole", "indole"} <= bare_hydride_aliases |
| 2985 | + assert all(retained_parent_metadata(alias) is None for alias in bare_hydride_aliases) |
| 2986 | + |
| 2987 | + exact_hydride_templates = [template for template in templates if "H-" in template.name] |
| 2988 | + assert exact_hydride_templates |
| 2989 | + for template in exact_hydride_templates: |
| 2990 | + metadata = retained_parent_metadata(template.name) |
| 2991 | + assert metadata is not None |
| 2992 | + assert metadata.default_indicated_h == template.default_indicated_h |
| 2993 | + |
| 2994 | + |
| 2995 | +def test_indicated_hydrogen_follows_graph_tautomer_but_not_hydrogen_free_spiro_carbon(): |
| 2996 | + cases = { |
| 2997 | + "c1ccc2c(c1)CN=C2C1=NCc2ccccc21": "3-(3H-isoindol-1-yl)-1H-isoindole", |
| 2998 | + "O=C(OCCNC1=NCc2ccccc21)c1ccccc1": "2-((3H-isoindol-1-yl)amino)ethyl benzoate", |
| 2999 | + "FN1CCC2(C=Nc3ccccc32)CC1": "1'-fluorospiro[indole-3,4'-piperidine]", |
| 3000 | + } |
| 3001 | + |
| 3002 | + for smiles, expected in cases.items(): |
| 3003 | + assert name_smiles(smiles) == expected |
| 3004 | + |
| 3005 | + |
2971 | 3006 | def test_retained_fused_graph_template_schema_validates_locant_graphs(): |
2972 | 3007 | template = retained_fused_template_from_data(_naphthalene_graph_template_row()) |
2973 | 3008 |
|
|
0 commit comments