def parse_genesets(self):
enrichr_library = self.get_libraries()<EOL>if isinstance(self.gene_sets, list):<EOL><INDENT>gss = self.gene_sets<EOL><DEDENT>elif isinstance(self.gene_sets, str):<EOL><INDENT>gss = [ g.strip() for g in self.gene_sets.strip().split("<STR_LIT:U+002C>") ]<EOL><DEDENT>elif isinstance(self.gene_sets, dict):<EOL><INDENT>gss = [self.gene_sets]<EOL><DEDENT>else:<EOL><INDENT>raise Exception("<STR_LIT>")<EOL><DEDENT>gss_exist = [] <EOL>for g in gss:<EOL><INDENT>if isinstance(g, dict): <EOL><INDENT>gss_exist.append(g)<EOL>continue<EOL><DEDENT>if isinstance(g, str): <EOL><INDENT>if g in enrichr_library: <EOL><INDENT>gss_exist.append(g)<EOL>continue<EOL><DEDENT>if g.lower().endswith("<STR_LIT>") and os.path.exists(g):<EOL><INDENT>self._logger.info("<STR_LIT>"%g)<EOL>with open(g) as genesets:<EOL><INDENT>g_dict = { line.strip().split("<STR_LIT:\t>")[<NUM_LIT:0>]: line.strip().split("<STR_LIT:\t>")[<NUM_LIT:2>:]<EOL>for line in genesets.readlines() }<EOL><DEDENT>gss_exist.append(g_dict)<EOL><DEDENT><DEDENT><DEDENT>return gss_exist<EOL>
parse gene_sets input file type