Changeset 1886:5a859e2c6ae1 in orange-bioinformatics for orangecontrib/bio/obiArrayExpress.py


Ignore:
Timestamp:
10/14/13 14:59:10 (6 months ago)
Author:
Ales Erjavec <ales.erjavec@…>
Branch:
default
Message:

Fixes for Arary Express query response parsing.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orangecontrib/bio/obiArrayExpress.py

    r1885 r1886  
    284284              
    285285        """ 
    286         stream = self.query_files(accession=accession, format="xml") 
    287         tree = ElementTree(file=stream) 
    288         files = tree.findall("experiment/file") 
     286        stream = self.query_files(accession=accession, format="json") 
     287        data = json.load(stream) 
     288        try: 
     289            files = data["files"]["experiment"]["file"] 
     290        except KeyError: 
     291            raise ValueError(accession) 
     292 
    289293        for file in files: 
    290             filekind = file.find("kind").text 
    291             fileext = file.find("extension").text 
    292             if filekind.strip() == kind and (fileext.strip() == ext or ext is None):  
    293                 url = file.find("url").text 
    294                 return self._cache_urlopen(url.strip(), timeout=self.timeout) 
    295              
     294            filekind = file["kind"] 
     295            fileext = file["extension"] 
     296            if (filekind == kind) and (fileext == ext or ext is None): 
     297                url = file["url"] 
     298                return self._cache_urlopen(str(url), timeout=self.timeout) 
     299 
     300        raise ValueError("%s does not have a file of kind: %r" % 
     301                         (accession, kind)) 
     302 
    296303    def _cache_urlopen(self, url, timeout=30): 
    297304        if self.cache is not None: 
     
    10171024        bool_values = {"true": True, "false": False} 
    10181025        self.rawdatafiles = bool_values[experiment.find("rawdatafiles").get("available","false")] 
    1019         self.fgemdatafiles = bool_values[experiment.find("fgemdatafiles").get("available", "false")] 
     1026        self.fgemdatafiles = bool_values[experiment.find("processeddatafiles").get("available", "false")] 
    10201027         
    10211028        self.sampleattributes = [] 
Note: See TracChangeset for help on using the changeset viewer.