-
Notifications
You must be signed in to change notification settings - Fork 25
ENH: broaden SMILES handling to match RDKit #60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1022,3 +1022,25 @@ def test_aromatic_molecules(smiles): | |
| """These molecules are totally aromatic""" | ||
| mol = read_smiles(smiles, reinterpret_aromatic=True) | ||
| assert all(nx.get_node_attributes(mol, 'aromatic').values()) | ||
|
|
||
|
|
||
| @pytest.mark.parametrize("smiles", [ | ||
| # these are both interpreted as the same | ||
| # molecule in RDKit | ||
| "C(c1c2cccc3c2c(cc1)C(=C)C(=C)C(=C)3)", | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The other pathological example from the cross-listed issue is far harder to shim around. My one hesitation is the danger of reinventing the wheel given the versatility |
||
| "C(c1c2cccc3c2c(cc1)C(=C)C(=C)C3(=C))" | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. for reference: from rdkit import Chem
smiles_1 = "C(c1c2cccc3c2c(cc1)C(=C)C(=C)C(=C)3)"
smiles_2 = "C(c1c2cccc3c2c(cc1)C(=C)C(=C)C3(=C))"
mol_1 = Chem.MolFromSmiles(smiles_1)
mol_2 = Chem.MolFromSmiles(smiles_2)
assert Chem.MolToSmiles(mol_1) == Chem.MolToSmiles(mol_2)and neither of those original SMILES matches what |
||
| ]) | ||
| def test_non_canonical_smiles_handling(smiles): | ||
| # harmonizing SMILES input handling to better match RDKit | ||
| # can help accommodate SMILES strings provided by chemists | ||
| # per: | ||
| # https://github.com/gruenewald-lab/CGsmiles/issues/70 | ||
| mol = read_smiles(smiles) | ||
| # expected values are from the "good" string at: | ||
| # https://github.com/gruenewald-lab/CGsmiles/issues/70#issuecomment-4750353505 | ||
| expected_nodes = list(range(17)) | ||
| expected_edges = [(0, 1), (1, 2), (1, 10), (2, 3), (2, 7), (3, 4), (4, 5), | ||
| (5, 6), (6, 7), (6, 15), (7, 8), (8, 9), (8, 11), (9, 10), | ||
| (11, 12), (11, 13), (13, 14), (13, 15), (15, 16)] | ||
| assert list(mol.nodes) == expected_nodes | ||
| assert list(mol.edges) == expected_edges | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose one could argue that this is the beginning of a slippery slope to shim around more and more pathological SMILES (
RDKitcan permute at least a dozen variants of the SMILES inputs used in this PR and still handles them just fine).It might be useful to clarify why we're not using
RDKitin this ecosystem--just the "weight" of the dependency?