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')
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)
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)
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')
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)
def reset(self): SupplyNode.reset(self) self._supplier.reset()
def __init__(self, dbResults, **kwargs): SupplyNode.__init__(self, **kwargs) self._dbResults = dbResults self._supplier = DbMolSupplier.RandomAccessDbMolSupplier(self._dbResults, **kwargs)
def __init__(self, cursor, cmd, binaryCol, **kwargs): SupplyNode.__init__(self, **kwargs) self._dbResults = dbResults self._supplier = DbMolSupplier.RandomAccessDbMolSupplier( self._dbResults, **kwargs)
def __init__(self, cursor, cmd, binaryCol, **kwargs): SupplyNode.__init__(self, **kwargs) self._dbResults = dbResults self._supplier = DbMolSupplier.RandomAccessDbMolSupplier(self._dbResults, **kwargs)
def __init__(self, fileName, **kwargs): SupplyNode.__init__(self, **kwargs) self._fileName = fileName self._supplier = Chem.SDMolSupplier(self._fileName)
def __init__(self, dbResults, **kwargs): SupplyNode.__init__(self, **kwargs) self._dbResults = dbResults self._supplier = DbMolSupplier.RandomAccessDbMolSupplier( self._dbResults, **kwargs)