Exemple #1
0
 def testStereoRefsAfterAddingOBMols(self):
     """The stereo ref for an implicit H ref was being set to 0"""
     smis = ["C", "[C@@H](Br)(Cl)I"]
     mols = [pybel.readstring("smi", smi) for smi in smis]
     # FIXME - does not seem to be possible to work out whether
     # tetrahedral or not from Python?
     stereodata = mols[1].OBMol.GetData(ob.StereoData)
     config = ob.toTetrahedralStereo(stereodata).GetConfig()
     self.assertEqual(config.from_or_towards, 4294967294)
     mols[0].OBMol += mols[1].OBMol
     self.assertEqual(mols[0].write("smi").rstrip(), ".".join(smis))
     stereodata = mols[0].OBMol.GetData(ob.StereoData)
     config = ob.toTetrahedralStereo(stereodata).GetConfig()
     self.assertEqual(config.from_or_towards, 4294967294)
Exemple #2
0
 def testStereoRefsAfterAddingOBMols(self):
     """The stereo ref for an implicit H ref was being set to 0"""
     smis = ["C", "[C@@H](Br)(Cl)I"]
     mols = [pybel.readstring("smi", smi) for smi in smis]
     # FIXME - does not seem to be possible to work out whether
     # tetrahedral or not from Python?
     stereodata = mols[1].OBMol.GetData(ob.StereoData)
     config = ob.toTetrahedralStereo(stereodata).GetConfig()
     self.assertEqual(config.from_or_towards, 4294967294)
     mols[0].OBMol += mols[1].OBMol
     self.assertEqual(mols[0].write("smi").rstrip(), ".".join(smis))
     stereodata = mols[0].OBMol.GetData(ob.StereoData)
     config = ob.toTetrahedralStereo(stereodata).GetConfig()
     self.assertEqual(config.from_or_towards, 4294967294)
Exemple #3
0
	def insert_molproperties(self, obmol):
		"""loop over openbabel mols' Properties and insert each"""
		for p in obmol.GetData():
			if p.GetDataType() == ob.PairData:
				if p.GetAttribute() == 'OpenBabel Symmetry Classes': continue
				self.db.insert_molproperty(p.GetAttribute(), p.GetValue())
			elif p.GetDataType() == ob.StereoData:
				ts = ob.toTetrahedralStereo(p)
				if ts.IsValid():
					cfg = ts.GetConfig()
					#print 'stereo',self.stereoCfgToDict(cfg, obmol)
					if cfg.specified:
						self.db.insert_molproperty('OBTetrahedralStereo', json.dumps(self.stereoCfgToDict(cfg, obmol)))
				else:
					ct = ob.toCisTransStereo(p)
					cfg = ct.GetConfig()
					#print 'cistrans',self.cistransCfgToDict(cfg, obmol)
					if cfg.specified:
						self.db.insert_molproperty('OBCisTransStereo', json.dumps(self.cistransCfgToDict(cfg, obmol)))
Exemple #4
0
	def test_stereo(self, mol):
		"""test of successful use of atom and bond stereo configurations"""
		print 'test stereo',mol.HasChiralityPerceived()
		#facade = ob.OBStereoFacade(mol);
		#for atom in ob.OBMolAtomIter(mol):
		#	if facade.HasTetrahedralStereo(atom.GetId()):
		#		stereo = self.get_atom_stereo(facade,mol,atom)
		#		print atom.GetId(), atom.GetIdx(), stereo
		for p in mol.GetData():
			if p.GetDataType() == ob.StereoData:
				ts = ob.toTetrahedralStereo(p)
				if ts.IsValid():
					cfg = ts.GetConfig()
					stereo = self.stereoCfgToDict(cfg, mol)
					print stereo
				else:
					ct = ob.toCisTransStereo(p)
					cfg = ct.GetConfig()
					cistrans = self.cistransCfgToDict(cfg, mol)
					print cistrans