gseapy/gsea.py
def parse_gmt(self, gmt):
        """gmt parser"""

        if gmt.lower().endswith(".gmt"):
            with open(gmt) as genesets:
                 genesets_dict = { line.strip().split("\t")[0]: line.strip().split("\t")[2:]
                                  for line in genesets.readlines()}
            return genesets_dict

        elif gmt in DEFAULT_LIBRARY:
            pass
        elif gmt in self.get_libraries():
            pass
        else:
            self._logger.error("No supported gene_sets: %s"%gmt)
            sys.exit(0)

        tmpname = "enrichr." + gmt + ".gmt"
        tempath = os.path.join(DEFAULT_CACHE_PATH, tmpname)
        # if file already download
        if os.path.isfile(tempath):
            self._logger.info("Enrichr library gene sets already downloaded in: %s, use local file"%DEFAULT_CACHE_PATH)
            return self.parse_gmt(tempath)
        else:
            return self._download_libraries(gmt)
def parse_gmt(self, gmt):
        """gmt parser"""

        if gmt.lower().endswith(".gmt"):
            with open(gmt) as genesets:
                 genesets_dict = { line.strip().split("\t")[0]: line.strip().split("\t")[2:]
                                  for line in genesets.readlines()}
            return genesets_dict

        elif gmt in DEFAULT_LIBRARY:
            pass
        elif gmt in self.get_libraries():
            pass
        else:
            self._logger.error("No supported gene_sets: %s"%gmt)
            sys.exit(0)

        tmpname = "enrichr." + gmt + ".gmt"
        tempath = os.path.join(DEFAULT_CACHE_PATH, tmpname)
        # if file already download
        if os.path.isfile(tempath):
            self._logger.info("Enrichr library gene sets already downloaded in: %s, use local file"%DEFAULT_CACHE_PATH)
            return self.parse_gmt(tempath)
        else:
            return self._download_libraries(gmt)
def parse_gmt ( self , gmt ) : if gmt . lower ( ) . endswith ( ".gmt" ) : with open ( gmt ) as genesets : genesets_dict = { line . strip ( ) . split ( "\t" ) [ 0 ] : line . strip ( ) . split ( "\t" ) [ 2 : ] for line in genesets . readlines ( ) } return genesets_dict elif gmt in DEFAULT_LIBRARY : pass elif gmt in self . get_libraries ( ) : pass else : self . _logger . error ( "No supported gene_sets: %s" % gmt ) sys . exit ( 0 ) tmpname = "enrichr." + gmt + ".gmt" tempath = os . path . join ( DEFAULT_CACHE_PATH , tmpname ) # if file already download if os . path . isfile ( tempath ) : self . _logger . info ( "Enrichr library gene sets already downloaded in: %s, use local file" % DEFAULT_CACHE_PATH ) return self . parse_gmt ( tempath ) else : return self . _download_libraries ( gmt )
gmt parser
gmt parser