id int32 0 252k | repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 51 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 |
|---|---|---|---|---|---|---|---|---|---|---|---|
242,300 | tanghaibao/goatools | goatools/go_search.py | GoSearch._search_vals | def _search_vals(self, compiled_pattern, fld_val):
"""Search for user-regex in scalar or iterable data values."""
matches = []
if isinstance(fld_val, set):
for val in fld_val:
self._search_val(matches, compiled_pattern, val)
elif isinstance(fld_val, str):
... | python | def _search_vals(self, compiled_pattern, fld_val):
matches = []
if isinstance(fld_val, set):
for val in fld_val:
self._search_val(matches, compiled_pattern, val)
elif isinstance(fld_val, str):
self._search_val(matches, compiled_pattern, fld_val)
re... | [
"def",
"_search_vals",
"(",
"self",
",",
"compiled_pattern",
",",
"fld_val",
")",
":",
"matches",
"=",
"[",
"]",
"if",
"isinstance",
"(",
"fld_val",
",",
"set",
")",
":",
"for",
"val",
"in",
"fld_val",
":",
"self",
".",
"_search_val",
"(",
"matches",
"... | Search for user-regex in scalar or iterable data values. | [
"Search",
"for",
"user",
"-",
"regex",
"in",
"scalar",
"or",
"iterable",
"data",
"values",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/go_search.py#L57-L65 |
242,301 | tanghaibao/goatools | goatools/go_search.py | GoSearch._search_val | def _search_val(matches, compiled_pattern, fld_val):
"""Search for user-regex in scalar data values."""
mtch = compiled_pattern.search(fld_val)
if mtch:
matches.append(fld_val) | python | def _search_val(matches, compiled_pattern, fld_val):
mtch = compiled_pattern.search(fld_val)
if mtch:
matches.append(fld_val) | [
"def",
"_search_val",
"(",
"matches",
",",
"compiled_pattern",
",",
"fld_val",
")",
":",
"mtch",
"=",
"compiled_pattern",
".",
"search",
"(",
"fld_val",
")",
"if",
"mtch",
":",
"matches",
".",
"append",
"(",
"fld_val",
")"
] | Search for user-regex in scalar data values. | [
"Search",
"for",
"user",
"-",
"regex",
"in",
"scalar",
"data",
"values",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/go_search.py#L68-L72 |
242,302 | tanghaibao/goatools | goatools/go_search.py | GoSearch.add_children_gos | def add_children_gos(self, gos):
"""Return children of input gos plus input gos."""
lst = []
obo_dag = self.obo_dag
get_children = lambda go_obj: list(go_obj.get_all_children()) + [go_obj.id]
for go_id in gos:
go_obj = obo_dag[go_id]
lst.extend(get_childre... | python | def add_children_gos(self, gos):
lst = []
obo_dag = self.obo_dag
get_children = lambda go_obj: list(go_obj.get_all_children()) + [go_obj.id]
for go_id in gos:
go_obj = obo_dag[go_id]
lst.extend(get_children(go_obj))
return set(lst) | [
"def",
"add_children_gos",
"(",
"self",
",",
"gos",
")",
":",
"lst",
"=",
"[",
"]",
"obo_dag",
"=",
"self",
".",
"obo_dag",
"get_children",
"=",
"lambda",
"go_obj",
":",
"list",
"(",
"go_obj",
".",
"get_all_children",
"(",
")",
")",
"+",
"[",
"go_obj",... | Return children of input gos plus input gos. | [
"Return",
"children",
"of",
"input",
"gos",
"plus",
"input",
"gos",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/go_search.py#L74-L82 |
242,303 | tanghaibao/goatools | goatools/go_search.py | GoSearch.get_items | def get_items(self, gos):
"""Given GO terms, return genes or gene products for the GOs."""
items = []
for go_id in gos:
items.extend(self.go2items.get(go_id, []))
return set(items) | python | def get_items(self, gos):
items = []
for go_id in gos:
items.extend(self.go2items.get(go_id, []))
return set(items) | [
"def",
"get_items",
"(",
"self",
",",
"gos",
")",
":",
"items",
"=",
"[",
"]",
"for",
"go_id",
"in",
"gos",
":",
"items",
".",
"extend",
"(",
"self",
".",
"go2items",
".",
"get",
"(",
"go_id",
",",
"[",
"]",
")",
")",
"return",
"set",
"(",
"ite... | Given GO terms, return genes or gene products for the GOs. | [
"Given",
"GO",
"terms",
"return",
"genes",
"or",
"gene",
"products",
"for",
"the",
"GOs",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/go_search.py#L84-L89 |
242,304 | tanghaibao/goatools | goatools/gosubdag/plot/goea_results.py | GoeaResults.prt_summary | def prt_summary(self, prt=sys.stdout):
"""Print summary of GOEA plotting object."""
desc = "NtGoeaResults" if self.is_goterm else "namedtuple"
prt.write("{N} GOEA results from {O}. P-values stored in {P}.\n".format(
N=len(self.go2res), O=desc, P=self.pval_name)) | python | def prt_summary(self, prt=sys.stdout):
desc = "NtGoeaResults" if self.is_goterm else "namedtuple"
prt.write("{N} GOEA results from {O}. P-values stored in {P}.\n".format(
N=len(self.go2res), O=desc, P=self.pval_name)) | [
"def",
"prt_summary",
"(",
"self",
",",
"prt",
"=",
"sys",
".",
"stdout",
")",
":",
"desc",
"=",
"\"NtGoeaResults\"",
"if",
"self",
".",
"is_goterm",
"else",
"\"namedtuple\"",
"prt",
".",
"write",
"(",
"\"{N} GOEA results from {O}. P-values stored in {P}.\\n\"",
"... | Print summary of GOEA plotting object. | [
"Print",
"summary",
"of",
"GOEA",
"plotting",
"object",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/gosubdag/plot/goea_results.py#L40-L44 |
242,305 | tanghaibao/goatools | goatools/gosubdag/plot/goea_results.py | GoeaResults.set_goid2color_pval | def set_goid2color_pval(self, goid2color):
"""Fill missing colors based on p-value of an enriched GO term."""
alpha2col = self.alpha2col
if self.pval_name is not None:
pval_name = self.pval_name
for goid, res in self.go2res.items():
pval = getattr(res, pva... | python | def set_goid2color_pval(self, goid2color):
alpha2col = self.alpha2col
if self.pval_name is not None:
pval_name = self.pval_name
for goid, res in self.go2res.items():
pval = getattr(res, pval_name, None)
if pval is not None:
for ... | [
"def",
"set_goid2color_pval",
"(",
"self",
",",
"goid2color",
")",
":",
"alpha2col",
"=",
"self",
".",
"alpha2col",
"if",
"self",
".",
"pval_name",
"is",
"not",
"None",
":",
"pval_name",
"=",
"self",
".",
"pval_name",
"for",
"goid",
",",
"res",
"in",
"se... | Fill missing colors based on p-value of an enriched GO term. | [
"Fill",
"missing",
"colors",
"based",
"on",
"p",
"-",
"value",
"of",
"an",
"enriched",
"GO",
"term",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/gosubdag/plot/goea_results.py#L55-L66 |
242,306 | tanghaibao/goatools | goatools/gosubdag/plot/goea_results.py | GoeaResults.get_goid2color_pval | def get_goid2color_pval(self):
"""Return a go2color dict containing GO colors determined by P-value."""
go2color = {}
self.set_goid2color_pval(go2color)
color_dflt = self.alpha2col[1.000]
for goid in self.go2res:
if goid not in go2color:
go2color[goid]... | python | def get_goid2color_pval(self):
go2color = {}
self.set_goid2color_pval(go2color)
color_dflt = self.alpha2col[1.000]
for goid in self.go2res:
if goid not in go2color:
go2color[goid] = color_dflt
return go2color | [
"def",
"get_goid2color_pval",
"(",
"self",
")",
":",
"go2color",
"=",
"{",
"}",
"self",
".",
"set_goid2color_pval",
"(",
"go2color",
")",
"color_dflt",
"=",
"self",
".",
"alpha2col",
"[",
"1.000",
"]",
"for",
"goid",
"in",
"self",
".",
"go2res",
":",
"if... | Return a go2color dict containing GO colors determined by P-value. | [
"Return",
"a",
"go2color",
"dict",
"containing",
"GO",
"colors",
"determined",
"by",
"P",
"-",
"value",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/gosubdag/plot/goea_results.py#L68-L76 |
242,307 | tanghaibao/goatools | goatools/rpt/rpt_lev_depth.py | RptLevDepth.prttex_summary_cnts_all | def prttex_summary_cnts_all(self, prt=sys.stdout):
"""Print LaTeX format summary of level and depth counts for all active GO Terms."""
cnts = self.get_cnts_levels_depths_recs(set(self.obo.values()))
self._prttex_summary_cnts(prt, cnts) | python | def prttex_summary_cnts_all(self, prt=sys.stdout):
cnts = self.get_cnts_levels_depths_recs(set(self.obo.values()))
self._prttex_summary_cnts(prt, cnts) | [
"def",
"prttex_summary_cnts_all",
"(",
"self",
",",
"prt",
"=",
"sys",
".",
"stdout",
")",
":",
"cnts",
"=",
"self",
".",
"get_cnts_levels_depths_recs",
"(",
"set",
"(",
"self",
".",
"obo",
".",
"values",
"(",
")",
")",
")",
"self",
".",
"_prttex_summary... | Print LaTeX format summary of level and depth counts for all active GO Terms. | [
"Print",
"LaTeX",
"format",
"summary",
"of",
"level",
"and",
"depth",
"counts",
"for",
"all",
"active",
"GO",
"Terms",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/rpt/rpt_lev_depth.py#L82-L85 |
242,308 | tanghaibao/goatools | goatools/rpt/rpt_lev_depth.py | RptLevDepth.write_summary_cnts_all | def write_summary_cnts_all(self):
"""Write summary of level and depth counts for all active GO Terms."""
cnts = self.get_cnts_levels_depths_recs(set(self.obo.values()))
self._write_summary_cnts(cnts) | python | def write_summary_cnts_all(self):
cnts = self.get_cnts_levels_depths_recs(set(self.obo.values()))
self._write_summary_cnts(cnts) | [
"def",
"write_summary_cnts_all",
"(",
"self",
")",
":",
"cnts",
"=",
"self",
".",
"get_cnts_levels_depths_recs",
"(",
"set",
"(",
"self",
".",
"obo",
".",
"values",
"(",
")",
")",
")",
"self",
".",
"_write_summary_cnts",
"(",
"cnts",
")"
] | Write summary of level and depth counts for all active GO Terms. | [
"Write",
"summary",
"of",
"level",
"and",
"depth",
"counts",
"for",
"all",
"active",
"GO",
"Terms",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/rpt/rpt_lev_depth.py#L87-L90 |
242,309 | tanghaibao/goatools | goatools/rpt/rpt_lev_depth.py | RptLevDepth.write_summary_cnts | def write_summary_cnts(self, go_ids):
"""Write summary of level and depth counts for specific GO ids."""
obo = self.obo
cnts = self.get_cnts_levels_depths_recs([obo.get(GO) for GO in go_ids])
self._write_summary_cnts(cnts) | python | def write_summary_cnts(self, go_ids):
obo = self.obo
cnts = self.get_cnts_levels_depths_recs([obo.get(GO) for GO in go_ids])
self._write_summary_cnts(cnts) | [
"def",
"write_summary_cnts",
"(",
"self",
",",
"go_ids",
")",
":",
"obo",
"=",
"self",
".",
"obo",
"cnts",
"=",
"self",
".",
"get_cnts_levels_depths_recs",
"(",
"[",
"obo",
".",
"get",
"(",
"GO",
")",
"for",
"GO",
"in",
"go_ids",
"]",
")",
"self",
".... | Write summary of level and depth counts for specific GO ids. | [
"Write",
"summary",
"of",
"level",
"and",
"depth",
"counts",
"for",
"specific",
"GO",
"ids",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/rpt/rpt_lev_depth.py#L92-L96 |
242,310 | tanghaibao/goatools | goatools/rpt/rpt_lev_depth.py | RptLevDepth.get_cnts_levels_depths_recs | def get_cnts_levels_depths_recs(recs):
"""Collect counts of levels and depths in a Group of GO Terms."""
cnts = cx.defaultdict(lambda: cx.defaultdict(cx.Counter))
for rec in recs:
if rec is not None and not rec.is_obsolete:
cnts['level'][rec.level][rec.namespace] += 1... | python | def get_cnts_levels_depths_recs(recs):
cnts = cx.defaultdict(lambda: cx.defaultdict(cx.Counter))
for rec in recs:
if rec is not None and not rec.is_obsolete:
cnts['level'][rec.level][rec.namespace] += 1
cnts['depth'][rec.depth][rec.namespace] += 1
retu... | [
"def",
"get_cnts_levels_depths_recs",
"(",
"recs",
")",
":",
"cnts",
"=",
"cx",
".",
"defaultdict",
"(",
"lambda",
":",
"cx",
".",
"defaultdict",
"(",
"cx",
".",
"Counter",
")",
")",
"for",
"rec",
"in",
"recs",
":",
"if",
"rec",
"is",
"not",
"None",
... | Collect counts of levels and depths in a Group of GO Terms. | [
"Collect",
"counts",
"of",
"levels",
"and",
"depths",
"in",
"a",
"Group",
"of",
"GO",
"Terms",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/rpt/rpt_lev_depth.py#L149-L156 |
242,311 | tanghaibao/goatools | goatools/rpt/rpt_lev_depth.py | RptLevDepth.get_data | def get_data(self):
"""Collect counts of GO terms at all levels and depths."""
# Count level(shortest path to root) and depth(longest path to root)
# values for all unique GO Terms.
data = []
ntobj = cx.namedtuple("NtGoCnt", "Depth_Level BP_D MF_D CC_D BP_L MF_L CC_L")
cn... | python | def get_data(self):
# Count level(shortest path to root) and depth(longest path to root)
# values for all unique GO Terms.
data = []
ntobj = cx.namedtuple("NtGoCnt", "Depth_Level BP_D MF_D CC_D BP_L MF_L CC_L")
cnts = self.get_cnts_levels_depths_recs(set(self.obo.values()))
... | [
"def",
"get_data",
"(",
"self",
")",
":",
"# Count level(shortest path to root) and depth(longest path to root)",
"# values for all unique GO Terms.",
"data",
"=",
"[",
"]",
"ntobj",
"=",
"cx",
".",
"namedtuple",
"(",
"\"NtGoCnt\"",
",",
"\"Depth_Level BP_D MF_D CC_D BP_L MF_... | Collect counts of GO terms at all levels and depths. | [
"Collect",
"counts",
"of",
"GO",
"terms",
"at",
"all",
"levels",
"and",
"depths",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/rpt/rpt_lev_depth.py#L158-L169 |
242,312 | tanghaibao/goatools | scripts/find_enrichment.py | main | def main():
"""Run gene enrichment analysis."""
# Load study, population, associations, and GoDag. Run GOEA.
obj = GoeaCliFnc(GoeaCliArgs().args)
# Reduce results to significant results (pval<value)
results_specified = obj.get_results()
# Print results in a flat list
obj.prt_results(results_... | python | def main():
# Load study, population, associations, and GoDag. Run GOEA.
obj = GoeaCliFnc(GoeaCliArgs().args)
# Reduce results to significant results (pval<value)
results_specified = obj.get_results()
# Print results in a flat list
obj.prt_results(results_specified) | [
"def",
"main",
"(",
")",
":",
"# Load study, population, associations, and GoDag. Run GOEA.",
"obj",
"=",
"GoeaCliFnc",
"(",
"GoeaCliArgs",
"(",
")",
".",
"args",
")",
"# Reduce results to significant results (pval<value)",
"results_specified",
"=",
"obj",
".",
"get_results... | Run gene enrichment analysis. | [
"Run",
"gene",
"enrichment",
"analysis",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/scripts/find_enrichment.py#L28-L35 |
242,313 | tanghaibao/goatools | goatools/anno/factory.py | get_objanno | def get_objanno(fin_anno, anno_type=None, **kws):
"""Read annotations in GAF, GPAD, Entrez gene2go, or text format."""
# kws get_objanno: taxids hdr_only prt allow_missing_symbol
anno_type = get_anno_desc(fin_anno, anno_type)
if anno_type is not None:
if anno_type == 'gene2go':
# kws... | python | def get_objanno(fin_anno, anno_type=None, **kws):
# kws get_objanno: taxids hdr_only prt allow_missing_symbol
anno_type = get_anno_desc(fin_anno, anno_type)
if anno_type is not None:
if anno_type == 'gene2go':
# kws: taxid taxids
return Gene2GoReader(fin_anno, **kws)
... | [
"def",
"get_objanno",
"(",
"fin_anno",
",",
"anno_type",
"=",
"None",
",",
"*",
"*",
"kws",
")",
":",
"# kws get_objanno: taxids hdr_only prt allow_missing_symbol",
"anno_type",
"=",
"get_anno_desc",
"(",
"fin_anno",
",",
"anno_type",
")",
"if",
"anno_type",
"is",
... | Read annotations in GAF, GPAD, Entrez gene2go, or text format. | [
"Read",
"annotations",
"in",
"GAF",
"GPAD",
"Entrez",
"gene2go",
"or",
"text",
"format",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/anno/factory.py#L13-L32 |
242,314 | tanghaibao/goatools | goatools/anno/gpad_reader.py | GpadReader.get_relation_cnt | def get_relation_cnt(self):
"""Return a Counter containing all relations contained in the Annotation Extensions."""
ctr = cx.Counter()
for ntgpad in self.associations:
if ntgpad.Extension is not None:
ctr += ntgpad.Extension.get_relations_cnt()
return ctr | python | def get_relation_cnt(self):
ctr = cx.Counter()
for ntgpad in self.associations:
if ntgpad.Extension is not None:
ctr += ntgpad.Extension.get_relations_cnt()
return ctr | [
"def",
"get_relation_cnt",
"(",
"self",
")",
":",
"ctr",
"=",
"cx",
".",
"Counter",
"(",
")",
"for",
"ntgpad",
"in",
"self",
".",
"associations",
":",
"if",
"ntgpad",
".",
"Extension",
"is",
"not",
"None",
":",
"ctr",
"+=",
"ntgpad",
".",
"Extension",
... | Return a Counter containing all relations contained in the Annotation Extensions. | [
"Return",
"a",
"Counter",
"containing",
"all",
"relations",
"contained",
"in",
"the",
"Annotation",
"Extensions",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/anno/gpad_reader.py#L24-L30 |
242,315 | tanghaibao/goatools | goatools/cli/find_enrichment.py | GoeaCliFnc._get_id2gos | def _get_id2gos(self):
"""Return annotations as id2gos"""
kws = {}
if self.args.ev_inc is not None:
kws['ev_include'] = set(self.args.ev_inc.split(','))
if self.args.ev_exc is not None:
kws['ev_exclude'] = set(self.args.ev_exc.split(','))
return self.objan... | python | def _get_id2gos(self):
kws = {}
if self.args.ev_inc is not None:
kws['ev_include'] = set(self.args.ev_inc.split(','))
if self.args.ev_exc is not None:
kws['ev_exclude'] = set(self.args.ev_exc.split(','))
return self.objanno.get_id2gos(**kws) | [
"def",
"_get_id2gos",
"(",
"self",
")",
":",
"kws",
"=",
"{",
"}",
"if",
"self",
".",
"args",
".",
"ev_inc",
"is",
"not",
"None",
":",
"kws",
"[",
"'ev_include'",
"]",
"=",
"set",
"(",
"self",
".",
"args",
".",
"ev_inc",
".",
"split",
"(",
"','",... | Return annotations as id2gos | [
"Return",
"annotations",
"as",
"id2gos"
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/cli/find_enrichment.py#L182-L189 |
242,316 | tanghaibao/goatools | goatools/cli/find_enrichment.py | GoeaCliFnc._get_objanno | def _get_objanno(self, assoc_fn):
"""Get an annotation object"""
# Determine annotation file format from filename, if possible
anno_type = get_anno_desc(assoc_fn, None)
# Default annotation file format is id2gos
if anno_type is None:
anno_type = self.args.annofmt if s... | python | def _get_objanno(self, assoc_fn):
# Determine annotation file format from filename, if possible
anno_type = get_anno_desc(assoc_fn, None)
# Default annotation file format is id2gos
if anno_type is None:
anno_type = self.args.annofmt if self.args.annofmt else 'id2gos'
... | [
"def",
"_get_objanno",
"(",
"self",
",",
"assoc_fn",
")",
":",
"# Determine annotation file format from filename, if possible",
"anno_type",
"=",
"get_anno_desc",
"(",
"assoc_fn",
",",
"None",
")",
"# Default annotation file format is id2gos",
"if",
"anno_type",
"is",
"None... | Get an annotation object | [
"Get",
"an",
"annotation",
"object"
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/cli/find_enrichment.py#L191-L199 |
242,317 | tanghaibao/goatools | goatools/cli/find_enrichment.py | GoeaCliFnc._init_itemid2name | def _init_itemid2name(self):
"""Print gene symbols instead of gene IDs, if provided."""
if not hasattr(self.args, 'id2sym'):
return None
fin_id2sym = self.args.id2sym
if fin_id2sym is not None and os.path.exists(fin_id2sym):
id2sym = {}
cmpl = re.compi... | python | def _init_itemid2name(self):
if not hasattr(self.args, 'id2sym'):
return None
fin_id2sym = self.args.id2sym
if fin_id2sym is not None and os.path.exists(fin_id2sym):
id2sym = {}
cmpl = re.compile(r'^\s*(\S+)[\s,;]+(\S+)')
with open(fin_id2sym) as i... | [
"def",
"_init_itemid2name",
"(",
"self",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
".",
"args",
",",
"'id2sym'",
")",
":",
"return",
"None",
"fin_id2sym",
"=",
"self",
".",
"args",
".",
"id2sym",
"if",
"fin_id2sym",
"is",
"not",
"None",
"and",
"os... | Print gene symbols instead of gene IDs, if provided. | [
"Print",
"gene",
"symbols",
"instead",
"of",
"gene",
"IDs",
"if",
"provided",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/cli/find_enrichment.py#L201-L214 |
242,318 | tanghaibao/goatools | goatools/cli/find_enrichment.py | GoeaCliFnc.prt_results | def prt_results(self, goea_results):
"""Print GOEA results to the screen or to a file."""
# objaart = self.prepgrp.get_objaart(goea_results) if self.prepgrp is not None else None
if self.args.outfile is None:
self._prt_results(goea_results)
else:
# Users can print... | python | def prt_results(self, goea_results):
# objaart = self.prepgrp.get_objaart(goea_results) if self.prepgrp is not None else None
if self.args.outfile is None:
self._prt_results(goea_results)
else:
# Users can print to both tab-separated file and xlsx file in one run.
... | [
"def",
"prt_results",
"(",
"self",
",",
"goea_results",
")",
":",
"# objaart = self.prepgrp.get_objaart(goea_results) if self.prepgrp is not None else None",
"if",
"self",
".",
"args",
".",
"outfile",
"is",
"None",
":",
"self",
".",
"_prt_results",
"(",
"goea_results",
... | Print GOEA results to the screen or to a file. | [
"Print",
"GOEA",
"results",
"to",
"the",
"screen",
"or",
"to",
"a",
"file",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/cli/find_enrichment.py#L216-L228 |
242,319 | tanghaibao/goatools | goatools/cli/find_enrichment.py | GoeaCliFnc._prt_results | def _prt_results(self, goea_results):
"""Print GOEA results to the screen."""
min_ratio = self.args.ratio
if min_ratio is not None:
assert 1 <= min_ratio <= 2
self.objgoea.print_date(min_ratio=min_ratio, pval=self.args.pval)
results_adj = self.objgoea.get_adj_records(... | python | def _prt_results(self, goea_results):
min_ratio = self.args.ratio
if min_ratio is not None:
assert 1 <= min_ratio <= 2
self.objgoea.print_date(min_ratio=min_ratio, pval=self.args.pval)
results_adj = self.objgoea.get_adj_records(goea_results, min_ratio, self.args.pval)
... | [
"def",
"_prt_results",
"(",
"self",
",",
"goea_results",
")",
":",
"min_ratio",
"=",
"self",
".",
"args",
".",
"ratio",
"if",
"min_ratio",
"is",
"not",
"None",
":",
"assert",
"1",
"<=",
"min_ratio",
"<=",
"2",
"self",
".",
"objgoea",
".",
"print_date",
... | Print GOEA results to the screen. | [
"Print",
"GOEA",
"results",
"to",
"the",
"screen",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/cli/find_enrichment.py#L241-L253 |
242,320 | tanghaibao/goatools | goatools/cli/find_enrichment.py | GoeaCliFnc.chk_genes | def chk_genes(self, study, pop, assoc=None):
"""Check gene sets."""
if len(pop) < len(study):
exit("\nERROR: The study file contains more elements than the population file. "
"Please check that the study file is a subset of the population file.\n")
# check the fracti... | python | def chk_genes(self, study, pop, assoc=None):
if len(pop) < len(study):
exit("\nERROR: The study file contains more elements than the population file. "
"Please check that the study file is a subset of the population file.\n")
# check the fraction of genomic ids that overlap ... | [
"def",
"chk_genes",
"(",
"self",
",",
"study",
",",
"pop",
",",
"assoc",
"=",
"None",
")",
":",
"if",
"len",
"(",
"pop",
")",
"<",
"len",
"(",
"study",
")",
":",
"exit",
"(",
"\"\\nERROR: The study file contains more elements than the population file. \"",
"\"... | Check gene sets. | [
"Check",
"gene",
"sets",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/cli/find_enrichment.py#L269-L289 |
242,321 | tanghaibao/goatools | goatools/cli/find_enrichment.py | GoeaCliFnc.get_results_sig | def get_results_sig(self):
"""Get significant results."""
# Only print results when uncorrected p-value < this value.
print("{N:7,} of {M:,} results have uncorrected P-values <= {PVAL}=pval\n".format(
N=sum(1 for r in self.results_all if r.p_uncorrected < self.args.pval),
... | python | def get_results_sig(self):
# Only print results when uncorrected p-value < this value.
print("{N:7,} of {M:,} results have uncorrected P-values <= {PVAL}=pval\n".format(
N=sum(1 for r in self.results_all if r.p_uncorrected < self.args.pval),
M=len(self.results_all),
P... | [
"def",
"get_results_sig",
"(",
"self",
")",
":",
"# Only print results when uncorrected p-value < this value.",
"print",
"(",
"\"{N:7,} of {M:,} results have uncorrected P-values <= {PVAL}=pval\\n\"",
".",
"format",
"(",
"N",
"=",
"sum",
"(",
"1",
"for",
"r",
"in",
"self",
... | Get significant results. | [
"Get",
"significant",
"results",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/cli/find_enrichment.py#L291-L300 |
242,322 | tanghaibao/goatools | goatools/cli/find_enrichment.py | GoeaCliFnc.get_pval_field | def get_pval_field(self):
"""Get 'p_uncorrected' or the user-specified field for determining significant results."""
pval_fld = self.args.pval_field
# If --pval_field [VAL] was specified
if pval_fld is not None:
if pval_fld[:2] != 'p_':
pval_fld = 'p_' + pval_... | python | def get_pval_field(self):
pval_fld = self.args.pval_field
# If --pval_field [VAL] was specified
if pval_fld is not None:
if pval_fld[:2] != 'p_':
pval_fld = 'p_' + pval_fld
# If only one method was used, use that instead of the uncorrected pvalue
elif ... | [
"def",
"get_pval_field",
"(",
"self",
")",
":",
"pval_fld",
"=",
"self",
".",
"args",
".",
"pval_field",
"# If --pval_field [VAL] was specified",
"if",
"pval_fld",
"is",
"not",
"None",
":",
"if",
"pval_fld",
"[",
":",
"2",
"]",
"!=",
"'p_'",
":",
"pval_fld",... | Get 'p_uncorrected' or the user-specified field for determining significant results. | [
"Get",
"p_uncorrected",
"or",
"the",
"user",
"-",
"specified",
"field",
"for",
"determining",
"significant",
"results",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/cli/find_enrichment.py#L307-L325 |
242,323 | tanghaibao/goatools | goatools/cli/find_enrichment.py | GoeaCliFnc.rd_files | def rd_files(self, study_fn, pop_fn):
"""Read files and return study and population."""
study, pop = self._read_geneset(study_fn, pop_fn)
print("Study: {0} vs. Population {1}\n".format(len(study), len(pop)))
return study, pop | python | def rd_files(self, study_fn, pop_fn):
study, pop = self._read_geneset(study_fn, pop_fn)
print("Study: {0} vs. Population {1}\n".format(len(study), len(pop)))
return study, pop | [
"def",
"rd_files",
"(",
"self",
",",
"study_fn",
",",
"pop_fn",
")",
":",
"study",
",",
"pop",
"=",
"self",
".",
"_read_geneset",
"(",
"study_fn",
",",
"pop_fn",
")",
"print",
"(",
"\"Study: {0} vs. Population {1}\\n\"",
".",
"format",
"(",
"len",
"(",
"st... | Read files and return study and population. | [
"Read",
"files",
"and",
"return",
"study",
"and",
"population",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/cli/find_enrichment.py#L327-L331 |
242,324 | tanghaibao/goatools | goatools/cli/find_enrichment.py | GoeaCliFnc._read_geneset | def _read_geneset(self, study_fn, pop_fn):
"""Open files containing genes. Return study genes and population genes."""
pop = set(_.strip() for _ in open(pop_fn) if _.strip())
study = frozenset(_.strip() for _ in open(study_fn) if _.strip())
if next(iter(pop)).isdigit():
pop =... | python | def _read_geneset(self, study_fn, pop_fn):
pop = set(_.strip() for _ in open(pop_fn) if _.strip())
study = frozenset(_.strip() for _ in open(study_fn) if _.strip())
if next(iter(pop)).isdigit():
pop = set(int(g) for g in pop)
study = frozenset(int(g) for g in study)
... | [
"def",
"_read_geneset",
"(",
"self",
",",
"study_fn",
",",
"pop_fn",
")",
":",
"pop",
"=",
"set",
"(",
"_",
".",
"strip",
"(",
")",
"for",
"_",
"in",
"open",
"(",
"pop_fn",
")",
"if",
"_",
".",
"strip",
"(",
")",
")",
"study",
"=",
"frozenset",
... | Open files containing genes. Return study genes and population genes. | [
"Open",
"files",
"containing",
"genes",
".",
"Return",
"study",
"genes",
"and",
"population",
"genes",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/cli/find_enrichment.py#L333-L351 |
242,325 | tanghaibao/goatools | goatools/cli/find_enrichment.py | GroupItems.get_objgrpwr | def get_objgrpwr(self, goea_results):
"""Get a GrpWr object to write grouped GOEA results."""
sortobj = self.get_sortobj(goea_results)
return GrpWr(sortobj, self.pval_fld, ver_list=self.ver_list) | python | def get_objgrpwr(self, goea_results):
sortobj = self.get_sortobj(goea_results)
return GrpWr(sortobj, self.pval_fld, ver_list=self.ver_list) | [
"def",
"get_objgrpwr",
"(",
"self",
",",
"goea_results",
")",
":",
"sortobj",
"=",
"self",
".",
"get_sortobj",
"(",
"goea_results",
")",
"return",
"GrpWr",
"(",
"sortobj",
",",
"self",
".",
"pval_fld",
",",
"ver_list",
"=",
"self",
".",
"ver_list",
")"
] | Get a GrpWr object to write grouped GOEA results. | [
"Get",
"a",
"GrpWr",
"object",
"to",
"write",
"grouped",
"GOEA",
"results",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/cli/find_enrichment.py#L370-L373 |
242,326 | tanghaibao/goatools | goatools/cli/find_enrichment.py | GroupItems.get_sortobj | def get_sortobj(self, goea_results, **kws):
"""Return a Grouper object, given a list of GOEnrichmentRecord."""
nts_goea = MgrNtGOEAs(goea_results).get_goea_nts_prt(**kws)
goids = set(nt.GO for nt in nts_goea)
go2nt = {nt.GO:nt for nt in nts_goea}
grprobj = Grouper("GOEA", goids, ... | python | def get_sortobj(self, goea_results, **kws):
nts_goea = MgrNtGOEAs(goea_results).get_goea_nts_prt(**kws)
goids = set(nt.GO for nt in nts_goea)
go2nt = {nt.GO:nt for nt in nts_goea}
grprobj = Grouper("GOEA", goids, self.hdrobj, self.grprdflt.gosubdag, go2nt=go2nt)
grprobj.prt_summa... | [
"def",
"get_sortobj",
"(",
"self",
",",
"goea_results",
",",
"*",
"*",
"kws",
")",
":",
"nts_goea",
"=",
"MgrNtGOEAs",
"(",
"goea_results",
")",
".",
"get_goea_nts_prt",
"(",
"*",
"*",
"kws",
")",
"goids",
"=",
"set",
"(",
"nt",
".",
"GO",
"for",
"nt... | Return a Grouper object, given a list of GOEnrichmentRecord. | [
"Return",
"a",
"Grouper",
"object",
"given",
"a",
"list",
"of",
"GOEnrichmentRecord",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/cli/find_enrichment.py#L375-L384 |
242,327 | tanghaibao/goatools | goatools/cli/find_enrichment.py | GroupItems._init_objaartall | def _init_objaartall(self):
"""Get background database info for making ASCII art."""
kws = {
'sortgo':lambda nt: [nt.NS, nt.dcnt],
# fmtgo=('{p_fdr_bh:8.2e} {GO} '
# Formatting for GO terms in grouped GO list
'fmtgo':('{hdr1usr01:2} {NS} {GO} {s_fdr_bh:8} ... | python | def _init_objaartall(self):
kws = {
'sortgo':lambda nt: [nt.NS, nt.dcnt],
# fmtgo=('{p_fdr_bh:8.2e} {GO} '
# Formatting for GO terms in grouped GO list
'fmtgo':('{hdr1usr01:2} {NS} {GO} {s_fdr_bh:8} '
'{dcnt:5} {childcnt:3} R{reldepth:02} '
... | [
"def",
"_init_objaartall",
"(",
"self",
")",
":",
"kws",
"=",
"{",
"'sortgo'",
":",
"lambda",
"nt",
":",
"[",
"nt",
".",
"NS",
",",
"nt",
".",
"dcnt",
"]",
",",
"# fmtgo=('{p_fdr_bh:8.2e} {GO} '",
"# Formatting for GO terms in grouped GO list",
"'fmtgo'",
":",
... | Get background database info for making ASCII art. | [
"Get",
"background",
"database",
"info",
"for",
"making",
"ASCII",
"art",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/cli/find_enrichment.py#L392-L407 |
242,328 | tanghaibao/goatools | goatools/cli/find_enrichment.py | GrpWr.wr_xlsx | def wr_xlsx(self, fout_xlsx):
"""Print grouped GOEA results into an xlsx file."""
objwr = WrXlsxSortedGos("GOEA", self.sortobj)
#### fld2fmt['ratio_in_study'] = '{:>8}'
#### fld2fmt['ratio_in_pop'] = '{:>12}'
#### ntfld2wbfmtdict = {
# ntfld_wbfmt = {
# 'ratio... | python | def wr_xlsx(self, fout_xlsx):
objwr = WrXlsxSortedGos("GOEA", self.sortobj)
#### fld2fmt['ratio_in_study'] = '{:>8}'
#### fld2fmt['ratio_in_pop'] = '{:>12}'
#### ntfld2wbfmtdict = {
# ntfld_wbfmt = {
# 'ratio_in_study': {'align':'right'},
# 'ratio_in_pop':... | [
"def",
"wr_xlsx",
"(",
"self",
",",
"fout_xlsx",
")",
":",
"objwr",
"=",
"WrXlsxSortedGos",
"(",
"\"GOEA\"",
",",
"self",
".",
"sortobj",
")",
"#### fld2fmt['ratio_in_study'] = '{:>8}'",
"#### fld2fmt['ratio_in_pop'] = '{:>12}'",
"#### ntfld2wbfmtdict = {",
"# ntfld_wbfmt =... | Print grouped GOEA results into an xlsx file. | [
"Print",
"grouped",
"GOEA",
"results",
"into",
"an",
"xlsx",
"file",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/cli/find_enrichment.py#L432-L448 |
242,329 | tanghaibao/goatools | goatools/cli/find_enrichment.py | GrpWr.wr_tsv | def wr_tsv(self, fout_tsv):
"""Print grouped GOEA results into a tab-separated file."""
with open(fout_tsv, 'w') as prt:
kws_tsv = {
'fld2fmt': {f:'{:8.2e}' for f in self.flds_cur if f[:2] == 'p_'},
'prt_flds':self.flds_cur}
prt_tsv_sections(prt, s... | python | def wr_tsv(self, fout_tsv):
with open(fout_tsv, 'w') as prt:
kws_tsv = {
'fld2fmt': {f:'{:8.2e}' for f in self.flds_cur if f[:2] == 'p_'},
'prt_flds':self.flds_cur}
prt_tsv_sections(prt, self.desc2nts['sections'], **kws_tsv)
print(" WROTE: {TS... | [
"def",
"wr_tsv",
"(",
"self",
",",
"fout_tsv",
")",
":",
"with",
"open",
"(",
"fout_tsv",
",",
"'w'",
")",
"as",
"prt",
":",
"kws_tsv",
"=",
"{",
"'fld2fmt'",
":",
"{",
"f",
":",
"'{:8.2e}'",
"for",
"f",
"in",
"self",
".",
"flds_cur",
"if",
"f",
... | Print grouped GOEA results into a tab-separated file. | [
"Print",
"grouped",
"GOEA",
"results",
"into",
"a",
"tab",
"-",
"separated",
"file",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/cli/find_enrichment.py#L450-L457 |
242,330 | tanghaibao/goatools | goatools/cli/find_enrichment.py | GrpWr.wr_txt | def wr_txt(self, fout_txt):
"""Write to a file GOEA results in an ASCII text format."""
with open(fout_txt, 'w') as prt:
for line in self.ver_list:
prt.write("{LINE}\n".format(LINE=line))
self.prt_txt(prt)
print(" WROTE: {TXT}".format(TXT=fout_txt)) | python | def wr_txt(self, fout_txt):
with open(fout_txt, 'w') as prt:
for line in self.ver_list:
prt.write("{LINE}\n".format(LINE=line))
self.prt_txt(prt)
print(" WROTE: {TXT}".format(TXT=fout_txt)) | [
"def",
"wr_txt",
"(",
"self",
",",
"fout_txt",
")",
":",
"with",
"open",
"(",
"fout_txt",
",",
"'w'",
")",
"as",
"prt",
":",
"for",
"line",
"in",
"self",
".",
"ver_list",
":",
"prt",
".",
"write",
"(",
"\"{LINE}\\n\"",
".",
"format",
"(",
"LINE",
"... | Write to a file GOEA results in an ASCII text format. | [
"Write",
"to",
"a",
"file",
"GOEA",
"results",
"in",
"an",
"ASCII",
"text",
"format",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/cli/find_enrichment.py#L459-L465 |
242,331 | tanghaibao/goatools | goatools/cli/find_enrichment.py | GrpWr.prt_tsv | def prt_tsv(self, prt=sys.stdout):
"""Print an ASCII text format."""
prtfmt = self.objprt.get_prtfmt_str(self.flds_cur)
prt.write("{FLDS}\n".format(FLDS=" ".join(self.flds_cur)))
WrSectionsTxt.prt_sections(prt, self.desc2nts['sections'], prtfmt, secspc=True) | python | def prt_tsv(self, prt=sys.stdout):
prtfmt = self.objprt.get_prtfmt_str(self.flds_cur)
prt.write("{FLDS}\n".format(FLDS=" ".join(self.flds_cur)))
WrSectionsTxt.prt_sections(prt, self.desc2nts['sections'], prtfmt, secspc=True) | [
"def",
"prt_tsv",
"(",
"self",
",",
"prt",
"=",
"sys",
".",
"stdout",
")",
":",
"prtfmt",
"=",
"self",
".",
"objprt",
".",
"get_prtfmt_str",
"(",
"self",
".",
"flds_cur",
")",
"prt",
".",
"write",
"(",
"\"{FLDS}\\n\"",
".",
"format",
"(",
"FLDS",
"="... | Print an ASCII text format. | [
"Print",
"an",
"ASCII",
"text",
"format",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/cli/find_enrichment.py#L467-L471 |
242,332 | tanghaibao/goatools | goatools/cli/find_enrichment.py | GrpWr._init_flds_cur | def _init_flds_cur(self):
"""Choose fields to print from a multitude of available fields."""
flds = []
# ('GO', 'NS', 'enrichment', 'name', 'ratio_in_study', 'ratio_in_pop', 'depth',
# 'p_uncorrected', 'p_bonferroni', 'p_sidak', 'p_holm', 'p_fdr_bh',
# 'pop_n', 'pop_count', 'pop_... | python | def _init_flds_cur(self):
flds = []
# ('GO', 'NS', 'enrichment', 'name', 'ratio_in_study', 'ratio_in_pop', 'depth',
# 'p_uncorrected', 'p_bonferroni', 'p_sidak', 'p_holm', 'p_fdr_bh',
# 'pop_n', 'pop_count', 'pop_items'
# 'study_n', 'study_count', 'study_items',
# 'is_rat... | [
"def",
"_init_flds_cur",
"(",
"self",
")",
":",
"flds",
"=",
"[",
"]",
"# ('GO', 'NS', 'enrichment', 'name', 'ratio_in_study', 'ratio_in_pop', 'depth',",
"# 'p_uncorrected', 'p_bonferroni', 'p_sidak', 'p_holm', 'p_fdr_bh',",
"# 'pop_n', 'pop_count', 'pop_items'",
"# 'study_n', 'study_count... | Choose fields to print from a multitude of available fields. | [
"Choose",
"fields",
"to",
"print",
"from",
"a",
"multitude",
"of",
"available",
"fields",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/cli/find_enrichment.py#L479-L499 |
242,333 | tanghaibao/goatools | goatools/parsers/ncbi_gene_file_reader.py | NCBIgeneFileReader.do_hdr | def do_hdr(self, line, hdrs_usr):
"""Initialize self.h2i."""
# If there is no header hint, consider the first line the header.
if self.hdr_ex is None:
self._init_hdr(line, hdrs_usr)
return True
# If there is a header hint, examine each beginning line until header ... | python | def do_hdr(self, line, hdrs_usr):
# If there is no header hint, consider the first line the header.
if self.hdr_ex is None:
self._init_hdr(line, hdrs_usr)
return True
# If there is a header hint, examine each beginning line until header hint is found.
elif self.hd... | [
"def",
"do_hdr",
"(",
"self",
",",
"line",
",",
"hdrs_usr",
")",
":",
"# If there is no header hint, consider the first line the header.",
"if",
"self",
".",
"hdr_ex",
"is",
"None",
":",
"self",
".",
"_init_hdr",
"(",
"line",
",",
"hdrs_usr",
")",
"return",
"Tru... | Initialize self.h2i. | [
"Initialize",
"self",
".",
"h2i",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/parsers/ncbi_gene_file_reader.py#L84-L94 |
242,334 | tanghaibao/goatools | goatools/parsers/ncbi_gene_file_reader.py | NCBIgeneFileReader.hdr_xform | def hdr_xform(self, hdrs):
"""Transform NCBI Gene header fields into valid namedtuple fields."""
xform = []
hdrs = self.replace_nulls(hdrs)
for hdr in hdrs:
hdr = hdr.replace('.', '_')
hdr = hdr.replace(' ', '_')
hdr = hdr.replace('#', 'N')
... | python | def hdr_xform(self, hdrs):
xform = []
hdrs = self.replace_nulls(hdrs)
for hdr in hdrs:
hdr = hdr.replace('.', '_')
hdr = hdr.replace(' ', '_')
hdr = hdr.replace('#', 'N')
hdr = hdr.replace('-', '_')
hdr = hdr.replace('"', '')
... | [
"def",
"hdr_xform",
"(",
"self",
",",
"hdrs",
")",
":",
"xform",
"=",
"[",
"]",
"hdrs",
"=",
"self",
".",
"replace_nulls",
"(",
"hdrs",
")",
"for",
"hdr",
"in",
"hdrs",
":",
"hdr",
"=",
"hdr",
".",
"replace",
"(",
"'.'",
",",
"'_'",
")",
"hdr",
... | Transform NCBI Gene header fields into valid namedtuple fields. | [
"Transform",
"NCBI",
"Gene",
"header",
"fields",
"into",
"valid",
"namedtuple",
"fields",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/parsers/ncbi_gene_file_reader.py#L146-L157 |
242,335 | tanghaibao/goatools | goatools/parsers/ncbi_gene_file_reader.py | NCBIgeneFileReader._init_nt_hdr | def _init_nt_hdr(self, line):
"""Convert headers into valid namedtuple fields."""
line = line.replace('.', '_')
line = line.replace(' ', '_')
line = line.replace('#', 'N')
line = line.replace('-', '_')
line = line.replace('"', '')
#line = re.sub(r"_$", r"", line)
... | python | def _init_nt_hdr(self, line):
line = line.replace('.', '_')
line = line.replace(' ', '_')
line = line.replace('#', 'N')
line = line.replace('-', '_')
line = line.replace('"', '')
#line = re.sub(r"_$", r"", line)
hdrs = re.split(self.sep, line)
if '' in hdr... | [
"def",
"_init_nt_hdr",
"(",
"self",
",",
"line",
")",
":",
"line",
"=",
"line",
".",
"replace",
"(",
"'.'",
",",
"'_'",
")",
"line",
"=",
"line",
".",
"replace",
"(",
"' '",
",",
"'_'",
")",
"line",
"=",
"line",
".",
"replace",
"(",
"'#'",
",",
... | Convert headers into valid namedtuple fields. | [
"Convert",
"headers",
"into",
"valid",
"namedtuple",
"fields",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/parsers/ncbi_gene_file_reader.py#L159-L174 |
242,336 | tanghaibao/goatools | goatools/parsers/ncbi_gene_file_reader.py | NCBIgeneFileReader.replace_nulls | def replace_nulls(hdrs):
"""Replace '' in hdrs."""
ret = []
idx = 0
for hdr in hdrs:
if hdr == '':
ret.append("no_hdr{}".format(idx))
else:
ret.append(hdr)
return ret | python | def replace_nulls(hdrs):
ret = []
idx = 0
for hdr in hdrs:
if hdr == '':
ret.append("no_hdr{}".format(idx))
else:
ret.append(hdr)
return ret | [
"def",
"replace_nulls",
"(",
"hdrs",
")",
":",
"ret",
"=",
"[",
"]",
"idx",
"=",
"0",
"for",
"hdr",
"in",
"hdrs",
":",
"if",
"hdr",
"==",
"''",
":",
"ret",
".",
"append",
"(",
"\"no_hdr{}\"",
".",
"format",
"(",
"idx",
")",
")",
"else",
":",
"r... | Replace '' in hdrs. | [
"Replace",
"in",
"hdrs",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/parsers/ncbi_gene_file_reader.py#L187-L196 |
242,337 | tanghaibao/goatools | goatools/parsers/ncbi_gene_file_reader.py | NCBIgeneFileReader._init_data_line | def _init_data_line(self, fnc, lnum, line):
"""Process Data line."""
fld = re.split(self.sep, line)
# Lines may contain different numbers of items.
# The line should have all columns requested by the user.
if self.usr_max_idx < len(fld):
self.convert_ints_floats(fld)
... | python | def _init_data_line(self, fnc, lnum, line):
fld = re.split(self.sep, line)
# Lines may contain different numbers of items.
# The line should have all columns requested by the user.
if self.usr_max_idx < len(fld):
self.convert_ints_floats(fld)
fnc(fld)
else... | [
"def",
"_init_data_line",
"(",
"self",
",",
"fnc",
",",
"lnum",
",",
"line",
")",
":",
"fld",
"=",
"re",
".",
"split",
"(",
"self",
".",
"sep",
",",
"line",
")",
"# Lines may contain different numbers of items.",
"# The line should have all columns requested by the ... | Process Data line. | [
"Process",
"Data",
"line",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/parsers/ncbi_gene_file_reader.py#L198-L213 |
242,338 | tanghaibao/goatools | goatools/parsers/ncbi_gene_file_reader.py | NCBIgeneFileReader.convert_ints_floats | def convert_ints_floats(self, flds):
"""Convert strings to ints and floats, if so specified."""
for idx in self.idxs_float:
flds[idx] = float(flds[idx])
for idx in self.idxs_int:
dig = flds[idx]
#print 'idx={} ({}) {}'.format(idx, flds[idx], flds) # DVK
... | python | def convert_ints_floats(self, flds):
for idx in self.idxs_float:
flds[idx] = float(flds[idx])
for idx in self.idxs_int:
dig = flds[idx]
#print 'idx={} ({}) {}'.format(idx, flds[idx], flds) # DVK
flds[idx] = int(flds[idx]) if dig.isdigit() else dig
... | [
"def",
"convert_ints_floats",
"(",
"self",
",",
"flds",
")",
":",
"for",
"idx",
"in",
"self",
".",
"idxs_float",
":",
"flds",
"[",
"idx",
"]",
"=",
"float",
"(",
"flds",
"[",
"idx",
"]",
")",
"for",
"idx",
"in",
"self",
".",
"idxs_int",
":",
"dig",... | Convert strings to ints and floats, if so specified. | [
"Convert",
"strings",
"to",
"ints",
"and",
"floats",
"if",
"so",
"specified",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/parsers/ncbi_gene_file_reader.py#L215-L226 |
242,339 | tanghaibao/goatools | goatools/parsers/ncbi_gene_file_reader.py | NCBIgeneFileReader._init_hdr | def _init_hdr(self, line, hdrs_usr):
"""Initialize self.hdr2idx, self.len, self.idxs_float, and self.idxs_int"""
self.hdr2idx = OrderedDict([(v.strip(), i) for i, v in enumerate(re.split(self.sep, line))])
self.len = len(self.hdr2idx)
# If user is requesting specific data fields...
... | python | def _init_hdr(self, line, hdrs_usr):
self.hdr2idx = OrderedDict([(v.strip(), i) for i, v in enumerate(re.split(self.sep, line))])
self.len = len(self.hdr2idx)
# If user is requesting specific data fields...
if hdrs_usr is not None:
# Loop through the user headers
... | [
"def",
"_init_hdr",
"(",
"self",
",",
"line",
",",
"hdrs_usr",
")",
":",
"self",
".",
"hdr2idx",
"=",
"OrderedDict",
"(",
"[",
"(",
"v",
".",
"strip",
"(",
")",
",",
"i",
")",
"for",
"i",
",",
"v",
"in",
"enumerate",
"(",
"re",
".",
"split",
"(... | Initialize self.hdr2idx, self.len, self.idxs_float, and self.idxs_int | [
"Initialize",
"self",
".",
"hdr2idx",
"self",
".",
"len",
"self",
".",
"idxs_float",
"and",
"self",
".",
"idxs_int"
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/parsers/ncbi_gene_file_reader.py#L228-L247 |
242,340 | tanghaibao/goatools | goatools/parsers/ncbi_gene_file_reader.py | NCBIgeneFileReader._init_idxs_float | def _init_idxs_float(self, usr_hdrs):
"""List of indexes whose values will be floats."""
self.idxs_float = [
Idx for Hdr, Idx in self.hdr2idx.items() if Hdr in usr_hdrs and Hdr in self.float_hdrs] | python | def _init_idxs_float(self, usr_hdrs):
self.idxs_float = [
Idx for Hdr, Idx in self.hdr2idx.items() if Hdr in usr_hdrs and Hdr in self.float_hdrs] | [
"def",
"_init_idxs_float",
"(",
"self",
",",
"usr_hdrs",
")",
":",
"self",
".",
"idxs_float",
"=",
"[",
"Idx",
"for",
"Hdr",
",",
"Idx",
"in",
"self",
".",
"hdr2idx",
".",
"items",
"(",
")",
"if",
"Hdr",
"in",
"usr_hdrs",
"and",
"Hdr",
"in",
"self",
... | List of indexes whose values will be floats. | [
"List",
"of",
"indexes",
"whose",
"values",
"will",
"be",
"floats",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/parsers/ncbi_gene_file_reader.py#L249-L252 |
242,341 | tanghaibao/goatools | goatools/parsers/ncbi_gene_file_reader.py | NCBIgeneFileReader._init_idxs_int | def _init_idxs_int(self, usr_hdrs):
"""List of indexes whose values will be ints."""
self.idxs_int = [
Idx for Hdr, Idx in self.hdr2idx.items() if Hdr in usr_hdrs and Hdr in self.int_hdrs] | python | def _init_idxs_int(self, usr_hdrs):
self.idxs_int = [
Idx for Hdr, Idx in self.hdr2idx.items() if Hdr in usr_hdrs and Hdr in self.int_hdrs] | [
"def",
"_init_idxs_int",
"(",
"self",
",",
"usr_hdrs",
")",
":",
"self",
".",
"idxs_int",
"=",
"[",
"Idx",
"for",
"Hdr",
",",
"Idx",
"in",
"self",
".",
"hdr2idx",
".",
"items",
"(",
")",
"if",
"Hdr",
"in",
"usr_hdrs",
"and",
"Hdr",
"in",
"self",
".... | List of indexes whose values will be ints. | [
"List",
"of",
"indexes",
"whose",
"values",
"will",
"be",
"ints",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/parsers/ncbi_gene_file_reader.py#L254-L257 |
242,342 | tanghaibao/goatools | goatools/parsers/ncbi_gene_file_reader.py | NCBIgeneFileReader._init_idxs_strpat | def _init_idxs_strpat(self, usr_hdrs):
"""List of indexes whose values will be strings."""
strpat = self.strpat_hdrs.keys()
self.idxs_strpat = [
Idx for Hdr, Idx in self.hdr2idx.items() if Hdr in usr_hdrs and Hdr in strpat] | python | def _init_idxs_strpat(self, usr_hdrs):
strpat = self.strpat_hdrs.keys()
self.idxs_strpat = [
Idx for Hdr, Idx in self.hdr2idx.items() if Hdr in usr_hdrs and Hdr in strpat] | [
"def",
"_init_idxs_strpat",
"(",
"self",
",",
"usr_hdrs",
")",
":",
"strpat",
"=",
"self",
".",
"strpat_hdrs",
".",
"keys",
"(",
")",
"self",
".",
"idxs_strpat",
"=",
"[",
"Idx",
"for",
"Hdr",
",",
"Idx",
"in",
"self",
".",
"hdr2idx",
".",
"items",
"... | List of indexes whose values will be strings. | [
"List",
"of",
"indexes",
"whose",
"values",
"will",
"be",
"strings",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/parsers/ncbi_gene_file_reader.py#L259-L263 |
242,343 | tanghaibao/goatools | goatools/cli/ncbi_gene_results_to_python.py | NCBIgeneToPythonCli._get_geneid2nt | def _get_geneid2nt(nts):
"""Get geneid2nt given a list of namedtuples."""
geneid2nt = {}
for ntd in nts:
geneid = ntd.GeneID
if geneid not in geneid2nt:
geneid2nt[geneid] = ntd
else:
print("DUPLICATE GeneID FOUND {N:9} {SYM}".fo... | python | def _get_geneid2nt(nts):
geneid2nt = {}
for ntd in nts:
geneid = ntd.GeneID
if geneid not in geneid2nt:
geneid2nt[geneid] = ntd
else:
print("DUPLICATE GeneID FOUND {N:9} {SYM}".format(N=geneid, SYM=ntd.Symbol))
return geneid2nt | [
"def",
"_get_geneid2nt",
"(",
"nts",
")",
":",
"geneid2nt",
"=",
"{",
"}",
"for",
"ntd",
"in",
"nts",
":",
"geneid",
"=",
"ntd",
".",
"GeneID",
"if",
"geneid",
"not",
"in",
"geneid2nt",
":",
"geneid2nt",
"[",
"geneid",
"]",
"=",
"ntd",
"else",
":",
... | Get geneid2nt given a list of namedtuples. | [
"Get",
"geneid2nt",
"given",
"a",
"list",
"of",
"namedtuples",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/cli/ncbi_gene_results_to_python.py#L50-L59 |
242,344 | tanghaibao/goatools | goatools/cli/ncbi_gene_results_to_python.py | NCBIgeneToPythonCli._wrpy_ncbi_gene_nts | def _wrpy_ncbi_gene_nts(fout_py, geneid2nt, log):
"""Write namedtuples to a dict in a Python module."""
num_genes = len(geneid2nt)
with open(fout_py, 'w') as ofstrm:
docstr = "Data downloaded from NCBI Gene converted into Python namedtuples."
ofstrm.write('"""{PYDOC}"""\n... | python | def _wrpy_ncbi_gene_nts(fout_py, geneid2nt, log):
num_genes = len(geneid2nt)
with open(fout_py, 'w') as ofstrm:
docstr = "Data downloaded from NCBI Gene converted into Python namedtuples."
ofstrm.write('"""{PYDOC}"""\n\n'.format(PYDOC=docstr))
ofstrm.write("from colle... | [
"def",
"_wrpy_ncbi_gene_nts",
"(",
"fout_py",
",",
"geneid2nt",
",",
"log",
")",
":",
"num_genes",
"=",
"len",
"(",
"geneid2nt",
")",
"with",
"open",
"(",
"fout_py",
",",
"'w'",
")",
"as",
"ofstrm",
":",
"docstr",
"=",
"\"Data downloaded from NCBI Gene convert... | Write namedtuples to a dict in a Python module. | [
"Write",
"namedtuples",
"to",
"a",
"dict",
"in",
"a",
"Python",
"module",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/cli/ncbi_gene_results_to_python.py#L62-L80 |
242,345 | tanghaibao/goatools | goatools/gosubdag/go_tasks.py | get_goobjs_altgo2goobj | def get_goobjs_altgo2goobj(go2obj):
"""Separate alt GO IDs and key GO IDs."""
goobjs = set()
altgo2goobj = {}
for goid, goobj in go2obj.items():
goobjs.add(goobj)
if goid != goobj.id:
altgo2goobj[goid] = goobj
return goobjs, altgo2goobj | python | def get_goobjs_altgo2goobj(go2obj):
goobjs = set()
altgo2goobj = {}
for goid, goobj in go2obj.items():
goobjs.add(goobj)
if goid != goobj.id:
altgo2goobj[goid] = goobj
return goobjs, altgo2goobj | [
"def",
"get_goobjs_altgo2goobj",
"(",
"go2obj",
")",
":",
"goobjs",
"=",
"set",
"(",
")",
"altgo2goobj",
"=",
"{",
"}",
"for",
"goid",
",",
"goobj",
"in",
"go2obj",
".",
"items",
"(",
")",
":",
"goobjs",
".",
"add",
"(",
"goobj",
")",
"if",
"goid",
... | Separate alt GO IDs and key GO IDs. | [
"Separate",
"alt",
"GO",
"IDs",
"and",
"key",
"GO",
"IDs",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/gosubdag/go_tasks.py#L99-L107 |
242,346 | tanghaibao/goatools | goatools/gosubdag/go_tasks.py | add_alt_goids | def add_alt_goids(go2values, altgo2goobj):
"""Add alternate source GO IDs."""
for goobj_key in altgo2goobj.values():
values_curr = go2values[goobj_key.id]
for goid_alt in goobj_key.alt_ids:
go2values[goid_alt] = values_curr
return go2values | python | def add_alt_goids(go2values, altgo2goobj):
for goobj_key in altgo2goobj.values():
values_curr = go2values[goobj_key.id]
for goid_alt in goobj_key.alt_ids:
go2values[goid_alt] = values_curr
return go2values | [
"def",
"add_alt_goids",
"(",
"go2values",
",",
"altgo2goobj",
")",
":",
"for",
"goobj_key",
"in",
"altgo2goobj",
".",
"values",
"(",
")",
":",
"values_curr",
"=",
"go2values",
"[",
"goobj_key",
".",
"id",
"]",
"for",
"goid_alt",
"in",
"goobj_key",
".",
"al... | Add alternate source GO IDs. | [
"Add",
"alternate",
"source",
"GO",
"IDs",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/gosubdag/go_tasks.py#L109-L115 |
242,347 | tanghaibao/goatools | goatools/gosubdag/go_tasks.py | fill_main_goids | def fill_main_goids(go2obj, goids):
"""Ensure main GO IDs are included in go2obj."""
# User GO IDs (goids) may be either main GO IDs or alternate GO IDs.
for goid in goids:
goobj = go2obj[goid]
# If a user specified an ALT GO ID and main GO ID not in go2obj:
if goid != goobj.id and g... | python | def fill_main_goids(go2obj, goids):
# User GO IDs (goids) may be either main GO IDs or alternate GO IDs.
for goid in goids:
goobj = go2obj[goid]
# If a user specified an ALT GO ID and main GO ID not in go2obj:
if goid != goobj.id and goobj.id not in go2obj:
# Add main GO ID t... | [
"def",
"fill_main_goids",
"(",
"go2obj",
",",
"goids",
")",
":",
"# User GO IDs (goids) may be either main GO IDs or alternate GO IDs.",
"for",
"goid",
"in",
"goids",
":",
"goobj",
"=",
"go2obj",
"[",
"goid",
"]",
"# If a user specified an ALT GO ID and main GO ID not in go2o... | Ensure main GO IDs are included in go2obj. | [
"Ensure",
"main",
"GO",
"IDs",
"are",
"included",
"in",
"go2obj",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/gosubdag/go_tasks.py#L118-L126 |
242,348 | tanghaibao/goatools | goatools/gosubdag/go_tasks.py | fill_altgoids | def fill_altgoids(go2obj):
"""Given a go2obj containing key GO IDs, fill with all alternate GO IDs."""
alt2obj = {altgo:goobj for goobj in go2obj.values() for altgo in goobj.alt_ids}
for goid, goobj in alt2obj.items():
go2obj[goid] = goobj | python | def fill_altgoids(go2obj):
alt2obj = {altgo:goobj for goobj in go2obj.values() for altgo in goobj.alt_ids}
for goid, goobj in alt2obj.items():
go2obj[goid] = goobj | [
"def",
"fill_altgoids",
"(",
"go2obj",
")",
":",
"alt2obj",
"=",
"{",
"altgo",
":",
"goobj",
"for",
"goobj",
"in",
"go2obj",
".",
"values",
"(",
")",
"for",
"altgo",
"in",
"goobj",
".",
"alt_ids",
"}",
"for",
"goid",
",",
"goobj",
"in",
"alt2obj",
".... | Given a go2obj containing key GO IDs, fill with all alternate GO IDs. | [
"Given",
"a",
"go2obj",
"containing",
"key",
"GO",
"IDs",
"fill",
"with",
"all",
"alternate",
"GO",
"IDs",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/gosubdag/go_tasks.py#L128-L132 |
242,349 | tanghaibao/goatools | goatools/gosubdag/go_tasks.py | fill_relationshipobjs | def fill_relationshipobjs(go2obj, relationships):
"""Add GO IDs to go2obj that are involved in relationships."""
# Get all GO Term record objects that have relationships
obj = RelationshipFill(go2obj, relationships)
for goobj in go2obj.values():
if goobj.relationship:
obj.fill_relati... | python | def fill_relationshipobjs(go2obj, relationships):
# Get all GO Term record objects that have relationships
obj = RelationshipFill(go2obj, relationships)
for goobj in go2obj.values():
if goobj.relationship:
obj.fill_relationshipgo2obj(goobj)
if goobj.relationship_rev:
... | [
"def",
"fill_relationshipobjs",
"(",
"go2obj",
",",
"relationships",
")",
":",
"# Get all GO Term record objects that have relationships",
"obj",
"=",
"RelationshipFill",
"(",
"go2obj",
",",
"relationships",
")",
"for",
"goobj",
"in",
"go2obj",
".",
"values",
"(",
")"... | Add GO IDs to go2obj that are involved in relationships. | [
"Add",
"GO",
"IDs",
"to",
"go2obj",
"that",
"are",
"involved",
"in",
"relationships",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/gosubdag/go_tasks.py#L135-L143 |
242,350 | tanghaibao/goatools | goatools/gosubdag/go_tasks.py | fill_childgoid2obj | def fill_childgoid2obj(childgoid2obj, parent_obj):
"""Fill childgoid2obj with all child key GO IDs and their objects."""
for child_obj in parent_obj.children:
if child_obj.id not in childgoid2obj:
childgoid2obj[child_obj.id] = child_obj
fill_childgoid2obj(childgoid2obj, child_obj... | python | def fill_childgoid2obj(childgoid2obj, parent_obj):
for child_obj in parent_obj.children:
if child_obj.id not in childgoid2obj:
childgoid2obj[child_obj.id] = child_obj
fill_childgoid2obj(childgoid2obj, child_obj) | [
"def",
"fill_childgoid2obj",
"(",
"childgoid2obj",
",",
"parent_obj",
")",
":",
"for",
"child_obj",
"in",
"parent_obj",
".",
"children",
":",
"if",
"child_obj",
".",
"id",
"not",
"in",
"childgoid2obj",
":",
"childgoid2obj",
"[",
"child_obj",
".",
"id",
"]",
... | Fill childgoid2obj with all child key GO IDs and their objects. | [
"Fill",
"childgoid2obj",
"with",
"all",
"child",
"key",
"GO",
"IDs",
"and",
"their",
"objects",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/gosubdag/go_tasks.py#L180-L185 |
242,351 | tanghaibao/goatools | goatools/gosubdag/go_tasks.py | get_leaf_children | def get_leaf_children(gos_user, go2obj_arg):
"""Find all the GO descendants under all user GO IDs. Return leaf-level GO IDs."""
childgoid2obj = {}
for goid_usr in gos_user:
goobj_usr = go2obj_arg[goid_usr]
fill_childgoid2obj(childgoid2obj, goobj_usr)
return set(go for go, o in childgoid2... | python | def get_leaf_children(gos_user, go2obj_arg):
childgoid2obj = {}
for goid_usr in gos_user:
goobj_usr = go2obj_arg[goid_usr]
fill_childgoid2obj(childgoid2obj, goobj_usr)
return set(go for go, o in childgoid2obj.items() if not o.children) | [
"def",
"get_leaf_children",
"(",
"gos_user",
",",
"go2obj_arg",
")",
":",
"childgoid2obj",
"=",
"{",
"}",
"for",
"goid_usr",
"in",
"gos_user",
":",
"goobj_usr",
"=",
"go2obj_arg",
"[",
"goid_usr",
"]",
"fill_childgoid2obj",
"(",
"childgoid2obj",
",",
"goobj_usr"... | Find all the GO descendants under all user GO IDs. Return leaf-level GO IDs. | [
"Find",
"all",
"the",
"GO",
"descendants",
"under",
"all",
"user",
"GO",
"IDs",
".",
"Return",
"leaf",
"-",
"level",
"GO",
"IDs",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/gosubdag/go_tasks.py#L188-L194 |
242,352 | tanghaibao/goatools | goatools/gosubdag/go_tasks.py | chk_goids | def chk_goids(goids, msg=None, raise_except=True):
"""check that all GO IDs have the proper format."""
for goid in goids:
if not goid_is_valid(goid):
if raise_except:
raise RuntimeError("BAD GO({GO}): {MSG}".format(GO=goid, MSG=msg))
else:
return g... | python | def chk_goids(goids, msg=None, raise_except=True):
for goid in goids:
if not goid_is_valid(goid):
if raise_except:
raise RuntimeError("BAD GO({GO}): {MSG}".format(GO=goid, MSG=msg))
else:
return goid | [
"def",
"chk_goids",
"(",
"goids",
",",
"msg",
"=",
"None",
",",
"raise_except",
"=",
"True",
")",
":",
"for",
"goid",
"in",
"goids",
":",
"if",
"not",
"goid_is_valid",
"(",
"goid",
")",
":",
"if",
"raise_except",
":",
"raise",
"RuntimeError",
"(",
"\"B... | check that all GO IDs have the proper format. | [
"check",
"that",
"all",
"GO",
"IDs",
"have",
"the",
"proper",
"format",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/gosubdag/go_tasks.py#L208-L215 |
242,353 | tanghaibao/goatools | goatools/gosubdag/go_tasks.py | TopologicalSortRelationships._get_sorted_relationships | def _get_sorted_relationships(self, goterm):
"""Traverse GO Terms above the current GO Term. Then add current GO Term to sorted."""
if goterm.id in self.goids_seen:
return
self.goids_seen.add(goterm.id)
for goterm_upper in goterm.get_goterms_upper():
self._get_sor... | python | def _get_sorted_relationships(self, goterm):
if goterm.id in self.goids_seen:
return
self.goids_seen.add(goterm.id)
for goterm_upper in goterm.get_goterms_upper():
self._get_sorted_relationships(goterm_upper)
self.goterms_sorted.append(goterm) | [
"def",
"_get_sorted_relationships",
"(",
"self",
",",
"goterm",
")",
":",
"if",
"goterm",
".",
"id",
"in",
"self",
".",
"goids_seen",
":",
"return",
"self",
".",
"goids_seen",
".",
"add",
"(",
"goterm",
".",
"id",
")",
"for",
"goterm_upper",
"in",
"goter... | Traverse GO Terms above the current GO Term. Then add current GO Term to sorted. | [
"Traverse",
"GO",
"Terms",
"above",
"the",
"current",
"GO",
"Term",
".",
"Then",
"add",
"current",
"GO",
"Term",
"to",
"sorted",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/gosubdag/go_tasks.py#L32-L39 |
242,354 | tanghaibao/goatools | goatools/grouper/read_goids.py | read_sections | def read_sections(sections_file, exclude_ungrouped=False, prt=sys.stdout):
"""Get sections and GO grouping hdrgos from file, if sections exist."""
if sections_file is None:
return None
assert isinstance(sections_file, str), "BAD SECTIONS FILENAME({S})".format(
S=sections_file)
if os.path... | python | def read_sections(sections_file, exclude_ungrouped=False, prt=sys.stdout):
if sections_file is None:
return None
assert isinstance(sections_file, str), "BAD SECTIONS FILENAME({S})".format(
S=sections_file)
if os.path.exists(sections_file):
return ReadGoids().read_sections(sections_fi... | [
"def",
"read_sections",
"(",
"sections_file",
",",
"exclude_ungrouped",
"=",
"False",
",",
"prt",
"=",
"sys",
".",
"stdout",
")",
":",
"if",
"sections_file",
"is",
"None",
":",
"return",
"None",
"assert",
"isinstance",
"(",
"sections_file",
",",
"str",
")",
... | Get sections and GO grouping hdrgos from file, if sections exist. | [
"Get",
"sections",
"and",
"GO",
"grouping",
"hdrgos",
"from",
"file",
"if",
"sections",
"exist",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/read_goids.py#L19-L40 |
242,355 | tanghaibao/goatools | goatools/grouper/read_goids.py | ReadGoids.read_py | def read_py(self, fin_txt, get_goids_only, exclude_ungrouped, prt=sys.stdout):
"""Read GO IDs or sections data from a Python file."""
goids_fin = self._read_py(fin_txt, get_goids_only, exclude_ungrouped)
sections = self._read_finish(goids_fin, prt)
# Print summary of GO IDs read
... | python | def read_py(self, fin_txt, get_goids_only, exclude_ungrouped, prt=sys.stdout):
goids_fin = self._read_py(fin_txt, get_goids_only, exclude_ungrouped)
sections = self._read_finish(goids_fin, prt)
# Print summary of GO IDs read
if prt is not None:
self._prt_read_msg(prt, fin_txt... | [
"def",
"read_py",
"(",
"self",
",",
"fin_txt",
",",
"get_goids_only",
",",
"exclude_ungrouped",
",",
"prt",
"=",
"sys",
".",
"stdout",
")",
":",
"goids_fin",
"=",
"self",
".",
"_read_py",
"(",
"fin_txt",
",",
"get_goids_only",
",",
"exclude_ungrouped",
")",
... | Read GO IDs or sections data from a Python file. | [
"Read",
"GO",
"IDs",
"or",
"sections",
"data",
"from",
"a",
"Python",
"file",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/read_goids.py#L74-L81 |
242,356 | tanghaibao/goatools | goatools/grouper/read_goids.py | ReadGoids.read_sections | def read_sections(self, sections_file, get_goids_only, exclude_ungrouped):
"""Read sections variable from a text file of from a Python file."""
ext = os.path.splitext(sections_file)[1]
file_contents = None
if ext == '.py':
file_contents = self.read_py(sections_file, get_goids... | python | def read_sections(self, sections_file, get_goids_only, exclude_ungrouped):
ext = os.path.splitext(sections_file)[1]
file_contents = None
if ext == '.py':
file_contents = self.read_py(sections_file, get_goids_only, exclude_ungrouped)
else:
file_contents = self.read... | [
"def",
"read_sections",
"(",
"self",
",",
"sections_file",
",",
"get_goids_only",
",",
"exclude_ungrouped",
")",
":",
"ext",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"sections_file",
")",
"[",
"1",
"]",
"file_contents",
"=",
"None",
"if",
"ext",
"==",... | Read sections variable from a text file of from a Python file. | [
"Read",
"sections",
"variable",
"from",
"a",
"text",
"file",
"of",
"from",
"a",
"Python",
"file",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/read_goids.py#L83-L92 |
242,357 | tanghaibao/goatools | goatools/grouper/read_goids.py | ReadGoids._rpt_unused_sections | def _rpt_unused_sections(self, prt):
"""Report unused sections."""
sections_unused = set(self.sections_seen).difference(self.section2goids.keys())
for sec in sections_unused:
prt.write(" UNUSED SECTION: {SEC}\n".format(SEC=sec)) | python | def _rpt_unused_sections(self, prt):
sections_unused = set(self.sections_seen).difference(self.section2goids.keys())
for sec in sections_unused:
prt.write(" UNUSED SECTION: {SEC}\n".format(SEC=sec)) | [
"def",
"_rpt_unused_sections",
"(",
"self",
",",
"prt",
")",
":",
"sections_unused",
"=",
"set",
"(",
"self",
".",
"sections_seen",
")",
".",
"difference",
"(",
"self",
".",
"section2goids",
".",
"keys",
"(",
")",
")",
"for",
"sec",
"in",
"sections_unused"... | Report unused sections. | [
"Report",
"unused",
"sections",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/read_goids.py#L161-L165 |
242,358 | tanghaibao/goatools | goatools/grouper/read_goids.py | ReadGoids._prt_read_msg | def _prt_read_msg(self, prt, fin_txt, exclude_ungrouped):
"""Print which file was read and the number of GO IDs found."""
if self.sections_seen or exclude_ungrouped:
# dat = Grouper.get_summary_data(self.section2goids.items(), HdrgosSections.secdflt)
dat = SummarySec2dHdrGos().su... | python | def _prt_read_msg(self, prt, fin_txt, exclude_ungrouped):
if self.sections_seen or exclude_ungrouped:
# dat = Grouper.get_summary_data(self.section2goids.items(), HdrgosSections.secdflt)
dat = SummarySec2dHdrGos().summarize_sec2hdrgos(self.section2goids.items())
sys.stdout.wr... | [
"def",
"_prt_read_msg",
"(",
"self",
",",
"prt",
",",
"fin_txt",
",",
"exclude_ungrouped",
")",
":",
"if",
"self",
".",
"sections_seen",
"or",
"exclude_ungrouped",
":",
"# dat = Grouper.get_summary_data(self.section2goids.items(), HdrgosSections.secdflt)",
"dat",
"=",
"Su... | Print which file was read and the number of GO IDs found. | [
"Print",
"which",
"file",
"was",
"read",
"and",
"the",
"number",
"of",
"GO",
"IDs",
"found",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/read_goids.py#L182-L191 |
242,359 | tanghaibao/goatools | goatools/gosubdag/go_edges.py | EdgesBase.rm_gos | def rm_gos(self, rm_goids):
"""Remove any edges that contain user-specified edges."""
self.edges = self._rm_gos_edges(rm_goids, self.edges)
self.edges_rel = self._rm_gos_edges_rel(rm_goids, self.edges_rel) | python | def rm_gos(self, rm_goids):
self.edges = self._rm_gos_edges(rm_goids, self.edges)
self.edges_rel = self._rm_gos_edges_rel(rm_goids, self.edges_rel) | [
"def",
"rm_gos",
"(",
"self",
",",
"rm_goids",
")",
":",
"self",
".",
"edges",
"=",
"self",
".",
"_rm_gos_edges",
"(",
"rm_goids",
",",
"self",
".",
"edges",
")",
"self",
".",
"edges_rel",
"=",
"self",
".",
"_rm_gos_edges_rel",
"(",
"rm_goids",
",",
"s... | Remove any edges that contain user-specified edges. | [
"Remove",
"any",
"edges",
"that",
"contain",
"user",
"-",
"specified",
"edges",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/gosubdag/go_edges.py#L64-L67 |
242,360 | tanghaibao/goatools | goatools/gosubdag/go_edges.py | EdgesBase._rm_gos_edges_rel | def _rm_gos_edges_rel(self, rm_goids, edges_rel):
"""Remove any relationship that contain user-specified edges."""
edges_ret = {}
for rname, edges_cur in edges_rel.items():
edges_new = self._rm_gos_edges(rm_goids, edges_cur)
if edges_new:
edges_ret[rname] ... | python | def _rm_gos_edges_rel(self, rm_goids, edges_rel):
edges_ret = {}
for rname, edges_cur in edges_rel.items():
edges_new = self._rm_gos_edges(rm_goids, edges_cur)
if edges_new:
edges_ret[rname] = edges_new
return edges_ret | [
"def",
"_rm_gos_edges_rel",
"(",
"self",
",",
"rm_goids",
",",
"edges_rel",
")",
":",
"edges_ret",
"=",
"{",
"}",
"for",
"rname",
",",
"edges_cur",
"in",
"edges_rel",
".",
"items",
"(",
")",
":",
"edges_new",
"=",
"self",
".",
"_rm_gos_edges",
"(",
"rm_g... | Remove any relationship that contain user-specified edges. | [
"Remove",
"any",
"relationship",
"that",
"contain",
"user",
"-",
"specified",
"edges",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/gosubdag/go_edges.py#L69-L76 |
242,361 | tanghaibao/goatools | goatools/gosubdag/go_edges.py | EdgesBase._rm_gos_edges | def _rm_gos_edges(rm_goids, edges_all):
"""Remove any is_a edges that contain user-specified edges."""
edges_reduced = []
for goid_child, goid_parent in sorted(edges_all, key=lambda t: t[1]):
if goid_child not in rm_goids and goid_parent not in rm_goids:
edges_reduced... | python | def _rm_gos_edges(rm_goids, edges_all):
edges_reduced = []
for goid_child, goid_parent in sorted(edges_all, key=lambda t: t[1]):
if goid_child not in rm_goids and goid_parent not in rm_goids:
edges_reduced.append((goid_child, goid_parent))
return edges_reduced | [
"def",
"_rm_gos_edges",
"(",
"rm_goids",
",",
"edges_all",
")",
":",
"edges_reduced",
"=",
"[",
"]",
"for",
"goid_child",
",",
"goid_parent",
"in",
"sorted",
"(",
"edges_all",
",",
"key",
"=",
"lambda",
"t",
":",
"t",
"[",
"1",
"]",
")",
":",
"if",
"... | Remove any is_a edges that contain user-specified edges. | [
"Remove",
"any",
"is_a",
"edges",
"that",
"contain",
"user",
"-",
"specified",
"edges",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/gosubdag/go_edges.py#L79-L85 |
242,362 | tanghaibao/goatools | goatools/gosubdag/go_edges.py | EdgesBase.get_all_edge_nodes | def get_all_edge_nodes(self):
"""Return a list of all GO IDs that are connected to edges."""
edge_nodes = set(e for es in self.edges for e in es)
for edges in self.edges_rel.values():
rel_nodes = set(e for es in edges for e in es)
edge_nodes.update(rel_nodes)
retu... | python | def get_all_edge_nodes(self):
edge_nodes = set(e for es in self.edges for e in es)
for edges in self.edges_rel.values():
rel_nodes = set(e for es in edges for e in es)
edge_nodes.update(rel_nodes)
return edge_nodes | [
"def",
"get_all_edge_nodes",
"(",
"self",
")",
":",
"edge_nodes",
"=",
"set",
"(",
"e",
"for",
"es",
"in",
"self",
".",
"edges",
"for",
"e",
"in",
"es",
")",
"for",
"edges",
"in",
"self",
".",
"edges_rel",
".",
"values",
"(",
")",
":",
"rel_nodes",
... | Return a list of all GO IDs that are connected to edges. | [
"Return",
"a",
"list",
"of",
"all",
"GO",
"IDs",
"that",
"are",
"connected",
"to",
"edges",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/gosubdag/go_edges.py#L87-L93 |
242,363 | tanghaibao/goatools | goatools/gosubdag/go_edges.py | EdgesBase.chk_edges | def chk_edges(self):
"""Check that all edge nodes exist in local subset."""
goids = set(self.go2obj)
self.chk_edges_nodes(self.edges, goids, "is_a")
for reltype, edges in self.edges_rel.items():
self.chk_edges_nodes(edges, goids, reltype) | python | def chk_edges(self):
goids = set(self.go2obj)
self.chk_edges_nodes(self.edges, goids, "is_a")
for reltype, edges in self.edges_rel.items():
self.chk_edges_nodes(edges, goids, reltype) | [
"def",
"chk_edges",
"(",
"self",
")",
":",
"goids",
"=",
"set",
"(",
"self",
".",
"go2obj",
")",
"self",
".",
"chk_edges_nodes",
"(",
"self",
".",
"edges",
",",
"goids",
",",
"\"is_a\"",
")",
"for",
"reltype",
",",
"edges",
"in",
"self",
".",
"edges_... | Check that all edge nodes exist in local subset. | [
"Check",
"that",
"all",
"edge",
"nodes",
"exist",
"in",
"local",
"subset",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/gosubdag/go_edges.py#L95-L100 |
242,364 | tanghaibao/goatools | goatools/gosubdag/go_edges.py | EdgesBase.chk_edges_nodes | def chk_edges_nodes(edges, nodes, name):
"""Check that user specified edges have a node which exists."""
edge_nodes = set(e for es in edges for e in es)
missing_nodes = edge_nodes.difference(nodes)
assert not missing_nodes, "MISSING: {GOs}\n{NM} EDGES MISSING {N} NODES (OF {T})".format(
... | python | def chk_edges_nodes(edges, nodes, name):
edge_nodes = set(e for es in edges for e in es)
missing_nodes = edge_nodes.difference(nodes)
assert not missing_nodes, "MISSING: {GOs}\n{NM} EDGES MISSING {N} NODES (OF {T})".format(
NM=name, N=len(missing_nodes), T=len(edge_nodes), GOs=missin... | [
"def",
"chk_edges_nodes",
"(",
"edges",
",",
"nodes",
",",
"name",
")",
":",
"edge_nodes",
"=",
"set",
"(",
"e",
"for",
"es",
"in",
"edges",
"for",
"e",
"in",
"es",
")",
"missing_nodes",
"=",
"edge_nodes",
".",
"difference",
"(",
"nodes",
")",
"assert"... | Check that user specified edges have a node which exists. | [
"Check",
"that",
"user",
"specified",
"edges",
"have",
"a",
"node",
"which",
"exists",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/gosubdag/go_edges.py#L103-L108 |
242,365 | tanghaibao/goatools | goatools/gosubdag/go_edges.py | EdgesBase.get_c2ps | def get_c2ps(self):
"""Set child2parents dict for all parents used in this set of edges."""
c2ps = defaultdict(set)
for goid_child, goid_parent in self.edges:
c2ps[goid_child].add(goid_parent)
return c2ps | python | def get_c2ps(self):
c2ps = defaultdict(set)
for goid_child, goid_parent in self.edges:
c2ps[goid_child].add(goid_parent)
return c2ps | [
"def",
"get_c2ps",
"(",
"self",
")",
":",
"c2ps",
"=",
"defaultdict",
"(",
"set",
")",
"for",
"goid_child",
",",
"goid_parent",
"in",
"self",
".",
"edges",
":",
"c2ps",
"[",
"goid_child",
"]",
".",
"add",
"(",
"goid_parent",
")",
"return",
"c2ps"
] | Set child2parents dict for all parents used in this set of edges. | [
"Set",
"child2parents",
"dict",
"for",
"all",
"parents",
"used",
"in",
"this",
"set",
"of",
"edges",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/gosubdag/go_edges.py#L110-L115 |
242,366 | tanghaibao/goatools | goatools/gosubdag/go_edges.py | EdgesRelatives._init_edges_relationships | def _init_edges_relationships(rel2src2dsts, rel2dst2srcs):
"""Get the directed edges from GO term to GO term using relationships."""
edge_rel2fromto = {}
relationships = set(rel2src2dsts).union(rel2dst2srcs)
for reltype in relationships:
edge_from_to = []
if relty... | python | def _init_edges_relationships(rel2src2dsts, rel2dst2srcs):
edge_rel2fromto = {}
relationships = set(rel2src2dsts).union(rel2dst2srcs)
for reltype in relationships:
edge_from_to = []
if reltype in rel2src2dsts:
for parent, children in rel2src2dsts[reltype].... | [
"def",
"_init_edges_relationships",
"(",
"rel2src2dsts",
",",
"rel2dst2srcs",
")",
":",
"edge_rel2fromto",
"=",
"{",
"}",
"relationships",
"=",
"set",
"(",
"rel2src2dsts",
")",
".",
"union",
"(",
"rel2dst2srcs",
")",
"for",
"reltype",
"in",
"relationships",
":",... | Get the directed edges from GO term to GO term using relationships. | [
"Get",
"the",
"directed",
"edges",
"from",
"GO",
"term",
"to",
"GO",
"term",
"using",
"relationships",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/gosubdag/go_edges.py#L169-L184 |
242,367 | tanghaibao/goatools | goatools/gosubdag/go_edges.py | EdgesRelatives._traverse_relationship_objs | def _traverse_relationship_objs(self, rel2src2dsts, goobj_child, goids_seen):
"""Traverse from source GO up relationships."""
child_id = goobj_child.id
goids_seen.add(child_id)
##A self.go2obj[child_id] = goobj_child
# Update goids_seen and go2obj with child alt_ids
for g... | python | def _traverse_relationship_objs(self, rel2src2dsts, goobj_child, goids_seen):
child_id = goobj_child.id
goids_seen.add(child_id)
##A self.go2obj[child_id] = goobj_child
# Update goids_seen and go2obj with child alt_ids
for goid_altid in goobj_child.alt_ids:
goids_seen... | [
"def",
"_traverse_relationship_objs",
"(",
"self",
",",
"rel2src2dsts",
",",
"goobj_child",
",",
"goids_seen",
")",
":",
"child_id",
"=",
"goobj_child",
".",
"id",
"goids_seen",
".",
"add",
"(",
"child_id",
")",
"##A self.go2obj[child_id] = goobj_child",
"# Update goi... | Traverse from source GO up relationships. | [
"Traverse",
"from",
"source",
"GO",
"up",
"relationships",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/gosubdag/go_edges.py#L200-L217 |
242,368 | tanghaibao/goatools | goatools/gosubdag/go_edges.py | EdgesRelatives._init_rel2dst2srcs | def _init_rel2dst2srcs(self, go_sources, traverse_child):
"""Traverse through reverse relationships."""
if not traverse_child or not self.relationships:
return {}
rel2dst2srcs = {r:defaultdict(set) for r in self.relationships}
goids_seen = set()
go2obj = self.go2obj
... | python | def _init_rel2dst2srcs(self, go_sources, traverse_child):
if not traverse_child or not self.relationships:
return {}
rel2dst2srcs = {r:defaultdict(set) for r in self.relationships}
goids_seen = set()
go2obj = self.go2obj
for goid_src in go_sources:
goobj_s... | [
"def",
"_init_rel2dst2srcs",
"(",
"self",
",",
"go_sources",
",",
"traverse_child",
")",
":",
"if",
"not",
"traverse_child",
"or",
"not",
"self",
".",
"relationships",
":",
"return",
"{",
"}",
"rel2dst2srcs",
"=",
"{",
"r",
":",
"defaultdict",
"(",
"set",
... | Traverse through reverse relationships. | [
"Traverse",
"through",
"reverse",
"relationships",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/gosubdag/go_edges.py#L220-L231 |
242,369 | tanghaibao/goatools | goatools/gosubdag/go_edges.py | EdgesRelatives._init_c2ps | def _init_c2ps(self, go_sources, traverse_child):
"""Traverse up children."""
if not traverse_child:
return {}
c2ps = defaultdict(set)
goids_seen = set()
go2obj = self.go2obj
for goid_src in go_sources:
goobj_src = go2obj[goid_src]
if g... | python | def _init_c2ps(self, go_sources, traverse_child):
if not traverse_child:
return {}
c2ps = defaultdict(set)
goids_seen = set()
go2obj = self.go2obj
for goid_src in go_sources:
goobj_src = go2obj[goid_src]
if goid_src not in goids_seen:
... | [
"def",
"_init_c2ps",
"(",
"self",
",",
"go_sources",
",",
"traverse_child",
")",
":",
"if",
"not",
"traverse_child",
":",
"return",
"{",
"}",
"c2ps",
"=",
"defaultdict",
"(",
"set",
")",
"goids_seen",
"=",
"set",
"(",
")",
"go2obj",
"=",
"self",
".",
"... | Traverse up children. | [
"Traverse",
"up",
"children",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/gosubdag/go_edges.py#L290-L302 |
242,370 | tanghaibao/goatools | goatools/anno/init/reader_gaf.py | GafData.chk | def chk(self, annotations, fout_err):
"""Check annotations."""
for idx, ntd in enumerate(annotations):
self._chk_fld(ntd, "Qualifier") # optional 0 or greater
self._chk_fld(ntd, "DB_Reference", 1) # required 1 or greater
self._chk_fld(ntd, "With_From") ... | python | def chk(self, annotations, fout_err):
for idx, ntd in enumerate(annotations):
self._chk_fld(ntd, "Qualifier") # optional 0 or greater
self._chk_fld(ntd, "DB_Reference", 1) # required 1 or greater
self._chk_fld(ntd, "With_From") # optional 0 or greater
... | [
"def",
"chk",
"(",
"self",
",",
"annotations",
",",
"fout_err",
")",
":",
"for",
"idx",
",",
"ntd",
"in",
"enumerate",
"(",
"annotations",
")",
":",
"self",
".",
"_chk_fld",
"(",
"ntd",
",",
"\"Qualifier\"",
")",
"# optional 0 or greater",
"self",
".",
"... | Check annotations. | [
"Check",
"annotations",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/anno/init/reader_gaf.py#L151-L167 |
242,371 | tanghaibao/goatools | goatools/anno/init/reader_gaf.py | GafData.get_gafvals | def get_gafvals(self, line):
"""Convert fields from string to preferred format for GAF ver 2.1 and 2.0."""
flds = line.split('\t')
flds[3] = self._get_qualifier(flds[3]) # 3 Qualifier
flds[5] = self._get_set(flds[5]) # 5 DB_Reference
flds[7] = self._get_set(flds[7]) #... | python | def get_gafvals(self, line):
flds = line.split('\t')
flds[3] = self._get_qualifier(flds[3]) # 3 Qualifier
flds[5] = self._get_set(flds[5]) # 5 DB_Reference
flds[7] = self._get_set(flds[7]) # 7 With_From
flds[8] = self.aspect2ns[flds[8]] # 8 GAF Aspect field conver... | [
"def",
"get_gafvals",
"(",
"self",
",",
"line",
")",
":",
"flds",
"=",
"line",
".",
"split",
"(",
"'\\t'",
")",
"flds",
"[",
"3",
"]",
"=",
"self",
".",
"_get_qualifier",
"(",
"flds",
"[",
"3",
"]",
")",
"# 3 Qualifier",
"flds",
"[",
"5",
"]",
"... | Convert fields from string to preferred format for GAF ver 2.1 and 2.0. | [
"Convert",
"fields",
"from",
"string",
"to",
"preferred",
"format",
"for",
"GAF",
"ver",
"2",
".",
"1",
"and",
"2",
".",
"0",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/anno/init/reader_gaf.py#L173-L192 |
242,372 | tanghaibao/goatools | goatools/anno/init/reader_gaf.py | GafData._get_qualifier | def _get_qualifier(val):
"""Get qualifiers. Correct for inconsistent capitalization in GAF files"""
quals = set()
if val == '':
return quals
for val in val.split('|'):
val = val.lower()
quals.add(val if val != 'not' else 'NOT')
return quals | python | def _get_qualifier(val):
quals = set()
if val == '':
return quals
for val in val.split('|'):
val = val.lower()
quals.add(val if val != 'not' else 'NOT')
return quals | [
"def",
"_get_qualifier",
"(",
"val",
")",
":",
"quals",
"=",
"set",
"(",
")",
"if",
"val",
"==",
"''",
":",
"return",
"quals",
"for",
"val",
"in",
"val",
".",
"split",
"(",
"'|'",
")",
":",
"val",
"=",
"val",
".",
"lower",
"(",
")",
"quals",
".... | Get qualifiers. Correct for inconsistent capitalization in GAF files | [
"Get",
"qualifiers",
".",
"Correct",
"for",
"inconsistent",
"capitalization",
"in",
"GAF",
"files"
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/anno/init/reader_gaf.py#L195-L203 |
242,373 | tanghaibao/goatools | goatools/anno/init/reader_gaf.py | GafData._chk_fld | def _chk_fld(self, ntd, name, qty_min=0, qty_max=None):
"""Further split a GAF value within a single field."""
vals = getattr(ntd, name)
num_vals = len(vals)
if num_vals < qty_min:
self.illegal_lines['MIN QTY'].append(
(-1, "FIELD({F}): MIN QUANTITY({Q}) WASN'... | python | def _chk_fld(self, ntd, name, qty_min=0, qty_max=None):
vals = getattr(ntd, name)
num_vals = len(vals)
if num_vals < qty_min:
self.illegal_lines['MIN QTY'].append(
(-1, "FIELD({F}): MIN QUANTITY({Q}) WASN'T MET: {V}".format(F=name, Q=qty_min, V=vals)))
if qty_... | [
"def",
"_chk_fld",
"(",
"self",
",",
"ntd",
",",
"name",
",",
"qty_min",
"=",
"0",
",",
"qty_max",
"=",
"None",
")",
":",
"vals",
"=",
"getattr",
"(",
"ntd",
",",
"name",
")",
"num_vals",
"=",
"len",
"(",
"vals",
")",
"if",
"num_vals",
"<",
"qty_... | Further split a GAF value within a single field. | [
"Further",
"split",
"a",
"GAF",
"value",
"within",
"a",
"single",
"field",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/anno/init/reader_gaf.py#L215-L226 |
242,374 | tanghaibao/goatools | goatools/anno/init/reader_gaf.py | GafData.prt_line_detail | def prt_line_detail(self, prt, line):
"""Print line header and values in a readable format."""
values = line.split('\t')
self._prt_line_detail(prt, values) | python | def prt_line_detail(self, prt, line):
values = line.split('\t')
self._prt_line_detail(prt, values) | [
"def",
"prt_line_detail",
"(",
"self",
",",
"prt",
",",
"line",
")",
":",
"values",
"=",
"line",
".",
"split",
"(",
"'\\t'",
")",
"self",
".",
"_prt_line_detail",
"(",
"prt",
",",
"values",
")"
] | Print line header and values in a readable format. | [
"Print",
"line",
"header",
"and",
"values",
"in",
"a",
"readable",
"format",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/anno/init/reader_gaf.py#L236-L239 |
242,375 | tanghaibao/goatools | goatools/anno/init/reader_gaf.py | GafData._prt_line_detail | def _prt_line_detail(self, prt, values, lnum=""):
"""Print header and field values in a readable format."""
#### data = zip(self.req_str, self.ntgafobj._fields, values)
data = zip(self.req_str, self.flds, values)
txt = ["{:2}) {:3} {:20} {}".format(i, req, hdr, val) for i, (req, hdr, val... | python | def _prt_line_detail(self, prt, values, lnum=""):
#### data = zip(self.req_str, self.ntgafobj._fields, values)
data = zip(self.req_str, self.flds, values)
txt = ["{:2}) {:3} {:20} {}".format(i, req, hdr, val) for i, (req, hdr, val) in enumerate(data)]
prt.write("{LNUM}\n{TXT}\n".format(L... | [
"def",
"_prt_line_detail",
"(",
"self",
",",
"prt",
",",
"values",
",",
"lnum",
"=",
"\"\"",
")",
":",
"#### data = zip(self.req_str, self.ntgafobj._fields, values)",
"data",
"=",
"zip",
"(",
"self",
".",
"req_str",
",",
"self",
".",
"flds",
",",
"values",
")"... | Print header and field values in a readable format. | [
"Print",
"header",
"and",
"field",
"values",
"in",
"a",
"readable",
"format",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/anno/init/reader_gaf.py#L241-L246 |
242,376 | tanghaibao/goatools | goatools/anno/init/reader_gaf.py | GafData.prt_error_summary | def prt_error_summary(self, fout_err):
"""Print a summary about the GAF file that was read."""
# Get summary of error types and their counts
errcnts = []
if self.ignored:
errcnts.append(" {N:9,} IGNORED associations\n".format(N=len(self.ignored)))
if self.illegal_lin... | python | def prt_error_summary(self, fout_err):
# Get summary of error types and their counts
errcnts = []
if self.ignored:
errcnts.append(" {N:9,} IGNORED associations\n".format(N=len(self.ignored)))
if self.illegal_lines:
for err_name, errors in self.illegal_lines.items... | [
"def",
"prt_error_summary",
"(",
"self",
",",
"fout_err",
")",
":",
"# Get summary of error types and their counts",
"errcnts",
"=",
"[",
"]",
"if",
"self",
".",
"ignored",
":",
"errcnts",
".",
"append",
"(",
"\" {N:9,} IGNORED associations\\n\"",
".",
"format",
"(... | Print a summary about the GAF file that was read. | [
"Print",
"a",
"summary",
"about",
"the",
"GAF",
"file",
"that",
"was",
"read",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/anno/init/reader_gaf.py#L265-L278 |
242,377 | tanghaibao/goatools | goatools/anno/init/reader_gaf.py | GafData._wrlog_details_illegal_gaf | def _wrlog_details_illegal_gaf(self, fout_err, err_cnts):
"""Print details regarding illegal GAF lines seen to a log file."""
# fout_err = "{}.log".format(fin_gaf)
gaf_base = os.path.basename(fout_err)
with open(fout_err, 'w') as prt:
prt.write("ILLEGAL GAF ERROR SUMMARY:\n\n... | python | def _wrlog_details_illegal_gaf(self, fout_err, err_cnts):
# fout_err = "{}.log".format(fin_gaf)
gaf_base = os.path.basename(fout_err)
with open(fout_err, 'w') as prt:
prt.write("ILLEGAL GAF ERROR SUMMARY:\n\n")
for err_cnt in err_cnts:
prt.write(err_cnt)
... | [
"def",
"_wrlog_details_illegal_gaf",
"(",
"self",
",",
"fout_err",
",",
"err_cnts",
")",
":",
"# fout_err = \"{}.log\".format(fin_gaf)",
"gaf_base",
"=",
"os",
".",
"path",
".",
"basename",
"(",
"fout_err",
")",
"with",
"open",
"(",
"fout_err",
",",
"'w'",
")",
... | Print details regarding illegal GAF lines seen to a log file. | [
"Print",
"details",
"regarding",
"illegal",
"GAF",
"lines",
"seen",
"to",
"a",
"log",
"file",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/anno/init/reader_gaf.py#L280-L300 |
242,378 | tanghaibao/goatools | goatools/gosubdag/godag_rcnt_init.py | CountRelativesInit.get_relationship_dicts | def get_relationship_dicts(self):
"""Given GO DAG relationships, return summaries per GO ID."""
if not self.relationships:
return None
for goid, goobj in self.go2obj.items():
for reltyp, relset in goobj.relationship.items():
relfwd_goids = set(o.id for o i... | python | def get_relationship_dicts(self):
if not self.relationships:
return None
for goid, goobj in self.go2obj.items():
for reltyp, relset in goobj.relationship.items():
relfwd_goids = set(o.id for o in relset)
# for relfwd_goid in relfwd_goids:
... | [
"def",
"get_relationship_dicts",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"relationships",
":",
"return",
"None",
"for",
"goid",
",",
"goobj",
"in",
"self",
".",
"go2obj",
".",
"items",
"(",
")",
":",
"for",
"reltyp",
",",
"relset",
"in",
"goob... | Given GO DAG relationships, return summaries per GO ID. | [
"Given",
"GO",
"DAG",
"relationships",
"return",
"summaries",
"per",
"GO",
"ID",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/gosubdag/godag_rcnt_init.py#L38-L48 |
242,379 | tanghaibao/goatools | goatools/gosubdag/godag_rcnt_init.py | CountRelativesInit.get_goone2ntletter | def get_goone2ntletter(self, go2dcnt, depth2goobjs):
"""Assign letters to depth-01 GO terms ordered using descendants cnt."""
# 1. Group level-01/depth-01 GO terms by namespace
ns2dcntgoobj = cx.defaultdict(list)
for goobj in depth2goobjs[1]:
dcnt = go2dcnt[goobj.id]
... | python | def get_goone2ntletter(self, go2dcnt, depth2goobjs):
# 1. Group level-01/depth-01 GO terms by namespace
ns2dcntgoobj = cx.defaultdict(list)
for goobj in depth2goobjs[1]:
dcnt = go2dcnt[goobj.id]
ns2dcntgoobj[goobj.namespace].append((dcnt, goobj))
# 2. Assign lette... | [
"def",
"get_goone2ntletter",
"(",
"self",
",",
"go2dcnt",
",",
"depth2goobjs",
")",
":",
"# 1. Group level-01/depth-01 GO terms by namespace",
"ns2dcntgoobj",
"=",
"cx",
".",
"defaultdict",
"(",
"list",
")",
"for",
"goobj",
"in",
"depth2goobjs",
"[",
"1",
"]",
":"... | Assign letters to depth-01 GO terms ordered using descendants cnt. | [
"Assign",
"letters",
"to",
"depth",
"-",
"01",
"GO",
"terms",
"ordered",
"using",
"descendants",
"cnt",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/gosubdag/godag_rcnt_init.py#L50-L68 |
242,380 | tanghaibao/goatools | goatools/grouper/grprdflts.py | GrouperDflts._init_goslims | def _init_goslims(self, dagslim):
"""Get GO IDs in GO slims."""
go2obj_main = self.gosubdag.go2obj
go2obj_slim = {go for go, o in dagslim.items() if go in go2obj_main}
if self.gosubdag.relationships:
return self._get_goslimids_norel(go2obj_slim)
return set(dagslim.key... | python | def _init_goslims(self, dagslim):
go2obj_main = self.gosubdag.go2obj
go2obj_slim = {go for go, o in dagslim.items() if go in go2obj_main}
if self.gosubdag.relationships:
return self._get_goslimids_norel(go2obj_slim)
return set(dagslim.keys()) | [
"def",
"_init_goslims",
"(",
"self",
",",
"dagslim",
")",
":",
"go2obj_main",
"=",
"self",
".",
"gosubdag",
".",
"go2obj",
"go2obj_slim",
"=",
"{",
"go",
"for",
"go",
",",
"o",
"in",
"dagslim",
".",
"items",
"(",
")",
"if",
"go",
"in",
"go2obj_main",
... | Get GO IDs in GO slims. | [
"Get",
"GO",
"IDs",
"in",
"GO",
"slims",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/grprdflts.py#L48-L54 |
242,381 | tanghaibao/goatools | goatools/grouper/grprdflts.py | GrouperDflts._get_goslimids_norel | def _get_goslimids_norel(self, dagslim):
"""Get all GO slim GO IDs that do not have a relationship."""
go_slims = set()
go2obj = self.gosubdag.go2obj
for goid in dagslim:
goobj = go2obj[goid]
if not goobj.relationship:
go_slims.add(goobj.id)
... | python | def _get_goslimids_norel(self, dagslim):
go_slims = set()
go2obj = self.gosubdag.go2obj
for goid in dagslim:
goobj = go2obj[goid]
if not goobj.relationship:
go_slims.add(goobj.id)
return go_slims | [
"def",
"_get_goslimids_norel",
"(",
"self",
",",
"dagslim",
")",
":",
"go_slims",
"=",
"set",
"(",
")",
"go2obj",
"=",
"self",
".",
"gosubdag",
".",
"go2obj",
"for",
"goid",
"in",
"dagslim",
":",
"goobj",
"=",
"go2obj",
"[",
"goid",
"]",
"if",
"not",
... | Get all GO slim GO IDs that do not have a relationship. | [
"Get",
"all",
"GO",
"slim",
"GO",
"IDs",
"that",
"do",
"not",
"have",
"a",
"relationship",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/grprdflts.py#L60-L68 |
242,382 | tanghaibao/goatools | goatools/grouper/grprdflts.py | GrouperDflts.get_gosubdag | def get_gosubdag(gosubdag=None):
"""Gets a GoSubDag initialized for use by a Grouper object."""
if gosubdag is not None:
if gosubdag.rcntobj is not None:
return gosubdag
else:
gosubdag.init_auxobjs()
return gosubdag
else:
... | python | def get_gosubdag(gosubdag=None):
if gosubdag is not None:
if gosubdag.rcntobj is not None:
return gosubdag
else:
gosubdag.init_auxobjs()
return gosubdag
else:
go2obj = get_godag()
return GoSubDag(None, go2obj... | [
"def",
"get_gosubdag",
"(",
"gosubdag",
"=",
"None",
")",
":",
"if",
"gosubdag",
"is",
"not",
"None",
":",
"if",
"gosubdag",
".",
"rcntobj",
"is",
"not",
"None",
":",
"return",
"gosubdag",
"else",
":",
"gosubdag",
".",
"init_auxobjs",
"(",
")",
"return",... | Gets a GoSubDag initialized for use by a Grouper object. | [
"Gets",
"a",
"GoSubDag",
"initialized",
"for",
"use",
"by",
"a",
"Grouper",
"object",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/grprdflts.py#L71-L81 |
242,383 | tanghaibao/goatools | goatools/anno/opts.py | AnnoOptions.getfnc_qual_ev | def getfnc_qual_ev(self):
"""Keep annotaion if it passes potentially modified selection."""
fnc_key = (
self.nd_not2desc[(self._keep_nd, self._keep_not)],
self.incexc2num[(
self.include_evcodes is not None,
self.exclude_evcodes is not None)],
... | python | def getfnc_qual_ev(self):
fnc_key = (
self.nd_not2desc[(self._keep_nd, self._keep_not)],
self.incexc2num[(
self.include_evcodes is not None,
self.exclude_evcodes is not None)],
)
return self.param2fnc[fnc_key] | [
"def",
"getfnc_qual_ev",
"(",
"self",
")",
":",
"fnc_key",
"=",
"(",
"self",
".",
"nd_not2desc",
"[",
"(",
"self",
".",
"_keep_nd",
",",
"self",
".",
"_keep_not",
")",
"]",
",",
"self",
".",
"incexc2num",
"[",
"(",
"self",
".",
"include_evcodes",
"is",... | Keep annotaion if it passes potentially modified selection. | [
"Keep",
"annotaion",
"if",
"it",
"passes",
"potentially",
"modified",
"selection",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/anno/opts.py#L65-L73 |
242,384 | tanghaibao/goatools | goatools/gosubdag/plot/go_node.py | GoNodeOpts.get_kws | def get_kws(self):
"""Only load keywords if they are specified by the user."""
ret = self.kws['dict'].copy()
act_set = self.kws['set']
if 'shorten' in act_set and 'goobj2fncname' not in ret:
ret['goobj2fncname'] = ShortenText().get_short_plot_name
return ret | python | def get_kws(self):
ret = self.kws['dict'].copy()
act_set = self.kws['set']
if 'shorten' in act_set and 'goobj2fncname' not in ret:
ret['goobj2fncname'] = ShortenText().get_short_plot_name
return ret | [
"def",
"get_kws",
"(",
"self",
")",
":",
"ret",
"=",
"self",
".",
"kws",
"[",
"'dict'",
"]",
".",
"copy",
"(",
")",
"act_set",
"=",
"self",
".",
"kws",
"[",
"'set'",
"]",
"if",
"'shorten'",
"in",
"act_set",
"and",
"'goobj2fncname'",
"not",
"in",
"r... | Only load keywords if they are specified by the user. | [
"Only",
"load",
"keywords",
"if",
"they",
"are",
"specified",
"by",
"the",
"user",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/gosubdag/plot/go_node.py#L32-L38 |
242,385 | tanghaibao/goatools | goatools/gosubdag/plot/go_node.py | GoNode.get_node | def get_node(self, goid, goobj):
"""Return pydot node."""
# pydot.Node.objdict holds this information. pydot.Node.objdict['name']
return pydot.Node(
self.get_node_text(goid, goobj),
shape="box",
style="rounded, filled",
fillcolor=self.go2color.get(... | python | def get_node(self, goid, goobj):
# pydot.Node.objdict holds this information. pydot.Node.objdict['name']
return pydot.Node(
self.get_node_text(goid, goobj),
shape="box",
style="rounded, filled",
fillcolor=self.go2color.get(goid, "white"),
color... | [
"def",
"get_node",
"(",
"self",
",",
"goid",
",",
"goobj",
")",
":",
"# pydot.Node.objdict holds this information. pydot.Node.objdict['name']",
"return",
"pydot",
".",
"Node",
"(",
"self",
".",
"get_node_text",
"(",
"goid",
",",
"goobj",
")",
",",
"shape",
"=",
... | Return pydot node. | [
"Return",
"pydot",
"node",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/gosubdag/plot/go_node.py#L56-L64 |
242,386 | tanghaibao/goatools | goatools/gosubdag/plot/go_node.py | GoNode.str_fmthdr | def str_fmthdr(self, goid, goobj):
"""Return hdr line seen inside a GO Term box."""
# Shorten: Ex: GO:0007608 -> G0007608
go_txt = goid.replace("GO:", "G")
if 'mark_alt_id' in self.present and goid != goobj.id:
go_txt += 'a'
return go_txt | python | def str_fmthdr(self, goid, goobj):
# Shorten: Ex: GO:0007608 -> G0007608
go_txt = goid.replace("GO:", "G")
if 'mark_alt_id' in self.present and goid != goobj.id:
go_txt += 'a'
return go_txt | [
"def",
"str_fmthdr",
"(",
"self",
",",
"goid",
",",
"goobj",
")",
":",
"# Shorten: Ex: GO:0007608 -> G0007608",
"go_txt",
"=",
"goid",
".",
"replace",
"(",
"\"GO:\"",
",",
"\"G\"",
")",
"if",
"'mark_alt_id'",
"in",
"self",
".",
"present",
"and",
"goid",
"!="... | Return hdr line seen inside a GO Term box. | [
"Return",
"hdr",
"line",
"seen",
"inside",
"a",
"GO",
"Term",
"box",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/gosubdag/plot/go_node.py#L66-L72 |
242,387 | tanghaibao/goatools | goatools/gosubdag/plot/go_node.py | GoNode._get_prtflds | def _get_prtflds(self):
"""Get print fields for GO header."""
# User-specified print fields
ntflds = self.gosubdag.prt_attr['flds']
prt_flds = self.kws.get('prt_flds')
if prt_flds:
return prt_flds.intersection(ntflds)
exclude = set()
# Default print fi... | python | def _get_prtflds(self):
# User-specified print fields
ntflds = self.gosubdag.prt_attr['flds']
prt_flds = self.kws.get('prt_flds')
if prt_flds:
return prt_flds.intersection(ntflds)
exclude = set()
# Default print fields
if self.gosubdag.relationships:
... | [
"def",
"_get_prtflds",
"(",
"self",
")",
":",
"# User-specified print fields",
"ntflds",
"=",
"self",
".",
"gosubdag",
".",
"prt_attr",
"[",
"'flds'",
"]",
"prt_flds",
"=",
"self",
".",
"kws",
".",
"get",
"(",
"'prt_flds'",
")",
"if",
"prt_flds",
":",
"ret... | Get print fields for GO header. | [
"Get",
"print",
"fields",
"for",
"GO",
"header",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/gosubdag/plot/go_node.py#L132-L143 |
242,388 | tanghaibao/goatools | goatools/gosubdag/plot/go_node.py | GoNode._get_hdr_childcnt | def _get_hdr_childcnt(self, goobj, ntgo):
"""Get string representing count of children for this GO term."""
if 'childcnt' in self.present:
return "c{N}".format(N=len(goobj.children))
elif self.gosubdag.relationships and not goobj.children and ntgo.dcnt != 0:
return "c0" | python | def _get_hdr_childcnt(self, goobj, ntgo):
if 'childcnt' in self.present:
return "c{N}".format(N=len(goobj.children))
elif self.gosubdag.relationships and not goobj.children and ntgo.dcnt != 0:
return "c0" | [
"def",
"_get_hdr_childcnt",
"(",
"self",
",",
"goobj",
",",
"ntgo",
")",
":",
"if",
"'childcnt'",
"in",
"self",
".",
"present",
":",
"return",
"\"c{N}\"",
".",
"format",
"(",
"N",
"=",
"len",
"(",
"goobj",
".",
"children",
")",
")",
"elif",
"self",
"... | Get string representing count of children for this GO term. | [
"Get",
"string",
"representing",
"count",
"of",
"children",
"for",
"this",
"GO",
"term",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/gosubdag/plot/go_node.py#L145-L150 |
242,389 | tanghaibao/goatools | goatools/gosubdag/plot/go_node.py | GoNode._add_parent_cnt | def _add_parent_cnt(self, hdr, goobj, c2ps):
"""Add the parent count to the GO term box for if not all parents are plotted."""
if goobj.id in c2ps:
parents = c2ps[goobj.id]
if 'prt_pcnt' in self.present or parents and len(goobj.parents) != len(parents):
assert len... | python | def _add_parent_cnt(self, hdr, goobj, c2ps):
if goobj.id in c2ps:
parents = c2ps[goobj.id]
if 'prt_pcnt' in self.present or parents and len(goobj.parents) != len(parents):
assert len(goobj.parents) == len(set(goobj.parents))
hdr.append("p{N}".format(N=len(... | [
"def",
"_add_parent_cnt",
"(",
"self",
",",
"hdr",
",",
"goobj",
",",
"c2ps",
")",
":",
"if",
"goobj",
".",
"id",
"in",
"c2ps",
":",
"parents",
"=",
"c2ps",
"[",
"goobj",
".",
"id",
"]",
"if",
"'prt_pcnt'",
"in",
"self",
".",
"present",
"or",
"pare... | Add the parent count to the GO term box for if not all parents are plotted. | [
"Add",
"the",
"parent",
"count",
"to",
"the",
"GO",
"term",
"box",
"for",
"if",
"not",
"all",
"parents",
"are",
"plotted",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/gosubdag/plot/go_node.py#L152-L158 |
242,390 | tanghaibao/goatools | goatools/anno/idtogos_reader.py | IdToGosReader.prt_summary_anno2ev | def prt_summary_anno2ev(self, prt=sys.stdout):
"""Print a summary of all Evidence Codes seen in annotations"""
prt.write('**NOTE: No evidence codes in associations: {F}\n'.format(F=self.filename)) | python | def prt_summary_anno2ev(self, prt=sys.stdout):
prt.write('**NOTE: No evidence codes in associations: {F}\n'.format(F=self.filename)) | [
"def",
"prt_summary_anno2ev",
"(",
"self",
",",
"prt",
"=",
"sys",
".",
"stdout",
")",
":",
"prt",
".",
"write",
"(",
"'**NOTE: No evidence codes in associations: {F}\\n'",
".",
"format",
"(",
"F",
"=",
"self",
".",
"filename",
")",
")"
] | Print a summary of all Evidence Codes seen in annotations | [
"Print",
"a",
"summary",
"of",
"all",
"Evidence",
"Codes",
"seen",
"in",
"annotations"
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/anno/idtogos_reader.py#L21-L23 |
242,391 | tanghaibao/goatools | goatools/ratio.py | count_terms | def count_terms(geneset, assoc, obo_dag):
"""count the number of terms in the study group
"""
term_cnt = Counter()
for gene in (g for g in geneset if g in assoc):
for goid in assoc[gene]:
if goid in obo_dag:
term_cnt[obo_dag[goid].id] += 1
return term_cnt | python | def count_terms(geneset, assoc, obo_dag):
term_cnt = Counter()
for gene in (g for g in geneset if g in assoc):
for goid in assoc[gene]:
if goid in obo_dag:
term_cnt[obo_dag[goid].id] += 1
return term_cnt | [
"def",
"count_terms",
"(",
"geneset",
",",
"assoc",
",",
"obo_dag",
")",
":",
"term_cnt",
"=",
"Counter",
"(",
")",
"for",
"gene",
"in",
"(",
"g",
"for",
"g",
"in",
"geneset",
"if",
"g",
"in",
"assoc",
")",
":",
"for",
"goid",
"in",
"assoc",
"[",
... | count the number of terms in the study group | [
"count",
"the",
"number",
"of",
"terms",
"in",
"the",
"study",
"group"
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/ratio.py#L10-L19 |
242,392 | tanghaibao/goatools | goatools/ratio.py | get_terms | def get_terms(desc, geneset, assoc, obo_dag, log):
"""Get the terms in the study group
"""
_chk_gene2go(assoc)
term2itemids = defaultdict(set)
genes = [g for g in geneset if g in assoc]
for gene in genes:
for goid in assoc[gene]:
if goid in obo_dag:
term2itemi... | python | def get_terms(desc, geneset, assoc, obo_dag, log):
_chk_gene2go(assoc)
term2itemids = defaultdict(set)
genes = [g for g in geneset if g in assoc]
for gene in genes:
for goid in assoc[gene]:
if goid in obo_dag:
term2itemids[obo_dag[goid].id].add(gene)
if log is not... | [
"def",
"get_terms",
"(",
"desc",
",",
"geneset",
",",
"assoc",
",",
"obo_dag",
",",
"log",
")",
":",
"_chk_gene2go",
"(",
"assoc",
")",
"term2itemids",
"=",
"defaultdict",
"(",
"set",
")",
"genes",
"=",
"[",
"g",
"for",
"g",
"in",
"geneset",
"if",
"g... | Get the terms in the study group | [
"Get",
"the",
"terms",
"in",
"the",
"study",
"group"
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/ratio.py#L21-L37 |
242,393 | tanghaibao/goatools | goatools/ratio.py | _chk_gene2go | def _chk_gene2go(assoc):
"""Check that associations is gene2go, not go2gene."""
if not assoc:
raise RuntimeError("NO ITEMS FOUND IN ASSOCIATIONS {A}".format(A=assoc))
for key in assoc:
if isinstance(key, str) and key[:3] == "GO:":
raise Exception("ASSOCIATIONS EXPECTED TO BE gene... | python | def _chk_gene2go(assoc):
if not assoc:
raise RuntimeError("NO ITEMS FOUND IN ASSOCIATIONS {A}".format(A=assoc))
for key in assoc:
if isinstance(key, str) and key[:3] == "GO:":
raise Exception("ASSOCIATIONS EXPECTED TO BE gene2go, NOT go2gene: {EX}".format(
EX=assoc.it... | [
"def",
"_chk_gene2go",
"(",
"assoc",
")",
":",
"if",
"not",
"assoc",
":",
"raise",
"RuntimeError",
"(",
"\"NO ITEMS FOUND IN ASSOCIATIONS {A}\"",
".",
"format",
"(",
"A",
"=",
"assoc",
")",
")",
"for",
"key",
"in",
"assoc",
":",
"if",
"isinstance",
"(",
"k... | Check that associations is gene2go, not go2gene. | [
"Check",
"that",
"associations",
"is",
"gene2go",
"not",
"go2gene",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/ratio.py#L56-L64 |
242,394 | tanghaibao/goatools | goatools/grouper/grprobj_init.py | GrouperInit._init_usrgos | def _init_usrgos(self, goids):
"""Return user GO IDs which have GO Terms."""
usrgos = set()
goids_missing = set()
_go2obj = self.gosubdag.go2obj
for goid in goids:
if goid in _go2obj:
usrgos.add(goid)
else:
goids_missing.add... | python | def _init_usrgos(self, goids):
usrgos = set()
goids_missing = set()
_go2obj = self.gosubdag.go2obj
for goid in goids:
if goid in _go2obj:
usrgos.add(goid)
else:
goids_missing.add(goid)
if goids_missing:
print("MI... | [
"def",
"_init_usrgos",
"(",
"self",
",",
"goids",
")",
":",
"usrgos",
"=",
"set",
"(",
")",
"goids_missing",
"=",
"set",
"(",
")",
"_go2obj",
"=",
"self",
".",
"gosubdag",
".",
"go2obj",
"for",
"goid",
"in",
"goids",
":",
"if",
"goid",
"in",
"_go2obj... | Return user GO IDs which have GO Terms. | [
"Return",
"user",
"GO",
"IDs",
"which",
"have",
"GO",
"Terms",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/grprobj_init.py#L49-L62 |
242,395 | tanghaibao/goatools | goatools/grouper/grprobj_init.py | GrouperInit.get_gos_all | def get_gos_all(self):
"""Return a flat list of all GO IDs in grouping object.
All GO IDs:
* header GO IDs that are not user GO IDs
* user GO IDs that are under header GOs
* user GO IDs that are header GOs in groups containing no other user GO IDs
... | python | def get_gos_all(self):
gos_all = set()
# Get:
# * Header GO IDs that are not user GO IDs
# * User GO IDs that are under header GOs
for hdrgo, usrgos in self.hdrgo2usrgos.items():
gos_all.add(hdrgo)
gos_all |= usrgos
# User GO IDs that are heade... | [
"def",
"get_gos_all",
"(",
"self",
")",
":",
"gos_all",
"=",
"set",
"(",
")",
"# Get:",
"# * Header GO IDs that are not user GO IDs",
"# * User GO IDs that are under header GOs",
"for",
"hdrgo",
",",
"usrgos",
"in",
"self",
".",
"hdrgo2usrgos",
".",
"items",
"(",
... | Return a flat list of all GO IDs in grouping object.
All GO IDs:
* header GO IDs that are not user GO IDs
* user GO IDs that are under header GOs
* user GO IDs that are header GOs in groups containing no other user GO IDs | [
"Return",
"a",
"flat",
"list",
"of",
"all",
"GO",
"IDs",
"in",
"grouping",
"object",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/grprobj_init.py#L64-L84 |
242,396 | tanghaibao/goatools | goatools/grouper/grprobj_init.py | GrouperInit._init_h2us | def _init_h2us(self, fnc_most_specific):
"""Given a set of user GO ids, return GO ids grouped under the "GO high" terms.
Example of a grouped go list:
gos = ['GO:0044464':[ # grp_term: D1 cell part
'GO:0005737', # child: D3 cytoplasm
'GO:... | python | def _init_h2us(self, fnc_most_specific):
# Header GO IDs are main. User GO IDs are as specified by the user
hdrgo2usrgos = cx.defaultdict(set)
# Contains user GO IDs which are also header GO IDs, plus user main GO if needed
hdrgo_is_usrgo = set()
_go2nt = self.gosubdag.go2nt
... | [
"def",
"_init_h2us",
"(",
"self",
",",
"fnc_most_specific",
")",
":",
"# Header GO IDs are main. User GO IDs are as specified by the user",
"hdrgo2usrgos",
"=",
"cx",
".",
"defaultdict",
"(",
"set",
")",
"# Contains user GO IDs which are also header GO IDs, plus user main GO if nee... | Given a set of user GO ids, return GO ids grouped under the "GO high" terms.
Example of a grouped go list:
gos = ['GO:0044464':[ # grp_term: D1 cell part
'GO:0005737', # child: D3 cytoplasm
'GO:0048471', # child: D4 perinuclear region of cytop... | [
"Given",
"a",
"set",
"of",
"user",
"GO",
"ids",
"return",
"GO",
"ids",
"grouped",
"under",
"the",
"GO",
"high",
"terms",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/grprobj_init.py#L86-L121 |
242,397 | tanghaibao/goatools | goatools/grouper/grprobj_init.py | GrouperInit.get_go2nt | def get_go2nt(self, usr_go2nt):
"""Combine user namedtuple fields, GO object fields, and format_txt."""
gos_all = self.get_gos_all()
# Minimum set of namedtuple fields available for use with Sorter on grouped GO IDs
prt_flds_all = get_hdridx_flds() + self.gosubdag.prt_attr['flds']
... | python | def get_go2nt(self, usr_go2nt):
gos_all = self.get_gos_all()
# Minimum set of namedtuple fields available for use with Sorter on grouped GO IDs
prt_flds_all = get_hdridx_flds() + self.gosubdag.prt_attr['flds']
if not usr_go2nt:
return self.__init_go2nt_dflt(gos_all, prt_flds_... | [
"def",
"get_go2nt",
"(",
"self",
",",
"usr_go2nt",
")",
":",
"gos_all",
"=",
"self",
".",
"get_gos_all",
"(",
")",
"# Minimum set of namedtuple fields available for use with Sorter on grouped GO IDs",
"prt_flds_all",
"=",
"get_hdridx_flds",
"(",
")",
"+",
"self",
".",
... | Combine user namedtuple fields, GO object fields, and format_txt. | [
"Combine",
"user",
"namedtuple",
"fields",
"GO",
"object",
"fields",
"and",
"format_txt",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/grprobj_init.py#L143-L155 |
242,398 | tanghaibao/goatools | goatools/grouper/grprobj_init.py | GrouperInit._init_go2nt_aug | def _init_go2nt_aug(self, go2nt):
"""Augment go2nt with GO ID key to account for alt GO IDs."""
go2obj = self.gosubdag.go2obj
# Get alt GO IDs
go2nt_aug = {}
# NOW
for goid_usr, nt_usr in go2nt.items():
goobj = go2obj[goid_usr]
if goobj.alt_ids:
... | python | def _init_go2nt_aug(self, go2nt):
go2obj = self.gosubdag.go2obj
# Get alt GO IDs
go2nt_aug = {}
# NOW
for goid_usr, nt_usr in go2nt.items():
goobj = go2obj[goid_usr]
if goobj.alt_ids:
alts = set(goobj.alt_ids)
alts.add(goobj... | [
"def",
"_init_go2nt_aug",
"(",
"self",
",",
"go2nt",
")",
":",
"go2obj",
"=",
"self",
".",
"gosubdag",
".",
"go2obj",
"# Get alt GO IDs",
"go2nt_aug",
"=",
"{",
"}",
"# NOW",
"for",
"goid_usr",
",",
"nt_usr",
"in",
"go2nt",
".",
"items",
"(",
")",
":",
... | Augment go2nt with GO ID key to account for alt GO IDs. | [
"Augment",
"go2nt",
"with",
"GO",
"ID",
"key",
"to",
"account",
"for",
"alt",
"GO",
"IDs",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/grprobj_init.py#L173-L191 |
242,399 | tanghaibao/goatools | goatools/grouper/grprobj_init.py | GrouperInit._get_go2nthdridx | def _get_go2nthdridx(self, gos_all):
"""Get GO IDs header index for each user GO ID and corresponding parent GO IDs."""
go2nthdridx = {}
# NtHdrIdx Namedtuple fields:
# * format_txt: Used to determine the format when writing Excel cells
# * hdr_idx: Value printed in an Excel ... | python | def _get_go2nthdridx(self, gos_all):
go2nthdridx = {}
# NtHdrIdx Namedtuple fields:
# * format_txt: Used to determine the format when writing Excel cells
# * hdr_idx: Value printed in an Excel cell
# shortcuts
obj = GrouperInit.NtMaker(self)
# Create go2nthdri... | [
"def",
"_get_go2nthdridx",
"(",
"self",
",",
"gos_all",
")",
":",
"go2nthdridx",
"=",
"{",
"}",
"# NtHdrIdx Namedtuple fields:",
"# * format_txt: Used to determine the format when writing Excel cells",
"# * hdr_idx: Value printed in an Excel cell",
"# shortcuts",
"obj",
"=",
... | Get GO IDs header index for each user GO ID and corresponding parent GO IDs. | [
"Get",
"GO",
"IDs",
"header",
"index",
"for",
"each",
"user",
"GO",
"ID",
"and",
"corresponding",
"parent",
"GO",
"IDs",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/grprobj_init.py#L193-L204 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.