예제 #1
0
 def test5EmbedFail(self):
   arr = Numeric.array([[0,1.0,5.0],
                        [1.0,0,1.0],
                        [3.0,1.0,0]],Numeric.Float)
   self.failUnlessRaises(ValueError,lambda : DG.EmbedBoundsMatrix(arr))
   #DG.EmbedBoundsMatrix(arr,randomizeOnFailure=0,randomSeed=1)
   DG.EmbedBoundsMatrix(arr,randomizeOnFailure=1);
예제 #2
0
 def test5EmbedFail(self):
   arr = np.array([[0, 1.0, 5.0],
                   [1.0, 0, 1.0],
                   [3.0, 1.0, 0]], np.float)
   self.assertRaises(ValueError, lambda : DG.EmbedBoundsMatrix(arr))
   #DG.EmbedBoundsMatrix(arr,randomizeOnFailure=0,randomSeed=1)
   DG.EmbedBoundsMatrix(arr, randomizeOnFailure=1)
예제 #3
0
def EmbedMol(mol,
             bm,
             atomMatch=None,
             weight=2.0,
             randomSeed=-1,
             excludedVolumes=None):
    """  Generates an embedding for a molecule based on a bounds matrix and adds
  a conformer (id 0) to the molecule

  if the optional argument atomMatch is provided, it will be used to provide
  supplemental weights for the embedding routine (used in the optimization
  phase to ensure that the resulting geometry really does satisfy the
  pharmacophore).

  if the excludedVolumes is provided, it should be a sequence of
  ExcludedVolume objects

  >>> m = Chem.MolFromSmiles('c1ccccc1C')
  >>> bounds = MolDG.GetMoleculeBoundsMatrix(m)
  >>> bounds.shape == (7, 7)
  True
  >>> m.GetNumConformers()
  0
  >>> EmbedMol(m,bounds,randomSeed=23)
  >>> m.GetNumConformers()
  1


  """
    nAts = mol.GetNumAtoms()
    weights = []
    if (atomMatch):
        for i in range(len(atomMatch)):
            for j in range(i + 1, len(atomMatch)):
                weights.append((i, j, weight))
    if (excludedVolumes):
        for vol in excludedVolumes:
            idx = vol.index
            # excluded volumes affect every other atom:
            for i in range(nAts):
                weights.append((i, idx, weight))
    coords = DG.EmbedBoundsMatrix(bm,
                                  weights=weights,
                                  numZeroFail=1,
                                  randomSeed=randomSeed)
    #for row in coords:
    #  print(', '.join(['%.2f'%x for x in row]))

    conf = Chem.Conformer(nAts)
    conf.SetId(0)
    for i in range(nAts):
        conf.SetAtomPosition(i, list(coords[i]))
    if excludedVolumes:
        for vol in excludedVolumes:
            vol.pos = numpy.array(coords[vol.index])

        #print('   % 7.4f   % 7.4f   % 7.4f Ar  0  0  0  0  0  0  0  0  0  0  0  0'%tuple(coords[-1]), file=sys.stderr)
    mol.AddConformer(conf)
예제 #4
0
  def test6EmbedConstraints(self):
    arr = Numeric.array([[0.0,1.0,1.0],
                         [1.0,0.0,1.0],
                         [0.99,1.0,0.0]],
                         Numeric.Float)
    self.failUnless(DG.DoTriangleSmoothing(arr))
    coords = DG.EmbedBoundsMatrix(arr, randomSeed=100)
    v1 = coords[0]-coords[1]
    v2 = coords[1]-coords[2]
    d1 = Numeric.dot(v1,v1)
    
    self.failUnless(feq(d1,1.0,2e-3));
    d2 = Numeric.dot(v2,v2)
    self.failUnless(feq(d2,1.0,2e-3));
    arr = Numeric.array([[0.0,1.0,1.0,1.01],
                         [1.0,0.0,1.0,1.0],
                         [1.0,1.0,0.0,1.0],
                         [0.99,1.0,1.0,0.0],
                         ],Numeric.Float)
    self.failUnless(DG.DoTriangleSmoothing(arr))
    coords = DG.EmbedBoundsMatrix(arr)
    v1 = coords[0]-coords[1]
    v2 = coords[1]-coords[2]
    d1 = Numeric.dot(v1,v1)
    self.failUnless(feq(d1,1.0,1e-3));
    d2 = Numeric.dot(v2,v2)
    self.failUnless(feq(d2,1.0,1e-3));

    return
    # this test is currently (rev:4769) passing on windows and
    # failing on linux.  It's kind of dependent on fp precision, so
    # it's probably ok to ditch it.
    arr = Numeric.array([[0.0,1.0,1.0,1.0],
                         [1.0,0.0,1.0,1.0],
                         [1.0,1.0,0.0,1.0],
                         [1.0,1.0,1.0,0.0],
                         ],Numeric.Float)
    self.failUnless(DG.DoTriangleSmoothing(arr))
    coords = DG.EmbedBoundsMatrix(arr,randomSeed=100)
    v1 = coords[0]-coords[1]
    v2 = coords[1]-coords[2]
    d1 = Numeric.dot(v1,v1)
    self.failUnless(feq(d1,1.0,1e-3));
    d2 = Numeric.dot(v2,v2)
    self.failUnless(feq(d2,1.0,1e-3));
예제 #5
0
파일: rough_test.py 프로젝트: rwest/rdkit
 def test4Embed(self):
     arr = np.array([[0, 1.0, 5.0], [1.0, 0, 1.0], [0.0, 1.0, 0]], np.float)
     self.assertTrue(DG.DoTriangleSmoothing(arr))
     coords = DG.EmbedBoundsMatrix(arr, randomSeed=100)
     v1 = coords[0] - coords[1]
     v2 = coords[1] - coords[2]
     d1 = np.dot(v1, v1)
     self.assertTrue(feq(d1, 1.0, 0.001))
     d2 = np.dot(v2, v2)
     self.assertTrue(feq(d2, 1.0, 0.001))
예제 #6
0
 def test4Embed(self):
   arr = Numeric.array([[0,1.0,5.0],
                        [1.0,0,1.0],
                        [0.0,1.0,0]],Numeric.Float)
   self.failUnless(DG.DoTriangleSmoothing(arr))
   coords = DG.EmbedBoundsMatrix(arr,randomSeed=100);
   v1 = coords[0]-coords[1]
   v2 = coords[1]-coords[2]
   d1 = Numeric.dot(v1,v1)
   self.failUnless(feq(d1,1.0, 0.001));
   d2 = Numeric.dot(v2,v2)
   self.failUnless(feq(d2,1.0, 0.001));