def test_ReadMolFromMolFile(self): """Test reading the sample MOL file.""" molecule = PyChem2D() molecule.ReadMolFromMolFile(MOL_FILE) self.assertEqual(molecule.mol.GetNumHeavyAtoms(), self.num_heavy_atoms) self.assertEqual(Chem.rdMolDescriptors.CalcMolFormula(molecule.mol), self.formula) self.molecules.append(molecule)
def test_ReadMolFromSmiles(self): """Test reading from sample SMILES.""" molecule = PyChem2D() molecule.ReadMolFromSmile( 'CC1=C2[C@H](C(=O)[C@@]3([C@H](C[C@@H]4' '[C@]([C@H]3[C@@H]([C@@](C2(C)C)(C[C@@H]1OC(=O)[C@@H]([C@H]' '(C5=CC=CC=C5)NC(=O)OC(C)(C)C)O)O)OC(=O)C6=CC=CC=C6)(CO4)OC(=O)C)O)C)O' ) self.assertEqual(molecule.mol.GetNumHeavyAtoms(), self.num_heavy_atoms) self.assertEqual(Chem.rdMolDescriptors.CalcMolFormula(molecule.mol), self.formula) self.molecules.append(molecule)
def test_ReadMolFromInchi(self): """Test reading from sample InChI.""" molecule = PyChem2D() molecule.ReadMolFromInchi( 'InChI=1S/C43H53NO14/c1-22-26' '(55-37(51)32(48)30(24-15-11-9-12-16-24)44-38(52)58-39(3,4)5)' '20-43(53)35(56-36(50)25-17-13-10-14-18-25)33-41(8,34(49)31(47)' '29(22)40(43,6)7)27(46)19-28-42(33,21-54-28)57-23(2)45/h9-18,' '26-28,30-33,35,46-48,53H,19-21H2,1-8H3,(H,44,52)/t26-,27-,28+,' '30-,31+,32+,33-,35-,41+,42-,43+/m0/s1') self.assertEqual(molecule.mol.GetNumHeavyAtoms(), self.num_heavy_atoms) self.assertEqual(Chem.rdMolDescriptors.CalcMolFormula(molecule.mol), self.formula) self.molecules.append(molecule)
def test_ChEMBL_GetMolFromEBI(self): """Test reading from sample ChEMBL ID.""" molecule = PyChem2D() # Ensure TimeoutError is consistent passed, tryouts = False, 0 while not passed and tryouts < 5: try: molecule.GetMolFromNCBI('CHEMBL92') passed = True except TimeoutError: tryouts += 1 self.assertLess( tryouts, 5, 'Too many Timeout exceptions. Verify your internet connection.') self.assertEqual(molecule.mol.GetNumHeavyAtoms(), self.num_heavy_atoms) self.assertEqual(Chem.rdMolDescriptors.CalcMolFormula(molecule.mol), self.formula) self.molecules.append(molecule)