_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 75 19.8k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q223900 | GafData.prt_error_summary | train | 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 | {
"resource": ""
} |
q223901 | GafData._wrlog_details_illegal_gaf | train | 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 | {
"resource": ""
} |
q223902 | CountRelativesInit.get_relationship_dicts | train | 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 | {
"resource": ""
} |
q223903 | CountRelativesInit.get_goone2ntletter | train | 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 | {
"resource": ""
} |
q223904 | GrouperDflts._init_goslims | train | 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 | {
"resource": ""
} |
q223905 | GrouperDflts._get_goslimids_norel | train | 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 | {
"resource": ""
} |
q223906 | GrouperDflts.get_gosubdag | train | 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 | {
"resource": ""
} |
q223907 | AnnoOptions.getfnc_qual_ev | train | 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 | {
"resource": ""
} |
q223908 | GoNodeOpts.get_kws | train | 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 | {
"resource": ""
} |
q223909 | GoNode.get_node | train | 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 | {
"resource": ""
} |
q223910 | GoNode.str_fmthdr | train | 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 | {
"resource": ""
} |
q223911 | GoNode._get_prtflds | train | 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 | {
"resource": ""
} |
q223912 | GoNode._get_hdr_childcnt | train | 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 | {
"resource": ""
} |
q223913 | GoNode._add_parent_cnt | train | 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 | {
"resource": ""
} |
q223914 | IdToGosReader.prt_summary_anno2ev | train | 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 | {
"resource": ""
} |
q223915 | count_terms | train | 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 | {
"resource": ""
} |
q223916 | get_terms | train | 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 | {
"resource": ""
} |
q223917 | _chk_gene2go | train | 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 | {
"resource": ""
} |
q223918 | GrouperInit._init_usrgos | train | 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 | {
"resource": ""
} |
q223919 | GrouperInit.get_gos_all | train | 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 | {
"resource": ""
} |
q223920 | GrouperInit._init_h2us | train | 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 | {
"resource": ""
} |
q223921 | GrouperInit.get_go2nt | train | 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 | {
"resource": ""
} |
q223922 | GrouperInit._init_go2nt_aug | train | 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 | {
"resource": ""
} |
q223923 | GrouperInit._get_go2nthdridx | train | 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 | {
"resource": ""
} |
q223924 | OboToGoDagSmall._init_go2obj | train | 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 | {
"resource": ""
} |
q223925 | OboToGoDagSmall._init | train | 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 | {
"resource": ""
} |
q223926 | WrHierPrt.prt_hier_rec | train | 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 | {
"resource": ""
} |
q223927 | WrHierPrt._init_item_marks | train | 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 | {
"resource": ""
} |
q223928 | OBOReader._add_to_obj | train | 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 | {
"resource": ""
} |
q223929 | OBOReader._init_obo_version | train | 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 | {
"resource": ""
} |
q223930 | OBOReader._init_optional_attrs | train | 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 | {
"resource": ""
} |
q223931 | GOTerm.has_parent | train | 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 | {
"resource": ""
} |
q223932 | GOTerm.has_child | train | 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 | {
"resource": ""
} |
q223933 | GOTerm.get_all_parents | train | 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 | {
"resource": ""
} |
q223934 | GOTerm.get_all_upper | train | 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 | {
"resource": ""
} |
q223935 | GOTerm.get_all_children | train | 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 | {
"resource": ""
} |
q223936 | GOTerm.get_all_lower | train | 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 | {
"resource": ""
} |
q223937 | GOTerm.get_all_parent_edges | train | 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 | {
"resource": ""
} |
q223938 | GOTerm.get_all_child_edges | train | 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 | {
"resource": ""
} |
q223939 | GODag.load_obo_file | train | 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 | {
"resource": ""
} |
q223940 | GODag._str_desc | train | 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 | {
"resource": ""
} |
q223941 | GODag._populate_terms | train | 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 | {
"resource": ""
} |
q223942 | GODag._populate_relationships | train | 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 | {
"resource": ""
} |
q223943 | GODag._set_level_depth | train | 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 | {
"resource": ""
} |
q223944 | GODag.write_dag | train | 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 | {
"resource": ""
} |
q223945 | GODag.query_term | train | 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 | {
"resource": ""
} |
q223946 | GODag.label_wrap | train | 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 | {
"resource": ""
} |
q223947 | GODag.make_graph_pygraphviz | train | 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 | {
"resource": ""
} |
q223948 | GODag.draw_lineage | train | 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 | {
"resource": ""
} |
q223949 | InitAssc._get_ntgpadvals | train | 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 | {
"resource": ""
} |
q223950 | InitAssc._rd_fld_vals | train | 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 | {
"resource": ""
} |
q223951 | InitAssc._get_taxon | train | 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 | {
"resource": ""
} |
q223952 | InitAssc._get_ntgpadnt | train | 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 | {
"resource": ""
} |
q223953 | InitAssc._split_line | train | 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 | {
"resource": ""
} |
q223954 | GpadHdr.chkaddhdr | train | 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 | {
"resource": ""
} |
q223955 | get_dict_w_id2nts | train | 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 | {
"resource": ""
} |
q223956 | get_list_w_id2nts | train | 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 | {
"resource": ""
} |
q223957 | combine_nt_lists | train | 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 | {
"resource": ""
} |
q223958 | wr_py_nts | train | 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 | {
"resource": ""
} |
q223959 | prt_nts | train | 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 | {
"resource": ""
} |
q223960 | get_unique_fields | train | 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 | {
"resource": ""
} |
q223961 | _combine_nt_vals | train | 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 | {
"resource": ""
} |
q223962 | GetGOs.get_go2obj | train | 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 | {
"resource": ""
} |
q223963 | no_duplicates_sections2d | train | 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 | {
"resource": ""
} |
q223964 | EvidenceCodes.get_evcodes | train | 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 | {
"resource": ""
} |
q223965 | EvidenceCodes.get_evcodes_all | train | 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 | {
"resource": ""
} |
q223966 | EvidenceCodes._get_grps_n_codes | train | 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 | {
"resource": ""
} |
q223967 | EvidenceCodes.sort_nts | train | 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 | {
"resource": ""
} |
q223968 | EvidenceCodes.get_grp_name | train | 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 | {
"resource": ""
} |
q223969 | EvidenceCodes.prt_ev_cnts | train | 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 | {
"resource": ""
} |
q223970 | EvidenceCodes.get_order | train | def get_order(self, codes):
"""Return evidence codes in order shown in code2name."""
return sorted(codes, key=lambda e: [self.ev2idx.get(e)]) | python | {
"resource": ""
} |
q223971 | _Init.get_grp2code2nt | train | 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 | {
"resource": ""
} |
q223972 | _Init._init_grps | train | 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 | {
"resource": ""
} |
q223973 | _Init.get_grp2codes | train | 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 | {
"resource": ""
} |
q223974 | GrouperPlot.plot_sections | train | 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 | {
"resource": ""
} |
q223975 | GrouperPlot.get_pltdotstr | train | 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 | {
"resource": ""
} |
q223976 | GrouperPlot.plot_groups_unplaced | train | 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 | {
"resource": ""
} |
q223977 | GrouperPlot._get_kws_plt | train | 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 | {
"resource": ""
} |
q223978 | GrouperPlot.get_go2txt | train | 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 | {
"resource": ""
} |
q223979 | download_go_basic_obo | train | 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 | {
"resource": ""
} |
q223980 | download_ncbi_associations | train | 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 | {
"resource": ""
} |
q223981 | gunzip | train | 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 | {
"resource": ""
} |
q223982 | get_godag | train | 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 | {
"resource": ""
} |
q223983 | dnld_gaf | train | 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 | {
"resource": ""
} |
q223984 | dnld_gafs | train | 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 | {
"resource": ""
} |
q223985 | http_get | train | 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 | {
"resource": ""
} |
q223986 | ftp_get | train | def ftp_get(fin_src, fout):
"""Download a file from an ftp server"""
assert fin_src[:6] == 'ftp://', fin_src
dir_full, fin_ftp = os.path.split(fin_src[6:])
pt0 = dir_full.find('/')
assert pt0 != -1, pt0
ftphost = dir_full[:pt0]
chg_dir = dir_full[pt0+1:]
print('FTP RETR {HOST} {DIR} {SRC... | python | {
"resource": ""
} |
q223987 | dnld_file | train | def dnld_file(src_ftp, dst_file, prt=sys.stdout, loading_bar=True):
"""Download specified file if necessary."""
if os.path.isfile(dst_file):
return
do_gunzip = src_ftp[-3:] == '.gz' and dst_file[-3:] != '.gz'
dst_wget = "{DST}.gz".format(DST=dst_file) if do_gunzip else dst_file
# Write to st... | python | {
"resource": ""
} |
q223988 | OboOptionalAttrs.init_datamembers | train | def init_datamembers(self, rec):
"""Initialize current GOTerm with data members for storing optional attributes."""
# pylint: disable=multiple-statements
if 'synonym' in self.optional_attrs: rec.synonym = []
if 'xref' in self.optional_attrs: rec.xref = set()
if 'subs... | python | {
"resource": ""
} |
q223989 | OboOptionalAttrs._get_synonym | train | def _get_synonym(self, line):
"""Given line, return optional attribute synonym value in a namedtuple.
Example synonym and its storage in a namedtuple:
synonym: "The other white meat" EXACT MARKETING_SLOGAN [MEAT:00324, BACONBASE:03021]
text: "The other white meat"
scope:... | python | {
"resource": ""
} |
q223990 | OboOptionalAttrs._get_xref | train | def _get_xref(self, line):
"""Given line, return optional attribute xref value in a dict of sets."""
# Ex: Wikipedia:Zygotene
# Ex: Reactome:REACT_22295 "Addition of a third mannose to ..."
mtch = self.attr2cmp['xref'].match(line)
return mtch.group(1).replace(' ', '') | python | {
"resource": ""
} |
q223991 | OboOptionalAttrs._init_compile_patterns | train | def _init_compile_patterns(optional_attrs):
"""Compile search patterns for optional attributes if needed."""
attr2cmp = {}
if optional_attrs is None:
return attr2cmp
# "peptidase inhibitor complex" EXACT [GOC:bf, GOC:pr]
# "blood vessel formation from pre-existing blo... | python | {
"resource": ""
} |
q223992 | cli | train | def cli():
"""Command-line script to print a GO term's lower-level hierarchy."""
objcli = WrHierCli(sys.argv[1:])
fouts_txt = objcli.get_fouts()
if fouts_txt:
for fout_txt in fouts_txt:
objcli.wrtxt_hier(fout_txt)
else:
objcli.prt_hier(sys.stdout) | python | {
"resource": ""
} |
q223993 | WrHierCli.get_fouts | train | def get_fouts(self):
"""Get output filename."""
fouts_txt = []
if 'o' in self.kws:
fouts_txt.append(self.kws['o'])
if 'f' in self.kws:
fouts_txt.append(self._get_fout_go())
return fouts_txt | python | {
"resource": ""
} |
q223994 | WrHierCli._get_fout_go | train | def _get_fout_go(self):
"""Get the name of an output file based on the top GO term."""
assert self.goids, "NO VALID GO IDs WERE PROVIDED AS STARTING POINTS FOR HIERARCHY REPORT"
base = next(iter(self.goids)).replace(':', '')
upstr = '_up' if 'up' in self.kws else ''
return "hier_... | python | {
"resource": ""
} |
q223995 | WrHierCli.wrtxt_hier | train | def wrtxt_hier(self, fout_txt):
"""Write hierarchy below specfied GO IDs to an ASCII file."""
with open(fout_txt, 'wb') as prt:
self.prt_hier(prt)
print(" WROTE: {TXT}".format(TXT=fout_txt)) | python | {
"resource": ""
} |
q223996 | WrHierCli.prt_hier | train | def prt_hier(self, prt=sys.stdout):
"""Write hierarchy below specfied GO IDs."""
objwr = WrHierGO(self.gosubdag, **self.kws)
assert self.goids, "NO VALID GO IDs WERE PROVIDED"
if 'up' not in objwr.usrset:
for goid in self.goids:
objwr.prt_hier_down(goid, prt)
... | python | {
"resource": ""
} |
q223997 | WrHierCli._adj_for_assc | train | def _adj_for_assc(self):
"""Print only GO IDs from associations and their ancestors."""
if self.gene2gos:
gos_assoc = set(get_b2aset(self.gene2gos).keys())
if 'item_marks' not in self.kws:
self.kws['item_marks'] = {go:'>' for go in gos_assoc}
if 'inclu... | python | {
"resource": ""
} |
q223998 | PvalCalcBase.calc_pvalue | train | def calc_pvalue(self, study_count, study_n, pop_count, pop_n):
"""pvalues are calculated in derived classes."""
fnc_call = "calc_pvalue({SCNT}, {STOT}, {PCNT} {PTOT})".format(
SCNT=study_count, STOT=study_n, PCNT=pop_count, PTOT=pop_n)
raise Exception("NOT IMPLEMENTED: {FNC_CALL} usi... | python | {
"resource": ""
} |
q223999 | FisherFactory._init_pval_obj | train | def _init_pval_obj(self):
"""Returns a Fisher object based on user-input."""
if self.pval_fnc_name in self.options.keys():
try:
fisher_obj = self.options[self.pval_fnc_name](self.pval_fnc_name, self.log)
except ImportError:
print("fisher module not... | python | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.