class BuilderTest(unittest.TestCase): def setUp(self): self.builder = MolBuilder() def test_builder1(self): result = self.builder.build_smiles("CCCO") self.assertIsInstance(result, Molecule) self.assertNotEqual(result.atoms, []) atomO = [atom for atom in result.atoms if atom.symbol == "O"][0] atomC1 = atomO.connected[0] self.assertEqual(atomC1.symbol, "C") self.assertEqual(len(atomC1.connected), 2) atomC2 = [atom for atom in atomC1.connected if atom != atomO][0] self.assertEqual(atomC2.symbol, "C") self.assertEqual(len(atomC2.connected), 2) atomC3 = [atom for atom in atomC2.connected if atom != atomC1][0] self.assertEqual(atomC3.symbol, "C") self.assertEqual(len(atomC3.connected), 1) def test_builder2(self): result = self.builder.build_smiles("CC(=O)C") self.assertIsInstance(result, Molecule) self.assertNotEqual(result.atoms, []) atomO = [atom for atom in result.atoms if atom.symbol == "O"][0] atomC1 = atomO.connected[0] self.assertEqual(atomC1.symbol, "C") self.assertEqual(len(atomC1.connected), 3) other_C_atoms = [atom for atom in atomC1.connected if atom.symbol != "O"] for atomC in other_C_atoms: self.assertEqual(atomC.symbol, "C") self.assertEqual(len(atomC.connected), 1)
def setUp(self): self.builder = MolBuilder()