id int32 0 252k | repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 |
|---|---|---|---|---|---|---|---|---|---|---|---|
228,400 | 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",
")",
":",
"# Get the number of significant GO terms",
"ctr",
"=",
"cx",
".",
"Counter",
"(",
")",
"flds",
"=",
"set",
"(",
"[",
"'FDR'",
",",
"'Bonferroni'",
",",
"'Benjamini'",
",",
"'PValue'",
... | 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 |
228,401 | 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 |
228,402 | 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",
"]",
"# pylint: disable=bad-whitespace",
"return",
"self",
".",
"ntobj",
"(",
"Category",
"=",
"flds",
"[",
"0",
"]",
",",
... | 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 |
228,403 | 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 |
228,404 | 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",
")",
":",
"# 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",
"extstr",
":",
"return",
"No... | 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 |
228,405 | 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 |
228,406 | 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 |
228,407 | 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 |
228,408 | 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 |
228,409 | 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 |
228,410 | 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",
")",
":",
"# kws get_objanno: taxids hdr_only prt allow_missing_symbol",
"obj",
"=",
"get_objanno",
"(",
"assoc_fn",
",",
"anno_type",
",",
"*",
"*",
"kws",
")",
... | Return associatinos in id2gos format | [
"Return",
"associatinos",
"in",
"id2gos",
"format"
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/associations.py#L49-L54 |
228,411 | 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 |
228,412 | 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 |
228,413 | 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",
")",
"# By default, return id2gos. User can cause go2geneids to be returned by:",... | 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 |
228,414 | 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 |
228,415 | 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",
")",
":",
"# DEFN WAS: get_assc_pruned(assc_geneid2gos, max_genecnt=None, prt=sys.stdout):",
"# ADDED min_genecnt ... | 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 |
228,416 | 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 |
228,417 | 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",
")",
":",
"# kws: gaf gene2go",
"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 |
228,418 | 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",
")",
":",
"# Return Headers if the user explicitly lists them.",
"hdrs",
"=",
"kws",
".",
"get",
"(",
"'hdrs'",
",",
"None",
")",
"if",
"hdrs",
"is",
"not",
"None",
":",
"return",
"hdrs",
"# User may ... | 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 |
228,419 | 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 |
228,420 | 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",
")",
":",
"# print(\"ROW({R}) COL({C}) HDR({H}) FMT({F})\\n\".format(",
"# R=row_idx, C=col_idx, H=hdr, F=self.fmt_h... | 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 |
228,421 | 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",
"# User may specify to skip rows based on values in row",
"prt_if",
"=",
"self",
".",
"vars",
".",
"prt_if",
"# User m... | 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 |
228,422 | 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 |
228,423 | 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 |
228,424 | 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 |
228,425 | 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",
")",
"# Values in a \"format_txt\" \"column\" are used for formatting, not printing",
"return",
"[",
"h",
"for",
"h",
"... | Initialize column headers. | [
"Initialize",
"column",
"headers",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/wr_tbl_class.py#L149-L153 |
228,426 | 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",
"(",
"'form... | Initialize fmtname2wbfmtobj. | [
"Initialize",
"fmtname2wbfmtobj",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/wr_tbl_class.py#L155-L174 |
228,427 | 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'",
")",
"# User namedtuple field/value for color",
"... | 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 |
228,428 | 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 |
228,429 | 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 |
228,430 | 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 |
228,431 | 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",
")",
":",
"#### def get_annotations_dct(self, taxid, options):",
"if",
"len",
"(",
"self",
".",
"taxid2asscs",
")",
"==",
"1",
":",
"taxid",
"=",
"next",
"(",
"iter",
"(",
"self",
".",
"taxid2asscs",
... | 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 |
228,432 | 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 |
228,433 | 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 |
228,434 | 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 |
228,435 | 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 |
228,436 | 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 |
228,437 | 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 |
228,438 | 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 |
228,439 | 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",
"=",... | 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 |
228,440 | 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 |
228,441 | 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 |
228,442 | 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",
")",
"# Create 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 |
228,443 | 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",
")",
"# Create DAG ... | 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 |
228,444 | 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",
")",
"# namedtuple fields: hdrgo gosubdag tot_us... | 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 |
228,445 | 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",
")",
":",
"# Get GO IDs which are in the hdrgo path",
"goids_possible",
"=",
"ntpltgo1",
".",
"gosubdag",
".",
"go2obj",
".",
"keys",
"(",
")",
"# Get upper GO IDs which have... | 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 |
228,446 | tanghaibao/goatools | goatools/grouper/plotobj.py | PltGroupedGos._get_gosrcs_upper | def _get_gosrcs_upper(self, goids, max_upper, go2parentids):
"""Get GO IDs for the upper portion of the GO DAG."""
gosrcs_upper = set()
get_nt = self.gosubdag.go2nt.get
go2nt = {g:get_nt(g) for g in goids}
# Sort by descending order of descendant counts to find potential new hdrg... | python | def _get_gosrcs_upper(self, goids, max_upper, go2parentids):
"""Get GO IDs for the upper portion of the GO DAG."""
gosrcs_upper = set()
get_nt = self.gosubdag.go2nt.get
go2nt = {g:get_nt(g) for g in goids}
# Sort by descending order of descendant counts to find potential new hdrg... | [
"def",
"_get_gosrcs_upper",
"(",
"self",
",",
"goids",
",",
"max_upper",
",",
"go2parentids",
")",
":",
"gosrcs_upper",
"=",
"set",
"(",
")",
"get_nt",
"=",
"self",
".",
"gosubdag",
".",
"go2nt",
".",
"get",
"go2nt",
"=",
"{",
"g",
":",
"get_nt",
"(",
... | Get GO IDs for the upper portion of the GO DAG. | [
"Get",
"GO",
"IDs",
"for",
"the",
"upper",
"portion",
"of",
"the",
"GO",
"DAG",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/plotobj.py#L214-L231 |
228,447 | tanghaibao/goatools | goatools/grouper/plotobj.py | PltGroupedGos._get_gosubdagplotnt | def _get_gosubdagplotnt(self, ntplt, title, go2color, pltargs):
"""Return GoSubDagPlotNt, which contains both a GoSubDagPlot object and ntobj."""
kws_plt = pltargs.get_kws_plt()
kws_plt['id'] = '"{ID}"'.format(ID=ntplt.hdrgo)
kws_plt['title'] = "{TITLE} of {M} user GOs".format(TITLE=titl... | python | def _get_gosubdagplotnt(self, ntplt, title, go2color, pltargs):
"""Return GoSubDagPlotNt, which contains both a GoSubDagPlot object and ntobj."""
kws_plt = pltargs.get_kws_plt()
kws_plt['id'] = '"{ID}"'.format(ID=ntplt.hdrgo)
kws_plt['title'] = "{TITLE} of {M} user GOs".format(TITLE=titl... | [
"def",
"_get_gosubdagplotnt",
"(",
"self",
",",
"ntplt",
",",
"title",
",",
"go2color",
",",
"pltargs",
")",
":",
"kws_plt",
"=",
"pltargs",
".",
"get_kws_plt",
"(",
")",
"kws_plt",
"[",
"'id'",
"]",
"=",
"'\"{ID}\"'",
".",
"format",
"(",
"ID",
"=",
"n... | Return GoSubDagPlotNt, which contains both a GoSubDagPlot object and ntobj. | [
"Return",
"GoSubDagPlotNt",
"which",
"contains",
"both",
"a",
"GoSubDagPlot",
"object",
"and",
"ntobj",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/plotobj.py#L233-L243 |
228,448 | tanghaibao/goatools | goatools/grouper/plotobj.py | PltGroupedGos._no_ntplt | def _no_ntplt(self, ntplt):
"""Print a message about the GO DAG Plot we are NOT plotting."""
sys.stdout.write(" {GO_USR:>6,} usr {GO_ALL:>6,} GOs DID NOT WRITE: {B} {D}\n".format(
B=self.grprobj.get_fout_base(ntplt.hdrgo),
D=ntplt.desc,
GO_USR=len(ntplt.gosubdag.go_... | python | def _no_ntplt(self, ntplt):
"""Print a message about the GO DAG Plot we are NOT plotting."""
sys.stdout.write(" {GO_USR:>6,} usr {GO_ALL:>6,} GOs DID NOT WRITE: {B} {D}\n".format(
B=self.grprobj.get_fout_base(ntplt.hdrgo),
D=ntplt.desc,
GO_USR=len(ntplt.gosubdag.go_... | [
"def",
"_no_ntplt",
"(",
"self",
",",
"ntplt",
")",
":",
"sys",
".",
"stdout",
".",
"write",
"(",
"\" {GO_USR:>6,} usr {GO_ALL:>6,} GOs DID NOT WRITE: {B} {D}\\n\"",
".",
"format",
"(",
"B",
"=",
"self",
".",
"grprobj",
".",
"get_fout_base",
"(",
"ntplt",
".",... | Print a message about the GO DAG Plot we are NOT plotting. | [
"Print",
"a",
"message",
"about",
"the",
"GO",
"DAG",
"Plot",
"we",
"are",
"NOT",
"plotting",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/plotobj.py#L245-L251 |
228,449 | tanghaibao/goatools | goatools/grouper/plotobj.py | PltGroupedGos._get_pltdag_ancesters | def _get_pltdag_ancesters(self, hdrgo, usrgos, desc=""):
"""Get GoSubDag containing hdrgo and all usrgos and their ancesters."""
go_srcs = usrgos.union([hdrgo])
gosubdag = GoSubDag(go_srcs,
self.gosubdag.get_go2obj(go_srcs),
relationships=s... | python | def _get_pltdag_ancesters(self, hdrgo, usrgos, desc=""):
"""Get GoSubDag containing hdrgo and all usrgos and their ancesters."""
go_srcs = usrgos.union([hdrgo])
gosubdag = GoSubDag(go_srcs,
self.gosubdag.get_go2obj(go_srcs),
relationships=s... | [
"def",
"_get_pltdag_ancesters",
"(",
"self",
",",
"hdrgo",
",",
"usrgos",
",",
"desc",
"=",
"\"\"",
")",
":",
"go_srcs",
"=",
"usrgos",
".",
"union",
"(",
"[",
"hdrgo",
"]",
")",
"gosubdag",
"=",
"GoSubDag",
"(",
"go_srcs",
",",
"self",
".",
"gosubdag"... | Get GoSubDag containing hdrgo and all usrgos and their ancesters. | [
"Get",
"GoSubDag",
"containing",
"hdrgo",
"and",
"all",
"usrgos",
"and",
"their",
"ancesters",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/plotobj.py#L253-L267 |
228,450 | tanghaibao/goatools | goatools/grouper/plotobj.py | PltGroupedGos._get_pltdag_path_hdr | def _get_pltdag_path_hdr(self, hdrgo, usrgos, desc="pruned"):
"""Get GoSubDag with paths from usrgos through hdrgo."""
go_sources = usrgos.union([hdrgo])
gosubdag = GoSubDag(go_sources,
self.gosubdag.get_go2obj(go_sources),
relationships=se... | python | def _get_pltdag_path_hdr(self, hdrgo, usrgos, desc="pruned"):
"""Get GoSubDag with paths from usrgos through hdrgo."""
go_sources = usrgos.union([hdrgo])
gosubdag = GoSubDag(go_sources,
self.gosubdag.get_go2obj(go_sources),
relationships=se... | [
"def",
"_get_pltdag_path_hdr",
"(",
"self",
",",
"hdrgo",
",",
"usrgos",
",",
"desc",
"=",
"\"pruned\"",
")",
":",
"go_sources",
"=",
"usrgos",
".",
"union",
"(",
"[",
"hdrgo",
"]",
")",
"gosubdag",
"=",
"GoSubDag",
"(",
"go_sources",
",",
"self",
".",
... | Get GoSubDag with paths from usrgos through hdrgo. | [
"Get",
"GoSubDag",
"with",
"paths",
"from",
"usrgos",
"through",
"hdrgo",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/plotobj.py#L269-L284 |
228,451 | tanghaibao/goatools | goatools/grouper/plotobj.py | GoSubDagPlotNt.wrplt | def wrplt(self, fout_dir, plt_ext="png"):
"""Write png containing plot of GoSubDag."""
# Ex basename
basename = self.grprobj.get_fout_base(self.ntplt.hdrgo)
plt_pat = self.get_pltpat(plt_ext)
fout_basename = plt_pat.format(BASE=basename)
fout_plt = os.path.join(fout_dir, ... | python | def wrplt(self, fout_dir, plt_ext="png"):
"""Write png containing plot of GoSubDag."""
# Ex basename
basename = self.grprobj.get_fout_base(self.ntplt.hdrgo)
plt_pat = self.get_pltpat(plt_ext)
fout_basename = plt_pat.format(BASE=basename)
fout_plt = os.path.join(fout_dir, ... | [
"def",
"wrplt",
"(",
"self",
",",
"fout_dir",
",",
"plt_ext",
"=",
"\"png\"",
")",
":",
"# Ex basename",
"basename",
"=",
"self",
".",
"grprobj",
".",
"get_fout_base",
"(",
"self",
".",
"ntplt",
".",
"hdrgo",
")",
"plt_pat",
"=",
"self",
".",
"get_pltpat... | Write png containing plot of GoSubDag. | [
"Write",
"png",
"containing",
"plot",
"of",
"GoSubDag",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/plotobj.py#L296-L304 |
228,452 | tanghaibao/goatools | goatools/grouper/plotobj.py | GoSubDagPlotNt.get_dotstr | def get_dotstr(self):
"""Return a string containing DAG graph in Grpahviz's dot language."""
dotobj = self.gosubdagplot.get_pydot_graph() # pydot.Dot
dotstr = dotobj.create_dot()
return dotstr | python | def get_dotstr(self):
"""Return a string containing DAG graph in Grpahviz's dot language."""
dotobj = self.gosubdagplot.get_pydot_graph() # pydot.Dot
dotstr = dotobj.create_dot()
return dotstr | [
"def",
"get_dotstr",
"(",
"self",
")",
":",
"dotobj",
"=",
"self",
".",
"gosubdagplot",
".",
"get_pydot_graph",
"(",
")",
"# pydot.Dot",
"dotstr",
"=",
"dotobj",
".",
"create_dot",
"(",
")",
"return",
"dotstr"
] | Return a string containing DAG graph in Grpahviz's dot language. | [
"Return",
"a",
"string",
"containing",
"DAG",
"graph",
"in",
"Grpahviz",
"s",
"dot",
"language",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/plotobj.py#L306-L310 |
228,453 | tanghaibao/goatools | goatools/gosubdag/rpt/write_hierarchy.py | WrHierGO._get_wrhiercfg | def _get_wrhiercfg(self):
"""Initialize print format."""
prtfmt = self.gosubdag.prt_attr['fmt']
prtfmt = prtfmt.replace('{GO} # ', '')
prtfmt = prtfmt.replace('{D1:5} ', '')
return {'name2prtfmt':{'ITEM':prtfmt, 'ID':'{GO}{alt:1}'},
'max_indent': self.usrdct.get('... | python | def _get_wrhiercfg(self):
"""Initialize print format."""
prtfmt = self.gosubdag.prt_attr['fmt']
prtfmt = prtfmt.replace('{GO} # ', '')
prtfmt = prtfmt.replace('{D1:5} ', '')
return {'name2prtfmt':{'ITEM':prtfmt, 'ID':'{GO}{alt:1}'},
'max_indent': self.usrdct.get('... | [
"def",
"_get_wrhiercfg",
"(",
"self",
")",
":",
"prtfmt",
"=",
"self",
".",
"gosubdag",
".",
"prt_attr",
"[",
"'fmt'",
"]",
"prtfmt",
"=",
"prtfmt",
".",
"replace",
"(",
"'{GO} # '",
",",
"''",
")",
"prtfmt",
"=",
"prtfmt",
".",
"replace",
"(",
"'{D1:5... | Initialize print format. | [
"Initialize",
"print",
"format",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/gosubdag/rpt/write_hierarchy.py#L78-L91 |
228,454 | tanghaibao/goatools | goatools/gosubdag/rpt/write_hierarchy.py | WrHierGO._get_goroot | def _get_goroot(self, goids_all, namespace):
"""Get the top GO for the set of goids_all."""
root_goid = self.consts.NAMESPACE2GO[namespace]
if root_goid in goids_all:
return root_goid
root_goids = set()
for goid in goids_all:
goterm = self.gosubdag.go2obj[... | python | def _get_goroot(self, goids_all, namespace):
"""Get the top GO for the set of goids_all."""
root_goid = self.consts.NAMESPACE2GO[namespace]
if root_goid in goids_all:
return root_goid
root_goids = set()
for goid in goids_all:
goterm = self.gosubdag.go2obj[... | [
"def",
"_get_goroot",
"(",
"self",
",",
"goids_all",
",",
"namespace",
")",
":",
"root_goid",
"=",
"self",
".",
"consts",
".",
"NAMESPACE2GO",
"[",
"namespace",
"]",
"if",
"root_goid",
"in",
"goids_all",
":",
"return",
"root_goid",
"root_goids",
"=",
"set",
... | Get the top GO for the set of goids_all. | [
"Get",
"the",
"top",
"GO",
"for",
"the",
"set",
"of",
"goids_all",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/gosubdag/rpt/write_hierarchy.py#L93-L105 |
228,455 | tanghaibao/goatools | goatools/rpt/nts_xfrm.py | MgrNts.mknts | def mknts(self, add_dct):
"""Add information from add_dct to a new copy of namedtuples stored in nts."""
nts = []
assert len(add_dct) == len(self.nts)
flds = list(next(iter(self.nts))._fields) + list(next(iter(add_dct)).keys())
ntobj = cx.namedtuple("ntgoea", " ".join(flds))
... | python | def mknts(self, add_dct):
"""Add information from add_dct to a new copy of namedtuples stored in nts."""
nts = []
assert len(add_dct) == len(self.nts)
flds = list(next(iter(self.nts))._fields) + list(next(iter(add_dct)).keys())
ntobj = cx.namedtuple("ntgoea", " ".join(flds))
... | [
"def",
"mknts",
"(",
"self",
",",
"add_dct",
")",
":",
"nts",
"=",
"[",
"]",
"assert",
"len",
"(",
"add_dct",
")",
"==",
"len",
"(",
"self",
".",
"nts",
")",
"flds",
"=",
"list",
"(",
"next",
"(",
"iter",
"(",
"self",
".",
"nts",
")",
")",
".... | Add information from add_dct to a new copy of namedtuples stored in nts. | [
"Add",
"information",
"from",
"add_dct",
"to",
"a",
"new",
"copy",
"of",
"namedtuples",
"stored",
"in",
"nts",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/rpt/nts_xfrm.py#L22-L33 |
228,456 | tanghaibao/goatools | goatools/rpt/nts_xfrm.py | MgrNts.add_f2str | def add_f2str(self, dcts, srcfld, dstfld, dstfmt):
"""Add a namedtuple field of type string generated from an existing namedtuple field."""
# Example: f2str = objntmgr.add_f2str(dcts, "p_fdr_bh", "s_fdr_bh", "{:8.2e}")
# ntobj = self.get_ntobj()
# print(ntobj)
assert len(dcts) ==... | python | def add_f2str(self, dcts, srcfld, dstfld, dstfmt):
"""Add a namedtuple field of type string generated from an existing namedtuple field."""
# Example: f2str = objntmgr.add_f2str(dcts, "p_fdr_bh", "s_fdr_bh", "{:8.2e}")
# ntobj = self.get_ntobj()
# print(ntobj)
assert len(dcts) ==... | [
"def",
"add_f2str",
"(",
"self",
",",
"dcts",
",",
"srcfld",
",",
"dstfld",
",",
"dstfmt",
")",
":",
"# Example: f2str = objntmgr.add_f2str(dcts, \"p_fdr_bh\", \"s_fdr_bh\", \"{:8.2e}\")",
"# ntobj = self.get_ntobj()",
"# print(ntobj)",
"assert",
"len",
"(",
"dcts",
")",
... | Add a namedtuple field of type string generated from an existing namedtuple field. | [
"Add",
"a",
"namedtuple",
"field",
"of",
"type",
"string",
"generated",
"from",
"an",
"existing",
"namedtuple",
"field",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/rpt/nts_xfrm.py#L35-L44 |
228,457 | tanghaibao/goatools | goatools/rpt/nts_xfrm.py | MgrNts.get_ntobj | def get_ntobj(self):
"""Create namedtuple object with GOEA fields."""
if self.nts:
return cx.namedtuple("ntgoea", " ".join(vars(next(iter(self.nts))).keys())) | python | def get_ntobj(self):
"""Create namedtuple object with GOEA fields."""
if self.nts:
return cx.namedtuple("ntgoea", " ".join(vars(next(iter(self.nts))).keys())) | [
"def",
"get_ntobj",
"(",
"self",
")",
":",
"if",
"self",
".",
"nts",
":",
"return",
"cx",
".",
"namedtuple",
"(",
"\"ntgoea\"",
",",
"\" \"",
".",
"join",
"(",
"vars",
"(",
"next",
"(",
"iter",
"(",
"self",
".",
"nts",
")",
")",
")",
".",
"keys",... | Create namedtuple object with GOEA fields. | [
"Create",
"namedtuple",
"object",
"with",
"GOEA",
"fields",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/rpt/nts_xfrm.py#L46-L49 |
228,458 | tanghaibao/goatools | goatools/semantic.py | get_info_content | def get_info_content(go_id, termcounts):
'''
Calculates the information content of a GO term.
'''
# Get the observed frequency of the GO term
freq = termcounts.get_term_freq(go_id)
# Calculate the information content (i.e., -log("freq of GO term")
return -1.0 * math.log(freq) if freq el... | python | def get_info_content(go_id, termcounts):
'''
Calculates the information content of a GO term.
'''
# Get the observed frequency of the GO term
freq = termcounts.get_term_freq(go_id)
# Calculate the information content (i.e., -log("freq of GO term")
return -1.0 * math.log(freq) if freq el... | [
"def",
"get_info_content",
"(",
"go_id",
",",
"termcounts",
")",
":",
"# Get the observed frequency of the GO term",
"freq",
"=",
"termcounts",
".",
"get_term_freq",
"(",
"go_id",
")",
"# Calculate the information content (i.e., -log(\"freq of GO term\")",
"return",
"-",
"1.0... | Calculates the information content of a GO term. | [
"Calculates",
"the",
"information",
"content",
"of",
"a",
"GO",
"term",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/semantic.py#L120-L128 |
228,459 | tanghaibao/goatools | goatools/semantic.py | resnik_sim | def resnik_sim(go_id1, go_id2, godag, termcounts):
'''
Computes Resnik's similarity measure.
'''
goterm1 = godag[go_id1]
goterm2 = godag[go_id2]
if goterm1.namespace == goterm2.namespace:
msca_goid = deepest_common_ancestor([go_id1, go_id2], godag)
return get_info_content(msc... | python | def resnik_sim(go_id1, go_id2, godag, termcounts):
'''
Computes Resnik's similarity measure.
'''
goterm1 = godag[go_id1]
goterm2 = godag[go_id2]
if goterm1.namespace == goterm2.namespace:
msca_goid = deepest_common_ancestor([go_id1, go_id2], godag)
return get_info_content(msc... | [
"def",
"resnik_sim",
"(",
"go_id1",
",",
"go_id2",
",",
"godag",
",",
"termcounts",
")",
":",
"goterm1",
"=",
"godag",
"[",
"go_id1",
"]",
"goterm2",
"=",
"godag",
"[",
"go_id2",
"]",
"if",
"goterm1",
".",
"namespace",
"==",
"goterm2",
".",
"namespace",
... | Computes Resnik's similarity measure. | [
"Computes",
"Resnik",
"s",
"similarity",
"measure",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/semantic.py#L131-L139 |
228,460 | tanghaibao/goatools | goatools/semantic.py | lin_sim | def lin_sim(goid1, goid2, godag, termcnts):
'''
Computes Lin's similarity measure.
'''
sim_r = resnik_sim(goid1, goid2, godag, termcnts)
return lin_sim_calc(goid1, goid2, sim_r, termcnts) | python | def lin_sim(goid1, goid2, godag, termcnts):
'''
Computes Lin's similarity measure.
'''
sim_r = resnik_sim(goid1, goid2, godag, termcnts)
return lin_sim_calc(goid1, goid2, sim_r, termcnts) | [
"def",
"lin_sim",
"(",
"goid1",
",",
"goid2",
",",
"godag",
",",
"termcnts",
")",
":",
"sim_r",
"=",
"resnik_sim",
"(",
"goid1",
",",
"goid2",
",",
"godag",
",",
"termcnts",
")",
"return",
"lin_sim_calc",
"(",
"goid1",
",",
"goid2",
",",
"sim_r",
",",
... | Computes Lin's similarity measure. | [
"Computes",
"Lin",
"s",
"similarity",
"measure",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/semantic.py#L142-L147 |
228,461 | tanghaibao/goatools | goatools/semantic.py | lin_sim_calc | def lin_sim_calc(goid1, goid2, sim_r, termcnts):
'''
Computes Lin's similarity measure using pre-calculated Resnik's similarities.
'''
if sim_r is not None:
info = get_info_content(goid1, termcnts) + get_info_content(goid2, termcnts)
if info != 0:
return (2*sim_r)/info | python | def lin_sim_calc(goid1, goid2, sim_r, termcnts):
'''
Computes Lin's similarity measure using pre-calculated Resnik's similarities.
'''
if sim_r is not None:
info = get_info_content(goid1, termcnts) + get_info_content(goid2, termcnts)
if info != 0:
return (2*sim_r)/info | [
"def",
"lin_sim_calc",
"(",
"goid1",
",",
"goid2",
",",
"sim_r",
",",
"termcnts",
")",
":",
"if",
"sim_r",
"is",
"not",
"None",
":",
"info",
"=",
"get_info_content",
"(",
"goid1",
",",
"termcnts",
")",
"+",
"get_info_content",
"(",
"goid2",
",",
"termcnt... | Computes Lin's similarity measure using pre-calculated Resnik's similarities. | [
"Computes",
"Lin",
"s",
"similarity",
"measure",
"using",
"pre",
"-",
"calculated",
"Resnik",
"s",
"similarities",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/semantic.py#L150-L157 |
228,462 | tanghaibao/goatools | goatools/semantic.py | common_parent_go_ids | def common_parent_go_ids(goids, godag):
'''
This function finds the common ancestors in the GO
tree of the list of goids in the input.
'''
# Find candidates from first
rec = godag[goids[0]]
candidates = rec.get_all_parents()
candidates.update({goids[0]})
# Find intersection ... | python | def common_parent_go_ids(goids, godag):
'''
This function finds the common ancestors in the GO
tree of the list of goids in the input.
'''
# Find candidates from first
rec = godag[goids[0]]
candidates = rec.get_all_parents()
candidates.update({goids[0]})
# Find intersection ... | [
"def",
"common_parent_go_ids",
"(",
"goids",
",",
"godag",
")",
":",
"# Find candidates from first",
"rec",
"=",
"godag",
"[",
"goids",
"[",
"0",
"]",
"]",
"candidates",
"=",
"rec",
".",
"get_all_parents",
"(",
")",
"candidates",
".",
"update",
"(",
"{",
"... | This function finds the common ancestors in the GO
tree of the list of goids in the input. | [
"This",
"function",
"finds",
"the",
"common",
"ancestors",
"in",
"the",
"GO",
"tree",
"of",
"the",
"list",
"of",
"goids",
"in",
"the",
"input",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/semantic.py#L160-L178 |
228,463 | tanghaibao/goatools | goatools/semantic.py | deepest_common_ancestor | def deepest_common_ancestor(goterms, godag):
'''
This function gets the nearest common ancestor
using the above function.
Only returns single most specific - assumes unique exists.
'''
# Take the element at maximum depth.
return max(common_parent_go_ids(goterms, godag), key=lambd... | python | def deepest_common_ancestor(goterms, godag):
'''
This function gets the nearest common ancestor
using the above function.
Only returns single most specific - assumes unique exists.
'''
# Take the element at maximum depth.
return max(common_parent_go_ids(goterms, godag), key=lambd... | [
"def",
"deepest_common_ancestor",
"(",
"goterms",
",",
"godag",
")",
":",
"# Take the element at maximum depth.",
"return",
"max",
"(",
"common_parent_go_ids",
"(",
"goterms",
",",
"godag",
")",
",",
"key",
"=",
"lambda",
"t",
":",
"godag",
"[",
"t",
"]",
".",... | This function gets the nearest common ancestor
using the above function.
Only returns single most specific - assumes unique exists. | [
"This",
"function",
"gets",
"the",
"nearest",
"common",
"ancestor",
"using",
"the",
"above",
"function",
".",
"Only",
"returns",
"single",
"most",
"specific",
"-",
"assumes",
"unique",
"exists",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/semantic.py#L181-L188 |
228,464 | tanghaibao/goatools | goatools/semantic.py | min_branch_length | def min_branch_length(go_id1, go_id2, godag, branch_dist):
'''
Finds the minimum branch length between two terms in the GO DAG.
'''
# First get the deepest common ancestor
goterm1 = godag[go_id1]
goterm2 = godag[go_id2]
if goterm1.namespace == goterm2.namespace:
dca = deepest_com... | python | def min_branch_length(go_id1, go_id2, godag, branch_dist):
'''
Finds the minimum branch length between two terms in the GO DAG.
'''
# First get the deepest common ancestor
goterm1 = godag[go_id1]
goterm2 = godag[go_id2]
if goterm1.namespace == goterm2.namespace:
dca = deepest_com... | [
"def",
"min_branch_length",
"(",
"go_id1",
",",
"go_id2",
",",
"godag",
",",
"branch_dist",
")",
":",
"# First get the deepest common ancestor",
"goterm1",
"=",
"godag",
"[",
"go_id1",
"]",
"goterm2",
"=",
"godag",
"[",
"go_id2",
"]",
"if",
"goterm1",
".",
"na... | Finds the minimum branch length between two terms in the GO DAG. | [
"Finds",
"the",
"minimum",
"branch",
"length",
"between",
"two",
"terms",
"in",
"the",
"GO",
"DAG",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/semantic.py#L191-L210 |
228,465 | tanghaibao/goatools | goatools/semantic.py | TermCounts._init_count_terms | def _init_count_terms(self, annots):
'''
Fills in the counts and overall aspect counts.
'''
gonotindag = set()
gocnts = self.gocnts
go2obj = self.go2obj
# Fill gocnts with GO IDs in annotations and their corresponding counts
for terms in annots.values(... | python | def _init_count_terms(self, annots):
'''
Fills in the counts and overall aspect counts.
'''
gonotindag = set()
gocnts = self.gocnts
go2obj = self.go2obj
# Fill gocnts with GO IDs in annotations and their corresponding counts
for terms in annots.values(... | [
"def",
"_init_count_terms",
"(",
"self",
",",
"annots",
")",
":",
"gonotindag",
"=",
"set",
"(",
")",
"gocnts",
"=",
"self",
".",
"gocnts",
"go2obj",
"=",
"self",
".",
"go2obj",
"# Fill gocnts with GO IDs in annotations and their corresponding counts",
"for",
"terms... | Fills in the counts and overall aspect counts. | [
"Fills",
"in",
"the",
"counts",
"and",
"overall",
"aspect",
"counts",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/semantic.py#L43-L65 |
228,466 | tanghaibao/goatools | goatools/semantic.py | TermCounts._init_add_goid_alt | def _init_add_goid_alt(self):
'''
Add alternate GO IDs to term counts.
'''
# Fill aspect_counts. Find alternate GO IDs that may not be on gocnts
goid_alts = set()
go2cnt_add = {}
aspect_counts = self.aspect_counts
gocnts = self.gocnts
go2obj = ... | python | def _init_add_goid_alt(self):
'''
Add alternate GO IDs to term counts.
'''
# Fill aspect_counts. Find alternate GO IDs that may not be on gocnts
goid_alts = set()
go2cnt_add = {}
aspect_counts = self.aspect_counts
gocnts = self.gocnts
go2obj = ... | [
"def",
"_init_add_goid_alt",
"(",
"self",
")",
":",
"# Fill aspect_counts. Find alternate GO IDs that may not be on gocnts",
"goid_alts",
"=",
"set",
"(",
")",
"go2cnt_add",
"=",
"{",
"}",
"aspect_counts",
"=",
"self",
".",
"aspect_counts",
"gocnts",
"=",
"self",
".",... | Add alternate GO IDs to term counts. | [
"Add",
"alternate",
"GO",
"IDs",
"to",
"term",
"counts",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/semantic.py#L68-L96 |
228,467 | tanghaibao/goatools | goatools/semantic.py | TermCounts.get_term_freq | def get_term_freq(self, go_id):
'''
Returns the frequency at which a particular GO term has
been observed in the annotations.
'''
num_ns = float(self.get_total_count(self.go2obj[go_id].namespace))
return float(self.get_count(go_id))/num_ns if num_ns != 0 else 0 | python | def get_term_freq(self, go_id):
'''
Returns the frequency at which a particular GO term has
been observed in the annotations.
'''
num_ns = float(self.get_total_count(self.go2obj[go_id].namespace))
return float(self.get_count(go_id))/num_ns if num_ns != 0 else 0 | [
"def",
"get_term_freq",
"(",
"self",
",",
"go_id",
")",
":",
"num_ns",
"=",
"float",
"(",
"self",
".",
"get_total_count",
"(",
"self",
".",
"go2obj",
"[",
"go_id",
"]",
".",
"namespace",
")",
")",
"return",
"float",
"(",
"self",
".",
"get_count",
"(",
... | Returns the frequency at which a particular GO term has
been observed in the annotations. | [
"Returns",
"the",
"frequency",
"at",
"which",
"a",
"particular",
"GO",
"term",
"has",
"been",
"observed",
"in",
"the",
"annotations",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/semantic.py#L111-L117 |
228,468 | tanghaibao/goatools | goatools/grouper/hdrgos.py | HdrgosSections.get_sections | def get_sections(self, hdrgo, dflt_section=True):
"""Given a header GO, return the sections that contain it."""
dflt_list = []
# If the hdrgo is not in a section, return the default name for a section
if dflt_section:
dflt_list = [self.secdflt]
return self.hdrgo2secti... | python | def get_sections(self, hdrgo, dflt_section=True):
"""Given a header GO, return the sections that contain it."""
dflt_list = []
# If the hdrgo is not in a section, return the default name for a section
if dflt_section:
dflt_list = [self.secdflt]
return self.hdrgo2secti... | [
"def",
"get_sections",
"(",
"self",
",",
"hdrgo",
",",
"dflt_section",
"=",
"True",
")",
":",
"dflt_list",
"=",
"[",
"]",
"# If the hdrgo is not in a section, return the default name for a section",
"if",
"dflt_section",
":",
"dflt_list",
"=",
"[",
"self",
".",
"sec... | Given a header GO, return the sections that contain it. | [
"Given",
"a",
"header",
"GO",
"return",
"the",
"sections",
"that",
"contain",
"it",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/hdrgos.py#L25-L31 |
228,469 | tanghaibao/goatools | goatools/grouper/hdrgos.py | HdrgosSections.get_section_hdrgos | def get_section_hdrgos(self):
"""Get the GO group headers explicitly listed in sections."""
return set([h for _, hs in self.sections for h in hs]) if self.sections else set() | python | def get_section_hdrgos(self):
"""Get the GO group headers explicitly listed in sections."""
return set([h for _, hs in self.sections for h in hs]) if self.sections else set() | [
"def",
"get_section_hdrgos",
"(",
"self",
")",
":",
"return",
"set",
"(",
"[",
"h",
"for",
"_",
",",
"hs",
"in",
"self",
".",
"sections",
"for",
"h",
"in",
"hs",
"]",
")",
"if",
"self",
".",
"sections",
"else",
"set",
"(",
")"
] | Get the GO group headers explicitly listed in sections. | [
"Get",
"the",
"GO",
"group",
"headers",
"explicitly",
"listed",
"in",
"sections",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/hdrgos.py#L41-L43 |
228,470 | tanghaibao/goatools | goatools/grouper/hdrgos.py | HdrgosSections._chk_sections | def _chk_sections(sections):
"""Check format of user-provided 'sections' variable"""
if sections:
assert len(sections[0]) == 2, \
"SECTIONS DATA MUST BE A 2-D LIST. FOUND: {S}".format(S=sections)
for _, hdrgos in sections:
chk_goids(hdrgos, "Hdrgos... | python | def _chk_sections(sections):
"""Check format of user-provided 'sections' variable"""
if sections:
assert len(sections[0]) == 2, \
"SECTIONS DATA MUST BE A 2-D LIST. FOUND: {S}".format(S=sections)
for _, hdrgos in sections:
chk_goids(hdrgos, "Hdrgos... | [
"def",
"_chk_sections",
"(",
"sections",
")",
":",
"if",
"sections",
":",
"assert",
"len",
"(",
"sections",
"[",
"0",
"]",
")",
"==",
"2",
",",
"\"SECTIONS DATA MUST BE A 2-D LIST. FOUND: {S}\"",
".",
"format",
"(",
"S",
"=",
"sections",
")",
"for",
"_",
"... | Check format of user-provided 'sections' variable | [
"Check",
"format",
"of",
"user",
"-",
"provided",
"sections",
"variable"
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/hdrgos.py#L46-L52 |
228,471 | tanghaibao/goatools | goatools/grouper/hdrgos.py | HdrgosSections._init_hdrgos | def _init_hdrgos(self, hdrgos_dflt, hdrgos_usr=None, add_dflt=True):
"""Initialize GO high"""
# Use default GO group header values
if (hdrgos_usr is None or hdrgos_usr is False) and not self.sections:
return set(hdrgos_dflt)
# Get GO group headers provided by user
hdr... | python | def _init_hdrgos(self, hdrgos_dflt, hdrgos_usr=None, add_dflt=True):
"""Initialize GO high"""
# Use default GO group header values
if (hdrgos_usr is None or hdrgos_usr is False) and not self.sections:
return set(hdrgos_dflt)
# Get GO group headers provided by user
hdr... | [
"def",
"_init_hdrgos",
"(",
"self",
",",
"hdrgos_dflt",
",",
"hdrgos_usr",
"=",
"None",
",",
"add_dflt",
"=",
"True",
")",
":",
"# Use default GO group header values",
"if",
"(",
"hdrgos_usr",
"is",
"None",
"or",
"hdrgos_usr",
"is",
"False",
")",
"and",
"not",... | Initialize GO high | [
"Initialize",
"GO",
"high"
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/hdrgos.py#L69-L88 |
228,472 | tanghaibao/goatools | goatools/obo_tasks.py | get_all_parents | def get_all_parents(go_objs):
"""Return a set containing all GO Term parents of multiple GOTerm objects."""
go_parents = set()
for go_obj in go_objs:
go_parents |= go_obj.get_all_parents()
return go_parents | python | def get_all_parents(go_objs):
"""Return a set containing all GO Term parents of multiple GOTerm objects."""
go_parents = set()
for go_obj in go_objs:
go_parents |= go_obj.get_all_parents()
return go_parents | [
"def",
"get_all_parents",
"(",
"go_objs",
")",
":",
"go_parents",
"=",
"set",
"(",
")",
"for",
"go_obj",
"in",
"go_objs",
":",
"go_parents",
"|=",
"go_obj",
".",
"get_all_parents",
"(",
")",
"return",
"go_parents"
] | Return a set containing all GO Term parents of multiple GOTerm objects. | [
"Return",
"a",
"set",
"containing",
"all",
"GO",
"Term",
"parents",
"of",
"multiple",
"GOTerm",
"objects",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/obo_tasks.py#L3-L8 |
228,473 | tanghaibao/goatools | goatools/statsdescribe.py | StatsDescribe.prt_hdr | def prt_hdr(self, prt=sys.stdout, name="name "):
"""Print stats header in markdown style."""
hdr = "{NAME} | # {ITEMS:11} | range | 25th percentile | " \
" median | 75th percentile | mean | stddev\n".format(NAME=name, ITEMS=self.desc)
div = "{DASHES}|-----... | python | def prt_hdr(self, prt=sys.stdout, name="name "):
"""Print stats header in markdown style."""
hdr = "{NAME} | # {ITEMS:11} | range | 25th percentile | " \
" median | 75th percentile | mean | stddev\n".format(NAME=name, ITEMS=self.desc)
div = "{DASHES}|-----... | [
"def",
"prt_hdr",
"(",
"self",
",",
"prt",
"=",
"sys",
".",
"stdout",
",",
"name",
"=",
"\"name \"",
")",
":",
"hdr",
"=",
"\"{NAME} | # {ITEMS:11} | range | 25th percentile | \"",
"\" median | 75th percentile | mean | stddev\\n\"",
".",
"format",
... | Print stats header in markdown style. | [
"Print",
"stats",
"header",
"in",
"markdown",
"style",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/statsdescribe.py#L21-L29 |
228,474 | tanghaibao/goatools | goatools/statsdescribe.py | StatsDescribe.prt_data | def prt_data(self, name, vals, prt=sys.stdout):
"""Print stats data in markdown style."""
fld2val = self.get_fld2val(name, vals)
prt.write(self.fmt.format(**fld2val))
return fld2val | python | def prt_data(self, name, vals, prt=sys.stdout):
"""Print stats data in markdown style."""
fld2val = self.get_fld2val(name, vals)
prt.write(self.fmt.format(**fld2val))
return fld2val | [
"def",
"prt_data",
"(",
"self",
",",
"name",
",",
"vals",
",",
"prt",
"=",
"sys",
".",
"stdout",
")",
":",
"fld2val",
"=",
"self",
".",
"get_fld2val",
"(",
"name",
",",
"vals",
")",
"prt",
".",
"write",
"(",
"self",
".",
"fmt",
".",
"format",
"("... | Print stats data in markdown style. | [
"Print",
"stats",
"data",
"in",
"markdown",
"style",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/statsdescribe.py#L31-L35 |
228,475 | tanghaibao/goatools | goatools/statsdescribe.py | StatsDescribe.getstr_data | def getstr_data(self, name, vals):
"""Return stats data string in markdown style."""
fld2val = self.get_fld2val(name, vals)
return self.fmt.format(**fld2val) | python | def getstr_data(self, name, vals):
"""Return stats data string in markdown style."""
fld2val = self.get_fld2val(name, vals)
return self.fmt.format(**fld2val) | [
"def",
"getstr_data",
"(",
"self",
",",
"name",
",",
"vals",
")",
":",
"fld2val",
"=",
"self",
".",
"get_fld2val",
"(",
"name",
",",
"vals",
")",
"return",
"self",
".",
"fmt",
".",
"format",
"(",
"*",
"*",
"fld2val",
")"
] | Return stats data string in markdown style. | [
"Return",
"stats",
"data",
"string",
"in",
"markdown",
"style",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/statsdescribe.py#L37-L40 |
228,476 | tanghaibao/goatools | goatools/statsdescribe.py | StatsDescribe.get_fld2val | def get_fld2val(self, name, vals):
"""Describe summary statistics for a list of numbers."""
if vals:
return self._init_fld2val_stats(name, vals)
return self._init_fld2val_null(name) | python | def get_fld2val(self, name, vals):
"""Describe summary statistics for a list of numbers."""
if vals:
return self._init_fld2val_stats(name, vals)
return self._init_fld2val_null(name) | [
"def",
"get_fld2val",
"(",
"self",
",",
"name",
",",
"vals",
")",
":",
"if",
"vals",
":",
"return",
"self",
".",
"_init_fld2val_stats",
"(",
"name",
",",
"vals",
")",
"return",
"self",
".",
"_init_fld2val_null",
"(",
"name",
")"
] | Describe summary statistics for a list of numbers. | [
"Describe",
"summary",
"statistics",
"for",
"a",
"list",
"of",
"numbers",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/statsdescribe.py#L42-L46 |
228,477 | tanghaibao/goatools | goatools/statsdescribe.py | StatsDescribe._init_fld2val_stats | def _init_fld2val_stats(self, name, vals):
"""Return statistics on values."""
vals_stats = stats.describe(vals)
stddev = math.sqrt(vals_stats[3]) # stats variance
p25 = np.percentile(vals, 25)
p50 = np.percentile(vals, 50) # median
p75 = np.percentile(vals, 75)
fl... | python | def _init_fld2val_stats(self, name, vals):
"""Return statistics on values."""
vals_stats = stats.describe(vals)
stddev = math.sqrt(vals_stats[3]) # stats variance
p25 = np.percentile(vals, 25)
p50 = np.percentile(vals, 50) # median
p75 = np.percentile(vals, 75)
fl... | [
"def",
"_init_fld2val_stats",
"(",
"self",
",",
"name",
",",
"vals",
")",
":",
"vals_stats",
"=",
"stats",
".",
"describe",
"(",
"vals",
")",
"stddev",
"=",
"math",
".",
"sqrt",
"(",
"vals_stats",
"[",
"3",
"]",
")",
"# stats variance",
"p25",
"=",
"np... | Return statistics on values. | [
"Return",
"statistics",
"on",
"values",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/statsdescribe.py#L48-L71 |
228,478 | tanghaibao/goatools | goatools/statsdescribe.py | StatsDescribe._get_str_range | def _get_str_range(self, vals_stats):
"""Return a string containing the range of values."""
minmax = vals_stats[1] # stats minmax
minval = self.fmtstr.format(minmax[0])
maxval = self.fmtstr.format(minmax[1])
return '{A} to {B:6>}'.format(A=minval, B=maxval) | python | def _get_str_range(self, vals_stats):
"""Return a string containing the range of values."""
minmax = vals_stats[1] # stats minmax
minval = self.fmtstr.format(minmax[0])
maxval = self.fmtstr.format(minmax[1])
return '{A} to {B:6>}'.format(A=minval, B=maxval) | [
"def",
"_get_str_range",
"(",
"self",
",",
"vals_stats",
")",
":",
"minmax",
"=",
"vals_stats",
"[",
"1",
"]",
"# stats minmax",
"minval",
"=",
"self",
".",
"fmtstr",
".",
"format",
"(",
"minmax",
"[",
"0",
"]",
")",
"maxval",
"=",
"self",
".",
"fmtstr... | Return a string containing the range of values. | [
"Return",
"a",
"string",
"containing",
"the",
"range",
"of",
"values",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/statsdescribe.py#L85-L90 |
228,479 | tanghaibao/goatools | goatools/grouper/tasks.py | SummarySec2dHdrGos.summarize_sec2hdrgos | def summarize_sec2hdrgos(self, sec2d_hdrgos):
"""Get counts of header GO IDs and sections."""
hdrgos_all = set([])
hdrgos_grouped = set()
hdrgos_ungrouped = set()
sections_grouped = set()
for sectionname, hdrgos in sec2d_hdrgos:
self._chk_hdrgoids(hdrgos)
... | python | def summarize_sec2hdrgos(self, sec2d_hdrgos):
"""Get counts of header GO IDs and sections."""
hdrgos_all = set([])
hdrgos_grouped = set()
hdrgos_ungrouped = set()
sections_grouped = set()
for sectionname, hdrgos in sec2d_hdrgos:
self._chk_hdrgoids(hdrgos)
... | [
"def",
"summarize_sec2hdrgos",
"(",
"self",
",",
"sec2d_hdrgos",
")",
":",
"hdrgos_all",
"=",
"set",
"(",
"[",
"]",
")",
"hdrgos_grouped",
"=",
"set",
"(",
")",
"hdrgos_ungrouped",
"=",
"set",
"(",
")",
"sections_grouped",
"=",
"set",
"(",
")",
"for",
"s... | Get counts of header GO IDs and sections. | [
"Get",
"counts",
"of",
"header",
"GO",
"IDs",
"and",
"sections",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/tasks.py#L12-L28 |
228,480 | tanghaibao/goatools | goatools/grouper/tasks.py | SummarySec2dHdrGos.summarize_sec2hdrnts | def summarize_sec2hdrnts(self, sec2d_hdrnts):
"""Given namedtuples in each sectin, get counts of header GO IDs and sections."""
sec2d_hdrgos = [(s, set(nt.GO for nt in nts)) for s, nts in sec2d_hdrnts]
return self.summarize_sec2hdrgos(sec2d_hdrgos) | python | def summarize_sec2hdrnts(self, sec2d_hdrnts):
"""Given namedtuples in each sectin, get counts of header GO IDs and sections."""
sec2d_hdrgos = [(s, set(nt.GO for nt in nts)) for s, nts in sec2d_hdrnts]
return self.summarize_sec2hdrgos(sec2d_hdrgos) | [
"def",
"summarize_sec2hdrnts",
"(",
"self",
",",
"sec2d_hdrnts",
")",
":",
"sec2d_hdrgos",
"=",
"[",
"(",
"s",
",",
"set",
"(",
"nt",
".",
"GO",
"for",
"nt",
"in",
"nts",
")",
")",
"for",
"s",
",",
"nts",
"in",
"sec2d_hdrnts",
"]",
"return",
"self",
... | Given namedtuples in each sectin, get counts of header GO IDs and sections. | [
"Given",
"namedtuples",
"in",
"each",
"sectin",
"get",
"counts",
"of",
"header",
"GO",
"IDs",
"and",
"sections",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/tasks.py#L30-L33 |
228,481 | tanghaibao/goatools | goatools/grouper/tasks.py | SummarySec2dHdrGos._chk_hdrgoids | def _chk_hdrgoids(hdrgos):
"""Check that hdrgo set is a set of GO IDs."""
goid = next(iter(hdrgos))
if isinstance(goid, str) and goid[:3] == "GO:":
return
assert False, "HDRGOS DO NOT CONTAIN GO IDs: {E}".format(E=goid) | python | def _chk_hdrgoids(hdrgos):
"""Check that hdrgo set is a set of GO IDs."""
goid = next(iter(hdrgos))
if isinstance(goid, str) and goid[:3] == "GO:":
return
assert False, "HDRGOS DO NOT CONTAIN GO IDs: {E}".format(E=goid) | [
"def",
"_chk_hdrgoids",
"(",
"hdrgos",
")",
":",
"goid",
"=",
"next",
"(",
"iter",
"(",
"hdrgos",
")",
")",
"if",
"isinstance",
"(",
"goid",
",",
"str",
")",
"and",
"goid",
"[",
":",
"3",
"]",
"==",
"\"GO:\"",
":",
"return",
"assert",
"False",
",",... | Check that hdrgo set is a set of GO IDs. | [
"Check",
"that",
"hdrgo",
"set",
"is",
"a",
"set",
"of",
"GO",
"IDs",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/tasks.py#L36-L41 |
228,482 | tanghaibao/goatools | goatools/go_search.py | GoSearch.get_matching_gos | def get_matching_gos(self, compiled_pattern, **kws):
"""Return all GOs which match the user regex pattern."""
# kws: prt gos
matching_gos = []
obo_dag = self.obo_dag
prt = kws['prt'] if 'prt' in kws else self.log
prt.write('\nPATTERN SEARCH: "{P}"\n'.format(P=compiled_pat... | python | def get_matching_gos(self, compiled_pattern, **kws):
"""Return all GOs which match the user regex pattern."""
# kws: prt gos
matching_gos = []
obo_dag = self.obo_dag
prt = kws['prt'] if 'prt' in kws else self.log
prt.write('\nPATTERN SEARCH: "{P}"\n'.format(P=compiled_pat... | [
"def",
"get_matching_gos",
"(",
"self",
",",
"compiled_pattern",
",",
"*",
"*",
"kws",
")",
":",
"# kws: prt gos",
"matching_gos",
"=",
"[",
"]",
"obo_dag",
"=",
"self",
".",
"obo_dag",
"prt",
"=",
"kws",
"[",
"'prt'",
"]",
"if",
"'prt'",
"in",
"kws",
... | Return all GOs which match the user regex pattern. | [
"Return",
"all",
"GOs",
"which",
"match",
"the",
"user",
"regex",
"pattern",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/go_search.py#L20-L47 |
228,483 | tanghaibao/goatools | goatools/go_search.py | GoSearch._summary_matching_gos | def _summary_matching_gos(prt, pattern, matching_gos, all_gos):
"""Print summary for get_matching_gos."""
msg = 'Found {N} GO(s) out of {M} matching pattern("{P}")\n'
num_gos = len(matching_gos)
num_all = len(all_gos)
prt.write(msg.format(N=num_gos, M=num_all, P=pattern)) | python | def _summary_matching_gos(prt, pattern, matching_gos, all_gos):
"""Print summary for get_matching_gos."""
msg = 'Found {N} GO(s) out of {M} matching pattern("{P}")\n'
num_gos = len(matching_gos)
num_all = len(all_gos)
prt.write(msg.format(N=num_gos, M=num_all, P=pattern)) | [
"def",
"_summary_matching_gos",
"(",
"prt",
",",
"pattern",
",",
"matching_gos",
",",
"all_gos",
")",
":",
"msg",
"=",
"'Found {N} GO(s) out of {M} matching pattern(\"{P}\")\\n'",
"num_gos",
"=",
"len",
"(",
"matching_gos",
")",
"num_all",
"=",
"len",
"(",
"all_gos"... | Print summary for get_matching_gos. | [
"Print",
"summary",
"for",
"get_matching_gos",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/go_search.py#L50-L55 |
228,484 | tanghaibao/goatools | goatools/go_search.py | GoSearch._search_vals | def _search_vals(self, compiled_pattern, fld_val):
"""Search for user-regex in scalar or iterable data values."""
matches = []
if isinstance(fld_val, set):
for val in fld_val:
self._search_val(matches, compiled_pattern, val)
elif isinstance(fld_val, str):
... | python | def _search_vals(self, compiled_pattern, fld_val):
"""Search for user-regex in scalar or iterable data values."""
matches = []
if isinstance(fld_val, set):
for val in fld_val:
self._search_val(matches, compiled_pattern, val)
elif isinstance(fld_val, str):
... | [
"def",
"_search_vals",
"(",
"self",
",",
"compiled_pattern",
",",
"fld_val",
")",
":",
"matches",
"=",
"[",
"]",
"if",
"isinstance",
"(",
"fld_val",
",",
"set",
")",
":",
"for",
"val",
"in",
"fld_val",
":",
"self",
".",
"_search_val",
"(",
"matches",
"... | Search for user-regex in scalar or iterable data values. | [
"Search",
"for",
"user",
"-",
"regex",
"in",
"scalar",
"or",
"iterable",
"data",
"values",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/go_search.py#L57-L65 |
228,485 | tanghaibao/goatools | goatools/go_search.py | GoSearch._search_val | def _search_val(matches, compiled_pattern, fld_val):
"""Search for user-regex in scalar data values."""
mtch = compiled_pattern.search(fld_val)
if mtch:
matches.append(fld_val) | python | def _search_val(matches, compiled_pattern, fld_val):
"""Search for user-regex in scalar data values."""
mtch = compiled_pattern.search(fld_val)
if mtch:
matches.append(fld_val) | [
"def",
"_search_val",
"(",
"matches",
",",
"compiled_pattern",
",",
"fld_val",
")",
":",
"mtch",
"=",
"compiled_pattern",
".",
"search",
"(",
"fld_val",
")",
"if",
"mtch",
":",
"matches",
".",
"append",
"(",
"fld_val",
")"
] | Search for user-regex in scalar data values. | [
"Search",
"for",
"user",
"-",
"regex",
"in",
"scalar",
"data",
"values",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/go_search.py#L68-L72 |
228,486 | tanghaibao/goatools | goatools/go_search.py | GoSearch.add_children_gos | def add_children_gos(self, gos):
"""Return children of input gos plus input gos."""
lst = []
obo_dag = self.obo_dag
get_children = lambda go_obj: list(go_obj.get_all_children()) + [go_obj.id]
for go_id in gos:
go_obj = obo_dag[go_id]
lst.extend(get_childre... | python | def add_children_gos(self, gos):
"""Return children of input gos plus input gos."""
lst = []
obo_dag = self.obo_dag
get_children = lambda go_obj: list(go_obj.get_all_children()) + [go_obj.id]
for go_id in gos:
go_obj = obo_dag[go_id]
lst.extend(get_childre... | [
"def",
"add_children_gos",
"(",
"self",
",",
"gos",
")",
":",
"lst",
"=",
"[",
"]",
"obo_dag",
"=",
"self",
".",
"obo_dag",
"get_children",
"=",
"lambda",
"go_obj",
":",
"list",
"(",
"go_obj",
".",
"get_all_children",
"(",
")",
")",
"+",
"[",
"go_obj",... | Return children of input gos plus input gos. | [
"Return",
"children",
"of",
"input",
"gos",
"plus",
"input",
"gos",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/go_search.py#L74-L82 |
228,487 | tanghaibao/goatools | goatools/go_search.py | GoSearch.get_items | def get_items(self, gos):
"""Given GO terms, return genes or gene products for the GOs."""
items = []
for go_id in gos:
items.extend(self.go2items.get(go_id, []))
return set(items) | python | def get_items(self, gos):
"""Given GO terms, return genes or gene products for the GOs."""
items = []
for go_id in gos:
items.extend(self.go2items.get(go_id, []))
return set(items) | [
"def",
"get_items",
"(",
"self",
",",
"gos",
")",
":",
"items",
"=",
"[",
"]",
"for",
"go_id",
"in",
"gos",
":",
"items",
".",
"extend",
"(",
"self",
".",
"go2items",
".",
"get",
"(",
"go_id",
",",
"[",
"]",
")",
")",
"return",
"set",
"(",
"ite... | Given GO terms, return genes or gene products for the GOs. | [
"Given",
"GO",
"terms",
"return",
"genes",
"or",
"gene",
"products",
"for",
"the",
"GOs",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/go_search.py#L84-L89 |
228,488 | tanghaibao/goatools | goatools/gosubdag/plot/goea_results.py | GoeaResults.prt_summary | def prt_summary(self, prt=sys.stdout):
"""Print summary of GOEA plotting object."""
desc = "NtGoeaResults" if self.is_goterm else "namedtuple"
prt.write("{N} GOEA results from {O}. P-values stored in {P}.\n".format(
N=len(self.go2res), O=desc, P=self.pval_name)) | python | def prt_summary(self, prt=sys.stdout):
"""Print summary of GOEA plotting object."""
desc = "NtGoeaResults" if self.is_goterm else "namedtuple"
prt.write("{N} GOEA results from {O}. P-values stored in {P}.\n".format(
N=len(self.go2res), O=desc, P=self.pval_name)) | [
"def",
"prt_summary",
"(",
"self",
",",
"prt",
"=",
"sys",
".",
"stdout",
")",
":",
"desc",
"=",
"\"NtGoeaResults\"",
"if",
"self",
".",
"is_goterm",
"else",
"\"namedtuple\"",
"prt",
".",
"write",
"(",
"\"{N} GOEA results from {O}. P-values stored in {P}.\\n\"",
"... | Print summary of GOEA plotting object. | [
"Print",
"summary",
"of",
"GOEA",
"plotting",
"object",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/gosubdag/plot/goea_results.py#L40-L44 |
228,489 | tanghaibao/goatools | goatools/gosubdag/plot/goea_results.py | GoeaResults.set_goid2color_pval | def set_goid2color_pval(self, goid2color):
"""Fill missing colors based on p-value of an enriched GO term."""
alpha2col = self.alpha2col
if self.pval_name is not None:
pval_name = self.pval_name
for goid, res in self.go2res.items():
pval = getattr(res, pva... | python | def set_goid2color_pval(self, goid2color):
"""Fill missing colors based on p-value of an enriched GO term."""
alpha2col = self.alpha2col
if self.pval_name is not None:
pval_name = self.pval_name
for goid, res in self.go2res.items():
pval = getattr(res, pva... | [
"def",
"set_goid2color_pval",
"(",
"self",
",",
"goid2color",
")",
":",
"alpha2col",
"=",
"self",
".",
"alpha2col",
"if",
"self",
".",
"pval_name",
"is",
"not",
"None",
":",
"pval_name",
"=",
"self",
".",
"pval_name",
"for",
"goid",
",",
"res",
"in",
"se... | Fill missing colors based on p-value of an enriched GO term. | [
"Fill",
"missing",
"colors",
"based",
"on",
"p",
"-",
"value",
"of",
"an",
"enriched",
"GO",
"term",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/gosubdag/plot/goea_results.py#L55-L66 |
228,490 | tanghaibao/goatools | goatools/gosubdag/plot/goea_results.py | GoeaResults.get_goid2color_pval | def get_goid2color_pval(self):
"""Return a go2color dict containing GO colors determined by P-value."""
go2color = {}
self.set_goid2color_pval(go2color)
color_dflt = self.alpha2col[1.000]
for goid in self.go2res:
if goid not in go2color:
go2color[goid]... | python | def get_goid2color_pval(self):
"""Return a go2color dict containing GO colors determined by P-value."""
go2color = {}
self.set_goid2color_pval(go2color)
color_dflt = self.alpha2col[1.000]
for goid in self.go2res:
if goid not in go2color:
go2color[goid]... | [
"def",
"get_goid2color_pval",
"(",
"self",
")",
":",
"go2color",
"=",
"{",
"}",
"self",
".",
"set_goid2color_pval",
"(",
"go2color",
")",
"color_dflt",
"=",
"self",
".",
"alpha2col",
"[",
"1.000",
"]",
"for",
"goid",
"in",
"self",
".",
"go2res",
":",
"if... | Return a go2color dict containing GO colors determined by P-value. | [
"Return",
"a",
"go2color",
"dict",
"containing",
"GO",
"colors",
"determined",
"by",
"P",
"-",
"value",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/gosubdag/plot/goea_results.py#L68-L76 |
228,491 | tanghaibao/goatools | goatools/rpt/rpt_lev_depth.py | RptLevDepth.prttex_summary_cnts_all | def prttex_summary_cnts_all(self, prt=sys.stdout):
"""Print LaTeX format summary of level and depth counts for all active GO Terms."""
cnts = self.get_cnts_levels_depths_recs(set(self.obo.values()))
self._prttex_summary_cnts(prt, cnts) | python | def prttex_summary_cnts_all(self, prt=sys.stdout):
"""Print LaTeX format summary of level and depth counts for all active GO Terms."""
cnts = self.get_cnts_levels_depths_recs(set(self.obo.values()))
self._prttex_summary_cnts(prt, cnts) | [
"def",
"prttex_summary_cnts_all",
"(",
"self",
",",
"prt",
"=",
"sys",
".",
"stdout",
")",
":",
"cnts",
"=",
"self",
".",
"get_cnts_levels_depths_recs",
"(",
"set",
"(",
"self",
".",
"obo",
".",
"values",
"(",
")",
")",
")",
"self",
".",
"_prttex_summary... | Print LaTeX format summary of level and depth counts for all active GO Terms. | [
"Print",
"LaTeX",
"format",
"summary",
"of",
"level",
"and",
"depth",
"counts",
"for",
"all",
"active",
"GO",
"Terms",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/rpt/rpt_lev_depth.py#L82-L85 |
228,492 | tanghaibao/goatools | goatools/rpt/rpt_lev_depth.py | RptLevDepth.write_summary_cnts_all | def write_summary_cnts_all(self):
"""Write summary of level and depth counts for all active GO Terms."""
cnts = self.get_cnts_levels_depths_recs(set(self.obo.values()))
self._write_summary_cnts(cnts) | python | def write_summary_cnts_all(self):
"""Write summary of level and depth counts for all active GO Terms."""
cnts = self.get_cnts_levels_depths_recs(set(self.obo.values()))
self._write_summary_cnts(cnts) | [
"def",
"write_summary_cnts_all",
"(",
"self",
")",
":",
"cnts",
"=",
"self",
".",
"get_cnts_levels_depths_recs",
"(",
"set",
"(",
"self",
".",
"obo",
".",
"values",
"(",
")",
")",
")",
"self",
".",
"_write_summary_cnts",
"(",
"cnts",
")"
] | Write summary of level and depth counts for all active GO Terms. | [
"Write",
"summary",
"of",
"level",
"and",
"depth",
"counts",
"for",
"all",
"active",
"GO",
"Terms",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/rpt/rpt_lev_depth.py#L87-L90 |
228,493 | tanghaibao/goatools | goatools/rpt/rpt_lev_depth.py | RptLevDepth.write_summary_cnts | def write_summary_cnts(self, go_ids):
"""Write summary of level and depth counts for specific GO ids."""
obo = self.obo
cnts = self.get_cnts_levels_depths_recs([obo.get(GO) for GO in go_ids])
self._write_summary_cnts(cnts) | python | def write_summary_cnts(self, go_ids):
"""Write summary of level and depth counts for specific GO ids."""
obo = self.obo
cnts = self.get_cnts_levels_depths_recs([obo.get(GO) for GO in go_ids])
self._write_summary_cnts(cnts) | [
"def",
"write_summary_cnts",
"(",
"self",
",",
"go_ids",
")",
":",
"obo",
"=",
"self",
".",
"obo",
"cnts",
"=",
"self",
".",
"get_cnts_levels_depths_recs",
"(",
"[",
"obo",
".",
"get",
"(",
"GO",
")",
"for",
"GO",
"in",
"go_ids",
"]",
")",
"self",
".... | Write summary of level and depth counts for specific GO ids. | [
"Write",
"summary",
"of",
"level",
"and",
"depth",
"counts",
"for",
"specific",
"GO",
"ids",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/rpt/rpt_lev_depth.py#L92-L96 |
228,494 | tanghaibao/goatools | goatools/rpt/rpt_lev_depth.py | RptLevDepth.get_cnts_levels_depths_recs | def get_cnts_levels_depths_recs(recs):
"""Collect counts of levels and depths in a Group of GO Terms."""
cnts = cx.defaultdict(lambda: cx.defaultdict(cx.Counter))
for rec in recs:
if rec is not None and not rec.is_obsolete:
cnts['level'][rec.level][rec.namespace] += 1... | python | def get_cnts_levels_depths_recs(recs):
"""Collect counts of levels and depths in a Group of GO Terms."""
cnts = cx.defaultdict(lambda: cx.defaultdict(cx.Counter))
for rec in recs:
if rec is not None and not rec.is_obsolete:
cnts['level'][rec.level][rec.namespace] += 1... | [
"def",
"get_cnts_levels_depths_recs",
"(",
"recs",
")",
":",
"cnts",
"=",
"cx",
".",
"defaultdict",
"(",
"lambda",
":",
"cx",
".",
"defaultdict",
"(",
"cx",
".",
"Counter",
")",
")",
"for",
"rec",
"in",
"recs",
":",
"if",
"rec",
"is",
"not",
"None",
... | Collect counts of levels and depths in a Group of GO Terms. | [
"Collect",
"counts",
"of",
"levels",
"and",
"depths",
"in",
"a",
"Group",
"of",
"GO",
"Terms",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/rpt/rpt_lev_depth.py#L149-L156 |
228,495 | tanghaibao/goatools | goatools/rpt/rpt_lev_depth.py | RptLevDepth.get_data | def get_data(self):
"""Collect counts of GO terms at all levels and depths."""
# Count level(shortest path to root) and depth(longest path to root)
# values for all unique GO Terms.
data = []
ntobj = cx.namedtuple("NtGoCnt", "Depth_Level BP_D MF_D CC_D BP_L MF_L CC_L")
cn... | python | def get_data(self):
"""Collect counts of GO terms at all levels and depths."""
# Count level(shortest path to root) and depth(longest path to root)
# values for all unique GO Terms.
data = []
ntobj = cx.namedtuple("NtGoCnt", "Depth_Level BP_D MF_D CC_D BP_L MF_L CC_L")
cn... | [
"def",
"get_data",
"(",
"self",
")",
":",
"# Count level(shortest path to root) and depth(longest path to root)",
"# values for all unique GO Terms.",
"data",
"=",
"[",
"]",
"ntobj",
"=",
"cx",
".",
"namedtuple",
"(",
"\"NtGoCnt\"",
",",
"\"Depth_Level BP_D MF_D CC_D BP_L MF_... | Collect counts of GO terms at all levels and depths. | [
"Collect",
"counts",
"of",
"GO",
"terms",
"at",
"all",
"levels",
"and",
"depths",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/rpt/rpt_lev_depth.py#L158-L169 |
228,496 | tanghaibao/goatools | scripts/find_enrichment.py | main | def main():
"""Run gene enrichment analysis."""
# Load study, population, associations, and GoDag. Run GOEA.
obj = GoeaCliFnc(GoeaCliArgs().args)
# Reduce results to significant results (pval<value)
results_specified = obj.get_results()
# Print results in a flat list
obj.prt_results(results_... | python | def main():
"""Run gene enrichment analysis."""
# Load study, population, associations, and GoDag. Run GOEA.
obj = GoeaCliFnc(GoeaCliArgs().args)
# Reduce results to significant results (pval<value)
results_specified = obj.get_results()
# Print results in a flat list
obj.prt_results(results_... | [
"def",
"main",
"(",
")",
":",
"# Load study, population, associations, and GoDag. Run GOEA.",
"obj",
"=",
"GoeaCliFnc",
"(",
"GoeaCliArgs",
"(",
")",
".",
"args",
")",
"# Reduce results to significant results (pval<value)",
"results_specified",
"=",
"obj",
".",
"get_results... | Run gene enrichment analysis. | [
"Run",
"gene",
"enrichment",
"analysis",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/scripts/find_enrichment.py#L28-L35 |
228,497 | tanghaibao/goatools | goatools/anno/factory.py | get_objanno | def get_objanno(fin_anno, anno_type=None, **kws):
"""Read annotations in GAF, GPAD, Entrez gene2go, or text format."""
# kws get_objanno: taxids hdr_only prt allow_missing_symbol
anno_type = get_anno_desc(fin_anno, anno_type)
if anno_type is not None:
if anno_type == 'gene2go':
# kws... | python | def get_objanno(fin_anno, anno_type=None, **kws):
"""Read annotations in GAF, GPAD, Entrez gene2go, or text format."""
# kws get_objanno: taxids hdr_only prt allow_missing_symbol
anno_type = get_anno_desc(fin_anno, anno_type)
if anno_type is not None:
if anno_type == 'gene2go':
# kws... | [
"def",
"get_objanno",
"(",
"fin_anno",
",",
"anno_type",
"=",
"None",
",",
"*",
"*",
"kws",
")",
":",
"# kws get_objanno: taxids hdr_only prt allow_missing_symbol",
"anno_type",
"=",
"get_anno_desc",
"(",
"fin_anno",
",",
"anno_type",
")",
"if",
"anno_type",
"is",
... | Read annotations in GAF, GPAD, Entrez gene2go, or text format. | [
"Read",
"annotations",
"in",
"GAF",
"GPAD",
"Entrez",
"gene2go",
"or",
"text",
"format",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/anno/factory.py#L13-L32 |
228,498 | tanghaibao/goatools | goatools/anno/gpad_reader.py | GpadReader.get_relation_cnt | def get_relation_cnt(self):
"""Return a Counter containing all relations contained in the Annotation Extensions."""
ctr = cx.Counter()
for ntgpad in self.associations:
if ntgpad.Extension is not None:
ctr += ntgpad.Extension.get_relations_cnt()
return ctr | python | def get_relation_cnt(self):
"""Return a Counter containing all relations contained in the Annotation Extensions."""
ctr = cx.Counter()
for ntgpad in self.associations:
if ntgpad.Extension is not None:
ctr += ntgpad.Extension.get_relations_cnt()
return ctr | [
"def",
"get_relation_cnt",
"(",
"self",
")",
":",
"ctr",
"=",
"cx",
".",
"Counter",
"(",
")",
"for",
"ntgpad",
"in",
"self",
".",
"associations",
":",
"if",
"ntgpad",
".",
"Extension",
"is",
"not",
"None",
":",
"ctr",
"+=",
"ntgpad",
".",
"Extension",
... | Return a Counter containing all relations contained in the Annotation Extensions. | [
"Return",
"a",
"Counter",
"containing",
"all",
"relations",
"contained",
"in",
"the",
"Annotation",
"Extensions",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/anno/gpad_reader.py#L24-L30 |
228,499 | tanghaibao/goatools | goatools/cli/find_enrichment.py | GoeaCliFnc._get_id2gos | def _get_id2gos(self):
"""Return annotations as id2gos"""
kws = {}
if self.args.ev_inc is not None:
kws['ev_include'] = set(self.args.ev_inc.split(','))
if self.args.ev_exc is not None:
kws['ev_exclude'] = set(self.args.ev_exc.split(','))
return self.objan... | python | def _get_id2gos(self):
"""Return annotations as id2gos"""
kws = {}
if self.args.ev_inc is not None:
kws['ev_include'] = set(self.args.ev_inc.split(','))
if self.args.ev_exc is not None:
kws['ev_exclude'] = set(self.args.ev_exc.split(','))
return self.objan... | [
"def",
"_get_id2gos",
"(",
"self",
")",
":",
"kws",
"=",
"{",
"}",
"if",
"self",
".",
"args",
".",
"ev_inc",
"is",
"not",
"None",
":",
"kws",
"[",
"'ev_include'",
"]",
"=",
"set",
"(",
"self",
".",
"args",
".",
"ev_inc",
".",
"split",
"(",
"','",... | Return annotations as id2gos | [
"Return",
"annotations",
"as",
"id2gos"
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/cli/find_enrichment.py#L182-L189 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.