示例#1
0
 def hide_test_webel(self):
     from cinfony import webel
     mol = webel.readstring("smi", "CCC")
     desc = mol.calcdesc(webel.getdescs()[5:7])
     for d in desc:
         if desc[d] != desc[d]:
             desc[d] = '?'
     expectedDesc = {'AtomCountDescriptor_nAtom': 11.0, 'AutocorrelationDescriptorCharge_ATSc5': 0.0, 'AutocorrelationDescriptorCharge_ATSc4': 0.0, 'AutocorrelationDescriptorCharge_ATSc3': 0.0, 'AutocorrelationDescriptorCharge_ATSc2': 0.0, 'AutocorrelationDescriptorCharge_ATSc1': 0.0}
     self.assertEqual(desc,expectedDesc)
示例#2
0
 def test_webel(self):
     from cinfony import webel
     mol = webel.readstring("smi", "CCC")
     desc = mol.calcdesc(webel.getdescs()[5:7])
     for d in desc:
         if desc[d] != desc[d]:
             desc[d] = '?'
     expectedDesc = {'AtomCountDescriptor_nAtom': 11.0, 'AutocorrelationDescriptorCharge_ATSc5': 0.0, 'AutocorrelationDescriptorCharge_ATSc4': 0.0, 'AutocorrelationDescriptorCharge_ATSc3': 0.0, 'AutocorrelationDescriptorCharge_ATSc2': 0.0, 'AutocorrelationDescriptorCharge_ATSc1': 0.0}
     self.assertEqual(desc,expectedDesc)
示例#3
0
def get_IUPAC_name_from_web(inchi):
    """Will try getting name from web service."""
    webmol = webel.readstring('inchi', inchi)
    try:
        name = webmol.write('iupac').capitalize()
        if not name:
            names = webmol.write('names')
            if len(names) == 1:
                name = webmol.write('names')[0].capitalize()
            else:
                name = get_best_name(names)
    except IndexError:
        name = ''
    except AttributeError:
        name = ''
    return name
示例#4
0
def getWebelDescResult(data,descList):
    """ Calculates the descriptors for the descList using Webel
        It expects an attribute containing smiles with a name defined in AZOrangeConfig.SMILESNAMES
        It returns a dataset with the same smiles input variable, and as many variables as the descriptors 
       returned by the toolkit
    """
    if "webel" not in toolkitsEnabled:
        return None
    smilesName = getSMILESAttr(data)
    if not smilesName: return None

    myDescList = [desc.replace(webelTag,"") for desc in descList if webelTag in desc]
    if not myDescList: return None

    #Compute the results
    results = {}
    for ex in data:
        smile = str(ex[smilesName].value)
        mol = webel.readstring("smi", smile)
        results[smile] = mol.calcdesc(myDescList)
    # Get all the different descriptor names returned by webel
    varNames = []
    for res in results:
        for desc in results[res]:
            if desc not in varNames:
                varNames.append(desc)
    # Generate the dataset assuring the same order of examples
    resData = orange.ExampleTable(orange.Domain([data.domain[smilesName]] + [orange.FloatVariable(webelTag+name) for name in varNames],0))
    for ex in data:
        newEx = orange.Example(resData.domain)
        smile = str(ex[smilesName].value)
        newEx[smilesName] =smile
        for desc in results[smile]:
            newEx[webelTag+desc] = results[smile][desc]
        resData.append(newEx)

    return resData
示例#5
0
def getWebelDescResult(data,descList):
    """ Calculates the descriptors for the descList using Webel
        It expects an attribute containing smiles with a name defined in AZOrangeConfig.SMILESNAMES
        It returns a dataset with the same smiles input variable, and as many variables as the descriptors 
       returned by the toolkit
    """
    if "webel" not in toolkitsEnabled:
        return None
    smilesName = getSMILESAttr(data)
    if not smilesName: return None

    myDescList = [desc.replace(toolkitsDef["webel"]["tag"],"") for desc in descList if toolkitsDef["webel"]["tag"] in desc]
    if not myDescList: return None

    #Compute the results
    results = {}
    for ex in data:
        smile = str(ex[smilesName].value)
        mol = webel.readstring("smi", smile)
        results[smile] = mol.calcdesc(myDescList)
    # Get all the different descriptor names returned by webel
    varNames = []
    for res in results:
        for desc in results[res]:
            if desc not in varNames:
                varNames.append(desc)
    # Generate the dataset assuring the same order of examples
    resData = orange.ExampleTable(orange.Domain([data.domain[smilesName]] + [orange.FloatVariable(toolkitsDef["webel"]["tag"]+name) for name in varNames],0))
    for ex in data:
        newEx = orange.Example(resData.domain)
        smile = str(ex[smilesName].value)
        newEx[smilesName] =smile
        for desc in results[smile]:
            newEx[toolkitsDef["webel"]["tag"]+desc] = results[smile][desc]
        resData.append(newEx)

    return resData