コード例 #1
0
 def test_openbabel(self):
     from cinfony import obabel
     mol = obabel.readstring("smi", "CCC")
     desc = mol.calcdesc(obabel.descs[0:3])
     for d in desc:
         if desc[d] != desc[d]:
             desc[d] = '?'
     expectedDesc = {'HBA1': 0.0, 'HBD': 0.0, 'HBA2': 0.0}
     self.assertEqual(desc,expectedDesc)
コード例 #2
0
 def hide_test_openbabel(self):
     from cinfony import obabel
     mol = obabel.readstring("smi", "CCC")
     desc = mol.calcdesc(obabel.descs[0:3])
     for d in desc:
         if desc[d] != desc[d]:
             desc[d] = '?'
     #expectedDesc = {'HBA1': 0.0, 'HBD': 0.0, 'HBA2': 0.0}
     expectedDesc = {'abonds': 0.0, 'atoms': 3.0, 'bonds': 2.0}
     self.assertEqual(desc,expectedDesc)
コード例 #3
0
def getObabelDescResult(data,descList):
    """ Calculates the descriptors for the descList using obabel
        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 "obabel" not in toolkitsEnabled:
        return None
    smilesName = getSMILESAttr(data)
    if not smilesName: return None

    myDescList = [desc.replace(obabelTag,"") for desc in descList if obabelTag in desc]
    if not myDescList: return None
       
    resData = orange.ExampleTable(orange.Domain([data.domain[smilesName]] + [orange.FloatVariable(obabelTag+name) for name in myDescList],0))
    for ex in data:
        newEx = orange.Example(resData.domain)
        newEx[smilesName] = ex[smilesName]
        mol = obabel.readstring("smi", str(newEx[smilesName].value)) 
        moldesc = mol.calcdesc(myDescList)
        for desc in myDescList:
            newEx[obabelTag+desc] = moldesc[desc]
        resData.append(newEx)
    return resData
コード例 #4
0
def getObabelDescResult(data,descList):
    """ Calculates the descriptors for the descList using obabel
        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 "obabel" not in toolkitsEnabled:
        return None
    smilesName = getSMILESAttr(data)
    if not smilesName: return None

    myDescList = [desc.replace(toolkitsDef["obabel"]["tag"],"") for desc in descList if toolkitsDef["obabel"]["tag"] in desc]
    if not myDescList: return None
       
    resData = orange.ExampleTable(orange.Domain([data.domain[smilesName]] + [orange.FloatVariable(toolkitsDef["obabel"]["tag"]+name) for name in myDescList],0))
    for ex in data:
        newEx = orange.Example(resData.domain)
        newEx[smilesName] = ex[smilesName]
        mol = obabel.readstring("smi", str(newEx[smilesName].value)) 
        moldesc = mol.calcdesc(myDescList)
        for desc in myDescList:
            newEx[toolkitsDef["obabel"]["tag"]+desc] = moldesc[desc]
        resData.append(newEx)
    return resData