partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
train | main | Usage: pre-sugartex [OPTIONS]
Reads from stdin and writes to stdout.
When no options: only replace
U+02CE Modifier Letter Low Grave Accent
(that looks like low '`') with $
Options:
--all Full SugarTeX replace with regexp,
--kiwi Same as above but with kiwi flavor,
--... | sugartex/pre_sugartex.py | def main():
"""
Usage: pre-sugartex [OPTIONS]
Reads from stdin and writes to stdout.
When no options: only replace
U+02CE Modifier Letter Low Grave Accent
(that looks like low '`') with $
Options:
--all Full SugarTeX replace with regexp,
--kiwi Same as above but wi... | def main():
"""
Usage: pre-sugartex [OPTIONS]
Reads from stdin and writes to stdout.
When no options: only replace
U+02CE Modifier Letter Low Grave Accent
(that looks like low '`') with $
Options:
--all Full SugarTeX replace with regexp,
--kiwi Same as above but wi... | [
"Usage",
":",
"pre",
"-",
"sugartex",
"[",
"OPTIONS",
"]"
] | kiwi0fruit/sugartex | python | https://github.com/kiwi0fruit/sugartex/blob/9eb13703cb02d3e2163c9c5f29df280f6bf49cec/sugartex/pre_sugartex.py#L39-L67 | [
"def",
"main",
"(",
")",
":",
"if",
"len",
"(",
"sys",
".",
"argv",
")",
">",
"1",
":",
"arg1",
"=",
"sys",
".",
"argv",
"[",
"1",
"]",
"if",
"arg1",
"==",
"'--all'",
"or",
"arg1",
"==",
"'--kiwi'",
":",
"if",
"arg1",
"==",
"'--kiwi'",
":",
"... | 9eb13703cb02d3e2163c9c5f29df280f6bf49cec |
train | parallel | execute jobs in processes using N threads | ctbBio/parallel.py | def parallel(processes, threads):
"""
execute jobs in processes using N threads
"""
pool = multithread(threads)
pool.map(run_process, processes)
pool.close()
pool.join() | def parallel(processes, threads):
"""
execute jobs in processes using N threads
"""
pool = multithread(threads)
pool.map(run_process, processes)
pool.close()
pool.join() | [
"execute",
"jobs",
"in",
"processes",
"using",
"N",
"threads"
] | christophertbrown/bioscripts | python | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/parallel.py#L19-L26 | [
"def",
"parallel",
"(",
"processes",
",",
"threads",
")",
":",
"pool",
"=",
"multithread",
"(",
"threads",
")",
"pool",
".",
"map",
"(",
"run_process",
",",
"processes",
")",
"pool",
".",
"close",
"(",
")",
"pool",
".",
"join",
"(",
")"
] | 83b2566b3a5745437ec651cd6cafddd056846240 |
train | define_log_renderer | the final log processor that structlog requires to render. | basescript/log.py | def define_log_renderer(fmt, fpath, quiet):
"""
the final log processor that structlog requires to render.
"""
# it must accept a logger, method_name and event_dict (just like processors)
# but must return the rendered string, not a dictionary.
# TODO tty logic
if fmt:
return struct... | def define_log_renderer(fmt, fpath, quiet):
"""
the final log processor that structlog requires to render.
"""
# it must accept a logger, method_name and event_dict (just like processors)
# but must return the rendered string, not a dictionary.
# TODO tty logic
if fmt:
return struct... | [
"the",
"final",
"log",
"processor",
"that",
"structlog",
"requires",
"to",
"render",
"."
] | deep-compute/basescript | python | https://github.com/deep-compute/basescript/blob/f7233963c5291530fcb2444a7f45b556e6407b90/basescript/log.py#L239-L256 | [
"def",
"define_log_renderer",
"(",
"fmt",
",",
"fpath",
",",
"quiet",
")",
":",
"# it must accept a logger, method_name and event_dict (just like processors)",
"# but must return the rendered string, not a dictionary.",
"# TODO tty logic",
"if",
"fmt",
":",
"return",
"structlog",
... | f7233963c5291530fcb2444a7f45b556e6407b90 |
train | _structlog_default_keys_processor | Add unique id, type and hostname | basescript/log.py | def _structlog_default_keys_processor(logger_class, log_method, event):
''' Add unique id, type and hostname '''
global HOSTNAME
if 'id' not in event:
event['id'] = '%s_%s' % (
datetime.utcnow().strftime('%Y%m%dT%H%M%S'),
uuid.uuid1().hex
)
if 'type' not in even... | def _structlog_default_keys_processor(logger_class, log_method, event):
''' Add unique id, type and hostname '''
global HOSTNAME
if 'id' not in event:
event['id'] = '%s_%s' % (
datetime.utcnow().strftime('%Y%m%dT%H%M%S'),
uuid.uuid1().hex
)
if 'type' not in even... | [
"Add",
"unique",
"id",
"type",
"and",
"hostname"
] | deep-compute/basescript | python | https://github.com/deep-compute/basescript/blob/f7233963c5291530fcb2444a7f45b556e6407b90/basescript/log.py#L258-L273 | [
"def",
"_structlog_default_keys_processor",
"(",
"logger_class",
",",
"log_method",
",",
"event",
")",
":",
"global",
"HOSTNAME",
"if",
"'id'",
"not",
"in",
"event",
":",
"event",
"[",
"'id'",
"]",
"=",
"'%s_%s'",
"%",
"(",
"datetime",
".",
"utcnow",
"(",
... | f7233963c5291530fcb2444a7f45b556e6407b90 |
train | define_log_processors | log processors that structlog executes before final rendering | basescript/log.py | def define_log_processors():
"""
log processors that structlog executes before final rendering
"""
# these processors should accept logger, method_name and event_dict
# and return a new dictionary which will be passed as event_dict to the next one.
return [
structlog.processors.TimeStamp... | def define_log_processors():
"""
log processors that structlog executes before final rendering
"""
# these processors should accept logger, method_name and event_dict
# and return a new dictionary which will be passed as event_dict to the next one.
return [
structlog.processors.TimeStamp... | [
"log",
"processors",
"that",
"structlog",
"executes",
"before",
"final",
"rendering"
] | deep-compute/basescript | python | https://github.com/deep-compute/basescript/blob/f7233963c5291530fcb2444a7f45b556e6407b90/basescript/log.py#L352-L364 | [
"def",
"define_log_processors",
"(",
")",
":",
"# these processors should accept logger, method_name and event_dict",
"# and return a new dictionary which will be passed as event_dict to the next one.",
"return",
"[",
"structlog",
".",
"processors",
".",
"TimeStamper",
"(",
"fmt",
"=... | f7233963c5291530fcb2444a7f45b556e6407b90 |
train | _configure_logger | configures a logger when required write to stderr or a file | basescript/log.py | def _configure_logger(fmt, quiet, level, fpath,
pre_hooks, post_hooks, metric_grouping_interval):
"""
configures a logger when required write to stderr or a file
"""
# NOTE not thread safe. Multiple BaseScripts cannot be instantiated concurrently.
level = getattr(logging, level.upper())
gl... | def _configure_logger(fmt, quiet, level, fpath,
pre_hooks, post_hooks, metric_grouping_interval):
"""
configures a logger when required write to stderr or a file
"""
# NOTE not thread safe. Multiple BaseScripts cannot be instantiated concurrently.
level = getattr(logging, level.upper())
gl... | [
"configures",
"a",
"logger",
"when",
"required",
"write",
"to",
"stderr",
"or",
"a",
"file"
] | deep-compute/basescript | python | https://github.com/deep-compute/basescript/blob/f7233963c5291530fcb2444a7f45b556e6407b90/basescript/log.py#L366-L447 | [
"def",
"_configure_logger",
"(",
"fmt",
",",
"quiet",
",",
"level",
",",
"fpath",
",",
"pre_hooks",
",",
"post_hooks",
",",
"metric_grouping_interval",
")",
":",
"# NOTE not thread safe. Multiple BaseScripts cannot be instantiated concurrently.",
"level",
"=",
"getattr",
... | f7233963c5291530fcb2444a7f45b556e6407b90 |
train | BoundLevelLogger._add_base_info | Instead of using a processor, adding basic information like caller, filename etc
here. | basescript/log.py | def _add_base_info(self, event_dict):
"""
Instead of using a processor, adding basic information like caller, filename etc
here.
"""
f = sys._getframe()
level_method_frame = f.f_back
caller_frame = level_method_frame.f_back
return event_dict | def _add_base_info(self, event_dict):
"""
Instead of using a processor, adding basic information like caller, filename etc
here.
"""
f = sys._getframe()
level_method_frame = f.f_back
caller_frame = level_method_frame.f_back
return event_dict | [
"Instead",
"of",
"using",
"a",
"processor",
"adding",
"basic",
"information",
"like",
"caller",
"filename",
"etc",
"here",
"."
] | deep-compute/basescript | python | https://github.com/deep-compute/basescript/blob/f7233963c5291530fcb2444a7f45b556e6407b90/basescript/log.py#L121-L129 | [
"def",
"_add_base_info",
"(",
"self",
",",
"event_dict",
")",
":",
"f",
"=",
"sys",
".",
"_getframe",
"(",
")",
"level_method_frame",
"=",
"f",
".",
"f_back",
"caller_frame",
"=",
"level_method_frame",
".",
"f_back",
"return",
"event_dict"
] | f7233963c5291530fcb2444a7f45b556e6407b90 |
train | BoundLevelLogger.debug | Process event and call :meth:`logging.Logger.debug` with the result. | basescript/log.py | def debug(self, event=None, *args, **kw):
"""
Process event and call :meth:`logging.Logger.debug` with the result.
"""
if not self._logger.isEnabledFor(logging.DEBUG):
return
kw = self._add_base_info(kw)
kw['level'] = "debug"
return self._proxy_to_log... | def debug(self, event=None, *args, **kw):
"""
Process event and call :meth:`logging.Logger.debug` with the result.
"""
if not self._logger.isEnabledFor(logging.DEBUG):
return
kw = self._add_base_info(kw)
kw['level'] = "debug"
return self._proxy_to_log... | [
"Process",
"event",
"and",
"call",
":",
"meth",
":",
"logging",
".",
"Logger",
".",
"debug",
"with",
"the",
"result",
"."
] | deep-compute/basescript | python | https://github.com/deep-compute/basescript/blob/f7233963c5291530fcb2444a7f45b556e6407b90/basescript/log.py#L131-L140 | [
"def",
"debug",
"(",
"self",
",",
"event",
"=",
"None",
",",
"*",
"args",
",",
"*",
"*",
"kw",
")",
":",
"if",
"not",
"self",
".",
"_logger",
".",
"isEnabledFor",
"(",
"logging",
".",
"DEBUG",
")",
":",
"return",
"kw",
"=",
"self",
".",
"_add_bas... | f7233963c5291530fcb2444a7f45b556e6407b90 |
train | BoundLevelLogger.info | Process event and call :meth:`logging.Logger.info` with the result. | basescript/log.py | def info(self, event=None, *args, **kw):
"""
Process event and call :meth:`logging.Logger.info` with the result.
"""
if not self._logger.isEnabledFor(logging.INFO):
return
kw = self._add_base_info(kw)
kw['level'] = "info"
return self._proxy_to_logger(... | def info(self, event=None, *args, **kw):
"""
Process event and call :meth:`logging.Logger.info` with the result.
"""
if not self._logger.isEnabledFor(logging.INFO):
return
kw = self._add_base_info(kw)
kw['level'] = "info"
return self._proxy_to_logger(... | [
"Process",
"event",
"and",
"call",
":",
"meth",
":",
"logging",
".",
"Logger",
".",
"info",
"with",
"the",
"result",
"."
] | deep-compute/basescript | python | https://github.com/deep-compute/basescript/blob/f7233963c5291530fcb2444a7f45b556e6407b90/basescript/log.py#L142-L151 | [
"def",
"info",
"(",
"self",
",",
"event",
"=",
"None",
",",
"*",
"args",
",",
"*",
"*",
"kw",
")",
":",
"if",
"not",
"self",
".",
"_logger",
".",
"isEnabledFor",
"(",
"logging",
".",
"INFO",
")",
":",
"return",
"kw",
"=",
"self",
".",
"_add_base_... | f7233963c5291530fcb2444a7f45b556e6407b90 |
train | BoundLevelLogger.warning | Process event and call :meth:`logging.Logger.warning` with the result. | basescript/log.py | def warning(self, event=None, *args, **kw):
"""
Process event and call :meth:`logging.Logger.warning` with the result.
"""
if not self._logger.isEnabledFor(logging.WARNING):
return
kw = self._add_base_info(kw)
kw['level'] = "warning"
return self._prox... | def warning(self, event=None, *args, **kw):
"""
Process event and call :meth:`logging.Logger.warning` with the result.
"""
if not self._logger.isEnabledFor(logging.WARNING):
return
kw = self._add_base_info(kw)
kw['level'] = "warning"
return self._prox... | [
"Process",
"event",
"and",
"call",
":",
"meth",
":",
"logging",
".",
"Logger",
".",
"warning",
"with",
"the",
"result",
"."
] | deep-compute/basescript | python | https://github.com/deep-compute/basescript/blob/f7233963c5291530fcb2444a7f45b556e6407b90/basescript/log.py#L153-L162 | [
"def",
"warning",
"(",
"self",
",",
"event",
"=",
"None",
",",
"*",
"args",
",",
"*",
"*",
"kw",
")",
":",
"if",
"not",
"self",
".",
"_logger",
".",
"isEnabledFor",
"(",
"logging",
".",
"WARNING",
")",
":",
"return",
"kw",
"=",
"self",
".",
"_add... | f7233963c5291530fcb2444a7f45b556e6407b90 |
train | BoundLevelLogger.error | Process event and call :meth:`logging.Logger.error` with the result. | basescript/log.py | def error(self, event=None, *args, **kw):
"""
Process event and call :meth:`logging.Logger.error` with the result.
"""
if not self._logger.isEnabledFor(logging.ERROR):
return
kw = self._add_base_info(kw)
kw['level'] = "error"
return self._proxy_to_log... | def error(self, event=None, *args, **kw):
"""
Process event and call :meth:`logging.Logger.error` with the result.
"""
if not self._logger.isEnabledFor(logging.ERROR):
return
kw = self._add_base_info(kw)
kw['level'] = "error"
return self._proxy_to_log... | [
"Process",
"event",
"and",
"call",
":",
"meth",
":",
"logging",
".",
"Logger",
".",
"error",
"with",
"the",
"result",
"."
] | deep-compute/basescript | python | https://github.com/deep-compute/basescript/blob/f7233963c5291530fcb2444a7f45b556e6407b90/basescript/log.py#L166-L175 | [
"def",
"error",
"(",
"self",
",",
"event",
"=",
"None",
",",
"*",
"args",
",",
"*",
"*",
"kw",
")",
":",
"if",
"not",
"self",
".",
"_logger",
".",
"isEnabledFor",
"(",
"logging",
".",
"ERROR",
")",
":",
"return",
"kw",
"=",
"self",
".",
"_add_bas... | f7233963c5291530fcb2444a7f45b556e6407b90 |
train | BoundLevelLogger.critical | Process event and call :meth:`logging.Logger.critical` with the result. | basescript/log.py | def critical(self, event=None, *args, **kw):
"""
Process event and call :meth:`logging.Logger.critical` with the result.
"""
if not self._logger.isEnabledFor(logging.CRITICAL):
return
kw = self._add_base_info(kw)
kw['level'] = "critical"
return self._... | def critical(self, event=None, *args, **kw):
"""
Process event and call :meth:`logging.Logger.critical` with the result.
"""
if not self._logger.isEnabledFor(logging.CRITICAL):
return
kw = self._add_base_info(kw)
kw['level'] = "critical"
return self._... | [
"Process",
"event",
"and",
"call",
":",
"meth",
":",
"logging",
".",
"Logger",
".",
"critical",
"with",
"the",
"result",
"."
] | deep-compute/basescript | python | https://github.com/deep-compute/basescript/blob/f7233963c5291530fcb2444a7f45b556e6407b90/basescript/log.py#L177-L186 | [
"def",
"critical",
"(",
"self",
",",
"event",
"=",
"None",
",",
"*",
"args",
",",
"*",
"*",
"kw",
")",
":",
"if",
"not",
"self",
".",
"_logger",
".",
"isEnabledFor",
"(",
"logging",
".",
"CRITICAL",
")",
":",
"return",
"kw",
"=",
"self",
".",
"_a... | f7233963c5291530fcb2444a7f45b556e6407b90 |
train | BoundLevelLogger.exception | Process event and call :meth:`logging.Logger.error` with the result,
after setting ``exc_info`` to `True`. | basescript/log.py | def exception(self, event=None, *args, **kw):
"""
Process event and call :meth:`logging.Logger.error` with the result,
after setting ``exc_info`` to `True`.
"""
if not self._logger.isEnabledFor(logging.ERROR):
return
kw = self._add_base_info(kw)
kw['l... | def exception(self, event=None, *args, **kw):
"""
Process event and call :meth:`logging.Logger.error` with the result,
after setting ``exc_info`` to `True`.
"""
if not self._logger.isEnabledFor(logging.ERROR):
return
kw = self._add_base_info(kw)
kw['l... | [
"Process",
"event",
"and",
"call",
":",
"meth",
":",
"logging",
".",
"Logger",
".",
"error",
"with",
"the",
"result",
"after",
"setting",
"exc_info",
"to",
"True",
"."
] | deep-compute/basescript | python | https://github.com/deep-compute/basescript/blob/f7233963c5291530fcb2444a7f45b556e6407b90/basescript/log.py#L188-L199 | [
"def",
"exception",
"(",
"self",
",",
"event",
"=",
"None",
",",
"*",
"args",
",",
"*",
"*",
"kw",
")",
":",
"if",
"not",
"self",
".",
"_logger",
".",
"isEnabledFor",
"(",
"logging",
".",
"ERROR",
")",
":",
"return",
"kw",
"=",
"self",
".",
"_add... | f7233963c5291530fcb2444a7f45b556e6407b90 |
train | BoundLevelLogger._proxy_to_logger | Propagate a method call to the wrapped logger.
This is the same as the superclass implementation, except that
it also preserves positional arguments in the `event_dict` so
that the stdblib's support for format strings can be used. | basescript/log.py | def _proxy_to_logger(self, method_name, event, *event_args,
**event_kw):
"""
Propagate a method call to the wrapped logger.
This is the same as the superclass implementation, except that
it also preserves positional arguments in the `event_dict` so
that ... | def _proxy_to_logger(self, method_name, event, *event_args,
**event_kw):
"""
Propagate a method call to the wrapped logger.
This is the same as the superclass implementation, except that
it also preserves positional arguments in the `event_dict` so
that ... | [
"Propagate",
"a",
"method",
"call",
"to",
"the",
"wrapped",
"logger",
"."
] | deep-compute/basescript | python | https://github.com/deep-compute/basescript/blob/f7233963c5291530fcb2444a7f45b556e6407b90/basescript/log.py#L211-L229 | [
"def",
"_proxy_to_logger",
"(",
"self",
",",
"method_name",
",",
"event",
",",
"*",
"event_args",
",",
"*",
"*",
"event_kw",
")",
":",
"if",
"isinstance",
"(",
"event",
",",
"bytes",
")",
":",
"event",
"=",
"event",
".",
"decode",
"(",
"'utf-8'",
")",
... | f7233963c5291530fcb2444a7f45b556e6407b90 |
train | translate | Given four points of a rectangle, translate the
rectangle to the specified x and y coordinates and,
optionally, change the width.
:type rect: list of tuples
:param rect: Four points describing a rectangle.
:type x: float
:param x: The amount to shift the rectangle along the x-axis.
:type y:... | bin/core_overlap_plot.py | def translate(rect, x, y, width=1):
"""
Given four points of a rectangle, translate the
rectangle to the specified x and y coordinates and,
optionally, change the width.
:type rect: list of tuples
:param rect: Four points describing a rectangle.
:type x: float
:param x: The amount to sh... | def translate(rect, x, y, width=1):
"""
Given four points of a rectangle, translate the
rectangle to the specified x and y coordinates and,
optionally, change the width.
:type rect: list of tuples
:param rect: Four points describing a rectangle.
:type x: float
:param x: The amount to sh... | [
"Given",
"four",
"points",
"of",
"a",
"rectangle",
"translate",
"the",
"rectangle",
"to",
"the",
"specified",
"x",
"and",
"y",
"coordinates",
"and",
"optionally",
"change",
"the",
"width",
"."
] | smdabdoub/phylotoast | python | https://github.com/smdabdoub/phylotoast/blob/0b74ef171e6a84761710548501dfac71285a58a3/bin/core_overlap_plot.py#L57-L74 | [
"def",
"translate",
"(",
"rect",
",",
"x",
",",
"y",
",",
"width",
"=",
"1",
")",
":",
"return",
"(",
"(",
"rect",
"[",
"0",
"]",
"[",
"0",
"]",
"+",
"x",
",",
"rect",
"[",
"0",
"]",
"[",
"1",
"]",
"+",
"y",
")",
",",
"(",
"rect",
"[",
... | 0b74ef171e6a84761710548501dfac71285a58a3 |
train | load_core_file | For core OTU data file, returns Genus-species identifier for each data
entry.
:type core_fp: str
:param core_fp: A file containing core OTU data.
:rtype: str
:return: Returns genus-species identifier based on identified taxonomical
level. | bin/core_overlap_plot.py | def load_core_file(core_fp):
"""
For core OTU data file, returns Genus-species identifier for each data
entry.
:type core_fp: str
:param core_fp: A file containing core OTU data.
:rtype: str
:return: Returns genus-species identifier based on identified taxonomical
level.
"""... | def load_core_file(core_fp):
"""
For core OTU data file, returns Genus-species identifier for each data
entry.
:type core_fp: str
:param core_fp: A file containing core OTU data.
:rtype: str
:return: Returns genus-species identifier based on identified taxonomical
level.
"""... | [
"For",
"core",
"OTU",
"data",
"file",
"returns",
"Genus",
"-",
"species",
"identifier",
"for",
"each",
"data",
"entry",
".",
":",
"type",
"core_fp",
":",
"str",
":",
"param",
"core_fp",
":",
"A",
"file",
"containing",
"core",
"OTU",
"data",
".",
":",
"... | smdabdoub/phylotoast | python | https://github.com/smdabdoub/phylotoast/blob/0b74ef171e6a84761710548501dfac71285a58a3/bin/core_overlap_plot.py#L77-L93 | [
"def",
"load_core_file",
"(",
"core_fp",
")",
":",
"core",
"=",
"{",
"}",
"with",
"open",
"(",
"core_fp",
")",
"as",
"in_f",
":",
"for",
"line",
"in",
"in_f",
".",
"read",
"(",
")",
".",
"splitlines",
"(",
")",
":",
"if",
"not",
"line",
".",
"sta... | 0b74ef171e6a84761710548501dfac71285a58a3 |
train | plot_overlaps | Given a list of OTUs and a number of groups containing subsets of
the OTU set, plot a presence/absence bar chart showing which species
belong to which groups.
:type otus: list
:param otus: A list of OTU identifiers (names or otherwise) ordered
by greatest presence across the groups... | bin/core_overlap_plot.py | def plot_overlaps(otus, group_otus, group_colors,
out_fp, fig_size=None, title="",
filter_common=False):
"""
Given a list of OTUs and a number of groups containing subsets of
the OTU set, plot a presence/absence bar chart showing which species
belong to which groups.... | def plot_overlaps(otus, group_otus, group_colors,
out_fp, fig_size=None, title="",
filter_common=False):
"""
Given a list of OTUs and a number of groups containing subsets of
the OTU set, plot a presence/absence bar chart showing which species
belong to which groups.... | [
"Given",
"a",
"list",
"of",
"OTUs",
"and",
"a",
"number",
"of",
"groups",
"containing",
"subsets",
"of",
"the",
"OTU",
"set",
"plot",
"a",
"presence",
"/",
"absence",
"bar",
"chart",
"showing",
"which",
"species",
"belong",
"to",
"which",
"groups",
".",
... | smdabdoub/phylotoast | python | https://github.com/smdabdoub/phylotoast/blob/0b74ef171e6a84761710548501dfac71285a58a3/bin/core_overlap_plot.py#L104-L205 | [
"def",
"plot_overlaps",
"(",
"otus",
",",
"group_otus",
",",
"group_colors",
",",
"out_fp",
",",
"fig_size",
"=",
"None",
",",
"title",
"=",
"\"\"",
",",
"filter_common",
"=",
"False",
")",
":",
"def",
"sort_order_group",
"(",
"sp",
")",
":",
"\"\"\"\n ... | 0b74ef171e6a84761710548501dfac71285a58a3 |
train | remove_bad | remove problem characters from string | ctbBio/rax.py | def remove_bad(string):
"""
remove problem characters from string
"""
remove = [':', ',', '(', ')', ' ', '|', ';', '\'']
for c in remove:
string = string.replace(c, '_')
return string | def remove_bad(string):
"""
remove problem characters from string
"""
remove = [':', ',', '(', ')', ' ', '|', ';', '\'']
for c in remove:
string = string.replace(c, '_')
return string | [
"remove",
"problem",
"characters",
"from",
"string"
] | christophertbrown/bioscripts | python | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/rax.py#L43-L50 | [
"def",
"remove_bad",
"(",
"string",
")",
":",
"remove",
"=",
"[",
"':'",
",",
"','",
",",
"'('",
",",
"')'",
",",
"' '",
",",
"'|'",
",",
"';'",
",",
"'\\''",
"]",
"for",
"c",
"in",
"remove",
":",
"string",
"=",
"string",
".",
"replace",
"(",
"... | 83b2566b3a5745437ec651cd6cafddd056846240 |
train | get_ids | make copy of sequences with short identifier | ctbBio/rax.py | def get_ids(a):
"""
make copy of sequences with short identifier
"""
a_id = '%s.id.fa' % (a.rsplit('.', 1)[0])
a_id_lookup = '%s.id.lookup' % (a.rsplit('.', 1)[0])
if check(a_id) is True:
return a_id, a_id_lookup
a_id_f = open(a_id, 'w')
a_id_lookup_f = open(a_id_lookup, 'w')
... | def get_ids(a):
"""
make copy of sequences with short identifier
"""
a_id = '%s.id.fa' % (a.rsplit('.', 1)[0])
a_id_lookup = '%s.id.lookup' % (a.rsplit('.', 1)[0])
if check(a_id) is True:
return a_id, a_id_lookup
a_id_f = open(a_id, 'w')
a_id_lookup_f = open(a_id_lookup, 'w')
... | [
"make",
"copy",
"of",
"sequences",
"with",
"short",
"identifier"
] | christophertbrown/bioscripts | python | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/rax.py#L55-L76 | [
"def",
"get_ids",
"(",
"a",
")",
":",
"a_id",
"=",
"'%s.id.fa'",
"%",
"(",
"a",
".",
"rsplit",
"(",
"'.'",
",",
"1",
")",
"[",
"0",
"]",
")",
"a_id_lookup",
"=",
"'%s.id.lookup'",
"%",
"(",
"a",
".",
"rsplit",
"(",
"'.'",
",",
"1",
")",
"[",
... | 83b2566b3a5745437ec651cd6cafddd056846240 |
train | convert2phylip | convert fasta to phylip because RAxML is ridiculous | ctbBio/rax.py | def convert2phylip(convert):
"""
convert fasta to phylip because RAxML is ridiculous
"""
out = '%s.phy' % (convert.rsplit('.', 1)[0])
if check(out) is False:
convert = open(convert, 'rU')
out_f = open(out, 'w')
alignments = AlignIO.parse(convert, "fasta")
AlignIO.writ... | def convert2phylip(convert):
"""
convert fasta to phylip because RAxML is ridiculous
"""
out = '%s.phy' % (convert.rsplit('.', 1)[0])
if check(out) is False:
convert = open(convert, 'rU')
out_f = open(out, 'w')
alignments = AlignIO.parse(convert, "fasta")
AlignIO.writ... | [
"convert",
"fasta",
"to",
"phylip",
"because",
"RAxML",
"is",
"ridiculous"
] | christophertbrown/bioscripts | python | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/rax.py#L78-L88 | [
"def",
"convert2phylip",
"(",
"convert",
")",
":",
"out",
"=",
"'%s.phy'",
"%",
"(",
"convert",
".",
"rsplit",
"(",
"'.'",
",",
"1",
")",
"[",
"0",
"]",
")",
"if",
"check",
"(",
"out",
")",
"is",
"False",
":",
"convert",
"=",
"open",
"(",
"conver... | 83b2566b3a5745437ec651cd6cafddd056846240 |
train | run_fast | run FastTree | ctbBio/rax.py | def run_fast(aligned, threads, cluster, node):
"""
run FastTree
"""
tree = '%s.fasttree.nwk' % (aligned.rsplit('.', 1)[0])
if check(tree) is False:
if 'FastTreeV' in os.environ:
ft = os.environ['FastTreeV']
os.environ['OMP_NUM_THREADS'] = str(threads)
else:
... | def run_fast(aligned, threads, cluster, node):
"""
run FastTree
"""
tree = '%s.fasttree.nwk' % (aligned.rsplit('.', 1)[0])
if check(tree) is False:
if 'FastTreeV' in os.environ:
ft = os.environ['FastTreeV']
os.environ['OMP_NUM_THREADS'] = str(threads)
else:
... | [
"run",
"FastTree"
] | christophertbrown/bioscripts | python | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/rax.py#L90-L122 | [
"def",
"run_fast",
"(",
"aligned",
",",
"threads",
",",
"cluster",
",",
"node",
")",
":",
"tree",
"=",
"'%s.fasttree.nwk'",
"%",
"(",
"aligned",
".",
"rsplit",
"(",
"'.'",
",",
"1",
")",
"[",
"0",
"]",
")",
"if",
"check",
"(",
"tree",
")",
"is",
... | 83b2566b3a5745437ec651cd6cafddd056846240 |
train | run_raxml | run raxml | ctbBio/rax.py | def run_raxml(rax_out, boot, a_id_phylip, threads, aligned, model, cluster, node):
"""
run raxml
"""
# set ppn based on threads
if threads > 24:
ppn = 24
else:
ppn = threads
if 'raxml' in os.environ:
raxml = os.environ['raxml']
threads = '-T %s' % (threads)
... | def run_raxml(rax_out, boot, a_id_phylip, threads, aligned, model, cluster, node):
"""
run raxml
"""
# set ppn based on threads
if threads > 24:
ppn = 24
else:
ppn = threads
if 'raxml' in os.environ:
raxml = os.environ['raxml']
threads = '-T %s' % (threads)
... | [
"run",
"raxml"
] | christophertbrown/bioscripts | python | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/rax.py#L124-L161 | [
"def",
"run_raxml",
"(",
"rax_out",
",",
"boot",
",",
"a_id_phylip",
",",
"threads",
",",
"aligned",
",",
"model",
",",
"cluster",
",",
"node",
")",
":",
"# set ppn based on threads",
"if",
"threads",
">",
"24",
":",
"ppn",
"=",
"24",
"else",
":",
"ppn",... | 83b2566b3a5745437ec651cd6cafddd056846240 |
train | run_iqtree | run IQ-Tree | ctbBio/rax.py | def run_iqtree(phy, model, threads, cluster, node):
"""
run IQ-Tree
"""
# set ppn based on threads
if threads > 24:
ppn = 24
else:
ppn = threads
tree = '%s.treefile' % (phy)
if check(tree) is False:
if model is False:
model = 'TEST'
dir = os.ge... | def run_iqtree(phy, model, threads, cluster, node):
"""
run IQ-Tree
"""
# set ppn based on threads
if threads > 24:
ppn = 24
else:
ppn = threads
tree = '%s.treefile' % (phy)
if check(tree) is False:
if model is False:
model = 'TEST'
dir = os.ge... | [
"run",
"IQ",
"-",
"Tree"
] | christophertbrown/bioscripts | python | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/rax.py#L163-L190 | [
"def",
"run_iqtree",
"(",
"phy",
",",
"model",
",",
"threads",
",",
"cluster",
",",
"node",
")",
":",
"# set ppn based on threads",
"if",
"threads",
">",
"24",
":",
"ppn",
"=",
"24",
"else",
":",
"ppn",
"=",
"threads",
"tree",
"=",
"'%s.treefile'",
"%",
... | 83b2566b3a5745437ec651cd6cafddd056846240 |
train | fix_tree | get the names for sequences in the raxml tree | ctbBio/rax.py | def fix_tree(tree, a_id_lookup, out):
"""
get the names for sequences in the raxml tree
"""
if check(out) is False and check(tree) is True:
tree = open(tree).read()
for line in open(a_id_lookup):
id, name, header = line.strip().split('\t')
tree = tree.replace(id+'... | def fix_tree(tree, a_id_lookup, out):
"""
get the names for sequences in the raxml tree
"""
if check(out) is False and check(tree) is True:
tree = open(tree).read()
for line in open(a_id_lookup):
id, name, header = line.strip().split('\t')
tree = tree.replace(id+'... | [
"get",
"the",
"names",
"for",
"sequences",
"in",
"the",
"raxml",
"tree"
] | christophertbrown/bioscripts | python | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/rax.py#L192-L203 | [
"def",
"fix_tree",
"(",
"tree",
",",
"a_id_lookup",
",",
"out",
")",
":",
"if",
"check",
"(",
"out",
")",
"is",
"False",
"and",
"check",
"(",
"tree",
")",
"is",
"True",
":",
"tree",
"=",
"open",
"(",
"tree",
")",
".",
"read",
"(",
")",
"for",
"... | 83b2566b3a5745437ec651cd6cafddd056846240 |
train | rax | run raxml on 'a' (alignment) with 'boot' (bootstraps) and 'threads' (threads)
store all files in raxml_a_b
1. give every sequence a short identifier
2. convert fasta to phylip
3. run raxml
4. convert ids in raxml tree to original names | ctbBio/rax.py | def rax(a, boot, threads, \
fast = False, run_rax = False, run_iq = False, model = False, cluster = False, node = False):
"""
run raxml on 'a' (alignment) with 'boot' (bootstraps) and 'threads' (threads)
store all files in raxml_a_b
1. give every sequence a short identifier
2. convert fa... | def rax(a, boot, threads, \
fast = False, run_rax = False, run_iq = False, model = False, cluster = False, node = False):
"""
run raxml on 'a' (alignment) with 'boot' (bootstraps) and 'threads' (threads)
store all files in raxml_a_b
1. give every sequence a short identifier
2. convert fa... | [
"run",
"raxml",
"on",
"a",
"(",
"alignment",
")",
"with",
"boot",
"(",
"bootstraps",
")",
"and",
"threads",
"(",
"threads",
")",
"store",
"all",
"files",
"in",
"raxml_a_b",
"1",
".",
"give",
"every",
"sequence",
"a",
"short",
"identifier",
"2",
".",
"c... | christophertbrown/bioscripts | python | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/rax.py#L205-L241 | [
"def",
"rax",
"(",
"a",
",",
"boot",
",",
"threads",
",",
"fast",
"=",
"False",
",",
"run_rax",
"=",
"False",
",",
"run_iq",
"=",
"False",
",",
"model",
"=",
"False",
",",
"cluster",
"=",
"False",
",",
"node",
"=",
"False",
")",
":",
"a",
"=",
... | 83b2566b3a5745437ec651cd6cafddd056846240 |
train | send_arp_msg | send_arp_msg
Send an ``ARP`` message to the network device (``enp0s3`` by default). | network_pipeline/scripts/arp_send_msg.py | def send_arp_msg():
"""send_arp_msg
Send an ``ARP`` message to the network device (``enp0s3`` by default).
"""
dev = os.getenv(
"ARP_INTERFACE",
"enp0s3").strip().lstrip()
network_details = netifaces.ifaddresses(
dev)
dst_ip = os.getenv(
"ARP_DS... | def send_arp_msg():
"""send_arp_msg
Send an ``ARP`` message to the network device (``enp0s3`` by default).
"""
dev = os.getenv(
"ARP_INTERFACE",
"enp0s3").strip().lstrip()
network_details = netifaces.ifaddresses(
dev)
dst_ip = os.getenv(
"ARP_DS... | [
"send_arp_msg"
] | jay-johnson/network-pipeline | python | https://github.com/jay-johnson/network-pipeline/blob/4e53ae13fe12085e0cf2e5e1aff947368f4f1ffa/network_pipeline/scripts/arp_send_msg.py#L8-L48 | [
"def",
"send_arp_msg",
"(",
")",
":",
"dev",
"=",
"os",
".",
"getenv",
"(",
"\"ARP_INTERFACE\"",
",",
"\"enp0s3\"",
")",
".",
"strip",
"(",
")",
".",
"lstrip",
"(",
")",
"network_details",
"=",
"netifaces",
".",
"ifaddresses",
"(",
"dev",
")",
"dst_ip",
... | 4e53ae13fe12085e0cf2e5e1aff947368f4f1ffa |
train | shutdown_consumers | shutdown_consumers
:param num_workers:
:param tasks:
:param shutdown_msg: | network_pipeline/shutdown_consumers.py | def shutdown_consumers(num_workers=2,
tasks=None,
shutdown_msg="SHUTDOWN"):
"""shutdown_consumers
:param num_workers:
:param tasks:
:param shutdown_msg:
"""
if tasks:
# Add a poison pill for each consumer
for i in range(num_workers):... | def shutdown_consumers(num_workers=2,
tasks=None,
shutdown_msg="SHUTDOWN"):
"""shutdown_consumers
:param num_workers:
:param tasks:
:param shutdown_msg:
"""
if tasks:
# Add a poison pill for each consumer
for i in range(num_workers):... | [
"shutdown_consumers"
] | jay-johnson/network-pipeline | python | https://github.com/jay-johnson/network-pipeline/blob/4e53ae13fe12085e0cf2e5e1aff947368f4f1ffa/network_pipeline/shutdown_consumers.py#L3-L15 | [
"def",
"shutdown_consumers",
"(",
"num_workers",
"=",
"2",
",",
"tasks",
"=",
"None",
",",
"shutdown_msg",
"=",
"\"SHUTDOWN\"",
")",
":",
"if",
"tasks",
":",
"# Add a poison pill for each consumer",
"for",
"i",
"in",
"range",
"(",
"num_workers",
")",
":",
"tas... | 4e53ae13fe12085e0cf2e5e1aff947368f4f1ffa |
train | create_cluster | Creates a new Nydus cluster from the given settings.
:param settings: Dictionary of the cluster settings.
:returns: Configured instance of ``nydus.db.base.Cluster``.
>>> redis = create_cluster({
>>> 'backend': 'nydus.db.backends.redis.Redis',
>>> 'router': 'nydus.db.routers.redis.Partition... | nydus/db/__init__.py | def create_cluster(settings):
"""
Creates a new Nydus cluster from the given settings.
:param settings: Dictionary of the cluster settings.
:returns: Configured instance of ``nydus.db.base.Cluster``.
>>> redis = create_cluster({
>>> 'backend': 'nydus.db.backends.redis.Redis',
>>> '... | def create_cluster(settings):
"""
Creates a new Nydus cluster from the given settings.
:param settings: Dictionary of the cluster settings.
:returns: Configured instance of ``nydus.db.base.Cluster``.
>>> redis = create_cluster({
>>> 'backend': 'nydus.db.backends.redis.Redis',
>>> '... | [
"Creates",
"a",
"new",
"Nydus",
"cluster",
"from",
"the",
"given",
"settings",
"."
] | disqus/nydus | python | https://github.com/disqus/nydus/blob/9b505840da47a34f758a830c3992fa5dcb7bb7ad/nydus/db/__init__.py#L28-L82 | [
"def",
"create_cluster",
"(",
"settings",
")",
":",
"# Pull in our client",
"settings",
"=",
"copy",
".",
"deepcopy",
"(",
"settings",
")",
"backend",
"=",
"settings",
".",
"pop",
"(",
"'engine'",
",",
"settings",
".",
"pop",
"(",
"'backend'",
",",
"None",
... | 9b505840da47a34f758a830c3992fa5dcb7bb7ad |
train | MultilingualModel._get_translation | Gets the translation of a specific field for a specific language code.
This raises ObjectDoesNotExist if the lookup was unsuccesful. As of
today, this stuff is cached. As the cache is rather aggressive it
might cause rather strange effects. However, we would see the same
effects when an... | multilingual_model/models.py | def _get_translation(self, field, code):
"""
Gets the translation of a specific field for a specific language code.
This raises ObjectDoesNotExist if the lookup was unsuccesful. As of
today, this stuff is cached. As the cache is rather aggressive it
might cause rather strange ef... | def _get_translation(self, field, code):
"""
Gets the translation of a specific field for a specific language code.
This raises ObjectDoesNotExist if the lookup was unsuccesful. As of
today, this stuff is cached. As the cache is rather aggressive it
might cause rather strange ef... | [
"Gets",
"the",
"translation",
"of",
"a",
"specific",
"field",
"for",
"a",
"specific",
"language",
"code",
"."
] | dokterbob/django-multilingual-model | python | https://github.com/dokterbob/django-multilingual-model/blob/2479b2c3d6f7b697e95aa1e082c8bc8699f1f638/multilingual_model/models.py#L44-L90 | [
"def",
"_get_translation",
"(",
"self",
",",
"field",
",",
"code",
")",
":",
"if",
"not",
"code",
"in",
"self",
".",
"_translation_cache",
":",
"translations",
"=",
"self",
".",
"translations",
".",
"select_related",
"(",
")",
"logger",
".",
"debug",
"(",
... | 2479b2c3d6f7b697e95aa1e082c8bc8699f1f638 |
train | MultilingualModel.unicode_wrapper | Wrapper to allow for easy unicode representation of an object by
the specified property. If this wrapper is not able to find the
right translation of the specified property, it will return the
default value instead.
Example::
def __unicode__(self):
return uni... | multilingual_model/models.py | def unicode_wrapper(self, property, default=ugettext('Untitled')):
"""
Wrapper to allow for easy unicode representation of an object by
the specified property. If this wrapper is not able to find the
right translation of the specified property, it will return the
default value in... | def unicode_wrapper(self, property, default=ugettext('Untitled')):
"""
Wrapper to allow for easy unicode representation of an object by
the specified property. If this wrapper is not able to find the
right translation of the specified property, it will return the
default value in... | [
"Wrapper",
"to",
"allow",
"for",
"easy",
"unicode",
"representation",
"of",
"an",
"object",
"by",
"the",
"specified",
"property",
".",
"If",
"this",
"wrapper",
"is",
"not",
"able",
"to",
"find",
"the",
"right",
"translation",
"of",
"the",
"specified",
"prope... | dokterbob/django-multilingual-model | python | https://github.com/dokterbob/django-multilingual-model/blob/2479b2c3d6f7b697e95aa1e082c8bc8699f1f638/multilingual_model/models.py#L202-L228 | [
"def",
"unicode_wrapper",
"(",
"self",
",",
"property",
",",
"default",
"=",
"ugettext",
"(",
"'Untitled'",
")",
")",
":",
"# TODO: Test coverage!",
"try",
":",
"value",
"=",
"getattr",
"(",
"self",
",",
"property",
")",
"except",
"ValueError",
":",
"logger"... | 2479b2c3d6f7b697e95aa1e082c8bc8699f1f638 |
train | strip_inserts | remove insertion columns from aligned fasta file | ctbBio/strip_align_inserts.py | def strip_inserts(fasta):
"""
remove insertion columns from aligned fasta file
"""
for seq in parse_fasta(fasta):
seq[1] = ''.join([b for b in seq[1] if b == '-' or b.isupper()])
yield seq | def strip_inserts(fasta):
"""
remove insertion columns from aligned fasta file
"""
for seq in parse_fasta(fasta):
seq[1] = ''.join([b for b in seq[1] if b == '-' or b.isupper()])
yield seq | [
"remove",
"insertion",
"columns",
"from",
"aligned",
"fasta",
"file"
] | christophertbrown/bioscripts | python | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/strip_align_inserts.py#L12-L18 | [
"def",
"strip_inserts",
"(",
"fasta",
")",
":",
"for",
"seq",
"in",
"parse_fasta",
"(",
"fasta",
")",
":",
"seq",
"[",
"1",
"]",
"=",
"''",
".",
"join",
"(",
"[",
"b",
"for",
"b",
"in",
"seq",
"[",
"1",
"]",
"if",
"b",
"==",
"'-'",
"or",
"b",... | 83b2566b3a5745437ec651cd6cafddd056846240 |
train | Tokenizer.characters | Given a string as input, return a space-delimited string of Unicode characters
(code points rendered as glyphs).
Parameters
----------
string : str
A Unicode string to be tokenized into graphemes.
Returns
-------
result : str
String returne... | src/segments/tokenizer.py | def characters(self, string, segment_separator=' ', separator=' # ',):
"""
Given a string as input, return a space-delimited string of Unicode characters
(code points rendered as glyphs).
Parameters
----------
string : str
A Unicode string to be tokenized into... | def characters(self, string, segment_separator=' ', separator=' # ',):
"""
Given a string as input, return a space-delimited string of Unicode characters
(code points rendered as glyphs).
Parameters
----------
string : str
A Unicode string to be tokenized into... | [
"Given",
"a",
"string",
"as",
"input",
"return",
"a",
"space",
"-",
"delimited",
"string",
"of",
"Unicode",
"characters",
"(",
"code",
"points",
"rendered",
"as",
"glyphs",
")",
".",
"Parameters",
"----------",
"string",
":",
"str",
"A",
"Unicode",
"string",... | cldf/segments | python | https://github.com/cldf/segments/blob/9136a4ec89555bf9b574399ffbb07f3cc9a9f45f/src/segments/tokenizer.py#L188-L207 | [
"def",
"characters",
"(",
"self",
",",
"string",
",",
"segment_separator",
"=",
"' '",
",",
"separator",
"=",
"' # '",
",",
")",
":",
"return",
"separator",
".",
"join",
"(",
"segment_separator",
".",
"join",
"(",
"word",
")",
"for",
"word",
"in",
"nfd",... | 9136a4ec89555bf9b574399ffbb07f3cc9a9f45f |
train | Tokenizer.transform | Transform a string's graphemes into the mappings given in a different column
in the orthography profile.
Parameters
----------
word : str
The input string to be tokenized.
column : str (default = "Grapheme")
The label of the column to transform to. Defau... | src/segments/tokenizer.py | def transform(self, word, column=Profile.GRAPHEME_COL, error=errors.replace):
"""
Transform a string's graphemes into the mappings given in a different column
in the orthography profile.
Parameters
----------
word : str
The input string to be tokenized.
... | def transform(self, word, column=Profile.GRAPHEME_COL, error=errors.replace):
"""
Transform a string's graphemes into the mappings given in a different column
in the orthography profile.
Parameters
----------
word : str
The input string to be tokenized.
... | [
"Transform",
"a",
"string",
"s",
"graphemes",
"into",
"the",
"mappings",
"given",
"in",
"a",
"different",
"column",
"in",
"the",
"orthography",
"profile",
"."
] | cldf/segments | python | https://github.com/cldf/segments/blob/9136a4ec89555bf9b574399ffbb07f3cc9a9f45f/src/segments/tokenizer.py#L231-L270 | [
"def",
"transform",
"(",
"self",
",",
"word",
",",
"column",
"=",
"Profile",
".",
"GRAPHEME_COL",
",",
"error",
"=",
"errors",
".",
"replace",
")",
":",
"assert",
"self",
".",
"op",
",",
"'method can only be called with orthography profile.'",
"if",
"column",
... | 9136a4ec89555bf9b574399ffbb07f3cc9a9f45f |
train | Tokenizer.rules | Function to tokenize input string and return output of str with ortho rules
applied.
Parameters
----------
word : str
The input string to be tokenized.
Returns
-------
result : str
Result of the orthography rules applied to the input str. | src/segments/tokenizer.py | def rules(self, word):
"""
Function to tokenize input string and return output of str with ortho rules
applied.
Parameters
----------
word : str
The input string to be tokenized.
Returns
-------
result : str
Result of the ... | def rules(self, word):
"""
Function to tokenize input string and return output of str with ortho rules
applied.
Parameters
----------
word : str
The input string to be tokenized.
Returns
-------
result : str
Result of the ... | [
"Function",
"to",
"tokenize",
"input",
"string",
"and",
"return",
"output",
"of",
"str",
"with",
"ortho",
"rules",
"applied",
"."
] | cldf/segments | python | https://github.com/cldf/segments/blob/9136a4ec89555bf9b574399ffbb07f3cc9a9f45f/src/segments/tokenizer.py#L272-L288 | [
"def",
"rules",
"(",
"self",
",",
"word",
")",
":",
"return",
"self",
".",
"_rules",
".",
"apply",
"(",
"word",
")",
"if",
"self",
".",
"_rules",
"else",
"word"
] | 9136a4ec89555bf9b574399ffbb07f3cc9a9f45f |
train | Tokenizer.combine_modifiers | Given a string that is space-delimited on Unicode grapheme clusters,
group Unicode modifier letters with their preceding base characters,
deal with tie bars, etc.
Parameters
----------
string : str
A Unicode string tokenized into grapheme clusters to be tokenized int... | src/segments/tokenizer.py | def combine_modifiers(self, graphemes):
"""
Given a string that is space-delimited on Unicode grapheme clusters,
group Unicode modifier letters with their preceding base characters,
deal with tie bars, etc.
Parameters
----------
string : str
A Unicode... | def combine_modifiers(self, graphemes):
"""
Given a string that is space-delimited on Unicode grapheme clusters,
group Unicode modifier letters with their preceding base characters,
deal with tie bars, etc.
Parameters
----------
string : str
A Unicode... | [
"Given",
"a",
"string",
"that",
"is",
"space",
"-",
"delimited",
"on",
"Unicode",
"grapheme",
"clusters",
"group",
"Unicode",
"modifier",
"letters",
"with",
"their",
"preceding",
"base",
"characters",
"deal",
"with",
"tie",
"bars",
"etc",
"."
] | cldf/segments | python | https://github.com/cldf/segments/blob/9136a4ec89555bf9b574399ffbb07f3cc9a9f45f/src/segments/tokenizer.py#L290-L349 | [
"def",
"combine_modifiers",
"(",
"self",
",",
"graphemes",
")",
":",
"result",
"=",
"[",
"]",
"temp",
"=",
"\"\"",
"count",
"=",
"len",
"(",
"graphemes",
")",
"for",
"grapheme",
"in",
"reversed",
"(",
"graphemes",
")",
":",
"count",
"-=",
"1",
"if",
... | 9136a4ec89555bf9b574399ffbb07f3cc9a9f45f |
train | parse_catalytic | parse catalytic RNAs to gff format | ctbBio/rRNA_insertions_gff.py | def parse_catalytic(insertion, gff):
"""
parse catalytic RNAs to gff format
"""
offset = insertion['offset']
GeneStrand = insertion['strand']
if type(insertion['intron']) is not str:
return gff
for intron in parse_fasta(insertion['intron'].split('|')):
ID, annot, strand, pos ... | def parse_catalytic(insertion, gff):
"""
parse catalytic RNAs to gff format
"""
offset = insertion['offset']
GeneStrand = insertion['strand']
if type(insertion['intron']) is not str:
return gff
for intron in parse_fasta(insertion['intron'].split('|')):
ID, annot, strand, pos ... | [
"parse",
"catalytic",
"RNAs",
"to",
"gff",
"format"
] | christophertbrown/bioscripts | python | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/rRNA_insertions_gff.py#L13-L40 | [
"def",
"parse_catalytic",
"(",
"insertion",
",",
"gff",
")",
":",
"offset",
"=",
"insertion",
"[",
"'offset'",
"]",
"GeneStrand",
"=",
"insertion",
"[",
"'strand'",
"]",
"if",
"type",
"(",
"insertion",
"[",
"'intron'",
"]",
")",
"is",
"not",
"str",
":",
... | 83b2566b3a5745437ec651cd6cafddd056846240 |
train | parse_orf | parse ORF to gff format | ctbBio/rRNA_insertions_gff.py | def parse_orf(insertion, gff):
"""
parse ORF to gff format
"""
offset = insertion['offset']
if type(insertion['orf']) is not str:
return gff
for orf in parse_fasta(insertion['orf'].split('|')):
ID = orf[0].split('>')[1].split()[0]
Start, End, strand = [int(i) for i in orf... | def parse_orf(insertion, gff):
"""
parse ORF to gff format
"""
offset = insertion['offset']
if type(insertion['orf']) is not str:
return gff
for orf in parse_fasta(insertion['orf'].split('|')):
ID = orf[0].split('>')[1].split()[0]
Start, End, strand = [int(i) for i in orf... | [
"parse",
"ORF",
"to",
"gff",
"format"
] | christophertbrown/bioscripts | python | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/rRNA_insertions_gff.py#L42-L76 | [
"def",
"parse_orf",
"(",
"insertion",
",",
"gff",
")",
":",
"offset",
"=",
"insertion",
"[",
"'offset'",
"]",
"if",
"type",
"(",
"insertion",
"[",
"'orf'",
"]",
")",
"is",
"not",
"str",
":",
"return",
"gff",
"for",
"orf",
"in",
"parse_fasta",
"(",
"i... | 83b2566b3a5745437ec651cd6cafddd056846240 |
train | parse_insertion | parse insertion to gff format | ctbBio/rRNA_insertions_gff.py | def parse_insertion(insertion, gff):
"""
parse insertion to gff format
"""
offset = insertion['offset']
for ins in parse_fasta(insertion['insertion sequence'].split('|')):
strand = insertion['strand']
ID = ins[0].split('>')[1].split()[0]
Start, End = [int(i) for i in ins[0].s... | def parse_insertion(insertion, gff):
"""
parse insertion to gff format
"""
offset = insertion['offset']
for ins in parse_fasta(insertion['insertion sequence'].split('|')):
strand = insertion['strand']
ID = ins[0].split('>')[1].split()[0]
Start, End = [int(i) for i in ins[0].s... | [
"parse",
"insertion",
"to",
"gff",
"format"
] | christophertbrown/bioscripts | python | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/rRNA_insertions_gff.py#L78-L99 | [
"def",
"parse_insertion",
"(",
"insertion",
",",
"gff",
")",
":",
"offset",
"=",
"insertion",
"[",
"'offset'",
"]",
"for",
"ins",
"in",
"parse_fasta",
"(",
"insertion",
"[",
"'insertion sequence'",
"]",
".",
"split",
"(",
"'|'",
")",
")",
":",
"strand",
... | 83b2566b3a5745437ec651cd6cafddd056846240 |
train | parse_rRNA | parse rRNA to gff format | ctbBio/rRNA_insertions_gff.py | def parse_rRNA(insertion, seq, gff):
"""
parse rRNA to gff format
"""
offset = insertion['offset']
strand = insertion['strand']
for rRNA in parse_masked(seq, 0)[0]:
rRNA = ''.join(rRNA)
Start = seq[1].find(rRNA) + 1
End = Start + len(rRNA) - 1
if strand == '-':
... | def parse_rRNA(insertion, seq, gff):
"""
parse rRNA to gff format
"""
offset = insertion['offset']
strand = insertion['strand']
for rRNA in parse_masked(seq, 0)[0]:
rRNA = ''.join(rRNA)
Start = seq[1].find(rRNA) + 1
End = Start + len(rRNA) - 1
if strand == '-':
... | [
"parse",
"rRNA",
"to",
"gff",
"format"
] | christophertbrown/bioscripts | python | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/rRNA_insertions_gff.py#L122-L147 | [
"def",
"parse_rRNA",
"(",
"insertion",
",",
"seq",
",",
"gff",
")",
":",
"offset",
"=",
"insertion",
"[",
"'offset'",
"]",
"strand",
"=",
"insertion",
"[",
"'strand'",
"]",
"for",
"rRNA",
"in",
"parse_masked",
"(",
"seq",
",",
"0",
")",
"[",
"0",
"]"... | 83b2566b3a5745437ec651cd6cafddd056846240 |
train | iTable2GFF | convert iTable to gff file | ctbBio/rRNA_insertions_gff.py | def iTable2GFF(iTable, fa, contig = False):
"""
convert iTable to gff file
"""
columns = ['#seqname', 'source', 'feature', 'start', 'end', 'score', 'strand', 'frame', 'attribute']
gff = {c:[] for c in columns}
for insertion in iTable.iterrows():
insertion = insertion[1]
if insert... | def iTable2GFF(iTable, fa, contig = False):
"""
convert iTable to gff file
"""
columns = ['#seqname', 'source', 'feature', 'start', 'end', 'score', 'strand', 'frame', 'attribute']
gff = {c:[] for c in columns}
for insertion in iTable.iterrows():
insertion = insertion[1]
if insert... | [
"convert",
"iTable",
"to",
"gff",
"file"
] | christophertbrown/bioscripts | python | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/rRNA_insertions_gff.py#L149-L197 | [
"def",
"iTable2GFF",
"(",
"iTable",
",",
"fa",
",",
"contig",
"=",
"False",
")",
":",
"columns",
"=",
"[",
"'#seqname'",
",",
"'source'",
",",
"'feature'",
",",
"'start'",
",",
"'end'",
",",
"'score'",
",",
"'strand'",
",",
"'frame'",
",",
"'attribute'",... | 83b2566b3a5745437ec651cd6cafddd056846240 |
train | plot_kde | Plot a smoothed (by kernel density estimate) histogram.
:type data: numpy array
:param data: An array containing the data to be plotted
:type ax: matplotlib.Axes
:param ax: The Axes object to draw to
:type title: str
:param title: The plot title
:type color: str
:param color: The colo... | phylotoast/graph_util.py | def plot_kde(data, ax, title=None, color='r', fill_bt=True):
"""
Plot a smoothed (by kernel density estimate) histogram.
:type data: numpy array
:param data: An array containing the data to be plotted
:type ax: matplotlib.Axes
:param ax: The Axes object to draw to
:type title: str
:par... | def plot_kde(data, ax, title=None, color='r', fill_bt=True):
"""
Plot a smoothed (by kernel density estimate) histogram.
:type data: numpy array
:param data: An array containing the data to be plotted
:type ax: matplotlib.Axes
:param ax: The Axes object to draw to
:type title: str
:par... | [
"Plot",
"a",
"smoothed",
"(",
"by",
"kernel",
"density",
"estimate",
")",
"histogram",
".",
":",
"type",
"data",
":",
"numpy",
"array",
":",
"param",
"data",
":",
"An",
"array",
"containing",
"the",
"data",
"to",
"be",
"plotted"
] | smdabdoub/phylotoast | python | https://github.com/smdabdoub/phylotoast/blob/0b74ef171e6a84761710548501dfac71285a58a3/phylotoast/graph_util.py#L28-L57 | [
"def",
"plot_kde",
"(",
"data",
",",
"ax",
",",
"title",
"=",
"None",
",",
"color",
"=",
"'r'",
",",
"fill_bt",
"=",
"True",
")",
":",
"if",
"isinstance",
"(",
"data",
",",
"list",
")",
":",
"data",
"=",
"np",
".",
"asarray",
"(",
"data",
")",
... | 0b74ef171e6a84761710548501dfac71285a58a3 |
train | ggplot2_style | Styles an axes to appear like ggplot2
Must be called after all plot and axis manipulation operations have been
carried out (needs to know final tick spacing) | phylotoast/graph_util.py | def ggplot2_style(ax):
"""
Styles an axes to appear like ggplot2
Must be called after all plot and axis manipulation operations have been
carried out (needs to know final tick spacing)
"""
#set the style of the major and minor grid lines, filled blocks
ax.grid(True, 'major', color='w', lines... | def ggplot2_style(ax):
"""
Styles an axes to appear like ggplot2
Must be called after all plot and axis manipulation operations have been
carried out (needs to know final tick spacing)
"""
#set the style of the major and minor grid lines, filled blocks
ax.grid(True, 'major', color='w', lines... | [
"Styles",
"an",
"axes",
"to",
"appear",
"like",
"ggplot2",
"Must",
"be",
"called",
"after",
"all",
"plot",
"and",
"axis",
"manipulation",
"operations",
"have",
"been",
"carried",
"out",
"(",
"needs",
"to",
"know",
"final",
"tick",
"spacing",
")"
] | smdabdoub/phylotoast | python | https://github.com/smdabdoub/phylotoast/blob/0b74ef171e6a84761710548501dfac71285a58a3/phylotoast/graph_util.py#L59-L100 | [
"def",
"ggplot2_style",
"(",
"ax",
")",
":",
"#set the style of the major and minor grid lines, filled blocks",
"ax",
".",
"grid",
"(",
"True",
",",
"'major'",
",",
"color",
"=",
"'w'",
",",
"linestyle",
"=",
"'-'",
",",
"linewidth",
"=",
"1.4",
")",
"ax",
"."... | 0b74ef171e6a84761710548501dfac71285a58a3 |
train | summarize_taxa | Given an abundance table, group the counts by every
taxonomic level. | bin/biom_phyla_summary.py | def summarize_taxa(biom):
"""
Given an abundance table, group the counts by every
taxonomic level.
"""
tamtcounts = defaultdict(int)
tot_seqs = 0.0
for row, col, amt in biom['data']:
tot_seqs += amt
rtax = biom['rows'][row]['metadata']['taxonomy']
for i, t in enumera... | def summarize_taxa(biom):
"""
Given an abundance table, group the counts by every
taxonomic level.
"""
tamtcounts = defaultdict(int)
tot_seqs = 0.0
for row, col, amt in biom['data']:
tot_seqs += amt
rtax = biom['rows'][row]['metadata']['taxonomy']
for i, t in enumera... | [
"Given",
"an",
"abundance",
"table",
"group",
"the",
"counts",
"by",
"every",
"taxonomic",
"level",
"."
] | smdabdoub/phylotoast | python | https://github.com/smdabdoub/phylotoast/blob/0b74ef171e6a84761710548501dfac71285a58a3/bin/biom_phyla_summary.py#L27-L46 | [
"def",
"summarize_taxa",
"(",
"biom",
")",
":",
"tamtcounts",
"=",
"defaultdict",
"(",
"int",
")",
"tot_seqs",
"=",
"0.0",
"for",
"row",
",",
"col",
",",
"amt",
"in",
"biom",
"[",
"'data'",
"]",
":",
"tot_seqs",
"+=",
"amt",
"rtax",
"=",
"biom",
"[",... | 0b74ef171e6a84761710548501dfac71285a58a3 |
train | connect_forwarder | connect_forwarder
:param forward_host: host for receiving forwarded packets
:param forward_port: port for the forwarded packets
:param max_retries: retries, -1 = infinite
:param sleep_interval: how often to retry in this loop | network_pipeline/connect_forwarder.py | def connect_forwarder(forward_host=None,
forward_port=None,
max_retries=-1,
sleep_interval=1.0):
"""connect_forwarder
:param forward_host: host for receiving forwarded packets
:param forward_port: port for the forwarded packets
:param ma... | def connect_forwarder(forward_host=None,
forward_port=None,
max_retries=-1,
sleep_interval=1.0):
"""connect_forwarder
:param forward_host: host for receiving forwarded packets
:param forward_port: port for the forwarded packets
:param ma... | [
"connect_forwarder"
] | jay-johnson/network-pipeline | python | https://github.com/jay-johnson/network-pipeline/blob/4e53ae13fe12085e0cf2e5e1aff947368f4f1ffa/network_pipeline/connect_forwarder.py#L10-L56 | [
"def",
"connect_forwarder",
"(",
"forward_host",
"=",
"None",
",",
"forward_port",
"=",
"None",
",",
"max_retries",
"=",
"-",
"1",
",",
"sleep_interval",
"=",
"1.0",
")",
":",
"forward_skt",
"=",
"None",
"retry_count",
"=",
"0",
"if",
"max_retries",
"==",
... | 4e53ae13fe12085e0cf2e5e1aff947368f4f1ffa |
train | Game.custom_image | Returns the path to the custom image set for this game, or None if
no image is set | pysteam/legacy/game.py | def custom_image(self, user):
"""Returns the path to the custom image set for this game, or None if
no image is set"""
for ext in self.valid_custom_image_extensions():
image_location = self._custom_image_path(user, ext)
if os.path.isfile(image_location):
r... | def custom_image(self, user):
"""Returns the path to the custom image set for this game, or None if
no image is set"""
for ext in self.valid_custom_image_extensions():
image_location = self._custom_image_path(user, ext)
if os.path.isfile(image_location):
r... | [
"Returns",
"the",
"path",
"to",
"the",
"custom",
"image",
"set",
"for",
"this",
"game",
"or",
"None",
"if",
"no",
"image",
"is",
"set"
] | scottrice/pysteam | python | https://github.com/scottrice/pysteam/blob/1eb2254b5235a053a953e596fa7602d0b110245d/pysteam/legacy/game.py#L41-L48 | [
"def",
"custom_image",
"(",
"self",
",",
"user",
")",
":",
"for",
"ext",
"in",
"self",
".",
"valid_custom_image_extensions",
"(",
")",
":",
"image_location",
"=",
"self",
".",
"_custom_image_path",
"(",
"user",
",",
"ext",
")",
"if",
"os",
".",
"path",
"... | 1eb2254b5235a053a953e596fa7602d0b110245d |
train | Game.set_image | Sets a custom image for the game. `image_path` should refer to
an image file on disk | pysteam/legacy/game.py | def set_image(self, user, image_path):
"""Sets a custom image for the game. `image_path` should refer to
an image file on disk"""
_, ext = os.path.splitext(image_path)
shutil.copy(image_path, self._custom_image_path(user, ext)) | def set_image(self, user, image_path):
"""Sets a custom image for the game. `image_path` should refer to
an image file on disk"""
_, ext = os.path.splitext(image_path)
shutil.copy(image_path, self._custom_image_path(user, ext)) | [
"Sets",
"a",
"custom",
"image",
"for",
"the",
"game",
".",
"image_path",
"should",
"refer",
"to",
"an",
"image",
"file",
"on",
"disk"
] | scottrice/pysteam | python | https://github.com/scottrice/pysteam/blob/1eb2254b5235a053a953e596fa7602d0b110245d/pysteam/legacy/game.py#L50-L54 | [
"def",
"set_image",
"(",
"self",
",",
"user",
",",
"image_path",
")",
":",
"_",
",",
"ext",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"image_path",
")",
"shutil",
".",
"copy",
"(",
"image_path",
",",
"self",
".",
"_custom_image_path",
"(",
"user",
... | 1eb2254b5235a053a953e596fa7602d0b110245d |
train | sam_list | get a list of mapped reads | ctbBio/filter_fastq_sam.py | def sam_list(sam):
"""
get a list of mapped reads
"""
list = []
for file in sam:
for line in file:
if line.startswith('@') is False:
line = line.strip().split()
id, map = line[0], int(line[1])
if map != 4 and map != 8:
list.append(id)
return set(list) | def sam_list(sam):
"""
get a list of mapped reads
"""
list = []
for file in sam:
for line in file:
if line.startswith('@') is False:
line = line.strip().split()
id, map = line[0], int(line[1])
if map != 4 and map != 8:
list.append(id)
return set(list) | [
"get",
"a",
"list",
"of",
"mapped",
"reads"
] | christophertbrown/bioscripts | python | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/filter_fastq_sam.py#L7-L19 | [
"def",
"sam_list",
"(",
"sam",
")",
":",
"list",
"=",
"[",
"]",
"for",
"file",
"in",
"sam",
":",
"for",
"line",
"in",
"file",
":",
"if",
"line",
".",
"startswith",
"(",
"'@'",
")",
"is",
"False",
":",
"line",
"=",
"line",
".",
"strip",
"(",
")"... | 83b2566b3a5745437ec651cd6cafddd056846240 |
train | sam_list_paired | get a list of mapped reads
require that both pairs are mapped in the sam file in order to remove the reads | ctbBio/filter_fastq_sam.py | def sam_list_paired(sam):
"""
get a list of mapped reads
require that both pairs are mapped in the sam file in order to remove the reads
"""
list = []
pair = ['1', '2']
prev = ''
for file in sam:
for line in file:
if line.startswith('@') is False:
line = line.strip().split()
id, map = line[0], int(... | def sam_list_paired(sam):
"""
get a list of mapped reads
require that both pairs are mapped in the sam file in order to remove the reads
"""
list = []
pair = ['1', '2']
prev = ''
for file in sam:
for line in file:
if line.startswith('@') is False:
line = line.strip().split()
id, map = line[0], int(... | [
"get",
"a",
"list",
"of",
"mapped",
"reads",
"require",
"that",
"both",
"pairs",
"are",
"mapped",
"in",
"the",
"sam",
"file",
"in",
"order",
"to",
"remove",
"the",
"reads"
] | christophertbrown/bioscripts | python | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/filter_fastq_sam.py#L21-L39 | [
"def",
"sam_list_paired",
"(",
"sam",
")",
":",
"list",
"=",
"[",
"]",
"pair",
"=",
"[",
"'1'",
",",
"'2'",
"]",
"prev",
"=",
"''",
"for",
"file",
"in",
"sam",
":",
"for",
"line",
"in",
"file",
":",
"if",
"line",
".",
"startswith",
"(",
"'@'",
... | 83b2566b3a5745437ec651cd6cafddd056846240 |
train | filter_paired | require that both pairs are mapped in the sam file in order to remove the reads | ctbBio/filter_fastq_sam.py | def filter_paired(list):
"""
require that both pairs are mapped in the sam file in order to remove the reads
"""
pairs = {}
filtered = []
for id in list:
read = id.rsplit('/')[0]
if read not in pairs:
pairs[read] = []
pairs[read].append(id)
for read in pairs:
ids = pairs[read]
if len(ids) == 2:
f... | def filter_paired(list):
"""
require that both pairs are mapped in the sam file in order to remove the reads
"""
pairs = {}
filtered = []
for id in list:
read = id.rsplit('/')[0]
if read not in pairs:
pairs[read] = []
pairs[read].append(id)
for read in pairs:
ids = pairs[read]
if len(ids) == 2:
f... | [
"require",
"that",
"both",
"pairs",
"are",
"mapped",
"in",
"the",
"sam",
"file",
"in",
"order",
"to",
"remove",
"the",
"reads"
] | christophertbrown/bioscripts | python | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/filter_fastq_sam.py#L41-L56 | [
"def",
"filter_paired",
"(",
"list",
")",
":",
"pairs",
"=",
"{",
"}",
"filtered",
"=",
"[",
"]",
"for",
"id",
"in",
"list",
":",
"read",
"=",
"id",
".",
"rsplit",
"(",
"'/'",
")",
"[",
"0",
"]",
"if",
"read",
"not",
"in",
"pairs",
":",
"pairs"... | 83b2566b3a5745437ec651cd6cafddd056846240 |
train | filter | filter sequences that are shown to be mapped in the sam file
reads not in sam file are in *.filtered.fastq
reads that are in the sam file are in *.matched.fastq | ctbBio/filter_fastq_sam.py | def filter(fastq, sam, paired = False):
"""
filter sequences that are shown to be mapped in the sam file
reads not in sam file are in *.filtered.fastq
reads that are in the sam file are in *.matched.fastq
"""
if paired is False:
list = sam_list(sam)
else:
list = sam_list_paired(sam)
if paired is False:
f... | def filter(fastq, sam, paired = False):
"""
filter sequences that are shown to be mapped in the sam file
reads not in sam file are in *.filtered.fastq
reads that are in the sam file are in *.matched.fastq
"""
if paired is False:
list = sam_list(sam)
else:
list = sam_list_paired(sam)
if paired is False:
f... | [
"filter",
"sequences",
"that",
"are",
"shown",
"to",
"be",
"mapped",
"in",
"the",
"sam",
"file",
"reads",
"not",
"in",
"sam",
"file",
"are",
"in",
"*",
".",
"filtered",
".",
"fastq",
"reads",
"that",
"are",
"in",
"the",
"sam",
"file",
"are",
"in",
"*... | christophertbrown/bioscripts | python | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/filter_fastq_sam.py#L111-L124 | [
"def",
"filter",
"(",
"fastq",
",",
"sam",
",",
"paired",
"=",
"False",
")",
":",
"if",
"paired",
"is",
"False",
":",
"list",
"=",
"sam_list",
"(",
"sam",
")",
"else",
":",
"list",
"=",
"sam_list_paired",
"(",
"sam",
")",
"if",
"paired",
"is",
"Fal... | 83b2566b3a5745437ec651cd6cafddd056846240 |
train | handle_processing_packets | handle_processing_packets
Replacement packet processing engine. This is not done. | network_pipeline/scripts/consolidate_packets.py | def handle_processing_packets():
"""handle_processing_packets
Replacement packet processing engine. This is not done.
"""
host = os.getenv(
"LISTEN_ON_HOST",
"127.0.0.1").strip().lstrip()
port = int(os.getenv(
"LISTEN_ON_PORT",
"80").strip().lstrip())
backlog =... | def handle_processing_packets():
"""handle_processing_packets
Replacement packet processing engine. This is not done.
"""
host = os.getenv(
"LISTEN_ON_HOST",
"127.0.0.1").strip().lstrip()
port = int(os.getenv(
"LISTEN_ON_PORT",
"80").strip().lstrip())
backlog =... | [
"handle_processing_packets"
] | jay-johnson/network-pipeline | python | https://github.com/jay-johnson/network-pipeline/blob/4e53ae13fe12085e0cf2e5e1aff947368f4f1ffa/network_pipeline/scripts/consolidate_packets.py#L24-L184 | [
"def",
"handle_processing_packets",
"(",
")",
":",
"host",
"=",
"os",
".",
"getenv",
"(",
"\"LISTEN_ON_HOST\"",
",",
"\"127.0.0.1\"",
")",
".",
"strip",
"(",
")",
".",
"lstrip",
"(",
")",
"port",
"=",
"int",
"(",
"os",
".",
"getenv",
"(",
"\"LISTEN_ON_PO... | 4e53ae13fe12085e0cf2e5e1aff947368f4f1ffa |
train | listen_on_udp_port | listen_on_udp_port
Run a simple server for processing messages over ``UDP``.
``UDP_LISTEN_ON_HOST`` - listen on this host ip address
``UDP_LISTEN_ON_PORT`` - listen on this ``UDP`` port
``UDP_LISTEN_SIZE`` - listen on to packets of this size
``UDP_LISTEN_SLEEP`` - sleep this number of seconds p... | network_pipeline/scripts/listen_udp_port.py | def listen_on_udp_port():
"""listen_on_udp_port
Run a simple server for processing messages over ``UDP``.
``UDP_LISTEN_ON_HOST`` - listen on this host ip address
``UDP_LISTEN_ON_PORT`` - listen on this ``UDP`` port
``UDP_LISTEN_SIZE`` - listen on to packets of this size
``UDP_LISTEN_SLEEP``... | def listen_on_udp_port():
"""listen_on_udp_port
Run a simple server for processing messages over ``UDP``.
``UDP_LISTEN_ON_HOST`` - listen on this host ip address
``UDP_LISTEN_ON_PORT`` - listen on this ``UDP`` port
``UDP_LISTEN_SIZE`` - listen on to packets of this size
``UDP_LISTEN_SLEEP``... | [
"listen_on_udp_port"
] | jay-johnson/network-pipeline | python | https://github.com/jay-johnson/network-pipeline/blob/4e53ae13fe12085e0cf2e5e1aff947368f4f1ffa/network_pipeline/scripts/listen_udp_port.py#L10-L101 | [
"def",
"listen_on_udp_port",
"(",
")",
":",
"host",
"=",
"os",
".",
"getenv",
"(",
"\"UDP_LISTEN_ON_HOST\"",
",",
"\"127.0.0.1\"",
")",
".",
"strip",
"(",
")",
".",
"lstrip",
"(",
")",
"port",
"=",
"int",
"(",
"os",
".",
"getenv",
"(",
"\"UDP_LISTEN_ON_P... | 4e53ae13fe12085e0cf2e5e1aff947368f4f1ffa |
train | send_udp_message | send_udp_message
Send a ``UDP`` message to port 80 by default.
Environment variables:
``UDP_SEND_TO_HOST`` - host ip address
``UDP_SEND_TO_PORT`` - send to this UDP port | network_pipeline/scripts/udp_send_msg.py | def send_udp_message():
"""send_udp_message
Send a ``UDP`` message to port 80 by default.
Environment variables:
``UDP_SEND_TO_HOST`` - host ip address
``UDP_SEND_TO_PORT`` - send to this UDP port
"""
host = os.getenv(
"UDP_SEND_TO_HOST",
"0.0.0.0").strip().lstrip()
p... | def send_udp_message():
"""send_udp_message
Send a ``UDP`` message to port 80 by default.
Environment variables:
``UDP_SEND_TO_HOST`` - host ip address
``UDP_SEND_TO_PORT`` - send to this UDP port
"""
host = os.getenv(
"UDP_SEND_TO_HOST",
"0.0.0.0").strip().lstrip()
p... | [
"send_udp_message"
] | jay-johnson/network-pipeline | python | https://github.com/jay-johnson/network-pipeline/blob/4e53ae13fe12085e0cf2e5e1aff947368f4f1ffa/network_pipeline/scripts/udp_send_msg.py#L9-L48 | [
"def",
"send_udp_message",
"(",
")",
":",
"host",
"=",
"os",
".",
"getenv",
"(",
"\"UDP_SEND_TO_HOST\"",
",",
"\"0.0.0.0\"",
")",
".",
"strip",
"(",
")",
".",
"lstrip",
"(",
")",
"port",
"=",
"int",
"(",
"os",
".",
"getenv",
"(",
"\"UDP_SEND_TO_PORT\"",
... | 4e53ae13fe12085e0cf2e5e1aff947368f4f1ffa |
train | sam2fastq | print fastq from sam | ctbBio/mapped.py | def sam2fastq(line):
"""
print fastq from sam
"""
fastq = []
fastq.append('@%s' % line[0])
fastq.append(line[9])
fastq.append('+%s' % line[0])
fastq.append(line[10])
return fastq | def sam2fastq(line):
"""
print fastq from sam
"""
fastq = []
fastq.append('@%s' % line[0])
fastq.append(line[9])
fastq.append('+%s' % line[0])
fastq.append(line[10])
return fastq | [
"print",
"fastq",
"from",
"sam"
] | christophertbrown/bioscripts | python | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/mapped.py#L13-L22 | [
"def",
"sam2fastq",
"(",
"line",
")",
":",
"fastq",
"=",
"[",
"]",
"fastq",
".",
"append",
"(",
"'@%s'",
"%",
"line",
"[",
"0",
"]",
")",
"fastq",
".",
"append",
"(",
"line",
"[",
"9",
"]",
")",
"fastq",
".",
"append",
"(",
"'+%s'",
"%",
"line"... | 83b2566b3a5745437ec651cd6cafddd056846240 |
train | count_mismatches | look for NM:i:<N> flag to determine number of mismatches | ctbBio/mapped.py | def count_mismatches(read):
"""
look for NM:i:<N> flag to determine number of mismatches
"""
if read is False:
return False
mm = [int(i.split(':')[2]) for i in read[11:] if i.startswith('NM:i:')]
if len(mm) > 0:
return sum(mm)
else:
return False | def count_mismatches(read):
"""
look for NM:i:<N> flag to determine number of mismatches
"""
if read is False:
return False
mm = [int(i.split(':')[2]) for i in read[11:] if i.startswith('NM:i:')]
if len(mm) > 0:
return sum(mm)
else:
return False | [
"look",
"for",
"NM",
":",
"i",
":",
"<N",
">",
"flag",
"to",
"determine",
"number",
"of",
"mismatches"
] | christophertbrown/bioscripts | python | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/mapped.py#L24-L34 | [
"def",
"count_mismatches",
"(",
"read",
")",
":",
"if",
"read",
"is",
"False",
":",
"return",
"False",
"mm",
"=",
"[",
"int",
"(",
"i",
".",
"split",
"(",
"':'",
")",
"[",
"2",
"]",
")",
"for",
"i",
"in",
"read",
"[",
"11",
":",
"]",
"if",
"i... | 83b2566b3a5745437ec651cd6cafddd056846240 |
train | check_mismatches | - check to see if the read maps with <= threshold number of mismatches
- mm_option = 'one' or 'both' depending on whether or not one or both reads
in a pair need to pass the mismatch threshold
- pair can be False if read does not have a pair
- make sure alignment score is not 0, which would indicate ... | ctbBio/mapped.py | def check_mismatches(read, pair, mismatches, mm_option, req_map):
"""
- check to see if the read maps with <= threshold number of mismatches
- mm_option = 'one' or 'both' depending on whether or not one or both reads
in a pair need to pass the mismatch threshold
- pair can be False if read does n... | def check_mismatches(read, pair, mismatches, mm_option, req_map):
"""
- check to see if the read maps with <= threshold number of mismatches
- mm_option = 'one' or 'both' depending on whether or not one or both reads
in a pair need to pass the mismatch threshold
- pair can be False if read does n... | [
"-",
"check",
"to",
"see",
"if",
"the",
"read",
"maps",
"with",
"<",
"=",
"threshold",
"number",
"of",
"mismatches",
"-",
"mm_option",
"=",
"one",
"or",
"both",
"depending",
"on",
"whether",
"or",
"not",
"one",
"or",
"both",
"reads",
"in",
"a",
"pair",... | christophertbrown/bioscripts | python | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/mapped.py#L36-L84 | [
"def",
"check_mismatches",
"(",
"read",
",",
"pair",
",",
"mismatches",
",",
"mm_option",
",",
"req_map",
")",
":",
"# if read is not paired, make sure it is mapped and that mm <= thresh",
"if",
"pair",
"is",
"False",
":",
"mm",
"=",
"count_mismatches",
"(",
"read",
... | 83b2566b3a5745437ec651cd6cafddd056846240 |
train | check_region | determine whether or not reads map to specific region of scaffold | ctbBio/mapped.py | def check_region(read, pair, region):
"""
determine whether or not reads map to specific region of scaffold
"""
if region is False:
return True
for mapping in read, pair:
if mapping is False:
continue
start, length = int(mapping[3]), len(mapping[9])
r = [s... | def check_region(read, pair, region):
"""
determine whether or not reads map to specific region of scaffold
"""
if region is False:
return True
for mapping in read, pair:
if mapping is False:
continue
start, length = int(mapping[3]), len(mapping[9])
r = [s... | [
"determine",
"whether",
"or",
"not",
"reads",
"map",
"to",
"specific",
"region",
"of",
"scaffold"
] | christophertbrown/bioscripts | python | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/mapped.py#L92-L105 | [
"def",
"check_region",
"(",
"read",
",",
"pair",
",",
"region",
")",
":",
"if",
"region",
"is",
"False",
":",
"return",
"True",
"for",
"mapping",
"in",
"read",
",",
"pair",
":",
"if",
"mapping",
"is",
"False",
":",
"continue",
"start",
",",
"length",
... | 83b2566b3a5745437ec651cd6cafddd056846240 |
train | get_reads | get mapped reads (and their pairs) from an unsorted sam file | ctbBio/mapped.py | def get_reads(sam, \
contigs = False, mismatches = False, mm_option = False, \
sort_sam = True, req_map = False, region = False, sbuffer = False):
"""
get mapped reads (and their pairs) from an unsorted sam file
"""
tempdir = '%s/' % (os.path.abspath(sam).rsplit('/', 1)[0])
if sort_s... | def get_reads(sam, \
contigs = False, mismatches = False, mm_option = False, \
sort_sam = True, req_map = False, region = False, sbuffer = False):
"""
get mapped reads (and their pairs) from an unsorted sam file
"""
tempdir = '%s/' % (os.path.abspath(sam).rsplit('/', 1)[0])
if sort_s... | [
"get",
"mapped",
"reads",
"(",
"and",
"their",
"pairs",
")",
"from",
"an",
"unsorted",
"sam",
"file"
] | christophertbrown/bioscripts | python | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/mapped.py#L152-L178 | [
"def",
"get_reads",
"(",
"sam",
",",
"contigs",
"=",
"False",
",",
"mismatches",
"=",
"False",
",",
"mm_option",
"=",
"False",
",",
"sort_sam",
"=",
"True",
",",
"req_map",
"=",
"False",
",",
"region",
"=",
"False",
",",
"sbuffer",
"=",
"False",
")",
... | 83b2566b3a5745437ec651cd6cafddd056846240 |
train | get_steam | Returns a Steam object representing the current Steam installation on the
users computer. If the user doesn't have Steam installed, returns None. | pysteam/steam.py | def get_steam():
"""
Returns a Steam object representing the current Steam installation on the
users computer. If the user doesn't have Steam installed, returns None.
"""
# Helper function which checks if the potential userdata directory exists
# and returns a new Steam instance with that userdata directory... | def get_steam():
"""
Returns a Steam object representing the current Steam installation on the
users computer. If the user doesn't have Steam installed, returns None.
"""
# Helper function which checks if the potential userdata directory exists
# and returns a new Steam instance with that userdata directory... | [
"Returns",
"a",
"Steam",
"object",
"representing",
"the",
"current",
"Steam",
"installation",
"on",
"the",
"users",
"computer",
".",
"If",
"the",
"user",
"doesn",
"t",
"have",
"Steam",
"installed",
"returns",
"None",
"."
] | scottrice/pysteam | python | https://github.com/scottrice/pysteam/blob/1eb2254b5235a053a953e596fa7602d0b110245d/pysteam/steam.py#L12-L43 | [
"def",
"get_steam",
"(",
")",
":",
"# Helper function which checks if the potential userdata directory exists",
"# and returns a new Steam instance with that userdata directory if it does.",
"# If the directory doesnt exist it returns None instead",
"helper",
"=",
"lambda",
"udd",
":",
"St... | 1eb2254b5235a053a953e596fa7602d0b110245d |
train | otu_name | Determine a simple Genus-species identifier for an OTU, if possible.
If OTU is not identified to the species level, name it as
Unclassified (familly/genus/etc...).
:type tax: list
:param tax: QIIME-style taxonomy identifiers, e.g.
["k__Bacteria", u"p__Firmicutes", u"c__Bacilli", ...
... | phylotoast/otu_calc.py | def otu_name(tax):
"""
Determine a simple Genus-species identifier for an OTU, if possible.
If OTU is not identified to the species level, name it as
Unclassified (familly/genus/etc...).
:type tax: list
:param tax: QIIME-style taxonomy identifiers, e.g.
["k__Bacteria", u"p__Fir... | def otu_name(tax):
"""
Determine a simple Genus-species identifier for an OTU, if possible.
If OTU is not identified to the species level, name it as
Unclassified (familly/genus/etc...).
:type tax: list
:param tax: QIIME-style taxonomy identifiers, e.g.
["k__Bacteria", u"p__Fir... | [
"Determine",
"a",
"simple",
"Genus",
"-",
"species",
"identifier",
"for",
"an",
"OTU",
"if",
"possible",
".",
"If",
"OTU",
"is",
"not",
"identified",
"to",
"the",
"species",
"level",
"name",
"it",
"as",
"Unclassified",
"(",
"familly",
"/",
"genus",
"/",
... | smdabdoub/phylotoast | python | https://github.com/smdabdoub/phylotoast/blob/0b74ef171e6a84761710548501dfac71285a58a3/phylotoast/otu_calc.py#L7-L34 | [
"def",
"otu_name",
"(",
"tax",
")",
":",
"extract_name",
"=",
"lambda",
"lvl",
":",
"\"_\"",
".",
"join",
"(",
"lvl",
".",
"split",
"(",
"\"_\"",
")",
"[",
"2",
":",
"]",
")",
"spname",
"=",
"\"spp.\"",
"for",
"lvl",
"in",
"tax",
"[",
":",
":",
... | 0b74ef171e6a84761710548501dfac71285a58a3 |
train | load_core_file | For core OTU data file, returns Genus-species identifier for each data
entry.
:type core_fp: str
:param core_fp: A file containing core OTU data.
:rtype: str
:return: Returns genus-species identifier based on identified taxonomical
level. | phylotoast/otu_calc.py | def load_core_file(core_fp):
"""
For core OTU data file, returns Genus-species identifier for each data
entry.
:type core_fp: str
:param core_fp: A file containing core OTU data.
:rtype: str
:return: Returns genus-species identifier based on identified taxonomical
level.
"""... | def load_core_file(core_fp):
"""
For core OTU data file, returns Genus-species identifier for each data
entry.
:type core_fp: str
:param core_fp: A file containing core OTU data.
:rtype: str
:return: Returns genus-species identifier based on identified taxonomical
level.
"""... | [
"For",
"core",
"OTU",
"data",
"file",
"returns",
"Genus",
"-",
"species",
"identifier",
"for",
"each",
"data",
"entry",
".",
":",
"type",
"core_fp",
":",
"str",
":",
"param",
"core_fp",
":",
"A",
"file",
"containing",
"core",
"OTU",
"data",
".",
":",
"... | smdabdoub/phylotoast | python | https://github.com/smdabdoub/phylotoast/blob/0b74ef171e6a84761710548501dfac71285a58a3/phylotoast/otu_calc.py#L36-L48 | [
"def",
"load_core_file",
"(",
"core_fp",
")",
":",
"with",
"open",
"(",
"core_fp",
",",
"\"rU\"",
")",
"as",
"in_f",
":",
"return",
"{",
"otu_name",
"(",
"ast",
".",
"literal_eval",
"(",
"line",
".",
"split",
"(",
"\"\\t\"",
")",
"[",
"1",
"]",
")",
... | 0b74ef171e6a84761710548501dfac71285a58a3 |
train | assign_otu_membership | Determines the OTUIDs present in each sample.
:type biomfile: biom.table.Table
:param biomfile: BIOM table object from the biom-format library.
:rtype: dict
:return: Returns a dictionary keyed on Sample ID with sets containing
the IDs of OTUIDs found in each sample. | phylotoast/otu_calc.py | def assign_otu_membership(biomfile):
"""
Determines the OTUIDs present in each sample.
:type biomfile: biom.table.Table
:param biomfile: BIOM table object from the biom-format library.
:rtype: dict
:return: Returns a dictionary keyed on Sample ID with sets containing
the IDs of OTUIDs found ... | def assign_otu_membership(biomfile):
"""
Determines the OTUIDs present in each sample.
:type biomfile: biom.table.Table
:param biomfile: BIOM table object from the biom-format library.
:rtype: dict
:return: Returns a dictionary keyed on Sample ID with sets containing
the IDs of OTUIDs found ... | [
"Determines",
"the",
"OTUIDs",
"present",
"in",
"each",
"sample",
".",
":",
"type",
"biomfile",
":",
"biom",
".",
"table",
".",
"Table",
":",
"param",
"biomfile",
":",
"BIOM",
"table",
"object",
"from",
"the",
"biom",
"-",
"format",
"library",
".",
":",
... | smdabdoub/phylotoast | python | https://github.com/smdabdoub/phylotoast/blob/0b74ef171e6a84761710548501dfac71285a58a3/phylotoast/otu_calc.py#L50-L65 | [
"def",
"assign_otu_membership",
"(",
"biomfile",
")",
":",
"samples",
"=",
"defaultdict",
"(",
"set",
")",
"_",
"=",
"biomfile",
".",
"pa",
"(",
")",
"for",
"sid",
"in",
"biomfile",
".",
"ids",
"(",
")",
":",
"for",
"otuid",
"in",
"biomfile",
".",
"i... | 0b74ef171e6a84761710548501dfac71285a58a3 |
train | zero_to_one | normalize from zero to one for row or table | ctbBio/transform.py | def zero_to_one(table, option):
"""
normalize from zero to one for row or table
"""
if option == 'table':
m = min(min(table))
ma = max(max(table))
t = []
for row in table:
t_row = []
if option != 'table':
m, ma = min(row), max(row)
for i in row... | def zero_to_one(table, option):
"""
normalize from zero to one for row or table
"""
if option == 'table':
m = min(min(table))
ma = max(max(table))
t = []
for row in table:
t_row = []
if option != 'table':
m, ma = min(row), max(row)
for i in row... | [
"normalize",
"from",
"zero",
"to",
"one",
"for",
"row",
"or",
"table"
] | christophertbrown/bioscripts | python | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/transform.py#L18-L36 | [
"def",
"zero_to_one",
"(",
"table",
",",
"option",
")",
":",
"if",
"option",
"==",
"'table'",
":",
"m",
"=",
"min",
"(",
"min",
"(",
"table",
")",
")",
"ma",
"=",
"max",
"(",
"max",
"(",
"table",
")",
")",
"t",
"=",
"[",
"]",
"for",
"row",
"i... | 83b2566b3a5745437ec651cd6cafddd056846240 |
train | pertotal | calculate percent of total | ctbBio/transform.py | def pertotal(table, option):
"""
calculate percent of total
"""
if option == 'table':
total = sum([i for line in table for i in line])
t = []
for row in table:
t_row = []
if option != 'table':
total = sum(row)
for i in row:
if total == 0:
... | def pertotal(table, option):
"""
calculate percent of total
"""
if option == 'table':
total = sum([i for line in table for i in line])
t = []
for row in table:
t_row = []
if option != 'table':
total = sum(row)
for i in row:
if total == 0:
... | [
"calculate",
"percent",
"of",
"total"
] | christophertbrown/bioscripts | python | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/transform.py#L38-L55 | [
"def",
"pertotal",
"(",
"table",
",",
"option",
")",
":",
"if",
"option",
"==",
"'table'",
":",
"total",
"=",
"sum",
"(",
"[",
"i",
"for",
"line",
"in",
"table",
"for",
"i",
"in",
"line",
"]",
")",
"t",
"=",
"[",
"]",
"for",
"row",
"in",
"table... | 83b2566b3a5745437ec651cd6cafddd056846240 |
train | standardize | standardize
Z = (X - mean) / (standard deviation) | ctbBio/transform.py | def standardize(table, option):
"""
standardize
Z = (X - mean) / (standard deviation)
"""
if option == 'table':
mean = np.mean(table)
std = np.std(table)
t = []
for row in table:
t_row = []
if option != 'table':
mean = np.mean(row)
std ... | def standardize(table, option):
"""
standardize
Z = (X - mean) / (standard deviation)
"""
if option == 'table':
mean = np.mean(table)
std = np.std(table)
t = []
for row in table:
t_row = []
if option != 'table':
mean = np.mean(row)
std ... | [
"standardize",
"Z",
"=",
"(",
"X",
"-",
"mean",
")",
"/",
"(",
"standard",
"deviation",
")"
] | christophertbrown/bioscripts | python | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/transform.py#L57-L77 | [
"def",
"standardize",
"(",
"table",
",",
"option",
")",
":",
"if",
"option",
"==",
"'table'",
":",
"mean",
"=",
"np",
".",
"mean",
"(",
"table",
")",
"std",
"=",
"np",
".",
"std",
"(",
"table",
")",
"t",
"=",
"[",
"]",
"for",
"row",
"in",
"tabl... | 83b2566b3a5745437ec651cd6cafddd056846240 |
train | scale | scale table based on the column with the largest sum | ctbBio/transform.py | def scale(table):
"""
scale table based on the column with the largest sum
"""
t = []
columns = [[] for i in table[0]]
for row in table:
for i, v in enumerate(row):
columns[i].append(v)
sums = [float(sum(i)) for i in columns]
scale_to = float(max(sums))
scale_fact... | def scale(table):
"""
scale table based on the column with the largest sum
"""
t = []
columns = [[] for i in table[0]]
for row in table:
for i, v in enumerate(row):
columns[i].append(v)
sums = [float(sum(i)) for i in columns]
scale_to = float(max(sums))
scale_fact... | [
"scale",
"table",
"based",
"on",
"the",
"column",
"with",
"the",
"largest",
"sum"
] | christophertbrown/bioscripts | python | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/transform.py#L79-L93 | [
"def",
"scale",
"(",
"table",
")",
":",
"t",
"=",
"[",
"]",
"columns",
"=",
"[",
"[",
"]",
"for",
"i",
"in",
"table",
"[",
"0",
"]",
"]",
"for",
"row",
"in",
"table",
":",
"for",
"i",
",",
"v",
"in",
"enumerate",
"(",
"row",
")",
":",
"colu... | 83b2566b3a5745437ec651cd6cafddd056846240 |
train | norm | fit to normal distribution | ctbBio/transform.py | def norm(table):
"""
fit to normal distribution
"""
print('# norm dist is broken', file=sys.stderr)
exit()
from matplotlib.pyplot import hist as hist
t = []
for i in table:
t.append(np.ndarray.tolist(hist(i, bins = len(i), normed = True)[0]))
return t | def norm(table):
"""
fit to normal distribution
"""
print('# norm dist is broken', file=sys.stderr)
exit()
from matplotlib.pyplot import hist as hist
t = []
for i in table:
t.append(np.ndarray.tolist(hist(i, bins = len(i), normed = True)[0]))
return t | [
"fit",
"to",
"normal",
"distribution"
] | christophertbrown/bioscripts | python | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/transform.py#L95-L105 | [
"def",
"norm",
"(",
"table",
")",
":",
"print",
"(",
"'# norm dist is broken'",
",",
"file",
"=",
"sys",
".",
"stderr",
")",
"exit",
"(",
")",
"from",
"matplotlib",
".",
"pyplot",
"import",
"hist",
"as",
"hist",
"t",
"=",
"[",
"]",
"for",
"i",
"in",
... | 83b2566b3a5745437ec651cd6cafddd056846240 |
train | log_trans | log transform each value in table | ctbBio/transform.py | def log_trans(table):
"""
log transform each value in table
"""
t = []
all = [item for sublist in table for item in sublist]
if min(all) == 0:
scale = min([i for i in all if i != 0]) * 10e-10
else:
scale = 0
for i in table:
t.append(np.ndarray.tolist(np.log10([j +... | def log_trans(table):
"""
log transform each value in table
"""
t = []
all = [item for sublist in table for item in sublist]
if min(all) == 0:
scale = min([i for i in all if i != 0]) * 10e-10
else:
scale = 0
for i in table:
t.append(np.ndarray.tolist(np.log10([j +... | [
"log",
"transform",
"each",
"value",
"in",
"table"
] | christophertbrown/bioscripts | python | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/transform.py#L107-L119 | [
"def",
"log_trans",
"(",
"table",
")",
":",
"t",
"=",
"[",
"]",
"all",
"=",
"[",
"item",
"for",
"sublist",
"in",
"table",
"for",
"item",
"in",
"sublist",
"]",
"if",
"min",
"(",
"all",
")",
"==",
"0",
":",
"scale",
"=",
"min",
"(",
"[",
"i",
"... | 83b2566b3a5745437ec651cd6cafddd056846240 |
train | box_cox | box-cox transform table | ctbBio/transform.py | def box_cox(table):
"""
box-cox transform table
"""
from scipy.stats import boxcox as bc
t = []
for i in table:
if min(i) == 0:
scale = min([j for j in i if j != 0]) * 10e-10
else:
scale = 0
t.append(np.ndarray.tolist(bc(np.array([j + scale for j i... | def box_cox(table):
"""
box-cox transform table
"""
from scipy.stats import boxcox as bc
t = []
for i in table:
if min(i) == 0:
scale = min([j for j in i if j != 0]) * 10e-10
else:
scale = 0
t.append(np.ndarray.tolist(bc(np.array([j + scale for j i... | [
"box",
"-",
"cox",
"transform",
"table"
] | christophertbrown/bioscripts | python | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/transform.py#L121-L133 | [
"def",
"box_cox",
"(",
"table",
")",
":",
"from",
"scipy",
".",
"stats",
"import",
"boxcox",
"as",
"bc",
"t",
"=",
"[",
"]",
"for",
"i",
"in",
"table",
":",
"if",
"min",
"(",
"i",
")",
"==",
"0",
":",
"scale",
"=",
"min",
"(",
"[",
"j",
"for"... | 83b2566b3a5745437ec651cd6cafddd056846240 |
train | inh | inverse hyperbolic sine transformation | ctbBio/transform.py | def inh(table):
"""
inverse hyperbolic sine transformation
"""
t = []
for i in table:
t.append(np.ndarray.tolist(np.arcsinh(i)))
return t | def inh(table):
"""
inverse hyperbolic sine transformation
"""
t = []
for i in table:
t.append(np.ndarray.tolist(np.arcsinh(i)))
return t | [
"inverse",
"hyperbolic",
"sine",
"transformation"
] | christophertbrown/bioscripts | python | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/transform.py#L135-L142 | [
"def",
"inh",
"(",
"table",
")",
":",
"t",
"=",
"[",
"]",
"for",
"i",
"in",
"table",
":",
"t",
".",
"append",
"(",
"np",
".",
"ndarray",
".",
"tolist",
"(",
"np",
".",
"arcsinh",
"(",
"i",
")",
")",
")",
"return",
"t"
] | 83b2566b3a5745437ec651cd6cafddd056846240 |
train | diri | from SparCC - "randomly draw from the corresponding posterior
Dirichlet distribution with a uniform prior" | ctbBio/transform.py | def diri(table):
"""
from SparCC - "randomly draw from the corresponding posterior
Dirichlet distribution with a uniform prior"
"""
t = []
for i in table:
a = [j + 1 for j in i]
t.append(np.ndarray.tolist(np.random.mtrand.dirichlet(a)))
return t | def diri(table):
"""
from SparCC - "randomly draw from the corresponding posterior
Dirichlet distribution with a uniform prior"
"""
t = []
for i in table:
a = [j + 1 for j in i]
t.append(np.ndarray.tolist(np.random.mtrand.dirichlet(a)))
return t | [
"from",
"SparCC",
"-",
"randomly",
"draw",
"from",
"the",
"corresponding",
"posterior",
"Dirichlet",
"distribution",
"with",
"a",
"uniform",
"prior"
] | christophertbrown/bioscripts | python | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/transform.py#L144-L153 | [
"def",
"diri",
"(",
"table",
")",
":",
"t",
"=",
"[",
"]",
"for",
"i",
"in",
"table",
":",
"a",
"=",
"[",
"j",
"+",
"1",
"for",
"j",
"in",
"i",
"]",
"t",
".",
"append",
"(",
"np",
".",
"ndarray",
".",
"tolist",
"(",
"np",
".",
"random",
"... | 83b2566b3a5745437ec651cd6cafddd056846240 |
train | transpose | transpose matrix | ctbBio/transform.py | def transpose(table):
"""
transpose matrix
"""
t = []
for i in range(0, len(table[0])):
t.append([row[i] for row in table])
return t | def transpose(table):
"""
transpose matrix
"""
t = []
for i in range(0, len(table[0])):
t.append([row[i] for row in table])
return t | [
"transpose",
"matrix"
] | christophertbrown/bioscripts | python | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/transform.py#L155-L162 | [
"def",
"transpose",
"(",
"table",
")",
":",
"t",
"=",
"[",
"]",
"for",
"i",
"in",
"range",
"(",
"0",
",",
"len",
"(",
"table",
"[",
"0",
"]",
")",
")",
":",
"t",
".",
"append",
"(",
"[",
"row",
"[",
"i",
"]",
"for",
"row",
"in",
"table",
... | 83b2566b3a5745437ec651cd6cafddd056846240 |
train | transform | transform data table:
option:
rows
columns
table
mode:
0: 0-1
pertotal: percent of total
stand: standardize
scale: scale based on largest column | ctbBio/transform.py | def transform(table, option, mode):
"""
transform data table:
option:
rows
columns
table
mode:
0: 0-1
pertotal: percent of total
stand: standardize
scale: scale based on largest column
"""
if option != 'rows' and option != 'columns' and opt... | def transform(table, option, mode):
"""
transform data table:
option:
rows
columns
table
mode:
0: 0-1
pertotal: percent of total
stand: standardize
scale: scale based on largest column
"""
if option != 'rows' and option != 'columns' and opt... | [
"transform",
"data",
"table",
":",
"option",
":",
"rows",
"columns",
"table",
"mode",
":",
"0",
":",
"0",
"-",
"1",
"pertotal",
":",
"percent",
"of",
"total",
"stand",
":",
"standardize",
"scale",
":",
"scale",
"based",
"on",
"largest",
"column"
] | christophertbrown/bioscripts | python | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/transform.py#L164-L211 | [
"def",
"transform",
"(",
"table",
",",
"option",
",",
"mode",
")",
":",
"if",
"option",
"!=",
"'rows'",
"and",
"option",
"!=",
"'columns'",
"and",
"option",
"!=",
"'table'",
":",
"print",
"(",
"'# specify: rows, columns, or table'",
",",
"file",
"=",
"sys",
... | 83b2566b3a5745437ec651cd6cafddd056846240 |
train | send_tcp_large_message | send_tcp_large_message
Send a large ``TCP`` message to port 80 by default. | network_pipeline/scripts/tcp_send_large_msg.py | def send_tcp_large_message():
"""send_tcp_large_message
Send a large ``TCP`` message to port 80 by default.
"""
need_response = os.getenv("NEED_RESPONSE", "0") == "1"
msg = os.getenv(
"MSG",
"testing msg time={} - {}".format(
datetime.datetime.now().strfti... | def send_tcp_large_message():
"""send_tcp_large_message
Send a large ``TCP`` message to port 80 by default.
"""
need_response = os.getenv("NEED_RESPONSE", "0") == "1"
msg = os.getenv(
"MSG",
"testing msg time={} - {}".format(
datetime.datetime.now().strfti... | [
"send_tcp_large_message"
] | jay-johnson/network-pipeline | python | https://github.com/jay-johnson/network-pipeline/blob/4e53ae13fe12085e0cf2e5e1aff947368f4f1ffa/network_pipeline/scripts/tcp_send_large_msg.py#L9-L40 | [
"def",
"send_tcp_large_message",
"(",
")",
":",
"need_response",
"=",
"os",
".",
"getenv",
"(",
"\"NEED_RESPONSE\"",
",",
"\"0\"",
")",
"==",
"\"1\"",
"msg",
"=",
"os",
".",
"getenv",
"(",
"\"MSG\"",
",",
"\"testing msg time={} - {}\"",
".",
"format",
"(",
"... | 4e53ae13fe12085e0cf2e5e1aff947368f4f1ffa |
train | open_enc | Open a file for reading with either the standard built-in open() or the
open in the codecs module for reading UTF-16 encoded files.
:param fn: Name of the file to open
:param utf16: Boolean flag to specify a UTF-16 file | bin/sanger_qiimify.py | def open_enc(fn, utf16):
"""
Open a file for reading with either the standard built-in open() or the
open in the codecs module for reading UTF-16 encoded files.
:param fn: Name of the file to open
:param utf16: Boolean flag to specify a UTF-16 file
"""
if utf16:
return codecs.open(f... | def open_enc(fn, utf16):
"""
Open a file for reading with either the standard built-in open() or the
open in the codecs module for reading UTF-16 encoded files.
:param fn: Name of the file to open
:param utf16: Boolean flag to specify a UTF-16 file
"""
if utf16:
return codecs.open(f... | [
"Open",
"a",
"file",
"for",
"reading",
"with",
"either",
"the",
"standard",
"built",
"-",
"in",
"open",
"()",
"or",
"the",
"open",
"in",
"the",
"codecs",
"module",
"for",
"reading",
"UTF",
"-",
"16",
"encoded",
"files",
"."
] | smdabdoub/phylotoast | python | https://github.com/smdabdoub/phylotoast/blob/0b74ef171e6a84761710548501dfac71285a58a3/bin/sanger_qiimify.py#L53-L63 | [
"def",
"open_enc",
"(",
"fn",
",",
"utf16",
")",
":",
"if",
"utf16",
":",
"return",
"codecs",
".",
"open",
"(",
"fn",
",",
"encoding",
"=",
"'utf-16'",
")",
"# -be')",
"return",
"open",
"(",
"fn",
",",
"'rU'",
")"
] | 0b74ef171e6a84761710548501dfac71285a58a3 |
train | generate_barcodes | Given a list of sample IDs generate unique n-base barcodes for each.
Note that only 4^n unique barcodes are possible. | bin/sanger_qiimify.py | def generate_barcodes(nIds, codeLen=12):
"""
Given a list of sample IDs generate unique n-base barcodes for each.
Note that only 4^n unique barcodes are possible.
"""
def next_code(b, c, i):
return c[:i] + b + (c[i+1:] if i < -1 else '')
def rand_base():
return random.choice(['A... | def generate_barcodes(nIds, codeLen=12):
"""
Given a list of sample IDs generate unique n-base barcodes for each.
Note that only 4^n unique barcodes are possible.
"""
def next_code(b, c, i):
return c[:i] + b + (c[i+1:] if i < -1 else '')
def rand_base():
return random.choice(['A... | [
"Given",
"a",
"list",
"of",
"sample",
"IDs",
"generate",
"unique",
"n",
"-",
"base",
"barcodes",
"for",
"each",
".",
"Note",
"that",
"only",
"4^n",
"unique",
"barcodes",
"are",
"possible",
"."
] | smdabdoub/phylotoast | python | https://github.com/smdabdoub/phylotoast/blob/0b74ef171e6a84761710548501dfac71285a58a3/bin/sanger_qiimify.py#L94-L128 | [
"def",
"generate_barcodes",
"(",
"nIds",
",",
"codeLen",
"=",
"12",
")",
":",
"def",
"next_code",
"(",
"b",
",",
"c",
",",
"i",
")",
":",
"return",
"c",
"[",
":",
"i",
"]",
"+",
"b",
"+",
"(",
"c",
"[",
"i",
"+",
"1",
":",
"]",
"if",
"i",
... | 0b74ef171e6a84761710548501dfac71285a58a3 |
train | write_mapping_file | Given a mapping from sample IDs to barcodes/primers/other info,
write out a QIIME-compatible mapping file.
File format described at: http://qiime.org/documentation/file_formats.html
Note that primer column can be left blank. | bin/sanger_qiimify.py | def write_mapping_file(mapF, sampleIDs, barcodes, treatment=None):
"""
Given a mapping from sample IDs to barcodes/primers/other info,
write out a QIIME-compatible mapping file.
File format described at: http://qiime.org/documentation/file_formats.html
Note that primer column can be left blank.
... | def write_mapping_file(mapF, sampleIDs, barcodes, treatment=None):
"""
Given a mapping from sample IDs to barcodes/primers/other info,
write out a QIIME-compatible mapping file.
File format described at: http://qiime.org/documentation/file_formats.html
Note that primer column can be left blank.
... | [
"Given",
"a",
"mapping",
"from",
"sample",
"IDs",
"to",
"barcodes",
"/",
"primers",
"/",
"other",
"info",
"write",
"out",
"a",
"QIIME",
"-",
"compatible",
"mapping",
"file",
"."
] | smdabdoub/phylotoast | python | https://github.com/smdabdoub/phylotoast/blob/0b74ef171e6a84761710548501dfac71285a58a3/bin/sanger_qiimify.py#L131-L155 | [
"def",
"write_mapping_file",
"(",
"mapF",
",",
"sampleIDs",
",",
"barcodes",
",",
"treatment",
"=",
"None",
")",
":",
"header",
"=",
"[",
"'#SampleID'",
",",
"'BarcodeSequence'",
",",
"'LinkerPrimerSequence'",
",",
"'Description'",
",",
"'\\n'",
"]",
"if",
"tr... | 0b74ef171e6a84761710548501dfac71285a58a3 |
train | scrobble_data_dir | Given a sample ID and a mapping, modify a Sanger FASTA file
to include the barcode and 'primer' in the sequence data
and change the description line as needed. | bin/sanger_qiimify.py | def scrobble_data_dir(dataDir, sampleMap, outF, qualF=None, idopt=None,
utf16=False):
"""
Given a sample ID and a mapping, modify a Sanger FASTA file
to include the barcode and 'primer' in the sequence data
and change the description line as needed.
"""
seqcount = 0
out... | def scrobble_data_dir(dataDir, sampleMap, outF, qualF=None, idopt=None,
utf16=False):
"""
Given a sample ID and a mapping, modify a Sanger FASTA file
to include the barcode and 'primer' in the sequence data
and change the description line as needed.
"""
seqcount = 0
out... | [
"Given",
"a",
"sample",
"ID",
"and",
"a",
"mapping",
"modify",
"a",
"Sanger",
"FASTA",
"file",
"to",
"include",
"the",
"barcode",
"and",
"primer",
"in",
"the",
"sequence",
"data",
"and",
"change",
"the",
"description",
"line",
"as",
"needed",
"."
] | smdabdoub/phylotoast | python | https://github.com/smdabdoub/phylotoast/blob/0b74ef171e6a84761710548501dfac71285a58a3/bin/sanger_qiimify.py#L158-L199 | [
"def",
"scrobble_data_dir",
"(",
"dataDir",
",",
"sampleMap",
",",
"outF",
",",
"qualF",
"=",
"None",
",",
"idopt",
"=",
"None",
",",
"utf16",
"=",
"False",
")",
":",
"seqcount",
"=",
"0",
"outfiles",
"=",
"[",
"osp",
".",
"split",
"(",
"outF",
".",
... | 0b74ef171e6a84761710548501dfac71285a58a3 |
train | handle_program_options | Uses the built-in argparse module to handle command-line options for the
program.
:return: The gathered command-line options specified by the user
:rtype: argparse.ArgumentParser | bin/sanger_qiimify.py | def handle_program_options():
"""
Uses the built-in argparse module to handle command-line options for the
program.
:return: The gathered command-line options specified by the user
:rtype: argparse.ArgumentParser
"""
parser = argparse.ArgumentParser(description="Convert Sanger-sequencing \
... | def handle_program_options():
"""
Uses the built-in argparse module to handle command-line options for the
program.
:return: The gathered command-line options specified by the user
:rtype: argparse.ArgumentParser
"""
parser = argparse.ArgumentParser(description="Convert Sanger-sequencing \
... | [
"Uses",
"the",
"built",
"-",
"in",
"argparse",
"module",
"to",
"handle",
"command",
"-",
"line",
"options",
"for",
"the",
"program",
"."
] | smdabdoub/phylotoast | python | https://github.com/smdabdoub/phylotoast/blob/0b74ef171e6a84761710548501dfac71285a58a3/bin/sanger_qiimify.py#L202-L271 | [
"def",
"handle_program_options",
"(",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"\"Convert Sanger-sequencing \\\n derived data files for use with the \\\n metagenomics analysi... | 0b74ef171e6a84761710548501dfac71285a58a3 |
train | handle_packets | handle_packets
:param pk: data packet that kamene sends in | network_pipeline/handle_packets.py | def handle_packets(pk):
"""handle_packets
:param pk: data packet that kamene sends in
"""
log.info(("processing with pub={}")
.format(pub))
# get the lowest layer
eth = pk.getlayer(kamene.Ether)
should_forward = False
send_msg = {"data": {},
"created": rn... | def handle_packets(pk):
"""handle_packets
:param pk: data packet that kamene sends in
"""
log.info(("processing with pub={}")
.format(pub))
# get the lowest layer
eth = pk.getlayer(kamene.Ether)
should_forward = False
send_msg = {"data": {},
"created": rn... | [
"handle_packets"
] | jay-johnson/network-pipeline | python | https://github.com/jay-johnson/network-pipeline/blob/4e53ae13fe12085e0cf2e5e1aff947368f4f1ffa/network_pipeline/handle_packets.py#L16-L54 | [
"def",
"handle_packets",
"(",
"pk",
")",
":",
"log",
".",
"info",
"(",
"(",
"\"processing with pub={}\"",
")",
".",
"format",
"(",
"pub",
")",
")",
"# get the lowest layer",
"eth",
"=",
"pk",
".",
"getlayer",
"(",
"kamene",
".",
"Ether",
")",
"should_forwa... | 4e53ae13fe12085e0cf2e5e1aff947368f4f1ffa |
train | find_all_headers | find_all_headers
:param pipeline_files: files to process
:param label_rules: labeling rules | network_pipeline/scripts/builders/prepare_dataset.py | def find_all_headers(
pipeline_files=[],
label_rules=None):
"""find_all_headers
:param pipeline_files: files to process
:param label_rules: labeling rules
"""
log.info("find_all_headers - START")
headers = ["src_file"]
headers_dict = {"src_file": None}
if label_rules:... | def find_all_headers(
pipeline_files=[],
label_rules=None):
"""find_all_headers
:param pipeline_files: files to process
:param label_rules: labeling rules
"""
log.info("find_all_headers - START")
headers = ["src_file"]
headers_dict = {"src_file": None}
if label_rules:... | [
"find_all_headers"
] | jay-johnson/network-pipeline | python | https://github.com/jay-johnson/network-pipeline/blob/4e53ae13fe12085e0cf2e5e1aff947368f4f1ffa/network_pipeline/scripts/builders/prepare_dataset.py#L23-L58 | [
"def",
"find_all_headers",
"(",
"pipeline_files",
"=",
"[",
"]",
",",
"label_rules",
"=",
"None",
")",
":",
"log",
".",
"info",
"(",
"\"find_all_headers - START\"",
")",
"headers",
"=",
"[",
"\"src_file\"",
"]",
"headers_dict",
"=",
"{",
"\"src_file\"",
":",
... | 4e53ae13fe12085e0cf2e5e1aff947368f4f1ffa |
train | build_csv | build_csv
:param pipeline_files: files to process
:param fulldata_file: output all columns to this csv file
:param clean_file: output all numeric-ready columns to this csv file
:param post_proc_rules: rules after building the DataFrame
:param label_rules: labeling rules
:param metadata_filename... | network_pipeline/scripts/builders/prepare_dataset.py | def build_csv(
pipeline_files=[],
fulldata_file=None,
clean_file=None,
post_proc_rules=None,
label_rules=None,
metadata_filename="metadata.json"):
"""build_csv
:param pipeline_files: files to process
:param fulldata_file: output all columns to this csv file
... | def build_csv(
pipeline_files=[],
fulldata_file=None,
clean_file=None,
post_proc_rules=None,
label_rules=None,
metadata_filename="metadata.json"):
"""build_csv
:param pipeline_files: files to process
:param fulldata_file: output all columns to this csv file
... | [
"build_csv"
] | jay-johnson/network-pipeline | python | https://github.com/jay-johnson/network-pipeline/blob/4e53ae13fe12085e0cf2e5e1aff947368f4f1ffa/network_pipeline/scripts/builders/prepare_dataset.py#L62-L425 | [
"def",
"build_csv",
"(",
"pipeline_files",
"=",
"[",
"]",
",",
"fulldata_file",
"=",
"None",
",",
"clean_file",
"=",
"None",
",",
"post_proc_rules",
"=",
"None",
",",
"label_rules",
"=",
"None",
",",
"metadata_filename",
"=",
"\"metadata.json\"",
")",
":",
"... | 4e53ae13fe12085e0cf2e5e1aff947368f4f1ffa |
train | find_all_pipeline_csvs | find_all_pipeline_csvs
:param csv_glob_path: path to csvs | network_pipeline/scripts/builders/prepare_dataset.py | def find_all_pipeline_csvs(
csv_glob_path="/opt/antinex/datasets/**/*.csv"):
"""find_all_pipeline_csvs
:param csv_glob_path: path to csvs
"""
log.info("finding pipeline csvs in dir={}".format(csv_glob_path))
pipeline_files = []
for csv_file in glob.iglob(csv_glob_path,
... | def find_all_pipeline_csvs(
csv_glob_path="/opt/antinex/datasets/**/*.csv"):
"""find_all_pipeline_csvs
:param csv_glob_path: path to csvs
"""
log.info("finding pipeline csvs in dir={}".format(csv_glob_path))
pipeline_files = []
for csv_file in glob.iglob(csv_glob_path,
... | [
"find_all_pipeline_csvs"
] | jay-johnson/network-pipeline | python | https://github.com/jay-johnson/network-pipeline/blob/4e53ae13fe12085e0cf2e5e1aff947368f4f1ffa/network_pipeline/scripts/builders/prepare_dataset.py#L429-L450 | [
"def",
"find_all_pipeline_csvs",
"(",
"csv_glob_path",
"=",
"\"/opt/antinex/datasets/**/*.csv\"",
")",
":",
"log",
".",
"info",
"(",
"\"finding pipeline csvs in dir={}\"",
".",
"format",
"(",
"csv_glob_path",
")",
")",
"pipeline_files",
"=",
"[",
"]",
"for",
"csv_file... | 4e53ae13fe12085e0cf2e5e1aff947368f4f1ffa |
train | prepare_new_dataset | prepare_new_dataset | network_pipeline/scripts/builders/prepare_dataset.py | def prepare_new_dataset():
"""prepare_new_dataset"""
clean_dir = ev(
"OUTPUT_DIR",
"/tmp")
clean_file = ev(
"CLEANED_FILE",
"{}/cleaned_attack_scans.csv".format(
clean_dir))
fulldata_file = ev(
"FULLDATA_FILE",
"{}/fulldata_attack_scans.csv".fo... | def prepare_new_dataset():
"""prepare_new_dataset"""
clean_dir = ev(
"OUTPUT_DIR",
"/tmp")
clean_file = ev(
"CLEANED_FILE",
"{}/cleaned_attack_scans.csv".format(
clean_dir))
fulldata_file = ev(
"FULLDATA_FILE",
"{}/fulldata_attack_scans.csv".fo... | [
"prepare_new_dataset"
] | jay-johnson/network-pipeline | python | https://github.com/jay-johnson/network-pipeline/blob/4e53ae13fe12085e0cf2e5e1aff947368f4f1ffa/network_pipeline/scripts/builders/prepare_dataset.py#L454-L539 | [
"def",
"prepare_new_dataset",
"(",
")",
":",
"clean_dir",
"=",
"ev",
"(",
"\"OUTPUT_DIR\"",
",",
"\"/tmp\"",
")",
"clean_file",
"=",
"ev",
"(",
"\"CLEANED_FILE\"",
",",
"\"{}/cleaned_attack_scans.csv\"",
".",
"format",
"(",
"clean_dir",
")",
")",
"fulldata_file",
... | 4e53ae13fe12085e0cf2e5e1aff947368f4f1ffa |
train | write_biom | Write the BIOM table to a file.
:type biom_tbl: biom.table.Table
:param biom_tbl: A BIOM table containing the per-sample OTU counts and metadata
to be written out to file.
:type output_fp str
:param output_fp: Path to the BIOM-format file that will be written.
:type fmt: str
:p... | bin/transform_biom.py | def write_biom(biom_tbl, output_fp, fmt="hdf5", gzip=False):
"""
Write the BIOM table to a file.
:type biom_tbl: biom.table.Table
:param biom_tbl: A BIOM table containing the per-sample OTU counts and metadata
to be written out to file.
:type output_fp str
:param output_fp: Pat... | def write_biom(biom_tbl, output_fp, fmt="hdf5", gzip=False):
"""
Write the BIOM table to a file.
:type biom_tbl: biom.table.Table
:param biom_tbl: A BIOM table containing the per-sample OTU counts and metadata
to be written out to file.
:type output_fp str
:param output_fp: Pat... | [
"Write",
"the",
"BIOM",
"table",
"to",
"a",
"file",
".",
":",
"type",
"biom_tbl",
":",
"biom",
".",
"table",
".",
"Table",
":",
"param",
"biom_tbl",
":",
"A",
"BIOM",
"table",
"containing",
"the",
"per",
"-",
"sample",
"OTU",
"counts",
"and",
"metadata... | smdabdoub/phylotoast | python | https://github.com/smdabdoub/phylotoast/blob/0b74ef171e6a84761710548501dfac71285a58a3/bin/transform_biom.py#L26-L61 | [
"def",
"write_biom",
"(",
"biom_tbl",
",",
"output_fp",
",",
"fmt",
"=",
"\"hdf5\"",
",",
"gzip",
"=",
"False",
")",
":",
"opener",
"=",
"open",
"mode",
"=",
"'w'",
"if",
"gzip",
"and",
"fmt",
"!=",
"\"hdf5\"",
":",
"if",
"not",
"output_fp",
".",
"en... | 0b74ef171e6a84761710548501dfac71285a58a3 |
train | arcsin_sqrt | Applies the arcsine square root transform to the
given BIOM-format table | bin/transform_biom.py | def arcsin_sqrt(biom_tbl):
"""
Applies the arcsine square root transform to the
given BIOM-format table
"""
arcsint = lambda data, id_, md: np.arcsin(np.sqrt(data))
tbl_relabd = relative_abd(biom_tbl)
tbl_asin = tbl_relabd.transform(arcsint, inplace=False)
return tbl_asin | def arcsin_sqrt(biom_tbl):
"""
Applies the arcsine square root transform to the
given BIOM-format table
"""
arcsint = lambda data, id_, md: np.arcsin(np.sqrt(data))
tbl_relabd = relative_abd(biom_tbl)
tbl_asin = tbl_relabd.transform(arcsint, inplace=False)
return tbl_asin | [
"Applies",
"the",
"arcsine",
"square",
"root",
"transform",
"to",
"the",
"given",
"BIOM",
"-",
"format",
"table"
] | smdabdoub/phylotoast | python | https://github.com/smdabdoub/phylotoast/blob/0b74ef171e6a84761710548501dfac71285a58a3/bin/transform_biom.py#L78-L88 | [
"def",
"arcsin_sqrt",
"(",
"biom_tbl",
")",
":",
"arcsint",
"=",
"lambda",
"data",
",",
"id_",
",",
"md",
":",
"np",
".",
"arcsin",
"(",
"np",
".",
"sqrt",
"(",
"data",
")",
")",
"tbl_relabd",
"=",
"relative_abd",
"(",
"biom_tbl",
")",
"tbl_asin",
"=... | 0b74ef171e6a84761710548501dfac71285a58a3 |
train | parse_sam | parse sam file and check mapping quality | ctbBio/genome_variation.py | def parse_sam(sam, qual):
"""
parse sam file and check mapping quality
"""
for line in sam:
if line.startswith('@'):
continue
line = line.strip().split()
if int(line[4]) == 0 or int(line[4]) < qual:
continue
yield line | def parse_sam(sam, qual):
"""
parse sam file and check mapping quality
"""
for line in sam:
if line.startswith('@'):
continue
line = line.strip().split()
if int(line[4]) == 0 or int(line[4]) < qual:
continue
yield line | [
"parse",
"sam",
"file",
"and",
"check",
"mapping",
"quality"
] | christophertbrown/bioscripts | python | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/genome_variation.py#L23-L33 | [
"def",
"parse_sam",
"(",
"sam",
",",
"qual",
")",
":",
"for",
"line",
"in",
"sam",
":",
"if",
"line",
".",
"startswith",
"(",
"'@'",
")",
":",
"continue",
"line",
"=",
"line",
".",
"strip",
"(",
")",
".",
"split",
"(",
")",
"if",
"int",
"(",
"l... | 83b2566b3a5745437ec651cd6cafddd056846240 |
train | save_refs | genomes = {} # genomes[genome][contig][sample] = {'bp_stats':[]} | ctbBio/genome_variation.py | def save_refs(sam, fastas, genomes, s2b):
"""
genomes = {} # genomes[genome][contig][sample] = {'bp_stats':[]}
"""
if s2b is False:
s2b = {}
for fasta in fastas:
# if no reference sequence supplied, get length from sam file
if fasta is False:
for line in sam:
... | def save_refs(sam, fastas, genomes, s2b):
"""
genomes = {} # genomes[genome][contig][sample] = {'bp_stats':[]}
"""
if s2b is False:
s2b = {}
for fasta in fastas:
# if no reference sequence supplied, get length from sam file
if fasta is False:
for line in sam:
... | [
"genomes",
"=",
"{}",
"#",
"genomes",
"[",
"genome",
"]",
"[",
"contig",
"]",
"[",
"sample",
"]",
"=",
"{",
"bp_stats",
":",
"[]",
"}"
] | christophertbrown/bioscripts | python | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/genome_variation.py#L35-L81 | [
"def",
"save_refs",
"(",
"sam",
",",
"fastas",
",",
"genomes",
",",
"s2b",
")",
":",
"if",
"s2b",
"is",
"False",
":",
"s2b",
"=",
"{",
"}",
"for",
"fasta",
"in",
"fastas",
":",
"# if no reference sequence supplied, get length from sam file",
"if",
"fasta",
"... | 83b2566b3a5745437ec651cd6cafddd056846240 |
train | parse_cigar | parse cigar string into list of operations
e.g.: 28M1I29M2I6M1I46M ->
[['28', 'M'], ['1', 'I'], ['29', 'M'], ['2', 'I'], ['6', 'M'], ['1', 'I'], ['46', 'M']] | ctbBio/genome_variation.py | def parse_cigar(cigar):
"""
parse cigar string into list of operations
e.g.: 28M1I29M2I6M1I46M ->
[['28', 'M'], ['1', 'I'], ['29', 'M'], ['2', 'I'], ['6', 'M'], ['1', 'I'], ['46', 'M']]
"""
cigar = cigar.replace('M', 'M ').replace('I', 'I ').replace('D', 'D ').split()
cigar = [c.replac... | def parse_cigar(cigar):
"""
parse cigar string into list of operations
e.g.: 28M1I29M2I6M1I46M ->
[['28', 'M'], ['1', 'I'], ['29', 'M'], ['2', 'I'], ['6', 'M'], ['1', 'I'], ['46', 'M']]
"""
cigar = cigar.replace('M', 'M ').replace('I', 'I ').replace('D', 'D ').split()
cigar = [c.replac... | [
"parse",
"cigar",
"string",
"into",
"list",
"of",
"operations",
"e",
".",
"g",
".",
":",
"28M1I29M2I6M1I46M",
"-",
">",
"[[",
"28",
"M",
"]",
"[",
"1",
"I",
"]",
"[",
"29",
"M",
"]",
"[",
"2",
"I",
"]",
"[",
"6",
"M",
"]",
"[",
"1",
"I",
"]... | christophertbrown/bioscripts | python | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/genome_variation.py#L83-L91 | [
"def",
"parse_cigar",
"(",
"cigar",
")",
":",
"cigar",
"=",
"cigar",
".",
"replace",
"(",
"'M'",
",",
"'M '",
")",
".",
"replace",
"(",
"'I'",
",",
"'I '",
")",
".",
"replace",
"(",
"'D'",
",",
"'D '",
")",
".",
"split",
"(",
")",
"cigar",
"=",
... | 83b2566b3a5745437ec651cd6cafddd056846240 |
train | get_bp_stats | save base pair frequency statistics for each base from sam file
genomes = {} # genomes[genome][contig][sample] = {'bp_stats':{}} | ctbBio/genome_variation.py | def get_bp_stats(sam, genomes, s2b, qual):
"""
save base pair frequency statistics for each base from sam file
genomes = {} # genomes[genome][contig][sample] = {'bp_stats':{}}
"""
for read in parse_sam(sam, qual):
ref = read[2] # scaffold that read mapped to
if ref not in s2b:
... | def get_bp_stats(sam, genomes, s2b, qual):
"""
save base pair frequency statistics for each base from sam file
genomes = {} # genomes[genome][contig][sample] = {'bp_stats':{}}
"""
for read in parse_sam(sam, qual):
ref = read[2] # scaffold that read mapped to
if ref not in s2b:
... | [
"save",
"base",
"pair",
"frequency",
"statistics",
"for",
"each",
"base",
"from",
"sam",
"file",
"genomes",
"=",
"{}",
"#",
"genomes",
"[",
"genome",
"]",
"[",
"contig",
"]",
"[",
"sample",
"]",
"=",
"{",
"bp_stats",
":",
"{}",
"}"
] | christophertbrown/bioscripts | python | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/genome_variation.py#L93-L136 | [
"def",
"get_bp_stats",
"(",
"sam",
",",
"genomes",
",",
"s2b",
",",
"qual",
")",
":",
"for",
"read",
"in",
"parse_sam",
"(",
"sam",
",",
"qual",
")",
":",
"ref",
"=",
"read",
"[",
"2",
"]",
"# scaffold that read mapped to",
"if",
"ref",
"not",
"in",
... | 83b2566b3a5745437ec651cd6cafddd056846240 |
train | rc_stats | reverse completement stats | ctbBio/genome_variation.py | def rc_stats(stats):
"""
reverse completement stats
"""
rc_nucs = {'A':'T', 'T':'A', 'G':'C', 'C':'G', 'N':'N'}
rcs = []
for pos in reversed(stats):
rc = {}
rc['reference frequencey'] = pos['reference frequency']
rc['consensus frequencey'] = pos['consensus frequency']
... | def rc_stats(stats):
"""
reverse completement stats
"""
rc_nucs = {'A':'T', 'T':'A', 'G':'C', 'C':'G', 'N':'N'}
rcs = []
for pos in reversed(stats):
rc = {}
rc['reference frequencey'] = pos['reference frequency']
rc['consensus frequencey'] = pos['consensus frequency']
... | [
"reverse",
"completement",
"stats"
] | christophertbrown/bioscripts | python | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/genome_variation.py#L138-L156 | [
"def",
"rc_stats",
"(",
"stats",
")",
":",
"rc_nucs",
"=",
"{",
"'A'",
":",
"'T'",
",",
"'T'",
":",
"'A'",
",",
"'G'",
":",
"'C'",
",",
"'C'",
":",
"'G'",
",",
"'N'",
":",
"'N'",
"}",
"rcs",
"=",
"[",
"]",
"for",
"pos",
"in",
"reversed",
"(",... | 83b2566b3a5745437ec651cd6cafddd056846240 |
train | parse_codons | parse codon nucleotide positions in range start -> end, wrt strand | ctbBio/genome_variation.py | def parse_codons(ref, start, end, strand):
"""
parse codon nucleotide positions in range start -> end, wrt strand
"""
codon = []
c = cycle([1, 2, 3])
ref = ref[start - 1:end]
if strand == -1:
ref = rc_stats(ref)
for pos in ref:
n = next(c)
codon.append(pos)
... | def parse_codons(ref, start, end, strand):
"""
parse codon nucleotide positions in range start -> end, wrt strand
"""
codon = []
c = cycle([1, 2, 3])
ref = ref[start - 1:end]
if strand == -1:
ref = rc_stats(ref)
for pos in ref:
n = next(c)
codon.append(pos)
... | [
"parse",
"codon",
"nucleotide",
"positions",
"in",
"range",
"start",
"-",
">",
"end",
"wrt",
"strand"
] | christophertbrown/bioscripts | python | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/genome_variation.py#L158-L172 | [
"def",
"parse_codons",
"(",
"ref",
",",
"start",
",",
"end",
",",
"strand",
")",
":",
"codon",
"=",
"[",
"]",
"c",
"=",
"cycle",
"(",
"[",
"1",
",",
"2",
",",
"3",
"]",
")",
"ref",
"=",
"ref",
"[",
"start",
"-",
"1",
":",
"end",
"]",
"if",
... | 83b2566b3a5745437ec651cd6cafddd056846240 |
train | calc_coverage | calculate coverage for positions in range start -> end | ctbBio/genome_variation.py | def calc_coverage(ref, start, end, length, nucs):
"""
calculate coverage for positions in range start -> end
"""
ref = ref[start - 1:end]
bases = 0
for pos in ref:
for base, count in list(pos.items()):
if base in nucs:
bases += count
return float(bases)/fl... | def calc_coverage(ref, start, end, length, nucs):
"""
calculate coverage for positions in range start -> end
"""
ref = ref[start - 1:end]
bases = 0
for pos in ref:
for base, count in list(pos.items()):
if base in nucs:
bases += count
return float(bases)/fl... | [
"calculate",
"coverage",
"for",
"positions",
"in",
"range",
"start",
"-",
">",
"end"
] | christophertbrown/bioscripts | python | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/genome_variation.py#L174-L184 | [
"def",
"calc_coverage",
"(",
"ref",
",",
"start",
",",
"end",
",",
"length",
",",
"nucs",
")",
":",
"ref",
"=",
"ref",
"[",
"start",
"-",
"1",
":",
"end",
"]",
"bases",
"=",
"0",
"for",
"pos",
"in",
"ref",
":",
"for",
"base",
",",
"count",
"in"... | 83b2566b3a5745437ec651cd6cafddd056846240 |
train | parse_gbk | parse gbk file | ctbBio/genome_variation.py | def parse_gbk(gbks):
"""
parse gbk file
"""
for gbk in gbks:
for record in SeqIO.parse(open(gbk), 'genbank'):
for feature in record.features:
if feature.type == 'gene':
try:
locus = feature.qualifiers['locus_tag'][0]
... | def parse_gbk(gbks):
"""
parse gbk file
"""
for gbk in gbks:
for record in SeqIO.parse(open(gbk), 'genbank'):
for feature in record.features:
if feature.type == 'gene':
try:
locus = feature.qualifiers['locus_tag'][0]
... | [
"parse",
"gbk",
"file"
] | christophertbrown/bioscripts | python | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/genome_variation.py#L186-L213 | [
"def",
"parse_gbk",
"(",
"gbks",
")",
":",
"for",
"gbk",
"in",
"gbks",
":",
"for",
"record",
"in",
"SeqIO",
".",
"parse",
"(",
"open",
"(",
"gbk",
")",
",",
"'genbank'",
")",
":",
"for",
"feature",
"in",
"record",
".",
"features",
":",
"if",
"featu... | 83b2566b3a5745437ec651cd6cafddd056846240 |
train | parse_fasta_annotations | parse gene call information from Prodigal fasta output | ctbBio/genome_variation.py | def parse_fasta_annotations(fastas, annot_tables, trans_table):
"""
parse gene call information from Prodigal fasta output
"""
if annot_tables is not False:
annots = {}
for table in annot_tables:
for cds in open(table):
ID, start, end, strand = cds.strip().spl... | def parse_fasta_annotations(fastas, annot_tables, trans_table):
"""
parse gene call information from Prodigal fasta output
"""
if annot_tables is not False:
annots = {}
for table in annot_tables:
for cds in open(table):
ID, start, end, strand = cds.strip().spl... | [
"parse",
"gene",
"call",
"information",
"from",
"Prodigal",
"fasta",
"output"
] | christophertbrown/bioscripts | python | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/genome_variation.py#L215-L252 | [
"def",
"parse_fasta_annotations",
"(",
"fastas",
",",
"annot_tables",
",",
"trans_table",
")",
":",
"if",
"annot_tables",
"is",
"not",
"False",
":",
"annots",
"=",
"{",
"}",
"for",
"table",
"in",
"annot_tables",
":",
"for",
"cds",
"in",
"open",
"(",
"table... | 83b2566b3a5745437ec651cd6cafddd056846240 |
train | parse_annotations | parse annotations in either gbk or Prodigal fasta format | ctbBio/genome_variation.py | def parse_annotations(annots, fmt, annot_tables, trans_table):
"""
parse annotations in either gbk or Prodigal fasta format
"""
annotations = {} # annotations[contig] = [features]
# gbk format
if fmt is False:
for contig, feature in parse_gbk(annots):
if contig not in annotat... | def parse_annotations(annots, fmt, annot_tables, trans_table):
"""
parse annotations in either gbk or Prodigal fasta format
"""
annotations = {} # annotations[contig] = [features]
# gbk format
if fmt is False:
for contig, feature in parse_gbk(annots):
if contig not in annotat... | [
"parse",
"annotations",
"in",
"either",
"gbk",
"or",
"Prodigal",
"fasta",
"format"
] | christophertbrown/bioscripts | python | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/genome_variation.py#L254-L271 | [
"def",
"parse_annotations",
"(",
"annots",
",",
"fmt",
",",
"annot_tables",
",",
"trans_table",
")",
":",
"annotations",
"=",
"{",
"}",
"# annotations[contig] = [features]",
"# gbk format",
"if",
"fmt",
"is",
"False",
":",
"for",
"contig",
",",
"feature",
"in",
... | 83b2566b3a5745437ec651cd6cafddd056846240 |
train | count_mutations | count types of mutations in codon
counts = {'obs syn':#, 'pos syn':#, 'obs non-syn':#, 'pos non-syn':#} | ctbBio/genome_variation.py | def count_mutations(codon, AA, alleles, counts, nucs, trans_table):
"""
count types of mutations in codon
counts = {'obs syn':#, 'pos syn':#, 'obs non-syn':#, 'pos non-syn':#}
"""
# find alternative codons based on SNPs
obs_codons = [] # codons observed from SNPs
for pos, pos_mutations in en... | def count_mutations(codon, AA, alleles, counts, nucs, trans_table):
"""
count types of mutations in codon
counts = {'obs syn':#, 'pos syn':#, 'obs non-syn':#, 'pos non-syn':#}
"""
# find alternative codons based on SNPs
obs_codons = [] # codons observed from SNPs
for pos, pos_mutations in en... | [
"count",
"types",
"of",
"mutations",
"in",
"codon",
"counts",
"=",
"{",
"obs",
"syn",
":",
"#",
"pos",
"syn",
":",
"#",
"obs",
"non",
"-",
"syn",
":",
"#",
"pos",
"non",
"-",
"syn",
":",
"#",
"}"
] | christophertbrown/bioscripts | python | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/genome_variation.py#L273-L309 | [
"def",
"count_mutations",
"(",
"codon",
",",
"AA",
",",
"alleles",
",",
"counts",
",",
"nucs",
",",
"trans_table",
")",
":",
"# find alternative codons based on SNPs",
"obs_codons",
"=",
"[",
"]",
"# codons observed from SNPs",
"for",
"pos",
",",
"pos_mutations",
... | 83b2566b3a5745437ec651cd6cafddd056846240 |
train | codon2aa | convert codon to amino acid | ctbBio/genome_variation.py | def codon2aa(codon, trans_table):
"""
convert codon to amino acid
"""
return Seq(''.join(codon), IUPAC.ambiguous_dna).translate(table = trans_table)[0] | def codon2aa(codon, trans_table):
"""
convert codon to amino acid
"""
return Seq(''.join(codon), IUPAC.ambiguous_dna).translate(table = trans_table)[0] | [
"convert",
"codon",
"to",
"amino",
"acid"
] | christophertbrown/bioscripts | python | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/genome_variation.py#L311-L315 | [
"def",
"codon2aa",
"(",
"codon",
",",
"trans_table",
")",
":",
"return",
"Seq",
"(",
"''",
".",
"join",
"(",
"codon",
")",
",",
"IUPAC",
".",
"ambiguous_dna",
")",
".",
"translate",
"(",
"table",
"=",
"trans_table",
")",
"[",
"0",
"]"
] | 83b2566b3a5745437ec651cd6cafddd056846240 |
train | calc_PnPs | counts = {'obs syn':#, 'pos syn':#, 'obs non-syn':#, 'pos non-syn':#} | ctbBio/genome_variation.py | def calc_PnPs(counts):
"""
counts = {'obs syn':#, 'pos syn':#, 'obs non-syn':#, 'pos non-syn':#}
"""
if counts['pos non-syn'] == 0 or counts['pos syn'] == 0:
return 'n/a'
NonSyn = float(counts['obs non-syn'])/float(counts['pos non-syn'])
Syn = float(counts['obs syn']) /float(counts... | def calc_PnPs(counts):
"""
counts = {'obs syn':#, 'pos syn':#, 'obs non-syn':#, 'pos non-syn':#}
"""
if counts['pos non-syn'] == 0 or counts['pos syn'] == 0:
return 'n/a'
NonSyn = float(counts['obs non-syn'])/float(counts['pos non-syn'])
Syn = float(counts['obs syn']) /float(counts... | [
"counts",
"=",
"{",
"obs",
"syn",
":",
"#",
"pos",
"syn",
":",
"#",
"obs",
"non",
"-",
"syn",
":",
"#",
"pos",
"non",
"-",
"syn",
":",
"#",
"}"
] | christophertbrown/bioscripts | python | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/genome_variation.py#L317-L327 | [
"def",
"calc_PnPs",
"(",
"counts",
")",
":",
"if",
"counts",
"[",
"'pos non-syn'",
"]",
"==",
"0",
"or",
"counts",
"[",
"'pos syn'",
"]",
"==",
"0",
":",
"return",
"'n/a'",
"NonSyn",
"=",
"float",
"(",
"counts",
"[",
"'obs non-syn'",
"]",
")",
"/",
"... | 83b2566b3a5745437ec651cd6cafddd056846240 |
train | sub_rates | calculate syn and non-syn sub. rates for each locus/gene | ctbBio/genome_variation.py | def sub_rates(stats, annots):
"""
calculate syn and non-syn sub. rates for each locus/gene
"""
nucs = ['A', 'T', 'G', 'C']
subs = {} # subs[locus]{pn/ps reference, pn/ps consensus, snp density}
for cds in annots:
locus, location, info = cds
subs[locus] = {}
start, end, st... | def sub_rates(stats, annots):
"""
calculate syn and non-syn sub. rates for each locus/gene
"""
nucs = ['A', 'T', 'G', 'C']
subs = {} # subs[locus]{pn/ps reference, pn/ps consensus, snp density}
for cds in annots:
locus, location, info = cds
subs[locus] = {}
start, end, st... | [
"calculate",
"syn",
"and",
"non",
"-",
"syn",
"sub",
".",
"rates",
"for",
"each",
"locus",
"/",
"gene"
] | christophertbrown/bioscripts | python | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/genome_variation.py#L329-L369 | [
"def",
"sub_rates",
"(",
"stats",
",",
"annots",
")",
":",
"nucs",
"=",
"[",
"'A'",
",",
"'T'",
",",
"'G'",
",",
"'C'",
"]",
"subs",
"=",
"{",
"}",
"# subs[locus]{pn/ps reference, pn/ps consensus, snp density}",
"for",
"cds",
"in",
"annots",
":",
"locus",
... | 83b2566b3a5745437ec651cd6cafddd056846240 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.