def FullStandardization(smi):
    try:
        mol = Chem.MolFromSmiles(smi)
        if mol == None:
            # If rdkit could not parse the smiles, returns Error 1
            return "Error 1"
        else:
            STD = Standardizer()
            LFC = LargestFragmentChooser()
            UC = Uncharger()
            RI = Reionizer()
            TC = TautomerCanonicalizer()

            mol = STD(mol)
            mol = LFC(mol)

            allowed_elements = {
                "H", "B", "C", "N", "O", "F", "Si", "P", "S", "Cl", "Se", "Br",
                "I"
            }
            actual_elements = set(
                [atom.GetSymbol() for atom in mol.GetAtoms()])
            if len(actual_elements - allowed_elements) == 0:
                mol = UC(mol)
                mol = RI(mol)
                RemoveStereochemistry(mol)
                mol = TC(mol)
                return Chem.MolToSmiles(mol)
            else:
                # If molecule contains other than the allowed elements, returns "Error 2"
                return "Error 2"
    except:
        return "Check manually"
Esempio n. 2
0
def getReionisedMolecule(mol):
    reioniser = Reionizer()
    return reioniser.reionize(mol)
Esempio n. 3
0
def test_reionize():
    """Test reionizer moves proton to weaker acid."""
    mol = Chem.MolFromSmiles('C1=C(C=CC(=C1)[S]([O-])=O)[S](O)(=O)=O')
    r = Reionizer()
    mol = r.reionize(mol)
    assert Chem.MolToSmiles(mol) == 'O=S(O)c1ccc(S(=O)(=O)[O-])cc1'
Esempio n. 4
0
def test_reionize3():
    """"""
    mol = Chem.MolFromSmiles('C[N+]1=C[CH-]N(C(=N)N)/C1=C/[N+](=O)[O-]')
    r = Reionizer()
    mol = r.reionize(mol)
    assert Chem.MolToSmiles(mol) == 'C[N+]1=CCN(C(=N)N)C1=[C-][N+](=O)[O-]'
Esempio n. 5
0
def test_reionize2():
    """Test charged carbon doesn't get recognised as alpha-carbon-hydrogen-keto."""
    mol = Chem.MolFromSmiles('CCOC(=O)C(=O)[CH-]C#N')
    r = Reionizer()
    mol = r.reionize(mol)
    assert Chem.MolToSmiles(mol) == 'CCOC(=O)C(=O)[CH-]C#N'