Changeset 1608:bb559485a499 in orange-bioinformatics


Ignore:
Timestamp:
03/27/12 15:41:25 (2 years ago)
Author:
Lan Zagar <lan.zagar@…>
Branch:
default
Message:

Handle different line endings (see #1160).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • obiGeneSets.py

    r1576 r1608  
    249249    """ 
    250250    Eech line consists of tab separated elements. First is 
    251     the geneset name, next is it's description.  
     251    the geneset name, next is it's description. 
    252252     
    253253    For now the description is skipped. 
    254254    """ 
    255255    def hline(s): 
    256         tabs = [ tab.strip() for tab in s.split("\t") ] 
    257         return  obiGeneSets.GeneSet(id=tabs[0], description=tabs[1], hierarchy=(name,), genes=tabs[2:]) 
     256        tabs = [tab.strip() for tab in s.split("\t")] 
     257        return obiGeneSets.GeneSet(id=tabs[0], description=tabs[1], 
     258                                   hierarchy=(name,), genes=tabs[2:]) 
    258259 
    259260    def handleNELines(s, fn): 
     
    262263        Return a list of results for each line. 
    263264        """ 
    264         lines = s.split("\n") 
    265         lines = [ l.strip() for l in lines ] 
    266         lines = filter(lambda x: x != "", lines) 
    267         return [ fn(l) for l in lines ] 
     265        lines = (l.strip() for l in s.splitlines()) 
     266        return [fn(l) for l in lines if l] 
    268267 
    269268    return obiGeneSets.GeneSets(handleNELines(contents, hline)) 
Note: See TracChangeset for help on using the changeset viewer.