I think you've persuaded me that .SetIsotope() is the way to go...

I don't understand how that avoids any problem. How do you specify the
> target atom for that case?
> In any case, won't the InChI normalization affect some of your structures
> (e.g., detaching metals) and make it even harder to specify isotopes?


but just to clarify, here is the admittedly hackish via-InChI conversion I
had in mind.  The specification of isotopes still happens in smiles, which
I find easier for humans to grok than InChI.  {{Side note: the end
application here is modeling the labeling patterns in structurally complex
natural products that are biosynthesized from simple labeled substrates
(such as ethanol).  So I ultimately want to feed my labeled molecules to a
series of SMARTS reactions that will eventually lead to a complex
structure.  Given the vagaries of SMARTS reaction matching, I want to be
sure that all my reactions apply equally well to labeled and unlabeled
substrates.}}

def convert_to_smiles_via_inchi(smiles):
    """Make a molecule from SMILES but via Inchi"""
    temp_mol = Chem.MolFromSmiles(smiles)
    inchi = Chem.MolToInchi(temp_mol)
    final_mol = Chem.MolFromInchi(inchi)
    return final_mol

def same_implicit_valence(mol_1, mol_2, atom_idx=1):
    """Returns True if mol_1 and mol_2 have the same implicit valence for
the indexed atom"""
    mol_1_implicitH = mol_1.GetAtomWithIdx(atom_idx).GetImplicitValence()
    mol_2_implicitH = mol_2.GetAtomWithIdx(atom_idx).GetImplicitValence()
    return mol_1_implicitH == mol_2_implicitH

etoh_v1 = 'C[13C]O'
etoh_v2 = 'CCO'

etoh_versions = [etoh_v1, etoh_v2]

via_inchi = [convert_to_smiles_via_inchi(mol) for mol in etoh_versions]
smiles_only = [Chem.MolFromSmiles(mol) for mol in etoh_versions]

# this works
assert same_implicit_valence(*via_inchi)

# this doesn't
assert same_implicit_valence(*smiles_only)
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss

Reply via email to