Commits

Aleš Erjavec  committed 5a859e2

Fixes for Arary Express query response parsing.

  • Participants
  • Parent commits 8d46230

Comments (0)

Files changed (2)

File orangecontrib/bio/obiArrayExpress.py

             >>> processed_file = conn.open_file("E-TABM-1087", kind="fgem")
              
         """
-        stream = self.query_files(accession=accession, format="xml")
-        tree = ElementTree(file=stream)
-        files = tree.findall("experiment/file")
+        stream = self.query_files(accession=accession, format="json")
+        data = json.load(stream)
+        try:
+            files = data["files"]["experiment"]["file"]
+        except KeyError:
+            raise ValueError(accession)
+
         for file in files:
-            filekind = file.find("kind").text
-            fileext = file.find("extension").text
-            if filekind.strip() == kind and (fileext.strip() == ext or ext is None): 
-                url = file.find("url").text
-                return self._cache_urlopen(url.strip(), timeout=self.timeout)
-            
+            filekind = file["kind"]
+            fileext = file["extension"]
+            if (filekind == kind) and (fileext == ext or ext is None):
+                url = file["url"]
+                return self._cache_urlopen(str(url), timeout=self.timeout)
+
+        raise ValueError("%s does not have a file of kind: %r" %
+                         (accession, kind))
+
     def _cache_urlopen(self, url, timeout=30):
         if self.cache is not None:
             with self.open_cache("r") as cache:
         self.species = [e.text for e in experiment.findall("species")]
         bool_values = {"true": True, "false": False}
         self.rawdatafiles = bool_values[experiment.find("rawdatafiles").get("available","false")]
-        self.fgemdatafiles = bool_values[experiment.find("fgemdatafiles").get("available", "false")]
+        self.fgemdatafiles = bool_values[experiment.find("processeddatafiles").get("available", "false")]
         
         self.sampleattributes = []
         for sa in experiment.findall("sampleattribute"):

File orangecontrib/bio/widgets/prototypes/OWArrayExpress.py

 """
 <name>Array Express</name>
-<description>Access Array Express datasets<description>
+<description>Array Express datasets<description>
 
 """
 
 import sys
 import os
 from datetime import date
+
 import Orange
 
-from Orange.bio import obiArrayExpress
-
 from OWWidget import *
 import OWGUI
 
+from Orange.bio import obiArrayExpress
+
 
 class OWArrayExpress(OWWidget):
     settingsList = ["current_experiement", "search_string"]
 
     HEADER_LABELS = ["ID", "Title", "Species", "Assays", "Date"]
+
     def __init__(self, parent=None, signalManager=None, title="Array Express"):
         OWWidget.__init__(self, parent, signalManager, title)
 
         #####
 
         box = OWGUI.widgetBox(self.controlArea, "Info")
-        self.info = OWGUI.widgetLabel(box, "")
+        self.info = OWGUI.widgetLabel(box, "\n")
 
         OWGUI.rubber(self.controlArea)
         OWGUI.button(self.controlArea, self, "Commit", callback=self.commit)
         self.mainArea.layout().addWidget(self.experiments_view)
 
         self.setEnabled(False)
-        QTimer.singleShot(50, self.fill_experiments)
+        QTimer.singleShot(5, self.fill_experiments)
 
     def fill_experiments(self):
         self.connection = obiArrayExpress.ArrayExpressConnection()
                       [accession, title, species, assays, date])
             url = "http://www.ebi.ac.uk/arrayexpress/experiments/" + accession
             row[0].setData(QVariant(url), OWGUI.LinkRole)
+            if not exp.get("processeddatafiles", {}).get("available", False):
+                continue
+
             model.appendRow(row)
 
         self.experiments_view.setModel(model)