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,400 | twisted/epsilon | epsilon/hotfixes/delayedcall_seconds.py | DelayedCall.reset | def reset(self, secondsFromNow):
"""Reschedule this call for a different time
@type secondsFromNow: C{float}
@param secondsFromNow: The number of seconds from the time of the
C{reset} call at which this call will be scheduled.
@raise AlreadyCancelled: Raised if this call has be... | python | def reset(self, secondsFromNow):
"""Reschedule this call for a different time
@type secondsFromNow: C{float}
@param secondsFromNow: The number of seconds from the time of the
C{reset} call at which this call will be scheduled.
@raise AlreadyCancelled: Raised if this call has be... | [
"def",
"reset",
"(",
"self",
",",
"secondsFromNow",
")",
":",
"if",
"self",
".",
"cancelled",
":",
"raise",
"error",
".",
"AlreadyCancelled",
"elif",
"self",
".",
"called",
":",
"raise",
"error",
".",
"AlreadyCalled",
"else",
":",
"if",
"self",
".",
"sec... | Reschedule this call for a different time
@type secondsFromNow: C{float}
@param secondsFromNow: The number of seconds from the time of the
C{reset} call at which this call will be scheduled.
@raise AlreadyCancelled: Raised if this call has been cancelled.
@raise AlreadyCalled: ... | [
"Reschedule",
"this",
"call",
"for",
"a",
"different",
"time"
] | e85fa985a41983ef06e1d3bb26639181e1f78b24 | https://github.com/twisted/epsilon/blob/e85fa985a41983ef06e1d3bb26639181e1f78b24/epsilon/hotfixes/delayedcall_seconds.py#L57-L81 |
55,401 | twisted/epsilon | epsilon/hotfixes/delayedcall_seconds.py | DelayedCall.delay | def delay(self, secondsLater):
"""Reschedule this call for a later time
@type secondsLater: C{float}
@param secondsLater: The number of seconds after the originally
scheduled time for which to reschedule this call.
@raise AlreadyCancelled: Raised if this call has been cancelled... | python | def delay(self, secondsLater):
"""Reschedule this call for a later time
@type secondsLater: C{float}
@param secondsLater: The number of seconds after the originally
scheduled time for which to reschedule this call.
@raise AlreadyCancelled: Raised if this call has been cancelled... | [
"def",
"delay",
"(",
"self",
",",
"secondsLater",
")",
":",
"if",
"self",
".",
"cancelled",
":",
"raise",
"error",
".",
"AlreadyCancelled",
"elif",
"self",
".",
"called",
":",
"raise",
"error",
".",
"AlreadyCalled",
"else",
":",
"self",
".",
"delayed_time"... | Reschedule this call for a later time
@type secondsLater: C{float}
@param secondsLater: The number of seconds after the originally
scheduled time for which to reschedule this call.
@raise AlreadyCancelled: Raised if this call has been cancelled.
@raise AlreadyCalled: Raised if ... | [
"Reschedule",
"this",
"call",
"for",
"a",
"later",
"time"
] | e85fa985a41983ef06e1d3bb26639181e1f78b24 | https://github.com/twisted/epsilon/blob/e85fa985a41983ef06e1d3bb26639181e1f78b24/epsilon/hotfixes/delayedcall_seconds.py#L83-L101 |
55,402 | twisted/epsilon | doc/listings/amp/auth_server.py | main | def main():
"""
Start the AMP server and the reactor.
"""
startLogging(stdout)
checker = InMemoryUsernamePasswordDatabaseDontUse()
checker.addUser("testuser", "examplepass")
realm = AdditionRealm()
factory = CredAMPServerFactory(Portal(realm, [checker]))
reactor.listenTCP(7805, facto... | python | def main():
"""
Start the AMP server and the reactor.
"""
startLogging(stdout)
checker = InMemoryUsernamePasswordDatabaseDontUse()
checker.addUser("testuser", "examplepass")
realm = AdditionRealm()
factory = CredAMPServerFactory(Portal(realm, [checker]))
reactor.listenTCP(7805, facto... | [
"def",
"main",
"(",
")",
":",
"startLogging",
"(",
"stdout",
")",
"checker",
"=",
"InMemoryUsernamePasswordDatabaseDontUse",
"(",
")",
"checker",
".",
"addUser",
"(",
"\"testuser\"",
",",
"\"examplepass\"",
")",
"realm",
"=",
"AdditionRealm",
"(",
")",
"factory"... | Start the AMP server and the reactor. | [
"Start",
"the",
"AMP",
"server",
"and",
"the",
"reactor",
"."
] | e85fa985a41983ef06e1d3bb26639181e1f78b24 | https://github.com/twisted/epsilon/blob/e85fa985a41983ef06e1d3bb26639181e1f78b24/doc/listings/amp/auth_server.py#L63-L73 |
55,403 | jedie/django-cms-tools | django_cms_tools/plugin_landing_page/views.py | LandingPageDetailView.set_meta | def set_meta(self, instance):
"""
Set django-meta stuff from LandingPageModel instance.
"""
self.use_title_tag = True
self.title = instance.title | python | def set_meta(self, instance):
"""
Set django-meta stuff from LandingPageModel instance.
"""
self.use_title_tag = True
self.title = instance.title | [
"def",
"set_meta",
"(",
"self",
",",
"instance",
")",
":",
"self",
".",
"use_title_tag",
"=",
"True",
"self",
".",
"title",
"=",
"instance",
".",
"title"
] | Set django-meta stuff from LandingPageModel instance. | [
"Set",
"django",
"-",
"meta",
"stuff",
"from",
"LandingPageModel",
"instance",
"."
] | 0a70dbbb6f770f5a73c8ecd174d5559a37262792 | https://github.com/jedie/django-cms-tools/blob/0a70dbbb6f770f5a73c8ecd174d5559a37262792/django_cms_tools/plugin_landing_page/views.py#L36-L41 |
55,404 | SmartTeleMax/iktomi | iktomi/forms/perms.py | FieldPerm.check | def check(self, field):
'''
Returns permissions determined by object itself
'''
if self.permissions is None:
return field.parent.permissions
return self.permissions | python | def check(self, field):
'''
Returns permissions determined by object itself
'''
if self.permissions is None:
return field.parent.permissions
return self.permissions | [
"def",
"check",
"(",
"self",
",",
"field",
")",
":",
"if",
"self",
".",
"permissions",
"is",
"None",
":",
"return",
"field",
".",
"parent",
".",
"permissions",
"return",
"self",
".",
"permissions"
] | Returns permissions determined by object itself | [
"Returns",
"permissions",
"determined",
"by",
"object",
"itself"
] | 80bc0f1408d63efe7f5844367d1f6efba44b35f2 | https://github.com/SmartTeleMax/iktomi/blob/80bc0f1408d63efe7f5844367d1f6efba44b35f2/iktomi/forms/perms.py#L77-L83 |
55,405 | PythonRails/rails | rails/views/__init__.py | View._load_view | def _load_view(self, template_engine_name, template_dir):
"""
Load view by name and return an instance.
"""
file_name = template_engine_name.lower()
class_name = "{}View".format(template_engine_name.title())
try:
view_module = import_module("rails.views.{}".fo... | python | def _load_view(self, template_engine_name, template_dir):
"""
Load view by name and return an instance.
"""
file_name = template_engine_name.lower()
class_name = "{}View".format(template_engine_name.title())
try:
view_module = import_module("rails.views.{}".fo... | [
"def",
"_load_view",
"(",
"self",
",",
"template_engine_name",
",",
"template_dir",
")",
":",
"file_name",
"=",
"template_engine_name",
".",
"lower",
"(",
")",
"class_name",
"=",
"\"{}View\"",
".",
"format",
"(",
"template_engine_name",
".",
"title",
"(",
")",
... | Load view by name and return an instance. | [
"Load",
"view",
"by",
"name",
"and",
"return",
"an",
"instance",
"."
] | 1e199b9da4da5b24fef39fc6212d71fc9fbb18a5 | https://github.com/PythonRails/rails/blob/1e199b9da4da5b24fef39fc6212d71fc9fbb18a5/rails/views/__init__.py#L18-L29 |
55,406 | SmartTeleMax/iktomi | iktomi/utils/system.py | terminate | def terminate(pid, sig, timeout):
'''Terminates process with PID `pid` and returns True if process finished
during `timeout`. Current user must have permission to access process
information.'''
os.kill(pid, sig)
start = time.time()
while True:
try:
# This is requireed if it's... | python | def terminate(pid, sig, timeout):
'''Terminates process with PID `pid` and returns True if process finished
during `timeout`. Current user must have permission to access process
information.'''
os.kill(pid, sig)
start = time.time()
while True:
try:
# This is requireed if it's... | [
"def",
"terminate",
"(",
"pid",
",",
"sig",
",",
"timeout",
")",
":",
"os",
".",
"kill",
"(",
"pid",
",",
"sig",
")",
"start",
"=",
"time",
".",
"time",
"(",
")",
"while",
"True",
":",
"try",
":",
"# This is requireed if it's our child to avoid zombie. Als... | Terminates process with PID `pid` and returns True if process finished
during `timeout`. Current user must have permission to access process
information. | [
"Terminates",
"process",
"with",
"PID",
"pid",
"and",
"returns",
"True",
"if",
"process",
"finished",
"during",
"timeout",
".",
"Current",
"user",
"must",
"have",
"permission",
"to",
"access",
"process",
"information",
"."
] | 80bc0f1408d63efe7f5844367d1f6efba44b35f2 | https://github.com/SmartTeleMax/iktomi/blob/80bc0f1408d63efe7f5844367d1f6efba44b35f2/iktomi/utils/system.py#L18-L39 |
55,407 | SmartTeleMax/iktomi | iktomi/utils/system.py | doublefork | def doublefork(pidfile, logfile, cwd, umask): # pragma: nocover
'''Daemonize current process.
After first fork we return to the shell and removing our self from
controling terminal via `setsid`.
After second fork we are not session leader any more and cant get
controlling terminal when opening files... | python | def doublefork(pidfile, logfile, cwd, umask): # pragma: nocover
'''Daemonize current process.
After first fork we return to the shell and removing our self from
controling terminal via `setsid`.
After second fork we are not session leader any more and cant get
controlling terminal when opening files... | [
"def",
"doublefork",
"(",
"pidfile",
",",
"logfile",
",",
"cwd",
",",
"umask",
")",
":",
"# pragma: nocover",
"try",
":",
"if",
"os",
".",
"fork",
"(",
")",
":",
"os",
".",
"_exit",
"(",
"os",
".",
"EX_OK",
")",
"except",
"OSError",
"as",
"e",
":",... | Daemonize current process.
After first fork we return to the shell and removing our self from
controling terminal via `setsid`.
After second fork we are not session leader any more and cant get
controlling terminal when opening files. | [
"Daemonize",
"current",
"process",
".",
"After",
"first",
"fork",
"we",
"return",
"to",
"the",
"shell",
"and",
"removing",
"our",
"self",
"from",
"controling",
"terminal",
"via",
"setsid",
".",
"After",
"second",
"fork",
"we",
"are",
"not",
"session",
"leade... | 80bc0f1408d63efe7f5844367d1f6efba44b35f2 | https://github.com/SmartTeleMax/iktomi/blob/80bc0f1408d63efe7f5844367d1f6efba44b35f2/iktomi/utils/system.py#L49-L82 |
55,408 | CivicSpleen/ambry | ambry/bundle/partitions.py | Partitions.partition | def partition(self, id_):
"""Get a partition by the id number.
Arguments:
id_ -- a partition id value
Returns:
A partitions.Partition object
Throws:
a Sqlalchemy exception if the partition either does not exist or
is not unique
... | python | def partition(self, id_):
"""Get a partition by the id number.
Arguments:
id_ -- a partition id value
Returns:
A partitions.Partition object
Throws:
a Sqlalchemy exception if the partition either does not exist or
is not unique
... | [
"def",
"partition",
"(",
"self",
",",
"id_",
")",
":",
"from",
".",
".",
"orm",
"import",
"Partition",
"as",
"OrmPartition",
"from",
"sqlalchemy",
"import",
"or_",
"from",
".",
".",
"identity",
"import",
"PartialPartitionName",
"if",
"isinstance",
"(",
"id_"... | Get a partition by the id number.
Arguments:
id_ -- a partition id value
Returns:
A partitions.Partition object
Throws:
a Sqlalchemy exception if the partition either does not exist or
is not unique
Because this method works on the bund... | [
"Get",
"a",
"partition",
"by",
"the",
"id",
"number",
"."
] | d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42 | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/bundle/partitions.py#L45-L96 |
55,409 | CivicSpleen/ambry | ambry/bundle/partitions.py | Partitions._find_orm | def _find_orm(self, pnq):
"""Return a Partition object from the database based on a PartitionId.
An ORM object is returned, so changes can be persisted.
"""
# import sqlalchemy.orm.exc
from ambry.orm import Partition as OrmPartition # , Table
from sqlalchemy.orm import... | python | def _find_orm(self, pnq):
"""Return a Partition object from the database based on a PartitionId.
An ORM object is returned, so changes can be persisted.
"""
# import sqlalchemy.orm.exc
from ambry.orm import Partition as OrmPartition # , Table
from sqlalchemy.orm import... | [
"def",
"_find_orm",
"(",
"self",
",",
"pnq",
")",
":",
"# import sqlalchemy.orm.exc",
"from",
"ambry",
".",
"orm",
"import",
"Partition",
"as",
"OrmPartition",
"# , Table",
"from",
"sqlalchemy",
".",
"orm",
"import",
"joinedload",
"# , joinedload_all",
"assert",
"... | Return a Partition object from the database based on a PartitionId.
An ORM object is returned, so changes can be persisted. | [
"Return",
"a",
"Partition",
"object",
"from",
"the",
"database",
"based",
"on",
"a",
"PartitionId",
"."
] | d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42 | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/bundle/partitions.py#L98-L159 |
55,410 | CivicSpleen/ambry | ambry/bundle/partitions.py | Partitions.new_db_from_pandas | def new_db_from_pandas(self, frame, table=None, data=None, load=True, **kwargs):
"""Create a new db partition from a pandas data frame.
If the table does not exist, it will be created
"""
from ..orm import Column
# from dbexceptions import ConfigurationError
# Create ... | python | def new_db_from_pandas(self, frame, table=None, data=None, load=True, **kwargs):
"""Create a new db partition from a pandas data frame.
If the table does not exist, it will be created
"""
from ..orm import Column
# from dbexceptions import ConfigurationError
# Create ... | [
"def",
"new_db_from_pandas",
"(",
"self",
",",
"frame",
",",
"table",
"=",
"None",
",",
"data",
"=",
"None",
",",
"load",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"from",
".",
".",
"orm",
"import",
"Column",
"# from dbexceptions import Configuration... | Create a new db partition from a pandas data frame.
If the table does not exist, it will be created | [
"Create",
"a",
"new",
"db",
"partition",
"from",
"a",
"pandas",
"data",
"frame",
"."
] | d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42 | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/bundle/partitions.py#L212-L252 |
55,411 | project-ncl/pnc-cli | pnc_cli/projects.py | update_project | def update_project(id, **kwargs):
"""
Update an existing Project with new information
"""
content = update_project_raw(id, **kwargs)
if content:
return utils.format_json(content) | python | def update_project(id, **kwargs):
"""
Update an existing Project with new information
"""
content = update_project_raw(id, **kwargs)
if content:
return utils.format_json(content) | [
"def",
"update_project",
"(",
"id",
",",
"*",
"*",
"kwargs",
")",
":",
"content",
"=",
"update_project_raw",
"(",
"id",
",",
"*",
"*",
"kwargs",
")",
"if",
"content",
":",
"return",
"utils",
".",
"format_json",
"(",
"content",
")"
] | Update an existing Project with new information | [
"Update",
"an",
"existing",
"Project",
"with",
"new",
"information"
] | 3dc149bf84928f60a8044ac50b58bbaddd451902 | https://github.com/project-ncl/pnc-cli/blob/3dc149bf84928f60a8044ac50b58bbaddd451902/pnc_cli/projects.py#L44-L50 |
55,412 | project-ncl/pnc-cli | pnc_cli/projects.py | get_project | def get_project(id=None, name=None):
"""
Get a specific Project by ID or name
"""
content = get_project_raw(id, name)
if content:
return utils.format_json(content) | python | def get_project(id=None, name=None):
"""
Get a specific Project by ID or name
"""
content = get_project_raw(id, name)
if content:
return utils.format_json(content) | [
"def",
"get_project",
"(",
"id",
"=",
"None",
",",
"name",
"=",
"None",
")",
":",
"content",
"=",
"get_project_raw",
"(",
"id",
",",
"name",
")",
"if",
"content",
":",
"return",
"utils",
".",
"format_json",
"(",
"content",
")"
] | Get a specific Project by ID or name | [
"Get",
"a",
"specific",
"Project",
"by",
"ID",
"or",
"name"
] | 3dc149bf84928f60a8044ac50b58bbaddd451902 | https://github.com/project-ncl/pnc-cli/blob/3dc149bf84928f60a8044ac50b58bbaddd451902/pnc_cli/projects.py#L69-L75 |
55,413 | project-ncl/pnc-cli | pnc_cli/projects.py | delete_project | def delete_project(id=None, name=None):
"""
Delete a Project by ID or name.
"""
content = delete_project_raw(id, name)
if content:
return utils.format_json(content) | python | def delete_project(id=None, name=None):
"""
Delete a Project by ID or name.
"""
content = delete_project_raw(id, name)
if content:
return utils.format_json(content) | [
"def",
"delete_project",
"(",
"id",
"=",
"None",
",",
"name",
"=",
"None",
")",
":",
"content",
"=",
"delete_project_raw",
"(",
"id",
",",
"name",
")",
"if",
"content",
":",
"return",
"utils",
".",
"format_json",
"(",
"content",
")"
] | Delete a Project by ID or name. | [
"Delete",
"a",
"Project",
"by",
"ID",
"or",
"name",
"."
] | 3dc149bf84928f60a8044ac50b58bbaddd451902 | https://github.com/project-ncl/pnc-cli/blob/3dc149bf84928f60a8044ac50b58bbaddd451902/pnc_cli/projects.py#L85-L91 |
55,414 | project-ncl/pnc-cli | pnc_cli/projects.py | list_projects | def list_projects(page_size=200, page_index=0, sort="", q=""):
"""
List all Projects
"""
content = list_projects_raw(page_size=page_size, page_index=page_index, sort=sort, q=q)
if content:
return utils.format_json_list(content) | python | def list_projects(page_size=200, page_index=0, sort="", q=""):
"""
List all Projects
"""
content = list_projects_raw(page_size=page_size, page_index=page_index, sort=sort, q=q)
if content:
return utils.format_json_list(content) | [
"def",
"list_projects",
"(",
"page_size",
"=",
"200",
",",
"page_index",
"=",
"0",
",",
"sort",
"=",
"\"\"",
",",
"q",
"=",
"\"\"",
")",
":",
"content",
"=",
"list_projects_raw",
"(",
"page_size",
"=",
"page_size",
",",
"page_index",
"=",
"page_index",
"... | List all Projects | [
"List",
"all",
"Projects"
] | 3dc149bf84928f60a8044ac50b58bbaddd451902 | https://github.com/project-ncl/pnc-cli/blob/3dc149bf84928f60a8044ac50b58bbaddd451902/pnc_cli/projects.py#L104-L110 |
55,415 | flaviogrossi/sockjs-cyclone | sockjs/cyclone/session.py | BaseSession.set_handler | def set_handler(self, handler):
""" Set transport handler
@param handler: Handler, should derive from the
C{sockjs.cyclone.transports.base.BaseTransportMixin}
"""
if self.handler is not None:
raise Exception('Attempted to overwrite BaseSession handler... | python | def set_handler(self, handler):
""" Set transport handler
@param handler: Handler, should derive from the
C{sockjs.cyclone.transports.base.BaseTransportMixin}
"""
if self.handler is not None:
raise Exception('Attempted to overwrite BaseSession handler... | [
"def",
"set_handler",
"(",
"self",
",",
"handler",
")",
":",
"if",
"self",
".",
"handler",
"is",
"not",
"None",
":",
"raise",
"Exception",
"(",
"'Attempted to overwrite BaseSession handler'",
")",
"self",
".",
"handler",
"=",
"handler",
"self",
".",
"transport... | Set transport handler
@param handler: Handler, should derive from the
C{sockjs.cyclone.transports.base.BaseTransportMixin} | [
"Set",
"transport",
"handler"
] | d3ca053ec1aa1e85f652347bff562c2319be37a2 | https://github.com/flaviogrossi/sockjs-cyclone/blob/d3ca053ec1aa1e85f652347bff562c2319be37a2/sockjs/cyclone/session.py#L48-L64 |
55,416 | flaviogrossi/sockjs-cyclone | sockjs/cyclone/session.py | BaseSession.delayed_close | def delayed_close(self):
""" Delayed close - won't close immediately, but on the next reactor
loop. """
self.state = SESSION_STATE.CLOSING
reactor.callLater(0, self.close) | python | def delayed_close(self):
""" Delayed close - won't close immediately, but on the next reactor
loop. """
self.state = SESSION_STATE.CLOSING
reactor.callLater(0, self.close) | [
"def",
"delayed_close",
"(",
"self",
")",
":",
"self",
".",
"state",
"=",
"SESSION_STATE",
".",
"CLOSING",
"reactor",
".",
"callLater",
"(",
"0",
",",
"self",
".",
"close",
")"
] | Delayed close - won't close immediately, but on the next reactor
loop. | [
"Delayed",
"close",
"-",
"won",
"t",
"close",
"immediately",
"but",
"on",
"the",
"next",
"reactor",
"loop",
"."
] | d3ca053ec1aa1e85f652347bff562c2319be37a2 | https://github.com/flaviogrossi/sockjs-cyclone/blob/d3ca053ec1aa1e85f652347bff562c2319be37a2/sockjs/cyclone/session.py#L108-L112 |
55,417 | flaviogrossi/sockjs-cyclone | sockjs/cyclone/session.py | BaseSession.is_closed | def is_closed(self):
""" Check if session was closed. """
return (self.state == SESSION_STATE.CLOSED
or self.state == SESSION_STATE.CLOSING) | python | def is_closed(self):
""" Check if session was closed. """
return (self.state == SESSION_STATE.CLOSED
or self.state == SESSION_STATE.CLOSING) | [
"def",
"is_closed",
"(",
"self",
")",
":",
"return",
"(",
"self",
".",
"state",
"==",
"SESSION_STATE",
".",
"CLOSED",
"or",
"self",
".",
"state",
"==",
"SESSION_STATE",
".",
"CLOSING",
")"
] | Check if session was closed. | [
"Check",
"if",
"session",
"was",
"closed",
"."
] | d3ca053ec1aa1e85f652347bff562c2319be37a2 | https://github.com/flaviogrossi/sockjs-cyclone/blob/d3ca053ec1aa1e85f652347bff562c2319be37a2/sockjs/cyclone/session.py#L129-L132 |
55,418 | flaviogrossi/sockjs-cyclone | sockjs/cyclone/session.py | SessionMixin._random_key | def _random_key(self):
""" Return random session key """
hashstr = '%s%s' % (random.random(), self.time_module.time())
return hashlib.md5(hashstr).hexdigest() | python | def _random_key(self):
""" Return random session key """
hashstr = '%s%s' % (random.random(), self.time_module.time())
return hashlib.md5(hashstr).hexdigest() | [
"def",
"_random_key",
"(",
"self",
")",
":",
"hashstr",
"=",
"'%s%s'",
"%",
"(",
"random",
".",
"random",
"(",
")",
",",
"self",
".",
"time_module",
".",
"time",
"(",
")",
")",
"return",
"hashlib",
".",
"md5",
"(",
"hashstr",
")",
".",
"hexdigest",
... | Return random session key | [
"Return",
"random",
"session",
"key"
] | d3ca053ec1aa1e85f652347bff562c2319be37a2 | https://github.com/flaviogrossi/sockjs-cyclone/blob/d3ca053ec1aa1e85f652347bff562c2319be37a2/sockjs/cyclone/session.py#L192-L195 |
55,419 | flaviogrossi/sockjs-cyclone | sockjs/cyclone/session.py | SessionMixin.promote | def promote(self):
""" Mark object as alive, so it won't be collected during next
run of the garbage collector.
"""
if self.expiry is not None:
self.promoted = self.time_module.time() + self.expiry | python | def promote(self):
""" Mark object as alive, so it won't be collected during next
run of the garbage collector.
"""
if self.expiry is not None:
self.promoted = self.time_module.time() + self.expiry | [
"def",
"promote",
"(",
"self",
")",
":",
"if",
"self",
".",
"expiry",
"is",
"not",
"None",
":",
"self",
".",
"promoted",
"=",
"self",
".",
"time_module",
".",
"time",
"(",
")",
"+",
"self",
".",
"expiry"
] | Mark object as alive, so it won't be collected during next
run of the garbage collector. | [
"Mark",
"object",
"as",
"alive",
"so",
"it",
"won",
"t",
"be",
"collected",
"during",
"next",
"run",
"of",
"the",
"garbage",
"collector",
"."
] | d3ca053ec1aa1e85f652347bff562c2319be37a2 | https://github.com/flaviogrossi/sockjs-cyclone/blob/d3ca053ec1aa1e85f652347bff562c2319be37a2/sockjs/cyclone/session.py#L201-L206 |
55,420 | flaviogrossi/sockjs-cyclone | sockjs/cyclone/session.py | Session.close | def close(self, code=3000, message='Go away!'):
""" Close session.
@param code: Closing code
@param message: Closing message
"""
if self.state != SESSION_STATE.CLOSED:
# Notify handler
if self.handler is not None:
self.handler.send_pack(p... | python | def close(self, code=3000, message='Go away!'):
""" Close session.
@param code: Closing code
@param message: Closing message
"""
if self.state != SESSION_STATE.CLOSED:
# Notify handler
if self.handler is not None:
self.handler.send_pack(p... | [
"def",
"close",
"(",
"self",
",",
"code",
"=",
"3000",
",",
"message",
"=",
"'Go away!'",
")",
":",
"if",
"self",
".",
"state",
"!=",
"SESSION_STATE",
".",
"CLOSED",
":",
"# Notify handler",
"if",
"self",
".",
"handler",
"is",
"not",
"None",
":",
"self... | Close session.
@param code: Closing code
@param message: Closing message | [
"Close",
"session",
"."
] | d3ca053ec1aa1e85f652347bff562c2319be37a2 | https://github.com/flaviogrossi/sockjs-cyclone/blob/d3ca053ec1aa1e85f652347bff562c2319be37a2/sockjs/cyclone/session.py#L382-L394 |
55,421 | CivicSpleen/ambry | ambry/valuetype/census/__init__.py | CensusStateGeoid.parser | def parser(cls, v):
"""Ensure that the upstream parser gets two digits. """
return geoid.census.State.parse(str(v).zfill(2)) | python | def parser(cls, v):
"""Ensure that the upstream parser gets two digits. """
return geoid.census.State.parse(str(v).zfill(2)) | [
"def",
"parser",
"(",
"cls",
",",
"v",
")",
":",
"return",
"geoid",
".",
"census",
".",
"State",
".",
"parse",
"(",
"str",
"(",
"v",
")",
".",
"zfill",
"(",
"2",
")",
")"
] | Ensure that the upstream parser gets two digits. | [
"Ensure",
"that",
"the",
"upstream",
"parser",
"gets",
"two",
"digits",
"."
] | d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42 | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/valuetype/census/__init__.py#L97-L99 |
55,422 | project-ncl/pnc-cli | pnc_cli/tools/config_utils.py | ConfigReader.get_dependency_structure | def get_dependency_structure(self, artifact=None, include_dependencies=False):
"""
Reads dependency structure. If an artifact is passed in you get only its dependencies otherwise the complete
structure is returned.
:param artifact: an artifact task or artifact name if only an artifact's... | python | def get_dependency_structure(self, artifact=None, include_dependencies=False):
"""
Reads dependency structure. If an artifact is passed in you get only its dependencies otherwise the complete
structure is returned.
:param artifact: an artifact task or artifact name if only an artifact's... | [
"def",
"get_dependency_structure",
"(",
"self",
",",
"artifact",
"=",
"None",
",",
"include_dependencies",
"=",
"False",
")",
":",
"artifacts",
"=",
"[",
"]",
"dependencies_dict",
"=",
"{",
"}",
"if",
"artifact",
":",
"if",
"isinstance",
"(",
"artifact",
","... | Reads dependency structure. If an artifact is passed in you get only its dependencies otherwise the complete
structure is returned.
:param artifact: an artifact task or artifact name if only an artifact's deps are needed
:param include_dependencies: flag to include also dependencies in returned... | [
"Reads",
"dependency",
"structure",
".",
"If",
"an",
"artifact",
"is",
"passed",
"in",
"you",
"get",
"only",
"its",
"dependencies",
"otherwise",
"the",
"complete",
"structure",
"is",
"returned",
"."
] | 3dc149bf84928f60a8044ac50b58bbaddd451902 | https://github.com/project-ncl/pnc-cli/blob/3dc149bf84928f60a8044ac50b58bbaddd451902/pnc_cli/tools/config_utils.py#L149-L176 |
55,423 | CivicSpleen/ambry | ambry/valuetype/types.py | transform_generator | def transform_generator(fn):
"""A decorator that marks transform pipes that should be called to create the real transform"""
if six.PY2:
fn.func_dict['is_transform_generator'] = True
else:
# py3
fn.__dict__['is_transform_generator'] = True
return fn | python | def transform_generator(fn):
"""A decorator that marks transform pipes that should be called to create the real transform"""
if six.PY2:
fn.func_dict['is_transform_generator'] = True
else:
# py3
fn.__dict__['is_transform_generator'] = True
return fn | [
"def",
"transform_generator",
"(",
"fn",
")",
":",
"if",
"six",
".",
"PY2",
":",
"fn",
".",
"func_dict",
"[",
"'is_transform_generator'",
"]",
"=",
"True",
"else",
":",
"# py3",
"fn",
".",
"__dict__",
"[",
"'is_transform_generator'",
"]",
"=",
"True",
"ret... | A decorator that marks transform pipes that should be called to create the real transform | [
"A",
"decorator",
"that",
"marks",
"transform",
"pipes",
"that",
"should",
"be",
"called",
"to",
"create",
"the",
"real",
"transform"
] | d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42 | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/valuetype/types.py#L19-L26 |
55,424 | CivicSpleen/ambry | ambry/valuetype/types.py | is_transform_generator | def is_transform_generator(fn):
"""Return true of the function has been marked with @transform_generator"""
try:
if six.PY2:
fn.func_dict['is_transform_generator'] = True
else:
# py3
return fn.__dict__.get('is_transform_generator', False)
except AttributeE... | python | def is_transform_generator(fn):
"""Return true of the function has been marked with @transform_generator"""
try:
if six.PY2:
fn.func_dict['is_transform_generator'] = True
else:
# py3
return fn.__dict__.get('is_transform_generator', False)
except AttributeE... | [
"def",
"is_transform_generator",
"(",
"fn",
")",
":",
"try",
":",
"if",
"six",
".",
"PY2",
":",
"fn",
".",
"func_dict",
"[",
"'is_transform_generator'",
"]",
"=",
"True",
"else",
":",
"# py3",
"return",
"fn",
".",
"__dict__",
".",
"get",
"(",
"'is_transf... | Return true of the function has been marked with @transform_generator | [
"Return",
"true",
"of",
"the",
"function",
"has",
"been",
"marked",
"with"
] | d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42 | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/valuetype/types.py#L29-L38 |
55,425 | CivicSpleen/ambry | ambry/valuetype/types.py | nullify | def nullify(v):
"""Convert empty strings and strings with only spaces to None values. """
if isinstance(v, six.string_types):
v = v.strip()
if v is None or v == '':
return None
else:
return v | python | def nullify(v):
"""Convert empty strings and strings with only spaces to None values. """
if isinstance(v, six.string_types):
v = v.strip()
if v is None or v == '':
return None
else:
return v | [
"def",
"nullify",
"(",
"v",
")",
":",
"if",
"isinstance",
"(",
"v",
",",
"six",
".",
"string_types",
")",
":",
"v",
"=",
"v",
".",
"strip",
"(",
")",
"if",
"v",
"is",
"None",
"or",
"v",
"==",
"''",
":",
"return",
"None",
"else",
":",
"return",
... | Convert empty strings and strings with only spaces to None values. | [
"Convert",
"empty",
"strings",
"and",
"strings",
"with",
"only",
"spaces",
"to",
"None",
"values",
"."
] | d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42 | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/valuetype/types.py#L45-L54 |
55,426 | CivicSpleen/ambry | ambry/valuetype/types.py | parse_int | def parse_int(v, header_d):
"""Parse as an integer, or a subclass of Int."""
v = nullify(v)
if v is None:
return None
try:
# The converson to float allows converting float strings to ints.
# The conversion int('2.134') will fail.
return int(round(float(v), 0))
exce... | python | def parse_int(v, header_d):
"""Parse as an integer, or a subclass of Int."""
v = nullify(v)
if v is None:
return None
try:
# The converson to float allows converting float strings to ints.
# The conversion int('2.134') will fail.
return int(round(float(v), 0))
exce... | [
"def",
"parse_int",
"(",
"v",
",",
"header_d",
")",
":",
"v",
"=",
"nullify",
"(",
"v",
")",
"if",
"v",
"is",
"None",
":",
"return",
"None",
"try",
":",
"# The converson to float allows converting float strings to ints.",
"# The conversion int('2.134') will fail.",
... | Parse as an integer, or a subclass of Int. | [
"Parse",
"as",
"an",
"integer",
"or",
"a",
"subclass",
"of",
"Int",
"."
] | d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42 | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/valuetype/types.py#L127-L140 |
55,427 | CivicSpleen/ambry | ambry/valuetype/types.py | _parse_text | def _parse_text(v, header_d):
""" Parses unicode.
Note:
unicode types for py2 and str types for py3.
"""
v = nullify(v)
if v is None:
return None
try:
return six.text_type(v).strip()
except Exception as e:
raise CastingError(six.text_type, header_d, v, st... | python | def _parse_text(v, header_d):
""" Parses unicode.
Note:
unicode types for py2 and str types for py3.
"""
v = nullify(v)
if v is None:
return None
try:
return six.text_type(v).strip()
except Exception as e:
raise CastingError(six.text_type, header_d, v, st... | [
"def",
"_parse_text",
"(",
"v",
",",
"header_d",
")",
":",
"v",
"=",
"nullify",
"(",
"v",
")",
"if",
"v",
"is",
"None",
":",
"return",
"None",
"try",
":",
"return",
"six",
".",
"text_type",
"(",
"v",
")",
".",
"strip",
"(",
")",
"except",
"Except... | Parses unicode.
Note:
unicode types for py2 and str types for py3. | [
"Parses",
"unicode",
"."
] | d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42 | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/valuetype/types.py#L338-L354 |
55,428 | CivicSpleen/ambry | ambry/valuetype/types.py | _parse_binary | def _parse_binary(v, header_d):
""" Parses binary string.
Note:
<str> for py2 and <binary> for py3.
"""
# This is often a no-op, but it ocassionally converts numbers into strings
v = nullify(v)
if v is None:
return None
if six.PY2:
try:
return six.bi... | python | def _parse_binary(v, header_d):
""" Parses binary string.
Note:
<str> for py2 and <binary> for py3.
"""
# This is often a no-op, but it ocassionally converts numbers into strings
v = nullify(v)
if v is None:
return None
if six.PY2:
try:
return six.bi... | [
"def",
"_parse_binary",
"(",
"v",
",",
"header_d",
")",
":",
"# This is often a no-op, but it ocassionally converts numbers into strings",
"v",
"=",
"nullify",
"(",
"v",
")",
"if",
"v",
"is",
"None",
":",
"return",
"None",
"if",
"six",
".",
"PY2",
":",
"try",
... | Parses binary string.
Note:
<str> for py2 and <binary> for py3. | [
"Parses",
"binary",
"string",
"."
] | d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42 | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/valuetype/types.py#L357-L382 |
55,429 | twisted/epsilon | epsilon/juice.py | parseJuiceHeaders | def parseJuiceHeaders(lines):
"""
Create a JuiceBox from a list of header lines.
@param lines: a list of lines.
"""
b = JuiceBox()
bodylen = 0
key = None
for L in lines:
if L[0] == ' ':
# continuation
assert key is not None
b[key] += '\r\n'+L[... | python | def parseJuiceHeaders(lines):
"""
Create a JuiceBox from a list of header lines.
@param lines: a list of lines.
"""
b = JuiceBox()
bodylen = 0
key = None
for L in lines:
if L[0] == ' ':
# continuation
assert key is not None
b[key] += '\r\n'+L[... | [
"def",
"parseJuiceHeaders",
"(",
"lines",
")",
":",
"b",
"=",
"JuiceBox",
"(",
")",
"bodylen",
"=",
"0",
"key",
"=",
"None",
"for",
"L",
"in",
"lines",
":",
"if",
"L",
"[",
"0",
"]",
"==",
"' '",
":",
"# continuation",
"assert",
"key",
"is",
"not",... | Create a JuiceBox from a list of header lines.
@param lines: a list of lines. | [
"Create",
"a",
"JuiceBox",
"from",
"a",
"list",
"of",
"header",
"lines",
"."
] | e85fa985a41983ef06e1d3bb26639181e1f78b24 | https://github.com/twisted/epsilon/blob/e85fa985a41983ef06e1d3bb26639181e1f78b24/epsilon/juice.py#L283-L304 |
55,430 | twisted/epsilon | epsilon/juice.py | DispatchMixin.lookupFunction | def lookupFunction(self, proto, name, namespace):
"""Return a callable to invoke when executing the named command.
"""
# Try to find a method to be invoked in a transaction first
# Otherwise fallback to a "regular" method
fName = self.autoDispatchPrefix + name
fObj = geta... | python | def lookupFunction(self, proto, name, namespace):
"""Return a callable to invoke when executing the named command.
"""
# Try to find a method to be invoked in a transaction first
# Otherwise fallback to a "regular" method
fName = self.autoDispatchPrefix + name
fObj = geta... | [
"def",
"lookupFunction",
"(",
"self",
",",
"proto",
",",
"name",
",",
"namespace",
")",
":",
"# Try to find a method to be invoked in a transaction first",
"# Otherwise fallback to a \"regular\" method",
"fName",
"=",
"self",
".",
"autoDispatchPrefix",
"+",
"name",
"fObj",
... | Return a callable to invoke when executing the named command. | [
"Return",
"a",
"callable",
"to",
"invoke",
"when",
"executing",
"the",
"named",
"command",
"."
] | e85fa985a41983ef06e1d3bb26639181e1f78b24 | https://github.com/twisted/epsilon/blob/e85fa985a41983ef06e1d3bb26639181e1f78b24/epsilon/juice.py#L246-L262 |
55,431 | twisted/epsilon | epsilon/juice.py | Juice._switchTo | def _switchTo(self, newProto, clientFactory=None):
""" Switch this Juice instance to a new protocol. You need to do this
'simultaneously' on both ends of a connection; the easiest way to do
this is to use a subclass of ProtocolSwitchCommand.
"""
assert self.innerProtocol is Non... | python | def _switchTo(self, newProto, clientFactory=None):
""" Switch this Juice instance to a new protocol. You need to do this
'simultaneously' on both ends of a connection; the easiest way to do
this is to use a subclass of ProtocolSwitchCommand.
"""
assert self.innerProtocol is Non... | [
"def",
"_switchTo",
"(",
"self",
",",
"newProto",
",",
"clientFactory",
"=",
"None",
")",
":",
"assert",
"self",
".",
"innerProtocol",
"is",
"None",
",",
"\"Protocol can only be safely switched once.\"",
"self",
".",
"setRawMode",
"(",
")",
"self",
".",
"innerPr... | Switch this Juice instance to a new protocol. You need to do this
'simultaneously' on both ends of a connection; the easiest way to do
this is to use a subclass of ProtocolSwitchCommand. | [
"Switch",
"this",
"Juice",
"instance",
"to",
"a",
"new",
"protocol",
".",
"You",
"need",
"to",
"do",
"this",
"simultaneously",
"on",
"both",
"ends",
"of",
"a",
"connection",
";",
"the",
"easiest",
"way",
"to",
"do",
"this",
"is",
"to",
"use",
"a",
"sub... | e85fa985a41983ef06e1d3bb26639181e1f78b24 | https://github.com/twisted/epsilon/blob/e85fa985a41983ef06e1d3bb26639181e1f78b24/epsilon/juice.py#L784-L794 |
55,432 | twisted/epsilon | epsilon/juice.py | Juice.sendPacket | def sendPacket(self, completeBox):
"""
Send a juice.Box to my peer.
Note: transport.write is never called outside of this method.
"""
assert not self.__locked, "You cannot send juice packets when a connection is locked"
if self._startingTLSBuffer is not None:
... | python | def sendPacket(self, completeBox):
"""
Send a juice.Box to my peer.
Note: transport.write is never called outside of this method.
"""
assert not self.__locked, "You cannot send juice packets when a connection is locked"
if self._startingTLSBuffer is not None:
... | [
"def",
"sendPacket",
"(",
"self",
",",
"completeBox",
")",
":",
"assert",
"not",
"self",
".",
"__locked",
",",
"\"You cannot send juice packets when a connection is locked\"",
"if",
"self",
".",
"_startingTLSBuffer",
"is",
"not",
"None",
":",
"self",
".",
"_starting... | Send a juice.Box to my peer.
Note: transport.write is never called outside of this method. | [
"Send",
"a",
"juice",
".",
"Box",
"to",
"my",
"peer",
"."
] | e85fa985a41983ef06e1d3bb26639181e1f78b24 | https://github.com/twisted/epsilon/blob/e85fa985a41983ef06e1d3bb26639181e1f78b24/epsilon/juice.py#L805-L818 |
55,433 | CivicSpleen/ambry | ambry/orm/plot.py | Plot.dataframe | def dataframe(self, filtered_dims={}, unstack=False, df_class=None, add_code=False):
"""
Yield rows in a reduced format, with one dimension as an index, one measure column per
secondary dimension, and all other dimensions filtered.
:param measure: The column names of one or more measur... | python | def dataframe(self, filtered_dims={}, unstack=False, df_class=None, add_code=False):
"""
Yield rows in a reduced format, with one dimension as an index, one measure column per
secondary dimension, and all other dimensions filtered.
:param measure: The column names of one or more measur... | [
"def",
"dataframe",
"(",
"self",
",",
"filtered_dims",
"=",
"{",
"}",
",",
"unstack",
"=",
"False",
",",
"df_class",
"=",
"None",
",",
"add_code",
"=",
"False",
")",
":",
"measure",
"=",
"self",
".",
"table",
".",
"column",
"(",
"measure",
")",
"p_di... | Yield rows in a reduced format, with one dimension as an index, one measure column per
secondary dimension, and all other dimensions filtered.
:param measure: The column names of one or more measures
:param p_dim: The primary dimension. This will be the index of the dataframe.
:param s... | [
"Yield",
"rows",
"in",
"a",
"reduced",
"format",
"with",
"one",
"dimension",
"as",
"an",
"index",
"one",
"measure",
"column",
"per",
"secondary",
"dimension",
"and",
"all",
"other",
"dimensions",
"filtered",
"."
] | d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42 | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/orm/plot.py#L52-L160 |
55,434 | CivicSpleen/ambry | ambry/library/search_backends/sqlite_backend.py | DatasetSQLiteIndex._index_document | def _index_document(self, document, force=False):
""" Adds document to the index. """
query = text("""
INSERT INTO dataset_index(vid, title, keywords, doc)
VALUES(:vid, :title, :keywords, :doc);
""")
self.backend.library.database.connection.execute(query, **docume... | python | def _index_document(self, document, force=False):
""" Adds document to the index. """
query = text("""
INSERT INTO dataset_index(vid, title, keywords, doc)
VALUES(:vid, :title, :keywords, :doc);
""")
self.backend.library.database.connection.execute(query, **docume... | [
"def",
"_index_document",
"(",
"self",
",",
"document",
",",
"force",
"=",
"False",
")",
":",
"query",
"=",
"text",
"(",
"\"\"\"\n INSERT INTO dataset_index(vid, title, keywords, doc)\n VALUES(:vid, :title, :keywords, :doc);\n \"\"\"",
")",
"self",
... | Adds document to the index. | [
"Adds",
"document",
"to",
"the",
"index",
"."
] | d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42 | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/library/search_backends/sqlite_backend.py#L186-L192 |
55,435 | CivicSpleen/ambry | ambry/library/search_backends/sqlite_backend.py | IdentifierSQLiteIndex.list_documents | def list_documents(self, limit=None):
""" Generates vids of all indexed identifiers.
Args:
limit (int, optional): If not empty, the maximum number of results to return
Generates:
str: vid of the document.
"""
limit_str = ''
if limit:
... | python | def list_documents(self, limit=None):
""" Generates vids of all indexed identifiers.
Args:
limit (int, optional): If not empty, the maximum number of results to return
Generates:
str: vid of the document.
"""
limit_str = ''
if limit:
... | [
"def",
"list_documents",
"(",
"self",
",",
"limit",
"=",
"None",
")",
":",
"limit_str",
"=",
"''",
"if",
"limit",
":",
"try",
":",
"limit_str",
"=",
"'LIMIT {}'",
".",
"format",
"(",
"int",
"(",
"limit",
")",
")",
"except",
"(",
"TypeError",
",",
"Va... | Generates vids of all indexed identifiers.
Args:
limit (int, optional): If not empty, the maximum number of results to return
Generates:
str: vid of the document. | [
"Generates",
"vids",
"of",
"all",
"indexed",
"identifiers",
"."
] | d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42 | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/library/search_backends/sqlite_backend.py#L289-L308 |
55,436 | CivicSpleen/ambry | ambry/library/search_backends/sqlite_backend.py | IdentifierSQLiteIndex.reset | def reset(self):
""" Drops index table. """
query = """
DROP TABLE identifier_index;
"""
self.backend.library.database.connection.execute(query) | python | def reset(self):
""" Drops index table. """
query = """
DROP TABLE identifier_index;
"""
self.backend.library.database.connection.execute(query) | [
"def",
"reset",
"(",
"self",
")",
":",
"query",
"=",
"\"\"\"\n DROP TABLE identifier_index;\n \"\"\"",
"self",
".",
"backend",
".",
"library",
".",
"database",
".",
"connection",
".",
"execute",
"(",
"query",
")"
] | Drops index table. | [
"Drops",
"index",
"table",
"."
] | d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42 | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/library/search_backends/sqlite_backend.py#L318-L323 |
55,437 | kurtraschke/pyRFC3339 | pyrfc3339/utils.py | timezone | def timezone(utcoffset):
'''
Return a string representing the timezone offset.
Remaining seconds are rounded to the nearest minute.
>>> timezone(3600)
'+01:00'
>>> timezone(5400)
'+01:30'
>>> timezone(-28800)
'-08:00'
'''
hours, seconds = divmod(abs(utcoffset), 3600)
m... | python | def timezone(utcoffset):
'''
Return a string representing the timezone offset.
Remaining seconds are rounded to the nearest minute.
>>> timezone(3600)
'+01:00'
>>> timezone(5400)
'+01:30'
>>> timezone(-28800)
'-08:00'
'''
hours, seconds = divmod(abs(utcoffset), 3600)
m... | [
"def",
"timezone",
"(",
"utcoffset",
")",
":",
"hours",
",",
"seconds",
"=",
"divmod",
"(",
"abs",
"(",
"utcoffset",
")",
",",
"3600",
")",
"minutes",
"=",
"round",
"(",
"float",
"(",
"seconds",
")",
"/",
"60",
")",
"if",
"utcoffset",
">=",
"0",
":... | Return a string representing the timezone offset.
Remaining seconds are rounded to the nearest minute.
>>> timezone(3600)
'+01:00'
>>> timezone(5400)
'+01:30'
>>> timezone(-28800)
'-08:00' | [
"Return",
"a",
"string",
"representing",
"the",
"timezone",
"offset",
".",
"Remaining",
"seconds",
"are",
"rounded",
"to",
"the",
"nearest",
"minute",
"."
] | e30cc1555adce0ecc7bd65509a2249d47e5a41b4 | https://github.com/kurtraschke/pyRFC3339/blob/e30cc1555adce0ecc7bd65509a2249d47e5a41b4/pyrfc3339/utils.py#L122-L143 |
55,438 | CivicSpleen/ambry | ambry/orm/config.py | BuildConfigGroupAccessor.build_duration | def build_duration(self):
"""Return the difference between build and build_done states"""
return int(self.state.build_done) - int(self.state.build) | python | def build_duration(self):
"""Return the difference between build and build_done states"""
return int(self.state.build_done) - int(self.state.build) | [
"def",
"build_duration",
"(",
"self",
")",
":",
"return",
"int",
"(",
"self",
".",
"state",
".",
"build_done",
")",
"-",
"int",
"(",
"self",
".",
"state",
".",
"build",
")"
] | Return the difference between build and build_done states | [
"Return",
"the",
"difference",
"between",
"build",
"and",
"build_done",
"states"
] | d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42 | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/orm/config.py#L228-L231 |
55,439 | CivicSpleen/ambry | ambry/orm/config.py | BuildConfigGroupAccessor.build_duration_pretty | def build_duration_pretty(self):
"""Return the difference between build and build_done states, in a human readable format"""
from ambry.util import pretty_time
from time import time
if not self.state.building:
return None
built = self.state.built or time()
... | python | def build_duration_pretty(self):
"""Return the difference between build and build_done states, in a human readable format"""
from ambry.util import pretty_time
from time import time
if not self.state.building:
return None
built = self.state.built or time()
... | [
"def",
"build_duration_pretty",
"(",
"self",
")",
":",
"from",
"ambry",
".",
"util",
"import",
"pretty_time",
"from",
"time",
"import",
"time",
"if",
"not",
"self",
".",
"state",
".",
"building",
":",
"return",
"None",
"built",
"=",
"self",
".",
"state",
... | Return the difference between build and build_done states, in a human readable format | [
"Return",
"the",
"difference",
"between",
"build",
"and",
"build_done",
"states",
"in",
"a",
"human",
"readable",
"format"
] | d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42 | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/orm/config.py#L234-L247 |
55,440 | CivicSpleen/ambry | ambry/orm/config.py | BuildConfigGroupAccessor.built_datetime | def built_datetime(self):
"""Return the built time as a datetime object"""
from datetime import datetime
try:
return datetime.fromtimestamp(self.state.build_done)
except TypeError:
# build_done is null
return None | python | def built_datetime(self):
"""Return the built time as a datetime object"""
from datetime import datetime
try:
return datetime.fromtimestamp(self.state.build_done)
except TypeError:
# build_done is null
return None | [
"def",
"built_datetime",
"(",
"self",
")",
":",
"from",
"datetime",
"import",
"datetime",
"try",
":",
"return",
"datetime",
".",
"fromtimestamp",
"(",
"self",
".",
"state",
".",
"build_done",
")",
"except",
"TypeError",
":",
"# build_done is null",
"return",
"... | Return the built time as a datetime object | [
"Return",
"the",
"built",
"time",
"as",
"a",
"datetime",
"object"
] | d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42 | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/orm/config.py#L250-L257 |
55,441 | CivicSpleen/ambry | ambry/orm/config.py | BuildConfigGroupAccessor.new_datetime | def new_datetime(self):
"""Return the time the bundle was created as a datetime object"""
from datetime import datetime
try:
return datetime.fromtimestamp(self.state.new)
except TypeError:
return None | python | def new_datetime(self):
"""Return the time the bundle was created as a datetime object"""
from datetime import datetime
try:
return datetime.fromtimestamp(self.state.new)
except TypeError:
return None | [
"def",
"new_datetime",
"(",
"self",
")",
":",
"from",
"datetime",
"import",
"datetime",
"try",
":",
"return",
"datetime",
".",
"fromtimestamp",
"(",
"self",
".",
"state",
".",
"new",
")",
"except",
"TypeError",
":",
"return",
"None"
] | Return the time the bundle was created as a datetime object | [
"Return",
"the",
"time",
"the",
"bundle",
"was",
"created",
"as",
"a",
"datetime",
"object"
] | d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42 | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/orm/config.py#L260-L267 |
55,442 | CivicSpleen/ambry | ambry/orm/config.py | BuildConfigGroupAccessor.last_datetime | def last_datetime(self):
"""Return the time of the last operation on the bundle as a datetime object"""
from datetime import datetime
try:
return datetime.fromtimestamp(self.state.lasttime)
except TypeError:
return None | python | def last_datetime(self):
"""Return the time of the last operation on the bundle as a datetime object"""
from datetime import datetime
try:
return datetime.fromtimestamp(self.state.lasttime)
except TypeError:
return None | [
"def",
"last_datetime",
"(",
"self",
")",
":",
"from",
"datetime",
"import",
"datetime",
"try",
":",
"return",
"datetime",
".",
"fromtimestamp",
"(",
"self",
".",
"state",
".",
"lasttime",
")",
"except",
"TypeError",
":",
"return",
"None"
] | Return the time of the last operation on the bundle as a datetime object | [
"Return",
"the",
"time",
"of",
"the",
"last",
"operation",
"on",
"the",
"bundle",
"as",
"a",
"datetime",
"object"
] | d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42 | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/orm/config.py#L270-L277 |
55,443 | project-ncl/pnc-cli | pnc_cli/productversions.py | list_product_versions | def list_product_versions(page_size=200, page_index=0, sort="", q=""):
"""
List all ProductVersions
"""
content = list_product_versions_raw(page_size, page_index, sort, q)
if content:
return utils.format_json_list(content) | python | def list_product_versions(page_size=200, page_index=0, sort="", q=""):
"""
List all ProductVersions
"""
content = list_product_versions_raw(page_size, page_index, sort, q)
if content:
return utils.format_json_list(content) | [
"def",
"list_product_versions",
"(",
"page_size",
"=",
"200",
",",
"page_index",
"=",
"0",
",",
"sort",
"=",
"\"\"",
",",
"q",
"=",
"\"\"",
")",
":",
"content",
"=",
"list_product_versions_raw",
"(",
"page_size",
",",
"page_index",
",",
"sort",
",",
"q",
... | List all ProductVersions | [
"List",
"all",
"ProductVersions"
] | 3dc149bf84928f60a8044ac50b58bbaddd451902 | https://github.com/project-ncl/pnc-cli/blob/3dc149bf84928f60a8044ac50b58bbaddd451902/pnc_cli/productversions.py#L34-L40 |
55,444 | project-ncl/pnc-cli | pnc_cli/productversions.py | create_product_version | def create_product_version(product_id, version, **kwargs):
"""
Create a new ProductVersion.
Each ProductVersion represents a supported product release stream, which includes milestones and releases typically associated with a single major.minor version of a Product.
Follows the Red Hat product support c... | python | def create_product_version(product_id, version, **kwargs):
"""
Create a new ProductVersion.
Each ProductVersion represents a supported product release stream, which includes milestones and releases typically associated with a single major.minor version of a Product.
Follows the Red Hat product support c... | [
"def",
"create_product_version",
"(",
"product_id",
",",
"version",
",",
"*",
"*",
"kwargs",
")",
":",
"data",
"=",
"create_product_version_raw",
"(",
"product_id",
",",
"version",
",",
"*",
"*",
"kwargs",
")",
"if",
"data",
":",
"return",
"utils",
".",
"f... | Create a new ProductVersion.
Each ProductVersion represents a supported product release stream, which includes milestones and releases typically associated with a single major.minor version of a Product.
Follows the Red Hat product support cycle, and typically includes Alpha, Beta, GA, and CP releases with the ... | [
"Create",
"a",
"new",
"ProductVersion",
".",
"Each",
"ProductVersion",
"represents",
"a",
"supported",
"product",
"release",
"stream",
"which",
"includes",
"milestones",
"and",
"releases",
"typically",
"associated",
"with",
"a",
"single",
"major",
".",
"minor",
"v... | 3dc149bf84928f60a8044ac50b58bbaddd451902 | https://github.com/project-ncl/pnc-cli/blob/3dc149bf84928f60a8044ac50b58bbaddd451902/pnc_cli/productversions.py#L60-L72 |
55,445 | project-ncl/pnc-cli | pnc_cli/productversions.py | update_product_version | def update_product_version(id, **kwargs):
"""
Update the ProductVersion with ID id with new values.
"""
content = update_product_version_raw(id, **kwargs)
if content:
return utils.format_json(content) | python | def update_product_version(id, **kwargs):
"""
Update the ProductVersion with ID id with new values.
"""
content = update_product_version_raw(id, **kwargs)
if content:
return utils.format_json(content) | [
"def",
"update_product_version",
"(",
"id",
",",
"*",
"*",
"kwargs",
")",
":",
"content",
"=",
"update_product_version_raw",
"(",
"id",
",",
"*",
"*",
"kwargs",
")",
"if",
"content",
":",
"return",
"utils",
".",
"format_json",
"(",
"content",
")"
] | Update the ProductVersion with ID id with new values. | [
"Update",
"the",
"ProductVersion",
"with",
"ID",
"id",
"with",
"new",
"values",
"."
] | 3dc149bf84928f60a8044ac50b58bbaddd451902 | https://github.com/project-ncl/pnc-cli/blob/3dc149bf84928f60a8044ac50b58bbaddd451902/pnc_cli/productversions.py#L117-L123 |
55,446 | SmartTeleMax/iktomi | iktomi/forms/widgets.py | Widget.prepare_data | def prepare_data(self):
'''
Method returning data passed to template.
Subclasses can override it.
'''
value = self.get_raw_value()
return dict(widget=self,
field=self.field,
value=value,
readonly=not self.field.w... | python | def prepare_data(self):
'''
Method returning data passed to template.
Subclasses can override it.
'''
value = self.get_raw_value()
return dict(widget=self,
field=self.field,
value=value,
readonly=not self.field.w... | [
"def",
"prepare_data",
"(",
"self",
")",
":",
"value",
"=",
"self",
".",
"get_raw_value",
"(",
")",
"return",
"dict",
"(",
"widget",
"=",
"self",
",",
"field",
"=",
"self",
".",
"field",
",",
"value",
"=",
"value",
",",
"readonly",
"=",
"not",
"self"... | Method returning data passed to template.
Subclasses can override it. | [
"Method",
"returning",
"data",
"passed",
"to",
"template",
".",
"Subclasses",
"can",
"override",
"it",
"."
] | 80bc0f1408d63efe7f5844367d1f6efba44b35f2 | https://github.com/SmartTeleMax/iktomi/blob/80bc0f1408d63efe7f5844367d1f6efba44b35f2/iktomi/forms/widgets.py#L52-L61 |
55,447 | SmartTeleMax/iktomi | iktomi/forms/widgets.py | Widget.render | def render(self):
'''
Renders widget to template
'''
data = self.prepare_data()
if self.field.readable:
return self.env.template.render(self.template, **data)
return '' | python | def render(self):
'''
Renders widget to template
'''
data = self.prepare_data()
if self.field.readable:
return self.env.template.render(self.template, **data)
return '' | [
"def",
"render",
"(",
"self",
")",
":",
"data",
"=",
"self",
".",
"prepare_data",
"(",
")",
"if",
"self",
".",
"field",
".",
"readable",
":",
"return",
"self",
".",
"env",
".",
"template",
".",
"render",
"(",
"self",
".",
"template",
",",
"*",
"*",... | Renders widget to template | [
"Renders",
"widget",
"to",
"template"
] | 80bc0f1408d63efe7f5844367d1f6efba44b35f2 | https://github.com/SmartTeleMax/iktomi/blob/80bc0f1408d63efe7f5844367d1f6efba44b35f2/iktomi/forms/widgets.py#L66-L73 |
55,448 | vovanec/httputil | httputil/request_engines/async.py | AsyncRequestEngine._request | def _request(self, url, *,
method='GET', headers=None, data=None, result_callback=None):
"""Perform asynchronous request.
:param str url: request URL.
:param str method: request method.
:param dict headers: request headers.
:param object data: JSON-encodable obj... | python | def _request(self, url, *,
method='GET', headers=None, data=None, result_callback=None):
"""Perform asynchronous request.
:param str url: request URL.
:param str method: request method.
:param dict headers: request headers.
:param object data: JSON-encodable obj... | [
"def",
"_request",
"(",
"self",
",",
"url",
",",
"*",
",",
"method",
"=",
"'GET'",
",",
"headers",
"=",
"None",
",",
"data",
"=",
"None",
",",
"result_callback",
"=",
"None",
")",
":",
"request",
"=",
"self",
".",
"_prepare_request",
"(",
"url",
",",... | Perform asynchronous request.
:param str url: request URL.
:param str method: request method.
:param dict headers: request headers.
:param object data: JSON-encodable object.
:param object -> object result_callback: result callback.
:rtype: dict
:raise: APIError | [
"Perform",
"asynchronous",
"request",
"."
] | 0b8dab5a23166cceb7dbc2a1dbc802ab5b311347 | https://github.com/vovanec/httputil/blob/0b8dab5a23166cceb7dbc2a1dbc802ab5b311347/httputil/request_engines/async.py#L56-L102 |
55,449 | acorg/dark-matter | dark/blast/alignments.py | BlastReadsAlignments.adjustHspsForPlotting | def adjustHspsForPlotting(self, titleAlignments):
"""
Our HSPs are about to be plotted. If we are using e-values, these need
to be adjusted.
@param titleAlignments: An instance of L{TitleAlignment}.
"""
# If we're using bit scores, there's nothing to do.
if self.... | python | def adjustHspsForPlotting(self, titleAlignments):
"""
Our HSPs are about to be plotted. If we are using e-values, these need
to be adjusted.
@param titleAlignments: An instance of L{TitleAlignment}.
"""
# If we're using bit scores, there's nothing to do.
if self.... | [
"def",
"adjustHspsForPlotting",
"(",
"self",
",",
"titleAlignments",
")",
":",
"# If we're using bit scores, there's nothing to do.",
"if",
"self",
".",
"scoreClass",
"is",
"HigherIsBetterScore",
":",
"return",
"# Convert all e-values to high positive values, and keep track of the"... | Our HSPs are about to be plotted. If we are using e-values, these need
to be adjusted.
@param titleAlignments: An instance of L{TitleAlignment}. | [
"Our",
"HSPs",
"are",
"about",
"to",
"be",
"plotted",
".",
"If",
"we",
"are",
"using",
"e",
"-",
"values",
"these",
"need",
"to",
"be",
"adjusted",
"."
] | c78a1bf262667fa5db3548fa7066c4ec14d0551d | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/blast/alignments.py#L195-L237 |
55,450 | acorg/dark-matter | dark/blast/alignments.py | BlastReadsAlignments.adjustPlot | def adjustPlot(self, readsAx):
"""
Add a horizontal line to the plotted reads if we're plotting e-values
and a zero e-value was found.
@param readsAx: A Matplotlib sub-plot instance, as returned by
matplotlib.pyplot.subplot.
"""
# If we're using bit scores, t... | python | def adjustPlot(self, readsAx):
"""
Add a horizontal line to the plotted reads if we're plotting e-values
and a zero e-value was found.
@param readsAx: A Matplotlib sub-plot instance, as returned by
matplotlib.pyplot.subplot.
"""
# If we're using bit scores, t... | [
"def",
"adjustPlot",
"(",
"self",
",",
"readsAx",
")",
":",
"# If we're using bit scores, there's nothing to do.",
"if",
"self",
".",
"scoreClass",
"is",
"HigherIsBetterScore",
":",
"return",
"if",
"self",
".",
"_zeroEValueFound",
":",
"readsAx",
".",
"axhline",
"("... | Add a horizontal line to the plotted reads if we're plotting e-values
and a zero e-value was found.
@param readsAx: A Matplotlib sub-plot instance, as returned by
matplotlib.pyplot.subplot. | [
"Add",
"a",
"horizontal",
"line",
"to",
"the",
"plotted",
"reads",
"if",
"we",
"re",
"plotting",
"e",
"-",
"values",
"and",
"a",
"zero",
"e",
"-",
"value",
"was",
"found",
"."
] | c78a1bf262667fa5db3548fa7066c4ec14d0551d | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/blast/alignments.py#L239-L253 |
55,451 | flo-compbio/genometools | genometools/expression/matrix.py | ExpMatrix.get_figure | def get_figure(self, heatmap_kw=None, **kwargs):
"""Generate a plotly figure showing the matrix as a heatmap.
This is a shortcut for ``ExpMatrix.get_heatmap(...).get_figure(...)``.
See :func:`ExpHeatmap.get_figure` for keyword arguments.
Parameters
----------
heatmap_k... | python | def get_figure(self, heatmap_kw=None, **kwargs):
"""Generate a plotly figure showing the matrix as a heatmap.
This is a shortcut for ``ExpMatrix.get_heatmap(...).get_figure(...)``.
See :func:`ExpHeatmap.get_figure` for keyword arguments.
Parameters
----------
heatmap_k... | [
"def",
"get_figure",
"(",
"self",
",",
"heatmap_kw",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"heatmap_kw",
"is",
"not",
"None",
":",
"assert",
"isinstance",
"(",
"heatmap_kw",
",",
"dict",
")",
"if",
"heatmap_kw",
"is",
"None",
":",
"heat... | Generate a plotly figure showing the matrix as a heatmap.
This is a shortcut for ``ExpMatrix.get_heatmap(...).get_figure(...)``.
See :func:`ExpHeatmap.get_figure` for keyword arguments.
Parameters
----------
heatmap_kw : dict or None
If not None, dictionary contain... | [
"Generate",
"a",
"plotly",
"figure",
"showing",
"the",
"matrix",
"as",
"a",
"heatmap",
"."
] | dd962bb26d60a0f14ca14d8c9a4dd75768962c7d | https://github.com/flo-compbio/genometools/blob/dd962bb26d60a0f14ca14d8c9a4dd75768962c7d/genometools/expression/matrix.py#L295-L319 |
55,452 | flo-compbio/genometools | genometools/expression/matrix.py | ExpMatrix.sort_genes | def sort_genes(self, stable=True, inplace=False, ascending=True):
"""Sort the rows of the matrix alphabetically by gene name.
Parameters
----------
stable: bool, optional
Whether to use a stable sorting algorithm. [True]
inplace: bool, optional
Whether to... | python | def sort_genes(self, stable=True, inplace=False, ascending=True):
"""Sort the rows of the matrix alphabetically by gene name.
Parameters
----------
stable: bool, optional
Whether to use a stable sorting algorithm. [True]
inplace: bool, optional
Whether to... | [
"def",
"sort_genes",
"(",
"self",
",",
"stable",
"=",
"True",
",",
"inplace",
"=",
"False",
",",
"ascending",
"=",
"True",
")",
":",
"kind",
"=",
"'quicksort'",
"if",
"stable",
":",
"kind",
"=",
"'mergesort'",
"return",
"self",
".",
"sort_index",
"(",
... | Sort the rows of the matrix alphabetically by gene name.
Parameters
----------
stable: bool, optional
Whether to use a stable sorting algorithm. [True]
inplace: bool, optional
Whether to perform the operation in place.[False]
ascending: bool, optional
... | [
"Sort",
"the",
"rows",
"of",
"the",
"matrix",
"alphabetically",
"by",
"gene",
"name",
"."
] | dd962bb26d60a0f14ca14d8c9a4dd75768962c7d | https://github.com/flo-compbio/genometools/blob/dd962bb26d60a0f14ca14d8c9a4dd75768962c7d/genometools/expression/matrix.py#L322-L342 |
55,453 | flo-compbio/genometools | genometools/expression/matrix.py | ExpMatrix.sort_samples | def sort_samples(self, stable=True, inplace=False, ascending=True):
"""Sort the columns of the matrix alphabetically by sample name.
Parameters
----------
stable: bool, optional
Whether to use a stable sorting algorithm. [True]
inplace: bool, optional
Whe... | python | def sort_samples(self, stable=True, inplace=False, ascending=True):
"""Sort the columns of the matrix alphabetically by sample name.
Parameters
----------
stable: bool, optional
Whether to use a stable sorting algorithm. [True]
inplace: bool, optional
Whe... | [
"def",
"sort_samples",
"(",
"self",
",",
"stable",
"=",
"True",
",",
"inplace",
"=",
"False",
",",
"ascending",
"=",
"True",
")",
":",
"kind",
"=",
"'quicksort'",
"if",
"stable",
":",
"kind",
"=",
"'mergesort'",
"return",
"self",
".",
"sort_index",
"(",
... | Sort the columns of the matrix alphabetically by sample name.
Parameters
----------
stable: bool, optional
Whether to use a stable sorting algorithm. [True]
inplace: bool, optional
Whether to perform the operation in place.[False]
ascending: bool, optiona... | [
"Sort",
"the",
"columns",
"of",
"the",
"matrix",
"alphabetically",
"by",
"sample",
"name",
"."
] | dd962bb26d60a0f14ca14d8c9a4dd75768962c7d | https://github.com/flo-compbio/genometools/blob/dd962bb26d60a0f14ca14d8c9a4dd75768962c7d/genometools/expression/matrix.py#L344-L365 |
55,454 | flo-compbio/genometools | genometools/expression/matrix.py | ExpMatrix.sample_correlations | def sample_correlations(self):
"""Returns an `ExpMatrix` containing all pairwise sample correlations.
Returns
-------
`ExpMatrix`
The sample correlation matrix.
"""
C = np.corrcoef(self.X.T)
corr_matrix = ExpMatrix(genes=self.samples, samples=self.sa... | python | def sample_correlations(self):
"""Returns an `ExpMatrix` containing all pairwise sample correlations.
Returns
-------
`ExpMatrix`
The sample correlation matrix.
"""
C = np.corrcoef(self.X.T)
corr_matrix = ExpMatrix(genes=self.samples, samples=self.sa... | [
"def",
"sample_correlations",
"(",
"self",
")",
":",
"C",
"=",
"np",
".",
"corrcoef",
"(",
"self",
".",
"X",
".",
"T",
")",
"corr_matrix",
"=",
"ExpMatrix",
"(",
"genes",
"=",
"self",
".",
"samples",
",",
"samples",
"=",
"self",
".",
"samples",
",",
... | Returns an `ExpMatrix` containing all pairwise sample correlations.
Returns
-------
`ExpMatrix`
The sample correlation matrix. | [
"Returns",
"an",
"ExpMatrix",
"containing",
"all",
"pairwise",
"sample",
"correlations",
"."
] | dd962bb26d60a0f14ca14d8c9a4dd75768962c7d | https://github.com/flo-compbio/genometools/blob/dd962bb26d60a0f14ca14d8c9a4dd75768962c7d/genometools/expression/matrix.py#L411-L422 |
55,455 | flo-compbio/genometools | genometools/expression/matrix.py | ExpMatrix.read_tsv | def read_tsv(cls, file_path: str, gene_table: ExpGeneTable = None,
encoding: str = 'UTF-8', sep: str = '\t'):
"""Read expression matrix from a tab-delimited text file.
Parameters
----------
file_path: str
The path of the text file.
gene_table: `ExpGe... | python | def read_tsv(cls, file_path: str, gene_table: ExpGeneTable = None,
encoding: str = 'UTF-8', sep: str = '\t'):
"""Read expression matrix from a tab-delimited text file.
Parameters
----------
file_path: str
The path of the text file.
gene_table: `ExpGe... | [
"def",
"read_tsv",
"(",
"cls",
",",
"file_path",
":",
"str",
",",
"gene_table",
":",
"ExpGeneTable",
"=",
"None",
",",
"encoding",
":",
"str",
"=",
"'UTF-8'",
",",
"sep",
":",
"str",
"=",
"'\\t'",
")",
":",
"# use pd.read_csv to parse the tsv file into a DataF... | Read expression matrix from a tab-delimited text file.
Parameters
----------
file_path: str
The path of the text file.
gene_table: `ExpGeneTable` object, optional
The set of valid genes. If given, the genes in the text file will
be filtered against th... | [
"Read",
"expression",
"matrix",
"from",
"a",
"tab",
"-",
"delimited",
"text",
"file",
"."
] | dd962bb26d60a0f14ca14d8c9a4dd75768962c7d | https://github.com/flo-compbio/genometools/blob/dd962bb26d60a0f14ca14d8c9a4dd75768962c7d/genometools/expression/matrix.py#L426-L466 |
55,456 | jvsteiner/merkletree | merkle.py | check_chain | def check_chain(chain):
"""Verify a merkle chain to see if the Merkle root can be reproduced.
"""
link = chain[0][0]
for i in range(1, len(chain) - 1):
if chain[i][1] == 'R':
link = hash_function(link + chain[i][0]).digest()
elif chain[i][1] == 'L':
link = hash_fu... | python | def check_chain(chain):
"""Verify a merkle chain to see if the Merkle root can be reproduced.
"""
link = chain[0][0]
for i in range(1, len(chain) - 1):
if chain[i][1] == 'R':
link = hash_function(link + chain[i][0]).digest()
elif chain[i][1] == 'L':
link = hash_fu... | [
"def",
"check_chain",
"(",
"chain",
")",
":",
"link",
"=",
"chain",
"[",
"0",
"]",
"[",
"0",
"]",
"for",
"i",
"in",
"range",
"(",
"1",
",",
"len",
"(",
"chain",
")",
"-",
"1",
")",
":",
"if",
"chain",
"[",
"i",
"]",
"[",
"1",
"]",
"==",
"... | Verify a merkle chain to see if the Merkle root can be reproduced. | [
"Verify",
"a",
"merkle",
"chain",
"to",
"see",
"if",
"the",
"Merkle",
"root",
"can",
"be",
"reproduced",
"."
] | 0d9284f9f90fab3b8c2ef4d356d0947719950bc2 | https://github.com/jvsteiner/merkletree/blob/0d9284f9f90fab3b8c2ef4d356d0947719950bc2/merkle.py#L174-L188 |
55,457 | jvsteiner/merkletree | merkle.py | check_hex_chain | def check_hex_chain(chain):
"""Verify a merkle chain, with hashes hex encoded, to see if the Merkle root can be reproduced.
"""
return codecs.encode(check_chain([(codecs.decode(i[0], 'hex_codec'), i[1]) for i in chain]), 'hex_codec') | python | def check_hex_chain(chain):
"""Verify a merkle chain, with hashes hex encoded, to see if the Merkle root can be reproduced.
"""
return codecs.encode(check_chain([(codecs.decode(i[0], 'hex_codec'), i[1]) for i in chain]), 'hex_codec') | [
"def",
"check_hex_chain",
"(",
"chain",
")",
":",
"return",
"codecs",
".",
"encode",
"(",
"check_chain",
"(",
"[",
"(",
"codecs",
".",
"decode",
"(",
"i",
"[",
"0",
"]",
",",
"'hex_codec'",
")",
",",
"i",
"[",
"1",
"]",
")",
"for",
"i",
"in",
"ch... | Verify a merkle chain, with hashes hex encoded, to see if the Merkle root can be reproduced. | [
"Verify",
"a",
"merkle",
"chain",
"with",
"hashes",
"hex",
"encoded",
"to",
"see",
"if",
"the",
"Merkle",
"root",
"can",
"be",
"reproduced",
"."
] | 0d9284f9f90fab3b8c2ef4d356d0947719950bc2 | https://github.com/jvsteiner/merkletree/blob/0d9284f9f90fab3b8c2ef4d356d0947719950bc2/merkle.py#L191-L194 |
55,458 | jvsteiner/merkletree | merkle.py | MerkleTree.add_hash | def add_hash(self, value):
"""Add a Node based on a precomputed, hex encoded, hash value.
"""
self.leaves.append(Node(codecs.decode(value, 'hex_codec'), prehashed=True)) | python | def add_hash(self, value):
"""Add a Node based on a precomputed, hex encoded, hash value.
"""
self.leaves.append(Node(codecs.decode(value, 'hex_codec'), prehashed=True)) | [
"def",
"add_hash",
"(",
"self",
",",
"value",
")",
":",
"self",
".",
"leaves",
".",
"append",
"(",
"Node",
"(",
"codecs",
".",
"decode",
"(",
"value",
",",
"'hex_codec'",
")",
",",
"prehashed",
"=",
"True",
")",
")"
] | Add a Node based on a precomputed, hex encoded, hash value. | [
"Add",
"a",
"Node",
"based",
"on",
"a",
"precomputed",
"hex",
"encoded",
"hash",
"value",
"."
] | 0d9284f9f90fab3b8c2ef4d356d0947719950bc2 | https://github.com/jvsteiner/merkletree/blob/0d9284f9f90fab3b8c2ef4d356d0947719950bc2/merkle.py#L57-L60 |
55,459 | jvsteiner/merkletree | merkle.py | MerkleTree.clear | def clear(self):
"""Clears the Merkle Tree by releasing the Merkle root and each leaf's references, the rest
should be garbage collected. This may be useful for situations where you want to take an existing
tree, make changes to the leaves, but leave it uncalculated for some time, without node
... | python | def clear(self):
"""Clears the Merkle Tree by releasing the Merkle root and each leaf's references, the rest
should be garbage collected. This may be useful for situations where you want to take an existing
tree, make changes to the leaves, but leave it uncalculated for some time, without node
... | [
"def",
"clear",
"(",
"self",
")",
":",
"self",
".",
"root",
"=",
"None",
"for",
"leaf",
"in",
"self",
".",
"leaves",
":",
"leaf",
".",
"p",
",",
"leaf",
".",
"sib",
",",
"leaf",
".",
"side",
"=",
"(",
"None",
",",
")",
"*",
"3"
] | Clears the Merkle Tree by releasing the Merkle root and each leaf's references, the rest
should be garbage collected. This may be useful for situations where you want to take an existing
tree, make changes to the leaves, but leave it uncalculated for some time, without node
references that are ... | [
"Clears",
"the",
"Merkle",
"Tree",
"by",
"releasing",
"the",
"Merkle",
"root",
"and",
"each",
"leaf",
"s",
"references",
"the",
"rest",
"should",
"be",
"garbage",
"collected",
".",
"This",
"may",
"be",
"useful",
"for",
"situations",
"where",
"you",
"want",
... | 0d9284f9f90fab3b8c2ef4d356d0947719950bc2 | https://github.com/jvsteiner/merkletree/blob/0d9284f9f90fab3b8c2ef4d356d0947719950bc2/merkle.py#L62-L71 |
55,460 | jvsteiner/merkletree | merkle.py | MerkleTree.build_fun | def build_fun(self, layer=None):
"""Calculate the merkle root and make references between nodes in the tree.
Written in functional style purely for fun.
"""
if not layer:
if not self.leaves:
raise MerkleError('The tree has no leaves and cannot be calculated.')... | python | def build_fun(self, layer=None):
"""Calculate the merkle root and make references between nodes in the tree.
Written in functional style purely for fun.
"""
if not layer:
if not self.leaves:
raise MerkleError('The tree has no leaves and cannot be calculated.')... | [
"def",
"build_fun",
"(",
"self",
",",
"layer",
"=",
"None",
")",
":",
"if",
"not",
"layer",
":",
"if",
"not",
"self",
".",
"leaves",
":",
"raise",
"MerkleError",
"(",
"'The tree has no leaves and cannot be calculated.'",
")",
"layer",
"=",
"self",
".",
"leav... | Calculate the merkle root and make references between nodes in the tree.
Written in functional style purely for fun. | [
"Calculate",
"the",
"merkle",
"root",
"and",
"make",
"references",
"between",
"nodes",
"in",
"the",
"tree",
".",
"Written",
"in",
"functional",
"style",
"purely",
"for",
"fun",
"."
] | 0d9284f9f90fab3b8c2ef4d356d0947719950bc2 | https://github.com/jvsteiner/merkletree/blob/0d9284f9f90fab3b8c2ef4d356d0947719950bc2/merkle.py#L84-L97 |
55,461 | jvsteiner/merkletree | merkle.py | MerkleTree._build | def _build(self, leaves):
"""Private helper function to create the next aggregation level and put all references in place.
"""
new, odd = [], None
# check if even number of leaves, promote odd leaf to next level, if not
if len(leaves) % 2 == 1:
odd = leaves.pop(-1)
... | python | def _build(self, leaves):
"""Private helper function to create the next aggregation level and put all references in place.
"""
new, odd = [], None
# check if even number of leaves, promote odd leaf to next level, if not
if len(leaves) % 2 == 1:
odd = leaves.pop(-1)
... | [
"def",
"_build",
"(",
"self",
",",
"leaves",
")",
":",
"new",
",",
"odd",
"=",
"[",
"]",
",",
"None",
"# check if even number of leaves, promote odd leaf to next level, if not",
"if",
"len",
"(",
"leaves",
")",
"%",
"2",
"==",
"1",
":",
"odd",
"=",
"leaves",... | Private helper function to create the next aggregation level and put all references in place. | [
"Private",
"helper",
"function",
"to",
"create",
"the",
"next",
"aggregation",
"level",
"and",
"put",
"all",
"references",
"in",
"place",
"."
] | 0d9284f9f90fab3b8c2ef4d356d0947719950bc2 | https://github.com/jvsteiner/merkletree/blob/0d9284f9f90fab3b8c2ef4d356d0947719950bc2/merkle.py#L99-L114 |
55,462 | jvsteiner/merkletree | merkle.py | MerkleTree.get_chain | def get_chain(self, index):
"""Assemble and return the chain leading from a given node to the merkle root of this tree.
"""
chain = []
this = self.leaves[index]
chain.append((this.val, 'SELF'))
while this.p:
chain.append((this.sib.val, this.sib.side))
... | python | def get_chain(self, index):
"""Assemble and return the chain leading from a given node to the merkle root of this tree.
"""
chain = []
this = self.leaves[index]
chain.append((this.val, 'SELF'))
while this.p:
chain.append((this.sib.val, this.sib.side))
... | [
"def",
"get_chain",
"(",
"self",
",",
"index",
")",
":",
"chain",
"=",
"[",
"]",
"this",
"=",
"self",
".",
"leaves",
"[",
"index",
"]",
"chain",
".",
"append",
"(",
"(",
"this",
".",
"val",
",",
"'SELF'",
")",
")",
"while",
"this",
".",
"p",
":... | Assemble and return the chain leading from a given node to the merkle root of this tree. | [
"Assemble",
"and",
"return",
"the",
"chain",
"leading",
"from",
"a",
"given",
"node",
"to",
"the",
"merkle",
"root",
"of",
"this",
"tree",
"."
] | 0d9284f9f90fab3b8c2ef4d356d0947719950bc2 | https://github.com/jvsteiner/merkletree/blob/0d9284f9f90fab3b8c2ef4d356d0947719950bc2/merkle.py#L116-L126 |
55,463 | jvsteiner/merkletree | merkle.py | MerkleTree.get_all_chains | def get_all_chains(self):
"""Assemble and return a list of all chains for all leaf nodes to the merkle root.
"""
return [self.get_chain(i) for i in range(len(self.leaves))] | python | def get_all_chains(self):
"""Assemble and return a list of all chains for all leaf nodes to the merkle root.
"""
return [self.get_chain(i) for i in range(len(self.leaves))] | [
"def",
"get_all_chains",
"(",
"self",
")",
":",
"return",
"[",
"self",
".",
"get_chain",
"(",
"i",
")",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"self",
".",
"leaves",
")",
")",
"]"
] | Assemble and return a list of all chains for all leaf nodes to the merkle root. | [
"Assemble",
"and",
"return",
"a",
"list",
"of",
"all",
"chains",
"for",
"all",
"leaf",
"nodes",
"to",
"the",
"merkle",
"root",
"."
] | 0d9284f9f90fab3b8c2ef4d356d0947719950bc2 | https://github.com/jvsteiner/merkletree/blob/0d9284f9f90fab3b8c2ef4d356d0947719950bc2/merkle.py#L128-L131 |
55,464 | jvsteiner/merkletree | merkle.py | MerkleTree.get_hex_chain | def get_hex_chain(self, index):
"""Assemble and return the chain leading from a given node to the merkle root of this tree
with hash values in hex form
"""
return [(codecs.encode(i[0], 'hex_codec'), i[1]) for i in self.get_chain(index)] | python | def get_hex_chain(self, index):
"""Assemble and return the chain leading from a given node to the merkle root of this tree
with hash values in hex form
"""
return [(codecs.encode(i[0], 'hex_codec'), i[1]) for i in self.get_chain(index)] | [
"def",
"get_hex_chain",
"(",
"self",
",",
"index",
")",
":",
"return",
"[",
"(",
"codecs",
".",
"encode",
"(",
"i",
"[",
"0",
"]",
",",
"'hex_codec'",
")",
",",
"i",
"[",
"1",
"]",
")",
"for",
"i",
"in",
"self",
".",
"get_chain",
"(",
"index",
... | Assemble and return the chain leading from a given node to the merkle root of this tree
with hash values in hex form | [
"Assemble",
"and",
"return",
"the",
"chain",
"leading",
"from",
"a",
"given",
"node",
"to",
"the",
"merkle",
"root",
"of",
"this",
"tree",
"with",
"hash",
"values",
"in",
"hex",
"form"
] | 0d9284f9f90fab3b8c2ef4d356d0947719950bc2 | https://github.com/jvsteiner/merkletree/blob/0d9284f9f90fab3b8c2ef4d356d0947719950bc2/merkle.py#L133-L137 |
55,465 | jvsteiner/merkletree | merkle.py | MerkleTree.get_all_hex_chains | def get_all_hex_chains(self):
"""Assemble and return a list of all chains for all nodes to the merkle root, hex encoded.
"""
return [[(codecs.encode(i[0], 'hex_codec'), i[1]) for i in j] for j in self.get_all_chains()] | python | def get_all_hex_chains(self):
"""Assemble and return a list of all chains for all nodes to the merkle root, hex encoded.
"""
return [[(codecs.encode(i[0], 'hex_codec'), i[1]) for i in j] for j in self.get_all_chains()] | [
"def",
"get_all_hex_chains",
"(",
"self",
")",
":",
"return",
"[",
"[",
"(",
"codecs",
".",
"encode",
"(",
"i",
"[",
"0",
"]",
",",
"'hex_codec'",
")",
",",
"i",
"[",
"1",
"]",
")",
"for",
"i",
"in",
"j",
"]",
"for",
"j",
"in",
"self",
".",
"... | Assemble and return a list of all chains for all nodes to the merkle root, hex encoded. | [
"Assemble",
"and",
"return",
"a",
"list",
"of",
"all",
"chains",
"for",
"all",
"nodes",
"to",
"the",
"merkle",
"root",
"hex",
"encoded",
"."
] | 0d9284f9f90fab3b8c2ef4d356d0947719950bc2 | https://github.com/jvsteiner/merkletree/blob/0d9284f9f90fab3b8c2ef4d356d0947719950bc2/merkle.py#L139-L142 |
55,466 | jvsteiner/merkletree | merkle.py | MerkleTree._get_whole_subtrees | def _get_whole_subtrees(self):
"""Returns an array of nodes in the tree that have balanced subtrees beneath them,
moving from left to right.
"""
subtrees = []
loose_leaves = len(self.leaves) - 2**int(log(len(self.leaves), 2))
the_node = self.root
while loose_leave... | python | def _get_whole_subtrees(self):
"""Returns an array of nodes in the tree that have balanced subtrees beneath them,
moving from left to right.
"""
subtrees = []
loose_leaves = len(self.leaves) - 2**int(log(len(self.leaves), 2))
the_node = self.root
while loose_leave... | [
"def",
"_get_whole_subtrees",
"(",
"self",
")",
":",
"subtrees",
"=",
"[",
"]",
"loose_leaves",
"=",
"len",
"(",
"self",
".",
"leaves",
")",
"-",
"2",
"**",
"int",
"(",
"log",
"(",
"len",
"(",
"self",
".",
"leaves",
")",
",",
"2",
")",
")",
"the_... | Returns an array of nodes in the tree that have balanced subtrees beneath them,
moving from left to right. | [
"Returns",
"an",
"array",
"of",
"nodes",
"in",
"the",
"tree",
"that",
"have",
"balanced",
"subtrees",
"beneath",
"them",
"moving",
"from",
"left",
"to",
"right",
"."
] | 0d9284f9f90fab3b8c2ef4d356d0947719950bc2 | https://github.com/jvsteiner/merkletree/blob/0d9284f9f90fab3b8c2ef4d356d0947719950bc2/merkle.py#L144-L156 |
55,467 | jvsteiner/merkletree | merkle.py | MerkleTree.add_adjust | def add_adjust(self, data, prehashed=False):
"""Add a new leaf, and adjust the tree, without rebuilding the whole thing.
"""
subtrees = self._get_whole_subtrees()
new_node = Node(data, prehashed=prehashed)
self.leaves.append(new_node)
for node in reversed(subtrees):
... | python | def add_adjust(self, data, prehashed=False):
"""Add a new leaf, and adjust the tree, without rebuilding the whole thing.
"""
subtrees = self._get_whole_subtrees()
new_node = Node(data, prehashed=prehashed)
self.leaves.append(new_node)
for node in reversed(subtrees):
... | [
"def",
"add_adjust",
"(",
"self",
",",
"data",
",",
"prehashed",
"=",
"False",
")",
":",
"subtrees",
"=",
"self",
".",
"_get_whole_subtrees",
"(",
")",
"new_node",
"=",
"Node",
"(",
"data",
",",
"prehashed",
"=",
"prehashed",
")",
"self",
".",
"leaves",
... | Add a new leaf, and adjust the tree, without rebuilding the whole thing. | [
"Add",
"a",
"new",
"leaf",
"and",
"adjust",
"the",
"tree",
"without",
"rebuilding",
"the",
"whole",
"thing",
"."
] | 0d9284f9f90fab3b8c2ef4d356d0947719950bc2 | https://github.com/jvsteiner/merkletree/blob/0d9284f9f90fab3b8c2ef4d356d0947719950bc2/merkle.py#L158-L171 |
55,468 | flo-compbio/genometools | genometools/enrichment/result.py | StaticGSEResult.fold_enrichment | def fold_enrichment(self):
"""Returns the fold enrichment of the gene set.
Fold enrichment is defined as ratio between the observed and the
expected number of gene set genes present.
"""
expected = self.K * (self.n/float(self.N))
return self.k / expected | python | def fold_enrichment(self):
"""Returns the fold enrichment of the gene set.
Fold enrichment is defined as ratio between the observed and the
expected number of gene set genes present.
"""
expected = self.K * (self.n/float(self.N))
return self.k / expected | [
"def",
"fold_enrichment",
"(",
"self",
")",
":",
"expected",
"=",
"self",
".",
"K",
"*",
"(",
"self",
".",
"n",
"/",
"float",
"(",
"self",
".",
"N",
")",
")",
"return",
"self",
".",
"k",
"/",
"expected"
] | Returns the fold enrichment of the gene set.
Fold enrichment is defined as ratio between the observed and the
expected number of gene set genes present. | [
"Returns",
"the",
"fold",
"enrichment",
"of",
"the",
"gene",
"set",
"."
] | dd962bb26d60a0f14ca14d8c9a4dd75768962c7d | https://github.com/flo-compbio/genometools/blob/dd962bb26d60a0f14ca14d8c9a4dd75768962c7d/genometools/enrichment/result.py#L112-L119 |
55,469 | flo-compbio/genometools | genometools/enrichment/result.py | StaticGSEResult.get_pretty_format | def get_pretty_format(self, max_name_length=0):
"""Returns a nicely formatted string describing the result.
Parameters
----------
max_name_length: int [0]
The maximum length of the gene set name (in characters). If the
gene set name is longer than this number, it... | python | def get_pretty_format(self, max_name_length=0):
"""Returns a nicely formatted string describing the result.
Parameters
----------
max_name_length: int [0]
The maximum length of the gene set name (in characters). If the
gene set name is longer than this number, it... | [
"def",
"get_pretty_format",
"(",
"self",
",",
"max_name_length",
"=",
"0",
")",
":",
"assert",
"isinstance",
"(",
"max_name_length",
",",
"(",
"int",
",",
"np",
".",
"integer",
")",
")",
"if",
"max_name_length",
"<",
"0",
"or",
"(",
"1",
"<=",
"max_name_... | Returns a nicely formatted string describing the result.
Parameters
----------
max_name_length: int [0]
The maximum length of the gene set name (in characters). If the
gene set name is longer than this number, it will be truncated and
"..." will be appended t... | [
"Returns",
"a",
"nicely",
"formatted",
"string",
"describing",
"the",
"result",
"."
] | dd962bb26d60a0f14ca14d8c9a4dd75768962c7d | https://github.com/flo-compbio/genometools/blob/dd962bb26d60a0f14ca14d8c9a4dd75768962c7d/genometools/enrichment/result.py#L121-L158 |
55,470 | acorg/dark-matter | bin/get-reads.py | main | def main(recordFilenames, fastaFilename, title, xRange, bitRange):
"""
Print reads that match in a specified X-axis and bit score range.
@param recordFilenames: A C{list} of C{str} file names contain results of a
BLAST run, in JSON format.
@param fastaFilename: The C{str} name of the FASTA file... | python | def main(recordFilenames, fastaFilename, title, xRange, bitRange):
"""
Print reads that match in a specified X-axis and bit score range.
@param recordFilenames: A C{list} of C{str} file names contain results of a
BLAST run, in JSON format.
@param fastaFilename: The C{str} name of the FASTA file... | [
"def",
"main",
"(",
"recordFilenames",
",",
"fastaFilename",
",",
"title",
",",
"xRange",
",",
"bitRange",
")",
":",
"reads",
"=",
"FastaReads",
"(",
"fastaFilename",
")",
"blastReadsAlignments",
"=",
"BlastReadsAlignments",
"(",
"reads",
",",
"recordFilenames",
... | Print reads that match in a specified X-axis and bit score range.
@param recordFilenames: A C{list} of C{str} file names contain results of a
BLAST run, in JSON format.
@param fastaFilename: The C{str} name of the FASTA file that was originally
BLASTed.
@param title: The C{str} title of the... | [
"Print",
"reads",
"that",
"match",
"in",
"a",
"specified",
"X",
"-",
"axis",
"and",
"bit",
"score",
"range",
"."
] | c78a1bf262667fa5db3548fa7066c4ec14d0551d | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/bin/get-reads.py#L14-L46 |
55,471 | biocommons/bioutils | src/bioutils/seqfetcher.py | fetch_seq | def fetch_seq(ac, start_i=None, end_i=None):
"""Fetches sequences and subsequences from NCBI eutils and Ensembl
REST interfaces.
:param string ac: accession of sequence to fetch
:param int start_i: start position of *interbase* interval
:param int end_i: end position of *interbase* interval
*... | python | def fetch_seq(ac, start_i=None, end_i=None):
"""Fetches sequences and subsequences from NCBI eutils and Ensembl
REST interfaces.
:param string ac: accession of sequence to fetch
:param int start_i: start position of *interbase* interval
:param int end_i: end position of *interbase* interval
*... | [
"def",
"fetch_seq",
"(",
"ac",
",",
"start_i",
"=",
"None",
",",
"end_i",
"=",
"None",
")",
":",
"ac_dispatch",
"=",
"[",
"{",
"\"re\"",
":",
"re",
".",
"compile",
"(",
"r\"^(?:AC|N[CGMPRTW])_|^[A-L]\\w\\d|^U\\d\"",
")",
",",
"\"fetcher\"",
":",
"_fetch_seq_... | Fetches sequences and subsequences from NCBI eutils and Ensembl
REST interfaces.
:param string ac: accession of sequence to fetch
:param int start_i: start position of *interbase* interval
:param int end_i: end position of *interbase* interval
**IMPORTANT** start_i and end_i specify 0-based inter... | [
"Fetches",
"sequences",
"and",
"subsequences",
"from",
"NCBI",
"eutils",
"and",
"Ensembl",
"REST",
"interfaces",
"."
] | 88bcbdfa707268fed1110800e91b6d4f8e9475a0 | https://github.com/biocommons/bioutils/blob/88bcbdfa707268fed1110800e91b6d4f8e9475a0/src/bioutils/seqfetcher.py#L24-L123 |
55,472 | biocommons/bioutils | src/bioutils/seqfetcher.py | _fetch_seq_ensembl | def _fetch_seq_ensembl(ac, start_i=None, end_i=None):
"""Fetch the specified sequence slice from Ensembl using the public
REST interface.
An interbase interval may be optionally provided with start_i and
end_i. However, the Ensembl REST interface does not currently
accept intervals, so the entire s... | python | def _fetch_seq_ensembl(ac, start_i=None, end_i=None):
"""Fetch the specified sequence slice from Ensembl using the public
REST interface.
An interbase interval may be optionally provided with start_i and
end_i. However, the Ensembl REST interface does not currently
accept intervals, so the entire s... | [
"def",
"_fetch_seq_ensembl",
"(",
"ac",
",",
"start_i",
"=",
"None",
",",
"end_i",
"=",
"None",
")",
":",
"url_fmt",
"=",
"\"http://rest.ensembl.org/sequence/id/{ac}\"",
"url",
"=",
"url_fmt",
".",
"format",
"(",
"ac",
"=",
"ac",
")",
"r",
"=",
"requests",
... | Fetch the specified sequence slice from Ensembl using the public
REST interface.
An interbase interval may be optionally provided with start_i and
end_i. However, the Ensembl REST interface does not currently
accept intervals, so the entire sequence is returned and sliced
locally.
>> len(_fetc... | [
"Fetch",
"the",
"specified",
"sequence",
"slice",
"from",
"Ensembl",
"using",
"the",
"public",
"REST",
"interface",
"."
] | 88bcbdfa707268fed1110800e91b6d4f8e9475a0 | https://github.com/biocommons/bioutils/blob/88bcbdfa707268fed1110800e91b6d4f8e9475a0/src/bioutils/seqfetcher.py#L130-L159 |
55,473 | biocommons/bioutils | src/bioutils/seqfetcher.py | _fetch_seq_ncbi | def _fetch_seq_ncbi(ac, start_i=None, end_i=None):
"""Fetch sequences from NCBI using the eutils interface.
An interbase interval may be optionally provided with start_i and
end_i. NCBI eutils will return just the requested subsequence,
which might greatly reduce payload sizes (especially with
chro... | python | def _fetch_seq_ncbi(ac, start_i=None, end_i=None):
"""Fetch sequences from NCBI using the eutils interface.
An interbase interval may be optionally provided with start_i and
end_i. NCBI eutils will return just the requested subsequence,
which might greatly reduce payload sizes (especially with
chro... | [
"def",
"_fetch_seq_ncbi",
"(",
"ac",
",",
"start_i",
"=",
"None",
",",
"end_i",
"=",
"None",
")",
":",
"db",
"=",
"\"protein\"",
"if",
"ac",
"[",
"1",
"]",
"==",
"\"P\"",
"else",
"\"nucleotide\"",
"url_fmt",
"=",
"(",
"\"https://eutils.ncbi.nlm.nih.gov/entre... | Fetch sequences from NCBI using the eutils interface.
An interbase interval may be optionally provided with start_i and
end_i. NCBI eutils will return just the requested subsequence,
which might greatly reduce payload sizes (especially with
chromosome-scale sequences).
The request includes `tool` ... | [
"Fetch",
"sequences",
"from",
"NCBI",
"using",
"the",
"eutils",
"interface",
"."
] | 88bcbdfa707268fed1110800e91b6d4f8e9475a0 | https://github.com/biocommons/bioutils/blob/88bcbdfa707268fed1110800e91b6d4f8e9475a0/src/bioutils/seqfetcher.py#L162-L226 |
55,474 | biocommons/bioutils | src/bioutils/seqfetcher.py | _add_eutils_api_key | def _add_eutils_api_key(url):
"""Adds eutils api key to the query
:param url: eutils url with a query string
:return: url with api_key parameter set to the value of environment
variable 'NCBI_API_KEY' if available
"""
apikey = os.environ.get("NCBI_API_KEY")
if apikey:
url += "&api_k... | python | def _add_eutils_api_key(url):
"""Adds eutils api key to the query
:param url: eutils url with a query string
:return: url with api_key parameter set to the value of environment
variable 'NCBI_API_KEY' if available
"""
apikey = os.environ.get("NCBI_API_KEY")
if apikey:
url += "&api_k... | [
"def",
"_add_eutils_api_key",
"(",
"url",
")",
":",
"apikey",
"=",
"os",
".",
"environ",
".",
"get",
"(",
"\"NCBI_API_KEY\"",
")",
"if",
"apikey",
":",
"url",
"+=",
"\"&api_key={apikey}\"",
".",
"format",
"(",
"apikey",
"=",
"apikey",
")",
"return",
"url"
... | Adds eutils api key to the query
:param url: eutils url with a query string
:return: url with api_key parameter set to the value of environment
variable 'NCBI_API_KEY' if available | [
"Adds",
"eutils",
"api",
"key",
"to",
"the",
"query"
] | 88bcbdfa707268fed1110800e91b6d4f8e9475a0 | https://github.com/biocommons/bioutils/blob/88bcbdfa707268fed1110800e91b6d4f8e9475a0/src/bioutils/seqfetcher.py#L229-L239 |
55,475 | nkavaldj/myhdl_lib | myhdl_lib/mem.py | rom | def rom(addr, dout, CONTENT):
''' CONTENT == tuple of non-sparse values '''
@always_comb
def read():
dout.next = CONTENT[int(addr)]
return read | python | def rom(addr, dout, CONTENT):
''' CONTENT == tuple of non-sparse values '''
@always_comb
def read():
dout.next = CONTENT[int(addr)]
return read | [
"def",
"rom",
"(",
"addr",
",",
"dout",
",",
"CONTENT",
")",
":",
"@",
"always_comb",
"def",
"read",
"(",
")",
":",
"dout",
".",
"next",
"=",
"CONTENT",
"[",
"int",
"(",
"addr",
")",
"]",
"return",
"read"
] | CONTENT == tuple of non-sparse values | [
"CONTENT",
"==",
"tuple",
"of",
"non",
"-",
"sparse",
"values"
] | 9902afd2031e7847373f692821b2135fd0810aa8 | https://github.com/nkavaldj/myhdl_lib/blob/9902afd2031e7847373f692821b2135fd0810aa8/myhdl_lib/mem.py#L3-L9 |
55,476 | disqus/overseer | overseer/models.py | Event.post_to_twitter | def post_to_twitter(self, message=None):
"""Update twitter status, i.e., post a tweet"""
consumer = oauth2.Consumer(key=conf.TWITTER_CONSUMER_KEY,
secret=conf.TWITTER_CONSUMER_SECRET)
token = oauth2.Token(key=conf.TWITTER_ACCESS_TOKEN, secret=conf.TWITTER_ACCES... | python | def post_to_twitter(self, message=None):
"""Update twitter status, i.e., post a tweet"""
consumer = oauth2.Consumer(key=conf.TWITTER_CONSUMER_KEY,
secret=conf.TWITTER_CONSUMER_SECRET)
token = oauth2.Token(key=conf.TWITTER_ACCESS_TOKEN, secret=conf.TWITTER_ACCES... | [
"def",
"post_to_twitter",
"(",
"self",
",",
"message",
"=",
"None",
")",
":",
"consumer",
"=",
"oauth2",
".",
"Consumer",
"(",
"key",
"=",
"conf",
".",
"TWITTER_CONSUMER_KEY",
",",
"secret",
"=",
"conf",
".",
"TWITTER_CONSUMER_SECRET",
")",
"token",
"=",
"... | Update twitter status, i.e., post a tweet | [
"Update",
"twitter",
"status",
"i",
".",
"e",
".",
"post",
"a",
"tweet"
] | b37573aba33b20aa86f89eb0c7e6f4d9905bedef | https://github.com/disqus/overseer/blob/b37573aba33b20aa86f89eb0c7e6f4d9905bedef/overseer/models.py#L176-L201 |
55,477 | flo-compbio/genometools | genometools/ebi/uniprot_goa.py | get_gaf_gene_ontology_file | def get_gaf_gene_ontology_file(path):
"""Extract the gene ontology file associated with a GO annotation file.
Parameters
----------
path: str
The path name of the GO annotation file.
Returns
-------
str
The URL of the associated gene ontology file.
"""
assert isinst... | python | def get_gaf_gene_ontology_file(path):
"""Extract the gene ontology file associated with a GO annotation file.
Parameters
----------
path: str
The path name of the GO annotation file.
Returns
-------
str
The URL of the associated gene ontology file.
"""
assert isinst... | [
"def",
"get_gaf_gene_ontology_file",
"(",
"path",
")",
":",
"assert",
"isinstance",
"(",
"path",
",",
"str",
")",
"version",
"=",
"None",
"with",
"misc",
".",
"smart_open_read",
"(",
"path",
",",
"encoding",
"=",
"'UTF-8'",
",",
"try_gzip",
"=",
"True",
")... | Extract the gene ontology file associated with a GO annotation file.
Parameters
----------
path: str
The path name of the GO annotation file.
Returns
-------
str
The URL of the associated gene ontology file. | [
"Extract",
"the",
"gene",
"ontology",
"file",
"associated",
"with",
"a",
"GO",
"annotation",
"file",
"."
] | dd962bb26d60a0f14ca14d8c9a4dd75768962c7d | https://github.com/flo-compbio/genometools/blob/dd962bb26d60a0f14ca14d8c9a4dd75768962c7d/genometools/ebi/uniprot_goa.py#L27-L50 |
55,478 | thunder-project/thunder-registration | registration/transforms.py | Displacement.apply | def apply(self, im):
"""
Apply an n-dimensional displacement by shifting an image or volume.
Parameters
----------
im : ndarray
The image or volume to shift
"""
from scipy.ndimage.interpolation import shift
return shift(im, map(lambda x: -x, s... | python | def apply(self, im):
"""
Apply an n-dimensional displacement by shifting an image or volume.
Parameters
----------
im : ndarray
The image or volume to shift
"""
from scipy.ndimage.interpolation import shift
return shift(im, map(lambda x: -x, s... | [
"def",
"apply",
"(",
"self",
",",
"im",
")",
":",
"from",
"scipy",
".",
"ndimage",
".",
"interpolation",
"import",
"shift",
"return",
"shift",
"(",
"im",
",",
"map",
"(",
"lambda",
"x",
":",
"-",
"x",
",",
"self",
".",
"delta",
")",
",",
"mode",
... | Apply an n-dimensional displacement by shifting an image or volume.
Parameters
----------
im : ndarray
The image or volume to shift | [
"Apply",
"an",
"n",
"-",
"dimensional",
"displacement",
"by",
"shifting",
"an",
"image",
"or",
"volume",
"."
] | 286f091e6c402d592e9686d4821e0fd80dbf86ec | https://github.com/thunder-project/thunder-registration/blob/286f091e6c402d592e9686d4821e0fd80dbf86ec/registration/transforms.py#L36-L46 |
55,479 | thunder-project/thunder-registration | registration/transforms.py | Displacement.compute | def compute(a, b):
"""
Compute an optimal displacement between two ndarrays.
Finds the displacement between two ndimensional arrays. Arrays must be
of the same size. Algorithm uses a cross correlation, computed efficiently
through an n-dimensional fft.
Parameters
... | python | def compute(a, b):
"""
Compute an optimal displacement between two ndarrays.
Finds the displacement between two ndimensional arrays. Arrays must be
of the same size. Algorithm uses a cross correlation, computed efficiently
through an n-dimensional fft.
Parameters
... | [
"def",
"compute",
"(",
"a",
",",
"b",
")",
":",
"from",
"numpy",
".",
"fft",
"import",
"rfftn",
",",
"irfftn",
"from",
"numpy",
"import",
"unravel_index",
",",
"argmax",
"# compute real-valued cross-correlation in fourier domain",
"s",
"=",
"a",
".",
"shape",
... | Compute an optimal displacement between two ndarrays.
Finds the displacement between two ndimensional arrays. Arrays must be
of the same size. Algorithm uses a cross correlation, computed efficiently
through an n-dimensional fft.
Parameters
----------
a : ndarray
... | [
"Compute",
"an",
"optimal",
"displacement",
"between",
"two",
"ndarrays",
"."
] | 286f091e6c402d592e9686d4821e0fd80dbf86ec | https://github.com/thunder-project/thunder-registration/blob/286f091e6c402d592e9686d4821e0fd80dbf86ec/registration/transforms.py#L49-L82 |
55,480 | thunder-project/thunder-registration | registration/transforms.py | LocalDisplacement.compute | def compute(a, b, axis):
"""
Finds optimal displacements localized along an axis
"""
delta = []
for aa, bb in zip(rollaxis(a, axis, 0), rollaxis(b, axis, 0)):
delta.append(Displacement.compute(aa, bb).delta)
return LocalDisplacement(delta, axis=axis) | python | def compute(a, b, axis):
"""
Finds optimal displacements localized along an axis
"""
delta = []
for aa, bb in zip(rollaxis(a, axis, 0), rollaxis(b, axis, 0)):
delta.append(Displacement.compute(aa, bb).delta)
return LocalDisplacement(delta, axis=axis) | [
"def",
"compute",
"(",
"a",
",",
"b",
",",
"axis",
")",
":",
"delta",
"=",
"[",
"]",
"for",
"aa",
",",
"bb",
"in",
"zip",
"(",
"rollaxis",
"(",
"a",
",",
"axis",
",",
"0",
")",
",",
"rollaxis",
"(",
"b",
",",
"axis",
",",
"0",
")",
")",
"... | Finds optimal displacements localized along an axis | [
"Finds",
"optimal",
"displacements",
"localized",
"along",
"an",
"axis"
] | 286f091e6c402d592e9686d4821e0fd80dbf86ec | https://github.com/thunder-project/thunder-registration/blob/286f091e6c402d592e9686d4821e0fd80dbf86ec/registration/transforms.py#L114-L121 |
55,481 | thunder-project/thunder-registration | registration/transforms.py | LocalDisplacement.apply | def apply(self, im):
"""
Apply axis-localized displacements.
Parameters
----------
im : ndarray
The image or volume to shift
"""
from scipy.ndimage.interpolation import shift
im = rollaxis(im, self.axis)
im.setflags(write=True)
... | python | def apply(self, im):
"""
Apply axis-localized displacements.
Parameters
----------
im : ndarray
The image or volume to shift
"""
from scipy.ndimage.interpolation import shift
im = rollaxis(im, self.axis)
im.setflags(write=True)
... | [
"def",
"apply",
"(",
"self",
",",
"im",
")",
":",
"from",
"scipy",
".",
"ndimage",
".",
"interpolation",
"import",
"shift",
"im",
"=",
"rollaxis",
"(",
"im",
",",
"self",
".",
"axis",
")",
"im",
".",
"setflags",
"(",
"write",
"=",
"True",
")",
"for... | Apply axis-localized displacements.
Parameters
----------
im : ndarray
The image or volume to shift | [
"Apply",
"axis",
"-",
"localized",
"displacements",
"."
] | 286f091e6c402d592e9686d4821e0fd80dbf86ec | https://github.com/thunder-project/thunder-registration/blob/286f091e6c402d592e9686d4821e0fd80dbf86ec/registration/transforms.py#L123-L139 |
55,482 | flo-compbio/genometools | genometools/ncbi/geo/functions.py | write_sample_sheet | def write_sample_sheet(output_file, accessions, names, celfile_urls, sel=None):
"""Generate a sample sheet in tab-separated text format.
The columns contain the following sample attributes:
1) accession
2) name
3) CEL file name
4) CEL file URL
Parameters
----------
output_file: str... | python | def write_sample_sheet(output_file, accessions, names, celfile_urls, sel=None):
"""Generate a sample sheet in tab-separated text format.
The columns contain the following sample attributes:
1) accession
2) name
3) CEL file name
4) CEL file URL
Parameters
----------
output_file: str... | [
"def",
"write_sample_sheet",
"(",
"output_file",
",",
"accessions",
",",
"names",
",",
"celfile_urls",
",",
"sel",
"=",
"None",
")",
":",
"assert",
"isinstance",
"(",
"output_file",
",",
"str",
")",
"assert",
"isinstance",
"(",
"accessions",
",",
"(",
"list"... | Generate a sample sheet in tab-separated text format.
The columns contain the following sample attributes:
1) accession
2) name
3) CEL file name
4) CEL file URL
Parameters
----------
output_file: str
The path of the output file.
accessions: list or tuple of str
The ... | [
"Generate",
"a",
"sample",
"sheet",
"in",
"tab",
"-",
"separated",
"text",
"format",
"."
] | dd962bb26d60a0f14ca14d8c9a4dd75768962c7d | https://github.com/flo-compbio/genometools/blob/dd962bb26d60a0f14ca14d8c9a4dd75768962c7d/genometools/ncbi/geo/functions.py#L83-L137 |
55,483 | acorg/dark-matter | dark/html.py | NCBISequenceLinkURL | def NCBISequenceLinkURL(title, default=None):
"""
Given a sequence title, like "gi|42768646|gb|AY516849.1| Homo sapiens",
return the URL of a link to the info page at NCBI.
title: the sequence title to produce a link URL for.
default: the value to return if the title cannot be parsed.
"""
t... | python | def NCBISequenceLinkURL(title, default=None):
"""
Given a sequence title, like "gi|42768646|gb|AY516849.1| Homo sapiens",
return the URL of a link to the info page at NCBI.
title: the sequence title to produce a link URL for.
default: the value to return if the title cannot be parsed.
"""
t... | [
"def",
"NCBISequenceLinkURL",
"(",
"title",
",",
"default",
"=",
"None",
")",
":",
"try",
":",
"ref",
"=",
"title",
".",
"split",
"(",
"'|'",
")",
"[",
"3",
"]",
".",
"split",
"(",
"'.'",
")",
"[",
"0",
"]",
"except",
"IndexError",
":",
"return",
... | Given a sequence title, like "gi|42768646|gb|AY516849.1| Homo sapiens",
return the URL of a link to the info page at NCBI.
title: the sequence title to produce a link URL for.
default: the value to return if the title cannot be parsed. | [
"Given",
"a",
"sequence",
"title",
"like",
"gi|42768646|gb|AY516849",
".",
"1|",
"Homo",
"sapiens",
"return",
"the",
"URL",
"of",
"a",
"link",
"to",
"the",
"info",
"page",
"at",
"NCBI",
"."
] | c78a1bf262667fa5db3548fa7066c4ec14d0551d | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/html.py#L8-L21 |
55,484 | acorg/dark-matter | dark/html.py | NCBISequenceLink | def NCBISequenceLink(title, default=None):
"""
Given a sequence title, like "gi|42768646|gb|AY516849.1| Homo sapiens",
return an HTML A tag dispalying a link to the info page at NCBI.
title: the sequence title to produce an HTML link for.
default: the value to return if the title cannot be parsed.
... | python | def NCBISequenceLink(title, default=None):
"""
Given a sequence title, like "gi|42768646|gb|AY516849.1| Homo sapiens",
return an HTML A tag dispalying a link to the info page at NCBI.
title: the sequence title to produce an HTML link for.
default: the value to return if the title cannot be parsed.
... | [
"def",
"NCBISequenceLink",
"(",
"title",
",",
"default",
"=",
"None",
")",
":",
"url",
"=",
"NCBISequenceLinkURL",
"(",
"title",
")",
"if",
"url",
"is",
"None",
":",
"return",
"default",
"else",
":",
"return",
"'<a href=\"%s\" target=\"_blank\">%s</a>'",
"%",
... | Given a sequence title, like "gi|42768646|gb|AY516849.1| Homo sapiens",
return an HTML A tag dispalying a link to the info page at NCBI.
title: the sequence title to produce an HTML link for.
default: the value to return if the title cannot be parsed. | [
"Given",
"a",
"sequence",
"title",
"like",
"gi|42768646|gb|AY516849",
".",
"1|",
"Homo",
"sapiens",
"return",
"an",
"HTML",
"A",
"tag",
"dispalying",
"a",
"link",
"to",
"the",
"info",
"page",
"at",
"NCBI",
"."
] | c78a1bf262667fa5db3548fa7066c4ec14d0551d | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/html.py#L24-L36 |
55,485 | acorg/dark-matter | dark/html.py | AlignmentPanelHTMLWriter._writeFASTA | def _writeFASTA(self, i, image):
"""
Write a FASTA file containing the set of reads that hit a sequence.
@param i: The number of the image in self._images.
@param image: A member of self._images.
@return: A C{str}, either 'fasta' or 'fastq' indicating the format
of t... | python | def _writeFASTA(self, i, image):
"""
Write a FASTA file containing the set of reads that hit a sequence.
@param i: The number of the image in self._images.
@param image: A member of self._images.
@return: A C{str}, either 'fasta' or 'fastq' indicating the format
of t... | [
"def",
"_writeFASTA",
"(",
"self",
",",
"i",
",",
"image",
")",
":",
"if",
"isinstance",
"(",
"self",
".",
"_titlesAlignments",
".",
"readsAlignments",
".",
"reads",
",",
"FastqReads",
")",
":",
"format_",
"=",
"'fastq'",
"else",
":",
"format_",
"=",
"'f... | Write a FASTA file containing the set of reads that hit a sequence.
@param i: The number of the image in self._images.
@param image: A member of self._images.
@return: A C{str}, either 'fasta' or 'fastq' indicating the format
of the reads in C{self._titlesAlignments}. | [
"Write",
"a",
"FASTA",
"file",
"containing",
"the",
"set",
"of",
"reads",
"that",
"hit",
"a",
"sequence",
"."
] | c78a1bf262667fa5db3548fa7066c4ec14d0551d | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/html.py#L274-L293 |
55,486 | acorg/dark-matter | dark/html.py | AlignmentPanelHTMLWriter._writeFeatures | def _writeFeatures(self, i, image):
"""
Write a text file containing the features as a table.
@param i: The number of the image in self._images.
@param image: A member of self._images.
@return: The C{str} features file name - just the base name, not
including the pat... | python | def _writeFeatures(self, i, image):
"""
Write a text file containing the features as a table.
@param i: The number of the image in self._images.
@param image: A member of self._images.
@return: The C{str} features file name - just the base name, not
including the pat... | [
"def",
"_writeFeatures",
"(",
"self",
",",
"i",
",",
"image",
")",
":",
"basename",
"=",
"'features-%d.txt'",
"%",
"i",
"filename",
"=",
"'%s/%s'",
"%",
"(",
"self",
".",
"_outputDir",
",",
"basename",
")",
"featureList",
"=",
"image",
"[",
"'graphInfo'",
... | Write a text file containing the features as a table.
@param i: The number of the image in self._images.
@param image: A member of self._images.
@return: The C{str} features file name - just the base name, not
including the path to the file. | [
"Write",
"a",
"text",
"file",
"containing",
"the",
"features",
"as",
"a",
"table",
"."
] | c78a1bf262667fa5db3548fa7066c4ec14d0551d | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/html.py#L295-L310 |
55,487 | kyegupov/py-unrar2 | UnRAR2/windows.py | DosDateTimeToTimeTuple | def DosDateTimeToTimeTuple(dosDateTime):
"""Convert an MS-DOS format date time to a Python time tuple.
"""
dos_date = dosDateTime >> 16
dos_time = dosDateTime & 0xffff
day = dos_date & 0x1f
month = (dos_date >> 5) & 0xf
year = 1980 + (dos_date >> 9)
second = 2 * (dos_time & 0x1f)
min... | python | def DosDateTimeToTimeTuple(dosDateTime):
"""Convert an MS-DOS format date time to a Python time tuple.
"""
dos_date = dosDateTime >> 16
dos_time = dosDateTime & 0xffff
day = dos_date & 0x1f
month = (dos_date >> 5) & 0xf
year = 1980 + (dos_date >> 9)
second = 2 * (dos_time & 0x1f)
min... | [
"def",
"DosDateTimeToTimeTuple",
"(",
"dosDateTime",
")",
":",
"dos_date",
"=",
"dosDateTime",
">>",
"16",
"dos_time",
"=",
"dosDateTime",
"&",
"0xffff",
"day",
"=",
"dos_date",
"&",
"0x1f",
"month",
"=",
"(",
"dos_date",
">>",
"5",
")",
"&",
"0xf",
"year"... | Convert an MS-DOS format date time to a Python time tuple. | [
"Convert",
"an",
"MS",
"-",
"DOS",
"format",
"date",
"time",
"to",
"a",
"Python",
"time",
"tuple",
"."
] | 186a4c1feb9ef3d96a2331f8fb3ebf88036e15e5 | https://github.com/kyegupov/py-unrar2/blob/186a4c1feb9ef3d96a2331f8fb3ebf88036e15e5/UnRAR2/windows.py#L150-L162 |
55,488 | acorg/dark-matter | dark/blast/score.py | bitScoreToEValue | def bitScoreToEValue(bitScore, dbSize, dbSequenceCount, queryLength,
lengthAdjustment):
"""
Convert a bit score to an e-value.
@param bitScore: The C{float} bit score to convert.
@param dbSize: The C{int} total size of the database (i.e., the sum of
the lengths of all seque... | python | def bitScoreToEValue(bitScore, dbSize, dbSequenceCount, queryLength,
lengthAdjustment):
"""
Convert a bit score to an e-value.
@param bitScore: The C{float} bit score to convert.
@param dbSize: The C{int} total size of the database (i.e., the sum of
the lengths of all seque... | [
"def",
"bitScoreToEValue",
"(",
"bitScore",
",",
"dbSize",
",",
"dbSequenceCount",
",",
"queryLength",
",",
"lengthAdjustment",
")",
":",
"effectiveDbSize",
"=",
"(",
"(",
"dbSize",
"-",
"dbSequenceCount",
"*",
"lengthAdjustment",
")",
"*",
"(",
"queryLength",
"... | Convert a bit score to an e-value.
@param bitScore: The C{float} bit score to convert.
@param dbSize: The C{int} total size of the database (i.e., the sum of
the lengths of all sequences in the BLAST database).
@param dbSequenceCount: The C{int} number of sequences in the database.
@param query... | [
"Convert",
"a",
"bit",
"score",
"to",
"an",
"e",
"-",
"value",
"."
] | c78a1bf262667fa5db3548fa7066c4ec14d0551d | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/blast/score.py#L24-L42 |
55,489 | acorg/dark-matter | dark/blast/score.py | eValueToBitScore | def eValueToBitScore(eValue, dbSize, dbSequenceCount, queryLength,
lengthAdjustment):
"""
Convert an e-value to a bit score.
@param eValue: The C{float} e-value to convert.
@param dbSize: The C{int} total size of the database (i.e., the sum of
the lengths of all sequences i... | python | def eValueToBitScore(eValue, dbSize, dbSequenceCount, queryLength,
lengthAdjustment):
"""
Convert an e-value to a bit score.
@param eValue: The C{float} e-value to convert.
@param dbSize: The C{int} total size of the database (i.e., the sum of
the lengths of all sequences i... | [
"def",
"eValueToBitScore",
"(",
"eValue",
",",
"dbSize",
",",
"dbSequenceCount",
",",
"queryLength",
",",
"lengthAdjustment",
")",
":",
"effectiveDbSize",
"=",
"(",
"(",
"dbSize",
"-",
"dbSequenceCount",
"*",
"lengthAdjustment",
")",
"*",
"(",
"queryLength",
"-"... | Convert an e-value to a bit score.
@param eValue: The C{float} e-value to convert.
@param dbSize: The C{int} total size of the database (i.e., the sum of
the lengths of all sequences in the BLAST database).
@param dbSequenceCount: The C{int} number of sequences in the database.
@param queryLeng... | [
"Convert",
"an",
"e",
"-",
"value",
"to",
"a",
"bit",
"score",
"."
] | c78a1bf262667fa5db3548fa7066c4ec14d0551d | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/blast/score.py#L45-L63 |
55,490 | acorg/dark-matter | dark/btop.py | parseBtop | def parseBtop(btopString):
"""
Parse a BTOP string.
The format is described at https://www.ncbi.nlm.nih.gov/books/NBK279682/
@param btopString: A C{str} BTOP sequence.
@raise ValueError: If C{btopString} is not valid BTOP.
@return: A generator that yields a series of integers and 2-tuples of
... | python | def parseBtop(btopString):
"""
Parse a BTOP string.
The format is described at https://www.ncbi.nlm.nih.gov/books/NBK279682/
@param btopString: A C{str} BTOP sequence.
@raise ValueError: If C{btopString} is not valid BTOP.
@return: A generator that yields a series of integers and 2-tuples of
... | [
"def",
"parseBtop",
"(",
"btopString",
")",
":",
"isdigit",
"=",
"str",
".",
"isdigit",
"value",
"=",
"None",
"queryLetter",
"=",
"None",
"for",
"offset",
",",
"char",
"in",
"enumerate",
"(",
"btopString",
")",
":",
"if",
"isdigit",
"(",
"char",
")",
"... | Parse a BTOP string.
The format is described at https://www.ncbi.nlm.nih.gov/books/NBK279682/
@param btopString: A C{str} BTOP sequence.
@raise ValueError: If C{btopString} is not valid BTOP.
@return: A generator that yields a series of integers and 2-tuples of
letters, as found in the BTOP st... | [
"Parse",
"a",
"BTOP",
"string",
"."
] | c78a1bf262667fa5db3548fa7066c4ec14d0551d | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/btop.py#L5-L53 |
55,491 | acorg/dark-matter | dark/btop.py | countGaps | def countGaps(btopString):
"""
Count the query and subject gaps in a BTOP string.
@param btopString: A C{str} BTOP sequence.
@raise ValueError: If L{parseBtop} finds an error in the BTOP string
C{btopString}.
@return: A 2-tuple of C{int}s, with the (query, subject) gaps counts as
fo... | python | def countGaps(btopString):
"""
Count the query and subject gaps in a BTOP string.
@param btopString: A C{str} BTOP sequence.
@raise ValueError: If L{parseBtop} finds an error in the BTOP string
C{btopString}.
@return: A 2-tuple of C{int}s, with the (query, subject) gaps counts as
fo... | [
"def",
"countGaps",
"(",
"btopString",
")",
":",
"queryGaps",
"=",
"subjectGaps",
"=",
"0",
"for",
"countOrMismatch",
"in",
"parseBtop",
"(",
"btopString",
")",
":",
"if",
"isinstance",
"(",
"countOrMismatch",
",",
"tuple",
")",
":",
"queryChar",
",",
"subje... | Count the query and subject gaps in a BTOP string.
@param btopString: A C{str} BTOP sequence.
@raise ValueError: If L{parseBtop} finds an error in the BTOP string
C{btopString}.
@return: A 2-tuple of C{int}s, with the (query, subject) gaps counts as
found in C{btopString}. | [
"Count",
"the",
"query",
"and",
"subject",
"gaps",
"in",
"a",
"BTOP",
"string",
"."
] | c78a1bf262667fa5db3548fa7066c4ec14d0551d | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/btop.py#L56-L73 |
55,492 | acorg/dark-matter | dark/btop.py | btop2cigar | def btop2cigar(btopString, concise=False, aa=False):
"""
Convert a BTOP string to a CIGAR string.
@param btopString: A C{str} BTOP sequence.
@param concise: If C{True}, use 'M' for matches and mismatches instead
of the more specific 'X' and '='.
@param aa: If C{True}, C{btopString} will be ... | python | def btop2cigar(btopString, concise=False, aa=False):
"""
Convert a BTOP string to a CIGAR string.
@param btopString: A C{str} BTOP sequence.
@param concise: If C{True}, use 'M' for matches and mismatches instead
of the more specific 'X' and '='.
@param aa: If C{True}, C{btopString} will be ... | [
"def",
"btop2cigar",
"(",
"btopString",
",",
"concise",
"=",
"False",
",",
"aa",
"=",
"False",
")",
":",
"if",
"aa",
"and",
"concise",
":",
"raise",
"ValueError",
"(",
"'aa and concise cannot both be True'",
")",
"result",
"=",
"[",
"]",
"thisLength",
"=",
... | Convert a BTOP string to a CIGAR string.
@param btopString: A C{str} BTOP sequence.
@param concise: If C{True}, use 'M' for matches and mismatches instead
of the more specific 'X' and '='.
@param aa: If C{True}, C{btopString} will be interpreted as though it
refers to amino acids (as in the... | [
"Convert",
"a",
"BTOP",
"string",
"to",
"a",
"CIGAR",
"string",
"."
] | c78a1bf262667fa5db3548fa7066c4ec14d0551d | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/btop.py#L76-L142 |
55,493 | Peter-Slump/django-dynamic-fixtures | src/dynamic_fixtures/management/commands/load_dynamic_fixtures.py | Command.progress_callback | def progress_callback(self, action, node, elapsed_time=None):
"""
Callback to report progress
:param str action:
:param list node: app, module
:param int | None elapsed_time:
"""
if action == 'load_start':
self.stdout.write('Loading fixture {}.{}...'.... | python | def progress_callback(self, action, node, elapsed_time=None):
"""
Callback to report progress
:param str action:
:param list node: app, module
:param int | None elapsed_time:
"""
if action == 'load_start':
self.stdout.write('Loading fixture {}.{}...'.... | [
"def",
"progress_callback",
"(",
"self",
",",
"action",
",",
"node",
",",
"elapsed_time",
"=",
"None",
")",
":",
"if",
"action",
"==",
"'load_start'",
":",
"self",
".",
"stdout",
".",
"write",
"(",
"'Loading fixture {}.{}...'",
".",
"format",
"(",
"*",
"no... | Callback to report progress
:param str action:
:param list node: app, module
:param int | None elapsed_time: | [
"Callback",
"to",
"report",
"progress"
] | da99b4b12b11be28ea4b36b6cf2896ca449c73c1 | https://github.com/Peter-Slump/django-dynamic-fixtures/blob/da99b4b12b11be28ea4b36b6cf2896ca449c73c1/src/dynamic_fixtures/management/commands/load_dynamic_fixtures.py#L61-L78 |
55,494 | flo-compbio/genometools | genometools/ontology/term.py | GOTerm.get_pretty_format | def get_pretty_format(self, include_id=True, max_name_length=0,
abbreviate=True):
"""Returns a nicely formatted string with the GO term information.
Parameters
----------
include_id: bool, optional
Include the GO term ID.
max_name_length: in... | python | def get_pretty_format(self, include_id=True, max_name_length=0,
abbreviate=True):
"""Returns a nicely formatted string with the GO term information.
Parameters
----------
include_id: bool, optional
Include the GO term ID.
max_name_length: in... | [
"def",
"get_pretty_format",
"(",
"self",
",",
"include_id",
"=",
"True",
",",
"max_name_length",
"=",
"0",
",",
"abbreviate",
"=",
"True",
")",
":",
"name",
"=",
"self",
".",
"name",
"if",
"abbreviate",
":",
"for",
"abb",
"in",
"self",
".",
"_abbrev",
... | Returns a nicely formatted string with the GO term information.
Parameters
----------
include_id: bool, optional
Include the GO term ID.
max_name_length: int, optional
Truncate the formatted string so that its total length does not
exceed this value.
... | [
"Returns",
"a",
"nicely",
"formatted",
"string",
"with",
"the",
"GO",
"term",
"information",
"."
] | dd962bb26d60a0f14ca14d8c9a4dd75768962c7d | https://github.com/flo-compbio/genometools/blob/dd962bb26d60a0f14ca14d8c9a4dd75768962c7d/genometools/ontology/term.py#L196-L225 |
55,495 | acorg/dark-matter | dark/hsp.py | HSP.toDict | def toDict(self):
"""
Get information about the HSP as a dictionary.
@return: A C{dict} representation of the HSP.
"""
result = _Base.toDict(self)
result['score'] = self.score.score
return result | python | def toDict(self):
"""
Get information about the HSP as a dictionary.
@return: A C{dict} representation of the HSP.
"""
result = _Base.toDict(self)
result['score'] = self.score.score
return result | [
"def",
"toDict",
"(",
"self",
")",
":",
"result",
"=",
"_Base",
".",
"toDict",
"(",
"self",
")",
"result",
"[",
"'score'",
"]",
"=",
"self",
".",
"score",
".",
"score",
"return",
"result"
] | Get information about the HSP as a dictionary.
@return: A C{dict} representation of the HSP. | [
"Get",
"information",
"about",
"the",
"HSP",
"as",
"a",
"dictionary",
"."
] | c78a1bf262667fa5db3548fa7066c4ec14d0551d | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/hsp.py#L133-L141 |
55,496 | flo-compbio/genometools | genometools/ensembl/filter_fasta.py | get_argument_parser | def get_argument_parser():
"""Returns an argument parser object for the script."""
desc = 'Filter FASTA file by chromosome names.'
parser = cli.get_argument_parser(desc=desc)
parser.add_argument(
'-f', '--fasta-file', default='-', type=str, help=textwrap.dedent("""\
Path of the... | python | def get_argument_parser():
"""Returns an argument parser object for the script."""
desc = 'Filter FASTA file by chromosome names.'
parser = cli.get_argument_parser(desc=desc)
parser.add_argument(
'-f', '--fasta-file', default='-', type=str, help=textwrap.dedent("""\
Path of the... | [
"def",
"get_argument_parser",
"(",
")",
":",
"desc",
"=",
"'Filter FASTA file by chromosome names.'",
"parser",
"=",
"cli",
".",
"get_argument_parser",
"(",
"desc",
"=",
"desc",
")",
"parser",
".",
"add_argument",
"(",
"'-f'",
",",
"'--fasta-file'",
",",
"default"... | Returns an argument parser object for the script. | [
"Returns",
"an",
"argument",
"parser",
"object",
"for",
"the",
"script",
"."
] | dd962bb26d60a0f14ca14d8c9a4dd75768962c7d | https://github.com/flo-compbio/genometools/blob/dd962bb26d60a0f14ca14d8c9a4dd75768962c7d/genometools/ensembl/filter_fasta.py#L49-L84 |
55,497 | flo-compbio/genometools | genometools/ensembl/filter_fasta.py | main | def main(args=None):
"""Script body."""
if args is None:
# parse command-line arguments
parser = get_argument_parser()
args = parser.parse_args()
fasta_file = args.fasta_file
species = args.species
chrom_pat = args.chromosome_pattern
output_file = args.output_file
... | python | def main(args=None):
"""Script body."""
if args is None:
# parse command-line arguments
parser = get_argument_parser()
args = parser.parse_args()
fasta_file = args.fasta_file
species = args.species
chrom_pat = args.chromosome_pattern
output_file = args.output_file
... | [
"def",
"main",
"(",
"args",
"=",
"None",
")",
":",
"if",
"args",
"is",
"None",
":",
"# parse command-line arguments ",
"parser",
"=",
"get_argument_parser",
"(",
")",
"args",
"=",
"parser",
".",
"parse_args",
"(",
")",
"fasta_file",
"=",
"args",
".",
"fast... | Script body. | [
"Script",
"body",
"."
] | dd962bb26d60a0f14ca14d8c9a4dd75768962c7d | https://github.com/flo-compbio/genometools/blob/dd962bb26d60a0f14ca14d8c9a4dd75768962c7d/genometools/ensembl/filter_fasta.py#L87-L139 |
55,498 | openfisca/openfisca-web-api | openfisca_web_api/application.py | make_app | def make_app(global_conf, **app_conf):
"""Create a WSGI application and return it
``global_conf``
The inherited configuration for this application. Normally from
the [DEFAULT] section of the Paste ini file.
``app_conf``
The application's local configuration. Normally specified in
... | python | def make_app(global_conf, **app_conf):
"""Create a WSGI application and return it
``global_conf``
The inherited configuration for this application. Normally from
the [DEFAULT] section of the Paste ini file.
``app_conf``
The application's local configuration. Normally specified in
... | [
"def",
"make_app",
"(",
"global_conf",
",",
"*",
"*",
"app_conf",
")",
":",
"# Configure the environment and fill conf dictionary.",
"environment",
".",
"load_environment",
"(",
"global_conf",
",",
"app_conf",
")",
"# Dispatch request to controllers.",
"app",
"=",
"contro... | Create a WSGI application and return it
``global_conf``
The inherited configuration for this application. Normally from
the [DEFAULT] section of the Paste ini file.
``app_conf``
The application's local configuration. Normally specified in
the [app:<name>] section of the Paste i... | [
"Create",
"a",
"WSGI",
"application",
"and",
"return",
"it"
] | d1cd3bfacac338e80bb0df7e0465b65649dd893b | https://github.com/openfisca/openfisca-web-api/blob/d1cd3bfacac338e80bb0df7e0465b65649dd893b/openfisca_web_api/application.py#L58-L103 |
55,499 | acorg/dark-matter | dark/dimension.py | dimensionalIterator | def dimensionalIterator(dimensions, maxItems=-1):
"""
Given a list of n positive integers, return a generator that yields
n-tuples of coordinates to 'fill' the dimensions. This is like an
odometer in a car, but the dimensions do not each have to be 10.
For example: dimensionalIterator((2, 3)) will ... | python | def dimensionalIterator(dimensions, maxItems=-1):
"""
Given a list of n positive integers, return a generator that yields
n-tuples of coordinates to 'fill' the dimensions. This is like an
odometer in a car, but the dimensions do not each have to be 10.
For example: dimensionalIterator((2, 3)) will ... | [
"def",
"dimensionalIterator",
"(",
"dimensions",
",",
"maxItems",
"=",
"-",
"1",
")",
":",
"nDimensions",
"=",
"len",
"(",
"dimensions",
")",
"if",
"nDimensions",
"==",
"0",
"or",
"maxItems",
"==",
"0",
":",
"return",
"if",
"any",
"(",
"map",
"(",
"lam... | Given a list of n positive integers, return a generator that yields
n-tuples of coordinates to 'fill' the dimensions. This is like an
odometer in a car, but the dimensions do not each have to be 10.
For example: dimensionalIterator((2, 3)) will yield in order
(0, 0), (0, 1), (0, 2), (1, 0), (1, 1), (1,... | [
"Given",
"a",
"list",
"of",
"n",
"positive",
"integers",
"return",
"a",
"generator",
"that",
"yields",
"n",
"-",
"tuples",
"of",
"coordinates",
"to",
"fill",
"the",
"dimensions",
".",
"This",
"is",
"like",
"an",
"odometer",
"in",
"a",
"car",
"but",
"the"... | c78a1bf262667fa5db3548fa7066c4ec14d0551d | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/dimension.py#L1-L34 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.