Exemplo n.º 1
0
def generate_molecule_from_smiles(smiles, name=None):
    """
    Parameters
    ----------
    smiles : str
       The canonical isomeric SMILES string.
    name : str, optional, default=None
       If specified, the molecule title will be set to this; if not, the IUPAC name will be assigned.

    """

    # Generate a molecule from canonical isomeric SMILES.
    molecule = oechem.OEMol()
    if not oechem.OEParseSmiles(molecule, smiles):
        raise ValueError("The supplied SMILES '%s' could not be parsed." %
                         smiles)

    # Assign aromaticity.
    oechem.OEAssignAromaticFlags(molecule, oechem.OEAroModelOpenEye)

    # Add hydrogens.
    oechem.OEAddExplicitHydrogens(molecule)

    # Set title.
    if name is None:
        # Set title to IUPAC name.
        name = oeiupac.OECreateIUPACName(molecule)
    molecule.SetTitle(name)

    # Check for any missing atom names, if found reassign all of them.
    if any([atom.GetName() == '' for atom in molecule.GetAtoms()]):
        oechem.OETriposAtomNames(molecule)

    return molecule
Exemplo n.º 2
0
def create_molecule_from_smiles(smiles):
    """
    Create an ``OEMol`` molecule from a smiles pattern.

    .. todo:: Replace with the toolkit function when finished.

    Parameters
    ----------
    smiles : str
        Smiles pattern

    Returns
    -------
    molecule : OEMol
        OEMol with 3D coordinates, but no charges
     """

    from openeye import oechem, oeomega

    # Check cache
    if smiles in _cached_molecules:
        return copy.deepcopy(_cached_molecules[smiles])

    # Create molecule from smiles.
    molecule = oechem.OEMol()
    parse_smiles_options = oechem.OEParseSmilesOptions(quiet=True)

    if not oechem.OEParseSmiles(molecule, smiles, parse_smiles_options):

        logging.warning('Could not parse SMILES: ' + smiles)
        return False

    # Normalize molecule
    oechem.OEAssignAromaticFlags(molecule, oechem.OEAroModelOpenEye)
    oechem.OEAddExplicitHydrogens(molecule)
    # oechem.OETriposAtomNames(molecule)

    # Create configuration
    omega = oeomega.OEOmega()

    omega.SetMaxConfs(1)
    omega.SetIncludeInput(False)
    omega.SetCanonOrder(False)
    omega.SetSampleHydrogens(True)
    omega.SetStrictStereo(True)
    omega.SetStrictAtomTypes(False)

    status = omega(molecule)

    if not status:

        logging.warning('Could not generate a conformer for ' + smiles)
        return False

    _cached_molecules[smiles] = molecule

    return molecule
Exemplo n.º 3
0
    def getoutput(self, smi):
        mol = oe.OEGraphMol()
        msgstream.clear()
        ok = oe.OEParseSmiles(mol, smi)
        if not ok:
            msg = msgstream.str().decode("utf-8")
            if "Kekul" in msg:
                return None, "Kekulization_failure"
            else:
                return None, "Parse_error"

        return [atom.GetImplicitHCount() for atom in mol.GetAtoms()], None
Exemplo n.º 4
0
def test_MDL_aromaticity(verbose=False):
    """Test support for alternate aromaticity models."""
    ffxml = StringIO(ffxml_MDL_contents)
    ff = ForceField(ffxml)
    from openeye import oechem
    mol = oechem.OEMol()
    oechem.OEParseSmiles(mol, 'c12c(cccc1)occ2')
    oechem.OEAddExplicitHydrogens(mol)

    labels = ff.labelMolecules([mol], verbose=True)
    # The bond 6-7 should get the b16 parameter iff the MDL model is working, otherwise it will pick up just the generic
    details = labels[0]['HarmonicBondGenerator']
    found = False
    for (atom_indices, pid, smirks) in details:
        if pid == 'b16' and atom_indices == [6, 7]:
            found = True
    if not found: raise Exception("Didn't find right param.")
Exemplo n.º 5
0
def test_drug_bank_oe(input, output):
    """

    Parameters
    ----------
    input
    output

    Returns
    -------

    """
    mol = oechem.OEMol()
    oechem.OEParseSmiles(mol, input)
    assert cmiles.utils.mol_to_smiles(mol,
                                      mapped=True,
                                      isomeric=True,
                                      explicit_hydrogen=True) == output
Exemplo n.º 6
0
    def test_parameter_completeness_check(self):
        """Test that proper exceptions are raised if a force field fails to assign parameters to valence terms in a molecule."""
        from openeye import oechem
        mol = oechem.OEMol()
        oechem.OEParseSmiles(mol, 'CCC')
        oechem.OEAddExplicitHydrogens(mol)
        oechem.OETriposAtomNames(mol)
        ff = ForceField(get_data_filename('forcefield/Frosst_AlkEthOH.ffxml'))
        topology = generateTopologyFromOEMol(mol)

        # Test nonbonded error checking by wiping out required LJ parameter
        params = ff.getParameter(paramID='n0001')
        params['smirks'] = '[#136:1]'
        ff.setParameter(paramID='n0001', params=params)
        ff.setParameter(paramID='n0002', params=params)
        with self.assertRaises(Exception):
            system = ff.createSystem(topology, [mol])
        ff = ForceField(get_data_filename('forcefield/Frosst_AlkEthOH.ffxml'))

        # Test bond error checking by wiping out a required bond parameter
        params = ff.getParameter(paramID='b0001')
        params['smirks'] = '[#136:1]~[*:2]'
        ff.setParameter(paramID='b0001', params=params)
        with self.assertRaises(Exception):
            system = ff.createSystem(topology, [mol])
        ff = ForceField(get_data_filename('forcefield/Frosst_AlkEthOH.ffxml'))

        # Test angle error checking by wiping out a required angle parameter
        params = ff.getParameter(paramID='a0001')
        params['smirks'] = '[#136:1]~[*:2]~[*:3]'
        ff.setParameter(paramID='a0001', params=params)
        with self.assertRaises(Exception):
            system = ff.createSystem(topology, [mol])
        ff = ForceField(get_data_filename('forcefield/Frosst_AlkEthOH.ffxml'))

        # Test torsion error checking by wiping out a required torsion parameter
        params = ff.getParameter(paramID='t0001')
        params['smirks'] = '[#136:1]~[*:2]~[*:3]~[*:4]'
        ff.setParameter(paramID='t0001', params=params)
        ff.setParameter(paramID='t0004', params=params)
        with self.assertRaises(Exception):
            system = ff.createSystem(topology, [mol])
        ff = ForceField(get_data_filename('forcefield/Frosst_AlkEthOH.ffxml'))
Exemplo n.º 7
0
    def standardizeSmiles(self, smiles, type="ISOMERIC"):  # pylint: disable=redefined-builtin
        """ Return a standardized SMILES (type) or None
        """
        smilesOut = None
        try:
            mol = oechem.OEGraphMol()
            if (oechem.OEParseSmiles(mol, smiles) == 1):
                oechem.OEAssignAromaticFlags(mol)
                if type == "CANNONICAL":
                    smilesOut = oechem.OECreateCanSmiString(mol)
                elif type == "ISOMERIC":
                    smilesOut = oechem.OECreateIsoSmiString(mol)
            else:
                logger.error("Unable to parse input SMILES '%s'", smiles)

        except Exception as e:
            logger.exception("Error '%s' occured. Arguments %s.", str(e), e.args)

        return smilesOut
Exemplo n.º 8
0
def test_molecule_labeling(verbose=False):
    """Test using labelMolecules to see which parameters applied to an oemol."""
    from openeye import oechem
    mol = oechem.OEMol()
    oechem.OEParseSmiles(mol, 'CCC')
    oechem.OEAddExplicitHydrogens(mol)
    ff = ForceField(get_data_filename('forcefield/Frosst_AlkEthOH.ffxml'))
    labels = ff.labelMolecules([mol], verbose=verbose)

    # Check that force terms aren't empty
    print(labels[0].keys())
    if not 'HarmonicBondGenerator' in labels[0].keys():
        raise Exception("No force term assigned for harmonic bonds.")
    if not 'HarmonicAngleGenerator' in labels[0].keys():
        raise Exception("No force term assigned for harmonic angles.")
    if not 'PeriodicTorsionGenerator' in labels[0].keys():
        raise Exception("No force term assigned for periodic torsions.")
    if not 'NonbondedGenerator' in labels[0].keys():
        raise Exception("No nonbonded force term assigned.")
Exemplo n.º 9
0
def smiles_to_oemol(smiles):
    """Create a OEMolBuilder from a smiles string.

    Parameters
    ----------
    smiles : str
        SMILES representation of desired molecule.
    Returns
    -------
    molecule : OEMol
        A normalized molecule with desired smiles string.

    """
    molecule = oechem.OEMol()
    if not oechem.OEParseSmiles(molecule, smiles):
        raise ValueError("The supplied SMILES '%s' could not be parsed." % smiles)

    molecule = normalize_molecule(molecule)

    return molecule
Exemplo n.º 10
0
    def smilesToMol(self, smiles, limitPerceptions=False, messageTag=None):
        """Parse the input SMILES string and return a molecule object (OeGraphMol).

        Args:
            smiles (str): SMILES string
            limitPerceptions (bool): flag to limit the perceptions/transformations of input SMILES

        Returns:
            object: OeGraphMol() object or None for failure
        """
        try:
            label = messageTag if messageTag else ""
            mol = oechem.OEGraphMol()
            smiles.strip()
            if limitPerceptions:
                # convert the SMILES string into a molecule
                if oechem.OEParseSmiles(mol, smiles, False, False):
                    return mol
                else:
                    logger.debug(
                        "%s parsing failed for input SMILES string %s", label,
                        smiles)
                    logger.error("%s parsing failed for input SMILES string",
                                 label)
            else:
                if oechem.OESmilesToMol(mol, smiles):
                    return mol
                else:
                    logger.debug(
                        "%s converting failed for input SMILES string %s",
                        label, smiles)
                    logger.error(
                        "%s converting failed for input SMILES string", label)
        except Exception as e:
            logger.exception("Failing with %s", str(e))
        return None
Exemplo n.º 11
0
def create_molecule_from_smiles(smiles, number_of_conformers=1):
    """
    Create an ``OEMol`` molecule from a smiles pattern.

    .. todo:: Replace with the toolkit function when finished.

    Parameters
    ----------
    smiles : str
        The smiles pattern to create the molecule from.
    number_of_conformers: int
        The number of conformers to generate for the molecule using Omega.

    Returns
    -------
    molecule : OEMol
        OEMol with no charges, and a number of conformers as specified
        by `number_of_conformers`
     """

    from openeye import oechem, oeomega

    # Check cache
    if (number_of_conformers, smiles) in _cached_molecules:
        return copy.deepcopy(_cached_molecules[(number_of_conformers, smiles)])

    # Create molecule from smiles.
    molecule = oechem.OEMol()
    parse_smiles_options = oechem.OEParseSmilesOptions(quiet=True)

    if not oechem.OEParseSmiles(molecule, smiles, parse_smiles_options):

        logging.warning('Could not parse SMILES: ' + smiles)
        return None

    # Normalize molecule
    oechem.OEAssignAromaticFlags(molecule, oechem.OEAroModelOpenEye)
    oechem.OEAddExplicitHydrogens(molecule)

    # Create configuration
    if number_of_conformers > 0:

        omega = oeomega.OEOmega()

        omega.SetMaxConfs(number_of_conformers)
        omega.SetIncludeInput(False)
        omega.SetCanonOrder(False)
        omega.SetSampleHydrogens(True)
        omega.SetStrictStereo(True)
        omega.SetStrictAtomTypes(False)

        status = omega(molecule)

        if not status:

            logging.warning('Could not generate a conformer for ' + smiles)
            return None

    _cached_molecules[(number_of_conformers, smiles)] = molecule

    return molecule
Exemplo n.º 12
0
#!/usr/bin/env python
# (C) 2017 OpenEye Scientific Software Inc. All rights reserved.
#
# TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
# provided to current licensees or subscribers of OpenEye products or
# SaaS offerings (each a "Customer").
# Customer is hereby permitted to use, copy, and modify the Sample Code,
# subject to these terms. OpenEye claims no rights to Customer's
# modifications. Modification of Sample Code is at Customer's sole and
# exclusive risk. Sample Code may require Customer to have a then
# current license or subscription to the applicable OpenEye offering.
# THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED.  OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT
# NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall OpenEye be
# liable for any damages or liability in connection with the Sample Code
# or its use.

# @ <SNIPPET>
from __future__ import print_function
from openeye import oechem

mol = oechem.OEGraphMol()

oechem.OEParseSmiles(mol, "c1ccccc1")
print("Number of benzene atoms:", mol.NumAtoms())

oechem.OEParseSmiles(mol, "c1ccccc1O")
print("Number of phenol atoms:", mol.NumAtoms())
# @ </SNIPPET>
Exemplo n.º 13
0
def smiles_to_pdf(smiles, file_path, rows=10, columns=6):
    """Creates a PDF file containing images of a list of molecules
    described by their SMILES patterns.

    Parameters
    ----------
    smiles: list of str or tuple of str
        The SMILES patterns of the molecules. The list can either contain
        a list of single SMILES strings, or a tuple of SMILES strings. If
        tuples of SMILES are provided, these smiles will be grouped together
        in the output. All tuples in the list must have the same length.
    file_path: str
        The file path to save the pdf to.
    rows: int
        The maximum number of rows of molecules to include per page.
    columns: int
        The maximum number of molecules to include per row.
    """

    assert len(smiles) > 0

    # Validate the input type.
    assert all(isinstance(x, str)
               for x in smiles) or all(isinstance(x, tuple) for x in smiles)

    # Make sure the smiles tuples are the same length.
    molecules_per_group = 1

    if isinstance(smiles[0], tuple):

        assert (len(x) == len(smiles[0]) for x in smiles)
        molecules_per_group = len(smiles[0])

    # Convert the list of tuple to list of strings.
    if isinstance(smiles[0], tuple):
        smiles = [".".join(sorted(x)) for x in smiles]

    # Create OEMol objects for each unique smiles pattern provided.
    oe_molecules = {}

    unique_smiles = set(smiles)

    for smiles_pattern in unique_smiles:

        molecule = oechem.OEMol()
        oechem.OEParseSmiles(molecule, smiles_pattern)

        oe_molecules[smiles_pattern] = molecule

    # Take into account that each group may have more than one molecule
    columns = int(math.floor(columns / molecules_per_group))

    report_options = oedepict.OEReportOptions(rows, columns)
    report_options.SetHeaderHeight(25)
    report_options.SetFooterHeight(25)
    report_options.SetCellGap(4)
    report_options.SetPageMargins(10)

    report = oedepict.OEReport(report_options)

    cell_width, cell_height = report.GetCellWidth(), report.GetCellHeight()

    display_options = oedepict.OE2DMolDisplayOptions(
        cell_width, cell_height, oedepict.OEScale_Default * 0.5)
    display_options.SetAromaticStyle(oedepict.OEAromaticStyle_Circle)

    pen = oedepict.OEPen(oechem.OEBlack, oechem.OEBlack, oedepict.OEFill_On,
                         1.0)
    display_options.SetDefaultBondPen(pen)

    interface = oechem.OEInterface()
    oedepict.OESetup2DMolDisplayOptions(display_options, interface)

    for i, smiles_pattern in enumerate(smiles):

        cell = report.NewCell()

        oe_molecule = oechem.OEMol(oe_molecules[smiles_pattern])
        oedepict.OEPrepareDepiction(oe_molecule, False, True)

        display = oedepict.OE2DMolDisplay(oe_molecule, display_options)
        oedepict.OERenderMolecule(cell, display)

    oedepict.OEWriteReport(file_path, report)
Exemplo n.º 14
0
def cluster_similar_molecules(
    smiles, fingerprint_type=oegraphsim.OEFPType_Tree, eps=0.5, min_samples=2
):
    """The method attempts to cluster a sets of molecules based on their
    similarity using a Tanimoto distance metric and the `sklearn` DBSCAN
    clustering code.

    Notes
    -----
    This is based on the code by David Mobley:

    https://github.com/openforcefield/release-1-benchmarking/blob/master/QM_molecule_selection/divide_sets.ipynb

    Parameters
    ----------
    smiles: list of str
        The SMILES representations of the molecules to cluster.
    fingerprint_type
        The type of molecular fingerprint to use.
    eps: float
        The `eps` parameter to pass as an argument to DBSCAN while clustering.
    min_samples: int
        The `min_samples` parameter to pass as an argument to DBSCAN while
        clustering.

    Returns
    -------
    dict of str and list of str
        The clustered SMILES patterns.
    """
    assert isinstance(smiles, list)

    # Build fingerprints
    fingerprints = {}

    for smiles_pattern in smiles:

        oe_molecule = oechem.OEMol()
        oechem.OEParseSmiles(oe_molecule, smiles_pattern)

        fingerprint = oegraphsim.OEFingerPrint()
        oegraphsim.OEMakeFP(fingerprint, oe_molecule, fingerprint_type)

        fingerprints[smiles_pattern] = fingerprint

    # Build a similarity matrix
    distance_matrix = np.zeros((len(smiles), len(smiles)))

    for i, smiles_i in enumerate(smiles):

        for j, smiles_j in enumerate(smiles):

            if i == j:
                continue

            distance_matrix[i, j] = 1.0 - oegraphsim.OETanimoto(
                fingerprints[smiles_i], fingerprints[smiles_j]
            )

    # Cluster the data
    clustering = DBSCAN(eps=eps, min_samples=min_samples, metric="precomputed")
    clustered_smiles = clustering.fit(distance_matrix)

    labels = clustered_smiles.labels_

    smiles_by_cluster = {}

    for label in set(labels):

        smiles_by_cluster[label] = [
            smiles[i] for i, x in enumerate(labels) if x == label
        ]

    return smiles_by_cluster
Exemplo n.º 15
0
        def smiles2mol(self, smiles):

            mol = oechem.OEGraphMol()
            oechem.OEParseSmiles(mol, smiles)
            return mol
Exemplo n.º 16
0
 def getoutput(self, smi):
     mol = oe.OEGraphMol()
     ok = oe.OEParseSmiles(mol, smi)
     assert ok
     return oe.OECreateSmiString(mol, flags)
Exemplo n.º 17
0
#
# TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
# provided to current licensees or subscribers of OpenEye products or
# SaaS offerings (each a "Customer").
# Customer is hereby permitted to use, copy, and modify the Sample Code,
# subject to these terms. OpenEye claims no rights to Customer's
# modifications. Modification of Sample Code is at Customer's sole and
# exclusive risk. Sample Code may require Customer to have a then
# current license or subscription to the applicable OpenEye offering.
# THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED.  OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT
# NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall OpenEye be
# liable for any damages or liability in connection with the Sample Code
# or its use.

# @ <SNIPPET>
from __future__ import print_function
from openeye import oechem

mol = oechem.OEGraphMol()
if not oechem.OEParseSmiles(mol, "C1=CC=CC=C1"):
    print("SMILES string was invalid!")

print("Number of aromatic atoms =",
      oechem.OECount(mol, oechem.OEIsAromaticAtom()))
oechem.OEAssignAromaticFlags(mol)
print("Number of aromatic atoms =",
      oechem.OECount(mol, oechem.OEIsAromaticAtom()))
# @ </SNIPPET>
Exemplo n.º 18
0
# SaaS offerings (each a "Customer").
# Customer is hereby permitted to use, copy, and modify the Sample Code,
# subject to these terms. OpenEye claims no rights to Customer's
# modifications. Modification of Sample Code is at Customer's sole and
# exclusive risk. Sample Code may require Customer to have a then
# current license or subscription to the applicable OpenEye offering.
# THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED.  OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT
# NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall OpenEye be
# liable for any damages or liability in connection with the Sample Code
# or its use.
# @ <SNIPPET>
from openeye import oechem

qmol = oechem.OEQMol()
oechem.OEParseSmarts(qmol, "c1cc[o,n,s]c1")
qscreen = oechem.OESubSearchScreen()
oechem.OEMakeSubSearchQueryScreen(qscreen, qmol, oechem.OESubSearchScreenType_SMARTS)

tmol = oechem.OEGraphMol()
oechem.OEParseSmiles(tmol, "c1ccoc1")
tscreen = oechem.OESubSearchScreen()
oechem.OEMakeSubSearchTargetScreen(tscreen, tmol, oechem.OESubSearchScreenType_MDL)

if oechem.OESameSubSearchScreenTypes(qscreen, tscreen):
    print("same screen types")
else:
    print("different screen types")
# @ </SNIPPET>
# TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
# provided to current licensees or subscribers of OpenEye products or
# SaaS offerings (each a "Customer").
# Customer is hereby permitted to use, copy, and modify the Sample Code,
# subject to these terms. OpenEye claims no rights to Customer's
# modifications. Modification of Sample Code is at Customer's sole and
# exclusive risk. Sample Code may require Customer to have a then
# current license or subscription to the applicable OpenEye offering.
# THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED.  OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT
# NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall OpenEye be
# liable for any damages or liability in connection with the Sample Code
# or its use.

# @ <SNIPPET>
from __future__ import print_function
from openeye import oechem
import sys

mol = oechem.OEGraphMol()
for smi in sys.stdin:
    mol.Clear()
    smi = smi.strip()
    if oechem.OEParseSmiles(mol, smi):
        oechem.OEAssignAromaticFlags(mol)
        print(oechem.OECreateCanSmiString(mol))
    else:
        oechem.OEThrow.Warning("%s is an invalid SMILES!" % smi)
# @ </SNIPPET>
Exemplo n.º 20
0
# exclusive risk. Sample Code may require Customer to have a then
# current license or subscription to the applicable OpenEye offering.
# THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED.  OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT
# NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall OpenEye be
# liable for any damages or liability in connection with the Sample Code
# or its use.

# @ <SNIPPET>
from __future__ import print_function
from openeye import oechem

# @ <SNIPPET-AROM-PERCEIVE>
mol = oechem.OEGraphMol()
oechem.OEParseSmiles(mol, "C1[NH]C=CC=1CO")
oechem.OEAssignAromaticFlags(mol)
# @ </SNIPPET-AROM-PERCEIVE>

# @ <SNIPPET-AROM-LOOP1>
for atom in mol.GetAtoms(oechem.OEIsAromaticAtom()):
    print(atom.GetIdx(), oechem.OEGetAtomicSymbol(atom.GetAtomicNum()))
# @ </SNIPPET-AROM-LOOP1>

# @ <SNIPPET-AROM-LOOP2>
for atom in mol.GetAtoms():
    if atom.IsAromatic():
        print(atom.GetIdx(), oechem.OEGetAtomicSymbol(atom.GetAtomicNum()))
# @ </SNIPPET-AROM-LOOP2>
# @ </SNIPPET>
Exemplo n.º 21
0
#!/usr/bin/env python
# (C) 2017 OpenEye Scientific Software Inc. All rights reserved.
#
# TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
# provided to current licensees or subscribers of OpenEye products or
# SaaS offerings (each a "Customer").
# Customer is hereby permitted to use, copy, and modify the Sample Code,
# subject to these terms. OpenEye claims no rights to Customer's
# modifications. Modification of Sample Code is at Customer's sole and
# exclusive risk. Sample Code may require Customer to have a then
# current license or subscription to the applicable OpenEye offering.
# THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED.  OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT
# NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall OpenEye be
# liable for any damages or liability in connection with the Sample Code
# or its use.

# @ <SNIPPET>
from __future__ import print_function
from openeye import oechem

mol = oechem.OEGraphMol()
oechem.OEParseSmiles(mol, "n1ccncc1")

print("Canonical smiles :", oechem.OECreateCanSmiString(mol))
oechem.OEClearAromaticFlags(mol)
oechem.OEKekulize(mol)
print("Kekule smiles    :", oechem.OECreateCanSmiString(mol))
# @ </SNIPPET>
Exemplo n.º 22
0
 def getoutput(self, smi):
     mol = oe.OEGraphMol()
     ok = oe.OEParseSmiles(mol, smi)
     assert ok
     oe.OEAssignAromaticFlags(mol)
     return oe.OECreateSmiString(mol, 0)
Exemplo n.º 23
0
# exclusive risk. Sample Code may require Customer to have a then
# current license or subscription to the applicable OpenEye offering.
# THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED.  OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT
# NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall OpenEye be
# liable for any damages or liability in connection with the Sample Code
# or its use.

# @ <SNIPPET>
from __future__ import print_function
from openeye import oechem

# @ <SNIPPET-DATA-ITER>
mol = oechem.OEGraphMol()
oechem.OEParseSmiles(mol, "C1CCCC(C(=O)O)C1")
activitytag = oechem.OEGetTag("activity")
mol.AddData(activitytag, "antiarthritic")
mol.AddData(activitytag, "antiinflammatory")
mol.SetData("weight", oechem.OECalculateMolecularWeight(mol))

for gdata in mol.GetDataIter():
    print(oechem.OEGetTag(gdata.GetTag()), gdata.GetData())
# @ </SNIPPET-DATA-ITER>

# @ <SNIPPET-DATA-ITER-WITH-TAG>
for gdata in mol.GetDataIter(oechem.OEGetTag("activity")):
    print(oechem.OEGetTag(gdata.GetTag()), gdata.GetData())
# @ </SNIPPET-DATA-ITER-WITH-TAG>
# @ </SNIPPET>