def test_atom_constraint5(self): testmol = Chem.MolFromSmiles('CC=C') s = """ fragment a{ C labeled c1 {!connected to >1 C with any bond} } """ molquery = Read(s) match_index = molquery.GetQueryMatches(testmol) self.assertEqual(match_index, ((0, ), (2, )))
def test_non_ring_bond(self): testmol = Chem.MolFromSmiles('CCC1CCC1') s = """ fragment a{ C labeled c1 C labeled c2 nonring bond to c1 } """ molquery = Read(s) match_index = molquery.GetQueryMatches(testmol) self.assertEqual(match_index, ((0, 1), (1, 0), (1, 2), (2, 1)))
def test_atom_prefix3(self): testmol = Chem.MolFromSmiles('CC=C') s = """ fragment a{ C labeled c1 allylic C labeled c2 single bond to c1 } """ molquery = Read(s) match_index = molquery.GetQueryMatches(testmol) self.assertEqual(match_index, ((0, 1), ))
def test_atom_constraint6(self): testmol = Chem.MolFromSmiles('CC1CCC1') s = """ fragment a{ C labeled c1 {!in ring of size >0} C labeled c2 single bond to c1 {in ring of size >0} } """ molquery = Read(s) match_index = molquery.GetQueryMatches(testmol) self.assertEqual(match_index, ((0, 1), ))
def test_other_bond10(self): testmol = Chem.MolFromSmiles('CCS') s = """ fragment a{ X labeled c1 & labeled c2 single bond to c1 } """ molquery = Read(s) match_index = molquery.GetQueryMatches(testmol) self.assertEqual(match_index, ((1, 2), ))
def test_atom_constraint3(self): testmol = Chem.MolFromSmiles('CC=C') s = """ fragment a{ C labeled c1 C labeled c2 single bond to c1 {connected to =1 C with double bond} } """ molquery = Read(s) match_index = molquery.GetQueryMatches(testmol) self.assertEqual(match_index, ((0, 1), ))
def test_other_bond7(self): testmol = Chem.MolFromSmiles('CCC') s = """ cyclic fragment a{ C labeled c1 C labeled c2 single bond to c1 } """ molquery = Read(s) match_index = molquery.GetQueryMatches(testmol) self.assertEqual(match_index, ())
def test_other_bond6(self): testmol = Chem.MolFromSmiles('CCC') s = """ linear fragment a{ C labeled c1 C labeled c2 single bond to c1 } """ molquery = Read(s) match_index = molquery.GetQueryMatches(testmol) self.assertEqual(match_index, ((0, 1), (1, 0), (1, 2), (2, 1)))
def test_strong_bond(self): testmol = Chem.MolFromSmiles('CC=CC#C') s = """ fragment a{ C labeled c1 C labeled c2 strong bond to c1 } """ molquery = Read(s) match_index = molquery.GetQueryMatches(testmol) self.assertEqual(match_index, ((1, 2), (2, 1), (3, 4), (4, 3)))
def test_ring_bond2(self): testmol = Chem.MolFromSmiles('CCC1CCC1') s = """ fragment a{ C labeled c1 C labeled c2 ring bond to c1 } """ molquery = Read(s) match_index = molquery.GetQueryMatches(testmol) self.assertEqual(match_index, ((2, 3), (2, 5), (3, 2), (3, 4), (4, 3), (4, 5), (5, 2), (5, 4)))
def test_other_bond8(self): testmol = Chem.MolFromSmiles('C1CCC1C') s = """ cyclic fragment a{ C labeled c1 C labeled c2 single bond to c1 } """ molquery = Read(s) match_index = molquery.GetQueryMatches(testmol) self.assertEqual(match_index, ((0, 1), (0, 3), (1, 0), (1, 2), (2, 1), (2, 3), (3, 0), (3, 2), (3, 4), (4, 3)))
def test_aromatic_bond(self): testmol = Chem.MolFromSmiles('c1ccccc1') s = """ fragment a{ C labeled c1 C labeled c2 aromatic bond to c1 } """ molquery = Read(s) match_index = molquery.GetQueryMatches(testmol) self.assertEqual(match_index, ((0, 1), (0, 5), (1, 0), (1, 2), (2, 1), (2, 3), (3, 2), (3, 4), (4, 3), (4, 5), (5, 0), (5, 4)))
def test_double_triple_bond(self): testmol = Chem.MolFromSmiles('C=C-C#C') s = """ fragment a{ C labeled c1 C labeled c2 double bond to c1 C labeled c3 single bond to c2 C labeled c4 triple bond to c3 } """ molquery = Read(s) match_index = molquery.GetQueryMatches(testmol) self.assertEqual(match_index, ((0, 1, 2, 3), ))
def test_symbol_atomsuffix(self): testmol = Chem.MolFromSmiles('CCC') s = """ fragment a{ $ labeled c1 $ labeled c2 single bond to c1 } """ molquery = Read(s) match_index = molquery.GetQueryMatches(testmol) self.assertEqual(match_index, ((0, 1), (0, 3), (0, 4), (0, 5), (1, 0), (1, 2), (1, 6), (1, 7), (2, 1), (2, 8), (2, 9), (2, 10), (3, 0), (4, 0), (5, 0), (6, 1), (7, 1), (8, 2), (9, 2), (10, 2)))
Created on Tue Oct 23 11:22:49 2018 @author: gerha """ from VGA.RINGParser.Reader import Read from rdkit import Chem ## fragment prefix test testmol = Chem.MolFromSmiles('C[CH2+]') s = """ positive fragment a{ C labeled c1 C labeled c2 single bond to c1 } """ molquery = Read(s) assert match_index == ((0, 1), (1, 0)) testmol = Chem.MolFromSmiles('C[CH2-]') s = """ negative fragment a{ C labeled c1 C labeled c2 single bond to c1 } """ molquery = Read(s) match_index = molquery.GetQueryMatches(testmol) assert match_index == ((0, 1), (1, 0)) testmol = Chem.MolFromSmiles('[CH][CH][C+][C-][C][CH+][CH-][CH4+]')