Beispiel #1
0
    def testCreateSGroup(self):
        mol = Chem.MolFromMolBlock('''
  Mrv1810 10061910532D          

  0  0  0     0  0            999 V3000
M  V30 BEGIN CTAB
M  V30 COUNTS 4 3 0 0 0
M  V30 BEGIN ATOM
M  V30 1 O -14.8632 3.7053 0 0
M  V30 2 C -13.3232 3.7053 0 0
M  V30 3 O -11.7832 3.7053 0 0
M  V30 4 * -10.2453 3.6247 0 0
M  V30 END ATOM
M  V30 BEGIN BOND
M  V30 1 1 1 2
M  V30 2 1 2 3
M  V30 3 1 3 4
M  V30 END BOND
M  V30 END CTAB
M  END''')
        self.assertTrue(mol is not None)
        mcpy = Chem.Mol(mol)
        sg = Chem.CreateMolSubstanceGroup(mcpy, "SRU")
        self.assertEqual(sg.GetProp("TYPE"), "SRU")
        sg = Chem.GetMolSubstanceGroupWithIdx(mcpy, 0)
        sg.AddBracket((Geometry.Point3D(-11.1, 4.6,
                                        0), Geometry.Point3D(-11.1, 2.7, 0)))
        sg.AddBracket((Geometry.Point3D(-13.9, 2.7,
                                        0), Geometry.Point3D(-13.9, 4.6, 0)))
        sg.AddAtomWithIdx(1)
        sg.AddAtomWithIdx(2)
        sg.AddBondWithIdx(0)
        sg.AddBondWithIdx(2)
        sg.SetProp("CONNECT", "HT")
        sg.SetProp("LABEL", "n")
        mb = Chem.MolToMolBlock(mcpy, forceV3000=True)
        self.assertNotEqual(mb.find('V30 1 SRU'), -1)
        self.assertNotEqual(mb.find('BRKXYZ'), -1)
        self.assertNotEqual(mb.find('CONNECT=HT'), -1)
Beispiel #2
0
  def testAttachPoints(self):
    mol = Chem.MolFromMolBlock('''
  Mrv2014 09012006262D          

  0  0  0     0  0            999 V3000
M  V30 BEGIN CTAB
M  V30 COUNTS 4 3 1 0 0
M  V30 BEGIN ATOM
M  V30 1 C -5.0833 0.0833 0 0
M  V30 2 C -3.7497 0.8533 0 0
M  V30 3 O -2.416 0.0833 0 0
M  V30 4 O -3.7497 2.3933 0 0
M  V30 END ATOM
M  V30 BEGIN BOND
M  V30 1 1 1 2
M  V30 2 1 2 3
M  V30 3 2 2 4
M  V30 END BOND
M  V30 BEGIN SGROUP
M  V30 1 SUP 0 ATOMS=(3 2 3 4) SAP=(3 2 1 1) XBONDS=(1 1) LABEL=CO2H ESTATE=E
M  V30 END SGROUP
M  V30 END CTAB
M  END''')
    sgs = Chem.GetMolSubstanceGroups(mol)
    self.assertEqual(len(sgs), 1)
    sg0 = sgs[0]
    pd = sg0.GetPropsAsDict()
    self.assertTrue('TYPE' in pd)
    self.assertEqual(pd['TYPE'], 'SUP')
    aps = sg0.GetAttachPoints()
    self.assertEqual(len(aps), 1)
    self.assertEqual(aps[0].aIdx, 1)
    self.assertEqual(aps[0].lvIdx, 0)
    self.assertEqual(aps[0].id, '1')

    mol = Chem.MolFromMolBlock('''
  Mrv2014 09012006262D          

  0  0  0     0  0            999 V3000
M  V30 BEGIN CTAB
M  V30 COUNTS 4 3 0 0 0
M  V30 BEGIN ATOM
M  V30 1 C -5.0833 0.0833 0 0
M  V30 2 C -3.7497 0.8533 0 0
M  V30 3 O -2.416 0.0833 0 0
M  V30 4 O -3.7497 2.3933 0 0
M  V30 END ATOM
M  V30 BEGIN BOND
M  V30 1 1 1 2
M  V30 2 1 2 3
M  V30 3 2 2 4
M  V30 END BOND
M  V30 END CTAB
M  END''')
    sgs = Chem.GetMolSubstanceGroups(mol)
    self.assertEqual(len(sgs), 0)

    sg = Chem.CreateMolSubstanceGroup(mol, "SUP")
    sg.AddAtomWithIdx(1)
    sg.AddAtomWithIdx(2)
    sg.AddAtomWithIdx(3)
    sg.AddBondWithIdx(0)
    sg.SetProp('LABEL', 'CO2H')
    sg.AddAttachPoint(1, 0, '1')
    molb = Chem.MolToV3KMolBlock(mol)
    self.assertGreater(
      molb.find('M  V30 1 SUP 0 ATOMS=(3 2 3 4) XBONDS=(1 1) LABEL=CO2H SAP=(3 2 1 1)'), 0)