Esempio n. 1
0
 def sendData(self):
     """Sends out data.
     """
     if self.varA and self.varB:
         etAB = dataUtilities.horizontalMerge(self.dataA,self.dataB,self.varA,self.varB)
         self.send("Merged Examples A+B", etAB)
         
         etBA = dataUtilities.horizontalMerge(self.dataB,self.dataA,self.varB,self.varA)
         self.send("Merged Examples B+A", etBA)
     else:
         self.send("Merged Examples A+B", None)
         self.send("Merged Examples B+A", None)
Esempio n. 2
0
def getCinfonyDescResults(origData,descList,radius=1):
    """Calculates the cinfony descriptors on origData
       maintains the input variables and class
       Adds the Cinfony descritors 
            Returns a new Dataset"""
    if not origData or not descList: return None
    smilesName = getSMILESAttr(origData)
    if not smilesName: return None
    #Create a new domain saving original smiles and other attributes
    newDomain = orange.Domain([attr for attr in origData.domain if attr is not origData.domain.classVar] + [orange.StringVariable("origSmiles")],origData.domain.classVar)
    data = dataUtilities.DataTable(newDomain, origData)
    # Standardize SMILES
    for ex in data:
        ex["origSmiles"] = ex[smilesName].value
    #TODO: Call here some method to standardize the attribute smilesName in place having the attr origSmiles as ID
    results = []

    # Calculate available descriptors
    res = getObabelDescResult(data,descList)
    if res: results.append(res)

    res = getRdkDescResult(data,descList,radius)
    if res: results.append(res)

    res = getWebelDescResult(data,descList)
    if res: results.append(res)

    res = getCdkDescResult(data,descList)
    if res: results.append(res)

    # Convert any nan to a '?'
    if len(results):
        for res in results:
            for ex in res:
                for attr in ex.domain:
                    if ex[attr] != ex[attr]:   # Will fail if it is 'nan'
                        ex[attr] = '?'
    # return None if no results at all 
    if not results:
        return None
    resData = results[0]
    if len(results) > 1:
        for res in results[1:]:
            resData = dataUtilities.horizontalMerge(resData, res, smilesName, smilesName)
        
    data = dataUtilities.horizontalMerge(data, resData, smilesName, smilesName)
    # Revert the SMILES back to it's original state
    for ex in data:
        ex[smilesName] = ex["origSmiles"]
    #Remove the origSmiles attributes
    data = dataUtilities.DataTable(orange.Domain([attr for attr in data.domain if attr.name != "origSmiles" and attr is not data.domain.classVar],data.domain.classVar),data)
    return data
Esempio n. 3
0
def getCinfonyDescResults(origData,descList,radius=1):
    """Calculates the cinfony descriptors on origData
       maintains the input variables and class
       Adds the Cinfony descritors 
            Returns a new Dataset"""
    if not origData or not descList: return None
    smilesName = getSMILESAttr(origData)
    if not smilesName: return None
    #Create a new domain saving original smiles and other attributes
    newDomain = orange.Domain([attr for attr in origData.domain if attr is not origData.domain.classVar] + [orange.StringVariable("origSmiles")],origData.domain.classVar)
    data = dataUtilities.DataTable(newDomain, origData)
    # Standardize SMILES
    for ex in data:
        ex["origSmiles"] = ex[smilesName].value
    #TODO: Create a method in dataUtilities to standardize the attribute smilesName in place having the attr origSmiles as ID
    if "AZutilities.extraUtilities" in sys.modules and hasattr(extraUtilities, "StandardizeSMILES"):
         # Call a method for standardizing the SMILES in Data.
         # The method is expected to change the attribute defined as smiAttr in data object
         #                                 +->Data     +-> SMILES attribuite name     +->Compound Name or attribute to act as an ID"
         extraUtilities.StandardizeSMILES(data,      smiAttr = smilesName,           cName="origSmiles") 
    results = []

    # Calculate available descriptors
    res = getObabelDescResult(data,descList)
    if res: results.append(res)
    res = getRdkDescResult(data,descList,radius)
    if res: results.append(res)
    res = getWebelDescResult(data,descList)
    if res: results.append(res)
    res = getCdkDescResult(data,descList)
    if res: results.append(res)
    # Convert any nan to a '?'
    if len(results):
        for res in results:
            for ex in res:
                for attr in ex.domain:
                    if ex[attr] != ex[attr]:   # Will fail if it is 'nan'
                        ex[attr] = '?'
    # return None if no results at all 
    if not results:
        return None
    resData = results[0]
    if len(results) > 1:
        for res in results[1:]:
            resData = dataUtilities.horizontalMerge(resData, res, smilesName, smilesName)
    data = dataUtilities.horizontalMerge(data, resData, smilesName, smilesName)
    # Revert the SMILES back to it's original state
    for ex in data:
        ex[smilesName] = ex["origSmiles"]
    #Remove the origSmiles attributes
    data = dataUtilities.DataTable(orange.Domain([attr for attr in data.domain if attr.name != "origSmiles" and attr is not data.domain.classVar],data.domain.classVar),data)
    return data
Esempio n. 4
0
from AZutilities import dataUtilities

#file1 = "XEN025dragonNewHeaderRespRDKbulk.txt"
#file2 = "XEN025SMARTcyp.txt"
file1 = "LiuJCIM2015SMARTcyp.txt"
file2 = "LiuJCIM2015dragonNewHeaderRespRDKbulk.txt"

data1 = dataUtilities.DataTable(file1)
data2 = dataUtilities.DataTable(file2)

#data = dataUtilities.horizontalMerge(data1, data2, "NAME", "MV Number")
#data = dataUtilities.horizontalMerge(data1, data2, "NAME", "MVnumber")
data = dataUtilities.horizontalMerge(data1, data2, "MVnumber", "NAME")

#data.save("XEN025dragonNewHeaderRespRDKbulkSMARTcyp.txt")
data.save("LiuJCIM2015dragonNewHeaderRespRDKbulkSMARTcyp.txt")