id int32 0 252k | repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 |
|---|---|---|---|---|---|---|---|---|---|---|---|
228,300 | ecederstrand/exchangelib | exchangelib/services.py | GetFolder.call | def call(self, folders, additional_fields, shape):
"""
Takes a folder ID and returns the full information for that folder.
:param folders: a list of Folder objects
:param additional_fields: the extra fields that should be returned with the folder, as FieldPath objects
:param sha... | python | def call(self, folders, additional_fields, shape):
"""
Takes a folder ID and returns the full information for that folder.
:param folders: a list of Folder objects
:param additional_fields: the extra fields that should be returned with the folder, as FieldPath objects
:param sha... | [
"def",
"call",
"(",
"self",
",",
"folders",
",",
"additional_fields",
",",
"shape",
")",
":",
"# We can't easily find the correct folder class from the returned XML. Instead, return objects with the same",
"# class as the folder instance it was requested with.",
"from",
".",
"folders... | Takes a folder ID and returns the full information for that folder.
:param folders: a list of Folder objects
:param additional_fields: the extra fields that should be returned with the folder, as FieldPath objects
:param shape: The set of attributes to return
:return: XML elements for t... | [
"Takes",
"a",
"folder",
"ID",
"and",
"returns",
"the",
"full",
"information",
"for",
"that",
"folder",
"."
] | 736347b337c239fcd6d592db5b29e819f753c1ba | https://github.com/ecederstrand/exchangelib/blob/736347b337c239fcd6d592db5b29e819f753c1ba/exchangelib/services.py#L1132-L1172 |
228,301 | ecederstrand/exchangelib | exchangelib/services.py | UploadItems.get_payload | def get_payload(self, items):
"""Upload given items to given account
data is an iterable of tuples where the first element is a Folder
instance representing the ParentFolder that the item will be placed in
and the second element is a Data string returned from an ExportItems
call... | python | def get_payload(self, items):
"""Upload given items to given account
data is an iterable of tuples where the first element is a Folder
instance representing the ParentFolder that the item will be placed in
and the second element is a Data string returned from an ExportItems
call... | [
"def",
"get_payload",
"(",
"self",
",",
"items",
")",
":",
"from",
".",
"properties",
"import",
"ParentFolderId",
"uploaditems",
"=",
"create_element",
"(",
"'m:%s'",
"%",
"self",
".",
"SERVICE_NAME",
")",
"itemselement",
"=",
"create_element",
"(",
"'m:Items'",... | Upload given items to given account
data is an iterable of tuples where the first element is a Folder
instance representing the ParentFolder that the item will be placed in
and the second element is a Data string returned from an ExportItems
call. | [
"Upload",
"given",
"items",
"to",
"given",
"account"
] | 736347b337c239fcd6d592db5b29e819f753c1ba | https://github.com/ecederstrand/exchangelib/blob/736347b337c239fcd6d592db5b29e819f753c1ba/exchangelib/services.py#L1880-L1898 |
228,302 | ecederstrand/exchangelib | exchangelib/folders.py | FolderCollection.find_items | def find_items(self, q, shape=ID_ONLY, depth=SHALLOW, additional_fields=None, order_fields=None,
calendar_view=None, page_size=None, max_items=None, offset=0):
"""
Private method to call the FindItem service
:param q: a Q instance containing any restrictions
:param sh... | python | def find_items(self, q, shape=ID_ONLY, depth=SHALLOW, additional_fields=None, order_fields=None,
calendar_view=None, page_size=None, max_items=None, offset=0):
"""
Private method to call the FindItem service
:param q: a Q instance containing any restrictions
:param sh... | [
"def",
"find_items",
"(",
"self",
",",
"q",
",",
"shape",
"=",
"ID_ONLY",
",",
"depth",
"=",
"SHALLOW",
",",
"additional_fields",
"=",
"None",
",",
"order_fields",
"=",
"None",
",",
"calendar_view",
"=",
"None",
",",
"page_size",
"=",
"None",
",",
"max_i... | Private method to call the FindItem service
:param q: a Q instance containing any restrictions
:param shape: controls whether to return (id, chanegkey) tuples or Item objects. If additional_fields is
non-null, we always return Item objects.
:param depth: controls the whether to r... | [
"Private",
"method",
"to",
"call",
"the",
"FindItem",
"service"
] | 736347b337c239fcd6d592db5b29e819f753c1ba | https://github.com/ecederstrand/exchangelib/blob/736347b337c239fcd6d592db5b29e819f753c1ba/exchangelib/folders.py#L185-L257 |
228,303 | ecederstrand/exchangelib | exchangelib/folders.py | RootOfHierarchy.get_distinguished | def get_distinguished(cls, account):
"""Gets the distinguished folder for this folder class"""
if not cls.DISTINGUISHED_FOLDER_ID:
raise ValueError('Class %s must have a DISTINGUISHED_FOLDER_ID value' % cls)
folders = list(FolderCollection(
account=account,
fo... | python | def get_distinguished(cls, account):
"""Gets the distinguished folder for this folder class"""
if not cls.DISTINGUISHED_FOLDER_ID:
raise ValueError('Class %s must have a DISTINGUISHED_FOLDER_ID value' % cls)
folders = list(FolderCollection(
account=account,
fo... | [
"def",
"get_distinguished",
"(",
"cls",
",",
"account",
")",
":",
"if",
"not",
"cls",
".",
"DISTINGUISHED_FOLDER_ID",
":",
"raise",
"ValueError",
"(",
"'Class %s must have a DISTINGUISHED_FOLDER_ID value'",
"%",
"cls",
")",
"folders",
"=",
"list",
"(",
"FolderCollec... | Gets the distinguished folder for this folder class | [
"Gets",
"the",
"distinguished",
"folder",
"for",
"this",
"folder",
"class"
] | 736347b337c239fcd6d592db5b29e819f753c1ba | https://github.com/ecederstrand/exchangelib/blob/736347b337c239fcd6d592db5b29e819f753c1ba/exchangelib/folders.py#L1489-L1507 |
228,304 | ecederstrand/exchangelib | exchangelib/folders.py | RootOfHierarchy.folder_cls_from_folder_name | def folder_cls_from_folder_name(cls, folder_name, locale):
"""Returns the folder class that matches a localized folder name.
locale is a string, e.g. 'da_DK'
"""
for folder_cls in cls.WELLKNOWN_FOLDERS + NON_DELETEABLE_FOLDERS:
if folder_name.lower() in folder_cls.localized_... | python | def folder_cls_from_folder_name(cls, folder_name, locale):
"""Returns the folder class that matches a localized folder name.
locale is a string, e.g. 'da_DK'
"""
for folder_cls in cls.WELLKNOWN_FOLDERS + NON_DELETEABLE_FOLDERS:
if folder_name.lower() in folder_cls.localized_... | [
"def",
"folder_cls_from_folder_name",
"(",
"cls",
",",
"folder_name",
",",
"locale",
")",
":",
"for",
"folder_cls",
"in",
"cls",
".",
"WELLKNOWN_FOLDERS",
"+",
"NON_DELETEABLE_FOLDERS",
":",
"if",
"folder_name",
".",
"lower",
"(",
")",
"in",
"folder_cls",
".",
... | Returns the folder class that matches a localized folder name.
locale is a string, e.g. 'da_DK' | [
"Returns",
"the",
"folder",
"class",
"that",
"matches",
"a",
"localized",
"folder",
"name",
"."
] | 736347b337c239fcd6d592db5b29e819f753c1ba | https://github.com/ecederstrand/exchangelib/blob/736347b337c239fcd6d592db5b29e819f753c1ba/exchangelib/folders.py#L1594-L1602 |
228,305 | ecederstrand/exchangelib | exchangelib/items.py | RegisterMixIn.register | def register(cls, attr_name, attr_cls):
"""
Register a custom extended property in this item class so they can be accessed just like any other attribute
"""
if not cls.INSERT_AFTER_FIELD:
raise ValueError('Class %s is missing INSERT_AFTER_FIELD value' % cls)
try:
... | python | def register(cls, attr_name, attr_cls):
"""
Register a custom extended property in this item class so they can be accessed just like any other attribute
"""
if not cls.INSERT_AFTER_FIELD:
raise ValueError('Class %s is missing INSERT_AFTER_FIELD value' % cls)
try:
... | [
"def",
"register",
"(",
"cls",
",",
"attr_name",
",",
"attr_cls",
")",
":",
"if",
"not",
"cls",
".",
"INSERT_AFTER_FIELD",
":",
"raise",
"ValueError",
"(",
"'Class %s is missing INSERT_AFTER_FIELD value'",
"%",
"cls",
")",
"try",
":",
"cls",
".",
"get_field_by_f... | Register a custom extended property in this item class so they can be accessed just like any other attribute | [
"Register",
"a",
"custom",
"extended",
"property",
"in",
"this",
"item",
"class",
"so",
"they",
"can",
"be",
"accessed",
"just",
"like",
"any",
"other",
"attribute"
] | 736347b337c239fcd6d592db5b29e819f753c1ba | https://github.com/ecederstrand/exchangelib/blob/736347b337c239fcd6d592db5b29e819f753c1ba/exchangelib/items.py#L92-L113 |
228,306 | ecederstrand/exchangelib | exchangelib/items.py | Item.attach | def attach(self, attachments):
"""Add an attachment, or a list of attachments, to this item. If the item has already been saved, the
attachments will be created on the server immediately. If the item has not yet been saved, the attachments will
be created on the server the item is saved.
... | python | def attach(self, attachments):
"""Add an attachment, or a list of attachments, to this item. If the item has already been saved, the
attachments will be created on the server immediately. If the item has not yet been saved, the attachments will
be created on the server the item is saved.
... | [
"def",
"attach",
"(",
"self",
",",
"attachments",
")",
":",
"if",
"not",
"is_iterable",
"(",
"attachments",
",",
"generators_allowed",
"=",
"True",
")",
":",
"attachments",
"=",
"[",
"attachments",
"]",
"for",
"a",
"in",
"attachments",
":",
"if",
"not",
... | Add an attachment, or a list of attachments, to this item. If the item has already been saved, the
attachments will be created on the server immediately. If the item has not yet been saved, the attachments will
be created on the server the item is saved.
Adding attachments to an existing item w... | [
"Add",
"an",
"attachment",
"or",
"a",
"list",
"of",
"attachments",
"to",
"this",
"item",
".",
"If",
"the",
"item",
"has",
"already",
"been",
"saved",
"the",
"attachments",
"will",
"be",
"created",
"on",
"the",
"server",
"immediately",
".",
"If",
"the",
"... | 736347b337c239fcd6d592db5b29e819f753c1ba | https://github.com/ecederstrand/exchangelib/blob/736347b337c239fcd6d592db5b29e819f753c1ba/exchangelib/items.py#L426-L442 |
228,307 | ecederstrand/exchangelib | exchangelib/items.py | Item.detach | def detach(self, attachments):
"""Remove an attachment, or a list of attachments, from this item. If the item has already been saved, the
attachments will be deleted on the server immediately. If the item has not yet been saved, the attachments will
simply not be created on the server the item i... | python | def detach(self, attachments):
"""Remove an attachment, or a list of attachments, from this item. If the item has already been saved, the
attachments will be deleted on the server immediately. If the item has not yet been saved, the attachments will
simply not be created on the server the item i... | [
"def",
"detach",
"(",
"self",
",",
"attachments",
")",
":",
"if",
"not",
"is_iterable",
"(",
"attachments",
",",
"generators_allowed",
"=",
"True",
")",
":",
"attachments",
"=",
"[",
"attachments",
"]",
"for",
"a",
"in",
"attachments",
":",
"if",
"a",
".... | Remove an attachment, or a list of attachments, from this item. If the item has already been saved, the
attachments will be deleted on the server immediately. If the item has not yet been saved, the attachments will
simply not be created on the server the item is saved.
Removing attachments fro... | [
"Remove",
"an",
"attachment",
"or",
"a",
"list",
"of",
"attachments",
"from",
"this",
"item",
".",
"If",
"the",
"item",
"has",
"already",
"been",
"saved",
"the",
"attachments",
"will",
"be",
"deleted",
"on",
"the",
"server",
"immediately",
".",
"If",
"the"... | 736347b337c239fcd6d592db5b29e819f753c1ba | https://github.com/ecederstrand/exchangelib/blob/736347b337c239fcd6d592db5b29e819f753c1ba/exchangelib/items.py#L444-L460 |
228,308 | ecederstrand/exchangelib | exchangelib/credentials.py | ServiceAccount.back_off_until | def back_off_until(self):
"""Returns the back off value as a datetime. Resets the current back off value if it has expired."""
if self._back_off_until is None:
return None
with self._back_off_lock:
if self._back_off_until is None:
return None
i... | python | def back_off_until(self):
"""Returns the back off value as a datetime. Resets the current back off value if it has expired."""
if self._back_off_until is None:
return None
with self._back_off_lock:
if self._back_off_until is None:
return None
i... | [
"def",
"back_off_until",
"(",
"self",
")",
":",
"if",
"self",
".",
"_back_off_until",
"is",
"None",
":",
"return",
"None",
"with",
"self",
".",
"_back_off_lock",
":",
"if",
"self",
".",
"_back_off_until",
"is",
"None",
":",
"return",
"None",
"if",
"self",
... | Returns the back off value as a datetime. Resets the current back off value if it has expired. | [
"Returns",
"the",
"back",
"off",
"value",
"as",
"a",
"datetime",
".",
"Resets",
"the",
"current",
"back",
"off",
"value",
"if",
"it",
"has",
"expired",
"."
] | 736347b337c239fcd6d592db5b29e819f753c1ba | https://github.com/ecederstrand/exchangelib/blob/736347b337c239fcd6d592db5b29e819f753c1ba/exchangelib/credentials.py#L103-L113 |
228,309 | ecederstrand/exchangelib | exchangelib/winzone.py | generate_map | def generate_map(timeout=10):
""" Helper method to update the map if the CLDR database is updated """
r = requests.get(CLDR_WINZONE_URL, timeout=timeout)
if r.status_code != 200:
raise ValueError('Unexpected response: %s' % r)
tz_map = {}
for e in to_xml(r.content).find('windowsZones').find(... | python | def generate_map(timeout=10):
""" Helper method to update the map if the CLDR database is updated """
r = requests.get(CLDR_WINZONE_URL, timeout=timeout)
if r.status_code != 200:
raise ValueError('Unexpected response: %s' % r)
tz_map = {}
for e in to_xml(r.content).find('windowsZones').find(... | [
"def",
"generate_map",
"(",
"timeout",
"=",
"10",
")",
":",
"r",
"=",
"requests",
".",
"get",
"(",
"CLDR_WINZONE_URL",
",",
"timeout",
"=",
"timeout",
")",
"if",
"r",
".",
"status_code",
"!=",
"200",
":",
"raise",
"ValueError",
"(",
"'Unexpected response: ... | Helper method to update the map if the CLDR database is updated | [
"Helper",
"method",
"to",
"update",
"the",
"map",
"if",
"the",
"CLDR",
"database",
"is",
"updated"
] | 736347b337c239fcd6d592db5b29e819f753c1ba | https://github.com/ecederstrand/exchangelib/blob/736347b337c239fcd6d592db5b29e819f753c1ba/exchangelib/winzone.py#L11-L23 |
228,310 | tanghaibao/goatools | scripts/compare_gos.py | run | def run():
"""Compare two or more sets of GO IDs. Best done using sections."""
obj = CompareGOsCli()
obj.write(obj.kws.get('xlsx'), obj.kws.get('ofile'), obj.kws.get('verbose', False)) | python | def run():
"""Compare two or more sets of GO IDs. Best done using sections."""
obj = CompareGOsCli()
obj.write(obj.kws.get('xlsx'), obj.kws.get('ofile'), obj.kws.get('verbose', False)) | [
"def",
"run",
"(",
")",
":",
"obj",
"=",
"CompareGOsCli",
"(",
")",
"obj",
".",
"write",
"(",
"obj",
".",
"kws",
".",
"get",
"(",
"'xlsx'",
")",
",",
"obj",
".",
"kws",
".",
"get",
"(",
"'ofile'",
")",
",",
"obj",
".",
"kws",
".",
"get",
"(",... | Compare two or more sets of GO IDs. Best done using sections. | [
"Compare",
"two",
"or",
"more",
"sets",
"of",
"GO",
"IDs",
".",
"Best",
"done",
"using",
"sections",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/scripts/compare_gos.py#L10-L13 |
228,311 | tanghaibao/goatools | goatools/grouper/sorter_gos.py | SorterGoIds.sortby | def sortby(self, ntd):
"""Return function for sorting."""
if 'reldepth' in self.grprobj.gosubdag.prt_attr['flds']:
return [ntd.NS, -1*ntd.dcnt, ntd.reldepth]
else:
return [ntd.NS, -1*ntd.dcnt, ntd.depth] | python | def sortby(self, ntd):
"""Return function for sorting."""
if 'reldepth' in self.grprobj.gosubdag.prt_attr['flds']:
return [ntd.NS, -1*ntd.dcnt, ntd.reldepth]
else:
return [ntd.NS, -1*ntd.dcnt, ntd.depth] | [
"def",
"sortby",
"(",
"self",
",",
"ntd",
")",
":",
"if",
"'reldepth'",
"in",
"self",
".",
"grprobj",
".",
"gosubdag",
".",
"prt_attr",
"[",
"'flds'",
"]",
":",
"return",
"[",
"ntd",
".",
"NS",
",",
"-",
"1",
"*",
"ntd",
".",
"dcnt",
",",
"ntd",
... | Return function for sorting. | [
"Return",
"function",
"for",
"sorting",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/sorter_gos.py#L33-L38 |
228,312 | tanghaibao/goatools | goatools/grouper/sorter_gos.py | SorterGoIds.get_nts_sorted | def get_nts_sorted(self, hdrgo_prt, hdrgos, hdrgo_sort):
"""Return a flat list of grouped and sorted GO terms."""
nts_flat = []
self.get_sorted_hdrgo2usrgos(hdrgos, nts_flat, hdrgo_prt, hdrgo_sort)
return nts_flat | python | def get_nts_sorted(self, hdrgo_prt, hdrgos, hdrgo_sort):
"""Return a flat list of grouped and sorted GO terms."""
nts_flat = []
self.get_sorted_hdrgo2usrgos(hdrgos, nts_flat, hdrgo_prt, hdrgo_sort)
return nts_flat | [
"def",
"get_nts_sorted",
"(",
"self",
",",
"hdrgo_prt",
",",
"hdrgos",
",",
"hdrgo_sort",
")",
":",
"nts_flat",
"=",
"[",
"]",
"self",
".",
"get_sorted_hdrgo2usrgos",
"(",
"hdrgos",
",",
"nts_flat",
",",
"hdrgo_prt",
",",
"hdrgo_sort",
")",
"return",
"nts_fl... | Return a flat list of grouped and sorted GO terms. | [
"Return",
"a",
"flat",
"list",
"of",
"grouped",
"and",
"sorted",
"GO",
"terms",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/sorter_gos.py#L64-L68 |
228,313 | tanghaibao/goatools | goatools/grouper/sorter_gos.py | SorterGoIds.get_sorted_hdrgo2usrgos | def get_sorted_hdrgo2usrgos(self, hdrgos, flat_list=None, hdrgo_prt=True, hdrgo_sort=True):
"""Return GO IDs sorting using go2nt's namedtuple."""
# Return user-specfied sort or default sort of header and user GO IDs
sorted_hdrgos_usrgos = []
h2u_get = self.grprobj.hdrgo2usrgos.get
... | python | def get_sorted_hdrgo2usrgos(self, hdrgos, flat_list=None, hdrgo_prt=True, hdrgo_sort=True):
"""Return GO IDs sorting using go2nt's namedtuple."""
# Return user-specfied sort or default sort of header and user GO IDs
sorted_hdrgos_usrgos = []
h2u_get = self.grprobj.hdrgo2usrgos.get
... | [
"def",
"get_sorted_hdrgo2usrgos",
"(",
"self",
",",
"hdrgos",
",",
"flat_list",
"=",
"None",
",",
"hdrgo_prt",
"=",
"True",
",",
"hdrgo_sort",
"=",
"True",
")",
":",
"# Return user-specfied sort or default sort of header and user GO IDs",
"sorted_hdrgos_usrgos",
"=",
"[... | Return GO IDs sorting using go2nt's namedtuple. | [
"Return",
"GO",
"IDs",
"sorting",
"using",
"go2nt",
"s",
"namedtuple",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/sorter_gos.py#L70-L94 |
228,314 | tanghaibao/goatools | goatools/grouper/sorter_gos.py | SorterGoIds._get_go2nt | def _get_go2nt(self, goids):
"""Get go2nt for given goids."""
go2nt_all = self.grprobj.go2nt
return {go:go2nt_all[go] for go in goids} | python | def _get_go2nt(self, goids):
"""Get go2nt for given goids."""
go2nt_all = self.grprobj.go2nt
return {go:go2nt_all[go] for go in goids} | [
"def",
"_get_go2nt",
"(",
"self",
",",
"goids",
")",
":",
"go2nt_all",
"=",
"self",
".",
"grprobj",
".",
"go2nt",
"return",
"{",
"go",
":",
"go2nt_all",
"[",
"go",
"]",
"for",
"go",
"in",
"goids",
"}"
] | Get go2nt for given goids. | [
"Get",
"go2nt",
"for",
"given",
"goids",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/sorter_gos.py#L96-L99 |
228,315 | tanghaibao/goatools | goatools/grouper/sorter_gos.py | SorterGoIds._init_hdrgo_sortby | def _init_hdrgo_sortby(self, hdrgo_sortby, sortby):
"""Initialize header sort function."""
if hdrgo_sortby is not None:
return hdrgo_sortby
if sortby is not None:
return sortby
return self.sortby | python | def _init_hdrgo_sortby(self, hdrgo_sortby, sortby):
"""Initialize header sort function."""
if hdrgo_sortby is not None:
return hdrgo_sortby
if sortby is not None:
return sortby
return self.sortby | [
"def",
"_init_hdrgo_sortby",
"(",
"self",
",",
"hdrgo_sortby",
",",
"sortby",
")",
":",
"if",
"hdrgo_sortby",
"is",
"not",
"None",
":",
"return",
"hdrgo_sortby",
"if",
"sortby",
"is",
"not",
"None",
":",
"return",
"sortby",
"return",
"self",
".",
"sortby"
] | Initialize header sort function. | [
"Initialize",
"header",
"sort",
"function",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/sorter_gos.py#L101-L107 |
228,316 | tanghaibao/goatools | goatools/godag_plot.py | plot_goid2goobj | def plot_goid2goobj(fout_png, goid2goobj, *args, **kws):
"""Given a dict containing GO id and its goobj, create a plot of paths from GO ids."""
engine = kws['engine'] if 'engine' in kws else 'pydot'
godagsmall = OboToGoDagSmall(goid2goobj=goid2goobj).godag
godagplot = GODagSmallPlot(godagsmall, *args, *... | python | def plot_goid2goobj(fout_png, goid2goobj, *args, **kws):
"""Given a dict containing GO id and its goobj, create a plot of paths from GO ids."""
engine = kws['engine'] if 'engine' in kws else 'pydot'
godagsmall = OboToGoDagSmall(goid2goobj=goid2goobj).godag
godagplot = GODagSmallPlot(godagsmall, *args, *... | [
"def",
"plot_goid2goobj",
"(",
"fout_png",
",",
"goid2goobj",
",",
"*",
"args",
",",
"*",
"*",
"kws",
")",
":",
"engine",
"=",
"kws",
"[",
"'engine'",
"]",
"if",
"'engine'",
"in",
"kws",
"else",
"'pydot'",
"godagsmall",
"=",
"OboToGoDagSmall",
"(",
"goid... | Given a dict containing GO id and its goobj, create a plot of paths from GO ids. | [
"Given",
"a",
"dict",
"containing",
"GO",
"id",
"and",
"its",
"goobj",
"create",
"a",
"plot",
"of",
"paths",
"from",
"GO",
"ids",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/godag_plot.py#L19-L24 |
228,317 | tanghaibao/goatools | goatools/godag_plot.py | GODagSmallPlot._init_study_items_max | def _init_study_items_max(self):
"""User can limit the number of genes printed in a GO term."""
if self.study_items is None:
return None
if self.study_items is True:
return None
if isinstance(self.study_items, int):
return self.study_items
retu... | python | def _init_study_items_max(self):
"""User can limit the number of genes printed in a GO term."""
if self.study_items is None:
return None
if self.study_items is True:
return None
if isinstance(self.study_items, int):
return self.study_items
retu... | [
"def",
"_init_study_items_max",
"(",
"self",
")",
":",
"if",
"self",
".",
"study_items",
"is",
"None",
":",
"return",
"None",
"if",
"self",
".",
"study_items",
"is",
"True",
":",
"return",
"None",
"if",
"isinstance",
"(",
"self",
".",
"study_items",
",",
... | User can limit the number of genes printed in a GO term. | [
"User",
"can",
"limit",
"the",
"number",
"of",
"genes",
"printed",
"in",
"a",
"GO",
"term",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/godag_plot.py#L105-L113 |
228,318 | tanghaibao/goatools | goatools/godag_plot.py | GODagSmallPlot._init_go2res | def _init_go2res(**kws):
"""Initialize GOEA results."""
if 'goea_results' in kws:
return {res.GO:res for res in kws['goea_results']}
if 'go2nt' in kws:
return kws['go2nt'] | python | def _init_go2res(**kws):
"""Initialize GOEA results."""
if 'goea_results' in kws:
return {res.GO:res for res in kws['goea_results']}
if 'go2nt' in kws:
return kws['go2nt'] | [
"def",
"_init_go2res",
"(",
"*",
"*",
"kws",
")",
":",
"if",
"'goea_results'",
"in",
"kws",
":",
"return",
"{",
"res",
".",
"GO",
":",
"res",
"for",
"res",
"in",
"kws",
"[",
"'goea_results'",
"]",
"}",
"if",
"'go2nt'",
"in",
"kws",
":",
"return",
"... | Initialize GOEA results. | [
"Initialize",
"GOEA",
"results",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/godag_plot.py#L116-L121 |
228,319 | tanghaibao/goatools | goatools/godag_plot.py | GODagSmallPlot._get_pydot | def _get_pydot(self):
"""Return pydot package. Load pydot, if necessary."""
if self.pydot:
return self.pydot
self.pydot = __import__("pydot")
return self.pydot | python | def _get_pydot(self):
"""Return pydot package. Load pydot, if necessary."""
if self.pydot:
return self.pydot
self.pydot = __import__("pydot")
return self.pydot | [
"def",
"_get_pydot",
"(",
"self",
")",
":",
"if",
"self",
".",
"pydot",
":",
"return",
"self",
".",
"pydot",
"self",
".",
"pydot",
"=",
"__import__",
"(",
"\"pydot\"",
")",
"return",
"self",
".",
"pydot"
] | Return pydot package. Load pydot, if necessary. | [
"Return",
"pydot",
"package",
".",
"Load",
"pydot",
"if",
"necessary",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/godag_plot.py#L217-L222 |
228,320 | tanghaibao/goatools | goatools/wr_tbl.py | wr_xlsx | def wr_xlsx(fout_xlsx, data_xlsx, **kws):
"""Write a spreadsheet into a xlsx file."""
from goatools.wr_tbl_class import WrXlsx
# optional keyword args: fld2col_widths hdrs prt_if sort_by fld2fmt prt_flds
items_str = kws.get("items", "items") if "items" not in kws else kws["items"]
if data_xlsx:
... | python | def wr_xlsx(fout_xlsx, data_xlsx, **kws):
"""Write a spreadsheet into a xlsx file."""
from goatools.wr_tbl_class import WrXlsx
# optional keyword args: fld2col_widths hdrs prt_if sort_by fld2fmt prt_flds
items_str = kws.get("items", "items") if "items" not in kws else kws["items"]
if data_xlsx:
... | [
"def",
"wr_xlsx",
"(",
"fout_xlsx",
",",
"data_xlsx",
",",
"*",
"*",
"kws",
")",
":",
"from",
"goatools",
".",
"wr_tbl_class",
"import",
"WrXlsx",
"# optional keyword args: fld2col_widths hdrs prt_if sort_by fld2fmt prt_flds",
"items_str",
"=",
"kws",
".",
"get",
"(",... | Write a spreadsheet into a xlsx file. | [
"Write",
"a",
"spreadsheet",
"into",
"a",
"xlsx",
"file",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/wr_tbl.py#L63-L84 |
228,321 | tanghaibao/goatools | goatools/wr_tbl.py | wr_xlsx_sections | def wr_xlsx_sections(fout_xlsx, xlsx_data, **kws):
"""Write xlsx file containing section names followed by lines of namedtuple data."""
from goatools.wr_tbl_class import WrXlsx
items_str = "items" if "items" not in kws else kws["items"]
prt_hdr_min = 10
num_items = 0
if xlsx_data:
# Basi... | python | def wr_xlsx_sections(fout_xlsx, xlsx_data, **kws):
"""Write xlsx file containing section names followed by lines of namedtuple data."""
from goatools.wr_tbl_class import WrXlsx
items_str = "items" if "items" not in kws else kws["items"]
prt_hdr_min = 10
num_items = 0
if xlsx_data:
# Basi... | [
"def",
"wr_xlsx_sections",
"(",
"fout_xlsx",
",",
"xlsx_data",
",",
"*",
"*",
"kws",
")",
":",
"from",
"goatools",
".",
"wr_tbl_class",
"import",
"WrXlsx",
"items_str",
"=",
"\"items\"",
"if",
"\"items\"",
"not",
"in",
"kws",
"else",
"kws",
"[",
"\"items\"",... | Write xlsx file containing section names followed by lines of namedtuple data. | [
"Write",
"xlsx",
"file",
"containing",
"section",
"names",
"followed",
"by",
"lines",
"of",
"namedtuple",
"data",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/wr_tbl.py#L86-L117 |
228,322 | tanghaibao/goatools | goatools/wr_tbl.py | wr_tsv | def wr_tsv(fout_tsv, tsv_data, **kws):
"""Write a file of tab-separated table data"""
items_str = "items" if "items" not in kws else kws["items"]
if tsv_data:
ifstrm = sys.stdout if fout_tsv is None else open(fout_tsv, 'w')
num_items = prt_tsv(ifstrm, tsv_data, **kws)
if fout_tsv is ... | python | def wr_tsv(fout_tsv, tsv_data, **kws):
"""Write a file of tab-separated table data"""
items_str = "items" if "items" not in kws else kws["items"]
if tsv_data:
ifstrm = sys.stdout if fout_tsv is None else open(fout_tsv, 'w')
num_items = prt_tsv(ifstrm, tsv_data, **kws)
if fout_tsv is ... | [
"def",
"wr_tsv",
"(",
"fout_tsv",
",",
"tsv_data",
",",
"*",
"*",
"kws",
")",
":",
"items_str",
"=",
"\"items\"",
"if",
"\"items\"",
"not",
"in",
"kws",
"else",
"kws",
"[",
"\"items\"",
"]",
"if",
"tsv_data",
":",
"ifstrm",
"=",
"sys",
".",
"stdout",
... | Write a file of tab-separated table data | [
"Write",
"a",
"file",
"of",
"tab",
"-",
"separated",
"table",
"data"
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/wr_tbl.py#L119-L131 |
228,323 | tanghaibao/goatools | goatools/wr_tbl.py | prt_tsv_sections | def prt_tsv_sections(prt, tsv_data, **kws):
"""Write tsv file containing section names followed by lines of namedtuple data."""
prt_hdr_min = 10 # Print hdr on the 1st section and for any following 'large' sections
num_items = 0
if tsv_data:
# Basic data checks
assert len(tsv_data[0]) =... | python | def prt_tsv_sections(prt, tsv_data, **kws):
"""Write tsv file containing section names followed by lines of namedtuple data."""
prt_hdr_min = 10 # Print hdr on the 1st section and for any following 'large' sections
num_items = 0
if tsv_data:
# Basic data checks
assert len(tsv_data[0]) =... | [
"def",
"prt_tsv_sections",
"(",
"prt",
",",
"tsv_data",
",",
"*",
"*",
"kws",
")",
":",
"prt_hdr_min",
"=",
"10",
"# Print hdr on the 1st section and for any following 'large' sections",
"num_items",
"=",
"0",
"if",
"tsv_data",
":",
"# Basic data checks",
"assert",
"l... | Write tsv file containing section names followed by lines of namedtuple data. | [
"Write",
"tsv",
"file",
"containing",
"section",
"names",
"followed",
"by",
"lines",
"of",
"namedtuple",
"data",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/wr_tbl.py#L133-L155 |
228,324 | tanghaibao/goatools | goatools/wr_tbl.py | prt_tsv | def prt_tsv(prt, data_nts, **kws):
"""Print tab-separated table headers and data"""
# User-controlled printing options
prt_tsv_hdr(prt, data_nts, **kws)
return prt_tsv_dat(prt, data_nts, **kws) | python | def prt_tsv(prt, data_nts, **kws):
"""Print tab-separated table headers and data"""
# User-controlled printing options
prt_tsv_hdr(prt, data_nts, **kws)
return prt_tsv_dat(prt, data_nts, **kws) | [
"def",
"prt_tsv",
"(",
"prt",
",",
"data_nts",
",",
"*",
"*",
"kws",
")",
":",
"# User-controlled printing options",
"prt_tsv_hdr",
"(",
"prt",
",",
"data_nts",
",",
"*",
"*",
"kws",
")",
"return",
"prt_tsv_dat",
"(",
"prt",
",",
"data_nts",
",",
"*",
"*... | Print tab-separated table headers and data | [
"Print",
"tab",
"-",
"separated",
"table",
"headers",
"and",
"data"
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/wr_tbl.py#L157-L161 |
228,325 | tanghaibao/goatools | goatools/wr_tbl.py | prt_tsv_hdr | def prt_tsv_hdr(prt, data_nts, **kws):
"""Print tab-separated table headers"""
sep = "\t" if 'sep' not in kws else kws['sep']
flds_all = data_nts[0]._fields
hdrs = get_hdrs(flds_all, **kws)
prt.write("# {}\n".format(sep.join(hdrs))) | python | def prt_tsv_hdr(prt, data_nts, **kws):
"""Print tab-separated table headers"""
sep = "\t" if 'sep' not in kws else kws['sep']
flds_all = data_nts[0]._fields
hdrs = get_hdrs(flds_all, **kws)
prt.write("# {}\n".format(sep.join(hdrs))) | [
"def",
"prt_tsv_hdr",
"(",
"prt",
",",
"data_nts",
",",
"*",
"*",
"kws",
")",
":",
"sep",
"=",
"\"\\t\"",
"if",
"'sep'",
"not",
"in",
"kws",
"else",
"kws",
"[",
"'sep'",
"]",
"flds_all",
"=",
"data_nts",
"[",
"0",
"]",
".",
"_fields",
"hdrs",
"=",
... | Print tab-separated table headers | [
"Print",
"tab",
"-",
"separated",
"table",
"headers"
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/wr_tbl.py#L163-L168 |
228,326 | tanghaibao/goatools | goatools/wr_tbl.py | prt_tsv_dat | def prt_tsv_dat(prt, data_nts, **kws):
"""Print tab-separated table data"""
sep = "\t" if 'sep' not in kws else kws['sep']
fld2fmt = None if 'fld2fmt' not in kws else kws['fld2fmt']
if 'sort_by' in kws:
data_nts = sorted(data_nts, key=kws['sort_by'])
prt_if = kws['prt_if'] if 'prt_if' in kws... | python | def prt_tsv_dat(prt, data_nts, **kws):
"""Print tab-separated table data"""
sep = "\t" if 'sep' not in kws else kws['sep']
fld2fmt = None if 'fld2fmt' not in kws else kws['fld2fmt']
if 'sort_by' in kws:
data_nts = sorted(data_nts, key=kws['sort_by'])
prt_if = kws['prt_if'] if 'prt_if' in kws... | [
"def",
"prt_tsv_dat",
"(",
"prt",
",",
"data_nts",
",",
"*",
"*",
"kws",
")",
":",
"sep",
"=",
"\"\\t\"",
"if",
"'sep'",
"not",
"in",
"kws",
"else",
"kws",
"[",
"'sep'",
"]",
"fld2fmt",
"=",
"None",
"if",
"'fld2fmt'",
"not",
"in",
"kws",
"else",
"k... | Print tab-separated table data | [
"Print",
"tab",
"-",
"separated",
"table",
"data"
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/wr_tbl.py#L170-L188 |
228,327 | tanghaibao/goatools | goatools/wr_tbl.py | _chk_flds_fmt | def _chk_flds_fmt(nt_fields, prtfmt):
"""Check that all fields in the prtfmt have corresponding data in the namedtuple."""
fmtflds = get_fmtflds(prtfmt)
missing_data = set(fmtflds).difference(set(nt_fields))
# All data needed for print is present, return.
if not missing_data:
return
#rai... | python | def _chk_flds_fmt(nt_fields, prtfmt):
"""Check that all fields in the prtfmt have corresponding data in the namedtuple."""
fmtflds = get_fmtflds(prtfmt)
missing_data = set(fmtflds).difference(set(nt_fields))
# All data needed for print is present, return.
if not missing_data:
return
#rai... | [
"def",
"_chk_flds_fmt",
"(",
"nt_fields",
",",
"prtfmt",
")",
":",
"fmtflds",
"=",
"get_fmtflds",
"(",
"prtfmt",
")",
"missing_data",
"=",
"set",
"(",
"fmtflds",
")",
".",
"difference",
"(",
"set",
"(",
"nt_fields",
")",
")",
"# All data needed for print is pr... | Check that all fields in the prtfmt have corresponding data in the namedtuple. | [
"Check",
"that",
"all",
"fields",
"in",
"the",
"prtfmt",
"have",
"corresponding",
"data",
"in",
"the",
"namedtuple",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/wr_tbl.py#L199-L211 |
228,328 | tanghaibao/goatools | goatools/wr_tbl.py | _prt_txt_hdr | def _prt_txt_hdr(prt, prtfmt):
"""Print header for text report."""
tblhdrs = get_fmtfldsdict(prtfmt)
# If needed, reformat for format_string for header, which has strings, not floats.
hdrfmt = re.sub(r':(\d+)\.\S+}', r':\1}', prtfmt)
hdrfmt = re.sub(r':(0+)(\d+)}', r':\2}', hdrfmt)
prt.write("#{... | python | def _prt_txt_hdr(prt, prtfmt):
"""Print header for text report."""
tblhdrs = get_fmtfldsdict(prtfmt)
# If needed, reformat for format_string for header, which has strings, not floats.
hdrfmt = re.sub(r':(\d+)\.\S+}', r':\1}', prtfmt)
hdrfmt = re.sub(r':(0+)(\d+)}', r':\2}', hdrfmt)
prt.write("#{... | [
"def",
"_prt_txt_hdr",
"(",
"prt",
",",
"prtfmt",
")",
":",
"tblhdrs",
"=",
"get_fmtfldsdict",
"(",
"prtfmt",
")",
"# If needed, reformat for format_string for header, which has strings, not floats.",
"hdrfmt",
"=",
"re",
".",
"sub",
"(",
"r':(\\d+)\\.\\S+}'",
",",
"r':... | Print header for text report. | [
"Print",
"header",
"for",
"text",
"report",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/wr_tbl.py#L223-L229 |
228,329 | tanghaibao/goatools | goatools/wr_tbl.py | mk_fmtfld | def mk_fmtfld(nt_item, joinchr=" ", eol="\n"):
"""Given a namedtuple, return a format_field string."""
fldstrs = []
# Default formats based on fieldname
fld2fmt = {
'hdrgo' : lambda f: "{{{FLD}:1,}}".format(FLD=f),
'dcnt' : lambda f: "{{{FLD}:6,}}".format(FLD=f),
'level' : lambda... | python | def mk_fmtfld(nt_item, joinchr=" ", eol="\n"):
"""Given a namedtuple, return a format_field string."""
fldstrs = []
# Default formats based on fieldname
fld2fmt = {
'hdrgo' : lambda f: "{{{FLD}:1,}}".format(FLD=f),
'dcnt' : lambda f: "{{{FLD}:6,}}".format(FLD=f),
'level' : lambda... | [
"def",
"mk_fmtfld",
"(",
"nt_item",
",",
"joinchr",
"=",
"\" \"",
",",
"eol",
"=",
"\"\\n\"",
")",
":",
"fldstrs",
"=",
"[",
"]",
"# Default formats based on fieldname",
"fld2fmt",
"=",
"{",
"'hdrgo'",
":",
"lambda",
"f",
":",
"\"{{{FLD}:1,}}\"",
".",
"forma... | Given a namedtuple, return a format_field string. | [
"Given",
"a",
"namedtuple",
"return",
"a",
"format_field",
"string",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/wr_tbl.py#L231-L247 |
228,330 | tanghaibao/goatools | goatools/cli/compare_gos.py | CompareGOsCli._get_prtfmt | def _get_prtfmt(self, objgowr, verbose):
"""Get print format containing markers."""
prtfmt = objgowr.get_prtfmt('fmt')
prtfmt = prtfmt.replace('# ', '')
# print('PPPPPPPPPPP', prtfmt)
if not verbose:
prtfmt = prtfmt.replace('{hdr1usr01:2}', '')
prtfmt = pr... | python | def _get_prtfmt(self, objgowr, verbose):
"""Get print format containing markers."""
prtfmt = objgowr.get_prtfmt('fmt')
prtfmt = prtfmt.replace('# ', '')
# print('PPPPPPPPPPP', prtfmt)
if not verbose:
prtfmt = prtfmt.replace('{hdr1usr01:2}', '')
prtfmt = pr... | [
"def",
"_get_prtfmt",
"(",
"self",
",",
"objgowr",
",",
"verbose",
")",
":",
"prtfmt",
"=",
"objgowr",
".",
"get_prtfmt",
"(",
"'fmt'",
")",
"prtfmt",
"=",
"prtfmt",
".",
"replace",
"(",
"'# '",
",",
"''",
")",
"# print('PPPPPPPPPPP', prtfmt)",
"if",
"not"... | Get print format containing markers. | [
"Get",
"print",
"format",
"containing",
"markers",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/cli/compare_gos.py#L113-L126 |
228,331 | tanghaibao/goatools | goatools/cli/compare_gos.py | CompareGOsCli._wr_ver_n_key | def _wr_ver_n_key(self, fout_txt, verbose):
"""Write GO DAG version and key indicating presence of GO ID in a list."""
with open(fout_txt, 'w') as prt:
self._prt_ver_n_key(prt, verbose)
print(' WROTE: {TXT}'.format(TXT=fout_txt)) | python | def _wr_ver_n_key(self, fout_txt, verbose):
"""Write GO DAG version and key indicating presence of GO ID in a list."""
with open(fout_txt, 'w') as prt:
self._prt_ver_n_key(prt, verbose)
print(' WROTE: {TXT}'.format(TXT=fout_txt)) | [
"def",
"_wr_ver_n_key",
"(",
"self",
",",
"fout_txt",
",",
"verbose",
")",
":",
"with",
"open",
"(",
"fout_txt",
",",
"'w'",
")",
"as",
"prt",
":",
"self",
".",
"_prt_ver_n_key",
"(",
"prt",
",",
"verbose",
")",
"print",
"(",
"' WROTE: {TXT}'... | Write GO DAG version and key indicating presence of GO ID in a list. | [
"Write",
"GO",
"DAG",
"version",
"and",
"key",
"indicating",
"presence",
"of",
"GO",
"ID",
"in",
"a",
"list",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/cli/compare_gos.py#L153-L157 |
228,332 | tanghaibao/goatools | goatools/cli/compare_gos.py | CompareGOsCli._prt_ver_n_key | def _prt_ver_n_key(self, prt, verbose):
"""Print GO DAG version and key indicating presence of GO ID in a list."""
pre = '# '
prt.write('# ----------------------------------------------------------------\n')
prt.write('# - Description of GO ID fields\n')
prt.write('# ------------... | python | def _prt_ver_n_key(self, prt, verbose):
"""Print GO DAG version and key indicating presence of GO ID in a list."""
pre = '# '
prt.write('# ----------------------------------------------------------------\n')
prt.write('# - Description of GO ID fields\n')
prt.write('# ------------... | [
"def",
"_prt_ver_n_key",
"(",
"self",
",",
"prt",
",",
"verbose",
")",
":",
"pre",
"=",
"'# '",
"prt",
".",
"write",
"(",
"'# ----------------------------------------------------------------\\n'",
")",
"prt",
".",
"write",
"(",
"'# - Description of GO ID fields\\n'",
... | Print GO DAG version and key indicating presence of GO ID in a list. | [
"Print",
"GO",
"DAG",
"version",
"and",
"key",
"indicating",
"presence",
"of",
"GO",
"ID",
"in",
"a",
"list",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/cli/compare_gos.py#L160-L197 |
228,333 | tanghaibao/goatools | goatools/cli/compare_gos.py | _Init.get_grouped | def get_grouped(self, go_ntsets, go_all, gosubdag, **kws):
"""Get Grouped object."""
kws_grpd = {k:v for k, v in kws.items() if k in Grouped.kws_dict}
kws_grpd['go2nt'] = self._init_go2ntpresent(go_ntsets, go_all, gosubdag)
return Grouped(gosubdag, self.godag.version, **kws_grpd) | python | def get_grouped(self, go_ntsets, go_all, gosubdag, **kws):
"""Get Grouped object."""
kws_grpd = {k:v for k, v in kws.items() if k in Grouped.kws_dict}
kws_grpd['go2nt'] = self._init_go2ntpresent(go_ntsets, go_all, gosubdag)
return Grouped(gosubdag, self.godag.version, **kws_grpd) | [
"def",
"get_grouped",
"(",
"self",
",",
"go_ntsets",
",",
"go_all",
",",
"gosubdag",
",",
"*",
"*",
"kws",
")",
":",
"kws_grpd",
"=",
"{",
"k",
":",
"v",
"for",
"k",
",",
"v",
"in",
"kws",
".",
"items",
"(",
")",
"if",
"k",
"in",
"Grouped",
"."... | Get Grouped object. | [
"Get",
"Grouped",
"object",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/cli/compare_gos.py#L214-L218 |
228,334 | tanghaibao/goatools | goatools/cli/compare_gos.py | _Init._init_go2ntpresent | def _init_go2ntpresent(go_ntsets, go_all, gosubdag):
"""Mark all GO IDs with an X if present in the user GO list."""
go2ntpresent = {}
ntobj = namedtuple('NtPresent', " ".join(nt.hdr for nt in go_ntsets))
# Get present marks for GO sources
for goid_all in go_all:
pres... | python | def _init_go2ntpresent(go_ntsets, go_all, gosubdag):
"""Mark all GO IDs with an X if present in the user GO list."""
go2ntpresent = {}
ntobj = namedtuple('NtPresent', " ".join(nt.hdr for nt in go_ntsets))
# Get present marks for GO sources
for goid_all in go_all:
pres... | [
"def",
"_init_go2ntpresent",
"(",
"go_ntsets",
",",
"go_all",
",",
"gosubdag",
")",
":",
"go2ntpresent",
"=",
"{",
"}",
"ntobj",
"=",
"namedtuple",
"(",
"'NtPresent'",
",",
"\" \"",
".",
"join",
"(",
"nt",
".",
"hdr",
"for",
"nt",
"in",
"go_ntsets",
")",... | Mark all GO IDs with an X if present in the user GO list. | [
"Mark",
"all",
"GO",
"IDs",
"with",
"an",
"X",
"if",
"present",
"in",
"the",
"user",
"GO",
"list",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/cli/compare_gos.py#L221-L236 |
228,335 | tanghaibao/goatools | goatools/cli/compare_gos.py | _Init.get_go_ntsets | def get_go_ntsets(self, go_fins):
"""For each file containing GOs, extract GO IDs, store filename and header."""
nts = []
ntobj = namedtuple('NtGOFiles', 'hdr go_set, go_fin')
go_sets = self._init_go_sets(go_fins)
hdrs = [os.path.splitext(os.path.basename(f))[0] for f in go_fins]... | python | def get_go_ntsets(self, go_fins):
"""For each file containing GOs, extract GO IDs, store filename and header."""
nts = []
ntobj = namedtuple('NtGOFiles', 'hdr go_set, go_fin')
go_sets = self._init_go_sets(go_fins)
hdrs = [os.path.splitext(os.path.basename(f))[0] for f in go_fins]... | [
"def",
"get_go_ntsets",
"(",
"self",
",",
"go_fins",
")",
":",
"nts",
"=",
"[",
"]",
"ntobj",
"=",
"namedtuple",
"(",
"'NtGOFiles'",
",",
"'hdr go_set, go_fin'",
")",
"go_sets",
"=",
"self",
".",
"_init_go_sets",
"(",
"go_fins",
")",
"hdrs",
"=",
"[",
"o... | For each file containing GOs, extract GO IDs, store filename and header. | [
"For",
"each",
"file",
"containing",
"GOs",
"extract",
"GO",
"IDs",
"store",
"filename",
"and",
"header",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/cli/compare_gos.py#L238-L248 |
228,336 | tanghaibao/goatools | goatools/cli/compare_gos.py | _Init._init_go_sets | def _init_go_sets(self, go_fins):
"""Get lists of GO IDs."""
go_sets = []
assert go_fins, "EXPECTED FILES CONTAINING GO IDs"
assert len(go_fins) >= 2, "EXPECTED 2+ GO LISTS. FOUND: {L}".format(
L=' '.join(go_fins))
obj = GetGOs(self.godag)
for fin in go_fins:
... | python | def _init_go_sets(self, go_fins):
"""Get lists of GO IDs."""
go_sets = []
assert go_fins, "EXPECTED FILES CONTAINING GO IDs"
assert len(go_fins) >= 2, "EXPECTED 2+ GO LISTS. FOUND: {L}".format(
L=' '.join(go_fins))
obj = GetGOs(self.godag)
for fin in go_fins:
... | [
"def",
"_init_go_sets",
"(",
"self",
",",
"go_fins",
")",
":",
"go_sets",
"=",
"[",
"]",
"assert",
"go_fins",
",",
"\"EXPECTED FILES CONTAINING GO IDs\"",
"assert",
"len",
"(",
"go_fins",
")",
">=",
"2",
",",
"\"EXPECTED 2+ GO LISTS. FOUND: {L}\"",
".",
"format",
... | Get lists of GO IDs. | [
"Get",
"lists",
"of",
"GO",
"IDs",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/cli/compare_gos.py#L250-L260 |
228,337 | tanghaibao/goatools | goatools/gosubdag/godag_rcnt.py | CountRelatives.get_parents_letters | def get_parents_letters(self, goobj):
"""Get the letters representing all parent terms which are depth-01 GO terms."""
parents_all = set.union(self.go2parents[goobj.id])
parents_all.add(goobj.id)
# print "{}({}) D{:02}".format(goobj.id, goobj.name, goobj.depth), parents_all
paren... | python | def get_parents_letters(self, goobj):
"""Get the letters representing all parent terms which are depth-01 GO terms."""
parents_all = set.union(self.go2parents[goobj.id])
parents_all.add(goobj.id)
# print "{}({}) D{:02}".format(goobj.id, goobj.name, goobj.depth), parents_all
paren... | [
"def",
"get_parents_letters",
"(",
"self",
",",
"goobj",
")",
":",
"parents_all",
"=",
"set",
".",
"union",
"(",
"self",
".",
"go2parents",
"[",
"goobj",
".",
"id",
"]",
")",
"parents_all",
".",
"add",
"(",
"goobj",
".",
"id",
")",
"# print \"{}({}) D{:0... | Get the letters representing all parent terms which are depth-01 GO terms. | [
"Get",
"the",
"letters",
"representing",
"all",
"parent",
"terms",
"which",
"are",
"depth",
"-",
"01",
"GO",
"terms",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/gosubdag/godag_rcnt.py#L28-L34 |
228,338 | tanghaibao/goatools | goatools/gosubdag/godag_rcnt.py | CountRelatives.get_d1str | def get_d1str(self, goobj, reverse=False):
"""Get D1-string representing all parent terms which are depth-01 GO terms."""
return "".join(sorted(self.get_parents_letters(goobj), reverse=reverse)) | python | def get_d1str(self, goobj, reverse=False):
"""Get D1-string representing all parent terms which are depth-01 GO terms."""
return "".join(sorted(self.get_parents_letters(goobj), reverse=reverse)) | [
"def",
"get_d1str",
"(",
"self",
",",
"goobj",
",",
"reverse",
"=",
"False",
")",
":",
"return",
"\"\"",
".",
"join",
"(",
"sorted",
"(",
"self",
".",
"get_parents_letters",
"(",
"goobj",
")",
",",
"reverse",
"=",
"reverse",
")",
")"
] | Get D1-string representing all parent terms which are depth-01 GO terms. | [
"Get",
"D1",
"-",
"string",
"representing",
"all",
"parent",
"terms",
"which",
"are",
"depth",
"-",
"01",
"GO",
"terms",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/gosubdag/godag_rcnt.py#L36-L38 |
228,339 | tanghaibao/goatools | goatools/gosubdag/go_most_specific.py | get_most_specific_dcnt | def get_most_specific_dcnt(goids, go2nt):
"""Get the GO ID with the lowest descendants count."""
# go2nt_usr = {go:go2nt[go] for go in goids}
# return min(go2nt_usr.items(), key=lambda t: t[1].dcnt)[0]
return min(_get_go2nt(goids, go2nt), key=lambda t: t[1].dcnt)[0] | python | def get_most_specific_dcnt(goids, go2nt):
"""Get the GO ID with the lowest descendants count."""
# go2nt_usr = {go:go2nt[go] for go in goids}
# return min(go2nt_usr.items(), key=lambda t: t[1].dcnt)[0]
return min(_get_go2nt(goids, go2nt), key=lambda t: t[1].dcnt)[0] | [
"def",
"get_most_specific_dcnt",
"(",
"goids",
",",
"go2nt",
")",
":",
"# go2nt_usr = {go:go2nt[go] for go in goids}",
"# return min(go2nt_usr.items(), key=lambda t: t[1].dcnt)[0]",
"return",
"min",
"(",
"_get_go2nt",
"(",
"goids",
",",
"go2nt",
")",
",",
"key",
"=",
"lam... | Get the GO ID with the lowest descendants count. | [
"Get",
"the",
"GO",
"ID",
"with",
"the",
"lowest",
"descendants",
"count",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/gosubdag/go_most_specific.py#L7-L11 |
228,340 | tanghaibao/goatools | goatools/gosubdag/go_most_specific.py | _get_go2nt | def _get_go2nt(goids, go2nt_all):
"""Get user go2nt using main GO IDs, not alt IDs."""
go_nt_list = []
goids_seen = set()
for goid_usr in goids:
ntgo = go2nt_all[goid_usr]
goid_main = ntgo.id
if goid_main not in goids_seen:
goids_seen.add(goid_main)
go_nt_... | python | def _get_go2nt(goids, go2nt_all):
"""Get user go2nt using main GO IDs, not alt IDs."""
go_nt_list = []
goids_seen = set()
for goid_usr in goids:
ntgo = go2nt_all[goid_usr]
goid_main = ntgo.id
if goid_main not in goids_seen:
goids_seen.add(goid_main)
go_nt_... | [
"def",
"_get_go2nt",
"(",
"goids",
",",
"go2nt_all",
")",
":",
"go_nt_list",
"=",
"[",
"]",
"goids_seen",
"=",
"set",
"(",
")",
"for",
"goid_usr",
"in",
"goids",
":",
"ntgo",
"=",
"go2nt_all",
"[",
"goid_usr",
"]",
"goid_main",
"=",
"ntgo",
".",
"id",
... | Get user go2nt using main GO IDs, not alt IDs. | [
"Get",
"user",
"go2nt",
"using",
"main",
"GO",
"IDs",
"not",
"alt",
"IDs",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/gosubdag/go_most_specific.py#L25-L35 |
228,341 | tanghaibao/goatools | goatools/grouper/aart_geneproducts_one.py | AArtGeneProductSetsOne.prt_gos_grouped | def prt_gos_grouped(self, prt, **kws_grp):
"""Print grouped GO list."""
prtfmt = self.datobj.kws['fmtgo']
wrobj = WrXlsxSortedGos(self.name, self.sortobj)
# Keyword arguments: control content: hdrgo_prt section_prt top_n use_sections
desc2nts = self.sortobj.get_desc2nts(**kws_grp... | python | def prt_gos_grouped(self, prt, **kws_grp):
"""Print grouped GO list."""
prtfmt = self.datobj.kws['fmtgo']
wrobj = WrXlsxSortedGos(self.name, self.sortobj)
# Keyword arguments: control content: hdrgo_prt section_prt top_n use_sections
desc2nts = self.sortobj.get_desc2nts(**kws_grp... | [
"def",
"prt_gos_grouped",
"(",
"self",
",",
"prt",
",",
"*",
"*",
"kws_grp",
")",
":",
"prtfmt",
"=",
"self",
".",
"datobj",
".",
"kws",
"[",
"'fmtgo'",
"]",
"wrobj",
"=",
"WrXlsxSortedGos",
"(",
"self",
".",
"name",
",",
"self",
".",
"sortobj",
")",... | Print grouped GO list. | [
"Print",
"grouped",
"GO",
"list",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/aart_geneproducts_one.py#L74-L80 |
228,342 | tanghaibao/goatools | goatools/grouper/aart_geneproducts_one.py | AArtGeneProductSetsOne.prt_gos_flat | def prt_gos_flat(self, prt):
"""Print flat GO list."""
prtfmt = self.datobj.kws['fmtgo']
_go2nt = self.sortobj.grprobj.go2nt
go2nt = {go:_go2nt[go] for go in self.go2nt}
prt.write("\n{N} GO IDs:\n".format(N=len(go2nt)))
_sortby = self._get_sortgo()
for ntgo in sor... | python | def prt_gos_flat(self, prt):
"""Print flat GO list."""
prtfmt = self.datobj.kws['fmtgo']
_go2nt = self.sortobj.grprobj.go2nt
go2nt = {go:_go2nt[go] for go in self.go2nt}
prt.write("\n{N} GO IDs:\n".format(N=len(go2nt)))
_sortby = self._get_sortgo()
for ntgo in sor... | [
"def",
"prt_gos_flat",
"(",
"self",
",",
"prt",
")",
":",
"prtfmt",
"=",
"self",
".",
"datobj",
".",
"kws",
"[",
"'fmtgo'",
"]",
"_go2nt",
"=",
"self",
".",
"sortobj",
".",
"grprobj",
".",
"go2nt",
"go2nt",
"=",
"{",
"go",
":",
"_go2nt",
"[",
"go",... | Print flat GO list. | [
"Print",
"flat",
"GO",
"list",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/aart_geneproducts_one.py#L82-L90 |
228,343 | tanghaibao/goatools | goatools/grouper/aart_geneproducts_one.py | AArtGeneProductSetsOne._get_sortgo | def _get_sortgo(self):
"""Get function for sorting GO terms in a list of namedtuples."""
if 'sortgo' in self.datobj.kws:
return self.datobj.kws['sortgo']
return self.datobj.grprdflt.gosubdag.prt_attr['sort'] + "\n" | python | def _get_sortgo(self):
"""Get function for sorting GO terms in a list of namedtuples."""
if 'sortgo' in self.datobj.kws:
return self.datobj.kws['sortgo']
return self.datobj.grprdflt.gosubdag.prt_attr['sort'] + "\n" | [
"def",
"_get_sortgo",
"(",
"self",
")",
":",
"if",
"'sortgo'",
"in",
"self",
".",
"datobj",
".",
"kws",
":",
"return",
"self",
".",
"datobj",
".",
"kws",
"[",
"'sortgo'",
"]",
"return",
"self",
".",
"datobj",
".",
"grprdflt",
".",
"gosubdag",
".",
"p... | Get function for sorting GO terms in a list of namedtuples. | [
"Get",
"function",
"for",
"sorting",
"GO",
"terms",
"in",
"a",
"list",
"of",
"namedtuples",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/aart_geneproducts_one.py#L93-L97 |
228,344 | tanghaibao/goatools | goatools/grouper/aart_geneproducts_one.py | AArtGeneProductSetsOne.get_gene2binvec | def get_gene2binvec(self):
"""Return a boolean vector for each gene representing GO section membership."""
_sec2chr = self.sec2chr
return {g:[s in s2gos for s in _sec2chr] for g, s2gos in self.gene2section2gos.items()} | python | def get_gene2binvec(self):
"""Return a boolean vector for each gene representing GO section membership."""
_sec2chr = self.sec2chr
return {g:[s in s2gos for s in _sec2chr] for g, s2gos in self.gene2section2gos.items()} | [
"def",
"get_gene2binvec",
"(",
"self",
")",
":",
"_sec2chr",
"=",
"self",
".",
"sec2chr",
"return",
"{",
"g",
":",
"[",
"s",
"in",
"s2gos",
"for",
"s",
"in",
"_sec2chr",
"]",
"for",
"g",
",",
"s2gos",
"in",
"self",
".",
"gene2section2gos",
".",
"item... | Return a boolean vector for each gene representing GO section membership. | [
"Return",
"a",
"boolean",
"vector",
"for",
"each",
"gene",
"representing",
"GO",
"section",
"membership",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/aart_geneproducts_one.py#L140-L143 |
228,345 | tanghaibao/goatools | goatools/grouper/aart_geneproducts_one.py | _Init.get_go2nt | def get_go2nt(self, goea_results):
"""Return go2nt with added formatted string versions of the P-values."""
go2obj = self.objaartall.grprdflt.gosubdag.go2obj
# Add string version of P-values
goea_nts = MgrNtGOEAs(goea_results).get_nts_strpval()
return {go2obj[nt.GO].id:nt for nt ... | python | def get_go2nt(self, goea_results):
"""Return go2nt with added formatted string versions of the P-values."""
go2obj = self.objaartall.grprdflt.gosubdag.go2obj
# Add string version of P-values
goea_nts = MgrNtGOEAs(goea_results).get_nts_strpval()
return {go2obj[nt.GO].id:nt for nt ... | [
"def",
"get_go2nt",
"(",
"self",
",",
"goea_results",
")",
":",
"go2obj",
"=",
"self",
".",
"objaartall",
".",
"grprdflt",
".",
"gosubdag",
".",
"go2obj",
"# Add string version of P-values",
"goea_nts",
"=",
"MgrNtGOEAs",
"(",
"goea_results",
")",
".",
"get_nts_... | Return go2nt with added formatted string versions of the P-values. | [
"Return",
"go2nt",
"with",
"added",
"formatted",
"string",
"versions",
"of",
"the",
"P",
"-",
"values",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/aart_geneproducts_one.py#L151-L156 |
228,346 | tanghaibao/goatools | goatools/grouper/aart_geneproducts_one.py | _Init.get_sec2gos | def get_sec2gos(sortobj):
"""Initialize section_name2goids."""
sec_gos = []
for section_name, nts in sortobj.get_desc2nts_fnc(hdrgo_prt=True)['sections']:
sec_gos.append((section_name, set(nt.GO for nt in nts)))
return cx.OrderedDict(sec_gos) | python | def get_sec2gos(sortobj):
"""Initialize section_name2goids."""
sec_gos = []
for section_name, nts in sortobj.get_desc2nts_fnc(hdrgo_prt=True)['sections']:
sec_gos.append((section_name, set(nt.GO for nt in nts)))
return cx.OrderedDict(sec_gos) | [
"def",
"get_sec2gos",
"(",
"sortobj",
")",
":",
"sec_gos",
"=",
"[",
"]",
"for",
"section_name",
",",
"nts",
"in",
"sortobj",
".",
"get_desc2nts_fnc",
"(",
"hdrgo_prt",
"=",
"True",
")",
"[",
"'sections'",
"]",
":",
"sec_gos",
".",
"append",
"(",
"(",
... | Initialize section_name2goids. | [
"Initialize",
"section_name2goids",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/aart_geneproducts_one.py#L159-L164 |
228,347 | tanghaibao/goatools | goatools/grouper/aart_geneproducts_one.py | _Init.get_gene2gos | def get_gene2gos(go2nt):
"""Create a gene product to GO set dict."""
gene2gos = cx.defaultdict(set)
nt0 = next(iter(go2nt.values()))
b_str = isinstance(nt0.study_items, str)
# print("NNNNTTTT", nt0)
for goid, ntgo in go2nt.items():
study_items = ntgo.study_ite... | python | def get_gene2gos(go2nt):
"""Create a gene product to GO set dict."""
gene2gos = cx.defaultdict(set)
nt0 = next(iter(go2nt.values()))
b_str = isinstance(nt0.study_items, str)
# print("NNNNTTTT", nt0)
for goid, ntgo in go2nt.items():
study_items = ntgo.study_ite... | [
"def",
"get_gene2gos",
"(",
"go2nt",
")",
":",
"gene2gos",
"=",
"cx",
".",
"defaultdict",
"(",
"set",
")",
"nt0",
"=",
"next",
"(",
"iter",
"(",
"go2nt",
".",
"values",
"(",
")",
")",
")",
"b_str",
"=",
"isinstance",
"(",
"nt0",
".",
"study_items",
... | Create a gene product to GO set dict. | [
"Create",
"a",
"gene",
"product",
"to",
"GO",
"set",
"dict",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/aart_geneproducts_one.py#L167-L181 |
228,348 | tanghaibao/goatools | goatools/grouper/aart_geneproducts_one.py | _Init.get_gene2aart | def get_gene2aart(gene2section2gos, sec2chr):
"""Return a string for each gene representing GO section membership."""
geneid2str = {}
for geneid, section2gos_gene in gene2section2gos.items():
letters = [abc if s in section2gos_gene else "." for s, abc in sec2chr.items()]
... | python | def get_gene2aart(gene2section2gos, sec2chr):
"""Return a string for each gene representing GO section membership."""
geneid2str = {}
for geneid, section2gos_gene in gene2section2gos.items():
letters = [abc if s in section2gos_gene else "." for s, abc in sec2chr.items()]
... | [
"def",
"get_gene2aart",
"(",
"gene2section2gos",
",",
"sec2chr",
")",
":",
"geneid2str",
"=",
"{",
"}",
"for",
"geneid",
",",
"section2gos_gene",
"in",
"gene2section2gos",
".",
"items",
"(",
")",
":",
"letters",
"=",
"[",
"abc",
"if",
"s",
"in",
"section2g... | Return a string for each gene representing GO section membership. | [
"Return",
"a",
"string",
"for",
"each",
"gene",
"representing",
"GO",
"section",
"membership",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/aart_geneproducts_one.py#L192-L198 |
228,349 | tanghaibao/goatools | goatools/grouper/aart_geneproducts_one.py | _Init.get_gene2section2gos | def get_gene2section2gos(gene2gos, sec2gos):
"""Get a list of section aliases for each gene product ID."""
gene2section2gos = {}
for geneid, gos_gene in gene2gos.items():
section2gos = {}
for section_name, gos_sec in sec2gos.items():
gos_secgene = gos_gene... | python | def get_gene2section2gos(gene2gos, sec2gos):
"""Get a list of section aliases for each gene product ID."""
gene2section2gos = {}
for geneid, gos_gene in gene2gos.items():
section2gos = {}
for section_name, gos_sec in sec2gos.items():
gos_secgene = gos_gene... | [
"def",
"get_gene2section2gos",
"(",
"gene2gos",
",",
"sec2gos",
")",
":",
"gene2section2gos",
"=",
"{",
"}",
"for",
"geneid",
",",
"gos_gene",
"in",
"gene2gos",
".",
"items",
"(",
")",
":",
"section2gos",
"=",
"{",
"}",
"for",
"section_name",
",",
"gos_sec... | Get a list of section aliases for each gene product ID. | [
"Get",
"a",
"list",
"of",
"section",
"aliases",
"for",
"each",
"gene",
"product",
"ID",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/aart_geneproducts_one.py#L201-L211 |
228,350 | tanghaibao/goatools | goatools/gosubdag/plot/gosubdag_plot.py | GoSubDagPlot._init_objcolor | def _init_objcolor(self, node_opts, **kwu):
"""Return user-created Go2Color object or create one."""
objgoea = node_opts.kws['dict'].get('objgoea', None)
# kwu: go2color go2bordercolor dflt_bordercolor key2col
return Go2Color(self.gosubdag, objgoea, **kwu) | python | def _init_objcolor(self, node_opts, **kwu):
"""Return user-created Go2Color object or create one."""
objgoea = node_opts.kws['dict'].get('objgoea', None)
# kwu: go2color go2bordercolor dflt_bordercolor key2col
return Go2Color(self.gosubdag, objgoea, **kwu) | [
"def",
"_init_objcolor",
"(",
"self",
",",
"node_opts",
",",
"*",
"*",
"kwu",
")",
":",
"objgoea",
"=",
"node_opts",
".",
"kws",
"[",
"'dict'",
"]",
".",
"get",
"(",
"'objgoea'",
",",
"None",
")",
"# kwu: go2color go2bordercolor dflt_bordercolor key2col",
"ret... | Return user-created Go2Color object or create one. | [
"Return",
"user",
"-",
"created",
"Go2Color",
"object",
"or",
"create",
"one",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/gosubdag/plot/gosubdag_plot.py#L104-L108 |
228,351 | tanghaibao/goatools | goatools/gosubdag/plot/gosubdag_plot.py | GoSubDagPlot._init_gonodeopts | def _init_gonodeopts(self, **kws_usr):
"""Initialize a GO Node plot options object, GoNodeOpts."""
options = GoNodeOpts(self.gosubdag, **self.kws['node_go'])
# Add parent edge count if either is in kws: parentcnt, prt_pcnt
if not options.kws['set'].isdisjoint(['parentcnt', 'prt_pcnt']):
... | python | def _init_gonodeopts(self, **kws_usr):
"""Initialize a GO Node plot options object, GoNodeOpts."""
options = GoNodeOpts(self.gosubdag, **self.kws['node_go'])
# Add parent edge count if either is in kws: parentcnt, prt_pcnt
if not options.kws['set'].isdisjoint(['parentcnt', 'prt_pcnt']):
... | [
"def",
"_init_gonodeopts",
"(",
"self",
",",
"*",
"*",
"kws_usr",
")",
":",
"options",
"=",
"GoNodeOpts",
"(",
"self",
".",
"gosubdag",
",",
"*",
"*",
"self",
".",
"kws",
"[",
"'node_go'",
"]",
")",
"# Add parent edge count if either is in kws: parentcnt, prt_pc... | Initialize a GO Node plot options object, GoNodeOpts. | [
"Initialize",
"a",
"GO",
"Node",
"plot",
"options",
"object",
"GoNodeOpts",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/gosubdag/plot/gosubdag_plot.py#L110-L120 |
228,352 | tanghaibao/goatools | goatools/gosubdag/plot/gosubdag_plot.py | GoSubDagPlot.prt_goids | def prt_goids(self, prt):
"""Print all GO IDs in the plot, plus their color."""
fmt = self.gosubdag.prt_attr['fmta']
nts = sorted(self.gosubdag.go2nt.values(), key=lambda nt: [nt.NS, nt.depth, nt.alt])
_get_color = self.pydotnodego.go2color.get
for ntgo in nts:
gostr ... | python | def prt_goids(self, prt):
"""Print all GO IDs in the plot, plus their color."""
fmt = self.gosubdag.prt_attr['fmta']
nts = sorted(self.gosubdag.go2nt.values(), key=lambda nt: [nt.NS, nt.depth, nt.alt])
_get_color = self.pydotnodego.go2color.get
for ntgo in nts:
gostr ... | [
"def",
"prt_goids",
"(",
"self",
",",
"prt",
")",
":",
"fmt",
"=",
"self",
".",
"gosubdag",
".",
"prt_attr",
"[",
"'fmta'",
"]",
"nts",
"=",
"sorted",
"(",
"self",
".",
"gosubdag",
".",
"go2nt",
".",
"values",
"(",
")",
",",
"key",
"=",
"lambda",
... | Print all GO IDs in the plot, plus their color. | [
"Print",
"all",
"GO",
"IDs",
"in",
"the",
"plot",
"plus",
"their",
"color",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/gosubdag/plot/gosubdag_plot.py#L122-L130 |
228,353 | tanghaibao/goatools | goatools/gosubdag/plot/gosubdag_plot.py | GoSubDagPlot._init_kws | def _init_kws(self, **kws_usr):
"""Return a dict containing user-specified plotting options."""
kws_self = {}
user_keys = set(kws_usr)
for objname, expset in self.exp_keys.items():
usrkeys_curr = user_keys.intersection(expset)
kws_self[objname] = get_kwargs(kws_us... | python | def _init_kws(self, **kws_usr):
"""Return a dict containing user-specified plotting options."""
kws_self = {}
user_keys = set(kws_usr)
for objname, expset in self.exp_keys.items():
usrkeys_curr = user_keys.intersection(expset)
kws_self[objname] = get_kwargs(kws_us... | [
"def",
"_init_kws",
"(",
"self",
",",
"*",
"*",
"kws_usr",
")",
":",
"kws_self",
"=",
"{",
"}",
"user_keys",
"=",
"set",
"(",
"kws_usr",
")",
"for",
"objname",
",",
"expset",
"in",
"self",
".",
"exp_keys",
".",
"items",
"(",
")",
":",
"usrkeys_curr",... | Return a dict containing user-specified plotting options. | [
"Return",
"a",
"dict",
"containing",
"user",
"-",
"specified",
"plotting",
"options",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/gosubdag/plot/gosubdag_plot.py#L132-L141 |
228,354 | tanghaibao/goatools | goatools/gosubdag/plot/gosubdag_plot.py | GoSubDagPlot._prt_edge | def _prt_edge(dag_edge, attr):
"""Print edge attribute"""
# sequence parent_graph points attributes type parent_edge_list
print("Edge {ATTR}: {VAL}".format(ATTR=attr, VAL=dag_edge.obj_dict[attr])) | python | def _prt_edge(dag_edge, attr):
"""Print edge attribute"""
# sequence parent_graph points attributes type parent_edge_list
print("Edge {ATTR}: {VAL}".format(ATTR=attr, VAL=dag_edge.obj_dict[attr])) | [
"def",
"_prt_edge",
"(",
"dag_edge",
",",
"attr",
")",
":",
"# sequence parent_graph points attributes type parent_edge_list",
"print",
"(",
"\"Edge {ATTR}: {VAL}\"",
".",
"format",
"(",
"ATTR",
"=",
"attr",
",",
"VAL",
"=",
"dag_edge",
".",
"obj_dict",
"[",
"attr",... | Print edge attribute | [
"Print",
"edge",
"attribute"
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/gosubdag/plot/gosubdag_plot.py#L205-L208 |
228,355 | tanghaibao/goatools | goatools/gosubdag/gosubdag.py | GoSubDag.prt_goids | def prt_goids(self, goids=None, prtfmt=None, sortby=True, prt=sys.stdout):
"""Given GO IDs, print decriptive info about each GO Term."""
if goids is None:
goids = self.go_sources
nts = self.get_nts(goids, sortby)
if prtfmt is None:
prtfmt = self.prt_attr['fmta']
... | python | def prt_goids(self, goids=None, prtfmt=None, sortby=True, prt=sys.stdout):
"""Given GO IDs, print decriptive info about each GO Term."""
if goids is None:
goids = self.go_sources
nts = self.get_nts(goids, sortby)
if prtfmt is None:
prtfmt = self.prt_attr['fmta']
... | [
"def",
"prt_goids",
"(",
"self",
",",
"goids",
"=",
"None",
",",
"prtfmt",
"=",
"None",
",",
"sortby",
"=",
"True",
",",
"prt",
"=",
"sys",
".",
"stdout",
")",
":",
"if",
"goids",
"is",
"None",
":",
"goids",
"=",
"self",
".",
"go_sources",
"nts",
... | Given GO IDs, print decriptive info about each GO Term. | [
"Given",
"GO",
"IDs",
"print",
"decriptive",
"info",
"about",
"each",
"GO",
"Term",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/gosubdag/gosubdag.py#L42-L52 |
228,356 | tanghaibao/goatools | goatools/gosubdag/gosubdag.py | GoSubDag.get_nts | def get_nts(self, goids=None, sortby=None):
"""Given GO IDs, get a list of namedtuples."""
nts = []
# User GO IDs
if goids is None:
goids = self.go_sources
else:
chk_goids(goids, "GoSubDag::get_nts")
if goids:
ntobj = cx.namedtuple("NtG... | python | def get_nts(self, goids=None, sortby=None):
"""Given GO IDs, get a list of namedtuples."""
nts = []
# User GO IDs
if goids is None:
goids = self.go_sources
else:
chk_goids(goids, "GoSubDag::get_nts")
if goids:
ntobj = cx.namedtuple("NtG... | [
"def",
"get_nts",
"(",
"self",
",",
"goids",
"=",
"None",
",",
"sortby",
"=",
"None",
")",
":",
"nts",
"=",
"[",
"]",
"# User GO IDs",
"if",
"goids",
"is",
"None",
":",
"goids",
"=",
"self",
".",
"go_sources",
"else",
":",
"chk_goids",
"(",
"goids",
... | Given GO IDs, get a list of namedtuples. | [
"Given",
"GO",
"IDs",
"get",
"a",
"list",
"of",
"namedtuples",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/gosubdag/gosubdag.py#L54-L73 |
228,357 | tanghaibao/goatools | goatools/gosubdag/gosubdag.py | GoSubDag.get_go2nt | def get_go2nt(self, goids):
"""Return dict of GO ID as key and GO object information in namedtuple."""
get_nt = self.go2nt
goids_present = set(goids).intersection(self.go2obj)
if len(goids_present) != len(goids):
print("GO IDs NOT FOUND IN DAG: {GOs}".format(
... | python | def get_go2nt(self, goids):
"""Return dict of GO ID as key and GO object information in namedtuple."""
get_nt = self.go2nt
goids_present = set(goids).intersection(self.go2obj)
if len(goids_present) != len(goids):
print("GO IDs NOT FOUND IN DAG: {GOs}".format(
... | [
"def",
"get_go2nt",
"(",
"self",
",",
"goids",
")",
":",
"get_nt",
"=",
"self",
".",
"go2nt",
"goids_present",
"=",
"set",
"(",
"goids",
")",
".",
"intersection",
"(",
"self",
".",
"go2obj",
")",
"if",
"len",
"(",
"goids_present",
")",
"!=",
"len",
"... | Return dict of GO ID as key and GO object information in namedtuple. | [
"Return",
"dict",
"of",
"GO",
"ID",
"as",
"key",
"and",
"GO",
"object",
"information",
"in",
"namedtuple",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/gosubdag/gosubdag.py#L94-L101 |
228,358 | tanghaibao/goatools | goatools/gosubdag/gosubdag.py | GoSubDag.get_key_goids | def get_key_goids(self, goids):
"""Given GO IDs, return key GO IDs."""
go2obj = self.go2obj
return set(go2obj[go].id for go in goids) | python | def get_key_goids(self, goids):
"""Given GO IDs, return key GO IDs."""
go2obj = self.go2obj
return set(go2obj[go].id for go in goids) | [
"def",
"get_key_goids",
"(",
"self",
",",
"goids",
")",
":",
"go2obj",
"=",
"self",
".",
"go2obj",
"return",
"set",
"(",
"go2obj",
"[",
"go",
"]",
".",
"id",
"for",
"go",
"in",
"goids",
")"
] | Given GO IDs, return key GO IDs. | [
"Given",
"GO",
"IDs",
"return",
"key",
"GO",
"IDs",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/gosubdag/gosubdag.py#L115-L118 |
228,359 | tanghaibao/goatools | goatools/gosubdag/gosubdag.py | GoSubDag.prt_objdesc | def prt_objdesc(self, prt):
"""Return description of this GoSubDag object."""
txt = "INITIALIZING GoSubDag: {N:3} sources in {M:3} GOs rcnt({R}). {A} alt GO IDs\n"
alt2obj = {go:o for go, o in self.go2obj.items() if go != o.id}
prt.write(txt.format(
N=len(self.go_sources),
... | python | def prt_objdesc(self, prt):
"""Return description of this GoSubDag object."""
txt = "INITIALIZING GoSubDag: {N:3} sources in {M:3} GOs rcnt({R}). {A} alt GO IDs\n"
alt2obj = {go:o for go, o in self.go2obj.items() if go != o.id}
prt.write(txt.format(
N=len(self.go_sources),
... | [
"def",
"prt_objdesc",
"(",
"self",
",",
"prt",
")",
":",
"txt",
"=",
"\"INITIALIZING GoSubDag: {N:3} sources in {M:3} GOs rcnt({R}). {A} alt GO IDs\\n\"",
"alt2obj",
"=",
"{",
"go",
":",
"o",
"for",
"go",
",",
"o",
"in",
"self",
".",
"go2obj",
".",
"items",
"(",... | Return description of this GoSubDag object. | [
"Return",
"description",
"of",
"this",
"GoSubDag",
"object",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/gosubdag/gosubdag.py#L128-L139 |
228,360 | tanghaibao/goatools | goatools/anno/init/reader_genetogo.py | InitAssc._init_taxids | def _init_taxids(taxid, taxids):
"""Return taxid set"""
ret = set()
if taxids is not None:
if taxids is True:
return True
if isinstance(taxids, int):
ret.add(taxids)
else:
ret.update(taxids)
if taxid is n... | python | def _init_taxids(taxid, taxids):
"""Return taxid set"""
ret = set()
if taxids is not None:
if taxids is True:
return True
if isinstance(taxids, int):
ret.add(taxids)
else:
ret.update(taxids)
if taxid is n... | [
"def",
"_init_taxids",
"(",
"taxid",
",",
"taxids",
")",
":",
"ret",
"=",
"set",
"(",
")",
"if",
"taxids",
"is",
"not",
"None",
":",
"if",
"taxids",
"is",
"True",
":",
"return",
"True",
"if",
"isinstance",
"(",
"taxids",
",",
"int",
")",
":",
"ret"... | Return taxid set | [
"Return",
"taxid",
"set"
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/anno/init/reader_genetogo.py#L34-L50 |
228,361 | tanghaibao/goatools | goatools/anno/init/reader_genetogo.py | InitAssc.init_associations | def init_associations(self, fin_anno, taxids=None):
"""Read annotation file. Store annotation data in a list of namedtuples."""
nts = []
if fin_anno is None:
return nts
tic = timeit.default_timer()
lnum = -1
line = "\t"*len(self.flds)
try:
... | python | def init_associations(self, fin_anno, taxids=None):
"""Read annotation file. Store annotation data in a list of namedtuples."""
nts = []
if fin_anno is None:
return nts
tic = timeit.default_timer()
lnum = -1
line = "\t"*len(self.flds)
try:
... | [
"def",
"init_associations",
"(",
"self",
",",
"fin_anno",
",",
"taxids",
"=",
"None",
")",
":",
"nts",
"=",
"[",
"]",
"if",
"fin_anno",
"is",
"None",
":",
"return",
"nts",
"tic",
"=",
"timeit",
".",
"default_timer",
"(",
")",
"lnum",
"=",
"-",
"1",
... | Read annotation file. Store annotation data in a list of namedtuples. | [
"Read",
"annotation",
"file",
".",
"Store",
"annotation",
"data",
"in",
"a",
"list",
"of",
"namedtuples",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/anno/init/reader_genetogo.py#L53-L100 |
228,362 | tanghaibao/goatools | goatools/anno/init/reader_genetogo.py | InitAssc._prt_line_detail | def _prt_line_detail(self, prt, line, lnum=""):
"""Print each field and its value."""
data = zip(self.flds, line.split('\t'))
txt = ["{:2}) {:13} {}".format(i, hdr, val) for i, (hdr, val) in enumerate(data)]
prt.write("{LNUM}\n{TXT}\n".format(LNUM=lnum, TXT='\n'.join(txt))) | python | def _prt_line_detail(self, prt, line, lnum=""):
"""Print each field and its value."""
data = zip(self.flds, line.split('\t'))
txt = ["{:2}) {:13} {}".format(i, hdr, val) for i, (hdr, val) in enumerate(data)]
prt.write("{LNUM}\n{TXT}\n".format(LNUM=lnum, TXT='\n'.join(txt))) | [
"def",
"_prt_line_detail",
"(",
"self",
",",
"prt",
",",
"line",
",",
"lnum",
"=",
"\"\"",
")",
":",
"data",
"=",
"zip",
"(",
"self",
".",
"flds",
",",
"line",
".",
"split",
"(",
"'\\t'",
")",
")",
"txt",
"=",
"[",
"\"{:2}) {:13} {}\"",
".",
"forma... | Print each field and its value. | [
"Print",
"each",
"field",
"and",
"its",
"value",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/anno/init/reader_genetogo.py#L114-L118 |
228,363 | tanghaibao/goatools | goatools/anno/gaf_reader.py | GafReader.chk_associations | def chk_associations(self, fout_err="gaf.err"):
"""Check that fields are legal in GAF"""
obj = GafData("2.1")
return obj.chk(self.associations, fout_err) | python | def chk_associations(self, fout_err="gaf.err"):
"""Check that fields are legal in GAF"""
obj = GafData("2.1")
return obj.chk(self.associations, fout_err) | [
"def",
"chk_associations",
"(",
"self",
",",
"fout_err",
"=",
"\"gaf.err\"",
")",
":",
"obj",
"=",
"GafData",
"(",
"\"2.1\"",
")",
"return",
"obj",
".",
"chk",
"(",
"self",
".",
"associations",
",",
"fout_err",
")"
] | Check that fields are legal in GAF | [
"Check",
"that",
"fields",
"are",
"legal",
"in",
"GAF"
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/anno/gaf_reader.py#L33-L36 |
228,364 | tanghaibao/goatools | goatools/cli/gosubdag_plot.py | GetGOs._update_ret | def _update_ret(ret, goids, go2color):
"""Update 'GOs' and 'go2color' in dict with goids and go2color."""
if goids:
ret['GOs'].update(goids)
if go2color:
for goid, color in go2color.items():
ret['go2color'][goid] = color | python | def _update_ret(ret, goids, go2color):
"""Update 'GOs' and 'go2color' in dict with goids and go2color."""
if goids:
ret['GOs'].update(goids)
if go2color:
for goid, color in go2color.items():
ret['go2color'][goid] = color | [
"def",
"_update_ret",
"(",
"ret",
",",
"goids",
",",
"go2color",
")",
":",
"if",
"goids",
":",
"ret",
"[",
"'GOs'",
"]",
".",
"update",
"(",
"goids",
")",
"if",
"go2color",
":",
"for",
"goid",
",",
"color",
"in",
"go2color",
".",
"items",
"(",
")",... | Update 'GOs' and 'go2color' in dict with goids and go2color. | [
"Update",
"GOs",
"and",
"go2color",
"in",
"dict",
"with",
"goids",
"and",
"go2color",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/cli/gosubdag_plot.py#L160-L166 |
228,365 | tanghaibao/goatools | goatools/cli/gosubdag_plot.py | PlotCli._plt_gogrouped | def _plt_gogrouped(self, goids, go2color_usr, **kws):
"""Plot grouped GO IDs."""
fout_img = self.get_outfile(kws['outfile'], goids)
sections = read_sections(kws['sections'], exclude_ungrouped=True)
# print ("KWWSSSSSSSS", kws)
# kws_plt = {k:v for k, v in kws.items if k in self.k... | python | def _plt_gogrouped(self, goids, go2color_usr, **kws):
"""Plot grouped GO IDs."""
fout_img = self.get_outfile(kws['outfile'], goids)
sections = read_sections(kws['sections'], exclude_ungrouped=True)
# print ("KWWSSSSSSSS", kws)
# kws_plt = {k:v for k, v in kws.items if k in self.k... | [
"def",
"_plt_gogrouped",
"(",
"self",
",",
"goids",
",",
"go2color_usr",
",",
"*",
"*",
"kws",
")",
":",
"fout_img",
"=",
"self",
".",
"get_outfile",
"(",
"kws",
"[",
"'outfile'",
"]",
",",
"goids",
")",
"sections",
"=",
"read_sections",
"(",
"kws",
"[... | Plot grouped GO IDs. | [
"Plot",
"grouped",
"GO",
"IDs",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/cli/gosubdag_plot.py#L205-L227 |
228,366 | tanghaibao/goatools | goatools/cli/gosubdag_plot.py | PlotCli._get_grprobj | def _get_grprobj(self, goids, sections):
"""Get Grouper, given GO IDs and sections."""
grprdflt = GrouperDflts(self.gosubdag, "goslim_generic.obo")
hdrobj = HdrgosSections(self.gosubdag, grprdflt.hdrgos_dflt, sections)
return Grouper("sections", goids, hdrobj, self.gosubdag) | python | def _get_grprobj(self, goids, sections):
"""Get Grouper, given GO IDs and sections."""
grprdflt = GrouperDflts(self.gosubdag, "goslim_generic.obo")
hdrobj = HdrgosSections(self.gosubdag, grprdflt.hdrgos_dflt, sections)
return Grouper("sections", goids, hdrobj, self.gosubdag) | [
"def",
"_get_grprobj",
"(",
"self",
",",
"goids",
",",
"sections",
")",
":",
"grprdflt",
"=",
"GrouperDflts",
"(",
"self",
".",
"gosubdag",
",",
"\"goslim_generic.obo\"",
")",
"hdrobj",
"=",
"HdrgosSections",
"(",
"self",
".",
"gosubdag",
",",
"grprdflt",
".... | Get Grouper, given GO IDs and sections. | [
"Get",
"Grouper",
"given",
"GO",
"IDs",
"and",
"sections",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/cli/gosubdag_plot.py#L229-L233 |
228,367 | tanghaibao/goatools | goatools/cli/gosubdag_plot.py | PlotCli._get_kwsdag | def _get_kwsdag(self, goids, go2obj, **kws_all):
"""Get keyword args for a GoSubDag."""
kws_dag = {}
# Term Counts for GO Term information score
tcntobj = self._get_tcntobj(goids, go2obj, **kws_all) # TermCounts or None
if tcntobj is not None:
kws_dag['tcntobj'] = tc... | python | def _get_kwsdag(self, goids, go2obj, **kws_all):
"""Get keyword args for a GoSubDag."""
kws_dag = {}
# Term Counts for GO Term information score
tcntobj = self._get_tcntobj(goids, go2obj, **kws_all) # TermCounts or None
if tcntobj is not None:
kws_dag['tcntobj'] = tc... | [
"def",
"_get_kwsdag",
"(",
"self",
",",
"goids",
",",
"go2obj",
",",
"*",
"*",
"kws_all",
")",
":",
"kws_dag",
"=",
"{",
"}",
"# Term Counts for GO Term information score",
"tcntobj",
"=",
"self",
".",
"_get_tcntobj",
"(",
"goids",
",",
"go2obj",
",",
"*",
... | Get keyword args for a GoSubDag. | [
"Get",
"keyword",
"args",
"for",
"a",
"GoSubDag",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/cli/gosubdag_plot.py#L244-L258 |
228,368 | tanghaibao/goatools | goatools/cli/gosubdag_plot.py | PlotCli._chk_docopts | def _chk_docopts(self, kws):
"""Check for common user command-line errors."""
# outfile should contain .png, .png, etc.
outfile = kws['outfile']
if len(kws) == 2 and os.path.basename(kws['obo']) == "go-basic.obo" and \
kws['outfile'] == self.dflt_outfile:
self._er... | python | def _chk_docopts(self, kws):
"""Check for common user command-line errors."""
# outfile should contain .png, .png, etc.
outfile = kws['outfile']
if len(kws) == 2 and os.path.basename(kws['obo']) == "go-basic.obo" and \
kws['outfile'] == self.dflt_outfile:
self._er... | [
"def",
"_chk_docopts",
"(",
"self",
",",
"kws",
")",
":",
"# outfile should contain .png, .png, etc.",
"outfile",
"=",
"kws",
"[",
"'outfile'",
"]",
"if",
"len",
"(",
"kws",
")",
"==",
"2",
"and",
"os",
".",
"path",
".",
"basename",
"(",
"kws",
"[",
"'ob... | Check for common user command-line errors. | [
"Check",
"for",
"common",
"user",
"command",
"-",
"line",
"errors",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/cli/gosubdag_plot.py#L277-L290 |
228,369 | tanghaibao/goatools | goatools/cli/gosubdag_plot.py | PlotCli._err | def _err(self, msg, err=True):
"""Print useage and error before exiting."""
severity = "FATAL" if err else "NOTE"
txt = "".join([self.objdoc.doc,
"User's command-line:\n\n",
" % go_plot.py {ARGS}\n\n".format(ARGS=" ".join(sys.argv[1:])),
... | python | def _err(self, msg, err=True):
"""Print useage and error before exiting."""
severity = "FATAL" if err else "NOTE"
txt = "".join([self.objdoc.doc,
"User's command-line:\n\n",
" % go_plot.py {ARGS}\n\n".format(ARGS=" ".join(sys.argv[1:])),
... | [
"def",
"_err",
"(",
"self",
",",
"msg",
",",
"err",
"=",
"True",
")",
":",
"severity",
"=",
"\"FATAL\"",
"if",
"err",
"else",
"\"NOTE\"",
"txt",
"=",
"\"\"",
".",
"join",
"(",
"[",
"self",
".",
"objdoc",
".",
"doc",
",",
"\"User's command-line:\\n\\n\"... | Print useage and error before exiting. | [
"Print",
"useage",
"and",
"error",
"before",
"exiting",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/cli/gosubdag_plot.py#L292-L302 |
228,370 | tanghaibao/goatools | goatools/cli/gosubdag_plot.py | PlotCli.get_outfile | def get_outfile(self, outfile, goids=None):
"""Return output file for GO Term plot."""
# 1. Use the user-specfied output filename for the GO Term plot
if outfile != self.dflt_outfile:
return outfile
# 2. If only plotting 1 GO term, use GO is in plot name
if goids is n... | python | def get_outfile(self, outfile, goids=None):
"""Return output file for GO Term plot."""
# 1. Use the user-specfied output filename for the GO Term plot
if outfile != self.dflt_outfile:
return outfile
# 2. If only plotting 1 GO term, use GO is in plot name
if goids is n... | [
"def",
"get_outfile",
"(",
"self",
",",
"outfile",
",",
"goids",
"=",
"None",
")",
":",
"# 1. Use the user-specfied output filename for the GO Term plot",
"if",
"outfile",
"!=",
"self",
".",
"dflt_outfile",
":",
"return",
"outfile",
"# 2. If only plotting 1 GO term, use G... | Return output file for GO Term plot. | [
"Return",
"output",
"file",
"for",
"GO",
"Term",
"plot",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/cli/gosubdag_plot.py#L304-L316 |
228,371 | tanghaibao/goatools | goatools/cli/gosubdag_plot.py | PlotCli._get_optional_attrs | def _get_optional_attrs(kws):
"""Given keyword args, return optional_attributes to be loaded into the GODag."""
vals = OboOptionalAttrs.attributes.intersection(kws.keys())
if 'sections' in kws:
vals.add('relationship')
if 'norel' in kws:
vals.discard('relationship... | python | def _get_optional_attrs(kws):
"""Given keyword args, return optional_attributes to be loaded into the GODag."""
vals = OboOptionalAttrs.attributes.intersection(kws.keys())
if 'sections' in kws:
vals.add('relationship')
if 'norel' in kws:
vals.discard('relationship... | [
"def",
"_get_optional_attrs",
"(",
"kws",
")",
":",
"vals",
"=",
"OboOptionalAttrs",
".",
"attributes",
".",
"intersection",
"(",
"kws",
".",
"keys",
"(",
")",
")",
"if",
"'sections'",
"in",
"kws",
":",
"vals",
".",
"add",
"(",
"'relationship'",
")",
"if... | Given keyword args, return optional_attributes to be loaded into the GODag. | [
"Given",
"keyword",
"args",
"return",
"optional_attributes",
"to",
"be",
"loaded",
"into",
"the",
"GODag",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/cli/gosubdag_plot.py#L319-L326 |
228,372 | tanghaibao/goatools | goatools/cli/wr_sections.py | WrSectionsCli._read_sections | def _read_sections(ifile):
"""Read sections_in.txt file, if it exists."""
if os.path.exists(ifile):
return read_sections(ifile, exclude_ungrouped=True, prt=None) | python | def _read_sections(ifile):
"""Read sections_in.txt file, if it exists."""
if os.path.exists(ifile):
return read_sections(ifile, exclude_ungrouped=True, prt=None) | [
"def",
"_read_sections",
"(",
"ifile",
")",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"ifile",
")",
":",
"return",
"read_sections",
"(",
"ifile",
",",
"exclude_ungrouped",
"=",
"True",
",",
"prt",
"=",
"None",
")"
] | Read sections_in.txt file, if it exists. | [
"Read",
"sections_in",
".",
"txt",
"file",
"if",
"it",
"exists",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/cli/wr_sections.py#L96-L99 |
228,373 | tanghaibao/goatools | goatools/gosubdag/go_paths.py | GoPaths.get_paths_from_to | def get_paths_from_to(self, goobj_start, goid_end=None, dn0_up1=True):
"""Get a list of paths from goobj_start to either top or goid_end."""
paths = []
# Queue of terms to be examined (and storage for their paths)
working_q = cx.deque([[goobj_start]])
# Loop thru GO terms until w... | python | def get_paths_from_to(self, goobj_start, goid_end=None, dn0_up1=True):
"""Get a list of paths from goobj_start to either top or goid_end."""
paths = []
# Queue of terms to be examined (and storage for their paths)
working_q = cx.deque([[goobj_start]])
# Loop thru GO terms until w... | [
"def",
"get_paths_from_to",
"(",
"self",
",",
"goobj_start",
",",
"goid_end",
"=",
"None",
",",
"dn0_up1",
"=",
"True",
")",
":",
"paths",
"=",
"[",
"]",
"# Queue of terms to be examined (and storage for their paths)",
"working_q",
"=",
"cx",
".",
"deque",
"(",
... | Get a list of paths from goobj_start to either top or goid_end. | [
"Get",
"a",
"list",
"of",
"paths",
"from",
"goobj_start",
"to",
"either",
"top",
"or",
"goid_end",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/gosubdag/go_paths.py#L19-L45 |
228,374 | tanghaibao/goatools | goatools/gosubdag/go_paths.py | GoPaths.prt_paths | def prt_paths(paths, prt=sys.stdout):
"""Print list of paths."""
pat = "PATHES: {GO} L{L:02} D{D:02}\n"
for path in paths:
for go_obj in path:
prt.write(pat.format(GO=go_obj.id, L=go_obj.level, D=go_obj.depth))
prt.write("\n") | python | def prt_paths(paths, prt=sys.stdout):
"""Print list of paths."""
pat = "PATHES: {GO} L{L:02} D{D:02}\n"
for path in paths:
for go_obj in path:
prt.write(pat.format(GO=go_obj.id, L=go_obj.level, D=go_obj.depth))
prt.write("\n") | [
"def",
"prt_paths",
"(",
"paths",
",",
"prt",
"=",
"sys",
".",
"stdout",
")",
":",
"pat",
"=",
"\"PATHES: {GO} L{L:02} D{D:02}\\n\"",
"for",
"path",
"in",
"paths",
":",
"for",
"go_obj",
"in",
"path",
":",
"prt",
".",
"write",
"(",
"pat",
".",
"format",
... | Print list of paths. | [
"Print",
"list",
"of",
"paths",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/gosubdag/go_paths.py#L48-L54 |
228,375 | tanghaibao/goatools | goatools/godag/relationship_str.py | RelationshipStr.prt_keys | def prt_keys(self, prt, pre):
"""Print the alias for a relationship and its alias."""
prt.write('{PRE}Relationship to parent: {ABC}\n'.format(
PRE=pre, ABC=''.join(self.rel2chr.values())))
for rel, alias in self.rel2chr.items():
prt.write('{PRE} {A} {DESC}\n'.format(PR... | python | def prt_keys(self, prt, pre):
"""Print the alias for a relationship and its alias."""
prt.write('{PRE}Relationship to parent: {ABC}\n'.format(
PRE=pre, ABC=''.join(self.rel2chr.values())))
for rel, alias in self.rel2chr.items():
prt.write('{PRE} {A} {DESC}\n'.format(PR... | [
"def",
"prt_keys",
"(",
"self",
",",
"prt",
",",
"pre",
")",
":",
"prt",
".",
"write",
"(",
"'{PRE}Relationship to parent: {ABC}\\n'",
".",
"format",
"(",
"PRE",
"=",
"pre",
",",
"ABC",
"=",
"''",
".",
"join",
"(",
"self",
".",
"rel2chr",
".",
"values"... | Print the alias for a relationship and its alias. | [
"Print",
"the",
"alias",
"for",
"a",
"relationship",
"and",
"its",
"alias",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/godag/relationship_str.py#L79-L88 |
228,376 | tanghaibao/goatools | goatools/anno/annoreader_base.py | AnnoReaderBase._get_id2gos | def _get_id2gos(self, associations, **kws):
"""Return given associations in a dict, id2gos"""
options = AnnoOptions(self.evobj, **kws)
# Default reduction is to remove. For all options, see goatools/anno/opts.py:
# * Evidence_Code == ND -> No biological data No biological Data availabl... | python | def _get_id2gos(self, associations, **kws):
"""Return given associations in a dict, id2gos"""
options = AnnoOptions(self.evobj, **kws)
# Default reduction is to remove. For all options, see goatools/anno/opts.py:
# * Evidence_Code == ND -> No biological data No biological Data availabl... | [
"def",
"_get_id2gos",
"(",
"self",
",",
"associations",
",",
"*",
"*",
"kws",
")",
":",
"options",
"=",
"AnnoOptions",
"(",
"self",
".",
"evobj",
",",
"*",
"*",
"kws",
")",
"# Default reduction is to remove. For all options, see goatools/anno/opts.py:",
"# * Evide... | Return given associations in a dict, id2gos | [
"Return",
"given",
"associations",
"in",
"a",
"dict",
"id2gos"
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/anno/annoreader_base.py#L83-L90 |
228,377 | tanghaibao/goatools | goatools/anno/annoreader_base.py | AnnoReaderBase.get_date_yyyymmdd | def get_date_yyyymmdd(yyyymmdd):
"""Return datetime.date given string."""
return date(int(yyyymmdd[:4]), int(yyyymmdd[4:6], base=10), int(yyyymmdd[6:], base=10)) | python | def get_date_yyyymmdd(yyyymmdd):
"""Return datetime.date given string."""
return date(int(yyyymmdd[:4]), int(yyyymmdd[4:6], base=10), int(yyyymmdd[6:], base=10)) | [
"def",
"get_date_yyyymmdd",
"(",
"yyyymmdd",
")",
":",
"return",
"date",
"(",
"int",
"(",
"yyyymmdd",
"[",
":",
"4",
"]",
")",
",",
"int",
"(",
"yyyymmdd",
"[",
"4",
":",
"6",
"]",
",",
"base",
"=",
"10",
")",
",",
"int",
"(",
"yyyymmdd",
"[",
... | Return datetime.date given string. | [
"Return",
"datetime",
".",
"date",
"given",
"string",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/anno/annoreader_base.py#L139-L141 |
228,378 | tanghaibao/goatools | goatools/anno/annoreader_base.py | AnnoReaderBase.hms | def hms(self, msg, tic=None, prt=sys.stdout):
"""Print elapsed time and message."""
if tic is None:
tic = self.tic
now = timeit.default_timer()
hms = str(datetime.timedelta(seconds=(now-tic)))
prt.write('{HMS}: {MSG}\n'.format(HMS=hms, MSG=msg))
return now | python | def hms(self, msg, tic=None, prt=sys.stdout):
"""Print elapsed time and message."""
if tic is None:
tic = self.tic
now = timeit.default_timer()
hms = str(datetime.timedelta(seconds=(now-tic)))
prt.write('{HMS}: {MSG}\n'.format(HMS=hms, MSG=msg))
return now | [
"def",
"hms",
"(",
"self",
",",
"msg",
",",
"tic",
"=",
"None",
",",
"prt",
"=",
"sys",
".",
"stdout",
")",
":",
"if",
"tic",
"is",
"None",
":",
"tic",
"=",
"self",
".",
"tic",
"now",
"=",
"timeit",
".",
"default_timer",
"(",
")",
"hms",
"=",
... | Print elapsed time and message. | [
"Print",
"elapsed",
"time",
"and",
"message",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/anno/annoreader_base.py#L143-L150 |
228,379 | tanghaibao/goatools | goatools/anno/annoreader_base.py | AnnoReaderBase.chk_qualifiers | def chk_qualifiers(self):
"""Check format of qualifier"""
if self.name == 'id2gos':
return
for ntd in self.associations:
# print(ntd)
qual = ntd.Qualifier
assert isinstance(qual, set), '{NAME}: QUALIFIER MUST BE A LIST: {NT}'.format(
... | python | def chk_qualifiers(self):
"""Check format of qualifier"""
if self.name == 'id2gos':
return
for ntd in self.associations:
# print(ntd)
qual = ntd.Qualifier
assert isinstance(qual, set), '{NAME}: QUALIFIER MUST BE A LIST: {NT}'.format(
... | [
"def",
"chk_qualifiers",
"(",
"self",
")",
":",
"if",
"self",
".",
"name",
"==",
"'id2gos'",
":",
"return",
"for",
"ntd",
"in",
"self",
".",
"associations",
":",
"# print(ntd)",
"qual",
"=",
"ntd",
".",
"Qualifier",
"assert",
"isinstance",
"(",
"qual",
"... | Check format of qualifier | [
"Check",
"format",
"of",
"qualifier"
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/anno/annoreader_base.py#L164-L175 |
228,380 | tanghaibao/goatools | goatools/anno/annoreader_base.py | AnnoReaderBase._has_not_qual | def _has_not_qual(ntd):
"""Return True if the qualifiers contain a 'NOT'"""
for qual in ntd.Qualifier:
if 'not' in qual:
return True
if 'NOT' in qual:
return True
return False | python | def _has_not_qual(ntd):
"""Return True if the qualifiers contain a 'NOT'"""
for qual in ntd.Qualifier:
if 'not' in qual:
return True
if 'NOT' in qual:
return True
return False | [
"def",
"_has_not_qual",
"(",
"ntd",
")",
":",
"for",
"qual",
"in",
"ntd",
".",
"Qualifier",
":",
"if",
"'not'",
"in",
"qual",
":",
"return",
"True",
"if",
"'NOT'",
"in",
"qual",
":",
"return",
"True",
"return",
"False"
] | Return True if the qualifiers contain a 'NOT | [
"Return",
"True",
"if",
"the",
"qualifiers",
"contain",
"a",
"NOT"
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/anno/annoreader_base.py#L178-L185 |
228,381 | tanghaibao/goatools | goatools/grouper/sorter_nts.py | SorterNts._get_sorted_section | def _get_sorted_section(self, nts_section):
"""Sort GO IDs in each section, if requested by user."""
#pylint: disable=unnecessary-lambda
if self.section_sortby is True:
return sorted(nts_section, key=lambda nt: self.sortgos.usrgo_sortby(nt))
if self.section_sortby is False or... | python | def _get_sorted_section(self, nts_section):
"""Sort GO IDs in each section, if requested by user."""
#pylint: disable=unnecessary-lambda
if self.section_sortby is True:
return sorted(nts_section, key=lambda nt: self.sortgos.usrgo_sortby(nt))
if self.section_sortby is False or... | [
"def",
"_get_sorted_section",
"(",
"self",
",",
"nts_section",
")",
":",
"#pylint: disable=unnecessary-lambda",
"if",
"self",
".",
"section_sortby",
"is",
"True",
":",
"return",
"sorted",
"(",
"nts_section",
",",
"key",
"=",
"lambda",
"nt",
":",
"self",
".",
"... | Sort GO IDs in each section, if requested by user. | [
"Sort",
"GO",
"IDs",
"in",
"each",
"section",
"if",
"requested",
"by",
"user",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/sorter_nts.py#L88-L96 |
228,382 | tanghaibao/goatools | goatools/godag/go_tasks.py | get_relationship_targets | def get_relationship_targets(item_ids, relationships, id2rec):
"""Get item ID set of item IDs in a relationship target set."""
# Requirements to use this function:
# 1) item Terms must have been loaded with 'relationships'
# 2) item IDs in 'item_ids' arguement must be present in id2rec
# ... | python | def get_relationship_targets(item_ids, relationships, id2rec):
"""Get item ID set of item IDs in a relationship target set."""
# Requirements to use this function:
# 1) item Terms must have been loaded with 'relationships'
# 2) item IDs in 'item_ids' arguement must be present in id2rec
# ... | [
"def",
"get_relationship_targets",
"(",
"item_ids",
",",
"relationships",
",",
"id2rec",
")",
":",
"# Requirements to use this function:",
"# 1) item Terms must have been loaded with 'relationships'",
"# 2) item IDs in 'item_ids' arguement must be present in id2rec",
"# 3) Arg,... | Get item ID set of item IDs in a relationship target set. | [
"Get",
"item",
"ID",
"set",
"of",
"item",
"IDs",
"in",
"a",
"relationship",
"target",
"set",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/godag/go_tasks.py#L35-L47 |
228,383 | tanghaibao/goatools | goatools/godag/go_tasks.py | _get_id2parents | def _get_id2parents(id2parents, item_id, item_obj):
"""Add the parent item IDs for one item object and their parents."""
if item_id in id2parents:
return id2parents[item_id]
parent_ids = set()
for parent_obj in item_obj.parents:
parent_id = parent_obj.item_id
parent_ids.add(paren... | python | def _get_id2parents(id2parents, item_id, item_obj):
"""Add the parent item IDs for one item object and their parents."""
if item_id in id2parents:
return id2parents[item_id]
parent_ids = set()
for parent_obj in item_obj.parents:
parent_id = parent_obj.item_id
parent_ids.add(paren... | [
"def",
"_get_id2parents",
"(",
"id2parents",
",",
"item_id",
",",
"item_obj",
")",
":",
"if",
"item_id",
"in",
"id2parents",
":",
"return",
"id2parents",
"[",
"item_id",
"]",
"parent_ids",
"=",
"set",
"(",
")",
"for",
"parent_obj",
"in",
"item_obj",
".",
"... | Add the parent item IDs for one item object and their parents. | [
"Add",
"the",
"parent",
"item",
"IDs",
"for",
"one",
"item",
"object",
"and",
"their",
"parents",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/godag/go_tasks.py#L50-L60 |
228,384 | tanghaibao/goatools | goatools/godag/go_tasks.py | _get_id2children | def _get_id2children(id2children, item_id, item_obj):
"""Add the child item IDs for one item object and their children."""
if item_id in id2children:
return id2children[item_id]
child_ids = set()
for child_obj in item_obj.children:
child_id = child_obj.item_id
child_ids.add(child... | python | def _get_id2children(id2children, item_id, item_obj):
"""Add the child item IDs for one item object and their children."""
if item_id in id2children:
return id2children[item_id]
child_ids = set()
for child_obj in item_obj.children:
child_id = child_obj.item_id
child_ids.add(child... | [
"def",
"_get_id2children",
"(",
"id2children",
",",
"item_id",
",",
"item_obj",
")",
":",
"if",
"item_id",
"in",
"id2children",
":",
"return",
"id2children",
"[",
"item_id",
"]",
"child_ids",
"=",
"set",
"(",
")",
"for",
"child_obj",
"in",
"item_obj",
".",
... | Add the child item IDs for one item object and their children. | [
"Add",
"the",
"child",
"item",
"IDs",
"for",
"one",
"item",
"object",
"and",
"their",
"children",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/godag/go_tasks.py#L62-L72 |
228,385 | tanghaibao/goatools | goatools/godag/go_tasks.py | _get_id2upper | def _get_id2upper(id2upper, item_id, item_obj):
"""Add the parent item IDs for one item object and their upper."""
if item_id in id2upper:
return id2upper[item_id]
upper_ids = set()
for upper_obj in item_obj.get_goterms_upper():
upper_id = upper_obj.item_id
upper_ids.add(upper_id... | python | def _get_id2upper(id2upper, item_id, item_obj):
"""Add the parent item IDs for one item object and their upper."""
if item_id in id2upper:
return id2upper[item_id]
upper_ids = set()
for upper_obj in item_obj.get_goterms_upper():
upper_id = upper_obj.item_id
upper_ids.add(upper_id... | [
"def",
"_get_id2upper",
"(",
"id2upper",
",",
"item_id",
",",
"item_obj",
")",
":",
"if",
"item_id",
"in",
"id2upper",
":",
"return",
"id2upper",
"[",
"item_id",
"]",
"upper_ids",
"=",
"set",
"(",
")",
"for",
"upper_obj",
"in",
"item_obj",
".",
"get_goterm... | Add the parent item IDs for one item object and their upper. | [
"Add",
"the",
"parent",
"item",
"IDs",
"for",
"one",
"item",
"object",
"and",
"their",
"upper",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/godag/go_tasks.py#L74-L84 |
228,386 | tanghaibao/goatools | goatools/godag/go_tasks.py | _get_id2lower | def _get_id2lower(id2lower, item_id, item_obj):
"""Add the lower item IDs for one item object and the objects below them."""
if item_id in id2lower:
return id2lower[item_id]
lower_ids = set()
for lower_obj in item_obj.get_goterms_lower():
lower_id = lower_obj.item_id
lower_ids.ad... | python | def _get_id2lower(id2lower, item_id, item_obj):
"""Add the lower item IDs for one item object and the objects below them."""
if item_id in id2lower:
return id2lower[item_id]
lower_ids = set()
for lower_obj in item_obj.get_goterms_lower():
lower_id = lower_obj.item_id
lower_ids.ad... | [
"def",
"_get_id2lower",
"(",
"id2lower",
",",
"item_id",
",",
"item_obj",
")",
":",
"if",
"item_id",
"in",
"id2lower",
":",
"return",
"id2lower",
"[",
"item_id",
"]",
"lower_ids",
"=",
"set",
"(",
")",
"for",
"lower_obj",
"in",
"item_obj",
".",
"get_goterm... | Add the lower item IDs for one item object and the objects below them. | [
"Add",
"the",
"lower",
"item",
"IDs",
"for",
"one",
"item",
"object",
"and",
"the",
"objects",
"below",
"them",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/godag/go_tasks.py#L86-L96 |
228,387 | tanghaibao/goatools | goatools/godag/go_tasks.py | CurNHigher.fill_parentidid2obj_r0 | def fill_parentidid2obj_r0(self, id2obj, child_obj):
"""Fill id2obj with all parent key item IDs and their objects."""
for parent_obj in child_obj.parents:
if parent_obj.item_id not in id2obj:
id2obj[parent_obj.item_id] = parent_obj
self.fill_parentidid2obj_r0... | python | def fill_parentidid2obj_r0(self, id2obj, child_obj):
"""Fill id2obj with all parent key item IDs and their objects."""
for parent_obj in child_obj.parents:
if parent_obj.item_id not in id2obj:
id2obj[parent_obj.item_id] = parent_obj
self.fill_parentidid2obj_r0... | [
"def",
"fill_parentidid2obj_r0",
"(",
"self",
",",
"id2obj",
",",
"child_obj",
")",
":",
"for",
"parent_obj",
"in",
"child_obj",
".",
"parents",
":",
"if",
"parent_obj",
".",
"item_id",
"not",
"in",
"id2obj",
":",
"id2obj",
"[",
"parent_obj",
".",
"item_id",... | Fill id2obj with all parent key item IDs and their objects. | [
"Fill",
"id2obj",
"with",
"all",
"parent",
"key",
"item",
"IDs",
"and",
"their",
"objects",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/godag/go_tasks.py#L123-L128 |
228,388 | tanghaibao/goatools | goatools/grouper/wr_sections.py | WrSectionsBase.prt_ver | def prt_ver(self, prt):
"""Print version of GO-DAG for the GO and for GO slims."""
if self.ver_list is not None:
prt.write("# Versions:\n# {VER}\n\n".format(VER="\n# ".join(self.ver_list))) | python | def prt_ver(self, prt):
"""Print version of GO-DAG for the GO and for GO slims."""
if self.ver_list is not None:
prt.write("# Versions:\n# {VER}\n\n".format(VER="\n# ".join(self.ver_list))) | [
"def",
"prt_ver",
"(",
"self",
",",
"prt",
")",
":",
"if",
"self",
".",
"ver_list",
"is",
"not",
"None",
":",
"prt",
".",
"write",
"(",
"\"# Versions:\\n# {VER}\\n\\n\"",
".",
"format",
"(",
"VER",
"=",
"\"\\n# \"",
".",
"join",
"(",
"self",
".",
... | Print version of GO-DAG for the GO and for GO slims. | [
"Print",
"version",
"of",
"GO",
"-",
"DAG",
"for",
"the",
"GO",
"and",
"for",
"GO",
"slims",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/wr_sections.py#L22-L25 |
228,389 | tanghaibao/goatools | goatools/grouper/wr_sections.py | WrSectionsBase.get_sections_2dnt | def get_sections_2dnt(self, sec2d_go):
"""Return a sections list containing sorted lists of namedtuples."""
return [(nm, self.get_ntgos_sorted(gos)) for nm, gos in sec2d_go] | python | def get_sections_2dnt(self, sec2d_go):
"""Return a sections list containing sorted lists of namedtuples."""
return [(nm, self.get_ntgos_sorted(gos)) for nm, gos in sec2d_go] | [
"def",
"get_sections_2dnt",
"(",
"self",
",",
"sec2d_go",
")",
":",
"return",
"[",
"(",
"nm",
",",
"self",
".",
"get_ntgos_sorted",
"(",
"gos",
")",
")",
"for",
"nm",
",",
"gos",
"in",
"sec2d_go",
"]"
] | Return a sections list containing sorted lists of namedtuples. | [
"Return",
"a",
"sections",
"list",
"containing",
"sorted",
"lists",
"of",
"namedtuples",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/wr_sections.py#L27-L29 |
228,390 | tanghaibao/goatools | goatools/grouper/wr_sections.py | WrSectionsBase.get_ntgos_sorted | def get_ntgos_sorted(self, hdrgos):
"""Return sorted Grouper namedtuples if there are user GO IDs underneath."""
go2nt = self.grprobj.go2nt
return sorted([go2nt[go] for go in hdrgos if go in go2nt], key=self.fncsortnt) | python | def get_ntgos_sorted(self, hdrgos):
"""Return sorted Grouper namedtuples if there are user GO IDs underneath."""
go2nt = self.grprobj.go2nt
return sorted([go2nt[go] for go in hdrgos if go in go2nt], key=self.fncsortnt) | [
"def",
"get_ntgos_sorted",
"(",
"self",
",",
"hdrgos",
")",
":",
"go2nt",
"=",
"self",
".",
"grprobj",
".",
"go2nt",
"return",
"sorted",
"(",
"[",
"go2nt",
"[",
"go",
"]",
"for",
"go",
"in",
"hdrgos",
"if",
"go",
"in",
"go2nt",
"]",
",",
"key",
"="... | Return sorted Grouper namedtuples if there are user GO IDs underneath. | [
"Return",
"sorted",
"Grouper",
"namedtuples",
"if",
"there",
"are",
"user",
"GO",
"IDs",
"underneath",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/wr_sections.py#L31-L34 |
228,391 | tanghaibao/goatools | goatools/grouper/wr_sections.py | WrSectionsBase.prt_ntgos | def prt_ntgos(self, prt, ntgos):
"""Print the Grouper namedtuples."""
for ntgo in ntgos:
key2val = ntgo._asdict()
prt.write("{GO_LINE}\n".format(GO_LINE=self.prtfmt.format(**key2val))) | python | def prt_ntgos(self, prt, ntgos):
"""Print the Grouper namedtuples."""
for ntgo in ntgos:
key2val = ntgo._asdict()
prt.write("{GO_LINE}\n".format(GO_LINE=self.prtfmt.format(**key2val))) | [
"def",
"prt_ntgos",
"(",
"self",
",",
"prt",
",",
"ntgos",
")",
":",
"for",
"ntgo",
"in",
"ntgos",
":",
"key2val",
"=",
"ntgo",
".",
"_asdict",
"(",
")",
"prt",
".",
"write",
"(",
"\"{GO_LINE}\\n\"",
".",
"format",
"(",
"GO_LINE",
"=",
"self",
".",
... | Print the Grouper namedtuples. | [
"Print",
"the",
"Grouper",
"namedtuples",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/wr_sections.py#L36-L40 |
228,392 | tanghaibao/goatools | goatools/grouper/wr_sections.py | WrSectionsPy.wr_py_sections_new | def wr_py_sections_new(self, fout_py, doc=None):
"""Write the first sections file."""
sections = self.grprobj.get_sections_2d()
return self.wr_py_sections(fout_py, sections, doc) | python | def wr_py_sections_new(self, fout_py, doc=None):
"""Write the first sections file."""
sections = self.grprobj.get_sections_2d()
return self.wr_py_sections(fout_py, sections, doc) | [
"def",
"wr_py_sections_new",
"(",
"self",
",",
"fout_py",
",",
"doc",
"=",
"None",
")",
":",
"sections",
"=",
"self",
".",
"grprobj",
".",
"get_sections_2d",
"(",
")",
"return",
"self",
".",
"wr_py_sections",
"(",
"fout_py",
",",
"sections",
",",
"doc",
... | Write the first sections file. | [
"Write",
"the",
"first",
"sections",
"file",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/wr_sections.py#L92-L95 |
228,393 | tanghaibao/goatools | goatools/grouper/wr_sections.py | WrSectionsPy.wr_py_sections | def wr_py_sections(self, fout_py, sections, doc=None):
"""Write sections 2-D list into a Python format list."""
if sections is None:
sections = self.grprobj.get_sections_2d()
sec2d_nt = self.get_sections_2dnt(sections) # lists of GO Grouper namedtuples
with open(fout_py, 'w'... | python | def wr_py_sections(self, fout_py, sections, doc=None):
"""Write sections 2-D list into a Python format list."""
if sections is None:
sections = self.grprobj.get_sections_2d()
sec2d_nt = self.get_sections_2dnt(sections) # lists of GO Grouper namedtuples
with open(fout_py, 'w'... | [
"def",
"wr_py_sections",
"(",
"self",
",",
"fout_py",
",",
"sections",
",",
"doc",
"=",
"None",
")",
":",
"if",
"sections",
"is",
"None",
":",
"sections",
"=",
"self",
".",
"grprobj",
".",
"get_sections_2d",
"(",
")",
"sec2d_nt",
"=",
"self",
".",
"get... | Write sections 2-D list into a Python format list. | [
"Write",
"sections",
"2",
"-",
"D",
"list",
"into",
"a",
"Python",
"format",
"list",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/wr_sections.py#L97-L108 |
228,394 | tanghaibao/goatools | goatools/grouper/wr_sections.py | WrSectionsPy._prt_py_sections | def _prt_py_sections(self, sec2d_nt, prt=sys.stdout, doc=None):
"""Print sections 2-D list into a Python format list."""
if doc is None:
doc = 'Sections variable'
prt.write('"""{DOC}"""\n\n'.format(DOC=doc))
self.prt_ver(prt)
prt.write("# pylint: disable=line-too-long... | python | def _prt_py_sections(self, sec2d_nt, prt=sys.stdout, doc=None):
"""Print sections 2-D list into a Python format list."""
if doc is None:
doc = 'Sections variable'
prt.write('"""{DOC}"""\n\n'.format(DOC=doc))
self.prt_ver(prt)
prt.write("# pylint: disable=line-too-long... | [
"def",
"_prt_py_sections",
"(",
"self",
",",
"sec2d_nt",
",",
"prt",
"=",
"sys",
".",
"stdout",
",",
"doc",
"=",
"None",
")",
":",
"if",
"doc",
"is",
"None",
":",
"doc",
"=",
"'Sections variable'",
"prt",
".",
"write",
"(",
"'\"\"\"{DOC}\"\"\"\\n\\n'",
"... | Print sections 2-D list into a Python format list. | [
"Print",
"sections",
"2",
"-",
"D",
"list",
"into",
"a",
"Python",
"format",
"list",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/wr_sections.py#L110-L123 |
228,395 | tanghaibao/goatools | goatools/grouper/wr_sections.py | WrSectionsPy._prt_py_section | def _prt_py_section(self, prt, section_name, ntgos):
"""Print one section and its GO headers."""
prt.write(' ("{SEC}", [ # {N} GO-headers\n'.format(SEC=section_name, N=len(ntgos)))
self.prt_ntgos(prt, ntgos)
prt.write(" ]),\n") | python | def _prt_py_section(self, prt, section_name, ntgos):
"""Print one section and its GO headers."""
prt.write(' ("{SEC}", [ # {N} GO-headers\n'.format(SEC=section_name, N=len(ntgos)))
self.prt_ntgos(prt, ntgos)
prt.write(" ]),\n") | [
"def",
"_prt_py_section",
"(",
"self",
",",
"prt",
",",
"section_name",
",",
"ntgos",
")",
":",
"prt",
".",
"write",
"(",
"' (\"{SEC}\", [ # {N} GO-headers\\n'",
".",
"format",
"(",
"SEC",
"=",
"section_name",
",",
"N",
"=",
"len",
"(",
"ntgos",
")",
")... | Print one section and its GO headers. | [
"Print",
"one",
"section",
"and",
"its",
"GO",
"headers",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/wr_sections.py#L125-L129 |
228,396 | tanghaibao/goatools | goatools/grouper/wr_sections.py | WrSectionsTxt.prt_goid_cnt | def prt_goid_cnt(self, prt=sys.stdout):
"""Get number of hdrgos and usrgos in each section."""
for section_name, hdrgos_sec in self.grprobj.get_sections_2d():
prt.write("{NAME} {Us:5,} {Hs:5,} {SEC}\n".format(
NAME=self.grprobj.grpname,
Us=len(self.grprobj.get... | python | def prt_goid_cnt(self, prt=sys.stdout):
"""Get number of hdrgos and usrgos in each section."""
for section_name, hdrgos_sec in self.grprobj.get_sections_2d():
prt.write("{NAME} {Us:5,} {Hs:5,} {SEC}\n".format(
NAME=self.grprobj.grpname,
Us=len(self.grprobj.get... | [
"def",
"prt_goid_cnt",
"(",
"self",
",",
"prt",
"=",
"sys",
".",
"stdout",
")",
":",
"for",
"section_name",
",",
"hdrgos_sec",
"in",
"self",
".",
"grprobj",
".",
"get_sections_2d",
"(",
")",
":",
"prt",
".",
"write",
"(",
"\"{NAME} {Us:5,} {Hs:5,} {SEC}\\n\"... | Get number of hdrgos and usrgos in each section. | [
"Get",
"number",
"of",
"hdrgos",
"and",
"usrgos",
"in",
"each",
"section",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/wr_sections.py#L162-L169 |
228,397 | tanghaibao/goatools | goatools/grouper/wr_sections.py | WrSectionsTxt.wr_txt_grouping_gos | def wr_txt_grouping_gos(self):
"""Write one file per GO group."""
prt_goids = self.grprobj.gosubdag.prt_goids
for hdrgo, usrgos in self.grprobj.hdrgo2usrgos.items():
keygos = usrgos.union([hdrgo])
fout_txt = "{BASE}.txt".format(BASE=self.grprobj.get_fout_base(hdrgo))
... | python | def wr_txt_grouping_gos(self):
"""Write one file per GO group."""
prt_goids = self.grprobj.gosubdag.prt_goids
for hdrgo, usrgos in self.grprobj.hdrgo2usrgos.items():
keygos = usrgos.union([hdrgo])
fout_txt = "{BASE}.txt".format(BASE=self.grprobj.get_fout_base(hdrgo))
... | [
"def",
"wr_txt_grouping_gos",
"(",
"self",
")",
":",
"prt_goids",
"=",
"self",
".",
"grprobj",
".",
"gosubdag",
".",
"prt_goids",
"for",
"hdrgo",
",",
"usrgos",
"in",
"self",
".",
"grprobj",
".",
"hdrgo2usrgos",
".",
"items",
"(",
")",
":",
"keygos",
"="... | Write one file per GO group. | [
"Write",
"one",
"file",
"per",
"GO",
"group",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/wr_sections.py#L171-L180 |
228,398 | tanghaibao/goatools | goatools/grouper/wr_sections.py | WrSectionsTxt.wr_txt_section_hdrgos | def wr_txt_section_hdrgos(self, fout_txt, sortby=None, prt_section=True):
"""Write high GO IDs that are actually used to group current set of GO IDs."""
sec2d_go = self.grprobj.get_sections_2d() # lists of GO IDs
sec2d_nt = self.get_sections_2dnt(sec2d_go) # lists of GO Grouper namedtuples
... | python | def wr_txt_section_hdrgos(self, fout_txt, sortby=None, prt_section=True):
"""Write high GO IDs that are actually used to group current set of GO IDs."""
sec2d_go = self.grprobj.get_sections_2d() # lists of GO IDs
sec2d_nt = self.get_sections_2dnt(sec2d_go) # lists of GO Grouper namedtuples
... | [
"def",
"wr_txt_section_hdrgos",
"(",
"self",
",",
"fout_txt",
",",
"sortby",
"=",
"None",
",",
"prt_section",
"=",
"True",
")",
":",
"sec2d_go",
"=",
"self",
".",
"grprobj",
".",
"get_sections_2d",
"(",
")",
"# lists of GO IDs",
"sec2d_nt",
"=",
"self",
".",... | Write high GO IDs that are actually used to group current set of GO IDs. | [
"Write",
"high",
"GO",
"IDs",
"that",
"are",
"actually",
"used",
"to",
"group",
"current",
"set",
"of",
"GO",
"IDs",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/wr_sections.py#L182-L202 |
228,399 | tanghaibao/goatools | goatools/parsers/david_chart.py | DavidChartReader.prt_num_sig | def prt_num_sig(self, prt=sys.stdout, alpha=0.05):
"""Print the number of significant GO terms."""
ctr = self.get_num_sig(alpha)
prt.write("{N:6,} TOTAL: {TXT}\n".format(N=len(self.nts), TXT=" ".join([
"FDR({FDR:4})".format(FDR=ctr['FDR']),
"Bonferroni({B:4})".format(B=ct... | python | def prt_num_sig(self, prt=sys.stdout, alpha=0.05):
"""Print the number of significant GO terms."""
ctr = self.get_num_sig(alpha)
prt.write("{N:6,} TOTAL: {TXT}\n".format(N=len(self.nts), TXT=" ".join([
"FDR({FDR:4})".format(FDR=ctr['FDR']),
"Bonferroni({B:4})".format(B=ct... | [
"def",
"prt_num_sig",
"(",
"self",
",",
"prt",
"=",
"sys",
".",
"stdout",
",",
"alpha",
"=",
"0.05",
")",
":",
"ctr",
"=",
"self",
".",
"get_num_sig",
"(",
"alpha",
")",
"prt",
".",
"write",
"(",
"\"{N:6,} TOTAL: {TXT}\\n\"",
".",
"format",
"(",
"N",
... | Print the number of significant GO terms. | [
"Print",
"the",
"number",
"of",
"significant",
"GO",
"terms",
"."
] | 407682e573a108864a79031f8ca19ee3bf377626 | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/parsers/david_chart.py#L81-L89 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.