# Path: oe_utils/chem/scaffold.py
# class Scaffold(object):
#     """
#     Extract the scaffold of a molecule. The default parameters give the
#     Murcko scaffold as defined in J. Med. Chem. 1996, 39, 2887-289.
# 
#     To be part of the scaffold, an atom must be in a ring or in a linker
#     between two rings.
# 
#     Parameters
#     ----------
#     stereo : bool, optional (default False)
#         Whether to retain stereochemistry in the scaffold.
#     """
#     def __init__(self, stereo=False):
#         self.stereo = stereo
# 
#     def __call__(self, mol):
#         """
#         Extract the scaffold of a molecule.
# 
#         Parameters
#         ----------
#         mol : OEMol
#             Molecule.
#         """
#         return self.get_scaffold(mol)
# 
#     def get_scaffold(self, mol):
#         """
#         Extract the scaffold of a molecule.
# 
#         Parameters
#         ----------
#         mol : OEMol
#             Molecule.
#         """
#         mol = mol.CreateCopy()
#         pred = IsInScaffold()
#         OEFindRingAtomsAndBonds(mol)  # prepare molecule
#         scaffold = OEMol()
#         adjust_h_count = True
#         OESubsetMol(scaffold, mol, pred, adjust_h_count)
# 
#         # acyclic molecules: return the original molecule
#         if not scaffold.IsValid():
#             scaffold = mol
# 
#         # handle stereochemistry
#         if not self.stereo:
#             flat = OECreateCanSmiString(scaffold)
#             scaffold = OEMol()
#             OESmilesToMol(scaffold, flat)
#         else:
#             OEPerceiveChiral(scaffold)
#         return scaffold
# 
#     def get_scaffold_smiles(self, mol):
#         """
#         Extract the scaffold of a molecule as a SMILES string.
# 
#         Parameters
#         ----------
#         mol : OEMol
#             Molecule.
#         """
#         return OECreateIsoSmiString(self.get_scaffold(mol))


import unittest
from oe_utils.chem.scaffold import Scaffold
from openeye.oechem import *
"""
Test scaffold utilities.
"""



class TestScaffold(unittest.TestCase):
    """
    Test Scaffold.
    """
    def setUp(self):
        """
        Set up tests.
        """
        smiles = 'C[C@@]1(C(=O)NC(=O)N(C1=O)C)C2=CCCCC2 (S)-Hexobarbital'
        self.mol = OEMol()
        OESmilesToMol(self.mol, smiles)

# Path: oe_utils/chem/scaffold.py
# class Scaffold(object):
#     """
#     Extract the scaffold of a molecule. The default parameters give the
#     Murcko scaffold as defined in J. Med. Chem. 1996, 39, 2887-289.
# 
#     To be part of the scaffold, an atom must be in a ring or in a linker
#     between two rings.
# 
#     Parameters
#     ----------
#     stereo : bool, optional (default False)
#         Whether to retain stereochemistry in the scaffold.
#     """
#     def __init__(self, stereo=False):
#         self.stereo = stereo
# 
#     def __call__(self, mol):
#         """
#         Extract the scaffold of a molecule.
# 
#         Parameters
#         ----------
#         mol : OEMol
#             Molecule.
#         """
#         return self.get_scaffold(mol)
# 
#     def get_scaffold(self, mol):
#         """
#         Extract the scaffold of a molecule.
# 
#         Parameters
#         ----------
#         mol : OEMol
#             Molecule.
#         """
#         mol = mol.CreateCopy()
#         pred = IsInScaffold()
#         OEFindRingAtomsAndBonds(mol)  # prepare molecule
#         scaffold = OEMol()
#         adjust_h_count = True
#         OESubsetMol(scaffold, mol, pred, adjust_h_count)
# 
#         # acyclic molecules: return the original molecule
#         if not scaffold.IsValid():
#             scaffold = mol
# 
#         # handle stereochemistry
#         if not self.stereo:
#             flat = OECreateCanSmiString(scaffold)
#             scaffold = OEMol()
#             OESmilesToMol(scaffold, flat)
#         else:
#             OEPerceiveChiral(scaffold)
#         return scaffold
# 
#     def get_scaffold_smiles(self, mol):
#         """
#         Extract the scaffold of a molecule as a SMILES string.
# 
#         Parameters
#         ----------
#         mol : OEMol
#             Molecule.
#         """
#         return OECreateIsoSmiString(self.get_scaffold(mol))


# Path: oe_utils/chem/tests/test_scaffold.py
import unittest
from oe_utils.chem.scaffold import Scaffold
from openeye.oechem import *

"""
Test scaffold utilities.
"""



class TestScaffold(unittest.TestCase):
    """
    Test Scaffold.
    """
    def setUp(self):
        """
        Set up tests.
        """
        smiles = 'C[C@@]1(C(=O)NC(=O)N(C1=O)C)C2=CCCCC2 (S)-Hexobarbital'
        self.mol = OEMol()
        OESmilesToMol(self.mol, smiles)

        self.engine = Scaffold()