Example #1
0
 def test_chiral_scaffolds(self):
     """
     Test chiral scaffold generation.
     """
     achiral_scaffold = self.engine.get_scaffold(self.mols[1])
     self.engine = ScaffoldGenerator(include_chirality=True)
     chiral_scaffold = self.engine.get_scaffold(self.mols[1])
     assert '@' not in achiral_scaffold
     assert '@' in chiral_scaffold
     assert (Chem.MolFromSmiles(achiral_scaffold).GetNumAtoms() ==
             Chem.MolFromSmiles(chiral_scaffold).GetNumAtoms())
Example #2
0
 def setUp(self):
     """
     Set up tests.
     """
     smiles = [
         'CC(=O)OC1=CC=CC=C1C(=O)O',
         'CN1C=C(C2=CC=CC=C21)C(=O)[C@@H]3CCC4=C(C3)NC=N4'
     ]
     names = ['aspirin', 'ramosetron']
     self.mols = []
     for this_smiles, name in zip(smiles, names):
         mol = Chem.MolFromSmiles(this_smiles)
         mol.SetProp('_Name', name)
         self.mols.append(mol)
     self.engine = ScaffoldGenerator()
Example #3
0
class Scaffold(Featurizer):
    """
    Molecular scaffolds.

    Parameters
    ----------
    Parameters
    ----------
    include_chirality : : bool, optional (default False)
        Include chirality in scaffolds.
    """
    name = 'scaffold'

    def __init__(self, include_chirality=False):
        self.include_chirality = include_chirality
        self.engine = ScaffoldGenerator(include_chirality=include_chirality)

    def _featurize(self, mol):
        """
        Generate a 2D depiction of a molecule.

        Parameters
        ----------
        mol : RDKit Mol
            Molecule.
        """
        return self.engine.get_scaffold(mol)
Example #4
0
class TestScaffoldGenerator(unittest.TestCase):
    """
    Test ScaffoldGenerator.
    """
    def setUp(self):
        """
        Set up tests.
        """
        smiles = [
            'CC(=O)OC1=CC=CC=C1C(=O)O',
            'CN1C=C(C2=CC=CC=C21)C(=O)[C@@H]3CCC4=C(C3)NC=N4'
        ]
        names = ['aspirin', 'ramosetron']
        self.mols = []
        for this_smiles, name in zip(smiles, names):
            mol = Chem.MolFromSmiles(this_smiles)
            mol.SetProp('_Name', name)
            self.mols.append(mol)
        self.engine = ScaffoldGenerator()

    def test_scaffolds(self):
        """
        Test scaffold generation.
        """
        scaffolds = [self.engine.get_scaffold(mol) for mol in self.mols]
        scaffold_mols = [
            Chem.MolFromSmiles(scaffold) for scaffold in scaffolds
        ]
        for mol, ref_mol in zip(scaffold_mols, self.mols):
            assert mol.GetNumAtoms() < ref_mol.GetNumAtoms()
        assert scaffold_mols[0].GetNumAtoms() == 6
        assert scaffold_mols[1].GetNumAtoms() == 20

    def test_chiral_scaffolds(self):
        """
        Test chiral scaffold generation.
        """
        achiral_scaffold = self.engine.get_scaffold(self.mols[1])
        self.engine = ScaffoldGenerator(include_chirality=True)
        chiral_scaffold = self.engine.get_scaffold(self.mols[1])
        assert '@' not in achiral_scaffold
        assert '@' in chiral_scaffold
        assert (Chem.MolFromSmiles(achiral_scaffold).GetNumAtoms() ==
                Chem.MolFromSmiles(chiral_scaffold).GetNumAtoms())
Example #5
0
 def test_chiral_scaffolds(self):
     """
     Test chiral scaffold generation.
     """
     achiral_scaffold = self.engine.get_scaffold(self.mols[1])
     self.engine = ScaffoldGenerator(include_chirality=True)
     chiral_scaffold = self.engine.get_scaffold(self.mols[1])
     assert '@' not in achiral_scaffold
     assert '@' in chiral_scaffold
     assert (Chem.MolFromSmiles(achiral_scaffold).GetNumAtoms() ==
             Chem.MolFromSmiles(chiral_scaffold).GetNumAtoms())
Example #6
0
class TestScaffoldGenerator(unittest.TestCase):
    """
    Test ScaffoldGenerator.
    """
    def setUp(self):
        """
        Set up tests.
        """
        smiles = ['CC(=O)OC1=CC=CC=C1C(=O)O',
                  'CN1C=C(C2=CC=CC=C21)C(=O)[C@@H]3CCC4=C(C3)NC=N4']
        names = ['aspirin', 'ramosetron']
        self.mols = []
        for this_smiles, name in zip(smiles, names):
            mol = Chem.MolFromSmiles(this_smiles)
            mol.SetProp('_Name', name)
            self.mols.append(mol)
        self.engine = ScaffoldGenerator()

    def test_scaffolds(self):
        """
        Test scaffold generation.
        """
        scaffolds = [self.engine.get_scaffold(mol) for mol in self.mols]
        scaffold_mols = [Chem.MolFromSmiles(scaffold)
                         for scaffold in scaffolds]
        for mol, ref_mol in zip(scaffold_mols, self.mols):
            assert mol.GetNumAtoms() < ref_mol.GetNumAtoms()
        assert scaffold_mols[0].GetNumAtoms() == 6
        assert scaffold_mols[1].GetNumAtoms() == 20

    def test_chiral_scaffolds(self):
        """
        Test chiral scaffold generation.
        """
        achiral_scaffold = self.engine.get_scaffold(self.mols[1])
        self.engine = ScaffoldGenerator(include_chirality=True)
        chiral_scaffold = self.engine.get_scaffold(self.mols[1])
        assert '@' not in achiral_scaffold
        assert '@' in chiral_scaffold
        assert (Chem.MolFromSmiles(achiral_scaffold).GetNumAtoms() ==
                Chem.MolFromSmiles(chiral_scaffold).GetNumAtoms())
Example #7
0
def get_scaffolds(mols, include_chirality=False):
    """
    Get Murcko scaffolds for molecules.

    Murcko scaffolds are described in DOI: 10.1021/jm9602928. They are
    essentially that part of the molecule consisting of rings and the linker
    atoms between them.

    Parameters
    ----------
    mols : array_like
        Molecules.
    include_chirality : bool, optional (default False)
        Whether to include chirality in scaffolds.
    """
    print "Generating molecule scaffolds..."
    engine = ScaffoldGenerator(include_chirality=include_chirality)
    scaffolds = []
    for mol in mols:
        scaffolds.append(engine.get_scaffold(mol))
    scaffolds = np.asarray(scaffolds)
    return scaffolds
Example #8
0
 def setUp(self):
     """
     Set up tests.
     """
     smiles = ['CC(=O)OC1=CC=CC=C1C(=O)O',
               'CN1C=C(C2=CC=CC=C21)C(=O)[C@@H]3CCC4=C(C3)NC=N4']
     names = ['aspirin', 'ramosetron']
     self.mols = []
     for this_smiles, name in zip(smiles, names):
         mol = Chem.MolFromSmiles(this_smiles)
         mol.SetProp('_Name', name)
         self.mols.append(mol)
     self.engine = ScaffoldGenerator()
Example #9
0
def get_scaffolds(mols, include_chirality=False):
    """
    Get Murcko scaffolds for molecules.

    Murcko scaffolds are described in DOI: 10.1021/jm9602928. They are
    essentially that part of the molecule consisting of rings and the linker
    atoms between them.

    Parameters
    ----------
    mols : array_like
        Molecules.
    include_chirality : bool, optional (default False)
        Whether to include chirality in scaffolds.
    """
    print "Generating molecule scaffolds..."
    engine = ScaffoldGenerator(include_chirality=include_chirality)
    scaffolds = []
    for mol in mols:
        scaffolds.append(engine.get_scaffold(mol))
    scaffolds = np.asarray(scaffolds)
    return scaffolds
Example #10
0
def generate_scaffold(smiles, include_chirality=False):
  """Compute the Bemis-Murcko scaffold for a SMILES string."""
  mol = Chem.MolFromSmiles(smiles)
  engine = ScaffoldGenerator(include_chirality=include_chirality)
  scaffold = engine.get_scaffold(mol)
  return scaffold
Example #11
0
 def __init__(self, include_chirality=False):
     self.include_chirality = include_chirality
     self.engine = ScaffoldGenerator(include_chirality=include_chirality)