Exemplo n.º 1
0
def get_mcs_indices_indigo(m_sdf, t_sdf, timeout=None, exact=False):
    import indigo
    indigo = indigo.Indigo()

    m_mol = indigo.loadMolecule(m_sdf)
    t_mol = indigo.loadMolecule(t_sdf)

    # find common substructure
    arr = indigo.createArray()
    arr.arrayAdd(m_mol)
    arr.arrayAdd(t_mol)
    mcs = indigo.extractCommonScaffold(arr, 'exact' if exact else 'approx')

    # match to scaffold
    query = indigo.loadQueryMolecule(mcs.smiles())
    m_match = indigo.substructureMatcher(m_mol).match(query)
    t_match = indigo.substructureMatcher(t_mol).match(query)

    # atom indices of match
    m_atoms = [m_match.mapAtom(a) for a in query.iterateAtoms()]
    t_atoms = [t_match.mapAtom(a) for a in query.iterateAtoms()]
    m_indices = [a.index() for a in m_atoms if a is not None]
    t_indices = [a.index() for a in t_atoms if a is not None]

    return m_indices, t_indices
Exemplo n.º 2
0
def get_mcs_indices_indigo(m_sdf, t_sdf, timeout=None, exact=False):
    import indigo
    indigo = indigo.Indigo()

    m_mol = indigo.loadMolecule(m_sdf)
    t_mol = indigo.loadMolecule(t_sdf)

    # find common substructure
    arr = indigo.createArray()
    arr.arrayAdd(m_mol)
    arr.arrayAdd(t_mol)
    mcs = indigo.extractCommonScaffold(arr, 'exact' if exact else 'approx')

    # match to scaffold
    query = indigo.loadQueryMolecule(mcs.smiles())
    m_match = indigo.substructureMatcher(m_mol).match(query)
    t_match = indigo.substructureMatcher(t_mol).match(query)

    # atom indices of match
    m_atoms = [m_match.mapAtom(a) for a in query.iterateAtoms()]
    t_atoms = [t_match.mapAtom(a) for a in query.iterateAtoms()]
    m_indices = [a.index() for a in m_atoms if a is not None]
    t_indices = [a.index() for a in t_atoms if a is not None]

    return m_indices, t_indices