Пример #1
0
    def testIsInCycle(self):

        # ethane
        molecule = Molecule().fromSMILES('CC')
        for atom in molecule.atoms:
            self.assertFalse(molecule.isAtomInCycle(atom))
        for atom1 in molecule.bonds:
            for atom2 in molecule.bonds[atom1]:
                self.assertFalse(molecule.isBondInCycle(atom1, atom2))

        # cyclohexane
        molecule = Molecule().fromInChI('InChI=1/C6H12/c1-2-4-6-5-3-1/h1-6H2')
        for atom in molecule.atoms:
            if atom.isHydrogen():
                self.assertFalse(molecule.isAtomInCycle(atom))
            elif atom.isCarbon():
                self.assertTrue(molecule.isAtomInCycle(atom))
        for atom1 in molecule.bonds:
            for atom2 in molecule.bonds[atom1]:
                if atom1.isCarbon() and atom2.isCarbon():
                    self.assertTrue(molecule.isBondInCycle(atom1, atom2))
                else:
                    self.assertFalse(molecule.isBondInCycle(atom1, atom2))