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,500
tanghaibao/goatools
goatools/cli/find_enrichment.py
GoeaCliFnc._get_objanno
def _get_objanno(self, assoc_fn): """Get an annotation object""" # Determine annotation file format from filename, if possible anno_type = get_anno_desc(assoc_fn, None) # Default annotation file format is id2gos if anno_type is None: anno_type = self.args.annofmt if s...
python
def _get_objanno(self, assoc_fn): """Get an annotation object""" # Determine annotation file format from filename, if possible anno_type = get_anno_desc(assoc_fn, None) # Default annotation file format is id2gos if anno_type is None: anno_type = self.args.annofmt if s...
[ "def", "_get_objanno", "(", "self", ",", "assoc_fn", ")", ":", "# Determine annotation file format from filename, if possible", "anno_type", "=", "get_anno_desc", "(", "assoc_fn", ",", "None", ")", "# Default annotation file format is id2gos", "if", "anno_type", "is", "None...
Get an annotation object
[ "Get", "an", "annotation", "object" ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/cli/find_enrichment.py#L191-L199
228,501
tanghaibao/goatools
goatools/cli/find_enrichment.py
GoeaCliFnc._init_itemid2name
def _init_itemid2name(self): """Print gene symbols instead of gene IDs, if provided.""" if not hasattr(self.args, 'id2sym'): return None fin_id2sym = self.args.id2sym if fin_id2sym is not None and os.path.exists(fin_id2sym): id2sym = {} cmpl = re.compi...
python
def _init_itemid2name(self): """Print gene symbols instead of gene IDs, if provided.""" if not hasattr(self.args, 'id2sym'): return None fin_id2sym = self.args.id2sym if fin_id2sym is not None and os.path.exists(fin_id2sym): id2sym = {} cmpl = re.compi...
[ "def", "_init_itemid2name", "(", "self", ")", ":", "if", "not", "hasattr", "(", "self", ".", "args", ",", "'id2sym'", ")", ":", "return", "None", "fin_id2sym", "=", "self", ".", "args", ".", "id2sym", "if", "fin_id2sym", "is", "not", "None", "and", "os...
Print gene symbols instead of gene IDs, if provided.
[ "Print", "gene", "symbols", "instead", "of", "gene", "IDs", "if", "provided", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/cli/find_enrichment.py#L201-L214
228,502
tanghaibao/goatools
goatools/cli/find_enrichment.py
GoeaCliFnc.prt_results
def prt_results(self, goea_results): """Print GOEA results to the screen or to a file.""" # objaart = self.prepgrp.get_objaart(goea_results) if self.prepgrp is not None else None if self.args.outfile is None: self._prt_results(goea_results) else: # Users can print...
python
def prt_results(self, goea_results): """Print GOEA results to the screen or to a file.""" # objaart = self.prepgrp.get_objaart(goea_results) if self.prepgrp is not None else None if self.args.outfile is None: self._prt_results(goea_results) else: # Users can print...
[ "def", "prt_results", "(", "self", ",", "goea_results", ")", ":", "# objaart = self.prepgrp.get_objaart(goea_results) if self.prepgrp is not None else None", "if", "self", ".", "args", ".", "outfile", "is", "None", ":", "self", ".", "_prt_results", "(", "goea_results", ...
Print GOEA results to the screen or to a file.
[ "Print", "GOEA", "results", "to", "the", "screen", "or", "to", "a", "file", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/cli/find_enrichment.py#L216-L228
228,503
tanghaibao/goatools
goatools/cli/find_enrichment.py
GoeaCliFnc._prt_results
def _prt_results(self, goea_results): """Print GOEA results to the screen.""" min_ratio = self.args.ratio if min_ratio is not None: assert 1 <= min_ratio <= 2 self.objgoea.print_date(min_ratio=min_ratio, pval=self.args.pval) results_adj = self.objgoea.get_adj_records(...
python
def _prt_results(self, goea_results): """Print GOEA results to the screen.""" min_ratio = self.args.ratio if min_ratio is not None: assert 1 <= min_ratio <= 2 self.objgoea.print_date(min_ratio=min_ratio, pval=self.args.pval) results_adj = self.objgoea.get_adj_records(...
[ "def", "_prt_results", "(", "self", ",", "goea_results", ")", ":", "min_ratio", "=", "self", ".", "args", ".", "ratio", "if", "min_ratio", "is", "not", "None", ":", "assert", "1", "<=", "min_ratio", "<=", "2", "self", ".", "objgoea", ".", "print_date", ...
Print GOEA results to the screen.
[ "Print", "GOEA", "results", "to", "the", "screen", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/cli/find_enrichment.py#L241-L253
228,504
tanghaibao/goatools
goatools/cli/find_enrichment.py
GoeaCliFnc.chk_genes
def chk_genes(self, study, pop, assoc=None): """Check gene sets.""" if len(pop) < len(study): exit("\nERROR: The study file contains more elements than the population file. " "Please check that the study file is a subset of the population file.\n") # check the fracti...
python
def chk_genes(self, study, pop, assoc=None): """Check gene sets.""" if len(pop) < len(study): exit("\nERROR: The study file contains more elements than the population file. " "Please check that the study file is a subset of the population file.\n") # check the fracti...
[ "def", "chk_genes", "(", "self", ",", "study", ",", "pop", ",", "assoc", "=", "None", ")", ":", "if", "len", "(", "pop", ")", "<", "len", "(", "study", ")", ":", "exit", "(", "\"\\nERROR: The study file contains more elements than the population file. \"", "\"...
Check gene sets.
[ "Check", "gene", "sets", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/cli/find_enrichment.py#L269-L289
228,505
tanghaibao/goatools
goatools/cli/find_enrichment.py
GoeaCliFnc.get_results_sig
def get_results_sig(self): """Get significant results.""" # Only print results when uncorrected p-value < this value. print("{N:7,} of {M:,} results have uncorrected P-values <= {PVAL}=pval\n".format( N=sum(1 for r in self.results_all if r.p_uncorrected < self.args.pval), ...
python
def get_results_sig(self): """Get significant results.""" # Only print results when uncorrected p-value < this value. print("{N:7,} of {M:,} results have uncorrected P-values <= {PVAL}=pval\n".format( N=sum(1 for r in self.results_all if r.p_uncorrected < self.args.pval), ...
[ "def", "get_results_sig", "(", "self", ")", ":", "# Only print results when uncorrected p-value < this value.", "print", "(", "\"{N:7,} of {M:,} results have uncorrected P-values <= {PVAL}=pval\\n\"", ".", "format", "(", "N", "=", "sum", "(", "1", "for", "r", "in", "self", ...
Get significant results.
[ "Get", "significant", "results", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/cli/find_enrichment.py#L291-L300
228,506
tanghaibao/goatools
goatools/cli/find_enrichment.py
GoeaCliFnc.get_pval_field
def get_pval_field(self): """Get 'p_uncorrected' or the user-specified field for determining significant results.""" pval_fld = self.args.pval_field # If --pval_field [VAL] was specified if pval_fld is not None: if pval_fld[:2] != 'p_': pval_fld = 'p_' + pval_...
python
def get_pval_field(self): """Get 'p_uncorrected' or the user-specified field for determining significant results.""" pval_fld = self.args.pval_field # If --pval_field [VAL] was specified if pval_fld is not None: if pval_fld[:2] != 'p_': pval_fld = 'p_' + pval_...
[ "def", "get_pval_field", "(", "self", ")", ":", "pval_fld", "=", "self", ".", "args", ".", "pval_field", "# If --pval_field [VAL] was specified", "if", "pval_fld", "is", "not", "None", ":", "if", "pval_fld", "[", ":", "2", "]", "!=", "'p_'", ":", "pval_fld",...
Get 'p_uncorrected' or the user-specified field for determining significant results.
[ "Get", "p_uncorrected", "or", "the", "user", "-", "specified", "field", "for", "determining", "significant", "results", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/cli/find_enrichment.py#L307-L325
228,507
tanghaibao/goatools
goatools/cli/find_enrichment.py
GoeaCliFnc.rd_files
def rd_files(self, study_fn, pop_fn): """Read files and return study and population.""" study, pop = self._read_geneset(study_fn, pop_fn) print("Study: {0} vs. Population {1}\n".format(len(study), len(pop))) return study, pop
python
def rd_files(self, study_fn, pop_fn): """Read files and return study and population.""" study, pop = self._read_geneset(study_fn, pop_fn) print("Study: {0} vs. Population {1}\n".format(len(study), len(pop))) return study, pop
[ "def", "rd_files", "(", "self", ",", "study_fn", ",", "pop_fn", ")", ":", "study", ",", "pop", "=", "self", ".", "_read_geneset", "(", "study_fn", ",", "pop_fn", ")", "print", "(", "\"Study: {0} vs. Population {1}\\n\"", ".", "format", "(", "len", "(", "st...
Read files and return study and population.
[ "Read", "files", "and", "return", "study", "and", "population", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/cli/find_enrichment.py#L327-L331
228,508
tanghaibao/goatools
goatools/cli/find_enrichment.py
GoeaCliFnc._read_geneset
def _read_geneset(self, study_fn, pop_fn): """Open files containing genes. Return study genes and population genes.""" pop = set(_.strip() for _ in open(pop_fn) if _.strip()) study = frozenset(_.strip() for _ in open(study_fn) if _.strip()) if next(iter(pop)).isdigit(): pop =...
python
def _read_geneset(self, study_fn, pop_fn): """Open files containing genes. Return study genes and population genes.""" pop = set(_.strip() for _ in open(pop_fn) if _.strip()) study = frozenset(_.strip() for _ in open(study_fn) if _.strip()) if next(iter(pop)).isdigit(): pop =...
[ "def", "_read_geneset", "(", "self", ",", "study_fn", ",", "pop_fn", ")", ":", "pop", "=", "set", "(", "_", ".", "strip", "(", ")", "for", "_", "in", "open", "(", "pop_fn", ")", "if", "_", ".", "strip", "(", ")", ")", "study", "=", "frozenset", ...
Open files containing genes. Return study genes and population genes.
[ "Open", "files", "containing", "genes", ".", "Return", "study", "genes", "and", "population", "genes", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/cli/find_enrichment.py#L333-L351
228,509
tanghaibao/goatools
goatools/cli/find_enrichment.py
GroupItems.get_objgrpwr
def get_objgrpwr(self, goea_results): """Get a GrpWr object to write grouped GOEA results.""" sortobj = self.get_sortobj(goea_results) return GrpWr(sortobj, self.pval_fld, ver_list=self.ver_list)
python
def get_objgrpwr(self, goea_results): """Get a GrpWr object to write grouped GOEA results.""" sortobj = self.get_sortobj(goea_results) return GrpWr(sortobj, self.pval_fld, ver_list=self.ver_list)
[ "def", "get_objgrpwr", "(", "self", ",", "goea_results", ")", ":", "sortobj", "=", "self", ".", "get_sortobj", "(", "goea_results", ")", "return", "GrpWr", "(", "sortobj", ",", "self", ".", "pval_fld", ",", "ver_list", "=", "self", ".", "ver_list", ")" ]
Get a GrpWr object to write grouped GOEA results.
[ "Get", "a", "GrpWr", "object", "to", "write", "grouped", "GOEA", "results", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/cli/find_enrichment.py#L370-L373
228,510
tanghaibao/goatools
goatools/cli/find_enrichment.py
GroupItems.get_sortobj
def get_sortobj(self, goea_results, **kws): """Return a Grouper object, given a list of GOEnrichmentRecord.""" nts_goea = MgrNtGOEAs(goea_results).get_goea_nts_prt(**kws) goids = set(nt.GO for nt in nts_goea) go2nt = {nt.GO:nt for nt in nts_goea} grprobj = Grouper("GOEA", goids, ...
python
def get_sortobj(self, goea_results, **kws): """Return a Grouper object, given a list of GOEnrichmentRecord.""" nts_goea = MgrNtGOEAs(goea_results).get_goea_nts_prt(**kws) goids = set(nt.GO for nt in nts_goea) go2nt = {nt.GO:nt for nt in nts_goea} grprobj = Grouper("GOEA", goids, ...
[ "def", "get_sortobj", "(", "self", ",", "goea_results", ",", "*", "*", "kws", ")", ":", "nts_goea", "=", "MgrNtGOEAs", "(", "goea_results", ")", ".", "get_goea_nts_prt", "(", "*", "*", "kws", ")", "goids", "=", "set", "(", "nt", ".", "GO", "for", "nt...
Return a Grouper object, given a list of GOEnrichmentRecord.
[ "Return", "a", "Grouper", "object", "given", "a", "list", "of", "GOEnrichmentRecord", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/cli/find_enrichment.py#L375-L384
228,511
tanghaibao/goatools
goatools/cli/find_enrichment.py
GroupItems._init_objaartall
def _init_objaartall(self): """Get background database info for making ASCII art.""" kws = { 'sortgo':lambda nt: [nt.NS, nt.dcnt], # fmtgo=('{p_fdr_bh:8.2e} {GO} ' # Formatting for GO terms in grouped GO list 'fmtgo':('{hdr1usr01:2} {NS} {GO} {s_fdr_bh:8} ...
python
def _init_objaartall(self): """Get background database info for making ASCII art.""" kws = { 'sortgo':lambda nt: [nt.NS, nt.dcnt], # fmtgo=('{p_fdr_bh:8.2e} {GO} ' # Formatting for GO terms in grouped GO list 'fmtgo':('{hdr1usr01:2} {NS} {GO} {s_fdr_bh:8} ...
[ "def", "_init_objaartall", "(", "self", ")", ":", "kws", "=", "{", "'sortgo'", ":", "lambda", "nt", ":", "[", "nt", ".", "NS", ",", "nt", ".", "dcnt", "]", ",", "# fmtgo=('{p_fdr_bh:8.2e} {GO} '", "# Formatting for GO terms in grouped GO list", "'fmtgo'", ":", ...
Get background database info for making ASCII art.
[ "Get", "background", "database", "info", "for", "making", "ASCII", "art", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/cli/find_enrichment.py#L392-L407
228,512
tanghaibao/goatools
goatools/cli/find_enrichment.py
GrpWr.wr_xlsx
def wr_xlsx(self, fout_xlsx): """Print grouped GOEA results into an xlsx file.""" objwr = WrXlsxSortedGos("GOEA", self.sortobj) #### fld2fmt['ratio_in_study'] = '{:>8}' #### fld2fmt['ratio_in_pop'] = '{:>12}' #### ntfld2wbfmtdict = { # ntfld_wbfmt = { # 'ratio...
python
def wr_xlsx(self, fout_xlsx): """Print grouped GOEA results into an xlsx file.""" objwr = WrXlsxSortedGos("GOEA", self.sortobj) #### fld2fmt['ratio_in_study'] = '{:>8}' #### fld2fmt['ratio_in_pop'] = '{:>12}' #### ntfld2wbfmtdict = { # ntfld_wbfmt = { # 'ratio...
[ "def", "wr_xlsx", "(", "self", ",", "fout_xlsx", ")", ":", "objwr", "=", "WrXlsxSortedGos", "(", "\"GOEA\"", ",", "self", ".", "sortobj", ")", "#### fld2fmt['ratio_in_study'] = '{:>8}'", "#### fld2fmt['ratio_in_pop'] = '{:>12}'", "#### ntfld2wbfmtdict = {", "# ntfld_wbfmt =...
Print grouped GOEA results into an xlsx file.
[ "Print", "grouped", "GOEA", "results", "into", "an", "xlsx", "file", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/cli/find_enrichment.py#L432-L448
228,513
tanghaibao/goatools
goatools/cli/find_enrichment.py
GrpWr.wr_tsv
def wr_tsv(self, fout_tsv): """Print grouped GOEA results into a tab-separated file.""" with open(fout_tsv, 'w') as prt: kws_tsv = { 'fld2fmt': {f:'{:8.2e}' for f in self.flds_cur if f[:2] == 'p_'}, 'prt_flds':self.flds_cur} prt_tsv_sections(prt, s...
python
def wr_tsv(self, fout_tsv): """Print grouped GOEA results into a tab-separated file.""" with open(fout_tsv, 'w') as prt: kws_tsv = { 'fld2fmt': {f:'{:8.2e}' for f in self.flds_cur if f[:2] == 'p_'}, 'prt_flds':self.flds_cur} prt_tsv_sections(prt, s...
[ "def", "wr_tsv", "(", "self", ",", "fout_tsv", ")", ":", "with", "open", "(", "fout_tsv", ",", "'w'", ")", "as", "prt", ":", "kws_tsv", "=", "{", "'fld2fmt'", ":", "{", "f", ":", "'{:8.2e}'", "for", "f", "in", "self", ".", "flds_cur", "if", "f", ...
Print grouped GOEA results into a tab-separated file.
[ "Print", "grouped", "GOEA", "results", "into", "a", "tab", "-", "separated", "file", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/cli/find_enrichment.py#L450-L457
228,514
tanghaibao/goatools
goatools/cli/find_enrichment.py
GrpWr.wr_txt
def wr_txt(self, fout_txt): """Write to a file GOEA results in an ASCII text format.""" with open(fout_txt, 'w') as prt: for line in self.ver_list: prt.write("{LINE}\n".format(LINE=line)) self.prt_txt(prt) print(" WROTE: {TXT}".format(TXT=fout_txt))
python
def wr_txt(self, fout_txt): """Write to a file GOEA results in an ASCII text format.""" with open(fout_txt, 'w') as prt: for line in self.ver_list: prt.write("{LINE}\n".format(LINE=line)) self.prt_txt(prt) print(" WROTE: {TXT}".format(TXT=fout_txt))
[ "def", "wr_txt", "(", "self", ",", "fout_txt", ")", ":", "with", "open", "(", "fout_txt", ",", "'w'", ")", "as", "prt", ":", "for", "line", "in", "self", ".", "ver_list", ":", "prt", ".", "write", "(", "\"{LINE}\\n\"", ".", "format", "(", "LINE", "...
Write to a file GOEA results in an ASCII text format.
[ "Write", "to", "a", "file", "GOEA", "results", "in", "an", "ASCII", "text", "format", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/cli/find_enrichment.py#L459-L465
228,515
tanghaibao/goatools
goatools/cli/find_enrichment.py
GrpWr.prt_tsv
def prt_tsv(self, prt=sys.stdout): """Print an ASCII text format.""" prtfmt = self.objprt.get_prtfmt_str(self.flds_cur) prt.write("{FLDS}\n".format(FLDS=" ".join(self.flds_cur))) WrSectionsTxt.prt_sections(prt, self.desc2nts['sections'], prtfmt, secspc=True)
python
def prt_tsv(self, prt=sys.stdout): """Print an ASCII text format.""" prtfmt = self.objprt.get_prtfmt_str(self.flds_cur) prt.write("{FLDS}\n".format(FLDS=" ".join(self.flds_cur))) WrSectionsTxt.prt_sections(prt, self.desc2nts['sections'], prtfmt, secspc=True)
[ "def", "prt_tsv", "(", "self", ",", "prt", "=", "sys", ".", "stdout", ")", ":", "prtfmt", "=", "self", ".", "objprt", ".", "get_prtfmt_str", "(", "self", ".", "flds_cur", ")", "prt", ".", "write", "(", "\"{FLDS}\\n\"", ".", "format", "(", "FLDS", "="...
Print an ASCII text format.
[ "Print", "an", "ASCII", "text", "format", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/cli/find_enrichment.py#L467-L471
228,516
tanghaibao/goatools
goatools/cli/find_enrichment.py
GrpWr._init_flds_cur
def _init_flds_cur(self): """Choose fields to print from a multitude of available fields.""" flds = [] # ('GO', 'NS', 'enrichment', 'name', 'ratio_in_study', 'ratio_in_pop', 'depth', # 'p_uncorrected', 'p_bonferroni', 'p_sidak', 'p_holm', 'p_fdr_bh', # 'pop_n', 'pop_count', 'pop_...
python
def _init_flds_cur(self): """Choose fields to print from a multitude of available fields.""" flds = [] # ('GO', 'NS', 'enrichment', 'name', 'ratio_in_study', 'ratio_in_pop', 'depth', # 'p_uncorrected', 'p_bonferroni', 'p_sidak', 'p_holm', 'p_fdr_bh', # 'pop_n', 'pop_count', 'pop_...
[ "def", "_init_flds_cur", "(", "self", ")", ":", "flds", "=", "[", "]", "# ('GO', 'NS', 'enrichment', 'name', 'ratio_in_study', 'ratio_in_pop', 'depth',", "# 'p_uncorrected', 'p_bonferroni', 'p_sidak', 'p_holm', 'p_fdr_bh',", "# 'pop_n', 'pop_count', 'pop_items'", "# 'study_n', 'study_count...
Choose fields to print from a multitude of available fields.
[ "Choose", "fields", "to", "print", "from", "a", "multitude", "of", "available", "fields", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/cli/find_enrichment.py#L479-L499
228,517
tanghaibao/goatools
goatools/parsers/ncbi_gene_file_reader.py
NCBIgeneFileReader.do_hdr
def do_hdr(self, line, hdrs_usr): """Initialize self.h2i.""" # If there is no header hint, consider the first line the header. if self.hdr_ex is None: self._init_hdr(line, hdrs_usr) return True # If there is a header hint, examine each beginning line until header ...
python
def do_hdr(self, line, hdrs_usr): """Initialize self.h2i.""" # If there is no header hint, consider the first line the header. if self.hdr_ex is None: self._init_hdr(line, hdrs_usr) return True # If there is a header hint, examine each beginning line until header ...
[ "def", "do_hdr", "(", "self", ",", "line", ",", "hdrs_usr", ")", ":", "# If there is no header hint, consider the first line the header.", "if", "self", ".", "hdr_ex", "is", "None", ":", "self", ".", "_init_hdr", "(", "line", ",", "hdrs_usr", ")", "return", "Tru...
Initialize self.h2i.
[ "Initialize", "self", ".", "h2i", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/parsers/ncbi_gene_file_reader.py#L84-L94
228,518
tanghaibao/goatools
goatools/parsers/ncbi_gene_file_reader.py
NCBIgeneFileReader.hdr_xform
def hdr_xform(self, hdrs): """Transform NCBI Gene header fields into valid namedtuple fields.""" xform = [] hdrs = self.replace_nulls(hdrs) for hdr in hdrs: hdr = hdr.replace('.', '_') hdr = hdr.replace(' ', '_') hdr = hdr.replace('#', 'N') ...
python
def hdr_xform(self, hdrs): """Transform NCBI Gene header fields into valid namedtuple fields.""" xform = [] hdrs = self.replace_nulls(hdrs) for hdr in hdrs: hdr = hdr.replace('.', '_') hdr = hdr.replace(' ', '_') hdr = hdr.replace('#', 'N') ...
[ "def", "hdr_xform", "(", "self", ",", "hdrs", ")", ":", "xform", "=", "[", "]", "hdrs", "=", "self", ".", "replace_nulls", "(", "hdrs", ")", "for", "hdr", "in", "hdrs", ":", "hdr", "=", "hdr", ".", "replace", "(", "'.'", ",", "'_'", ")", "hdr", ...
Transform NCBI Gene header fields into valid namedtuple fields.
[ "Transform", "NCBI", "Gene", "header", "fields", "into", "valid", "namedtuple", "fields", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/parsers/ncbi_gene_file_reader.py#L146-L157
228,519
tanghaibao/goatools
goatools/parsers/ncbi_gene_file_reader.py
NCBIgeneFileReader._init_nt_hdr
def _init_nt_hdr(self, line): """Convert headers into valid namedtuple fields.""" line = line.replace('.', '_') line = line.replace(' ', '_') line = line.replace('#', 'N') line = line.replace('-', '_') line = line.replace('"', '') #line = re.sub(r"_$", r"", line) ...
python
def _init_nt_hdr(self, line): """Convert headers into valid namedtuple fields.""" line = line.replace('.', '_') line = line.replace(' ', '_') line = line.replace('#', 'N') line = line.replace('-', '_') line = line.replace('"', '') #line = re.sub(r"_$", r"", line) ...
[ "def", "_init_nt_hdr", "(", "self", ",", "line", ")", ":", "line", "=", "line", ".", "replace", "(", "'.'", ",", "'_'", ")", "line", "=", "line", ".", "replace", "(", "' '", ",", "'_'", ")", "line", "=", "line", ".", "replace", "(", "'#'", ",", ...
Convert headers into valid namedtuple fields.
[ "Convert", "headers", "into", "valid", "namedtuple", "fields", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/parsers/ncbi_gene_file_reader.py#L159-L174
228,520
tanghaibao/goatools
goatools/parsers/ncbi_gene_file_reader.py
NCBIgeneFileReader.replace_nulls
def replace_nulls(hdrs): """Replace '' in hdrs.""" ret = [] idx = 0 for hdr in hdrs: if hdr == '': ret.append("no_hdr{}".format(idx)) else: ret.append(hdr) return ret
python
def replace_nulls(hdrs): """Replace '' in hdrs.""" ret = [] idx = 0 for hdr in hdrs: if hdr == '': ret.append("no_hdr{}".format(idx)) else: ret.append(hdr) return ret
[ "def", "replace_nulls", "(", "hdrs", ")", ":", "ret", "=", "[", "]", "idx", "=", "0", "for", "hdr", "in", "hdrs", ":", "if", "hdr", "==", "''", ":", "ret", ".", "append", "(", "\"no_hdr{}\"", ".", "format", "(", "idx", ")", ")", "else", ":", "r...
Replace '' in hdrs.
[ "Replace", "in", "hdrs", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/parsers/ncbi_gene_file_reader.py#L187-L196
228,521
tanghaibao/goatools
goatools/parsers/ncbi_gene_file_reader.py
NCBIgeneFileReader._init_data_line
def _init_data_line(self, fnc, lnum, line): """Process Data line.""" fld = re.split(self.sep, line) # Lines may contain different numbers of items. # The line should have all columns requested by the user. if self.usr_max_idx < len(fld): self.convert_ints_floats(fld) ...
python
def _init_data_line(self, fnc, lnum, line): """Process Data line.""" fld = re.split(self.sep, line) # Lines may contain different numbers of items. # The line should have all columns requested by the user. if self.usr_max_idx < len(fld): self.convert_ints_floats(fld) ...
[ "def", "_init_data_line", "(", "self", ",", "fnc", ",", "lnum", ",", "line", ")", ":", "fld", "=", "re", ".", "split", "(", "self", ".", "sep", ",", "line", ")", "# Lines may contain different numbers of items.", "# The line should have all columns requested by the ...
Process Data line.
[ "Process", "Data", "line", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/parsers/ncbi_gene_file_reader.py#L198-L213
228,522
tanghaibao/goatools
goatools/parsers/ncbi_gene_file_reader.py
NCBIgeneFileReader.convert_ints_floats
def convert_ints_floats(self, flds): """Convert strings to ints and floats, if so specified.""" for idx in self.idxs_float: flds[idx] = float(flds[idx]) for idx in self.idxs_int: dig = flds[idx] #print 'idx={} ({}) {}'.format(idx, flds[idx], flds) # DVK ...
python
def convert_ints_floats(self, flds): """Convert strings to ints and floats, if so specified.""" for idx in self.idxs_float: flds[idx] = float(flds[idx]) for idx in self.idxs_int: dig = flds[idx] #print 'idx={} ({}) {}'.format(idx, flds[idx], flds) # DVK ...
[ "def", "convert_ints_floats", "(", "self", ",", "flds", ")", ":", "for", "idx", "in", "self", ".", "idxs_float", ":", "flds", "[", "idx", "]", "=", "float", "(", "flds", "[", "idx", "]", ")", "for", "idx", "in", "self", ".", "idxs_int", ":", "dig",...
Convert strings to ints and floats, if so specified.
[ "Convert", "strings", "to", "ints", "and", "floats", "if", "so", "specified", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/parsers/ncbi_gene_file_reader.py#L215-L226
228,523
tanghaibao/goatools
goatools/parsers/ncbi_gene_file_reader.py
NCBIgeneFileReader._init_hdr
def _init_hdr(self, line, hdrs_usr): """Initialize self.hdr2idx, self.len, self.idxs_float, and self.idxs_int""" self.hdr2idx = OrderedDict([(v.strip(), i) for i, v in enumerate(re.split(self.sep, line))]) self.len = len(self.hdr2idx) # If user is requesting specific data fields... ...
python
def _init_hdr(self, line, hdrs_usr): """Initialize self.hdr2idx, self.len, self.idxs_float, and self.idxs_int""" self.hdr2idx = OrderedDict([(v.strip(), i) for i, v in enumerate(re.split(self.sep, line))]) self.len = len(self.hdr2idx) # If user is requesting specific data fields... ...
[ "def", "_init_hdr", "(", "self", ",", "line", ",", "hdrs_usr", ")", ":", "self", ".", "hdr2idx", "=", "OrderedDict", "(", "[", "(", "v", ".", "strip", "(", ")", ",", "i", ")", "for", "i", ",", "v", "in", "enumerate", "(", "re", ".", "split", "(...
Initialize self.hdr2idx, self.len, self.idxs_float, and self.idxs_int
[ "Initialize", "self", ".", "hdr2idx", "self", ".", "len", "self", ".", "idxs_float", "and", "self", ".", "idxs_int" ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/parsers/ncbi_gene_file_reader.py#L228-L247
228,524
tanghaibao/goatools
goatools/parsers/ncbi_gene_file_reader.py
NCBIgeneFileReader._init_idxs_float
def _init_idxs_float(self, usr_hdrs): """List of indexes whose values will be floats.""" self.idxs_float = [ Idx for Hdr, Idx in self.hdr2idx.items() if Hdr in usr_hdrs and Hdr in self.float_hdrs]
python
def _init_idxs_float(self, usr_hdrs): """List of indexes whose values will be floats.""" self.idxs_float = [ Idx for Hdr, Idx in self.hdr2idx.items() if Hdr in usr_hdrs and Hdr in self.float_hdrs]
[ "def", "_init_idxs_float", "(", "self", ",", "usr_hdrs", ")", ":", "self", ".", "idxs_float", "=", "[", "Idx", "for", "Hdr", ",", "Idx", "in", "self", ".", "hdr2idx", ".", "items", "(", ")", "if", "Hdr", "in", "usr_hdrs", "and", "Hdr", "in", "self", ...
List of indexes whose values will be floats.
[ "List", "of", "indexes", "whose", "values", "will", "be", "floats", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/parsers/ncbi_gene_file_reader.py#L249-L252
228,525
tanghaibao/goatools
goatools/parsers/ncbi_gene_file_reader.py
NCBIgeneFileReader._init_idxs_int
def _init_idxs_int(self, usr_hdrs): """List of indexes whose values will be ints.""" self.idxs_int = [ Idx for Hdr, Idx in self.hdr2idx.items() if Hdr in usr_hdrs and Hdr in self.int_hdrs]
python
def _init_idxs_int(self, usr_hdrs): """List of indexes whose values will be ints.""" self.idxs_int = [ Idx for Hdr, Idx in self.hdr2idx.items() if Hdr in usr_hdrs and Hdr in self.int_hdrs]
[ "def", "_init_idxs_int", "(", "self", ",", "usr_hdrs", ")", ":", "self", ".", "idxs_int", "=", "[", "Idx", "for", "Hdr", ",", "Idx", "in", "self", ".", "hdr2idx", ".", "items", "(", ")", "if", "Hdr", "in", "usr_hdrs", "and", "Hdr", "in", "self", "....
List of indexes whose values will be ints.
[ "List", "of", "indexes", "whose", "values", "will", "be", "ints", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/parsers/ncbi_gene_file_reader.py#L254-L257
228,526
tanghaibao/goatools
goatools/parsers/ncbi_gene_file_reader.py
NCBIgeneFileReader._init_idxs_strpat
def _init_idxs_strpat(self, usr_hdrs): """List of indexes whose values will be strings.""" strpat = self.strpat_hdrs.keys() self.idxs_strpat = [ Idx for Hdr, Idx in self.hdr2idx.items() if Hdr in usr_hdrs and Hdr in strpat]
python
def _init_idxs_strpat(self, usr_hdrs): """List of indexes whose values will be strings.""" strpat = self.strpat_hdrs.keys() self.idxs_strpat = [ Idx for Hdr, Idx in self.hdr2idx.items() if Hdr in usr_hdrs and Hdr in strpat]
[ "def", "_init_idxs_strpat", "(", "self", ",", "usr_hdrs", ")", ":", "strpat", "=", "self", ".", "strpat_hdrs", ".", "keys", "(", ")", "self", ".", "idxs_strpat", "=", "[", "Idx", "for", "Hdr", ",", "Idx", "in", "self", ".", "hdr2idx", ".", "items", "...
List of indexes whose values will be strings.
[ "List", "of", "indexes", "whose", "values", "will", "be", "strings", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/parsers/ncbi_gene_file_reader.py#L259-L263
228,527
tanghaibao/goatools
goatools/cli/ncbi_gene_results_to_python.py
NCBIgeneToPythonCli._get_geneid2nt
def _get_geneid2nt(nts): """Get geneid2nt given a list of namedtuples.""" geneid2nt = {} for ntd in nts: geneid = ntd.GeneID if geneid not in geneid2nt: geneid2nt[geneid] = ntd else: print("DUPLICATE GeneID FOUND {N:9} {SYM}".fo...
python
def _get_geneid2nt(nts): """Get geneid2nt given a list of namedtuples.""" geneid2nt = {} for ntd in nts: geneid = ntd.GeneID if geneid not in geneid2nt: geneid2nt[geneid] = ntd else: print("DUPLICATE GeneID FOUND {N:9} {SYM}".fo...
[ "def", "_get_geneid2nt", "(", "nts", ")", ":", "geneid2nt", "=", "{", "}", "for", "ntd", "in", "nts", ":", "geneid", "=", "ntd", ".", "GeneID", "if", "geneid", "not", "in", "geneid2nt", ":", "geneid2nt", "[", "geneid", "]", "=", "ntd", "else", ":", ...
Get geneid2nt given a list of namedtuples.
[ "Get", "geneid2nt", "given", "a", "list", "of", "namedtuples", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/cli/ncbi_gene_results_to_python.py#L50-L59
228,528
tanghaibao/goatools
goatools/cli/ncbi_gene_results_to_python.py
NCBIgeneToPythonCli._wrpy_ncbi_gene_nts
def _wrpy_ncbi_gene_nts(fout_py, geneid2nt, log): """Write namedtuples to a dict in a Python module.""" num_genes = len(geneid2nt) with open(fout_py, 'w') as ofstrm: docstr = "Data downloaded from NCBI Gene converted into Python namedtuples." ofstrm.write('"""{PYDOC}"""\n...
python
def _wrpy_ncbi_gene_nts(fout_py, geneid2nt, log): """Write namedtuples to a dict in a Python module.""" num_genes = len(geneid2nt) with open(fout_py, 'w') as ofstrm: docstr = "Data downloaded from NCBI Gene converted into Python namedtuples." ofstrm.write('"""{PYDOC}"""\n...
[ "def", "_wrpy_ncbi_gene_nts", "(", "fout_py", ",", "geneid2nt", ",", "log", ")", ":", "num_genes", "=", "len", "(", "geneid2nt", ")", "with", "open", "(", "fout_py", ",", "'w'", ")", "as", "ofstrm", ":", "docstr", "=", "\"Data downloaded from NCBI Gene convert...
Write namedtuples to a dict in a Python module.
[ "Write", "namedtuples", "to", "a", "dict", "in", "a", "Python", "module", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/cli/ncbi_gene_results_to_python.py#L62-L80
228,529
tanghaibao/goatools
goatools/gosubdag/go_tasks.py
get_goobjs_altgo2goobj
def get_goobjs_altgo2goobj(go2obj): """Separate alt GO IDs and key GO IDs.""" goobjs = set() altgo2goobj = {} for goid, goobj in go2obj.items(): goobjs.add(goobj) if goid != goobj.id: altgo2goobj[goid] = goobj return goobjs, altgo2goobj
python
def get_goobjs_altgo2goobj(go2obj): """Separate alt GO IDs and key GO IDs.""" goobjs = set() altgo2goobj = {} for goid, goobj in go2obj.items(): goobjs.add(goobj) if goid != goobj.id: altgo2goobj[goid] = goobj return goobjs, altgo2goobj
[ "def", "get_goobjs_altgo2goobj", "(", "go2obj", ")", ":", "goobjs", "=", "set", "(", ")", "altgo2goobj", "=", "{", "}", "for", "goid", ",", "goobj", "in", "go2obj", ".", "items", "(", ")", ":", "goobjs", ".", "add", "(", "goobj", ")", "if", "goid", ...
Separate alt GO IDs and key GO IDs.
[ "Separate", "alt", "GO", "IDs", "and", "key", "GO", "IDs", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/gosubdag/go_tasks.py#L99-L107
228,530
tanghaibao/goatools
goatools/gosubdag/go_tasks.py
add_alt_goids
def add_alt_goids(go2values, altgo2goobj): """Add alternate source GO IDs.""" for goobj_key in altgo2goobj.values(): values_curr = go2values[goobj_key.id] for goid_alt in goobj_key.alt_ids: go2values[goid_alt] = values_curr return go2values
python
def add_alt_goids(go2values, altgo2goobj): """Add alternate source GO IDs.""" for goobj_key in altgo2goobj.values(): values_curr = go2values[goobj_key.id] for goid_alt in goobj_key.alt_ids: go2values[goid_alt] = values_curr return go2values
[ "def", "add_alt_goids", "(", "go2values", ",", "altgo2goobj", ")", ":", "for", "goobj_key", "in", "altgo2goobj", ".", "values", "(", ")", ":", "values_curr", "=", "go2values", "[", "goobj_key", ".", "id", "]", "for", "goid_alt", "in", "goobj_key", ".", "al...
Add alternate source GO IDs.
[ "Add", "alternate", "source", "GO", "IDs", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/gosubdag/go_tasks.py#L109-L115
228,531
tanghaibao/goatools
goatools/gosubdag/go_tasks.py
fill_main_goids
def fill_main_goids(go2obj, goids): """Ensure main GO IDs are included in go2obj.""" # User GO IDs (goids) may be either main GO IDs or alternate GO IDs. for goid in goids: goobj = go2obj[goid] # If a user specified an ALT GO ID and main GO ID not in go2obj: if goid != goobj.id and g...
python
def fill_main_goids(go2obj, goids): """Ensure main GO IDs are included in go2obj.""" # User GO IDs (goids) may be either main GO IDs or alternate GO IDs. for goid in goids: goobj = go2obj[goid] # If a user specified an ALT GO ID and main GO ID not in go2obj: if goid != goobj.id and g...
[ "def", "fill_main_goids", "(", "go2obj", ",", "goids", ")", ":", "# User GO IDs (goids) may be either main GO IDs or alternate GO IDs.", "for", "goid", "in", "goids", ":", "goobj", "=", "go2obj", "[", "goid", "]", "# If a user specified an ALT GO ID and main GO ID not in go2o...
Ensure main GO IDs are included in go2obj.
[ "Ensure", "main", "GO", "IDs", "are", "included", "in", "go2obj", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/gosubdag/go_tasks.py#L118-L126
228,532
tanghaibao/goatools
goatools/gosubdag/go_tasks.py
fill_altgoids
def fill_altgoids(go2obj): """Given a go2obj containing key GO IDs, fill with all alternate GO IDs.""" alt2obj = {altgo:goobj for goobj in go2obj.values() for altgo in goobj.alt_ids} for goid, goobj in alt2obj.items(): go2obj[goid] = goobj
python
def fill_altgoids(go2obj): """Given a go2obj containing key GO IDs, fill with all alternate GO IDs.""" alt2obj = {altgo:goobj for goobj in go2obj.values() for altgo in goobj.alt_ids} for goid, goobj in alt2obj.items(): go2obj[goid] = goobj
[ "def", "fill_altgoids", "(", "go2obj", ")", ":", "alt2obj", "=", "{", "altgo", ":", "goobj", "for", "goobj", "in", "go2obj", ".", "values", "(", ")", "for", "altgo", "in", "goobj", ".", "alt_ids", "}", "for", "goid", ",", "goobj", "in", "alt2obj", "....
Given a go2obj containing key GO IDs, fill with all alternate GO IDs.
[ "Given", "a", "go2obj", "containing", "key", "GO", "IDs", "fill", "with", "all", "alternate", "GO", "IDs", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/gosubdag/go_tasks.py#L128-L132
228,533
tanghaibao/goatools
goatools/gosubdag/go_tasks.py
fill_relationshipobjs
def fill_relationshipobjs(go2obj, relationships): """Add GO IDs to go2obj that are involved in relationships.""" # Get all GO Term record objects that have relationships obj = RelationshipFill(go2obj, relationships) for goobj in go2obj.values(): if goobj.relationship: obj.fill_relati...
python
def fill_relationshipobjs(go2obj, relationships): """Add GO IDs to go2obj that are involved in relationships.""" # Get all GO Term record objects that have relationships obj = RelationshipFill(go2obj, relationships) for goobj in go2obj.values(): if goobj.relationship: obj.fill_relati...
[ "def", "fill_relationshipobjs", "(", "go2obj", ",", "relationships", ")", ":", "# Get all GO Term record objects that have relationships", "obj", "=", "RelationshipFill", "(", "go2obj", ",", "relationships", ")", "for", "goobj", "in", "go2obj", ".", "values", "(", ")"...
Add GO IDs to go2obj that are involved in relationships.
[ "Add", "GO", "IDs", "to", "go2obj", "that", "are", "involved", "in", "relationships", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/gosubdag/go_tasks.py#L135-L143
228,534
tanghaibao/goatools
goatools/gosubdag/go_tasks.py
fill_childgoid2obj
def fill_childgoid2obj(childgoid2obj, parent_obj): """Fill childgoid2obj with all child key GO IDs and their objects.""" for child_obj in parent_obj.children: if child_obj.id not in childgoid2obj: childgoid2obj[child_obj.id] = child_obj fill_childgoid2obj(childgoid2obj, child_obj...
python
def fill_childgoid2obj(childgoid2obj, parent_obj): """Fill childgoid2obj with all child key GO IDs and their objects.""" for child_obj in parent_obj.children: if child_obj.id not in childgoid2obj: childgoid2obj[child_obj.id] = child_obj fill_childgoid2obj(childgoid2obj, child_obj...
[ "def", "fill_childgoid2obj", "(", "childgoid2obj", ",", "parent_obj", ")", ":", "for", "child_obj", "in", "parent_obj", ".", "children", ":", "if", "child_obj", ".", "id", "not", "in", "childgoid2obj", ":", "childgoid2obj", "[", "child_obj", ".", "id", "]", ...
Fill childgoid2obj with all child key GO IDs and their objects.
[ "Fill", "childgoid2obj", "with", "all", "child", "key", "GO", "IDs", "and", "their", "objects", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/gosubdag/go_tasks.py#L180-L185
228,535
tanghaibao/goatools
goatools/gosubdag/go_tasks.py
get_leaf_children
def get_leaf_children(gos_user, go2obj_arg): """Find all the GO descendants under all user GO IDs. Return leaf-level GO IDs.""" childgoid2obj = {} for goid_usr in gos_user: goobj_usr = go2obj_arg[goid_usr] fill_childgoid2obj(childgoid2obj, goobj_usr) return set(go for go, o in childgoid2...
python
def get_leaf_children(gos_user, go2obj_arg): """Find all the GO descendants under all user GO IDs. Return leaf-level GO IDs.""" childgoid2obj = {} for goid_usr in gos_user: goobj_usr = go2obj_arg[goid_usr] fill_childgoid2obj(childgoid2obj, goobj_usr) return set(go for go, o in childgoid2...
[ "def", "get_leaf_children", "(", "gos_user", ",", "go2obj_arg", ")", ":", "childgoid2obj", "=", "{", "}", "for", "goid_usr", "in", "gos_user", ":", "goobj_usr", "=", "go2obj_arg", "[", "goid_usr", "]", "fill_childgoid2obj", "(", "childgoid2obj", ",", "goobj_usr"...
Find all the GO descendants under all user GO IDs. Return leaf-level GO IDs.
[ "Find", "all", "the", "GO", "descendants", "under", "all", "user", "GO", "IDs", ".", "Return", "leaf", "-", "level", "GO", "IDs", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/gosubdag/go_tasks.py#L188-L194
228,536
tanghaibao/goatools
goatools/gosubdag/go_tasks.py
chk_goids
def chk_goids(goids, msg=None, raise_except=True): """check that all GO IDs have the proper format.""" for goid in goids: if not goid_is_valid(goid): if raise_except: raise RuntimeError("BAD GO({GO}): {MSG}".format(GO=goid, MSG=msg)) else: return g...
python
def chk_goids(goids, msg=None, raise_except=True): """check that all GO IDs have the proper format.""" for goid in goids: if not goid_is_valid(goid): if raise_except: raise RuntimeError("BAD GO({GO}): {MSG}".format(GO=goid, MSG=msg)) else: return g...
[ "def", "chk_goids", "(", "goids", ",", "msg", "=", "None", ",", "raise_except", "=", "True", ")", ":", "for", "goid", "in", "goids", ":", "if", "not", "goid_is_valid", "(", "goid", ")", ":", "if", "raise_except", ":", "raise", "RuntimeError", "(", "\"B...
check that all GO IDs have the proper format.
[ "check", "that", "all", "GO", "IDs", "have", "the", "proper", "format", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/gosubdag/go_tasks.py#L208-L215
228,537
tanghaibao/goatools
goatools/gosubdag/go_tasks.py
TopologicalSortRelationships._get_sorted_relationships
def _get_sorted_relationships(self, goterm): """Traverse GO Terms above the current GO Term. Then add current GO Term to sorted.""" if goterm.id in self.goids_seen: return self.goids_seen.add(goterm.id) for goterm_upper in goterm.get_goterms_upper(): self._get_sor...
python
def _get_sorted_relationships(self, goterm): """Traverse GO Terms above the current GO Term. Then add current GO Term to sorted.""" if goterm.id in self.goids_seen: return self.goids_seen.add(goterm.id) for goterm_upper in goterm.get_goterms_upper(): self._get_sor...
[ "def", "_get_sorted_relationships", "(", "self", ",", "goterm", ")", ":", "if", "goterm", ".", "id", "in", "self", ".", "goids_seen", ":", "return", "self", ".", "goids_seen", ".", "add", "(", "goterm", ".", "id", ")", "for", "goterm_upper", "in", "goter...
Traverse GO Terms above the current GO Term. Then add current GO Term to sorted.
[ "Traverse", "GO", "Terms", "above", "the", "current", "GO", "Term", ".", "Then", "add", "current", "GO", "Term", "to", "sorted", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/gosubdag/go_tasks.py#L32-L39
228,538
tanghaibao/goatools
goatools/grouper/read_goids.py
read_sections
def read_sections(sections_file, exclude_ungrouped=False, prt=sys.stdout): """Get sections and GO grouping hdrgos from file, if sections exist.""" if sections_file is None: return None assert isinstance(sections_file, str), "BAD SECTIONS FILENAME({S})".format( S=sections_file) if os.path...
python
def read_sections(sections_file, exclude_ungrouped=False, prt=sys.stdout): """Get sections and GO grouping hdrgos from file, if sections exist.""" if sections_file is None: return None assert isinstance(sections_file, str), "BAD SECTIONS FILENAME({S})".format( S=sections_file) if os.path...
[ "def", "read_sections", "(", "sections_file", ",", "exclude_ungrouped", "=", "False", ",", "prt", "=", "sys", ".", "stdout", ")", ":", "if", "sections_file", "is", "None", ":", "return", "None", "assert", "isinstance", "(", "sections_file", ",", "str", ")", ...
Get sections and GO grouping hdrgos from file, if sections exist.
[ "Get", "sections", "and", "GO", "grouping", "hdrgos", "from", "file", "if", "sections", "exist", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/read_goids.py#L19-L40
228,539
tanghaibao/goatools
goatools/grouper/read_goids.py
ReadGoids.read_py
def read_py(self, fin_txt, get_goids_only, exclude_ungrouped, prt=sys.stdout): """Read GO IDs or sections data from a Python file.""" goids_fin = self._read_py(fin_txt, get_goids_only, exclude_ungrouped) sections = self._read_finish(goids_fin, prt) # Print summary of GO IDs read ...
python
def read_py(self, fin_txt, get_goids_only, exclude_ungrouped, prt=sys.stdout): """Read GO IDs or sections data from a Python file.""" goids_fin = self._read_py(fin_txt, get_goids_only, exclude_ungrouped) sections = self._read_finish(goids_fin, prt) # Print summary of GO IDs read ...
[ "def", "read_py", "(", "self", ",", "fin_txt", ",", "get_goids_only", ",", "exclude_ungrouped", ",", "prt", "=", "sys", ".", "stdout", ")", ":", "goids_fin", "=", "self", ".", "_read_py", "(", "fin_txt", ",", "get_goids_only", ",", "exclude_ungrouped", ")", ...
Read GO IDs or sections data from a Python file.
[ "Read", "GO", "IDs", "or", "sections", "data", "from", "a", "Python", "file", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/read_goids.py#L74-L81
228,540
tanghaibao/goatools
goatools/grouper/read_goids.py
ReadGoids.read_sections
def read_sections(self, sections_file, get_goids_only, exclude_ungrouped): """Read sections variable from a text file of from a Python file.""" ext = os.path.splitext(sections_file)[1] file_contents = None if ext == '.py': file_contents = self.read_py(sections_file, get_goids...
python
def read_sections(self, sections_file, get_goids_only, exclude_ungrouped): """Read sections variable from a text file of from a Python file.""" ext = os.path.splitext(sections_file)[1] file_contents = None if ext == '.py': file_contents = self.read_py(sections_file, get_goids...
[ "def", "read_sections", "(", "self", ",", "sections_file", ",", "get_goids_only", ",", "exclude_ungrouped", ")", ":", "ext", "=", "os", ".", "path", ".", "splitext", "(", "sections_file", ")", "[", "1", "]", "file_contents", "=", "None", "if", "ext", "==",...
Read sections variable from a text file of from a Python file.
[ "Read", "sections", "variable", "from", "a", "text", "file", "of", "from", "a", "Python", "file", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/read_goids.py#L83-L92
228,541
tanghaibao/goatools
goatools/grouper/read_goids.py
ReadGoids._rpt_unused_sections
def _rpt_unused_sections(self, prt): """Report unused sections.""" sections_unused = set(self.sections_seen).difference(self.section2goids.keys()) for sec in sections_unused: prt.write(" UNUSED SECTION: {SEC}\n".format(SEC=sec))
python
def _rpt_unused_sections(self, prt): """Report unused sections.""" sections_unused = set(self.sections_seen).difference(self.section2goids.keys()) for sec in sections_unused: prt.write(" UNUSED SECTION: {SEC}\n".format(SEC=sec))
[ "def", "_rpt_unused_sections", "(", "self", ",", "prt", ")", ":", "sections_unused", "=", "set", "(", "self", ".", "sections_seen", ")", ".", "difference", "(", "self", ".", "section2goids", ".", "keys", "(", ")", ")", "for", "sec", "in", "sections_unused"...
Report unused sections.
[ "Report", "unused", "sections", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/read_goids.py#L161-L165
228,542
tanghaibao/goatools
goatools/grouper/read_goids.py
ReadGoids._prt_read_msg
def _prt_read_msg(self, prt, fin_txt, exclude_ungrouped): """Print which file was read and the number of GO IDs found.""" if self.sections_seen or exclude_ungrouped: # dat = Grouper.get_summary_data(self.section2goids.items(), HdrgosSections.secdflt) dat = SummarySec2dHdrGos().su...
python
def _prt_read_msg(self, prt, fin_txt, exclude_ungrouped): """Print which file was read and the number of GO IDs found.""" if self.sections_seen or exclude_ungrouped: # dat = Grouper.get_summary_data(self.section2goids.items(), HdrgosSections.secdflt) dat = SummarySec2dHdrGos().su...
[ "def", "_prt_read_msg", "(", "self", ",", "prt", ",", "fin_txt", ",", "exclude_ungrouped", ")", ":", "if", "self", ".", "sections_seen", "or", "exclude_ungrouped", ":", "# dat = Grouper.get_summary_data(self.section2goids.items(), HdrgosSections.secdflt)", "dat", "=", "Su...
Print which file was read and the number of GO IDs found.
[ "Print", "which", "file", "was", "read", "and", "the", "number", "of", "GO", "IDs", "found", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/read_goids.py#L182-L191
228,543
tanghaibao/goatools
goatools/gosubdag/go_edges.py
EdgesBase.rm_gos
def rm_gos(self, rm_goids): """Remove any edges that contain user-specified edges.""" self.edges = self._rm_gos_edges(rm_goids, self.edges) self.edges_rel = self._rm_gos_edges_rel(rm_goids, self.edges_rel)
python
def rm_gos(self, rm_goids): """Remove any edges that contain user-specified edges.""" self.edges = self._rm_gos_edges(rm_goids, self.edges) self.edges_rel = self._rm_gos_edges_rel(rm_goids, self.edges_rel)
[ "def", "rm_gos", "(", "self", ",", "rm_goids", ")", ":", "self", ".", "edges", "=", "self", ".", "_rm_gos_edges", "(", "rm_goids", ",", "self", ".", "edges", ")", "self", ".", "edges_rel", "=", "self", ".", "_rm_gos_edges_rel", "(", "rm_goids", ",", "s...
Remove any edges that contain user-specified edges.
[ "Remove", "any", "edges", "that", "contain", "user", "-", "specified", "edges", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/gosubdag/go_edges.py#L64-L67
228,544
tanghaibao/goatools
goatools/gosubdag/go_edges.py
EdgesBase._rm_gos_edges_rel
def _rm_gos_edges_rel(self, rm_goids, edges_rel): """Remove any relationship that contain user-specified edges.""" edges_ret = {} for rname, edges_cur in edges_rel.items(): edges_new = self._rm_gos_edges(rm_goids, edges_cur) if edges_new: edges_ret[rname] ...
python
def _rm_gos_edges_rel(self, rm_goids, edges_rel): """Remove any relationship that contain user-specified edges.""" edges_ret = {} for rname, edges_cur in edges_rel.items(): edges_new = self._rm_gos_edges(rm_goids, edges_cur) if edges_new: edges_ret[rname] ...
[ "def", "_rm_gos_edges_rel", "(", "self", ",", "rm_goids", ",", "edges_rel", ")", ":", "edges_ret", "=", "{", "}", "for", "rname", ",", "edges_cur", "in", "edges_rel", ".", "items", "(", ")", ":", "edges_new", "=", "self", ".", "_rm_gos_edges", "(", "rm_g...
Remove any relationship that contain user-specified edges.
[ "Remove", "any", "relationship", "that", "contain", "user", "-", "specified", "edges", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/gosubdag/go_edges.py#L69-L76
228,545
tanghaibao/goatools
goatools/gosubdag/go_edges.py
EdgesBase._rm_gos_edges
def _rm_gos_edges(rm_goids, edges_all): """Remove any is_a edges that contain user-specified edges.""" edges_reduced = [] for goid_child, goid_parent in sorted(edges_all, key=lambda t: t[1]): if goid_child not in rm_goids and goid_parent not in rm_goids: edges_reduced...
python
def _rm_gos_edges(rm_goids, edges_all): """Remove any is_a edges that contain user-specified edges.""" edges_reduced = [] for goid_child, goid_parent in sorted(edges_all, key=lambda t: t[1]): if goid_child not in rm_goids and goid_parent not in rm_goids: edges_reduced...
[ "def", "_rm_gos_edges", "(", "rm_goids", ",", "edges_all", ")", ":", "edges_reduced", "=", "[", "]", "for", "goid_child", ",", "goid_parent", "in", "sorted", "(", "edges_all", ",", "key", "=", "lambda", "t", ":", "t", "[", "1", "]", ")", ":", "if", "...
Remove any is_a edges that contain user-specified edges.
[ "Remove", "any", "is_a", "edges", "that", "contain", "user", "-", "specified", "edges", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/gosubdag/go_edges.py#L79-L85
228,546
tanghaibao/goatools
goatools/gosubdag/go_edges.py
EdgesBase.get_all_edge_nodes
def get_all_edge_nodes(self): """Return a list of all GO IDs that are connected to edges.""" edge_nodes = set(e for es in self.edges for e in es) for edges in self.edges_rel.values(): rel_nodes = set(e for es in edges for e in es) edge_nodes.update(rel_nodes) retu...
python
def get_all_edge_nodes(self): """Return a list of all GO IDs that are connected to edges.""" edge_nodes = set(e for es in self.edges for e in es) for edges in self.edges_rel.values(): rel_nodes = set(e for es in edges for e in es) edge_nodes.update(rel_nodes) retu...
[ "def", "get_all_edge_nodes", "(", "self", ")", ":", "edge_nodes", "=", "set", "(", "e", "for", "es", "in", "self", ".", "edges", "for", "e", "in", "es", ")", "for", "edges", "in", "self", ".", "edges_rel", ".", "values", "(", ")", ":", "rel_nodes", ...
Return a list of all GO IDs that are connected to edges.
[ "Return", "a", "list", "of", "all", "GO", "IDs", "that", "are", "connected", "to", "edges", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/gosubdag/go_edges.py#L87-L93
228,547
tanghaibao/goatools
goatools/gosubdag/go_edges.py
EdgesBase.chk_edges
def chk_edges(self): """Check that all edge nodes exist in local subset.""" goids = set(self.go2obj) self.chk_edges_nodes(self.edges, goids, "is_a") for reltype, edges in self.edges_rel.items(): self.chk_edges_nodes(edges, goids, reltype)
python
def chk_edges(self): """Check that all edge nodes exist in local subset.""" goids = set(self.go2obj) self.chk_edges_nodes(self.edges, goids, "is_a") for reltype, edges in self.edges_rel.items(): self.chk_edges_nodes(edges, goids, reltype)
[ "def", "chk_edges", "(", "self", ")", ":", "goids", "=", "set", "(", "self", ".", "go2obj", ")", "self", ".", "chk_edges_nodes", "(", "self", ".", "edges", ",", "goids", ",", "\"is_a\"", ")", "for", "reltype", ",", "edges", "in", "self", ".", "edges_...
Check that all edge nodes exist in local subset.
[ "Check", "that", "all", "edge", "nodes", "exist", "in", "local", "subset", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/gosubdag/go_edges.py#L95-L100
228,548
tanghaibao/goatools
goatools/gosubdag/go_edges.py
EdgesBase.chk_edges_nodes
def chk_edges_nodes(edges, nodes, name): """Check that user specified edges have a node which exists.""" edge_nodes = set(e for es in edges for e in es) missing_nodes = edge_nodes.difference(nodes) assert not missing_nodes, "MISSING: {GOs}\n{NM} EDGES MISSING {N} NODES (OF {T})".format( ...
python
def chk_edges_nodes(edges, nodes, name): """Check that user specified edges have a node which exists.""" edge_nodes = set(e for es in edges for e in es) missing_nodes = edge_nodes.difference(nodes) assert not missing_nodes, "MISSING: {GOs}\n{NM} EDGES MISSING {N} NODES (OF {T})".format( ...
[ "def", "chk_edges_nodes", "(", "edges", ",", "nodes", ",", "name", ")", ":", "edge_nodes", "=", "set", "(", "e", "for", "es", "in", "edges", "for", "e", "in", "es", ")", "missing_nodes", "=", "edge_nodes", ".", "difference", "(", "nodes", ")", "assert"...
Check that user specified edges have a node which exists.
[ "Check", "that", "user", "specified", "edges", "have", "a", "node", "which", "exists", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/gosubdag/go_edges.py#L103-L108
228,549
tanghaibao/goatools
goatools/gosubdag/go_edges.py
EdgesBase.get_c2ps
def get_c2ps(self): """Set child2parents dict for all parents used in this set of edges.""" c2ps = defaultdict(set) for goid_child, goid_parent in self.edges: c2ps[goid_child].add(goid_parent) return c2ps
python
def get_c2ps(self): """Set child2parents dict for all parents used in this set of edges.""" c2ps = defaultdict(set) for goid_child, goid_parent in self.edges: c2ps[goid_child].add(goid_parent) return c2ps
[ "def", "get_c2ps", "(", "self", ")", ":", "c2ps", "=", "defaultdict", "(", "set", ")", "for", "goid_child", ",", "goid_parent", "in", "self", ".", "edges", ":", "c2ps", "[", "goid_child", "]", ".", "add", "(", "goid_parent", ")", "return", "c2ps" ]
Set child2parents dict for all parents used in this set of edges.
[ "Set", "child2parents", "dict", "for", "all", "parents", "used", "in", "this", "set", "of", "edges", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/gosubdag/go_edges.py#L110-L115
228,550
tanghaibao/goatools
goatools/gosubdag/go_edges.py
EdgesRelatives._init_edges_relationships
def _init_edges_relationships(rel2src2dsts, rel2dst2srcs): """Get the directed edges from GO term to GO term using relationships.""" edge_rel2fromto = {} relationships = set(rel2src2dsts).union(rel2dst2srcs) for reltype in relationships: edge_from_to = [] if relty...
python
def _init_edges_relationships(rel2src2dsts, rel2dst2srcs): """Get the directed edges from GO term to GO term using relationships.""" edge_rel2fromto = {} relationships = set(rel2src2dsts).union(rel2dst2srcs) for reltype in relationships: edge_from_to = [] if relty...
[ "def", "_init_edges_relationships", "(", "rel2src2dsts", ",", "rel2dst2srcs", ")", ":", "edge_rel2fromto", "=", "{", "}", "relationships", "=", "set", "(", "rel2src2dsts", ")", ".", "union", "(", "rel2dst2srcs", ")", "for", "reltype", "in", "relationships", ":",...
Get the directed edges from GO term to GO term using relationships.
[ "Get", "the", "directed", "edges", "from", "GO", "term", "to", "GO", "term", "using", "relationships", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/gosubdag/go_edges.py#L169-L184
228,551
tanghaibao/goatools
goatools/gosubdag/go_edges.py
EdgesRelatives._traverse_relationship_objs
def _traverse_relationship_objs(self, rel2src2dsts, goobj_child, goids_seen): """Traverse from source GO up relationships.""" child_id = goobj_child.id goids_seen.add(child_id) ##A self.go2obj[child_id] = goobj_child # Update goids_seen and go2obj with child alt_ids for g...
python
def _traverse_relationship_objs(self, rel2src2dsts, goobj_child, goids_seen): """Traverse from source GO up relationships.""" child_id = goobj_child.id goids_seen.add(child_id) ##A self.go2obj[child_id] = goobj_child # Update goids_seen and go2obj with child alt_ids for g...
[ "def", "_traverse_relationship_objs", "(", "self", ",", "rel2src2dsts", ",", "goobj_child", ",", "goids_seen", ")", ":", "child_id", "=", "goobj_child", ".", "id", "goids_seen", ".", "add", "(", "child_id", ")", "##A self.go2obj[child_id] = goobj_child", "# Update goi...
Traverse from source GO up relationships.
[ "Traverse", "from", "source", "GO", "up", "relationships", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/gosubdag/go_edges.py#L200-L217
228,552
tanghaibao/goatools
goatools/gosubdag/go_edges.py
EdgesRelatives._init_rel2dst2srcs
def _init_rel2dst2srcs(self, go_sources, traverse_child): """Traverse through reverse relationships.""" if not traverse_child or not self.relationships: return {} rel2dst2srcs = {r:defaultdict(set) for r in self.relationships} goids_seen = set() go2obj = self.go2obj ...
python
def _init_rel2dst2srcs(self, go_sources, traverse_child): """Traverse through reverse relationships.""" if not traverse_child or not self.relationships: return {} rel2dst2srcs = {r:defaultdict(set) for r in self.relationships} goids_seen = set() go2obj = self.go2obj ...
[ "def", "_init_rel2dst2srcs", "(", "self", ",", "go_sources", ",", "traverse_child", ")", ":", "if", "not", "traverse_child", "or", "not", "self", ".", "relationships", ":", "return", "{", "}", "rel2dst2srcs", "=", "{", "r", ":", "defaultdict", "(", "set", ...
Traverse through reverse relationships.
[ "Traverse", "through", "reverse", "relationships", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/gosubdag/go_edges.py#L220-L231
228,553
tanghaibao/goatools
goatools/gosubdag/go_edges.py
EdgesRelatives._init_c2ps
def _init_c2ps(self, go_sources, traverse_child): """Traverse up children.""" if not traverse_child: return {} c2ps = defaultdict(set) goids_seen = set() go2obj = self.go2obj for goid_src in go_sources: goobj_src = go2obj[goid_src] if g...
python
def _init_c2ps(self, go_sources, traverse_child): """Traverse up children.""" if not traverse_child: return {} c2ps = defaultdict(set) goids_seen = set() go2obj = self.go2obj for goid_src in go_sources: goobj_src = go2obj[goid_src] if g...
[ "def", "_init_c2ps", "(", "self", ",", "go_sources", ",", "traverse_child", ")", ":", "if", "not", "traverse_child", ":", "return", "{", "}", "c2ps", "=", "defaultdict", "(", "set", ")", "goids_seen", "=", "set", "(", ")", "go2obj", "=", "self", ".", "...
Traverse up children.
[ "Traverse", "up", "children", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/gosubdag/go_edges.py#L290-L302
228,554
tanghaibao/goatools
goatools/anno/init/reader_gaf.py
GafData.chk
def chk(self, annotations, fout_err): """Check annotations.""" for idx, ntd in enumerate(annotations): self._chk_fld(ntd, "Qualifier") # optional 0 or greater self._chk_fld(ntd, "DB_Reference", 1) # required 1 or greater self._chk_fld(ntd, "With_From") ...
python
def chk(self, annotations, fout_err): """Check annotations.""" for idx, ntd in enumerate(annotations): self._chk_fld(ntd, "Qualifier") # optional 0 or greater self._chk_fld(ntd, "DB_Reference", 1) # required 1 or greater self._chk_fld(ntd, "With_From") ...
[ "def", "chk", "(", "self", ",", "annotations", ",", "fout_err", ")", ":", "for", "idx", ",", "ntd", "in", "enumerate", "(", "annotations", ")", ":", "self", ".", "_chk_fld", "(", "ntd", ",", "\"Qualifier\"", ")", "# optional 0 or greater", "self", ".", "...
Check annotations.
[ "Check", "annotations", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/anno/init/reader_gaf.py#L151-L167
228,555
tanghaibao/goatools
goatools/anno/init/reader_gaf.py
GafData.get_gafvals
def get_gafvals(self, line): """Convert fields from string to preferred format for GAF ver 2.1 and 2.0.""" flds = line.split('\t') flds[3] = self._get_qualifier(flds[3]) # 3 Qualifier flds[5] = self._get_set(flds[5]) # 5 DB_Reference flds[7] = self._get_set(flds[7]) #...
python
def get_gafvals(self, line): """Convert fields from string to preferred format for GAF ver 2.1 and 2.0.""" flds = line.split('\t') flds[3] = self._get_qualifier(flds[3]) # 3 Qualifier flds[5] = self._get_set(flds[5]) # 5 DB_Reference flds[7] = self._get_set(flds[7]) #...
[ "def", "get_gafvals", "(", "self", ",", "line", ")", ":", "flds", "=", "line", ".", "split", "(", "'\\t'", ")", "flds", "[", "3", "]", "=", "self", ".", "_get_qualifier", "(", "flds", "[", "3", "]", ")", "# 3 Qualifier", "flds", "[", "5", "]", "...
Convert fields from string to preferred format for GAF ver 2.1 and 2.0.
[ "Convert", "fields", "from", "string", "to", "preferred", "format", "for", "GAF", "ver", "2", ".", "1", "and", "2", ".", "0", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/anno/init/reader_gaf.py#L173-L192
228,556
tanghaibao/goatools
goatools/anno/init/reader_gaf.py
GafData._get_qualifier
def _get_qualifier(val): """Get qualifiers. Correct for inconsistent capitalization in GAF files""" quals = set() if val == '': return quals for val in val.split('|'): val = val.lower() quals.add(val if val != 'not' else 'NOT') return quals
python
def _get_qualifier(val): """Get qualifiers. Correct for inconsistent capitalization in GAF files""" quals = set() if val == '': return quals for val in val.split('|'): val = val.lower() quals.add(val if val != 'not' else 'NOT') return quals
[ "def", "_get_qualifier", "(", "val", ")", ":", "quals", "=", "set", "(", ")", "if", "val", "==", "''", ":", "return", "quals", "for", "val", "in", "val", ".", "split", "(", "'|'", ")", ":", "val", "=", "val", ".", "lower", "(", ")", "quals", "....
Get qualifiers. Correct for inconsistent capitalization in GAF files
[ "Get", "qualifiers", ".", "Correct", "for", "inconsistent", "capitalization", "in", "GAF", "files" ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/anno/init/reader_gaf.py#L195-L203
228,557
tanghaibao/goatools
goatools/anno/init/reader_gaf.py
GafData._chk_fld
def _chk_fld(self, ntd, name, qty_min=0, qty_max=None): """Further split a GAF value within a single field.""" vals = getattr(ntd, name) num_vals = len(vals) if num_vals < qty_min: self.illegal_lines['MIN QTY'].append( (-1, "FIELD({F}): MIN QUANTITY({Q}) WASN'...
python
def _chk_fld(self, ntd, name, qty_min=0, qty_max=None): """Further split a GAF value within a single field.""" vals = getattr(ntd, name) num_vals = len(vals) if num_vals < qty_min: self.illegal_lines['MIN QTY'].append( (-1, "FIELD({F}): MIN QUANTITY({Q}) WASN'...
[ "def", "_chk_fld", "(", "self", ",", "ntd", ",", "name", ",", "qty_min", "=", "0", ",", "qty_max", "=", "None", ")", ":", "vals", "=", "getattr", "(", "ntd", ",", "name", ")", "num_vals", "=", "len", "(", "vals", ")", "if", "num_vals", "<", "qty_...
Further split a GAF value within a single field.
[ "Further", "split", "a", "GAF", "value", "within", "a", "single", "field", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/anno/init/reader_gaf.py#L215-L226
228,558
tanghaibao/goatools
goatools/anno/init/reader_gaf.py
GafData.prt_line_detail
def prt_line_detail(self, prt, line): """Print line header and values in a readable format.""" values = line.split('\t') self._prt_line_detail(prt, values)
python
def prt_line_detail(self, prt, line): """Print line header and values in a readable format.""" values = line.split('\t') self._prt_line_detail(prt, values)
[ "def", "prt_line_detail", "(", "self", ",", "prt", ",", "line", ")", ":", "values", "=", "line", ".", "split", "(", "'\\t'", ")", "self", ".", "_prt_line_detail", "(", "prt", ",", "values", ")" ]
Print line header and values in a readable format.
[ "Print", "line", "header", "and", "values", "in", "a", "readable", "format", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/anno/init/reader_gaf.py#L236-L239
228,559
tanghaibao/goatools
goatools/anno/init/reader_gaf.py
GafData._prt_line_detail
def _prt_line_detail(self, prt, values, lnum=""): """Print header and field values in a readable format.""" #### data = zip(self.req_str, self.ntgafobj._fields, values) data = zip(self.req_str, self.flds, values) txt = ["{:2}) {:3} {:20} {}".format(i, req, hdr, val) for i, (req, hdr, val...
python
def _prt_line_detail(self, prt, values, lnum=""): """Print header and field values in a readable format.""" #### data = zip(self.req_str, self.ntgafobj._fields, values) data = zip(self.req_str, self.flds, values) txt = ["{:2}) {:3} {:20} {}".format(i, req, hdr, val) for i, (req, hdr, val...
[ "def", "_prt_line_detail", "(", "self", ",", "prt", ",", "values", ",", "lnum", "=", "\"\"", ")", ":", "#### data = zip(self.req_str, self.ntgafobj._fields, values)", "data", "=", "zip", "(", "self", ".", "req_str", ",", "self", ".", "flds", ",", "values", ")"...
Print header and field values in a readable format.
[ "Print", "header", "and", "field", "values", "in", "a", "readable", "format", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/anno/init/reader_gaf.py#L241-L246
228,560
tanghaibao/goatools
goatools/anno/init/reader_gaf.py
GafData.prt_error_summary
def prt_error_summary(self, fout_err): """Print a summary about the GAF file that was read.""" # Get summary of error types and their counts errcnts = [] if self.ignored: errcnts.append(" {N:9,} IGNORED associations\n".format(N=len(self.ignored))) if self.illegal_lin...
python
def prt_error_summary(self, fout_err): """Print a summary about the GAF file that was read.""" # Get summary of error types and their counts errcnts = [] if self.ignored: errcnts.append(" {N:9,} IGNORED associations\n".format(N=len(self.ignored))) if self.illegal_lin...
[ "def", "prt_error_summary", "(", "self", ",", "fout_err", ")", ":", "# Get summary of error types and their counts", "errcnts", "=", "[", "]", "if", "self", ".", "ignored", ":", "errcnts", ".", "append", "(", "\" {N:9,} IGNORED associations\\n\"", ".", "format", "(...
Print a summary about the GAF file that was read.
[ "Print", "a", "summary", "about", "the", "GAF", "file", "that", "was", "read", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/anno/init/reader_gaf.py#L265-L278
228,561
tanghaibao/goatools
goatools/anno/init/reader_gaf.py
GafData._wrlog_details_illegal_gaf
def _wrlog_details_illegal_gaf(self, fout_err, err_cnts): """Print details regarding illegal GAF lines seen to a log file.""" # fout_err = "{}.log".format(fin_gaf) gaf_base = os.path.basename(fout_err) with open(fout_err, 'w') as prt: prt.write("ILLEGAL GAF ERROR SUMMARY:\n\n...
python
def _wrlog_details_illegal_gaf(self, fout_err, err_cnts): """Print details regarding illegal GAF lines seen to a log file.""" # fout_err = "{}.log".format(fin_gaf) gaf_base = os.path.basename(fout_err) with open(fout_err, 'w') as prt: prt.write("ILLEGAL GAF ERROR SUMMARY:\n\n...
[ "def", "_wrlog_details_illegal_gaf", "(", "self", ",", "fout_err", ",", "err_cnts", ")", ":", "# fout_err = \"{}.log\".format(fin_gaf)", "gaf_base", "=", "os", ".", "path", ".", "basename", "(", "fout_err", ")", "with", "open", "(", "fout_err", ",", "'w'", ")", ...
Print details regarding illegal GAF lines seen to a log file.
[ "Print", "details", "regarding", "illegal", "GAF", "lines", "seen", "to", "a", "log", "file", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/anno/init/reader_gaf.py#L280-L300
228,562
tanghaibao/goatools
goatools/gosubdag/godag_rcnt_init.py
CountRelativesInit.get_relationship_dicts
def get_relationship_dicts(self): """Given GO DAG relationships, return summaries per GO ID.""" if not self.relationships: return None for goid, goobj in self.go2obj.items(): for reltyp, relset in goobj.relationship.items(): relfwd_goids = set(o.id for o i...
python
def get_relationship_dicts(self): """Given GO DAG relationships, return summaries per GO ID.""" if not self.relationships: return None for goid, goobj in self.go2obj.items(): for reltyp, relset in goobj.relationship.items(): relfwd_goids = set(o.id for o i...
[ "def", "get_relationship_dicts", "(", "self", ")", ":", "if", "not", "self", ".", "relationships", ":", "return", "None", "for", "goid", ",", "goobj", "in", "self", ".", "go2obj", ".", "items", "(", ")", ":", "for", "reltyp", ",", "relset", "in", "goob...
Given GO DAG relationships, return summaries per GO ID.
[ "Given", "GO", "DAG", "relationships", "return", "summaries", "per", "GO", "ID", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/gosubdag/godag_rcnt_init.py#L38-L48
228,563
tanghaibao/goatools
goatools/gosubdag/godag_rcnt_init.py
CountRelativesInit.get_goone2ntletter
def get_goone2ntletter(self, go2dcnt, depth2goobjs): """Assign letters to depth-01 GO terms ordered using descendants cnt.""" # 1. Group level-01/depth-01 GO terms by namespace ns2dcntgoobj = cx.defaultdict(list) for goobj in depth2goobjs[1]: dcnt = go2dcnt[goobj.id] ...
python
def get_goone2ntletter(self, go2dcnt, depth2goobjs): """Assign letters to depth-01 GO terms ordered using descendants cnt.""" # 1. Group level-01/depth-01 GO terms by namespace ns2dcntgoobj = cx.defaultdict(list) for goobj in depth2goobjs[1]: dcnt = go2dcnt[goobj.id] ...
[ "def", "get_goone2ntletter", "(", "self", ",", "go2dcnt", ",", "depth2goobjs", ")", ":", "# 1. Group level-01/depth-01 GO terms by namespace", "ns2dcntgoobj", "=", "cx", ".", "defaultdict", "(", "list", ")", "for", "goobj", "in", "depth2goobjs", "[", "1", "]", ":"...
Assign letters to depth-01 GO terms ordered using descendants cnt.
[ "Assign", "letters", "to", "depth", "-", "01", "GO", "terms", "ordered", "using", "descendants", "cnt", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/gosubdag/godag_rcnt_init.py#L50-L68
228,564
tanghaibao/goatools
goatools/grouper/grprdflts.py
GrouperDflts._init_goslims
def _init_goslims(self, dagslim): """Get GO IDs in GO slims.""" go2obj_main = self.gosubdag.go2obj go2obj_slim = {go for go, o in dagslim.items() if go in go2obj_main} if self.gosubdag.relationships: return self._get_goslimids_norel(go2obj_slim) return set(dagslim.key...
python
def _init_goslims(self, dagslim): """Get GO IDs in GO slims.""" go2obj_main = self.gosubdag.go2obj go2obj_slim = {go for go, o in dagslim.items() if go in go2obj_main} if self.gosubdag.relationships: return self._get_goslimids_norel(go2obj_slim) return set(dagslim.key...
[ "def", "_init_goslims", "(", "self", ",", "dagslim", ")", ":", "go2obj_main", "=", "self", ".", "gosubdag", ".", "go2obj", "go2obj_slim", "=", "{", "go", "for", "go", ",", "o", "in", "dagslim", ".", "items", "(", ")", "if", "go", "in", "go2obj_main", ...
Get GO IDs in GO slims.
[ "Get", "GO", "IDs", "in", "GO", "slims", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/grprdflts.py#L48-L54
228,565
tanghaibao/goatools
goatools/grouper/grprdflts.py
GrouperDflts._get_goslimids_norel
def _get_goslimids_norel(self, dagslim): """Get all GO slim GO IDs that do not have a relationship.""" go_slims = set() go2obj = self.gosubdag.go2obj for goid in dagslim: goobj = go2obj[goid] if not goobj.relationship: go_slims.add(goobj.id) ...
python
def _get_goslimids_norel(self, dagslim): """Get all GO slim GO IDs that do not have a relationship.""" go_slims = set() go2obj = self.gosubdag.go2obj for goid in dagslim: goobj = go2obj[goid] if not goobj.relationship: go_slims.add(goobj.id) ...
[ "def", "_get_goslimids_norel", "(", "self", ",", "dagslim", ")", ":", "go_slims", "=", "set", "(", ")", "go2obj", "=", "self", ".", "gosubdag", ".", "go2obj", "for", "goid", "in", "dagslim", ":", "goobj", "=", "go2obj", "[", "goid", "]", "if", "not", ...
Get all GO slim GO IDs that do not have a relationship.
[ "Get", "all", "GO", "slim", "GO", "IDs", "that", "do", "not", "have", "a", "relationship", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/grprdflts.py#L60-L68
228,566
tanghaibao/goatools
goatools/grouper/grprdflts.py
GrouperDflts.get_gosubdag
def get_gosubdag(gosubdag=None): """Gets a GoSubDag initialized for use by a Grouper object.""" if gosubdag is not None: if gosubdag.rcntobj is not None: return gosubdag else: gosubdag.init_auxobjs() return gosubdag else: ...
python
def get_gosubdag(gosubdag=None): """Gets a GoSubDag initialized for use by a Grouper object.""" if gosubdag is not None: if gosubdag.rcntobj is not None: return gosubdag else: gosubdag.init_auxobjs() return gosubdag else: ...
[ "def", "get_gosubdag", "(", "gosubdag", "=", "None", ")", ":", "if", "gosubdag", "is", "not", "None", ":", "if", "gosubdag", ".", "rcntobj", "is", "not", "None", ":", "return", "gosubdag", "else", ":", "gosubdag", ".", "init_auxobjs", "(", ")", "return",...
Gets a GoSubDag initialized for use by a Grouper object.
[ "Gets", "a", "GoSubDag", "initialized", "for", "use", "by", "a", "Grouper", "object", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/grprdflts.py#L71-L81
228,567
tanghaibao/goatools
goatools/anno/opts.py
AnnoOptions.getfnc_qual_ev
def getfnc_qual_ev(self): """Keep annotaion if it passes potentially modified selection.""" fnc_key = ( self.nd_not2desc[(self._keep_nd, self._keep_not)], self.incexc2num[( self.include_evcodes is not None, self.exclude_evcodes is not None)], ...
python
def getfnc_qual_ev(self): """Keep annotaion if it passes potentially modified selection.""" fnc_key = ( self.nd_not2desc[(self._keep_nd, self._keep_not)], self.incexc2num[( self.include_evcodes is not None, self.exclude_evcodes is not None)], ...
[ "def", "getfnc_qual_ev", "(", "self", ")", ":", "fnc_key", "=", "(", "self", ".", "nd_not2desc", "[", "(", "self", ".", "_keep_nd", ",", "self", ".", "_keep_not", ")", "]", ",", "self", ".", "incexc2num", "[", "(", "self", ".", "include_evcodes", "is",...
Keep annotaion if it passes potentially modified selection.
[ "Keep", "annotaion", "if", "it", "passes", "potentially", "modified", "selection", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/anno/opts.py#L65-L73
228,568
tanghaibao/goatools
goatools/gosubdag/plot/go_node.py
GoNodeOpts.get_kws
def get_kws(self): """Only load keywords if they are specified by the user.""" ret = self.kws['dict'].copy() act_set = self.kws['set'] if 'shorten' in act_set and 'goobj2fncname' not in ret: ret['goobj2fncname'] = ShortenText().get_short_plot_name return ret
python
def get_kws(self): """Only load keywords if they are specified by the user.""" ret = self.kws['dict'].copy() act_set = self.kws['set'] if 'shorten' in act_set and 'goobj2fncname' not in ret: ret['goobj2fncname'] = ShortenText().get_short_plot_name return ret
[ "def", "get_kws", "(", "self", ")", ":", "ret", "=", "self", ".", "kws", "[", "'dict'", "]", ".", "copy", "(", ")", "act_set", "=", "self", ".", "kws", "[", "'set'", "]", "if", "'shorten'", "in", "act_set", "and", "'goobj2fncname'", "not", "in", "r...
Only load keywords if they are specified by the user.
[ "Only", "load", "keywords", "if", "they", "are", "specified", "by", "the", "user", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/gosubdag/plot/go_node.py#L32-L38
228,569
tanghaibao/goatools
goatools/gosubdag/plot/go_node.py
GoNode.get_node
def get_node(self, goid, goobj): """Return pydot node.""" # pydot.Node.objdict holds this information. pydot.Node.objdict['name'] return pydot.Node( self.get_node_text(goid, goobj), shape="box", style="rounded, filled", fillcolor=self.go2color.get(...
python
def get_node(self, goid, goobj): """Return pydot node.""" # pydot.Node.objdict holds this information. pydot.Node.objdict['name'] return pydot.Node( self.get_node_text(goid, goobj), shape="box", style="rounded, filled", fillcolor=self.go2color.get(...
[ "def", "get_node", "(", "self", ",", "goid", ",", "goobj", ")", ":", "# pydot.Node.objdict holds this information. pydot.Node.objdict['name']", "return", "pydot", ".", "Node", "(", "self", ".", "get_node_text", "(", "goid", ",", "goobj", ")", ",", "shape", "=", ...
Return pydot node.
[ "Return", "pydot", "node", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/gosubdag/plot/go_node.py#L56-L64
228,570
tanghaibao/goatools
goatools/gosubdag/plot/go_node.py
GoNode.str_fmthdr
def str_fmthdr(self, goid, goobj): """Return hdr line seen inside a GO Term box.""" # Shorten: Ex: GO:0007608 -> G0007608 go_txt = goid.replace("GO:", "G") if 'mark_alt_id' in self.present and goid != goobj.id: go_txt += 'a' return go_txt
python
def str_fmthdr(self, goid, goobj): """Return hdr line seen inside a GO Term box.""" # Shorten: Ex: GO:0007608 -> G0007608 go_txt = goid.replace("GO:", "G") if 'mark_alt_id' in self.present and goid != goobj.id: go_txt += 'a' return go_txt
[ "def", "str_fmthdr", "(", "self", ",", "goid", ",", "goobj", ")", ":", "# Shorten: Ex: GO:0007608 -> G0007608", "go_txt", "=", "goid", ".", "replace", "(", "\"GO:\"", ",", "\"G\"", ")", "if", "'mark_alt_id'", "in", "self", ".", "present", "and", "goid", "!="...
Return hdr line seen inside a GO Term box.
[ "Return", "hdr", "line", "seen", "inside", "a", "GO", "Term", "box", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/gosubdag/plot/go_node.py#L66-L72
228,571
tanghaibao/goatools
goatools/gosubdag/plot/go_node.py
GoNode._get_prtflds
def _get_prtflds(self): """Get print fields for GO header.""" # User-specified print fields ntflds = self.gosubdag.prt_attr['flds'] prt_flds = self.kws.get('prt_flds') if prt_flds: return prt_flds.intersection(ntflds) exclude = set() # Default print fi...
python
def _get_prtflds(self): """Get print fields for GO header.""" # User-specified print fields ntflds = self.gosubdag.prt_attr['flds'] prt_flds = self.kws.get('prt_flds') if prt_flds: return prt_flds.intersection(ntflds) exclude = set() # Default print fi...
[ "def", "_get_prtflds", "(", "self", ")", ":", "# User-specified print fields", "ntflds", "=", "self", ".", "gosubdag", ".", "prt_attr", "[", "'flds'", "]", "prt_flds", "=", "self", ".", "kws", ".", "get", "(", "'prt_flds'", ")", "if", "prt_flds", ":", "ret...
Get print fields for GO header.
[ "Get", "print", "fields", "for", "GO", "header", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/gosubdag/plot/go_node.py#L132-L143
228,572
tanghaibao/goatools
goatools/gosubdag/plot/go_node.py
GoNode._get_hdr_childcnt
def _get_hdr_childcnt(self, goobj, ntgo): """Get string representing count of children for this GO term.""" if 'childcnt' in self.present: return "c{N}".format(N=len(goobj.children)) elif self.gosubdag.relationships and not goobj.children and ntgo.dcnt != 0: return "c0"
python
def _get_hdr_childcnt(self, goobj, ntgo): """Get string representing count of children for this GO term.""" if 'childcnt' in self.present: return "c{N}".format(N=len(goobj.children)) elif self.gosubdag.relationships and not goobj.children and ntgo.dcnt != 0: return "c0"
[ "def", "_get_hdr_childcnt", "(", "self", ",", "goobj", ",", "ntgo", ")", ":", "if", "'childcnt'", "in", "self", ".", "present", ":", "return", "\"c{N}\"", ".", "format", "(", "N", "=", "len", "(", "goobj", ".", "children", ")", ")", "elif", "self", "...
Get string representing count of children for this GO term.
[ "Get", "string", "representing", "count", "of", "children", "for", "this", "GO", "term", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/gosubdag/plot/go_node.py#L145-L150
228,573
tanghaibao/goatools
goatools/gosubdag/plot/go_node.py
GoNode._add_parent_cnt
def _add_parent_cnt(self, hdr, goobj, c2ps): """Add the parent count to the GO term box for if not all parents are plotted.""" if goobj.id in c2ps: parents = c2ps[goobj.id] if 'prt_pcnt' in self.present or parents and len(goobj.parents) != len(parents): assert len...
python
def _add_parent_cnt(self, hdr, goobj, c2ps): """Add the parent count to the GO term box for if not all parents are plotted.""" if goobj.id in c2ps: parents = c2ps[goobj.id] if 'prt_pcnt' in self.present or parents and len(goobj.parents) != len(parents): assert len...
[ "def", "_add_parent_cnt", "(", "self", ",", "hdr", ",", "goobj", ",", "c2ps", ")", ":", "if", "goobj", ".", "id", "in", "c2ps", ":", "parents", "=", "c2ps", "[", "goobj", ".", "id", "]", "if", "'prt_pcnt'", "in", "self", ".", "present", "or", "pare...
Add the parent count to the GO term box for if not all parents are plotted.
[ "Add", "the", "parent", "count", "to", "the", "GO", "term", "box", "for", "if", "not", "all", "parents", "are", "plotted", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/gosubdag/plot/go_node.py#L152-L158
228,574
tanghaibao/goatools
goatools/anno/idtogos_reader.py
IdToGosReader.prt_summary_anno2ev
def prt_summary_anno2ev(self, prt=sys.stdout): """Print a summary of all Evidence Codes seen in annotations""" prt.write('**NOTE: No evidence codes in associations: {F}\n'.format(F=self.filename))
python
def prt_summary_anno2ev(self, prt=sys.stdout): """Print a summary of all Evidence Codes seen in annotations""" prt.write('**NOTE: No evidence codes in associations: {F}\n'.format(F=self.filename))
[ "def", "prt_summary_anno2ev", "(", "self", ",", "prt", "=", "sys", ".", "stdout", ")", ":", "prt", ".", "write", "(", "'**NOTE: No evidence codes in associations: {F}\\n'", ".", "format", "(", "F", "=", "self", ".", "filename", ")", ")" ]
Print a summary of all Evidence Codes seen in annotations
[ "Print", "a", "summary", "of", "all", "Evidence", "Codes", "seen", "in", "annotations" ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/anno/idtogos_reader.py#L21-L23
228,575
tanghaibao/goatools
goatools/ratio.py
count_terms
def count_terms(geneset, assoc, obo_dag): """count the number of terms in the study group """ term_cnt = Counter() for gene in (g for g in geneset if g in assoc): for goid in assoc[gene]: if goid in obo_dag: term_cnt[obo_dag[goid].id] += 1 return term_cnt
python
def count_terms(geneset, assoc, obo_dag): """count the number of terms in the study group """ term_cnt = Counter() for gene in (g for g in geneset if g in assoc): for goid in assoc[gene]: if goid in obo_dag: term_cnt[obo_dag[goid].id] += 1 return term_cnt
[ "def", "count_terms", "(", "geneset", ",", "assoc", ",", "obo_dag", ")", ":", "term_cnt", "=", "Counter", "(", ")", "for", "gene", "in", "(", "g", "for", "g", "in", "geneset", "if", "g", "in", "assoc", ")", ":", "for", "goid", "in", "assoc", "[", ...
count the number of terms in the study group
[ "count", "the", "number", "of", "terms", "in", "the", "study", "group" ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/ratio.py#L10-L19
228,576
tanghaibao/goatools
goatools/ratio.py
get_terms
def get_terms(desc, geneset, assoc, obo_dag, log): """Get the terms in the study group """ _chk_gene2go(assoc) term2itemids = defaultdict(set) genes = [g for g in geneset if g in assoc] for gene in genes: for goid in assoc[gene]: if goid in obo_dag: term2itemi...
python
def get_terms(desc, geneset, assoc, obo_dag, log): """Get the terms in the study group """ _chk_gene2go(assoc) term2itemids = defaultdict(set) genes = [g for g in geneset if g in assoc] for gene in genes: for goid in assoc[gene]: if goid in obo_dag: term2itemi...
[ "def", "get_terms", "(", "desc", ",", "geneset", ",", "assoc", ",", "obo_dag", ",", "log", ")", ":", "_chk_gene2go", "(", "assoc", ")", "term2itemids", "=", "defaultdict", "(", "set", ")", "genes", "=", "[", "g", "for", "g", "in", "geneset", "if", "g...
Get the terms in the study group
[ "Get", "the", "terms", "in", "the", "study", "group" ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/ratio.py#L21-L37
228,577
tanghaibao/goatools
goatools/ratio.py
_chk_gene2go
def _chk_gene2go(assoc): """Check that associations is gene2go, not go2gene.""" if not assoc: raise RuntimeError("NO ITEMS FOUND IN ASSOCIATIONS {A}".format(A=assoc)) for key in assoc: if isinstance(key, str) and key[:3] == "GO:": raise Exception("ASSOCIATIONS EXPECTED TO BE gene...
python
def _chk_gene2go(assoc): """Check that associations is gene2go, not go2gene.""" if not assoc: raise RuntimeError("NO ITEMS FOUND IN ASSOCIATIONS {A}".format(A=assoc)) for key in assoc: if isinstance(key, str) and key[:3] == "GO:": raise Exception("ASSOCIATIONS EXPECTED TO BE gene...
[ "def", "_chk_gene2go", "(", "assoc", ")", ":", "if", "not", "assoc", ":", "raise", "RuntimeError", "(", "\"NO ITEMS FOUND IN ASSOCIATIONS {A}\"", ".", "format", "(", "A", "=", "assoc", ")", ")", "for", "key", "in", "assoc", ":", "if", "isinstance", "(", "k...
Check that associations is gene2go, not go2gene.
[ "Check", "that", "associations", "is", "gene2go", "not", "go2gene", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/ratio.py#L56-L64
228,578
tanghaibao/goatools
goatools/grouper/grprobj_init.py
GrouperInit._init_usrgos
def _init_usrgos(self, goids): """Return user GO IDs which have GO Terms.""" usrgos = set() goids_missing = set() _go2obj = self.gosubdag.go2obj for goid in goids: if goid in _go2obj: usrgos.add(goid) else: goids_missing.add...
python
def _init_usrgos(self, goids): """Return user GO IDs which have GO Terms.""" usrgos = set() goids_missing = set() _go2obj = self.gosubdag.go2obj for goid in goids: if goid in _go2obj: usrgos.add(goid) else: goids_missing.add...
[ "def", "_init_usrgos", "(", "self", ",", "goids", ")", ":", "usrgos", "=", "set", "(", ")", "goids_missing", "=", "set", "(", ")", "_go2obj", "=", "self", ".", "gosubdag", ".", "go2obj", "for", "goid", "in", "goids", ":", "if", "goid", "in", "_go2obj...
Return user GO IDs which have GO Terms.
[ "Return", "user", "GO", "IDs", "which", "have", "GO", "Terms", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/grprobj_init.py#L49-L62
228,579
tanghaibao/goatools
goatools/grouper/grprobj_init.py
GrouperInit.get_gos_all
def get_gos_all(self): """Return a flat list of all GO IDs in grouping object. All GO IDs: * header GO IDs that are not user GO IDs * user GO IDs that are under header GOs * user GO IDs that are header GOs in groups containing no other user GO IDs ...
python
def get_gos_all(self): """Return a flat list of all GO IDs in grouping object. All GO IDs: * header GO IDs that are not user GO IDs * user GO IDs that are under header GOs * user GO IDs that are header GOs in groups containing no other user GO IDs ...
[ "def", "get_gos_all", "(", "self", ")", ":", "gos_all", "=", "set", "(", ")", "# Get:", "# * Header GO IDs that are not user GO IDs", "# * User GO IDs that are under header GOs", "for", "hdrgo", ",", "usrgos", "in", "self", ".", "hdrgo2usrgos", ".", "items", "(", ...
Return a flat list of all GO IDs in grouping object. All GO IDs: * header GO IDs that are not user GO IDs * user GO IDs that are under header GOs * user GO IDs that are header GOs in groups containing no other user GO IDs
[ "Return", "a", "flat", "list", "of", "all", "GO", "IDs", "in", "grouping", "object", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/grprobj_init.py#L64-L84
228,580
tanghaibao/goatools
goatools/grouper/grprobj_init.py
GrouperInit._init_h2us
def _init_h2us(self, fnc_most_specific): """Given a set of user GO ids, return GO ids grouped under the "GO high" terms. Example of a grouped go list: gos = ['GO:0044464':[ # grp_term: D1 cell part 'GO:0005737', # child: D3 cytoplasm 'GO:...
python
def _init_h2us(self, fnc_most_specific): """Given a set of user GO ids, return GO ids grouped under the "GO high" terms. Example of a grouped go list: gos = ['GO:0044464':[ # grp_term: D1 cell part 'GO:0005737', # child: D3 cytoplasm 'GO:...
[ "def", "_init_h2us", "(", "self", ",", "fnc_most_specific", ")", ":", "# Header GO IDs are main. User GO IDs are as specified by the user", "hdrgo2usrgos", "=", "cx", ".", "defaultdict", "(", "set", ")", "# Contains user GO IDs which are also header GO IDs, plus user main GO if nee...
Given a set of user GO ids, return GO ids grouped under the "GO high" terms. Example of a grouped go list: gos = ['GO:0044464':[ # grp_term: D1 cell part 'GO:0005737', # child: D3 cytoplasm 'GO:0048471', # child: D4 perinuclear region of cytop...
[ "Given", "a", "set", "of", "user", "GO", "ids", "return", "GO", "ids", "grouped", "under", "the", "GO", "high", "terms", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/grprobj_init.py#L86-L121
228,581
tanghaibao/goatools
goatools/grouper/grprobj_init.py
GrouperInit.get_go2nt
def get_go2nt(self, usr_go2nt): """Combine user namedtuple fields, GO object fields, and format_txt.""" gos_all = self.get_gos_all() # Minimum set of namedtuple fields available for use with Sorter on grouped GO IDs prt_flds_all = get_hdridx_flds() + self.gosubdag.prt_attr['flds'] ...
python
def get_go2nt(self, usr_go2nt): """Combine user namedtuple fields, GO object fields, and format_txt.""" gos_all = self.get_gos_all() # Minimum set of namedtuple fields available for use with Sorter on grouped GO IDs prt_flds_all = get_hdridx_flds() + self.gosubdag.prt_attr['flds'] ...
[ "def", "get_go2nt", "(", "self", ",", "usr_go2nt", ")", ":", "gos_all", "=", "self", ".", "get_gos_all", "(", ")", "# Minimum set of namedtuple fields available for use with Sorter on grouped GO IDs", "prt_flds_all", "=", "get_hdridx_flds", "(", ")", "+", "self", ".", ...
Combine user namedtuple fields, GO object fields, and format_txt.
[ "Combine", "user", "namedtuple", "fields", "GO", "object", "fields", "and", "format_txt", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/grprobj_init.py#L143-L155
228,582
tanghaibao/goatools
goatools/grouper/grprobj_init.py
GrouperInit._init_go2nt_aug
def _init_go2nt_aug(self, go2nt): """Augment go2nt with GO ID key to account for alt GO IDs.""" go2obj = self.gosubdag.go2obj # Get alt GO IDs go2nt_aug = {} # NOW for goid_usr, nt_usr in go2nt.items(): goobj = go2obj[goid_usr] if goobj.alt_ids: ...
python
def _init_go2nt_aug(self, go2nt): """Augment go2nt with GO ID key to account for alt GO IDs.""" go2obj = self.gosubdag.go2obj # Get alt GO IDs go2nt_aug = {} # NOW for goid_usr, nt_usr in go2nt.items(): goobj = go2obj[goid_usr] if goobj.alt_ids: ...
[ "def", "_init_go2nt_aug", "(", "self", ",", "go2nt", ")", ":", "go2obj", "=", "self", ".", "gosubdag", ".", "go2obj", "# Get alt GO IDs", "go2nt_aug", "=", "{", "}", "# NOW", "for", "goid_usr", ",", "nt_usr", "in", "go2nt", ".", "items", "(", ")", ":", ...
Augment go2nt with GO ID key to account for alt GO IDs.
[ "Augment", "go2nt", "with", "GO", "ID", "key", "to", "account", "for", "alt", "GO", "IDs", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/grprobj_init.py#L173-L191
228,583
tanghaibao/goatools
goatools/grouper/grprobj_init.py
GrouperInit._get_go2nthdridx
def _get_go2nthdridx(self, gos_all): """Get GO IDs header index for each user GO ID and corresponding parent GO IDs.""" go2nthdridx = {} # NtHdrIdx Namedtuple fields: # * format_txt: Used to determine the format when writing Excel cells # * hdr_idx: Value printed in an Excel ...
python
def _get_go2nthdridx(self, gos_all): """Get GO IDs header index for each user GO ID and corresponding parent GO IDs.""" go2nthdridx = {} # NtHdrIdx Namedtuple fields: # * format_txt: Used to determine the format when writing Excel cells # * hdr_idx: Value printed in an Excel ...
[ "def", "_get_go2nthdridx", "(", "self", ",", "gos_all", ")", ":", "go2nthdridx", "=", "{", "}", "# NtHdrIdx Namedtuple fields:", "# * format_txt: Used to determine the format when writing Excel cells", "# * hdr_idx: Value printed in an Excel cell", "# shortcuts", "obj", "=", ...
Get GO IDs header index for each user GO ID and corresponding parent GO IDs.
[ "Get", "GO", "IDs", "header", "index", "for", "each", "user", "GO", "ID", "and", "corresponding", "parent", "GO", "IDs", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/grprobj_init.py#L193-L204
228,584
tanghaibao/goatools
goatools/godag_obosm.py
OboToGoDagSmall._init_go2obj
def _init_go2obj(self, **kws): """Initialize go2obj in small dag for source gos.""" if 'goids' in kws and 'obodag' in kws: self.godag.go_sources = kws['goids'] obo = kws['obodag'] for goid in self.godag.go_sources: self.godag.go2obj[goid] = obo[goid] ...
python
def _init_go2obj(self, **kws): """Initialize go2obj in small dag for source gos.""" if 'goids' in kws and 'obodag' in kws: self.godag.go_sources = kws['goids'] obo = kws['obodag'] for goid in self.godag.go_sources: self.godag.go2obj[goid] = obo[goid] ...
[ "def", "_init_go2obj", "(", "self", ",", "*", "*", "kws", ")", ":", "if", "'goids'", "in", "kws", "and", "'obodag'", "in", "kws", ":", "self", ".", "godag", ".", "go_sources", "=", "kws", "[", "'goids'", "]", "obo", "=", "kws", "[", "'obodag'", "]"...
Initialize go2obj in small dag for source gos.
[ "Initialize", "go2obj", "in", "small", "dag", "for", "source", "gos", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/godag_obosm.py#L28-L43
228,585
tanghaibao/goatools
goatools/godag_obosm.py
OboToGoDagSmall._init
def _init(self): """Given GO ids and GOTerm objects, create mini GO dag.""" for goid in self.godag.go_sources: goobj = self.godag.go2obj[goid] self.godag.go2obj[goid] = goobj # Traverse up parents if self.traverse_parent and goid not in self.seen_cids: ...
python
def _init(self): """Given GO ids and GOTerm objects, create mini GO dag.""" for goid in self.godag.go_sources: goobj = self.godag.go2obj[goid] self.godag.go2obj[goid] = goobj # Traverse up parents if self.traverse_parent and goid not in self.seen_cids: ...
[ "def", "_init", "(", "self", ")", ":", "for", "goid", "in", "self", ".", "godag", ".", "go_sources", ":", "goobj", "=", "self", ".", "godag", ".", "go2obj", "[", "goid", "]", "self", ".", "godag", ".", "go2obj", "[", "goid", "]", "=", "goobj", "#...
Given GO ids and GOTerm objects, create mini GO dag.
[ "Given", "GO", "ids", "and", "GOTerm", "objects", "create", "mini", "GO", "dag", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/godag_obosm.py#L45-L55
228,586
tanghaibao/goatools
goatools/rpt/write_hierarchy_base.py
WrHierPrt.prt_hier_rec
def prt_hier_rec(self, item_id, depth=1): """Write hierarchy for a GO Term record and all GO IDs down to the leaf level.""" # Shortens hierarchy report by only printing the hierarchy # for the sub-set of user-specified GO terms which are connected. if self.include_only and item_id not in...
python
def prt_hier_rec(self, item_id, depth=1): """Write hierarchy for a GO Term record and all GO IDs down to the leaf level.""" # Shortens hierarchy report by only printing the hierarchy # for the sub-set of user-specified GO terms which are connected. if self.include_only and item_id not in...
[ "def", "prt_hier_rec", "(", "self", ",", "item_id", ",", "depth", "=", "1", ")", ":", "# Shortens hierarchy report by only printing the hierarchy", "# for the sub-set of user-specified GO terms which are connected.", "if", "self", ".", "include_only", "and", "item_id", "not",...
Write hierarchy for a GO Term record and all GO IDs down to the leaf level.
[ "Write", "hierarchy", "for", "a", "GO", "Term", "record", "and", "all", "GO", "IDs", "down", "to", "the", "leaf", "level", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/rpt/write_hierarchy_base.py#L34-L68
228,587
tanghaibao/goatools
goatools/rpt/write_hierarchy_base.py
WrHierPrt._init_item_marks
def _init_item_marks(item_marks): """Initialize the makred item dict.""" if isinstance(item_marks, dict): return item_marks if item_marks: return {item_id:'>' for item_id in item_marks}
python
def _init_item_marks(item_marks): """Initialize the makred item dict.""" if isinstance(item_marks, dict): return item_marks if item_marks: return {item_id:'>' for item_id in item_marks}
[ "def", "_init_item_marks", "(", "item_marks", ")", ":", "if", "isinstance", "(", "item_marks", ",", "dict", ")", ":", "return", "item_marks", "if", "item_marks", ":", "return", "{", "item_id", ":", "'>'", "for", "item_id", "in", "item_marks", "}" ]
Initialize the makred item dict.
[ "Initialize", "the", "makred", "item", "dict", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/rpt/write_hierarchy_base.py#L97-L102
228,588
tanghaibao/goatools
goatools/obo_parser.py
OBOReader._add_to_obj
def _add_to_obj(self, rec_curr, typedef_curr, line): """Add information on line to GOTerm or Typedef.""" if rec_curr is not None: self._add_to_ref(rec_curr, line) else: add_to_typedef(typedef_curr, line)
python
def _add_to_obj(self, rec_curr, typedef_curr, line): """Add information on line to GOTerm or Typedef.""" if rec_curr is not None: self._add_to_ref(rec_curr, line) else: add_to_typedef(typedef_curr, line)
[ "def", "_add_to_obj", "(", "self", ",", "rec_curr", ",", "typedef_curr", ",", "line", ")", ":", "if", "rec_curr", "is", "not", "None", ":", "self", ".", "_add_to_ref", "(", "rec_curr", ",", "line", ")", "else", ":", "add_to_typedef", "(", "typedef_curr", ...
Add information on line to GOTerm or Typedef.
[ "Add", "information", "on", "line", "to", "GOTerm", "or", "Typedef", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/obo_parser.py#L87-L92
228,589
tanghaibao/goatools
goatools/obo_parser.py
OBOReader._init_obo_version
def _init_obo_version(self, line): """Save obo version and release.""" if line[0:14] == "format-version": self.format_version = line[16:-1] if line[0:12] == "data-version": self.data_version = line[14:-1]
python
def _init_obo_version(self, line): """Save obo version and release.""" if line[0:14] == "format-version": self.format_version = line[16:-1] if line[0:12] == "data-version": self.data_version = line[14:-1]
[ "def", "_init_obo_version", "(", "self", ",", "line", ")", ":", "if", "line", "[", "0", ":", "14", "]", "==", "\"format-version\"", ":", "self", ".", "format_version", "=", "line", "[", "16", ":", "-", "1", "]", "if", "line", "[", "0", ":", "12", ...
Save obo version and release.
[ "Save", "obo", "version", "and", "release", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/obo_parser.py#L94-L99
228,590
tanghaibao/goatools
goatools/obo_parser.py
OBOReader._init_optional_attrs
def _init_optional_attrs(optional_attrs): """Create OboOptionalAttrs or return None.""" if optional_attrs is None: return None opts = OboOptionalAttrs.get_optional_attrs(optional_attrs) if opts: return OboOptionalAttrs(opts)
python
def _init_optional_attrs(optional_attrs): """Create OboOptionalAttrs or return None.""" if optional_attrs is None: return None opts = OboOptionalAttrs.get_optional_attrs(optional_attrs) if opts: return OboOptionalAttrs(opts)
[ "def", "_init_optional_attrs", "(", "optional_attrs", ")", ":", "if", "optional_attrs", "is", "None", ":", "return", "None", "opts", "=", "OboOptionalAttrs", ".", "get_optional_attrs", "(", "optional_attrs", ")", "if", "opts", ":", "return", "OboOptionalAttrs", "(...
Create OboOptionalAttrs or return None.
[ "Create", "OboOptionalAttrs", "or", "return", "None", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/obo_parser.py#L130-L136
228,591
tanghaibao/goatools
goatools/obo_parser.py
GOTerm.has_parent
def has_parent(self, term): """Return True if this GO object has a parent GO ID.""" for parent in self.parents: if parent.item_id == term or parent.has_parent(term): return True return False
python
def has_parent(self, term): """Return True if this GO object has a parent GO ID.""" for parent in self.parents: if parent.item_id == term or parent.has_parent(term): return True return False
[ "def", "has_parent", "(", "self", ",", "term", ")", ":", "for", "parent", "in", "self", ".", "parents", ":", "if", "parent", ".", "item_id", "==", "term", "or", "parent", ".", "has_parent", "(", "term", ")", ":", "return", "True", "return", "False" ]
Return True if this GO object has a parent GO ID.
[ "Return", "True", "if", "this", "GO", "object", "has", "a", "parent", "GO", "ID", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/obo_parser.py#L191-L196
228,592
tanghaibao/goatools
goatools/obo_parser.py
GOTerm.has_child
def has_child(self, term): """Return True if this GO object has a child GO ID.""" for parent in self.children: if parent.item_id == term or parent.has_child(term): return True return False
python
def has_child(self, term): """Return True if this GO object has a child GO ID.""" for parent in self.children: if parent.item_id == term or parent.has_child(term): return True return False
[ "def", "has_child", "(", "self", ",", "term", ")", ":", "for", "parent", "in", "self", ".", "children", ":", "if", "parent", ".", "item_id", "==", "term", "or", "parent", ".", "has_child", "(", "term", ")", ":", "return", "True", "return", "False" ]
Return True if this GO object has a child GO ID.
[ "Return", "True", "if", "this", "GO", "object", "has", "a", "child", "GO", "ID", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/obo_parser.py#L198-L203
228,593
tanghaibao/goatools
goatools/obo_parser.py
GOTerm.get_all_parents
def get_all_parents(self): """Return all parent GO IDs.""" all_parents = set() for parent in self.parents: all_parents.add(parent.item_id) all_parents |= parent.get_all_parents() return all_parents
python
def get_all_parents(self): """Return all parent GO IDs.""" all_parents = set() for parent in self.parents: all_parents.add(parent.item_id) all_parents |= parent.get_all_parents() return all_parents
[ "def", "get_all_parents", "(", "self", ")", ":", "all_parents", "=", "set", "(", ")", "for", "parent", "in", "self", ".", "parents", ":", "all_parents", ".", "add", "(", "parent", ".", "item_id", ")", "all_parents", "|=", "parent", ".", "get_all_parents", ...
Return all parent GO IDs.
[ "Return", "all", "parent", "GO", "IDs", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/obo_parser.py#L205-L211
228,594
tanghaibao/goatools
goatools/obo_parser.py
GOTerm.get_all_upper
def get_all_upper(self): """Return all parent GO IDs through both 'is_a' and all relationships.""" all_upper = set() for upper in self.get_goterms_upper(): all_upper.add(upper.item_id) all_upper |= upper.get_all_upper() return all_upper
python
def get_all_upper(self): """Return all parent GO IDs through both 'is_a' and all relationships.""" all_upper = set() for upper in self.get_goterms_upper(): all_upper.add(upper.item_id) all_upper |= upper.get_all_upper() return all_upper
[ "def", "get_all_upper", "(", "self", ")", ":", "all_upper", "=", "set", "(", ")", "for", "upper", "in", "self", ".", "get_goterms_upper", "(", ")", ":", "all_upper", ".", "add", "(", "upper", ".", "item_id", ")", "all_upper", "|=", "upper", ".", "get_a...
Return all parent GO IDs through both 'is_a' and all relationships.
[ "Return", "all", "parent", "GO", "IDs", "through", "both", "is_a", "and", "all", "relationships", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/obo_parser.py#L213-L219
228,595
tanghaibao/goatools
goatools/obo_parser.py
GOTerm.get_all_children
def get_all_children(self): """Return all children GO IDs.""" all_children = set() for parent in self.children: all_children.add(parent.item_id) all_children |= parent.get_all_children() return all_children
python
def get_all_children(self): """Return all children GO IDs.""" all_children = set() for parent in self.children: all_children.add(parent.item_id) all_children |= parent.get_all_children() return all_children
[ "def", "get_all_children", "(", "self", ")", ":", "all_children", "=", "set", "(", ")", "for", "parent", "in", "self", ".", "children", ":", "all_children", ".", "add", "(", "parent", ".", "item_id", ")", "all_children", "|=", "parent", ".", "get_all_child...
Return all children GO IDs.
[ "Return", "all", "children", "GO", "IDs", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/obo_parser.py#L221-L227
228,596
tanghaibao/goatools
goatools/obo_parser.py
GOTerm.get_all_lower
def get_all_lower(self): """Return all parent GO IDs through both reverse 'is_a' and all relationships.""" all_lower = set() for lower in self.get_goterms_lower(): all_lower.add(lower.item_id) all_lower |= lower.get_all_lower() return all_lower
python
def get_all_lower(self): """Return all parent GO IDs through both reverse 'is_a' and all relationships.""" all_lower = set() for lower in self.get_goterms_lower(): all_lower.add(lower.item_id) all_lower |= lower.get_all_lower() return all_lower
[ "def", "get_all_lower", "(", "self", ")", ":", "all_lower", "=", "set", "(", ")", "for", "lower", "in", "self", ".", "get_goterms_lower", "(", ")", ":", "all_lower", ".", "add", "(", "lower", ".", "item_id", ")", "all_lower", "|=", "lower", ".", "get_a...
Return all parent GO IDs through both reverse 'is_a' and all relationships.
[ "Return", "all", "parent", "GO", "IDs", "through", "both", "reverse", "is_a", "and", "all", "relationships", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/obo_parser.py#L229-L235
228,597
tanghaibao/goatools
goatools/obo_parser.py
GOTerm.get_all_parent_edges
def get_all_parent_edges(self): """Return tuples for all parent GO IDs, containing current GO ID and parent GO ID.""" all_parent_edges = set() for parent in self.parents: all_parent_edges.add((self.item_id, parent.item_id)) all_parent_edges |= parent.get_all_parent_edges(...
python
def get_all_parent_edges(self): """Return tuples for all parent GO IDs, containing current GO ID and parent GO ID.""" all_parent_edges = set() for parent in self.parents: all_parent_edges.add((self.item_id, parent.item_id)) all_parent_edges |= parent.get_all_parent_edges(...
[ "def", "get_all_parent_edges", "(", "self", ")", ":", "all_parent_edges", "=", "set", "(", ")", "for", "parent", "in", "self", ".", "parents", ":", "all_parent_edges", ".", "add", "(", "(", "self", ".", "item_id", ",", "parent", ".", "item_id", ")", ")",...
Return tuples for all parent GO IDs, containing current GO ID and parent GO ID.
[ "Return", "tuples", "for", "all", "parent", "GO", "IDs", "containing", "current", "GO", "ID", "and", "parent", "GO", "ID", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/obo_parser.py#L237-L243
228,598
tanghaibao/goatools
goatools/obo_parser.py
GOTerm.get_all_child_edges
def get_all_child_edges(self): """Return tuples for all child GO IDs, containing current GO ID and child GO ID.""" all_child_edges = set() for parent in self.children: all_child_edges.add((parent.item_id, self.item_id)) all_child_edges |= parent.get_all_child_edges() ...
python
def get_all_child_edges(self): """Return tuples for all child GO IDs, containing current GO ID and child GO ID.""" all_child_edges = set() for parent in self.children: all_child_edges.add((parent.item_id, self.item_id)) all_child_edges |= parent.get_all_child_edges() ...
[ "def", "get_all_child_edges", "(", "self", ")", ":", "all_child_edges", "=", "set", "(", ")", "for", "parent", "in", "self", ".", "children", ":", "all_child_edges", ".", "add", "(", "(", "parent", ".", "item_id", ",", "self", ".", "item_id", ")", ")", ...
Return tuples for all child GO IDs, containing current GO ID and child GO ID.
[ "Return", "tuples", "for", "all", "child", "GO", "IDs", "containing", "current", "GO", "ID", "and", "child", "GO", "ID", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/obo_parser.py#L245-L251
228,599
tanghaibao/goatools
goatools/obo_parser.py
GODag.load_obo_file
def load_obo_file(self, obo_file, optional_attrs, load_obsolete, prt): """Read obo file. Store results.""" reader = OBOReader(obo_file, optional_attrs) # Save alt_ids and their corresponding main GO ID. Add to GODag after populating GO Terms alt2rec = {} for rec in reader: ...
python
def load_obo_file(self, obo_file, optional_attrs, load_obsolete, prt): """Read obo file. Store results.""" reader = OBOReader(obo_file, optional_attrs) # Save alt_ids and their corresponding main GO ID. Add to GODag after populating GO Terms alt2rec = {} for rec in reader: ...
[ "def", "load_obo_file", "(", "self", ",", "obo_file", ",", "optional_attrs", ",", "load_obsolete", ",", "prt", ")", ":", "reader", "=", "OBOReader", "(", "obo_file", ",", "optional_attrs", ")", "# Save alt_ids and their corresponding main GO ID. Add to GODag after populat...
Read obo file. Store results.
[ "Read", "obo", "file", ".", "Store", "results", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/obo_parser.py#L312-L340