Commits

Aleš Erjavec  committed de5081a

Ported orngChem widgets to PyQt4 (MoleculeMatch and SensProfile).
Added OWFragmenter widget (old uncommited widget).
(Fixes #893)

  • Participants
  • Parent commits 642ebe0

Comments (0)

Files changed (3)

File widgets/OWFragmenter.py

+"""<name>Fragmenter</name>
+<description>Find frequent fragments in molecules</description>
+"""
+
+from OWWidget import *
+import OWGUI
+
+import pybel
+import obiChem 
+
+class OWFragmenter(OWWidget):
+    settingsList = ["minSupport", "maxSupport"]
+    contextHandlers = {"active": DomainContextHandler("active", ["activeSmilesAttr"]),
+                       "inactive": DomainContextHandler("inactive", ["inactiveSmilesAttr"])
+                       }
+    
+    def __init__(self, parent=None, signalManager=None, name="Fragmenter"):
+        OWWidget.__init__(self, parent, signalManager, name, wantMainArea=False)
+        
+        self.inputs = [("Active chemicals", ExampleTable, self.setActive), ("Inactive chemicals", ExampleTable, self.setInactive)]
+        self.outputs = [("Fragments", ExampleTable)]
+        
+        self.minSupport = 0.2
+        self.maxSupport = 0.2
+        self.activeSmilesAttr = 0
+        self.inactiveSmilesAttr = 0
+        
+        self.loadSettings()
+        #  GUI
+        
+        box = OWGUI.widgetBox(self.controlArea, "Active Chemicals Set") 
+        OWGUI.doubleSpin(box, self, "minSupport", 0.05, 0.95, step=0.05, 
+                         label="Min. active frequency", 
+                         tooltip="Minimal fragment frequency in the active chemicals set.",
+                         callback=self.updateFreq)
+        
+        self.activeSmilesAttrCB = OWGUI.comboBox(box, self, "activeSmilesAttr",
+                                                 label="SMILES attribute",
+                                                 callback=self.updateAttrs)
+        
+        box = OWGUI.widgetBox(self.controlArea, "Inactive Chemicals Set")
+        OWGUI.doubleSpin(box, self, "maxSupport", 0.05, 0.95, step=0.05,
+                         label="Max. inactive frequency",
+                         tooltip="Maximal fragment frequency in the inactive chemicals set.",
+                         callback=self.updateFreq)
+        
+        self.inactiveSmilesAttrCB = OWGUI.comboBox(box, self, "inactiveSmilesAttr",
+                                                   label="SMILES attribute",
+                                                   callback=self.updateAttrs)
+        
+        OWGUI.button(self.controlArea, self, "Run",
+                     callback=self.run)
+        
+        self.activeData = None
+        self.inactiveData = None
+        self.activeDataAttrs = []
+        self.inactiveDataAttrs = []
+        
+        self.resize(100, 100)
+        
+    def updateFreq(self):
+        pass
+    
+    def updateAttrs(self):
+        #TODO: update info box
+        pass
+    
+    def setActive(self, data=None):
+        self.activeData = data
+        self.activeSmilesAttrCB.clear()
+        if data is not None:
+            fragmenter = obiChem.Fragmenter()
+            attrs = [fragmenter.FindSmilesAttr(data)]
+            self.activeDataAttrs = attrs
+            self.activeSmilesAttrCB.addItems([attr.name for attr in attrs])
+            
+    def setInactive(self, data=None):
+        self.inactiveData = data
+        self.inactiveSmilesAttrCB.clear()
+        if data is not None:
+            fragmenter = obiChem.Fragmenter()
+            attrs = [fragmenter.FindSmilesAttr(data)]
+            self.inactiveDataAttrs = attrs
+            self.inactiveSmilesAttrCB.addItems([attr.name for attr in attrs])
+            
+    def run(self):
+        active = self.getActiveSmiles()
+        inactive = self.getInactiveSmiles()
+        if not active:
+            return 
+        miner = obiChem.FragmentMiner(active, inactive, minSupport=self.minSupport,
+                                      maxSupport=self.maxSupport,
+                                      addWholeRings=True,
+                                      canonicalPruning=True,
+                                      findClosed=True)
+        fragments = []
+        import zlib, math
+        estimation = len(zlib.compress(" ".join(active), 9)) # estimation of fragments
+        estimation = math.log(len(set("".join(active)).difference(set("()[]"))) ** estimation) * (1.0 - self.minSupport) / 100
+        
+        self.progressBarInit()
+        for i, fragment in enumerate(miner.SearchIterator()):
+            fragments.append((fragment.ToSmiles(), fragment.Support()))
+            self.progressBarSet(min(100.0 * i / estimation, 100.0))
+        self.progressBarFinished()
+        
+        def getVal(var, smilesAttr, smarts ,example, returnWhat):
+            mol = pybel.readstring("smi", str(example[smilesAttr]))
+            if smarts.findall(mol):
+                return var(1)
+            else:
+                return var(0)
+            
+        fragmentVars = []
+        from functools import partial
+        for fragment, support in fragments:
+            var = orange.FloatVariable(fragment, numberOfDecimals=0)
+            var.getValueFrom = partial(getVal, var, self.activeDataAttrs[self.activeSmilesAttr], pybel.Smarts(fragment))
+            fragmentVars.append(var)
+        newdomain = orange.Domain(self.activeData.domain.attributes + fragmentVars, self.activeData.domain.classVar)
+        newdomain.addmetas(self.activeData.domain.getmetas())
+        
+        data = orange.ExampleTable(newdomain, self.activeData)
+        self.send("Fragments", data)
+        
+    def getActiveSmiles(self):
+        if self.activeData and self.activeDataAttrs:
+            attr = self.activeDataAttrs[self.activeSmilesAttr]
+            return [str(ex[attr]) for ex in self.activeData if not ex[attr].isSpecial()]
+        else:
+            return []
+        
+    def getInactiveSmiles(self):
+        if self.inactiveData and self.inactiveDataAttrs:
+            attr = self.inactiveDataAttrs[self.inactiveSmilesAttr]
+            return [str(ex[attr]) for ex in self.inactiveData if not ex[attr].isSpecial()]
+        else:
+            return []
+        
+        
+        
+            
+            
+        
+        

File widgets/OWMoleculeMatch.py

 """<name>Molecule Match</name>
-<description>Selection of molecules based on SMILES fragments</description>
+<description>Selection of molecules based on SMARTS patterns</description>
 <contact>Ales Erjavec (ales.erjavec(@at@)fri.uni-lj.si)</contact> 
 <priority>2020</priority>"""
 
 import orange
-import orngChem
+import obiChem
 from OWWidget import *
-from qt import *
 import OWGUI
 import sys
 import os
-#import vis
-import pybel
+
+try:
+    import pybel
+    HAVE_PYBEL = True
+except ImportError:
+    HAVE_PYBEL = False
+    
 
 class OWMoleculeMatch(OWWidget):
     settingsList = ["recentFragments"]
     def __init__(self, parent=None, signalManager=None, name="Molecule Match"):
-        apply(OWWidget.__init__, (self, parent, signalManager, name))
+        OWWidget.__init__(self, parent, signalManager, name, wantMainArea=False)
+        
         self.inputs = [("Molecules", ExampleTable, self.SetMoleculeTable)]
         self.outputs = [("Selected molecules", ExampleTable), ("All molecules", ExampleTable)]
+        
         self.fragment = ""
         self.recentFragments = []
         self.comboSelection = 0 
         self.loadSettings()
 
         ##GUI        
-        self.lineEdit = OWGUI.lineEdit(self.controlArea, self, "fragment", box="Fragment", callback=self.LineEditSelect)
+        self.lineEdit = OWGUI.lineEdit(self.controlArea, self, "fragment",
+                                       box="Pattern",
+                                       tooltip="A SMARTS pattern to filter the examples with.",
+                                       callback=self.LineEditSelect)
+        
         OWGUI.separator(self.controlArea)
-        self.fragmentComboBox = OWGUI.comboBox(self.controlArea, self, "comboSelection", "Recent Fragments", items=self.recentFragments, callback=self.RecentSelect)
+        
+        self.fragmentComboBox = OWGUI.comboBox(self.controlArea, self, 
+                                   "comboSelection", "Recent Patterns",
+                                   tooltip="Select a recently used pattern.",
+                                   items=self.recentFragments,
+                                   callback=self.RecentSelect)
+        
         OWGUI.separator(self.controlArea)
-        self.smilesAttrCombo = OWGUI.comboBox(self.controlArea, self, "smilesAttr", "Fragment SMILES attribute", callback=self.Process)
-        OWGUI.separator(self.controlArea)
+        
+        self.smilesAttrCombo = OWGUI.comboBox(self.controlArea, self, "smilesAttr",
+                                              "Examples SMILES attribute",
+                                              tooltip="Select the attribute in the input example \
+                                              table that stores the SMILES molecule description", 
+                                              callback=self.Process)
+        
+        OWGUI.rubber(self.controlArea)
         self.resize(100, 100)
+        
+        if not HAVE_PYBEL:
+            self.error(10, "This widget requires pybel module (part of openbabel python extension).")
 
     def SetMoleculeTable(self, data=None):
         self.data = data
             self.Process()
 
     def SetSmilesAttrCombo(self):
-        fragmenter = orngChem.Fragmenter()
+        fragmenter = obiChem.Fragmenter()
         attr = [fragmenter.FindSmilesAttr(self.data)]
-        self.smilesAttrList=attr
+        self.smilesAttrList = attr
         if self.smilesAttr > len(attr)-1:
             self.smilesAttr = 0
         self.smilesAttrCombo.clear()
-        self.smilesAttrCombo.insertStrList(map(str, attr))
+        icons = OWGUI.getAttributeIcons()
+        for a in attr:
+            self.smilesAttrCombo.addItem(QIcon(icons[a.varType]), a.name)
             
     def LineEditSelect(self):
         self.Process()
         self.recentFragments.insert(0, self.fragment)
-        self.fragmentComboBox.insertItem(self.fragment, 0)
+        self.fragmentComboBox.insertItem(0, self.fragment)
         if len(self.recentFragments) > 10:
             self.recentFragments = self.recentFragments[:10]
 
         self.Process()
 
     def Process(self):
+        if not HAVE_PYBEL:
+            return
         from functools import partial
-        newVar = orange.FloatVariable(str(self.fragment), numberOfDecimals=0)
+        newVar = orange.Variable.make(str(self.fragment), orange.VarTypes.Continuous)
+#        newVar = orange.FloatVariable(str(self.fragment), numberOfDecimals=0)
+        
         def getVal(var, smilesAttr, smarts ,example, returnWhat):
-            mol = pybel.readstring("smi", str(example[self.smilesAttrList[smilesAttr]]))
+            mol = pybel.readstring("smi", str(example[smilesAttr]))
             if smarts.findall(mol):
                 return var(1)
             else:
                 return var(0)
-        newVar.getValueFrom  = partial(getVal, newVar, self.smilesAttr, pybel.Smarts(str(self.fragment)))
-        vars = list(self.data.domain.attributes) + [newVar] + (self.data.domain.classVar and [self.data.domain.classVar] or [])
-        domain = orange.Domain(vars)
+            
+        newVar.getValueFrom  = partial(getVal, newVar, self.smilesAttrList[self.smilesAttr], pybel.Smarts(str(self.fragment)))
+        domain = orange.Domain(self.data.domain.attributes + [newVar], self.data.domain.classVar)
         domain.addmetas(self.data.domain.getmetas())
+        
         selected = []
         all = []
         for example in self.data:
     app = QApplication(sys.argv)
     w = OWMoleculeMatch()
     w.show()
-    app.setMainWidget(w)
     data = orange.ExampleTable("E:/orangecvs/Chemo/smiles.tab")
     w.SetMoleculeTable(data)
-    app.exec_loop()
+    app.exec_()
+    w.saveSettings()
+    

File widgets/OWSensProfile.py

 """
-<name>Sensitivity profile analisys</name>
+<name>Sensitivity profile analysis</name>
 """
 
 import orange
-import orngChem
+import obiChem
 from OWWidget import *
-from qt import *
 import OWGUI
-import go
+import obiGO
 
-go.loadGO()
-go.loadAnnotation()
 
 class OWSensProfile(OWWidget):
-    settingsList=["aspectNum", "fragFreq", "smilesFileName"]
+    settingsList = ["aspectNum", "fragFreq", "smilesFileName"]
+    
     def __init__(self, parent=None, signalManager=None, name="Sens profile"):
-        OWWidget.__init__(self, parent, signalManager, name)
-        self.inputs=[("Sensitivity", ExampleTable, self.sensData)]
-        self.outputs=[("Molecule fragmetns", ExampleTable),("Slim-based molecular profiles", ExampleTable),("Molecule-based slim profiles", ExampleTable),("Slim-based fragment profiles", ExampleTable), ("Fragment-based slim profiles", ExampleTable)]
+        OWWidget.__init__(self, parent, signalManager, name, wantMainArea=False)
+        self.inputs = [("Sensitivity", ExampleTable, self.sensData)]
+        self.outputs = [("Molecule fragmetns", ExampleTable), ("Slim-based molecular profiles", ExampleTable), ("Molecule-based slim profiles", ExampleTable), ("Slim-based fragment profiles", ExampleTable), ("Fragment-based slim profiles", ExampleTable)]
 
-        self.aspectNum=0
-        self.fragFreq=0.1
-        self.smilesFileName=""
-        self.slimsOnly=1
-        self.maxTerms=100
+        self.aspectNum = 0
+        self.fragFreq = 0.1
+        self.smilesFileName = ""
+        self.slimsOnly = 1
+        self.maxTerms = 100
         
-        OWGUI.radioButtonsInBox(self.controlArea, self, "aspectNum",["Process", "Function", "Component"], "Aspect")
-        #self.findTermsButton=OWGUI.button(self.controlArea, self, "Find slim terms", callback=self.findTerms)
-        OWGUI.checkBox(self.controlArea, self, "slimsOnly","Slims only")
-        OWGUI.spin(self.controlArea, self, "maxTerms", 10, 1000, box="Number of terms")
-        self.findTermsButton=OWGUI.button(self.controlArea, self, "Find terms", callback=self.findTerms)
-        OWGUI.button(self.controlArea, self, "Load selected terms", callback=self.loadSelectedTerms)
-        OWGUI.doubleSpin(self.controlArea, self, "fragFreq", 0.1, 1.0, 0.1, "Fragment frequency")
-        self.findFragmentsButton=OWGUI.button(self.controlArea, self, "Find fragments", callback=self.findFragments)
-        OWGUI.button(self.controlArea, self, "Load smiles", callback=self.loadSmiles)
-        self.commitButton=OWGUI.button(self.controlArea, self, "Commit", callback=self.commitData)
+        self.loadSettings()
+        
+        OWGUI.radioButtonsInBox(self.controlArea, self, "aspectNum",
+                                ["Process", "Function", "Component"], "Aspect")
+        
+        OWGUI.checkBox(self.controlArea, self, "slimsOnly", "Slims only",
+                       tooltip="Search for slim GO terms only")
+        
+        OWGUI.spin(self.controlArea, self, "maxTerms", 10, 1000, box="Number of terms",
+                   tooltip="Maximum number of GO terms")
+        
+        self.findTermsButton = OWGUI.button(self.controlArea, self, "Find terms",
+                                            tooltip="Run term search",
+                                            callback=self.findTerms)
+        
+        OWGUI.button(self.controlArea, self, "Load selected terms",
+                     tooltip="Load selected terms from a file",
+                     callback=self.loadSelectedTerms)
+        
+        OWGUI.doubleSpin(self.controlArea, self, "fragFreq", 0.05, 0.95, 0.05,
+                         box="Fragment frequency",
+                         tooltip="Minimum fragment frequency")
+        
+        self.findFragmentsButton = OWGUI.button(self.controlArea, self, "Find fragments",
+                                                tooltip="Run fragment search", 
+                                                callback=self.findFragments)
+        
+        OWGUI.button(self.controlArea, self, "Load smiles",
+                     tooltip="Load fragment SMILES descriptors from a file",
+                     callback=self.loadSmiles)
+        
+        self.commitButton = OWGUI.button(self.controlArea, self, "Commit",
+                                         callback=self.commitData)
+        
         self.findTermsButton.setEnabled(0)
         self.findFragmentsButton.setEnabled(0)
         self.commitButton.setEnabled(0)
         self.resize(100,100)
-        self.fragments=[]
-        self.sensDict={}
-        self.smilesDict={}
-        self.reverseSmilesDict={}
-        self.data=None
-        self.fragmentMap=None
-        self.terms=None
+        
+        self.fragments = []
+        self.sensDict = {}
+        self.smilesDict = {}
+        self.reverseSmilesDict = {}
+        self.data = None
+        self.fragmentMap = None
+        self.terms = None
+        self.ontology = None
+        self.annotations = None
+        self.selectedTerms = []
+        self.lastDir = os.path.expanduser("~/")
+        
+        
         self.loadSmiles(self.smilesFileName)
-        self.selectedTerms=[]
+        
         self.loadSettings()
         
     def findFragments(self):
         if self.smilesDict:
-            smiles=[self.smilesDict[chem] for chem in self.chemicals if chem in self.smilesDict]
-            self.fragments=orngChem.find_fragments(smiles, self.fragFreq)
-            self.fragmentMap=orngChem.map_fragments(self.fragments, smiles)
+            smiles = [self.smilesDict[chem] for chem in self.chemicals if chem in self.smilesDict]
+            fragments = []
+            miner = obiChem.FragmentMiner(smiles, [], minSupport=self.fragFreq)
+            for fragment in miner.SearchIterator():
+                fragments.append(fragment.ToSmiles())
+                
+            self.fragments = fragments
+#            self.fragmentMap = obiChem.map_fragments(self.fragments, smiles)
+            self.fragmentMap = map_fragments(self.fragments, smiles)
+
             if self.terms:
                 self.commitButton.setEnabled(1)
 
     def findTerms(self):
         if not self.data:
             return 
-        genes=[str(e[0]) for e in self.data]
-        aspect=["P","F","C"][self.aspectNum]
-        if not go.loadedGO:
-            go.loadGO()
-        if not go.loadedSlimGO:
-            go.setSlims("goslim_yeast")
-        if not go.loadedAnnotation:
-            go.loadAnnotation()
+        genes = [str(e[0]) for e in self.data]
+        aspect = ["P", "F", "C"][self.aspectNum]
+        if self.ontology is None:
+            self.ontology = obiGO.Ontology()
+            self.ontology.SetSlimsSubset("goslim_yeast")
+        
+        if self.annotations is None:
+            self.annotations = obiGO.Annotations("yeast", ontology=self.ontology)
+        
         self.progressBarInit()
-        #self.terms=go.GOTermFinder(genes, slimsOnly=self.slimsOnly, aspect=aspect, progressCallback=self.progressBarSet)
-        self.terms=go.findTerms(genes, slimsOnly=self.slimsOnly, aspect=[aspect],reportEvidence=False, progressCallback=self.progressBarSet)
+        
+        self.terms = self.annotations.GetEnrichedTerms(genes, slimsOnly=self.slimsOnly, aspect=aspect, progressCallback=self.progressBarSet)
+#        self.terms=go.findTerms(genes, slimsOnly=self.slimsOnly, aspect=[aspect],reportEvidence=False, progressCallback=self.progressBarSet)
+        
         self.progressBarFinished()
         self.filterTerms()
         if self.fragments:
             self.commitButton.setEnabled(1)
 
     def filterTerms(self):
-        ll=[]
+        ll = []
         for key, val in self.terms.items():
             if self.selectedTerms and key in self.selectedTerms:
                 ll.append((key, val))
         self.terms=dict(ll)
 
     def sendFragments(self):
-        vars=[orange.FloatVariable(frag) for frag in self.fragments]
-        mid=orange.newmetaid()
-        chemVar=orange.StringVariable("chemical name")
-        domain=orange.Domain(vars,0)
+        vars = [orange.FloatVariable(frag) for frag in self.fragments]
+        mid = orange.newmetaid()
+        chemVar = orange.StringVariable("chemical name")
+        domain = orange.Domain(vars,0)
         domain.addmeta(mid, chemVar)
-        table=orange.ExampleTable(domain)
+        table = orange.ExampleTable(domain)
         for chem, map in self.fragmentMap.items():
-            val=[map[frag] for frag in self.fragments]
-            e=orange.Example(domain, val)
-            e[mid]=chem
+            val = [map[frag] for frag in self.fragments]
+            e = orange.Example(domain, val)
+            e[mid] = chem
             table.append(e)
         self.send("Molecule fragmetns", table)
 
         for frag in self.fragments:
             vec=[]
             for term in self.terms.keys():
-                genes=self.terms[term]#[0]
-                #print genes
+                genes=self.terms[term][0]
                 chem=filter(lambda a:self.fragmentMap[a][frag], self.fragmentMap.keys())
                 avgSens=0.0
                 for g in genes:
         domain.addmeta(mid, orange.StringVariable("term id"))
         domain.addmeta(mid1, orange.StringVariable("term name"))
         table=orange.ExampleTable(domain)
-        for term, vec in zip(self.terms.keys(),matrix):
+        for term_id, vec in zip(self.terms.keys(),matrix):
             e=orange.Example(domain, list(vec))
-            e[mid]=term
-            e[mid1]=go.loadedGO.termDict[term].name
+            term = self.ontology[term_id]
+            e[mid]=term_id
+            e[mid1]=term.name
             table.append(e)
         self.send("Fragment-based slim profiles", table)
 
         for chem in self.data.domain.variables[1:]:
             vec=[]
             for term in self.terms.keys():
-                genes=self.terms[term]#[0]
+                genes=self.terms[term][0]
                 avgSens=0.0
                 for g in genes:
                     avgSens+=self.sensDict[g][chem]
         domain.addmeta(mid, orange.StringVariable("term id"))
         domain.addmeta(mid1, orange.StringVariable("term name"))
         table=orange.ExampleTable(domain)
-        for term, vec in zip(self.terms.keys(),matrix):
+        for term_id, vec in zip(self.terms.keys(),matrix):
             e=orange.Example(domain, list(vec))
-            e[mid]=term
-            e[mid1]=go.loadedGO.termDict[term].name
+            term = self.ontology[term_id]
+            e[mid]=term_id
+            e[mid1]=term.name
             table.append(e)
         self.send("Molecule-based slim profiles", table)
 
         if self.data:
             self.findTermsButton.setEnabled(1)
             self.sensDict={}
+            geneAttr = 0
             for e in data:
-                self.sensDict[str(e[0])]=e
-                self.sensDict[go.mapGeneName(str(e[0]))]=e
+                self.sensDict[str(e[geneAttr])] = e
+#                self.sensDict[go.mapGeneName(str(e[0]))]=e
             self.chemicals=[var.name for var in data.domain.variables[1:]]
         else:
             self.findTermsButton.setEnabled(0)
         
     def loadSmiles(self, filename=""):
         if not filename:
-            filename=str(QFileDialog.getOpenFileName("./","Text files (*.txt *.tab)",self,"open", "Choose a smiles file"))
+            filename = str(QFileDialog.getOpenFileName(self, "Choose a smiles file", self.lastDir, "Text files (*.txt *.tab)"))
         try:
-            #if filename.endswith(".txt"):
-            #    raise ""
-            data=orange.ExampleTable(filename)
-            self.smilesDict=[(str(e[0]), str(e[1])) for e in data if not e[1].isSpecial()]
+            data = orange.ExampleTable(filename)
+            self.smilesDict = [(str(e[0]), str(e[1])) for e in data if not e[1].isSpecial()]
         except:
-            file=open(filename)
-            data=file.read()
-            lines=data.split("\n")
-            self.smilesDict=[l.split("\t") for l in lines]
+            file = open(filename)
+            data = file.read()
+            lines = data.split("\n")
+            self.smilesDict = [l.split("\t") for l in lines]
         self.smilesDict=dict([(a[0].strip(), a[1].strip()) for a in self.smilesDict if a[1].strip() or a[1].strip()!="?"])
-        self.reverseSmilesDict=dict([(val, key) for key, val in self.smilesDict.items()])
-        self.smilesFileName=filename
+        self.reverseSmilesDict = dict([(val, key) for key, val in self.smilesDict.items()])
+        self.smilesFileName = filename
+        self.lastDir = os.path.dirname(filename)
         self.findFragmentsButton.setEnabled(1)
 
     def loadSelectedTerms(self):
-        filename=str(QFileDialog.getOpenFileName("./","Text file (*.txt)",self,"open", "Choose file containing terms"))
+        filename=str(QFileDialog.getOpenFileName(self, "Choose file containing terms", self.lastDir, "Text file (*.txt)"))
         data=open(filename)
         data=data.read().split("\n")
-        self.selectedTerms=data
+        self.selectedTerms = data
+        self.lastDir = os.path.dirname(filename)
         
+        
+def map_fragments(fragments, smiles):
+    from collections import defaultdict
+    map = defaultdict(dict)
+    for mol in smiles:
+        for frag in fragments:
+            map[mol][frag] = obiChem.ContaindIn(mol, frag)
+    return dict(map)
+
+
 if __name__=="__main__":
     import sys
-    go.setDataDir("E://GO//data")
     app=QApplication(sys.argv)
     w=OWSensProfile()
-    app.setMainWidget(w)
-    d=orange.ExampleTable("E://chem//boone//sens.tab")
+    d=orange.ExampleTable("../sens.tab")
     w.sensData(d)
     w.show()
-    app.exec_loop()
+    app.exec_()
     w.saveSettings()