repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
tanghaibao/goatools
goatools/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
train
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
train
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
train
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
train
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
train
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", ")", "for", "goid_altid", "in", "goobj_child", ".", "...
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
train
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
train
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
train
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\"", ")", "self", ".", "_chk_fld", "(", "ntd", ...
Check annotations.
[ "Check", "annotations", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/anno/init/reader_gaf.py#L151-L167
train
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", "]", ")", "flds", "[", "5", "]", "=", "self", ".",...
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
train
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
train
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
train
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
train
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", ".", "flds", ",", "values", ")", "txt", "=", "[", "\"{:2}) {:3} {:20} {}\"", ".", "fo...
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
train
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", ")", ":", "errcnts", "=", "[", "]", "if", "self", ".", "ignored", ":", "errcnts", ".", "append", "(", "\" {N:9,} IGNORED associations\\n\"", ".", "format", "(", "N", "=", "len", "(", "self", ".", ...
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
train
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", ")", ":", "gaf_base", "=", "os", ".", "path", ".", "basename", "(", "fout_err", ")", "with", "open", "(", "fout_err", ",", "'w'", ")", "as", "prt", ":", "prt", ".", "wr...
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
train
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
train
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", ")", ":", "ns2dcntgoobj", "=", "cx", ".", "defaultdict", "(", "list", ")", "for", "goobj", "in", "depth2goobjs", "[", "1", "]", ":", "dcnt", "=", "go2dcnt", "[", "goobj", ".",...
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
train
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
train
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
train
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
train
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
train
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
train
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", ")", ":", "return", "pydot", ".", "Node", "(", "self", ".", "get_node_text", "(", "goid", ",", "goobj", ")", ",", "shape", "=", "\"box\"", ",", "style", "=", "\"rounded, filled\"", ",", "fillco...
Return pydot node.
[ "Return", "pydot", "node", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/gosubdag/plot/go_node.py#L56-L64
train
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", ")", ":", "go_txt", "=", "goid", ".", "replace", "(", "\"GO:\"", ",", "\"G\"", ")", "if", "'mark_alt_id'", "in", "self", ".", "present", "and", "goid", "!=", "goobj", ".", "id", ":", "go_tx...
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
train
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", ")", ":", "ntflds", "=", "self", ".", "gosubdag", ".", "prt_attr", "[", "'flds'", "]", "prt_flds", "=", "self", ".", "kws", ".", "get", "(", "'prt_flds'", ")", "if", "prt_flds", ":", "return", "prt_flds", ".", "inter...
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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", "(", ")", "for", "hdrgo", ",", "usrgos", "in", "self", ".", "hdrgo2usrgos", ".", "items", "(", ")", ":", "gos_all", ".", "add", "(", "hdrgo", ")", "gos_all", "|=", "usrgos", "gos_all...
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
train
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", ")", ":", "hdrgo2usrgos", "=", "cx", ".", "defaultdict", "(", "set", ")", "hdrgo_is_usrgo", "=", "set", "(", ")", "_go2nt", "=", "self", ".", "gosubdag", ".", "go2nt", "objhi", "=", "GrouperInit",...
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
train
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", "(", ")", "prt_flds_all", "=", "get_hdridx_flds", "(", ")", "+", "self", ".", "gosubdag", ".", "prt_attr", "[", "'flds'", "]", "if", "not", "usr_go2n...
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
train
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", "go2nt_aug", "=", "{", "}", "for", "goid_usr", ",", "nt_usr", "in", "go2nt", ".", "items", "(", ")", ":", "goobj", "=", "go2obj", "[...
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
train
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", "=", "{", "}", "obj", "=", "GrouperInit", ".", "NtMaker", "(", "self", ")", "for", "goid", "in", "gos_all", ":", "go2nthdridx", "[", "goid", "]", "=", "obj", ".", "get_nt"...
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
train
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'", "]", "f...
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
train
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", "i...
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
train
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", ")", ":", "if", "self", ".", "include_only", "and", "item_id", "not", "in", "self", ".", "include_only", ":", "return", "obj", "=", "self", ".", "id2obj", "[", "item_id", "]", ...
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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", ")", "alt2rec", "=", "{", "}", "for", "rec", "in", "reader", ":", ...
Read obo file. Store results.
[ "Read", "obo", "file", ".", "Store", "results", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/obo_parser.py#L312-L340
train
tanghaibao/goatools
goatools/obo_parser.py
GODag._str_desc
def _str_desc(self, reader): """String containing information about the current GO DAG.""" data_version = reader.data_version if data_version is not None: data_version = data_version.replace("releases/", "") desc = "{OBO}: fmt({FMT}) rel({REL}) {N:,} GO Terms".format( ...
python
def _str_desc(self, reader): """String containing information about the current GO DAG.""" data_version = reader.data_version if data_version is not None: data_version = data_version.replace("releases/", "") desc = "{OBO}: fmt({FMT}) rel({REL}) {N:,} GO Terms".format( ...
[ "def", "_str_desc", "(", "self", ",", "reader", ")", ":", "data_version", "=", "reader", ".", "data_version", "if", "data_version", "is", "not", "None", ":", "data_version", "=", "data_version", ".", "replace", "(", "\"releases/\"", ",", "\"\"", ")", "desc",...
String containing information about the current GO DAG.
[ "String", "containing", "information", "about", "the", "current", "GO", "DAG", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/obo_parser.py#L342-L352
train
tanghaibao/goatools
goatools/obo_parser.py
GODag._populate_terms
def _populate_terms(self, optobj): """Convert GO IDs to GO Term record objects. Populate children.""" has_relationship = optobj is not None and 'relationship' in optobj.optional_attrs # Make parents and relationships references to the actual GO terms. for rec in self.values(): ...
python
def _populate_terms(self, optobj): """Convert GO IDs to GO Term record objects. Populate children.""" has_relationship = optobj is not None and 'relationship' in optobj.optional_attrs # Make parents and relationships references to the actual GO terms. for rec in self.values(): ...
[ "def", "_populate_terms", "(", "self", ",", "optobj", ")", ":", "has_relationship", "=", "optobj", "is", "not", "None", "and", "'relationship'", "in", "optobj", ".", "optional_attrs", "for", "rec", "in", "self", ".", "values", "(", ")", ":", "rec", ".", ...
Convert GO IDs to GO Term record objects. Populate children.
[ "Convert", "GO", "IDs", "to", "GO", "Term", "record", "objects", ".", "Populate", "children", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/obo_parser.py#L355-L368
train
tanghaibao/goatools
goatools/obo_parser.py
GODag._populate_relationships
def _populate_relationships(self, rec_curr): """Convert GO IDs in relationships to GO Term record objects. Populate children.""" for relationship_type, goids in rec_curr.relationship.items(): parent_recs = set([self[goid] for goid in goids]) rec_curr.relationship[relationship_typ...
python
def _populate_relationships(self, rec_curr): """Convert GO IDs in relationships to GO Term record objects. Populate children.""" for relationship_type, goids in rec_curr.relationship.items(): parent_recs = set([self[goid] for goid in goids]) rec_curr.relationship[relationship_typ...
[ "def", "_populate_relationships", "(", "self", ",", "rec_curr", ")", ":", "for", "relationship_type", ",", "goids", "in", "rec_curr", ".", "relationship", ".", "items", "(", ")", ":", "parent_recs", "=", "set", "(", "[", "self", "[", "goid", "]", "for", ...
Convert GO IDs in relationships to GO Term record objects. Populate children.
[ "Convert", "GO", "IDs", "in", "relationships", "to", "GO", "Term", "record", "objects", ".", "Populate", "children", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/obo_parser.py#L370-L379
train
tanghaibao/goatools
goatools/obo_parser.py
GODag._set_level_depth
def _set_level_depth(self, optobj): """Set level, depth and add inverted relationships.""" has_relationship = optobj is not None and 'relationship' in optobj.optional_attrs def _init_level(rec): if rec.level is None: if rec.parents: rec.level = mi...
python
def _set_level_depth(self, optobj): """Set level, depth and add inverted relationships.""" has_relationship = optobj is not None and 'relationship' in optobj.optional_attrs def _init_level(rec): if rec.level is None: if rec.parents: rec.level = mi...
[ "def", "_set_level_depth", "(", "self", ",", "optobj", ")", ":", "has_relationship", "=", "optobj", "is", "not", "None", "and", "'relationship'", "in", "optobj", ".", "optional_attrs", "def", "_init_level", "(", "rec", ")", ":", "if", "rec", ".", "level", ...
Set level, depth and add inverted relationships.
[ "Set", "level", "depth", "and", "add", "inverted", "relationships", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/obo_parser.py#L381-L434
train
tanghaibao/goatools
goatools/obo_parser.py
GODag.write_dag
def write_dag(self, out=sys.stdout): """Write info for all GO Terms in obo file, sorted numerically.""" for rec in sorted(self.values()): print(rec, file=out)
python
def write_dag(self, out=sys.stdout): """Write info for all GO Terms in obo file, sorted numerically.""" for rec in sorted(self.values()): print(rec, file=out)
[ "def", "write_dag", "(", "self", ",", "out", "=", "sys", ".", "stdout", ")", ":", "for", "rec", "in", "sorted", "(", "self", ".", "values", "(", ")", ")", ":", "print", "(", "rec", ",", "file", "=", "out", ")" ]
Write info for all GO Terms in obo file, sorted numerically.
[ "Write", "info", "for", "all", "GO", "Terms", "in", "obo", "file", "sorted", "numerically", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/obo_parser.py#L436-L439
train
tanghaibao/goatools
goatools/obo_parser.py
GODag.query_term
def query_term(self, term, verbose=False): """Given a GO ID, return GO object.""" if term not in self: sys.stderr.write("Term %s not found!\n" % term) return rec = self[term] if verbose: print(rec) sys.stderr.write("all parents: {}\n".form...
python
def query_term(self, term, verbose=False): """Given a GO ID, return GO object.""" if term not in self: sys.stderr.write("Term %s not found!\n" % term) return rec = self[term] if verbose: print(rec) sys.stderr.write("all parents: {}\n".form...
[ "def", "query_term", "(", "self", ",", "term", ",", "verbose", "=", "False", ")", ":", "if", "term", "not", "in", "self", ":", "sys", ".", "stderr", ".", "write", "(", "\"Term %s not found!\\n\"", "%", "term", ")", "return", "rec", "=", "self", "[", ...
Given a GO ID, return GO object.
[ "Given", "a", "GO", "ID", "return", "GO", "object", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/obo_parser.py#L461-L474
train
tanghaibao/goatools
goatools/obo_parser.py
GODag.label_wrap
def label_wrap(self, label): """Label text for plot.""" wrapped_label = r"%s\n%s" % (label, self[label].name.replace(",", r"\n")) return wrapped_label
python
def label_wrap(self, label): """Label text for plot.""" wrapped_label = r"%s\n%s" % (label, self[label].name.replace(",", r"\n")) return wrapped_label
[ "def", "label_wrap", "(", "self", ",", "label", ")", ":", "wrapped_label", "=", "r\"%s\\n%s\"", "%", "(", "label", ",", "self", "[", "label", "]", ".", "name", ".", "replace", "(", "\",\"", ",", "r\"\\n\"", ")", ")", "return", "wrapped_label" ]
Label text for plot.
[ "Label", "text", "for", "plot", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/obo_parser.py#L512-L516
train
tanghaibao/goatools
goatools/obo_parser.py
GODag.make_graph_pygraphviz
def make_graph_pygraphviz(self, recs, nodecolor, edgecolor, dpi, draw_parents=True, draw_children=True): """Draw AMIGO style network, lineage containing one query record.""" import pygraphviz as pgv grph = pgv.AGraph(name="GO tree") ...
python
def make_graph_pygraphviz(self, recs, nodecolor, edgecolor, dpi, draw_parents=True, draw_children=True): """Draw AMIGO style network, lineage containing one query record.""" import pygraphviz as pgv grph = pgv.AGraph(name="GO tree") ...
[ "def", "make_graph_pygraphviz", "(", "self", ",", "recs", ",", "nodecolor", ",", "edgecolor", ",", "dpi", ",", "draw_parents", "=", "True", ",", "draw_children", "=", "True", ")", ":", "import", "pygraphviz", "as", "pgv", "grph", "=", "pgv", ".", "AGraph",...
Draw AMIGO style network, lineage containing one query record.
[ "Draw", "AMIGO", "style", "network", "lineage", "containing", "one", "query", "record", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/obo_parser.py#L557-L599
train
tanghaibao/goatools
goatools/obo_parser.py
GODag.draw_lineage
def draw_lineage(self, recs, nodecolor="mediumseagreen", edgecolor="lightslateblue", dpi=96, lineage_img="GO_lineage.png", engine="pygraphviz", gml=False, draw_parents=True, draw_children=True): """Draw GO DAG subplot.""" assert engine in Gr...
python
def draw_lineage(self, recs, nodecolor="mediumseagreen", edgecolor="lightslateblue", dpi=96, lineage_img="GO_lineage.png", engine="pygraphviz", gml=False, draw_parents=True, draw_children=True): """Draw GO DAG subplot.""" assert engine in Gr...
[ "def", "draw_lineage", "(", "self", ",", "recs", ",", "nodecolor", "=", "\"mediumseagreen\"", ",", "edgecolor", "=", "\"lightslateblue\"", ",", "dpi", "=", "96", ",", "lineage_img", "=", "\"GO_lineage.png\"", ",", "engine", "=", "\"pygraphviz\"", ",", "gml", "...
Draw GO DAG subplot.
[ "Draw", "GO", "DAG", "subplot", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/obo_parser.py#L601-L633
train
tanghaibao/goatools
goatools/anno/init/reader_gpad.py
InitAssc._get_ntgpadvals
def _get_ntgpadvals(self, flds, add_ns): """Convert fields from string to preferred format for GPAD ver 2.1 and 2.0.""" is_set = False qualifiers = self._get_qualifier(flds[2]) assert flds[3][:3] == 'GO:', 'UNRECOGNIZED GO({GO})'.format(GO=flds[3]) db_reference = self._rd_fld_val...
python
def _get_ntgpadvals(self, flds, add_ns): """Convert fields from string to preferred format for GPAD ver 2.1 and 2.0.""" is_set = False qualifiers = self._get_qualifier(flds[2]) assert flds[3][:3] == 'GO:', 'UNRECOGNIZED GO({GO})'.format(GO=flds[3]) db_reference = self._rd_fld_val...
[ "def", "_get_ntgpadvals", "(", "self", ",", "flds", ",", "add_ns", ")", ":", "is_set", "=", "False", "qualifiers", "=", "self", ".", "_get_qualifier", "(", "flds", "[", "2", "]", ")", "assert", "flds", "[", "3", "]", "[", ":", "3", "]", "==", "'GO:...
Convert fields from string to preferred format for GPAD ver 2.1 and 2.0.
[ "Convert", "fields", "from", "string", "to", "preferred", "format", "for", "GPAD", "ver", "2", ".", "1", "and", "2", ".", "0", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/anno/init/reader_gpad.py#L74-L109
train
tanghaibao/goatools
goatools/anno/init/reader_gpad.py
InitAssc._rd_fld_vals
def _rd_fld_vals(name, val, set_list_ft=True, qty_min=0, qty_max=None): """Further split a GPAD value within a single field.""" if not val and qty_min == 0: return [] if set_list_ft else set() vals = val.split('|') # Use a pipe to separate entries num_vals = len(vals) ...
python
def _rd_fld_vals(name, val, set_list_ft=True, qty_min=0, qty_max=None): """Further split a GPAD value within a single field.""" if not val and qty_min == 0: return [] if set_list_ft else set() vals = val.split('|') # Use a pipe to separate entries num_vals = len(vals) ...
[ "def", "_rd_fld_vals", "(", "name", ",", "val", ",", "set_list_ft", "=", "True", ",", "qty_min", "=", "0", ",", "qty_max", "=", "None", ")", ":", "if", "not", "val", "and", "qty_min", "==", "0", ":", "return", "[", "]", "if", "set_list_ft", "else", ...
Further split a GPAD value within a single field.
[ "Further", "split", "a", "GPAD", "value", "within", "a", "single", "field", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/anno/init/reader_gpad.py#L123-L136
train
tanghaibao/goatools
goatools/anno/init/reader_gpad.py
InitAssc._get_taxon
def _get_taxon(taxon): """Return Interacting taxon ID | optional | 0 or 1 | gaf column 13.""" if not taxon: return None ## assert taxon[:6] == 'taxon:', 'UNRECOGNIZED Taxon({Taxon})'.format(Taxon=taxon) ## taxid = taxon[6:] ## assert taxon[:10] == 'NCBITaxon:', 'UNREC...
python
def _get_taxon(taxon): """Return Interacting taxon ID | optional | 0 or 1 | gaf column 13.""" if not taxon: return None ## assert taxon[:6] == 'taxon:', 'UNRECOGNIZED Taxon({Taxon})'.format(Taxon=taxon) ## taxid = taxon[6:] ## assert taxon[:10] == 'NCBITaxon:', 'UNREC...
[ "def", "_get_taxon", "(", "taxon", ")", ":", "if", "not", "taxon", ":", "return", "None", "sep", "=", "taxon", ".", "find", "(", "':'", ")", "taxid", "=", "taxon", "[", "sep", "+", "1", ":", "]", "assert", "taxid", ".", "isdigit", "(", ")", ",", ...
Return Interacting taxon ID | optional | 0 or 1 | gaf column 13.
[ "Return", "Interacting", "taxon", "ID", "|", "optional", "|", "0", "or", "1", "|", "gaf", "column", "13", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/anno/init/reader_gpad.py#L139-L151
train
tanghaibao/goatools
goatools/anno/init/reader_gpad.py
InitAssc._get_ntgpadnt
def _get_ntgpadnt(self, ver, add_ns): """Create a namedtuple object for each annotation""" hdrs = self.gpad_columns[ver] if add_ns: hdrs = hdrs + ['NS'] return cx.namedtuple("ntgpadobj", hdrs)
python
def _get_ntgpadnt(self, ver, add_ns): """Create a namedtuple object for each annotation""" hdrs = self.gpad_columns[ver] if add_ns: hdrs = hdrs + ['NS'] return cx.namedtuple("ntgpadobj", hdrs)
[ "def", "_get_ntgpadnt", "(", "self", ",", "ver", ",", "add_ns", ")", ":", "hdrs", "=", "self", ".", "gpad_columns", "[", "ver", "]", "if", "add_ns", ":", "hdrs", "=", "hdrs", "+", "[", "'NS'", "]", "return", "cx", ".", "namedtuple", "(", "\"ntgpadobj...
Create a namedtuple object for each annotation
[ "Create", "a", "namedtuple", "object", "for", "each", "annotation" ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/anno/init/reader_gpad.py#L226-L231
train
tanghaibao/goatools
goatools/anno/init/reader_gpad.py
InitAssc._split_line
def _split_line(self, line): """Split line into field values.""" line = line.rstrip('\r\n') flds = re.split('\t', line) assert len(flds) == self.exp_numcol, "EXPECTED({E}) COLUMNS, ACTUAL({A}): {L}".format( E=self.exp_numcol, A=len(flds), L=line) return flds
python
def _split_line(self, line): """Split line into field values.""" line = line.rstrip('\r\n') flds = re.split('\t', line) assert len(flds) == self.exp_numcol, "EXPECTED({E}) COLUMNS, ACTUAL({A}): {L}".format( E=self.exp_numcol, A=len(flds), L=line) return flds
[ "def", "_split_line", "(", "self", ",", "line", ")", ":", "line", "=", "line", ".", "rstrip", "(", "'\\r\\n'", ")", "flds", "=", "re", ".", "split", "(", "'\\t'", ",", "line", ")", "assert", "len", "(", "flds", ")", "==", "self", ".", "exp_numcol",...
Split line into field values.
[ "Split", "line", "into", "field", "values", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/anno/init/reader_gpad.py#L233-L239
train
tanghaibao/goatools
goatools/anno/init/reader_gpad.py
GpadHdr.chkaddhdr
def chkaddhdr(self, line): """If this line contains desired header info, save it.""" mtch = self.cmpline.search(line) if mtch: self.gpadhdr.append(mtch.group(1))
python
def chkaddhdr(self, line): """If this line contains desired header info, save it.""" mtch = self.cmpline.search(line) if mtch: self.gpadhdr.append(mtch.group(1))
[ "def", "chkaddhdr", "(", "self", ",", "line", ")", ":", "mtch", "=", "self", ".", "cmpline", ".", "search", "(", "line", ")", "if", "mtch", ":", "self", ".", "gpadhdr", ".", "append", "(", "mtch", ".", "group", "(", "1", ")", ")" ]
If this line contains desired header info, save it.
[ "If", "this", "line", "contains", "desired", "header", "info", "save", "it", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/anno/init/reader_gpad.py#L268-L272
train
tanghaibao/goatools
goatools/nt_utils.py
get_dict_w_id2nts
def get_dict_w_id2nts(ids, id2nts, flds, dflt_null=""): """Return a new dict of namedtuples by combining "dicts" of namedtuples or objects.""" assert len(ids) == len(set(ids)), "NOT ALL IDs ARE UNIQUE: {IDs}".format(IDs=ids) assert len(flds) == len(set(flds)), "DUPLICATE FIELDS: {IDs}".format( IDs=c...
python
def get_dict_w_id2nts(ids, id2nts, flds, dflt_null=""): """Return a new dict of namedtuples by combining "dicts" of namedtuples or objects.""" assert len(ids) == len(set(ids)), "NOT ALL IDs ARE UNIQUE: {IDs}".format(IDs=ids) assert len(flds) == len(set(flds)), "DUPLICATE FIELDS: {IDs}".format( IDs=c...
[ "def", "get_dict_w_id2nts", "(", "ids", ",", "id2nts", ",", "flds", ",", "dflt_null", "=", "\"\"", ")", ":", "assert", "len", "(", "ids", ")", "==", "len", "(", "set", "(", "ids", ")", ")", ",", "\"NOT ALL IDs ARE UNIQUE: {IDs}\"", ".", "format", "(", ...
Return a new dict of namedtuples by combining "dicts" of namedtuples or objects.
[ "Return", "a", "new", "dict", "of", "namedtuples", "by", "combining", "dicts", "of", "namedtuples", "or", "objects", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/nt_utils.py#L10-L24
train
tanghaibao/goatools
goatools/nt_utils.py
get_list_w_id2nts
def get_list_w_id2nts(ids, id2nts, flds, dflt_null=""): """Return a new list of namedtuples by combining "dicts" of namedtuples or objects.""" combined_nt_list = [] # 1. Instantiate namedtuple object ntobj = cx.namedtuple("Nt", " ".join(flds)) # 2. Fill dict with namedtuple objects for desired ids ...
python
def get_list_w_id2nts(ids, id2nts, flds, dflt_null=""): """Return a new list of namedtuples by combining "dicts" of namedtuples or objects.""" combined_nt_list = [] # 1. Instantiate namedtuple object ntobj = cx.namedtuple("Nt", " ".join(flds)) # 2. Fill dict with namedtuple objects for desired ids ...
[ "def", "get_list_w_id2nts", "(", "ids", ",", "id2nts", ",", "flds", ",", "dflt_null", "=", "\"\"", ")", ":", "combined_nt_list", "=", "[", "]", "ntobj", "=", "cx", ".", "namedtuple", "(", "\"Nt\"", ",", "\" \"", ".", "join", "(", "flds", ")", ")", "f...
Return a new list of namedtuples by combining "dicts" of namedtuples or objects.
[ "Return", "a", "new", "list", "of", "namedtuples", "by", "combining", "dicts", "of", "namedtuples", "or", "objects", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/nt_utils.py#L26-L37
train
tanghaibao/goatools
goatools/nt_utils.py
combine_nt_lists
def combine_nt_lists(lists, flds, dflt_null=""): """Return a new list of namedtuples by zipping "lists" of namedtuples or objects.""" combined_nt_list = [] # Check that all lists are the same length lens = [len(lst) for lst in lists] assert len(set(lens)) == 1, \ "LIST LENGTHS MUST BE EQUAL:...
python
def combine_nt_lists(lists, flds, dflt_null=""): """Return a new list of namedtuples by zipping "lists" of namedtuples or objects.""" combined_nt_list = [] # Check that all lists are the same length lens = [len(lst) for lst in lists] assert len(set(lens)) == 1, \ "LIST LENGTHS MUST BE EQUAL:...
[ "def", "combine_nt_lists", "(", "lists", ",", "flds", ",", "dflt_null", "=", "\"\"", ")", ":", "combined_nt_list", "=", "[", "]", "lens", "=", "[", "len", "(", "lst", ")", "for", "lst", "in", "lists", "]", "assert", "len", "(", "set", "(", "lens", ...
Return a new list of namedtuples by zipping "lists" of namedtuples or objects.
[ "Return", "a", "new", "list", "of", "namedtuples", "by", "zipping", "lists", "of", "namedtuples", "or", "objects", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/nt_utils.py#L39-L52
train
tanghaibao/goatools
goatools/nt_utils.py
wr_py_nts
def wr_py_nts(fout_py, nts, docstring=None, varname="nts"): """Save namedtuples into a Python module.""" if nts: with open(fout_py, 'w') as prt: prt.write('"""{DOCSTRING}"""\n\n'.format(DOCSTRING=docstring)) prt.write("# Created: {DATE}\n".format(DATE=str(datetime.date.today())))...
python
def wr_py_nts(fout_py, nts, docstring=None, varname="nts"): """Save namedtuples into a Python module.""" if nts: with open(fout_py, 'w') as prt: prt.write('"""{DOCSTRING}"""\n\n'.format(DOCSTRING=docstring)) prt.write("# Created: {DATE}\n".format(DATE=str(datetime.date.today())))...
[ "def", "wr_py_nts", "(", "fout_py", ",", "nts", ",", "docstring", "=", "None", ",", "varname", "=", "\"nts\"", ")", ":", "if", "nts", ":", "with", "open", "(", "fout_py", ",", "'w'", ")", "as", "prt", ":", "prt", ".", "write", "(", "'\\n\\n'", ".",...
Save namedtuples into a Python module.
[ "Save", "namedtuples", "into", "a", "Python", "module", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/nt_utils.py#L54-L61
train
tanghaibao/goatools
goatools/nt_utils.py
prt_nts
def prt_nts(prt, nts, varname, spc=' '): """Print namedtuples into a Python module.""" first_nt = nts[0] nt_name = type(first_nt).__name__ prt.write("import collections as cx\n\n") prt.write("NT_FIELDS = [\n") for fld in first_nt._fields: prt.write('{SPC}"{F}",\n'.format(SPC=spc, F=fl...
python
def prt_nts(prt, nts, varname, spc=' '): """Print namedtuples into a Python module.""" first_nt = nts[0] nt_name = type(first_nt).__name__ prt.write("import collections as cx\n\n") prt.write("NT_FIELDS = [\n") for fld in first_nt._fields: prt.write('{SPC}"{F}",\n'.format(SPC=spc, F=fl...
[ "def", "prt_nts", "(", "prt", ",", "nts", ",", "varname", ",", "spc", "=", "' '", ")", ":", "first_nt", "=", "nts", "[", "0", "]", "nt_name", "=", "type", "(", "first_nt", ")", ".", "__name__", "prt", ".", "write", "(", "\"import collections as cx\\...
Print namedtuples into a Python module.
[ "Print", "namedtuples", "into", "a", "Python", "module", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/nt_utils.py#L63-L79
train
tanghaibao/goatools
goatools/nt_utils.py
get_unique_fields
def get_unique_fields(fld_lists): """Get unique namedtuple fields, despite potential duplicates in lists of fields.""" flds = [] fld_set = set([f for flst in fld_lists for f in flst]) fld_seen = set() # Add unique fields to list of fields in order that they appear for fld_list in fld_lists: ...
python
def get_unique_fields(fld_lists): """Get unique namedtuple fields, despite potential duplicates in lists of fields.""" flds = [] fld_set = set([f for flst in fld_lists for f in flst]) fld_seen = set() # Add unique fields to list of fields in order that they appear for fld_list in fld_lists: ...
[ "def", "get_unique_fields", "(", "fld_lists", ")", ":", "flds", "=", "[", "]", "fld_set", "=", "set", "(", "[", "f", "for", "flst", "in", "fld_lists", "for", "f", "in", "flst", "]", ")", "fld_seen", "=", "set", "(", ")", "for", "fld_list", "in", "f...
Get unique namedtuple fields, despite potential duplicates in lists of fields.
[ "Get", "unique", "namedtuple", "fields", "despite", "potential", "duplicates", "in", "lists", "of", "fields", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/nt_utils.py#L81-L94
train
tanghaibao/goatools
goatools/nt_utils.py
_combine_nt_vals
def _combine_nt_vals(lst0_lstn, flds, dflt_null): """Given a list of lists of nts, return a single namedtuple.""" vals = [] for fld in flds: fld_seen = False # Set field value using the **first** value seen in list of nt lists(lst0_lstn) for nt_curr in lst0_lstn: if hasat...
python
def _combine_nt_vals(lst0_lstn, flds, dflt_null): """Given a list of lists of nts, return a single namedtuple.""" vals = [] for fld in flds: fld_seen = False # Set field value using the **first** value seen in list of nt lists(lst0_lstn) for nt_curr in lst0_lstn: if hasat...
[ "def", "_combine_nt_vals", "(", "lst0_lstn", ",", "flds", ",", "dflt_null", ")", ":", "vals", "=", "[", "]", "for", "fld", "in", "flds", ":", "fld_seen", "=", "False", "for", "nt_curr", "in", "lst0_lstn", ":", "if", "hasattr", "(", "nt_curr", ",", "fld...
Given a list of lists of nts, return a single namedtuple.
[ "Given", "a", "list", "of", "lists", "of", "nts", "return", "a", "single", "namedtuple", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/nt_utils.py#L97-L111
train
tanghaibao/goatools
goatools/cli/gos_get.py
GetGOs.get_go2obj
def get_go2obj(self, goids): """Return GO Terms for each user-specified GO ID. Note missing GO IDs.""" goids = goids.intersection(self.go2obj.keys()) if len(goids) != len(goids): goids_missing = goids.difference(goids) print(" {N} MISSING GO IDs: {GOs}".format(N=len(goid...
python
def get_go2obj(self, goids): """Return GO Terms for each user-specified GO ID. Note missing GO IDs.""" goids = goids.intersection(self.go2obj.keys()) if len(goids) != len(goids): goids_missing = goids.difference(goids) print(" {N} MISSING GO IDs: {GOs}".format(N=len(goid...
[ "def", "get_go2obj", "(", "self", ",", "goids", ")", ":", "goids", "=", "goids", ".", "intersection", "(", "self", ".", "go2obj", ".", "keys", "(", ")", ")", "if", "len", "(", "goids", ")", "!=", "len", "(", "goids", ")", ":", "goids_missing", "=",...
Return GO Terms for each user-specified GO ID. Note missing GO IDs.
[ "Return", "GO", "Terms", "for", "each", "user", "-", "specified", "GO", "ID", ".", "Note", "missing", "GO", "IDs", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/cli/gos_get.py#L46-L52
train
tanghaibao/goatools
goatools/grouper/utils.py
no_duplicates_sections2d
def no_duplicates_sections2d(sections2d, prt=None): """Check for duplicate header GO IDs in the 2-D sections variable.""" no_dups = True ctr = cx.Counter() for _, hdrgos in sections2d: for goid in hdrgos: ctr[goid] += 1 for goid, cnt in ctr.most_common(): if cnt == 1: ...
python
def no_duplicates_sections2d(sections2d, prt=None): """Check for duplicate header GO IDs in the 2-D sections variable.""" no_dups = True ctr = cx.Counter() for _, hdrgos in sections2d: for goid in hdrgos: ctr[goid] += 1 for goid, cnt in ctr.most_common(): if cnt == 1: ...
[ "def", "no_duplicates_sections2d", "(", "sections2d", ",", "prt", "=", "None", ")", ":", "no_dups", "=", "True", "ctr", "=", "cx", ".", "Counter", "(", ")", "for", "_", ",", "hdrgos", "in", "sections2d", ":", "for", "goid", "in", "hdrgos", ":", "ctr", ...
Check for duplicate header GO IDs in the 2-D sections variable.
[ "Check", "for", "duplicate", "header", "GO", "IDs", "in", "the", "2", "-", "D", "sections", "variable", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/utils.py#L13-L26
train
tanghaibao/goatools
goatools/evidence_codes.py
EvidenceCodes.get_evcodes
def get_evcodes(self, inc_set=None, exc_set=None): """Get evidence code for all but NOT 'No biological data'""" codes = self.get_evcodes_all(inc_set, exc_set) codes.discard('ND') return codes
python
def get_evcodes(self, inc_set=None, exc_set=None): """Get evidence code for all but NOT 'No biological data'""" codes = self.get_evcodes_all(inc_set, exc_set) codes.discard('ND') return codes
[ "def", "get_evcodes", "(", "self", ",", "inc_set", "=", "None", ",", "exc_set", "=", "None", ")", ":", "codes", "=", "self", ".", "get_evcodes_all", "(", "inc_set", ",", "exc_set", ")", "codes", ".", "discard", "(", "'ND'", ")", "return", "codes" ]
Get evidence code for all but NOT 'No biological data
[ "Get", "evidence", "code", "for", "all", "but", "NOT", "No", "biological", "data" ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/evidence_codes.py#L90-L94
train
tanghaibao/goatools
goatools/evidence_codes.py
EvidenceCodes.get_evcodes_all
def get_evcodes_all(self, inc_set=None, exc_set=None): """Get set of evidence codes given include set and exclude set""" codes = self._get_grps_n_codes(inc_set) if inc_set else set(self.code2nt) if exc_set: codes.difference_update(self._get_grps_n_codes(exc_set)) return codes
python
def get_evcodes_all(self, inc_set=None, exc_set=None): """Get set of evidence codes given include set and exclude set""" codes = self._get_grps_n_codes(inc_set) if inc_set else set(self.code2nt) if exc_set: codes.difference_update(self._get_grps_n_codes(exc_set)) return codes
[ "def", "get_evcodes_all", "(", "self", ",", "inc_set", "=", "None", ",", "exc_set", "=", "None", ")", ":", "codes", "=", "self", ".", "_get_grps_n_codes", "(", "inc_set", ")", "if", "inc_set", "else", "set", "(", "self", ".", "code2nt", ")", "if", "exc...
Get set of evidence codes given include set and exclude set
[ "Get", "set", "of", "evidence", "codes", "given", "include", "set", "and", "exclude", "set" ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/evidence_codes.py#L96-L101
train
tanghaibao/goatools
goatools/evidence_codes.py
EvidenceCodes._get_grps_n_codes
def _get_grps_n_codes(self, usr_set): """Get codes, given codes or groups.""" codes = usr_set.intersection(self.code2nt) for grp in usr_set.intersection(self.grp2codes): codes.update(self.grp2codes[grp]) return codes
python
def _get_grps_n_codes(self, usr_set): """Get codes, given codes or groups.""" codes = usr_set.intersection(self.code2nt) for grp in usr_set.intersection(self.grp2codes): codes.update(self.grp2codes[grp]) return codes
[ "def", "_get_grps_n_codes", "(", "self", ",", "usr_set", ")", ":", "codes", "=", "usr_set", ".", "intersection", "(", "self", ".", "code2nt", ")", "for", "grp", "in", "usr_set", ".", "intersection", "(", "self", ".", "grp2codes", ")", ":", "codes", ".", ...
Get codes, given codes or groups.
[ "Get", "codes", "given", "codes", "or", "groups", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/evidence_codes.py#L103-L108
train
tanghaibao/goatools
goatools/evidence_codes.py
EvidenceCodes.sort_nts
def sort_nts(self, nt_list, codekey): """Sort list of namedtuples such so evidence codes in same order as code2nt.""" # Problem is that some members in the nt_list do NOT have # codekey=EvidenceCode, then it returns None, which breaks py34 and 35 # The fix here is that for these members,...
python
def sort_nts(self, nt_list, codekey): """Sort list of namedtuples such so evidence codes in same order as code2nt.""" # Problem is that some members in the nt_list do NOT have # codekey=EvidenceCode, then it returns None, which breaks py34 and 35 # The fix here is that for these members,...
[ "def", "sort_nts", "(", "self", ",", "nt_list", ",", "codekey", ")", ":", "sortby", "=", "lambda", "nt", ":", "self", ".", "ev2idx", ".", "get", "(", "getattr", "(", "nt", ",", "codekey", ")", ",", "-", "1", ")", "return", "sorted", "(", "nt_list",...
Sort list of namedtuples such so evidence codes in same order as code2nt.
[ "Sort", "list", "of", "namedtuples", "such", "so", "evidence", "codes", "in", "same", "order", "as", "code2nt", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/evidence_codes.py#L110-L116
train
tanghaibao/goatools
goatools/evidence_codes.py
EvidenceCodes.get_grp_name
def get_grp_name(self, code): """Return group and name for an evidence code.""" nt_code = self.code2nt.get(code.strip(), None) if nt_code is not None: return nt_code.group, nt_code.name return "", ""
python
def get_grp_name(self, code): """Return group and name for an evidence code.""" nt_code = self.code2nt.get(code.strip(), None) if nt_code is not None: return nt_code.group, nt_code.name return "", ""
[ "def", "get_grp_name", "(", "self", ",", "code", ")", ":", "nt_code", "=", "self", ".", "code2nt", ".", "get", "(", "code", ".", "strip", "(", ")", ",", "None", ")", "if", "nt_code", "is", "not", "None", ":", "return", "nt_code", ".", "group", ",",...
Return group and name for an evidence code.
[ "Return", "group", "and", "name", "for", "an", "evidence", "code", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/evidence_codes.py#L118-L123
train
tanghaibao/goatools
goatools/evidence_codes.py
EvidenceCodes.prt_ev_cnts
def prt_ev_cnts(self, ctr, prt=sys.stdout): """Prints evidence code counts stored in a collections Counter.""" for key, cnt in ctr.most_common(): grp, name = self.get_grp_name(key.replace("NOT ", "")) prt.write("{CNT:7,} {EV:>7} {GROUP:<15} {NAME}\n".format( CNT=c...
python
def prt_ev_cnts(self, ctr, prt=sys.stdout): """Prints evidence code counts stored in a collections Counter.""" for key, cnt in ctr.most_common(): grp, name = self.get_grp_name(key.replace("NOT ", "")) prt.write("{CNT:7,} {EV:>7} {GROUP:<15} {NAME}\n".format( CNT=c...
[ "def", "prt_ev_cnts", "(", "self", ",", "ctr", ",", "prt", "=", "sys", ".", "stdout", ")", ":", "for", "key", ",", "cnt", "in", "ctr", ".", "most_common", "(", ")", ":", "grp", ",", "name", "=", "self", ".", "get_grp_name", "(", "key", ".", "repl...
Prints evidence code counts stored in a collections Counter.
[ "Prints", "evidence", "code", "counts", "stored", "in", "a", "collections", "Counter", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/evidence_codes.py#L125-L130
train
tanghaibao/goatools
goatools/evidence_codes.py
EvidenceCodes.get_order
def get_order(self, codes): """Return evidence codes in order shown in code2name.""" return sorted(codes, key=lambda e: [self.ev2idx.get(e)])
python
def get_order(self, codes): """Return evidence codes in order shown in code2name.""" return sorted(codes, key=lambda e: [self.ev2idx.get(e)])
[ "def", "get_order", "(", "self", ",", "codes", ")", ":", "return", "sorted", "(", "codes", ",", "key", "=", "lambda", "e", ":", "[", "self", ".", "ev2idx", ".", "get", "(", "e", ")", "]", ")" ]
Return evidence codes in order shown in code2name.
[ "Return", "evidence", "codes", "in", "order", "shown", "in", "code2name", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/evidence_codes.py#L132-L134
train
tanghaibao/goatools
goatools/evidence_codes.py
_Init.get_grp2code2nt
def get_grp2code2nt(self): """Return ordered dict for group to namedtuple""" grp2code2nt = cx.OrderedDict([(g, []) for g in self.grps]) for code, ntd in self.code2nt.items(): grp2code2nt[ntd.group].append((code, ntd)) for grp, nts in grp2code2nt.items(): grp2code2...
python
def get_grp2code2nt(self): """Return ordered dict for group to namedtuple""" grp2code2nt = cx.OrderedDict([(g, []) for g in self.grps]) for code, ntd in self.code2nt.items(): grp2code2nt[ntd.group].append((code, ntd)) for grp, nts in grp2code2nt.items(): grp2code2...
[ "def", "get_grp2code2nt", "(", "self", ")", ":", "grp2code2nt", "=", "cx", ".", "OrderedDict", "(", "[", "(", "g", ",", "[", "]", ")", "for", "g", "in", "self", ".", "grps", "]", ")", "for", "code", ",", "ntd", "in", "self", ".", "code2nt", ".", ...
Return ordered dict for group to namedtuple
[ "Return", "ordered", "dict", "for", "group", "to", "namedtuple" ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/evidence_codes.py#L156-L163
train
tanghaibao/goatools
goatools/evidence_codes.py
_Init._init_grps
def _init_grps(code2nt): """Return list of groups in same order as in code2nt""" seen = set() seen_add = seen.add groups = [nt.group for nt in code2nt.values()] return [g for g in groups if not (g in seen or seen_add(g))]
python
def _init_grps(code2nt): """Return list of groups in same order as in code2nt""" seen = set() seen_add = seen.add groups = [nt.group for nt in code2nt.values()] return [g for g in groups if not (g in seen or seen_add(g))]
[ "def", "_init_grps", "(", "code2nt", ")", ":", "seen", "=", "set", "(", ")", "seen_add", "=", "seen", ".", "add", "groups", "=", "[", "nt", ".", "group", "for", "nt", "in", "code2nt", ".", "values", "(", ")", "]", "return", "[", "g", "for", "g", ...
Return list of groups in same order as in code2nt
[ "Return", "list", "of", "groups", "in", "same", "order", "as", "in", "code2nt" ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/evidence_codes.py#L166-L171
train
tanghaibao/goatools
goatools/evidence_codes.py
_Init.get_grp2codes
def get_grp2codes(self): """Get dict of group name to namedtuples.""" grp2codes = cx.defaultdict(set) for code, ntd in self.code2nt.items(): grp2codes[ntd.group].add(code) return dict(grp2codes)
python
def get_grp2codes(self): """Get dict of group name to namedtuples.""" grp2codes = cx.defaultdict(set) for code, ntd in self.code2nt.items(): grp2codes[ntd.group].add(code) return dict(grp2codes)
[ "def", "get_grp2codes", "(", "self", ")", ":", "grp2codes", "=", "cx", ".", "defaultdict", "(", "set", ")", "for", "code", ",", "ntd", "in", "self", ".", "code2nt", ".", "items", "(", ")", ":", "grp2codes", "[", "ntd", ".", "group", "]", ".", "add"...
Get dict of group name to namedtuples.
[ "Get", "dict", "of", "group", "name", "to", "namedtuples", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/evidence_codes.py#L173-L178
train
tanghaibao/goatools
goatools/grouper/grprplt.py
GrouperPlot.plot_sections
def plot_sections(self, fout_dir=".", **kws_usr): """Plot groups of GOs which have been placed in sections.""" kws_plt, _ = self._get_kws_plt(None, **kws_usr) PltGroupedGos(self).plot_sections(fout_dir, **kws_plt)
python
def plot_sections(self, fout_dir=".", **kws_usr): """Plot groups of GOs which have been placed in sections.""" kws_plt, _ = self._get_kws_plt(None, **kws_usr) PltGroupedGos(self).plot_sections(fout_dir, **kws_plt)
[ "def", "plot_sections", "(", "self", ",", "fout_dir", "=", "\".\"", ",", "**", "kws_usr", ")", ":", "kws_plt", ",", "_", "=", "self", ".", "_get_kws_plt", "(", "None", ",", "**", "kws_usr", ")", "PltGroupedGos", "(", "self", ")", ".", "plot_sections", ...
Plot groups of GOs which have been placed in sections.
[ "Plot", "groups", "of", "GOs", "which", "have", "been", "placed", "in", "sections", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/grprplt.py#L31-L34
train
tanghaibao/goatools
goatools/grouper/grprplt.py
GrouperPlot.get_pltdotstr
def get_pltdotstr(self, **kws_usr): """Plot one GO header group in Grouper.""" dotstrs = self.get_pltdotstrs(**kws_usr) assert len(dotstrs) == 1 return dotstrs[0]
python
def get_pltdotstr(self, **kws_usr): """Plot one GO header group in Grouper.""" dotstrs = self.get_pltdotstrs(**kws_usr) assert len(dotstrs) == 1 return dotstrs[0]
[ "def", "get_pltdotstr", "(", "self", ",", "**", "kws_usr", ")", ":", "dotstrs", "=", "self", ".", "get_pltdotstrs", "(", "**", "kws_usr", ")", "assert", "len", "(", "dotstrs", ")", "==", "1", "return", "dotstrs", "[", "0", "]" ]
Plot one GO header group in Grouper.
[ "Plot", "one", "GO", "header", "group", "in", "Grouper", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/grprplt.py#L46-L50
train
tanghaibao/goatools
goatools/grouper/grprplt.py
GrouperPlot.plot_groups_unplaced
def plot_groups_unplaced(self, fout_dir=".", **kws_usr): """Plot each GO group.""" # kws: go2color max_gos upper_trigger max_upper plotobj = PltGroupedGos(self) return plotobj.plot_groups_unplaced(fout_dir, **kws_usr)
python
def plot_groups_unplaced(self, fout_dir=".", **kws_usr): """Plot each GO group.""" # kws: go2color max_gos upper_trigger max_upper plotobj = PltGroupedGos(self) return plotobj.plot_groups_unplaced(fout_dir, **kws_usr)
[ "def", "plot_groups_unplaced", "(", "self", ",", "fout_dir", "=", "\".\"", ",", "**", "kws_usr", ")", ":", "plotobj", "=", "PltGroupedGos", "(", "self", ")", "return", "plotobj", ".", "plot_groups_unplaced", "(", "fout_dir", ",", "**", "kws_usr", ")" ]
Plot each GO group.
[ "Plot", "each", "GO", "group", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/grprplt.py#L52-L56
train
tanghaibao/goatools
goatools/grouper/grprplt.py
GrouperPlot._get_kws_plt
def _get_kws_plt(self, usrgos, **kws_usr): """Add go2color and go2bordercolor relevant to this grouping into plot.""" kws_plt = kws_usr.copy() kws_dag = {} hdrgo = kws_plt.get('hdrgo', None) objcolor = GrouperColors(self.grprobj) # GO term colors if 'go2color' not...
python
def _get_kws_plt(self, usrgos, **kws_usr): """Add go2color and go2bordercolor relevant to this grouping into plot.""" kws_plt = kws_usr.copy() kws_dag = {} hdrgo = kws_plt.get('hdrgo', None) objcolor = GrouperColors(self.grprobj) # GO term colors if 'go2color' not...
[ "def", "_get_kws_plt", "(", "self", ",", "usrgos", ",", "**", "kws_usr", ")", ":", "kws_plt", "=", "kws_usr", ".", "copy", "(", ")", "kws_dag", "=", "{", "}", "hdrgo", "=", "kws_plt", ".", "get", "(", "'hdrgo'", ",", "None", ")", "objcolor", "=", "...
Add go2color and go2bordercolor relevant to this grouping into plot.
[ "Add", "go2color", "and", "go2bordercolor", "relevant", "to", "this", "grouping", "into", "plot", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/grprplt.py#L77-L103
train
tanghaibao/goatools
goatools/grouper/grprplt.py
GrouperPlot.get_go2txt
def get_go2txt(grprobj_cur, grp_go2color, grp_go2bordercolor): """Adds section text in all GO terms if not Misc. Adds Misc in terms of interest.""" goids_main = set(o.id for o in grprobj_cur.gosubdag.go2obj.values()) hdrobj = grprobj_cur.hdrobj grprobj_all = Grouper("all", ...
python
def get_go2txt(grprobj_cur, grp_go2color, grp_go2bordercolor): """Adds section text in all GO terms if not Misc. Adds Misc in terms of interest.""" goids_main = set(o.id for o in grprobj_cur.gosubdag.go2obj.values()) hdrobj = grprobj_cur.hdrobj grprobj_all = Grouper("all", ...
[ "def", "get_go2txt", "(", "grprobj_cur", ",", "grp_go2color", ",", "grp_go2bordercolor", ")", ":", "goids_main", "=", "set", "(", "o", ".", "id", "for", "o", "in", "grprobj_cur", ".", "gosubdag", ".", "go2obj", ".", "values", "(", ")", ")", "hdrobj", "="...
Adds section text in all GO terms if not Misc. Adds Misc in terms of interest.
[ "Adds", "section", "text", "in", "all", "GO", "terms", "if", "not", "Misc", ".", "Adds", "Misc", "in", "terms", "of", "interest", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/grprplt.py#L106-L123
train
tanghaibao/goatools
goatools/base.py
download_go_basic_obo
def download_go_basic_obo(obo="go-basic.obo", prt=sys.stdout, loading_bar=True): """Download Ontologies, if necessary.""" if not os.path.isfile(obo): http = "http://purl.obolibrary.org/obo/go" if "slim" in obo: http = "http://www.geneontology.org/ontology/subsets" # http ...
python
def download_go_basic_obo(obo="go-basic.obo", prt=sys.stdout, loading_bar=True): """Download Ontologies, if necessary.""" if not os.path.isfile(obo): http = "http://purl.obolibrary.org/obo/go" if "slim" in obo: http = "http://www.geneontology.org/ontology/subsets" # http ...
[ "def", "download_go_basic_obo", "(", "obo", "=", "\"go-basic.obo\"", ",", "prt", "=", "sys", ".", "stdout", ",", "loading_bar", "=", "True", ")", ":", "if", "not", "os", ".", "path", ".", "isfile", "(", "obo", ")", ":", "http", "=", "\"http://purl.obolib...
Download Ontologies, if necessary.
[ "Download", "Ontologies", "if", "necessary", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/base.py#L113-L125
train
tanghaibao/goatools
goatools/base.py
download_ncbi_associations
def download_ncbi_associations(gene2go="gene2go", prt=sys.stdout, loading_bar=True): """Download associations from NCBI, if necessary""" # Download: ftp://ftp.ncbi.nlm.nih.gov/gene/DATA/gene2go.gz gzip_file = "{GENE2GO}.gz".format(GENE2GO=gene2go) if not os.path.isfile(gene2go): file_remote = "f...
python
def download_ncbi_associations(gene2go="gene2go", prt=sys.stdout, loading_bar=True): """Download associations from NCBI, if necessary""" # Download: ftp://ftp.ncbi.nlm.nih.gov/gene/DATA/gene2go.gz gzip_file = "{GENE2GO}.gz".format(GENE2GO=gene2go) if not os.path.isfile(gene2go): file_remote = "f...
[ "def", "download_ncbi_associations", "(", "gene2go", "=", "\"gene2go\"", ",", "prt", "=", "sys", ".", "stdout", ",", "loading_bar", "=", "True", ")", ":", "gzip_file", "=", "\"{GENE2GO}.gz\"", ".", "format", "(", "GENE2GO", "=", "gene2go", ")", "if", "not", ...
Download associations from NCBI, if necessary
[ "Download", "associations", "from", "NCBI", "if", "necessary" ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/base.py#L127-L138
train
tanghaibao/goatools
goatools/base.py
gunzip
def gunzip(gzip_file, file_gunzip=None): """Unzip .gz file. Return filename of unzipped file.""" if file_gunzip is None: file_gunzip = os.path.splitext(gzip_file)[0] gzip_open_to(gzip_file, file_gunzip) return file_gunzip
python
def gunzip(gzip_file, file_gunzip=None): """Unzip .gz file. Return filename of unzipped file.""" if file_gunzip is None: file_gunzip = os.path.splitext(gzip_file)[0] gzip_open_to(gzip_file, file_gunzip) return file_gunzip
[ "def", "gunzip", "(", "gzip_file", ",", "file_gunzip", "=", "None", ")", ":", "if", "file_gunzip", "is", "None", ":", "file_gunzip", "=", "os", ".", "path", ".", "splitext", "(", "gzip_file", ")", "[", "0", "]", "gzip_open_to", "(", "gzip_file", ",", "...
Unzip .gz file. Return filename of unzipped file.
[ "Unzip", ".", "gz", "file", ".", "Return", "filename", "of", "unzipped", "file", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/base.py#L140-L145
train
tanghaibao/goatools
goatools/base.py
get_godag
def get_godag(fin_obo="go-basic.obo", prt=sys.stdout, loading_bar=True, optional_attrs=None): """Return GODag object. Initialize, if necessary.""" from goatools.obo_parser import GODag download_go_basic_obo(fin_obo, prt, loading_bar) return GODag(fin_obo, optional_attrs, load_obsolete=False, prt=prt)
python
def get_godag(fin_obo="go-basic.obo", prt=sys.stdout, loading_bar=True, optional_attrs=None): """Return GODag object. Initialize, if necessary.""" from goatools.obo_parser import GODag download_go_basic_obo(fin_obo, prt, loading_bar) return GODag(fin_obo, optional_attrs, load_obsolete=False, prt=prt)
[ "def", "get_godag", "(", "fin_obo", "=", "\"go-basic.obo\"", ",", "prt", "=", "sys", ".", "stdout", ",", "loading_bar", "=", "True", ",", "optional_attrs", "=", "None", ")", ":", "from", "goatools", ".", "obo_parser", "import", "GODag", "download_go_basic_obo"...
Return GODag object. Initialize, if necessary.
[ "Return", "GODag", "object", ".", "Initialize", "if", "necessary", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/base.py#L147-L151
train
tanghaibao/goatools
goatools/base.py
dnld_gaf
def dnld_gaf(species_txt, prt=sys.stdout, loading_bar=True): """Download GAF file if necessary.""" return dnld_gafs([species_txt], prt, loading_bar)[0]
python
def dnld_gaf(species_txt, prt=sys.stdout, loading_bar=True): """Download GAF file if necessary.""" return dnld_gafs([species_txt], prt, loading_bar)[0]
[ "def", "dnld_gaf", "(", "species_txt", ",", "prt", "=", "sys", ".", "stdout", ",", "loading_bar", "=", "True", ")", ":", "return", "dnld_gafs", "(", "[", "species_txt", "]", ",", "prt", ",", "loading_bar", ")", "[", "0", "]" ]
Download GAF file if necessary.
[ "Download", "GAF", "file", "if", "necessary", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/base.py#L153-L155
train
tanghaibao/goatools
goatools/base.py
dnld_gafs
def dnld_gafs(species_list, prt=sys.stdout, loading_bar=True): """Download GAF files if necessary.""" # Example GAF files in http://current.geneontology.org/annotations/: # http://current.geneontology.org/annotations/mgi.gaf.gz # http://current.geneontology.org/annotations/fb.gaf.gz # http://...
python
def dnld_gafs(species_list, prt=sys.stdout, loading_bar=True): """Download GAF files if necessary.""" # Example GAF files in http://current.geneontology.org/annotations/: # http://current.geneontology.org/annotations/mgi.gaf.gz # http://current.geneontology.org/annotations/fb.gaf.gz # http://...
[ "def", "dnld_gafs", "(", "species_list", ",", "prt", "=", "sys", ".", "stdout", ",", "loading_bar", "=", "True", ")", ":", "http", "=", "\"http://current.geneontology.org/annotations\"", "fin_gafs", "=", "[", "]", "cwd", "=", "os", ".", "getcwd", "(", ")", ...
Download GAF files if necessary.
[ "Download", "GAF", "files", "if", "necessary", "." ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/base.py#L157-L173
train
tanghaibao/goatools
goatools/base.py
http_get
def http_get(url, fout=None): """Download a file from http. Save it in a file named by fout""" print('requests.get({URL}, stream=True)'.format(URL=url)) rsp = requests.get(url, stream=True) if rsp.status_code == 200 and fout is not None: with open(fout, 'wb') as prt: for chunk in rsp...
python
def http_get(url, fout=None): """Download a file from http. Save it in a file named by fout""" print('requests.get({URL}, stream=True)'.format(URL=url)) rsp = requests.get(url, stream=True) if rsp.status_code == 200 and fout is not None: with open(fout, 'wb') as prt: for chunk in rsp...
[ "def", "http_get", "(", "url", ",", "fout", "=", "None", ")", ":", "print", "(", "'requests.get({URL}, stream=True)'", ".", "format", "(", "URL", "=", "url", ")", ")", "rsp", "=", "requests", ".", "get", "(", "url", ",", "stream", "=", "True", ")", "...
Download a file from http. Save it in a file named by fout
[ "Download", "a", "file", "from", "http", ".", "Save", "it", "in", "a", "file", "named", "by", "fout" ]
407682e573a108864a79031f8ca19ee3bf377626
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/base.py#L175-L187
train