id int32 0 252k | repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 |
|---|---|---|---|---|---|---|---|---|---|---|---|
55,700 | udragon/pybrctl | pybrctl/pybrctl.py | Bridge.setpathcost | def setpathcost(self, port, cost):
""" Set port path cost value for STP protocol. """
_runshell([brctlexe, 'setpathcost', self.name, port, str(cost)],
"Could not set path cost in port %s in %s." % (port, self.name)) | python | def setpathcost(self, port, cost):
""" Set port path cost value for STP protocol. """
_runshell([brctlexe, 'setpathcost', self.name, port, str(cost)],
"Could not set path cost in port %s in %s." % (port, self.name)) | [
"def",
"setpathcost",
"(",
"self",
",",
"port",
",",
"cost",
")",
":",
"_runshell",
"(",
"[",
"brctlexe",
",",
"'setpathcost'",
",",
"self",
".",
"name",
",",
"port",
",",
"str",
"(",
"cost",
")",
"]",
",",
"\"Could not set path cost in port %s in %s.\"",
... | Set port path cost value for STP protocol. | [
"Set",
"port",
"path",
"cost",
"value",
"for",
"STP",
"protocol",
"."
] | 9e834a605b57bd969a81c56a886dee81f7d715c1 | https://github.com/udragon/pybrctl/blob/9e834a605b57bd969a81c56a886dee81f7d715c1/pybrctl/pybrctl.py#L73-L76 |
55,701 | udragon/pybrctl | pybrctl/pybrctl.py | Bridge.setportprio | def setportprio(self, port, prio):
""" Set port priority value. """
_runshell([brctlexe, 'setportprio', self.name, port, str(prio)],
"Could not set priority in port %s in %s." % (port, self.name)) | python | def setportprio(self, port, prio):
""" Set port priority value. """
_runshell([brctlexe, 'setportprio', self.name, port, str(prio)],
"Could not set priority in port %s in %s." % (port, self.name)) | [
"def",
"setportprio",
"(",
"self",
",",
"port",
",",
"prio",
")",
":",
"_runshell",
"(",
"[",
"brctlexe",
",",
"'setportprio'",
",",
"self",
".",
"name",
",",
"port",
",",
"str",
"(",
"prio",
")",
"]",
",",
"\"Could not set priority in port %s in %s.\"",
"... | Set port priority value. | [
"Set",
"port",
"priority",
"value",
"."
] | 9e834a605b57bd969a81c56a886dee81f7d715c1 | https://github.com/udragon/pybrctl/blob/9e834a605b57bd969a81c56a886dee81f7d715c1/pybrctl/pybrctl.py#L78-L81 |
55,702 | udragon/pybrctl | pybrctl/pybrctl.py | Bridge._show | def _show(self):
""" Return a list of unsorted bridge details. """
p = _runshell([brctlexe, 'show', self.name],
"Could not show %s." % self.name)
return p.stdout.read().split()[7:] | python | def _show(self):
""" Return a list of unsorted bridge details. """
p = _runshell([brctlexe, 'show', self.name],
"Could not show %s." % self.name)
return p.stdout.read().split()[7:] | [
"def",
"_show",
"(",
"self",
")",
":",
"p",
"=",
"_runshell",
"(",
"[",
"brctlexe",
",",
"'show'",
",",
"self",
".",
"name",
"]",
",",
"\"Could not show %s.\"",
"%",
"self",
".",
"name",
")",
"return",
"p",
".",
"stdout",
".",
"read",
"(",
")",
"."... | Return a list of unsorted bridge details. | [
"Return",
"a",
"list",
"of",
"unsorted",
"bridge",
"details",
"."
] | 9e834a605b57bd969a81c56a886dee81f7d715c1 | https://github.com/udragon/pybrctl/blob/9e834a605b57bd969a81c56a886dee81f7d715c1/pybrctl/pybrctl.py#L83-L87 |
55,703 | udragon/pybrctl | pybrctl/pybrctl.py | BridgeController.addbr | def addbr(self, name):
""" Create a bridge and set the device up. """
_runshell([brctlexe, 'addbr', name],
"Could not create bridge %s." % name)
_runshell([ipexe, 'link', 'set', 'dev', name, 'up'],
"Could not set link up for %s." % name)
return Bridge(name) | python | def addbr(self, name):
""" Create a bridge and set the device up. """
_runshell([brctlexe, 'addbr', name],
"Could not create bridge %s." % name)
_runshell([ipexe, 'link', 'set', 'dev', name, 'up'],
"Could not set link up for %s." % name)
return Bridge(name) | [
"def",
"addbr",
"(",
"self",
",",
"name",
")",
":",
"_runshell",
"(",
"[",
"brctlexe",
",",
"'addbr'",
",",
"name",
"]",
",",
"\"Could not create bridge %s.\"",
"%",
"name",
")",
"_runshell",
"(",
"[",
"ipexe",
",",
"'link'",
",",
"'set'",
",",
"'dev'",
... | Create a bridge and set the device up. | [
"Create",
"a",
"bridge",
"and",
"set",
"the",
"device",
"up",
"."
] | 9e834a605b57bd969a81c56a886dee81f7d715c1 | https://github.com/udragon/pybrctl/blob/9e834a605b57bd969a81c56a886dee81f7d715c1/pybrctl/pybrctl.py#L112-L118 |
55,704 | udragon/pybrctl | pybrctl/pybrctl.py | BridgeController.delbr | def delbr(self, name):
""" Set the device down and delete the bridge. """
self.getbr(name) # Check if exists
_runshell([ipexe, 'link', 'set', 'dev', name, 'down'],
"Could not set link down for %s." % name)
_runshell([brctlexe, 'delbr', name],
"Could not delete bri... | python | def delbr(self, name):
""" Set the device down and delete the bridge. """
self.getbr(name) # Check if exists
_runshell([ipexe, 'link', 'set', 'dev', name, 'down'],
"Could not set link down for %s." % name)
_runshell([brctlexe, 'delbr', name],
"Could not delete bri... | [
"def",
"delbr",
"(",
"self",
",",
"name",
")",
":",
"self",
".",
"getbr",
"(",
"name",
")",
"# Check if exists",
"_runshell",
"(",
"[",
"ipexe",
",",
"'link'",
",",
"'set'",
",",
"'dev'",
",",
"name",
",",
"'down'",
"]",
",",
"\"Could not set link down f... | Set the device down and delete the bridge. | [
"Set",
"the",
"device",
"down",
"and",
"delete",
"the",
"bridge",
"."
] | 9e834a605b57bd969a81c56a886dee81f7d715c1 | https://github.com/udragon/pybrctl/blob/9e834a605b57bd969a81c56a886dee81f7d715c1/pybrctl/pybrctl.py#L120-L126 |
55,705 | udragon/pybrctl | pybrctl/pybrctl.py | BridgeController.showall | def showall(self):
""" Return a list of all available bridges. """
p = _runshell([brctlexe, 'show'],
"Could not show bridges.")
wlist = map(str.split, p.stdout.read().splitlines()[1:])
brwlist = filter(lambda x: len(x) != 1, wlist)
brlist = map(lambda x: x[0], brwlist... | python | def showall(self):
""" Return a list of all available bridges. """
p = _runshell([brctlexe, 'show'],
"Could not show bridges.")
wlist = map(str.split, p.stdout.read().splitlines()[1:])
brwlist = filter(lambda x: len(x) != 1, wlist)
brlist = map(lambda x: x[0], brwlist... | [
"def",
"showall",
"(",
"self",
")",
":",
"p",
"=",
"_runshell",
"(",
"[",
"brctlexe",
",",
"'show'",
"]",
",",
"\"Could not show bridges.\"",
")",
"wlist",
"=",
"map",
"(",
"str",
".",
"split",
",",
"p",
".",
"stdout",
".",
"read",
"(",
")",
".",
"... | Return a list of all available bridges. | [
"Return",
"a",
"list",
"of",
"all",
"available",
"bridges",
"."
] | 9e834a605b57bd969a81c56a886dee81f7d715c1 | https://github.com/udragon/pybrctl/blob/9e834a605b57bd969a81c56a886dee81f7d715c1/pybrctl/pybrctl.py#L128-L135 |
55,706 | udragon/pybrctl | pybrctl/pybrctl.py | BridgeController.getbr | def getbr(self, name):
""" Return a bridge object."""
for br in self.showall():
if br.name == name:
return br
raise BridgeException("Bridge does not exist.") | python | def getbr(self, name):
""" Return a bridge object."""
for br in self.showall():
if br.name == name:
return br
raise BridgeException("Bridge does not exist.") | [
"def",
"getbr",
"(",
"self",
",",
"name",
")",
":",
"for",
"br",
"in",
"self",
".",
"showall",
"(",
")",
":",
"if",
"br",
".",
"name",
"==",
"name",
":",
"return",
"br",
"raise",
"BridgeException",
"(",
"\"Bridge does not exist.\"",
")"
] | Return a bridge object. | [
"Return",
"a",
"bridge",
"object",
"."
] | 9e834a605b57bd969a81c56a886dee81f7d715c1 | https://github.com/udragon/pybrctl/blob/9e834a605b57bd969a81c56a886dee81f7d715c1/pybrctl/pybrctl.py#L137-L142 |
55,707 | closeio/cleancat | cleancat/base.py | Field.clean | def clean(self, value):
"""Take a dirty value and clean it."""
if (
self.base_type is not None and
value is not None and
not isinstance(value, self.base_type)
):
if isinstance(self.base_type, tuple):
allowed_types = [typ.__name__ fo... | python | def clean(self, value):
"""Take a dirty value and clean it."""
if (
self.base_type is not None and
value is not None and
not isinstance(value, self.base_type)
):
if isinstance(self.base_type, tuple):
allowed_types = [typ.__name__ fo... | [
"def",
"clean",
"(",
"self",
",",
"value",
")",
":",
"if",
"(",
"self",
".",
"base_type",
"is",
"not",
"None",
"and",
"value",
"is",
"not",
"None",
"and",
"not",
"isinstance",
"(",
"value",
",",
"self",
".",
"base_type",
")",
")",
":",
"if",
"isins... | Take a dirty value and clean it. | [
"Take",
"a",
"dirty",
"value",
"and",
"clean",
"it",
"."
] | 59df1422b3ebea9477026ca80cd7af1ae9734d89 | https://github.com/closeio/cleancat/blob/59df1422b3ebea9477026ca80cd7af1ae9734d89/cleancat/base.py#L54-L78 |
55,708 | closeio/cleancat | cleancat/base.py | EmbeddedReference.clean_new | def clean_new(self, value):
"""Return a new object instantiated with cleaned data."""
value = self.schema_class(value).full_clean()
return self.object_class(**value) | python | def clean_new(self, value):
"""Return a new object instantiated with cleaned data."""
value = self.schema_class(value).full_clean()
return self.object_class(**value) | [
"def",
"clean_new",
"(",
"self",
",",
"value",
")",
":",
"value",
"=",
"self",
".",
"schema_class",
"(",
"value",
")",
".",
"full_clean",
"(",
")",
"return",
"self",
".",
"object_class",
"(",
"*",
"*",
"value",
")"
] | Return a new object instantiated with cleaned data. | [
"Return",
"a",
"new",
"object",
"instantiated",
"with",
"cleaned",
"data",
"."
] | 59df1422b3ebea9477026ca80cd7af1ae9734d89 | https://github.com/closeio/cleancat/blob/59df1422b3ebea9477026ca80cd7af1ae9734d89/cleancat/base.py#L446-L449 |
55,709 | closeio/cleancat | cleancat/base.py | EmbeddedReference.clean_existing | def clean_existing(self, value):
"""Clean the data and return an existing document with its fields
updated based on the cleaned values.
"""
existing_pk = value[self.pk_field]
try:
obj = self.fetch_existing(existing_pk)
except ReferenceNotFoundError:
... | python | def clean_existing(self, value):
"""Clean the data and return an existing document with its fields
updated based on the cleaned values.
"""
existing_pk = value[self.pk_field]
try:
obj = self.fetch_existing(existing_pk)
except ReferenceNotFoundError:
... | [
"def",
"clean_existing",
"(",
"self",
",",
"value",
")",
":",
"existing_pk",
"=",
"value",
"[",
"self",
".",
"pk_field",
"]",
"try",
":",
"obj",
"=",
"self",
".",
"fetch_existing",
"(",
"existing_pk",
")",
"except",
"ReferenceNotFoundError",
":",
"raise",
... | Clean the data and return an existing document with its fields
updated based on the cleaned values. | [
"Clean",
"the",
"data",
"and",
"return",
"an",
"existing",
"document",
"with",
"its",
"fields",
"updated",
"based",
"on",
"the",
"cleaned",
"values",
"."
] | 59df1422b3ebea9477026ca80cd7af1ae9734d89 | https://github.com/closeio/cleancat/blob/59df1422b3ebea9477026ca80cd7af1ae9734d89/cleancat/base.py#L451-L471 |
55,710 | closeio/cleancat | cleancat/base.py | Schema.get_fields | def get_fields(cls):
"""
Returns a dictionary of fields and field instances for this schema.
"""
fields = {}
for field_name in dir(cls):
if isinstance(getattr(cls, field_name), Field):
field = getattr(cls, field_name)
field_name = field... | python | def get_fields(cls):
"""
Returns a dictionary of fields and field instances for this schema.
"""
fields = {}
for field_name in dir(cls):
if isinstance(getattr(cls, field_name), Field):
field = getattr(cls, field_name)
field_name = field... | [
"def",
"get_fields",
"(",
"cls",
")",
":",
"fields",
"=",
"{",
"}",
"for",
"field_name",
"in",
"dir",
"(",
"cls",
")",
":",
"if",
"isinstance",
"(",
"getattr",
"(",
"cls",
",",
"field_name",
")",
",",
"Field",
")",
":",
"field",
"=",
"getattr",
"("... | Returns a dictionary of fields and field instances for this schema. | [
"Returns",
"a",
"dictionary",
"of",
"fields",
"and",
"field",
"instances",
"for",
"this",
"schema",
"."
] | 59df1422b3ebea9477026ca80cd7af1ae9734d89 | https://github.com/closeio/cleancat/blob/59df1422b3ebea9477026ca80cd7af1ae9734d89/cleancat/base.py#L674-L684 |
55,711 | closeio/cleancat | cleancat/base.py | Schema.obj_to_dict | def obj_to_dict(cls, obj):
"""
Takes a model object and converts it into a dictionary suitable for
passing to the constructor's data attribute.
"""
data = {}
for field_name in cls.get_fields():
try:
value = getattr(obj, field_name)
... | python | def obj_to_dict(cls, obj):
"""
Takes a model object and converts it into a dictionary suitable for
passing to the constructor's data attribute.
"""
data = {}
for field_name in cls.get_fields():
try:
value = getattr(obj, field_name)
... | [
"def",
"obj_to_dict",
"(",
"cls",
",",
"obj",
")",
":",
"data",
"=",
"{",
"}",
"for",
"field_name",
"in",
"cls",
".",
"get_fields",
"(",
")",
":",
"try",
":",
"value",
"=",
"getattr",
"(",
"obj",
",",
"field_name",
")",
"except",
"AttributeError",
":... | Takes a model object and converts it into a dictionary suitable for
passing to the constructor's data attribute. | [
"Takes",
"a",
"model",
"object",
"and",
"converts",
"it",
"into",
"a",
"dictionary",
"suitable",
"for",
"passing",
"to",
"the",
"constructor",
"s",
"data",
"attribute",
"."
] | 59df1422b3ebea9477026ca80cd7af1ae9734d89 | https://github.com/closeio/cleancat/blob/59df1422b3ebea9477026ca80cd7af1ae9734d89/cleancat/base.py#L687-L708 |
55,712 | thunder-project/thunder-registration | registration/model.py | RegistrationModel.transform | def transform(self, images):
"""
Apply the transformation to an Images object.
Will apply the underlying dictionary of transformations to
the images or volumes of the Images object. The dictionary acts as a lookup
table specifying which transformation should be applied to which ... | python | def transform(self, images):
"""
Apply the transformation to an Images object.
Will apply the underlying dictionary of transformations to
the images or volumes of the Images object. The dictionary acts as a lookup
table specifying which transformation should be applied to which ... | [
"def",
"transform",
"(",
"self",
",",
"images",
")",
":",
"images",
"=",
"check_images",
"(",
"images",
")",
"def",
"apply",
"(",
"item",
")",
":",
"(",
"k",
",",
"v",
")",
"=",
"item",
"return",
"self",
".",
"transformations",
"[",
"k",
"]",
".",
... | Apply the transformation to an Images object.
Will apply the underlying dictionary of transformations to
the images or volumes of the Images object. The dictionary acts as a lookup
table specifying which transformation should be applied to which record of the
Images object based on the ... | [
"Apply",
"the",
"transformation",
"to",
"an",
"Images",
"object",
"."
] | 286f091e6c402d592e9686d4821e0fd80dbf86ec | https://github.com/thunder-project/thunder-registration/blob/286f091e6c402d592e9686d4821e0fd80dbf86ec/registration/model.py#L24-L45 |
55,713 | xonsh/lazyasd | lazyasd-py2.py | load_module_in_background | def load_module_in_background(name, package=None, debug='DEBUG', env=None,
replacements=None):
"""Entry point for loading modules in background thread.
Parameters
----------
name : str
Module name to load in background thread.
package : str or None, optional
... | python | def load_module_in_background(name, package=None, debug='DEBUG', env=None,
replacements=None):
"""Entry point for loading modules in background thread.
Parameters
----------
name : str
Module name to load in background thread.
package : str or None, optional
... | [
"def",
"load_module_in_background",
"(",
"name",
",",
"package",
"=",
"None",
",",
"debug",
"=",
"'DEBUG'",
",",
"env",
"=",
"None",
",",
"replacements",
"=",
"None",
")",
":",
"modname",
"=",
"resolve_name",
"(",
"name",
",",
"package",
")",
"if",
"modn... | Entry point for loading modules in background thread.
Parameters
----------
name : str
Module name to load in background thread.
package : str or None, optional
Package name, has the same meaning as in importlib.import_module().
debug : str, optional
Debugging symbol name to... | [
"Entry",
"point",
"for",
"loading",
"modules",
"in",
"background",
"thread",
"."
] | 5f40b193f1602e723f7ede82435836e218e0e5ec | https://github.com/xonsh/lazyasd/blob/5f40b193f1602e723f7ede82435836e218e0e5ec/lazyasd-py2.py#L331-L373 |
55,714 | jordanh/neurio-python | neurio/__init__.py | TokenProvider.get_token | def get_token(self):
"""Performs Neurio API token authentication using provided key and secret.
Note:
This method is generally not called by hand; rather it is usually
called as-needed by a Neurio Client object.
Returns:
string: the access token
"""
if self.__token is not None:
... | python | def get_token(self):
"""Performs Neurio API token authentication using provided key and secret.
Note:
This method is generally not called by hand; rather it is usually
called as-needed by a Neurio Client object.
Returns:
string: the access token
"""
if self.__token is not None:
... | [
"def",
"get_token",
"(",
"self",
")",
":",
"if",
"self",
".",
"__token",
"is",
"not",
"None",
":",
"return",
"self",
".",
"__token",
"url",
"=",
"\"https://api.neur.io/v1/oauth2/token\"",
"creds",
"=",
"b64encode",
"(",
"\":\"",
".",
"join",
"(",
"[",
"sel... | Performs Neurio API token authentication using provided key and secret.
Note:
This method is generally not called by hand; rather it is usually
called as-needed by a Neurio Client object.
Returns:
string: the access token | [
"Performs",
"Neurio",
"API",
"token",
"authentication",
"using",
"provided",
"key",
"and",
"secret",
"."
] | 3a1bcadadb3bb3ad48f2df41c039d8b828ffd9c8 | https://github.com/jordanh/neurio-python/blob/3a1bcadadb3bb3ad48f2df41c039d8b828ffd9c8/neurio/__init__.py#L51-L79 |
55,715 | jordanh/neurio-python | neurio/__init__.py | Client.__append_url_params | def __append_url_params(self, url, params):
"""Utility method formatting url request parameters."""
url_parts = list(urlparse(url))
query = dict(parse_qsl(url_parts[4]))
query.update(params)
url_parts[4] = urlencode(query)
return urlunparse(url_parts) | python | def __append_url_params(self, url, params):
"""Utility method formatting url request parameters."""
url_parts = list(urlparse(url))
query = dict(parse_qsl(url_parts[4]))
query.update(params)
url_parts[4] = urlencode(query)
return urlunparse(url_parts) | [
"def",
"__append_url_params",
"(",
"self",
",",
"url",
",",
"params",
")",
":",
"url_parts",
"=",
"list",
"(",
"urlparse",
"(",
"url",
")",
")",
"query",
"=",
"dict",
"(",
"parse_qsl",
"(",
"url_parts",
"[",
"4",
"]",
")",
")",
"query",
".",
"update"... | Utility method formatting url request parameters. | [
"Utility",
"method",
"formatting",
"url",
"request",
"parameters",
"."
] | 3a1bcadadb3bb3ad48f2df41c039d8b828ffd9c8 | https://github.com/jordanh/neurio-python/blob/3a1bcadadb3bb3ad48f2df41c039d8b828ffd9c8/neurio/__init__.py#L106-L113 |
55,716 | jordanh/neurio-python | neurio/__init__.py | Client.get_appliance | def get_appliance(self, appliance_id):
"""Get the information for a specified appliance
Args:
appliance_id (string): identifiying string of appliance
Returns:
list: dictionary object containing information about the specified appliance
"""
url = "https://api.neur.io/v1/appliances/%s"%(... | python | def get_appliance(self, appliance_id):
"""Get the information for a specified appliance
Args:
appliance_id (string): identifiying string of appliance
Returns:
list: dictionary object containing information about the specified appliance
"""
url = "https://api.neur.io/v1/appliances/%s"%(... | [
"def",
"get_appliance",
"(",
"self",
",",
"appliance_id",
")",
":",
"url",
"=",
"\"https://api.neur.io/v1/appliances/%s\"",
"%",
"(",
"appliance_id",
")",
"headers",
"=",
"self",
".",
"__gen_headers",
"(",
")",
"headers",
"[",
"\"Content-Type\"",
"]",
"=",
"\"ap... | Get the information for a specified appliance
Args:
appliance_id (string): identifiying string of appliance
Returns:
list: dictionary object containing information about the specified appliance | [
"Get",
"the",
"information",
"for",
"a",
"specified",
"appliance"
] | 3a1bcadadb3bb3ad48f2df41c039d8b828ffd9c8 | https://github.com/jordanh/neurio-python/blob/3a1bcadadb3bb3ad48f2df41c039d8b828ffd9c8/neurio/__init__.py#L115-L130 |
55,717 | jordanh/neurio-python | neurio/__init__.py | Client.get_appliances | def get_appliances(self, location_id):
"""Get the appliances added for a specified location.
Args:
location_id (string): identifiying string of appliance
Returns:
list: dictionary objects containing appliances data
"""
url = "https://api.neur.io/v1/appliances"
headers = self.__gen... | python | def get_appliances(self, location_id):
"""Get the appliances added for a specified location.
Args:
location_id (string): identifiying string of appliance
Returns:
list: dictionary objects containing appliances data
"""
url = "https://api.neur.io/v1/appliances"
headers = self.__gen... | [
"def",
"get_appliances",
"(",
"self",
",",
"location_id",
")",
":",
"url",
"=",
"\"https://api.neur.io/v1/appliances\"",
"headers",
"=",
"self",
".",
"__gen_headers",
"(",
")",
"headers",
"[",
"\"Content-Type\"",
"]",
"=",
"\"application/json\"",
"params",
"=",
"{... | Get the appliances added for a specified location.
Args:
location_id (string): identifiying string of appliance
Returns:
list: dictionary objects containing appliances data | [
"Get",
"the",
"appliances",
"added",
"for",
"a",
"specified",
"location",
"."
] | 3a1bcadadb3bb3ad48f2df41c039d8b828ffd9c8 | https://github.com/jordanh/neurio-python/blob/3a1bcadadb3bb3ad48f2df41c039d8b828ffd9c8/neurio/__init__.py#L132-L152 |
55,718 | jordanh/neurio-python | neurio/__init__.py | Client.get_appliance_event_after_time | def get_appliance_event_after_time(self, location_id, since, per_page=None, page=None, min_power=None):
"""Get appliance events by location Id after defined time.
Args:
location_id (string): hexadecimal id of the sensor to query, e.g.
``0x0013A20040B65FAD``
since (string):... | python | def get_appliance_event_after_time(self, location_id, since, per_page=None, page=None, min_power=None):
"""Get appliance events by location Id after defined time.
Args:
location_id (string): hexadecimal id of the sensor to query, e.g.
``0x0013A20040B65FAD``
since (string):... | [
"def",
"get_appliance_event_after_time",
"(",
"self",
",",
"location_id",
",",
"since",
",",
"per_page",
"=",
"None",
",",
"page",
"=",
"None",
",",
"min_power",
"=",
"None",
")",
":",
"url",
"=",
"\"https://api.neur.io/v1/appliances/events\"",
"headers",
"=",
"... | Get appliance events by location Id after defined time.
Args:
location_id (string): hexadecimal id of the sensor to query, e.g.
``0x0013A20040B65FAD``
since (string): ISO 8601 start time for getting the events that are created or updated after it.
Maxiumim value allowe... | [
"Get",
"appliance",
"events",
"by",
"location",
"Id",
"after",
"defined",
"time",
"."
] | 3a1bcadadb3bb3ad48f2df41c039d8b828ffd9c8 | https://github.com/jordanh/neurio-python/blob/3a1bcadadb3bb3ad48f2df41c039d8b828ffd9c8/neurio/__init__.py#L195-L232 |
55,719 | jordanh/neurio-python | neurio/__init__.py | Client.get_appliance_stats_by_location | def get_appliance_stats_by_location(self, location_id, start, end, granularity=None, per_page=None, page=None,
min_power=None):
"""Get appliance usage data for a given location within a given time range.
Stats are generated by fetching appliance events that match the suppli... | python | def get_appliance_stats_by_location(self, location_id, start, end, granularity=None, per_page=None, page=None,
min_power=None):
"""Get appliance usage data for a given location within a given time range.
Stats are generated by fetching appliance events that match the suppli... | [
"def",
"get_appliance_stats_by_location",
"(",
"self",
",",
"location_id",
",",
"start",
",",
"end",
",",
"granularity",
"=",
"None",
",",
"per_page",
"=",
"None",
",",
"page",
"=",
"None",
",",
"min_power",
"=",
"None",
")",
":",
"url",
"=",
"\"https://ap... | Get appliance usage data for a given location within a given time range.
Stats are generated by fetching appliance events that match the supplied
criteria and then aggregating them together based on the granularity
specified with the request.
Note:
This endpoint uses the location's time zone when... | [
"Get",
"appliance",
"usage",
"data",
"for",
"a",
"given",
"location",
"within",
"a",
"given",
"time",
"range",
".",
"Stats",
"are",
"generated",
"by",
"fetching",
"appliance",
"events",
"that",
"match",
"the",
"supplied",
"criteria",
"and",
"then",
"aggregatin... | 3a1bcadadb3bb3ad48f2df41c039d8b828ffd9c8 | https://github.com/jordanh/neurio-python/blob/3a1bcadadb3bb3ad48f2df41c039d8b828ffd9c8/neurio/__init__.py#L332-L387 |
55,720 | jordanh/neurio-python | neurio/__init__.py | Client.get_samples_live | def get_samples_live(self, sensor_id, last=None):
"""Get recent samples, one sample per second for up to the last 2 minutes.
Args:
sensor_id (string): hexadecimal id of the sensor to query, e.g.
``0x0013A20040B65FAD``
last (string): starting range, as ISO8601 timestamp
Returns:
l... | python | def get_samples_live(self, sensor_id, last=None):
"""Get recent samples, one sample per second for up to the last 2 minutes.
Args:
sensor_id (string): hexadecimal id of the sensor to query, e.g.
``0x0013A20040B65FAD``
last (string): starting range, as ISO8601 timestamp
Returns:
l... | [
"def",
"get_samples_live",
"(",
"self",
",",
"sensor_id",
",",
"last",
"=",
"None",
")",
":",
"url",
"=",
"\"https://api.neur.io/v1/samples/live\"",
"headers",
"=",
"self",
".",
"__gen_headers",
"(",
")",
"headers",
"[",
"\"Content-Type\"",
"]",
"=",
"\"applicat... | Get recent samples, one sample per second for up to the last 2 minutes.
Args:
sensor_id (string): hexadecimal id of the sensor to query, e.g.
``0x0013A20040B65FAD``
last (string): starting range, as ISO8601 timestamp
Returns:
list: dictionary objects containing sample data | [
"Get",
"recent",
"samples",
"one",
"sample",
"per",
"second",
"for",
"up",
"to",
"the",
"last",
"2",
"minutes",
"."
] | 3a1bcadadb3bb3ad48f2df41c039d8b828ffd9c8 | https://github.com/jordanh/neurio-python/blob/3a1bcadadb3bb3ad48f2df41c039d8b828ffd9c8/neurio/__init__.py#L415-L437 |
55,721 | jordanh/neurio-python | neurio/__init__.py | Client.get_samples_live_last | def get_samples_live_last(self, sensor_id):
"""Get the last sample recorded by the sensor.
Args:
sensor_id (string): hexadecimal id of the sensor to query, e.g.
``0x0013A20040B65FAD``
Returns:
list: dictionary objects containing sample data
"""
url = "https://api.neur.io/v1/sam... | python | def get_samples_live_last(self, sensor_id):
"""Get the last sample recorded by the sensor.
Args:
sensor_id (string): hexadecimal id of the sensor to query, e.g.
``0x0013A20040B65FAD``
Returns:
list: dictionary objects containing sample data
"""
url = "https://api.neur.io/v1/sam... | [
"def",
"get_samples_live_last",
"(",
"self",
",",
"sensor_id",
")",
":",
"url",
"=",
"\"https://api.neur.io/v1/samples/live/last\"",
"headers",
"=",
"self",
".",
"__gen_headers",
"(",
")",
"headers",
"[",
"\"Content-Type\"",
"]",
"=",
"\"application/json\"",
"params",... | Get the last sample recorded by the sensor.
Args:
sensor_id (string): hexadecimal id of the sensor to query, e.g.
``0x0013A20040B65FAD``
Returns:
list: dictionary objects containing sample data | [
"Get",
"the",
"last",
"sample",
"recorded",
"by",
"the",
"sensor",
"."
] | 3a1bcadadb3bb3ad48f2df41c039d8b828ffd9c8 | https://github.com/jordanh/neurio-python/blob/3a1bcadadb3bb3ad48f2df41c039d8b828ffd9c8/neurio/__init__.py#L439-L458 |
55,722 | jordanh/neurio-python | neurio/__init__.py | Client.get_samples | def get_samples(self, sensor_id, start, granularity, end=None,
frequency=None, per_page=None, page=None,
full=False):
"""Get a sensor's samples for a specified time interval.
Args:
sensor_id (string): hexadecimal id of the sensor to query, e.g.
... | python | def get_samples(self, sensor_id, start, granularity, end=None,
frequency=None, per_page=None, page=None,
full=False):
"""Get a sensor's samples for a specified time interval.
Args:
sensor_id (string): hexadecimal id of the sensor to query, e.g.
... | [
"def",
"get_samples",
"(",
"self",
",",
"sensor_id",
",",
"start",
",",
"granularity",
",",
"end",
"=",
"None",
",",
"frequency",
"=",
"None",
",",
"per_page",
"=",
"None",
",",
"page",
"=",
"None",
",",
"full",
"=",
"False",
")",
":",
"url",
"=",
... | Get a sensor's samples for a specified time interval.
Args:
sensor_id (string): hexadecimal id of the sensor to query, e.g.
``0x0013A20040B65FAD``
start (string): ISO 8601 start time of sampling; depends on the
``granularity`` parameter value, the maximum supported tim... | [
"Get",
"a",
"sensor",
"s",
"samples",
"for",
"a",
"specified",
"time",
"interval",
"."
] | 3a1bcadadb3bb3ad48f2df41c039d8b828ffd9c8 | https://github.com/jordanh/neurio-python/blob/3a1bcadadb3bb3ad48f2df41c039d8b828ffd9c8/neurio/__init__.py#L460-L514 |
55,723 | jordanh/neurio-python | neurio/__init__.py | Client.get_user_information | def get_user_information(self):
"""Gets the current user information, including sensor ID
Args:
None
Returns:
dictionary object containing information about the current user
"""
url = "https://api.neur.io/v1/users/current"
headers = self.__gen_headers()
headers["Content-Type"]... | python | def get_user_information(self):
"""Gets the current user information, including sensor ID
Args:
None
Returns:
dictionary object containing information about the current user
"""
url = "https://api.neur.io/v1/users/current"
headers = self.__gen_headers()
headers["Content-Type"]... | [
"def",
"get_user_information",
"(",
"self",
")",
":",
"url",
"=",
"\"https://api.neur.io/v1/users/current\"",
"headers",
"=",
"self",
".",
"__gen_headers",
"(",
")",
"headers",
"[",
"\"Content-Type\"",
"]",
"=",
"\"application/json\"",
"r",
"=",
"requests",
".",
"... | Gets the current user information, including sensor ID
Args:
None
Returns:
dictionary object containing information about the current user | [
"Gets",
"the",
"current",
"user",
"information",
"including",
"sensor",
"ID"
] | 3a1bcadadb3bb3ad48f2df41c039d8b828ffd9c8 | https://github.com/jordanh/neurio-python/blob/3a1bcadadb3bb3ad48f2df41c039d8b828ffd9c8/neurio/__init__.py#L572-L587 |
55,724 | openfisca/openfisca-web-api | openfisca_web_api/controllers/formula.py | api2_formula | def api2_formula(req):
"""
A simple `GET`-, URL-based API to OpenFisca, making the assumption of computing formulas for a single person.
Combination
-----------
You can compute several formulas at once by combining the paths and joining them with `+`.
Example:
```
/salaire_super_brut+salaire_net_a_payer?salaire_... | python | def api2_formula(req):
"""
A simple `GET`-, URL-based API to OpenFisca, making the assumption of computing formulas for a single person.
Combination
-----------
You can compute several formulas at once by combining the paths and joining them with `+`.
Example:
```
/salaire_super_brut+salaire_net_a_payer?salaire_... | [
"def",
"api2_formula",
"(",
"req",
")",
":",
"API_VERSION",
"=",
"'2.1.0'",
"wsgihelpers",
".",
"track",
"(",
"req",
".",
"url",
".",
"decode",
"(",
"'utf-8'",
")",
")",
"params",
"=",
"dict",
"(",
"req",
".",
"GET",
")",
"data",
"=",
"dict",
"(",
... | A simple `GET`-, URL-based API to OpenFisca, making the assumption of computing formulas for a single person.
Combination
-----------
You can compute several formulas at once by combining the paths and joining them with `+`.
Example:
```
/salaire_super_brut+salaire_net_a_payer?salaire_de_base=1440
```
This will com... | [
"A",
"simple",
"GET",
"-",
"URL",
"-",
"based",
"API",
"to",
"OpenFisca",
"making",
"the",
"assumption",
"of",
"computing",
"formulas",
"for",
"a",
"single",
"person",
"."
] | d1cd3bfacac338e80bb0df7e0465b65649dd893b | https://github.com/openfisca/openfisca-web-api/blob/d1cd3bfacac338e80bb0df7e0465b65649dd893b/openfisca_web_api/controllers/formula.py#L37-L109 |
55,725 | nkavaldj/myhdl_lib | examples/pipeline_control_stop_tx.py | arithmetic_mean4 | def arithmetic_mean4(rst, clk, rx_rdy, rx_vld, rx_dat, tx_rdy, tx_vld, tx_dat):
''' Calculates the arithmetic mean of every 4 consecutive input numbers
Input handshake & data
rx_rdy - (o) Ready
rx_vld - (i) Valid
rx_dat - (i) Data
Output handshake & data
... | python | def arithmetic_mean4(rst, clk, rx_rdy, rx_vld, rx_dat, tx_rdy, tx_vld, tx_dat):
''' Calculates the arithmetic mean of every 4 consecutive input numbers
Input handshake & data
rx_rdy - (o) Ready
rx_vld - (i) Valid
rx_dat - (i) Data
Output handshake & data
... | [
"def",
"arithmetic_mean4",
"(",
"rst",
",",
"clk",
",",
"rx_rdy",
",",
"rx_vld",
",",
"rx_dat",
",",
"tx_rdy",
",",
"tx_vld",
",",
"tx_dat",
")",
":",
"DATA_WIDTH",
"=",
"len",
"(",
"rx_dat",
")",
"NUM_STAGES",
"=",
"3",
"stage_en",
"=",
"Signal",
"(",... | Calculates the arithmetic mean of every 4 consecutive input numbers
Input handshake & data
rx_rdy - (o) Ready
rx_vld - (i) Valid
rx_dat - (i) Data
Output handshake & data
tx_rdy - (i) Ready
tx_vld - (o) Valid
tx_dat - (o) Data
... | [
"Calculates",
"the",
"arithmetic",
"mean",
"of",
"every",
"4",
"consecutive",
"input",
"numbers"
] | 9902afd2031e7847373f692821b2135fd0810aa8 | https://github.com/nkavaldj/myhdl_lib/blob/9902afd2031e7847373f692821b2135fd0810aa8/examples/pipeline_control_stop_tx.py#L7-L96 |
55,726 | nkavaldj/myhdl_lib | examples/pipeline_control_stop_tx.py | pipeline_control_stop_tx | def pipeline_control_stop_tx():
''' Instantiates the arithmetic_mean4 pipeline, feeds it with data and drains its output '''
clk = sim.Clock(val=0, period=10, units="ns")
rst = sim.ResetSync(clk=clk, val=0, active=1)
rx_rdy, rx_vld, tx_rdy, tx_vld = [Signal(bool(0)) for _ in range(4)]
rx_dat = Sig... | python | def pipeline_control_stop_tx():
''' Instantiates the arithmetic_mean4 pipeline, feeds it with data and drains its output '''
clk = sim.Clock(val=0, period=10, units="ns")
rst = sim.ResetSync(clk=clk, val=0, active=1)
rx_rdy, rx_vld, tx_rdy, tx_vld = [Signal(bool(0)) for _ in range(4)]
rx_dat = Sig... | [
"def",
"pipeline_control_stop_tx",
"(",
")",
":",
"clk",
"=",
"sim",
".",
"Clock",
"(",
"val",
"=",
"0",
",",
"period",
"=",
"10",
",",
"units",
"=",
"\"ns\"",
")",
"rst",
"=",
"sim",
".",
"ResetSync",
"(",
"clk",
"=",
"clk",
",",
"val",
"=",
"0"... | Instantiates the arithmetic_mean4 pipeline, feeds it with data and drains its output | [
"Instantiates",
"the",
"arithmetic_mean4",
"pipeline",
"feeds",
"it",
"with",
"data",
"and",
"drains",
"its",
"output"
] | 9902afd2031e7847373f692821b2135fd0810aa8 | https://github.com/nkavaldj/myhdl_lib/blob/9902afd2031e7847373f692821b2135fd0810aa8/examples/pipeline_control_stop_tx.py#L152-L207 |
55,727 | closeio/cleancat | cleancat/mongo.py | MongoEmbedded.clean | def clean(self, value):
"""Clean the provided dict of values and then return an
EmbeddedDocument instantiated with them.
"""
value = super(MongoEmbedded, self).clean(value)
return self.document_class(**value) | python | def clean(self, value):
"""Clean the provided dict of values and then return an
EmbeddedDocument instantiated with them.
"""
value = super(MongoEmbedded, self).clean(value)
return self.document_class(**value) | [
"def",
"clean",
"(",
"self",
",",
"value",
")",
":",
"value",
"=",
"super",
"(",
"MongoEmbedded",
",",
"self",
")",
".",
"clean",
"(",
"value",
")",
"return",
"self",
".",
"document_class",
"(",
"*",
"*",
"value",
")"
] | Clean the provided dict of values and then return an
EmbeddedDocument instantiated with them. | [
"Clean",
"the",
"provided",
"dict",
"of",
"values",
"and",
"then",
"return",
"an",
"EmbeddedDocument",
"instantiated",
"with",
"them",
"."
] | 59df1422b3ebea9477026ca80cd7af1ae9734d89 | https://github.com/closeio/cleancat/blob/59df1422b3ebea9477026ca80cd7af1ae9734d89/cleancat/mongo.py#L24-L29 |
55,728 | closeio/cleancat | cleancat/mongo.py | MongoReference.fetch_object | def fetch_object(self, doc_id):
"""Fetch the document by its PK."""
try:
return self.object_class.objects.get(pk=doc_id)
except self.object_class.DoesNotExist:
raise ReferenceNotFoundError | python | def fetch_object(self, doc_id):
"""Fetch the document by its PK."""
try:
return self.object_class.objects.get(pk=doc_id)
except self.object_class.DoesNotExist:
raise ReferenceNotFoundError | [
"def",
"fetch_object",
"(",
"self",
",",
"doc_id",
")",
":",
"try",
":",
"return",
"self",
".",
"object_class",
".",
"objects",
".",
"get",
"(",
"pk",
"=",
"doc_id",
")",
"except",
"self",
".",
"object_class",
".",
"DoesNotExist",
":",
"raise",
"Referenc... | Fetch the document by its PK. | [
"Fetch",
"the",
"document",
"by",
"its",
"PK",
"."
] | 59df1422b3ebea9477026ca80cd7af1ae9734d89 | https://github.com/closeio/cleancat/blob/59df1422b3ebea9477026ca80cd7af1ae9734d89/cleancat/mongo.py#L69-L74 |
55,729 | flo-compbio/genometools | genometools/ncbi/geo/generate_sample_sheet.py | get_argument_parser | def get_argument_parser():
"""Create the argument parser for the script.
Parameters
----------
Returns
-------
`argparse.ArgumentParser`
The arguemnt parser.
"""
desc = 'Generate a sample sheet based on a GEO series matrix.'
parser = cli.get_argument_parser(desc=desc)
... | python | def get_argument_parser():
"""Create the argument parser for the script.
Parameters
----------
Returns
-------
`argparse.ArgumentParser`
The arguemnt parser.
"""
desc = 'Generate a sample sheet based on a GEO series matrix.'
parser = cli.get_argument_parser(desc=desc)
... | [
"def",
"get_argument_parser",
"(",
")",
":",
"desc",
"=",
"'Generate a sample sheet based on a GEO series matrix.'",
"parser",
"=",
"cli",
".",
"get_argument_parser",
"(",
"desc",
"=",
"desc",
")",
"g",
"=",
"parser",
".",
"add_argument_group",
"(",
"'Input and output... | Create the argument parser for the script.
Parameters
----------
Returns
-------
`argparse.ArgumentParser`
The arguemnt parser. | [
"Create",
"the",
"argument",
"parser",
"for",
"the",
"script",
"."
] | dd962bb26d60a0f14ca14d8c9a4dd75768962c7d | https://github.com/flo-compbio/genometools/blob/dd962bb26d60a0f14ca14d8c9a4dd75768962c7d/genometools/ncbi/geo/generate_sample_sheet.py#L38-L73 |
55,730 | flo-compbio/genometools | genometools/ncbi/geo/generate_sample_sheet.py | read_series_matrix | def read_series_matrix(path, encoding):
"""Read the series matrix."""
assert isinstance(path, str)
accessions = None
titles = None
celfile_urls = None
with misc.smart_open_read(path, mode='rb', try_gzip=True) as fh:
reader = csv.reader(fh, dialect='excel-tab', encoding=encoding)
... | python | def read_series_matrix(path, encoding):
"""Read the series matrix."""
assert isinstance(path, str)
accessions = None
titles = None
celfile_urls = None
with misc.smart_open_read(path, mode='rb', try_gzip=True) as fh:
reader = csv.reader(fh, dialect='excel-tab', encoding=encoding)
... | [
"def",
"read_series_matrix",
"(",
"path",
",",
"encoding",
")",
":",
"assert",
"isinstance",
"(",
"path",
",",
"str",
")",
"accessions",
"=",
"None",
"titles",
"=",
"None",
"celfile_urls",
"=",
"None",
"with",
"misc",
".",
"smart_open_read",
"(",
"path",
"... | Read the series matrix. | [
"Read",
"the",
"series",
"matrix",
"."
] | dd962bb26d60a0f14ca14d8c9a4dd75768962c7d | https://github.com/flo-compbio/genometools/blob/dd962bb26d60a0f14ca14d8c9a4dd75768962c7d/genometools/ncbi/geo/generate_sample_sheet.py#L76-L97 |
55,731 | flo-compbio/genometools | genometools/ncbi/geo/generate_sample_sheet.py | write_sample_sheet | def write_sample_sheet(path, accessions, names, celfile_urls, sel=None):
"""Write the sample sheet."""
with open(path, 'wb') as ofh:
writer = csv.writer(ofh, dialect='excel-tab',
lineterminator=os.linesep,
quoting=csv.QUOTE_NONE)
# write he... | python | def write_sample_sheet(path, accessions, names, celfile_urls, sel=None):
"""Write the sample sheet."""
with open(path, 'wb') as ofh:
writer = csv.writer(ofh, dialect='excel-tab',
lineterminator=os.linesep,
quoting=csv.QUOTE_NONE)
# write he... | [
"def",
"write_sample_sheet",
"(",
"path",
",",
"accessions",
",",
"names",
",",
"celfile_urls",
",",
"sel",
"=",
"None",
")",
":",
"with",
"open",
"(",
"path",
",",
"'wb'",
")",
"as",
"ofh",
":",
"writer",
"=",
"csv",
".",
"writer",
"(",
"ofh",
",",
... | Write the sample sheet. | [
"Write",
"the",
"sample",
"sheet",
"."
] | dd962bb26d60a0f14ca14d8c9a4dd75768962c7d | https://github.com/flo-compbio/genometools/blob/dd962bb26d60a0f14ca14d8c9a4dd75768962c7d/genometools/ncbi/geo/generate_sample_sheet.py#L100-L114 |
55,732 | inveniosoftware/invenio-jsonschemas | invenio_jsonschemas/views.py | create_blueprint | def create_blueprint(state):
"""Create blueprint serving JSON schemas.
:param state: :class:`invenio_jsonschemas.ext.InvenioJSONSchemasState`
instance used to retrieve the schemas.
"""
blueprint = Blueprint(
'invenio_jsonschemas',
__name__,
)
@blueprint.route('/<path:sc... | python | def create_blueprint(state):
"""Create blueprint serving JSON schemas.
:param state: :class:`invenio_jsonschemas.ext.InvenioJSONSchemasState`
instance used to retrieve the schemas.
"""
blueprint = Blueprint(
'invenio_jsonschemas',
__name__,
)
@blueprint.route('/<path:sc... | [
"def",
"create_blueprint",
"(",
"state",
")",
":",
"blueprint",
"=",
"Blueprint",
"(",
"'invenio_jsonschemas'",
",",
"__name__",
",",
")",
"@",
"blueprint",
".",
"route",
"(",
"'/<path:schema_path>'",
")",
"def",
"get_schema",
"(",
"schema_path",
")",
":",
"\"... | Create blueprint serving JSON schemas.
:param state: :class:`invenio_jsonschemas.ext.InvenioJSONSchemasState`
instance used to retrieve the schemas. | [
"Create",
"blueprint",
"serving",
"JSON",
"schemas",
"."
] | 93019b8fe3bf549335e94c84198c9c0b76d8fde2 | https://github.com/inveniosoftware/invenio-jsonschemas/blob/93019b8fe3bf549335e94c84198c9c0b76d8fde2/invenio_jsonschemas/views.py#L23-L64 |
55,733 | acorg/dark-matter | dark/blast/records.py | printBlastRecord | def printBlastRecord(record):
"""
Print a BLAST record.
@param record: A BioPython C{Bio.Blast.Record.Blast} instance.
"""
for key in sorted(record.__dict__.keys()):
if key not in ['alignments', 'descriptions', 'reference']:
print('%s: %r' % (key, record.__dict__[key]))
prin... | python | def printBlastRecord(record):
"""
Print a BLAST record.
@param record: A BioPython C{Bio.Blast.Record.Blast} instance.
"""
for key in sorted(record.__dict__.keys()):
if key not in ['alignments', 'descriptions', 'reference']:
print('%s: %r' % (key, record.__dict__[key]))
prin... | [
"def",
"printBlastRecord",
"(",
"record",
")",
":",
"for",
"key",
"in",
"sorted",
"(",
"record",
".",
"__dict__",
".",
"keys",
"(",
")",
")",
":",
"if",
"key",
"not",
"in",
"[",
"'alignments'",
",",
"'descriptions'",
",",
"'reference'",
"]",
":",
"prin... | Print a BLAST record.
@param record: A BioPython C{Bio.Blast.Record.Blast} instance. | [
"Print",
"a",
"BLAST",
"record",
"."
] | c78a1bf262667fa5db3548fa7066c4ec14d0551d | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/blast/records.py#L4-L24 |
55,734 | flo-compbio/genometools | genometools/ontology/gaf.py | get_goa_gene_sets | def get_goa_gene_sets(go_annotations):
"""Generate a list of gene sets from a collection of GO annotations.
Each gene set corresponds to all genes annotated with a certain GO term.
"""
go_term_genes = OrderedDict()
term_ids = {}
for ann in go_annotations:
term_ids[ann.go_term.id] = ann.... | python | def get_goa_gene_sets(go_annotations):
"""Generate a list of gene sets from a collection of GO annotations.
Each gene set corresponds to all genes annotated with a certain GO term.
"""
go_term_genes = OrderedDict()
term_ids = {}
for ann in go_annotations:
term_ids[ann.go_term.id] = ann.... | [
"def",
"get_goa_gene_sets",
"(",
"go_annotations",
")",
":",
"go_term_genes",
"=",
"OrderedDict",
"(",
")",
"term_ids",
"=",
"{",
"}",
"for",
"ann",
"in",
"go_annotations",
":",
"term_ids",
"[",
"ann",
".",
"go_term",
".",
"id",
"]",
"=",
"ann",
".",
"go... | Generate a list of gene sets from a collection of GO annotations.
Each gene set corresponds to all genes annotated with a certain GO term. | [
"Generate",
"a",
"list",
"of",
"gene",
"sets",
"from",
"a",
"collection",
"of",
"GO",
"annotations",
"."
] | dd962bb26d60a0f14ca14d8c9a4dd75768962c7d | https://github.com/flo-compbio/genometools/blob/dd962bb26d60a0f14ca14d8c9a4dd75768962c7d/genometools/ontology/gaf.py#L136-L160 |
55,735 | nkavaldj/myhdl_lib | myhdl_lib/pipeline_control.py | _stage_ctrl | def _stage_ctrl(rst, clk, rx_rdy, rx_vld, tx_rdy, tx_vld, stage_en, stop_rx=None, stop_tx=None, BC=False):
''' Single stage control
BC - enable bubble compression
'''
if stop_rx==None:
stop_rx = False
if stop_tx==None:
stop_tx = False
state = Signal(bool(0))
a = Sig... | python | def _stage_ctrl(rst, clk, rx_rdy, rx_vld, tx_rdy, tx_vld, stage_en, stop_rx=None, stop_tx=None, BC=False):
''' Single stage control
BC - enable bubble compression
'''
if stop_rx==None:
stop_rx = False
if stop_tx==None:
stop_tx = False
state = Signal(bool(0))
a = Sig... | [
"def",
"_stage_ctrl",
"(",
"rst",
",",
"clk",
",",
"rx_rdy",
",",
"rx_vld",
",",
"tx_rdy",
",",
"tx_vld",
",",
"stage_en",
",",
"stop_rx",
"=",
"None",
",",
"stop_tx",
"=",
"None",
",",
"BC",
"=",
"False",
")",
":",
"if",
"stop_rx",
"==",
"None",
"... | Single stage control
BC - enable bubble compression | [
"Single",
"stage",
"control",
"BC",
"-",
"enable",
"bubble",
"compression"
] | 9902afd2031e7847373f692821b2135fd0810aa8 | https://github.com/nkavaldj/myhdl_lib/blob/9902afd2031e7847373f692821b2135fd0810aa8/myhdl_lib/pipeline_control.py#L124-L155 |
55,736 | acorg/dark-matter | dark/diamond/hsp.py | _sanityCheck | def _sanityCheck(subjectStart, subjectEnd, queryStart, queryEnd,
queryStartInSubject, queryEndInSubject, hsp, queryLen,
subjectGaps, queryGaps, localDict):
"""
Perform some sanity checks on an HSP. Call _debugPrint on any error.
@param subjectStart: The 0-based C{int} star... | python | def _sanityCheck(subjectStart, subjectEnd, queryStart, queryEnd,
queryStartInSubject, queryEndInSubject, hsp, queryLen,
subjectGaps, queryGaps, localDict):
"""
Perform some sanity checks on an HSP. Call _debugPrint on any error.
@param subjectStart: The 0-based C{int} star... | [
"def",
"_sanityCheck",
"(",
"subjectStart",
",",
"subjectEnd",
",",
"queryStart",
",",
"queryEnd",
",",
"queryStartInSubject",
",",
"queryEndInSubject",
",",
"hsp",
",",
"queryLen",
",",
"subjectGaps",
",",
"queryGaps",
",",
"localDict",
")",
":",
"# Subject indic... | Perform some sanity checks on an HSP. Call _debugPrint on any error.
@param subjectStart: The 0-based C{int} start offset of the match in the
subject.
@param subjectEnd: The 0-based C{int} end offset of the match in the
subject.
@param queryStart: The 0-based C{int} start offset of the matc... | [
"Perform",
"some",
"sanity",
"checks",
"on",
"an",
"HSP",
".",
"Call",
"_debugPrint",
"on",
"any",
"error",
"."
] | c78a1bf262667fa5db3548fa7066c4ec14d0551d | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/diamond/hsp.py#L34-L82 |
55,737 | flo-compbio/genometools | genometools/gcloud/service_account.py | get_compute_credentials | def get_compute_credentials(key):
"""Authenticates a service account for the compute engine.
This uses the `oauth2client.service_account` module. Since the `google`
Python package does not support the compute engine (yet?), we need to make
direct HTTP requests. For that we need authentication tokens. O... | python | def get_compute_credentials(key):
"""Authenticates a service account for the compute engine.
This uses the `oauth2client.service_account` module. Since the `google`
Python package does not support the compute engine (yet?), we need to make
direct HTTP requests. For that we need authentication tokens. O... | [
"def",
"get_compute_credentials",
"(",
"key",
")",
":",
"scopes",
"=",
"[",
"'https://www.googleapis.com/auth/compute'",
"]",
"credentials",
"=",
"ServiceAccountCredentials",
".",
"from_json_keyfile_dict",
"(",
"key",
",",
"scopes",
"=",
"scopes",
")",
"return",
"cred... | Authenticates a service account for the compute engine.
This uses the `oauth2client.service_account` module. Since the `google`
Python package does not support the compute engine (yet?), we need to make
direct HTTP requests. For that we need authentication tokens. Obtaining
these based on the credentia... | [
"Authenticates",
"a",
"service",
"account",
"for",
"the",
"compute",
"engine",
"."
] | dd962bb26d60a0f14ca14d8c9a4dd75768962c7d | https://github.com/flo-compbio/genometools/blob/dd962bb26d60a0f14ca14d8c9a4dd75768962c7d/genometools/gcloud/service_account.py#L28-L47 |
55,738 | flo-compbio/genometools | genometools/expression/gene_table.py | ExpGeneTable.hash | def hash(self):
"""Generate a hash value."""
h = hash_pandas_object(self, index=True)
return hashlib.md5(h.values.tobytes()).hexdigest() | python | def hash(self):
"""Generate a hash value."""
h = hash_pandas_object(self, index=True)
return hashlib.md5(h.values.tobytes()).hexdigest() | [
"def",
"hash",
"(",
"self",
")",
":",
"h",
"=",
"hash_pandas_object",
"(",
"self",
",",
"index",
"=",
"True",
")",
"return",
"hashlib",
".",
"md5",
"(",
"h",
".",
"values",
".",
"tobytes",
"(",
")",
")",
".",
"hexdigest",
"(",
")"
] | Generate a hash value. | [
"Generate",
"a",
"hash",
"value",
"."
] | dd962bb26d60a0f14ca14d8c9a4dd75768962c7d | https://github.com/flo-compbio/genometools/blob/dd962bb26d60a0f14ca14d8c9a4dd75768962c7d/genometools/expression/gene_table.py#L86-L89 |
55,739 | flo-compbio/genometools | genometools/expression/gene_table.py | ExpGeneTable.genes | def genes(self):
"""Return a list of all genes."""
return [ExpGene.from_series(g)
for i, g in self.reset_index().iterrows()] | python | def genes(self):
"""Return a list of all genes."""
return [ExpGene.from_series(g)
for i, g in self.reset_index().iterrows()] | [
"def",
"genes",
"(",
"self",
")",
":",
"return",
"[",
"ExpGene",
".",
"from_series",
"(",
"g",
")",
"for",
"i",
",",
"g",
"in",
"self",
".",
"reset_index",
"(",
")",
".",
"iterrows",
"(",
")",
"]"
] | Return a list of all genes. | [
"Return",
"a",
"list",
"of",
"all",
"genes",
"."
] | dd962bb26d60a0f14ca14d8c9a4dd75768962c7d | https://github.com/flo-compbio/genometools/blob/dd962bb26d60a0f14ca14d8c9a4dd75768962c7d/genometools/expression/gene_table.py#L97-L100 |
55,740 | flo-compbio/genometools | genometools/expression/gene_table.py | ExpGeneTable.read_tsv | def read_tsv(cls, file_or_buffer: str):
"""Read genes from tab-delimited text file."""
df = pd.read_csv(file_or_buffer, sep='\t', index_col=0)
df = df.where(pd.notnull(df), None)
# Note: df.where(..., None) changes all column types to `object`.
return cls(df) | python | def read_tsv(cls, file_or_buffer: str):
"""Read genes from tab-delimited text file."""
df = pd.read_csv(file_or_buffer, sep='\t', index_col=0)
df = df.where(pd.notnull(df), None)
# Note: df.where(..., None) changes all column types to `object`.
return cls(df) | [
"def",
"read_tsv",
"(",
"cls",
",",
"file_or_buffer",
":",
"str",
")",
":",
"df",
"=",
"pd",
".",
"read_csv",
"(",
"file_or_buffer",
",",
"sep",
"=",
"'\\t'",
",",
"index_col",
"=",
"0",
")",
"df",
"=",
"df",
".",
"where",
"(",
"pd",
".",
"notnull"... | Read genes from tab-delimited text file. | [
"Read",
"genes",
"from",
"tab",
"-",
"delimited",
"text",
"file",
"."
] | dd962bb26d60a0f14ca14d8c9a4dd75768962c7d | https://github.com/flo-compbio/genometools/blob/dd962bb26d60a0f14ca14d8c9a4dd75768962c7d/genometools/expression/gene_table.py#L113-L118 |
55,741 | flo-compbio/genometools | genometools/expression/gene_table.py | ExpGeneTable.from_genes | def from_genes(cls, genes: List[ExpGene]):
"""Initialize instance using a list of `ExpGene` objects."""
data = [g.to_dict() for g in genes]
index = [d.pop('ensembl_id') for d in data]
table = cls(data, index=index)
return table | python | def from_genes(cls, genes: List[ExpGene]):
"""Initialize instance using a list of `ExpGene` objects."""
data = [g.to_dict() for g in genes]
index = [d.pop('ensembl_id') for d in data]
table = cls(data, index=index)
return table | [
"def",
"from_genes",
"(",
"cls",
",",
"genes",
":",
"List",
"[",
"ExpGene",
"]",
")",
":",
"data",
"=",
"[",
"g",
".",
"to_dict",
"(",
")",
"for",
"g",
"in",
"genes",
"]",
"index",
"=",
"[",
"d",
".",
"pop",
"(",
"'ensembl_id'",
")",
"for",
"d"... | Initialize instance using a list of `ExpGene` objects. | [
"Initialize",
"instance",
"using",
"a",
"list",
"of",
"ExpGene",
"objects",
"."
] | dd962bb26d60a0f14ca14d8c9a4dd75768962c7d | https://github.com/flo-compbio/genometools/blob/dd962bb26d60a0f14ca14d8c9a4dd75768962c7d/genometools/expression/gene_table.py#L121-L126 |
55,742 | flo-compbio/genometools | genometools/expression/gene_table.py | ExpGeneTable.from_gene_ids | def from_gene_ids(cls, gene_ids: List[str]):
"""Initialize instance from gene IDs."""
genes = [ExpGene(id_) for id_ in gene_ids]
return cls.from_genes(genes) | python | def from_gene_ids(cls, gene_ids: List[str]):
"""Initialize instance from gene IDs."""
genes = [ExpGene(id_) for id_ in gene_ids]
return cls.from_genes(genes) | [
"def",
"from_gene_ids",
"(",
"cls",
",",
"gene_ids",
":",
"List",
"[",
"str",
"]",
")",
":",
"genes",
"=",
"[",
"ExpGene",
"(",
"id_",
")",
"for",
"id_",
"in",
"gene_ids",
"]",
"return",
"cls",
".",
"from_genes",
"(",
"genes",
")"
] | Initialize instance from gene IDs. | [
"Initialize",
"instance",
"from",
"gene",
"IDs",
"."
] | dd962bb26d60a0f14ca14d8c9a4dd75768962c7d | https://github.com/flo-compbio/genometools/blob/dd962bb26d60a0f14ca14d8c9a4dd75768962c7d/genometools/expression/gene_table.py#L129-L132 |
55,743 | flo-compbio/genometools | genometools/expression/gene_table.py | ExpGeneTable.from_gene_ids_and_names | def from_gene_ids_and_names(cls, gene_names: Dict[str, str]):
"""Initialize instance from gene IDs and names."""
genes = [ExpGene(id_, name=name) for id_, name in gene_names.items()]
return cls.from_genes(genes) | python | def from_gene_ids_and_names(cls, gene_names: Dict[str, str]):
"""Initialize instance from gene IDs and names."""
genes = [ExpGene(id_, name=name) for id_, name in gene_names.items()]
return cls.from_genes(genes) | [
"def",
"from_gene_ids_and_names",
"(",
"cls",
",",
"gene_names",
":",
"Dict",
"[",
"str",
",",
"str",
"]",
")",
":",
"genes",
"=",
"[",
"ExpGene",
"(",
"id_",
",",
"name",
"=",
"name",
")",
"for",
"id_",
",",
"name",
"in",
"gene_names",
".",
"items",... | Initialize instance from gene IDs and names. | [
"Initialize",
"instance",
"from",
"gene",
"IDs",
"and",
"names",
"."
] | dd962bb26d60a0f14ca14d8c9a4dd75768962c7d | https://github.com/flo-compbio/genometools/blob/dd962bb26d60a0f14ca14d8c9a4dd75768962c7d/genometools/expression/gene_table.py#L135-L138 |
55,744 | ownport/scrapy-dblite | dblite/__init__.py | copy | def copy(src, trg, transform=None):
''' copy items with optional fields transformation
'''
source = open(src[0], src[1])
target = open(trg[0], trg[1], autocommit=1000)
for item in source.get():
item = dict(item)
if '_id' in item:
del item['_id']
if transform:
... | python | def copy(src, trg, transform=None):
''' copy items with optional fields transformation
'''
source = open(src[0], src[1])
target = open(trg[0], trg[1], autocommit=1000)
for item in source.get():
item = dict(item)
if '_id' in item:
del item['_id']
if transform:
... | [
"def",
"copy",
"(",
"src",
",",
"trg",
",",
"transform",
"=",
"None",
")",
":",
"source",
"=",
"open",
"(",
"src",
"[",
"0",
"]",
",",
"src",
"[",
"1",
"]",
")",
"target",
"=",
"open",
"(",
"trg",
"[",
"0",
"]",
",",
"trg",
"[",
"1",
"]",
... | copy items with optional fields transformation | [
"copy",
"items",
"with",
"optional",
"fields",
"transformation"
] | 6de5021caa31d439478d9808738b046d1db699c9 | https://github.com/ownport/scrapy-dblite/blob/6de5021caa31d439478d9808738b046d1db699c9/dblite/__init__.py#L34-L51 |
55,745 | ownport/scrapy-dblite | dblite/__init__.py | _regexp | def _regexp(expr, item):
''' REGEXP function for Sqlite
'''
reg = re.compile(expr)
return reg.search(item) is not None | python | def _regexp(expr, item):
''' REGEXP function for Sqlite
'''
reg = re.compile(expr)
return reg.search(item) is not None | [
"def",
"_regexp",
"(",
"expr",
",",
"item",
")",
":",
"reg",
"=",
"re",
".",
"compile",
"(",
"expr",
")",
"return",
"reg",
".",
"search",
"(",
"item",
")",
"is",
"not",
"None"
] | REGEXP function for Sqlite | [
"REGEXP",
"function",
"for",
"Sqlite"
] | 6de5021caa31d439478d9808738b046d1db699c9 | https://github.com/ownport/scrapy-dblite/blob/6de5021caa31d439478d9808738b046d1db699c9/dblite/__init__.py#L54-L58 |
55,746 | ownport/scrapy-dblite | dblite/__init__.py | Storage._dict_factory | def _dict_factory(cursor, row):
''' factory for sqlite3 to return results as dict
'''
d = {}
for idx, col in enumerate(cursor.description):
if col[0] == 'rowid':
d['_id'] = row[idx]
else:
d[col[0]] = row[idx]
return d | python | def _dict_factory(cursor, row):
''' factory for sqlite3 to return results as dict
'''
d = {}
for idx, col in enumerate(cursor.description):
if col[0] == 'rowid':
d['_id'] = row[idx]
else:
d[col[0]] = row[idx]
return d | [
"def",
"_dict_factory",
"(",
"cursor",
",",
"row",
")",
":",
"d",
"=",
"{",
"}",
"for",
"idx",
",",
"col",
"in",
"enumerate",
"(",
"cursor",
".",
"description",
")",
":",
"if",
"col",
"[",
"0",
"]",
"==",
"'rowid'",
":",
"d",
"[",
"'_id'",
"]",
... | factory for sqlite3 to return results as dict | [
"factory",
"for",
"sqlite3",
"to",
"return",
"results",
"as",
"dict"
] | 6de5021caa31d439478d9808738b046d1db699c9 | https://github.com/ownport/scrapy-dblite/blob/6de5021caa31d439478d9808738b046d1db699c9/dblite/__init__.py#L121-L130 |
55,747 | ownport/scrapy-dblite | dblite/__init__.py | Storage._create_table | def _create_table(self, table_name):
''' create sqlite's table for storing simple dictionaries
'''
if self.fieldnames:
sql_fields = []
for field in self._fields:
if field != '_id':
if 'dblite' in self._fields[field]:
... | python | def _create_table(self, table_name):
''' create sqlite's table for storing simple dictionaries
'''
if self.fieldnames:
sql_fields = []
for field in self._fields:
if field != '_id':
if 'dblite' in self._fields[field]:
... | [
"def",
"_create_table",
"(",
"self",
",",
"table_name",
")",
":",
"if",
"self",
".",
"fieldnames",
":",
"sql_fields",
"=",
"[",
"]",
"for",
"field",
"in",
"self",
".",
"_fields",
":",
"if",
"field",
"!=",
"'_id'",
":",
"if",
"'dblite'",
"in",
"self",
... | create sqlite's table for storing simple dictionaries | [
"create",
"sqlite",
"s",
"table",
"for",
"storing",
"simple",
"dictionaries"
] | 6de5021caa31d439478d9808738b046d1db699c9 | https://github.com/ownport/scrapy-dblite/blob/6de5021caa31d439478d9808738b046d1db699c9/dblite/__init__.py#L160-L176 |
55,748 | ownport/scrapy-dblite | dblite/__init__.py | Storage._make_item | def _make_item(self, item):
''' make Item class
'''
for field in self._item_class.fields:
if (field in item) and ('dblite_serializer' in self._item_class.fields[field]):
serializer = self._item_class.fields[field]['dblite_serializer']
item[field] = ser... | python | def _make_item(self, item):
''' make Item class
'''
for field in self._item_class.fields:
if (field in item) and ('dblite_serializer' in self._item_class.fields[field]):
serializer = self._item_class.fields[field]['dblite_serializer']
item[field] = ser... | [
"def",
"_make_item",
"(",
"self",
",",
"item",
")",
":",
"for",
"field",
"in",
"self",
".",
"_item_class",
".",
"fields",
":",
"if",
"(",
"field",
"in",
"item",
")",
"and",
"(",
"'dblite_serializer'",
"in",
"self",
".",
"_item_class",
".",
"fields",
"[... | make Item class | [
"make",
"Item",
"class"
] | 6de5021caa31d439478d9808738b046d1db699c9 | https://github.com/ownport/scrapy-dblite/blob/6de5021caa31d439478d9808738b046d1db699c9/dblite/__init__.py#L178-L185 |
55,749 | ownport/scrapy-dblite | dblite/__init__.py | Storage._get_all | def _get_all(self):
''' return all items
'''
rowid = 0
while True:
SQL_SELECT_MANY = 'SELECT rowid, * FROM %s WHERE rowid > ? LIMIT ?;' % self._table
self._cursor.execute(SQL_SELECT_MANY, (rowid, ITEMS_PER_REQUEST))
items = self._cursor.fetchall()
... | python | def _get_all(self):
''' return all items
'''
rowid = 0
while True:
SQL_SELECT_MANY = 'SELECT rowid, * FROM %s WHERE rowid > ? LIMIT ?;' % self._table
self._cursor.execute(SQL_SELECT_MANY, (rowid, ITEMS_PER_REQUEST))
items = self._cursor.fetchall()
... | [
"def",
"_get_all",
"(",
"self",
")",
":",
"rowid",
"=",
"0",
"while",
"True",
":",
"SQL_SELECT_MANY",
"=",
"'SELECT rowid, * FROM %s WHERE rowid > ? LIMIT ?;'",
"%",
"self",
".",
"_table",
"self",
".",
"_cursor",
".",
"execute",
"(",
"SQL_SELECT_MANY",
",",
"(",... | return all items | [
"return",
"all",
"items"
] | 6de5021caa31d439478d9808738b046d1db699c9 | https://github.com/ownport/scrapy-dblite/blob/6de5021caa31d439478d9808738b046d1db699c9/dblite/__init__.py#L199-L211 |
55,750 | ownport/scrapy-dblite | dblite/__init__.py | Storage.get_one | def get_one(self, criteria):
''' return one item
'''
try:
items = [item for item in self._get_with_criteria(criteria, limit=1)]
return items[0]
except:
return None | python | def get_one(self, criteria):
''' return one item
'''
try:
items = [item for item in self._get_with_criteria(criteria, limit=1)]
return items[0]
except:
return None | [
"def",
"get_one",
"(",
"self",
",",
"criteria",
")",
":",
"try",
":",
"items",
"=",
"[",
"item",
"for",
"item",
"in",
"self",
".",
"_get_with_criteria",
"(",
"criteria",
",",
"limit",
"=",
"1",
")",
"]",
"return",
"items",
"[",
"0",
"]",
"except",
... | return one item | [
"return",
"one",
"item"
] | 6de5021caa31d439478d9808738b046d1db699c9 | https://github.com/ownport/scrapy-dblite/blob/6de5021caa31d439478d9808738b046d1db699c9/dblite/__init__.py#L221-L228 |
55,751 | ownport/scrapy-dblite | dblite/__init__.py | Storage.put | def put(self, item):
''' store item in sqlite database
'''
if isinstance(item, self._item_class):
self._put_one(item)
elif isinstance(item, (list, tuple)):
self._put_many(item)
else:
raise RuntimeError('Unknown item(s) type, %s' % type(item)) | python | def put(self, item):
''' store item in sqlite database
'''
if isinstance(item, self._item_class):
self._put_one(item)
elif isinstance(item, (list, tuple)):
self._put_many(item)
else:
raise RuntimeError('Unknown item(s) type, %s' % type(item)) | [
"def",
"put",
"(",
"self",
",",
"item",
")",
":",
"if",
"isinstance",
"(",
"item",
",",
"self",
".",
"_item_class",
")",
":",
"self",
".",
"_put_one",
"(",
"item",
")",
"elif",
"isinstance",
"(",
"item",
",",
"(",
"list",
",",
"tuple",
")",
")",
... | store item in sqlite database | [
"store",
"item",
"in",
"sqlite",
"database"
] | 6de5021caa31d439478d9808738b046d1db699c9 | https://github.com/ownport/scrapy-dblite/blob/6de5021caa31d439478d9808738b046d1db699c9/dblite/__init__.py#L246-L254 |
55,752 | ownport/scrapy-dblite | dblite/__init__.py | Storage._put_one | def _put_one(self, item):
''' store one item in database
'''
# prepare values
values = []
for k, v in item.items():
if k == '_id':
continue
if 'dblite_serializer' in item.fields[k]:
serializer = item.fields[k]['dblite_serial... | python | def _put_one(self, item):
''' store one item in database
'''
# prepare values
values = []
for k, v in item.items():
if k == '_id':
continue
if 'dblite_serializer' in item.fields[k]:
serializer = item.fields[k]['dblite_serial... | [
"def",
"_put_one",
"(",
"self",
",",
"item",
")",
":",
"# prepare values",
"values",
"=",
"[",
"]",
"for",
"k",
",",
"v",
"in",
"item",
".",
"items",
"(",
")",
":",
"if",
"k",
"==",
"'_id'",
":",
"continue",
"if",
"'dblite_serializer'",
"in",
"item",... | store one item in database | [
"store",
"one",
"item",
"in",
"database"
] | 6de5021caa31d439478d9808738b046d1db699c9 | https://github.com/ownport/scrapy-dblite/blob/6de5021caa31d439478d9808738b046d1db699c9/dblite/__init__.py#L256-L288 |
55,753 | ownport/scrapy-dblite | dblite/__init__.py | Storage._put_many | def _put_many(self, items):
''' store items in sqlite database
'''
for item in items:
if not isinstance(item, self._item_class):
raise RuntimeError('Items mismatch for %s and %s' % (self._item_class, type(item)))
self._put_one(item) | python | def _put_many(self, items):
''' store items in sqlite database
'''
for item in items:
if not isinstance(item, self._item_class):
raise RuntimeError('Items mismatch for %s and %s' % (self._item_class, type(item)))
self._put_one(item) | [
"def",
"_put_many",
"(",
"self",
",",
"items",
")",
":",
"for",
"item",
"in",
"items",
":",
"if",
"not",
"isinstance",
"(",
"item",
",",
"self",
".",
"_item_class",
")",
":",
"raise",
"RuntimeError",
"(",
"'Items mismatch for %s and %s'",
"%",
"(",
"self",... | store items in sqlite database | [
"store",
"items",
"in",
"sqlite",
"database"
] | 6de5021caa31d439478d9808738b046d1db699c9 | https://github.com/ownport/scrapy-dblite/blob/6de5021caa31d439478d9808738b046d1db699c9/dblite/__init__.py#L290-L296 |
55,754 | ownport/scrapy-dblite | dblite/__init__.py | Storage.sql | def sql(self, sql, params=()):
''' execute sql request and return items
'''
def _items(items):
for item in items:
yield self._item_class(item)
sql = sql.strip()
try:
self._cursor.execute(sql, params)
except sqlite3.OperationalError... | python | def sql(self, sql, params=()):
''' execute sql request and return items
'''
def _items(items):
for item in items:
yield self._item_class(item)
sql = sql.strip()
try:
self._cursor.execute(sql, params)
except sqlite3.OperationalError... | [
"def",
"sql",
"(",
"self",
",",
"sql",
",",
"params",
"=",
"(",
")",
")",
":",
"def",
"_items",
"(",
"items",
")",
":",
"for",
"item",
"in",
"items",
":",
"yield",
"self",
".",
"_item_class",
"(",
"item",
")",
"sql",
"=",
"sql",
".",
"strip",
"... | execute sql request and return items | [
"execute",
"sql",
"request",
"and",
"return",
"items"
] | 6de5021caa31d439478d9808738b046d1db699c9 | https://github.com/ownport/scrapy-dblite/blob/6de5021caa31d439478d9808738b046d1db699c9/dblite/__init__.py#L298-L316 |
55,755 | invenia/Arbiter | arbiter/async.py | run_tasks | def run_tasks(tasks, max_workers=None, use_processes=False):
"""
Run an iterable of tasks.
tasks: The iterable of tasks
max_workers: (optional, None) The maximum number of workers to use.
As of Python 3.5, if None is passed to the thread executor will
default to 5 * the number of proces... | python | def run_tasks(tasks, max_workers=None, use_processes=False):
"""
Run an iterable of tasks.
tasks: The iterable of tasks
max_workers: (optional, None) The maximum number of workers to use.
As of Python 3.5, if None is passed to the thread executor will
default to 5 * the number of proces... | [
"def",
"run_tasks",
"(",
"tasks",
",",
"max_workers",
"=",
"None",
",",
"use_processes",
"=",
"False",
")",
":",
"futures",
"=",
"set",
"(",
")",
"if",
"use_processes",
":",
"get_executor",
"=",
"concurrent",
".",
"futures",
".",
"ProcessPoolExecutor",
"else... | Run an iterable of tasks.
tasks: The iterable of tasks
max_workers: (optional, None) The maximum number of workers to use.
As of Python 3.5, if None is passed to the thread executor will
default to 5 * the number of processors and the process executor
will default to the number of proce... | [
"Run",
"an",
"iterable",
"of",
"tasks",
"."
] | 51008393ae8797da85bcd67807259a157f941dfd | https://github.com/invenia/Arbiter/blob/51008393ae8797da85bcd67807259a157f941dfd/arbiter/async.py#L12-L70 |
55,756 | flo-compbio/genometools | genometools/gcloud/operations.py | wait_for_zone_op | def wait_for_zone_op(access_token, project, zone, name, interval=1.0):
"""Wait until a zone operation is finished.
TODO: docstring"""
assert isinstance(interval, (int, float))
assert interval >= 0.1
status = 'RUNNING'
progress = 0
LOGGER.info('Waiting for zone operation "%s" to finis... | python | def wait_for_zone_op(access_token, project, zone, name, interval=1.0):
"""Wait until a zone operation is finished.
TODO: docstring"""
assert isinstance(interval, (int, float))
assert interval >= 0.1
status = 'RUNNING'
progress = 0
LOGGER.info('Waiting for zone operation "%s" to finis... | [
"def",
"wait_for_zone_op",
"(",
"access_token",
",",
"project",
",",
"zone",
",",
"name",
",",
"interval",
"=",
"1.0",
")",
":",
"assert",
"isinstance",
"(",
"interval",
",",
"(",
"int",
",",
"float",
")",
")",
"assert",
"interval",
">=",
"0.1",
"status"... | Wait until a zone operation is finished.
TODO: docstring | [
"Wait",
"until",
"a",
"zone",
"operation",
"is",
"finished",
"."
] | dd962bb26d60a0f14ca14d8c9a4dd75768962c7d | https://github.com/flo-compbio/genometools/blob/dd962bb26d60a0f14ca14d8c9a4dd75768962c7d/genometools/gcloud/operations.py#L12-L41 |
55,757 | acorg/dark-matter | dark/local_align.py | LocalAlignment._initialise | def _initialise(self):
"""
Initialises table with dictionary.
"""
d = {'score': 0, 'pointer': None, 'ins': 0, 'del': 0}
cols = len(self.seq1Seq) + 1
rows = len(self.seq2Seq) + 1
# Note that this puts a ref to the same dict (d) into each cell of
# the table... | python | def _initialise(self):
"""
Initialises table with dictionary.
"""
d = {'score': 0, 'pointer': None, 'ins': 0, 'del': 0}
cols = len(self.seq1Seq) + 1
rows = len(self.seq2Seq) + 1
# Note that this puts a ref to the same dict (d) into each cell of
# the table... | [
"def",
"_initialise",
"(",
"self",
")",
":",
"d",
"=",
"{",
"'score'",
":",
"0",
",",
"'pointer'",
":",
"None",
",",
"'ins'",
":",
"0",
",",
"'del'",
":",
"0",
"}",
"cols",
"=",
"len",
"(",
"self",
".",
"seq1Seq",
")",
"+",
"1",
"rows",
"=",
... | Initialises table with dictionary. | [
"Initialises",
"table",
"with",
"dictionary",
"."
] | c78a1bf262667fa5db3548fa7066c4ec14d0551d | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/local_align.py#L57-L69 |
55,758 | acorg/dark-matter | dark/local_align.py | LocalAlignment._cigarString | def _cigarString(self, output):
"""
Return a cigar string of aligned sequences.
@param output: a C{tup} of strings (align1, align, align2)
@return: a C{str} containing the cigar string. Eg with input:
'GGCCCGCA' and 'GG-CTGCA', return 2=1D1=1X3=
"""
cigar = [... | python | def _cigarString(self, output):
"""
Return a cigar string of aligned sequences.
@param output: a C{tup} of strings (align1, align, align2)
@return: a C{str} containing the cigar string. Eg with input:
'GGCCCGCA' and 'GG-CTGCA', return 2=1D1=1X3=
"""
cigar = [... | [
"def",
"_cigarString",
"(",
"self",
",",
"output",
")",
":",
"cigar",
"=",
"[",
"]",
"count",
"=",
"0",
"align1",
"=",
"output",
"[",
"0",
"]",
"align2",
"=",
"output",
"[",
"2",
"]",
"for",
"nt1",
",",
"nt2",
"in",
"zip",
"(",
"align1",
",",
"... | Return a cigar string of aligned sequences.
@param output: a C{tup} of strings (align1, align, align2)
@return: a C{str} containing the cigar string. Eg with input:
'GGCCCGCA' and 'GG-CTGCA', return 2=1D1=1X3= | [
"Return",
"a",
"cigar",
"string",
"of",
"aligned",
"sequences",
"."
] | c78a1bf262667fa5db3548fa7066c4ec14d0551d | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/local_align.py#L201-L242 |
55,759 | acorg/dark-matter | dark/local_align.py | LocalAlignment._alignmentToStr | def _alignmentToStr(self, result):
"""
Make a textual representation of an alignment result.
@param result: A C{dict}, as returned by C{self.createAlignment}.
@return: A C{str} desription of a result. For every three lines the
first and third contain the input sequences, pos... | python | def _alignmentToStr(self, result):
"""
Make a textual representation of an alignment result.
@param result: A C{dict}, as returned by C{self.createAlignment}.
@return: A C{str} desription of a result. For every three lines the
first and third contain the input sequences, pos... | [
"def",
"_alignmentToStr",
"(",
"self",
",",
"result",
")",
":",
"if",
"result",
"is",
"None",
":",
"return",
"(",
"'\\nNo alignment between %s and %s\\n'",
"%",
"(",
"self",
".",
"seq1ID",
",",
"self",
".",
"seq2ID",
")",
")",
"else",
":",
"header",
"=",
... | Make a textual representation of an alignment result.
@param result: A C{dict}, as returned by C{self.createAlignment}.
@return: A C{str} desription of a result. For every three lines the
first and third contain the input sequences, possibly padded
with '-'. The second contains ... | [
"Make",
"a",
"textual",
"representation",
"of",
"an",
"alignment",
"result",
"."
] | c78a1bf262667fa5db3548fa7066c4ec14d0551d | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/local_align.py#L293-L326 |
55,760 | acorg/dark-matter | dark/local_align.py | LocalAlignment.createAlignment | def createAlignment(self, resultFormat=dict):
"""
Run the alignment algorithm.
@param resultFormat: Either C{dict} or C{str}, giving the desired
result format.
@return: If C{resultFormat} is C{dict}, a C{dict} containing
information about the match (or C{None}) i... | python | def createAlignment(self, resultFormat=dict):
"""
Run the alignment algorithm.
@param resultFormat: Either C{dict} or C{str}, giving the desired
result format.
@return: If C{resultFormat} is C{dict}, a C{dict} containing
information about the match (or C{None}) i... | [
"def",
"createAlignment",
"(",
"self",
",",
"resultFormat",
"=",
"dict",
")",
":",
"table",
"=",
"self",
".",
"_initialise",
"(",
")",
"alignment",
"=",
"self",
".",
"_fillAndTraceback",
"(",
"table",
")",
"output",
"=",
"alignment",
"[",
"0",
"]",
"if",... | Run the alignment algorithm.
@param resultFormat: Either C{dict} or C{str}, giving the desired
result format.
@return: If C{resultFormat} is C{dict}, a C{dict} containing
information about the match (or C{None}) if there is no match.
If C{resultFormat} is C{str}, a C... | [
"Run",
"the",
"alignment",
"algorithm",
"."
] | c78a1bf262667fa5db3548fa7066c4ec14d0551d | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/local_align.py#L328-L356 |
55,761 | ownport/scrapy-dblite | dblite/query.py | SQLBuilder.select | def select(self, fields=['rowid', '*'], offset=None, limit=None):
''' return SELECT SQL
'''
# base SQL
SQL = 'SELECT %s FROM %s' % (','.join(fields), self._table)
# selectors
if self._selectors:
SQL = ' '.join([SQL, 'WHERE', self._selectors]).strip()
... | python | def select(self, fields=['rowid', '*'], offset=None, limit=None):
''' return SELECT SQL
'''
# base SQL
SQL = 'SELECT %s FROM %s' % (','.join(fields), self._table)
# selectors
if self._selectors:
SQL = ' '.join([SQL, 'WHERE', self._selectors]).strip()
... | [
"def",
"select",
"(",
"self",
",",
"fields",
"=",
"[",
"'rowid'",
",",
"'*'",
"]",
",",
"offset",
"=",
"None",
",",
"limit",
"=",
"None",
")",
":",
"# base SQL",
"SQL",
"=",
"'SELECT %s FROM %s'",
"%",
"(",
"','",
".",
"join",
"(",
"fields",
")",
"... | return SELECT SQL | [
"return",
"SELECT",
"SQL"
] | 6de5021caa31d439478d9808738b046d1db699c9 | https://github.com/ownport/scrapy-dblite/blob/6de5021caa31d439478d9808738b046d1db699c9/dblite/query.py#L37-L59 |
55,762 | ownport/scrapy-dblite | dblite/query.py | SQLBuilder.delete | def delete(self):
''' return DELETE SQL
'''
SQL = 'DELETE FROM %s' % self._table
if self._selectors:
SQL = ' '.join([SQL, 'WHERE', self._selectors]).strip()
return SQL | python | def delete(self):
''' return DELETE SQL
'''
SQL = 'DELETE FROM %s' % self._table
if self._selectors:
SQL = ' '.join([SQL, 'WHERE', self._selectors]).strip()
return SQL | [
"def",
"delete",
"(",
"self",
")",
":",
"SQL",
"=",
"'DELETE FROM %s'",
"%",
"self",
".",
"_table",
"if",
"self",
".",
"_selectors",
":",
"SQL",
"=",
"' '",
".",
"join",
"(",
"[",
"SQL",
",",
"'WHERE'",
",",
"self",
".",
"_selectors",
"]",
")",
"."... | return DELETE SQL | [
"return",
"DELETE",
"SQL"
] | 6de5021caa31d439478d9808738b046d1db699c9 | https://github.com/ownport/scrapy-dblite/blob/6de5021caa31d439478d9808738b046d1db699c9/dblite/query.py#L61-L68 |
55,763 | ownport/scrapy-dblite | dblite/query.py | SQLBuilder._parse | def _parse(self, params):
''' parse parameters and return SQL
'''
if not isinstance(params, dict):
return None, None
if len(params) == 0:
return None, None
selectors = list()
modifiers = list()
for k in params.keys():
... | python | def _parse(self, params):
''' parse parameters and return SQL
'''
if not isinstance(params, dict):
return None, None
if len(params) == 0:
return None, None
selectors = list()
modifiers = list()
for k in params.keys():
... | [
"def",
"_parse",
"(",
"self",
",",
"params",
")",
":",
"if",
"not",
"isinstance",
"(",
"params",
",",
"dict",
")",
":",
"return",
"None",
",",
"None",
"if",
"len",
"(",
"params",
")",
"==",
"0",
":",
"return",
"None",
",",
"None",
"selectors",
"=",... | parse parameters and return SQL | [
"parse",
"parameters",
"and",
"return",
"SQL"
] | 6de5021caa31d439478d9808738b046d1db699c9 | https://github.com/ownport/scrapy-dblite/blob/6de5021caa31d439478d9808738b046d1db699c9/dblite/query.py#L70-L98 |
55,764 | ownport/scrapy-dblite | dblite/query.py | SQLBuilder._value_wrapper | def _value_wrapper(self, value):
''' wrapper for values
'''
if isinstance(value, (int, float,)):
return '=%s' % value
elif isinstance(value, (str, unicode)):
value = value.strip()
# LIKE
if RE_LIKE.match(value):
return ' LI... | python | def _value_wrapper(self, value):
''' wrapper for values
'''
if isinstance(value, (int, float,)):
return '=%s' % value
elif isinstance(value, (str, unicode)):
value = value.strip()
# LIKE
if RE_LIKE.match(value):
return ' LI... | [
"def",
"_value_wrapper",
"(",
"self",
",",
"value",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"(",
"int",
",",
"float",
",",
")",
")",
":",
"return",
"'=%s'",
"%",
"value",
"elif",
"isinstance",
"(",
"value",
",",
"(",
"str",
",",
"unicode",
... | wrapper for values | [
"wrapper",
"for",
"values"
] | 6de5021caa31d439478d9808738b046d1db699c9 | https://github.com/ownport/scrapy-dblite/blob/6de5021caa31d439478d9808738b046d1db699c9/dblite/query.py#L140-L156 |
55,765 | openfisca/openfisca-web-api | openfisca_web_api/urls.py | make_router | def make_router(*routings):
"""Return a WSGI application that dispatches requests to controllers """
routes = []
for routing in routings:
methods, regex, app = routing[:3]
if isinstance(methods, basestring):
methods = (methods,)
vars = routing[3] if len(routing) >= 4 else... | python | def make_router(*routings):
"""Return a WSGI application that dispatches requests to controllers """
routes = []
for routing in routings:
methods, regex, app = routing[:3]
if isinstance(methods, basestring):
methods = (methods,)
vars = routing[3] if len(routing) >= 4 else... | [
"def",
"make_router",
"(",
"*",
"routings",
")",
":",
"routes",
"=",
"[",
"]",
"for",
"routing",
"in",
"routings",
":",
"methods",
",",
"regex",
",",
"app",
"=",
"routing",
"[",
":",
"3",
"]",
"if",
"isinstance",
"(",
"methods",
",",
"basestring",
")... | Return a WSGI application that dispatches requests to controllers | [
"Return",
"a",
"WSGI",
"application",
"that",
"dispatches",
"requests",
"to",
"controllers"
] | d1cd3bfacac338e80bb0df7e0465b65649dd893b | https://github.com/openfisca/openfisca-web-api/blob/d1cd3bfacac338e80bb0df7e0465b65649dd893b/openfisca_web_api/urls.py#L63-L129 |
55,766 | openfisca/openfisca-web-api | openfisca_web_api/wsgihelpers.py | respond_json | def respond_json(ctx, data, code = None, headers = [], json_dumps_default = None, jsonp = None):
"""Return a JSON response.
This function is optimized for JSON following
`Google JSON Style Guide <http://google-styleguide.googlecode.com/svn/trunk/jsoncstyleguide.xml>`_, but will handle
any JSON except f... | python | def respond_json(ctx, data, code = None, headers = [], json_dumps_default = None, jsonp = None):
"""Return a JSON response.
This function is optimized for JSON following
`Google JSON Style Guide <http://google-styleguide.googlecode.com/svn/trunk/jsoncstyleguide.xml>`_, but will handle
any JSON except f... | [
"def",
"respond_json",
"(",
"ctx",
",",
"data",
",",
"code",
"=",
"None",
",",
"headers",
"=",
"[",
"]",
",",
"json_dumps_default",
"=",
"None",
",",
"jsonp",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"data",
",",
"collections",
".",
"Mapping",
... | Return a JSON response.
This function is optimized for JSON following
`Google JSON Style Guide <http://google-styleguide.googlecode.com/svn/trunk/jsoncstyleguide.xml>`_, but will handle
any JSON except for HTTP errors. | [
"Return",
"a",
"JSON",
"response",
"."
] | d1cd3bfacac338e80bb0df7e0465b65649dd893b | https://github.com/openfisca/openfisca-web-api/blob/d1cd3bfacac338e80bb0df7e0465b65649dd893b/openfisca_web_api/wsgihelpers.py#L69-L128 |
55,767 | biocommons/bioutils | src/bioutils/assemblies.py | get_assembly | def get_assembly(name):
"""read a single assembly by name, returning a dictionary of assembly data
>>> assy = get_assembly('GRCh37.p13')
>>> assy['name']
'GRCh37.p13'
>>> assy['description']
'Genome Reference Consortium Human Build 37 patch release 13 (GRCh37.p13)'
>>> assy['refseq_ac']
... | python | def get_assembly(name):
"""read a single assembly by name, returning a dictionary of assembly data
>>> assy = get_assembly('GRCh37.p13')
>>> assy['name']
'GRCh37.p13'
>>> assy['description']
'Genome Reference Consortium Human Build 37 patch release 13 (GRCh37.p13)'
>>> assy['refseq_ac']
... | [
"def",
"get_assembly",
"(",
"name",
")",
":",
"fn",
"=",
"pkg_resources",
".",
"resource_filename",
"(",
"__name__",
",",
"_assy_path_fmt",
".",
"format",
"(",
"name",
"=",
"name",
")",
")",
"return",
"json",
".",
"load",
"(",
"gzip",
".",
"open",
"(",
... | read a single assembly by name, returning a dictionary of assembly data
>>> assy = get_assembly('GRCh37.p13')
>>> assy['name']
'GRCh37.p13'
>>> assy['description']
'Genome Reference Consortium Human Build 37 patch release 13 (GRCh37.p13)'
>>> assy['refseq_ac']
'GCF_000001405.25'
>>>... | [
"read",
"a",
"single",
"assembly",
"by",
"name",
"returning",
"a",
"dictionary",
"of",
"assembly",
"data"
] | 88bcbdfa707268fed1110800e91b6d4f8e9475a0 | https://github.com/biocommons/bioutils/blob/88bcbdfa707268fed1110800e91b6d4f8e9475a0/src/bioutils/assemblies.py#L51-L85 |
55,768 | biocommons/bioutils | src/bioutils/assemblies.py | make_name_ac_map | def make_name_ac_map(assy_name, primary_only=False):
"""make map from sequence name to accession for given assembly name
>>> grch38p5_name_ac_map = make_name_ac_map('GRCh38.p5')
>>> grch38p5_name_ac_map['1']
'NC_000001.11'
"""
return {
s['name']: s['refseq_ac']
for s in get_ass... | python | def make_name_ac_map(assy_name, primary_only=False):
"""make map from sequence name to accession for given assembly name
>>> grch38p5_name_ac_map = make_name_ac_map('GRCh38.p5')
>>> grch38p5_name_ac_map['1']
'NC_000001.11'
"""
return {
s['name']: s['refseq_ac']
for s in get_ass... | [
"def",
"make_name_ac_map",
"(",
"assy_name",
",",
"primary_only",
"=",
"False",
")",
":",
"return",
"{",
"s",
"[",
"'name'",
"]",
":",
"s",
"[",
"'refseq_ac'",
"]",
"for",
"s",
"in",
"get_assembly",
"(",
"assy_name",
")",
"[",
"'sequences'",
"]",
"if",
... | make map from sequence name to accession for given assembly name
>>> grch38p5_name_ac_map = make_name_ac_map('GRCh38.p5')
>>> grch38p5_name_ac_map['1']
'NC_000001.11' | [
"make",
"map",
"from",
"sequence",
"name",
"to",
"accession",
"for",
"given",
"assembly",
"name"
] | 88bcbdfa707268fed1110800e91b6d4f8e9475a0 | https://github.com/biocommons/bioutils/blob/88bcbdfa707268fed1110800e91b6d4f8e9475a0/src/bioutils/assemblies.py#L107-L119 |
55,769 | flo-compbio/genometools | genometools/ensembl/cli/extract_protein_coding_exon_annotations.py | main | def main(args=None):
"""Extract all exon annotations of protein-coding genes."""
if args is None:
parser = get_argument_parser()
args = parser.parse_args()
input_file = args.annotation_file
output_file = args.output_file
species = args.species
chrom_pat = args.chromosome_patter... | python | def main(args=None):
"""Extract all exon annotations of protein-coding genes."""
if args is None:
parser = get_argument_parser()
args = parser.parse_args()
input_file = args.annotation_file
output_file = args.output_file
species = args.species
chrom_pat = args.chromosome_patter... | [
"def",
"main",
"(",
"args",
"=",
"None",
")",
":",
"if",
"args",
"is",
"None",
":",
"parser",
"=",
"get_argument_parser",
"(",
")",
"args",
"=",
"parser",
".",
"parse_args",
"(",
")",
"input_file",
"=",
"args",
".",
"annotation_file",
"output_file",
"=",... | Extract all exon annotations of protein-coding genes. | [
"Extract",
"all",
"exon",
"annotations",
"of",
"protein",
"-",
"coding",
"genes",
"."
] | dd962bb26d60a0f14ca14d8c9a4dd75768962c7d | https://github.com/flo-compbio/genometools/blob/dd962bb26d60a0f14ca14d8c9a4dd75768962c7d/genometools/ensembl/cli/extract_protein_coding_exon_annotations.py#L53-L131 |
55,770 | acorg/dark-matter | dark/titles.py | titleCounts | def titleCounts(readsAlignments):
"""
Count the number of times each title in a readsAlignments instance is
matched. This is useful for rapidly discovering what titles were matched
and with what frequency.
@param readsAlignments: A L{dark.alignments.ReadsAlignments} instance.
@return: A C{dict}... | python | def titleCounts(readsAlignments):
"""
Count the number of times each title in a readsAlignments instance is
matched. This is useful for rapidly discovering what titles were matched
and with what frequency.
@param readsAlignments: A L{dark.alignments.ReadsAlignments} instance.
@return: A C{dict}... | [
"def",
"titleCounts",
"(",
"readsAlignments",
")",
":",
"titles",
"=",
"defaultdict",
"(",
"int",
")",
"for",
"readAlignments",
"in",
"readsAlignments",
":",
"for",
"alignment",
"in",
"readAlignments",
":",
"titles",
"[",
"alignment",
".",
"subjectTitle",
"]",
... | Count the number of times each title in a readsAlignments instance is
matched. This is useful for rapidly discovering what titles were matched
and with what frequency.
@param readsAlignments: A L{dark.alignments.ReadsAlignments} instance.
@return: A C{dict} whose keys are titles and whose values are th... | [
"Count",
"the",
"number",
"of",
"times",
"each",
"title",
"in",
"a",
"readsAlignments",
"instance",
"is",
"matched",
".",
"This",
"is",
"useful",
"for",
"rapidly",
"discovering",
"what",
"titles",
"were",
"matched",
"and",
"with",
"what",
"frequency",
"."
] | c78a1bf262667fa5db3548fa7066c4ec14d0551d | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/titles.py#L8-L23 |
55,771 | acorg/dark-matter | dark/titles.py | TitleAlignment.toDict | def toDict(self):
"""
Get information about a title alignment as a dictionary.
@return: A C{dict} representation of the title aligment.
"""
return {
'hsps': [hsp.toDict() for hsp in self.hsps],
'read': self.read.toDict(),
} | python | def toDict(self):
"""
Get information about a title alignment as a dictionary.
@return: A C{dict} representation of the title aligment.
"""
return {
'hsps': [hsp.toDict() for hsp in self.hsps],
'read': self.read.toDict(),
} | [
"def",
"toDict",
"(",
"self",
")",
":",
"return",
"{",
"'hsps'",
":",
"[",
"hsp",
".",
"toDict",
"(",
")",
"for",
"hsp",
"in",
"self",
".",
"hsps",
"]",
",",
"'read'",
":",
"self",
".",
"read",
".",
"toDict",
"(",
")",
",",
"}"
] | Get information about a title alignment as a dictionary.
@return: A C{dict} representation of the title aligment. | [
"Get",
"information",
"about",
"a",
"title",
"alignment",
"as",
"a",
"dictionary",
"."
] | c78a1bf262667fa5db3548fa7066c4ec14d0551d | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/titles.py#L38-L47 |
55,772 | acorg/dark-matter | dark/titles.py | TitleAlignments.hasScoreBetterThan | def hasScoreBetterThan(self, score):
"""
Is there an HSP with a score better than a given value?
@return: A C{bool}, C{True} if there is at least one HSP in the
alignments for this title with a score better than C{score}.
"""
# Note: Do not assume that HSPs in an alignme... | python | def hasScoreBetterThan(self, score):
"""
Is there an HSP with a score better than a given value?
@return: A C{bool}, C{True} if there is at least one HSP in the
alignments for this title with a score better than C{score}.
"""
# Note: Do not assume that HSPs in an alignme... | [
"def",
"hasScoreBetterThan",
"(",
"self",
",",
"score",
")",
":",
"# Note: Do not assume that HSPs in an alignment are sorted in",
"# decreasing order (as they are in BLAST output). If we could",
"# assume that, we could just check the first HSP in each alignment.",
"for",
"hsp",
"in",
"... | Is there an HSP with a score better than a given value?
@return: A C{bool}, C{True} if there is at least one HSP in the
alignments for this title with a score better than C{score}. | [
"Is",
"there",
"an",
"HSP",
"with",
"a",
"score",
"better",
"than",
"a",
"given",
"value?"
] | c78a1bf262667fa5db3548fa7066c4ec14d0551d | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/titles.py#L133-L146 |
55,773 | acorg/dark-matter | dark/titles.py | TitleAlignments.coverage | def coverage(self):
"""
Get the fraction of this title sequence that is matched by its reads.
@return: The C{float} fraction of the title sequence matched by its
reads.
"""
intervals = ReadIntervals(self.subjectLength)
for hsp in self.hsps():
inte... | python | def coverage(self):
"""
Get the fraction of this title sequence that is matched by its reads.
@return: The C{float} fraction of the title sequence matched by its
reads.
"""
intervals = ReadIntervals(self.subjectLength)
for hsp in self.hsps():
inte... | [
"def",
"coverage",
"(",
"self",
")",
":",
"intervals",
"=",
"ReadIntervals",
"(",
"self",
".",
"subjectLength",
")",
"for",
"hsp",
"in",
"self",
".",
"hsps",
"(",
")",
":",
"intervals",
".",
"add",
"(",
"hsp",
".",
"subjectStart",
",",
"hsp",
".",
"s... | Get the fraction of this title sequence that is matched by its reads.
@return: The C{float} fraction of the title sequence matched by its
reads. | [
"Get",
"the",
"fraction",
"of",
"this",
"title",
"sequence",
"that",
"is",
"matched",
"by",
"its",
"reads",
"."
] | c78a1bf262667fa5db3548fa7066c4ec14d0551d | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/titles.py#L159-L169 |
55,774 | acorg/dark-matter | dark/titles.py | TitleAlignments.coverageInfo | def coverageInfo(self):
"""
Return information about the bases found at each location in our title
sequence.
@return: A C{dict} whose keys are C{int} subject offsets and whose
values are unsorted lists of (score, base) 2-tuples, giving all the
bases from reads th... | python | def coverageInfo(self):
"""
Return information about the bases found at each location in our title
sequence.
@return: A C{dict} whose keys are C{int} subject offsets and whose
values are unsorted lists of (score, base) 2-tuples, giving all the
bases from reads th... | [
"def",
"coverageInfo",
"(",
"self",
")",
":",
"result",
"=",
"defaultdict",
"(",
"list",
")",
"for",
"titleAlignment",
"in",
"self",
":",
"for",
"hsp",
"in",
"titleAlignment",
".",
"hsps",
":",
"score",
"=",
"hsp",
".",
"score",
".",
"score",
"for",
"(... | Return information about the bases found at each location in our title
sequence.
@return: A C{dict} whose keys are C{int} subject offsets and whose
values are unsorted lists of (score, base) 2-tuples, giving all the
bases from reads that matched the subject at subject location,
... | [
"Return",
"information",
"about",
"the",
"bases",
"found",
"at",
"each",
"location",
"in",
"our",
"title",
"sequence",
"."
] | c78a1bf262667fa5db3548fa7066c4ec14d0551d | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/titles.py#L181-L200 |
55,775 | acorg/dark-matter | dark/titles.py | TitleAlignments.residueCounts | def residueCounts(self, convertCaseTo='upper'):
"""
Count residue frequencies at all sequence locations matched by reads.
@param convertCaseTo: A C{str}, 'upper', 'lower', or 'none'.
If 'none', case will not be converted (both the upper and lower
case string of a residue... | python | def residueCounts(self, convertCaseTo='upper'):
"""
Count residue frequencies at all sequence locations matched by reads.
@param convertCaseTo: A C{str}, 'upper', 'lower', or 'none'.
If 'none', case will not be converted (both the upper and lower
case string of a residue... | [
"def",
"residueCounts",
"(",
"self",
",",
"convertCaseTo",
"=",
"'upper'",
")",
":",
"if",
"convertCaseTo",
"==",
"'none'",
":",
"def",
"convert",
"(",
"x",
")",
":",
"return",
"x",
"elif",
"convertCaseTo",
"==",
"'lower'",
":",
"convert",
"=",
"str",
".... | Count residue frequencies at all sequence locations matched by reads.
@param convertCaseTo: A C{str}, 'upper', 'lower', or 'none'.
If 'none', case will not be converted (both the upper and lower
case string of a residue will be present in the result if they are
present in th... | [
"Count",
"residue",
"frequencies",
"at",
"all",
"sequence",
"locations",
"matched",
"by",
"reads",
"."
] | c78a1bf262667fa5db3548fa7066c4ec14d0551d | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/titles.py#L202-L233 |
55,776 | acorg/dark-matter | dark/titles.py | TitleAlignments.summary | def summary(self):
"""
Summarize the alignments for this subject.
@return: A C{dict} with C{str} keys:
bestScore: The C{float} best score of the matching reads.
coverage: The C{float} fraction of the subject genome that is
matched by at least one read.
... | python | def summary(self):
"""
Summarize the alignments for this subject.
@return: A C{dict} with C{str} keys:
bestScore: The C{float} best score of the matching reads.
coverage: The C{float} fraction of the subject genome that is
matched by at least one read.
... | [
"def",
"summary",
"(",
"self",
")",
":",
"return",
"{",
"'bestScore'",
":",
"self",
".",
"bestHsp",
"(",
")",
".",
"score",
".",
"score",
",",
"'coverage'",
":",
"self",
".",
"coverage",
"(",
")",
",",
"'hspCount'",
":",
"self",
".",
"hspCount",
"(",... | Summarize the alignments for this subject.
@return: A C{dict} with C{str} keys:
bestScore: The C{float} best score of the matching reads.
coverage: The C{float} fraction of the subject genome that is
matched by at least one read.
hspCount: The C{int} number o... | [
"Summarize",
"the",
"alignments",
"for",
"this",
"subject",
"."
] | c78a1bf262667fa5db3548fa7066c4ec14d0551d | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/titles.py#L235-L257 |
55,777 | acorg/dark-matter | dark/titles.py | TitleAlignments.toDict | def toDict(self):
"""
Get information about the title's alignments as a dictionary.
@return: A C{dict} representation of the title's aligments.
"""
return {
'titleAlignments': [titleAlignment.toDict()
for titleAlignment in self],
... | python | def toDict(self):
"""
Get information about the title's alignments as a dictionary.
@return: A C{dict} representation of the title's aligments.
"""
return {
'titleAlignments': [titleAlignment.toDict()
for titleAlignment in self],
... | [
"def",
"toDict",
"(",
"self",
")",
":",
"return",
"{",
"'titleAlignments'",
":",
"[",
"titleAlignment",
".",
"toDict",
"(",
")",
"for",
"titleAlignment",
"in",
"self",
"]",
",",
"'subjectTitle'",
":",
"self",
".",
"subjectTitle",
",",
"'subjectLength'",
":",... | Get information about the title's alignments as a dictionary.
@return: A C{dict} representation of the title's aligments. | [
"Get",
"information",
"about",
"the",
"title",
"s",
"alignments",
"as",
"a",
"dictionary",
"."
] | c78a1bf262667fa5db3548fa7066c4ec14d0551d | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/titles.py#L259-L270 |
55,778 | acorg/dark-matter | dark/titles.py | TitlesAlignments.addTitle | def addTitle(self, title, titleAlignments):
"""
Add a new title to self.
@param title: A C{str} title.
@param titleAlignments: An instance of L{TitleAlignments}.
@raises KeyError: If the title is already present.
"""
if title in self:
raise KeyError('... | python | def addTitle(self, title, titleAlignments):
"""
Add a new title to self.
@param title: A C{str} title.
@param titleAlignments: An instance of L{TitleAlignments}.
@raises KeyError: If the title is already present.
"""
if title in self:
raise KeyError('... | [
"def",
"addTitle",
"(",
"self",
",",
"title",
",",
"titleAlignments",
")",
":",
"if",
"title",
"in",
"self",
":",
"raise",
"KeyError",
"(",
"'Title %r already present in TitlesAlignments '",
"'instance.'",
"%",
"title",
")",
"else",
":",
"self",
"[",
"title",
... | Add a new title to self.
@param title: A C{str} title.
@param titleAlignments: An instance of L{TitleAlignments}.
@raises KeyError: If the title is already present. | [
"Add",
"a",
"new",
"title",
"to",
"self",
"."
] | c78a1bf262667fa5db3548fa7066c4ec14d0551d | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/titles.py#L307-L319 |
55,779 | acorg/dark-matter | dark/titles.py | TitlesAlignments.filter | def filter(self, minMatchingReads=None, minMedianScore=None,
withScoreBetterThan=None, minNewReads=None, minCoverage=None,
maxTitles=None, sortOn='maxScore'):
"""
Filter the titles in self to create another TitlesAlignments.
@param minMatchingReads: titles that are... | python | def filter(self, minMatchingReads=None, minMedianScore=None,
withScoreBetterThan=None, minNewReads=None, minCoverage=None,
maxTitles=None, sortOn='maxScore'):
"""
Filter the titles in self to create another TitlesAlignments.
@param minMatchingReads: titles that are... | [
"def",
"filter",
"(",
"self",
",",
"minMatchingReads",
"=",
"None",
",",
"minMedianScore",
"=",
"None",
",",
"withScoreBetterThan",
"=",
"None",
",",
"minNewReads",
"=",
"None",
",",
"minCoverage",
"=",
"None",
",",
"maxTitles",
"=",
"None",
",",
"sortOn",
... | Filter the titles in self to create another TitlesAlignments.
@param minMatchingReads: titles that are matched by fewer reads
are unacceptable.
@param minMedianScore: sequences that are matched with a median
bit score that is less are unacceptable.
@param withScoreBetter... | [
"Filter",
"the",
"titles",
"in",
"self",
"to",
"create",
"another",
"TitlesAlignments",
"."
] | c78a1bf262667fa5db3548fa7066c4ec14d0551d | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/titles.py#L321-L413 |
55,780 | acorg/dark-matter | dark/titles.py | TitlesAlignments.hsps | def hsps(self):
"""
Get all HSPs for all the alignments for all titles.
@return: A generator yielding L{dark.hsp.HSP} instances.
"""
return (hsp for titleAlignments in self.values()
for alignment in titleAlignments for hsp in alignment.hsps) | python | def hsps(self):
"""
Get all HSPs for all the alignments for all titles.
@return: A generator yielding L{dark.hsp.HSP} instances.
"""
return (hsp for titleAlignments in self.values()
for alignment in titleAlignments for hsp in alignment.hsps) | [
"def",
"hsps",
"(",
"self",
")",
":",
"return",
"(",
"hsp",
"for",
"titleAlignments",
"in",
"self",
".",
"values",
"(",
")",
"for",
"alignment",
"in",
"titleAlignments",
"for",
"hsp",
"in",
"alignment",
".",
"hsps",
")"
] | Get all HSPs for all the alignments for all titles.
@return: A generator yielding L{dark.hsp.HSP} instances. | [
"Get",
"all",
"HSPs",
"for",
"all",
"the",
"alignments",
"for",
"all",
"titles",
"."
] | c78a1bf262667fa5db3548fa7066c4ec14d0551d | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/titles.py#L415-L422 |
55,781 | acorg/dark-matter | dark/titles.py | TitlesAlignments.sortTitles | def sortTitles(self, by):
"""
Sort titles by a given attribute and then by title.
@param by: A C{str}, one of 'length', 'maxScore', 'medianScore',
'readCount', or 'title'.
@raise ValueError: If an unknown C{by} value is given.
@return: A sorted C{list} of titles.
... | python | def sortTitles(self, by):
"""
Sort titles by a given attribute and then by title.
@param by: A C{str}, one of 'length', 'maxScore', 'medianScore',
'readCount', or 'title'.
@raise ValueError: If an unknown C{by} value is given.
@return: A sorted C{list} of titles.
... | [
"def",
"sortTitles",
"(",
"self",
",",
"by",
")",
":",
"# First sort titles by the secondary key, which is always the title.",
"titles",
"=",
"sorted",
"(",
"iter",
"(",
"self",
")",
")",
"# Then sort on the primary key (if any).",
"if",
"by",
"==",
"'length'",
":",
"... | Sort titles by a given attribute and then by title.
@param by: A C{str}, one of 'length', 'maxScore', 'medianScore',
'readCount', or 'title'.
@raise ValueError: If an unknown C{by} value is given.
@return: A sorted C{list} of titles. | [
"Sort",
"titles",
"by",
"a",
"given",
"attribute",
"and",
"then",
"by",
"title",
"."
] | c78a1bf262667fa5db3548fa7066c4ec14d0551d | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/titles.py#L424-L456 |
55,782 | acorg/dark-matter | dark/titles.py | TitlesAlignments.summary | def summary(self, sortOn=None):
"""
Summarize all the alignments for this title.
@param sortOn: A C{str} attribute to sort titles on. One of 'length',
'maxScore', 'medianScore', 'readCount', or 'title'.
@raise ValueError: If an unknown C{sortOn} value is given.
@retu... | python | def summary(self, sortOn=None):
"""
Summarize all the alignments for this title.
@param sortOn: A C{str} attribute to sort titles on. One of 'length',
'maxScore', 'medianScore', 'readCount', or 'title'.
@raise ValueError: If an unknown C{sortOn} value is given.
@retu... | [
"def",
"summary",
"(",
"self",
",",
"sortOn",
"=",
"None",
")",
":",
"titles",
"=",
"self",
"if",
"sortOn",
"is",
"None",
"else",
"self",
".",
"sortTitles",
"(",
"sortOn",
")",
"for",
"title",
"in",
"titles",
":",
"yield",
"self",
"[",
"title",
"]",
... | Summarize all the alignments for this title.
@param sortOn: A C{str} attribute to sort titles on. One of 'length',
'maxScore', 'medianScore', 'readCount', or 'title'.
@raise ValueError: If an unknown C{sortOn} value is given.
@return: A generator that yields C{dict} instances as pro... | [
"Summarize",
"all",
"the",
"alignments",
"for",
"this",
"title",
"."
] | c78a1bf262667fa5db3548fa7066c4ec14d0551d | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/titles.py#L458-L472 |
55,783 | acorg/dark-matter | dark/titles.py | TitlesAlignments.tabSeparatedSummary | def tabSeparatedSummary(self, sortOn=None):
"""
Summarize all the alignments for this title as multi-line string with
TAB-separated values on each line.
@param sortOn: A C{str} attribute to sort titles on. One of 'length',
'maxScore', 'medianScore', 'readCount', or 'title'.
... | python | def tabSeparatedSummary(self, sortOn=None):
"""
Summarize all the alignments for this title as multi-line string with
TAB-separated values on each line.
@param sortOn: A C{str} attribute to sort titles on. One of 'length',
'maxScore', 'medianScore', 'readCount', or 'title'.
... | [
"def",
"tabSeparatedSummary",
"(",
"self",
",",
"sortOn",
"=",
"None",
")",
":",
"# The order of the fields returned here is somewhat arbitrary. The",
"# subject titles are last because they are so variable in length.",
"# Putting them last makes it more likely that the initial columns in",
... | Summarize all the alignments for this title as multi-line string with
TAB-separated values on each line.
@param sortOn: A C{str} attribute to sort titles on. One of 'length',
'maxScore', 'medianScore', 'readCount', or 'title'.
@raise ValueError: If an unknown C{sortOn} value is give... | [
"Summarize",
"all",
"the",
"alignments",
"for",
"this",
"title",
"as",
"multi",
"-",
"line",
"string",
"with",
"TAB",
"-",
"separated",
"values",
"on",
"each",
"line",
"."
] | c78a1bf262667fa5db3548fa7066c4ec14d0551d | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/titles.py#L474-L508 |
55,784 | acorg/dark-matter | dark/titles.py | TitlesAlignments.toDict | def toDict(self):
"""
Get information about the titles alignments as a dictionary.
@return: A C{dict} representation of the titles aligments.
"""
return {
'scoreClass': self.scoreClass.__name__,
'titles': dict((title, titleAlignments.toDict())
... | python | def toDict(self):
"""
Get information about the titles alignments as a dictionary.
@return: A C{dict} representation of the titles aligments.
"""
return {
'scoreClass': self.scoreClass.__name__,
'titles': dict((title, titleAlignments.toDict())
... | [
"def",
"toDict",
"(",
"self",
")",
":",
"return",
"{",
"'scoreClass'",
":",
"self",
".",
"scoreClass",
".",
"__name__",
",",
"'titles'",
":",
"dict",
"(",
"(",
"title",
",",
"titleAlignments",
".",
"toDict",
"(",
")",
")",
"for",
"title",
",",
"titleAl... | Get information about the titles alignments as a dictionary.
@return: A C{dict} representation of the titles aligments. | [
"Get",
"information",
"about",
"the",
"titles",
"alignments",
"as",
"a",
"dictionary",
"."
] | c78a1bf262667fa5db3548fa7066c4ec14d0551d | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/titles.py#L510-L520 |
55,785 | acorg/dark-matter | dark/filter.py | addFASTAFilteringCommandLineOptions | def addFASTAFilteringCommandLineOptions(parser):
"""
Add standard FASTA filtering command-line options to an argparse parser.
These are options that can be used to select or omit entire FASTA records,
NOT options that change them (for that see
addFASTAEditingCommandLineOptions).
@param parser:... | python | def addFASTAFilteringCommandLineOptions(parser):
"""
Add standard FASTA filtering command-line options to an argparse parser.
These are options that can be used to select or omit entire FASTA records,
NOT options that change them (for that see
addFASTAEditingCommandLineOptions).
@param parser:... | [
"def",
"addFASTAFilteringCommandLineOptions",
"(",
"parser",
")",
":",
"parser",
".",
"add_argument",
"(",
"'--minLength'",
",",
"type",
"=",
"int",
",",
"help",
"=",
"'The minimum sequence length'",
")",
"parser",
".",
"add_argument",
"(",
"'--maxLength'",
",",
"... | Add standard FASTA filtering command-line options to an argparse parser.
These are options that can be used to select or omit entire FASTA records,
NOT options that change them (for that see
addFASTAEditingCommandLineOptions).
@param parser: An C{argparse.ArgumentParser} instance. | [
"Add",
"standard",
"FASTA",
"filtering",
"command",
"-",
"line",
"options",
"to",
"an",
"argparse",
"parser",
"."
] | c78a1bf262667fa5db3548fa7066c4ec14d0551d | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/filter.py#L172-L268 |
55,786 | acorg/dark-matter | dark/filter.py | parseFASTAFilteringCommandLineOptions | def parseFASTAFilteringCommandLineOptions(args, reads):
"""
Examine parsed FASTA filtering command-line options and return filtered
reads.
@param args: An argparse namespace, as returned by the argparse
C{parse_args} function.
@param reads: A C{Reads} instance to filter.
@return: The fi... | python | def parseFASTAFilteringCommandLineOptions(args, reads):
"""
Examine parsed FASTA filtering command-line options and return filtered
reads.
@param args: An argparse namespace, as returned by the argparse
C{parse_args} function.
@param reads: A C{Reads} instance to filter.
@return: The fi... | [
"def",
"parseFASTAFilteringCommandLineOptions",
"(",
"args",
",",
"reads",
")",
":",
"keepSequences",
"=",
"(",
"parseRangeString",
"(",
"args",
".",
"keepSequences",
",",
"convertToZeroBased",
"=",
"True",
")",
"if",
"args",
".",
"keepSequences",
"else",
"None",
... | Examine parsed FASTA filtering command-line options and return filtered
reads.
@param args: An argparse namespace, as returned by the argparse
C{parse_args} function.
@param reads: A C{Reads} instance to filter.
@return: The filtered C{Reads} instance. | [
"Examine",
"parsed",
"FASTA",
"filtering",
"command",
"-",
"line",
"options",
"and",
"return",
"filtered",
"reads",
"."
] | c78a1bf262667fa5db3548fa7066c4ec14d0551d | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/filter.py#L271-L301 |
55,787 | acorg/dark-matter | dark/filter.py | addFASTAEditingCommandLineOptions | def addFASTAEditingCommandLineOptions(parser):
"""
Add standard FASTA editing command-line options to an argparse parser.
These are options that can be used to alter FASTA records, NOT options
that simply select or reject those things (for those see
addFASTAFilteringCommandLineOptions).
@param... | python | def addFASTAEditingCommandLineOptions(parser):
"""
Add standard FASTA editing command-line options to an argparse parser.
These are options that can be used to alter FASTA records, NOT options
that simply select or reject those things (for those see
addFASTAFilteringCommandLineOptions).
@param... | [
"def",
"addFASTAEditingCommandLineOptions",
"(",
"parser",
")",
":",
"# A mutually exclusive group for --keepSites, --keepSitesFile,",
"# --removeSites, and --removeSitesFile.",
"group",
"=",
"parser",
".",
"add_mutually_exclusive_group",
"(",
")",
"# In the 4 options below, the 'indic... | Add standard FASTA editing command-line options to an argparse parser.
These are options that can be used to alter FASTA records, NOT options
that simply select or reject those things (for those see
addFASTAFilteringCommandLineOptions).
@param parser: An C{argparse.ArgumentParser} instance. | [
"Add",
"standard",
"FASTA",
"editing",
"command",
"-",
"line",
"options",
"to",
"an",
"argparse",
"parser",
"."
] | c78a1bf262667fa5db3548fa7066c4ec14d0551d | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/filter.py#L304-L389 |
55,788 | acorg/dark-matter | dark/filter.py | parseFASTAEditingCommandLineOptions | def parseFASTAEditingCommandLineOptions(args, reads):
"""
Examine parsed FASTA editing command-line options and return information
about kept sites and sequences.
@param args: An argparse namespace, as returned by the argparse
C{parse_args} function.
@param reads: A C{Reads} instance to fil... | python | def parseFASTAEditingCommandLineOptions(args, reads):
"""
Examine parsed FASTA editing command-line options and return information
about kept sites and sequences.
@param args: An argparse namespace, as returned by the argparse
C{parse_args} function.
@param reads: A C{Reads} instance to fil... | [
"def",
"parseFASTAEditingCommandLineOptions",
"(",
"args",
",",
"reads",
")",
":",
"removeGaps",
"=",
"args",
".",
"removeGaps",
"removeDescriptions",
"=",
"args",
".",
"removeDescriptions",
"truncateTitlesAfter",
"=",
"args",
".",
"truncateTitlesAfter",
"keepSites",
... | Examine parsed FASTA editing command-line options and return information
about kept sites and sequences.
@param args: An argparse namespace, as returned by the argparse
C{parse_args} function.
@param reads: A C{Reads} instance to filter.
@return: The filtered C{Reads} instance. | [
"Examine",
"parsed",
"FASTA",
"editing",
"command",
"-",
"line",
"options",
"and",
"return",
"information",
"about",
"kept",
"sites",
"and",
"sequences",
"."
] | c78a1bf262667fa5db3548fa7066c4ec14d0551d | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/filter.py#L392-L443 |
55,789 | acorg/dark-matter | dark/blast/conversion.py | XMLRecordsReader.records | def records(self):
"""
Yield BLAST records, as read by the BioPython NCBIXML.parse
method. Set self.params from data in the first record.
"""
first = True
with as_handle(self._filename) as fp:
for record in NCBIXML.parse(fp):
if first:
... | python | def records(self):
"""
Yield BLAST records, as read by the BioPython NCBIXML.parse
method. Set self.params from data in the first record.
"""
first = True
with as_handle(self._filename) as fp:
for record in NCBIXML.parse(fp):
if first:
... | [
"def",
"records",
"(",
"self",
")",
":",
"first",
"=",
"True",
"with",
"as_handle",
"(",
"self",
".",
"_filename",
")",
"as",
"fp",
":",
"for",
"record",
"in",
"NCBIXML",
".",
"parse",
"(",
"fp",
")",
":",
"if",
"first",
":",
"self",
".",
"params",... | Yield BLAST records, as read by the BioPython NCBIXML.parse
method. Set self.params from data in the first record. | [
"Yield",
"BLAST",
"records",
"as",
"read",
"by",
"the",
"BioPython",
"NCBIXML",
".",
"parse",
"method",
".",
"Set",
"self",
".",
"params",
"from",
"data",
"in",
"the",
"first",
"record",
"."
] | c78a1bf262667fa5db3548fa7066c4ec14d0551d | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/blast/conversion.py#L142-L153 |
55,790 | acorg/dark-matter | dark/blast/conversion.py | XMLRecordsReader.saveAsJSON | def saveAsJSON(self, fp):
"""
Write the records out as JSON. The first JSON object saved contains
the BLAST parameters.
@param fp: A C{str} file pointer to write to.
"""
first = True
for record in self.records():
if first:
print(dumps(... | python | def saveAsJSON(self, fp):
"""
Write the records out as JSON. The first JSON object saved contains
the BLAST parameters.
@param fp: A C{str} file pointer to write to.
"""
first = True
for record in self.records():
if first:
print(dumps(... | [
"def",
"saveAsJSON",
"(",
"self",
",",
"fp",
")",
":",
"first",
"=",
"True",
"for",
"record",
"in",
"self",
".",
"records",
"(",
")",
":",
"if",
"first",
":",
"print",
"(",
"dumps",
"(",
"self",
".",
"params",
",",
"separators",
"=",
"(",
"','",
... | Write the records out as JSON. The first JSON object saved contains
the BLAST parameters.
@param fp: A C{str} file pointer to write to. | [
"Write",
"the",
"records",
"out",
"as",
"JSON",
".",
"The",
"first",
"JSON",
"object",
"saved",
"contains",
"the",
"BLAST",
"parameters",
"."
] | c78a1bf262667fa5db3548fa7066c4ec14d0551d | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/blast/conversion.py#L155-L168 |
55,791 | acorg/dark-matter | dark/blast/conversion.py | JSONRecordsReader._open | def _open(self, filename):
"""
Open the input file. Set self._fp to point to it. Read the first
line of parameters.
@param filename: A C{str} filename containing JSON BLAST records.
@raise ValueError: if the first line of the file isn't valid JSON,
if the input file ... | python | def _open(self, filename):
"""
Open the input file. Set self._fp to point to it. Read the first
line of parameters.
@param filename: A C{str} filename containing JSON BLAST records.
@raise ValueError: if the first line of the file isn't valid JSON,
if the input file ... | [
"def",
"_open",
"(",
"self",
",",
"filename",
")",
":",
"if",
"filename",
".",
"endswith",
"(",
"'.bz2'",
")",
":",
"if",
"six",
".",
"PY3",
":",
"self",
".",
"_fp",
"=",
"bz2",
".",
"open",
"(",
"filename",
",",
"mode",
"=",
"'rt'",
",",
"encodi... | Open the input file. Set self._fp to point to it. Read the first
line of parameters.
@param filename: A C{str} filename containing JSON BLAST records.
@raise ValueError: if the first line of the file isn't valid JSON,
if the input file is empty, or if the JSON does not contain an
... | [
"Open",
"the",
"input",
"file",
".",
"Set",
"self",
".",
"_fp",
"to",
"point",
"to",
"it",
".",
"Read",
"the",
"first",
"line",
"of",
"parameters",
"."
] | c78a1bf262667fa5db3548fa7066c4ec14d0551d | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/blast/conversion.py#L196-L229 |
55,792 | acorg/dark-matter | dark/blast/conversion.py | JSONRecordsReader.readAlignments | def readAlignments(self, reads):
"""
Read lines of JSON from self._filename, convert them to read alignments
and yield them.
@param reads: An iterable of L{Read} instances, corresponding to the
reads that were given to BLAST.
@raise ValueError: If any of the lines in... | python | def readAlignments(self, reads):
"""
Read lines of JSON from self._filename, convert them to read alignments
and yield them.
@param reads: An iterable of L{Read} instances, corresponding to the
reads that were given to BLAST.
@raise ValueError: If any of the lines in... | [
"def",
"readAlignments",
"(",
"self",
",",
"reads",
")",
":",
"if",
"self",
".",
"_fp",
"is",
"None",
":",
"self",
".",
"_open",
"(",
"self",
".",
"_filename",
")",
"reads",
"=",
"iter",
"(",
"reads",
")",
"try",
":",
"for",
"lineNumber",
",",
"lin... | Read lines of JSON from self._filename, convert them to read alignments
and yield them.
@param reads: An iterable of L{Read} instances, corresponding to the
reads that were given to BLAST.
@raise ValueError: If any of the lines in the file cannot be converted
to JSON.
... | [
"Read",
"lines",
"of",
"JSON",
"from",
"self",
".",
"_filename",
"convert",
"them",
"to",
"read",
"alignments",
"and",
"yield",
"them",
"."
] | c78a1bf262667fa5db3548fa7066c4ec14d0551d | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/blast/conversion.py#L287-L326 |
55,793 | acorg/dark-matter | dark/reads.py | _makeComplementTable | def _makeComplementTable(complementData):
"""
Make a sequence complement table.
@param complementData: A C{dict} whose keys and values are strings of
length one. A key, value pair indicates a substitution that should
be performed during complementation.
@return: A 256 character string t... | python | def _makeComplementTable(complementData):
"""
Make a sequence complement table.
@param complementData: A C{dict} whose keys and values are strings of
length one. A key, value pair indicates a substitution that should
be performed during complementation.
@return: A 256 character string t... | [
"def",
"_makeComplementTable",
"(",
"complementData",
")",
":",
"table",
"=",
"list",
"(",
"range",
"(",
"256",
")",
")",
"for",
"_from",
",",
"to",
"in",
"complementData",
".",
"items",
"(",
")",
":",
"table",
"[",
"ord",
"(",
"_from",
"[",
"0",
"]"... | Make a sequence complement table.
@param complementData: A C{dict} whose keys and values are strings of
length one. A key, value pair indicates a substitution that should
be performed during complementation.
@return: A 256 character string that can be used as a translation table
by the ... | [
"Make",
"a",
"sequence",
"complement",
"table",
"."
] | c78a1bf262667fa5db3548fa7066c4ec14d0551d | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/reads.py#L18-L32 |
55,794 | acorg/dark-matter | dark/reads.py | addFASTACommandLineOptions | def addFASTACommandLineOptions(parser):
"""
Add standard command-line options to an argparse parser.
@param parser: An C{argparse.ArgumentParser} instance.
"""
parser.add_argument(
'--fastaFile', type=open, default=sys.stdin, metavar='FILENAME',
help=('The name of the FASTA input f... | python | def addFASTACommandLineOptions(parser):
"""
Add standard command-line options to an argparse parser.
@param parser: An C{argparse.ArgumentParser} instance.
"""
parser.add_argument(
'--fastaFile', type=open, default=sys.stdin, metavar='FILENAME',
help=('The name of the FASTA input f... | [
"def",
"addFASTACommandLineOptions",
"(",
"parser",
")",
":",
"parser",
".",
"add_argument",
"(",
"'--fastaFile'",
",",
"type",
"=",
"open",
",",
"default",
"=",
"sys",
".",
"stdin",
",",
"metavar",
"=",
"'FILENAME'",
",",
"help",
"=",
"(",
"'The name of the... | Add standard command-line options to an argparse parser.
@param parser: An C{argparse.ArgumentParser} instance. | [
"Add",
"standard",
"command",
"-",
"line",
"options",
"to",
"an",
"argparse",
"parser",
"."
] | c78a1bf262667fa5db3548fa7066c4ec14d0551d | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/reads.py#L1476-L1510 |
55,795 | acorg/dark-matter | dark/reads.py | parseFASTACommandLineOptions | def parseFASTACommandLineOptions(args):
"""
Examine parsed command-line options and return a Reads instance.
@param args: An argparse namespace, as returned by the argparse
C{parse_args} function.
@return: A C{Reads} subclass instance, depending on the type of FASTA file
given.
"""
... | python | def parseFASTACommandLineOptions(args):
"""
Examine parsed command-line options and return a Reads instance.
@param args: An argparse namespace, as returned by the argparse
C{parse_args} function.
@return: A C{Reads} subclass instance, depending on the type of FASTA file
given.
"""
... | [
"def",
"parseFASTACommandLineOptions",
"(",
"args",
")",
":",
"# Set default FASTA type.",
"if",
"not",
"(",
"args",
".",
"fasta",
"or",
"args",
".",
"fastq",
"or",
"args",
".",
"fasta_ss",
")",
":",
"args",
".",
"fasta",
"=",
"True",
"readClass",
"=",
"re... | Examine parsed command-line options and return a Reads instance.
@param args: An argparse namespace, as returned by the argparse
C{parse_args} function.
@return: A C{Reads} subclass instance, depending on the type of FASTA file
given. | [
"Examine",
"parsed",
"command",
"-",
"line",
"options",
"and",
"return",
"a",
"Reads",
"instance",
"."
] | c78a1bf262667fa5db3548fa7066c4ec14d0551d | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/reads.py#L1513-L1536 |
55,796 | acorg/dark-matter | dark/reads.py | _NucleotideRead.translations | def translations(self):
"""
Yield all six translations of a nucleotide sequence.
@return: A generator that produces six L{TranslatedRead} instances.
"""
rc = self.reverseComplement().sequence
for reverseComplemented in False, True:
for frame in 0, 1, 2:
... | python | def translations(self):
"""
Yield all six translations of a nucleotide sequence.
@return: A generator that produces six L{TranslatedRead} instances.
"""
rc = self.reverseComplement().sequence
for reverseComplemented in False, True:
for frame in 0, 1, 2:
... | [
"def",
"translations",
"(",
"self",
")",
":",
"rc",
"=",
"self",
".",
"reverseComplement",
"(",
")",
".",
"sequence",
"for",
"reverseComplemented",
"in",
"False",
",",
"True",
":",
"for",
"frame",
"in",
"0",
",",
"1",
",",
"2",
":",
"seq",
"=",
"rc",... | Yield all six translations of a nucleotide sequence.
@return: A generator that produces six L{TranslatedRead} instances. | [
"Yield",
"all",
"six",
"translations",
"of",
"a",
"nucleotide",
"sequence",
"."
] | c78a1bf262667fa5db3548fa7066c4ec14d0551d | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/reads.py#L275-L295 |
55,797 | acorg/dark-matter | dark/reads.py | _NucleotideRead.reverseComplement | def reverseComplement(self):
"""
Reverse complement a nucleotide sequence.
@return: The reverse complemented sequence as an instance of the
current class.
"""
quality = None if self.quality is None else self.quality[::-1]
sequence = self.sequence.translate(se... | python | def reverseComplement(self):
"""
Reverse complement a nucleotide sequence.
@return: The reverse complemented sequence as an instance of the
current class.
"""
quality = None if self.quality is None else self.quality[::-1]
sequence = self.sequence.translate(se... | [
"def",
"reverseComplement",
"(",
"self",
")",
":",
"quality",
"=",
"None",
"if",
"self",
".",
"quality",
"is",
"None",
"else",
"self",
".",
"quality",
"[",
":",
":",
"-",
"1",
"]",
"sequence",
"=",
"self",
".",
"sequence",
".",
"translate",
"(",
"sel... | Reverse complement a nucleotide sequence.
@return: The reverse complemented sequence as an instance of the
current class. | [
"Reverse",
"complement",
"a",
"nucleotide",
"sequence",
"."
] | c78a1bf262667fa5db3548fa7066c4ec14d0551d | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/reads.py#L297-L306 |
55,798 | acorg/dark-matter | dark/reads.py | AARead.checkAlphabet | def checkAlphabet(self, count=10):
"""
A function which checks if an AA read really contains amino acids. This
additional testing is needed, because the letters in the DNA alphabet
are also in the AA alphabet.
@param count: An C{int}, indicating how many bases or amino acids at
... | python | def checkAlphabet(self, count=10):
"""
A function which checks if an AA read really contains amino acids. This
additional testing is needed, because the letters in the DNA alphabet
are also in the AA alphabet.
@param count: An C{int}, indicating how many bases or amino acids at
... | [
"def",
"checkAlphabet",
"(",
"self",
",",
"count",
"=",
"10",
")",
":",
"if",
"six",
".",
"PY3",
":",
"readLetters",
"=",
"super",
"(",
")",
".",
"checkAlphabet",
"(",
"count",
")",
"else",
":",
"readLetters",
"=",
"Read",
".",
"checkAlphabet",
"(",
... | A function which checks if an AA read really contains amino acids. This
additional testing is needed, because the letters in the DNA alphabet
are also in the AA alphabet.
@param count: An C{int}, indicating how many bases or amino acids at
the start of the sequence should be conside... | [
"A",
"function",
"which",
"checks",
"if",
"an",
"AA",
"read",
"really",
"contains",
"amino",
"acids",
".",
"This",
"additional",
"testing",
"is",
"needed",
"because",
"the",
"letters",
"in",
"the",
"DNA",
"alphabet",
"are",
"also",
"in",
"the",
"AA",
"alph... | c78a1bf262667fa5db3548fa7066c4ec14d0551d | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/reads.py#L385-L406 |
55,799 | acorg/dark-matter | dark/reads.py | AARead.ORFs | def ORFs(self, openORFs=False):
"""
Find all ORFs in our sequence.
@param openORFs: If C{True} allow ORFs that do not have a start codon
and/or do not have a stop codon.
@return: A generator that yields AAReadORF instances that correspond
to the ORFs found in the... | python | def ORFs(self, openORFs=False):
"""
Find all ORFs in our sequence.
@param openORFs: If C{True} allow ORFs that do not have a start codon
and/or do not have a stop codon.
@return: A generator that yields AAReadORF instances that correspond
to the ORFs found in the... | [
"def",
"ORFs",
"(",
"self",
",",
"openORFs",
"=",
"False",
")",
":",
"# Return open ORFs to the left and right and closed ORFs within the",
"# sequence.",
"if",
"openORFs",
":",
"ORFStart",
"=",
"0",
"inOpenORF",
"=",
"True",
"# open on the left",
"inORF",
"=",
"False... | Find all ORFs in our sequence.
@param openORFs: If C{True} allow ORFs that do not have a start codon
and/or do not have a stop codon.
@return: A generator that yields AAReadORF instances that correspond
to the ORFs found in the AA sequence. | [
"Find",
"all",
"ORFs",
"in",
"our",
"sequence",
"."
] | c78a1bf262667fa5db3548fa7066c4ec14d0551d | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/reads.py#L427-L482 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.