repo stringlengths 7 55 | path stringlengths 4 223 | func_name stringlengths 1 134 | original_string stringlengths 75 104k | language stringclasses 1
value | code stringlengths 75 104k | code_tokens listlengths 19 28.4k | docstring stringlengths 1 46.9k | docstring_tokens listlengths 1 1.97k | sha stringlengths 40 40 | url stringlengths 87 315 | partition stringclasses 3
values | summary stringlengths 4 350 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
nocarryr/python-dispatch | pydispatch/dispatch.py | Dispatcher.unbind | def unbind(self, *args):
"""Unsubscribes from events or :class:`~pydispatch.properties.Property` updates
Multiple arguments can be given. Each of which can be either the method
that was used for the original call to :meth:`bind` or an instance
object.
If an instance of an objec... | python | def unbind(self, *args):
"""Unsubscribes from events or :class:`~pydispatch.properties.Property` updates
Multiple arguments can be given. Each of which can be either the method
that was used for the original call to :meth:`bind` or an instance
object.
If an instance of an objec... | [
"def",
"unbind",
"(",
"self",
",",
"*",
"args",
")",
":",
"props",
"=",
"self",
".",
"__property_events",
".",
"values",
"(",
")",
"events",
"=",
"self",
".",
"__events",
".",
"values",
"(",
")",
"for",
"arg",
"in",
"args",
":",
"for",
"prop",
"in"... | Unsubscribes from events or :class:`~pydispatch.properties.Property` updates
Multiple arguments can be given. Each of which can be either the method
that was used for the original call to :meth:`bind` or an instance
object.
If an instance of an object is supplied, any previously bound ... | [
"Unsubscribes",
"from",
"events",
"or",
":",
"class",
":",
"~pydispatch",
".",
"properties",
".",
"Property",
"updates"
] | 7c5ca03835c922cbfdfd62772c9e560062c954c7 | https://github.com/nocarryr/python-dispatch/blob/7c5ca03835c922cbfdfd62772c9e560062c954c7/pydispatch/dispatch.py#L199-L215 | train | Unsubscribes from events or properties or instances of this object. |
nocarryr/python-dispatch | pydispatch/dispatch.py | Dispatcher.emit | def emit(self, name, *args, **kwargs):
"""Dispatches an event to any subscribed listeners
Note:
If a listener returns :obj:`False`, the event will stop dispatching to
other listeners. Any other return value is ignored.
Args:
name (str): The name of the :clas... | python | def emit(self, name, *args, **kwargs):
"""Dispatches an event to any subscribed listeners
Note:
If a listener returns :obj:`False`, the event will stop dispatching to
other listeners. Any other return value is ignored.
Args:
name (str): The name of the :clas... | [
"def",
"emit",
"(",
"self",
",",
"name",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"e",
"=",
"self",
".",
"__property_events",
".",
"get",
"(",
"name",
")",
"if",
"e",
"is",
"None",
":",
"e",
"=",
"self",
".",
"__events",
"[",
"name"... | Dispatches an event to any subscribed listeners
Note:
If a listener returns :obj:`False`, the event will stop dispatching to
other listeners. Any other return value is ignored.
Args:
name (str): The name of the :class:`Event` to dispatch
*args (Optional)... | [
"Dispatches",
"an",
"event",
"to",
"any",
"subscribed",
"listeners"
] | 7c5ca03835c922cbfdfd62772c9e560062c954c7 | https://github.com/nocarryr/python-dispatch/blob/7c5ca03835c922cbfdfd62772c9e560062c954c7/pydispatch/dispatch.py#L236-L251 | train | Dispatches an event to any subscribed listeners. |
nocarryr/python-dispatch | pydispatch/dispatch.py | Dispatcher.get_dispatcher_event | def get_dispatcher_event(self, name):
"""Retrieves an Event object by name
Args:
name (str): The name of the :class:`Event` or
:class:`~pydispatch.properties.Property` object to retrieve
Returns:
The :class:`Event` instance for the event or property defi... | python | def get_dispatcher_event(self, name):
"""Retrieves an Event object by name
Args:
name (str): The name of the :class:`Event` or
:class:`~pydispatch.properties.Property` object to retrieve
Returns:
The :class:`Event` instance for the event or property defi... | [
"def",
"get_dispatcher_event",
"(",
"self",
",",
"name",
")",
":",
"e",
"=",
"self",
".",
"__property_events",
".",
"get",
"(",
"name",
")",
"if",
"e",
"is",
"None",
":",
"e",
"=",
"self",
".",
"__events",
"[",
"name",
"]",
"return",
"e"
] | Retrieves an Event object by name
Args:
name (str): The name of the :class:`Event` or
:class:`~pydispatch.properties.Property` object to retrieve
Returns:
The :class:`Event` instance for the event or property definition
.. versionadded:: 0.1.0 | [
"Retrieves",
"an",
"Event",
"object",
"by",
"name"
] | 7c5ca03835c922cbfdfd62772c9e560062c954c7 | https://github.com/nocarryr/python-dispatch/blob/7c5ca03835c922cbfdfd62772c9e560062c954c7/pydispatch/dispatch.py#L252-L267 | train | Retrieves an Event object by name. |
nocarryr/python-dispatch | pydispatch/dispatch.py | Dispatcher.emission_lock | def emission_lock(self, name):
"""Holds emission of events and dispatches the last event on release
The context manager returned will store the last event data called by
:meth:`emit` and prevent callbacks until it exits. On exit, it will
dispatch the last event captured (if any)::
... | python | def emission_lock(self, name):
"""Holds emission of events and dispatches the last event on release
The context manager returned will store the last event data called by
:meth:`emit` and prevent callbacks until it exits. On exit, it will
dispatch the last event captured (if any)::
... | [
"def",
"emission_lock",
"(",
"self",
",",
"name",
")",
":",
"e",
"=",
"self",
".",
"__property_events",
".",
"get",
"(",
"name",
")",
"if",
"e",
"is",
"None",
":",
"e",
"=",
"self",
".",
"__events",
"[",
"name",
"]",
"return",
"e",
".",
"emission_l... | Holds emission of events and dispatches the last event on release
The context manager returned will store the last event data called by
:meth:`emit` and prevent callbacks until it exits. On exit, it will
dispatch the last event captured (if any)::
class Foo(Dispatcher):
... | [
"Holds",
"emission",
"of",
"events",
"and",
"dispatches",
"the",
"last",
"event",
"on",
"release"
] | 7c5ca03835c922cbfdfd62772c9e560062c954c7 | https://github.com/nocarryr/python-dispatch/blob/7c5ca03835c922cbfdfd62772c9e560062c954c7/pydispatch/dispatch.py#L268-L309 | train | Holds emission of events and dispatches the last event on release
|
acutesoftware/AIKIF | aikif/toolbox/image_detection_tools.py | TEST | def TEST(fname):
"""
Test function to step through all functions in
order to try and identify all features on a map
This test function should be placed in a main
section later
"""
#fname = os.path.join(os.getcwd(), '..','..', # os.path.join(os.path.getcwd(), '
m = MapObject(fname, os.p... | python | def TEST(fname):
"""
Test function to step through all functions in
order to try and identify all features on a map
This test function should be placed in a main
section later
"""
#fname = os.path.join(os.getcwd(), '..','..', # os.path.join(os.path.getcwd(), '
m = MapObject(fname, os.p... | [
"def",
"TEST",
"(",
"fname",
")",
":",
"#fname = os.path.join(os.getcwd(), '..','..', # os.path.join(os.path.getcwd(), '",
"m",
"=",
"MapObject",
"(",
"fname",
",",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"getcwd",
"(",
")",
",",
"'img_prog_results'",
")"... | Test function to step through all functions in
order to try and identify all features on a map
This test function should be placed in a main
section later | [
"Test",
"function",
"to",
"step",
"through",
"all",
"functions",
"in",
"order",
"to",
"try",
"and",
"identify",
"all",
"features",
"on",
"a",
"map",
"This",
"test",
"function",
"should",
"be",
"placed",
"in",
"a",
"main",
"section",
"later"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/toolbox/image_detection_tools.py#L41-L61 | train | Test function to step through all functions in
order to try and identify all features on a map |
acutesoftware/AIKIF | aikif/dataTools/cls_datatable.py | DataTable.describe_contents | def describe_contents(self):
""" describes various contents of data table """
print('======================================================================')
print(self)
print('Table = ', str(len(self.header)) + ' cols x ' + str(len(self.arr)) + ' rows')
print('HEADER = ', self... | python | def describe_contents(self):
""" describes various contents of data table """
print('======================================================================')
print(self)
print('Table = ', str(len(self.header)) + ' cols x ' + str(len(self.arr)) + ' rows')
print('HEADER = ', self... | [
"def",
"describe_contents",
"(",
"self",
")",
":",
"print",
"(",
"'======================================================================'",
")",
"print",
"(",
"self",
")",
"print",
"(",
"'Table = '",
",",
"str",
"(",
"len",
"(",
"self",
".",
"header",
")",
")",
... | describes various contents of data table | [
"describes",
"various",
"contents",
"of",
"data",
"table"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/dataTools/cls_datatable.py#L68-L74 | train | describes various contents of the data table |
acutesoftware/AIKIF | aikif/dataTools/cls_datatable.py | DataTable.get_distinct_values_from_cols | def get_distinct_values_from_cols(self, l_col_list):
"""
returns the list of distinct combinations in a dataset
based on the columns in the list. Note that this is
currently implemented as MAX permutations of the combo
so it is not guarenteed to have values in each case.
... | python | def get_distinct_values_from_cols(self, l_col_list):
"""
returns the list of distinct combinations in a dataset
based on the columns in the list. Note that this is
currently implemented as MAX permutations of the combo
so it is not guarenteed to have values in each case.
... | [
"def",
"get_distinct_values_from_cols",
"(",
"self",
",",
"l_col_list",
")",
":",
"uniq_vals",
"=",
"[",
"]",
"for",
"l_col_name",
"in",
"l_col_list",
":",
"#print('col_name: ' + l_col_name) ",
"uniq_vals",
".",
"append",
"(",
"set",
"(",
"self",
".",
"get_col_d... | returns the list of distinct combinations in a dataset
based on the columns in the list. Note that this is
currently implemented as MAX permutations of the combo
so it is not guarenteed to have values in each case. | [
"returns",
"the",
"list",
"of",
"distinct",
"combinations",
"in",
"a",
"dataset",
"based",
"on",
"the",
"columns",
"in",
"the",
"list",
".",
"Note",
"that",
"this",
"is",
"currently",
"implemented",
"as",
"MAX",
"permutations",
"of",
"the",
"combo",
"so",
... | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/dataTools/cls_datatable.py#L79-L104 | train | returns the list of distinct combinations in a dataset
based on the columns in the list |
acutesoftware/AIKIF | aikif/dataTools/cls_datatable.py | DataTable.select_where | def select_where(self, where_col_list, where_value_list, col_name=''):
"""
selects rows from the array where col_list == val_list
"""
res = [] # list of rows to be returned
col_ids = [] # ids of the columns to check
#print('select_where : arr = ', len(self.ar... | python | def select_where(self, where_col_list, where_value_list, col_name=''):
"""
selects rows from the array where col_list == val_list
"""
res = [] # list of rows to be returned
col_ids = [] # ids of the columns to check
#print('select_where : arr = ', len(self.ar... | [
"def",
"select_where",
"(",
"self",
",",
"where_col_list",
",",
"where_value_list",
",",
"col_name",
"=",
"''",
")",
":",
"res",
"=",
"[",
"]",
"# list of rows to be returned",
"col_ids",
"=",
"[",
"]",
"# ids of the columns to check",
"#print('select_where : arr = '... | selects rows from the array where col_list == val_list | [
"selects",
"rows",
"from",
"the",
"array",
"where",
"col_list",
"==",
"val_list"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/dataTools/cls_datatable.py#L117-L145 | train | selects rows from the array where col_list == val_list
|
acutesoftware/AIKIF | aikif/dataTools/cls_datatable.py | DataTable.update_where | def update_where(self, col, value, where_col_list, where_value_list):
"""
updates the array to set cell = value where col_list == val_list
"""
if type(col) is str:
col_ndx = self.get_col_by_name(col)
else:
col_ndx = col
#print('col_ndx = ', col_nd... | python | def update_where(self, col, value, where_col_list, where_value_list):
"""
updates the array to set cell = value where col_list == val_list
"""
if type(col) is str:
col_ndx = self.get_col_by_name(col)
else:
col_ndx = col
#print('col_ndx = ', col_nd... | [
"def",
"update_where",
"(",
"self",
",",
"col",
",",
"value",
",",
"where_col_list",
",",
"where_value_list",
")",
":",
"if",
"type",
"(",
"col",
")",
"is",
"str",
":",
"col_ndx",
"=",
"self",
".",
"get_col_by_name",
"(",
"col",
")",
"else",
":",
"col_... | updates the array to set cell = value where col_list == val_list | [
"updates",
"the",
"array",
"to",
"set",
"cell",
"=",
"value",
"where",
"col_list",
"==",
"val_list"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/dataTools/cls_datatable.py#L171-L184 | train | updates the array to set value where col_list == val_list |
acutesoftware/AIKIF | aikif/dataTools/cls_datatable.py | DataTable.calc_percentiles | def calc_percentiles(self, col_name, where_col_list, where_value_list):
"""
calculates the percentiles of col_name
WHERE [where_col_list] = [where_value_list]
"""
#col_data = self.get_col_data_by_name(col_name)
col_data = self.select_where(where_col_list, where_value_li... | python | def calc_percentiles(self, col_name, where_col_list, where_value_list):
"""
calculates the percentiles of col_name
WHERE [where_col_list] = [where_value_list]
"""
#col_data = self.get_col_data_by_name(col_name)
col_data = self.select_where(where_col_list, where_value_li... | [
"def",
"calc_percentiles",
"(",
"self",
",",
"col_name",
",",
"where_col_list",
",",
"where_value_list",
")",
":",
"#col_data = self.get_col_data_by_name(col_name)",
"col_data",
"=",
"self",
".",
"select_where",
"(",
"where_col_list",
",",
"where_value_list",
",",
"col_... | calculates the percentiles of col_name
WHERE [where_col_list] = [where_value_list] | [
"calculates",
"the",
"percentiles",
"of",
"col_name",
"WHERE",
"[",
"where_col_list",
"]",
"=",
"[",
"where_value_list",
"]"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/dataTools/cls_datatable.py#L188-L204 | train | Calculates the percentiles of col_name
|
acutesoftware/AIKIF | aikif/dataTools/cls_datatable.py | DataTable.percentile | def percentile(self, lst_data, percent , key=lambda x:x):
""" calculates the 'num' percentile of the items in the list """
new_list = sorted(lst_data)
#print('new list = ' , new_list)
#n = float(len(lst_data))
k = (len(new_list)-1) * percent
f = math.floor(k)
c = ... | python | def percentile(self, lst_data, percent , key=lambda x:x):
""" calculates the 'num' percentile of the items in the list """
new_list = sorted(lst_data)
#print('new list = ' , new_list)
#n = float(len(lst_data))
k = (len(new_list)-1) * percent
f = math.floor(k)
c = ... | [
"def",
"percentile",
"(",
"self",
",",
"lst_data",
",",
"percent",
",",
"key",
"=",
"lambda",
"x",
":",
"x",
")",
":",
"new_list",
"=",
"sorted",
"(",
"lst_data",
")",
"#print('new list = ' , new_list)",
"#n = float(len(lst_data))",
"k",
"=",
"(",
"len",
"("... | calculates the 'num' percentile of the items in the list | [
"calculates",
"the",
"num",
"percentile",
"of",
"the",
"items",
"in",
"the",
"list"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/dataTools/cls_datatable.py#L206-L219 | train | Calculates the num percentile of the items in the list |
acutesoftware/AIKIF | aikif/dataTools/cls_datatable.py | DataTable.save | def save(self, filename, content):
"""
default is to save a file from list of lines
"""
with open(filename, "w") as f:
if hasattr(content, '__iter__'):
f.write('\n'.join([row for row in content]))
else:
print('WRINGI CONTWETESWREWR'... | python | def save(self, filename, content):
"""
default is to save a file from list of lines
"""
with open(filename, "w") as f:
if hasattr(content, '__iter__'):
f.write('\n'.join([row for row in content]))
else:
print('WRINGI CONTWETESWREWR'... | [
"def",
"save",
"(",
"self",
",",
"filename",
",",
"content",
")",
":",
"with",
"open",
"(",
"filename",
",",
"\"w\"",
")",
"as",
"f",
":",
"if",
"hasattr",
"(",
"content",
",",
"'__iter__'",
")",
":",
"f",
".",
"write",
"(",
"'\\n'",
".",
"join",
... | default is to save a file from list of lines | [
"default",
"is",
"to",
"save",
"a",
"file",
"from",
"list",
"of",
"lines"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/dataTools/cls_datatable.py#L230-L239 | train | save a file from a list of lines |
acutesoftware/AIKIF | aikif/dataTools/cls_datatable.py | DataTable.save_csv | def save_csv(self, filename, write_header_separately=True):
"""
save the default array as a CSV file
"""
txt = ''
#print("SAVING arr = ", self.arr)
with open(filename, "w") as f:
if write_header_separately:
f.write(','.join([c for c in... | python | def save_csv(self, filename, write_header_separately=True):
"""
save the default array as a CSV file
"""
txt = ''
#print("SAVING arr = ", self.arr)
with open(filename, "w") as f:
if write_header_separately:
f.write(','.join([c for c in... | [
"def",
"save_csv",
"(",
"self",
",",
"filename",
",",
"write_header_separately",
"=",
"True",
")",
":",
"txt",
"=",
"''",
"#print(\"SAVING arr = \", self.arr)",
"with",
"open",
"(",
"filename",
",",
"\"w\"",
")",
"as",
"f",
":",
"if",
"write_header_separately",
... | save the default array as a CSV file | [
"save",
"the",
"default",
"array",
"as",
"a",
"CSV",
"file"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/dataTools/cls_datatable.py#L241-L256 | train | save the default array as a CSV file |
acutesoftware/AIKIF | aikif/dataTools/cls_datatable.py | DataTable.drop | def drop(self, fname):
"""
drop the table, view or delete the file
"""
if self.dataset_type == 'file':
import os
try:
os.remove(fname)
except Exception as ex:
print('cant drop file "' + fname + '" : ' + str(ex)) | python | def drop(self, fname):
"""
drop the table, view or delete the file
"""
if self.dataset_type == 'file':
import os
try:
os.remove(fname)
except Exception as ex:
print('cant drop file "' + fname + '" : ' + str(ex)) | [
"def",
"drop",
"(",
"self",
",",
"fname",
")",
":",
"if",
"self",
".",
"dataset_type",
"==",
"'file'",
":",
"import",
"os",
"try",
":",
"os",
".",
"remove",
"(",
"fname",
")",
"except",
"Exception",
"as",
"ex",
":",
"print",
"(",
"'cant drop file \"'",... | drop the table, view or delete the file | [
"drop",
"the",
"table",
"view",
"or",
"delete",
"the",
"file"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/dataTools/cls_datatable.py#L258-L267 | train | drop the table view or delete the file |
acutesoftware/AIKIF | aikif/dataTools/cls_datatable.py | DataTable.get_col_data_by_name | def get_col_data_by_name(self, col_name, WHERE_Clause=''):
""" returns the values of col_name according to where """
#print('get_col_data_by_name: col_name = ', col_name, ' WHERE = ', WHERE_Clause)
col_key = self.get_col_by_name(col_name)
if col_key is None:
print('get_col_da... | python | def get_col_data_by_name(self, col_name, WHERE_Clause=''):
""" returns the values of col_name according to where """
#print('get_col_data_by_name: col_name = ', col_name, ' WHERE = ', WHERE_Clause)
col_key = self.get_col_by_name(col_name)
if col_key is None:
print('get_col_da... | [
"def",
"get_col_data_by_name",
"(",
"self",
",",
"col_name",
",",
"WHERE_Clause",
"=",
"''",
")",
":",
"#print('get_col_data_by_name: col_name = ', col_name, ' WHERE = ', WHERE_Clause)",
"col_key",
"=",
"self",
".",
"get_col_by_name",
"(",
"col_name",
")",
"if",
"col_key"... | returns the values of col_name according to where | [
"returns",
"the",
"values",
"of",
"col_name",
"according",
"to",
"where"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/dataTools/cls_datatable.py#L311-L323 | train | returns the values of col_name according to WHERE_Clause |
acutesoftware/AIKIF | aikif/dataTools/cls_datatable.py | DataTable.format_rst | def format_rst(self):
"""
return table in RST format
"""
res = ''
num_cols = len(self.header)
col_width = 25
for _ in range(num_cols):
res += ''.join(['=' for _ in range(col_width - 1)]) + ' '
res += '\n'
for c in self.header:
... | python | def format_rst(self):
"""
return table in RST format
"""
res = ''
num_cols = len(self.header)
col_width = 25
for _ in range(num_cols):
res += ''.join(['=' for _ in range(col_width - 1)]) + ' '
res += '\n'
for c in self.header:
... | [
"def",
"format_rst",
"(",
"self",
")",
":",
"res",
"=",
"''",
"num_cols",
"=",
"len",
"(",
"self",
".",
"header",
")",
"col_width",
"=",
"25",
"for",
"_",
"in",
"range",
"(",
"num_cols",
")",
":",
"res",
"+=",
"''",
".",
"join",
"(",
"[",
"'='",
... | return table in RST format | [
"return",
"table",
"in",
"RST",
"format"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/dataTools/cls_datatable.py#L325-L348 | train | return table in RST format |
cox-labs/perseuspy | perseuspy/io/perseus/network.py | read_networks | def read_networks(folder):
"""
Read perseus network collection folder format
>>> network_table, networks = read_networks(folder)
:param folder: Path to network collection
:returns: Network table and dictionary with 'name', 'edge_table', and 'node_table' keys.
"""
network_table = re... | python | def read_networks(folder):
"""
Read perseus network collection folder format
>>> network_table, networks = read_networks(folder)
:param folder: Path to network collection
:returns: Network table and dictionary with 'name', 'edge_table', and 'node_table' keys.
"""
network_table = re... | [
"def",
"read_networks",
"(",
"folder",
")",
":",
"network_table",
"=",
"read_perseus",
"(",
"path",
".",
"join",
"(",
"folder",
",",
"\"networks.txt\"",
")",
")",
"networks",
"=",
"{",
"}",
"for",
"name",
",",
"guid",
"in",
"network_table",
"[",
"[",
"'N... | Read perseus network collection folder format
>>> network_table, networks = read_networks(folder)
:param folder: Path to network collection
:returns: Network table and dictionary with 'name', 'edge_table', and 'node_table' keys. | [
"Read",
"perseus",
"network",
"collection",
"folder",
"format",
">>>",
"network_table",
"networks",
"=",
"read_networks",
"(",
"folder",
")",
":",
"param",
"folder",
":",
"Path",
"to",
"network",
"collection",
":",
"returns",
":",
"Network",
"table",
"and",
"d... | 3809c1bd46512605f9e7ca7f97e026e4940ed604 | https://github.com/cox-labs/perseuspy/blob/3809c1bd46512605f9e7ca7f97e026e4940ed604/perseuspy/io/perseus/network.py#L9-L27 | train | Read perseus network collection folder format
|
cox-labs/perseuspy | perseuspy/io/perseus/network.py | from_perseus | def from_perseus(network_table, networks):
"""
Create networkx graph from network tables
>>> from perseuspy import read_networks, nx
>>> network_table, networks = read_networks(folder)
>>> graphs = nx.from_perseus(network_table, networks)
"""
graphs = []
for guid, graph_attr in zip(... | python | def from_perseus(network_table, networks):
"""
Create networkx graph from network tables
>>> from perseuspy import read_networks, nx
>>> network_table, networks = read_networks(folder)
>>> graphs = nx.from_perseus(network_table, networks)
"""
graphs = []
for guid, graph_attr in zip(... | [
"def",
"from_perseus",
"(",
"network_table",
",",
"networks",
")",
":",
"graphs",
"=",
"[",
"]",
"for",
"guid",
",",
"graph_attr",
"in",
"zip",
"(",
"network_table",
"[",
"'GUID'",
"]",
",",
"network_table",
".",
"values",
")",
":",
"network",
"=",
"netw... | Create networkx graph from network tables
>>> from perseuspy import read_networks, nx
>>> network_table, networks = read_networks(folder)
>>> graphs = nx.from_perseus(network_table, networks) | [
"Create",
"networkx",
"graph",
"from",
"network",
"tables",
">>>",
"from",
"perseuspy",
"import",
"read_networks",
"nx",
">>>",
"network_table",
"networks",
"=",
"read_networks",
"(",
"folder",
")",
">>>",
"graphs",
"=",
"nx",
".",
"from_perseus",
"(",
"network_... | 3809c1bd46512605f9e7ca7f97e026e4940ed604 | https://github.com/cox-labs/perseuspy/blob/3809c1bd46512605f9e7ca7f97e026e4940ed604/perseuspy/io/perseus/network.py#L29-L56 | train | Create networkx graph from perseus network tables |
cox-labs/perseuspy | perseuspy/io/perseus/network.py | to_perseus | def to_perseus(graphs):
"""
Create a network table and the network dictionary for export to Perseus.
:param graphs: Collection of networkx graphs
>>> from perseuspy import nx
>>> G = nx.random_graphs.barabasi_albert_graph(10, 3)
>>> network_table, networks = nx.to_perseus([G])
"""
... | python | def to_perseus(graphs):
"""
Create a network table and the network dictionary for export to Perseus.
:param graphs: Collection of networkx graphs
>>> from perseuspy import nx
>>> G = nx.random_graphs.barabasi_albert_graph(10, 3)
>>> network_table, networks = nx.to_perseus([G])
"""
... | [
"def",
"to_perseus",
"(",
"graphs",
")",
":",
"graph_attributes",
"=",
"[",
"]",
"networks",
"=",
"{",
"}",
"for",
"graph",
"in",
"graphs",
":",
"attributes",
"=",
"dict",
"(",
"graph",
".",
"graph",
")",
"attributes",
".",
"update",
"(",
"{",
"\"Name\... | Create a network table and the network dictionary for export to Perseus.
:param graphs: Collection of networkx graphs
>>> from perseuspy import nx
>>> G = nx.random_graphs.barabasi_albert_graph(10, 3)
>>> network_table, networks = nx.to_perseus([G]) | [
"Create",
"a",
"network",
"table",
"and",
"the",
"network",
"dictionary",
"for",
"export",
"to",
"Perseus",
".",
":",
"param",
"graphs",
":",
"Collection",
"of",
"networkx",
"graphs"
] | 3809c1bd46512605f9e7ca7f97e026e4940ed604 | https://github.com/cox-labs/perseuspy/blob/3809c1bd46512605f9e7ca7f97e026e4940ed604/perseuspy/io/perseus/network.py#L58-L91 | train | Create a network table and the network dictionary for export to Perseus. |
cox-labs/perseuspy | perseuspy/io/perseus/network.py | write_networks | def write_networks(folder, network_table, networks):
"""
Writing networkTable, nodes and edges to Perseus readable format.
:param folder: Path to output directory.
:param network_table: Network table.
:param networks: Dictionary with node and edge tables, indexed by network guid.
"""
ma... | python | def write_networks(folder, network_table, networks):
"""
Writing networkTable, nodes and edges to Perseus readable format.
:param folder: Path to output directory.
:param network_table: Network table.
:param networks: Dictionary with node and edge tables, indexed by network guid.
"""
ma... | [
"def",
"write_networks",
"(",
"folder",
",",
"network_table",
",",
"networks",
")",
":",
"makedirs",
"(",
"folder",
",",
"exist_ok",
"=",
"True",
")",
"network_table",
".",
"to_perseus",
"(",
"path",
".",
"join",
"(",
"folder",
",",
"'networks.txt'",
")",
... | Writing networkTable, nodes and edges to Perseus readable format.
:param folder: Path to output directory.
:param network_table: Network table.
:param networks: Dictionary with node and edge tables, indexed by network guid. | [
"Writing",
"networkTable",
"nodes",
"and",
"edges",
"to",
"Perseus",
"readable",
"format",
".",
":",
"param",
"folder",
":",
"Path",
"to",
"output",
"directory",
".",
":",
"param",
"network_table",
":",
"Network",
"table",
".",
":",
"param",
"networks",
":",... | 3809c1bd46512605f9e7ca7f97e026e4940ed604 | https://github.com/cox-labs/perseuspy/blob/3809c1bd46512605f9e7ca7f97e026e4940ed604/perseuspy/io/perseus/network.py#L93-L105 | train | Writes the networks to Perseus readable format. |
mpg-age-bioinformatics/AGEpy | AGEpy/homology.py | getHomoloGene | def getHomoloGene(taxfile="build_inputs/taxid_taxname",\
genefile="homologene.data",\
proteinsfile="build_inputs/all_proteins.data",\
proteinsclusterfile="build_inputs/proteins_for_clustering.data",\
baseURL="http://ftp.ncbi.nih.gov/pub/HomoloGene/... | python | def getHomoloGene(taxfile="build_inputs/taxid_taxname",\
genefile="homologene.data",\
proteinsfile="build_inputs/all_proteins.data",\
proteinsclusterfile="build_inputs/proteins_for_clustering.data",\
baseURL="http://ftp.ncbi.nih.gov/pub/HomoloGene/... | [
"def",
"getHomoloGene",
"(",
"taxfile",
"=",
"\"build_inputs/taxid_taxname\"",
",",
"genefile",
"=",
"\"homologene.data\"",
",",
"proteinsfile",
"=",
"\"build_inputs/all_proteins.data\"",
",",
"proteinsclusterfile",
"=",
"\"build_inputs/proteins_for_clustering.data\"",
",",
"ba... | Returns NBCI's Homolog Gene tables.
:param taxfile: path to local file or to baseURL/taxfile
:param genefile: path to local file or to baseURL/genefile
:param proteinsfile: path to local file or to baseURL/proteinsfile
:param proteinsclusterfile: path to local file or to baseURL/proteinsclusterfile
... | [
"Returns",
"NBCI",
"s",
"Homolog",
"Gene",
"tables",
"."
] | 887808a7a2c1504f39ce8d8cb36c15c1721cd29f | https://github.com/mpg-age-bioinformatics/AGEpy/blob/887808a7a2c1504f39ce8d8cb36c15c1721cd29f/AGEpy/homology.py#L6-L66 | train | Returns a dataframe of the Homolog Gene tables. |
mpg-age-bioinformatics/AGEpy | AGEpy/fasta.py | getFasta | def getFasta(opened_file, sequence_name):
"""
Retrieves a sequence from an opened multifasta file
:param opened_file: an opened multifasta file eg. opened_file=open("/path/to/file.fa",'r+')
:param sequence_name: the name of the sequence to be retrieved eg. for '>2 dna:chromosome chromosome:GRCm38:2:1:1... | python | def getFasta(opened_file, sequence_name):
"""
Retrieves a sequence from an opened multifasta file
:param opened_file: an opened multifasta file eg. opened_file=open("/path/to/file.fa",'r+')
:param sequence_name: the name of the sequence to be retrieved eg. for '>2 dna:chromosome chromosome:GRCm38:2:1:1... | [
"def",
"getFasta",
"(",
"opened_file",
",",
"sequence_name",
")",
":",
"lines",
"=",
"opened_file",
".",
"readlines",
"(",
")",
"seq",
"=",
"str",
"(",
"\"\"",
")",
"for",
"i",
"in",
"range",
"(",
"0",
",",
"len",
"(",
"lines",
")",
")",
":",
"line... | Retrieves a sequence from an opened multifasta file
:param opened_file: an opened multifasta file eg. opened_file=open("/path/to/file.fa",'r+')
:param sequence_name: the name of the sequence to be retrieved eg. for '>2 dna:chromosome chromosome:GRCm38:2:1:182113224:1 REF' use: sequence_name=str(2)
returns... | [
"Retrieves",
"a",
"sequence",
"from",
"an",
"opened",
"multifasta",
"file"
] | 887808a7a2c1504f39ce8d8cb36c15c1721cd29f | https://github.com/mpg-age-bioinformatics/AGEpy/blob/887808a7a2c1504f39ce8d8cb36c15c1721cd29f/AGEpy/fasta.py#L2-L34 | train | Returns a string with the sequence of interest in the multifasta file |
mpg-age-bioinformatics/AGEpy | AGEpy/fasta.py | writeFasta | def writeFasta(sequence, sequence_name, output_file):
"""
Writes a fasta sequence into a file.
:param sequence: a string with the sequence to be written
:param sequence_name: name of the the fasta sequence
:param output_file: /path/to/file.fa to be written
:returns: nothing
"""
i=0
... | python | def writeFasta(sequence, sequence_name, output_file):
"""
Writes a fasta sequence into a file.
:param sequence: a string with the sequence to be written
:param sequence_name: name of the the fasta sequence
:param output_file: /path/to/file.fa to be written
:returns: nothing
"""
i=0
... | [
"def",
"writeFasta",
"(",
"sequence",
",",
"sequence_name",
",",
"output_file",
")",
":",
"i",
"=",
"0",
"f",
"=",
"open",
"(",
"output_file",
",",
"'w'",
")",
"f",
".",
"write",
"(",
"\">\"",
"+",
"str",
"(",
"sequence_name",
")",
"+",
"\"\\n\"",
")... | Writes a fasta sequence into a file.
:param sequence: a string with the sequence to be written
:param sequence_name: name of the the fasta sequence
:param output_file: /path/to/file.fa to be written
:returns: nothing | [
"Writes",
"a",
"fasta",
"sequence",
"into",
"a",
"file",
"."
] | 887808a7a2c1504f39ce8d8cb36c15c1721cd29f | https://github.com/mpg-age-bioinformatics/AGEpy/blob/887808a7a2c1504f39ce8d8cb36c15c1721cd29f/AGEpy/fasta.py#L36-L52 | train | Writes a sequence into a file. |
mpg-age-bioinformatics/AGEpy | AGEpy/fasta.py | rewriteFasta | def rewriteFasta(sequence, sequence_name, fasta_in, fasta_out):
"""
Rewrites a specific sequence in a multifasta file while keeping the sequence header.
:param sequence: a string with the sequence to be written
:param sequence_name: the name of the sequence to be retrieved eg. for '>2 dna:chromosome ch... | python | def rewriteFasta(sequence, sequence_name, fasta_in, fasta_out):
"""
Rewrites a specific sequence in a multifasta file while keeping the sequence header.
:param sequence: a string with the sequence to be written
:param sequence_name: the name of the sequence to be retrieved eg. for '>2 dna:chromosome ch... | [
"def",
"rewriteFasta",
"(",
"sequence",
",",
"sequence_name",
",",
"fasta_in",
",",
"fasta_out",
")",
":",
"f",
"=",
"open",
"(",
"fasta_in",
",",
"'r+'",
")",
"f2",
"=",
"open",
"(",
"fasta_out",
",",
"'w'",
")",
"lines",
"=",
"f",
".",
"readlines",
... | Rewrites a specific sequence in a multifasta file while keeping the sequence header.
:param sequence: a string with the sequence to be written
:param sequence_name: the name of the sequence to be retrieved eg. for '>2 dna:chromosome chromosome:GRCm38:2:1:182113224:1 REF' use: sequence_name=str(2)
:param fa... | [
"Rewrites",
"a",
"specific",
"sequence",
"in",
"a",
"multifasta",
"file",
"while",
"keeping",
"the",
"sequence",
"header",
"."
] | 887808a7a2c1504f39ce8d8cb36c15c1721cd29f | https://github.com/mpg-age-bioinformatics/AGEpy/blob/887808a7a2c1504f39ce8d8cb36c15c1721cd29f/AGEpy/fasta.py#L54-L92 | train | Rewrites a specific sequence in a multifasta file while keeping the sequence header. |
acutesoftware/AIKIF | aikif/toolbox/Toolbox.py | Toolbox._get_tool_str | def _get_tool_str(self, tool):
"""
get a string representation of the tool
"""
res = tool['file']
try:
res += '.' + tool['function']
except Exception as ex:
print('Warning - no function defined for tool ' + str(tool))
res += '\n'
r... | python | def _get_tool_str(self, tool):
"""
get a string representation of the tool
"""
res = tool['file']
try:
res += '.' + tool['function']
except Exception as ex:
print('Warning - no function defined for tool ' + str(tool))
res += '\n'
r... | [
"def",
"_get_tool_str",
"(",
"self",
",",
"tool",
")",
":",
"res",
"=",
"tool",
"[",
"'file'",
"]",
"try",
":",
"res",
"+=",
"'.'",
"+",
"tool",
"[",
"'function'",
"]",
"except",
"Exception",
"as",
"ex",
":",
"print",
"(",
"'Warning - no function defined... | get a string representation of the tool | [
"get",
"a",
"string",
"representation",
"of",
"the",
"tool"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/toolbox/Toolbox.py#L42-L52 | train | get a string representation of the tool |
acutesoftware/AIKIF | aikif/toolbox/Toolbox.py | Toolbox.get_tool_by_name | def get_tool_by_name(self, nme):
"""
get the tool object by name or file
"""
for t in self.lstTools:
if 'name' in t:
if t['name'] == nme:
return t
if 'file' in t:
if t['file'] == nme:
return t... | python | def get_tool_by_name(self, nme):
"""
get the tool object by name or file
"""
for t in self.lstTools:
if 'name' in t:
if t['name'] == nme:
return t
if 'file' in t:
if t['file'] == nme:
return t... | [
"def",
"get_tool_by_name",
"(",
"self",
",",
"nme",
")",
":",
"for",
"t",
"in",
"self",
".",
"lstTools",
":",
"if",
"'name'",
"in",
"t",
":",
"if",
"t",
"[",
"'name'",
"]",
"==",
"nme",
":",
"return",
"t",
"if",
"'file'",
"in",
"t",
":",
"if",
... | get the tool object by name or file | [
"get",
"the",
"tool",
"object",
"by",
"name",
"or",
"file"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/toolbox/Toolbox.py#L54-L65 | train | get the tool object by name or file |
acutesoftware/AIKIF | aikif/toolbox/Toolbox.py | Toolbox.add | def add(self, tool):
"""
Adds a Tool to the list, logs the reference and TODO
"""
self.lstTools.append(tool)
self.lg.record_process(self._get_tool_str(tool)) | python | def add(self, tool):
"""
Adds a Tool to the list, logs the reference and TODO
"""
self.lstTools.append(tool)
self.lg.record_process(self._get_tool_str(tool)) | [
"def",
"add",
"(",
"self",
",",
"tool",
")",
":",
"self",
".",
"lstTools",
".",
"append",
"(",
"tool",
")",
"self",
".",
"lg",
".",
"record_process",
"(",
"self",
".",
"_get_tool_str",
"(",
"tool",
")",
")"
] | Adds a Tool to the list, logs the reference and TODO | [
"Adds",
"a",
"Tool",
"to",
"the",
"list",
"logs",
"the",
"reference",
"and",
"TODO"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/toolbox/Toolbox.py#L67-L72 | train | Adds a Tool to the list logs the reference and TODO
|
acutesoftware/AIKIF | aikif/toolbox/Toolbox.py | Toolbox.save | def save(self, fname=''):
"""
Save the list of tools to AIKIF core and optionally to local file fname
"""
if fname != '':
with open(fname, 'w') as f:
for t in self.lstTools:
self.verify(t)
f.write(self.tool_as_string(t)) | python | def save(self, fname=''):
"""
Save the list of tools to AIKIF core and optionally to local file fname
"""
if fname != '':
with open(fname, 'w') as f:
for t in self.lstTools:
self.verify(t)
f.write(self.tool_as_string(t)) | [
"def",
"save",
"(",
"self",
",",
"fname",
"=",
"''",
")",
":",
"if",
"fname",
"!=",
"''",
":",
"with",
"open",
"(",
"fname",
",",
"'w'",
")",
"as",
"f",
":",
"for",
"t",
"in",
"self",
".",
"lstTools",
":",
"self",
".",
"verify",
"(",
"t",
")"... | Save the list of tools to AIKIF core and optionally to local file fname | [
"Save",
"the",
"list",
"of",
"tools",
"to",
"AIKIF",
"core",
"and",
"optionally",
"to",
"local",
"file",
"fname"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/toolbox/Toolbox.py#L88-L96 | train | Save the list of tools to AIKIF core and optionally to local file fname |
acutesoftware/AIKIF | aikif/toolbox/Toolbox.py | Toolbox.verify | def verify(self, tool):
"""
check that the tool exists
"""
if os.path.isfile(tool['file']):
print('Toolbox: program exists = TOK :: ' + tool['file'])
return True
else:
print('Toolbox: program exists = FAIL :: ' + tool['file'])
retu... | python | def verify(self, tool):
"""
check that the tool exists
"""
if os.path.isfile(tool['file']):
print('Toolbox: program exists = TOK :: ' + tool['file'])
return True
else:
print('Toolbox: program exists = FAIL :: ' + tool['file'])
retu... | [
"def",
"verify",
"(",
"self",
",",
"tool",
")",
":",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"tool",
"[",
"'file'",
"]",
")",
":",
"print",
"(",
"'Toolbox: program exists = TOK :: '",
"+",
"tool",
"[",
"'file'",
"]",
")",
"return",
"True",
"else"... | check that the tool exists | [
"check",
"that",
"the",
"tool",
"exists"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/toolbox/Toolbox.py#L98-L107 | train | check that the tool exists |
acutesoftware/AIKIF | aikif/toolbox/Toolbox.py | Toolbox.run | def run(self, tool, args, new_import_path=''):
"""
import the tool and call the function, passing the args.
"""
if new_import_path != '':
#print('APPENDING PATH = ', new_import_path)
sys.path.append(new_import_path)
#if silent == 'N':
prin... | python | def run(self, tool, args, new_import_path=''):
"""
import the tool and call the function, passing the args.
"""
if new_import_path != '':
#print('APPENDING PATH = ', new_import_path)
sys.path.append(new_import_path)
#if silent == 'N':
prin... | [
"def",
"run",
"(",
"self",
",",
"tool",
",",
"args",
",",
"new_import_path",
"=",
"''",
")",
":",
"if",
"new_import_path",
"!=",
"''",
":",
"#print('APPENDING PATH = ', new_import_path)",
"sys",
".",
"path",
".",
"append",
"(",
"new_import_path",
")",
"#if sil... | import the tool and call the function, passing the args. | [
"import",
"the",
"tool",
"and",
"call",
"the",
"function",
"passing",
"the",
"args",
"."
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/toolbox/Toolbox.py#L109-L123 | train | import the tool and call the function passing the args. |
Nachtfeuer/pipeline | spline/application.py | main | def main(**kwargs):
"""The Pipeline tool."""
options = ApplicationOptions(**kwargs)
Event.configure(is_logging_enabled=options.event_logging)
application = Application(options)
application.run(options.definition) | python | def main(**kwargs):
"""The Pipeline tool."""
options = ApplicationOptions(**kwargs)
Event.configure(is_logging_enabled=options.event_logging)
application = Application(options)
application.run(options.definition) | [
"def",
"main",
"(",
"*",
"*",
"kwargs",
")",
":",
"options",
"=",
"ApplicationOptions",
"(",
"*",
"*",
"kwargs",
")",
"Event",
".",
"configure",
"(",
"is_logging_enabled",
"=",
"options",
".",
"event_logging",
")",
"application",
"=",
"Application",
"(",
"... | The Pipeline tool. | [
"The",
"Pipeline",
"tool",
"."
] | 04ca18c4e95e4349532bb45b768206393e1f2c13 | https://github.com/Nachtfeuer/pipeline/blob/04ca18c4e95e4349532bb45b768206393e1f2c13/spline/application.py#L209-L214 | train | The Pipeline tool. |
Nachtfeuer/pipeline | spline/application.py | Application.setup_logging | def setup_logging(self):
"""Setup of application logging."""
is_custom_logging = len(self.options.logging_config) > 0
is_custom_logging = is_custom_logging and os.path.isfile(self.options.logging_config)
is_custom_logging = is_custom_logging and not self.options.dry_run
if is_cu... | python | def setup_logging(self):
"""Setup of application logging."""
is_custom_logging = len(self.options.logging_config) > 0
is_custom_logging = is_custom_logging and os.path.isfile(self.options.logging_config)
is_custom_logging = is_custom_logging and not self.options.dry_run
if is_cu... | [
"def",
"setup_logging",
"(",
"self",
")",
":",
"is_custom_logging",
"=",
"len",
"(",
"self",
".",
"options",
".",
"logging_config",
")",
">",
"0",
"is_custom_logging",
"=",
"is_custom_logging",
"and",
"os",
".",
"path",
".",
"isfile",
"(",
"self",
".",
"op... | Setup of application logging. | [
"Setup",
"of",
"application",
"logging",
"."
] | 04ca18c4e95e4349532bb45b768206393e1f2c13 | https://github.com/Nachtfeuer/pipeline/blob/04ca18c4e95e4349532bb45b768206393e1f2c13/spline/application.py#L56-L68 | train | Setup of application logging. |
Nachtfeuer/pipeline | spline/application.py | Application.validate_document | def validate_document(self, definition):
"""
Validate given pipeline document.
The method is trying to load, parse and validate the spline document.
The validator verifies the Python structure B{not} the file format.
Args:
definition (str): path and filename of a ya... | python | def validate_document(self, definition):
"""
Validate given pipeline document.
The method is trying to load, parse and validate the spline document.
The validator verifies the Python structure B{not} the file format.
Args:
definition (str): path and filename of a ya... | [
"def",
"validate_document",
"(",
"self",
",",
"definition",
")",
":",
"initial_document",
"=",
"{",
"}",
"try",
":",
"initial_document",
"=",
"Loader",
".",
"load",
"(",
"definition",
")",
"except",
"RuntimeError",
"as",
"exception",
":",
"self",
".",
"logge... | Validate given pipeline document.
The method is trying to load, parse and validate the spline document.
The validator verifies the Python structure B{not} the file format.
Args:
definition (str): path and filename of a yaml file containing a valid spline definition.
Return... | [
"Validate",
"given",
"pipeline",
"document",
"."
] | 04ca18c4e95e4349532bb45b768206393e1f2c13 | https://github.com/Nachtfeuer/pipeline/blob/04ca18c4e95e4349532bb45b768206393e1f2c13/spline/application.py#L70-L101 | train | Validate a pipeline document. |
Nachtfeuer/pipeline | spline/application.py | Application.run_matrix | def run_matrix(self, matrix_definition, document):
"""
Running pipeline via a matrix.
Args:
matrix_definition (dict): one concrete matrix item.
document (dict): spline document (complete) as loaded from yaml file.
"""
matrix = Matrix(matrix_definition, 'm... | python | def run_matrix(self, matrix_definition, document):
"""
Running pipeline via a matrix.
Args:
matrix_definition (dict): one concrete matrix item.
document (dict): spline document (complete) as loaded from yaml file.
"""
matrix = Matrix(matrix_definition, 'm... | [
"def",
"run_matrix",
"(",
"self",
",",
"matrix_definition",
",",
"document",
")",
":",
"matrix",
"=",
"Matrix",
"(",
"matrix_definition",
",",
"'matrix(parallel)'",
"in",
"document",
")",
"process_data",
"=",
"MatrixProcessData",
"(",
")",
"process_data",
".",
"... | Running pipeline via a matrix.
Args:
matrix_definition (dict): one concrete matrix item.
document (dict): spline document (complete) as loaded from yaml file. | [
"Running",
"pipeline",
"via",
"a",
"matrix",
"."
] | 04ca18c4e95e4349532bb45b768206393e1f2c13 | https://github.com/Nachtfeuer/pipeline/blob/04ca18c4e95e4349532bb45b768206393e1f2c13/spline/application.py#L103-L119 | train | Runs a pipeline via a matrix. |
Nachtfeuer/pipeline | spline/application.py | Application.shutdown | def shutdown(self, collector, success):
"""Shutdown of the application."""
self.event.delegate(success)
if collector is not None:
collector.queue.put(None)
collector.join()
if not success:
sys.exit(1) | python | def shutdown(self, collector, success):
"""Shutdown of the application."""
self.event.delegate(success)
if collector is not None:
collector.queue.put(None)
collector.join()
if not success:
sys.exit(1) | [
"def",
"shutdown",
"(",
"self",
",",
"collector",
",",
"success",
")",
":",
"self",
".",
"event",
".",
"delegate",
"(",
"success",
")",
"if",
"collector",
"is",
"not",
"None",
":",
"collector",
".",
"queue",
".",
"put",
"(",
"None",
")",
"collector",
... | Shutdown of the application. | [
"Shutdown",
"of",
"the",
"application",
"."
] | 04ca18c4e95e4349532bb45b768206393e1f2c13 | https://github.com/Nachtfeuer/pipeline/blob/04ca18c4e95e4349532bb45b768206393e1f2c13/spline/application.py#L121-L128 | train | Shutdown of the application. |
Nachtfeuer/pipeline | spline/application.py | Application.run | def run(self, definition):
"""Processing the pipeline."""
self.logger.info("Running with Python %s", sys.version.replace("\n", ""))
self.logger.info("Running on platform %s", platform.platform())
self.logger.info("Current cpu count is %d", multiprocessing.cpu_count())
self.logger... | python | def run(self, definition):
"""Processing the pipeline."""
self.logger.info("Running with Python %s", sys.version.replace("\n", ""))
self.logger.info("Running on platform %s", platform.platform())
self.logger.info("Current cpu count is %d", multiprocessing.cpu_count())
self.logger... | [
"def",
"run",
"(",
"self",
",",
"definition",
")",
":",
"self",
".",
"logger",
".",
"info",
"(",
"\"Running with Python %s\"",
",",
"sys",
".",
"version",
".",
"replace",
"(",
"\"\\n\"",
",",
"\"\"",
")",
")",
"self",
".",
"logger",
".",
"info",
"(",
... | Processing the pipeline. | [
"Processing",
"the",
"pipeline",
"."
] | 04ca18c4e95e4349532bb45b768206393e1f2c13 | https://github.com/Nachtfeuer/pipeline/blob/04ca18c4e95e4349532bb45b768206393e1f2c13/spline/application.py#L130-L160 | train | Runs the pipeline. |
Nachtfeuer/pipeline | spline/application.py | Application.provide_temporary_scripts_path | def provide_temporary_scripts_path(self):
"""When configured trying to ensure that path does exist."""
if len(self.options.temporary_scripts_path) > 0:
if os.path.isfile(self.options.temporary_scripts_path):
self.logger.error("Error: configured script path seems to be a file!... | python | def provide_temporary_scripts_path(self):
"""When configured trying to ensure that path does exist."""
if len(self.options.temporary_scripts_path) > 0:
if os.path.isfile(self.options.temporary_scripts_path):
self.logger.error("Error: configured script path seems to be a file!... | [
"def",
"provide_temporary_scripts_path",
"(",
"self",
")",
":",
"if",
"len",
"(",
"self",
".",
"options",
".",
"temporary_scripts_path",
")",
">",
"0",
":",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"self",
".",
"options",
".",
"temporary_scripts_path",
... | When configured trying to ensure that path does exist. | [
"When",
"configured",
"trying",
"to",
"ensure",
"that",
"path",
"does",
"exist",
"."
] | 04ca18c4e95e4349532bb45b768206393e1f2c13 | https://github.com/Nachtfeuer/pipeline/blob/04ca18c4e95e4349532bb45b768206393e1f2c13/spline/application.py#L162-L171 | train | When configured to ensure that the temporary scripts path exists. |
Nachtfeuer/pipeline | spline/application.py | Application.create_and_run_collector | def create_and_run_collector(document, options):
"""Create and run collector process for report data."""
collector = None
if not options.report == 'off':
collector = Collector()
collector.store.configure(document)
Event.configure(collector_queue=collector.queu... | python | def create_and_run_collector(document, options):
"""Create and run collector process for report data."""
collector = None
if not options.report == 'off':
collector = Collector()
collector.store.configure(document)
Event.configure(collector_queue=collector.queu... | [
"def",
"create_and_run_collector",
"(",
"document",
",",
"options",
")",
":",
"collector",
"=",
"None",
"if",
"not",
"options",
".",
"report",
"==",
"'off'",
":",
"collector",
"=",
"Collector",
"(",
")",
"collector",
".",
"store",
".",
"configure",
"(",
"d... | Create and run collector process for report data. | [
"Create",
"and",
"run",
"collector",
"process",
"for",
"report",
"data",
"."
] | 04ca18c4e95e4349532bb45b768206393e1f2c13 | https://github.com/Nachtfeuer/pipeline/blob/04ca18c4e95e4349532bb45b768206393e1f2c13/spline/application.py#L174-L182 | train | Create and run collector process for report data. |
Nachtfeuer/pipeline | spline/tools/filters.py | render | def render(value, **kwargs):
"""
Use Jinja2 rendering for given text an key key/values.
Args:
value (str): the template to be rendered.
kwargs (dict): named parameters representing available variables
inside the template.
>>> model = {"message": "hello world 1!"}... | python | def render(value, **kwargs):
"""
Use Jinja2 rendering for given text an key key/values.
Args:
value (str): the template to be rendered.
kwargs (dict): named parameters representing available variables
inside the template.
>>> model = {"message": "hello world 1!"}... | [
"def",
"render",
"(",
"value",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"environment",
"=",
"Environment",
"(",
"autoescape",
"=",
"False",
")",
"# nosec",
"environment",
".",
"filters",
"[",
"'render'",
"]",
"=",
"render",
"environment",
".",
"fil... | Use Jinja2 rendering for given text an key key/values.
Args:
value (str): the template to be rendered.
kwargs (dict): named parameters representing available variables
inside the template.
>>> model = {"message": "hello world 1!"}
>>> rendered_text = render("{{model.... | [
"Use",
"Jinja2",
"rendering",
"for",
"given",
"text",
"an",
"key",
"key",
"/",
"values",
"."
] | 04ca18c4e95e4349532bb45b768206393e1f2c13 | https://github.com/Nachtfeuer/pipeline/blob/04ca18c4e95e4349532bb45b768206393e1f2c13/spline/tools/filters.py#L23-L57 | train | Render a template with Jinja2 rendering. |
Nachtfeuer/pipeline | spline/tools/filters.py | docker_environment | def docker_environment(env):
"""
Transform dictionary of environment variables into Docker -e parameters.
>>> result = docker_environment({'param1': 'val1', 'param2': 'val2'})
>>> result in ['-e "param1=val1" -e "param2=val2"', '-e "param2=val2" -e "param1=val1"']
True
"""
return ' '.join(
... | python | def docker_environment(env):
"""
Transform dictionary of environment variables into Docker -e parameters.
>>> result = docker_environment({'param1': 'val1', 'param2': 'val2'})
>>> result in ['-e "param1=val1" -e "param2=val2"', '-e "param2=val2" -e "param1=val1"']
True
"""
return ' '.join(
... | [
"def",
"docker_environment",
"(",
"env",
")",
":",
"return",
"' '",
".",
"join",
"(",
"[",
"\"-e \\\"%s=%s\\\"\"",
"%",
"(",
"key",
",",
"value",
".",
"replace",
"(",
"\"$\"",
",",
"\"\\\\$\"",
")",
".",
"replace",
"(",
"\"\\\"\"",
",",
"\"\\\\\\\"\"",
"... | Transform dictionary of environment variables into Docker -e parameters.
>>> result = docker_environment({'param1': 'val1', 'param2': 'val2'})
>>> result in ['-e "param1=val1" -e "param2=val2"', '-e "param2=val2" -e "param1=val1"']
True | [
"Transform",
"dictionary",
"of",
"environment",
"variables",
"into",
"Docker",
"-",
"e",
"parameters",
"."
] | 04ca18c4e95e4349532bb45b768206393e1f2c13 | https://github.com/Nachtfeuer/pipeline/blob/04ca18c4e95e4349532bb45b768206393e1f2c13/spline/tools/filters.py#L60-L70 | train | Transform dictionary of environment variables into Docker - e parameters. |
Nachtfeuer/pipeline | spline/tools/filters.py | find_stages | def find_stages(document):
"""
Find **stages** in document.
Args:
document (dict): validated spline document loaded from a yaml file.
Returns:
list: stages as a part of the spline document or an empty list if not given.
>>> find_stages({'pipeline': [{'stage(Prepare)':1}, {'stage(... | python | def find_stages(document):
"""
Find **stages** in document.
Args:
document (dict): validated spline document loaded from a yaml file.
Returns:
list: stages as a part of the spline document or an empty list if not given.
>>> find_stages({'pipeline': [{'stage(Prepare)':1}, {'stage(... | [
"def",
"find_stages",
"(",
"document",
")",
":",
"names",
"=",
"[",
"]",
"if",
"'pipeline'",
"in",
"document",
":",
"for",
"entry",
"in",
"document",
"[",
"'pipeline'",
"]",
":",
"# each entry is dictionary with one key only",
"key",
",",
"_",
"=",
"list",
"... | Find **stages** in document.
Args:
document (dict): validated spline document loaded from a yaml file.
Returns:
list: stages as a part of the spline document or an empty list if not given.
>>> find_stages({'pipeline': [{'stage(Prepare)':1}, {'stage(Build)':1}, {'stage(Deploy)':2}]})
... | [
"Find",
"**",
"stages",
"**",
"in",
"document",
"."
] | 04ca18c4e95e4349532bb45b768206393e1f2c13 | https://github.com/Nachtfeuer/pipeline/blob/04ca18c4e95e4349532bb45b768206393e1f2c13/spline/tools/filters.py#L103-L123 | train | Find the stages in a spline document. |
OpenHydrology/floodestimation | floodestimation/fehdata.py | _retrieve_download_url | def _retrieve_download_url():
"""
Retrieves download location for FEH data zip file from hosted json configuration file.
:return: URL for FEH data file
:rtype: str
"""
try:
# Try to obtain the url from the Open Hydrology json config file.
with urlopen(config['nrfa']['oh_json_url... | python | def _retrieve_download_url():
"""
Retrieves download location for FEH data zip file from hosted json configuration file.
:return: URL for FEH data file
:rtype: str
"""
try:
# Try to obtain the url from the Open Hydrology json config file.
with urlopen(config['nrfa']['oh_json_url... | [
"def",
"_retrieve_download_url",
"(",
")",
":",
"try",
":",
"# Try to obtain the url from the Open Hydrology json config file.",
"with",
"urlopen",
"(",
"config",
"[",
"'nrfa'",
"]",
"[",
"'oh_json_url'",
"]",
",",
"timeout",
"=",
"10",
")",
"as",
"f",
":",
"remot... | Retrieves download location for FEH data zip file from hosted json configuration file.
:return: URL for FEH data file
:rtype: str | [
"Retrieves",
"download",
"location",
"for",
"FEH",
"data",
"zip",
"file",
"from",
"hosted",
"json",
"configuration",
"file",
"."
] | 782da7c5abd1348923129efe89fb70003ebb088c | https://github.com/OpenHydrology/floodestimation/blob/782da7c5abd1348923129efe89fb70003ebb088c/floodestimation/fehdata.py#L58-L79 | train | Retrieve the download location for FEH data zip file from hosted json configuration file. |
OpenHydrology/floodestimation | floodestimation/fehdata.py | update_available | def update_available(after_days=1):
"""
Check whether updated NRFA data is available.
:param after_days: Only check if not checked previously since a certain number of days ago
:type after_days: float
:return: `True` if update available, `False` if not, `None` if remote location cannot be reached.
... | python | def update_available(after_days=1):
"""
Check whether updated NRFA data is available.
:param after_days: Only check if not checked previously since a certain number of days ago
:type after_days: float
:return: `True` if update available, `False` if not, `None` if remote location cannot be reached.
... | [
"def",
"update_available",
"(",
"after_days",
"=",
"1",
")",
":",
"never_downloaded",
"=",
"not",
"bool",
"(",
"config",
".",
"get",
"(",
"'nrfa'",
",",
"'downloaded_on'",
",",
"fallback",
"=",
"None",
")",
"or",
"None",
")",
"if",
"never_downloaded",
":",... | Check whether updated NRFA data is available.
:param after_days: Only check if not checked previously since a certain number of days ago
:type after_days: float
:return: `True` if update available, `False` if not, `None` if remote location cannot be reached.
:rtype: bool or None | [
"Check",
"whether",
"updated",
"NRFA",
"data",
"is",
"available",
"."
] | 782da7c5abd1348923129efe89fb70003ebb088c | https://github.com/OpenHydrology/floodestimation/blob/782da7c5abd1348923129efe89fb70003ebb088c/floodestimation/fehdata.py#L82-L109 | train | Check whether updated NRFA data is available. |
OpenHydrology/floodestimation | floodestimation/fehdata.py | download_data | def download_data():
"""
Downloads complete station dataset including catchment descriptors and amax records. And saves it into a cache
folder.
"""
with urlopen(_retrieve_download_url()) as f:
with open(os.path.join(CACHE_FOLDER, CACHE_ZIP), "wb") as local_file:
local_file.write(... | python | def download_data():
"""
Downloads complete station dataset including catchment descriptors and amax records. And saves it into a cache
folder.
"""
with urlopen(_retrieve_download_url()) as f:
with open(os.path.join(CACHE_FOLDER, CACHE_ZIP), "wb") as local_file:
local_file.write(... | [
"def",
"download_data",
"(",
")",
":",
"with",
"urlopen",
"(",
"_retrieve_download_url",
"(",
")",
")",
"as",
"f",
":",
"with",
"open",
"(",
"os",
".",
"path",
".",
"join",
"(",
"CACHE_FOLDER",
",",
"CACHE_ZIP",
")",
",",
"\"wb\"",
")",
"as",
"local_fi... | Downloads complete station dataset including catchment descriptors and amax records. And saves it into a cache
folder. | [
"Downloads",
"complete",
"station",
"dataset",
"including",
"catchment",
"descriptors",
"and",
"amax",
"records",
".",
"And",
"saves",
"it",
"into",
"a",
"cache",
"folder",
"."
] | 782da7c5abd1348923129efe89fb70003ebb088c | https://github.com/OpenHydrology/floodestimation/blob/782da7c5abd1348923129efe89fb70003ebb088c/floodestimation/fehdata.py#L112-L119 | train | Downloads complete station dataset including catchment descriptors and amax records and saves it into a cache
folder. |
OpenHydrology/floodestimation | floodestimation/fehdata.py | _update_nrfa_metadata | def _update_nrfa_metadata(remote_config):
"""
Save NRFA metadata to local config file using retrieved config data
:param remote_config: Downloaded JSON data, not a ConfigParser object!
"""
config['nrfa']['oh_json_url'] = remote_config['nrfa_oh_json_url']
config['nrfa']['version'] = remote_confi... | python | def _update_nrfa_metadata(remote_config):
"""
Save NRFA metadata to local config file using retrieved config data
:param remote_config: Downloaded JSON data, not a ConfigParser object!
"""
config['nrfa']['oh_json_url'] = remote_config['nrfa_oh_json_url']
config['nrfa']['version'] = remote_confi... | [
"def",
"_update_nrfa_metadata",
"(",
"remote_config",
")",
":",
"config",
"[",
"'nrfa'",
"]",
"[",
"'oh_json_url'",
"]",
"=",
"remote_config",
"[",
"'nrfa_oh_json_url'",
"]",
"config",
"[",
"'nrfa'",
"]",
"[",
"'version'",
"]",
"=",
"remote_config",
"[",
"'nrf... | Save NRFA metadata to local config file using retrieved config data
:param remote_config: Downloaded JSON data, not a ConfigParser object! | [
"Save",
"NRFA",
"metadata",
"to",
"local",
"config",
"file",
"using",
"retrieved",
"config",
"data"
] | 782da7c5abd1348923129efe89fb70003ebb088c | https://github.com/OpenHydrology/floodestimation/blob/782da7c5abd1348923129efe89fb70003ebb088c/floodestimation/fehdata.py#L122-L134 | train | Update NRFA metadata in local config file using retrieved config data |
OpenHydrology/floodestimation | floodestimation/fehdata.py | nrfa_metadata | def nrfa_metadata():
"""
Return metadata on the NRFA data.
Returned metadata is a dict with the following elements:
- `url`: string with NRFA data download URL
- `version`: string with NRFA version number, e.g. '3.3.4'
- `published_on`: datetime of data release/publication (only month and year... | python | def nrfa_metadata():
"""
Return metadata on the NRFA data.
Returned metadata is a dict with the following elements:
- `url`: string with NRFA data download URL
- `version`: string with NRFA version number, e.g. '3.3.4'
- `published_on`: datetime of data release/publication (only month and year... | [
"def",
"nrfa_metadata",
"(",
")",
":",
"result",
"=",
"{",
"'url'",
":",
"config",
".",
"get",
"(",
"'nrfa'",
",",
"'url'",
",",
"fallback",
"=",
"None",
")",
"or",
"None",
",",
"# Empty strings '' become None",
"'version'",
":",
"config",
".",
"get",
"(... | Return metadata on the NRFA data.
Returned metadata is a dict with the following elements:
- `url`: string with NRFA data download URL
- `version`: string with NRFA version number, e.g. '3.3.4'
- `published_on`: datetime of data release/publication (only month and year are accurate, rest should be ign... | [
"Return",
"metadata",
"on",
"the",
"NRFA",
"data",
"."
] | 782da7c5abd1348923129efe89fb70003ebb088c | https://github.com/OpenHydrology/floodestimation/blob/782da7c5abd1348923129efe89fb70003ebb088c/floodestimation/fehdata.py#L137-L157 | train | Return metadata on the NRFA data. |
OpenHydrology/floodestimation | floodestimation/fehdata.py | unzip_data | def unzip_data():
"""
Extract all files from downloaded FEH data zip file.
"""
with ZipFile(os.path.join(CACHE_FOLDER, CACHE_ZIP), 'r') as zf:
zf.extractall(path=CACHE_FOLDER) | python | def unzip_data():
"""
Extract all files from downloaded FEH data zip file.
"""
with ZipFile(os.path.join(CACHE_FOLDER, CACHE_ZIP), 'r') as zf:
zf.extractall(path=CACHE_FOLDER) | [
"def",
"unzip_data",
"(",
")",
":",
"with",
"ZipFile",
"(",
"os",
".",
"path",
".",
"join",
"(",
"CACHE_FOLDER",
",",
"CACHE_ZIP",
")",
",",
"'r'",
")",
"as",
"zf",
":",
"zf",
".",
"extractall",
"(",
"path",
"=",
"CACHE_FOLDER",
")"
] | Extract all files from downloaded FEH data zip file. | [
"Extract",
"all",
"files",
"from",
"downloaded",
"FEH",
"data",
"zip",
"file",
"."
] | 782da7c5abd1348923129efe89fb70003ebb088c | https://github.com/OpenHydrology/floodestimation/blob/782da7c5abd1348923129efe89fb70003ebb088c/floodestimation/fehdata.py#L160-L165 | train | Extract all files from downloaded FEH data zip file. |
OpenHydrology/floodestimation | floodestimation/fehdata.py | amax_files | def amax_files():
"""
Return all annual maximum flow (`*.am`) files in cache folder and sub folders.
:return: List of file paths
:rtype: list
"""
return [os.path.join(dp, f) for dp, dn, filenames in os.walk(CACHE_FOLDER)
for f in filenames if os.path.splitext(f)[1].lower() == '.am'] | python | def amax_files():
"""
Return all annual maximum flow (`*.am`) files in cache folder and sub folders.
:return: List of file paths
:rtype: list
"""
return [os.path.join(dp, f) for dp, dn, filenames in os.walk(CACHE_FOLDER)
for f in filenames if os.path.splitext(f)[1].lower() == '.am'] | [
"def",
"amax_files",
"(",
")",
":",
"return",
"[",
"os",
".",
"path",
".",
"join",
"(",
"dp",
",",
"f",
")",
"for",
"dp",
",",
"dn",
",",
"filenames",
"in",
"os",
".",
"walk",
"(",
"CACHE_FOLDER",
")",
"for",
"f",
"in",
"filenames",
"if",
"os",
... | Return all annual maximum flow (`*.am`) files in cache folder and sub folders.
:return: List of file paths
:rtype: list | [
"Return",
"all",
"annual",
"maximum",
"flow",
"(",
"*",
".",
"am",
")",
"files",
"in",
"cache",
"folder",
"and",
"sub",
"folders",
"."
] | 782da7c5abd1348923129efe89fb70003ebb088c | https://github.com/OpenHydrology/floodestimation/blob/782da7c5abd1348923129efe89fb70003ebb088c/floodestimation/fehdata.py#L176-L184 | train | Return all annual maximum flow files in cache folder and sub folders. |
acutesoftware/AIKIF | aikif/toolbox/xml_tools.py | get_xml_stats | def get_xml_stats(fname):
"""
return a dictionary of statistics about an
XML file including size in bytes, num lines,
number of elements, count by elements
"""
f = mod_file.TextFile(fname)
res = {}
res['shortname'] = f.name
res['folder'] = f.path
res['filesize'] = str(f.size) + ... | python | def get_xml_stats(fname):
"""
return a dictionary of statistics about an
XML file including size in bytes, num lines,
number of elements, count by elements
"""
f = mod_file.TextFile(fname)
res = {}
res['shortname'] = f.name
res['folder'] = f.path
res['filesize'] = str(f.size) + ... | [
"def",
"get_xml_stats",
"(",
"fname",
")",
":",
"f",
"=",
"mod_file",
".",
"TextFile",
"(",
"fname",
")",
"res",
"=",
"{",
"}",
"res",
"[",
"'shortname'",
"]",
"=",
"f",
".",
"name",
"res",
"[",
"'folder'",
"]",
"=",
"f",
".",
"path",
"res",
"[",... | return a dictionary of statistics about an
XML file including size in bytes, num lines,
number of elements, count by elements | [
"return",
"a",
"dictionary",
"of",
"statistics",
"about",
"an",
"XML",
"file",
"including",
"size",
"in",
"bytes",
"num",
"lines",
"number",
"of",
"elements",
"count",
"by",
"elements"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/toolbox/xml_tools.py#L18-L32 | train | Returns a dictionary of statistics about an
XML file |
acutesoftware/AIKIF | aikif/toolbox/xml_tools.py | make_random_xml_file | def make_random_xml_file(fname, num_elements=200, depth=3):
"""
makes a random xml file mainly for testing the xml_split
"""
with open(fname, 'w') as f:
f.write('<?xml version="1.0" ?>\n<random>\n')
for dep_num, _ in enumerate(range(1,depth)):
f.write(' <depth>\n <content>\n... | python | def make_random_xml_file(fname, num_elements=200, depth=3):
"""
makes a random xml file mainly for testing the xml_split
"""
with open(fname, 'w') as f:
f.write('<?xml version="1.0" ?>\n<random>\n')
for dep_num, _ in enumerate(range(1,depth)):
f.write(' <depth>\n <content>\n... | [
"def",
"make_random_xml_file",
"(",
"fname",
",",
"num_elements",
"=",
"200",
",",
"depth",
"=",
"3",
")",
":",
"with",
"open",
"(",
"fname",
",",
"'w'",
")",
"as",
"f",
":",
"f",
".",
"write",
"(",
"'<?xml version=\"1.0\" ?>\\n<random>\\n'",
")",
"for",
... | makes a random xml file mainly for testing the xml_split | [
"makes",
"a",
"random",
"xml",
"file",
"mainly",
"for",
"testing",
"the",
"xml_split"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/toolbox/xml_tools.py#L34-L48 | train | Makes a random xml file only for testing the xml_split
|
acutesoftware/AIKIF | aikif/toolbox/xml_tools.py | count_elements | def count_elements(fname, element):
"""
returns (511, 35082) for ANC__WhereToHongKong.xml
"""
num = 0
tot = 0
for event, elem in iterparse(fname):
tot += 1
if elem.text != '':
#print(' tag = ', elem.tag)
#print(' event = ', event # always end
... | python | def count_elements(fname, element):
"""
returns (511, 35082) for ANC__WhereToHongKong.xml
"""
num = 0
tot = 0
for event, elem in iterparse(fname):
tot += 1
if elem.text != '':
#print(' tag = ', elem.tag)
#print(' event = ', event # always end
... | [
"def",
"count_elements",
"(",
"fname",
",",
"element",
")",
":",
"num",
"=",
"0",
"tot",
"=",
"0",
"for",
"event",
",",
"elem",
"in",
"iterparse",
"(",
"fname",
")",
":",
"tot",
"+=",
"1",
"if",
"elem",
".",
"text",
"!=",
"''",
":",
"#print(' tag ... | returns (511, 35082) for ANC__WhereToHongKong.xml | [
"returns",
"(",
"511",
"35082",
")",
"for",
"ANC__WhereToHongKong",
".",
"xml"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/toolbox/xml_tools.py#L53-L71 | train | returns ( 511 35082 ) for ANC__WhereToHongKong. xml
returns ( 511 35082 ) for ANC__WhereToHongKong. xml
returns ( 35082 ) for ANC__WhereToHongKong. xml
returns ( 511 35082 ) for ANC__WhereToHongKong. xml
returns ( 511 35082 ) for ANC__WhereToHongKong. xml
|
mpg-age-bioinformatics/AGEpy | AGEpy/kegg.py | organismsKEGG | def organismsKEGG():
"""
Lists all organisms present in the KEGG database.
:returns: a dataframe containing one organism per row.
"""
organisms=urlopen("http://rest.kegg.jp/list/organism").read()
organisms=organisms.split("\n")
#for o in organisms:
# print o
# sys.stdout.flus... | python | def organismsKEGG():
"""
Lists all organisms present in the KEGG database.
:returns: a dataframe containing one organism per row.
"""
organisms=urlopen("http://rest.kegg.jp/list/organism").read()
organisms=organisms.split("\n")
#for o in organisms:
# print o
# sys.stdout.flus... | [
"def",
"organismsKEGG",
"(",
")",
":",
"organisms",
"=",
"urlopen",
"(",
"\"http://rest.kegg.jp/list/organism\"",
")",
".",
"read",
"(",
")",
"organisms",
"=",
"organisms",
".",
"split",
"(",
"\"\\n\"",
")",
"#for o in organisms:",
"# print o",
"# sys.stdout.f... | Lists all organisms present in the KEGG database.
:returns: a dataframe containing one organism per row. | [
"Lists",
"all",
"organisms",
"present",
"in",
"the",
"KEGG",
"database",
"."
] | 887808a7a2c1504f39ce8d8cb36c15c1721cd29f | https://github.com/mpg-age-bioinformatics/AGEpy/blob/887808a7a2c1504f39ce8d8cb36c15c1721cd29f/AGEpy/kegg.py#L19-L33 | train | Lists all organisms present in the KEGG database. |
mpg-age-bioinformatics/AGEpy | AGEpy/kegg.py | databasesKEGG | def databasesKEGG(organism,ens_ids):
"""
Finds KEGG database identifiers for a respective organism given example ensembl ids.
:param organism: an organism as listed in organismsKEGG()
:param ens_ids: a list of ensenbl ids of the respective organism
:returns: nothing if no database was found, or a... | python | def databasesKEGG(organism,ens_ids):
"""
Finds KEGG database identifiers for a respective organism given example ensembl ids.
:param organism: an organism as listed in organismsKEGG()
:param ens_ids: a list of ensenbl ids of the respective organism
:returns: nothing if no database was found, or a... | [
"def",
"databasesKEGG",
"(",
"organism",
",",
"ens_ids",
")",
":",
"all_genes",
"=",
"urlopen",
"(",
"\"http://rest.kegg.jp/list/\"",
"+",
"organism",
")",
".",
"read",
"(",
")",
"all_genes",
"=",
"all_genes",
".",
"split",
"(",
"\"\\n\"",
")",
"dbs",
"=",
... | Finds KEGG database identifiers for a respective organism given example ensembl ids.
:param organism: an organism as listed in organismsKEGG()
:param ens_ids: a list of ensenbl ids of the respective organism
:returns: nothing if no database was found, or a string if a database was found | [
"Finds",
"KEGG",
"database",
"identifiers",
"for",
"a",
"respective",
"organism",
"given",
"example",
"ensembl",
"ids",
"."
] | 887808a7a2c1504f39ce8d8cb36c15c1721cd29f | https://github.com/mpg-age-bioinformatics/AGEpy/blob/887808a7a2c1504f39ce8d8cb36c15c1721cd29f/AGEpy/kegg.py#L36-L80 | train | Finds KEGG - linked databases for a given organism given a list of ensembl ids. |
mpg-age-bioinformatics/AGEpy | AGEpy/kegg.py | ensembl_to_kegg | def ensembl_to_kegg(organism,kegg_db):
"""
Looks up KEGG mappings of KEGG ids to ensembl ids
:param organism: an organisms as listed in organismsKEGG()
:param kegg_db: a matching KEGG db as reported in databasesKEGG
:returns: a Pandas dataframe of with 'KEGGid' and 'ENSid'.
"""
print("KEG... | python | def ensembl_to_kegg(organism,kegg_db):
"""
Looks up KEGG mappings of KEGG ids to ensembl ids
:param organism: an organisms as listed in organismsKEGG()
:param kegg_db: a matching KEGG db as reported in databasesKEGG
:returns: a Pandas dataframe of with 'KEGGid' and 'ENSid'.
"""
print("KEG... | [
"def",
"ensembl_to_kegg",
"(",
"organism",
",",
"kegg_db",
")",
":",
"print",
"(",
"\"KEGG API: http://rest.genome.jp/link/\"",
"+",
"kegg_db",
"+",
"\"/\"",
"+",
"organism",
")",
"sys",
".",
"stdout",
".",
"flush",
"(",
")",
"kegg_ens",
"=",
"urlopen",
"(",
... | Looks up KEGG mappings of KEGG ids to ensembl ids
:param organism: an organisms as listed in organismsKEGG()
:param kegg_db: a matching KEGG db as reported in databasesKEGG
:returns: a Pandas dataframe of with 'KEGGid' and 'ENSid'. | [
"Looks",
"up",
"KEGG",
"mappings",
"of",
"KEGG",
"ids",
"to",
"ensembl",
"ids"
] | 887808a7a2c1504f39ce8d8cb36c15c1721cd29f | https://github.com/mpg-age-bioinformatics/AGEpy/blob/887808a7a2c1504f39ce8d8cb36c15c1721cd29f/AGEpy/kegg.py#L83-L105 | train | Returns a Pandas dataframe of with KEGGid and ENSid. |
mpg-age-bioinformatics/AGEpy | AGEpy/kegg.py | ecs_idsKEGG | def ecs_idsKEGG(organism):
"""
Uses KEGG to retrieve all ids and respective ecs for a given KEGG organism
:param organism: an organisms as listed in organismsKEGG()
:returns: a Pandas dataframe of with 'ec' and 'KEGGid'.
"""
kegg_ec=urlopen("http://rest.kegg.jp/link/"+organism+"/enzyme").read... | python | def ecs_idsKEGG(organism):
"""
Uses KEGG to retrieve all ids and respective ecs for a given KEGG organism
:param organism: an organisms as listed in organismsKEGG()
:returns: a Pandas dataframe of with 'ec' and 'KEGGid'.
"""
kegg_ec=urlopen("http://rest.kegg.jp/link/"+organism+"/enzyme").read... | [
"def",
"ecs_idsKEGG",
"(",
"organism",
")",
":",
"kegg_ec",
"=",
"urlopen",
"(",
"\"http://rest.kegg.jp/link/\"",
"+",
"organism",
"+",
"\"/enzyme\"",
")",
".",
"read",
"(",
")",
"kegg_ec",
"=",
"kegg_ec",
".",
"split",
"(",
"\"\\n\"",
")",
"final",
"=",
"... | Uses KEGG to retrieve all ids and respective ecs for a given KEGG organism
:param organism: an organisms as listed in organismsKEGG()
:returns: a Pandas dataframe of with 'ec' and 'KEGGid'. | [
"Uses",
"KEGG",
"to",
"retrieve",
"all",
"ids",
"and",
"respective",
"ecs",
"for",
"a",
"given",
"KEGG",
"organism"
] | 887808a7a2c1504f39ce8d8cb36c15c1721cd29f | https://github.com/mpg-age-bioinformatics/AGEpy/blob/887808a7a2c1504f39ce8d8cb36c15c1721cd29f/AGEpy/kegg.py#L107-L123 | train | Uses KEGG to retrieve all ids and respective ecs for a given KEGG organism |
mpg-age-bioinformatics/AGEpy | AGEpy/kegg.py | idsKEGG | def idsKEGG(organism):
"""
Uses KEGG to retrieve all ids for a given KEGG organism
:param organism: an organism as listed in organismsKEGG()
:returns: a Pandas dataframe of with 'gene_name' and 'KEGGid'.
"""
ORG=urlopen("http://rest.kegg.jp/list/"+organism).read()
ORG=ORG.split("\n")
... | python | def idsKEGG(organism):
"""
Uses KEGG to retrieve all ids for a given KEGG organism
:param organism: an organism as listed in organismsKEGG()
:returns: a Pandas dataframe of with 'gene_name' and 'KEGGid'.
"""
ORG=urlopen("http://rest.kegg.jp/list/"+organism).read()
ORG=ORG.split("\n")
... | [
"def",
"idsKEGG",
"(",
"organism",
")",
":",
"ORG",
"=",
"urlopen",
"(",
"\"http://rest.kegg.jp/list/\"",
"+",
"organism",
")",
".",
"read",
"(",
")",
"ORG",
"=",
"ORG",
".",
"split",
"(",
"\"\\n\"",
")",
"final",
"=",
"[",
"]",
"for",
"k",
"in",
"OR... | Uses KEGG to retrieve all ids for a given KEGG organism
:param organism: an organism as listed in organismsKEGG()
:returns: a Pandas dataframe of with 'gene_name' and 'KEGGid'. | [
"Uses",
"KEGG",
"to",
"retrieve",
"all",
"ids",
"for",
"a",
"given",
"KEGG",
"organism"
] | 887808a7a2c1504f39ce8d8cb36c15c1721cd29f | https://github.com/mpg-age-bioinformatics/AGEpy/blob/887808a7a2c1504f39ce8d8cb36c15c1721cd29f/AGEpy/kegg.py#L126-L147 | train | Uses KEGG to retrieve all ids for a given KEGG organism |
mpg-age-bioinformatics/AGEpy | AGEpy/kegg.py | pathwaysKEGG | def pathwaysKEGG(organism):
"""
Retrieves all pathways for a given organism.
:param organism: an organism as listed in organismsKEGG()
:returns df: a Pandas dataframe with the columns 'KEGGid','pathIDs', and 'pathName'.
:returns df_: a Pandas dataframe with a columns for 'KEGGid', and one column for... | python | def pathwaysKEGG(organism):
"""
Retrieves all pathways for a given organism.
:param organism: an organism as listed in organismsKEGG()
:returns df: a Pandas dataframe with the columns 'KEGGid','pathIDs', and 'pathName'.
:returns df_: a Pandas dataframe with a columns for 'KEGGid', and one column for... | [
"def",
"pathwaysKEGG",
"(",
"organism",
")",
":",
"print",
"(",
"\"KEGG API: http://rest.kegg.jp/list/pathway/\"",
"+",
"organism",
")",
"sys",
".",
"stdout",
".",
"flush",
"(",
")",
"kegg_paths",
"=",
"urlopen",
"(",
"\"http://rest.kegg.jp/list/pathway/\"",
"+",
"o... | Retrieves all pathways for a given organism.
:param organism: an organism as listed in organismsKEGG()
:returns df: a Pandas dataframe with the columns 'KEGGid','pathIDs', and 'pathName'.
:returns df_: a Pandas dataframe with a columns for 'KEGGid', and one column for each pathway with the corresponding gen... | [
"Retrieves",
"all",
"pathways",
"for",
"a",
"given",
"organism",
".",
":",
"param",
"organism",
":",
"an",
"organism",
"as",
"listed",
"in",
"organismsKEGG",
"()",
":",
"returns",
"df",
":",
"a",
"Pandas",
"dataframe",
"with",
"the",
"columns",
"KEGGid",
"... | 887808a7a2c1504f39ce8d8cb36c15c1721cd29f | https://github.com/mpg-age-bioinformatics/AGEpy/blob/887808a7a2c1504f39ce8d8cb36c15c1721cd29f/AGEpy/kegg.py#L149-L191 | train | Retrieves all pathways for a given organism. |
mpg-age-bioinformatics/AGEpy | AGEpy/kegg.py | biomaRtTOkegg | def biomaRtTOkegg(df):
"""
Transforms a pandas dataframe with the columns 'ensembl_gene_id','kegg_enzyme'
to dataframe ready for use in ...
:param df: a pandas dataframe with the following columns: 'ensembl_gene_id','kegg_enzyme'
:returns: a pandas dataframe with the following columns: 'ensembl_ge... | python | def biomaRtTOkegg(df):
"""
Transforms a pandas dataframe with the columns 'ensembl_gene_id','kegg_enzyme'
to dataframe ready for use in ...
:param df: a pandas dataframe with the following columns: 'ensembl_gene_id','kegg_enzyme'
:returns: a pandas dataframe with the following columns: 'ensembl_ge... | [
"def",
"biomaRtTOkegg",
"(",
"df",
")",
":",
"df",
"=",
"df",
".",
"dropna",
"(",
")",
"ECcols",
"=",
"df",
".",
"columns",
".",
"tolist",
"(",
")",
"df",
".",
"reset_index",
"(",
"inplace",
"=",
"True",
",",
"drop",
"=",
"True",
")",
"# field = EC... | Transforms a pandas dataframe with the columns 'ensembl_gene_id','kegg_enzyme'
to dataframe ready for use in ...
:param df: a pandas dataframe with the following columns: 'ensembl_gene_id','kegg_enzyme'
:returns: a pandas dataframe with the following columns: 'ensembl_gene_id','kegg_enzyme' | [
"Transforms",
"a",
"pandas",
"dataframe",
"with",
"the",
"columns",
"ensembl_gene_id",
"kegg_enzyme",
"to",
"dataframe",
"ready",
"for",
"use",
"in",
"..."
] | 887808a7a2c1504f39ce8d8cb36c15c1721cd29f | https://github.com/mpg-age-bioinformatics/AGEpy/blob/887808a7a2c1504f39ce8d8cb36c15c1721cd29f/AGEpy/kegg.py#L194-L232 | train | Transforms a pandas dataframe with the columns ensembl_gene_id kegg_enzyme to dataframe ready for use in...
|
mpg-age-bioinformatics/AGEpy | AGEpy/kegg.py | expKEGG | def expKEGG(organism,names_KEGGids):
"""
Gets all KEGG pathways for an organism
:param organism: an organism as listed in organismsKEGG()
:param names_KEGGids: a Pandas dataframe with the columns 'gene_name': and 'KEGGid' as reported from idsKEGG(organism) (or a subset of it).
:returns df: a Pand... | python | def expKEGG(organism,names_KEGGids):
"""
Gets all KEGG pathways for an organism
:param organism: an organism as listed in organismsKEGG()
:param names_KEGGids: a Pandas dataframe with the columns 'gene_name': and 'KEGGid' as reported from idsKEGG(organism) (or a subset of it).
:returns df: a Pand... | [
"def",
"expKEGG",
"(",
"organism",
",",
"names_KEGGids",
")",
":",
"#print \"KEGG API: http://rest.kegg.jp/list/pathway/\"+organism",
"#sys.stdout.flush()",
"kegg_paths",
"=",
"urlopen",
"(",
"\"http://rest.kegg.jp/list/pathway/\"",
"+",
"organism",
")",
".",
"read",
"(",
"... | Gets all KEGG pathways for an organism
:param organism: an organism as listed in organismsKEGG()
:param names_KEGGids: a Pandas dataframe with the columns 'gene_name': and 'KEGGid' as reported from idsKEGG(organism) (or a subset of it).
:returns df: a Pandas dataframe with 'KEGGid','pathID(1):pathNAME(1)... | [
"Gets",
"all",
"KEGG",
"pathways",
"for",
"an",
"organism"
] | 887808a7a2c1504f39ce8d8cb36c15c1721cd29f | https://github.com/mpg-age-bioinformatics/AGEpy/blob/887808a7a2c1504f39ce8d8cb36c15c1721cd29f/AGEpy/kegg.py#L236-L287 | train | Retrieves all KEGG pathways for an organism |
mpg-age-bioinformatics/AGEpy | AGEpy/kegg.py | KEGGmatrix | def KEGGmatrix(organism, dataset, query_attributes=['ensembl_gene_id','kegg_enzyme'], host=biomart_host,links=True,dfexp=None,kegg_db=None, database=None ):
"""
Looks for all KEGG annotatios of an organism in biomart and the respective pathways in KEGG. It can also retrieve links to pathways figures with red la... | python | def KEGGmatrix(organism, dataset, query_attributes=['ensembl_gene_id','kegg_enzyme'], host=biomart_host,links=True,dfexp=None,kegg_db=None, database=None ):
"""
Looks for all KEGG annotatios of an organism in biomart and the respective pathways in KEGG. It can also retrieve links to pathways figures with red la... | [
"def",
"KEGGmatrix",
"(",
"organism",
",",
"dataset",
",",
"query_attributes",
"=",
"[",
"'ensembl_gene_id'",
",",
"'kegg_enzyme'",
"]",
",",
"host",
"=",
"biomart_host",
",",
"links",
"=",
"True",
",",
"dfexp",
"=",
"None",
",",
"kegg_db",
"=",
"None",
",... | Looks for all KEGG annotatios of an organism in biomart and the respective pathways in KEGG. It can also retrieve links to pathways figures with red labeled genes provided in a dataframe.
:param organism: a KEGG organism identifier
:param dataset: a biomaRt dataset
:param query_attributes: biomaRt query at... | [
"Looks",
"for",
"all",
"KEGG",
"annotatios",
"of",
"an",
"organism",
"in",
"biomart",
"and",
"the",
"respective",
"pathways",
"in",
"KEGG",
".",
"It",
"can",
"also",
"retrieve",
"links",
"to",
"pathways",
"figures",
"with",
"red",
"labeled",
"genes",
"provid... | 887808a7a2c1504f39ce8d8cb36c15c1721cd29f | https://github.com/mpg-age-bioinformatics/AGEpy/blob/887808a7a2c1504f39ce8d8cb36c15c1721cd29f/AGEpy/kegg.py#L292-L416 | train | Returns a Pandas dataframe with the columns for each KEGG pathway for each organism and the values for each pathways in the KEGG dataset. |
mpg-age-bioinformatics/AGEpy | AGEpy/rbiom.py | RdatabasesBM | def RdatabasesBM(host=rbiomart_host):
"""
Lists BioMart databases through a RPY2 connection.
:param host: address of the host server, default='www.ensembl.org'
:returns: nothing
"""
biomaRt = importr("biomaRt")
print(biomaRt.listMarts(host=host)) | python | def RdatabasesBM(host=rbiomart_host):
"""
Lists BioMart databases through a RPY2 connection.
:param host: address of the host server, default='www.ensembl.org'
:returns: nothing
"""
biomaRt = importr("biomaRt")
print(biomaRt.listMarts(host=host)) | [
"def",
"RdatabasesBM",
"(",
"host",
"=",
"rbiomart_host",
")",
":",
"biomaRt",
"=",
"importr",
"(",
"\"biomaRt\"",
")",
"print",
"(",
"biomaRt",
".",
"listMarts",
"(",
"host",
"=",
"host",
")",
")"
] | Lists BioMart databases through a RPY2 connection.
:param host: address of the host server, default='www.ensembl.org'
:returns: nothing | [
"Lists",
"BioMart",
"databases",
"through",
"a",
"RPY2",
"connection",
"."
] | 887808a7a2c1504f39ce8d8cb36c15c1721cd29f | https://github.com/mpg-age-bioinformatics/AGEpy/blob/887808a7a2c1504f39ce8d8cb36c15c1721cd29f/AGEpy/rbiom.py#L16-L26 | train | Lists BioMart databases through a RPY2 connection. |
mpg-age-bioinformatics/AGEpy | AGEpy/rbiom.py | RdatasetsBM | def RdatasetsBM(database,host=rbiomart_host):
"""
Lists BioMart datasets through a RPY2 connection.
:param database: a database listed in RdatabasesBM()
:param host: address of the host server, default='www.ensembl.org'
:returns: nothing
"""
biomaRt = importr("biomaRt")
ensemblMart=bi... | python | def RdatasetsBM(database,host=rbiomart_host):
"""
Lists BioMart datasets through a RPY2 connection.
:param database: a database listed in RdatabasesBM()
:param host: address of the host server, default='www.ensembl.org'
:returns: nothing
"""
biomaRt = importr("biomaRt")
ensemblMart=bi... | [
"def",
"RdatasetsBM",
"(",
"database",
",",
"host",
"=",
"rbiomart_host",
")",
":",
"biomaRt",
"=",
"importr",
"(",
"\"biomaRt\"",
")",
"ensemblMart",
"=",
"biomaRt",
".",
"useMart",
"(",
"database",
",",
"host",
"=",
"host",
")",
"print",
"(",
"biomaRt",
... | Lists BioMart datasets through a RPY2 connection.
:param database: a database listed in RdatabasesBM()
:param host: address of the host server, default='www.ensembl.org'
:returns: nothing | [
"Lists",
"BioMart",
"datasets",
"through",
"a",
"RPY2",
"connection",
"."
] | 887808a7a2c1504f39ce8d8cb36c15c1721cd29f | https://github.com/mpg-age-bioinformatics/AGEpy/blob/887808a7a2c1504f39ce8d8cb36c15c1721cd29f/AGEpy/rbiom.py#L28-L40 | train | Lists BioMart datasets through a RPY2 connection. |
mpg-age-bioinformatics/AGEpy | AGEpy/rbiom.py | RfiltersBM | def RfiltersBM(dataset,database,host=rbiomart_host):
"""
Lists BioMart filters through a RPY2 connection.
:param dataset: a dataset listed in RdatasetsBM()
:param database: a database listed in RdatabasesBM()
:param host: address of the host server, default='www.ensembl.org'
:returns: nothing
... | python | def RfiltersBM(dataset,database,host=rbiomart_host):
"""
Lists BioMart filters through a RPY2 connection.
:param dataset: a dataset listed in RdatasetsBM()
:param database: a database listed in RdatabasesBM()
:param host: address of the host server, default='www.ensembl.org'
:returns: nothing
... | [
"def",
"RfiltersBM",
"(",
"dataset",
",",
"database",
",",
"host",
"=",
"rbiomart_host",
")",
":",
"biomaRt",
"=",
"importr",
"(",
"\"biomaRt\"",
")",
"ensemblMart",
"=",
"biomaRt",
".",
"useMart",
"(",
"database",
",",
"host",
"=",
"host",
")",
"ensembl",... | Lists BioMart filters through a RPY2 connection.
:param dataset: a dataset listed in RdatasetsBM()
:param database: a database listed in RdatabasesBM()
:param host: address of the host server, default='www.ensembl.org'
:returns: nothing | [
"Lists",
"BioMart",
"filters",
"through",
"a",
"RPY2",
"connection",
"."
] | 887808a7a2c1504f39ce8d8cb36c15c1721cd29f | https://github.com/mpg-age-bioinformatics/AGEpy/blob/887808a7a2c1504f39ce8d8cb36c15c1721cd29f/AGEpy/rbiom.py#L42-L56 | train | Lists BioMart filters through a RPY2 connection. |
mpg-age-bioinformatics/AGEpy | AGEpy/rbiom.py | RattributesBM | def RattributesBM(dataset,database,host=rbiomart_host):
"""
Lists BioMart attributes through a RPY2 connection.
:param dataset: a dataset listed in RdatasetsBM()
:param database: a database listed in RdatabasesBM()
:param host: address of the host server, default='www.ensembl.org'
:returns: no... | python | def RattributesBM(dataset,database,host=rbiomart_host):
"""
Lists BioMart attributes through a RPY2 connection.
:param dataset: a dataset listed in RdatasetsBM()
:param database: a database listed in RdatabasesBM()
:param host: address of the host server, default='www.ensembl.org'
:returns: no... | [
"def",
"RattributesBM",
"(",
"dataset",
",",
"database",
",",
"host",
"=",
"rbiomart_host",
")",
":",
"biomaRt",
"=",
"importr",
"(",
"\"biomaRt\"",
")",
"ensemblMart",
"=",
"biomaRt",
".",
"useMart",
"(",
"database",
",",
"host",
"=",
"rbiomart_host",
")",
... | Lists BioMart attributes through a RPY2 connection.
:param dataset: a dataset listed in RdatasetsBM()
:param database: a database listed in RdatabasesBM()
:param host: address of the host server, default='www.ensembl.org'
:returns: nothing | [
"Lists",
"BioMart",
"attributes",
"through",
"a",
"RPY2",
"connection",
"."
] | 887808a7a2c1504f39ce8d8cb36c15c1721cd29f | https://github.com/mpg-age-bioinformatics/AGEpy/blob/887808a7a2c1504f39ce8d8cb36c15c1721cd29f/AGEpy/rbiom.py#L58-L72 | train | Lists BioMart attributes through a RPY2 connection. |
mpg-age-bioinformatics/AGEpy | AGEpy/rbiom.py | RqueryBM | def RqueryBM(query_filter,query_items,query_attributes,dataset,database,host=rbiomart_host):
"""
Queries BioMart.
:param query_filtery: one BioMart filter associated with the items being queried
:param query_items: list of items to be queried (must assoiate with given filter)
:param query_attribute... | python | def RqueryBM(query_filter,query_items,query_attributes,dataset,database,host=rbiomart_host):
"""
Queries BioMart.
:param query_filtery: one BioMart filter associated with the items being queried
:param query_items: list of items to be queried (must assoiate with given filter)
:param query_attribute... | [
"def",
"RqueryBM",
"(",
"query_filter",
",",
"query_items",
",",
"query_attributes",
",",
"dataset",
",",
"database",
",",
"host",
"=",
"rbiomart_host",
")",
":",
"biomaRt",
"=",
"importr",
"(",
"\"biomaRt\"",
")",
"ensemblMart",
"=",
"biomaRt",
".",
"useMart"... | Queries BioMart.
:param query_filtery: one BioMart filter associated with the items being queried
:param query_items: list of items to be queried (must assoiate with given filter)
:param query_attributes: list of attributes to recover from BioMart
:param dataset: dataset to query
:param database: d... | [
"Queries",
"BioMart",
"."
] | 887808a7a2c1504f39ce8d8cb36c15c1721cd29f | https://github.com/mpg-age-bioinformatics/AGEpy/blob/887808a7a2c1504f39ce8d8cb36c15c1721cd29f/AGEpy/rbiom.py#L74-L96 | train | Queries BioMart.
|
acutesoftware/AIKIF | scripts/examples/document_AIKIF.py | main | def main():
"""
Example of self documenting (of sorts) code, via aikif.
Simply call functions like below to build an overview
which has metadata automatically updated.
"""
fldr = mod_cfg.fldrs['program_path']
p = mod_prg.Programs('AIKIF Programs', fldr)
document_core_programs(p)
do... | python | def main():
"""
Example of self documenting (of sorts) code, via aikif.
Simply call functions like below to build an overview
which has metadata automatically updated.
"""
fldr = mod_cfg.fldrs['program_path']
p = mod_prg.Programs('AIKIF Programs', fldr)
document_core_programs(p)
do... | [
"def",
"main",
"(",
")",
":",
"fldr",
"=",
"mod_cfg",
".",
"fldrs",
"[",
"'program_path'",
"]",
"p",
"=",
"mod_prg",
".",
"Programs",
"(",
"'AIKIF Programs'",
",",
"fldr",
")",
"document_core_programs",
"(",
"p",
")",
"document_agents",
"(",
"p",
")",
"d... | Example of self documenting (of sorts) code, via aikif.
Simply call functions like below to build an overview
which has metadata automatically updated. | [
"Example",
"of",
"self",
"documenting",
"(",
"of",
"sorts",
")",
"code",
"via",
"aikif",
".",
"Simply",
"call",
"functions",
"like",
"below",
"to",
"build",
"an",
"overview",
"which",
"has",
"metadata",
"automatically",
"updated",
"."
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/scripts/examples/document_AIKIF.py#L13-L27 | train | This function is called by the main function of the AIKIF program. |
acutesoftware/AIKIF | scripts/examples/document_AIKIF.py | document_core_programs | def document_core_programs(p):
"""
Document a subset of core programs with purpose (and intent)
"""
p.comment('programs.py', 'collects list of aikif programs to show progress and allows comments to be added to each file')
p.comment('cls_file_mapping.py', 'uses ontology to get list of files to s... | python | def document_core_programs(p):
"""
Document a subset of core programs with purpose (and intent)
"""
p.comment('programs.py', 'collects list of aikif programs to show progress and allows comments to be added to each file')
p.comment('cls_file_mapping.py', 'uses ontology to get list of files to s... | [
"def",
"document_core_programs",
"(",
"p",
")",
":",
"p",
".",
"comment",
"(",
"'programs.py'",
",",
"'collects list of aikif programs to show progress and allows comments to be added to each file'",
")",
"p",
".",
"comment",
"(",
"'cls_file_mapping.py'",
",",
"'uses ontology... | Document a subset of core programs with purpose (and intent) | [
"Document",
"a",
"subset",
"of",
"core",
"programs",
"with",
"purpose",
"(",
"and",
"intent",
")"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/scripts/examples/document_AIKIF.py#L31-L93 | train | Document a subset of core programs |
acutesoftware/AIKIF | scripts/examples/document_AIKIF.py | document_examples | def document_examples(p):
"""
Document example programs with purpose (and intent)
"""
p.comment('maths_ml_algorithms.py', 'machine learning algorithms for toolbox in AIKIF')
p.comment('algebra.py', 'toolbox module for based evaluation of maths problems')
p.comment('crypt_utils.py', 'scripts to e... | python | def document_examples(p):
"""
Document example programs with purpose (and intent)
"""
p.comment('maths_ml_algorithms.py', 'machine learning algorithms for toolbox in AIKIF')
p.comment('algebra.py', 'toolbox module for based evaluation of maths problems')
p.comment('crypt_utils.py', 'scripts to e... | [
"def",
"document_examples",
"(",
"p",
")",
":",
"p",
".",
"comment",
"(",
"'maths_ml_algorithms.py'",
",",
"'machine learning algorithms for toolbox in AIKIF'",
")",
"p",
".",
"comment",
"(",
"'algebra.py'",
",",
"'toolbox module for based evaluation of maths problems'",
")... | Document example programs with purpose (and intent) | [
"Document",
"example",
"programs",
"with",
"purpose",
"(",
"and",
"intent",
")"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/scripts/examples/document_AIKIF.py#L95-L124 | train | Document examples for the AIKIF project |
acutesoftware/AIKIF | scripts/examples/document_AIKIF.py | document_agents | def document_agents(p):
"""
Document agents in AIKIF (purpose and intent)
"""
p.comment('agent.py', 'base agent class')
p.comment('run_agents.py', 'Top level function to run the agents')
p.comment('agent_image_metadata.py', 'agent to collect file picture metadata')
p.comment('agent_lear... | python | def document_agents(p):
"""
Document agents in AIKIF (purpose and intent)
"""
p.comment('agent.py', 'base agent class')
p.comment('run_agents.py', 'Top level function to run the agents')
p.comment('agent_image_metadata.py', 'agent to collect file picture metadata')
p.comment('agent_lear... | [
"def",
"document_agents",
"(",
"p",
")",
":",
"p",
".",
"comment",
"(",
"'agent.py'",
",",
"'base agent class'",
")",
"p",
".",
"comment",
"(",
"'run_agents.py'",
",",
"'Top level function to run the agents'",
")",
"p",
".",
"comment",
"(",
"'agent_image_metadata.... | Document agents in AIKIF (purpose and intent) | [
"Document",
"agents",
"in",
"AIKIF",
"(",
"purpose",
"and",
"intent",
")"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/scripts/examples/document_AIKIF.py#L126-L143 | train | A IKIF Agent Documents |
acutesoftware/AIKIF | scripts/examples/document_AIKIF.py | get_list_of_applications | def get_list_of_applications():
"""
Get list of applications
"""
apps = mod_prg.Programs('Applications', 'C:\\apps')
fl = mod_fl.FileList(['C:\\apps'], ['*.exe'], ["\\bk\\"])
for f in fl.get_list():
apps.add(f, 'autogenerated list')
apps.list()
apps.save() | python | def get_list_of_applications():
"""
Get list of applications
"""
apps = mod_prg.Programs('Applications', 'C:\\apps')
fl = mod_fl.FileList(['C:\\apps'], ['*.exe'], ["\\bk\\"])
for f in fl.get_list():
apps.add(f, 'autogenerated list')
apps.list()
apps.save() | [
"def",
"get_list_of_applications",
"(",
")",
":",
"apps",
"=",
"mod_prg",
".",
"Programs",
"(",
"'Applications'",
",",
"'C:\\\\apps'",
")",
"fl",
"=",
"mod_fl",
".",
"FileList",
"(",
"[",
"'C:\\\\apps'",
"]",
",",
"[",
"'*.exe'",
"]",
",",
"[",
"\"\\\\bk\\... | Get list of applications | [
"Get",
"list",
"of",
"applications"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/scripts/examples/document_AIKIF.py#L147-L156 | train | Get list of applications |
cox-labs/perseuspy | perseuspy/parameters.py | _simple_string_value | def _simple_string_value(tree, kind, name):
""" base function for extracting a simple parameter value.
:param tree: the parameters tree.
:param kind: the xml-tag name of the parameter.
:param name: the name of the parameter.
:returns value: the content of the parameter 'Value' as string."""
quer... | python | def _simple_string_value(tree, kind, name):
""" base function for extracting a simple parameter value.
:param tree: the parameters tree.
:param kind: the xml-tag name of the parameter.
:param name: the name of the parameter.
:returns value: the content of the parameter 'Value' as string."""
quer... | [
"def",
"_simple_string_value",
"(",
"tree",
",",
"kind",
",",
"name",
")",
":",
"query",
"=",
"\".//{kind}[@Name='{name}']/Value\"",
".",
"format",
"(",
"kind",
"=",
"kind",
",",
"name",
"=",
"name",
")",
"return",
"tree",
".",
"find",
"(",
"query",
")",
... | base function for extracting a simple parameter value.
:param tree: the parameters tree.
:param kind: the xml-tag name of the parameter.
:param name: the name of the parameter.
:returns value: the content of the parameter 'Value' as string. | [
"base",
"function",
"for",
"extracting",
"a",
"simple",
"parameter",
"value",
".",
":",
"param",
"tree",
":",
"the",
"parameters",
"tree",
".",
":",
"param",
"kind",
":",
"the",
"xml",
"-",
"tag",
"name",
"of",
"the",
"parameter",
".",
":",
"param",
"n... | 3809c1bd46512605f9e7ca7f97e026e4940ed604 | https://github.com/cox-labs/perseuspy/blob/3809c1bd46512605f9e7ca7f97e026e4940ed604/perseuspy/parameters.py#L15-L22 | train | base function for extracting a simple parameter value. |
cox-labs/perseuspy | perseuspy/parameters.py | boolParam | def boolParam(parameters, name):
""" boolean parameter value.
:param parameters: the parameters tree.
:param name: the name of the parameter. """
value = _simple_string_value(parameters, 'BoolParam', name)
if value not in {'true', 'false'}:
raise ValueError('BoolParam Value has to be either... | python | def boolParam(parameters, name):
""" boolean parameter value.
:param parameters: the parameters tree.
:param name: the name of the parameter. """
value = _simple_string_value(parameters, 'BoolParam', name)
if value not in {'true', 'false'}:
raise ValueError('BoolParam Value has to be either... | [
"def",
"boolParam",
"(",
"parameters",
",",
"name",
")",
":",
"value",
"=",
"_simple_string_value",
"(",
"parameters",
",",
"'BoolParam'",
",",
"name",
")",
"if",
"value",
"not",
"in",
"{",
"'true'",
",",
"'false'",
"}",
":",
"raise",
"ValueError",
"(",
... | boolean parameter value.
:param parameters: the parameters tree.
:param name: the name of the parameter. | [
"boolean",
"parameter",
"value",
".",
":",
"param",
"parameters",
":",
"the",
"parameters",
"tree",
".",
":",
"param",
"name",
":",
"the",
"name",
"of",
"the",
"parameter",
"."
] | 3809c1bd46512605f9e7ca7f97e026e4940ed604 | https://github.com/cox-labs/perseuspy/blob/3809c1bd46512605f9e7ca7f97e026e4940ed604/perseuspy/parameters.py#L42-L49 | train | Returns the value of a boolean parameter. |
cox-labs/perseuspy | perseuspy/parameters.py | singleChoiceParam | def singleChoiceParam(parameters, name, type_converter = str):
""" single choice parameter value. Returns -1 if no value was chosen.
:param parameters: the parameters tree.
:param name: the name of the parameter.
:param type_converter: function to convert the chosen value to a different type (e.g. str, ... | python | def singleChoiceParam(parameters, name, type_converter = str):
""" single choice parameter value. Returns -1 if no value was chosen.
:param parameters: the parameters tree.
:param name: the name of the parameter.
:param type_converter: function to convert the chosen value to a different type (e.g. str, ... | [
"def",
"singleChoiceParam",
"(",
"parameters",
",",
"name",
",",
"type_converter",
"=",
"str",
")",
":",
"param",
"=",
"parameters",
".",
"find",
"(",
"\".//SingleChoiceParam[@Name='{name}']\"",
".",
"format",
"(",
"name",
"=",
"name",
")",
")",
"value",
"=",
... | single choice parameter value. Returns -1 if no value was chosen.
:param parameters: the parameters tree.
:param name: the name of the parameter.
:param type_converter: function to convert the chosen value to a different type (e.g. str, float, int). default = 'str | [
"single",
"choice",
"parameter",
"value",
".",
"Returns",
"-",
"1",
"if",
"no",
"value",
"was",
"chosen",
".",
":",
"param",
"parameters",
":",
"the",
"parameters",
"tree",
".",
":",
"param",
"name",
":",
"the",
"name",
"of",
"the",
"parameter",
".",
"... | 3809c1bd46512605f9e7ca7f97e026e4940ed604 | https://github.com/cox-labs/perseuspy/blob/3809c1bd46512605f9e7ca7f97e026e4940ed604/perseuspy/parameters.py#L57-L67 | train | returns the value of a single choice parameter. Returns - 1 if no value was chosen. |
cox-labs/perseuspy | perseuspy/parameters.py | multiChoiceParam | def multiChoiceParam(parameters, name, type_converter = str):
""" multi choice parameter values.
:param parameters: the parameters tree.
:param name: the name of the parameter.
:param type_converter: function to convert the chosen value to a different type (e.g. str, float, int). default = 'str'
:re... | python | def multiChoiceParam(parameters, name, type_converter = str):
""" multi choice parameter values.
:param parameters: the parameters tree.
:param name: the name of the parameter.
:param type_converter: function to convert the chosen value to a different type (e.g. str, float, int). default = 'str'
:re... | [
"def",
"multiChoiceParam",
"(",
"parameters",
",",
"name",
",",
"type_converter",
"=",
"str",
")",
":",
"param",
"=",
"parameters",
".",
"find",
"(",
"\".//MultiChoiceParam[@Name='{name}']\"",
".",
"format",
"(",
"name",
"=",
"name",
")",
")",
"value",
"=",
... | multi choice parameter values.
:param parameters: the parameters tree.
:param name: the name of the parameter.
:param type_converter: function to convert the chosen value to a different type (e.g. str, float, int). default = 'str'
:returns dictionary: value -> values | [
"multi",
"choice",
"parameter",
"values",
".",
":",
"param",
"parameters",
":",
"the",
"parameters",
"tree",
".",
":",
"param",
"name",
":",
"the",
"name",
"of",
"the",
"parameter",
".",
":",
"param",
"type_converter",
":",
"function",
"to",
"convert",
"th... | 3809c1bd46512605f9e7ca7f97e026e4940ed604 | https://github.com/cox-labs/perseuspy/blob/3809c1bd46512605f9e7ca7f97e026e4940ed604/perseuspy/parameters.py#L69-L79 | train | returns the value of a multi choice parameter. |
cox-labs/perseuspy | perseuspy/parameters.py | boolWithSubParams | def boolWithSubParams(parameters, name):
""" single choice with sub parameters value and chosen subparameters. Returns -1 and None if no value was chosen.
:param parameters: the parameters tree.
:param name: the name of the parameter.
"""
param = parameters.find(".//BoolWithSubParams[@Name='{name}']... | python | def boolWithSubParams(parameters, name):
""" single choice with sub parameters value and chosen subparameters. Returns -1 and None if no value was chosen.
:param parameters: the parameters tree.
:param name: the name of the parameter.
"""
param = parameters.find(".//BoolWithSubParams[@Name='{name}']... | [
"def",
"boolWithSubParams",
"(",
"parameters",
",",
"name",
")",
":",
"param",
"=",
"parameters",
".",
"find",
"(",
"\".//BoolWithSubParams[@Name='{name}']\"",
".",
"format",
"(",
"name",
"=",
"name",
")",
")",
"str_value",
"=",
"param",
".",
"find",
"(",
"'... | single choice with sub parameters value and chosen subparameters. Returns -1 and None if no value was chosen.
:param parameters: the parameters tree.
:param name: the name of the parameter. | [
"single",
"choice",
"with",
"sub",
"parameters",
"value",
"and",
"chosen",
"subparameters",
".",
"Returns",
"-",
"1",
"and",
"None",
"if",
"no",
"value",
"was",
"chosen",
".",
":",
"param",
"parameters",
":",
"the",
"parameters",
"tree",
".",
":",
"param",... | 3809c1bd46512605f9e7ca7f97e026e4940ed604 | https://github.com/cox-labs/perseuspy/blob/3809c1bd46512605f9e7ca7f97e026e4940ed604/perseuspy/parameters.py#L93-L104 | train | single choice with sub parameters value and chosen subparameters. Returns - 1 and None if no value was chosen. Returns - 1 and None if no value was chosen. |
Timusan/wtforms-dynamic-fields | wtforms_dynamic_fields/wtforms_dynamic_fields.py | WTFormsDynamicFields.add_field | def add_field(self, name, label, field_type, *args, **kwargs):
""" Add the field to the internal configuration dictionary. """
if name in self._dyn_fields:
raise AttributeError('Field already added to the form.')
else:
self._dyn_fields[name] = {'label': label, 'type': fie... | python | def add_field(self, name, label, field_type, *args, **kwargs):
""" Add the field to the internal configuration dictionary. """
if name in self._dyn_fields:
raise AttributeError('Field already added to the form.')
else:
self._dyn_fields[name] = {'label': label, 'type': fie... | [
"def",
"add_field",
"(",
"self",
",",
"name",
",",
"label",
",",
"field_type",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"name",
"in",
"self",
".",
"_dyn_fields",
":",
"raise",
"AttributeError",
"(",
"'Field already added to the form.'",
"... | Add the field to the internal configuration dictionary. | [
"Add",
"the",
"field",
"to",
"the",
"internal",
"configuration",
"dictionary",
"."
] | d984a646075219a6f8a0e931c96035ca3e44be56 | https://github.com/Timusan/wtforms-dynamic-fields/blob/d984a646075219a6f8a0e931c96035ca3e44be56/wtforms_dynamic_fields/wtforms_dynamic_fields.py#L44-L50 | train | Add a field to the internal configuration dictionary. |
Timusan/wtforms-dynamic-fields | wtforms_dynamic_fields/wtforms_dynamic_fields.py | WTFormsDynamicFields.add_validator | def add_validator(self, name, validator, *args, **kwargs):
""" Add the validator to the internal configuration dictionary.
:param name:
The field machine name to apply the validator on
:param validator:
The WTForms validator object
The rest are optional arguments... | python | def add_validator(self, name, validator, *args, **kwargs):
""" Add the validator to the internal configuration dictionary.
:param name:
The field machine name to apply the validator on
:param validator:
The WTForms validator object
The rest are optional arguments... | [
"def",
"add_validator",
"(",
"self",
",",
"name",
",",
"validator",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"name",
"in",
"self",
".",
"_dyn_fields",
":",
"if",
"'validators'",
"in",
"self",
".",
"_dyn_fields",
"[",
"name",
"]",
":... | Add the validator to the internal configuration dictionary.
:param name:
The field machine name to apply the validator on
:param validator:
The WTForms validator object
The rest are optional arguments and keyword arguments that
belong to the validator. We let the... | [
"Add",
"the",
"validator",
"to",
"the",
"internal",
"configuration",
"dictionary",
"."
] | d984a646075219a6f8a0e931c96035ca3e44be56 | https://github.com/Timusan/wtforms-dynamic-fields/blob/d984a646075219a6f8a0e931c96035ca3e44be56/wtforms_dynamic_fields/wtforms_dynamic_fields.py#L52-L76 | train | Adds the validator to the internal configuration dictionary. |
Timusan/wtforms-dynamic-fields | wtforms_dynamic_fields/wtforms_dynamic_fields.py | WTFormsDynamicFields.process | def process(self, form, post):
""" Process the given WTForm Form object.
Itterate over the POST values and check each field
against the configuration that was made.
For each field that is valid, check all the validator
parameters for possible %field% replacement, then bind
... | python | def process(self, form, post):
""" Process the given WTForm Form object.
Itterate over the POST values and check each field
against the configuration that was made.
For each field that is valid, check all the validator
parameters for possible %field% replacement, then bind
... | [
"def",
"process",
"(",
"self",
",",
"form",
",",
"post",
")",
":",
"if",
"not",
"isinstance",
"(",
"form",
",",
"FormMeta",
")",
":",
"raise",
"TypeError",
"(",
"'Given form is not a valid WTForm.'",
")",
"re_field_name",
"=",
"re",
".",
"compile",
"(",
"r... | Process the given WTForm Form object.
Itterate over the POST values and check each field
against the configuration that was made.
For each field that is valid, check all the validator
parameters for possible %field% replacement, then bind
these parameters to their validator.
... | [
"Process",
"the",
"given",
"WTForm",
"Form",
"object",
"."
] | d984a646075219a6f8a0e931c96035ca3e44be56 | https://github.com/Timusan/wtforms-dynamic-fields/blob/d984a646075219a6f8a0e931c96035ca3e44be56/wtforms_dynamic_fields/wtforms_dynamic_fields.py#L90-L214 | train | Process the given WTForm Form object and the POST values. |
mpg-age-bioinformatics/AGEpy | AGEpy/bed.py | GetBEDnarrowPeakgz | def GetBEDnarrowPeakgz(URL_or_PATH_TO_file):
"""
Reads a gz compressed BED narrow peak file from a web address or local file
:param URL_or_PATH_TO_file: web address of path to local file
:returns: a Pandas dataframe
"""
if os.path.isfile(URL_or_PATH_TO_file):
response=open(URL_or_PATH... | python | def GetBEDnarrowPeakgz(URL_or_PATH_TO_file):
"""
Reads a gz compressed BED narrow peak file from a web address or local file
:param URL_or_PATH_TO_file: web address of path to local file
:returns: a Pandas dataframe
"""
if os.path.isfile(URL_or_PATH_TO_file):
response=open(URL_or_PATH... | [
"def",
"GetBEDnarrowPeakgz",
"(",
"URL_or_PATH_TO_file",
")",
":",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"URL_or_PATH_TO_file",
")",
":",
"response",
"=",
"open",
"(",
"URL_or_PATH_TO_file",
",",
"\"r\"",
")",
"compressedFile",
"=",
"StringIO",
".",
"St... | Reads a gz compressed BED narrow peak file from a web address or local file
:param URL_or_PATH_TO_file: web address of path to local file
:returns: a Pandas dataframe | [
"Reads",
"a",
"gz",
"compressed",
"BED",
"narrow",
"peak",
"file",
"from",
"a",
"web",
"address",
"or",
"local",
"file"
] | 887808a7a2c1504f39ce8d8cb36c15c1721cd29f | https://github.com/mpg-age-bioinformatics/AGEpy/blob/887808a7a2c1504f39ce8d8cb36c15c1721cd29f/AGEpy/bed.py#L30-L53 | train | Reads a gz compressed BED narrow peak file from a web address or local file. |
mpg-age-bioinformatics/AGEpy | AGEpy/bed.py | dfTObedtool | def dfTObedtool(df):
"""
Transforms a pandas dataframe into a bedtool
:param df: Pandas dataframe
:returns: a bedtool
"""
df=df.astype(str)
df=df.drop_duplicates()
df=df.values.tolist()
df=["\t".join(s) for s in df ]
df="\n".join(df)
df=BedTool(df, from_string=True)
re... | python | def dfTObedtool(df):
"""
Transforms a pandas dataframe into a bedtool
:param df: Pandas dataframe
:returns: a bedtool
"""
df=df.astype(str)
df=df.drop_duplicates()
df=df.values.tolist()
df=["\t".join(s) for s in df ]
df="\n".join(df)
df=BedTool(df, from_string=True)
re... | [
"def",
"dfTObedtool",
"(",
"df",
")",
":",
"df",
"=",
"df",
".",
"astype",
"(",
"str",
")",
"df",
"=",
"df",
".",
"drop_duplicates",
"(",
")",
"df",
"=",
"df",
".",
"values",
".",
"tolist",
"(",
")",
"df",
"=",
"[",
"\"\\t\"",
".",
"join",
"(",... | Transforms a pandas dataframe into a bedtool
:param df: Pandas dataframe
:returns: a bedtool | [
"Transforms",
"a",
"pandas",
"dataframe",
"into",
"a",
"bedtool"
] | 887808a7a2c1504f39ce8d8cb36c15c1721cd29f | https://github.com/mpg-age-bioinformatics/AGEpy/blob/887808a7a2c1504f39ce8d8cb36c15c1721cd29f/AGEpy/bed.py#L55-L70 | train | Transforms a pandas dataframe into a bedtool
|
mpg-age-bioinformatics/AGEpy | AGEpy/bed.py | GetPeaksExons | def GetPeaksExons(bed,parsedGTF):
"""
Annotates a bedtool, BED narrow peak
:param bed: a pandas dataframe in bed format
:param parsedGTF: a parsed GTF file as outputed by parseGTF() with the following columns
:returns: a Pandas dataframe
"""
bedtool_AB=dfTObedtool(bed)
exonsGTF=parse... | python | def GetPeaksExons(bed,parsedGTF):
"""
Annotates a bedtool, BED narrow peak
:param bed: a pandas dataframe in bed format
:param parsedGTF: a parsed GTF file as outputed by parseGTF() with the following columns
:returns: a Pandas dataframe
"""
bedtool_AB=dfTObedtool(bed)
exonsGTF=parse... | [
"def",
"GetPeaksExons",
"(",
"bed",
",",
"parsedGTF",
")",
":",
"bedtool_AB",
"=",
"dfTObedtool",
"(",
"bed",
")",
"exonsGTF",
"=",
"parsedGTF",
"[",
"parsedGTF",
"[",
"\"feature\"",
"]",
"==",
"\"exon\"",
"]",
"exonsGTF",
".",
"reset_index",
"(",
"inplace",... | Annotates a bedtool, BED narrow peak
:param bed: a pandas dataframe in bed format
:param parsedGTF: a parsed GTF file as outputed by parseGTF() with the following columns
:returns: a Pandas dataframe | [
"Annotates",
"a",
"bedtool",
"BED",
"narrow",
"peak"
] | 887808a7a2c1504f39ce8d8cb36c15c1721cd29f | https://github.com/mpg-age-bioinformatics/AGEpy/blob/887808a7a2c1504f39ce8d8cb36c15c1721cd29f/AGEpy/bed.py#L72-L192 | train | Returns a pandas dataframe with the number of exons in a narrow peak. |
mpg-age-bioinformatics/AGEpy | AGEpy/bed.py | AnnotateBED | def AnnotateBED(bed, GTF, genome_file, bedcols=None, promoter=[1000,200]):
"""
Annotates a bed file.
:param bed: either a /path/to/file.bed or a Pandas dataframe in bed format. /path/to/file.bed implies bedcols.
:param GTF: /path/to/file.gtf
:param genome_file: /path/to/file.genome - a tab separate... | python | def AnnotateBED(bed, GTF, genome_file, bedcols=None, promoter=[1000,200]):
"""
Annotates a bed file.
:param bed: either a /path/to/file.bed or a Pandas dataframe in bed format. /path/to/file.bed implies bedcols.
:param GTF: /path/to/file.gtf
:param genome_file: /path/to/file.genome - a tab separate... | [
"def",
"AnnotateBED",
"(",
"bed",
",",
"GTF",
",",
"genome_file",
",",
"bedcols",
"=",
"None",
",",
"promoter",
"=",
"[",
"1000",
",",
"200",
"]",
")",
":",
"if",
"type",
"(",
"bed",
")",
"==",
"type",
"(",
"\"string\"",
")",
":",
"bed",
"=",
"pd... | Annotates a bed file.
:param bed: either a /path/to/file.bed or a Pandas dataframe in bed format. /path/to/file.bed implies bedcols.
:param GTF: /path/to/file.gtf
:param genome_file: /path/to/file.genome - a tab separated values of chr name and size information
:param bedcols: a comma separated string ... | [
"Annotates",
"a",
"bed",
"file",
"."
] | 887808a7a2c1504f39ce8d8cb36c15c1721cd29f | https://github.com/mpg-age-bioinformatics/AGEpy/blob/887808a7a2c1504f39ce8d8cb36c15c1721cd29f/AGEpy/bed.py#L194-L369 | train | Annotate a BED file with a promoter region. |
Nachtfeuer/pipeline | spline/tools/event.py | Event.configure | def configure(**kwargs):
"""Global configuration for event handling."""
for key in kwargs:
if key == 'is_logging_enabled':
Event.is_logging_enabled = kwargs[key]
elif key == 'collector_queue':
Event.collector_queue = kwargs[key]
else:
... | python | def configure(**kwargs):
"""Global configuration for event handling."""
for key in kwargs:
if key == 'is_logging_enabled':
Event.is_logging_enabled = kwargs[key]
elif key == 'collector_queue':
Event.collector_queue = kwargs[key]
else:
... | [
"def",
"configure",
"(",
"*",
"*",
"kwargs",
")",
":",
"for",
"key",
"in",
"kwargs",
":",
"if",
"key",
"==",
"'is_logging_enabled'",
":",
"Event",
".",
"is_logging_enabled",
"=",
"kwargs",
"[",
"key",
"]",
"elif",
"key",
"==",
"'collector_queue'",
":",
"... | Global configuration for event handling. | [
"Global",
"configuration",
"for",
"event",
"handling",
"."
] | 04ca18c4e95e4349532bb45b768206393e1f2c13 | https://github.com/Nachtfeuer/pipeline/blob/04ca18c4e95e4349532bb45b768206393e1f2c13/spline/tools/event.py#L46-L55 | train | Global configuration for event handling. |
Nachtfeuer/pipeline | spline/tools/event.py | Event.delegate | def delegate(self, success, **kwargs):
"""Delegate success/failure to the right method."""
if success:
self.succeeded(**kwargs)
else:
self.failed(**kwargs) | python | def delegate(self, success, **kwargs):
"""Delegate success/failure to the right method."""
if success:
self.succeeded(**kwargs)
else:
self.failed(**kwargs) | [
"def",
"delegate",
"(",
"self",
",",
"success",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"success",
":",
"self",
".",
"succeeded",
"(",
"*",
"*",
"kwargs",
")",
"else",
":",
"self",
".",
"failed",
"(",
"*",
"*",
"kwargs",
")"
] | Delegate success/failure to the right method. | [
"Delegate",
"success",
"/",
"failure",
"to",
"the",
"right",
"method",
"."
] | 04ca18c4e95e4349532bb45b768206393e1f2c13 | https://github.com/Nachtfeuer/pipeline/blob/04ca18c4e95e4349532bb45b768206393e1f2c13/spline/tools/event.py#L62-L67 | train | Delegate success or failure to the right method. |
Nachtfeuer/pipeline | spline/tools/event.py | Event.failed | def failed(self, **kwargs):
"""Finish event as failed with optional additional information."""
self.finished = datetime.now()
self.status = 'failed'
self.information.update(kwargs)
self.logger.info("Failed - took %f seconds.", self.duration())
self.update_report_collector... | python | def failed(self, **kwargs):
"""Finish event as failed with optional additional information."""
self.finished = datetime.now()
self.status = 'failed'
self.information.update(kwargs)
self.logger.info("Failed - took %f seconds.", self.duration())
self.update_report_collector... | [
"def",
"failed",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"finished",
"=",
"datetime",
".",
"now",
"(",
")",
"self",
".",
"status",
"=",
"'failed'",
"self",
".",
"information",
".",
"update",
"(",
"kwargs",
")",
"self",
".",
"lo... | Finish event as failed with optional additional information. | [
"Finish",
"event",
"as",
"failed",
"with",
"optional",
"additional",
"information",
"."
] | 04ca18c4e95e4349532bb45b768206393e1f2c13 | https://github.com/Nachtfeuer/pipeline/blob/04ca18c4e95e4349532bb45b768206393e1f2c13/spline/tools/event.py#L69-L75 | train | Finish event as failed with optional additional information. |
Nachtfeuer/pipeline | spline/tools/event.py | Event.update_report_collector | def update_report_collector(self, timestamp):
"""Updating report collector for pipeline details."""
report_enabled = 'report' in self.information and self.information['report'] == 'html'
report_enabled = report_enabled and 'stage' in self.information
report_enabled = report_enabled and E... | python | def update_report_collector(self, timestamp):
"""Updating report collector for pipeline details."""
report_enabled = 'report' in self.information and self.information['report'] == 'html'
report_enabled = report_enabled and 'stage' in self.information
report_enabled = report_enabled and E... | [
"def",
"update_report_collector",
"(",
"self",
",",
"timestamp",
")",
":",
"report_enabled",
"=",
"'report'",
"in",
"self",
".",
"information",
"and",
"self",
".",
"information",
"[",
"'report'",
"]",
"==",
"'html'",
"report_enabled",
"=",
"report_enabled",
"and... | Updating report collector for pipeline details. | [
"Updating",
"report",
"collector",
"for",
"pipeline",
"details",
"."
] | 04ca18c4e95e4349532bb45b768206393e1f2c13 | https://github.com/Nachtfeuer/pipeline/blob/04ca18c4e95e4349532bb45b768206393e1f2c13/spline/tools/event.py#L89-L102 | train | Updates the report collector for the pipeline details. |
mpg-age-bioinformatics/AGEpy | AGEpy/go.py | getGeneAssociation | def getGeneAssociation(URL_or_file):
"""
This function collects GO annotation from http://geneontology.org/page/download-annotations.
:param URL_or_file: either a link to a file on geneontology.org eg. http://geneontology.org/gene-associations/gene_association.fb.gz or the path for the respective downlode... | python | def getGeneAssociation(URL_or_file):
"""
This function collects GO annotation from http://geneontology.org/page/download-annotations.
:param URL_or_file: either a link to a file on geneontology.org eg. http://geneontology.org/gene-associations/gene_association.fb.gz or the path for the respective downlode... | [
"def",
"getGeneAssociation",
"(",
"URL_or_file",
")",
":",
"if",
"URL_or_file",
"[",
":",
"4",
"]",
"==",
"\"http\"",
":",
"response",
"=",
"urllib2",
".",
"urlopen",
"(",
"URL_or_file",
")",
"compressedFile",
"=",
"StringIO",
".",
"StringIO",
"(",
"response... | This function collects GO annotation from http://geneontology.org/page/download-annotations.
:param URL_or_file: either a link to a file on geneontology.org eg. http://geneontology.org/gene-associations/gene_association.fb.gz or the path for the respective downloded .gz file.
:returns: a Pandas dataframe with... | [
"This",
"function",
"collects",
"GO",
"annotation",
"from",
"http",
":",
"//",
"geneontology",
".",
"org",
"/",
"page",
"/",
"download",
"-",
"annotations",
"."
] | 887808a7a2c1504f39ce8d8cb36c15c1721cd29f | https://github.com/mpg-age-bioinformatics/AGEpy/blob/887808a7a2c1504f39ce8d8cb36c15c1721cd29f/AGEpy/go.py#L10-L63 | train | This function collects GO associations from the geneontology. org page. |
acutesoftware/AIKIF | aikif/toolbox/sql_tools.py | count_lines_in_file | def count_lines_in_file(src_file ):
"""
test function.
"""
tot = 0
res = ''
try:
with open(src_file, 'r') as f:
for line in f:
tot += 1
res = str(tot) + ' recs read'
except:
res = 'ERROR -couldnt open file'
return res | python | def count_lines_in_file(src_file ):
"""
test function.
"""
tot = 0
res = ''
try:
with open(src_file, 'r') as f:
for line in f:
tot += 1
res = str(tot) + ' recs read'
except:
res = 'ERROR -couldnt open file'
return res | [
"def",
"count_lines_in_file",
"(",
"src_file",
")",
":",
"tot",
"=",
"0",
"res",
"=",
"''",
"try",
":",
"with",
"open",
"(",
"src_file",
",",
"'r'",
")",
"as",
"f",
":",
"for",
"line",
"in",
"f",
":",
"tot",
"+=",
"1",
"res",
"=",
"str",
"(",
"... | test function. | [
"test",
"function",
"."
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/toolbox/sql_tools.py#L10-L23 | train | test function. |
acutesoftware/AIKIF | aikif/toolbox/sql_tools.py | load_txt_to_sql | def load_txt_to_sql(tbl_name, src_file_and_path, src_file, op_folder):
"""
creates a SQL loader script to load a text file into a database
and then executes it.
Note that src_file is
"""
if op_folder == '':
pth = ''
else:
pth = op_folder + os.sep
fname_create_script... | python | def load_txt_to_sql(tbl_name, src_file_and_path, src_file, op_folder):
"""
creates a SQL loader script to load a text file into a database
and then executes it.
Note that src_file is
"""
if op_folder == '':
pth = ''
else:
pth = op_folder + os.sep
fname_create_script... | [
"def",
"load_txt_to_sql",
"(",
"tbl_name",
",",
"src_file_and_path",
",",
"src_file",
",",
"op_folder",
")",
":",
"if",
"op_folder",
"==",
"''",
":",
"pth",
"=",
"''",
"else",
":",
"pth",
"=",
"op_folder",
"+",
"os",
".",
"sep",
"fname_create_script",
"=",... | creates a SQL loader script to load a text file into a database
and then executes it.
Note that src_file is | [
"creates",
"a",
"SQL",
"loader",
"script",
"to",
"load",
"a",
"text",
"file",
"into",
"a",
"database",
"and",
"then",
"executes",
"it",
".",
"Note",
"that",
"src_file",
"is"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/toolbox/sql_tools.py#L26-L44 | train | Loads a text file into a database and executes it. |
acutesoftware/AIKIF | aikif/toolbox/sql_tools.py | create_CTL | def create_CTL(fname, tbl_name, col_list, TRUNC_OR_APPEND, delim=','):
"""
create_CTL(fname_control_file, tbl_name, src_file, cols, 'TRUNCATE')
"""
with open(fname, 'w') as ct:
ct.write('LOAD DATA\n')
ct.write(TRUNC_OR_APPEND + '\n')
ct.write('into table ' + tbl_name + '\n')
... | python | def create_CTL(fname, tbl_name, col_list, TRUNC_OR_APPEND, delim=','):
"""
create_CTL(fname_control_file, tbl_name, src_file, cols, 'TRUNCATE')
"""
with open(fname, 'w') as ct:
ct.write('LOAD DATA\n')
ct.write(TRUNC_OR_APPEND + '\n')
ct.write('into table ' + tbl_name + '\n')
... | [
"def",
"create_CTL",
"(",
"fname",
",",
"tbl_name",
",",
"col_list",
",",
"TRUNC_OR_APPEND",
",",
"delim",
"=",
"','",
")",
":",
"with",
"open",
"(",
"fname",
",",
"'w'",
")",
"as",
"ct",
":",
"ct",
".",
"write",
"(",
"'LOAD DATA\\n'",
")",
"ct",
"."... | create_CTL(fname_control_file, tbl_name, src_file, cols, 'TRUNCATE') | [
"create_CTL",
"(",
"fname_control_file",
"tbl_name",
"src_file",
"cols",
"TRUNCATE",
")"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/toolbox/sql_tools.py#L72-L85 | train | Create a new control file in the specified table. |
asyncdef/aitertools | aitertools/__init__.py | aiter | async def aiter(*args):
"""Return an iterator object.
Args:
obj: An object that implements the __iter__ or __aiter__ method.
sentinel: An optional sentinel value to look for while iterator.
Return:
iterable: Some iterable that provides a __anext__ method.
Raises:
TypeE... | python | async def aiter(*args):
"""Return an iterator object.
Args:
obj: An object that implements the __iter__ or __aiter__ method.
sentinel: An optional sentinel value to look for while iterator.
Return:
iterable: Some iterable that provides a __anext__ method.
Raises:
TypeE... | [
"async",
"def",
"aiter",
"(",
"*",
"args",
")",
":",
"if",
"not",
"args",
":",
"raise",
"TypeError",
"(",
"'aiter() expected at least 1 arguments, got 0'",
")",
"if",
"len",
"(",
"args",
")",
">",
"2",
":",
"raise",
"TypeError",
"(",
"'aiter() expected at most... | Return an iterator object.
Args:
obj: An object that implements the __iter__ or __aiter__ method.
sentinel: An optional sentinel value to look for while iterator.
Return:
iterable: Some iterable that provides a __anext__ method.
Raises:
TypeError: If only the object is giv... | [
"Return",
"an",
"iterator",
"object",
"."
] | 26a6c7e71e87dd1ddc4acb755d70ca30894f7928 | https://github.com/asyncdef/aitertools/blob/26a6c7e71e87dd1ddc4acb755d70ca30894f7928/aitertools/__init__.py#L37-L99 | train | Return an async iterable that yields items from the given object. |
asyncdef/aitertools | aitertools/__init__.py | anext | async def anext(*args):
"""Return the next item from an async iterator.
Args:
iterable: An async iterable.
default: An optional default value to return if the iterable is empty.
Return:
The next value of the iterable.
Raises:
TypeError: The iterable given is not async.... | python | async def anext(*args):
"""Return the next item from an async iterator.
Args:
iterable: An async iterable.
default: An optional default value to return if the iterable is empty.
Return:
The next value of the iterable.
Raises:
TypeError: The iterable given is not async.... | [
"async",
"def",
"anext",
"(",
"*",
"args",
")",
":",
"if",
"not",
"args",
":",
"raise",
"TypeError",
"(",
"'anext() expected at least 1 arguments, got 0'",
")",
"if",
"len",
"(",
"args",
")",
">",
"2",
":",
"raise",
"TypeError",
"(",
"'anext() expected at most... | Return the next item from an async iterator.
Args:
iterable: An async iterable.
default: An optional default value to return if the iterable is empty.
Return:
The next value of the iterable.
Raises:
TypeError: The iterable given is not async.
This function will return... | [
"Return",
"the",
"next",
"item",
"from",
"an",
"async",
"iterator",
"."
] | 26a6c7e71e87dd1ddc4acb755d70ca30894f7928 | https://github.com/asyncdef/aitertools/blob/26a6c7e71e87dd1ddc4acb755d70ca30894f7928/aitertools/__init__.py#L102-L146 | train | Return the next item from an async iterable. |
asyncdef/aitertools | aitertools/__init__.py | repeat | def repeat(obj, times=None):
"""Make an iterator that returns object over and over again."""
if times is None:
return AsyncIterWrapper(sync_itertools.repeat(obj))
return AsyncIterWrapper(sync_itertools.repeat(obj, times)) | python | def repeat(obj, times=None):
"""Make an iterator that returns object over and over again."""
if times is None:
return AsyncIterWrapper(sync_itertools.repeat(obj))
return AsyncIterWrapper(sync_itertools.repeat(obj, times)) | [
"def",
"repeat",
"(",
"obj",
",",
"times",
"=",
"None",
")",
":",
"if",
"times",
"is",
"None",
":",
"return",
"AsyncIterWrapper",
"(",
"sync_itertools",
".",
"repeat",
"(",
"obj",
")",
")",
"return",
"AsyncIterWrapper",
"(",
"sync_itertools",
".",
"repeat"... | Make an iterator that returns object over and over again. | [
"Make",
"an",
"iterator",
"that",
"returns",
"object",
"over",
"and",
"over",
"again",
"."
] | 26a6c7e71e87dd1ddc4acb755d70ca30894f7928 | https://github.com/asyncdef/aitertools/blob/26a6c7e71e87dd1ddc4acb755d70ca30894f7928/aitertools/__init__.py#L240-L246 | train | Make an iterator that returns object over and over again. |
asyncdef/aitertools | aitertools/__init__.py | _async_callable | def _async_callable(func):
"""Ensure the callable is an async def."""
if isinstance(func, types.CoroutineType):
return func
@functools.wraps(func)
async def _async_def_wrapper(*args, **kwargs):
"""Wrap a a sync callable in an async def."""
return func(*args, **kwargs)
retu... | python | def _async_callable(func):
"""Ensure the callable is an async def."""
if isinstance(func, types.CoroutineType):
return func
@functools.wraps(func)
async def _async_def_wrapper(*args, **kwargs):
"""Wrap a a sync callable in an async def."""
return func(*args, **kwargs)
retu... | [
"def",
"_async_callable",
"(",
"func",
")",
":",
"if",
"isinstance",
"(",
"func",
",",
"types",
".",
"CoroutineType",
")",
":",
"return",
"func",
"@",
"functools",
".",
"wraps",
"(",
"func",
")",
"async",
"def",
"_async_def_wrapper",
"(",
"*",
"args",
",... | Ensure the callable is an async def. | [
"Ensure",
"the",
"callable",
"is",
"an",
"async",
"def",
"."
] | 26a6c7e71e87dd1ddc4acb755d70ca30894f7928 | https://github.com/asyncdef/aitertools/blob/26a6c7e71e87dd1ddc4acb755d70ca30894f7928/aitertools/__init__.py#L249-L260 | train | Ensure the callable is an async def. |
asyncdef/aitertools | aitertools/__init__.py | tee | def tee(iterable, n=2):
"""Return n independent iterators from a single iterable.
Once tee() has made a split, the original iterable should not be used
anywhere else; otherwise, the iterable could get advanced without the tee
objects being informed.
This itertool may require significant auxiliary ... | python | def tee(iterable, n=2):
"""Return n independent iterators from a single iterable.
Once tee() has made a split, the original iterable should not be used
anywhere else; otherwise, the iterable could get advanced without the tee
objects being informed.
This itertool may require significant auxiliary ... | [
"def",
"tee",
"(",
"iterable",
",",
"n",
"=",
"2",
")",
":",
"tees",
"=",
"tuple",
"(",
"AsyncTeeIterable",
"(",
"iterable",
")",
"for",
"_",
"in",
"range",
"(",
"n",
")",
")",
"for",
"tee",
"in",
"tees",
":",
"tee",
".",
"_siblings",
"=",
"tees"... | Return n independent iterators from a single iterable.
Once tee() has made a split, the original iterable should not be used
anywhere else; otherwise, the iterable could get advanced without the tee
objects being informed.
This itertool may require significant auxiliary storage (depending on how
m... | [
"Return",
"n",
"independent",
"iterators",
"from",
"a",
"single",
"iterable",
"."
] | 26a6c7e71e87dd1ddc4acb755d70ca30894f7928 | https://github.com/asyncdef/aitertools/blob/26a6c7e71e87dd1ddc4acb755d70ca30894f7928/aitertools/__init__.py#L890-L907 | train | Return n independent iterators from a single iterable. |
nocarryr/python-dispatch | pydispatch/properties.py | Property._on_change | def _on_change(self, obj, old, value, **kwargs):
"""Called internally to emit changes from the instance object
The keyword arguments here will be passed to callbacks through the
instance object's :meth:`~pydispatch.dispatch.Dispatcher.emit` method.
Keyword Args:
property: T... | python | def _on_change(self, obj, old, value, **kwargs):
"""Called internally to emit changes from the instance object
The keyword arguments here will be passed to callbacks through the
instance object's :meth:`~pydispatch.dispatch.Dispatcher.emit` method.
Keyword Args:
property: T... | [
"def",
"_on_change",
"(",
"self",
",",
"obj",
",",
"old",
",",
"value",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
"[",
"'property'",
"]",
"=",
"self",
"obj",
".",
"emit",
"(",
"self",
".",
"name",
",",
"obj",
",",
"value",
",",
"old",
"=",
"... | Called internally to emit changes from the instance object
The keyword arguments here will be passed to callbacks through the
instance object's :meth:`~pydispatch.dispatch.Dispatcher.emit` method.
Keyword Args:
property: The :class:`Property` instance. This is useful if multiple
... | [
"Called",
"internally",
"to",
"emit",
"changes",
"from",
"the",
"instance",
"object"
] | 7c5ca03835c922cbfdfd62772c9e560062c954c7 | https://github.com/nocarryr/python-dispatch/blob/7c5ca03835c922cbfdfd62772c9e560062c954c7/pydispatch/properties.py#L96-L114 | train | Called internally to emit changes from the object object. |
OpenHydrology/floodestimation | floodestimation/parsers.py | FehFileParser.parse_str | def parse_str(self, s):
"""
Parse string and return relevant object
:param s: string to parse
:type s: str
:return: Parsed object
"""
self.object = self.parsed_class()
in_section = None # Holds name of FEH file section while traversing through file.
... | python | def parse_str(self, s):
"""
Parse string and return relevant object
:param s: string to parse
:type s: str
:return: Parsed object
"""
self.object = self.parsed_class()
in_section = None # Holds name of FEH file section while traversing through file.
... | [
"def",
"parse_str",
"(",
"self",
",",
"s",
")",
":",
"self",
".",
"object",
"=",
"self",
".",
"parsed_class",
"(",
")",
"in_section",
"=",
"None",
"# Holds name of FEH file section while traversing through file.",
"for",
"line",
"in",
"s",
".",
"split",
"(",
"... | Parse string and return relevant object
:param s: string to parse
:type s: str
:return: Parsed object | [
"Parse",
"string",
"and",
"return",
"relevant",
"object"
] | 782da7c5abd1348923129efe89fb70003ebb088c | https://github.com/OpenHydrology/floodestimation/blob/782da7c5abd1348923129efe89fb70003ebb088c/floodestimation/parsers.py#L70-L93 | train | Parse string and return relevant object |
OpenHydrology/floodestimation | floodestimation/parsers.py | FehFileParser.parse | def parse(self, file_name):
"""
Parse entire file and return relevant object.
:param file_name: File path
:type file_name: str
:return: Parsed object
"""
self.object = self.parsed_class()
with open(file_name, encoding='utf-8') as f:
self.parse... | python | def parse(self, file_name):
"""
Parse entire file and return relevant object.
:param file_name: File path
:type file_name: str
:return: Parsed object
"""
self.object = self.parsed_class()
with open(file_name, encoding='utf-8') as f:
self.parse... | [
"def",
"parse",
"(",
"self",
",",
"file_name",
")",
":",
"self",
".",
"object",
"=",
"self",
".",
"parsed_class",
"(",
")",
"with",
"open",
"(",
"file_name",
",",
"encoding",
"=",
"'utf-8'",
")",
"as",
"f",
":",
"self",
".",
"parse_str",
"(",
"f",
... | Parse entire file and return relevant object.
:param file_name: File path
:type file_name: str
:return: Parsed object | [
"Parse",
"entire",
"file",
"and",
"return",
"relevant",
"object",
"."
] | 782da7c5abd1348923129efe89fb70003ebb088c | https://github.com/OpenHydrology/floodestimation/blob/782da7c5abd1348923129efe89fb70003ebb088c/floodestimation/parsers.py#L95-L106 | train | Parse entire file and return relevant object. |
OpenHydrology/floodestimation | floodestimation/parsers.py | XmlCatchmentParser.parse | def parse(self, file_name):
"""
Parse entire file and return a :class:`Catchment` object.
:param file_name: File path
:type file_name: str
:return: Parsed object
:rtype: :class:`Catchment`
"""
root = ET.parse(file_name).getroot()
return self._pars... | python | def parse(self, file_name):
"""
Parse entire file and return a :class:`Catchment` object.
:param file_name: File path
:type file_name: str
:return: Parsed object
:rtype: :class:`Catchment`
"""
root = ET.parse(file_name).getroot()
return self._pars... | [
"def",
"parse",
"(",
"self",
",",
"file_name",
")",
":",
"root",
"=",
"ET",
".",
"parse",
"(",
"file_name",
")",
".",
"getroot",
"(",
")",
"return",
"self",
".",
"_parse",
"(",
"root",
")"
] | Parse entire file and return a :class:`Catchment` object.
:param file_name: File path
:type file_name: str
:return: Parsed object
:rtype: :class:`Catchment` | [
"Parse",
"entire",
"file",
"and",
"return",
"a",
":",
"class",
":",
"Catchment",
"object",
"."
] | 782da7c5abd1348923129efe89fb70003ebb088c | https://github.com/OpenHydrology/floodestimation/blob/782da7c5abd1348923129efe89fb70003ebb088c/floodestimation/parsers.py#L270-L280 | train | Parse a file and return a Parsed object. |
OpenHydrology/floodestimation | floodestimation/parsers.py | XmlCatchmentParser.parse_str | def parse_str(self, s):
"""
Parse entire file and return a :class:`Catchment` object.
:param file_name: File path
:type file_name: str
:return: Parsed object
:rtype: :class:`Catchment`
"""
root = ET.fromstring(s)
return self._parse(root) | python | def parse_str(self, s):
"""
Parse entire file and return a :class:`Catchment` object.
:param file_name: File path
:type file_name: str
:return: Parsed object
:rtype: :class:`Catchment`
"""
root = ET.fromstring(s)
return self._parse(root) | [
"def",
"parse_str",
"(",
"self",
",",
"s",
")",
":",
"root",
"=",
"ET",
".",
"fromstring",
"(",
"s",
")",
"return",
"self",
".",
"_parse",
"(",
"root",
")"
] | Parse entire file and return a :class:`Catchment` object.
:param file_name: File path
:type file_name: str
:return: Parsed object
:rtype: :class:`Catchment` | [
"Parse",
"entire",
"file",
"and",
"return",
"a",
":",
"class",
":",
"Catchment",
"object",
"."
] | 782da7c5abd1348923129efe89fb70003ebb088c | https://github.com/OpenHydrology/floodestimation/blob/782da7c5abd1348923129efe89fb70003ebb088c/floodestimation/parsers.py#L282-L292 | train | Parse a string into a dict. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.