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 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
tanghaibao/goatools | goatools/grouper/aart_geneproducts_one.py | _Init.get_sec2gos | def get_sec2gos(sortobj):
"""Initialize section_name2goids."""
sec_gos = []
for section_name, nts in sortobj.get_desc2nts_fnc(hdrgo_prt=True)['sections']:
sec_gos.append((section_name, set(nt.GO for nt in nts)))
return cx.OrderedDict(sec_gos) | python | def get_sec2gos(sortobj):
"""Initialize section_name2goids."""
sec_gos = []
for section_name, nts in sortobj.get_desc2nts_fnc(hdrgo_prt=True)['sections']:
sec_gos.append((section_name, set(nt.GO for nt in nts)))
return cx.OrderedDict(sec_gos) | [
"def",
"get_sec2gos",
"(",
"sortobj",
")",
":",
"sec_gos",
"=",
"[",
"]",
"for",
"section_name",
",",
"nts",
"in",
"sortobj",
".",
"get_desc2nts_fnc",
"(",
"hdrgo_prt",
"=",
"True",
")",
"[",
"'sections'",
"]",
":",
"sec_gos",
".",
"append",
"(",
"(",
... | Initialize section_name2goids. | [
"Initialize",
"section_name2goids",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/aart_geneproducts_one.py#L159-L164 | train |
tanghaibao/goatools | goatools/grouper/aart_geneproducts_one.py | _Init.get_gene2gos | def get_gene2gos(go2nt):
"""Create a gene product to GO set dict."""
gene2gos = cx.defaultdict(set)
nt0 = next(iter(go2nt.values()))
b_str = isinstance(nt0.study_items, str)
# print("NNNNTTTT", nt0)
for goid, ntgo in go2nt.items():
study_items = ntgo.study_ite... | python | def get_gene2gos(go2nt):
"""Create a gene product to GO set dict."""
gene2gos = cx.defaultdict(set)
nt0 = next(iter(go2nt.values()))
b_str = isinstance(nt0.study_items, str)
# print("NNNNTTTT", nt0)
for goid, ntgo in go2nt.items():
study_items = ntgo.study_ite... | [
"def",
"get_gene2gos",
"(",
"go2nt",
")",
":",
"gene2gos",
"=",
"cx",
".",
"defaultdict",
"(",
"set",
")",
"nt0",
"=",
"next",
"(",
"iter",
"(",
"go2nt",
".",
"values",
"(",
")",
")",
")",
"b_str",
"=",
"isinstance",
"(",
"nt0",
".",
"study_items",
... | Create a gene product to GO set dict. | [
"Create",
"a",
"gene",
"product",
"to",
"GO",
"set",
"dict",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/aart_geneproducts_one.py#L167-L181 | train |
tanghaibao/goatools | goatools/grouper/aart_geneproducts_one.py | _Init.get_gene2aart | def get_gene2aart(gene2section2gos, sec2chr):
"""Return a string for each gene representing GO section membership."""
geneid2str = {}
for geneid, section2gos_gene in gene2section2gos.items():
letters = [abc if s in section2gos_gene else "." for s, abc in sec2chr.items()]
... | python | def get_gene2aart(gene2section2gos, sec2chr):
"""Return a string for each gene representing GO section membership."""
geneid2str = {}
for geneid, section2gos_gene in gene2section2gos.items():
letters = [abc if s in section2gos_gene else "." for s, abc in sec2chr.items()]
... | [
"def",
"get_gene2aart",
"(",
"gene2section2gos",
",",
"sec2chr",
")",
":",
"geneid2str",
"=",
"{",
"}",
"for",
"geneid",
",",
"section2gos_gene",
"in",
"gene2section2gos",
".",
"items",
"(",
")",
":",
"letters",
"=",
"[",
"abc",
"if",
"s",
"in",
"section2g... | Return a string for each gene representing GO section membership. | [
"Return",
"a",
"string",
"for",
"each",
"gene",
"representing",
"GO",
"section",
"membership",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/aart_geneproducts_one.py#L192-L198 | train |
tanghaibao/goatools | goatools/grouper/aart_geneproducts_one.py | _Init.get_gene2section2gos | def get_gene2section2gos(gene2gos, sec2gos):
"""Get a list of section aliases for each gene product ID."""
gene2section2gos = {}
for geneid, gos_gene in gene2gos.items():
section2gos = {}
for section_name, gos_sec in sec2gos.items():
gos_secgene = gos_gene... | python | def get_gene2section2gos(gene2gos, sec2gos):
"""Get a list of section aliases for each gene product ID."""
gene2section2gos = {}
for geneid, gos_gene in gene2gos.items():
section2gos = {}
for section_name, gos_sec in sec2gos.items():
gos_secgene = gos_gene... | [
"def",
"get_gene2section2gos",
"(",
"gene2gos",
",",
"sec2gos",
")",
":",
"gene2section2gos",
"=",
"{",
"}",
"for",
"geneid",
",",
"gos_gene",
"in",
"gene2gos",
".",
"items",
"(",
")",
":",
"section2gos",
"=",
"{",
"}",
"for",
"section_name",
",",
"gos_sec... | Get a list of section aliases for each gene product ID. | [
"Get",
"a",
"list",
"of",
"section",
"aliases",
"for",
"each",
"gene",
"product",
"ID",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/aart_geneproducts_one.py#L201-L211 | train |
tanghaibao/goatools | goatools/gosubdag/plot/gosubdag_plot.py | GoSubDagPlot._init_objcolor | def _init_objcolor(self, node_opts, **kwu):
"""Return user-created Go2Color object or create one."""
objgoea = node_opts.kws['dict'].get('objgoea', None)
# kwu: go2color go2bordercolor dflt_bordercolor key2col
return Go2Color(self.gosubdag, objgoea, **kwu) | python | def _init_objcolor(self, node_opts, **kwu):
"""Return user-created Go2Color object or create one."""
objgoea = node_opts.kws['dict'].get('objgoea', None)
# kwu: go2color go2bordercolor dflt_bordercolor key2col
return Go2Color(self.gosubdag, objgoea, **kwu) | [
"def",
"_init_objcolor",
"(",
"self",
",",
"node_opts",
",",
"**",
"kwu",
")",
":",
"objgoea",
"=",
"node_opts",
".",
"kws",
"[",
"'dict'",
"]",
".",
"get",
"(",
"'objgoea'",
",",
"None",
")",
"return",
"Go2Color",
"(",
"self",
".",
"gosubdag",
",",
... | Return user-created Go2Color object or create one. | [
"Return",
"user",
"-",
"created",
"Go2Color",
"object",
"or",
"create",
"one",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/gosubdag/plot/gosubdag_plot.py#L104-L108 | train |
tanghaibao/goatools | goatools/gosubdag/plot/gosubdag_plot.py | GoSubDagPlot._init_gonodeopts | def _init_gonodeopts(self, **kws_usr):
"""Initialize a GO Node plot options object, GoNodeOpts."""
options = GoNodeOpts(self.gosubdag, **self.kws['node_go'])
# Add parent edge count if either is in kws: parentcnt, prt_pcnt
if not options.kws['set'].isdisjoint(['parentcnt', 'prt_pcnt']):
... | python | def _init_gonodeopts(self, **kws_usr):
"""Initialize a GO Node plot options object, GoNodeOpts."""
options = GoNodeOpts(self.gosubdag, **self.kws['node_go'])
# Add parent edge count if either is in kws: parentcnt, prt_pcnt
if not options.kws['set'].isdisjoint(['parentcnt', 'prt_pcnt']):
... | [
"def",
"_init_gonodeopts",
"(",
"self",
",",
"**",
"kws_usr",
")",
":",
"options",
"=",
"GoNodeOpts",
"(",
"self",
".",
"gosubdag",
",",
"**",
"self",
".",
"kws",
"[",
"'node_go'",
"]",
")",
"if",
"not",
"options",
".",
"kws",
"[",
"'set'",
"]",
".",... | Initialize a GO Node plot options object, GoNodeOpts. | [
"Initialize",
"a",
"GO",
"Node",
"plot",
"options",
"object",
"GoNodeOpts",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/gosubdag/plot/gosubdag_plot.py#L110-L120 | train |
tanghaibao/goatools | goatools/gosubdag/plot/gosubdag_plot.py | GoSubDagPlot.prt_goids | def prt_goids(self, prt):
"""Print all GO IDs in the plot, plus their color."""
fmt = self.gosubdag.prt_attr['fmta']
nts = sorted(self.gosubdag.go2nt.values(), key=lambda nt: [nt.NS, nt.depth, nt.alt])
_get_color = self.pydotnodego.go2color.get
for ntgo in nts:
gostr ... | python | def prt_goids(self, prt):
"""Print all GO IDs in the plot, plus their color."""
fmt = self.gosubdag.prt_attr['fmta']
nts = sorted(self.gosubdag.go2nt.values(), key=lambda nt: [nt.NS, nt.depth, nt.alt])
_get_color = self.pydotnodego.go2color.get
for ntgo in nts:
gostr ... | [
"def",
"prt_goids",
"(",
"self",
",",
"prt",
")",
":",
"fmt",
"=",
"self",
".",
"gosubdag",
".",
"prt_attr",
"[",
"'fmta'",
"]",
"nts",
"=",
"sorted",
"(",
"self",
".",
"gosubdag",
".",
"go2nt",
".",
"values",
"(",
")",
",",
"key",
"=",
"lambda",
... | Print all GO IDs in the plot, plus their color. | [
"Print",
"all",
"GO",
"IDs",
"in",
"the",
"plot",
"plus",
"their",
"color",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/gosubdag/plot/gosubdag_plot.py#L122-L130 | train |
tanghaibao/goatools | goatools/gosubdag/plot/gosubdag_plot.py | GoSubDagPlot._init_kws | def _init_kws(self, **kws_usr):
"""Return a dict containing user-specified plotting options."""
kws_self = {}
user_keys = set(kws_usr)
for objname, expset in self.exp_keys.items():
usrkeys_curr = user_keys.intersection(expset)
kws_self[objname] = get_kwargs(kws_us... | python | def _init_kws(self, **kws_usr):
"""Return a dict containing user-specified plotting options."""
kws_self = {}
user_keys = set(kws_usr)
for objname, expset in self.exp_keys.items():
usrkeys_curr = user_keys.intersection(expset)
kws_self[objname] = get_kwargs(kws_us... | [
"def",
"_init_kws",
"(",
"self",
",",
"**",
"kws_usr",
")",
":",
"kws_self",
"=",
"{",
"}",
"user_keys",
"=",
"set",
"(",
"kws_usr",
")",
"for",
"objname",
",",
"expset",
"in",
"self",
".",
"exp_keys",
".",
"items",
"(",
")",
":",
"usrkeys_curr",
"="... | Return a dict containing user-specified plotting options. | [
"Return",
"a",
"dict",
"containing",
"user",
"-",
"specified",
"plotting",
"options",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/gosubdag/plot/gosubdag_plot.py#L132-L141 | train |
tanghaibao/goatools | goatools/gosubdag/plot/gosubdag_plot.py | GoSubDagPlot._prt_edge | def _prt_edge(dag_edge, attr):
"""Print edge attribute"""
# sequence parent_graph points attributes type parent_edge_list
print("Edge {ATTR}: {VAL}".format(ATTR=attr, VAL=dag_edge.obj_dict[attr])) | python | def _prt_edge(dag_edge, attr):
"""Print edge attribute"""
# sequence parent_graph points attributes type parent_edge_list
print("Edge {ATTR}: {VAL}".format(ATTR=attr, VAL=dag_edge.obj_dict[attr])) | [
"def",
"_prt_edge",
"(",
"dag_edge",
",",
"attr",
")",
":",
"print",
"(",
"\"Edge {ATTR}: {VAL}\"",
".",
"format",
"(",
"ATTR",
"=",
"attr",
",",
"VAL",
"=",
"dag_edge",
".",
"obj_dict",
"[",
"attr",
"]",
")",
")"
] | Print edge attribute | [
"Print",
"edge",
"attribute"
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/gosubdag/plot/gosubdag_plot.py#L205-L208 | train |
tanghaibao/goatools | goatools/gosubdag/gosubdag.py | GoSubDag.prt_goids | def prt_goids(self, goids=None, prtfmt=None, sortby=True, prt=sys.stdout):
"""Given GO IDs, print decriptive info about each GO Term."""
if goids is None:
goids = self.go_sources
nts = self.get_nts(goids, sortby)
if prtfmt is None:
prtfmt = self.prt_attr['fmta']
... | python | def prt_goids(self, goids=None, prtfmt=None, sortby=True, prt=sys.stdout):
"""Given GO IDs, print decriptive info about each GO Term."""
if goids is None:
goids = self.go_sources
nts = self.get_nts(goids, sortby)
if prtfmt is None:
prtfmt = self.prt_attr['fmta']
... | [
"def",
"prt_goids",
"(",
"self",
",",
"goids",
"=",
"None",
",",
"prtfmt",
"=",
"None",
",",
"sortby",
"=",
"True",
",",
"prt",
"=",
"sys",
".",
"stdout",
")",
":",
"if",
"goids",
"is",
"None",
":",
"goids",
"=",
"self",
".",
"go_sources",
"nts",
... | Given GO IDs, print decriptive info about each GO Term. | [
"Given",
"GO",
"IDs",
"print",
"decriptive",
"info",
"about",
"each",
"GO",
"Term",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/gosubdag/gosubdag.py#L42-L52 | train |
tanghaibao/goatools | goatools/gosubdag/gosubdag.py | GoSubDag.get_nts | def get_nts(self, goids=None, sortby=None):
"""Given GO IDs, get a list of namedtuples."""
nts = []
# User GO IDs
if goids is None:
goids = self.go_sources
else:
chk_goids(goids, "GoSubDag::get_nts")
if goids:
ntobj = cx.namedtuple("NtG... | python | def get_nts(self, goids=None, sortby=None):
"""Given GO IDs, get a list of namedtuples."""
nts = []
# User GO IDs
if goids is None:
goids = self.go_sources
else:
chk_goids(goids, "GoSubDag::get_nts")
if goids:
ntobj = cx.namedtuple("NtG... | [
"def",
"get_nts",
"(",
"self",
",",
"goids",
"=",
"None",
",",
"sortby",
"=",
"None",
")",
":",
"nts",
"=",
"[",
"]",
"if",
"goids",
"is",
"None",
":",
"goids",
"=",
"self",
".",
"go_sources",
"else",
":",
"chk_goids",
"(",
"goids",
",",
"\"GoSubDa... | Given GO IDs, get a list of namedtuples. | [
"Given",
"GO",
"IDs",
"get",
"a",
"list",
"of",
"namedtuples",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/gosubdag/gosubdag.py#L54-L73 | train |
tanghaibao/goatools | goatools/gosubdag/gosubdag.py | GoSubDag.get_go2nt | def get_go2nt(self, goids):
"""Return dict of GO ID as key and GO object information in namedtuple."""
get_nt = self.go2nt
goids_present = set(goids).intersection(self.go2obj)
if len(goids_present) != len(goids):
print("GO IDs NOT FOUND IN DAG: {GOs}".format(
... | python | def get_go2nt(self, goids):
"""Return dict of GO ID as key and GO object information in namedtuple."""
get_nt = self.go2nt
goids_present = set(goids).intersection(self.go2obj)
if len(goids_present) != len(goids):
print("GO IDs NOT FOUND IN DAG: {GOs}".format(
... | [
"def",
"get_go2nt",
"(",
"self",
",",
"goids",
")",
":",
"get_nt",
"=",
"self",
".",
"go2nt",
"goids_present",
"=",
"set",
"(",
"goids",
")",
".",
"intersection",
"(",
"self",
".",
"go2obj",
")",
"if",
"len",
"(",
"goids_present",
")",
"!=",
"len",
"... | Return dict of GO ID as key and GO object information in namedtuple. | [
"Return",
"dict",
"of",
"GO",
"ID",
"as",
"key",
"and",
"GO",
"object",
"information",
"in",
"namedtuple",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/gosubdag/gosubdag.py#L94-L101 | train |
tanghaibao/goatools | goatools/gosubdag/gosubdag.py | GoSubDag.get_key_goids | def get_key_goids(self, goids):
"""Given GO IDs, return key GO IDs."""
go2obj = self.go2obj
return set(go2obj[go].id for go in goids) | python | def get_key_goids(self, goids):
"""Given GO IDs, return key GO IDs."""
go2obj = self.go2obj
return set(go2obj[go].id for go in goids) | [
"def",
"get_key_goids",
"(",
"self",
",",
"goids",
")",
":",
"go2obj",
"=",
"self",
".",
"go2obj",
"return",
"set",
"(",
"go2obj",
"[",
"go",
"]",
".",
"id",
"for",
"go",
"in",
"goids",
")"
] | Given GO IDs, return key GO IDs. | [
"Given",
"GO",
"IDs",
"return",
"key",
"GO",
"IDs",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/gosubdag/gosubdag.py#L115-L118 | train |
tanghaibao/goatools | goatools/gosubdag/gosubdag.py | GoSubDag.prt_objdesc | def prt_objdesc(self, prt):
"""Return description of this GoSubDag object."""
txt = "INITIALIZING GoSubDag: {N:3} sources in {M:3} GOs rcnt({R}). {A} alt GO IDs\n"
alt2obj = {go:o for go, o in self.go2obj.items() if go != o.id}
prt.write(txt.format(
N=len(self.go_sources),
... | python | def prt_objdesc(self, prt):
"""Return description of this GoSubDag object."""
txt = "INITIALIZING GoSubDag: {N:3} sources in {M:3} GOs rcnt({R}). {A} alt GO IDs\n"
alt2obj = {go:o for go, o in self.go2obj.items() if go != o.id}
prt.write(txt.format(
N=len(self.go_sources),
... | [
"def",
"prt_objdesc",
"(",
"self",
",",
"prt",
")",
":",
"txt",
"=",
"\"INITIALIZING GoSubDag: {N:3} sources in {M:3} GOs rcnt({R}). {A} alt GO IDs\\n\"",
"alt2obj",
"=",
"{",
"go",
":",
"o",
"for",
"go",
",",
"o",
"in",
"self",
".",
"go2obj",
".",
"items",
"(",... | Return description of this GoSubDag object. | [
"Return",
"description",
"of",
"this",
"GoSubDag",
"object",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/gosubdag/gosubdag.py#L128-L139 | train |
tanghaibao/goatools | goatools/anno/init/reader_genetogo.py | InitAssc._init_taxids | def _init_taxids(taxid, taxids):
"""Return taxid set"""
ret = set()
if taxids is not None:
if taxids is True:
return True
if isinstance(taxids, int):
ret.add(taxids)
else:
ret.update(taxids)
if taxid is n... | python | def _init_taxids(taxid, taxids):
"""Return taxid set"""
ret = set()
if taxids is not None:
if taxids is True:
return True
if isinstance(taxids, int):
ret.add(taxids)
else:
ret.update(taxids)
if taxid is n... | [
"def",
"_init_taxids",
"(",
"taxid",
",",
"taxids",
")",
":",
"ret",
"=",
"set",
"(",
")",
"if",
"taxids",
"is",
"not",
"None",
":",
"if",
"taxids",
"is",
"True",
":",
"return",
"True",
"if",
"isinstance",
"(",
"taxids",
",",
"int",
")",
":",
"ret"... | Return taxid set | [
"Return",
"taxid",
"set"
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/anno/init/reader_genetogo.py#L34-L50 | train |
tanghaibao/goatools | goatools/anno/init/reader_genetogo.py | InitAssc.init_associations | def init_associations(self, fin_anno, taxids=None):
"""Read annotation file. Store annotation data in a list of namedtuples."""
nts = []
if fin_anno is None:
return nts
tic = timeit.default_timer()
lnum = -1
line = "\t"*len(self.flds)
try:
... | python | def init_associations(self, fin_anno, taxids=None):
"""Read annotation file. Store annotation data in a list of namedtuples."""
nts = []
if fin_anno is None:
return nts
tic = timeit.default_timer()
lnum = -1
line = "\t"*len(self.flds)
try:
... | [
"def",
"init_associations",
"(",
"self",
",",
"fin_anno",
",",
"taxids",
"=",
"None",
")",
":",
"nts",
"=",
"[",
"]",
"if",
"fin_anno",
"is",
"None",
":",
"return",
"nts",
"tic",
"=",
"timeit",
".",
"default_timer",
"(",
")",
"lnum",
"=",
"-",
"1",
... | Read annotation file. Store annotation data in a list of namedtuples. | [
"Read",
"annotation",
"file",
".",
"Store",
"annotation",
"data",
"in",
"a",
"list",
"of",
"namedtuples",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/anno/init/reader_genetogo.py#L53-L100 | train |
tanghaibao/goatools | goatools/anno/init/reader_genetogo.py | InitAssc._prt_line_detail | def _prt_line_detail(self, prt, line, lnum=""):
"""Print each field and its value."""
data = zip(self.flds, line.split('\t'))
txt = ["{:2}) {:13} {}".format(i, hdr, val) for i, (hdr, val) in enumerate(data)]
prt.write("{LNUM}\n{TXT}\n".format(LNUM=lnum, TXT='\n'.join(txt))) | python | def _prt_line_detail(self, prt, line, lnum=""):
"""Print each field and its value."""
data = zip(self.flds, line.split('\t'))
txt = ["{:2}) {:13} {}".format(i, hdr, val) for i, (hdr, val) in enumerate(data)]
prt.write("{LNUM}\n{TXT}\n".format(LNUM=lnum, TXT='\n'.join(txt))) | [
"def",
"_prt_line_detail",
"(",
"self",
",",
"prt",
",",
"line",
",",
"lnum",
"=",
"\"\"",
")",
":",
"data",
"=",
"zip",
"(",
"self",
".",
"flds",
",",
"line",
".",
"split",
"(",
"'\\t'",
")",
")",
"txt",
"=",
"[",
"\"{:2}) {:13} {}\"",
".",
"forma... | Print each field and its value. | [
"Print",
"each",
"field",
"and",
"its",
"value",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/anno/init/reader_genetogo.py#L114-L118 | train |
tanghaibao/goatools | goatools/anno/gaf_reader.py | GafReader.chk_associations | def chk_associations(self, fout_err="gaf.err"):
"""Check that fields are legal in GAF"""
obj = GafData("2.1")
return obj.chk(self.associations, fout_err) | python | def chk_associations(self, fout_err="gaf.err"):
"""Check that fields are legal in GAF"""
obj = GafData("2.1")
return obj.chk(self.associations, fout_err) | [
"def",
"chk_associations",
"(",
"self",
",",
"fout_err",
"=",
"\"gaf.err\"",
")",
":",
"obj",
"=",
"GafData",
"(",
"\"2.1\"",
")",
"return",
"obj",
".",
"chk",
"(",
"self",
".",
"associations",
",",
"fout_err",
")"
] | Check that fields are legal in GAF | [
"Check",
"that",
"fields",
"are",
"legal",
"in",
"GAF"
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/anno/gaf_reader.py#L33-L36 | train |
tanghaibao/goatools | goatools/cli/gosubdag_plot.py | GetGOs._update_ret | def _update_ret(ret, goids, go2color):
"""Update 'GOs' and 'go2color' in dict with goids and go2color."""
if goids:
ret['GOs'].update(goids)
if go2color:
for goid, color in go2color.items():
ret['go2color'][goid] = color | python | def _update_ret(ret, goids, go2color):
"""Update 'GOs' and 'go2color' in dict with goids and go2color."""
if goids:
ret['GOs'].update(goids)
if go2color:
for goid, color in go2color.items():
ret['go2color'][goid] = color | [
"def",
"_update_ret",
"(",
"ret",
",",
"goids",
",",
"go2color",
")",
":",
"if",
"goids",
":",
"ret",
"[",
"'GOs'",
"]",
".",
"update",
"(",
"goids",
")",
"if",
"go2color",
":",
"for",
"goid",
",",
"color",
"in",
"go2color",
".",
"items",
"(",
")",... | Update 'GOs' and 'go2color' in dict with goids and go2color. | [
"Update",
"GOs",
"and",
"go2color",
"in",
"dict",
"with",
"goids",
"and",
"go2color",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/cli/gosubdag_plot.py#L160-L166 | train |
tanghaibao/goatools | goatools/cli/gosubdag_plot.py | PlotCli._plt_gogrouped | def _plt_gogrouped(self, goids, go2color_usr, **kws):
"""Plot grouped GO IDs."""
fout_img = self.get_outfile(kws['outfile'], goids)
sections = read_sections(kws['sections'], exclude_ungrouped=True)
# print ("KWWSSSSSSSS", kws)
# kws_plt = {k:v for k, v in kws.items if k in self.k... | python | def _plt_gogrouped(self, goids, go2color_usr, **kws):
"""Plot grouped GO IDs."""
fout_img = self.get_outfile(kws['outfile'], goids)
sections = read_sections(kws['sections'], exclude_ungrouped=True)
# print ("KWWSSSSSSSS", kws)
# kws_plt = {k:v for k, v in kws.items if k in self.k... | [
"def",
"_plt_gogrouped",
"(",
"self",
",",
"goids",
",",
"go2color_usr",
",",
"**",
"kws",
")",
":",
"fout_img",
"=",
"self",
".",
"get_outfile",
"(",
"kws",
"[",
"'outfile'",
"]",
",",
"goids",
")",
"sections",
"=",
"read_sections",
"(",
"kws",
"[",
"... | Plot grouped GO IDs. | [
"Plot",
"grouped",
"GO",
"IDs",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/cli/gosubdag_plot.py#L205-L227 | train |
tanghaibao/goatools | goatools/cli/gosubdag_plot.py | PlotCli._get_grprobj | def _get_grprobj(self, goids, sections):
"""Get Grouper, given GO IDs and sections."""
grprdflt = GrouperDflts(self.gosubdag, "goslim_generic.obo")
hdrobj = HdrgosSections(self.gosubdag, grprdflt.hdrgos_dflt, sections)
return Grouper("sections", goids, hdrobj, self.gosubdag) | python | def _get_grprobj(self, goids, sections):
"""Get Grouper, given GO IDs and sections."""
grprdflt = GrouperDflts(self.gosubdag, "goslim_generic.obo")
hdrobj = HdrgosSections(self.gosubdag, grprdflt.hdrgos_dflt, sections)
return Grouper("sections", goids, hdrobj, self.gosubdag) | [
"def",
"_get_grprobj",
"(",
"self",
",",
"goids",
",",
"sections",
")",
":",
"grprdflt",
"=",
"GrouperDflts",
"(",
"self",
".",
"gosubdag",
",",
"\"goslim_generic.obo\"",
")",
"hdrobj",
"=",
"HdrgosSections",
"(",
"self",
".",
"gosubdag",
",",
"grprdflt",
".... | Get Grouper, given GO IDs and sections. | [
"Get",
"Grouper",
"given",
"GO",
"IDs",
"and",
"sections",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/cli/gosubdag_plot.py#L229-L233 | train |
tanghaibao/goatools | goatools/cli/gosubdag_plot.py | PlotCli._get_kwsdag | def _get_kwsdag(self, goids, go2obj, **kws_all):
"""Get keyword args for a GoSubDag."""
kws_dag = {}
# Term Counts for GO Term information score
tcntobj = self._get_tcntobj(goids, go2obj, **kws_all) # TermCounts or None
if tcntobj is not None:
kws_dag['tcntobj'] = tc... | python | def _get_kwsdag(self, goids, go2obj, **kws_all):
"""Get keyword args for a GoSubDag."""
kws_dag = {}
# Term Counts for GO Term information score
tcntobj = self._get_tcntobj(goids, go2obj, **kws_all) # TermCounts or None
if tcntobj is not None:
kws_dag['tcntobj'] = tc... | [
"def",
"_get_kwsdag",
"(",
"self",
",",
"goids",
",",
"go2obj",
",",
"**",
"kws_all",
")",
":",
"kws_dag",
"=",
"{",
"}",
"tcntobj",
"=",
"self",
".",
"_get_tcntobj",
"(",
"goids",
",",
"go2obj",
",",
"**",
"kws_all",
")",
"if",
"tcntobj",
"is",
"not... | Get keyword args for a GoSubDag. | [
"Get",
"keyword",
"args",
"for",
"a",
"GoSubDag",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/cli/gosubdag_plot.py#L244-L258 | train |
tanghaibao/goatools | goatools/cli/gosubdag_plot.py | PlotCli._chk_docopts | def _chk_docopts(self, kws):
"""Check for common user command-line errors."""
# outfile should contain .png, .png, etc.
outfile = kws['outfile']
if len(kws) == 2 and os.path.basename(kws['obo']) == "go-basic.obo" and \
kws['outfile'] == self.dflt_outfile:
self._er... | python | def _chk_docopts(self, kws):
"""Check for common user command-line errors."""
# outfile should contain .png, .png, etc.
outfile = kws['outfile']
if len(kws) == 2 and os.path.basename(kws['obo']) == "go-basic.obo" and \
kws['outfile'] == self.dflt_outfile:
self._er... | [
"def",
"_chk_docopts",
"(",
"self",
",",
"kws",
")",
":",
"outfile",
"=",
"kws",
"[",
"'outfile'",
"]",
"if",
"len",
"(",
"kws",
")",
"==",
"2",
"and",
"os",
".",
"path",
".",
"basename",
"(",
"kws",
"[",
"'obo'",
"]",
")",
"==",
"\"go-basic.obo\""... | Check for common user command-line errors. | [
"Check",
"for",
"common",
"user",
"command",
"-",
"line",
"errors",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/cli/gosubdag_plot.py#L277-L290 | train |
tanghaibao/goatools | goatools/cli/gosubdag_plot.py | PlotCli._err | def _err(self, msg, err=True):
"""Print useage and error before exiting."""
severity = "FATAL" if err else "NOTE"
txt = "".join([self.objdoc.doc,
"User's command-line:\n\n",
" % go_plot.py {ARGS}\n\n".format(ARGS=" ".join(sys.argv[1:])),
... | python | def _err(self, msg, err=True):
"""Print useage and error before exiting."""
severity = "FATAL" if err else "NOTE"
txt = "".join([self.objdoc.doc,
"User's command-line:\n\n",
" % go_plot.py {ARGS}\n\n".format(ARGS=" ".join(sys.argv[1:])),
... | [
"def",
"_err",
"(",
"self",
",",
"msg",
",",
"err",
"=",
"True",
")",
":",
"severity",
"=",
"\"FATAL\"",
"if",
"err",
"else",
"\"NOTE\"",
"txt",
"=",
"\"\"",
".",
"join",
"(",
"[",
"self",
".",
"objdoc",
".",
"doc",
",",
"\"User's command-line:\\n\\n\"... | Print useage and error before exiting. | [
"Print",
"useage",
"and",
"error",
"before",
"exiting",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/cli/gosubdag_plot.py#L292-L302 | train |
tanghaibao/goatools | goatools/cli/gosubdag_plot.py | PlotCli.get_outfile | def get_outfile(self, outfile, goids=None):
"""Return output file for GO Term plot."""
# 1. Use the user-specfied output filename for the GO Term plot
if outfile != self.dflt_outfile:
return outfile
# 2. If only plotting 1 GO term, use GO is in plot name
if goids is n... | python | def get_outfile(self, outfile, goids=None):
"""Return output file for GO Term plot."""
# 1. Use the user-specfied output filename for the GO Term plot
if outfile != self.dflt_outfile:
return outfile
# 2. If only plotting 1 GO term, use GO is in plot name
if goids is n... | [
"def",
"get_outfile",
"(",
"self",
",",
"outfile",
",",
"goids",
"=",
"None",
")",
":",
"if",
"outfile",
"!=",
"self",
".",
"dflt_outfile",
":",
"return",
"outfile",
"if",
"goids",
"is",
"not",
"None",
"and",
"len",
"(",
"goids",
")",
"==",
"1",
":",... | Return output file for GO Term plot. | [
"Return",
"output",
"file",
"for",
"GO",
"Term",
"plot",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/cli/gosubdag_plot.py#L304-L316 | train |
tanghaibao/goatools | goatools/cli/gosubdag_plot.py | PlotCli._get_optional_attrs | def _get_optional_attrs(kws):
"""Given keyword args, return optional_attributes to be loaded into the GODag."""
vals = OboOptionalAttrs.attributes.intersection(kws.keys())
if 'sections' in kws:
vals.add('relationship')
if 'norel' in kws:
vals.discard('relationship... | python | def _get_optional_attrs(kws):
"""Given keyword args, return optional_attributes to be loaded into the GODag."""
vals = OboOptionalAttrs.attributes.intersection(kws.keys())
if 'sections' in kws:
vals.add('relationship')
if 'norel' in kws:
vals.discard('relationship... | [
"def",
"_get_optional_attrs",
"(",
"kws",
")",
":",
"vals",
"=",
"OboOptionalAttrs",
".",
"attributes",
".",
"intersection",
"(",
"kws",
".",
"keys",
"(",
")",
")",
"if",
"'sections'",
"in",
"kws",
":",
"vals",
".",
"add",
"(",
"'relationship'",
")",
"if... | Given keyword args, return optional_attributes to be loaded into the GODag. | [
"Given",
"keyword",
"args",
"return",
"optional_attributes",
"to",
"be",
"loaded",
"into",
"the",
"GODag",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/cli/gosubdag_plot.py#L319-L326 | train |
tanghaibao/goatools | goatools/cli/wr_sections.py | WrSectionsCli._read_sections | def _read_sections(ifile):
"""Read sections_in.txt file, if it exists."""
if os.path.exists(ifile):
return read_sections(ifile, exclude_ungrouped=True, prt=None) | python | def _read_sections(ifile):
"""Read sections_in.txt file, if it exists."""
if os.path.exists(ifile):
return read_sections(ifile, exclude_ungrouped=True, prt=None) | [
"def",
"_read_sections",
"(",
"ifile",
")",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"ifile",
")",
":",
"return",
"read_sections",
"(",
"ifile",
",",
"exclude_ungrouped",
"=",
"True",
",",
"prt",
"=",
"None",
")"
] | Read sections_in.txt file, if it exists. | [
"Read",
"sections_in",
".",
"txt",
"file",
"if",
"it",
"exists",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/cli/wr_sections.py#L96-L99 | train |
tanghaibao/goatools | goatools/gosubdag/go_paths.py | GoPaths.get_paths_from_to | def get_paths_from_to(self, goobj_start, goid_end=None, dn0_up1=True):
"""Get a list of paths from goobj_start to either top or goid_end."""
paths = []
# Queue of terms to be examined (and storage for their paths)
working_q = cx.deque([[goobj_start]])
# Loop thru GO terms until w... | python | def get_paths_from_to(self, goobj_start, goid_end=None, dn0_up1=True):
"""Get a list of paths from goobj_start to either top or goid_end."""
paths = []
# Queue of terms to be examined (and storage for their paths)
working_q = cx.deque([[goobj_start]])
# Loop thru GO terms until w... | [
"def",
"get_paths_from_to",
"(",
"self",
",",
"goobj_start",
",",
"goid_end",
"=",
"None",
",",
"dn0_up1",
"=",
"True",
")",
":",
"paths",
"=",
"[",
"]",
"working_q",
"=",
"cx",
".",
"deque",
"(",
"[",
"[",
"goobj_start",
"]",
"]",
")",
"adjfnc",
"="... | Get a list of paths from goobj_start to either top or goid_end. | [
"Get",
"a",
"list",
"of",
"paths",
"from",
"goobj_start",
"to",
"either",
"top",
"or",
"goid_end",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/gosubdag/go_paths.py#L19-L45 | train |
tanghaibao/goatools | goatools/gosubdag/go_paths.py | GoPaths.prt_paths | def prt_paths(paths, prt=sys.stdout):
"""Print list of paths."""
pat = "PATHES: {GO} L{L:02} D{D:02}\n"
for path in paths:
for go_obj in path:
prt.write(pat.format(GO=go_obj.id, L=go_obj.level, D=go_obj.depth))
prt.write("\n") | python | def prt_paths(paths, prt=sys.stdout):
"""Print list of paths."""
pat = "PATHES: {GO} L{L:02} D{D:02}\n"
for path in paths:
for go_obj in path:
prt.write(pat.format(GO=go_obj.id, L=go_obj.level, D=go_obj.depth))
prt.write("\n") | [
"def",
"prt_paths",
"(",
"paths",
",",
"prt",
"=",
"sys",
".",
"stdout",
")",
":",
"pat",
"=",
"\"PATHES: {GO} L{L:02} D{D:02}\\n\"",
"for",
"path",
"in",
"paths",
":",
"for",
"go_obj",
"in",
"path",
":",
"prt",
".",
"write",
"(",
"pat",
".",
"format",
... | Print list of paths. | [
"Print",
"list",
"of",
"paths",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/gosubdag/go_paths.py#L48-L54 | train |
tanghaibao/goatools | goatools/godag/relationship_str.py | RelationshipStr.prt_keys | def prt_keys(self, prt, pre):
"""Print the alias for a relationship and its alias."""
prt.write('{PRE}Relationship to parent: {ABC}\n'.format(
PRE=pre, ABC=''.join(self.rel2chr.values())))
for rel, alias in self.rel2chr.items():
prt.write('{PRE} {A} {DESC}\n'.format(PR... | python | def prt_keys(self, prt, pre):
"""Print the alias for a relationship and its alias."""
prt.write('{PRE}Relationship to parent: {ABC}\n'.format(
PRE=pre, ABC=''.join(self.rel2chr.values())))
for rel, alias in self.rel2chr.items():
prt.write('{PRE} {A} {DESC}\n'.format(PR... | [
"def",
"prt_keys",
"(",
"self",
",",
"prt",
",",
"pre",
")",
":",
"prt",
".",
"write",
"(",
"'{PRE}Relationship to parent: {ABC}\\n'",
".",
"format",
"(",
"PRE",
"=",
"pre",
",",
"ABC",
"=",
"''",
".",
"join",
"(",
"self",
".",
"rel2chr",
".",
"values"... | Print the alias for a relationship and its alias. | [
"Print",
"the",
"alias",
"for",
"a",
"relationship",
"and",
"its",
"alias",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/godag/relationship_str.py#L79-L88 | train |
tanghaibao/goatools | goatools/anno/annoreader_base.py | AnnoReaderBase._get_id2gos | def _get_id2gos(self, associations, **kws):
"""Return given associations in a dict, id2gos"""
options = AnnoOptions(self.evobj, **kws)
# Default reduction is to remove. For all options, see goatools/anno/opts.py:
# * Evidence_Code == ND -> No biological data No biological Data availabl... | python | def _get_id2gos(self, associations, **kws):
"""Return given associations in a dict, id2gos"""
options = AnnoOptions(self.evobj, **kws)
# Default reduction is to remove. For all options, see goatools/anno/opts.py:
# * Evidence_Code == ND -> No biological data No biological Data availabl... | [
"def",
"_get_id2gos",
"(",
"self",
",",
"associations",
",",
"**",
"kws",
")",
":",
"options",
"=",
"AnnoOptions",
"(",
"self",
".",
"evobj",
",",
"**",
"kws",
")",
"assc",
"=",
"self",
".",
"reduce_annotations",
"(",
"associations",
",",
"options",
")",... | Return given associations in a dict, id2gos | [
"Return",
"given",
"associations",
"in",
"a",
"dict",
"id2gos"
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/anno/annoreader_base.py#L83-L90 | train |
tanghaibao/goatools | goatools/anno/annoreader_base.py | AnnoReaderBase.get_date_yyyymmdd | def get_date_yyyymmdd(yyyymmdd):
"""Return datetime.date given string."""
return date(int(yyyymmdd[:4]), int(yyyymmdd[4:6], base=10), int(yyyymmdd[6:], base=10)) | python | def get_date_yyyymmdd(yyyymmdd):
"""Return datetime.date given string."""
return date(int(yyyymmdd[:4]), int(yyyymmdd[4:6], base=10), int(yyyymmdd[6:], base=10)) | [
"def",
"get_date_yyyymmdd",
"(",
"yyyymmdd",
")",
":",
"return",
"date",
"(",
"int",
"(",
"yyyymmdd",
"[",
":",
"4",
"]",
")",
",",
"int",
"(",
"yyyymmdd",
"[",
"4",
":",
"6",
"]",
",",
"base",
"=",
"10",
")",
",",
"int",
"(",
"yyyymmdd",
"[",
... | Return datetime.date given string. | [
"Return",
"datetime",
".",
"date",
"given",
"string",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/anno/annoreader_base.py#L139-L141 | train |
tanghaibao/goatools | goatools/anno/annoreader_base.py | AnnoReaderBase.hms | def hms(self, msg, tic=None, prt=sys.stdout):
"""Print elapsed time and message."""
if tic is None:
tic = self.tic
now = timeit.default_timer()
hms = str(datetime.timedelta(seconds=(now-tic)))
prt.write('{HMS}: {MSG}\n'.format(HMS=hms, MSG=msg))
return now | python | def hms(self, msg, tic=None, prt=sys.stdout):
"""Print elapsed time and message."""
if tic is None:
tic = self.tic
now = timeit.default_timer()
hms = str(datetime.timedelta(seconds=(now-tic)))
prt.write('{HMS}: {MSG}\n'.format(HMS=hms, MSG=msg))
return now | [
"def",
"hms",
"(",
"self",
",",
"msg",
",",
"tic",
"=",
"None",
",",
"prt",
"=",
"sys",
".",
"stdout",
")",
":",
"if",
"tic",
"is",
"None",
":",
"tic",
"=",
"self",
".",
"tic",
"now",
"=",
"timeit",
".",
"default_timer",
"(",
")",
"hms",
"=",
... | Print elapsed time and message. | [
"Print",
"elapsed",
"time",
"and",
"message",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/anno/annoreader_base.py#L143-L150 | train |
tanghaibao/goatools | goatools/anno/annoreader_base.py | AnnoReaderBase.chk_qualifiers | def chk_qualifiers(self):
"""Check format of qualifier"""
if self.name == 'id2gos':
return
for ntd in self.associations:
# print(ntd)
qual = ntd.Qualifier
assert isinstance(qual, set), '{NAME}: QUALIFIER MUST BE A LIST: {NT}'.format(
... | python | def chk_qualifiers(self):
"""Check format of qualifier"""
if self.name == 'id2gos':
return
for ntd in self.associations:
# print(ntd)
qual = ntd.Qualifier
assert isinstance(qual, set), '{NAME}: QUALIFIER MUST BE A LIST: {NT}'.format(
... | [
"def",
"chk_qualifiers",
"(",
"self",
")",
":",
"if",
"self",
".",
"name",
"==",
"'id2gos'",
":",
"return",
"for",
"ntd",
"in",
"self",
".",
"associations",
":",
"qual",
"=",
"ntd",
".",
"Qualifier",
"assert",
"isinstance",
"(",
"qual",
",",
"set",
")"... | Check format of qualifier | [
"Check",
"format",
"of",
"qualifier"
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/anno/annoreader_base.py#L164-L175 | train |
tanghaibao/goatools | goatools/anno/annoreader_base.py | AnnoReaderBase._has_not_qual | def _has_not_qual(ntd):
"""Return True if the qualifiers contain a 'NOT'"""
for qual in ntd.Qualifier:
if 'not' in qual:
return True
if 'NOT' in qual:
return True
return False | python | def _has_not_qual(ntd):
"""Return True if the qualifiers contain a 'NOT'"""
for qual in ntd.Qualifier:
if 'not' in qual:
return True
if 'NOT' in qual:
return True
return False | [
"def",
"_has_not_qual",
"(",
"ntd",
")",
":",
"for",
"qual",
"in",
"ntd",
".",
"Qualifier",
":",
"if",
"'not'",
"in",
"qual",
":",
"return",
"True",
"if",
"'NOT'",
"in",
"qual",
":",
"return",
"True",
"return",
"False"
] | Return True if the qualifiers contain a 'NOT | [
"Return",
"True",
"if",
"the",
"qualifiers",
"contain",
"a",
"NOT"
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/anno/annoreader_base.py#L178-L185 | train |
tanghaibao/goatools | goatools/grouper/sorter_nts.py | SorterNts._get_sorted_section | def _get_sorted_section(self, nts_section):
"""Sort GO IDs in each section, if requested by user."""
#pylint: disable=unnecessary-lambda
if self.section_sortby is True:
return sorted(nts_section, key=lambda nt: self.sortgos.usrgo_sortby(nt))
if self.section_sortby is False or... | python | def _get_sorted_section(self, nts_section):
"""Sort GO IDs in each section, if requested by user."""
#pylint: disable=unnecessary-lambda
if self.section_sortby is True:
return sorted(nts_section, key=lambda nt: self.sortgos.usrgo_sortby(nt))
if self.section_sortby is False or... | [
"def",
"_get_sorted_section",
"(",
"self",
",",
"nts_section",
")",
":",
"if",
"self",
".",
"section_sortby",
"is",
"True",
":",
"return",
"sorted",
"(",
"nts_section",
",",
"key",
"=",
"lambda",
"nt",
":",
"self",
".",
"sortgos",
".",
"usrgo_sortby",
"(",... | Sort GO IDs in each section, if requested by user. | [
"Sort",
"GO",
"IDs",
"in",
"each",
"section",
"if",
"requested",
"by",
"user",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/sorter_nts.py#L88-L96 | train |
tanghaibao/goatools | goatools/godag/go_tasks.py | get_relationship_targets | def get_relationship_targets(item_ids, relationships, id2rec):
"""Get item ID set of item IDs in a relationship target set."""
# Requirements to use this function:
# 1) item Terms must have been loaded with 'relationships'
# 2) item IDs in 'item_ids' arguement must be present in id2rec
# ... | python | def get_relationship_targets(item_ids, relationships, id2rec):
"""Get item ID set of item IDs in a relationship target set."""
# Requirements to use this function:
# 1) item Terms must have been loaded with 'relationships'
# 2) item IDs in 'item_ids' arguement must be present in id2rec
# ... | [
"def",
"get_relationship_targets",
"(",
"item_ids",
",",
"relationships",
",",
"id2rec",
")",
":",
"reltgt_objs_all",
"=",
"set",
"(",
")",
"for",
"goid",
"in",
"item_ids",
":",
"obj",
"=",
"id2rec",
"[",
"goid",
"]",
"for",
"reltype",
",",
"reltgt_objs_cur"... | Get item ID set of item IDs in a relationship target set. | [
"Get",
"item",
"ID",
"set",
"of",
"item",
"IDs",
"in",
"a",
"relationship",
"target",
"set",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/godag/go_tasks.py#L35-L47 | train |
tanghaibao/goatools | goatools/godag/go_tasks.py | _get_id2parents | def _get_id2parents(id2parents, item_id, item_obj):
"""Add the parent item IDs for one item object and their parents."""
if item_id in id2parents:
return id2parents[item_id]
parent_ids = set()
for parent_obj in item_obj.parents:
parent_id = parent_obj.item_id
parent_ids.add(paren... | python | def _get_id2parents(id2parents, item_id, item_obj):
"""Add the parent item IDs for one item object and their parents."""
if item_id in id2parents:
return id2parents[item_id]
parent_ids = set()
for parent_obj in item_obj.parents:
parent_id = parent_obj.item_id
parent_ids.add(paren... | [
"def",
"_get_id2parents",
"(",
"id2parents",
",",
"item_id",
",",
"item_obj",
")",
":",
"if",
"item_id",
"in",
"id2parents",
":",
"return",
"id2parents",
"[",
"item_id",
"]",
"parent_ids",
"=",
"set",
"(",
")",
"for",
"parent_obj",
"in",
"item_obj",
".",
"... | Add the parent item IDs for one item object and their parents. | [
"Add",
"the",
"parent",
"item",
"IDs",
"for",
"one",
"item",
"object",
"and",
"their",
"parents",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/godag/go_tasks.py#L50-L60 | train |
tanghaibao/goatools | goatools/godag/go_tasks.py | _get_id2children | def _get_id2children(id2children, item_id, item_obj):
"""Add the child item IDs for one item object and their children."""
if item_id in id2children:
return id2children[item_id]
child_ids = set()
for child_obj in item_obj.children:
child_id = child_obj.item_id
child_ids.add(child... | python | def _get_id2children(id2children, item_id, item_obj):
"""Add the child item IDs for one item object and their children."""
if item_id in id2children:
return id2children[item_id]
child_ids = set()
for child_obj in item_obj.children:
child_id = child_obj.item_id
child_ids.add(child... | [
"def",
"_get_id2children",
"(",
"id2children",
",",
"item_id",
",",
"item_obj",
")",
":",
"if",
"item_id",
"in",
"id2children",
":",
"return",
"id2children",
"[",
"item_id",
"]",
"child_ids",
"=",
"set",
"(",
")",
"for",
"child_obj",
"in",
"item_obj",
".",
... | Add the child item IDs for one item object and their children. | [
"Add",
"the",
"child",
"item",
"IDs",
"for",
"one",
"item",
"object",
"and",
"their",
"children",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/godag/go_tasks.py#L62-L72 | train |
tanghaibao/goatools | goatools/godag/go_tasks.py | _get_id2upper | def _get_id2upper(id2upper, item_id, item_obj):
"""Add the parent item IDs for one item object and their upper."""
if item_id in id2upper:
return id2upper[item_id]
upper_ids = set()
for upper_obj in item_obj.get_goterms_upper():
upper_id = upper_obj.item_id
upper_ids.add(upper_id... | python | def _get_id2upper(id2upper, item_id, item_obj):
"""Add the parent item IDs for one item object and their upper."""
if item_id in id2upper:
return id2upper[item_id]
upper_ids = set()
for upper_obj in item_obj.get_goterms_upper():
upper_id = upper_obj.item_id
upper_ids.add(upper_id... | [
"def",
"_get_id2upper",
"(",
"id2upper",
",",
"item_id",
",",
"item_obj",
")",
":",
"if",
"item_id",
"in",
"id2upper",
":",
"return",
"id2upper",
"[",
"item_id",
"]",
"upper_ids",
"=",
"set",
"(",
")",
"for",
"upper_obj",
"in",
"item_obj",
".",
"get_goterm... | Add the parent item IDs for one item object and their upper. | [
"Add",
"the",
"parent",
"item",
"IDs",
"for",
"one",
"item",
"object",
"and",
"their",
"upper",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/godag/go_tasks.py#L74-L84 | train |
tanghaibao/goatools | goatools/godag/go_tasks.py | _get_id2lower | def _get_id2lower(id2lower, item_id, item_obj):
"""Add the lower item IDs for one item object and the objects below them."""
if item_id in id2lower:
return id2lower[item_id]
lower_ids = set()
for lower_obj in item_obj.get_goterms_lower():
lower_id = lower_obj.item_id
lower_ids.ad... | python | def _get_id2lower(id2lower, item_id, item_obj):
"""Add the lower item IDs for one item object and the objects below them."""
if item_id in id2lower:
return id2lower[item_id]
lower_ids = set()
for lower_obj in item_obj.get_goterms_lower():
lower_id = lower_obj.item_id
lower_ids.ad... | [
"def",
"_get_id2lower",
"(",
"id2lower",
",",
"item_id",
",",
"item_obj",
")",
":",
"if",
"item_id",
"in",
"id2lower",
":",
"return",
"id2lower",
"[",
"item_id",
"]",
"lower_ids",
"=",
"set",
"(",
")",
"for",
"lower_obj",
"in",
"item_obj",
".",
"get_goterm... | Add the lower item IDs for one item object and the objects below them. | [
"Add",
"the",
"lower",
"item",
"IDs",
"for",
"one",
"item",
"object",
"and",
"the",
"objects",
"below",
"them",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/godag/go_tasks.py#L86-L96 | train |
tanghaibao/goatools | goatools/godag/go_tasks.py | CurNHigher.fill_parentidid2obj_r0 | def fill_parentidid2obj_r0(self, id2obj, child_obj):
"""Fill id2obj with all parent key item IDs and their objects."""
for parent_obj in child_obj.parents:
if parent_obj.item_id not in id2obj:
id2obj[parent_obj.item_id] = parent_obj
self.fill_parentidid2obj_r0... | python | def fill_parentidid2obj_r0(self, id2obj, child_obj):
"""Fill id2obj with all parent key item IDs and their objects."""
for parent_obj in child_obj.parents:
if parent_obj.item_id not in id2obj:
id2obj[parent_obj.item_id] = parent_obj
self.fill_parentidid2obj_r0... | [
"def",
"fill_parentidid2obj_r0",
"(",
"self",
",",
"id2obj",
",",
"child_obj",
")",
":",
"for",
"parent_obj",
"in",
"child_obj",
".",
"parents",
":",
"if",
"parent_obj",
".",
"item_id",
"not",
"in",
"id2obj",
":",
"id2obj",
"[",
"parent_obj",
".",
"item_id",... | Fill id2obj with all parent key item IDs and their objects. | [
"Fill",
"id2obj",
"with",
"all",
"parent",
"key",
"item",
"IDs",
"and",
"their",
"objects",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/godag/go_tasks.py#L123-L128 | train |
tanghaibao/goatools | goatools/grouper/wr_sections.py | WrSectionsBase.prt_ver | def prt_ver(self, prt):
"""Print version of GO-DAG for the GO and for GO slims."""
if self.ver_list is not None:
prt.write("# Versions:\n# {VER}\n\n".format(VER="\n# ".join(self.ver_list))) | python | def prt_ver(self, prt):
"""Print version of GO-DAG for the GO and for GO slims."""
if self.ver_list is not None:
prt.write("# Versions:\n# {VER}\n\n".format(VER="\n# ".join(self.ver_list))) | [
"def",
"prt_ver",
"(",
"self",
",",
"prt",
")",
":",
"if",
"self",
".",
"ver_list",
"is",
"not",
"None",
":",
"prt",
".",
"write",
"(",
"\"# Versions:\\n# {VER}\\n\\n\"",
".",
"format",
"(",
"VER",
"=",
"\"\\n# \"",
".",
"join",
"(",
"self",
".",
... | Print version of GO-DAG for the GO and for GO slims. | [
"Print",
"version",
"of",
"GO",
"-",
"DAG",
"for",
"the",
"GO",
"and",
"for",
"GO",
"slims",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/wr_sections.py#L22-L25 | train |
tanghaibao/goatools | goatools/grouper/wr_sections.py | WrSectionsBase.get_sections_2dnt | def get_sections_2dnt(self, sec2d_go):
"""Return a sections list containing sorted lists of namedtuples."""
return [(nm, self.get_ntgos_sorted(gos)) for nm, gos in sec2d_go] | python | def get_sections_2dnt(self, sec2d_go):
"""Return a sections list containing sorted lists of namedtuples."""
return [(nm, self.get_ntgos_sorted(gos)) for nm, gos in sec2d_go] | [
"def",
"get_sections_2dnt",
"(",
"self",
",",
"sec2d_go",
")",
":",
"return",
"[",
"(",
"nm",
",",
"self",
".",
"get_ntgos_sorted",
"(",
"gos",
")",
")",
"for",
"nm",
",",
"gos",
"in",
"sec2d_go",
"]"
] | Return a sections list containing sorted lists of namedtuples. | [
"Return",
"a",
"sections",
"list",
"containing",
"sorted",
"lists",
"of",
"namedtuples",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/wr_sections.py#L27-L29 | train |
tanghaibao/goatools | goatools/grouper/wr_sections.py | WrSectionsBase.get_ntgos_sorted | def get_ntgos_sorted(self, hdrgos):
"""Return sorted Grouper namedtuples if there are user GO IDs underneath."""
go2nt = self.grprobj.go2nt
return sorted([go2nt[go] for go in hdrgos if go in go2nt], key=self.fncsortnt) | python | def get_ntgos_sorted(self, hdrgos):
"""Return sorted Grouper namedtuples if there are user GO IDs underneath."""
go2nt = self.grprobj.go2nt
return sorted([go2nt[go] for go in hdrgos if go in go2nt], key=self.fncsortnt) | [
"def",
"get_ntgos_sorted",
"(",
"self",
",",
"hdrgos",
")",
":",
"go2nt",
"=",
"self",
".",
"grprobj",
".",
"go2nt",
"return",
"sorted",
"(",
"[",
"go2nt",
"[",
"go",
"]",
"for",
"go",
"in",
"hdrgos",
"if",
"go",
"in",
"go2nt",
"]",
",",
"key",
"="... | Return sorted Grouper namedtuples if there are user GO IDs underneath. | [
"Return",
"sorted",
"Grouper",
"namedtuples",
"if",
"there",
"are",
"user",
"GO",
"IDs",
"underneath",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/wr_sections.py#L31-L34 | train |
tanghaibao/goatools | goatools/grouper/wr_sections.py | WrSectionsBase.prt_ntgos | def prt_ntgos(self, prt, ntgos):
"""Print the Grouper namedtuples."""
for ntgo in ntgos:
key2val = ntgo._asdict()
prt.write("{GO_LINE}\n".format(GO_LINE=self.prtfmt.format(**key2val))) | python | def prt_ntgos(self, prt, ntgos):
"""Print the Grouper namedtuples."""
for ntgo in ntgos:
key2val = ntgo._asdict()
prt.write("{GO_LINE}\n".format(GO_LINE=self.prtfmt.format(**key2val))) | [
"def",
"prt_ntgos",
"(",
"self",
",",
"prt",
",",
"ntgos",
")",
":",
"for",
"ntgo",
"in",
"ntgos",
":",
"key2val",
"=",
"ntgo",
".",
"_asdict",
"(",
")",
"prt",
".",
"write",
"(",
"\"{GO_LINE}\\n\"",
".",
"format",
"(",
"GO_LINE",
"=",
"self",
".",
... | Print the Grouper namedtuples. | [
"Print",
"the",
"Grouper",
"namedtuples",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/wr_sections.py#L36-L40 | train |
tanghaibao/goatools | goatools/grouper/wr_sections.py | WrSectionsPy.wr_py_sections_new | def wr_py_sections_new(self, fout_py, doc=None):
"""Write the first sections file."""
sections = self.grprobj.get_sections_2d()
return self.wr_py_sections(fout_py, sections, doc) | python | def wr_py_sections_new(self, fout_py, doc=None):
"""Write the first sections file."""
sections = self.grprobj.get_sections_2d()
return self.wr_py_sections(fout_py, sections, doc) | [
"def",
"wr_py_sections_new",
"(",
"self",
",",
"fout_py",
",",
"doc",
"=",
"None",
")",
":",
"sections",
"=",
"self",
".",
"grprobj",
".",
"get_sections_2d",
"(",
")",
"return",
"self",
".",
"wr_py_sections",
"(",
"fout_py",
",",
"sections",
",",
"doc",
... | Write the first sections file. | [
"Write",
"the",
"first",
"sections",
"file",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/wr_sections.py#L92-L95 | train |
tanghaibao/goatools | goatools/grouper/wr_sections.py | WrSectionsPy.wr_py_sections | def wr_py_sections(self, fout_py, sections, doc=None):
"""Write sections 2-D list into a Python format list."""
if sections is None:
sections = self.grprobj.get_sections_2d()
sec2d_nt = self.get_sections_2dnt(sections) # lists of GO Grouper namedtuples
with open(fout_py, 'w'... | python | def wr_py_sections(self, fout_py, sections, doc=None):
"""Write sections 2-D list into a Python format list."""
if sections is None:
sections = self.grprobj.get_sections_2d()
sec2d_nt = self.get_sections_2dnt(sections) # lists of GO Grouper namedtuples
with open(fout_py, 'w'... | [
"def",
"wr_py_sections",
"(",
"self",
",",
"fout_py",
",",
"sections",
",",
"doc",
"=",
"None",
")",
":",
"if",
"sections",
"is",
"None",
":",
"sections",
"=",
"self",
".",
"grprobj",
".",
"get_sections_2d",
"(",
")",
"sec2d_nt",
"=",
"self",
".",
"get... | Write sections 2-D list into a Python format list. | [
"Write",
"sections",
"2",
"-",
"D",
"list",
"into",
"a",
"Python",
"format",
"list",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/wr_sections.py#L97-L108 | train |
tanghaibao/goatools | goatools/grouper/wr_sections.py | WrSectionsPy._prt_py_sections | def _prt_py_sections(self, sec2d_nt, prt=sys.stdout, doc=None):
"""Print sections 2-D list into a Python format list."""
if doc is None:
doc = 'Sections variable'
prt.write('"""{DOC}"""\n\n'.format(DOC=doc))
self.prt_ver(prt)
prt.write("# pylint: disable=line-too-long... | python | def _prt_py_sections(self, sec2d_nt, prt=sys.stdout, doc=None):
"""Print sections 2-D list into a Python format list."""
if doc is None:
doc = 'Sections variable'
prt.write('"""{DOC}"""\n\n'.format(DOC=doc))
self.prt_ver(prt)
prt.write("# pylint: disable=line-too-long... | [
"def",
"_prt_py_sections",
"(",
"self",
",",
"sec2d_nt",
",",
"prt",
"=",
"sys",
".",
"stdout",
",",
"doc",
"=",
"None",
")",
":",
"if",
"doc",
"is",
"None",
":",
"doc",
"=",
"'Sections variable'",
"prt",
".",
"write",
"(",
"'\\n\\n'",
".",
"format",
... | Print sections 2-D list into a Python format list. | [
"Print",
"sections",
"2",
"-",
"D",
"list",
"into",
"a",
"Python",
"format",
"list",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/wr_sections.py#L110-L123 | train |
tanghaibao/goatools | goatools/grouper/wr_sections.py | WrSectionsPy._prt_py_section | def _prt_py_section(self, prt, section_name, ntgos):
"""Print one section and its GO headers."""
prt.write(' ("{SEC}", [ # {N} GO-headers\n'.format(SEC=section_name, N=len(ntgos)))
self.prt_ntgos(prt, ntgos)
prt.write(" ]),\n") | python | def _prt_py_section(self, prt, section_name, ntgos):
"""Print one section and its GO headers."""
prt.write(' ("{SEC}", [ # {N} GO-headers\n'.format(SEC=section_name, N=len(ntgos)))
self.prt_ntgos(prt, ntgos)
prt.write(" ]),\n") | [
"def",
"_prt_py_section",
"(",
"self",
",",
"prt",
",",
"section_name",
",",
"ntgos",
")",
":",
"prt",
".",
"write",
"(",
"' (\"{SEC}\", [ # {N} GO-headers\\n'",
".",
"format",
"(",
"SEC",
"=",
"section_name",
",",
"N",
"=",
"len",
"(",
"ntgos",
")",
")... | Print one section and its GO headers. | [
"Print",
"one",
"section",
"and",
"its",
"GO",
"headers",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/wr_sections.py#L125-L129 | train |
tanghaibao/goatools | goatools/grouper/wr_sections.py | WrSectionsTxt.prt_goid_cnt | def prt_goid_cnt(self, prt=sys.stdout):
"""Get number of hdrgos and usrgos in each section."""
for section_name, hdrgos_sec in self.grprobj.get_sections_2d():
prt.write("{NAME} {Us:5,} {Hs:5,} {SEC}\n".format(
NAME=self.grprobj.grpname,
Us=len(self.grprobj.get... | python | def prt_goid_cnt(self, prt=sys.stdout):
"""Get number of hdrgos and usrgos in each section."""
for section_name, hdrgos_sec in self.grprobj.get_sections_2d():
prt.write("{NAME} {Us:5,} {Hs:5,} {SEC}\n".format(
NAME=self.grprobj.grpname,
Us=len(self.grprobj.get... | [
"def",
"prt_goid_cnt",
"(",
"self",
",",
"prt",
"=",
"sys",
".",
"stdout",
")",
":",
"for",
"section_name",
",",
"hdrgos_sec",
"in",
"self",
".",
"grprobj",
".",
"get_sections_2d",
"(",
")",
":",
"prt",
".",
"write",
"(",
"\"{NAME} {Us:5,} {Hs:5,} {SEC}\\n\"... | Get number of hdrgos and usrgos in each section. | [
"Get",
"number",
"of",
"hdrgos",
"and",
"usrgos",
"in",
"each",
"section",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/wr_sections.py#L162-L169 | train |
tanghaibao/goatools | goatools/grouper/wr_sections.py | WrSectionsTxt.wr_txt_grouping_gos | def wr_txt_grouping_gos(self):
"""Write one file per GO group."""
prt_goids = self.grprobj.gosubdag.prt_goids
for hdrgo, usrgos in self.grprobj.hdrgo2usrgos.items():
keygos = usrgos.union([hdrgo])
fout_txt = "{BASE}.txt".format(BASE=self.grprobj.get_fout_base(hdrgo))
... | python | def wr_txt_grouping_gos(self):
"""Write one file per GO group."""
prt_goids = self.grprobj.gosubdag.prt_goids
for hdrgo, usrgos in self.grprobj.hdrgo2usrgos.items():
keygos = usrgos.union([hdrgo])
fout_txt = "{BASE}.txt".format(BASE=self.grprobj.get_fout_base(hdrgo))
... | [
"def",
"wr_txt_grouping_gos",
"(",
"self",
")",
":",
"prt_goids",
"=",
"self",
".",
"grprobj",
".",
"gosubdag",
".",
"prt_goids",
"for",
"hdrgo",
",",
"usrgos",
"in",
"self",
".",
"grprobj",
".",
"hdrgo2usrgos",
".",
"items",
"(",
")",
":",
"keygos",
"="... | Write one file per GO group. | [
"Write",
"one",
"file",
"per",
"GO",
"group",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/wr_sections.py#L171-L180 | train |
tanghaibao/goatools | goatools/grouper/wr_sections.py | WrSectionsTxt.wr_txt_section_hdrgos | def wr_txt_section_hdrgos(self, fout_txt, sortby=None, prt_section=True):
"""Write high GO IDs that are actually used to group current set of GO IDs."""
sec2d_go = self.grprobj.get_sections_2d() # lists of GO IDs
sec2d_nt = self.get_sections_2dnt(sec2d_go) # lists of GO Grouper namedtuples
... | python | def wr_txt_section_hdrgos(self, fout_txt, sortby=None, prt_section=True):
"""Write high GO IDs that are actually used to group current set of GO IDs."""
sec2d_go = self.grprobj.get_sections_2d() # lists of GO IDs
sec2d_nt = self.get_sections_2dnt(sec2d_go) # lists of GO Grouper namedtuples
... | [
"def",
"wr_txt_section_hdrgos",
"(",
"self",
",",
"fout_txt",
",",
"sortby",
"=",
"None",
",",
"prt_section",
"=",
"True",
")",
":",
"sec2d_go",
"=",
"self",
".",
"grprobj",
".",
"get_sections_2d",
"(",
")",
"sec2d_nt",
"=",
"self",
".",
"get_sections_2dnt",... | Write high GO IDs that are actually used to group current set of GO IDs. | [
"Write",
"high",
"GO",
"IDs",
"that",
"are",
"actually",
"used",
"to",
"group",
"current",
"set",
"of",
"GO",
"IDs",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/wr_sections.py#L182-L202 | train |
tanghaibao/goatools | goatools/parsers/david_chart.py | DavidChartReader.prt_num_sig | def prt_num_sig(self, prt=sys.stdout, alpha=0.05):
"""Print the number of significant GO terms."""
ctr = self.get_num_sig(alpha)
prt.write("{N:6,} TOTAL: {TXT}\n".format(N=len(self.nts), TXT=" ".join([
"FDR({FDR:4})".format(FDR=ctr['FDR']),
"Bonferroni({B:4})".format(B=ct... | python | def prt_num_sig(self, prt=sys.stdout, alpha=0.05):
"""Print the number of significant GO terms."""
ctr = self.get_num_sig(alpha)
prt.write("{N:6,} TOTAL: {TXT}\n".format(N=len(self.nts), TXT=" ".join([
"FDR({FDR:4})".format(FDR=ctr['FDR']),
"Bonferroni({B:4})".format(B=ct... | [
"def",
"prt_num_sig",
"(",
"self",
",",
"prt",
"=",
"sys",
".",
"stdout",
",",
"alpha",
"=",
"0.05",
")",
":",
"ctr",
"=",
"self",
".",
"get_num_sig",
"(",
"alpha",
")",
"prt",
".",
"write",
"(",
"\"{N:6,} TOTAL: {TXT}\\n\"",
".",
"format",
"(",
"N",
... | Print the number of significant GO terms. | [
"Print",
"the",
"number",
"of",
"significant",
"GO",
"terms",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/parsers/david_chart.py#L81-L89 | train |
tanghaibao/goatools | goatools/parsers/david_chart.py | DavidChartReader.get_num_sig | def get_num_sig(self, alpha=0.05):
"""Print the number of significant results using various metrics."""
# Get the number of significant GO terms
ctr = cx.Counter()
flds = set(['FDR', 'Bonferroni', 'Benjamini', 'PValue'])
for ntd in self.nts:
for fld in flds:
... | python | def get_num_sig(self, alpha=0.05):
"""Print the number of significant results using various metrics."""
# Get the number of significant GO terms
ctr = cx.Counter()
flds = set(['FDR', 'Bonferroni', 'Benjamini', 'PValue'])
for ntd in self.nts:
for fld in flds:
... | [
"def",
"get_num_sig",
"(",
"self",
",",
"alpha",
"=",
"0.05",
")",
":",
"ctr",
"=",
"cx",
".",
"Counter",
"(",
")",
"flds",
"=",
"set",
"(",
"[",
"'FDR'",
",",
"'Bonferroni'",
",",
"'Benjamini'",
",",
"'PValue'",
"]",
")",
"for",
"ntd",
"in",
"self... | Print the number of significant results using various metrics. | [
"Print",
"the",
"number",
"of",
"significant",
"results",
"using",
"various",
"metrics",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/parsers/david_chart.py#L91-L100 | train |
tanghaibao/goatools | goatools/parsers/david_chart.py | _Init.get_nts | def get_nts(self, fin_davidchart):
"""Read DAVID Chart file. Store each line in a namedtuple."""
nts = []
with open(fin_davidchart) as ifstrm:
hdr_seen = False
for line in ifstrm:
line = line.rstrip()
flds = line.split('\t')
... | python | def get_nts(self, fin_davidchart):
"""Read DAVID Chart file. Store each line in a namedtuple."""
nts = []
with open(fin_davidchart) as ifstrm:
hdr_seen = False
for line in ifstrm:
line = line.rstrip()
flds = line.split('\t')
... | [
"def",
"get_nts",
"(",
"self",
",",
"fin_davidchart",
")",
":",
"nts",
"=",
"[",
"]",
"with",
"open",
"(",
"fin_davidchart",
")",
"as",
"ifstrm",
":",
"hdr_seen",
"=",
"False",
"for",
"line",
"in",
"ifstrm",
":",
"line",
"=",
"line",
".",
"rstrip",
"... | Read DAVID Chart file. Store each line in a namedtuple. | [
"Read",
"DAVID",
"Chart",
"file",
".",
"Store",
"each",
"line",
"in",
"a",
"namedtuple",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/parsers/david_chart.py#L127-L145 | train |
tanghaibao/goatools | goatools/parsers/david_chart.py | _Init._init_nt | def _init_nt(self, flds):
"""Given string fields from a DAVID chart file, return namedtuple."""
term = flds[1]
genes_str = flds[5]
# pylint: disable=bad-whitespace
return self.ntobj(
Category = flds[0],
GO = term[:10], # 1 GO:004520... | python | def _init_nt(self, flds):
"""Given string fields from a DAVID chart file, return namedtuple."""
term = flds[1]
genes_str = flds[5]
# pylint: disable=bad-whitespace
return self.ntobj(
Category = flds[0],
GO = term[:10], # 1 GO:004520... | [
"def",
"_init_nt",
"(",
"self",
",",
"flds",
")",
":",
"term",
"=",
"flds",
"[",
"1",
"]",
"genes_str",
"=",
"flds",
"[",
"5",
"]",
"return",
"self",
".",
"ntobj",
"(",
"Category",
"=",
"flds",
"[",
"0",
"]",
",",
"GO",
"=",
"term",
"[",
":",
... | Given string fields from a DAVID chart file, return namedtuple. | [
"Given",
"string",
"fields",
"from",
"a",
"DAVID",
"chart",
"file",
"return",
"namedtuple",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/parsers/david_chart.py#L147-L167 | train |
tanghaibao/goatools | goatools/parsers/david_chart.py | _Init.get_genes | def get_genes(genes_str):
"""Given a string containng genes, return a list."""
gene_set = genes_str.split(', ')
if gene_set and gene_set[0].isdigit():
gene_set = set(int(g) for g in gene_set)
return gene_set | python | def get_genes(genes_str):
"""Given a string containng genes, return a list."""
gene_set = genes_str.split(', ')
if gene_set and gene_set[0].isdigit():
gene_set = set(int(g) for g in gene_set)
return gene_set | [
"def",
"get_genes",
"(",
"genes_str",
")",
":",
"gene_set",
"=",
"genes_str",
".",
"split",
"(",
"', '",
")",
"if",
"gene_set",
"and",
"gene_set",
"[",
"0",
"]",
".",
"isdigit",
"(",
")",
":",
"gene_set",
"=",
"set",
"(",
"int",
"(",
"g",
")",
"for... | Given a string containng genes, return a list. | [
"Given",
"a",
"string",
"containng",
"genes",
"return",
"a",
"list",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/parsers/david_chart.py#L170-L175 | train |
tanghaibao/goatools | goatools/anno/extensions/factory.py | get_extensions | def get_extensions(extstr):
"""Return zero or greater Annotation Extensions, given a line of text."""
# Extension examples:
# has_direct_input(UniProtKB:P37840),occurs_in(GO:0005576)
# part_of(UBERON:0006618),part_of(UBERON:0002302)
# occurs_in(CL:0000988)|occurs_in(CL:0001021)
if not exts... | python | def get_extensions(extstr):
"""Return zero or greater Annotation Extensions, given a line of text."""
# Extension examples:
# has_direct_input(UniProtKB:P37840),occurs_in(GO:0005576)
# part_of(UBERON:0006618),part_of(UBERON:0002302)
# occurs_in(CL:0000988)|occurs_in(CL:0001021)
if not exts... | [
"def",
"get_extensions",
"(",
"extstr",
")",
":",
"if",
"not",
"extstr",
":",
"return",
"None",
"exts",
"=",
"[",
"]",
"for",
"ext_lst",
"in",
"extstr",
".",
"split",
"(",
"'|'",
")",
":",
"grp",
"=",
"[",
"]",
"for",
"ext",
"in",
"ext_lst",
".",
... | Return zero or greater Annotation Extensions, given a line of text. | [
"Return",
"zero",
"or",
"greater",
"Annotation",
"Extensions",
"given",
"a",
"line",
"of",
"text",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/anno/extensions/factory.py#L25-L44 | train |
tanghaibao/goatools | goatools/cli/docopt_parse.py | DocOptParse._set_intvals | def _set_intvals(kws, keys):
"""Convert keyword values to int."""
for key in keys:
if key in kws:
kws[key] = int(kws[key]) | python | def _set_intvals(kws, keys):
"""Convert keyword values to int."""
for key in keys:
if key in kws:
kws[key] = int(kws[key]) | [
"def",
"_set_intvals",
"(",
"kws",
",",
"keys",
")",
":",
"for",
"key",
"in",
"keys",
":",
"if",
"key",
"in",
"kws",
":",
"kws",
"[",
"key",
"]",
"=",
"int",
"(",
"kws",
"[",
"key",
"]",
")"
] | Convert keyword values to int. | [
"Convert",
"keyword",
"values",
"to",
"int",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/cli/docopt_parse.py#L51-L55 | train |
tanghaibao/goatools | goatools/cli/docopt_parse.py | DocOptParse._chk_docopt_exit | def _chk_docopt_exit(self, args, exp_letters):
"""Check if docopt exit was for an unknown argument."""
if args is None:
args = sys.argv[1:]
keys_all = self.exp_keys.union(self.exp_elems)
if exp_letters:
keys_all |= exp_letters
unknown_args = self._chk_docu... | python | def _chk_docopt_exit(self, args, exp_letters):
"""Check if docopt exit was for an unknown argument."""
if args is None:
args = sys.argv[1:]
keys_all = self.exp_keys.union(self.exp_elems)
if exp_letters:
keys_all |= exp_letters
unknown_args = self._chk_docu... | [
"def",
"_chk_docopt_exit",
"(",
"self",
",",
"args",
",",
"exp_letters",
")",
":",
"if",
"args",
"is",
"None",
":",
"args",
"=",
"sys",
".",
"argv",
"[",
"1",
":",
"]",
"keys_all",
"=",
"self",
".",
"exp_keys",
".",
"union",
"(",
"self",
".",
"exp_... | Check if docopt exit was for an unknown argument. | [
"Check",
"if",
"docopt",
"exit",
"was",
"for",
"an",
"unknown",
"argument",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/cli/docopt_parse.py#L57-L67 | train |
tanghaibao/goatools | goatools/cli/docopt_parse.py | DocOptParse._chk_docopt_kws | def _chk_docopt_kws(self, docdict, exp):
"""Check for common user errors when running from the command-line."""
for key, val in docdict.items():
if isinstance(val, str):
assert '=' not in val, self._err("'=' FOUND IN VALUE", key, val, exp)
elif key != 'help' and k... | python | def _chk_docopt_kws(self, docdict, exp):
"""Check for common user errors when running from the command-line."""
for key, val in docdict.items():
if isinstance(val, str):
assert '=' not in val, self._err("'=' FOUND IN VALUE", key, val, exp)
elif key != 'help' and k... | [
"def",
"_chk_docopt_kws",
"(",
"self",
",",
"docdict",
",",
"exp",
")",
":",
"for",
"key",
",",
"val",
"in",
"docdict",
".",
"items",
"(",
")",
":",
"if",
"isinstance",
"(",
"val",
",",
"str",
")",
":",
"assert",
"'='",
"not",
"in",
"val",
",",
"... | Check for common user errors when running from the command-line. | [
"Check",
"for",
"common",
"user",
"errors",
"when",
"running",
"from",
"the",
"command",
"-",
"line",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/cli/docopt_parse.py#L69-L75 | train |
tanghaibao/goatools | goatools/cli/docopt_parse.py | DocOptParse._chk_docunknown | def _chk_docunknown(args, exp):
"""Return any unknown args."""
unknown = []
for arg in args:
if arg[:2] == '--':
val = arg[2:]
if val not in exp:
unknown.append(arg)
elif arg[:1] == '-':
val = arg[1:]
... | python | def _chk_docunknown(args, exp):
"""Return any unknown args."""
unknown = []
for arg in args:
if arg[:2] == '--':
val = arg[2:]
if val not in exp:
unknown.append(arg)
elif arg[:1] == '-':
val = arg[1:]
... | [
"def",
"_chk_docunknown",
"(",
"args",
",",
"exp",
")",
":",
"unknown",
"=",
"[",
"]",
"for",
"arg",
"in",
"args",
":",
"if",
"arg",
"[",
":",
"2",
"]",
"==",
"'--'",
":",
"val",
"=",
"arg",
"[",
"2",
":",
"]",
"if",
"val",
"not",
"in",
"exp"... | Return any unknown args. | [
"Return",
"any",
"unknown",
"args",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/cli/docopt_parse.py#L82-L96 | train |
tanghaibao/goatools | goatools/anno/dnld_ebi_goa.py | DnldGoa.dnld_goa | def dnld_goa(self, species, ext='gaf', item=None, fileout=None):
"""Download GOA source file name on EMBL-EBI ftp server."""
basename = self.get_basename(species, ext, item)
src = os.path.join(self.ftp_src_goa, species.upper(), "{F}.gz".format(F=basename))
dst = os.path.join(os.getcwd(),... | python | def dnld_goa(self, species, ext='gaf', item=None, fileout=None):
"""Download GOA source file name on EMBL-EBI ftp server."""
basename = self.get_basename(species, ext, item)
src = os.path.join(self.ftp_src_goa, species.upper(), "{F}.gz".format(F=basename))
dst = os.path.join(os.getcwd(),... | [
"def",
"dnld_goa",
"(",
"self",
",",
"species",
",",
"ext",
"=",
"'gaf'",
",",
"item",
"=",
"None",
",",
"fileout",
"=",
"None",
")",
":",
"basename",
"=",
"self",
".",
"get_basename",
"(",
"species",
",",
"ext",
",",
"item",
")",
"src",
"=",
"os",... | Download GOA source file name on EMBL-EBI ftp server. | [
"Download",
"GOA",
"source",
"file",
"name",
"on",
"EMBL",
"-",
"EBI",
"ftp",
"server",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/anno/dnld_ebi_goa.py#L41-L47 | train |
tanghaibao/goatools | goatools/associations.py | read_associations | def read_associations(assoc_fn, anno_type='id2gos', **kws):
"""Return associatinos in id2gos format"""
# kws get_objanno: taxids hdr_only prt allow_missing_symbol
obj = get_objanno(assoc_fn, anno_type, **kws)
# kws get_id2gos: ev_include ev_exclude keep_ND keep_NOT b_geneid2gos go2geneids
return obj... | python | def read_associations(assoc_fn, anno_type='id2gos', **kws):
"""Return associatinos in id2gos format"""
# kws get_objanno: taxids hdr_only prt allow_missing_symbol
obj = get_objanno(assoc_fn, anno_type, **kws)
# kws get_id2gos: ev_include ev_exclude keep_ND keep_NOT b_geneid2gos go2geneids
return obj... | [
"def",
"read_associations",
"(",
"assoc_fn",
",",
"anno_type",
"=",
"'id2gos'",
",",
"**",
"kws",
")",
":",
"obj",
"=",
"get_objanno",
"(",
"assoc_fn",
",",
"anno_type",
",",
"**",
"kws",
")",
"return",
"obj",
".",
"get_id2gos",
"(",
"**",
"kws",
")"
] | Return associatinos in id2gos format | [
"Return",
"associatinos",
"in",
"id2gos",
"format"
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/associations.py#L49-L54 | train |
tanghaibao/goatools | goatools/associations.py | dnld_ncbi_gene_file | def dnld_ncbi_gene_file(fin, force_dnld=False, log=sys.stdout, loading_bar=True):
"""Download a file from NCBI Gene's ftp server."""
if not os.path.exists(fin) or force_dnld:
import gzip
fin_dir, fin_base = os.path.split(fin)
fin_gz = "{F}.gz".format(F=fin_base)
fin_gz = os.path.... | python | def dnld_ncbi_gene_file(fin, force_dnld=False, log=sys.stdout, loading_bar=True):
"""Download a file from NCBI Gene's ftp server."""
if not os.path.exists(fin) or force_dnld:
import gzip
fin_dir, fin_base = os.path.split(fin)
fin_gz = "{F}.gz".format(F=fin_base)
fin_gz = os.path.... | [
"def",
"dnld_ncbi_gene_file",
"(",
"fin",
",",
"force_dnld",
"=",
"False",
",",
"log",
"=",
"sys",
".",
"stdout",
",",
"loading_bar",
"=",
"True",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"fin",
")",
"or",
"force_dnld",
":",
"imp... | Download a file from NCBI Gene's ftp server. | [
"Download",
"a",
"file",
"from",
"NCBI",
"Gene",
"s",
"ftp",
"server",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/associations.py#L62-L85 | train |
tanghaibao/goatools | goatools/associations.py | dnld_annofile | def dnld_annofile(fin_anno, anno_type):
"""Download annotation file, if needed"""
if os.path.exists(fin_anno):
return
anno_type = get_anno_desc(fin_anno, anno_type)
if anno_type == 'gene2go':
dnld_ncbi_gene_file(fin_anno)
if anno_type in {'gaf', 'gpad'}:
dnld_annotation(fin_a... | python | def dnld_annofile(fin_anno, anno_type):
"""Download annotation file, if needed"""
if os.path.exists(fin_anno):
return
anno_type = get_anno_desc(fin_anno, anno_type)
if anno_type == 'gene2go':
dnld_ncbi_gene_file(fin_anno)
if anno_type in {'gaf', 'gpad'}:
dnld_annotation(fin_a... | [
"def",
"dnld_annofile",
"(",
"fin_anno",
",",
"anno_type",
")",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"fin_anno",
")",
":",
"return",
"anno_type",
"=",
"get_anno_desc",
"(",
"fin_anno",
",",
"anno_type",
")",
"if",
"anno_type",
"==",
"'gene2go'... | Download annotation file, if needed | [
"Download",
"annotation",
"file",
"if",
"needed"
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/associations.py#L87-L95 | train |
tanghaibao/goatools | goatools/associations.py | read_ncbi_gene2go | def read_ncbi_gene2go(fin_gene2go, taxids=None, **kws):
"""Read NCBI's gene2go. Return gene2go data for user-specified taxids."""
obj = Gene2GoReader(fin_gene2go, taxids=taxids)
# By default, return id2gos. User can cause go2geneids to be returned by:
# >>> read_ncbi_gene2go(..., go2geneids=True
i... | python | def read_ncbi_gene2go(fin_gene2go, taxids=None, **kws):
"""Read NCBI's gene2go. Return gene2go data for user-specified taxids."""
obj = Gene2GoReader(fin_gene2go, taxids=taxids)
# By default, return id2gos. User can cause go2geneids to be returned by:
# >>> read_ncbi_gene2go(..., go2geneids=True
i... | [
"def",
"read_ncbi_gene2go",
"(",
"fin_gene2go",
",",
"taxids",
"=",
"None",
",",
"**",
"kws",
")",
":",
"obj",
"=",
"Gene2GoReader",
"(",
"fin_gene2go",
",",
"taxids",
"=",
"taxids",
")",
"if",
"'taxid2asscs'",
"not",
"in",
"kws",
":",
"if",
"len",
"(",
... | Read NCBI's gene2go. Return gene2go data for user-specified taxids. | [
"Read",
"NCBI",
"s",
"gene2go",
".",
"Return",
"gene2go",
"data",
"for",
"user",
"-",
"specified",
"taxids",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/associations.py#L97-L114 | train |
tanghaibao/goatools | goatools/associations.py | get_b2aset | def get_b2aset(a2bset):
"""Given gene2gos, return go2genes. Given go2genes, return gene2gos."""
b2aset = {}
for a_item, bset in a2bset.items():
for b_item in bset:
if b_item in b2aset:
b2aset[b_item].add(a_item)
else:
b2aset[b_item] = set([a_it... | python | def get_b2aset(a2bset):
"""Given gene2gos, return go2genes. Given go2genes, return gene2gos."""
b2aset = {}
for a_item, bset in a2bset.items():
for b_item in bset:
if b_item in b2aset:
b2aset[b_item].add(a_item)
else:
b2aset[b_item] = set([a_it... | [
"def",
"get_b2aset",
"(",
"a2bset",
")",
":",
"b2aset",
"=",
"{",
"}",
"for",
"a_item",
",",
"bset",
"in",
"a2bset",
".",
"items",
"(",
")",
":",
"for",
"b_item",
"in",
"bset",
":",
"if",
"b_item",
"in",
"b2aset",
":",
"b2aset",
"[",
"b_item",
"]",... | Given gene2gos, return go2genes. Given go2genes, return gene2gos. | [
"Given",
"gene2gos",
"return",
"go2genes",
".",
"Given",
"go2genes",
"return",
"gene2gos",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/associations.py#L125-L134 | train |
tanghaibao/goatools | goatools/associations.py | get_assc_pruned | def get_assc_pruned(assc_geneid2gos, min_genecnt=None, max_genecnt=None, prt=sys.stdout):
"""Remove GO IDs associated with large numbers of genes. Used in stochastic simulations."""
# DEFN WAS: get_assc_pruned(assc_geneid2gos, max_genecnt=None, prt=sys.stdout):
# ADDED min_genecnt argument and function... | python | def get_assc_pruned(assc_geneid2gos, min_genecnt=None, max_genecnt=None, prt=sys.stdout):
"""Remove GO IDs associated with large numbers of genes. Used in stochastic simulations."""
# DEFN WAS: get_assc_pruned(assc_geneid2gos, max_genecnt=None, prt=sys.stdout):
# ADDED min_genecnt argument and function... | [
"def",
"get_assc_pruned",
"(",
"assc_geneid2gos",
",",
"min_genecnt",
"=",
"None",
",",
"max_genecnt",
"=",
"None",
",",
"prt",
"=",
"sys",
".",
"stdout",
")",
":",
"if",
"max_genecnt",
"is",
"None",
"and",
"min_genecnt",
"is",
"None",
":",
"return",
"assc... | Remove GO IDs associated with large numbers of genes. Used in stochastic simulations. | [
"Remove",
"GO",
"IDs",
"associated",
"with",
"large",
"numbers",
"of",
"genes",
".",
"Used",
"in",
"stochastic",
"simulations",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/associations.py#L136-L161 | train |
tanghaibao/goatools | goatools/associations.py | read_annotations | def read_annotations(**kws):
"""Read annotations from either a GAF file or NCBI's gene2go file."""
if 'gaf' not in kws and 'gene2go' not in kws:
return
gene2gos = None
if 'gaf' in kws:
gene2gos = read_gaf(kws['gaf'], prt=sys.stdout)
if not gene2gos:
raise RuntimeError... | python | def read_annotations(**kws):
"""Read annotations from either a GAF file or NCBI's gene2go file."""
if 'gaf' not in kws and 'gene2go' not in kws:
return
gene2gos = None
if 'gaf' in kws:
gene2gos = read_gaf(kws['gaf'], prt=sys.stdout)
if not gene2gos:
raise RuntimeError... | [
"def",
"read_annotations",
"(",
"**",
"kws",
")",
":",
"if",
"'gaf'",
"not",
"in",
"kws",
"and",
"'gene2go'",
"not",
"in",
"kws",
":",
"return",
"gene2gos",
"=",
"None",
"if",
"'gaf'",
"in",
"kws",
":",
"gene2gos",
"=",
"read_gaf",
"(",
"kws",
"[",
"... | Read annotations from either a GAF file or NCBI's gene2go file. | [
"Read",
"annotations",
"from",
"either",
"a",
"GAF",
"file",
"or",
"NCBI",
"s",
"gene2go",
"file",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/associations.py#L163-L178 | train |
tanghaibao/goatools | goatools/associations.py | get_tcntobj | def get_tcntobj(go2obj, **kws):
"""Return a TermCounts object if the user provides an annotation file, otherwise None."""
# kws: gaf gene2go
annots = read_annotations(**kws)
if annots:
return TermCounts(go2obj, annots) | python | def get_tcntobj(go2obj, **kws):
"""Return a TermCounts object if the user provides an annotation file, otherwise None."""
# kws: gaf gene2go
annots = read_annotations(**kws)
if annots:
return TermCounts(go2obj, annots) | [
"def",
"get_tcntobj",
"(",
"go2obj",
",",
"**",
"kws",
")",
":",
"annots",
"=",
"read_annotations",
"(",
"**",
"kws",
")",
"if",
"annots",
":",
"return",
"TermCounts",
"(",
"go2obj",
",",
"annots",
")"
] | Return a TermCounts object if the user provides an annotation file, otherwise None. | [
"Return",
"a",
"TermCounts",
"object",
"if",
"the",
"user",
"provides",
"an",
"annotation",
"file",
"otherwise",
"None",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/associations.py#L180-L185 | train |
tanghaibao/goatools | goatools/wr_tbl_class.py | get_hdrs | def get_hdrs(flds_all, **kws):
"""Return headers, given user-specified key-word args."""
# Return Headers if the user explicitly lists them.
hdrs = kws.get('hdrs', None)
if hdrs is not None:
return hdrs
# User may specify a subset of fields or a column order using prt_flds
if 'prt_flds' ... | python | def get_hdrs(flds_all, **kws):
"""Return headers, given user-specified key-word args."""
# Return Headers if the user explicitly lists them.
hdrs = kws.get('hdrs', None)
if hdrs is not None:
return hdrs
# User may specify a subset of fields or a column order using prt_flds
if 'prt_flds' ... | [
"def",
"get_hdrs",
"(",
"flds_all",
",",
"**",
"kws",
")",
":",
"hdrs",
"=",
"kws",
".",
"get",
"(",
"'hdrs'",
",",
"None",
")",
"if",
"hdrs",
"is",
"not",
"None",
":",
"return",
"hdrs",
"if",
"'prt_flds'",
"in",
"kws",
":",
"return",
"kws",
"[",
... | Return headers, given user-specified key-word args. | [
"Return",
"headers",
"given",
"user",
"-",
"specified",
"key",
"-",
"word",
"args",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/wr_tbl_class.py#L218-L228 | train |
tanghaibao/goatools | goatools/wr_tbl_class.py | WrXlsx.wr_row_mergeall | def wr_row_mergeall(self, worksheet, txtstr, fmt, row_idx):
"""Merge all columns and place text string in widened cell."""
hdridxval = len(self.hdrs) - 1
worksheet.merge_range(row_idx, 0, row_idx, hdridxval, txtstr, fmt)
return row_idx + 1 | python | def wr_row_mergeall(self, worksheet, txtstr, fmt, row_idx):
"""Merge all columns and place text string in widened cell."""
hdridxval = len(self.hdrs) - 1
worksheet.merge_range(row_idx, 0, row_idx, hdridxval, txtstr, fmt)
return row_idx + 1 | [
"def",
"wr_row_mergeall",
"(",
"self",
",",
"worksheet",
",",
"txtstr",
",",
"fmt",
",",
"row_idx",
")",
":",
"hdridxval",
"=",
"len",
"(",
"self",
".",
"hdrs",
")",
"-",
"1",
"worksheet",
".",
"merge_range",
"(",
"row_idx",
",",
"0",
",",
"row_idx",
... | Merge all columns and place text string in widened cell. | [
"Merge",
"all",
"columns",
"and",
"place",
"text",
"string",
"in",
"widened",
"cell",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/wr_tbl_class.py#L49-L53 | train |
tanghaibao/goatools | goatools/wr_tbl_class.py | WrXlsx.wr_hdrs | def wr_hdrs(self, worksheet, row_idx):
"""Print row of column headers"""
for col_idx, hdr in enumerate(self.hdrs):
# print("ROW({R}) COL({C}) HDR({H}) FMT({F})\n".format(
# R=row_idx, C=col_idx, H=hdr, F=self.fmt_hdr))
worksheet.write(row_idx, col_idx, hdr, self.f... | python | def wr_hdrs(self, worksheet, row_idx):
"""Print row of column headers"""
for col_idx, hdr in enumerate(self.hdrs):
# print("ROW({R}) COL({C}) HDR({H}) FMT({F})\n".format(
# R=row_idx, C=col_idx, H=hdr, F=self.fmt_hdr))
worksheet.write(row_idx, col_idx, hdr, self.f... | [
"def",
"wr_hdrs",
"(",
"self",
",",
"worksheet",
",",
"row_idx",
")",
":",
"for",
"col_idx",
",",
"hdr",
"in",
"enumerate",
"(",
"self",
".",
"hdrs",
")",
":",
"worksheet",
".",
"write",
"(",
"row_idx",
",",
"col_idx",
",",
"hdr",
",",
"self",
".",
... | Print row of column headers | [
"Print",
"row",
"of",
"column",
"headers"
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/wr_tbl_class.py#L55-L62 | train |
tanghaibao/goatools | goatools/wr_tbl_class.py | WrXlsx.wr_data | def wr_data(self, xlsx_data, row_i, worksheet):
"""Write data into xlsx worksheet."""
fld2fmt = self.vars.fld2fmt
# User may specify to skip rows based on values in row
prt_if = self.vars.prt_if
# User may specify a subset of columns to print or
# a column ordering differ... | python | def wr_data(self, xlsx_data, row_i, worksheet):
"""Write data into xlsx worksheet."""
fld2fmt = self.vars.fld2fmt
# User may specify to skip rows based on values in row
prt_if = self.vars.prt_if
# User may specify a subset of columns to print or
# a column ordering differ... | [
"def",
"wr_data",
"(",
"self",
",",
"xlsx_data",
",",
"row_i",
",",
"worksheet",
")",
":",
"fld2fmt",
"=",
"self",
".",
"vars",
".",
"fld2fmt",
"prt_if",
"=",
"self",
".",
"vars",
".",
"prt_if",
"prt_flds",
"=",
"self",
".",
"wbfmtobj",
".",
"get_prt_f... | Write data into xlsx worksheet. | [
"Write",
"data",
"into",
"xlsx",
"worksheet",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/wr_tbl_class.py#L64-L97 | train |
tanghaibao/goatools | goatools/wr_tbl_class.py | WrXlsx._get_err_msg | def _get_err_msg(row, col, fld, val, prt_flds):
"""Return an informative message with details of xlsx write attempt."""
import traceback
traceback.print_exc()
err_msg = (
"ROW({R}) COL({C}) FIELD({F}) VAL({V})\n".format(R=row, C=col, F=fld, V=val),
"PRINT FIELDS({... | python | def _get_err_msg(row, col, fld, val, prt_flds):
"""Return an informative message with details of xlsx write attempt."""
import traceback
traceback.print_exc()
err_msg = (
"ROW({R}) COL({C}) FIELD({F}) VAL({V})\n".format(R=row, C=col, F=fld, V=val),
"PRINT FIELDS({... | [
"def",
"_get_err_msg",
"(",
"row",
",",
"col",
",",
"fld",
",",
"val",
",",
"prt_flds",
")",
":",
"import",
"traceback",
"traceback",
".",
"print_exc",
"(",
")",
"err_msg",
"=",
"(",
"\"ROW({R}) COL({C}) FIELD({F}) VAL({V})\\n\"",
".",
"format",
"(",
"R",
"=... | Return an informative message with details of xlsx write attempt. | [
"Return",
"an",
"informative",
"message",
"with",
"details",
"of",
"xlsx",
"write",
"attempt",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/wr_tbl_class.py#L100-L107 | train |
tanghaibao/goatools | goatools/wr_tbl_class.py | WrXlsx.add_worksheet | def add_worksheet(self):
"""Add a worksheet to the workbook."""
wsh = self.workbook.add_worksheet()
if self.vars.fld2col_widths is not None:
self.set_xlsx_colwidths(wsh, self.vars.fld2col_widths, self.wbfmtobj.get_prt_flds())
return wsh | python | def add_worksheet(self):
"""Add a worksheet to the workbook."""
wsh = self.workbook.add_worksheet()
if self.vars.fld2col_widths is not None:
self.set_xlsx_colwidths(wsh, self.vars.fld2col_widths, self.wbfmtobj.get_prt_flds())
return wsh | [
"def",
"add_worksheet",
"(",
"self",
")",
":",
"wsh",
"=",
"self",
".",
"workbook",
".",
"add_worksheet",
"(",
")",
"if",
"self",
".",
"vars",
".",
"fld2col_widths",
"is",
"not",
"None",
":",
"self",
".",
"set_xlsx_colwidths",
"(",
"wsh",
",",
"self",
... | Add a worksheet to the workbook. | [
"Add",
"a",
"worksheet",
"to",
"the",
"workbook",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/wr_tbl_class.py#L109-L114 | train |
tanghaibao/goatools | goatools/wr_tbl_class.py | WrXlsx.set_xlsx_colwidths | def set_xlsx_colwidths(worksheet, fld2col_widths, fldnames):
"""Set xlsx column widths using fld2col_widths."""
for col_idx, fld in enumerate(fldnames):
col_width = fld2col_widths.get(fld, None)
if col_width is not None:
worksheet.set_column(col_idx, col_idx, col_... | python | def set_xlsx_colwidths(worksheet, fld2col_widths, fldnames):
"""Set xlsx column widths using fld2col_widths."""
for col_idx, fld in enumerate(fldnames):
col_width = fld2col_widths.get(fld, None)
if col_width is not None:
worksheet.set_column(col_idx, col_idx, col_... | [
"def",
"set_xlsx_colwidths",
"(",
"worksheet",
",",
"fld2col_widths",
",",
"fldnames",
")",
":",
"for",
"col_idx",
",",
"fld",
"in",
"enumerate",
"(",
"fldnames",
")",
":",
"col_width",
"=",
"fld2col_widths",
".",
"get",
"(",
"fld",
",",
"None",
")",
"if",... | Set xlsx column widths using fld2col_widths. | [
"Set",
"xlsx",
"column",
"widths",
"using",
"fld2col_widths",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/wr_tbl_class.py#L117-L122 | train |
tanghaibao/goatools | goatools/wr_tbl_class.py | WbFmt.get_hdrs | def get_hdrs(self, **kws):
"""Initialize column headers."""
hdrs = get_hdrs(self.prt_flds, **kws)
# Values in a "format_txt" "column" are used for formatting, not printing
return [h for h in hdrs if h != "format_txt"] | python | def get_hdrs(self, **kws):
"""Initialize column headers."""
hdrs = get_hdrs(self.prt_flds, **kws)
# Values in a "format_txt" "column" are used for formatting, not printing
return [h for h in hdrs if h != "format_txt"] | [
"def",
"get_hdrs",
"(",
"self",
",",
"**",
"kws",
")",
":",
"hdrs",
"=",
"get_hdrs",
"(",
"self",
".",
"prt_flds",
",",
"**",
"kws",
")",
"return",
"[",
"h",
"for",
"h",
"in",
"hdrs",
"if",
"h",
"!=",
"\"format_txt\"",
"]"
] | Initialize column headers. | [
"Initialize",
"column",
"headers",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/wr_tbl_class.py#L149-L153 | train |
tanghaibao/goatools | goatools/wr_tbl_class.py | WbFmt._init_fmtname2wbfmtobj | def _init_fmtname2wbfmtobj(self, workbook, **kws):
"""Initialize fmtname2wbfmtobj."""
wbfmtdict = [
kws.get('format_txt0', self.dflt_wbfmtdict[0]),
kws.get('format_txt1', self.dflt_wbfmtdict[1]),
kws.get('format_txt2', self.dflt_wbfmtdict[2]),
kws.get('for... | python | def _init_fmtname2wbfmtobj(self, workbook, **kws):
"""Initialize fmtname2wbfmtobj."""
wbfmtdict = [
kws.get('format_txt0', self.dflt_wbfmtdict[0]),
kws.get('format_txt1', self.dflt_wbfmtdict[1]),
kws.get('format_txt2', self.dflt_wbfmtdict[2]),
kws.get('for... | [
"def",
"_init_fmtname2wbfmtobj",
"(",
"self",
",",
"workbook",
",",
"**",
"kws",
")",
":",
"wbfmtdict",
"=",
"[",
"kws",
".",
"get",
"(",
"'format_txt0'",
",",
"self",
".",
"dflt_wbfmtdict",
"[",
"0",
"]",
")",
",",
"kws",
".",
"get",
"(",
"'format_txt... | Initialize fmtname2wbfmtobj. | [
"Initialize",
"fmtname2wbfmtobj",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/wr_tbl_class.py#L155-L174 | train |
tanghaibao/goatools | goatools/wr_tbl_class.py | WbFmt.get_wbfmt | def get_wbfmt(self, data_nt=None):
"""Return format for text cell."""
if data_nt is None or self.b_plain:
return self.fmtname2wbfmtobj.get('plain')
# User namedtuple field/value for color
if self.ntfld_wbfmt is not None:
return self.__get_wbfmt_usrfld(data_nt)
... | python | def get_wbfmt(self, data_nt=None):
"""Return format for text cell."""
if data_nt is None or self.b_plain:
return self.fmtname2wbfmtobj.get('plain')
# User namedtuple field/value for color
if self.ntfld_wbfmt is not None:
return self.__get_wbfmt_usrfld(data_nt)
... | [
"def",
"get_wbfmt",
"(",
"self",
",",
"data_nt",
"=",
"None",
")",
":",
"if",
"data_nt",
"is",
"None",
"or",
"self",
".",
"b_plain",
":",
"return",
"self",
".",
"fmtname2wbfmtobj",
".",
"get",
"(",
"'plain'",
")",
"if",
"self",
".",
"ntfld_wbfmt",
"is"... | Return format for text cell. | [
"Return",
"format",
"for",
"text",
"cell",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/wr_tbl_class.py#L176-L190 | train |
tanghaibao/goatools | goatools/wr_tbl_class.py | WbFmt.__get_wbfmt_usrfld | def __get_wbfmt_usrfld(self, data_nt):
"""Return format for text cell from namedtuple field specified by 'ntfld_wbfmt'"""
if self.ntfld_wbfmt is not None:
if isinstance(self.ntfld_wbfmt, str):
ntval = getattr(data_nt, self.ntfld_wbfmt, None) # Ex: 'section'
if... | python | def __get_wbfmt_usrfld(self, data_nt):
"""Return format for text cell from namedtuple field specified by 'ntfld_wbfmt'"""
if self.ntfld_wbfmt is not None:
if isinstance(self.ntfld_wbfmt, str):
ntval = getattr(data_nt, self.ntfld_wbfmt, None) # Ex: 'section'
if... | [
"def",
"__get_wbfmt_usrfld",
"(",
"self",
",",
"data_nt",
")",
":",
"if",
"self",
".",
"ntfld_wbfmt",
"is",
"not",
"None",
":",
"if",
"isinstance",
"(",
"self",
".",
"ntfld_wbfmt",
",",
"str",
")",
":",
"ntval",
"=",
"getattr",
"(",
"data_nt",
",",
"se... | Return format for text cell from namedtuple field specified by 'ntfld_wbfmt | [
"Return",
"format",
"for",
"text",
"cell",
"from",
"namedtuple",
"field",
"specified",
"by",
"ntfld_wbfmt"
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/wr_tbl_class.py#L192-L198 | train |
tanghaibao/goatools | goatools/wr_tbl_class.py | WbFmt.__get_wbfmt_format_txt | def __get_wbfmt_format_txt(self, data_nt):
"""Return format for text cell from namedtuple field, 'format_txt'."""
format_txt_val = getattr(data_nt, "format_txt")
if format_txt_val == 1:
return self.fmtname2wbfmtobj.get("very light grey")
if format_txt_val == 2:
re... | python | def __get_wbfmt_format_txt(self, data_nt):
"""Return format for text cell from namedtuple field, 'format_txt'."""
format_txt_val = getattr(data_nt, "format_txt")
if format_txt_val == 1:
return self.fmtname2wbfmtobj.get("very light grey")
if format_txt_val == 2:
re... | [
"def",
"__get_wbfmt_format_txt",
"(",
"self",
",",
"data_nt",
")",
":",
"format_txt_val",
"=",
"getattr",
"(",
"data_nt",
",",
"\"format_txt\"",
")",
"if",
"format_txt_val",
"==",
"1",
":",
"return",
"self",
".",
"fmtname2wbfmtobj",
".",
"get",
"(",
"\"very li... | Return format for text cell from namedtuple field, 'format_txt'. | [
"Return",
"format",
"for",
"text",
"cell",
"from",
"namedtuple",
"field",
"format_txt",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/wr_tbl_class.py#L202-L209 | train |
tanghaibao/goatools | goatools/wr_tbl_class.py | WbFmt.get_fmt_section | def get_fmt_section(self):
"""Grey if printing header GOs and plain if not printing header GOs."""
if self.b_format_txt:
return self.fmtname2wbfmtobj.get("light grey")
return self.fmtname2wbfmtobj.get("plain bold") | python | def get_fmt_section(self):
"""Grey if printing header GOs and plain if not printing header GOs."""
if self.b_format_txt:
return self.fmtname2wbfmtobj.get("light grey")
return self.fmtname2wbfmtobj.get("plain bold") | [
"def",
"get_fmt_section",
"(",
"self",
")",
":",
"if",
"self",
".",
"b_format_txt",
":",
"return",
"self",
".",
"fmtname2wbfmtobj",
".",
"get",
"(",
"\"light grey\"",
")",
"return",
"self",
".",
"fmtname2wbfmtobj",
".",
"get",
"(",
"\"plain bold\"",
")"
] | Grey if printing header GOs and plain if not printing header GOs. | [
"Grey",
"if",
"printing",
"header",
"GOs",
"and",
"plain",
"if",
"not",
"printing",
"header",
"GOs",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/wr_tbl_class.py#L211-L215 | train |
tanghaibao/goatools | goatools/anno/genetogo_reader.py | Gene2GoReader.get_id2gos | def get_id2gos(self, **kws):
#### def get_annotations_dct(self, taxid, options):
"""Return geneid2gos, or optionally go2geneids."""
if len(self.taxid2asscs) == 1:
taxid = next(iter(self.taxid2asscs.keys()))
return self._get_id2gos(self.taxid2asscs[taxid], **kws)
asser... | python | def get_id2gos(self, **kws):
#### def get_annotations_dct(self, taxid, options):
"""Return geneid2gos, or optionally go2geneids."""
if len(self.taxid2asscs) == 1:
taxid = next(iter(self.taxid2asscs.keys()))
return self._get_id2gos(self.taxid2asscs[taxid], **kws)
asser... | [
"def",
"get_id2gos",
"(",
"self",
",",
"**",
"kws",
")",
":",
"if",
"len",
"(",
"self",
".",
"taxid2asscs",
")",
"==",
"1",
":",
"taxid",
"=",
"next",
"(",
"iter",
"(",
"self",
".",
"taxid2asscs",
".",
"keys",
"(",
")",
")",
")",
"return",
"self"... | Return geneid2gos, or optionally go2geneids. | [
"Return",
"geneid2gos",
"or",
"optionally",
"go2geneids",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/anno/genetogo_reader.py#L28-L37 | train |
tanghaibao/goatools | goatools/anno/genetogo_reader.py | Gene2GoReader.get_name | def get_name(self):
"""Get name using taxid"""
if len(self.taxid2asscs) == 1:
return '{BASE}_{TAXID}'.format(
BASE=self.name, TAXID=next(iter(self.taxid2asscs.keys())))
return '{BASE}_various'.format(BASE=self.name) | python | def get_name(self):
"""Get name using taxid"""
if len(self.taxid2asscs) == 1:
return '{BASE}_{TAXID}'.format(
BASE=self.name, TAXID=next(iter(self.taxid2asscs.keys())))
return '{BASE}_various'.format(BASE=self.name) | [
"def",
"get_name",
"(",
"self",
")",
":",
"if",
"len",
"(",
"self",
".",
"taxid2asscs",
")",
"==",
"1",
":",
"return",
"'{BASE}_{TAXID}'",
".",
"format",
"(",
"BASE",
"=",
"self",
".",
"name",
",",
"TAXID",
"=",
"next",
"(",
"iter",
"(",
"self",
".... | Get name using taxid | [
"Get",
"name",
"using",
"taxid"
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/anno/genetogo_reader.py#L39-L44 | train |
tanghaibao/goatools | goatools/anno/genetogo_reader.py | Gene2GoReader.get_taxid | def get_taxid(self):
"""Return taxid, if one was provided. Other wise return True representing all taxids"""
return next(iter(self.taxid2asscs.keys())) if len(self.taxid2asscs) == 1 else True | python | def get_taxid(self):
"""Return taxid, if one was provided. Other wise return True representing all taxids"""
return next(iter(self.taxid2asscs.keys())) if len(self.taxid2asscs) == 1 else True | [
"def",
"get_taxid",
"(",
"self",
")",
":",
"return",
"next",
"(",
"iter",
"(",
"self",
".",
"taxid2asscs",
".",
"keys",
"(",
")",
")",
")",
"if",
"len",
"(",
"self",
".",
"taxid2asscs",
")",
"==",
"1",
"else",
"True"
] | Return taxid, if one was provided. Other wise return True representing all taxids | [
"Return",
"taxid",
"if",
"one",
"was",
"provided",
".",
"Other",
"wise",
"return",
"True",
"representing",
"all",
"taxids"
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/anno/genetogo_reader.py#L46-L48 | train |
tanghaibao/goatools | goatools/anno/genetogo_reader.py | Gene2GoReader.fill_taxid2asscs | def fill_taxid2asscs(taxid2asscs_usr, taxid2asscs_ret):
"""Fill user taxid2asscs for backward compatibility."""
for taxid, ab_ret in taxid2asscs_ret.items():
taxid2asscs_usr[taxid]['ID2GOs'] = ab_ret['ID2GOs']
taxid2asscs_usr[taxid]['GO2IDs'] = ab_ret['GO2IDs'] | python | def fill_taxid2asscs(taxid2asscs_usr, taxid2asscs_ret):
"""Fill user taxid2asscs for backward compatibility."""
for taxid, ab_ret in taxid2asscs_ret.items():
taxid2asscs_usr[taxid]['ID2GOs'] = ab_ret['ID2GOs']
taxid2asscs_usr[taxid]['GO2IDs'] = ab_ret['GO2IDs'] | [
"def",
"fill_taxid2asscs",
"(",
"taxid2asscs_usr",
",",
"taxid2asscs_ret",
")",
":",
"for",
"taxid",
",",
"ab_ret",
"in",
"taxid2asscs_ret",
".",
"items",
"(",
")",
":",
"taxid2asscs_usr",
"[",
"taxid",
"]",
"[",
"'ID2GOs'",
"]",
"=",
"ab_ret",
"[",
"'ID2GOs... | Fill user taxid2asscs for backward compatibility. | [
"Fill",
"user",
"taxid2asscs",
"for",
"backward",
"compatibility",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/anno/genetogo_reader.py#L64-L68 | train |
tanghaibao/goatools | goatools/anno/genetogo_reader.py | Gene2GoReader._get_taxids | def _get_taxids(self, taxids=None):
"""Return user-specified taxids or taxids in self.taxid2asscs"""
taxid_keys = set(self.taxid2asscs.keys())
return taxid_keys if taxids is None else set(taxids).intersection(taxid_keys) | python | def _get_taxids(self, taxids=None):
"""Return user-specified taxids or taxids in self.taxid2asscs"""
taxid_keys = set(self.taxid2asscs.keys())
return taxid_keys if taxids is None else set(taxids).intersection(taxid_keys) | [
"def",
"_get_taxids",
"(",
"self",
",",
"taxids",
"=",
"None",
")",
":",
"taxid_keys",
"=",
"set",
"(",
"self",
".",
"taxid2asscs",
".",
"keys",
"(",
")",
")",
"return",
"taxid_keys",
"if",
"taxids",
"is",
"None",
"else",
"set",
"(",
"taxids",
")",
"... | Return user-specified taxids or taxids in self.taxid2asscs | [
"Return",
"user",
"-",
"specified",
"taxids",
"or",
"taxids",
"in",
"self",
".",
"taxid2asscs"
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/anno/genetogo_reader.py#L79-L82 | train |
tanghaibao/goatools | goatools/anno/genetogo_reader.py | Gene2GoReader._init_taxid2asscs | def _init_taxid2asscs(self):
"""Create dict with taxid keys and annotation namedtuple list."""
taxid2asscs = cx.defaultdict(list)
for ntanno in self.associations:
taxid2asscs[ntanno.tax_id].append(ntanno)
assert len(taxid2asscs) != 0, "**FATAL: NO TAXIDS: {F}".format(F=self.f... | python | def _init_taxid2asscs(self):
"""Create dict with taxid keys and annotation namedtuple list."""
taxid2asscs = cx.defaultdict(list)
for ntanno in self.associations:
taxid2asscs[ntanno.tax_id].append(ntanno)
assert len(taxid2asscs) != 0, "**FATAL: NO TAXIDS: {F}".format(F=self.f... | [
"def",
"_init_taxid2asscs",
"(",
"self",
")",
":",
"taxid2asscs",
"=",
"cx",
".",
"defaultdict",
"(",
"list",
")",
"for",
"ntanno",
"in",
"self",
".",
"associations",
":",
"taxid2asscs",
"[",
"ntanno",
".",
"tax_id",
"]",
".",
"append",
"(",
"ntanno",
")... | Create dict with taxid keys and annotation namedtuple list. | [
"Create",
"dict",
"with",
"taxid",
"keys",
"and",
"annotation",
"namedtuple",
"list",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/anno/genetogo_reader.py#L90-L103 | train |
tanghaibao/goatools | goatools/grouper/plotobj.py | PltGroupedGosArgs.get_go2color_inst | def get_go2color_inst(self, hdrgo):
"""Get a copy of go2color with GO group header colored."""
go2color = self.go2color.copy()
go2color[hdrgo] = self.hdrgo_dflt_color
return go2color | python | def get_go2color_inst(self, hdrgo):
"""Get a copy of go2color with GO group header colored."""
go2color = self.go2color.copy()
go2color[hdrgo] = self.hdrgo_dflt_color
return go2color | [
"def",
"get_go2color_inst",
"(",
"self",
",",
"hdrgo",
")",
":",
"go2color",
"=",
"self",
".",
"go2color",
".",
"copy",
"(",
")",
"go2color",
"[",
"hdrgo",
"]",
"=",
"self",
".",
"hdrgo_dflt_color",
"return",
"go2color"
] | Get a copy of go2color with GO group header colored. | [
"Get",
"a",
"copy",
"of",
"go2color",
"with",
"GO",
"group",
"header",
"colored",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/plotobj.py#L38-L42 | train |
tanghaibao/goatools | goatools/grouper/plotobj.py | PltGroupedGosArgs.get_kws_plt | def get_kws_plt(self):
"""Get keyword args for GoSubDagPlot from self unless they are None."""
kws_plt = {}
for key_plt in self.keys_plt:
key_val = getattr(self, key_plt, None)
if key_val is not None:
kws_plt[key_plt] = key_val
elif key_plt in ... | python | def get_kws_plt(self):
"""Get keyword args for GoSubDagPlot from self unless they are None."""
kws_plt = {}
for key_plt in self.keys_plt:
key_val = getattr(self, key_plt, None)
if key_val is not None:
kws_plt[key_plt] = key_val
elif key_plt in ... | [
"def",
"get_kws_plt",
"(",
"self",
")",
":",
"kws_plt",
"=",
"{",
"}",
"for",
"key_plt",
"in",
"self",
".",
"keys_plt",
":",
"key_val",
"=",
"getattr",
"(",
"self",
",",
"key_plt",
",",
"None",
")",
"if",
"key_val",
"is",
"not",
"None",
":",
"kws_plt... | Get keyword args for GoSubDagPlot from self unless they are None. | [
"Get",
"keyword",
"args",
"for",
"GoSubDagPlot",
"from",
"self",
"unless",
"they",
"are",
"None",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/plotobj.py#L44-L53 | train |
tanghaibao/goatools | goatools/grouper/plotobj.py | PltGroupedGosArgs._init_go2bordercolor | def _init_go2bordercolor(objcolors, **kws):
"""Initialize go2bordercolor with default to make hdrgos bright blue."""
go2bordercolor_ret = objcolors.get_bordercolor()
if 'go2bordercolor' not in kws:
return go2bordercolor_ret
go2bordercolor_usr = kws['go2bordercolor']
g... | python | def _init_go2bordercolor(objcolors, **kws):
"""Initialize go2bordercolor with default to make hdrgos bright blue."""
go2bordercolor_ret = objcolors.get_bordercolor()
if 'go2bordercolor' not in kws:
return go2bordercolor_ret
go2bordercolor_usr = kws['go2bordercolor']
g... | [
"def",
"_init_go2bordercolor",
"(",
"objcolors",
",",
"**",
"kws",
")",
":",
"go2bordercolor_ret",
"=",
"objcolors",
".",
"get_bordercolor",
"(",
")",
"if",
"'go2bordercolor'",
"not",
"in",
"kws",
":",
"return",
"go2bordercolor_ret",
"go2bordercolor_usr",
"=",
"kw... | Initialize go2bordercolor with default to make hdrgos bright blue. | [
"Initialize",
"go2bordercolor",
"with",
"default",
"to",
"make",
"hdrgos",
"bright",
"blue",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/plotobj.py#L56-L65 | train |
tanghaibao/goatools | goatools/grouper/plotobj.py | PltGroupedGos.plot_groups_unplaced | def plot_groups_unplaced(self, fout_dir=".", **kws_pltargs):
"""Plot GO DAGs for groups of user GOs which are not in a section."""
hdrgos = self.grprobj.get_hdrgos_unplaced()
pltargs = PltGroupedGosArgs(self.grprobj, fout_dir=fout_dir, **kws_pltargs)
return self._plot_groups_hdrgos(hdrgo... | python | def plot_groups_unplaced(self, fout_dir=".", **kws_pltargs):
"""Plot GO DAGs for groups of user GOs which are not in a section."""
hdrgos = self.grprobj.get_hdrgos_unplaced()
pltargs = PltGroupedGosArgs(self.grprobj, fout_dir=fout_dir, **kws_pltargs)
return self._plot_groups_hdrgos(hdrgo... | [
"def",
"plot_groups_unplaced",
"(",
"self",
",",
"fout_dir",
"=",
"\".\"",
",",
"**",
"kws_pltargs",
")",
":",
"hdrgos",
"=",
"self",
".",
"grprobj",
".",
"get_hdrgos_unplaced",
"(",
")",
"pltargs",
"=",
"PltGroupedGosArgs",
"(",
"self",
".",
"grprobj",
",",... | Plot GO DAGs for groups of user GOs which are not in a section. | [
"Plot",
"GO",
"DAGs",
"for",
"groups",
"of",
"user",
"GOs",
"which",
"are",
"not",
"in",
"a",
"section",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/plotobj.py#L92-L96 | train |
tanghaibao/goatools | goatools/grouper/plotobj.py | PltGroupedGos._get_plt_data | def _get_plt_data(self, hdrgos_usr):
"""Given User GO IDs, return their GO headers and other GO info."""
hdrgo2usrgos = self.grprobj.get_hdrgo2usrgos(hdrgos_usr)
usrgos_actual = set([u for us in hdrgo2usrgos.values() for u in us])
go2obj = self.gosubdag.get_go2obj(usrgos_actual.union(hdr... | python | def _get_plt_data(self, hdrgos_usr):
"""Given User GO IDs, return their GO headers and other GO info."""
hdrgo2usrgos = self.grprobj.get_hdrgo2usrgos(hdrgos_usr)
usrgos_actual = set([u for us in hdrgo2usrgos.values() for u in us])
go2obj = self.gosubdag.get_go2obj(usrgos_actual.union(hdr... | [
"def",
"_get_plt_data",
"(",
"self",
",",
"hdrgos_usr",
")",
":",
"hdrgo2usrgos",
"=",
"self",
".",
"grprobj",
".",
"get_hdrgo2usrgos",
"(",
"hdrgos_usr",
")",
"usrgos_actual",
"=",
"set",
"(",
"[",
"u",
"for",
"us",
"in",
"hdrgo2usrgos",
".",
"values",
"(... | Given User GO IDs, return their GO headers and other GO info. | [
"Given",
"User",
"GO",
"IDs",
"return",
"their",
"GO",
"headers",
"and",
"other",
"GO",
"info",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/plotobj.py#L103-L108 | train |
tanghaibao/goatools | goatools/grouper/plotobj.py | PltGroupedGos._plot_go_group | def _plot_go_group(self, hdrgo, usrgos, pltargs, go2parentids):
"""Plot an exploratory GO DAG for a single Group of user GOs."""
gosubdagplotnts = self._get_gosubdagplotnts(hdrgo, usrgos, pltargs, go2parentids)
# Create pngs and return png names
pngs = [obj.wrplt(pltargs.fout_dir, pltarg... | python | def _plot_go_group(self, hdrgo, usrgos, pltargs, go2parentids):
"""Plot an exploratory GO DAG for a single Group of user GOs."""
gosubdagplotnts = self._get_gosubdagplotnts(hdrgo, usrgos, pltargs, go2parentids)
# Create pngs and return png names
pngs = [obj.wrplt(pltargs.fout_dir, pltarg... | [
"def",
"_plot_go_group",
"(",
"self",
",",
"hdrgo",
",",
"usrgos",
",",
"pltargs",
",",
"go2parentids",
")",
":",
"gosubdagplotnts",
"=",
"self",
".",
"_get_gosubdagplotnts",
"(",
"hdrgo",
",",
"usrgos",
",",
"pltargs",
",",
"go2parentids",
")",
"pngs",
"=",... | Plot an exploratory GO DAG for a single Group of user GOs. | [
"Plot",
"an",
"exploratory",
"GO",
"DAG",
"for",
"a",
"single",
"Group",
"of",
"user",
"GOs",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/plotobj.py#L150-L155 | train |
tanghaibao/goatools | goatools/grouper/plotobj.py | PltGroupedGos._get_dotgraphs | def _get_dotgraphs(self, hdrgo, usrgos, pltargs, go2parentids):
"""Get a GO DAG in a dot-language string for a single Group of user GOs."""
gosubdagplotnts = self._get_gosubdagplotnts(hdrgo, usrgos, pltargs, go2parentids)
# Create DAG graphs as dot language strings. Loop through GoSubDagPlotNt l... | python | def _get_dotgraphs(self, hdrgo, usrgos, pltargs, go2parentids):
"""Get a GO DAG in a dot-language string for a single Group of user GOs."""
gosubdagplotnts = self._get_gosubdagplotnts(hdrgo, usrgos, pltargs, go2parentids)
# Create DAG graphs as dot language strings. Loop through GoSubDagPlotNt l... | [
"def",
"_get_dotgraphs",
"(",
"self",
",",
"hdrgo",
",",
"usrgos",
",",
"pltargs",
",",
"go2parentids",
")",
":",
"gosubdagplotnts",
"=",
"self",
".",
"_get_gosubdagplotnts",
"(",
"hdrgo",
",",
"usrgos",
",",
"pltargs",
",",
"go2parentids",
")",
"dotstrs",
"... | Get a GO DAG in a dot-language string for a single Group of user GOs. | [
"Get",
"a",
"GO",
"DAG",
"in",
"a",
"dot",
"-",
"language",
"string",
"for",
"a",
"single",
"Group",
"of",
"user",
"GOs",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/plotobj.py#L157-L162 | train |
tanghaibao/goatools | goatools/grouper/plotobj.py | PltGroupedGos._get_gosubdagplotnts | def _get_gosubdagplotnts(self, hdrgo, usrgos, pltargs, go2parentids):
"""Get list of GoSubDagPlotNt for plotting an exploratory GODAG for 1 Group of user GOs."""
dotgraphs = []
go2color = pltargs.get_go2color_inst(hdrgo)
# namedtuple fields: hdrgo gosubdag tot_usrgos parentcnt desc
... | python | def _get_gosubdagplotnts(self, hdrgo, usrgos, pltargs, go2parentids):
"""Get list of GoSubDagPlotNt for plotting an exploratory GODAG for 1 Group of user GOs."""
dotgraphs = []
go2color = pltargs.get_go2color_inst(hdrgo)
# namedtuple fields: hdrgo gosubdag tot_usrgos parentcnt desc
... | [
"def",
"_get_gosubdagplotnts",
"(",
"self",
",",
"hdrgo",
",",
"usrgos",
",",
"pltargs",
",",
"go2parentids",
")",
":",
"dotgraphs",
"=",
"[",
"]",
"go2color",
"=",
"pltargs",
".",
"get_go2color_inst",
"(",
"hdrgo",
")",
"ntpltgo0",
"=",
"self",
".",
"_get... | Get list of GoSubDagPlotNt for plotting an exploratory GODAG for 1 Group of user GOs. | [
"Get",
"list",
"of",
"GoSubDagPlotNt",
"for",
"plotting",
"an",
"exploratory",
"GODAG",
"for",
"1",
"Group",
"of",
"user",
"GOs",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/plotobj.py#L164-L205 | train |
tanghaibao/goatools | goatools/grouper/plotobj.py | PltGroupedGos._get_gos_upper | def _get_gos_upper(self, ntpltgo1, max_upper, go2parentids):
"""Plot a GO DAG for the upper portion of a single Group of user GOs."""
# Get GO IDs which are in the hdrgo path
goids_possible = ntpltgo1.gosubdag.go2obj.keys()
# Get upper GO IDs which have the most descendants
retur... | python | def _get_gos_upper(self, ntpltgo1, max_upper, go2parentids):
"""Plot a GO DAG for the upper portion of a single Group of user GOs."""
# Get GO IDs which are in the hdrgo path
goids_possible = ntpltgo1.gosubdag.go2obj.keys()
# Get upper GO IDs which have the most descendants
retur... | [
"def",
"_get_gos_upper",
"(",
"self",
",",
"ntpltgo1",
",",
"max_upper",
",",
"go2parentids",
")",
":",
"goids_possible",
"=",
"ntpltgo1",
".",
"gosubdag",
".",
"go2obj",
".",
"keys",
"(",
")",
"return",
"self",
".",
"_get_gosrcs_upper",
"(",
"goids_possible",... | Plot a GO DAG for the upper portion of a single Group of user GOs. | [
"Plot",
"a",
"GO",
"DAG",
"for",
"the",
"upper",
"portion",
"of",
"a",
"single",
"Group",
"of",
"user",
"GOs",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/plotobj.py#L207-L212 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.