Пример #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
Пример #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
Пример #3
0
 def test_smiles(self):
     inp = "O=C1NC%91=NC2NC=NC=21.[*:1]%91 |$;;;;;;;;;;_R1$|"
     molfile = indigo.loadMolecule(inp).molfile()
     r = make_request("smiles", (("moldata", molfile), ))
     self.assertEquals(200, r.code)
     status, smiles = r.read().split('\n', 1)
     self.assertEquals(status, "Ok.")
     self.assertEquals(inp, indigo.loadMolecule(smiles).canonicalSmiles())
Пример #4
0
 def test_calculate_cip(self):
     inp = "CCCN1C(=O)N=C(O)c2[nH]c[n]c12"
     r = make_request("calculate_cip", (("moldata", inp), ))
     self.assertEquals(200, r.code)
     status, molfile = r.read().split('\n', 1)
     self.assertEquals(status, "Ok.")
     smiles = indigo.loadMolecule(molfile).canonicalSmiles()
     self.assertEquals(smiles, "CCCN1C(=O)N=C(O)C2NC=NC1=2")
Пример #5
0
 def test_aromatize(self):
     inp = "N1=C(O)C2NC=NC=2N(CCC)C1=O"
     r = make_request("aromatize", (("moldata", inp), ))
     self.assertEquals(200, r.code)
     status, molfile = r.read().split('\n', 1)
     self.assertEquals(status, "Ok.")
     smiles = indigo.loadMolecule(molfile).canonicalSmiles()
     self.assertEquals(smiles, "CCCN1C(=O)N=C(O)c2[nH]c[n]c12")
Пример #6
0
 def load_moldata(self, is_query=False):
     moldata = self.fields.getfirst('moldata')
     if moldata.startswith('$RXN'):
         if is_query:
             md = indigo.loadQueryReaction(moldata)
         else:
             md = indigo.loadReaction(moldata)
         is_rxn = True
     else:
         if is_query:
             md = indigo.loadQueryMolecule(moldata)
         else:
             md = indigo.loadMolecule(moldata)
         is_rxn = False
     return md, is_rxn
Пример #7
0
 def load_moldata(self, is_query=False):
     moldata = self.fields.getfirst('moldata')
     if moldata.startswith('$RXN'):
         if is_query:
             md = indigo.loadQueryReaction(moldata)
         else:
             md = indigo.loadReaction(moldata)
         is_rxn = True
     else:
         if is_query:
             md = indigo.loadQueryMolecule(moldata)
         else:
             md = indigo.loadMolecule(moldata)
         is_rxn = False
     return md, is_rxn