Пример #1
0
    def test_SmartsMolFilter(self):
        smis = ['C1CCC1', 'C1CCC1C=O', 'CCCC', 'CCC=O', 'CC(=O)C', 'CCN', 'NCCN', 'NCC=O']
        mols = [Chem.MolFromSmiles(x) for x in smis]
        suppl = SupplyNode(contents=mols)
        self.assertEqual(len(list(suppl)), 8)

        smas = ['C=O', 'CN']
        counts = [1, 2]
        filt = SmartsMolFilter.SmartsFilter(patterns=smas, counts=counts)
        filt.AddParent(suppl)
        self.assertEqual(len(list(filt)), 5)

        suppl.reset()
        filt.SetNegate(True)
        self.assertEqual(len(list(filt)), 3)

        smas = ['C=O', 'CN']
        filt = SmartsMolFilter.SmartsFilter(patterns=smas)
        filt.AddParent(suppl)
        self.assertEqual(len(list(filt)), 6)

        self.assertRaises(ValueError, SmartsMolFilter.SmartsFilter, patterns=smas,
                          counts=['notEnough', ])
        RDLogger.DisableLog('rdApp.error')
        self.assertRaises(ValueError, SmartsMolFilter.SmartsFilter, patterns=['BadSmarts'])
        RDLogger.EnableLog('rdApp.error')
Пример #2
0
  def test_SmartsMolFilter(self):
    smis = ['C1CCC1', 'C1CCC1C=O', 'CCCC', 'CCC=O', 'CC(=O)C', 'CCN', 'NCCN', 'NCC=O']
    mols = [Chem.MolFromSmiles(x) for x in smis]
    suppl = SupplyNode(contents=mols)
    self.assertEqual(len(list(suppl)), 8)

    smas = ['C=O', 'CN']
    counts = [1, 2]
    filt = SmartsMolFilter.SmartsFilter(patterns=smas, counts=counts)
    filt.AddParent(suppl)
    self.assertEqual(len(list(filt)), 5)

    suppl.reset()
    filt.SetNegate(True)
    self.assertEqual(len(list(filt)), 3)

    smas = ['C=O', 'CN']
    filt = SmartsMolFilter.SmartsFilter(patterns=smas)
    filt.AddParent(suppl)
    self.assertEqual(len(list(filt)), 6)

    self.assertRaises(ValueError, SmartsMolFilter.SmartsFilter, patterns=smas,
                      counts=['notEnough', ])
    RDLogger.DisableLog('rdApp.error')
    self.assertRaises(ValueError, SmartsMolFilter.SmartsFilter, patterns=['BadSmarts'])
    RDLogger.EnableLog('rdApp.error')
Пример #3
0
 def __init__(self,fileName,delim="\t",nameColumn=1,smilesColumn=0,titleLine=0,
              **kwargs):
   SupplyNode.__init__(self,**kwargs)
   self._fileName = fileName
   self._supplier = Chem.SmilesMolSupplier(self._fileName,delimiter=delim,
                                           smilesColumn=smilesColumn,
                                           nameColumn=nameColumn,
                                           titleLine=titleLine)
Пример #4
0
 def __init__(self,
              fileName,
              delim="\t",
              nameColumn=1,
              smilesColumn=0,
              titleLine=0,
              **kwargs):
     SupplyNode.__init__(self, **kwargs)
     self._fileName = fileName
     self._supplier = Chem.SmilesMolSupplier(self._fileName,
                                             delimiter=delim,
                                             smilesColumn=smilesColumn,
                                             nameColumn=nameColumn,
                                             titleLine=titleLine)
Пример #5
0
    def test_SmilesOutput(self):
        smis = ['C1CCC1', 'C1CC1', 'C=O', 'CCN']
        mols = [Chem.MolFromSmiles(x) for x in smis]
        for i, mol in enumerate(mols, 100):
            mol.SetProp('ID', str(i))

        suppl1 = SupplyNode(contents=mols)
        suppl2 = SupplyNode(contents='abcd')

        sio = StringIO()
        node = SmilesOutput.OutputNode(idField='ID', dest=sio, delim=', ')
        node.AddParent(suppl1)
        node.AddParent(suppl2)
        list(node)
        self.assertEqual(
            sio.getvalue(), '100, C1CCC1, a\n101, C1CC1, b\n102, C=O, c\n103, CCN, d\n')
Пример #6
0
    def test_SmilesDupeFilter(self):
        smis = ['C1CCC1', 'CCCC', 'CCCC', 'C1CCC1']
        mols = [Chem.MolFromSmiles(x) for x in smis]
        suppl = SupplyNode(contents=mols)
        self.assertEqual(len(list(suppl)), 4)

        dupFilter = SmilesDupeFilter.DupeFilter()
        dupFilter.AddParent(suppl)
        self.assertEqual(len(list(dupFilter)), 2)
Пример #7
0
 def reset(self):
     SupplyNode.reset(self)
     self._supplier.reset()
Пример #8
0
 def reset(self):
     SupplyNode.reset(self)
     self._supplier.reset()
Пример #9
0
 def __init__(self, dbResults, **kwargs):
   SupplyNode.__init__(self, **kwargs)
   self._dbResults = dbResults
   self._supplier = DbMolSupplier.RandomAccessDbMolSupplier(self._dbResults, **kwargs)
Пример #10
0
 def __init__(self, cursor, cmd, binaryCol, **kwargs):
     SupplyNode.__init__(self, **kwargs)
     self._dbResults = dbResults
     self._supplier = DbMolSupplier.RandomAccessDbMolSupplier(
         self._dbResults, **kwargs)
Пример #11
0
 def __init__(self, cursor, cmd, binaryCol, **kwargs):
   SupplyNode.__init__(self, **kwargs)
   self._dbResults = dbResults
   self._supplier = DbMolSupplier.RandomAccessDbMolSupplier(self._dbResults, **kwargs)
Пример #12
0
 def __init__(self, fileName, **kwargs):
     SupplyNode.__init__(self, **kwargs)
     self._fileName = fileName
     self._supplier = Chem.SDMolSupplier(self._fileName)
Пример #13
0
 def __init__(self, fileName, **kwargs):
   SupplyNode.__init__(self, **kwargs)
   self._fileName = fileName
   self._supplier = Chem.SDMolSupplier(self._fileName)
Пример #14
0
 def __init__(self, dbResults, **kwargs):
     SupplyNode.__init__(self, **kwargs)
     self._dbResults = dbResults
     self._supplier = DbMolSupplier.RandomAccessDbMolSupplier(
         self._dbResults, **kwargs)