Changeset 1682:2e2c671e4300 in orange-bioinformatics


Ignore:
Timestamp:
06/12/12 11:15:18 (22 months ago)
Author:
Lan Zagar <lan.zagar@…>
Branch:
default
Message:

Replaced split(\n) with splitlines (closes #1160).

Files:
9 edited

Legend:

Unmodified
Added
Removed
  • _bioinformatics/obiBioMart.py

    r1636 r1682  
    165165 
    166166def de_tab(text, sep="\t"): 
    167     return [line.split(sep) for line in text.split("\n") if line.strip()] 
     167    return [line.split(sep) for line in text.splitlines() if line.strip()] 
    168168 
    169169 
  • _bioinformatics/obiGO.py

    r1643 r1682  
    177177    def ParseStanza(self, stanza): 
    178178        intern_tags = set(self._INTERN_TAGS) 
    179         for line in stanza.split("\n"): 
     179        for line in stanza.splitlines(): 
    180180            if ":" not in line: 
    181181                continue 
     
    354354        """ Return a list of defined subsets. 
    355355        """ 
    356         return [line.split()[1] for line in self.header.split("\n") if line.startswith("subsetdef:")] 
     356        return [line.split()[1] for line in self.header.splitlines() if line.startswith("subsetdef:")] 
    357357 
    358358    def SetSlimsSubset(self, subset): 
     
    648648        else: 
    649649            f = file 
    650         lines = [line for line in f.read().split("\n") if line.strip()] 
     650        lines = [line for line in f.read().splitlines() if line.strip()] 
    651651        from Orange.orng import orngMisc 
    652652        milestones = orngMisc.progressBarMilestones(len(lines), 100) 
  • _bioinformatics/obiGene.py

    r1643 r1682  
    7474        fname = orngServerFiles.localpath_download("NCBI_geneinfo", "gene_info.%s.db" % self.taxid) 
    7575        file = open(fname, "rb") 
    76         self.update(dict([(line.split("\t", 3)[1], line) for line in file.read().split("\n") if line.strip() and not line.startswith("#")])) 
     76        self.update(dict([(line.split("\t", 3)[1], line) for line in file.read().splitlines() if line.strip() and not line.startswith("#")])) 
    7777 
    7878        # NOTE orig init time for gene matcher: 2.5s, new 4s: investigate the slowdown 
     
    9494            fname = orngServerFiles.localpath_download("NCBI_geneinfo", "gene_history.%s.db" % self.taxid) 
    9595            try: 
    96                 self._history = dict([(line.split("\t")[2], GeneHistory(line)) for line in open(fname, "rb").read().split("\n")]) 
     96                self._history = dict([(line.split("\t")[2], GeneHistory(line)) for line in open(fname, "rb").read().splitlines()]) 
    9797                 
    9898            except Exception, ex: 
     
    127127        if type(file) in [str, unicode]: 
    128128            file = open(file, "rb") 
    129         return cls((line.split("\t", 3)[1], line) for line in file.read().split("\n") if line.strip() and not line.startswith("#")) 
     129        return cls((line.split("\t", 3)[1], line) for line in file.read().splitlines() if line.strip() and not line.startswith("#")) 
    130130         
    131131    def get_info(self, gene_id, def_=None): 
  • _bioinformatics/obiHomoloGene.py

    r1636 r1682  
    6666    def load(self): 
    6767        path = orngServerFiles.localpath_download(self.DOMAIN, self.FILENAME) 
    68         lines = open(path, "rb").read().split("\n")[:-1] 
     68        lines = open(path, "rb").read().splitlines()[:-1] 
    6969        self._homologs = {}  
    7070        self._homologs = dict([((h.taxonomy_id, h.gene_symbol), h) for h in [_homolog(line) for line in lines]]) 
  • _bioinformatics/obiKEGG.py

    r1636 r1682  
    228228    def to_dict(cls, text, field): 
    229229        text = cls.deindent(text, field).replace("\n ", " ") 
    230         lines = [t.split(": ",1) for t in text.split("\n")] 
     230        lines = [t.split(": ",1) for t in text.splitlines()] 
    231231        return dict([(key, [t.strip() for t in value.split(" ") if t]) for key, value in lines]) 
    232232     
    233233    @classmethod 
    234234    def to_ids(cls, text, field): 
    235         lines = [line.split(" ", 2)[:2] for line in cls.deindent(text, field).split("\n") if ":" in line.split(" ", 1)[0]] 
     235        lines = [line.split(" ", 2)[:2] for line in cls.deindent(text, field).splitlines() if ":" in line.split(" ", 1)[0]] 
    236236        return [db.lower() + id for db, id in lines]  
    237 #        ids = reduce(lambda col, line:1, text.split("\n"), []) 
     237#        ids = reduce(lambda col, line:1, text.splitlines(), []) 
    238238        return ids 
    239239    default = deindent 
     
    305305        self.entrytext = entrytext 
    306306        if not self.FIELDS: 
    307             self.FIELDS = set([line.split()[0] for line in entrytext.split("\n") if line.strip() and not line.startswith(" ")]) 
     307            self.FIELDS = set([line.split()[0] for line in entrytext.splitlines() if line.strip() and not line.startswith(" ")]) 
    308308        self._index(index) 
    309309         
  • _bioinformatics/obiKEGG2/entry/fields.py

    r1636 r1682  
    129129    def _convert(self): 
    130130        # Some dblinks can span multiple lines but are always 'indented'  
    131         links = DBSimpleField._convert(self).replace("\n ", "").split("\n") 
     131        links = DBSimpleField._convert(self).replace("\n ", "").splitlines() 
    132132        links = [tuple(link.split(": ", 1)) for link in links] 
    133133        links = [(key, [v for v in values.split(" ") if v]) \ 
  • _bioinformatics/obiOMIM.py

    r1636 r1682  
    6262    def load(self, filename): 
    6363        file = open(filename, "rb") 
    64         lines = file.read().split("\n") 
     64        lines = file.read().splitlines() 
    6565        self._disease_dict = dict([(disease(line), line) for line in lines if line]) 
    6666         
  • _bioinformatics/obiPPI.py

    r1636 r1682  
    11571157        text = open(orngServerFiles.localpath_download("PPI", "BIOGRID-ALL.tab"), "rb").read() 
    11581158        text = text.split("SOURCE\tPUBMED_ID\tORGANISM_A_ID\tORGANISM_B_ID\n", 1)[-1] 
    1159         self.interactions = [BioGRIDInteraction(line) for line in text.split("\n") if line.strip()] 
     1159        self.interactions = [BioGRIDInteraction(line) for line in text.splitlines() if line.strip()] 
    11601160         
    11611161        self.protein_interactions = defaultdict(set) 
  • docs/reference-html/obiGO-yeast.py

    r1662 r1682  
    145145 
    146146def proces_david(dav): 
    147     lines = [line.split("\t") for line in dav.split("\n") if line] 
     147    lines = [line.split("\t") for line in dav.splitlines() if line] 
    148148    keys = lines[0] 
    149149    return dict([(line[1].split("~")[0], dict(zip(keys, line))) for line in lines]) 
Note: See TracChangeset for help on using the changeset viewer.