Exemplo n.º 1
0
def _getDescriptors(data, ds, loadMol=True, useRDKitChemistry=True):
    if ds:
        ds = ds.split(',')
    return _apply(
        _parseMolData(data,
                      loadMol=loadMol,
                      useRDKitChemistry=useRDKitChemistry), _desc_list, ds)
Exemplo n.º 2
0
def _removeHs(data):
    mols = _parseMolData(data, loadMol=False, useRDKitChemistry=False)
    ms = []
    for molblock in mols:
        mol = parse_molblock(molblock, useRDKitChemistry=False)
        props = molblock.split("M  END")[1].strip()
        props = props if len(props) > 1 else None
        Chem.FastFindRings(mol)
        mol.UpdatePropertyCache(strict=False)
        Chem.AssignAtomChiralTagsFromStructure(mol)
        Chem.AssignStereochemistry(mol, cleanIt=True, force=True)
        ms.append((remove_hs_from_mol(mol), props))
    return _getSDFString(ms)
Exemplo n.º 3
0
def _mcs(data, asSmiles, atomCompare, bondCompare, threshold, ringMatchesRingOnly, completeRingsOnly, loadMol=False, useRDKitChemistry=False,
         isomericSmiles=False, canonical=True, kekuleSmiles=False):
    ms = _parseMolData(data, loadMol=loadMol,
                       useRDKitChemistry=useRDKitChemistry)
    if not ms:
        return
    if len(ms) == 1:
        if asSmiles:
            return Chem.MolToSmiles(ms[0])
        else:
            return Chem.MolToSmarts(ms[0])

    if threshold:
        threshold = float(threshold)
    try:
        mcs = MCS.FindMCS(ms,
                          atomCompare=atomCompare,
                          bondCompare=bondCompare,
                          ringMatchesRingOnly=ringMatchesRingOnly,
                          completeRingsOnly=completeRingsOnly,
                          threshold=threshold)
    except TypeError:
        ac = MCS.AtomCompare.CompareAny
        if hasattr(MCS.AtomCompare, atomCompare):
            ac = getattr(MCS.AtomCompare, atomCompare)
        bc = MCS.BondCompare.CompareOrder
        if hasattr(MCS.BondCompare, bondCompare):
            bc = getattr(MCS.BondCompare, bondCompare)
        th = 1.0
        if threshold:
            th = threshold
        mcs = MCS.FindMCS(ms,
                          atomCompare=ac,
                          bondCompare=bc,
                          ringMatchesRingOnly=ringMatchesRingOnly,
                          completeRingsOnly=completeRingsOnly,
                          threshold=th
                          )
    if hasattr(mcs, 'smarts'):
        res = mcs.smarts
    else:
        res = mcs.smartsString
    if asSmiles:
        p = Chem.MolFromSmarts(res)
        for m in ms:
            if m.HasSubstructMatch(p):
                match = m.GetSubstructMatch(p)
                res = Chem.MolFragmentToSmiles(m, atomsToUse=match, isomericSmiles=isomericSmiles, canonical=canonical,
                                               kekuleSmiles=kekuleSmiles)
                break
    return res
Exemplo n.º 4
0
def _ctab2svg(data,
              size,
              loadMol=True,
              useRDKitChemistry=False,
              kekulize=False,
              atomMapNumber=False,
              computeCoords=False):
    return _mols2svg(_parseMolData(data,
                                   loadMol=loadMol,
                                   useRDKitChemistry=useRDKitChemistry),
                     size,
                     kekulize=kekulize,
                     atomMapNumber=atomMapNumber,
                     computeCoords=computeCoords)
Exemplo n.º 5
0
def _sdf2SimilarityMapSVG(data,
                          width=500,
                          height=500,
                          radius=2,
                          fingerprint='morgan',
                          loadMol=True,
                          useRDKitChemistry=True,
                          format='svg'):
    return _similarityMapSVG(_parseMolData(
        data, loadMol=loadMol, useRDKitChemistry=useRDKitChemistry),
                             width=width,
                             height=height,
                             radius=radius,
                             fingerprint=fingerprint,
                             format=format)
Exemplo n.º 6
0
def _highlightCtabFragmentSVG(data,
                              smarts,
                              size,
                              loadMol=True,
                              useRDKitChemistry=False,
                              kekulize=False,
                              atomMapNumber=False,
                              computeCoords=False,
                              force=False):
    mols = _parseMolData(data,
                         loadMol=loadMol,
                         useRDKitChemistry=useRDKitChemistry)
    matches = _getMatches(mols, smarts, force)
    return _mols2svg(mols,
                     size,
                     kekulize=kekulize,
                     atomMapNumber=atomMapNumber,
                     computeCoords=computeCoords,
                     highlightAtomLists=matches)
Exemplo n.º 7
0
def _ctab22D(data, loadMol=True, useRDKitChemistry=False):
    mols = _parseMolData(data, loadMol=True, useRDKitChemistry=False)
    optimisedMols = _apply(mols, _2D22D)
    return _getSDFString(optimisedMols)
Exemplo n.º 8
0
def _get_alerts(data, loadMol=True, useRDKitChemistry=False):
    mols = _parseMolData(data,
                         loadMol=loadMol,
                         useRDKitChemistry=useRDKitChemistry)
    res = _apply(mols, get_matches)
    return json.dumps(res)
Exemplo n.º 9
0
def _ctab2inchi(data, loadMol=False, useRDKitChemistry=False):
    return '\n'.join(_apply(_parseMolData(data, loadMol=False, useRDKitChemistry=False), Chem.MolBlockToInchi))
Exemplo n.º 10
0
def _ctab2smiles(data, loadMol=True, useRDKitChemistry=True, delimiter=' ', nameHeader='Name', includeHeader=True):
    return _getSMILESString(_parseMolData(data, loadMol=True, useRDKitChemistry=True),
                            delimiter=delimiter, nameHeader=nameHeader, includeHeader=includeHeader)
Exemplo n.º 11
0
def _ctab2smarts(data, loadMol=True, useRDKitChemistry=True):
    return _getSMARTSString(_parseMolData(data, loadMol=True, useRDKitChemistry=True))
Exemplo n.º 12
0
def _is3D(data, loadMol=True, useRDKitChemistry=True):
    mols = _parseMolData(data,
                         loadMol=loadMol,
                         useRDKitChemistry=useRDKitChemistry)
    flags = _apply(mols, _check3Dcoords)
    return json.dumps(flags)
Exemplo n.º 13
0
def _getChemblDescriptors(data, loadMol=True, useRDKitChemistry=True):
    return _apply(
        _parseMolData(data,
                      loadMol=loadMol,
                      useRDKitChemistry=useRDKitChemistry), _chembl_desc_list)
Exemplo n.º 14
0
def _check(data, loadMol=False, useRDKitChemistry=False):
    mols = _parseMolData(data, loadMol=loadMol, useRDKitChemistry=useRDKitChemistry)
    res = _apply(mols, checker.check_molblock)
    return json.dumps(res)
Exemplo n.º 15
0
def _exclude(data, loadMol=True, useRDKitChemistry=False):
    mols = _parseMolData(data, loadMol=loadMol, useRDKitChemistry=useRDKitChemistry)
    res = _apply(mols, exclude_flag, False)
    return json.dumps(res)
Exemplo n.º 16
0
def _standardize(data, loadMol=False, useRDKitChemistry=False):
    mols = _parseMolData(data, loadMol=loadMol, useRDKitChemistry=useRDKitChemistry)
    res = _apply(mols, standardizer.standardize_molblock)
    res_list = [{'standard_molblock': m} for m in res]
    return json.dumps(res_list)
Exemplo n.º 17
0
def _get_parent(data, loadMol=False, useRDKitChemistry=False):
    mols = _parseMolData(data, loadMol=loadMol, useRDKitChemistry=useRDKitChemistry)
    res = _apply(mols, standardizer.get_parent_molblock)
    res_dict = [{k: v for e in m for k, v in zip(('parent_molblock', 'exclude'), m)} for m in res]
    return json.dumps(res_dict)