Пример #1
0
 def test2Bug28(self):
     smi = 'Cc([s]1)nnc1SCC(\CS2)=C(/C([O-])=O)N3C(=O)[C@H]([C@@H]23)NC(=O)C[n]4cnnn4'
     mol = Chem.MolFromSmiles(smi)
     factory = Gobbi_Pharm2D.factory
     factory.SetBins([(2, 3), (3, 4), (4, 5), (5, 8), (8, 100)])
     sig = Generate.Gen2DFingerprint(mol, factory)
     onBits = sig.GetOnBits()
     for bit in onBits:
         atoms = Matcher.GetAtomsMatchingBit(factory, bit, mol, justOne=1)
         self.assertTrue(len(atoms))
Пример #2
0
 def test3Roundtrip(self):
     # longer-running Bug 28 test
     nToDo = 20
     with open(os.path.join(RDConfig.RDDataDir, 'NCI', 'first_5K.smi'), 'r') as inF:
         inD = inF.readlines()[:nToDo]
     factory = Gobbi_Pharm2D.factory
     factory.SetBins([(2, 3), (3, 4), (4, 5), (5, 8), (8, 100)])
     for line in inD:
         smi = line.split('\t')[0]
         mol = Chem.MolFromSmiles(smi)
         sig = Generate.Gen2DFingerprint(mol, factory)
         onBits = sig.GetOnBits()
         for bit in onBits:
             atoms = Matcher.GetAtomsMatchingBit(factory, bit, mol, justOne=1)
             assert len(atoms), f'bit {bit} failed to match for smi {smi}'
Пример #3
0
    def test1_simple(self):
        mol = Chem.MolFromSmiles('OCC(=O)CCCN')
        self.factory.skipFeats = ['Donor']
        self.factory.Init()
        self.assertEqual(self.factory.GetSigSize(), 510)
        Generate._verbose = False
        sig = Generate.Gen2DFingerprint(mol, self.factory)
        Generate._verbose = False
        tgt = (1, 2, 11, 52, 117)
        onBits = sig.GetOnBits()
        self.assertEqual(tuple(onBits), tgt)
        self.assertEqual(len(onBits), len(tgt))

        bitMatches = ([((0, ), (3, ))],
                      [((0, ), (7, )), ((3, ), (7, ))],
                      [((0, ), (3, ), (7, ))], )
        for i, bit in enumerate(onBits):
            matches = Matcher.GetAtomsMatchingBit(self.factory, bit, mol)
Пример #4
0
  def GetBit(self,idx):
    """ returns a bool indicating whether or not the bit is set

    """
    if idx < 0 or idx >= self.sig.GetSize():
      raise IndexError('Index %d invalid'%(idx))
    if self.bits is not None and self.bits.has_key(idx):
      return self.bits[idx]
    
    tmp = Matcher.GetAtomsMatchingBit(self.sig,idx,self.mol,
                                      dMat=self.dMat,justOne=1,
                                      matchingAtoms=self.pattMatches)
    if not tmp or len(tmp)==0: res = 0
    else: res = 1
    
    if self.bits is not None:
      self.bits[idx] = res
    return res
Пример #5
0
 def test_exampleCode(self):
   # We make sure that the example code runs
   f = StringIO()
   with redirect_stdout(f):
     Matcher._exampleCode()
   self.assertIn('finished', f.getvalue())
Пример #6
0
 def test_exampleCode(self):
     # We make sure that the example code runs
     f = StringIO()
     with redirect_stdout(f):
         Matcher._exampleCode()
     self.assertIn('finished', f.getvalue())