repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
sanoma/django-arctic
arctic/templatetags/arctic_pagination_tags.py
str_to_bool
def str_to_bool(val): """ Helper function to turn a string representation of "true" into boolean True. """ if isinstance(val, str): val = val.lower() return val in ["true", "on", "yes", True]
python
def str_to_bool(val): """ Helper function to turn a string representation of "true" into boolean True. """ if isinstance(val, str): val = val.lower() return val in ["true", "on", "yes", True]
[ "def", "str_to_bool", "(", "val", ")", ":", "if", "isinstance", "(", "val", ",", "str", ")", ":", "val", "=", "val", ".", "lower", "(", ")", "return", "val", "in", "[", "\"true\"", ",", "\"on\"", ",", "\"yes\"", ",", "True", "]" ]
Helper function to turn a string representation of "true" into boolean True.
[ "Helper", "function", "to", "turn", "a", "string", "representation", "of", "true", "into", "boolean", "True", "." ]
train
https://github.com/sanoma/django-arctic/blob/c81b092c2643ca220708bf3c586017d9175161f5/arctic/templatetags/arctic_pagination_tags.py#L44-L52
sanoma/django-arctic
arctic/templatetags/arctic_pagination_tags.py
arctic_paginate
def arctic_paginate(parser, token): """ Renders a Page object with pagination bar. Example:: {% arctic_paginate page_obj paginator=page_obj.paginator range=10 %} Named Parameters:: range - The size of the pagination bar (ie, if set to 10 then, at most, 10 page numbers wil...
python
def arctic_paginate(parser, token): """ Renders a Page object with pagination bar. Example:: {% arctic_paginate page_obj paginator=page_obj.paginator range=10 %} Named Parameters:: range - The size of the pagination bar (ie, if set to 10 then, at most, 10 page numbers wil...
[ "def", "arctic_paginate", "(", "parser", ",", "token", ")", ":", "bits", "=", "token", ".", "split_contents", "(", ")", "if", "len", "(", "bits", ")", "<", "2", ":", "raise", "TemplateSyntaxError", "(", "\"'%s' takes at least one argument\"", "\" (Page object re...
Renders a Page object with pagination bar. Example:: {% arctic_paginate page_obj paginator=page_obj.paginator range=10 %} Named Parameters:: range - The size of the pagination bar (ie, if set to 10 then, at most, 10 page numbers will display at any given time) Defaults to ...
[ "Renders", "a", "Page", "object", "with", "pagination", "bar", ".", "Example", "::", "{", "%", "arctic_paginate", "page_obj", "paginator", "=", "page_obj", ".", "paginator", "range", "=", "10", "%", "}", "Named", "Parameters", "::", "range", "-", "The", "s...
train
https://github.com/sanoma/django-arctic/blob/c81b092c2643ca220708bf3c586017d9175161f5/arctic/templatetags/arctic_pagination_tags.py#L153-L188
sanoma/django-arctic
arctic/utils.py
menu
def menu(menu_config=None, **kwargs): """ Tranforms a menu definition into a dictionary which is a frendlier format to parse in a template. """ request = kwargs.pop("request", None) user = kwargs.pop("user", None) url_full_name = ":".join( [request.resolver_match.namespace, request.r...
python
def menu(menu_config=None, **kwargs): """ Tranforms a menu definition into a dictionary which is a frendlier format to parse in a template. """ request = kwargs.pop("request", None) user = kwargs.pop("user", None) url_full_name = ":".join( [request.resolver_match.namespace, request.r...
[ "def", "menu", "(", "menu_config", "=", "None", ",", "*", "*", "kwargs", ")", ":", "request", "=", "kwargs", ".", "pop", "(", "\"request\"", ",", "None", ")", "user", "=", "kwargs", ".", "pop", "(", "\"user\"", ",", "None", ")", "url_full_name", "=",...
Tranforms a menu definition into a dictionary which is a frendlier format to parse in a template.
[ "Tranforms", "a", "menu", "definition", "into", "a", "dictionary", "which", "is", "a", "frendlier", "format", "to", "parse", "in", "a", "template", "." ]
train
https://github.com/sanoma/django-arctic/blob/c81b092c2643ca220708bf3c586017d9175161f5/arctic/utils.py#L49-L95
sanoma/django-arctic
arctic/utils.py
menu_clean
def menu_clean(menu_config): """ Make sure that only the menu item with the largest weight is active. If a child of a menu item is active, the parent should be active too. :param menu: :return: """ max_weight = -1 for _, value in list(menu_config.items()): if value["submenu"]: ...
python
def menu_clean(menu_config): """ Make sure that only the menu item with the largest weight is active. If a child of a menu item is active, the parent should be active too. :param menu: :return: """ max_weight = -1 for _, value in list(menu_config.items()): if value["submenu"]: ...
[ "def", "menu_clean", "(", "menu_config", ")", ":", "max_weight", "=", "-", "1", "for", "_", ",", "value", "in", "list", "(", "menu_config", ".", "items", "(", ")", ")", ":", "if", "value", "[", "\"submenu\"", "]", ":", "for", "_", ",", "v", "in", ...
Make sure that only the menu item with the largest weight is active. If a child of a menu item is active, the parent should be active too. :param menu: :return:
[ "Make", "sure", "that", "only", "the", "menu", "item", "with", "the", "largest", "weight", "is", "active", ".", "If", "a", "child", "of", "a", "menu", "item", "is", "active", "the", "parent", "should", "be", "active", "too", ".", ":", "param", "menu", ...
train
https://github.com/sanoma/django-arctic/blob/c81b092c2643ca220708bf3c586017d9175161f5/arctic/utils.py#L104-L128
sanoma/django-arctic
arctic/utils.py
view_from_url
def view_from_url(named_url): # noqa """ Finds and returns the view class from a named url """ # code below is `stolen` from django's reverse method. resolver = get_resolver(get_urlconf()) if type(named_url) in (list, tuple): named_url = named_url[0] parts = named_url.split(":") ...
python
def view_from_url(named_url): # noqa """ Finds and returns the view class from a named url """ # code below is `stolen` from django's reverse method. resolver = get_resolver(get_urlconf()) if type(named_url) in (list, tuple): named_url = named_url[0] parts = named_url.split(":") ...
[ "def", "view_from_url", "(", "named_url", ")", ":", "# noqa", "# code below is `stolen` from django's reverse method.", "resolver", "=", "get_resolver", "(", "get_urlconf", "(", ")", ")", "if", "type", "(", "named_url", ")", "in", "(", "list", ",", "tuple", ")", ...
Finds and returns the view class from a named url
[ "Finds", "and", "returns", "the", "view", "class", "from", "a", "named", "url" ]
train
https://github.com/sanoma/django-arctic/blob/c81b092c2643ca220708bf3c586017d9175161f5/arctic/utils.py#L131-L211
sanoma/django-arctic
arctic/utils.py
find_attribute
def find_attribute(obj, value): """ Finds the attribute connected to the last object when a chain of connected objects is given in a string separated with double underscores. For example when a model x has a foreign key to model y and model y has attribute a, findattr(x, 'y__a') will return the a at...
python
def find_attribute(obj, value): """ Finds the attribute connected to the last object when a chain of connected objects is given in a string separated with double underscores. For example when a model x has a foreign key to model y and model y has attribute a, findattr(x, 'y__a') will return the a at...
[ "def", "find_attribute", "(", "obj", ",", "value", ")", ":", "if", "\"__\"", "in", "value", ":", "value_list", "=", "value", ".", "split", "(", "\"__\"", ")", "attr", "=", "get_attribute", "(", "obj", ",", "value_list", "[", "0", "]", ")", "return", ...
Finds the attribute connected to the last object when a chain of connected objects is given in a string separated with double underscores. For example when a model x has a foreign key to model y and model y has attribute a, findattr(x, 'y__a') will return the a attribute from the y model that exists in ...
[ "Finds", "the", "attribute", "connected", "to", "the", "last", "object", "when", "a", "chain", "of", "connected", "objects", "is", "given", "in", "a", "string", "separated", "with", "double", "underscores", ".", "For", "example", "when", "a", "model", "x", ...
train
https://github.com/sanoma/django-arctic/blob/c81b092c2643ca220708bf3c586017d9175161f5/arctic/utils.py#L214-L226
sanoma/django-arctic
arctic/utils.py
get_attribute
def get_attribute(obj, value): """ Normally the result of list_items for listviews are a set of model objects. But when you want a GROUP_BY query (with 'values' method), than the result will be a dict. This method will help you find an item for either objects or dictionaries. """ if type(obj...
python
def get_attribute(obj, value): """ Normally the result of list_items for listviews are a set of model objects. But when you want a GROUP_BY query (with 'values' method), than the result will be a dict. This method will help you find an item for either objects or dictionaries. """ if type(obj...
[ "def", "get_attribute", "(", "obj", ",", "value", ")", ":", "if", "type", "(", "obj", ")", "==", "dict", ":", "return", "dict", ".", "get", "(", "obj", ",", "value", ")", "else", ":", "return", "getattr", "(", "obj", ",", "value", ")" ]
Normally the result of list_items for listviews are a set of model objects. But when you want a GROUP_BY query (with 'values' method), than the result will be a dict. This method will help you find an item for either objects or dictionaries.
[ "Normally", "the", "result", "of", "list_items", "for", "listviews", "are", "a", "set", "of", "model", "objects", ".", "But", "when", "you", "want", "a", "GROUP_BY", "query", "(", "with", "values", "method", ")", "than", "the", "result", "will", "be", "a...
train
https://github.com/sanoma/django-arctic/blob/c81b092c2643ca220708bf3c586017d9175161f5/arctic/utils.py#L229-L239
sanoma/django-arctic
arctic/utils.py
find_field_meta
def find_field_meta(obj, value): """ In a model, finds the attribute meta connected to the last object when a chain of connected objects is given in a string separated with double underscores. """ if "__" in value: value_list = value.split("__") child_obj = obj._meta.get_field(v...
python
def find_field_meta(obj, value): """ In a model, finds the attribute meta connected to the last object when a chain of connected objects is given in a string separated with double underscores. """ if "__" in value: value_list = value.split("__") child_obj = obj._meta.get_field(v...
[ "def", "find_field_meta", "(", "obj", ",", "value", ")", ":", "if", "\"__\"", "in", "value", ":", "value_list", "=", "value", ".", "split", "(", "\"__\"", ")", "child_obj", "=", "obj", ".", "_meta", ".", "get_field", "(", "value_list", "[", "0", "]", ...
In a model, finds the attribute meta connected to the last object when a chain of connected objects is given in a string separated with double underscores.
[ "In", "a", "model", "finds", "the", "attribute", "meta", "connected", "to", "the", "last", "object", "when", "a", "chain", "of", "connected", "objects", "is", "given", "in", "a", "string", "separated", "with", "double", "underscores", "." ]
train
https://github.com/sanoma/django-arctic/blob/c81b092c2643ca220708bf3c586017d9175161f5/arctic/utils.py#L242-L252
sanoma/django-arctic
arctic/utils.py
get_field_class
def get_field_class(qs, field_name): """ Given a queryset and a field name, it will return the field's class """ try: return qs.model._meta.get_field(field_name).__class__.__name__ # while annotating, it's possible that field does not exists. except FieldDoesNotExist: return None
python
def get_field_class(qs, field_name): """ Given a queryset and a field name, it will return the field's class """ try: return qs.model._meta.get_field(field_name).__class__.__name__ # while annotating, it's possible that field does not exists. except FieldDoesNotExist: return None
[ "def", "get_field_class", "(", "qs", ",", "field_name", ")", ":", "try", ":", "return", "qs", ".", "model", ".", "_meta", ".", "get_field", "(", "field_name", ")", ".", "__class__", ".", "__name__", "# while annotating, it's possible that field does not exists.", ...
Given a queryset and a field name, it will return the field's class
[ "Given", "a", "queryset", "and", "a", "field", "name", "it", "will", "return", "the", "field", "s", "class" ]
train
https://github.com/sanoma/django-arctic/blob/c81b092c2643ca220708bf3c586017d9175161f5/arctic/utils.py#L255-L263
sanoma/django-arctic
arctic/utils.py
reverse_url
def reverse_url(url, obj, fallback_field=None): """ Reverses a named url, in addition to the standard django reverse, it also accepts a list of ('named url', 'field1', 'field2', ...) and will use the value of the supplied fields as arguments. When a fallback field is given it will use it as an argum...
python
def reverse_url(url, obj, fallback_field=None): """ Reverses a named url, in addition to the standard django reverse, it also accepts a list of ('named url', 'field1', 'field2', ...) and will use the value of the supplied fields as arguments. When a fallback field is given it will use it as an argum...
[ "def", "reverse_url", "(", "url", ",", "obj", ",", "fallback_field", "=", "None", ")", ":", "args", "=", "[", "]", "if", "type", "(", "url", ")", "in", "(", "list", ",", "tuple", ")", ":", "named_url", "=", "url", "[", "0", "]", "for", "arg", "...
Reverses a named url, in addition to the standard django reverse, it also accepts a list of ('named url', 'field1', 'field2', ...) and will use the value of the supplied fields as arguments. When a fallback field is given it will use it as an argument if none other are given.
[ "Reverses", "a", "named", "url", "in", "addition", "to", "the", "standard", "django", "reverse", "it", "also", "accepts", "a", "list", "of", "(", "named", "url", "field1", "field2", "...", ")", "and", "will", "use", "the", "value", "of", "the", "supplied...
train
https://github.com/sanoma/django-arctic/blob/c81b092c2643ca220708bf3c586017d9175161f5/arctic/utils.py#L266-L297
sanoma/django-arctic
arctic/utils.py
arctic_setting
def arctic_setting(setting_name, valid_options=None): """ Tries to get a setting from the django settings, if not available defaults to the one defined in defaults.py """ try: value = getattr(settings, setting_name) if valid_options and value not in valid_options: error_m...
python
def arctic_setting(setting_name, valid_options=None): """ Tries to get a setting from the django settings, if not available defaults to the one defined in defaults.py """ try: value = getattr(settings, setting_name) if valid_options and value not in valid_options: error_m...
[ "def", "arctic_setting", "(", "setting_name", ",", "valid_options", "=", "None", ")", ":", "try", ":", "value", "=", "getattr", "(", "settings", ",", "setting_name", ")", "if", "valid_options", "and", "value", "not", "in", "valid_options", ":", "error_message"...
Tries to get a setting from the django settings, if not available defaults to the one defined in defaults.py
[ "Tries", "to", "get", "a", "setting", "from", "the", "django", "settings", "if", "not", "available", "defaults", "to", "the", "one", "defined", "in", "defaults", ".", "py" ]
train
https://github.com/sanoma/django-arctic/blob/c81b092c2643ca220708bf3c586017d9175161f5/arctic/utils.py#L300-L314
sanoma/django-arctic
arctic/utils.py
offset_limit
def offset_limit(func): """ Decorator that converts python slicing to offset and limit """ def func_wrapper(self, start, stop): offset = start limit = stop - start return func(self, offset, limit) return func_wrapper
python
def offset_limit(func): """ Decorator that converts python slicing to offset and limit """ def func_wrapper(self, start, stop): offset = start limit = stop - start return func(self, offset, limit) return func_wrapper
[ "def", "offset_limit", "(", "func", ")", ":", "def", "func_wrapper", "(", "self", ",", "start", ",", "stop", ")", ":", "offset", "=", "start", "limit", "=", "stop", "-", "start", "return", "func", "(", "self", ",", "offset", ",", "limit", ")", "retur...
Decorator that converts python slicing to offset and limit
[ "Decorator", "that", "converts", "python", "slicing", "to", "offset", "and", "limit" ]
train
https://github.com/sanoma/django-arctic/blob/c81b092c2643ca220708bf3c586017d9175161f5/arctic/utils.py#L367-L377
sanoma/django-arctic
arctic/utils.py
is_list_of_list
def is_list_of_list(item): """ check whether the item is list (tuple) and consist of list (tuple) elements """ if ( type(item) in (list, tuple) and len(item) and isinstance(item[0], (list, tuple)) ): return True return False
python
def is_list_of_list(item): """ check whether the item is list (tuple) and consist of list (tuple) elements """ if ( type(item) in (list, tuple) and len(item) and isinstance(item[0], (list, tuple)) ): return True return False
[ "def", "is_list_of_list", "(", "item", ")", ":", "if", "(", "type", "(", "item", ")", "in", "(", "list", ",", "tuple", ")", "and", "len", "(", "item", ")", "and", "isinstance", "(", "item", "[", "0", "]", ",", "(", "list", ",", "tuple", ")", ")...
check whether the item is list (tuple) and consist of list (tuple) elements
[ "check", "whether", "the", "item", "is", "list", "(", "tuple", ")", "and", "consist", "of", "list", "(", "tuple", ")", "elements" ]
train
https://github.com/sanoma/django-arctic/blob/c81b092c2643ca220708bf3c586017d9175161f5/arctic/utils.py#L380-L391
sanoma/django-arctic
arctic/utils.py
generate_id
def generate_id(*s): """ generates an id from one or more given strings it uses english as the base language in case some strings are translated, this ensures consistent ids """ with translation.override("en"): generated_id = slugify("-".join([str(i) for i in s])) return generated_id
python
def generate_id(*s): """ generates an id from one or more given strings it uses english as the base language in case some strings are translated, this ensures consistent ids """ with translation.override("en"): generated_id = slugify("-".join([str(i) for i in s])) return generated_id
[ "def", "generate_id", "(", "*", "s", ")", ":", "with", "translation", ".", "override", "(", "\"en\"", ")", ":", "generated_id", "=", "slugify", "(", "\"-\"", ".", "join", "(", "[", "str", "(", "i", ")", "for", "i", "in", "s", "]", ")", ")", "retu...
generates an id from one or more given strings it uses english as the base language in case some strings are translated, this ensures consistent ids
[ "generates", "an", "id", "from", "one", "or", "more", "given", "strings", "it", "uses", "english", "as", "the", "base", "language", "in", "case", "some", "strings", "are", "translated", "this", "ensures", "consistent", "ids" ]
train
https://github.com/sanoma/django-arctic/blob/c81b092c2643ca220708bf3c586017d9175161f5/arctic/utils.py#L394-L402
sanoma/django-arctic
arctic/utils.py
append_query_parameter
def append_query_parameter(url, parameters, ignore_if_exists=True): """ quick and dirty appending of query parameters to a url """ if ignore_if_exists: for key in parameters.keys(): if key + "=" in url: del parameters[key] parameters_str = "&".join(k + "=" + v for k, v in...
python
def append_query_parameter(url, parameters, ignore_if_exists=True): """ quick and dirty appending of query parameters to a url """ if ignore_if_exists: for key in parameters.keys(): if key + "=" in url: del parameters[key] parameters_str = "&".join(k + "=" + v for k, v in...
[ "def", "append_query_parameter", "(", "url", ",", "parameters", ",", "ignore_if_exists", "=", "True", ")", ":", "if", "ignore_if_exists", ":", "for", "key", "in", "parameters", ".", "keys", "(", ")", ":", "if", "key", "+", "\"=\"", "in", "url", ":", "del...
quick and dirty appending of query parameters to a url
[ "quick", "and", "dirty", "appending", "of", "query", "parameters", "to", "a", "url" ]
train
https://github.com/sanoma/django-arctic/blob/c81b092c2643ca220708bf3c586017d9175161f5/arctic/utils.py#L405-L413
sanoma/django-arctic
arctic/widgets.py
BetterFileInput.render
def render(self, name, value, attrs=None, renderer=None): """For django 1.10 compatibility""" if django.VERSION >= (1, 11): return super(BetterFileInput, self).render(name, value, attrs) t = render_to_string( template_name=self.template_name, context=self.get...
python
def render(self, name, value, attrs=None, renderer=None): """For django 1.10 compatibility""" if django.VERSION >= (1, 11): return super(BetterFileInput, self).render(name, value, attrs) t = render_to_string( template_name=self.template_name, context=self.get...
[ "def", "render", "(", "self", ",", "name", ",", "value", ",", "attrs", "=", "None", ",", "renderer", "=", "None", ")", ":", "if", "django", ".", "VERSION", ">=", "(", "1", ",", "11", ")", ":", "return", "super", "(", "BetterFileInput", ",", "self",...
For django 1.10 compatibility
[ "For", "django", "1", ".", "10", "compatibility" ]
train
https://github.com/sanoma/django-arctic/blob/c81b092c2643ca220708bf3c586017d9175161f5/arctic/widgets.py#L186-L195
ncrocfer/whatportis
whatportis/__main__.py
get_table
def get_table(ports): """ This function returns a pretty table used to display the port results. :param ports: list of found ports :return: the table to display """ table = PrettyTable(["Name", "Port", "Protocol", "Description"]) table.align["Name"] = "l" table.align["Description"] = "l...
python
def get_table(ports): """ This function returns a pretty table used to display the port results. :param ports: list of found ports :return: the table to display """ table = PrettyTable(["Name", "Port", "Protocol", "Description"]) table.align["Name"] = "l" table.align["Description"] = "l...
[ "def", "get_table", "(", "ports", ")", ":", "table", "=", "PrettyTable", "(", "[", "\"Name\"", ",", "\"Port\"", ",", "\"Protocol\"", ",", "\"Description\"", "]", ")", "table", ".", "align", "[", "\"Name\"", "]", "=", "\"l\"", "table", ".", "align", "[", ...
This function returns a pretty table used to display the port results. :param ports: list of found ports :return: the table to display
[ "This", "function", "returns", "a", "pretty", "table", "used", "to", "display", "the", "port", "results", "." ]
train
https://github.com/ncrocfer/whatportis/blob/66a04b249dc9edf23dadd7eb91473b7f125fb27f/whatportis/__main__.py#L17-L32
ncrocfer/whatportis
whatportis/__main__.py
run
def run(port, like, use_json, server): """Search port names and numbers.""" if not port and not server[0]: raise click.UsageError("Please specify a port") if server[0]: app.run(host=server[0], port=server[1]) return ports = get_ports(port, like) if not ports: sys.st...
python
def run(port, like, use_json, server): """Search port names and numbers.""" if not port and not server[0]: raise click.UsageError("Please specify a port") if server[0]: app.run(host=server[0], port=server[1]) return ports = get_ports(port, like) if not ports: sys.st...
[ "def", "run", "(", "port", ",", "like", ",", "use_json", ",", "server", ")", ":", "if", "not", "port", "and", "not", "server", "[", "0", "]", ":", "raise", "click", ".", "UsageError", "(", "\"Please specify a port\"", ")", "if", "server", "[", "0", "...
Search port names and numbers.
[ "Search", "port", "names", "and", "numbers", "." ]
train
https://github.com/ncrocfer/whatportis/blob/66a04b249dc9edf23dadd7eb91473b7f125fb27f/whatportis/__main__.py#L44-L62
ncrocfer/whatportis
whatportis/core.py
get_ports
def get_ports(port, like=False): """ This function creates the SQL query depending on the specified port and the --like option. :param port: the specified port :param like: the --like option :return: all ports matching the given ``port`` :rtype: list """ where_field = "port" if port...
python
def get_ports(port, like=False): """ This function creates the SQL query depending on the specified port and the --like option. :param port: the specified port :param like: the --like option :return: all ports matching the given ``port`` :rtype: list """ where_field = "port" if port...
[ "def", "get_ports", "(", "port", ",", "like", "=", "False", ")", ":", "where_field", "=", "\"port\"", "if", "port", ".", "isdigit", "(", ")", "else", "\"name\"", "if", "like", ":", "ports", "=", "__DB__", ".", "search", "(", "where", "(", "where_field"...
This function creates the SQL query depending on the specified port and the --like option. :param port: the specified port :param like: the --like option :return: all ports matching the given ``port`` :rtype: list
[ "This", "function", "creates", "the", "SQL", "query", "depending", "on", "the", "specified", "port", "and", "the", "--", "like", "option", "." ]
train
https://github.com/ncrocfer/whatportis/blob/66a04b249dc9edf23dadd7eb91473b7f125fb27f/whatportis/core.py#L22-L38
CityOfZion/neo-python-rpc
neorpc/Client.py
RPCClient.get_account
def get_account(self, address, id=None, endpoint=None): """ Look up an account on the blockchain. Sample output: Args: address: (str) address to lookup ( in format 'AXjaFSP23Jkbe6Pk9pPGT6NBDs1HVdqaXK') id: (int, optional) id to use for response tracking endp...
python
def get_account(self, address, id=None, endpoint=None): """ Look up an account on the blockchain. Sample output: Args: address: (str) address to lookup ( in format 'AXjaFSP23Jkbe6Pk9pPGT6NBDs1HVdqaXK') id: (int, optional) id to use for response tracking endp...
[ "def", "get_account", "(", "self", ",", "address", ",", "id", "=", "None", ",", "endpoint", "=", "None", ")", ":", "return", "self", ".", "_call_endpoint", "(", "GET_ACCOUNT_STATE", ",", "params", "=", "[", "address", "]", ",", "id", "=", "id", ",", ...
Look up an account on the blockchain. Sample output: Args: address: (str) address to lookup ( in format 'AXjaFSP23Jkbe6Pk9pPGT6NBDs1HVdqaXK') id: (int, optional) id to use for response tracking endpoint: (RPCEndpoint, optional) endpoint to specify to use Returns: ...
[ "Look", "up", "an", "account", "on", "the", "blockchain", ".", "Sample", "output", ":" ]
train
https://github.com/CityOfZion/neo-python-rpc/blob/89d22c4043654b2941bf26b15a1c09082901d9ef/neorpc/Client.py#L26-L39
CityOfZion/neo-python-rpc
neorpc/Client.py
RPCClient.get_height
def get_height(self, id=None, endpoint=None): """ Get the current height of the blockchain Args: id: (int, optional) id to use for response tracking endpoint: (RPCEndpoint, optional) endpoint to specify to use Returns: json object of the result or the...
python
def get_height(self, id=None, endpoint=None): """ Get the current height of the blockchain Args: id: (int, optional) id to use for response tracking endpoint: (RPCEndpoint, optional) endpoint to specify to use Returns: json object of the result or the...
[ "def", "get_height", "(", "self", ",", "id", "=", "None", ",", "endpoint", "=", "None", ")", ":", "return", "self", ".", "_call_endpoint", "(", "GET_BLOCK_COUNT", ",", "id", "=", "id", ",", "endpoint", "=", "endpoint", ")" ]
Get the current height of the blockchain Args: id: (int, optional) id to use for response tracking endpoint: (RPCEndpoint, optional) endpoint to specify to use Returns: json object of the result or the error encountered in the RPC call
[ "Get", "the", "current", "height", "of", "the", "blockchain", "Args", ":", "id", ":", "(", "int", "optional", ")", "id", "to", "use", "for", "response", "tracking", "endpoint", ":", "(", "RPCEndpoint", "optional", ")", "endpoint", "to", "specify", "to", ...
train
https://github.com/CityOfZion/neo-python-rpc/blob/89d22c4043654b2941bf26b15a1c09082901d9ef/neorpc/Client.py#L41-L51
CityOfZion/neo-python-rpc
neorpc/Client.py
RPCClient.get_asset
def get_asset(self, asset_hash, id=None, endpoint=None): """ Get an asset by its hash Args: asset_hash: (str) asset to lookup, example would be 'c56f33fc6ecfcd0c225c4ab356fee59390af8560be0e930faebe74a6daff7c9b' id: (int, optional) id to use for response tracking ...
python
def get_asset(self, asset_hash, id=None, endpoint=None): """ Get an asset by its hash Args: asset_hash: (str) asset to lookup, example would be 'c56f33fc6ecfcd0c225c4ab356fee59390af8560be0e930faebe74a6daff7c9b' id: (int, optional) id to use for response tracking ...
[ "def", "get_asset", "(", "self", ",", "asset_hash", ",", "id", "=", "None", ",", "endpoint", "=", "None", ")", ":", "return", "self", ".", "_call_endpoint", "(", "GET_ASSET_STATE", ",", "params", "=", "[", "asset_hash", "]", ",", "id", "=", "id", ",", ...
Get an asset by its hash Args: asset_hash: (str) asset to lookup, example would be 'c56f33fc6ecfcd0c225c4ab356fee59390af8560be0e930faebe74a6daff7c9b' id: (int, optional) id to use for response tracking endpoint: (RPCEndpoint, optional) endpoint to specify to use Retu...
[ "Get", "an", "asset", "by", "its", "hash", "Args", ":", "asset_hash", ":", "(", "str", ")", "asset", "to", "lookup", "example", "would", "be", "c56f33fc6ecfcd0c225c4ab356fee59390af8560be0e930faebe74a6daff7c9b", "id", ":", "(", "int", "optional", ")", "id", "to",...
train
https://github.com/CityOfZion/neo-python-rpc/blob/89d22c4043654b2941bf26b15a1c09082901d9ef/neorpc/Client.py#L53-L64
CityOfZion/neo-python-rpc
neorpc/Client.py
RPCClient.get_balance
def get_balance(self, asset_hash, id=None, endpoint=None): """ Get balance by asset hash Args: asset_hash: (str) asset to lookup, example would be 'c56f33fc6ecfcd0c225c4ab356fee59390af8560be0e930faebe74a6daff7c9b' id: (int, optional) id to use for response tracking ...
python
def get_balance(self, asset_hash, id=None, endpoint=None): """ Get balance by asset hash Args: asset_hash: (str) asset to lookup, example would be 'c56f33fc6ecfcd0c225c4ab356fee59390af8560be0e930faebe74a6daff7c9b' id: (int, optional) id to use for response tracking ...
[ "def", "get_balance", "(", "self", ",", "asset_hash", ",", "id", "=", "None", ",", "endpoint", "=", "None", ")", ":", "return", "self", ".", "_call_endpoint", "(", "GET_BALANCE", ",", "params", "=", "[", "asset_hash", "]", ",", "id", "=", "id", ",", ...
Get balance by asset hash Args: asset_hash: (str) asset to lookup, example would be 'c56f33fc6ecfcd0c225c4ab356fee59390af8560be0e930faebe74a6daff7c9b' id: (int, optional) id to use for response tracking endpoint: (RPCEndpoint, optional) endpoint to specify to use Ret...
[ "Get", "balance", "by", "asset", "hash", "Args", ":", "asset_hash", ":", "(", "str", ")", "asset", "to", "lookup", "example", "would", "be", "c56f33fc6ecfcd0c225c4ab356fee59390af8560be0e930faebe74a6daff7c9b", "id", ":", "(", "int", "optional", ")", "id", "to", "...
train
https://github.com/CityOfZion/neo-python-rpc/blob/89d22c4043654b2941bf26b15a1c09082901d9ef/neorpc/Client.py#L66-L77
CityOfZion/neo-python-rpc
neorpc/Client.py
RPCClient.get_best_blockhash
def get_best_blockhash(self, id=None, endpoint=None): """ Get the hash of the highest block Args: id: (int, optional) id to use for response tracking endpoint: (RPCEndpoint, optional) endpoint to specify to use Returns: json object of the result or the...
python
def get_best_blockhash(self, id=None, endpoint=None): """ Get the hash of the highest block Args: id: (int, optional) id to use for response tracking endpoint: (RPCEndpoint, optional) endpoint to specify to use Returns: json object of the result or the...
[ "def", "get_best_blockhash", "(", "self", ",", "id", "=", "None", ",", "endpoint", "=", "None", ")", ":", "return", "self", ".", "_call_endpoint", "(", "GET_BEST_BLOCK_HASH", ",", "id", "=", "id", ",", "endpoint", "=", "endpoint", ")" ]
Get the hash of the highest block Args: id: (int, optional) id to use for response tracking endpoint: (RPCEndpoint, optional) endpoint to specify to use Returns: json object of the result or the error encountered in the RPC call
[ "Get", "the", "hash", "of", "the", "highest", "block", "Args", ":", "id", ":", "(", "int", "optional", ")", "id", "to", "use", "for", "response", "tracking", "endpoint", ":", "(", "RPCEndpoint", "optional", ")", "endpoint", "to", "specify", "to", "use", ...
train
https://github.com/CityOfZion/neo-python-rpc/blob/89d22c4043654b2941bf26b15a1c09082901d9ef/neorpc/Client.py#L79-L88
CityOfZion/neo-python-rpc
neorpc/Client.py
RPCClient.get_block
def get_block(self, height_or_hash, id=None, endpoint=None): """ Look up a block by the height or hash of the block. Args: height_or_hash: (int or str) either the height of the desired block or its hash in the form '1e67372c158a4cfbb17b9ad3aaae77001a4247a00318e354c62e53b56af4006f' ...
python
def get_block(self, height_or_hash, id=None, endpoint=None): """ Look up a block by the height or hash of the block. Args: height_or_hash: (int or str) either the height of the desired block or its hash in the form '1e67372c158a4cfbb17b9ad3aaae77001a4247a00318e354c62e53b56af4006f' ...
[ "def", "get_block", "(", "self", ",", "height_or_hash", ",", "id", "=", "None", ",", "endpoint", "=", "None", ")", ":", "return", "self", ".", "_call_endpoint", "(", "GET_BLOCK", ",", "params", "=", "[", "height_or_hash", ",", "1", "]", ",", "id", "=",...
Look up a block by the height or hash of the block. Args: height_or_hash: (int or str) either the height of the desired block or its hash in the form '1e67372c158a4cfbb17b9ad3aaae77001a4247a00318e354c62e53b56af4006f' id: (int, optional) id to use for response tracking endpoin...
[ "Look", "up", "a", "block", "by", "the", "height", "or", "hash", "of", "the", "block", ".", "Args", ":", "height_or_hash", ":", "(", "int", "or", "str", ")", "either", "the", "height", "of", "the", "desired", "block", "or", "its", "hash", "in", "the"...
train
https://github.com/CityOfZion/neo-python-rpc/blob/89d22c4043654b2941bf26b15a1c09082901d9ef/neorpc/Client.py#L90-L101
CityOfZion/neo-python-rpc
neorpc/Client.py
RPCClient.get_block_hash
def get_block_hash(self, height, id=None, endpoint=None): """ Get hash of a block by its height Args: height: (int) height of the block to lookup id: (int, optional) id to use for response tracking endpoint: (RPCEndpoint, optional) endpoint to specify to use ...
python
def get_block_hash(self, height, id=None, endpoint=None): """ Get hash of a block by its height Args: height: (int) height of the block to lookup id: (int, optional) id to use for response tracking endpoint: (RPCEndpoint, optional) endpoint to specify to use ...
[ "def", "get_block_hash", "(", "self", ",", "height", ",", "id", "=", "None", ",", "endpoint", "=", "None", ")", ":", "return", "self", ".", "_call_endpoint", "(", "GET_BLOCK_HASH", ",", "params", "=", "[", "height", "]", ",", "id", "=", "id", ",", "e...
Get hash of a block by its height Args: height: (int) height of the block to lookup id: (int, optional) id to use for response tracking endpoint: (RPCEndpoint, optional) endpoint to specify to use Returns: json object of the result or the error encountere...
[ "Get", "hash", "of", "a", "block", "by", "its", "height", "Args", ":", "height", ":", "(", "int", ")", "height", "of", "the", "block", "to", "lookup", "id", ":", "(", "int", "optional", ")", "id", "to", "use", "for", "response", "tracking", "endpoint...
train
https://github.com/CityOfZion/neo-python-rpc/blob/89d22c4043654b2941bf26b15a1c09082901d9ef/neorpc/Client.py#L103-L114
CityOfZion/neo-python-rpc
neorpc/Client.py
RPCClient.get_block_header
def get_block_header(self, block_hash, id=None, endpoint=None): """ Get the corresponding block header information according to the specified script hash. Args: block_hash: (str) the block scripthash (e.g. 'a5508c9b6ed0fc09a531a62bc0b3efcb6b8a9250abaf72ab8e9591294c1f6957') ...
python
def get_block_header(self, block_hash, id=None, endpoint=None): """ Get the corresponding block header information according to the specified script hash. Args: block_hash: (str) the block scripthash (e.g. 'a5508c9b6ed0fc09a531a62bc0b3efcb6b8a9250abaf72ab8e9591294c1f6957') ...
[ "def", "get_block_header", "(", "self", ",", "block_hash", ",", "id", "=", "None", ",", "endpoint", "=", "None", ")", ":", "return", "self", ".", "_call_endpoint", "(", "GET_BLOCK_HEADER", ",", "params", "=", "[", "block_hash", ",", "1", "]", ",", "id", ...
Get the corresponding block header information according to the specified script hash. Args: block_hash: (str) the block scripthash (e.g. 'a5508c9b6ed0fc09a531a62bc0b3efcb6b8a9250abaf72ab8e9591294c1f6957') id: (int, optional) id to use for response tracking endpoint: (RPCEndp...
[ "Get", "the", "corresponding", "block", "header", "information", "according", "to", "the", "specified", "script", "hash", ".", "Args", ":", "block_hash", ":", "(", "str", ")", "the", "block", "scripthash", "(", "e", ".", "g", ".", "a5508c9b6ed0fc09a531a62bc0b3...
train
https://github.com/CityOfZion/neo-python-rpc/blob/89d22c4043654b2941bf26b15a1c09082901d9ef/neorpc/Client.py#L116-L127
CityOfZion/neo-python-rpc
neorpc/Client.py
RPCClient.get_block_sysfee
def get_block_sysfee(self, height, id=None, endpoint=None): """ Get the system fee of a block by height. This is used in calculating gas claims Args: height: (int) height of the block to lookup id: (int, optional) id to use for response tracking endpoint: (RP...
python
def get_block_sysfee(self, height, id=None, endpoint=None): """ Get the system fee of a block by height. This is used in calculating gas claims Args: height: (int) height of the block to lookup id: (int, optional) id to use for response tracking endpoint: (RP...
[ "def", "get_block_sysfee", "(", "self", ",", "height", ",", "id", "=", "None", ",", "endpoint", "=", "None", ")", ":", "return", "self", ".", "_call_endpoint", "(", "GET_BLOCK_SYS_FEE", ",", "params", "=", "[", "height", "]", ",", "id", "=", "id", ",",...
Get the system fee of a block by height. This is used in calculating gas claims Args: height: (int) height of the block to lookup id: (int, optional) id to use for response tracking endpoint: (RPCEndpoint, optional) endpoint to specify to use Returns: js...
[ "Get", "the", "system", "fee", "of", "a", "block", "by", "height", ".", "This", "is", "used", "in", "calculating", "gas", "claims", "Args", ":", "height", ":", "(", "int", ")", "height", "of", "the", "block", "to", "lookup", "id", ":", "(", "int", ...
train
https://github.com/CityOfZion/neo-python-rpc/blob/89d22c4043654b2941bf26b15a1c09082901d9ef/neorpc/Client.py#L129-L140
CityOfZion/neo-python-rpc
neorpc/Client.py
RPCClient.get_connection_count
def get_connection_count(self, id=None, endpoint=None): """ Gets the number of nodes connected to the endpoint Args: id: (int, optional) id to use for response tracking endpoint: (RPCEndpoint, optional) endpoint to specify to use Returns: json object o...
python
def get_connection_count(self, id=None, endpoint=None): """ Gets the number of nodes connected to the endpoint Args: id: (int, optional) id to use for response tracking endpoint: (RPCEndpoint, optional) endpoint to specify to use Returns: json object o...
[ "def", "get_connection_count", "(", "self", ",", "id", "=", "None", ",", "endpoint", "=", "None", ")", ":", "return", "self", ".", "_call_endpoint", "(", "GET_CONNECTION_COUNT", ",", "id", "=", "id", ",", "endpoint", "=", "endpoint", ")" ]
Gets the number of nodes connected to the endpoint Args: id: (int, optional) id to use for response tracking endpoint: (RPCEndpoint, optional) endpoint to specify to use Returns: json object of the result or the error encountered in the RPC call
[ "Gets", "the", "number", "of", "nodes", "connected", "to", "the", "endpoint", "Args", ":", "id", ":", "(", "int", "optional", ")", "id", "to", "use", "for", "response", "tracking", "endpoint", ":", "(", "RPCEndpoint", "optional", ")", "endpoint", "to", "...
train
https://github.com/CityOfZion/neo-python-rpc/blob/89d22c4043654b2941bf26b15a1c09082901d9ef/neorpc/Client.py#L142-L151
CityOfZion/neo-python-rpc
neorpc/Client.py
RPCClient.get_contract_state
def get_contract_state(self, contract_hash, id=None, endpoint=None): """ Get a contract state object by its hash Args: contract_hash: (str) the hash of the contract to lookup, for example 'd7678dd97c000be3f33e9362e673101bac4ca654' id: (int, optional) id to use for respons...
python
def get_contract_state(self, contract_hash, id=None, endpoint=None): """ Get a contract state object by its hash Args: contract_hash: (str) the hash of the contract to lookup, for example 'd7678dd97c000be3f33e9362e673101bac4ca654' id: (int, optional) id to use for respons...
[ "def", "get_contract_state", "(", "self", ",", "contract_hash", ",", "id", "=", "None", ",", "endpoint", "=", "None", ")", ":", "return", "self", ".", "_call_endpoint", "(", "GET_CONTRACT_STATE", ",", "params", "=", "[", "contract_hash", "]", ",", "id", "=...
Get a contract state object by its hash Args: contract_hash: (str) the hash of the contract to lookup, for example 'd7678dd97c000be3f33e9362e673101bac4ca654' id: (int, optional) id to use for response tracking endpoint: (RPCEndpoint, optional) endpoint to specify to use ...
[ "Get", "a", "contract", "state", "object", "by", "its", "hash", "Args", ":", "contract_hash", ":", "(", "str", ")", "the", "hash", "of", "the", "contract", "to", "lookup", "for", "example", "d7678dd97c000be3f33e9362e673101bac4ca654", "id", ":", "(", "int", "...
train
https://github.com/CityOfZion/neo-python-rpc/blob/89d22c4043654b2941bf26b15a1c09082901d9ef/neorpc/Client.py#L153-L163
CityOfZion/neo-python-rpc
neorpc/Client.py
RPCClient.get_raw_mempool
def get_raw_mempool(self, id=None, endpoint=None): """ Returns the tx that are in the memorypool of the endpoint Args: id: (int, optional) id to use for response tracking endpoint: (RPCEndpoint, optional) endpoint to specify to use Returns: json object...
python
def get_raw_mempool(self, id=None, endpoint=None): """ Returns the tx that are in the memorypool of the endpoint Args: id: (int, optional) id to use for response tracking endpoint: (RPCEndpoint, optional) endpoint to specify to use Returns: json object...
[ "def", "get_raw_mempool", "(", "self", ",", "id", "=", "None", ",", "endpoint", "=", "None", ")", ":", "return", "self", ".", "_call_endpoint", "(", "GET_RAW_MEMPOOL", ",", "id", "=", "id", ",", "endpoint", "=", "endpoint", ")" ]
Returns the tx that are in the memorypool of the endpoint Args: id: (int, optional) id to use for response tracking endpoint: (RPCEndpoint, optional) endpoint to specify to use Returns: json object of the result or the error encountered in the RPC call
[ "Returns", "the", "tx", "that", "are", "in", "the", "memorypool", "of", "the", "endpoint", "Args", ":", "id", ":", "(", "int", "optional", ")", "id", "to", "use", "for", "response", "tracking", "endpoint", ":", "(", "RPCEndpoint", "optional", ")", "endpo...
train
https://github.com/CityOfZion/neo-python-rpc/blob/89d22c4043654b2941bf26b15a1c09082901d9ef/neorpc/Client.py#L165-L174
CityOfZion/neo-python-rpc
neorpc/Client.py
RPCClient.get_transaction
def get_transaction(self, tx_hash, id=None, endpoint=None): """ Look up a transaction by hash. Args: tx_hash: (str) hash in the form '58c634f81fbd4ae2733d7e3930a9849021840fc19dc6af064d6f2812a333f91d' id: (int, optional) id to use for response tracking endpoint...
python
def get_transaction(self, tx_hash, id=None, endpoint=None): """ Look up a transaction by hash. Args: tx_hash: (str) hash in the form '58c634f81fbd4ae2733d7e3930a9849021840fc19dc6af064d6f2812a333f91d' id: (int, optional) id to use for response tracking endpoint...
[ "def", "get_transaction", "(", "self", ",", "tx_hash", ",", "id", "=", "None", ",", "endpoint", "=", "None", ")", ":", "return", "self", ".", "_call_endpoint", "(", "GET_RAW_TRANSACTION", ",", "params", "=", "[", "tx_hash", ",", "1", "]", ",", "id", "=...
Look up a transaction by hash. Args: tx_hash: (str) hash in the form '58c634f81fbd4ae2733d7e3930a9849021840fc19dc6af064d6f2812a333f91d' id: (int, optional) id to use for response tracking endpoint: (RPCEndpoint, optional) endpoint to specify to use Returns: ...
[ "Look", "up", "a", "transaction", "by", "hash", ".", "Args", ":", "tx_hash", ":", "(", "str", ")", "hash", "in", "the", "form", "58c634f81fbd4ae2733d7e3930a9849021840fc19dc6af064d6f2812a333f91d", "id", ":", "(", "int", "optional", ")", "id", "to", "use", "for"...
train
https://github.com/CityOfZion/neo-python-rpc/blob/89d22c4043654b2941bf26b15a1c09082901d9ef/neorpc/Client.py#L176-L187
CityOfZion/neo-python-rpc
neorpc/Client.py
RPCClient.get_storage
def get_storage(self, contract_hash, storage_key, id=None, endpoint=None): """ Returns a storage item of a specified contract Args: contract_hash: (str) hash of the contract to lookup, for example 'd7678dd97c000be3f33e9362e673101bac4ca654' storage_key: (str) storage key t...
python
def get_storage(self, contract_hash, storage_key, id=None, endpoint=None): """ Returns a storage item of a specified contract Args: contract_hash: (str) hash of the contract to lookup, for example 'd7678dd97c000be3f33e9362e673101bac4ca654' storage_key: (str) storage key t...
[ "def", "get_storage", "(", "self", ",", "contract_hash", ",", "storage_key", ",", "id", "=", "None", ",", "endpoint", "=", "None", ")", ":", "result", "=", "self", ".", "_call_endpoint", "(", "GET_STORAGE", ",", "params", "=", "[", "contract_hash", ",", ...
Returns a storage item of a specified contract Args: contract_hash: (str) hash of the contract to lookup, for example 'd7678dd97c000be3f33e9362e673101bac4ca654' storage_key: (str) storage key to lookup, for example 'totalSupply' id: (int, optional) id to use for response trac...
[ "Returns", "a", "storage", "item", "of", "a", "specified", "contract", "Args", ":", "contract_hash", ":", "(", "str", ")", "hash", "of", "the", "contract", "to", "lookup", "for", "example", "d7678dd97c000be3f33e9362e673101bac4ca654", "storage_key", ":", "(", "st...
train
https://github.com/CityOfZion/neo-python-rpc/blob/89d22c4043654b2941bf26b15a1c09082901d9ef/neorpc/Client.py#L189-L205
CityOfZion/neo-python-rpc
neorpc/Client.py
RPCClient.get_tx_out
def get_tx_out(self, tx_hash, vout_id, id=None, endpoint=None): """ Gets a transaction output by specified transaction hash and output index Args: tx_hash: (str) hash in the form '58c634f81fbd4ae2733d7e3930a9849021840fc19dc6af064d6f2812a333f91d' vout_id: (int) index of th...
python
def get_tx_out(self, tx_hash, vout_id, id=None, endpoint=None): """ Gets a transaction output by specified transaction hash and output index Args: tx_hash: (str) hash in the form '58c634f81fbd4ae2733d7e3930a9849021840fc19dc6af064d6f2812a333f91d' vout_id: (int) index of th...
[ "def", "get_tx_out", "(", "self", ",", "tx_hash", ",", "vout_id", ",", "id", "=", "None", ",", "endpoint", "=", "None", ")", ":", "return", "self", ".", "_call_endpoint", "(", "GET_TX_OUT", ",", "params", "=", "[", "tx_hash", ",", "vout_id", "]", ",", ...
Gets a transaction output by specified transaction hash and output index Args: tx_hash: (str) hash in the form '58c634f81fbd4ae2733d7e3930a9849021840fc19dc6af064d6f2812a333f91d' vout_id: (int) index of the transaction output in the transaction id: (int, optional) id to use fo...
[ "Gets", "a", "transaction", "output", "by", "specified", "transaction", "hash", "and", "output", "index", "Args", ":", "tx_hash", ":", "(", "str", ")", "hash", "in", "the", "form", "58c634f81fbd4ae2733d7e3930a9849021840fc19dc6af064d6f2812a333f91d", "vout_id", ":", "...
train
https://github.com/CityOfZion/neo-python-rpc/blob/89d22c4043654b2941bf26b15a1c09082901d9ef/neorpc/Client.py#L207-L218
CityOfZion/neo-python-rpc
neorpc/Client.py
RPCClient.invoke_contract
def invoke_contract(self, contract_hash, params, id=None, endpoint=None): """ Invokes a contract Args: contract_hash: (str) hash of the contract, for example 'd7678dd97c000be3f33e9362e673101bac4ca654' params: (list) a list of json ContractParameters to pass along with the...
python
def invoke_contract(self, contract_hash, params, id=None, endpoint=None): """ Invokes a contract Args: contract_hash: (str) hash of the contract, for example 'd7678dd97c000be3f33e9362e673101bac4ca654' params: (list) a list of json ContractParameters to pass along with the...
[ "def", "invoke_contract", "(", "self", ",", "contract_hash", ",", "params", ",", "id", "=", "None", ",", "endpoint", "=", "None", ")", ":", "return", "self", ".", "_call_endpoint", "(", "INVOKE", ",", "params", "=", "[", "contract_hash", ",", "params", "...
Invokes a contract Args: contract_hash: (str) hash of the contract, for example 'd7678dd97c000be3f33e9362e673101bac4ca654' params: (list) a list of json ContractParameters to pass along with the invocation, example [{'type':7,'value':'symbol'},{'type':16, 'value':[]}] id: (in...
[ "Invokes", "a", "contract", "Args", ":", "contract_hash", ":", "(", "str", ")", "hash", "of", "the", "contract", "for", "example", "d7678dd97c000be3f33e9362e673101bac4ca654", "params", ":", "(", "list", ")", "a", "list", "of", "json", "ContractParameters", "to",...
train
https://github.com/CityOfZion/neo-python-rpc/blob/89d22c4043654b2941bf26b15a1c09082901d9ef/neorpc/Client.py#L220-L231
CityOfZion/neo-python-rpc
neorpc/Client.py
RPCClient.invoke_contract_fn
def invoke_contract_fn(self, contract_hash, operation, params=None, id=None, endpoint=None): """ Invokes a contract Args: contract_hash: (str) hash of the contract, for example 'd7678dd97c000be3f33e9362e673101bac4ca654' operation: (str) the operation to call on the contra...
python
def invoke_contract_fn(self, contract_hash, operation, params=None, id=None, endpoint=None): """ Invokes a contract Args: contract_hash: (str) hash of the contract, for example 'd7678dd97c000be3f33e9362e673101bac4ca654' operation: (str) the operation to call on the contra...
[ "def", "invoke_contract_fn", "(", "self", ",", "contract_hash", ",", "operation", ",", "params", "=", "None", ",", "id", "=", "None", ",", "endpoint", "=", "None", ")", ":", "return", "self", ".", "_call_endpoint", "(", "INVOKE_FUNCTION", ",", "params", "=...
Invokes a contract Args: contract_hash: (str) hash of the contract, for example 'd7678dd97c000be3f33e9362e673101bac4ca654' operation: (str) the operation to call on the contract params: (list) a list of json ContractParameters to pass along with the invocation, example [{'typ...
[ "Invokes", "a", "contract", "Args", ":", "contract_hash", ":", "(", "str", ")", "hash", "of", "the", "contract", "for", "example", "d7678dd97c000be3f33e9362e673101bac4ca654", "operation", ":", "(", "str", ")", "the", "operation", "to", "call", "on", "the", "co...
train
https://github.com/CityOfZion/neo-python-rpc/blob/89d22c4043654b2941bf26b15a1c09082901d9ef/neorpc/Client.py#L233-L245
CityOfZion/neo-python-rpc
neorpc/Client.py
RPCClient.invoke_script
def invoke_script(self, script, id=None, endpoint=None): """ Invokes a script that has been assembled Args: script: (str) a hexlified string of a contract invocation script, example '00c10b746f74616c537570706c796754a64cac1b1073e662933ef3e30b007cd98d67d7' id: (int, optiona...
python
def invoke_script(self, script, id=None, endpoint=None): """ Invokes a script that has been assembled Args: script: (str) a hexlified string of a contract invocation script, example '00c10b746f74616c537570706c796754a64cac1b1073e662933ef3e30b007cd98d67d7' id: (int, optiona...
[ "def", "invoke_script", "(", "self", ",", "script", ",", "id", "=", "None", ",", "endpoint", "=", "None", ")", ":", "return", "self", ".", "_call_endpoint", "(", "INVOKE_SCRIPT", ",", "params", "=", "[", "script", "]", ",", "id", "=", "id", ",", "end...
Invokes a script that has been assembled Args: script: (str) a hexlified string of a contract invocation script, example '00c10b746f74616c537570706c796754a64cac1b1073e662933ef3e30b007cd98d67d7' id: (int, optional) id to use for response tracking endpoint: (RPCEndpoint, option...
[ "Invokes", "a", "script", "that", "has", "been", "assembled", "Args", ":", "script", ":", "(", "str", ")", "a", "hexlified", "string", "of", "a", "contract", "invocation", "script", "example", "00c10b746f74616c537570706c796754a64cac1b1073e662933ef3e30b007cd98d67d7", "...
train
https://github.com/CityOfZion/neo-python-rpc/blob/89d22c4043654b2941bf26b15a1c09082901d9ef/neorpc/Client.py#L247-L257
CityOfZion/neo-python-rpc
neorpc/Client.py
RPCClient.send_raw_tx
def send_raw_tx(self, serialized_tx, id=None, endpoint=None): """ Submits a serialized tx to the network Args: serialized_tx: (str) a hexlified string of a transaction id: (int, optional) id to use for response tracking endpoint: (RPCEndpoint, optional) endpoi...
python
def send_raw_tx(self, serialized_tx, id=None, endpoint=None): """ Submits a serialized tx to the network Args: serialized_tx: (str) a hexlified string of a transaction id: (int, optional) id to use for response tracking endpoint: (RPCEndpoint, optional) endpoi...
[ "def", "send_raw_tx", "(", "self", ",", "serialized_tx", ",", "id", "=", "None", ",", "endpoint", "=", "None", ")", ":", "return", "self", ".", "_call_endpoint", "(", "SEND_TX", ",", "params", "=", "[", "serialized_tx", "]", ",", "id", "=", "id", ",", ...
Submits a serialized tx to the network Args: serialized_tx: (str) a hexlified string of a transaction id: (int, optional) id to use for response tracking endpoint: (RPCEndpoint, optional) endpoint to specify to use Returns: bool: whether the tx was accepte...
[ "Submits", "a", "serialized", "tx", "to", "the", "network", "Args", ":", "serialized_tx", ":", "(", "str", ")", "a", "hexlified", "string", "of", "a", "transaction", "id", ":", "(", "int", "optional", ")", "id", "to", "use", "for", "response", "tracking"...
train
https://github.com/CityOfZion/neo-python-rpc/blob/89d22c4043654b2941bf26b15a1c09082901d9ef/neorpc/Client.py#L259-L269
CityOfZion/neo-python-rpc
neorpc/Client.py
RPCClient.validate_addr
def validate_addr(self, address, id=None, endpoint=None): """ returns whether or not addr string is valid Args: address: (str) address to lookup ( in format 'AXjaFSP23Jkbe6Pk9pPGT6NBDs1HVdqaXK') id: (int, optional) id to use for response tracking endpoint: (R...
python
def validate_addr(self, address, id=None, endpoint=None): """ returns whether or not addr string is valid Args: address: (str) address to lookup ( in format 'AXjaFSP23Jkbe6Pk9pPGT6NBDs1HVdqaXK') id: (int, optional) id to use for response tracking endpoint: (R...
[ "def", "validate_addr", "(", "self", ",", "address", ",", "id", "=", "None", ",", "endpoint", "=", "None", ")", ":", "return", "self", ".", "_call_endpoint", "(", "VALIDATE_ADDR", ",", "params", "=", "[", "address", "]", ",", "id", "=", "id", ",", "e...
returns whether or not addr string is valid Args: address: (str) address to lookup ( in format 'AXjaFSP23Jkbe6Pk9pPGT6NBDs1HVdqaXK') id: (int, optional) id to use for response tracking endpoint: (RPCEndpoint, optional) endpoint to specify to use Returns: ...
[ "returns", "whether", "or", "not", "addr", "string", "is", "valid" ]
train
https://github.com/CityOfZion/neo-python-rpc/blob/89d22c4043654b2941bf26b15a1c09082901d9ef/neorpc/Client.py#L271-L284
CityOfZion/neo-python-rpc
neorpc/Client.py
RPCClient.get_peers
def get_peers(self, id=None, endpoint=None): """ Get the current peers of a remote node Args: id: (int, optional) id to use for response tracking endpoint: (RPCEndpoint, optional) endpoint to specify to use Returns: json object of the result or the er...
python
def get_peers(self, id=None, endpoint=None): """ Get the current peers of a remote node Args: id: (int, optional) id to use for response tracking endpoint: (RPCEndpoint, optional) endpoint to specify to use Returns: json object of the result or the er...
[ "def", "get_peers", "(", "self", ",", "id", "=", "None", ",", "endpoint", "=", "None", ")", ":", "return", "self", ".", "_call_endpoint", "(", "GET_PEERS", ",", "id", "=", "id", ",", "endpoint", "=", "endpoint", ")" ]
Get the current peers of a remote node Args: id: (int, optional) id to use for response tracking endpoint: (RPCEndpoint, optional) endpoint to specify to use Returns: json object of the result or the error encountered in the RPC call
[ "Get", "the", "current", "peers", "of", "a", "remote", "node", "Args", ":", "id", ":", "(", "int", "optional", ")", "id", "to", "use", "for", "response", "tracking", "endpoint", ":", "(", "RPCEndpoint", "optional", ")", "endpoint", "to", "specify", "to",...
train
https://github.com/CityOfZion/neo-python-rpc/blob/89d22c4043654b2941bf26b15a1c09082901d9ef/neorpc/Client.py#L286-L296
CityOfZion/neo-python-rpc
neorpc/Client.py
RPCClient.get_validators
def get_validators(self, id=None, endpoint=None): """ Returns the current NEO consensus nodes information and voting status. Args: id: (int, optional) id to use for response tracking endpoint: (RPCEndpoint, optional) endpoint to specify to use Returns: ...
python
def get_validators(self, id=None, endpoint=None): """ Returns the current NEO consensus nodes information and voting status. Args: id: (int, optional) id to use for response tracking endpoint: (RPCEndpoint, optional) endpoint to specify to use Returns: ...
[ "def", "get_validators", "(", "self", ",", "id", "=", "None", ",", "endpoint", "=", "None", ")", ":", "return", "self", ".", "_call_endpoint", "(", "GET_VALIDATORS", ",", "id", "=", "id", ",", "endpoint", "=", "endpoint", ")" ]
Returns the current NEO consensus nodes information and voting status. Args: id: (int, optional) id to use for response tracking endpoint: (RPCEndpoint, optional) endpoint to specify to use Returns: json object of the result or the error encountered in the RPC call
[ "Returns", "the", "current", "NEO", "consensus", "nodes", "information", "and", "voting", "status", ".", "Args", ":", "id", ":", "(", "int", "optional", ")", "id", "to", "use", "for", "response", "tracking", "endpoint", ":", "(", "RPCEndpoint", "optional", ...
train
https://github.com/CityOfZion/neo-python-rpc/blob/89d22c4043654b2941bf26b15a1c09082901d9ef/neorpc/Client.py#L298-L308
CityOfZion/neo-python-rpc
neorpc/Client.py
RPCClient.get_version
def get_version(self, id=None, endpoint=None): """ Get the current version of the endpoint. Note: Not all endpoints currently implement this method Args: id: (int, optional) id to use for response tracking endpoint: (RPCEndpoint, optional) endpoint to specify to ...
python
def get_version(self, id=None, endpoint=None): """ Get the current version of the endpoint. Note: Not all endpoints currently implement this method Args: id: (int, optional) id to use for response tracking endpoint: (RPCEndpoint, optional) endpoint to specify to ...
[ "def", "get_version", "(", "self", ",", "id", "=", "None", ",", "endpoint", "=", "None", ")", ":", "return", "self", ".", "_call_endpoint", "(", "GET_VERSION", ",", "id", "=", "id", ",", "endpoint", "=", "endpoint", ")" ]
Get the current version of the endpoint. Note: Not all endpoints currently implement this method Args: id: (int, optional) id to use for response tracking endpoint: (RPCEndpoint, optional) endpoint to specify to use Returns: json object of the result or the e...
[ "Get", "the", "current", "version", "of", "the", "endpoint", ".", "Note", ":", "Not", "all", "endpoints", "currently", "implement", "this", "method" ]
train
https://github.com/CityOfZion/neo-python-rpc/blob/89d22c4043654b2941bf26b15a1c09082901d9ef/neorpc/Client.py#L310-L321
CityOfZion/neo-python-rpc
neorpc/Client.py
RPCClient.get_new_address
def get_new_address(self, id=None, endpoint=None): """ Create new address Args: id: (int, optional) id to use for response tracking endpoint: (RPCEndpoint, optional) endpoint to specify to use Returns: json object of the result or the error encountered...
python
def get_new_address(self, id=None, endpoint=None): """ Create new address Args: id: (int, optional) id to use for response tracking endpoint: (RPCEndpoint, optional) endpoint to specify to use Returns: json object of the result or the error encountered...
[ "def", "get_new_address", "(", "self", ",", "id", "=", "None", ",", "endpoint", "=", "None", ")", ":", "return", "self", ".", "_call_endpoint", "(", "GET_NEW_ADDRESS", ",", "id", "=", "id", ",", "endpoint", "=", "endpoint", ")" ]
Create new address Args: id: (int, optional) id to use for response tracking endpoint: (RPCEndpoint, optional) endpoint to specify to use Returns: json object of the result or the error encountered in the RPC call
[ "Create", "new", "address", "Args", ":", "id", ":", "(", "int", "optional", ")", "id", "to", "use", "for", "response", "tracking", "endpoint", ":", "(", "RPCEndpoint", "optional", ")", "endpoint", "to", "specify", "to", "use", "Returns", ":", "json", "ob...
train
https://github.com/CityOfZion/neo-python-rpc/blob/89d22c4043654b2941bf26b15a1c09082901d9ef/neorpc/Client.py#L323-L332
CityOfZion/neo-python-rpc
neorpc/Client.py
RPCClient.get_wallet_height
def get_wallet_height(self, id=None, endpoint=None): """ Get the current wallet index height. Args: id: (int, optional) id to use for response tracking endpoint: (RPCEndpoint, optional) endpoint to specify to use Returns: json object of the result or t...
python
def get_wallet_height(self, id=None, endpoint=None): """ Get the current wallet index height. Args: id: (int, optional) id to use for response tracking endpoint: (RPCEndpoint, optional) endpoint to specify to use Returns: json object of the result or t...
[ "def", "get_wallet_height", "(", "self", ",", "id", "=", "None", ",", "endpoint", "=", "None", ")", ":", "return", "self", ".", "_call_endpoint", "(", "GET_WALLET_HEIGHT", ",", "id", "=", "id", ",", "endpoint", "=", "endpoint", ")" ]
Get the current wallet index height. Args: id: (int, optional) id to use for response tracking endpoint: (RPCEndpoint, optional) endpoint to specify to use Returns: json object of the result or the error encountered in the RPC call
[ "Get", "the", "current", "wallet", "index", "height", ".", "Args", ":", "id", ":", "(", "int", "optional", ")", "id", "to", "use", "for", "response", "tracking", "endpoint", ":", "(", "RPCEndpoint", "optional", ")", "endpoint", "to", "specify", "to", "us...
train
https://github.com/CityOfZion/neo-python-rpc/blob/89d22c4043654b2941bf26b15a1c09082901d9ef/neorpc/Client.py#L334-L343
CityOfZion/neo-python-rpc
neorpc/Client.py
RPCClient.list_address
def list_address(self, id=None, endpoint=None): """ Lists all the addresses in the current wallet. Args: id: (int, optional) id to use for response tracking endpoint: (RPCEndpoint, optional) endpoint to specify to use Returns: json object of the result...
python
def list_address(self, id=None, endpoint=None): """ Lists all the addresses in the current wallet. Args: id: (int, optional) id to use for response tracking endpoint: (RPCEndpoint, optional) endpoint to specify to use Returns: json object of the result...
[ "def", "list_address", "(", "self", ",", "id", "=", "None", ",", "endpoint", "=", "None", ")", ":", "return", "self", ".", "_call_endpoint", "(", "LIST_ADDRESS", ",", "id", "=", "id", ",", "endpoint", "=", "endpoint", ")" ]
Lists all the addresses in the current wallet. Args: id: (int, optional) id to use for response tracking endpoint: (RPCEndpoint, optional) endpoint to specify to use Returns: json object of the result or the error encountered in the RPC call
[ "Lists", "all", "the", "addresses", "in", "the", "current", "wallet", ".", "Args", ":", "id", ":", "(", "int", "optional", ")", "id", "to", "use", "for", "response", "tracking", "endpoint", ":", "(", "RPCEndpoint", "optional", ")", "endpoint", "to", "spe...
train
https://github.com/CityOfZion/neo-python-rpc/blob/89d22c4043654b2941bf26b15a1c09082901d9ef/neorpc/Client.py#L345-L354
CityOfZion/neo-python-rpc
neorpc/Client.py
RPCClient.send_from
def send_from(self, asset_id, addr_from, to_addr, value, fee=None, change_addr=None, id=None, endpoint=None): """ Transfer from the specified address to the destination address. Args: asset_id: (str) asset identifier (for NEO: 'c56f33fc6ecfcd0c225c4ab356fee59390af8560be0e930faebe74a6...
python
def send_from(self, asset_id, addr_from, to_addr, value, fee=None, change_addr=None, id=None, endpoint=None): """ Transfer from the specified address to the destination address. Args: asset_id: (str) asset identifier (for NEO: 'c56f33fc6ecfcd0c225c4ab356fee59390af8560be0e930faebe74a6...
[ "def", "send_from", "(", "self", ",", "asset_id", ",", "addr_from", ",", "to_addr", ",", "value", ",", "fee", "=", "None", ",", "change_addr", "=", "None", ",", "id", "=", "None", ",", "endpoint", "=", "None", ")", ":", "params", "=", "[", "asset_id"...
Transfer from the specified address to the destination address. Args: asset_id: (str) asset identifier (for NEO: 'c56f33fc6ecfcd0c225c4ab356fee59390af8560be0e930faebe74a6daff7c9b', for GAS: '602c79718b16e442de58778e148d0b1084e3b2dffd5de6b7b16cee7969282de7') addr_from: (str) transfering a...
[ "Transfer", "from", "the", "specified", "address", "to", "the", "destination", "address", ".", "Args", ":", "asset_id", ":", "(", "str", ")", "asset", "identifier", "(", "for", "NEO", ":", "c56f33fc6ecfcd0c225c4ab356fee59390af8560be0e930faebe74a6daff7c9b", "for", "G...
train
https://github.com/CityOfZion/neo-python-rpc/blob/89d22c4043654b2941bf26b15a1c09082901d9ef/neorpc/Client.py#L356-L379
CityOfZion/neo-python-rpc
neorpc/Client.py
RPCClient.send_to_address
def send_to_address(self, asset_id, to_addr, value, fee=None, change_addr=None, id=None, endpoint=None): """ Args: asset_id: (str) asset identifier (for NEO: 'c56f33fc6ecfcd0c225c4ab356fee59390af8560be0e930faebe74a6daff7c9b', for GAS: '602c79718b16e442de58778e148d0b1084e3b2dffd5de6b7b16cee79...
python
def send_to_address(self, asset_id, to_addr, value, fee=None, change_addr=None, id=None, endpoint=None): """ Args: asset_id: (str) asset identifier (for NEO: 'c56f33fc6ecfcd0c225c4ab356fee59390af8560be0e930faebe74a6daff7c9b', for GAS: '602c79718b16e442de58778e148d0b1084e3b2dffd5de6b7b16cee79...
[ "def", "send_to_address", "(", "self", ",", "asset_id", ",", "to_addr", ",", "value", ",", "fee", "=", "None", ",", "change_addr", "=", "None", ",", "id", "=", "None", ",", "endpoint", "=", "None", ")", ":", "params", "=", "[", "asset_id", ",", "to_a...
Args: asset_id: (str) asset identifier (for NEO: 'c56f33fc6ecfcd0c225c4ab356fee59390af8560be0e930faebe74a6daff7c9b', for GAS: '602c79718b16e442de58778e148d0b1084e3b2dffd5de6b7b16cee7969282de7') to_addr: (str) destination address value: (int/decimal) transfer amount fee: (...
[ "Args", ":", "asset_id", ":", "(", "str", ")", "asset", "identifier", "(", "for", "NEO", ":", "c56f33fc6ecfcd0c225c4ab356fee59390af8560be0e930faebe74a6daff7c9b", "for", "GAS", ":", "602c79718b16e442de58778e148d0b1084e3b2dffd5de6b7b16cee7969282de7", ")", "to_addr", ":", "(",...
train
https://github.com/CityOfZion/neo-python-rpc/blob/89d22c4043654b2941bf26b15a1c09082901d9ef/neorpc/Client.py#L381-L402
CityOfZion/neo-python-rpc
neorpc/Client.py
RPCClient.send_many
def send_many(self, outputs_array, fee=None, change_addr=None, id=None, endpoint=None): """ Args: outputs_array: (dict) array, the data structure of each element in the array is as follows: {"asset": <asset>,"value": <value>,"address": <address>} asset: (str) ...
python
def send_many(self, outputs_array, fee=None, change_addr=None, id=None, endpoint=None): """ Args: outputs_array: (dict) array, the data structure of each element in the array is as follows: {"asset": <asset>,"value": <value>,"address": <address>} asset: (str) ...
[ "def", "send_many", "(", "self", ",", "outputs_array", ",", "fee", "=", "None", ",", "change_addr", "=", "None", ",", "id", "=", "None", ",", "endpoint", "=", "None", ")", ":", "params", "=", "[", "outputs_array", "]", "if", "fee", ":", "params", "."...
Args: outputs_array: (dict) array, the data structure of each element in the array is as follows: {"asset": <asset>,"value": <value>,"address": <address>} asset: (str) asset identifier (for NEO: 'c56f33fc6ecfcd0c225c4ab356fee59390af8560be0e930faebe74a6daff7c9b', for GAS: '602...
[ "Args", ":", "outputs_array", ":", "(", "dict", ")", "array", "the", "data", "structure", "of", "each", "element", "in", "the", "array", "is", "as", "follows", ":", "{", "asset", ":", "<asset", ">", "value", ":", "<value", ">", "address", ":", "<addres...
train
https://github.com/CityOfZion/neo-python-rpc/blob/89d22c4043654b2941bf26b15a1c09082901d9ef/neorpc/Client.py#L404-L425
adrn/schwimmbad
schwimmbad/__init__.py
choose_pool
def choose_pool(mpi=False, processes=1, **kwargs): """ Choose between the different pools given options from, e.g., argparse. Parameters ---------- mpi : bool, optional Use the MPI processing pool, :class:`~schwimmbad.mpi.MPIPool`. By default, ``False``, will use the :class:`~schwim...
python
def choose_pool(mpi=False, processes=1, **kwargs): """ Choose between the different pools given options from, e.g., argparse. Parameters ---------- mpi : bool, optional Use the MPI processing pool, :class:`~schwimmbad.mpi.MPIPool`. By default, ``False``, will use the :class:`~schwim...
[ "def", "choose_pool", "(", "mpi", "=", "False", ",", "processes", "=", "1", ",", "*", "*", "kwargs", ")", ":", "if", "mpi", ":", "if", "not", "MPIPool", ".", "enabled", "(", ")", ":", "raise", "SystemError", "(", "\"Tried to run with MPI but MPIPool not en...
Choose between the different pools given options from, e.g., argparse. Parameters ---------- mpi : bool, optional Use the MPI processing pool, :class:`~schwimmbad.mpi.MPIPool`. By default, ``False``, will use the :class:`~schwimmbad.serial.SerialPool`. processes : int, optional ...
[ "Choose", "between", "the", "different", "pools", "given", "options", "from", "e", ".", "g", ".", "argparse", "." ]
train
https://github.com/adrn/schwimmbad/blob/d2538b77c821a56096f92eafecd1c08dd02f1f58/schwimmbad/__init__.py#L30-L67
adrn/schwimmbad
schwimmbad/mpi.py
MPIPool.wait
def wait(self, callback=None): """Tell the workers to wait and listen for the master process. This is called automatically when using :meth:`MPIPool.map` and doesn't need to be called by the user. """ if self.is_master(): return worker = self.comm.rank ...
python
def wait(self, callback=None): """Tell the workers to wait and listen for the master process. This is called automatically when using :meth:`MPIPool.map` and doesn't need to be called by the user. """ if self.is_master(): return worker = self.comm.rank ...
[ "def", "wait", "(", "self", ",", "callback", "=", "None", ")", ":", "if", "self", ".", "is_master", "(", ")", ":", "return", "worker", "=", "self", ".", "comm", ".", "rank", "status", "=", "MPI", ".", "Status", "(", ")", "while", "True", ":", "lo...
Tell the workers to wait and listen for the master process. This is called automatically when using :meth:`MPIPool.map` and doesn't need to be called by the user.
[ "Tell", "the", "workers", "to", "wait", "and", "listen", "for", "the", "master", "process", ".", "This", "is", "called", "automatically", "when", "using", ":", "meth", ":", "MPIPool", ".", "map", "and", "doesn", "t", "need", "to", "be", "called", "by", ...
train
https://github.com/adrn/schwimmbad/blob/d2538b77c821a56096f92eafecd1c08dd02f1f58/schwimmbad/mpi.py#L74-L106
adrn/schwimmbad
schwimmbad/mpi.py
MPIPool.map
def map(self, worker, tasks, callback=None): """Evaluate a function or callable on each task in parallel using MPI. The callable, ``worker``, is called on each element of the ``tasks`` iterable. The results are returned in the expected order (symmetric with ``tasks``). Paramete...
python
def map(self, worker, tasks, callback=None): """Evaluate a function or callable on each task in parallel using MPI. The callable, ``worker``, is called on each element of the ``tasks`` iterable. The results are returned in the expected order (symmetric with ``tasks``). Paramete...
[ "def", "map", "(", "self", ",", "worker", ",", "tasks", ",", "callback", "=", "None", ")", ":", "# If not the master just wait for instructions.", "if", "not", "self", ".", "is_master", "(", ")", ":", "self", ".", "wait", "(", ")", "return", "if", "callbac...
Evaluate a function or callable on each task in parallel using MPI. The callable, ``worker``, is called on each element of the ``tasks`` iterable. The results are returned in the expected order (symmetric with ``tasks``). Parameters ---------- worker : callable ...
[ "Evaluate", "a", "function", "or", "callable", "on", "each", "task", "in", "parallel", "using", "MPI", "." ]
train
https://github.com/adrn/schwimmbad/blob/d2538b77c821a56096f92eafecd1c08dd02f1f58/schwimmbad/mpi.py#L108-L180
adrn/schwimmbad
schwimmbad/mpi.py
MPIPool.close
def close(self): """ Tell all the workers to quit.""" if self.is_worker(): return for worker in self.workers: self.comm.send(None, worker, 0)
python
def close(self): """ Tell all the workers to quit.""" if self.is_worker(): return for worker in self.workers: self.comm.send(None, worker, 0)
[ "def", "close", "(", "self", ")", ":", "if", "self", ".", "is_worker", "(", ")", ":", "return", "for", "worker", "in", "self", ".", "workers", ":", "self", ".", "comm", ".", "send", "(", "None", ",", "worker", ",", "0", ")" ]
Tell all the workers to quit.
[ "Tell", "all", "the", "workers", "to", "quit", "." ]
train
https://github.com/adrn/schwimmbad/blob/d2538b77c821a56096f92eafecd1c08dd02f1f58/schwimmbad/mpi.py#L182-L188
adrn/schwimmbad
setup.py
update_git_devstr
def update_git_devstr(version, path=None): """ Updates the git revision string if and only if the path is being imported directly from a git working copy. This ensures that the revision number in the version string is accurate. """ try: # Quick way to determine if we're in git or not -...
python
def update_git_devstr(version, path=None): """ Updates the git revision string if and only if the path is being imported directly from a git working copy. This ensures that the revision number in the version string is accurate. """ try: # Quick way to determine if we're in git or not -...
[ "def", "update_git_devstr", "(", "version", ",", "path", "=", "None", ")", ":", "try", ":", "# Quick way to determine if we're in git or not - returns '' if not", "devstr", "=", "get_git_devstr", "(", "sha", "=", "True", ",", "show_warning", "=", "False", ",", "path...
Updates the git revision string if and only if the path is being imported directly from a git working copy. This ensures that the revision number in the version string is accurate.
[ "Updates", "the", "git", "revision", "string", "if", "and", "only", "if", "the", "path", "is", "being", "imported", "directly", "from", "a", "git", "working", "copy", ".", "This", "ensures", "that", "the", "revision", "number", "in", "the", "version", "str...
train
https://github.com/adrn/schwimmbad/blob/d2538b77c821a56096f92eafecd1c08dd02f1f58/setup.py#L58-L82
adrn/schwimmbad
setup.py
get_git_devstr
def get_git_devstr(sha=False, show_warning=True, path=None): """ Determines the number of revisions in this repository. Parameters ---------- sha : bool If True, the full SHA1 hash will be returned. Otherwise, the total count of commits in the repository will be used as a "revision ...
python
def get_git_devstr(sha=False, show_warning=True, path=None): """ Determines the number of revisions in this repository. Parameters ---------- sha : bool If True, the full SHA1 hash will be returned. Otherwise, the total count of commits in the repository will be used as a "revision ...
[ "def", "get_git_devstr", "(", "sha", "=", "False", ",", "show_warning", "=", "True", ",", "path", "=", "None", ")", ":", "if", "path", "is", "None", ":", "path", "=", "os", ".", "getcwd", "(", ")", "if", "not", "_get_repo_path", "(", "path", ",", "...
Determines the number of revisions in this repository. Parameters ---------- sha : bool If True, the full SHA1 hash will be returned. Otherwise, the total count of commits in the repository will be used as a "revision number". show_warning : bool If True, issue a warnin...
[ "Determines", "the", "number", "of", "revisions", "in", "this", "repository", "." ]
train
https://github.com/adrn/schwimmbad/blob/d2538b77c821a56096f92eafecd1c08dd02f1f58/setup.py#L85-L179
adrn/schwimmbad
setup.py
_get_repo_path
def _get_repo_path(pathname, levels=None): """ Given a file or directory name, determine the root of the git repository this path is under. If given, this won't look any higher than ``levels`` (that is, if ``levels=0`` then the given path must be the root of the git repository and is returned if so...
python
def _get_repo_path(pathname, levels=None): """ Given a file or directory name, determine the root of the git repository this path is under. If given, this won't look any higher than ``levels`` (that is, if ``levels=0`` then the given path must be the root of the git repository and is returned if so...
[ "def", "_get_repo_path", "(", "pathname", ",", "levels", "=", "None", ")", ":", "if", "os", ".", "path", ".", "isfile", "(", "pathname", ")", ":", "current_dir", "=", "os", ".", "path", ".", "abspath", "(", "os", ".", "path", ".", "dirname", "(", "...
Given a file or directory name, determine the root of the git repository this path is under. If given, this won't look any higher than ``levels`` (that is, if ``levels=0`` then the given path must be the root of the git repository and is returned if so. Returns `None` if the given path could not be de...
[ "Given", "a", "file", "or", "directory", "name", "determine", "the", "root", "of", "the", "git", "repository", "this", "path", "is", "under", ".", "If", "given", "this", "won", "t", "look", "any", "higher", "than", "levels", "(", "that", "is", "if", "l...
train
https://github.com/adrn/schwimmbad/blob/d2538b77c821a56096f92eafecd1c08dd02f1f58/setup.py#L182-L212
adrn/schwimmbad
schwimmbad/serial.py
SerialPool.map
def map(self, func, iterable, callback=None): """A wrapper around the built-in ``map()`` function to provide a consistent interface with the other ``Pool`` classes. Parameters ---------- worker : callable A function or callable object that is executed on each element...
python
def map(self, func, iterable, callback=None): """A wrapper around the built-in ``map()`` function to provide a consistent interface with the other ``Pool`` classes. Parameters ---------- worker : callable A function or callable object that is executed on each element...
[ "def", "map", "(", "self", ",", "func", ",", "iterable", ",", "callback", "=", "None", ")", ":", "return", "self", ".", "_call_callback", "(", "callback", ",", "map", "(", "func", ",", "iterable", ")", ")" ]
A wrapper around the built-in ``map()`` function to provide a consistent interface with the other ``Pool`` classes. Parameters ---------- worker : callable A function or callable object that is executed on each element of the specified ``tasks`` iterable. This ob...
[ "A", "wrapper", "around", "the", "built", "-", "in", "map", "()", "function", "to", "provide", "a", "consistent", "interface", "with", "the", "other", "Pool", "classes", "." ]
train
https://github.com/adrn/schwimmbad/blob/d2538b77c821a56096f92eafecd1c08dd02f1f58/schwimmbad/serial.py#L26-L52
openvax/varcode
varcode/effects/translate.py
translate_codon
def translate_codon(codon, aa_pos): """Translate a single codon into a single amino acid or stop '*' Parameters ---------- codon : str Expected to be of length 3 aa_pos : int Codon/amino acid offset into the protein (starting from 0) """ # not handling rare Leucine or Valine...
python
def translate_codon(codon, aa_pos): """Translate a single codon into a single amino acid or stop '*' Parameters ---------- codon : str Expected to be of length 3 aa_pos : int Codon/amino acid offset into the protein (starting from 0) """ # not handling rare Leucine or Valine...
[ "def", "translate_codon", "(", "codon", ",", "aa_pos", ")", ":", "# not handling rare Leucine or Valine starts!", "if", "aa_pos", "==", "0", "and", "codon", "in", "START_CODONS", ":", "return", "\"M\"", "elif", "codon", "in", "STOP_CODONS", ":", "return", "\"*\"",...
Translate a single codon into a single amino acid or stop '*' Parameters ---------- codon : str Expected to be of length 3 aa_pos : int Codon/amino acid offset into the protein (starting from 0)
[ "Translate", "a", "single", "codon", "into", "a", "single", "amino", "acid", "or", "stop", "*" ]
train
https://github.com/openvax/varcode/blob/981633db45ca2b31f76c06894a7360ea5d70a9b8/varcode/effects/translate.py#L31-L47
openvax/varcode
varcode/effects/translate.py
translate
def translate( nucleotide_sequence, first_codon_is_start=True, to_stop=True, truncate=False): """Translates cDNA coding sequence into amino acid protein sequence. Should typically start with a start codon but allowing non-methionine first residues since the CDS we're transla...
python
def translate( nucleotide_sequence, first_codon_is_start=True, to_stop=True, truncate=False): """Translates cDNA coding sequence into amino acid protein sequence. Should typically start with a start codon but allowing non-methionine first residues since the CDS we're transla...
[ "def", "translate", "(", "nucleotide_sequence", ",", "first_codon_is_start", "=", "True", ",", "to_stop", "=", "True", ",", "truncate", "=", "False", ")", ":", "if", "not", "isinstance", "(", "nucleotide_sequence", ",", "Seq", ")", ":", "nucleotide_sequence", ...
Translates cDNA coding sequence into amino acid protein sequence. Should typically start with a start codon but allowing non-methionine first residues since the CDS we're translating might have been affected by a start loss mutation. The sequence may include the 3' UTR but will stop translation at the...
[ "Translates", "cDNA", "coding", "sequence", "into", "amino", "acid", "protein", "sequence", "." ]
train
https://github.com/openvax/varcode/blob/981633db45ca2b31f76c06894a7360ea5d70a9b8/varcode/effects/translate.py#L50-L113
openvax/varcode
varcode/effects/translate.py
find_first_stop_codon
def find_first_stop_codon(nucleotide_sequence): """ Given a sequence of codons (expected to have length multiple of three), return index of first stop codon, or -1 if none is in the sequence. """ n_mutant_codons = len(nucleotide_sequence) // 3 for i in range(n_mutant_codons): codon = nuc...
python
def find_first_stop_codon(nucleotide_sequence): """ Given a sequence of codons (expected to have length multiple of three), return index of first stop codon, or -1 if none is in the sequence. """ n_mutant_codons = len(nucleotide_sequence) // 3 for i in range(n_mutant_codons): codon = nuc...
[ "def", "find_first_stop_codon", "(", "nucleotide_sequence", ")", ":", "n_mutant_codons", "=", "len", "(", "nucleotide_sequence", ")", "//", "3", "for", "i", "in", "range", "(", "n_mutant_codons", ")", ":", "codon", "=", "nucleotide_sequence", "[", "3", "*", "i...
Given a sequence of codons (expected to have length multiple of three), return index of first stop codon, or -1 if none is in the sequence.
[ "Given", "a", "sequence", "of", "codons", "(", "expected", "to", "have", "length", "multiple", "of", "three", ")", "return", "index", "of", "first", "stop", "codon", "or", "-", "1", "if", "none", "is", "in", "the", "sequence", "." ]
train
https://github.com/openvax/varcode/blob/981633db45ca2b31f76c06894a7360ea5d70a9b8/varcode/effects/translate.py#L116-L126
openvax/varcode
varcode/effects/translate.py
translate_in_frame_mutation
def translate_in_frame_mutation( transcript, ref_codon_start_offset, ref_codon_end_offset, mutant_codons): """ Returns: - mutant amino acid sequence - offset of first stop codon in the mutant sequence (or -1 if there was none) - boolean flag indicating whe...
python
def translate_in_frame_mutation( transcript, ref_codon_start_offset, ref_codon_end_offset, mutant_codons): """ Returns: - mutant amino acid sequence - offset of first stop codon in the mutant sequence (or -1 if there was none) - boolean flag indicating whe...
[ "def", "translate_in_frame_mutation", "(", "transcript", ",", "ref_codon_start_offset", ",", "ref_codon_end_offset", ",", "mutant_codons", ")", ":", "mutant_stop_codon_index", "=", "find_first_stop_codon", "(", "mutant_codons", ")", "using_three_prime_utr", "=", "False", "i...
Returns: - mutant amino acid sequence - offset of first stop codon in the mutant sequence (or -1 if there was none) - boolean flag indicating whether any codons from the 3' UTR were used Parameters ---------- transcript : pyensembl.Transcript Reference transcript to which a ...
[ "Returns", ":", "-", "mutant", "amino", "acid", "sequence", "-", "offset", "of", "first", "stop", "codon", "in", "the", "mutant", "sequence", "(", "or", "-", "1", "if", "there", "was", "none", ")", "-", "boolean", "flag", "indicating", "whether", "any", ...
train
https://github.com/openvax/varcode/blob/981633db45ca2b31f76c06894a7360ea5d70a9b8/varcode/effects/translate.py#L129-L194
openvax/varcode
varcode/cli/genes_script.py
main
def main(args_list=None): """ Script which loads variants and annotates them with overlapping genes. Example usage: varcode-genes --vcf mutect.vcf \ --vcf strelka.vcf \ --maf tcga_brca.maf \ --variant chr1 498584 C G \ --json-variants more...
python
def main(args_list=None): """ Script which loads variants and annotates them with overlapping genes. Example usage: varcode-genes --vcf mutect.vcf \ --vcf strelka.vcf \ --maf tcga_brca.maf \ --variant chr1 498584 C G \ --json-variants more...
[ "def", "main", "(", "args_list", "=", "None", ")", ":", "print_version_info", "(", ")", "if", "args_list", "is", "None", ":", "args_list", "=", "sys", ".", "argv", "[", "1", ":", "]", "args", "=", "arg_parser", ".", "parse_args", "(", "args_list", ")",...
Script which loads variants and annotates them with overlapping genes. Example usage: varcode-genes --vcf mutect.vcf \ --vcf strelka.vcf \ --maf tcga_brca.maf \ --variant chr1 498584 C G \ --json-variants more_variants.json
[ "Script", "which", "loads", "variants", "and", "annotates", "them", "with", "overlapping", "genes", "." ]
train
https://github.com/openvax/varcode/blob/981633db45ca2b31f76c06894a7360ea5d70a9b8/varcode/cli/genes_script.py#L32-L52
openvax/varcode
varcode/maf.py
load_maf_dataframe
def load_maf_dataframe(path, nrows=None, raise_on_error=True, encoding=None): """ Load the guaranteed columns of a TCGA MAF file into a DataFrame Parameters ---------- path : str Path to MAF file nrows : int Optional limit to number of rows loaded raise_on_error : bool ...
python
def load_maf_dataframe(path, nrows=None, raise_on_error=True, encoding=None): """ Load the guaranteed columns of a TCGA MAF file into a DataFrame Parameters ---------- path : str Path to MAF file nrows : int Optional limit to number of rows loaded raise_on_error : bool ...
[ "def", "load_maf_dataframe", "(", "path", ",", "nrows", "=", "None", ",", "raise_on_error", "=", "True", ",", "encoding", "=", "None", ")", ":", "require_string", "(", "path", ",", "\"Path to MAF\"", ")", "n_basic_columns", "=", "len", "(", "MAF_COLUMN_NAMES",...
Load the guaranteed columns of a TCGA MAF file into a DataFrame Parameters ---------- path : str Path to MAF file nrows : int Optional limit to number of rows loaded raise_on_error : bool Raise an exception upon encountering an error or log an error encoding : str, op...
[ "Load", "the", "guaranteed", "columns", "of", "a", "TCGA", "MAF", "file", "into", "a", "DataFrame" ]
train
https://github.com/openvax/varcode/blob/981633db45ca2b31f76c06894a7360ea5d70a9b8/varcode/maf.py#L51-L112
openvax/varcode
varcode/maf.py
load_maf
def load_maf( path, optional_cols=[], sort_key=variant_ascending_position_sort_key, distinct=True, raise_on_error=True, encoding=None): """ Load reference name and Variant objects from MAF filename. Parameters ---------- path : str Path to MA...
python
def load_maf( path, optional_cols=[], sort_key=variant_ascending_position_sort_key, distinct=True, raise_on_error=True, encoding=None): """ Load reference name and Variant objects from MAF filename. Parameters ---------- path : str Path to MA...
[ "def", "load_maf", "(", "path", ",", "optional_cols", "=", "[", "]", ",", "sort_key", "=", "variant_ascending_position_sort_key", ",", "distinct", "=", "True", ",", "raise_on_error", "=", "True", ",", "encoding", "=", "None", ")", ":", "# pylint: disable=no-memb...
Load reference name and Variant objects from MAF filename. Parameters ---------- path : str Path to MAF (*.maf). optional_cols : list, optional A list of MAF columns to include as metadata if they are present in the MAF. Does not result in an error if those columns are not pre...
[ "Load", "reference", "name", "and", "Variant", "objects", "from", "MAF", "filename", "." ]
train
https://github.com/openvax/varcode/blob/981633db45ca2b31f76c06894a7360ea5d70a9b8/varcode/maf.py#L114-L229
openvax/varcode
varcode/effects/effect_ordering.py
apply_to_field_if_exists
def apply_to_field_if_exists(effect, field_name, fn, default): """ Apply function to specified field of effect if it is not None, otherwise return default. """ value = getattr(effect, field_name, None) if value is None: return default else: return fn(value)
python
def apply_to_field_if_exists(effect, field_name, fn, default): """ Apply function to specified field of effect if it is not None, otherwise return default. """ value = getattr(effect, field_name, None) if value is None: return default else: return fn(value)
[ "def", "apply_to_field_if_exists", "(", "effect", ",", "field_name", ",", "fn", ",", "default", ")", ":", "value", "=", "getattr", "(", "effect", ",", "field_name", ",", "None", ")", "if", "value", "is", "None", ":", "return", "default", "else", ":", "re...
Apply function to specified field of effect if it is not None, otherwise return default.
[ "Apply", "function", "to", "specified", "field", "of", "effect", "if", "it", "is", "not", "None", "otherwise", "return", "default", "." ]
train
https://github.com/openvax/varcode/blob/981633db45ca2b31f76c06894a7360ea5d70a9b8/varcode/effects/effect_ordering.py#L103-L112
openvax/varcode
varcode/effects/effect_ordering.py
apply_to_transcript_if_exists
def apply_to_transcript_if_exists(effect, fn, default): """ Apply function to transcript associated with effect, if it exists, otherwise return default. """ return apply_to_field_if_exists( effect=effect, field_name="transcript", fn=fn, default=default)
python
def apply_to_transcript_if_exists(effect, fn, default): """ Apply function to transcript associated with effect, if it exists, otherwise return default. """ return apply_to_field_if_exists( effect=effect, field_name="transcript", fn=fn, default=default)
[ "def", "apply_to_transcript_if_exists", "(", "effect", ",", "fn", ",", "default", ")", ":", "return", "apply_to_field_if_exists", "(", "effect", "=", "effect", ",", "field_name", "=", "\"transcript\"", ",", "fn", "=", "fn", ",", "default", "=", "default", ")" ...
Apply function to transcript associated with effect, if it exists, otherwise return default.
[ "Apply", "function", "to", "transcript", "associated", "with", "effect", "if", "it", "exists", "otherwise", "return", "default", "." ]
train
https://github.com/openvax/varcode/blob/981633db45ca2b31f76c06894a7360ea5d70a9b8/varcode/effects/effect_ordering.py#L115-L124
openvax/varcode
varcode/effects/effect_ordering.py
number_exons_in_associated_transcript
def number_exons_in_associated_transcript(effect): """ Number of exons on transcript associated with effect, if there is one (otherwise return 0). """ return apply_to_transcript_if_exists( effect=effect, fn=lambda t: len(t.exons), default=0)
python
def number_exons_in_associated_transcript(effect): """ Number of exons on transcript associated with effect, if there is one (otherwise return 0). """ return apply_to_transcript_if_exists( effect=effect, fn=lambda t: len(t.exons), default=0)
[ "def", "number_exons_in_associated_transcript", "(", "effect", ")", ":", "return", "apply_to_transcript_if_exists", "(", "effect", "=", "effect", ",", "fn", "=", "lambda", "t", ":", "len", "(", "t", ".", "exons", ")", ",", "default", "=", "0", ")" ]
Number of exons on transcript associated with effect, if there is one (otherwise return 0).
[ "Number", "of", "exons", "on", "transcript", "associated", "with", "effect", "if", "there", "is", "one", "(", "otherwise", "return", "0", ")", "." ]
train
https://github.com/openvax/varcode/blob/981633db45ca2b31f76c06894a7360ea5d70a9b8/varcode/effects/effect_ordering.py#L135-L143
openvax/varcode
varcode/effects/effect_ordering.py
cds_length_of_associated_transcript
def cds_length_of_associated_transcript(effect): """ Length of coding sequence of transcript associated with effect, if there is one (otherwise return 0). """ return apply_to_transcript_if_exists( effect=effect, fn=lambda t: len(t.coding_sequence) if (t.complete and t.coding_sequence...
python
def cds_length_of_associated_transcript(effect): """ Length of coding sequence of transcript associated with effect, if there is one (otherwise return 0). """ return apply_to_transcript_if_exists( effect=effect, fn=lambda t: len(t.coding_sequence) if (t.complete and t.coding_sequence...
[ "def", "cds_length_of_associated_transcript", "(", "effect", ")", ":", "return", "apply_to_transcript_if_exists", "(", "effect", "=", "effect", ",", "fn", "=", "lambda", "t", ":", "len", "(", "t", ".", "coding_sequence", ")", "if", "(", "t", ".", "complete", ...
Length of coding sequence of transcript associated with effect, if there is one (otherwise return 0).
[ "Length", "of", "coding", "sequence", "of", "transcript", "associated", "with", "effect", "if", "there", "is", "one", "(", "otherwise", "return", "0", ")", "." ]
train
https://github.com/openvax/varcode/blob/981633db45ca2b31f76c06894a7360ea5d70a9b8/varcode/effects/effect_ordering.py#L146-L154
openvax/varcode
varcode/effects/effect_ordering.py
length_of_associated_transcript
def length_of_associated_transcript(effect): """ Length of spliced mRNA sequence of transcript associated with effect, if there is one (otherwise return 0). """ return apply_to_transcript_if_exists( effect=effect, fn=lambda t: len(t.sequence), default=0)
python
def length_of_associated_transcript(effect): """ Length of spliced mRNA sequence of transcript associated with effect, if there is one (otherwise return 0). """ return apply_to_transcript_if_exists( effect=effect, fn=lambda t: len(t.sequence), default=0)
[ "def", "length_of_associated_transcript", "(", "effect", ")", ":", "return", "apply_to_transcript_if_exists", "(", "effect", "=", "effect", ",", "fn", "=", "lambda", "t", ":", "len", "(", "t", ".", "sequence", ")", ",", "default", "=", "0", ")" ]
Length of spliced mRNA sequence of transcript associated with effect, if there is one (otherwise return 0).
[ "Length", "of", "spliced", "mRNA", "sequence", "of", "transcript", "associated", "with", "effect", "if", "there", "is", "one", "(", "otherwise", "return", "0", ")", "." ]
train
https://github.com/openvax/varcode/blob/981633db45ca2b31f76c06894a7360ea5d70a9b8/varcode/effects/effect_ordering.py#L157-L165
openvax/varcode
varcode/effects/effect_ordering.py
name_of_associated_transcript
def name_of_associated_transcript(effect): """ Name of transcript associated with effect, if there is one (otherwise return ""). """ return apply_to_transcript_if_exists( effect=effect, fn=lambda t: t.name, default="")
python
def name_of_associated_transcript(effect): """ Name of transcript associated with effect, if there is one (otherwise return ""). """ return apply_to_transcript_if_exists( effect=effect, fn=lambda t: t.name, default="")
[ "def", "name_of_associated_transcript", "(", "effect", ")", ":", "return", "apply_to_transcript_if_exists", "(", "effect", "=", "effect", ",", "fn", "=", "lambda", "t", ":", "t", ".", "name", ",", "default", "=", "\"\"", ")" ]
Name of transcript associated with effect, if there is one (otherwise return "").
[ "Name", "of", "transcript", "associated", "with", "effect", "if", "there", "is", "one", "(", "otherwise", "return", ")", "." ]
train
https://github.com/openvax/varcode/blob/981633db45ca2b31f76c06894a7360ea5d70a9b8/varcode/effects/effect_ordering.py#L168-L176
openvax/varcode
varcode/effects/effect_ordering.py
gene_id_of_associated_transcript
def gene_id_of_associated_transcript(effect): """ Ensembl gene ID of transcript associated with effect, returns None if effect does not have transcript. """ return apply_to_transcript_if_exists( effect=effect, fn=lambda t: t.gene_id, default=None)
python
def gene_id_of_associated_transcript(effect): """ Ensembl gene ID of transcript associated with effect, returns None if effect does not have transcript. """ return apply_to_transcript_if_exists( effect=effect, fn=lambda t: t.gene_id, default=None)
[ "def", "gene_id_of_associated_transcript", "(", "effect", ")", ":", "return", "apply_to_transcript_if_exists", "(", "effect", "=", "effect", ",", "fn", "=", "lambda", "t", ":", "t", ".", "gene_id", ",", "default", "=", "None", ")" ]
Ensembl gene ID of transcript associated with effect, returns None if effect does not have transcript.
[ "Ensembl", "gene", "ID", "of", "transcript", "associated", "with", "effect", "returns", "None", "if", "effect", "does", "not", "have", "transcript", "." ]
train
https://github.com/openvax/varcode/blob/981633db45ca2b31f76c06894a7360ea5d70a9b8/varcode/effects/effect_ordering.py#L179-L187
openvax/varcode
varcode/effects/effect_ordering.py
effect_has_complete_transcript
def effect_has_complete_transcript(effect): """ Parameters ---------- effect : subclass of MutationEffect Returns True if effect has transcript and that transcript has complete CDS """ return apply_to_transcript_if_exists( effect=effect, fn=lambda t: t.complete, defa...
python
def effect_has_complete_transcript(effect): """ Parameters ---------- effect : subclass of MutationEffect Returns True if effect has transcript and that transcript has complete CDS """ return apply_to_transcript_if_exists( effect=effect, fn=lambda t: t.complete, defa...
[ "def", "effect_has_complete_transcript", "(", "effect", ")", ":", "return", "apply_to_transcript_if_exists", "(", "effect", "=", "effect", ",", "fn", "=", "lambda", "t", ":", "t", ".", "complete", ",", "default", "=", "False", ")" ]
Parameters ---------- effect : subclass of MutationEffect Returns True if effect has transcript and that transcript has complete CDS
[ "Parameters", "----------", "effect", ":", "subclass", "of", "MutationEffect" ]
train
https://github.com/openvax/varcode/blob/981633db45ca2b31f76c06894a7360ea5d70a9b8/varcode/effects/effect_ordering.py#L190-L201
openvax/varcode
varcode/effects/effect_ordering.py
effect_associated_with_protein_coding_gene
def effect_associated_with_protein_coding_gene(effect): """ Parameters ---------- effect : subclass of MutationEffect Returns True if effect is associated with a gene and that gene has a protein_coding biotype. """ return apply_to_gene_if_exists( effect=effect, fn=lambda...
python
def effect_associated_with_protein_coding_gene(effect): """ Parameters ---------- effect : subclass of MutationEffect Returns True if effect is associated with a gene and that gene has a protein_coding biotype. """ return apply_to_gene_if_exists( effect=effect, fn=lambda...
[ "def", "effect_associated_with_protein_coding_gene", "(", "effect", ")", ":", "return", "apply_to_gene_if_exists", "(", "effect", "=", "effect", ",", "fn", "=", "lambda", "g", ":", "g", ".", "biotype", "==", "\"protein_coding\"", ",", "default", "=", "False", ")...
Parameters ---------- effect : subclass of MutationEffect Returns True if effect is associated with a gene and that gene has a protein_coding biotype.
[ "Parameters", "----------", "effect", ":", "subclass", "of", "MutationEffect" ]
train
https://github.com/openvax/varcode/blob/981633db45ca2b31f76c06894a7360ea5d70a9b8/varcode/effects/effect_ordering.py#L204-L216
openvax/varcode
varcode/effects/effect_ordering.py
effect_associated_with_protein_coding_transcript
def effect_associated_with_protein_coding_transcript(effect): """ Parameters ---------- effect : subclass of MutationEffect Returns True if effect is associated with a transcript and that transcript has a protein_coding biotype. """ return apply_to_transcript_if_exists( effect=e...
python
def effect_associated_with_protein_coding_transcript(effect): """ Parameters ---------- effect : subclass of MutationEffect Returns True if effect is associated with a transcript and that transcript has a protein_coding biotype. """ return apply_to_transcript_if_exists( effect=e...
[ "def", "effect_associated_with_protein_coding_transcript", "(", "effect", ")", ":", "return", "apply_to_transcript_if_exists", "(", "effect", "=", "effect", ",", "fn", "=", "lambda", "t", ":", "t", ".", "biotype", "==", "\"protein_coding\"", ",", "default", "=", "...
Parameters ---------- effect : subclass of MutationEffect Returns True if effect is associated with a transcript and that transcript has a protein_coding biotype.
[ "Parameters", "----------", "effect", ":", "subclass", "of", "MutationEffect" ]
train
https://github.com/openvax/varcode/blob/981633db45ca2b31f76c06894a7360ea5d70a9b8/varcode/effects/effect_ordering.py#L219-L231
openvax/varcode
varcode/effects/effect_ordering.py
parse_transcript_number
def parse_transcript_number(effect): """ Try to parse the number at the end of a transcript name associated with an effect. e.g. TP53-001 returns the integer 1. Parameters ---------- effect : subclass of MutationEffect Returns int """ name = name_of_associated_transcript(effec...
python
def parse_transcript_number(effect): """ Try to parse the number at the end of a transcript name associated with an effect. e.g. TP53-001 returns the integer 1. Parameters ---------- effect : subclass of MutationEffect Returns int """ name = name_of_associated_transcript(effec...
[ "def", "parse_transcript_number", "(", "effect", ")", ":", "name", "=", "name_of_associated_transcript", "(", "effect", ")", "if", "\"-\"", "not", "in", "name", ":", "return", "0", "parts", "=", "name", ".", "split", "(", "\"-\"", ")", "last_part", "=", "p...
Try to parse the number at the end of a transcript name associated with an effect. e.g. TP53-001 returns the integer 1. Parameters ---------- effect : subclass of MutationEffect Returns int
[ "Try", "to", "parse", "the", "number", "at", "the", "end", "of", "a", "transcript", "name", "associated", "with", "an", "effect", "." ]
train
https://github.com/openvax/varcode/blob/981633db45ca2b31f76c06894a7360ea5d70a9b8/varcode/effects/effect_ordering.py#L249-L270
openvax/varcode
varcode/effects/effect_ordering.py
multi_gene_effect_sort_key
def multi_gene_effect_sort_key(effect): """ This function acts as a sort key for choosing the highest priority effect across multiple genes (so does not assume that effects might involve the same start/stop codons). Returns tuple with the following elements: 1) Integer priority of the effec...
python
def multi_gene_effect_sort_key(effect): """ This function acts as a sort key for choosing the highest priority effect across multiple genes (so does not assume that effects might involve the same start/stop codons). Returns tuple with the following elements: 1) Integer priority of the effec...
[ "def", "multi_gene_effect_sort_key", "(", "effect", ")", ":", "return", "tuple", "(", "[", "effect_priority", "(", "effect", ")", ",", "effect_associated_with_protein_coding_gene", "(", "effect", ")", ",", "effect_associated_with_protein_coding_transcript", "(", "effect",...
This function acts as a sort key for choosing the highest priority effect across multiple genes (so does not assume that effects might involve the same start/stop codons). Returns tuple with the following elements: 1) Integer priority of the effect type. 2) Does the associated gene have a "...
[ "This", "function", "acts", "as", "a", "sort", "key", "for", "choosing", "the", "highest", "priority", "effect", "across", "multiple", "genes", "(", "so", "does", "not", "assume", "that", "effects", "might", "involve", "the", "same", "start", "/", "stop", ...
train
https://github.com/openvax/varcode/blob/981633db45ca2b31f76c06894a7360ea5d70a9b8/varcode/effects/effect_ordering.py#L273-L313
openvax/varcode
varcode/effects/effect_ordering.py
select_between_exonic_splice_site_and_alternate_effect
def select_between_exonic_splice_site_and_alternate_effect(effect): """ If the given effect is an ExonicSpliceSite then it might contain an alternate effect of higher priority. In that case, return the alternate effect. Otherwise, this acts as an identity function. """ if effect.__class__ is not...
python
def select_between_exonic_splice_site_and_alternate_effect(effect): """ If the given effect is an ExonicSpliceSite then it might contain an alternate effect of higher priority. In that case, return the alternate effect. Otherwise, this acts as an identity function. """ if effect.__class__ is not...
[ "def", "select_between_exonic_splice_site_and_alternate_effect", "(", "effect", ")", ":", "if", "effect", ".", "__class__", "is", "not", "ExonicSpliceSite", ":", "return", "effect", "if", "effect", ".", "alternate_effect", "is", "None", ":", "return", "effect", "spl...
If the given effect is an ExonicSpliceSite then it might contain an alternate effect of higher priority. In that case, return the alternate effect. Otherwise, this acts as an identity function.
[ "If", "the", "given", "effect", "is", "an", "ExonicSpliceSite", "then", "it", "might", "contain", "an", "alternate", "effect", "of", "higher", "priority", ".", "In", "that", "case", "return", "the", "alternate", "effect", ".", "Otherwise", "this", "acts", "a...
train
https://github.com/openvax/varcode/blob/981633db45ca2b31f76c06894a7360ea5d70a9b8/varcode/effects/effect_ordering.py#L316-L331
openvax/varcode
varcode/effects/effect_ordering.py
keep_max_priority_effects
def keep_max_priority_effects(effects): """ Given a list of effects, only keep the ones with the maximum priority effect type. Parameters ---------- effects : list of MutationEffect subclasses Returns list of same length or shorter """ priority_values = map(effect_priority, effects...
python
def keep_max_priority_effects(effects): """ Given a list of effects, only keep the ones with the maximum priority effect type. Parameters ---------- effects : list of MutationEffect subclasses Returns list of same length or shorter """ priority_values = map(effect_priority, effects...
[ "def", "keep_max_priority_effects", "(", "effects", ")", ":", "priority_values", "=", "map", "(", "effect_priority", ",", "effects", ")", "max_priority", "=", "max", "(", "priority_values", ")", "return", "[", "e", "for", "(", "e", ",", "p", ")", "in", "zi...
Given a list of effects, only keep the ones with the maximum priority effect type. Parameters ---------- effects : list of MutationEffect subclasses Returns list of same length or shorter
[ "Given", "a", "list", "of", "effects", "only", "keep", "the", "ones", "with", "the", "maximum", "priority", "effect", "type", "." ]
train
https://github.com/openvax/varcode/blob/981633db45ca2b31f76c06894a7360ea5d70a9b8/varcode/effects/effect_ordering.py#L334-L347
openvax/varcode
varcode/effects/effect_ordering.py
filter_pipeline
def filter_pipeline(effects, filters): """ Apply each filter to the effect list sequentially. If any filter returns zero values then ignore it. As soon as only one effect is left, return it. Parameters ---------- effects : list of MutationEffect subclass instances filters : list of fun...
python
def filter_pipeline(effects, filters): """ Apply each filter to the effect list sequentially. If any filter returns zero values then ignore it. As soon as only one effect is left, return it. Parameters ---------- effects : list of MutationEffect subclass instances filters : list of fun...
[ "def", "filter_pipeline", "(", "effects", ",", "filters", ")", ":", "for", "filter_fn", "in", "filters", ":", "filtered_effects", "=", "filter_fn", "(", "effects", ")", "if", "len", "(", "effects", ")", "==", "1", ":", "return", "effects", "elif", "len", ...
Apply each filter to the effect list sequentially. If any filter returns zero values then ignore it. As soon as only one effect is left, return it. Parameters ---------- effects : list of MutationEffect subclass instances filters : list of functions Each function takes a list of effect...
[ "Apply", "each", "filter", "to", "the", "effect", "list", "sequentially", ".", "If", "any", "filter", "returns", "zero", "values", "then", "ignore", "it", ".", "As", "soon", "as", "only", "one", "effect", "is", "left", "return", "it", "." ]
train
https://github.com/openvax/varcode/blob/981633db45ca2b31f76c06894a7360ea5d70a9b8/varcode/effects/effect_ordering.py#L394-L415
openvax/varcode
varcode/effects/effect_ordering.py
top_priority_effect_for_single_gene
def top_priority_effect_for_single_gene(effects): """ For effects which are from the same gene, check to see if there is a canonical transcript with both the maximum length CDS and maximum length full transcript sequence. If not, then use number of exons and transcript name as tie-breaking feat...
python
def top_priority_effect_for_single_gene(effects): """ For effects which are from the same gene, check to see if there is a canonical transcript with both the maximum length CDS and maximum length full transcript sequence. If not, then use number of exons and transcript name as tie-breaking feat...
[ "def", "top_priority_effect_for_single_gene", "(", "effects", ")", ":", "# first filter effects to keep those on", "# 1) maximum priority effects", "# 2) protein coding genes", "# 3) protein coding transcripts", "# 4) complete transcripts", "#", "# If any of these filters drop all the effect...
For effects which are from the same gene, check to see if there is a canonical transcript with both the maximum length CDS and maximum length full transcript sequence. If not, then use number of exons and transcript name as tie-breaking features. Parameters ---------- effects : list of Mut...
[ "For", "effects", "which", "are", "from", "the", "same", "gene", "check", "to", "see", "if", "there", "is", "a", "canonical", "transcript", "with", "both", "the", "maximum", "length", "CDS", "and", "maximum", "length", "full", "transcript", "sequence", "." ]
train
https://github.com/openvax/varcode/blob/981633db45ca2b31f76c06894a7360ea5d70a9b8/varcode/effects/effect_ordering.py#L439-L526
openvax/varcode
varcode/effects/effect_ordering.py
top_priority_effect
def top_priority_effect(effects): """ Given a collection of variant transcript effects, return the top priority object. ExonicSpliceSite variants require special treatment since they actually represent two effects -- the splicing modification and whatever else would happen to the exonic sequence if ...
python
def top_priority_effect(effects): """ Given a collection of variant transcript effects, return the top priority object. ExonicSpliceSite variants require special treatment since they actually represent two effects -- the splicing modification and whatever else would happen to the exonic sequence if ...
[ "def", "top_priority_effect", "(", "effects", ")", ":", "if", "len", "(", "effects", ")", "==", "0", ":", "raise", "ValueError", "(", "\"List of effects cannot be empty\"", ")", "effects", "=", "map", "(", "select_between_exonic_splice_site_and_alternate_effect", ",",...
Given a collection of variant transcript effects, return the top priority object. ExonicSpliceSite variants require special treatment since they actually represent two effects -- the splicing modification and whatever else would happen to the exonic sequence if nothing else gets changed. In cases where ...
[ "Given", "a", "collection", "of", "variant", "transcript", "effects", "return", "the", "top", "priority", "object", ".", "ExonicSpliceSite", "variants", "require", "special", "treatment", "since", "they", "actually", "represent", "two", "effects", "--", "the", "sp...
train
https://github.com/openvax/varcode/blob/981633db45ca2b31f76c06894a7360ea5d70a9b8/varcode/effects/effect_ordering.py#L529-L564
openvax/varcode
varcode/variant_collection.py
VariantCollection.to_dict
def to_dict(self): """ Since Collection.to_dict() returns a state dictionary with an 'elements' field we have to rename it to 'variants'. """ return dict( variants=self.variants, distinct=self.distinct, sort_key=self.sort_key, sourc...
python
def to_dict(self): """ Since Collection.to_dict() returns a state dictionary with an 'elements' field we have to rename it to 'variants'. """ return dict( variants=self.variants, distinct=self.distinct, sort_key=self.sort_key, sourc...
[ "def", "to_dict", "(", "self", ")", ":", "return", "dict", "(", "variants", "=", "self", ".", "variants", ",", "distinct", "=", "self", ".", "distinct", ",", "sort_key", "=", "self", ".", "sort_key", ",", "sources", "=", "self", ".", "sources", ",", ...
Since Collection.to_dict() returns a state dictionary with an 'elements' field we have to rename it to 'variants'.
[ "Since", "Collection", ".", "to_dict", "()", "returns", "a", "state", "dictionary", "with", "an", "elements", "field", "we", "have", "to", "rename", "it", "to", "variants", "." ]
train
https://github.com/openvax/varcode/blob/981633db45ca2b31f76c06894a7360ea5d70a9b8/varcode/variant_collection.py#L83-L93
openvax/varcode
varcode/variant_collection.py
VariantCollection.clone_with_new_elements
def clone_with_new_elements(self, new_elements): """ Create another VariantCollection of the same class and with same state (including metadata) but possibly different entries. Warning: metadata is a dictionary keyed by variants. This method leaves that dictionary as-is, which m...
python
def clone_with_new_elements(self, new_elements): """ Create another VariantCollection of the same class and with same state (including metadata) but possibly different entries. Warning: metadata is a dictionary keyed by variants. This method leaves that dictionary as-is, which m...
[ "def", "clone_with_new_elements", "(", "self", ",", "new_elements", ")", ":", "kwargs", "=", "self", ".", "to_dict", "(", ")", "kwargs", "[", "\"variants\"", "]", "=", "new_elements", "return", "self", ".", "from_dict", "(", "kwargs", ")" ]
Create another VariantCollection of the same class and with same state (including metadata) but possibly different entries. Warning: metadata is a dictionary keyed by variants. This method leaves that dictionary as-is, which may result in extraneous entries or missing entries.
[ "Create", "another", "VariantCollection", "of", "the", "same", "class", "and", "with", "same", "state", "(", "including", "metadata", ")", "but", "possibly", "different", "entries", "." ]
train
https://github.com/openvax/varcode/blob/981633db45ca2b31f76c06894a7360ea5d70a9b8/varcode/variant_collection.py#L95-L106
openvax/varcode
varcode/variant_collection.py
VariantCollection.effects
def effects(self, raise_on_error=True): """ Parameters ---------- raise_on_error : bool, optional If exception is raised while determining effect of variant on a transcript, should it be raised? This default is True, meaning errors result in raised exc...
python
def effects(self, raise_on_error=True): """ Parameters ---------- raise_on_error : bool, optional If exception is raised while determining effect of variant on a transcript, should it be raised? This default is True, meaning errors result in raised exc...
[ "def", "effects", "(", "self", ",", "raise_on_error", "=", "True", ")", ":", "return", "EffectCollection", "(", "[", "effect", "for", "variant", "in", "self", "for", "effect", "in", "variant", ".", "effects", "(", "raise_on_error", "=", "raise_on_error", ")"...
Parameters ---------- raise_on_error : bool, optional If exception is raised while determining effect of variant on a transcript, should it be raised? This default is True, meaning errors result in raised exceptions, otherwise they are only logged.
[ "Parameters", "----------", "raise_on_error", ":", "bool", "optional", "If", "exception", "is", "raised", "while", "determining", "effect", "of", "variant", "on", "a", "transcript", "should", "it", "be", "raised?", "This", "default", "is", "True", "meaning", "er...
train
https://github.com/openvax/varcode/blob/981633db45ca2b31f76c06894a7360ea5d70a9b8/varcode/variant_collection.py#L108-L122
openvax/varcode
varcode/variant_collection.py
VariantCollection.gene_counts
def gene_counts(self): """ Returns number of elements overlapping each gene name. Expects the derived class (VariantCollection or EffectCollection) to have an implementation of groupby_gene_name. """ return { gene_name: len(group) for (gene_name, g...
python
def gene_counts(self): """ Returns number of elements overlapping each gene name. Expects the derived class (VariantCollection or EffectCollection) to have an implementation of groupby_gene_name. """ return { gene_name: len(group) for (gene_name, g...
[ "def", "gene_counts", "(", "self", ")", ":", "return", "{", "gene_name", ":", "len", "(", "group", ")", "for", "(", "gene_name", ",", "group", ")", "in", "self", ".", "groupby_gene_name", "(", ")", ".", "items", "(", ")", "}" ]
Returns number of elements overlapping each gene name. Expects the derived class (VariantCollection or EffectCollection) to have an implementation of groupby_gene_name.
[ "Returns", "number", "of", "elements", "overlapping", "each", "gene", "name", ".", "Expects", "the", "derived", "class", "(", "VariantCollection", "or", "EffectCollection", ")", "to", "have", "an", "implementation", "of", "groupby_gene_name", "." ]
train
https://github.com/openvax/varcode/blob/981633db45ca2b31f76c06894a7360ea5d70a9b8/varcode/variant_collection.py#L145-L155
openvax/varcode
varcode/variant_collection.py
VariantCollection.filter_by_transcript_expression
def filter_by_transcript_expression( self, transcript_expression_dict, min_expression_value=0.0): """ Filters variants down to those which have overlap a transcript whose expression value in the transcript_expression_dict argument is greater than min_e...
python
def filter_by_transcript_expression( self, transcript_expression_dict, min_expression_value=0.0): """ Filters variants down to those which have overlap a transcript whose expression value in the transcript_expression_dict argument is greater than min_e...
[ "def", "filter_by_transcript_expression", "(", "self", ",", "transcript_expression_dict", ",", "min_expression_value", "=", "0.0", ")", ":", "return", "self", ".", "filter_any_above_threshold", "(", "multi_key_fn", "=", "lambda", "variant", ":", "variant", ".", "trans...
Filters variants down to those which have overlap a transcript whose expression value in the transcript_expression_dict argument is greater than min_expression_value. Parameters ---------- transcript_expression_dict : dict Dictionary mapping Ensembl transcript IDs to...
[ "Filters", "variants", "down", "to", "those", "which", "have", "overlap", "a", "transcript", "whose", "expression", "value", "in", "the", "transcript_expression_dict", "argument", "is", "greater", "than", "min_expression_value", "." ]
train
https://github.com/openvax/varcode/blob/981633db45ca2b31f76c06894a7360ea5d70a9b8/varcode/variant_collection.py#L175-L196
openvax/varcode
varcode/variant_collection.py
VariantCollection.filter_by_gene_expression
def filter_by_gene_expression( self, gene_expression_dict, min_expression_value=0.0): """ Filters variants down to those which have overlap a gene whose expression value in the transcript_expression_dict argument is greater than min_expression_value. ...
python
def filter_by_gene_expression( self, gene_expression_dict, min_expression_value=0.0): """ Filters variants down to those which have overlap a gene whose expression value in the transcript_expression_dict argument is greater than min_expression_value. ...
[ "def", "filter_by_gene_expression", "(", "self", ",", "gene_expression_dict", ",", "min_expression_value", "=", "0.0", ")", ":", "return", "self", ".", "filter_any_above_threshold", "(", "multi_key_fn", "=", "lambda", "effect", ":", "effect", ".", "gene_ids", ",", ...
Filters variants down to those which have overlap a gene whose expression value in the transcript_expression_dict argument is greater than min_expression_value. Parameters ---------- gene_expression_dict : dict Dictionary mapping Ensembl gene IDs to expression estima...
[ "Filters", "variants", "down", "to", "those", "which", "have", "overlap", "a", "gene", "whose", "expression", "value", "in", "the", "transcript_expression_dict", "argument", "is", "greater", "than", "min_expression_value", "." ]
train
https://github.com/openvax/varcode/blob/981633db45ca2b31f76c06894a7360ea5d70a9b8/varcode/variant_collection.py#L198-L219
openvax/varcode
varcode/variant_collection.py
VariantCollection.exactly_equal
def exactly_equal(self, other): ''' Comparison between VariantCollection instances that takes into account the info field of Variant instances. Returns ---------- True if the variants in this collection equal the variants in the other collection. The Variant.info...
python
def exactly_equal(self, other): ''' Comparison between VariantCollection instances that takes into account the info field of Variant instances. Returns ---------- True if the variants in this collection equal the variants in the other collection. The Variant.info...
[ "def", "exactly_equal", "(", "self", ",", "other", ")", ":", "return", "(", "self", ".", "__class__", "==", "other", ".", "__class__", "and", "len", "(", "self", ")", "==", "len", "(", "other", ")", "and", "all", "(", "x", ".", "exactly_equal", "(", ...
Comparison between VariantCollection instances that takes into account the info field of Variant instances. Returns ---------- True if the variants in this collection equal the variants in the other collection. The Variant.info fields are included in the comparison.
[ "Comparison", "between", "VariantCollection", "instances", "that", "takes", "into", "account", "the", "info", "field", "of", "Variant", "instances", "." ]
train
https://github.com/openvax/varcode/blob/981633db45ca2b31f76c06894a7360ea5d70a9b8/varcode/variant_collection.py#L221-L234
openvax/varcode
varcode/variant_collection.py
VariantCollection._merge_metadata_dictionaries
def _merge_metadata_dictionaries(cls, dictionaries): """ Helper function for combining variant collections: given multiple dictionaries mapping: source name -> (variant -> (attribute -> value)) Returns dictionary with union of all variants and sources. """ #...
python
def _merge_metadata_dictionaries(cls, dictionaries): """ Helper function for combining variant collections: given multiple dictionaries mapping: source name -> (variant -> (attribute -> value)) Returns dictionary with union of all variants and sources. """ #...
[ "def", "_merge_metadata_dictionaries", "(", "cls", ",", "dictionaries", ")", ":", "# three levels of nested dictionaries!", "# {source name: {variant: {attribute: value}}}", "combined_dictionary", "=", "{", "}", "for", "source_to_metadata_dict", "in", "dictionaries", ":", "fo...
Helper function for combining variant collections: given multiple dictionaries mapping: source name -> (variant -> (attribute -> value)) Returns dictionary with union of all variants and sources.
[ "Helper", "function", "for", "combining", "variant", "collections", ":", "given", "multiple", "dictionaries", "mapping", ":", "source", "name", "-", ">", "(", "variant", "-", ">", "(", "attribute", "-", ">", "value", "))" ]
train
https://github.com/openvax/varcode/blob/981633db45ca2b31f76c06894a7360ea5d70a9b8/varcode/variant_collection.py#L237-L255
openvax/varcode
varcode/variant_collection.py
VariantCollection._combine_variant_collections
def _combine_variant_collections(cls, combine_fn, variant_collections, kwargs): """ Create a single VariantCollection from multiple different collections. Parameters ---------- cls : class Should be VariantCollection combine_fn : function Functi...
python
def _combine_variant_collections(cls, combine_fn, variant_collections, kwargs): """ Create a single VariantCollection from multiple different collections. Parameters ---------- cls : class Should be VariantCollection combine_fn : function Functi...
[ "def", "_combine_variant_collections", "(", "cls", ",", "combine_fn", ",", "variant_collections", ",", "kwargs", ")", ":", "kwargs", "[", "\"variants\"", "]", "=", "combine_fn", "(", "*", "[", "set", "(", "vc", ")", "for", "vc", "in", "variant_collections", ...
Create a single VariantCollection from multiple different collections. Parameters ---------- cls : class Should be VariantCollection combine_fn : function Function which takes any number of sets of variants and returns some combination of them (typi...
[ "Create", "a", "single", "VariantCollection", "from", "multiple", "different", "collections", "." ]
train
https://github.com/openvax/varcode/blob/981633db45ca2b31f76c06894a7360ea5d70a9b8/varcode/variant_collection.py#L258-L293
openvax/varcode
varcode/variant_collection.py
VariantCollection.union
def union(self, *others, **kwargs): """ Returns the union of variants in a several VariantCollection objects. """ return self._combine_variant_collections( combine_fn=set.union, variant_collections=(self,) + others, kwargs=kwargs)
python
def union(self, *others, **kwargs): """ Returns the union of variants in a several VariantCollection objects. """ return self._combine_variant_collections( combine_fn=set.union, variant_collections=(self,) + others, kwargs=kwargs)
[ "def", "union", "(", "self", ",", "*", "others", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "_combine_variant_collections", "(", "combine_fn", "=", "set", ".", "union", ",", "variant_collections", "=", "(", "self", ",", ")", "+", "others",...
Returns the union of variants in a several VariantCollection objects.
[ "Returns", "the", "union", "of", "variants", "in", "a", "several", "VariantCollection", "objects", "." ]
train
https://github.com/openvax/varcode/blob/981633db45ca2b31f76c06894a7360ea5d70a9b8/varcode/variant_collection.py#L295-L302
openvax/varcode
varcode/variant_collection.py
VariantCollection.intersection
def intersection(self, *others, **kwargs): """ Returns the intersection of variants in several VariantCollection objects. """ return self._combine_variant_collections( combine_fn=set.intersection, variant_collections=(self,) + others, kwargs=kwargs)
python
def intersection(self, *others, **kwargs): """ Returns the intersection of variants in several VariantCollection objects. """ return self._combine_variant_collections( combine_fn=set.intersection, variant_collections=(self,) + others, kwargs=kwargs)
[ "def", "intersection", "(", "self", ",", "*", "others", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "_combine_variant_collections", "(", "combine_fn", "=", "set", ".", "intersection", ",", "variant_collections", "=", "(", "self", ",", ")", "+...
Returns the intersection of variants in several VariantCollection objects.
[ "Returns", "the", "intersection", "of", "variants", "in", "several", "VariantCollection", "objects", "." ]
train
https://github.com/openvax/varcode/blob/981633db45ca2b31f76c06894a7360ea5d70a9b8/varcode/variant_collection.py#L304-L311
openvax/varcode
varcode/variant_collection.py
VariantCollection.to_dataframe
def to_dataframe(self): """Build a DataFrame from this variant collection""" def row_from_variant(variant): return OrderedDict([ ("chr", variant.contig), ("start", variant.original_start), ("ref", variant.original_ref), ("alt", ...
python
def to_dataframe(self): """Build a DataFrame from this variant collection""" def row_from_variant(variant): return OrderedDict([ ("chr", variant.contig), ("start", variant.original_start), ("ref", variant.original_ref), ("alt", ...
[ "def", "to_dataframe", "(", "self", ")", ":", "def", "row_from_variant", "(", "variant", ")", ":", "return", "OrderedDict", "(", "[", "(", "\"chr\"", ",", "variant", ".", "contig", ")", ",", "(", "\"start\"", ",", "variant", ".", "original_start", ")", "...
Build a DataFrame from this variant collection
[ "Build", "a", "DataFrame", "from", "this", "variant", "collection" ]
train
https://github.com/openvax/varcode/blob/981633db45ca2b31f76c06894a7360ea5d70a9b8/varcode/variant_collection.py#L313-L328
openvax/varcode
varcode/string_helpers.py
trim_shared_prefix
def trim_shared_prefix(ref, alt): """ Sometimes mutations are given with a shared prefix between the reference and alternate strings. Examples: C>CT (nucleotides) or GYFP>G (amino acids). This function trims the common prefix and returns the disjoint ref and alt strings, along with the shared prefi...
python
def trim_shared_prefix(ref, alt): """ Sometimes mutations are given with a shared prefix between the reference and alternate strings. Examples: C>CT (nucleotides) or GYFP>G (amino acids). This function trims the common prefix and returns the disjoint ref and alt strings, along with the shared prefi...
[ "def", "trim_shared_prefix", "(", "ref", ",", "alt", ")", ":", "n_ref", "=", "len", "(", "ref", ")", "n_alt", "=", "len", "(", "alt", ")", "n_min", "=", "min", "(", "n_ref", ",", "n_alt", ")", "i", "=", "0", "while", "i", "<", "n_min", "and", "...
Sometimes mutations are given with a shared prefix between the reference and alternate strings. Examples: C>CT (nucleotides) or GYFP>G (amino acids). This function trims the common prefix and returns the disjoint ref and alt strings, along with the shared prefix.
[ "Sometimes", "mutations", "are", "given", "with", "a", "shared", "prefix", "between", "the", "reference", "and", "alternate", "strings", ".", "Examples", ":", "C", ">", "CT", "(", "nucleotides", ")", "or", "GYFP", ">", "G", "(", "amino", "acids", ")", "....
train
https://github.com/openvax/varcode/blob/981633db45ca2b31f76c06894a7360ea5d70a9b8/varcode/string_helpers.py#L18-L39
openvax/varcode
varcode/string_helpers.py
trim_shared_suffix
def trim_shared_suffix(ref, alt): """ Reuse the `trim_shared_prefix` function above to implement similar functionality for string suffixes. Given ref='ABC' and alt='BC', we first revese both strings: reverse_ref = 'CBA' reverse_alt = 'CB' and then the result of calling trim_shared_p...
python
def trim_shared_suffix(ref, alt): """ Reuse the `trim_shared_prefix` function above to implement similar functionality for string suffixes. Given ref='ABC' and alt='BC', we first revese both strings: reverse_ref = 'CBA' reverse_alt = 'CB' and then the result of calling trim_shared_p...
[ "def", "trim_shared_suffix", "(", "ref", ",", "alt", ")", ":", "n_ref", "=", "len", "(", "ref", ")", "n_alt", "=", "len", "(", "alt", ")", "n_min", "=", "min", "(", "n_ref", ",", "n_alt", ")", "i", "=", "0", "while", "i", "<", "n_min", "and", "...
Reuse the `trim_shared_prefix` function above to implement similar functionality for string suffixes. Given ref='ABC' and alt='BC', we first revese both strings: reverse_ref = 'CBA' reverse_alt = 'CB' and then the result of calling trim_shared_prefix will be: ('A', '', 'CB') We ...
[ "Reuse", "the", "trim_shared_prefix", "function", "above", "to", "implement", "similar", "functionality", "for", "string", "suffixes", "." ]
train
https://github.com/openvax/varcode/blob/981633db45ca2b31f76c06894a7360ea5d70a9b8/varcode/string_helpers.py#L42-L66
openvax/varcode
varcode/string_helpers.py
trim_shared_flanking_strings
def trim_shared_flanking_strings(ref, alt): """ Given two nucleotide or amino acid strings, identify if they have a common prefix, a common suffix, and return their unique components along with the prefix and suffix. For example, if the input ref = "SYFFQGR" and alt = "SYMLLFIFQGR" then the res...
python
def trim_shared_flanking_strings(ref, alt): """ Given two nucleotide or amino acid strings, identify if they have a common prefix, a common suffix, and return their unique components along with the prefix and suffix. For example, if the input ref = "SYFFQGR" and alt = "SYMLLFIFQGR" then the res...
[ "def", "trim_shared_flanking_strings", "(", "ref", ",", "alt", ")", ":", "ref", ",", "alt", ",", "prefix", "=", "trim_shared_prefix", "(", "ref", ",", "alt", ")", "ref", ",", "alt", ",", "suffix", "=", "trim_shared_suffix", "(", "ref", ",", "alt", ")", ...
Given two nucleotide or amino acid strings, identify if they have a common prefix, a common suffix, and return their unique components along with the prefix and suffix. For example, if the input ref = "SYFFQGR" and alt = "SYMLLFIFQGR" then the result will be: ("F", "MLLFI", "SY", "FQGR")
[ "Given", "two", "nucleotide", "or", "amino", "acid", "strings", "identify", "if", "they", "have", "a", "common", "prefix", "a", "common", "suffix", "and", "return", "their", "unique", "components", "along", "with", "the", "prefix", "and", "suffix", "." ]
train
https://github.com/openvax/varcode/blob/981633db45ca2b31f76c06894a7360ea5d70a9b8/varcode/string_helpers.py#L69-L81
openvax/varcode
varcode/cli/effects_script.py
main
def main(args_list=None): """ Script which loads variants and annotates them with overlapping genes and predicted coding effects. Example usage: varcode --vcf mutect.vcf \ --vcf strelka.vcf \ --maf tcga_brca.maf \ --variant chr1 498584 C G \ ...
python
def main(args_list=None): """ Script which loads variants and annotates them with overlapping genes and predicted coding effects. Example usage: varcode --vcf mutect.vcf \ --vcf strelka.vcf \ --maf tcga_brca.maf \ --variant chr1 498584 C G \ ...
[ "def", "main", "(", "args_list", "=", "None", ")", ":", "print_version_info", "(", ")", "if", "args_list", "is", "None", ":", "args_list", "=", "sys", ".", "argv", "[", "1", ":", "]", "args", "=", "arg_parser", ".", "parse_args", "(", "args_list", ")",...
Script which loads variants and annotates them with overlapping genes and predicted coding effects. Example usage: varcode --vcf mutect.vcf \ --vcf strelka.vcf \ --maf tcga_brca.maf \ --variant chr1 498584 C G \ --json-variants more_variants.j...
[ "Script", "which", "loads", "variants", "and", "annotates", "them", "with", "overlapping", "genes", "and", "predicted", "coding", "effects", "." ]
train
https://github.com/openvax/varcode/blob/981633db45ca2b31f76c06894a7360ea5d70a9b8/varcode/cli/effects_script.py#L48-L77
openvax/varcode
varcode/effects/effect_prediction_coding_in_frame.py
get_codons
def get_codons( variant, trimmed_cdna_ref, trimmed_cdna_alt, sequence_from_start_codon, cds_offset): """ Returns indices of first and last reference codons affected by the variant, as well as the actual sequence of the mutated codons which replace those reference ...
python
def get_codons( variant, trimmed_cdna_ref, trimmed_cdna_alt, sequence_from_start_codon, cds_offset): """ Returns indices of first and last reference codons affected by the variant, as well as the actual sequence of the mutated codons which replace those reference ...
[ "def", "get_codons", "(", "variant", ",", "trimmed_cdna_ref", ",", "trimmed_cdna_alt", ",", "sequence_from_start_codon", ",", "cds_offset", ")", ":", "# index (starting from 0) of first affected reference codon", "ref_codon_start_offset", "=", "cds_offset", "//", "3", "# whic...
Returns indices of first and last reference codons affected by the variant, as well as the actual sequence of the mutated codons which replace those reference codons. Parameters ---------- variant : Variant trimmed_cdna_ref : str Trimmed reference cDNA nucleotides affected by the varia...
[ "Returns", "indices", "of", "first", "and", "last", "reference", "codons", "affected", "by", "the", "variant", "as", "well", "as", "the", "actual", "sequence", "of", "the", "mutated", "codons", "which", "replace", "those", "reference", "codons", "." ]
train
https://github.com/openvax/varcode/blob/981633db45ca2b31f76c06894a7360ea5d70a9b8/varcode/effects/effect_prediction_coding_in_frame.py#L36-L107
openvax/varcode
varcode/effects/effect_prediction_coding_in_frame.py
predict_in_frame_coding_effect
def predict_in_frame_coding_effect( variant, transcript, trimmed_cdna_ref, trimmed_cdna_alt, sequence_from_start_codon, cds_offset): """Coding effect of an in-frame nucleotide change Parameters ---------- variant : Variant transcript : Transcript ...
python
def predict_in_frame_coding_effect( variant, transcript, trimmed_cdna_ref, trimmed_cdna_alt, sequence_from_start_codon, cds_offset): """Coding effect of an in-frame nucleotide change Parameters ---------- variant : Variant transcript : Transcript ...
[ "def", "predict_in_frame_coding_effect", "(", "variant", ",", "transcript", ",", "trimmed_cdna_ref", ",", "trimmed_cdna_alt", ",", "sequence_from_start_codon", ",", "cds_offset", ")", ":", "ref_codon_start_offset", ",", "ref_codon_end_offset", ",", "mutant_codons", "=", "...
Coding effect of an in-frame nucleotide change Parameters ---------- variant : Variant transcript : Transcript trimmed_cdna_ref : str Reference nucleotides from the coding sequence of the transcript trimmed_cdna_alt : str Nucleotides to insert in place of the reference nucleo...
[ "Coding", "effect", "of", "an", "in", "-", "frame", "nucleotide", "change" ]
train
https://github.com/openvax/varcode/blob/981633db45ca2b31f76c06894a7360ea5d70a9b8/varcode/effects/effect_prediction_coding_in_frame.py#L110-L267
openvax/varcode
varcode/cli/variant_args.py
add_variant_args
def add_variant_args(arg_parser): """ Extends an ArgumentParser instance with the following commandline arguments: --vcf --genome --maf --variant --json-variants """ variant_arg_group = arg_parser.add_argument_group( title="Variants", description="...
python
def add_variant_args(arg_parser): """ Extends an ArgumentParser instance with the following commandline arguments: --vcf --genome --maf --variant --json-variants """ variant_arg_group = arg_parser.add_argument_group( title="Variants", description="...
[ "def", "add_variant_args", "(", "arg_parser", ")", ":", "variant_arg_group", "=", "arg_parser", ".", "add_argument_group", "(", "title", "=", "\"Variants\"", ",", "description", "=", "\"Genomic variant files\"", ")", "variant_arg_group", ".", "add_argument", "(", "\"-...
Extends an ArgumentParser instance with the following commandline arguments: --vcf --genome --maf --variant --json-variants
[ "Extends", "an", "ArgumentParser", "instance", "with", "the", "following", "commandline", "arguments", ":", "--", "vcf", "--", "genome", "--", "maf", "--", "variant", "--", "json", "-", "variants" ]
train
https://github.com/openvax/varcode/blob/981633db45ca2b31f76c06894a7360ea5d70a9b8/varcode/cli/variant_args.py#L26-L90
openvax/varcode
varcode/effects/mutate.py
insert_before
def insert_before(sequence, offset, new_residues): """Mutate the given sequence by inserting the string `new_residues` before `offset`. Parameters ---------- sequence : sequence String of amino acids or DNA bases offset : int Base 0 offset from start of sequence, after which we...
python
def insert_before(sequence, offset, new_residues): """Mutate the given sequence by inserting the string `new_residues` before `offset`. Parameters ---------- sequence : sequence String of amino acids or DNA bases offset : int Base 0 offset from start of sequence, after which we...
[ "def", "insert_before", "(", "sequence", ",", "offset", ",", "new_residues", ")", ":", "assert", "0", "<", "offset", "<=", "len", "(", "sequence", ")", ",", "\"Invalid position %d for sequence of length %d\"", "%", "(", "offset", ",", "len", "(", "sequence", "...
Mutate the given sequence by inserting the string `new_residues` before `offset`. Parameters ---------- sequence : sequence String of amino acids or DNA bases offset : int Base 0 offset from start of sequence, after which we should insert `new_residues`. new_residues :...
[ "Mutate", "the", "given", "sequence", "by", "inserting", "the", "string", "new_residues", "before", "offset", "." ]
train
https://github.com/openvax/varcode/blob/981633db45ca2b31f76c06894a7360ea5d70a9b8/varcode/effects/mutate.py#L18-L38