Skip to content

Inappropriate Exclusion of Organic Solvents #4

@momeara

Description

@momeara

The standardiser inappropriately removes organic compounds that are sometimes used as organic solvents. For example, the important metabolite glutamate is removed:

from rdkit import Chem
from standardiser import standardise
smiles = 'NC(CCC(=O)O)C(=O)O' # glutamate
mol = Chem.MolFromSmiles(smiles, sanitize=False)
clean_mol = standardise.apply(mol) # throws no_non_salt exception

One approach to resolving this issue would be allow organic solvents if they are the only organic fragment in the molecule. Here is code that does this:

    organic_salt_frags = []

    non_salt_frags = []

    mol = break_bonds.apply(mol)

    for n, frag in enumerate(Chem.GetMolFrags(mol, asMols=True), 1):

        logger.debug("Starting fragment {n} '{smi}'...".format(n=n, smi=Chem.MolToSmiles(frag)))

        logger.debug("1) Check for non-organic elements...")

        if unsalt.is_nonorganic(frag): continue

        logger.debug("2) Attempting to neutralise (first pass)...")

        frag = neutralise.apply(frag)

        logger.debug("3) Applying rules...")

        frag = rules.apply(frag, output_rules_applied=output_rules_applied, verbose=verbose)

        logger.debug("4) Attempting to neutralise (second pass)...")

        frag = neutralise.apply(frag)

        logger.debug("5) Checking if frag is a salt/solvate...")

        if unsalt.is_salt(frag):

            organic_salt_frags.append(frag)

            continue

        logger.debug("...fragment kept.")

        non_salt_frags.append(frag)

    if len(non_salt_frags) == 0:

        logger.debug("No non-salt frags. If there is a single organic salt frag take it.")

        if len(organic_salt_frags) == 1:

            parent = organic_salt_frags[0]

        else:

            raise StandardiseException("no_non_salt")

    elif len(non_salt_frags) > 1:

        raise StandardiseException("multi_component")

    else:

        parent = non_salt_frags[0]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions