repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
pyviz/imagen | imagen/patternfn.py | smooth_rectangle | def smooth_rectangle(x, y, rec_w, rec_h, gaussian_width_x, gaussian_width_y):
"""
Rectangle with a solid central region, then Gaussian fall-off at the edges.
"""
gaussian_x_coord = abs(x)-rec_w/2.0
gaussian_y_coord = abs(y)-rec_h/2.0
box_x=np.less(gaussian_x_coord,0.0)
box_y=np.less(gaussi... | python | def smooth_rectangle(x, y, rec_w, rec_h, gaussian_width_x, gaussian_width_y):
"""
Rectangle with a solid central region, then Gaussian fall-off at the edges.
"""
gaussian_x_coord = abs(x)-rec_w/2.0
gaussian_y_coord = abs(y)-rec_h/2.0
box_x=np.less(gaussian_x_coord,0.0)
box_y=np.less(gaussi... | [
"def",
"smooth_rectangle",
"(",
"x",
",",
"y",
",",
"rec_w",
",",
"rec_h",
",",
"gaussian_width_x",
",",
"gaussian_width_y",
")",
":",
"gaussian_x_coord",
"=",
"abs",
"(",
"x",
")",
"-",
"rec_w",
"/",
"2.0",
"gaussian_y_coord",
"=",
"abs",
"(",
"y",
")",... | Rectangle with a solid central region, then Gaussian fall-off at the edges. | [
"Rectangle",
"with",
"a",
"solid",
"central",
"region",
"then",
"Gaussian",
"fall",
"-",
"off",
"at",
"the",
"edges",
"."
] | 53c5685c880f54b42795964d8db50b02e8590e88 | https://github.com/pyviz/imagen/blob/53c5685c880f54b42795964d8db50b02e8590e88/imagen/patternfn.py#L178-L197 | train |
bskinn/opan | opan/utils/base.py | pack_tups | def pack_tups(*args):
"""Pack an arbitrary set of iterables and non-iterables into tuples.
Function packs a set of inputs with arbitrary iterability into tuples.
Iterability is tested with :func:`iterable`. Non-iterable inputs
are repeated in each output tuple. Iterable inputs are expanded
uniforml... | python | def pack_tups(*args):
"""Pack an arbitrary set of iterables and non-iterables into tuples.
Function packs a set of inputs with arbitrary iterability into tuples.
Iterability is tested with :func:`iterable`. Non-iterable inputs
are repeated in each output tuple. Iterable inputs are expanded
uniforml... | [
"def",
"pack_tups",
"(",
"*",
"args",
")",
":",
"import",
"numpy",
"as",
"np",
"_DEBUG",
"=",
"False",
"NOT_ITER",
"=",
"-",
"1",
"UNINIT_VAL",
"=",
"-",
"1",
"if",
"_DEBUG",
":",
"print",
"(",
"\"args = {0}\"",
".",
"format",
"(",
"args",
")",
")",
... | Pack an arbitrary set of iterables and non-iterables into tuples.
Function packs a set of inputs with arbitrary iterability into tuples.
Iterability is tested with :func:`iterable`. Non-iterable inputs
are repeated in each output tuple. Iterable inputs are expanded
uniformly across the output tuples. ... | [
"Pack",
"an",
"arbitrary",
"set",
"of",
"iterables",
"and",
"non",
"-",
"iterables",
"into",
"tuples",
"."
] | 0b1b21662df6abc971407a9386db21a8796fbfe5 | https://github.com/bskinn/opan/blob/0b1b21662df6abc971407a9386db21a8796fbfe5/opan/utils/base.py#L44-L139 | train |
bskinn/opan | opan/utils/base.py | safe_cast | def safe_cast(invar, totype):
"""Performs a "safe" typecast.
Ensures that `invar` properly casts to `totype`. Checks after
casting that the result is actually of type `totype`. Any exceptions raised
by the typecast itself are unhandled.
Parameters
----------
invar
(arbitrary) -- Va... | python | def safe_cast(invar, totype):
"""Performs a "safe" typecast.
Ensures that `invar` properly casts to `totype`. Checks after
casting that the result is actually of type `totype`. Any exceptions raised
by the typecast itself are unhandled.
Parameters
----------
invar
(arbitrary) -- Va... | [
"def",
"safe_cast",
"(",
"invar",
",",
"totype",
")",
":",
"outvar",
"=",
"totype",
"(",
"invar",
")",
"if",
"not",
"isinstance",
"(",
"outvar",
",",
"totype",
")",
":",
"raise",
"TypeError",
"(",
"\"Result of cast to '{0}' is '{1}'\"",
".",
"format",
"(",
... | Performs a "safe" typecast.
Ensures that `invar` properly casts to `totype`. Checks after
casting that the result is actually of type `totype`. Any exceptions raised
by the typecast itself are unhandled.
Parameters
----------
invar
(arbitrary) -- Value to be typecast.
totype
... | [
"Performs",
"a",
"safe",
"typecast",
"."
] | 0b1b21662df6abc971407a9386db21a8796fbfe5 | https://github.com/bskinn/opan/blob/0b1b21662df6abc971407a9386db21a8796fbfe5/opan/utils/base.py#L168-L205 | train |
bskinn/opan | opan/utils/base.py | make_timestamp | def make_timestamp(el_time):
""" Generate an hour-minutes-seconds timestamp from an interval in seconds.
Assumes numeric input of a time interval in seconds. Converts this
interval to a string of the format "#h #m #s", indicating the number of
hours, minutes, and seconds in the interval. Intervals gr... | python | def make_timestamp(el_time):
""" Generate an hour-minutes-seconds timestamp from an interval in seconds.
Assumes numeric input of a time interval in seconds. Converts this
interval to a string of the format "#h #m #s", indicating the number of
hours, minutes, and seconds in the interval. Intervals gr... | [
"def",
"make_timestamp",
"(",
"el_time",
")",
":",
"hrs",
"=",
"el_time",
"//",
"3600.0",
"mins",
"=",
"(",
"el_time",
"%",
"3600.0",
")",
"//",
"60.0",
"secs",
"=",
"el_time",
"%",
"60.0",
"stamp",
"=",
"\"{0}h {1}m {2}s\"",
".",
"format",
"(",
"int",
... | Generate an hour-minutes-seconds timestamp from an interval in seconds.
Assumes numeric input of a time interval in seconds. Converts this
interval to a string of the format "#h #m #s", indicating the number of
hours, minutes, and seconds in the interval. Intervals greater than 24h
are unproblematic.... | [
"Generate",
"an",
"hour",
"-",
"minutes",
"-",
"seconds",
"timestamp",
"from",
"an",
"interval",
"in",
"seconds",
"."
] | 0b1b21662df6abc971407a9386db21a8796fbfe5 | https://github.com/bskinn/opan/blob/0b1b21662df6abc971407a9386db21a8796fbfe5/opan/utils/base.py#L210-L244 | train |
bskinn/opan | opan/utils/base.py | check_geom | def check_geom(c1, a1, c2, a2, tol=_DEF.XYZ_COORD_MATCH_TOL):
""" Check for consistency of two geometries and atom symbol lists
Cartesian coordinates are considered consistent with the input
coords if each component matches to within `tol`. If coords or
atoms vectors are passed that are of mismatched ... | python | def check_geom(c1, a1, c2, a2, tol=_DEF.XYZ_COORD_MATCH_TOL):
""" Check for consistency of two geometries and atom symbol lists
Cartesian coordinates are considered consistent with the input
coords if each component matches to within `tol`. If coords or
atoms vectors are passed that are of mismatched ... | [
"def",
"check_geom",
"(",
"c1",
",",
"a1",
",",
"c2",
",",
"a2",
",",
"tol",
"=",
"_DEF",
".",
"XYZ_COORD_MATCH_TOL",
")",
":",
"from",
".",
".",
"const",
"import",
"atom_num",
"import",
"numpy",
"as",
"np",
"from",
".",
".",
"const",
"import",
"Enum... | Check for consistency of two geometries and atom symbol lists
Cartesian coordinates are considered consistent with the input
coords if each component matches to within `tol`. If coords or
atoms vectors are passed that are of mismatched lengths, a
|False| value is returned.
Both coords vectors mus... | [
"Check",
"for",
"consistency",
"of",
"two",
"geometries",
"and",
"atom",
"symbol",
"lists"
] | 0b1b21662df6abc971407a9386db21a8796fbfe5 | https://github.com/bskinn/opan/blob/0b1b21662df6abc971407a9386db21a8796fbfe5/opan/utils/base.py#L250-L424 | train |
bskinn/opan | opan/utils/base.py | template_subst | def template_subst(template, subs, delims=('<', '>')):
""" Perform substitution of content into tagged string.
For substitutions into template input files for external computational
packages, no checks for valid syntax are performed.
Each key in `subs` corresponds to a delimited
substitution tag t... | python | def template_subst(template, subs, delims=('<', '>')):
""" Perform substitution of content into tagged string.
For substitutions into template input files for external computational
packages, no checks for valid syntax are performed.
Each key in `subs` corresponds to a delimited
substitution tag t... | [
"def",
"template_subst",
"(",
"template",
",",
"subs",
",",
"delims",
"=",
"(",
"'<'",
",",
"'>'",
")",
")",
":",
"subst_text",
"=",
"template",
"for",
"(",
"k",
",",
"v",
")",
"in",
"subs",
".",
"items",
"(",
")",
":",
"subst_text",
"=",
"subst_te... | Perform substitution of content into tagged string.
For substitutions into template input files for external computational
packages, no checks for valid syntax are performed.
Each key in `subs` corresponds to a delimited
substitution tag to be replaced in `template` by the entire text of the
value... | [
"Perform",
"substitution",
"of",
"content",
"into",
"tagged",
"string",
"."
] | 0b1b21662df6abc971407a9386db21a8796fbfe5 | https://github.com/bskinn/opan/blob/0b1b21662df6abc971407a9386db21a8796fbfe5/opan/utils/base.py#L429-L488 | train |
bskinn/opan | opan/utils/base.py | assert_npfloatarray | def assert_npfloatarray(obj, varname, desc, exc, tc, errsrc):
""" Assert a value is an |nparray| of NumPy floats.
Pass |None| to `varname` if `obj` itself is to be checked.
Otherwise, `varname` is the string name of the attribute of `obj` to
check. In either case, `desc` is a string description of the... | python | def assert_npfloatarray(obj, varname, desc, exc, tc, errsrc):
""" Assert a value is an |nparray| of NumPy floats.
Pass |None| to `varname` if `obj` itself is to be checked.
Otherwise, `varname` is the string name of the attribute of `obj` to
check. In either case, `desc` is a string description of the... | [
"def",
"assert_npfloatarray",
"(",
"obj",
",",
"varname",
",",
"desc",
",",
"exc",
",",
"tc",
",",
"errsrc",
")",
":",
"import",
"numpy",
"as",
"np",
"if",
"varname",
"is",
"None",
":",
"var",
"=",
"obj",
"else",
":",
"try",
":",
"var",
"=",
"getat... | Assert a value is an |nparray| of NumPy floats.
Pass |None| to `varname` if `obj` itself is to be checked.
Otherwise, `varname` is the string name of the attribute of `obj` to
check. In either case, `desc` is a string description of the
object to be checked, for use in raising of exceptions.
Rais... | [
"Assert",
"a",
"value",
"is",
"an",
"|nparray|",
"of",
"NumPy",
"floats",
"."
] | 0b1b21662df6abc971407a9386db21a8796fbfe5 | https://github.com/bskinn/opan/blob/0b1b21662df6abc971407a9386db21a8796fbfe5/opan/utils/base.py#L531-L609 | train |
mila-iqia/picklable-itertools | picklable_itertools/tee.py | tee_manager.advance | def advance(self):
"""Advance the base iterator, publish to constituent iterators."""
elem = next(self._iterable)
for deque in self._deques:
deque.append(elem) | python | def advance(self):
"""Advance the base iterator, publish to constituent iterators."""
elem = next(self._iterable)
for deque in self._deques:
deque.append(elem) | [
"def",
"advance",
"(",
"self",
")",
":",
"elem",
"=",
"next",
"(",
"self",
".",
"_iterable",
")",
"for",
"deque",
"in",
"self",
".",
"_deques",
":",
"deque",
".",
"append",
"(",
"elem",
")"
] | Advance the base iterator, publish to constituent iterators. | [
"Advance",
"the",
"base",
"iterator",
"publish",
"to",
"constituent",
"iterators",
"."
] | e00238867875df0258cf4f83f528d846e7c1afc4 | https://github.com/mila-iqia/picklable-itertools/blob/e00238867875df0258cf4f83f528d846e7c1afc4/picklable_itertools/tee.py#L36-L40 | train |
pyviz/imagen | imagen/deprecated.py | SeparatedComposite._advance_pattern_generators | def _advance_pattern_generators(self,p):
"""
Advance the parameters for each generator for this
presentation.
Picks a position for each generator that is accepted by
__distance_valid for all combinations. Returns a new list of
the generators, with some potentially omitt... | python | def _advance_pattern_generators(self,p):
"""
Advance the parameters for each generator for this
presentation.
Picks a position for each generator that is accepted by
__distance_valid for all combinations. Returns a new list of
the generators, with some potentially omitt... | [
"def",
"_advance_pattern_generators",
"(",
"self",
",",
"p",
")",
":",
"valid_generators",
"=",
"[",
"]",
"for",
"g",
"in",
"p",
".",
"generators",
":",
"for",
"trial",
"in",
"range",
"(",
"self",
".",
"max_trials",
")",
":",
"if",
"np",
".",
"alltrue"... | Advance the parameters for each generator for this
presentation.
Picks a position for each generator that is accepted by
__distance_valid for all combinations. Returns a new list of
the generators, with some potentially omitted due to failure
to meet the constraints. | [
"Advance",
"the",
"parameters",
"for",
"each",
"generator",
"for",
"this",
"presentation",
"."
] | 53c5685c880f54b42795964d8db50b02e8590e88 | https://github.com/pyviz/imagen/blob/53c5685c880f54b42795964d8db50b02e8590e88/imagen/deprecated.py#L64-L92 | train |
pyviz/imagen | imagen/deprecated.py | Translator._advance_params | def _advance_params(self):
"""
Explicitly generate new values for these parameters only
when appropriate.
"""
for p in ['x','y','direction']:
self.force_new_dynamic_value(p)
self.last_time = self.time_fn() | python | def _advance_params(self):
"""
Explicitly generate new values for these parameters only
when appropriate.
"""
for p in ['x','y','direction']:
self.force_new_dynamic_value(p)
self.last_time = self.time_fn() | [
"def",
"_advance_params",
"(",
"self",
")",
":",
"for",
"p",
"in",
"[",
"'x'",
",",
"'y'",
",",
"'direction'",
"]",
":",
"self",
".",
"force_new_dynamic_value",
"(",
"p",
")",
"self",
".",
"last_time",
"=",
"self",
".",
"time_fn",
"(",
")"
] | Explicitly generate new values for these parameters only
when appropriate. | [
"Explicitly",
"generate",
"new",
"values",
"for",
"these",
"parameters",
"only",
"when",
"appropriate",
"."
] | 53c5685c880f54b42795964d8db50b02e8590e88 | https://github.com/pyviz/imagen/blob/53c5685c880f54b42795964d8db50b02e8590e88/imagen/deprecated.py#L236-L243 | train |
matthewwithanm/django-classbasedsettings | cbsettings/switching/__init__.py | BaseSwitcher.register | def register(self, settings_class=NoSwitcher, *simple_checks,
**conditions):
"""
Register a settings class with the switcher. Can be passed the settings
class to register or be used as a decorator.
:param settings_class: The class to register with the provided
... | python | def register(self, settings_class=NoSwitcher, *simple_checks,
**conditions):
"""
Register a settings class with the switcher. Can be passed the settings
class to register or be used as a decorator.
:param settings_class: The class to register with the provided
... | [
"def",
"register",
"(",
"self",
",",
"settings_class",
"=",
"NoSwitcher",
",",
"*",
"simple_checks",
",",
"**",
"conditions",
")",
":",
"if",
"settings_class",
"is",
"NoSwitcher",
":",
"def",
"decorator",
"(",
"cls",
")",
":",
"self",
".",
"register",
"(",... | Register a settings class with the switcher. Can be passed the settings
class to register or be used as a decorator.
:param settings_class: The class to register with the provided
conditions.
:param *simple_checks: A list of conditions for using the settings
clas... | [
"Register",
"a",
"settings",
"class",
"with",
"the",
"switcher",
".",
"Can",
"be",
"passed",
"the",
"settings",
"class",
"to",
"register",
"or",
"be",
"used",
"as",
"a",
"decorator",
"."
] | ac9e4362bd1f4954f3e4679b97726cab2b22aea9 | https://github.com/matthewwithanm/django-classbasedsettings/blob/ac9e4362bd1f4954f3e4679b97726cab2b22aea9/cbsettings/switching/__init__.py#L32-L60 | train |
mikeboers/PyHAML | haml/parse.py | Parser._peek_buffer | def _peek_buffer(self, i=0):
"""Get the next line without consuming it."""
while len(self._buffer) <= i:
self._buffer.append(next(self._source))
return self._buffer[i] | python | def _peek_buffer(self, i=0):
"""Get the next line without consuming it."""
while len(self._buffer) <= i:
self._buffer.append(next(self._source))
return self._buffer[i] | [
"def",
"_peek_buffer",
"(",
"self",
",",
"i",
"=",
"0",
")",
":",
"while",
"len",
"(",
"self",
".",
"_buffer",
")",
"<=",
"i",
":",
"self",
".",
"_buffer",
".",
"append",
"(",
"next",
"(",
"self",
".",
"_source",
")",
")",
"return",
"self",
".",
... | Get the next line without consuming it. | [
"Get",
"the",
"next",
"line",
"without",
"consuming",
"it",
"."
] | 9ecb7c85349948428474869aad5b8d1c7de8dbed | https://github.com/mikeboers/PyHAML/blob/9ecb7c85349948428474869aad5b8d1c7de8dbed/haml/parse.py#L37-L41 | train |
mikeboers/PyHAML | haml/parse.py | Parser._make_readline_peeker | def _make_readline_peeker(self):
"""Make a readline-like function which peeks into the source."""
counter = itertools.count(0)
def readline():
try:
return self._peek_buffer(next(counter))
except StopIteration:
return ''
return readl... | python | def _make_readline_peeker(self):
"""Make a readline-like function which peeks into the source."""
counter = itertools.count(0)
def readline():
try:
return self._peek_buffer(next(counter))
except StopIteration:
return ''
return readl... | [
"def",
"_make_readline_peeker",
"(",
"self",
")",
":",
"counter",
"=",
"itertools",
".",
"count",
"(",
"0",
")",
"def",
"readline",
"(",
")",
":",
"try",
":",
"return",
"self",
".",
"_peek_buffer",
"(",
"next",
"(",
"counter",
")",
")",
"except",
"Stop... | Make a readline-like function which peeks into the source. | [
"Make",
"a",
"readline",
"-",
"like",
"function",
"which",
"peeks",
"into",
"the",
"source",
"."
] | 9ecb7c85349948428474869aad5b8d1c7de8dbed | https://github.com/mikeboers/PyHAML/blob/9ecb7c85349948428474869aad5b8d1c7de8dbed/haml/parse.py#L52-L60 | train |
mikeboers/PyHAML | haml/parse.py | Parser._add_node | def _add_node(self, node, depth):
"""Add a node to the graph, and the stack."""
self._topmost_node.add_child(node, bool(depth[1]))
self._stack.append((depth, node)) | python | def _add_node(self, node, depth):
"""Add a node to the graph, and the stack."""
self._topmost_node.add_child(node, bool(depth[1]))
self._stack.append((depth, node)) | [
"def",
"_add_node",
"(",
"self",
",",
"node",
",",
"depth",
")",
":",
"self",
".",
"_topmost_node",
".",
"add_child",
"(",
"node",
",",
"bool",
"(",
"depth",
"[",
"1",
"]",
")",
")",
"self",
".",
"_stack",
".",
"append",
"(",
"(",
"depth",
",",
"... | Add a node to the graph, and the stack. | [
"Add",
"a",
"node",
"to",
"the",
"graph",
"and",
"the",
"stack",
"."
] | 9ecb7c85349948428474869aad5b8d1c7de8dbed | https://github.com/mikeboers/PyHAML/blob/9ecb7c85349948428474869aad5b8d1c7de8dbed/haml/parse.py#L386-L389 | train |
bskinn/opan | opan/xyz.py | OpanXYZ._load_data | def _load_data(self, atom_syms, coords, bohrs=True):
""" Internal function for making XYZ object from explicit geom data.
Parameters
----------
atom_syms
Squeezes to array of N |str| --
Element symbols for the XYZ. Must be valid elements as defined in
... | python | def _load_data(self, atom_syms, coords, bohrs=True):
""" Internal function for making XYZ object from explicit geom data.
Parameters
----------
atom_syms
Squeezes to array of N |str| --
Element symbols for the XYZ. Must be valid elements as defined in
... | [
"def",
"_load_data",
"(",
"self",
",",
"atom_syms",
",",
"coords",
",",
"bohrs",
"=",
"True",
")",
":",
"import",
"numpy",
"as",
"np",
"from",
".",
"const",
"import",
"atom_num",
",",
"PHYS",
"from",
".",
"error",
"import",
"XYZError",
"if",
"'geoms'",
... | Internal function for making XYZ object from explicit geom data.
Parameters
----------
atom_syms
Squeezes to array of N |str| --
Element symbols for the XYZ. Must be valid elements as defined in
the keys of :data:`const.atom_num <opan.const.atom_num>`.
... | [
"Internal",
"function",
"for",
"making",
"XYZ",
"object",
"from",
"explicit",
"geom",
"data",
"."
] | 0b1b21662df6abc971407a9386db21a8796fbfe5 | https://github.com/bskinn/opan/blob/0b1b21662df6abc971407a9386db21a8796fbfe5/opan/xyz.py#L354-L438 | train |
bskinn/opan | opan/xyz.py | OpanXYZ.geom_iter | def geom_iter(self, g_nums):
"""Iterator over a subset of geometries.
The indices of the geometries to be returned are indicated by an
iterable of |int|\\ s passed as `g_nums`.
As with :meth:`geom_single`, each geometry is returned as a
length-3N |npfloat_| with each atom's x/y... | python | def geom_iter(self, g_nums):
"""Iterator over a subset of geometries.
The indices of the geometries to be returned are indicated by an
iterable of |int|\\ s passed as `g_nums`.
As with :meth:`geom_single`, each geometry is returned as a
length-3N |npfloat_| with each atom's x/y... | [
"def",
"geom_iter",
"(",
"self",
",",
"g_nums",
")",
":",
"from",
".",
"utils",
"import",
"pack_tups",
"vals",
"=",
"pack_tups",
"(",
"g_nums",
")",
"for",
"val",
"in",
"vals",
":",
"yield",
"self",
".",
"geom_single",
"(",
"val",
"[",
"0",
"]",
")"
... | Iterator over a subset of geometries.
The indices of the geometries to be returned are indicated by an
iterable of |int|\\ s passed as `g_nums`.
As with :meth:`geom_single`, each geometry is returned as a
length-3N |npfloat_| with each atom's x/y/z coordinates
grouped together:... | [
"Iterator",
"over",
"a",
"subset",
"of",
"geometries",
"."
] | 0b1b21662df6abc971407a9386db21a8796fbfe5 | https://github.com/bskinn/opan/blob/0b1b21662df6abc971407a9386db21a8796fbfe5/opan/xyz.py#L725-L770 | train |
bskinn/opan | opan/xyz.py | OpanXYZ.dist_single | def dist_single(self, g_num, at_1, at_2):
""" Distance between two atoms.
Parameters
----------
g_num
|int| -- Index of the desired geometry
at_1
|int| -- Index of the first atom
at_2
|int| -- Index of the second atom
Return... | python | def dist_single(self, g_num, at_1, at_2):
""" Distance between two atoms.
Parameters
----------
g_num
|int| -- Index of the desired geometry
at_1
|int| -- Index of the first atom
at_2
|int| -- Index of the second atom
Return... | [
"def",
"dist_single",
"(",
"self",
",",
"g_num",
",",
"at_1",
",",
"at_2",
")",
":",
"import",
"numpy",
"as",
"np",
"from",
"scipy",
"import",
"linalg",
"as",
"spla",
"from",
".",
"utils",
"import",
"safe_cast",
"as",
"scast",
"if",
"not",
"(",
"-",
... | Distance between two atoms.
Parameters
----------
g_num
|int| -- Index of the desired geometry
at_1
|int| -- Index of the first atom
at_2
|int| -- Index of the second atom
Returns
-------
dist
|npfloat_| ... | [
"Distance",
"between",
"two",
"atoms",
"."
] | 0b1b21662df6abc971407a9386db21a8796fbfe5 | https://github.com/bskinn/opan/blob/0b1b21662df6abc971407a9386db21a8796fbfe5/opan/xyz.py#L775-L836 | train |
bskinn/opan | opan/xyz.py | OpanXYZ.dist_iter | def dist_iter(self, g_nums, ats_1, ats_2, invalid_error=False):
""" Iterator over selected interatomic distances.
Distances are in Bohrs as with :meth:`dist_single`.
See `above <toc-generators_>`_ for more information on
calling options.
Parameters
----------
g... | python | def dist_iter(self, g_nums, ats_1, ats_2, invalid_error=False):
""" Iterator over selected interatomic distances.
Distances are in Bohrs as with :meth:`dist_single`.
See `above <toc-generators_>`_ for more information on
calling options.
Parameters
----------
g... | [
"def",
"dist_iter",
"(",
"self",
",",
"g_nums",
",",
"ats_1",
",",
"ats_2",
",",
"invalid_error",
"=",
"False",
")",
":",
"import",
"numpy",
"as",
"np",
"from",
".",
"utils",
"import",
"pack_tups",
"if",
"_DEBUG",
":",
"print",
"(",
"\"g_nums = {0}\"",
"... | Iterator over selected interatomic distances.
Distances are in Bohrs as with :meth:`dist_single`.
See `above <toc-generators_>`_ for more information on
calling options.
Parameters
----------
g_nums
|int| or length-R iterable |int| or |None| --
... | [
"Iterator",
"over",
"selected",
"interatomic",
"distances",
"."
] | 0b1b21662df6abc971407a9386db21a8796fbfe5 | https://github.com/bskinn/opan/blob/0b1b21662df6abc971407a9386db21a8796fbfe5/opan/xyz.py#L841-L913 | train |
bskinn/opan | opan/xyz.py | OpanXYZ.angle_single | def angle_single(self, g_num, at_1, at_2, at_3):
""" Spanning angle among three atoms.
The indices `at_1` and `at_3` can be the same (yielding a
trivial zero angle), but `at_2` must be different from
both `at_1` and `at_3`.
Parameters
----------
g_num
... | python | def angle_single(self, g_num, at_1, at_2, at_3):
""" Spanning angle among three atoms.
The indices `at_1` and `at_3` can be the same (yielding a
trivial zero angle), but `at_2` must be different from
both `at_1` and `at_3`.
Parameters
----------
g_num
... | [
"def",
"angle_single",
"(",
"self",
",",
"g_num",
",",
"at_1",
",",
"at_2",
",",
"at_3",
")",
":",
"import",
"numpy",
"as",
"np",
"from",
".",
"utils",
"import",
"safe_cast",
"as",
"scast",
"from",
".",
"utils",
".",
"vector",
"import",
"vec_angle",
"i... | Spanning angle among three atoms.
The indices `at_1` and `at_3` can be the same (yielding a
trivial zero angle), but `at_2` must be different from
both `at_1` and `at_3`.
Parameters
----------
g_num
|int| --
Index of the desired geometry
... | [
"Spanning",
"angle",
"among",
"three",
"atoms",
"."
] | 0b1b21662df6abc971407a9386db21a8796fbfe5 | https://github.com/bskinn/opan/blob/0b1b21662df6abc971407a9386db21a8796fbfe5/opan/xyz.py#L919-L1010 | train |
bskinn/opan | opan/xyz.py | OpanXYZ.angle_iter | def angle_iter(self, g_nums, ats_1, ats_2, ats_3, invalid_error=False):
""" Iterator over selected atomic angles.
Angles are in degrees as with :meth:`angle_single`.
See `above <toc-generators_>`_ for more information on
calling options.
Parameters
----------
g... | python | def angle_iter(self, g_nums, ats_1, ats_2, ats_3, invalid_error=False):
""" Iterator over selected atomic angles.
Angles are in degrees as with :meth:`angle_single`.
See `above <toc-generators_>`_ for more information on
calling options.
Parameters
----------
g... | [
"def",
"angle_iter",
"(",
"self",
",",
"g_nums",
",",
"ats_1",
",",
"ats_2",
",",
"ats_3",
",",
"invalid_error",
"=",
"False",
")",
":",
"from",
".",
"utils",
"import",
"pack_tups",
"if",
"_DEBUG",
":",
"print",
"(",
"\"g_nums = {0}\"",
".",
"format",
"(... | Iterator over selected atomic angles.
Angles are in degrees as with :meth:`angle_single`.
See `above <toc-generators_>`_ for more information on
calling options.
Parameters
----------
g_nums
|int| or iterable |int| or |None| --
Index of the desi... | [
"Iterator",
"over",
"selected",
"atomic",
"angles",
"."
] | 0b1b21662df6abc971407a9386db21a8796fbfe5 | https://github.com/bskinn/opan/blob/0b1b21662df6abc971407a9386db21a8796fbfe5/opan/xyz.py#L1015-L1098 | train |
bskinn/opan | opan/xyz.py | OpanXYZ.dihed_iter | def dihed_iter(self, g_nums, ats_1, ats_2, ats_3, ats_4, \
invalid_error=False):
""" Iterator over selected dihedral angles.
Angles are in degrees as with :meth:`dihed_single`.
See `above <toc-generators_>`_ for more information on
ca... | python | def dihed_iter(self, g_nums, ats_1, ats_2, ats_3, ats_4, \
invalid_error=False):
""" Iterator over selected dihedral angles.
Angles are in degrees as with :meth:`dihed_single`.
See `above <toc-generators_>`_ for more information on
ca... | [
"def",
"dihed_iter",
"(",
"self",
",",
"g_nums",
",",
"ats_1",
",",
"ats_2",
",",
"ats_3",
",",
"ats_4",
",",
"invalid_error",
"=",
"False",
")",
":",
"from",
".",
"utils",
"import",
"pack_tups",
"if",
"_DEBUG",
":",
"print",
"(",
"\"g_nums = {0}\"",
"."... | Iterator over selected dihedral angles.
Angles are in degrees as with :meth:`dihed_single`.
See `above <toc-generators_>`_ for more information on
calling options.
Parameters
----------
g_nums
|int| or iterable |int| or |None| --
Indices of the... | [
"Iterator",
"over",
"selected",
"dihedral",
"angles",
"."
] | 0b1b21662df6abc971407a9386db21a8796fbfe5 | https://github.com/bskinn/opan/blob/0b1b21662df6abc971407a9386db21a8796fbfe5/opan/xyz.py#L1293-L1384 | train |
bskinn/opan | opan/xyz.py | OpanXYZ.displ_single | def displ_single(self, g_num, at_1, at_2):
""" Displacement vector between two atoms.
Returns the displacement vector pointing from `at_1`
toward `at_2` from geometry `g_num`.
If `at_1` == `at_2` a strict zero vector is returned.
Displacement vector is returned in units of Bohr... | python | def displ_single(self, g_num, at_1, at_2):
""" Displacement vector between two atoms.
Returns the displacement vector pointing from `at_1`
toward `at_2` from geometry `g_num`.
If `at_1` == `at_2` a strict zero vector is returned.
Displacement vector is returned in units of Bohr... | [
"def",
"displ_single",
"(",
"self",
",",
"g_num",
",",
"at_1",
",",
"at_2",
")",
":",
"import",
"numpy",
"as",
"np",
"from",
".",
"utils",
"import",
"safe_cast",
"as",
"scast",
"if",
"not",
"(",
"-",
"self",
".",
"num_atoms",
"<=",
"at_1",
"<",
"self... | Displacement vector between two atoms.
Returns the displacement vector pointing from `at_1`
toward `at_2` from geometry `g_num`.
If `at_1` == `at_2` a strict zero vector is returned.
Displacement vector is returned in units of Bohrs.
Parameters
----------
g_num... | [
"Displacement",
"vector",
"between",
"two",
"atoms",
"."
] | 0b1b21662df6abc971407a9386db21a8796fbfe5 | https://github.com/bskinn/opan/blob/0b1b21662df6abc971407a9386db21a8796fbfe5/opan/xyz.py#L1390-L1457 | train |
bskinn/opan | opan/xyz.py | OpanXYZ.displ_iter | def displ_iter(self, g_nums, ats_1, ats_2, invalid_error=False):
""" Iterator over indicated displacement vectors.
Displacements are in Bohrs as with :meth:`displ_single`.
See `above <toc-generators_>`_ for more information on
calling options.
Parameters
----------
... | python | def displ_iter(self, g_nums, ats_1, ats_2, invalid_error=False):
""" Iterator over indicated displacement vectors.
Displacements are in Bohrs as with :meth:`displ_single`.
See `above <toc-generators_>`_ for more information on
calling options.
Parameters
----------
... | [
"def",
"displ_iter",
"(",
"self",
",",
"g_nums",
",",
"ats_1",
",",
"ats_2",
",",
"invalid_error",
"=",
"False",
")",
":",
"from",
".",
"utils",
"import",
"pack_tups",
"if",
"_DEBUG",
":",
"print",
"(",
"\"g_nums = {0}\"",
".",
"format",
"(",
"g_nums",
"... | Iterator over indicated displacement vectors.
Displacements are in Bohrs as with :meth:`displ_single`.
See `above <toc-generators_>`_ for more information on
calling options.
Parameters
----------
g_nums
|int| or length-R iterable |int| or |None| --
... | [
"Iterator",
"over",
"indicated",
"displacement",
"vectors",
"."
] | 0b1b21662df6abc971407a9386db21a8796fbfe5 | https://github.com/bskinn/opan/blob/0b1b21662df6abc971407a9386db21a8796fbfe5/opan/xyz.py#L1462-L1531 | train |
bskinn/opan | opan/xyz.py | OpanXYZ._none_subst | def _none_subst(self, *args):
""" Helper function to insert full ranges for |None| for X_iter methods.
Custom method, specifically tailored, taking in the arguments from
an X_iter method and performing the replacement of |None| after
error-checking the arguments for a max of one |None| ... | python | def _none_subst(self, *args):
""" Helper function to insert full ranges for |None| for X_iter methods.
Custom method, specifically tailored, taking in the arguments from
an X_iter method and performing the replacement of |None| after
error-checking the arguments for a max of one |None| ... | [
"def",
"_none_subst",
"(",
"self",
",",
"*",
"args",
")",
":",
"import",
"numpy",
"as",
"np",
"arglist",
"=",
"[",
"a",
"for",
"a",
"in",
"args",
"]",
"none_found",
"=",
"False",
"none_vals",
"=",
"list",
"(",
"map",
"(",
"lambda",
"e",
":",
"isins... | Helper function to insert full ranges for |None| for X_iter methods.
Custom method, specifically tailored, taking in the arguments from
an X_iter method and performing the replacement of |None| after
error-checking the arguments for a max of one |None| value, and ensuring
that if a |Non... | [
"Helper",
"function",
"to",
"insert",
"full",
"ranges",
"for",
"|None|",
"for",
"X_iter",
"methods",
"."
] | 0b1b21662df6abc971407a9386db21a8796fbfe5 | https://github.com/bskinn/opan/blob/0b1b21662df6abc971407a9386db21a8796fbfe5/opan/xyz.py#L1537-L1599 | train |
vfaronov/turq | turq/util/http.py | guess_external_url | def guess_external_url(local_host, port):
"""Return a URL that is most likely to route to `local_host` from outside.
The point is that we may be running on a remote host from the user's
point of view, so they can't access `local_host` from a Web browser just
by typing ``http://localhost:12345/``.
"... | python | def guess_external_url(local_host, port):
"""Return a URL that is most likely to route to `local_host` from outside.
The point is that we may be running on a remote host from the user's
point of view, so they can't access `local_host` from a Web browser just
by typing ``http://localhost:12345/``.
"... | [
"def",
"guess_external_url",
"(",
"local_host",
",",
"port",
")",
":",
"if",
"local_host",
"in",
"[",
"'0.0.0.0'",
",",
"'::'",
"]",
":",
"local_host",
"=",
"socket",
".",
"getfqdn",
"(",
")",
"match",
"=",
"IPV4_REVERSE_DNS",
".",
"match",
"(",
"local_hos... | Return a URL that is most likely to route to `local_host` from outside.
The point is that we may be running on a remote host from the user's
point of view, so they can't access `local_host` from a Web browser just
by typing ``http://localhost:12345/``. | [
"Return",
"a",
"URL",
"that",
"is",
"most",
"likely",
"to",
"route",
"to",
"local_host",
"from",
"outside",
"."
] | 3ef1261442b90d6d947b8fe2362e19e7f47a64c3 | https://github.com/vfaronov/turq/blob/3ef1261442b90d6d947b8fe2362e19e7f47a64c3/turq/util/http.py#L49-L79 | train |
openvax/isovar | isovar/dataframe_builder.py | DataFrameBuilder._check_column_lengths | def _check_column_lengths(self):
"""
Make sure columns are of the same length or else DataFrame construction
will fail.
"""
column_lengths_dict = {
name: len(xs)
for (name, xs)
in self.columns_dict.items()
}
unique_column_length... | python | def _check_column_lengths(self):
"""
Make sure columns are of the same length or else DataFrame construction
will fail.
"""
column_lengths_dict = {
name: len(xs)
for (name, xs)
in self.columns_dict.items()
}
unique_column_length... | [
"def",
"_check_column_lengths",
"(",
"self",
")",
":",
"column_lengths_dict",
"=",
"{",
"name",
":",
"len",
"(",
"xs",
")",
"for",
"(",
"name",
",",
"xs",
")",
"in",
"self",
".",
"columns_dict",
".",
"items",
"(",
")",
"}",
"unique_column_lengths",
"=",
... | Make sure columns are of the same length or else DataFrame construction
will fail. | [
"Make",
"sure",
"columns",
"are",
"of",
"the",
"same",
"length",
"or",
"else",
"DataFrame",
"construction",
"will",
"fail",
"."
] | b39b684920e3f6b344851d6598a1a1c67bce913b | https://github.com/openvax/isovar/blob/b39b684920e3f6b344851d6598a1a1c67bce913b/isovar/dataframe_builder.py#L169-L182 | train |
bskinn/opan | opan/vpt2/base.py | OpanVPT2.new_from_files | def new_from_files(self, basepath, basename, repo, \
bohrs=False, \
software=_E_SW.ORCA, \
repo_clobber=False, **kwargs):
""" Initialize with data from files.
"""
# Imports
import os
from os import path as osp
... | python | def new_from_files(self, basepath, basename, repo, \
bohrs=False, \
software=_E_SW.ORCA, \
repo_clobber=False, **kwargs):
""" Initialize with data from files.
"""
# Imports
import os
from os import path as osp
... | [
"def",
"new_from_files",
"(",
"self",
",",
"basepath",
",",
"basename",
",",
"repo",
",",
"bohrs",
"=",
"False",
",",
"software",
"=",
"_E_SW",
".",
"ORCA",
",",
"repo_clobber",
"=",
"False",
",",
"**",
"kwargs",
")",
":",
"import",
"os",
"from",
"os",... | Initialize with data from files. | [
"Initialize",
"with",
"data",
"from",
"files",
"."
] | 0b1b21662df6abc971407a9386db21a8796fbfe5 | https://github.com/bskinn/opan/blob/0b1b21662df6abc971407a9386db21a8796fbfe5/opan/vpt2/base.py#L54-L144 | train |
daskos/mentor | mentor/utils.py | remote_exception | def remote_exception(exc, tb):
""" Metaclass that wraps exception type in RemoteException """
if type(exc) in exceptions:
typ = exceptions[type(exc)]
return typ(exc, tb)
else:
try:
typ = type(exc.__class__.__name__,
(RemoteException, type(exc)),
... | python | def remote_exception(exc, tb):
""" Metaclass that wraps exception type in RemoteException """
if type(exc) in exceptions:
typ = exceptions[type(exc)]
return typ(exc, tb)
else:
try:
typ = type(exc.__class__.__name__,
(RemoteException, type(exc)),
... | [
"def",
"remote_exception",
"(",
"exc",
",",
"tb",
")",
":",
"if",
"type",
"(",
"exc",
")",
"in",
"exceptions",
":",
"typ",
"=",
"exceptions",
"[",
"type",
"(",
"exc",
")",
"]",
"return",
"typ",
"(",
"exc",
",",
"tb",
")",
"else",
":",
"try",
":",... | Metaclass that wraps exception type in RemoteException | [
"Metaclass",
"that",
"wraps",
"exception",
"type",
"in",
"RemoteException"
] | b5fd64e3a3192f5664fa5c03e8517cacb4e0590f | https://github.com/daskos/mentor/blob/b5fd64e3a3192f5664fa5c03e8517cacb4e0590f/mentor/utils.py#L61-L74 | train |
openvax/isovar | isovar/allele_reads.py | reads_overlapping_variants | def reads_overlapping_variants(variants, samfile, **kwargs):
"""
Generates sequence of tuples, each containing a variant paired with
a list of AlleleRead objects.
Parameters
----------
variants : varcode.VariantCollection
samfile : pysam.AlignmentFile
use_duplicate_reads : bool
... | python | def reads_overlapping_variants(variants, samfile, **kwargs):
"""
Generates sequence of tuples, each containing a variant paired with
a list of AlleleRead objects.
Parameters
----------
variants : varcode.VariantCollection
samfile : pysam.AlignmentFile
use_duplicate_reads : bool
... | [
"def",
"reads_overlapping_variants",
"(",
"variants",
",",
"samfile",
",",
"**",
"kwargs",
")",
":",
"chromosome_names",
"=",
"set",
"(",
"samfile",
".",
"references",
")",
"for",
"variant",
"in",
"variants",
":",
"if",
"variant",
".",
"contig",
"in",
"chrom... | Generates sequence of tuples, each containing a variant paired with
a list of AlleleRead objects.
Parameters
----------
variants : varcode.VariantCollection
samfile : pysam.AlignmentFile
use_duplicate_reads : bool
Should we use reads that have been marked as PCR duplicates
use_se... | [
"Generates",
"sequence",
"of",
"tuples",
"each",
"containing",
"a",
"variant",
"paired",
"with",
"a",
"list",
"of",
"AlleleRead",
"objects",
"."
] | b39b684920e3f6b344851d6598a1a1c67bce913b | https://github.com/openvax/isovar/blob/b39b684920e3f6b344851d6598a1a1c67bce913b/isovar/allele_reads.py#L234-L280 | train |
openvax/isovar | isovar/allele_reads.py | group_reads_by_allele | def group_reads_by_allele(allele_reads):
"""
Returns dictionary mapping each allele's nucleotide sequence to a list of
supporting AlleleRead objects.
"""
allele_to_reads_dict = defaultdict(list)
for allele_read in allele_reads:
allele_to_reads_dict[allele_read.allele].append(allele_read)... | python | def group_reads_by_allele(allele_reads):
"""
Returns dictionary mapping each allele's nucleotide sequence to a list of
supporting AlleleRead objects.
"""
allele_to_reads_dict = defaultdict(list)
for allele_read in allele_reads:
allele_to_reads_dict[allele_read.allele].append(allele_read)... | [
"def",
"group_reads_by_allele",
"(",
"allele_reads",
")",
":",
"allele_to_reads_dict",
"=",
"defaultdict",
"(",
"list",
")",
"for",
"allele_read",
"in",
"allele_reads",
":",
"allele_to_reads_dict",
"[",
"allele_read",
".",
"allele",
"]",
".",
"append",
"(",
"allel... | Returns dictionary mapping each allele's nucleotide sequence to a list of
supporting AlleleRead objects. | [
"Returns",
"dictionary",
"mapping",
"each",
"allele",
"s",
"nucleotide",
"sequence",
"to",
"a",
"list",
"of",
"supporting",
"AlleleRead",
"objects",
"."
] | b39b684920e3f6b344851d6598a1a1c67bce913b | https://github.com/openvax/isovar/blob/b39b684920e3f6b344851d6598a1a1c67bce913b/isovar/allele_reads.py#L283-L291 | train |
openvax/isovar | isovar/allele_reads.py | AlleleRead.from_locus_read | def from_locus_read(cls, locus_read, n_ref):
"""
Given a single LocusRead object, return either an AlleleRead or None
Parameters
----------
locus_read : LocusRead
Read which overlaps a variant locus but doesn't necessarily contain the
alternate nucleotide... | python | def from_locus_read(cls, locus_read, n_ref):
"""
Given a single LocusRead object, return either an AlleleRead or None
Parameters
----------
locus_read : LocusRead
Read which overlaps a variant locus but doesn't necessarily contain the
alternate nucleotide... | [
"def",
"from_locus_read",
"(",
"cls",
",",
"locus_read",
",",
"n_ref",
")",
":",
"sequence",
"=",
"locus_read",
".",
"sequence",
"reference_positions",
"=",
"locus_read",
".",
"reference_positions",
"read_pos_before",
"=",
"locus_read",
".",
"base0_read_position_befor... | Given a single LocusRead object, return either an AlleleRead or None
Parameters
----------
locus_read : LocusRead
Read which overlaps a variant locus but doesn't necessarily contain the
alternate nucleotides
n_ref : int
Number of reference positions ... | [
"Given",
"a",
"single",
"LocusRead",
"object",
"return",
"either",
"an",
"AlleleRead",
"or",
"None"
] | b39b684920e3f6b344851d6598a1a1c67bce913b | https://github.com/openvax/isovar/blob/b39b684920e3f6b344851d6598a1a1c67bce913b/isovar/allele_reads.py#L52-L140 | train |
openvax/isovar | isovar/nucleotide_counts.py | most_common_nucleotides | def most_common_nucleotides(partitioned_read_sequences):
"""
Find the most common nucleotide at each offset to the left and
right of a variant.
Parameters
----------
partitioned_read_sequences : list of tuples
Each tuple has three elements:
- sequence before mutant nucleotid... | python | def most_common_nucleotides(partitioned_read_sequences):
"""
Find the most common nucleotide at each offset to the left and
right of a variant.
Parameters
----------
partitioned_read_sequences : list of tuples
Each tuple has three elements:
- sequence before mutant nucleotid... | [
"def",
"most_common_nucleotides",
"(",
"partitioned_read_sequences",
")",
":",
"counts",
",",
"variant_column_indices",
"=",
"nucleotide_counts",
"(",
"partitioned_read_sequences",
")",
"max_count_per_column",
"=",
"counts",
".",
"max",
"(",
"axis",
"=",
"0",
")",
"as... | Find the most common nucleotide at each offset to the left and
right of a variant.
Parameters
----------
partitioned_read_sequences : list of tuples
Each tuple has three elements:
- sequence before mutant nucleotides
- mutant nucleotides
- sequence after muta... | [
"Find",
"the",
"most",
"common",
"nucleotide",
"at",
"each",
"offset",
"to",
"the",
"left",
"and",
"right",
"of",
"a",
"variant",
"."
] | b39b684920e3f6b344851d6598a1a1c67bce913b | https://github.com/openvax/isovar/blob/b39b684920e3f6b344851d6598a1a1c67bce913b/isovar/nucleotide_counts.py#L81-L112 | train |
bskinn/opan | opan/utils/symm.py | point_displ | def point_displ(pt1, pt2):
""" Calculate the displacement vector between two n-D points.
pt1 - pt2
.. todo:: Complete point_disp docstring
"""
#Imports
import numpy as np
# Make iterable
if not np.iterable(pt1):
pt1 = np.float64(np.array([pt1]))
else:
pt1 = np.fl... | python | def point_displ(pt1, pt2):
""" Calculate the displacement vector between two n-D points.
pt1 - pt2
.. todo:: Complete point_disp docstring
"""
#Imports
import numpy as np
# Make iterable
if not np.iterable(pt1):
pt1 = np.float64(np.array([pt1]))
else:
pt1 = np.fl... | [
"def",
"point_displ",
"(",
"pt1",
",",
"pt2",
")",
":",
"import",
"numpy",
"as",
"np",
"if",
"not",
"np",
".",
"iterable",
"(",
"pt1",
")",
":",
"pt1",
"=",
"np",
".",
"float64",
"(",
"np",
".",
"array",
"(",
"[",
"pt1",
"]",
")",
")",
"else",
... | Calculate the displacement vector between two n-D points.
pt1 - pt2
.. todo:: Complete point_disp docstring | [
"Calculate",
"the",
"displacement",
"vector",
"between",
"two",
"n",
"-",
"D",
"points",
"."
] | 0b1b21662df6abc971407a9386db21a8796fbfe5 | https://github.com/bskinn/opan/blob/0b1b21662df6abc971407a9386db21a8796fbfe5/opan/utils/symm.py#L42-L68 | train |
bskinn/opan | opan/utils/symm.py | point_dist | def point_dist(pt1, pt2):
""" Calculate the Euclidean distance between two n-D points.
|pt1 - pt2|
.. todo:: Complete point_dist docstring
"""
# Imports
from scipy import linalg as spla
dist = spla.norm(point_displ(pt1, pt2))
return dist | python | def point_dist(pt1, pt2):
""" Calculate the Euclidean distance between two n-D points.
|pt1 - pt2|
.. todo:: Complete point_dist docstring
"""
# Imports
from scipy import linalg as spla
dist = spla.norm(point_displ(pt1, pt2))
return dist | [
"def",
"point_dist",
"(",
"pt1",
",",
"pt2",
")",
":",
"from",
"scipy",
"import",
"linalg",
"as",
"spla",
"dist",
"=",
"spla",
".",
"norm",
"(",
"point_displ",
"(",
"pt1",
",",
"pt2",
")",
")",
"return",
"dist"
] | Calculate the Euclidean distance between two n-D points.
|pt1 - pt2|
.. todo:: Complete point_dist docstring | [
"Calculate",
"the",
"Euclidean",
"distance",
"between",
"two",
"n",
"-",
"D",
"points",
"."
] | 0b1b21662df6abc971407a9386db21a8796fbfe5 | https://github.com/bskinn/opan/blob/0b1b21662df6abc971407a9386db21a8796fbfe5/opan/utils/symm.py#L73-L86 | train |
bskinn/opan | opan/utils/symm.py | point_rotate | def point_rotate(pt, ax, theta):
""" Rotate a 3-D point around a 3-D axis through the origin.
Handedness is a counter-clockwise rotation when viewing the rotation
axis as pointing at the observer. Thus, in a right-handed x-y-z frame,
a 90deg rotation of (1,0,0) around the z-axis (0,0,1) yields a point... | python | def point_rotate(pt, ax, theta):
""" Rotate a 3-D point around a 3-D axis through the origin.
Handedness is a counter-clockwise rotation when viewing the rotation
axis as pointing at the observer. Thus, in a right-handed x-y-z frame,
a 90deg rotation of (1,0,0) around the z-axis (0,0,1) yields a point... | [
"def",
"point_rotate",
"(",
"pt",
",",
"ax",
",",
"theta",
")",
":",
"import",
"numpy",
"as",
"np",
"pt",
"=",
"make_nd_vec",
"(",
"pt",
",",
"nd",
"=",
"3",
",",
"t",
"=",
"np",
".",
"float64",
",",
"norm",
"=",
"False",
")",
"rot_pt",
"=",
"n... | Rotate a 3-D point around a 3-D axis through the origin.
Handedness is a counter-clockwise rotation when viewing the rotation
axis as pointing at the observer. Thus, in a right-handed x-y-z frame,
a 90deg rotation of (1,0,0) around the z-axis (0,0,1) yields a point at
(0,1,0).
.. todo:: Complete ... | [
"Rotate",
"a",
"3",
"-",
"D",
"point",
"around",
"a",
"3",
"-",
"D",
"axis",
"through",
"the",
"origin",
"."
] | 0b1b21662df6abc971407a9386db21a8796fbfe5 | https://github.com/bskinn/opan/blob/0b1b21662df6abc971407a9386db21a8796fbfe5/opan/utils/symm.py#L91-L118 | train |
bskinn/opan | opan/utils/symm.py | point_reflect | def point_reflect(pt, nv):
""" Reflect a 3-D point through a plane intersecting the origin.
nv defines the normal vector to the plane (needs not be normalized)
.. todo:: Complete point_reflect docstring
Raises
------
ValueError : If pt or nv are not reducible to 3-D vectors
ValueError : I... | python | def point_reflect(pt, nv):
""" Reflect a 3-D point through a plane intersecting the origin.
nv defines the normal vector to the plane (needs not be normalized)
.. todo:: Complete point_reflect docstring
Raises
------
ValueError : If pt or nv are not reducible to 3-D vectors
ValueError : I... | [
"def",
"point_reflect",
"(",
"pt",
",",
"nv",
")",
":",
"import",
"numpy",
"as",
"np",
"from",
"scipy",
"import",
"linalg",
"as",
"spla",
"pt",
"=",
"make_nd_vec",
"(",
"pt",
",",
"nd",
"=",
"3",
",",
"t",
"=",
"np",
".",
"float64",
",",
"norm",
... | Reflect a 3-D point through a plane intersecting the origin.
nv defines the normal vector to the plane (needs not be normalized)
.. todo:: Complete point_reflect docstring
Raises
------
ValueError : If pt or nv are not reducible to 3-D vectors
ValueError : If norm of nv is too small | [
"Reflect",
"a",
"3",
"-",
"D",
"point",
"through",
"a",
"plane",
"intersecting",
"the",
"origin",
"."
] | 0b1b21662df6abc971407a9386db21a8796fbfe5 | https://github.com/bskinn/opan/blob/0b1b21662df6abc971407a9386db21a8796fbfe5/opan/utils/symm.py#L123-L145 | train |
bskinn/opan | opan/utils/symm.py | geom_reflect | def geom_reflect(g, nv):
""" Reflection symmetry operation.
nv is normal vector to reflection plane
g is assumed already translated to center of mass @ origin
.. todo:: Complete geom_reflect docstring
"""
# Imports
import numpy as np
# Force g to n-vector
g = make_nd_vec(g, nd=N... | python | def geom_reflect(g, nv):
""" Reflection symmetry operation.
nv is normal vector to reflection plane
g is assumed already translated to center of mass @ origin
.. todo:: Complete geom_reflect docstring
"""
# Imports
import numpy as np
# Force g to n-vector
g = make_nd_vec(g, nd=N... | [
"def",
"geom_reflect",
"(",
"g",
",",
"nv",
")",
":",
"import",
"numpy",
"as",
"np",
"g",
"=",
"make_nd_vec",
"(",
"g",
",",
"nd",
"=",
"None",
",",
"t",
"=",
"np",
".",
"float64",
",",
"norm",
"=",
"False",
")",
"refl_g",
"=",
"np",
".",
"dot"... | Reflection symmetry operation.
nv is normal vector to reflection plane
g is assumed already translated to center of mass @ origin
.. todo:: Complete geom_reflect docstring | [
"Reflection",
"symmetry",
"operation",
"."
] | 0b1b21662df6abc971407a9386db21a8796fbfe5 | https://github.com/bskinn/opan/blob/0b1b21662df6abc971407a9386db21a8796fbfe5/opan/utils/symm.py#L150-L169 | train |
bskinn/opan | opan/utils/symm.py | geom_rotate | def geom_rotate(g, ax, theta):
""" Rotation symmetry operation.
ax is rotation axis
g is assumed already translated to center of mass @ origin
Sense of rotation is the same as point_rotate
.. todo:: Complete geom_rotate docstring
"""
# Imports
import numpy as np
# Force g to n-... | python | def geom_rotate(g, ax, theta):
""" Rotation symmetry operation.
ax is rotation axis
g is assumed already translated to center of mass @ origin
Sense of rotation is the same as point_rotate
.. todo:: Complete geom_rotate docstring
"""
# Imports
import numpy as np
# Force g to n-... | [
"def",
"geom_rotate",
"(",
"g",
",",
"ax",
",",
"theta",
")",
":",
"import",
"numpy",
"as",
"np",
"g",
"=",
"make_nd_vec",
"(",
"g",
",",
"nd",
"=",
"None",
",",
"t",
"=",
"np",
".",
"float64",
",",
"norm",
"=",
"False",
")",
"rot_g",
"=",
"np"... | Rotation symmetry operation.
ax is rotation axis
g is assumed already translated to center of mass @ origin
Sense of rotation is the same as point_rotate
.. todo:: Complete geom_rotate docstring | [
"Rotation",
"symmetry",
"operation",
"."
] | 0b1b21662df6abc971407a9386db21a8796fbfe5 | https://github.com/bskinn/opan/blob/0b1b21662df6abc971407a9386db21a8796fbfe5/opan/utils/symm.py#L174-L195 | train |
bskinn/opan | opan/utils/symm.py | symm_op | def symm_op(g, ax, theta, do_refl):
""" Perform general point symmetry operation on a geometry.
.. todo:: Complete symm_op docstring
"""
# Imports
import numpy as np
# Depend on lower functions' geometry vector coercion. Just
# do the rotation and, if indicated, the reflection.
gx =... | python | def symm_op(g, ax, theta, do_refl):
""" Perform general point symmetry operation on a geometry.
.. todo:: Complete symm_op docstring
"""
# Imports
import numpy as np
# Depend on lower functions' geometry vector coercion. Just
# do the rotation and, if indicated, the reflection.
gx =... | [
"def",
"symm_op",
"(",
"g",
",",
"ax",
",",
"theta",
",",
"do_refl",
")",
":",
"import",
"numpy",
"as",
"np",
"gx",
"=",
"geom_rotate",
"(",
"g",
",",
"ax",
",",
"theta",
")",
"if",
"do_refl",
":",
"gx",
"=",
"geom_reflect",
"(",
"gx",
",",
"ax",... | Perform general point symmetry operation on a geometry.
.. todo:: Complete symm_op docstring | [
"Perform",
"general",
"point",
"symmetry",
"operation",
"on",
"a",
"geometry",
"."
] | 0b1b21662df6abc971407a9386db21a8796fbfe5 | https://github.com/bskinn/opan/blob/0b1b21662df6abc971407a9386db21a8796fbfe5/opan/utils/symm.py#L200-L218 | train |
bskinn/opan | opan/utils/symm.py | geom_find_rotsymm | def geom_find_rotsymm(g, atwts, ax, improp, \
nmax=_DEF.SYMM_MATCH_NMAX, \
tol=_DEF.SYMM_MATCH_TOL):
""" Identify highest-order symmetry for a geometry on a given axis.
Regular and improper axes possible.
.. todo:: Complete geom_find_rotsymm docstring
"""
# Imports
import num... | python | def geom_find_rotsymm(g, atwts, ax, improp, \
nmax=_DEF.SYMM_MATCH_NMAX, \
tol=_DEF.SYMM_MATCH_TOL):
""" Identify highest-order symmetry for a geometry on a given axis.
Regular and improper axes possible.
.. todo:: Complete geom_find_rotsymm docstring
"""
# Imports
import num... | [
"def",
"geom_find_rotsymm",
"(",
"g",
",",
"atwts",
",",
"ax",
",",
"improp",
",",
"nmax",
"=",
"_DEF",
".",
"SYMM_MATCH_NMAX",
",",
"tol",
"=",
"_DEF",
".",
"SYMM_MATCH_TOL",
")",
":",
"import",
"numpy",
"as",
"np",
"g",
"=",
"make_nd_vec",
"(",
"g",
... | Identify highest-order symmetry for a geometry on a given axis.
Regular and improper axes possible.
.. todo:: Complete geom_find_rotsymm docstring | [
"Identify",
"highest",
"-",
"order",
"symmetry",
"for",
"a",
"geometry",
"on",
"a",
"given",
"axis",
"."
] | 0b1b21662df6abc971407a9386db21a8796fbfe5 | https://github.com/bskinn/opan/blob/0b1b21662df6abc971407a9386db21a8796fbfe5/opan/utils/symm.py#L305-L345 | train |
bskinn/opan | opan/utils/symm.py | g_subset | def g_subset(g, atwts, atwt,
digits=_DEF.SYMM_ATWT_ROUND_DIGITS):
""" Extract a subset of a geometry matching a desired atom.
.. todo:: Complete g_subset docstring
"""
# Imports
import numpy as np
# Ensure g and atwts are n-D vectors
g = make_nd_vec(g, nd=None, t=np.float64, ... | python | def g_subset(g, atwts, atwt,
digits=_DEF.SYMM_ATWT_ROUND_DIGITS):
""" Extract a subset of a geometry matching a desired atom.
.. todo:: Complete g_subset docstring
"""
# Imports
import numpy as np
# Ensure g and atwts are n-D vectors
g = make_nd_vec(g, nd=None, t=np.float64, ... | [
"def",
"g_subset",
"(",
"g",
",",
"atwts",
",",
"atwt",
",",
"digits",
"=",
"_DEF",
".",
"SYMM_ATWT_ROUND_DIGITS",
")",
":",
"import",
"numpy",
"as",
"np",
"g",
"=",
"make_nd_vec",
"(",
"g",
",",
"nd",
"=",
"None",
",",
"t",
"=",
"np",
".",
"float6... | Extract a subset of a geometry matching a desired atom.
.. todo:: Complete g_subset docstring | [
"Extract",
"a",
"subset",
"of",
"a",
"geometry",
"matching",
"a",
"desired",
"atom",
"."
] | 0b1b21662df6abc971407a9386db21a8796fbfe5 | https://github.com/bskinn/opan/blob/0b1b21662df6abc971407a9386db21a8796fbfe5/opan/utils/symm.py#L698-L734 | train |
bskinn/opan | opan/utils/symm.py | mtx_refl | def mtx_refl(nv, reps=1):
""" Generate block-diagonal reflection matrix about nv.
reps must be >=1 and indicates the number of times the reflection
matrix should be repeated along the block diagonal. Typically this
will be the number of atoms in a geometry.
.. todo:: Complete mtx_refl docstring
... | python | def mtx_refl(nv, reps=1):
""" Generate block-diagonal reflection matrix about nv.
reps must be >=1 and indicates the number of times the reflection
matrix should be repeated along the block diagonal. Typically this
will be the number of atoms in a geometry.
.. todo:: Complete mtx_refl docstring
... | [
"def",
"mtx_refl",
"(",
"nv",
",",
"reps",
"=",
"1",
")",
":",
"import",
"numpy",
"as",
"np",
"from",
"scipy",
"import",
"linalg",
"as",
"spla",
"from",
".",
".",
"const",
"import",
"PRM",
"if",
"spla",
".",
"norm",
"(",
"nv",
")",
"<",
"PRM",
".... | Generate block-diagonal reflection matrix about nv.
reps must be >=1 and indicates the number of times the reflection
matrix should be repeated along the block diagonal. Typically this
will be the number of atoms in a geometry.
.. todo:: Complete mtx_refl docstring | [
"Generate",
"block",
"-",
"diagonal",
"reflection",
"matrix",
"about",
"nv",
"."
] | 0b1b21662df6abc971407a9386db21a8796fbfe5 | https://github.com/bskinn/opan/blob/0b1b21662df6abc971407a9386db21a8796fbfe5/opan/utils/symm.py#L779-L832 | train |
bskinn/opan | opan/utils/symm.py | mtx_rot | def mtx_rot(ax, theta, reps=1):
""" Generate block-diagonal rotation matrix about ax.
[copy handedness from somewhere]
.. todo:: Complete mtx_rot docstring
"""
# Imports
import numpy as np
from scipy import linalg as spla
from ..const import PRM
# Ensure |ax| is large enough for... | python | def mtx_rot(ax, theta, reps=1):
""" Generate block-diagonal rotation matrix about ax.
[copy handedness from somewhere]
.. todo:: Complete mtx_rot docstring
"""
# Imports
import numpy as np
from scipy import linalg as spla
from ..const import PRM
# Ensure |ax| is large enough for... | [
"def",
"mtx_rot",
"(",
"ax",
",",
"theta",
",",
"reps",
"=",
"1",
")",
":",
"import",
"numpy",
"as",
"np",
"from",
"scipy",
"import",
"linalg",
"as",
"spla",
"from",
".",
".",
"const",
"import",
"PRM",
"if",
"spla",
".",
"norm",
"(",
"ax",
")",
"... | Generate block-diagonal rotation matrix about ax.
[copy handedness from somewhere]
.. todo:: Complete mtx_rot docstring | [
"Generate",
"block",
"-",
"diagonal",
"rotation",
"matrix",
"about",
"ax",
"."
] | 0b1b21662df6abc971407a9386db21a8796fbfe5 | https://github.com/bskinn/opan/blob/0b1b21662df6abc971407a9386db21a8796fbfe5/opan/utils/symm.py#L837-L896 | train |
daskos/mentor | mentor/binpack.py | ff | def ff(items, targets):
"""First-Fit
This is perhaps the simplest packing heuristic;
it simply packs items in the next available bin.
Complexity O(n^2)
"""
bins = [(target, []) for target in targets]
skip = []
for item in items:
for target, content in bins:
if item... | python | def ff(items, targets):
"""First-Fit
This is perhaps the simplest packing heuristic;
it simply packs items in the next available bin.
Complexity O(n^2)
"""
bins = [(target, []) for target in targets]
skip = []
for item in items:
for target, content in bins:
if item... | [
"def",
"ff",
"(",
"items",
",",
"targets",
")",
":",
"bins",
"=",
"[",
"(",
"target",
",",
"[",
"]",
")",
"for",
"target",
"in",
"targets",
"]",
"skip",
"=",
"[",
"]",
"for",
"item",
"in",
"items",
":",
"for",
"target",
",",
"content",
"in",
"b... | First-Fit
This is perhaps the simplest packing heuristic;
it simply packs items in the next available bin.
Complexity O(n^2) | [
"First",
"-",
"Fit"
] | b5fd64e3a3192f5664fa5c03e8517cacb4e0590f | https://github.com/daskos/mentor/blob/b5fd64e3a3192f5664fa5c03e8517cacb4e0590f/mentor/binpack.py#L22-L40 | train |
daskos/mentor | mentor/binpack.py | ffd | def ffd(items, targets, **kwargs):
"""First-Fit Decreasing
This is perhaps the simplest packing heuristic;
it simply packs items in the next available bin.
This algorithm differs only from Next-Fit Decreasing
in having a 'sort'; that is, the items are pre-sorted
(largest to smallest).
Com... | python | def ffd(items, targets, **kwargs):
"""First-Fit Decreasing
This is perhaps the simplest packing heuristic;
it simply packs items in the next available bin.
This algorithm differs only from Next-Fit Decreasing
in having a 'sort'; that is, the items are pre-sorted
(largest to smallest).
Com... | [
"def",
"ffd",
"(",
"items",
",",
"targets",
",",
"**",
"kwargs",
")",
":",
"sizes",
"=",
"zip",
"(",
"items",
",",
"weight",
"(",
"items",
",",
"**",
"kwargs",
")",
")",
"sizes",
"=",
"sorted",
"(",
"sizes",
",",
"key",
"=",
"operator",
".",
"ite... | First-Fit Decreasing
This is perhaps the simplest packing heuristic;
it simply packs items in the next available bin.
This algorithm differs only from Next-Fit Decreasing
in having a 'sort'; that is, the items are pre-sorted
(largest to smallest).
Complexity O(n^2) | [
"First",
"-",
"Fit",
"Decreasing"
] | b5fd64e3a3192f5664fa5c03e8517cacb4e0590f | https://github.com/daskos/mentor/blob/b5fd64e3a3192f5664fa5c03e8517cacb4e0590f/mentor/binpack.py#L43-L58 | train |
daskos/mentor | mentor/binpack.py | mr | def mr(items, targets, **kwargs):
"""Max-Rest
Complexity O(n^2)
"""
bins = [(target, []) for target in targets]
skip = []
for item in items:
capacities = [target - sum(content) for target, content in bins]
weighted = weight(capacities, **kwargs)
(target, content), capa... | python | def mr(items, targets, **kwargs):
"""Max-Rest
Complexity O(n^2)
"""
bins = [(target, []) for target in targets]
skip = []
for item in items:
capacities = [target - sum(content) for target, content in bins]
weighted = weight(capacities, **kwargs)
(target, content), capa... | [
"def",
"mr",
"(",
"items",
",",
"targets",
",",
"**",
"kwargs",
")",
":",
"bins",
"=",
"[",
"(",
"target",
",",
"[",
"]",
")",
"for",
"target",
"in",
"targets",
"]",
"skip",
"=",
"[",
"]",
"for",
"item",
"in",
"items",
":",
"capacities",
"=",
"... | Max-Rest
Complexity O(n^2) | [
"Max",
"-",
"Rest"
] | b5fd64e3a3192f5664fa5c03e8517cacb4e0590f | https://github.com/daskos/mentor/blob/b5fd64e3a3192f5664fa5c03e8517cacb4e0590f/mentor/binpack.py#L61-L79 | train |
daskos/mentor | mentor/binpack.py | bf | def bf(items, targets, **kwargs):
"""Best-Fit
Complexity O(n^2)
"""
bins = [(target, []) for target in targets]
skip = []
for item in items:
containers = []
capacities = []
for target, content in bins:
capacity = target - sum(content)
if item <= ... | python | def bf(items, targets, **kwargs):
"""Best-Fit
Complexity O(n^2)
"""
bins = [(target, []) for target in targets]
skip = []
for item in items:
containers = []
capacities = []
for target, content in bins:
capacity = target - sum(content)
if item <= ... | [
"def",
"bf",
"(",
"items",
",",
"targets",
",",
"**",
"kwargs",
")",
":",
"bins",
"=",
"[",
"(",
"target",
",",
"[",
"]",
")",
"for",
"target",
"in",
"targets",
"]",
"skip",
"=",
"[",
"]",
"for",
"item",
"in",
"items",
":",
"containers",
"=",
"... | Best-Fit
Complexity O(n^2) | [
"Best",
"-",
"Fit"
] | b5fd64e3a3192f5664fa5c03e8517cacb4e0590f | https://github.com/daskos/mentor/blob/b5fd64e3a3192f5664fa5c03e8517cacb4e0590f/mentor/binpack.py#L90-L113 | train |
daskos/mentor | mentor/binpack.py | bfd | def bfd(items, targets, **kwargs):
"""Best-Fit Decreasing
Complexity O(n^2)
"""
sizes = zip(items, weight(items, **kwargs))
sizes = sorted(sizes, key=operator.itemgetter(1), reverse=True)
items = map(operator.itemgetter(0), sizes)
return bf(items, targets, **kwargs) | python | def bfd(items, targets, **kwargs):
"""Best-Fit Decreasing
Complexity O(n^2)
"""
sizes = zip(items, weight(items, **kwargs))
sizes = sorted(sizes, key=operator.itemgetter(1), reverse=True)
items = map(operator.itemgetter(0), sizes)
return bf(items, targets, **kwargs) | [
"def",
"bfd",
"(",
"items",
",",
"targets",
",",
"**",
"kwargs",
")",
":",
"sizes",
"=",
"zip",
"(",
"items",
",",
"weight",
"(",
"items",
",",
"**",
"kwargs",
")",
")",
"sizes",
"=",
"sorted",
"(",
"sizes",
",",
"key",
"=",
"operator",
".",
"ite... | Best-Fit Decreasing
Complexity O(n^2) | [
"Best",
"-",
"Fit",
"Decreasing"
] | b5fd64e3a3192f5664fa5c03e8517cacb4e0590f | https://github.com/daskos/mentor/blob/b5fd64e3a3192f5664fa5c03e8517cacb4e0590f/mentor/binpack.py#L116-L124 | train |
openvax/isovar | isovar/variant_sequence_in_reading_frame.py | trim_sequences | def trim_sequences(variant_sequence, reference_context):
"""
A VariantSequence and ReferenceContext may contain a different number of
nucleotides before the variant locus. Furthermore, the VariantSequence is
always expressed in terms of the positive strand against which it aligned,
but reference tra... | python | def trim_sequences(variant_sequence, reference_context):
"""
A VariantSequence and ReferenceContext may contain a different number of
nucleotides before the variant locus. Furthermore, the VariantSequence is
always expressed in terms of the positive strand against which it aligned,
but reference tra... | [
"def",
"trim_sequences",
"(",
"variant_sequence",
",",
"reference_context",
")",
":",
"cdna_prefix",
"=",
"variant_sequence",
".",
"prefix",
"cdna_alt",
"=",
"variant_sequence",
".",
"alt",
"cdna_suffix",
"=",
"variant_sequence",
".",
"suffix",
"if",
"reference_contex... | A VariantSequence and ReferenceContext may contain a different number of
nucleotides before the variant locus. Furthermore, the VariantSequence is
always expressed in terms of the positive strand against which it aligned,
but reference transcripts may have sequences from the negative strand of the
genom... | [
"A",
"VariantSequence",
"and",
"ReferenceContext",
"may",
"contain",
"a",
"different",
"number",
"of",
"nucleotides",
"before",
"the",
"variant",
"locus",
".",
"Furthermore",
"the",
"VariantSequence",
"is",
"always",
"expressed",
"in",
"terms",
"of",
"the",
"posit... | b39b684920e3f6b344851d6598a1a1c67bce913b | https://github.com/openvax/isovar/blob/b39b684920e3f6b344851d6598a1a1c67bce913b/isovar/variant_sequence_in_reading_frame.py#L140-L213 | train |
openvax/isovar | isovar/variant_sequence_in_reading_frame.py | count_mismatches_before_variant | def count_mismatches_before_variant(reference_prefix, cdna_prefix):
"""
Computes the number of mismatching nucleotides between two cDNA sequences before a variant
locus.
Parameters
----------
reference_prefix : str
cDNA sequence of a reference transcript before a variant locus
cdna... | python | def count_mismatches_before_variant(reference_prefix, cdna_prefix):
"""
Computes the number of mismatching nucleotides between two cDNA sequences before a variant
locus.
Parameters
----------
reference_prefix : str
cDNA sequence of a reference transcript before a variant locus
cdna... | [
"def",
"count_mismatches_before_variant",
"(",
"reference_prefix",
",",
"cdna_prefix",
")",
":",
"if",
"len",
"(",
"reference_prefix",
")",
"!=",
"len",
"(",
"cdna_prefix",
")",
":",
"raise",
"ValueError",
"(",
"\"Expected reference prefix '%s' to be same length as %s\"",... | Computes the number of mismatching nucleotides between two cDNA sequences before a variant
locus.
Parameters
----------
reference_prefix : str
cDNA sequence of a reference transcript before a variant locus
cdna_prefix : str
cDNA sequence detected from RNAseq before a variant locus | [
"Computes",
"the",
"number",
"of",
"mismatching",
"nucleotides",
"between",
"two",
"cDNA",
"sequences",
"before",
"a",
"variant",
"locus",
"."
] | b39b684920e3f6b344851d6598a1a1c67bce913b | https://github.com/openvax/isovar/blob/b39b684920e3f6b344851d6598a1a1c67bce913b/isovar/variant_sequence_in_reading_frame.py#L216-L233 | train |
openvax/isovar | isovar/variant_sequence_in_reading_frame.py | count_mismatches_after_variant | def count_mismatches_after_variant(reference_suffix, cdna_suffix):
"""
Computes the number of mismatching nucleotides between two cDNA sequences after a variant locus.
Parameters
----------
reference_suffix : str
cDNA sequence of a reference transcript after a variant locus
cdna_suffix... | python | def count_mismatches_after_variant(reference_suffix, cdna_suffix):
"""
Computes the number of mismatching nucleotides between two cDNA sequences after a variant locus.
Parameters
----------
reference_suffix : str
cDNA sequence of a reference transcript after a variant locus
cdna_suffix... | [
"def",
"count_mismatches_after_variant",
"(",
"reference_suffix",
",",
"cdna_suffix",
")",
":",
"len_diff",
"=",
"len",
"(",
"cdna_suffix",
")",
"-",
"len",
"(",
"reference_suffix",
")",
"return",
"sum",
"(",
"xi",
"!=",
"yi",
"for",
"(",
"xi",
",",
"yi",
... | Computes the number of mismatching nucleotides between two cDNA sequences after a variant locus.
Parameters
----------
reference_suffix : str
cDNA sequence of a reference transcript after a variant locus
cdna_suffix : str
cDNA sequence detected from RNAseq after a variant locus | [
"Computes",
"the",
"number",
"of",
"mismatching",
"nucleotides",
"between",
"two",
"cDNA",
"sequences",
"after",
"a",
"variant",
"locus",
"."
] | b39b684920e3f6b344851d6598a1a1c67bce913b | https://github.com/openvax/isovar/blob/b39b684920e3f6b344851d6598a1a1c67bce913b/isovar/variant_sequence_in_reading_frame.py#L236-L253 | train |
openvax/isovar | isovar/variant_sequence_in_reading_frame.py | compute_offset_to_first_complete_codon | def compute_offset_to_first_complete_codon(
offset_to_first_complete_reference_codon,
n_trimmed_from_reference_sequence):
"""
Once we've aligned the variant sequence to the ReferenceContext, we need
to transfer reading frame from the reference transcripts to the variant
sequences.
P... | python | def compute_offset_to_first_complete_codon(
offset_to_first_complete_reference_codon,
n_trimmed_from_reference_sequence):
"""
Once we've aligned the variant sequence to the ReferenceContext, we need
to transfer reading frame from the reference transcripts to the variant
sequences.
P... | [
"def",
"compute_offset_to_first_complete_codon",
"(",
"offset_to_first_complete_reference_codon",
",",
"n_trimmed_from_reference_sequence",
")",
":",
"if",
"n_trimmed_from_reference_sequence",
"<=",
"offset_to_first_complete_reference_codon",
":",
"return",
"(",
"offset_to_first_comple... | Once we've aligned the variant sequence to the ReferenceContext, we need
to transfer reading frame from the reference transcripts to the variant
sequences.
Parameters
----------
offset_to_first_complete_reference_codon : int
n_trimmed_from_reference_sequence : int
Returns an offset into t... | [
"Once",
"we",
"ve",
"aligned",
"the",
"variant",
"sequence",
"to",
"the",
"ReferenceContext",
"we",
"need",
"to",
"transfer",
"reading",
"frame",
"from",
"the",
"reference",
"transcripts",
"to",
"the",
"variant",
"sequences",
"."
] | b39b684920e3f6b344851d6598a1a1c67bce913b | https://github.com/openvax/isovar/blob/b39b684920e3f6b344851d6598a1a1c67bce913b/isovar/variant_sequence_in_reading_frame.py#L256-L282 | train |
openvax/isovar | isovar/variant_sequence_in_reading_frame.py | match_variant_sequence_to_reference_context | def match_variant_sequence_to_reference_context(
variant_sequence,
reference_context,
min_transcript_prefix_length,
max_transcript_mismatches,
include_mismatches_after_variant=False,
max_trimming_attempts=2):
"""
Iteratively trim low-coverage subsequences of a var... | python | def match_variant_sequence_to_reference_context(
variant_sequence,
reference_context,
min_transcript_prefix_length,
max_transcript_mismatches,
include_mismatches_after_variant=False,
max_trimming_attempts=2):
"""
Iteratively trim low-coverage subsequences of a var... | [
"def",
"match_variant_sequence_to_reference_context",
"(",
"variant_sequence",
",",
"reference_context",
",",
"min_transcript_prefix_length",
",",
"max_transcript_mismatches",
",",
"include_mismatches_after_variant",
"=",
"False",
",",
"max_trimming_attempts",
"=",
"2",
")",
":... | Iteratively trim low-coverage subsequences of a variant sequence
until it either matches the given reference context or there
are too few nucleotides left in the variant sequence.
Parameters
----------
variant_sequence : VariantSequence
Assembled sequence from RNA reads, will need to be to ... | [
"Iteratively",
"trim",
"low",
"-",
"coverage",
"subsequences",
"of",
"a",
"variant",
"sequence",
"until",
"it",
"either",
"matches",
"the",
"given",
"reference",
"context",
"or",
"there",
"are",
"too",
"few",
"nucleotides",
"left",
"in",
"the",
"variant",
"seq... | b39b684920e3f6b344851d6598a1a1c67bce913b | https://github.com/openvax/isovar/blob/b39b684920e3f6b344851d6598a1a1c67bce913b/isovar/variant_sequence_in_reading_frame.py#L285-L392 | train |
openvax/isovar | isovar/genetic_code.py | GeneticCode._check_codons | def _check_codons(self):
"""
If codon table is missing stop codons, then add them.
"""
for stop_codon in self.stop_codons:
if stop_codon in self.codon_table:
if self.codon_table[stop_codon] != "*":
raise ValueError(
... | python | def _check_codons(self):
"""
If codon table is missing stop codons, then add them.
"""
for stop_codon in self.stop_codons:
if stop_codon in self.codon_table:
if self.codon_table[stop_codon] != "*":
raise ValueError(
... | [
"def",
"_check_codons",
"(",
"self",
")",
":",
"for",
"stop_codon",
"in",
"self",
".",
"stop_codons",
":",
"if",
"stop_codon",
"in",
"self",
".",
"codon_table",
":",
"if",
"self",
".",
"codon_table",
"[",
"stop_codon",
"]",
"!=",
"\"*\"",
":",
"raise",
"... | If codon table is missing stop codons, then add them. | [
"If",
"codon",
"table",
"is",
"missing",
"stop",
"codons",
"then",
"add",
"them",
"."
] | b39b684920e3f6b344851d6598a1a1c67bce913b | https://github.com/openvax/isovar/blob/b39b684920e3f6b344851d6598a1a1c67bce913b/isovar/genetic_code.py#L26-L54 | train |
openvax/isovar | isovar/genetic_code.py | GeneticCode.copy | def copy(
self,
name,
start_codons=None,
stop_codons=None,
codon_table=None,
codon_table_changes=None):
"""
Make copy of this GeneticCode object with optional replacement
values for all fields.
"""
new_start_... | python | def copy(
self,
name,
start_codons=None,
stop_codons=None,
codon_table=None,
codon_table_changes=None):
"""
Make copy of this GeneticCode object with optional replacement
values for all fields.
"""
new_start_... | [
"def",
"copy",
"(",
"self",
",",
"name",
",",
"start_codons",
"=",
"None",
",",
"stop_codons",
"=",
"None",
",",
"codon_table",
"=",
"None",
",",
"codon_table_changes",
"=",
"None",
")",
":",
"new_start_codons",
"=",
"(",
"self",
".",
"start_codons",
".",
... | Make copy of this GeneticCode object with optional replacement
values for all fields. | [
"Make",
"copy",
"of",
"this",
"GeneticCode",
"object",
"with",
"optional",
"replacement",
"values",
"for",
"all",
"fields",
"."
] | b39b684920e3f6b344851d6598a1a1c67bce913b | https://github.com/openvax/isovar/blob/b39b684920e3f6b344851d6598a1a1c67bce913b/isovar/genetic_code.py#L100-L133 | train |
centralniak/py-raildriver | raildriver/events.py | Listener.start | def start(self):
"""
Start listening to changes
"""
self.running = True
self.thread = threading.Thread(target=self._main_loop)
self.thread.start() | python | def start(self):
"""
Start listening to changes
"""
self.running = True
self.thread = threading.Thread(target=self._main_loop)
self.thread.start() | [
"def",
"start",
"(",
"self",
")",
":",
"self",
".",
"running",
"=",
"True",
"self",
".",
"thread",
"=",
"threading",
".",
"Thread",
"(",
"target",
"=",
"self",
".",
"_main_loop",
")",
"self",
".",
"thread",
".",
"start",
"(",
")"
] | Start listening to changes | [
"Start",
"listening",
"to",
"changes"
] | c7f5f551e0436451b9507fc63a62e49a229282b9 | https://github.com/centralniak/py-raildriver/blob/c7f5f551e0436451b9507fc63a62e49a229282b9/raildriver/events.py#L86-L92 | train |
centralniak/py-raildriver | raildriver/events.py | Listener.subscribe | def subscribe(self, field_names):
"""
Subscribe to given fields.
Special fields cannot be subscribed to and will be checked on every iteration. These include:
* loco name
* coordinates
* fuel level
* gradient
* current heading
* is in tunnel
... | python | def subscribe(self, field_names):
"""
Subscribe to given fields.
Special fields cannot be subscribed to and will be checked on every iteration. These include:
* loco name
* coordinates
* fuel level
* gradient
* current heading
* is in tunnel
... | [
"def",
"subscribe",
"(",
"self",
",",
"field_names",
")",
":",
"available_controls",
"=",
"dict",
"(",
"self",
".",
"raildriver",
".",
"get_controller_list",
"(",
")",
")",
".",
"values",
"(",
")",
"for",
"field",
"in",
"field_names",
":",
"if",
"field",
... | Subscribe to given fields.
Special fields cannot be subscribed to and will be checked on every iteration. These include:
* loco name
* coordinates
* fuel level
* gradient
* current heading
* is in tunnel
* time
You can of course still receive no... | [
"Subscribe",
"to",
"given",
"fields",
"."
] | c7f5f551e0436451b9507fc63a62e49a229282b9 | https://github.com/centralniak/py-raildriver/blob/c7f5f551e0436451b9507fc63a62e49a229282b9/raildriver/events.py#L101-L127 | train |
pyviz/imagen | imagen/patterngenerator.py | PatternGenerator.set_matrix_dimensions | def set_matrix_dimensions(self, bounds, xdensity, ydensity):
"""
Change the dimensions of the matrix into which the pattern
will be drawn. Users of this class should call this method
rather than changing the bounds, xdensity, and ydensity
parameters directly. Subclasses can ove... | python | def set_matrix_dimensions(self, bounds, xdensity, ydensity):
"""
Change the dimensions of the matrix into which the pattern
will be drawn. Users of this class should call this method
rather than changing the bounds, xdensity, and ydensity
parameters directly. Subclasses can ove... | [
"def",
"set_matrix_dimensions",
"(",
"self",
",",
"bounds",
",",
"xdensity",
",",
"ydensity",
")",
":",
"self",
".",
"bounds",
"=",
"bounds",
"self",
".",
"xdensity",
"=",
"xdensity",
"self",
".",
"ydensity",
"=",
"ydensity",
"scs",
"=",
"SheetCoordinateSyst... | Change the dimensions of the matrix into which the pattern
will be drawn. Users of this class should call this method
rather than changing the bounds, xdensity, and ydensity
parameters directly. Subclasses can override this method to
update any internal data structures that may depend ... | [
"Change",
"the",
"dimensions",
"of",
"the",
"matrix",
"into",
"which",
"the",
"pattern",
"will",
"be",
"drawn",
".",
"Users",
"of",
"this",
"class",
"should",
"call",
"this",
"method",
"rather",
"than",
"changing",
"the",
"bounds",
"xdensity",
"and",
"ydensi... | 53c5685c880f54b42795964d8db50b02e8590e88 | https://github.com/pyviz/imagen/blob/53c5685c880f54b42795964d8db50b02e8590e88/imagen/patterngenerator.py#L273-L288 | train |
pyviz/imagen | imagen/patterngenerator.py | PatternGenerator.state_push | def state_push(self):
"Save the state of the output functions, to be restored with state_pop."
for of in self.output_fns:
if hasattr(of,'state_push'):
of.state_push()
super(PatternGenerator, self).state_push() | python | def state_push(self):
"Save the state of the output functions, to be restored with state_pop."
for of in self.output_fns:
if hasattr(of,'state_push'):
of.state_push()
super(PatternGenerator, self).state_push() | [
"def",
"state_push",
"(",
"self",
")",
":",
"\"Save the state of the output functions, to be restored with state_pop.\"",
"for",
"of",
"in",
"self",
".",
"output_fns",
":",
"if",
"hasattr",
"(",
"of",
",",
"'state_push'",
")",
":",
"of",
".",
"state_push",
"(",
")... | Save the state of the output functions, to be restored with state_pop. | [
"Save",
"the",
"state",
"of",
"the",
"output",
"functions",
"to",
"be",
"restored",
"with",
"state_pop",
"."
] | 53c5685c880f54b42795964d8db50b02e8590e88 | https://github.com/pyviz/imagen/blob/53c5685c880f54b42795964d8db50b02e8590e88/imagen/patterngenerator.py#L290-L295 | train |
pyviz/imagen | imagen/patterngenerator.py | PatternGenerator.state_pop | def state_pop(self):
"Restore the state of the output functions saved by state_push."
for of in self.output_fns:
if hasattr(of,'state_pop'):
of.state_pop()
super(PatternGenerator, self).state_pop() | python | def state_pop(self):
"Restore the state of the output functions saved by state_push."
for of in self.output_fns:
if hasattr(of,'state_pop'):
of.state_pop()
super(PatternGenerator, self).state_pop() | [
"def",
"state_pop",
"(",
"self",
")",
":",
"\"Restore the state of the output functions saved by state_push.\"",
"for",
"of",
"in",
"self",
".",
"output_fns",
":",
"if",
"hasattr",
"(",
"of",
",",
"'state_pop'",
")",
":",
"of",
".",
"state_pop",
"(",
")",
"super... | Restore the state of the output functions saved by state_push. | [
"Restore",
"the",
"state",
"of",
"the",
"output",
"functions",
"saved",
"by",
"state_push",
"."
] | 53c5685c880f54b42795964d8db50b02e8590e88 | https://github.com/pyviz/imagen/blob/53c5685c880f54b42795964d8db50b02e8590e88/imagen/patterngenerator.py#L298-L303 | train |
pyviz/imagen | imagen/patterngenerator.py | PatternGenerator.pil | def pil(self, **params_to_override):
"""Returns a PIL image for this pattern, overriding parameters if provided."""
from PIL.Image import fromarray
nchans = self.num_channels()
if nchans in [0, 1]:
mode, arr = None, self(**params_to_override)
arr = (255.0 / arr.m... | python | def pil(self, **params_to_override):
"""Returns a PIL image for this pattern, overriding parameters if provided."""
from PIL.Image import fromarray
nchans = self.num_channels()
if nchans in [0, 1]:
mode, arr = None, self(**params_to_override)
arr = (255.0 / arr.m... | [
"def",
"pil",
"(",
"self",
",",
"**",
"params_to_override",
")",
":",
"from",
"PIL",
".",
"Image",
"import",
"fromarray",
"nchans",
"=",
"self",
".",
"num_channels",
"(",
")",
"if",
"nchans",
"in",
"[",
"0",
",",
"1",
"]",
":",
"mode",
",",
"arr",
... | Returns a PIL image for this pattern, overriding parameters if provided. | [
"Returns",
"a",
"PIL",
"image",
"for",
"this",
"pattern",
"overriding",
"parameters",
"if",
"provided",
"."
] | 53c5685c880f54b42795964d8db50b02e8590e88 | https://github.com/pyviz/imagen/blob/53c5685c880f54b42795964d8db50b02e8590e88/imagen/patterngenerator.py#L394-L411 | train |
pyviz/imagen | imagen/patterngenerator.py | Composite.state_push | def state_push(self):
"""
Push the state of all generators
"""
super(Composite,self).state_push()
for gen in self.generators:
gen.state_push() | python | def state_push(self):
"""
Push the state of all generators
"""
super(Composite,self).state_push()
for gen in self.generators:
gen.state_push() | [
"def",
"state_push",
"(",
"self",
")",
":",
"super",
"(",
"Composite",
",",
"self",
")",
".",
"state_push",
"(",
")",
"for",
"gen",
"in",
"self",
".",
"generators",
":",
"gen",
".",
"state_push",
"(",
")"
] | Push the state of all generators | [
"Push",
"the",
"state",
"of",
"all",
"generators"
] | 53c5685c880f54b42795964d8db50b02e8590e88 | https://github.com/pyviz/imagen/blob/53c5685c880f54b42795964d8db50b02e8590e88/imagen/patterngenerator.py#L516-L522 | train |
pyviz/imagen | imagen/patterngenerator.py | Composite.state_pop | def state_pop(self):
"""
Pop the state of all generators
"""
super(Composite,self).state_pop()
for gen in self.generators:
gen.state_pop() | python | def state_pop(self):
"""
Pop the state of all generators
"""
super(Composite,self).state_pop()
for gen in self.generators:
gen.state_pop() | [
"def",
"state_pop",
"(",
"self",
")",
":",
"super",
"(",
"Composite",
",",
"self",
")",
".",
"state_pop",
"(",
")",
"for",
"gen",
"in",
"self",
".",
"generators",
":",
"gen",
".",
"state_pop",
"(",
")"
] | Pop the state of all generators | [
"Pop",
"the",
"state",
"of",
"all",
"generators"
] | 53c5685c880f54b42795964d8db50b02e8590e88 | https://github.com/pyviz/imagen/blob/53c5685c880f54b42795964d8db50b02e8590e88/imagen/patterngenerator.py#L524-L530 | train |
pyviz/imagen | imagen/patterngenerator.py | Composite.function | def function(self,p):
"""Constructs combined pattern out of the individual ones."""
generators = self._advance_pattern_generators(p)
assert hasattr(p.operator,'reduce'),repr(p.operator)+" does not support 'reduce'."
# CEBALERT: mask gets applied by all PGs including the Composite itsel... | python | def function(self,p):
"""Constructs combined pattern out of the individual ones."""
generators = self._advance_pattern_generators(p)
assert hasattr(p.operator,'reduce'),repr(p.operator)+" does not support 'reduce'."
# CEBALERT: mask gets applied by all PGs including the Composite itsel... | [
"def",
"function",
"(",
"self",
",",
"p",
")",
":",
"generators",
"=",
"self",
".",
"_advance_pattern_generators",
"(",
"p",
")",
"assert",
"hasattr",
"(",
"p",
".",
"operator",
",",
"'reduce'",
")",
",",
"repr",
"(",
"p",
".",
"operator",
")",
"+",
... | Constructs combined pattern out of the individual ones. | [
"Constructs",
"combined",
"pattern",
"out",
"of",
"the",
"individual",
"ones",
"."
] | 53c5685c880f54b42795964d8db50b02e8590e88 | https://github.com/pyviz/imagen/blob/53c5685c880f54b42795964d8db50b02e8590e88/imagen/patterngenerator.py#L535-L552 | train |
portfoliome/postpy | postpy/ddl.py | compile_column | def compile_column(name: str, data_type: str, nullable: bool) -> str:
"""Create column definition statement."""
null_str = 'NULL' if nullable else 'NOT NULL'
return '{name} {data_type} {null},'.format(name=name,
data_type=data_type,
... | python | def compile_column(name: str, data_type: str, nullable: bool) -> str:
"""Create column definition statement."""
null_str = 'NULL' if nullable else 'NOT NULL'
return '{name} {data_type} {null},'.format(name=name,
data_type=data_type,
... | [
"def",
"compile_column",
"(",
"name",
":",
"str",
",",
"data_type",
":",
"str",
",",
"nullable",
":",
"bool",
")",
"->",
"str",
":",
"null_str",
"=",
"'NULL'",
"if",
"nullable",
"else",
"'NOT NULL'",
"return",
"'{name} {data_type} {null},'",
".",
"format",
"... | Create column definition statement. | [
"Create",
"column",
"definition",
"statement",
"."
] | fe26199131b15295fc5f669a0ad2a7f47bf490ee | https://github.com/portfoliome/postpy/blob/fe26199131b15295fc5f669a0ad2a7f47bf490ee/postpy/ddl.py#L39-L46 | train |
portfoliome/postpy | postpy/ddl.py | MaterializedView.create | def create(self, no_data=False):
"""Declare materalized view."""
if self.query:
ddl_statement = self.compile_create_as()
else:
ddl_statement = self.compile_create()
if no_data:
ddl_statement += '\nWITH NO DATA'
return ddl_statement, self.que... | python | def create(self, no_data=False):
"""Declare materalized view."""
if self.query:
ddl_statement = self.compile_create_as()
else:
ddl_statement = self.compile_create()
if no_data:
ddl_statement += '\nWITH NO DATA'
return ddl_statement, self.que... | [
"def",
"create",
"(",
"self",
",",
"no_data",
"=",
"False",
")",
":",
"if",
"self",
".",
"query",
":",
"ddl_statement",
"=",
"self",
".",
"compile_create_as",
"(",
")",
"else",
":",
"ddl_statement",
"=",
"self",
".",
"compile_create",
"(",
")",
"if",
"... | Declare materalized view. | [
"Declare",
"materalized",
"view",
"."
] | fe26199131b15295fc5f669a0ad2a7f47bf490ee | https://github.com/portfoliome/postpy/blob/fe26199131b15295fc5f669a0ad2a7f47bf490ee/postpy/ddl.py#L97-L108 | train |
openvax/isovar | isovar/effect_prediction.py | predicted_effects_for_variant | def predicted_effects_for_variant(
variant,
transcript_id_whitelist=None,
only_coding_changes=True):
"""
For a given variant, return its set of predicted effects. Optionally
filter to transcripts where this variant results in a non-synonymous
change to the protein sequence.
... | python | def predicted_effects_for_variant(
variant,
transcript_id_whitelist=None,
only_coding_changes=True):
"""
For a given variant, return its set of predicted effects. Optionally
filter to transcripts where this variant results in a non-synonymous
change to the protein sequence.
... | [
"def",
"predicted_effects_for_variant",
"(",
"variant",
",",
"transcript_id_whitelist",
"=",
"None",
",",
"only_coding_changes",
"=",
"True",
")",
":",
"effects",
"=",
"[",
"]",
"for",
"transcript",
"in",
"variant",
".",
"transcripts",
":",
"if",
"only_coding_chan... | For a given variant, return its set of predicted effects. Optionally
filter to transcripts where this variant results in a non-synonymous
change to the protein sequence.
Parameters
----------
variant : varcode.Variant
transcript_id_whitelist : set
Filter effect predictions to only incl... | [
"For",
"a",
"given",
"variant",
"return",
"its",
"set",
"of",
"predicted",
"effects",
".",
"Optionally",
"filter",
"to",
"transcripts",
"where",
"this",
"variant",
"results",
"in",
"a",
"non",
"-",
"synonymous",
"change",
"to",
"the",
"protein",
"sequence",
... | b39b684920e3f6b344851d6598a1a1c67bce913b | https://github.com/openvax/isovar/blob/b39b684920e3f6b344851d6598a1a1c67bce913b/isovar/effect_prediction.py#L24-L88 | train |
openvax/isovar | isovar/effect_prediction.py | reference_transcripts_for_variant | def reference_transcripts_for_variant(
variant,
transcript_id_whitelist=None,
only_coding_changes=True):
"""
For a given variant, find all the transcripts which overlap the
variant and for which it has a predictable effect on the amino acid
sequence of the protein.
"""
pr... | python | def reference_transcripts_for_variant(
variant,
transcript_id_whitelist=None,
only_coding_changes=True):
"""
For a given variant, find all the transcripts which overlap the
variant and for which it has a predictable effect on the amino acid
sequence of the protein.
"""
pr... | [
"def",
"reference_transcripts_for_variant",
"(",
"variant",
",",
"transcript_id_whitelist",
"=",
"None",
",",
"only_coding_changes",
"=",
"True",
")",
":",
"predicted_effects",
"=",
"predicted_effects_for_variant",
"(",
"variant",
"=",
"variant",
",",
"transcript_id_white... | For a given variant, find all the transcripts which overlap the
variant and for which it has a predictable effect on the amino acid
sequence of the protein. | [
"For",
"a",
"given",
"variant",
"find",
"all",
"the",
"transcripts",
"which",
"overlap",
"the",
"variant",
"and",
"for",
"which",
"it",
"has",
"a",
"predictable",
"effect",
"on",
"the",
"amino",
"acid",
"sequence",
"of",
"the",
"protein",
"."
] | b39b684920e3f6b344851d6598a1a1c67bce913b | https://github.com/openvax/isovar/blob/b39b684920e3f6b344851d6598a1a1c67bce913b/isovar/effect_prediction.py#L91-L104 | train |
openvax/isovar | isovar/locus_reads.py | pileup_reads_at_position | def pileup_reads_at_position(samfile, chromosome, base0_position):
"""
Returns a pileup column at the specified position. Unclear if a function
like this is hiding somewhere in pysam API.
"""
# TODO: I want to pass truncate=True, stepper="all"
# but for some reason I get this error:
# ... | python | def pileup_reads_at_position(samfile, chromosome, base0_position):
"""
Returns a pileup column at the specified position. Unclear if a function
like this is hiding somewhere in pysam API.
"""
# TODO: I want to pass truncate=True, stepper="all"
# but for some reason I get this error:
# ... | [
"def",
"pileup_reads_at_position",
"(",
"samfile",
",",
"chromosome",
",",
"base0_position",
")",
":",
"for",
"column",
"in",
"samfile",
".",
"pileup",
"(",
"chromosome",
",",
"start",
"=",
"base0_position",
",",
"end",
"=",
"base0_position",
"+",
"1",
")",
... | Returns a pileup column at the specified position. Unclear if a function
like this is hiding somewhere in pysam API. | [
"Returns",
"a",
"pileup",
"column",
"at",
"the",
"specified",
"position",
".",
"Unclear",
"if",
"a",
"function",
"like",
"this",
"is",
"hiding",
"somewhere",
"in",
"pysam",
"API",
"."
] | b39b684920e3f6b344851d6598a1a1c67bce913b | https://github.com/openvax/isovar/blob/b39b684920e3f6b344851d6598a1a1c67bce913b/isovar/locus_reads.py#L215-L240 | train |
openvax/isovar | isovar/locus_reads.py | locus_read_generator | def locus_read_generator(
samfile,
chromosome,
base1_position_before_variant,
base1_position_after_variant,
use_duplicate_reads=USE_DUPLICATE_READS,
use_secondary_alignments=USE_SECONDARY_ALIGNMENTS,
min_mapping_quality=MIN_READ_MAPPING_QUALITY):
"""
Gener... | python | def locus_read_generator(
samfile,
chromosome,
base1_position_before_variant,
base1_position_after_variant,
use_duplicate_reads=USE_DUPLICATE_READS,
use_secondary_alignments=USE_SECONDARY_ALIGNMENTS,
min_mapping_quality=MIN_READ_MAPPING_QUALITY):
"""
Gener... | [
"def",
"locus_read_generator",
"(",
"samfile",
",",
"chromosome",
",",
"base1_position_before_variant",
",",
"base1_position_after_variant",
",",
"use_duplicate_reads",
"=",
"USE_DUPLICATE_READS",
",",
"use_secondary_alignments",
"=",
"USE_SECONDARY_ALIGNMENTS",
",",
"min_mappi... | Generator that yields a sequence of ReadAtLocus records for reads which
contain the positions before and after a variant. The actual work to figure
out if what's between those positions matches a variant happens later in
the `variant_reads` module.
Parameters
----------
samfile : pysam.Alignmen... | [
"Generator",
"that",
"yields",
"a",
"sequence",
"of",
"ReadAtLocus",
"records",
"for",
"reads",
"which",
"contain",
"the",
"positions",
"before",
"and",
"after",
"a",
"variant",
".",
"The",
"actual",
"work",
"to",
"figure",
"out",
"if",
"what",
"s",
"between... | b39b684920e3f6b344851d6598a1a1c67bce913b | https://github.com/openvax/isovar/blob/b39b684920e3f6b344851d6598a1a1c67bce913b/isovar/locus_reads.py#L243-L317 | train |
openvax/isovar | isovar/locus_reads.py | locus_reads_dataframe | def locus_reads_dataframe(*args, **kwargs):
"""
Traverse a BAM file to find all the reads overlapping a specified locus.
Parameters are the same as those for read_locus_generator.
"""
df_builder = DataFrameBuilder(
LocusRead,
variant_columns=False,
converters={
"... | python | def locus_reads_dataframe(*args, **kwargs):
"""
Traverse a BAM file to find all the reads overlapping a specified locus.
Parameters are the same as those for read_locus_generator.
"""
df_builder = DataFrameBuilder(
LocusRead,
variant_columns=False,
converters={
"... | [
"def",
"locus_reads_dataframe",
"(",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"df_builder",
"=",
"DataFrameBuilder",
"(",
"LocusRead",
",",
"variant_columns",
"=",
"False",
",",
"converters",
"=",
"{",
"\"reference_positions\"",
":",
"list_to_string",
",",
"\... | Traverse a BAM file to find all the reads overlapping a specified locus.
Parameters are the same as those for read_locus_generator. | [
"Traverse",
"a",
"BAM",
"file",
"to",
"find",
"all",
"the",
"reads",
"overlapping",
"a",
"specified",
"locus",
"."
] | b39b684920e3f6b344851d6598a1a1c67bce913b | https://github.com/openvax/isovar/blob/b39b684920e3f6b344851d6598a1a1c67bce913b/isovar/locus_reads.py#L320-L335 | train |
portfoliome/postpy | postpy/dml_copy.py | copy_from_csv_sql | def copy_from_csv_sql(qualified_name: str, delimiter=',', encoding='utf8',
null_str='', header=True, escape_str='\\', quote_char='"',
force_not_null=None, force_null=None):
"""Generate copy from csv statement."""
options = []
options.append("DELIMITER '%s'" % del... | python | def copy_from_csv_sql(qualified_name: str, delimiter=',', encoding='utf8',
null_str='', header=True, escape_str='\\', quote_char='"',
force_not_null=None, force_null=None):
"""Generate copy from csv statement."""
options = []
options.append("DELIMITER '%s'" % del... | [
"def",
"copy_from_csv_sql",
"(",
"qualified_name",
":",
"str",
",",
"delimiter",
"=",
"','",
",",
"encoding",
"=",
"'utf8'",
",",
"null_str",
"=",
"''",
",",
"header",
"=",
"True",
",",
"escape_str",
"=",
"'\\\\'",
",",
"quote_char",
"=",
"'\"'",
",",
"f... | Generate copy from csv statement. | [
"Generate",
"copy",
"from",
"csv",
"statement",
"."
] | fe26199131b15295fc5f669a0ad2a7f47bf490ee | https://github.com/portfoliome/postpy/blob/fe26199131b15295fc5f669a0ad2a7f47bf490ee/postpy/dml_copy.py#L83-L109 | train |
openvax/isovar | isovar/protein_sequences.py | sort_protein_sequences | def sort_protein_sequences(protein_sequences):
"""
Sort protein sequences in decreasing order of priority
"""
return list(
sorted(
protein_sequences,
key=ProteinSequence.ascending_sort_key,
reverse=True)) | python | def sort_protein_sequences(protein_sequences):
"""
Sort protein sequences in decreasing order of priority
"""
return list(
sorted(
protein_sequences,
key=ProteinSequence.ascending_sort_key,
reverse=True)) | [
"def",
"sort_protein_sequences",
"(",
"protein_sequences",
")",
":",
"return",
"list",
"(",
"sorted",
"(",
"protein_sequences",
",",
"key",
"=",
"ProteinSequence",
".",
"ascending_sort_key",
",",
"reverse",
"=",
"True",
")",
")"
] | Sort protein sequences in decreasing order of priority | [
"Sort",
"protein",
"sequences",
"in",
"decreasing",
"order",
"of",
"priority"
] | b39b684920e3f6b344851d6598a1a1c67bce913b | https://github.com/openvax/isovar/blob/b39b684920e3f6b344851d6598a1a1c67bce913b/isovar/protein_sequences.py#L182-L190 | train |
openvax/isovar | isovar/protein_sequences.py | reads_generator_to_protein_sequences_generator | def reads_generator_to_protein_sequences_generator(
variant_and_overlapping_reads_generator,
transcript_id_whitelist=None,
protein_sequence_length=PROTEIN_SEQUENCE_LENGTH,
min_alt_rna_reads=MIN_ALT_RNA_READS,
min_variant_sequence_coverage=MIN_VARIANT_SEQUENCE_COVERAGE,
mi... | python | def reads_generator_to_protein_sequences_generator(
variant_and_overlapping_reads_generator,
transcript_id_whitelist=None,
protein_sequence_length=PROTEIN_SEQUENCE_LENGTH,
min_alt_rna_reads=MIN_ALT_RNA_READS,
min_variant_sequence_coverage=MIN_VARIANT_SEQUENCE_COVERAGE,
mi... | [
"def",
"reads_generator_to_protein_sequences_generator",
"(",
"variant_and_overlapping_reads_generator",
",",
"transcript_id_whitelist",
"=",
"None",
",",
"protein_sequence_length",
"=",
"PROTEIN_SEQUENCE_LENGTH",
",",
"min_alt_rna_reads",
"=",
"MIN_ALT_RNA_READS",
",",
"min_varian... | Translates each coding variant in a collection to one or more
Translation objects, which are then aggregated into equivalent
ProteinSequence objects.
Parameters
----------
variant_and_overlapping_reads_generator : generator
Yields sequence of varcode.Variant objects paired with sequences
... | [
"Translates",
"each",
"coding",
"variant",
"in",
"a",
"collection",
"to",
"one",
"or",
"more",
"Translation",
"objects",
"which",
"are",
"then",
"aggregated",
"into",
"equivalent",
"ProteinSequence",
"objects",
"."
] | b39b684920e3f6b344851d6598a1a1c67bce913b | https://github.com/openvax/isovar/blob/b39b684920e3f6b344851d6598a1a1c67bce913b/isovar/protein_sequences.py#L192-L311 | train |
openvax/isovar | isovar/protein_sequences.py | ProteinSequence.from_translation_key | def from_translation_key(
cls,
translation_key,
translations,
overlapping_reads,
ref_reads,
alt_reads,
alt_reads_supporting_protein_sequence,
transcripts_overlapping_variant,
transcripts_supporting_protein_sequen... | python | def from_translation_key(
cls,
translation_key,
translations,
overlapping_reads,
ref_reads,
alt_reads,
alt_reads_supporting_protein_sequence,
transcripts_overlapping_variant,
transcripts_supporting_protein_sequen... | [
"def",
"from_translation_key",
"(",
"cls",
",",
"translation_key",
",",
"translations",
",",
"overlapping_reads",
",",
"ref_reads",
",",
"alt_reads",
",",
"alt_reads_supporting_protein_sequence",
",",
"transcripts_overlapping_variant",
",",
"transcripts_supporting_protein_seque... | Create a ProteinSequence object from a TranslationKey, along with
all the extra fields a ProteinSequence requires. | [
"Create",
"a",
"ProteinSequence",
"object",
"from",
"a",
"TranslationKey",
"along",
"with",
"all",
"the",
"extra",
"fields",
"a",
"ProteinSequence",
"requires",
"."
] | b39b684920e3f6b344851d6598a1a1c67bce913b | https://github.com/openvax/isovar/blob/b39b684920e3f6b344851d6598a1a1c67bce913b/isovar/protein_sequences.py#L131-L161 | train |
portfoliome/postpy | postpy/base.py | make_delete_table | def make_delete_table(table: Table, delete_prefix='delete_from__') -> Table:
"""Table referencing a delete from using primary key join."""
name = delete_prefix + table.name
primary_key = table.primary_key
key_names = set(primary_key.column_names)
columns = [column for column in table.columns if col... | python | def make_delete_table(table: Table, delete_prefix='delete_from__') -> Table:
"""Table referencing a delete from using primary key join."""
name = delete_prefix + table.name
primary_key = table.primary_key
key_names = set(primary_key.column_names)
columns = [column for column in table.columns if col... | [
"def",
"make_delete_table",
"(",
"table",
":",
"Table",
",",
"delete_prefix",
"=",
"'delete_from__'",
")",
"->",
"Table",
":",
"name",
"=",
"delete_prefix",
"+",
"table",
".",
"name",
"primary_key",
"=",
"table",
".",
"primary_key",
"key_names",
"=",
"set",
... | Table referencing a delete from using primary key join. | [
"Table",
"referencing",
"a",
"delete",
"from",
"using",
"primary",
"key",
"join",
"."
] | fe26199131b15295fc5f669a0ad2a7f47bf490ee | https://github.com/portfoliome/postpy/blob/fe26199131b15295fc5f669a0ad2a7f47bf490ee/postpy/base.py#L136-L145 | train |
openvax/isovar | isovar/variant_helpers.py | trim_variant_fields | def trim_variant_fields(location, ref, alt):
"""
Trims common prefixes from the ref and alt sequences
Parameters
----------
location : int
Position (starting from 1) on some chromosome
ref : str
Reference nucleotides
alt : str
Alternate (mutant) nucleotide
Ret... | python | def trim_variant_fields(location, ref, alt):
"""
Trims common prefixes from the ref and alt sequences
Parameters
----------
location : int
Position (starting from 1) on some chromosome
ref : str
Reference nucleotides
alt : str
Alternate (mutant) nucleotide
Ret... | [
"def",
"trim_variant_fields",
"(",
"location",
",",
"ref",
",",
"alt",
")",
":",
"if",
"len",
"(",
"alt",
")",
">",
"0",
"and",
"ref",
".",
"startswith",
"(",
"alt",
")",
":",
"ref",
"=",
"ref",
"[",
"len",
"(",
"alt",
")",
":",
"]",
"location",
... | Trims common prefixes from the ref and alt sequences
Parameters
----------
location : int
Position (starting from 1) on some chromosome
ref : str
Reference nucleotides
alt : str
Alternate (mutant) nucleotide
Returns adjusted triplet (location, ref, alt) | [
"Trims",
"common",
"prefixes",
"from",
"the",
"ref",
"and",
"alt",
"sequences"
] | b39b684920e3f6b344851d6598a1a1c67bce913b | https://github.com/openvax/isovar/blob/b39b684920e3f6b344851d6598a1a1c67bce913b/isovar/variant_helpers.py#L27-L64 | train |
openvax/isovar | isovar/variant_helpers.py | base0_interval_for_variant | def base0_interval_for_variant(variant):
"""
Inteval of interbase offsets of the affected reference positions for a
particular variant.
Parameters
----------
variant : varcode.Variant
Returns triplet of (base1_location, ref, alt)
"""
base1_location, ref, alt = trim_variant(variant)... | python | def base0_interval_for_variant(variant):
"""
Inteval of interbase offsets of the affected reference positions for a
particular variant.
Parameters
----------
variant : varcode.Variant
Returns triplet of (base1_location, ref, alt)
"""
base1_location, ref, alt = trim_variant(variant)... | [
"def",
"base0_interval_for_variant",
"(",
"variant",
")",
":",
"base1_location",
",",
"ref",
",",
"alt",
"=",
"trim_variant",
"(",
"variant",
")",
"return",
"base0_interval_for_variant_fields",
"(",
"base1_location",
"=",
"base1_location",
",",
"ref",
"=",
"ref",
... | Inteval of interbase offsets of the affected reference positions for a
particular variant.
Parameters
----------
variant : varcode.Variant
Returns triplet of (base1_location, ref, alt) | [
"Inteval",
"of",
"interbase",
"offsets",
"of",
"the",
"affected",
"reference",
"positions",
"for",
"a",
"particular",
"variant",
"."
] | b39b684920e3f6b344851d6598a1a1c67bce913b | https://github.com/openvax/isovar/blob/b39b684920e3f6b344851d6598a1a1c67bce913b/isovar/variant_helpers.py#L110-L125 | train |
openvax/isovar | isovar/variant_helpers.py | interbase_range_affected_by_variant_on_transcript | def interbase_range_affected_by_variant_on_transcript(variant, transcript):
"""
Convert from a variant's position in global genomic coordinates on the
forward strand to an interval of interbase offsets on a particular
transcript's mRNA.
Parameters
----------
variant : varcode.Variant
t... | python | def interbase_range_affected_by_variant_on_transcript(variant, transcript):
"""
Convert from a variant's position in global genomic coordinates on the
forward strand to an interval of interbase offsets on a particular
transcript's mRNA.
Parameters
----------
variant : varcode.Variant
t... | [
"def",
"interbase_range_affected_by_variant_on_transcript",
"(",
"variant",
",",
"transcript",
")",
":",
"if",
"variant",
".",
"is_insertion",
":",
"if",
"transcript",
".",
"strand",
"==",
"\"+\"",
":",
"start_offset",
"=",
"transcript",
".",
"spliced_offset",
"(",
... | Convert from a variant's position in global genomic coordinates on the
forward strand to an interval of interbase offsets on a particular
transcript's mRNA.
Parameters
----------
variant : varcode.Variant
transcript : pyensembl.Transcript
Assumes that the transcript overlaps the variant.
... | [
"Convert",
"from",
"a",
"variant",
"s",
"position",
"in",
"global",
"genomic",
"coordinates",
"on",
"the",
"forward",
"strand",
"to",
"an",
"interval",
"of",
"interbase",
"offsets",
"on",
"a",
"particular",
"transcript",
"s",
"mRNA",
"."
] | b39b684920e3f6b344851d6598a1a1c67bce913b | https://github.com/openvax/isovar/blob/b39b684920e3f6b344851d6598a1a1c67bce913b/isovar/variant_helpers.py#L127-L190 | train |
portfoliome/postpy | postpy/dml.py | insert | def insert(conn, qualified_name: str, column_names, records):
"""Insert a collection of namedtuple records."""
query = create_insert_statement(qualified_name, column_names)
with conn:
with conn.cursor(cursor_factory=NamedTupleCursor) as cursor:
for record in records:
cu... | python | def insert(conn, qualified_name: str, column_names, records):
"""Insert a collection of namedtuple records."""
query = create_insert_statement(qualified_name, column_names)
with conn:
with conn.cursor(cursor_factory=NamedTupleCursor) as cursor:
for record in records:
cu... | [
"def",
"insert",
"(",
"conn",
",",
"qualified_name",
":",
"str",
",",
"column_names",
",",
"records",
")",
":",
"query",
"=",
"create_insert_statement",
"(",
"qualified_name",
",",
"column_names",
")",
"with",
"conn",
":",
"with",
"conn",
".",
"cursor",
"(",... | Insert a collection of namedtuple records. | [
"Insert",
"a",
"collection",
"of",
"namedtuple",
"records",
"."
] | fe26199131b15295fc5f669a0ad2a7f47bf490ee | https://github.com/portfoliome/postpy/blob/fe26199131b15295fc5f669a0ad2a7f47bf490ee/postpy/dml.py#L30-L38 | train |
portfoliome/postpy | postpy/dml.py | insert_many | def insert_many(conn, tablename, column_names, records, chunksize=2500):
"""Insert many records by chunking data into insert statements.
Notes
-----
records should be Iterable collection of namedtuples or tuples.
"""
groups = chunks(records, chunksize)
column_str = ','.join(column_names)
... | python | def insert_many(conn, tablename, column_names, records, chunksize=2500):
"""Insert many records by chunking data into insert statements.
Notes
-----
records should be Iterable collection of namedtuples or tuples.
"""
groups = chunks(records, chunksize)
column_str = ','.join(column_names)
... | [
"def",
"insert_many",
"(",
"conn",
",",
"tablename",
",",
"column_names",
",",
"records",
",",
"chunksize",
"=",
"2500",
")",
":",
"groups",
"=",
"chunks",
"(",
"records",
",",
"chunksize",
")",
"column_str",
"=",
"','",
".",
"join",
"(",
"column_names",
... | Insert many records by chunking data into insert statements.
Notes
-----
records should be Iterable collection of namedtuples or tuples. | [
"Insert",
"many",
"records",
"by",
"chunking",
"data",
"into",
"insert",
"statements",
"."
] | fe26199131b15295fc5f669a0ad2a7f47bf490ee | https://github.com/portfoliome/postpy/blob/fe26199131b15295fc5f669a0ad2a7f47bf490ee/postpy/dml.py#L41-L60 | train |
portfoliome/postpy | postpy/dml.py | upsert_records | def upsert_records(conn, records, upsert_statement):
"""Upsert records."""
with conn:
with conn.cursor() as cursor:
for record in records:
cursor.execute(upsert_statement, record) | python | def upsert_records(conn, records, upsert_statement):
"""Upsert records."""
with conn:
with conn.cursor() as cursor:
for record in records:
cursor.execute(upsert_statement, record) | [
"def",
"upsert_records",
"(",
"conn",
",",
"records",
",",
"upsert_statement",
")",
":",
"with",
"conn",
":",
"with",
"conn",
".",
"cursor",
"(",
")",
"as",
"cursor",
":",
"for",
"record",
"in",
"records",
":",
"cursor",
".",
"execute",
"(",
"upsert_stat... | Upsert records. | [
"Upsert",
"records",
"."
] | fe26199131b15295fc5f669a0ad2a7f47bf490ee | https://github.com/portfoliome/postpy/blob/fe26199131b15295fc5f669a0ad2a7f47bf490ee/postpy/dml.py#L63-L69 | train |
portfoliome/postpy | postpy/dml.py | delete_joined_table_sql | def delete_joined_table_sql(qualified_name, removing_qualified_name, primary_key):
"""SQL statement for a joined delete from.
Generate SQL statement for deleting the intersection of rows between
both tables from table referenced by tablename.
"""
condition_template = 't.{}=d.{}'
where_clause = ... | python | def delete_joined_table_sql(qualified_name, removing_qualified_name, primary_key):
"""SQL statement for a joined delete from.
Generate SQL statement for deleting the intersection of rows between
both tables from table referenced by tablename.
"""
condition_template = 't.{}=d.{}'
where_clause = ... | [
"def",
"delete_joined_table_sql",
"(",
"qualified_name",
",",
"removing_qualified_name",
",",
"primary_key",
")",
":",
"condition_template",
"=",
"'t.{}=d.{}'",
"where_clause",
"=",
"' AND '",
".",
"join",
"(",
"condition_template",
".",
"format",
"(",
"pkey",
",",
... | SQL statement for a joined delete from.
Generate SQL statement for deleting the intersection of rows between
both tables from table referenced by tablename. | [
"SQL",
"statement",
"for",
"a",
"joined",
"delete",
"from",
".",
"Generate",
"SQL",
"statement",
"for",
"deleting",
"the",
"intersection",
"of",
"rows",
"between",
"both",
"tables",
"from",
"table",
"referenced",
"by",
"tablename",
"."
] | fe26199131b15295fc5f669a0ad2a7f47bf490ee | https://github.com/portfoliome/postpy/blob/fe26199131b15295fc5f669a0ad2a7f47bf490ee/postpy/dml.py#L165-L180 | train |
portfoliome/postpy | postpy/dml.py | copy_from_csv | def copy_from_csv(conn, file, qualified_name: str, delimiter=',', encoding='utf8',
null_str='', header=True, escape_str='\\', quote_char='"',
force_not_null=None, force_null=None):
"""Copy file-like object to database table.
Notes
-----
Implementation defaults to pos... | python | def copy_from_csv(conn, file, qualified_name: str, delimiter=',', encoding='utf8',
null_str='', header=True, escape_str='\\', quote_char='"',
force_not_null=None, force_null=None):
"""Copy file-like object to database table.
Notes
-----
Implementation defaults to pos... | [
"def",
"copy_from_csv",
"(",
"conn",
",",
"file",
",",
"qualified_name",
":",
"str",
",",
"delimiter",
"=",
"','",
",",
"encoding",
"=",
"'utf8'",
",",
"null_str",
"=",
"''",
",",
"header",
"=",
"True",
",",
"escape_str",
"=",
"'\\\\'",
",",
"quote_char"... | Copy file-like object to database table.
Notes
-----
Implementation defaults to postgres standard except for encoding.
Postgres falls back on client encoding, while function defaults to utf-8.
References
----------
https://www.postgresql.org/docs/current/static/sql-copy.html | [
"Copy",
"file",
"-",
"like",
"object",
"to",
"database",
"table",
"."
] | fe26199131b15295fc5f669a0ad2a7f47bf490ee | https://github.com/portfoliome/postpy/blob/fe26199131b15295fc5f669a0ad2a7f47bf490ee/postpy/dml.py#L237-L261 | train |
portfoliome/postpy | postpy/admin.py | get_user_tables | def get_user_tables(conn):
"""Retrieve all user tables."""
query_string = "select schemaname, relname from pg_stat_user_tables;"
with conn.cursor() as cursor:
cursor.execute(query_string)
tables = cursor.fetchall()
return tables | python | def get_user_tables(conn):
"""Retrieve all user tables."""
query_string = "select schemaname, relname from pg_stat_user_tables;"
with conn.cursor() as cursor:
cursor.execute(query_string)
tables = cursor.fetchall()
return tables | [
"def",
"get_user_tables",
"(",
"conn",
")",
":",
"query_string",
"=",
"\"select schemaname, relname from pg_stat_user_tables;\"",
"with",
"conn",
".",
"cursor",
"(",
")",
"as",
"cursor",
":",
"cursor",
".",
"execute",
"(",
"query_string",
")",
"tables",
"=",
"curs... | Retrieve all user tables. | [
"Retrieve",
"all",
"user",
"tables",
"."
] | fe26199131b15295fc5f669a0ad2a7f47bf490ee | https://github.com/portfoliome/postpy/blob/fe26199131b15295fc5f669a0ad2a7f47bf490ee/postpy/admin.py#L13-L21 | train |
portfoliome/postpy | postpy/admin.py | get_column_metadata | def get_column_metadata(conn, table: str, schema='public'):
"""Returns column data following db.Column parameter specification."""
query = """\
SELECT
attname as name,
format_type(atttypid, atttypmod) AS data_type,
NOT attnotnull AS nullable
FROM pg_catalog.pg_attribute
WHERE attrelid=%s::regclass
AND a... | python | def get_column_metadata(conn, table: str, schema='public'):
"""Returns column data following db.Column parameter specification."""
query = """\
SELECT
attname as name,
format_type(atttypid, atttypmod) AS data_type,
NOT attnotnull AS nullable
FROM pg_catalog.pg_attribute
WHERE attrelid=%s::regclass
AND a... | [
"def",
"get_column_metadata",
"(",
"conn",
",",
"table",
":",
"str",
",",
"schema",
"=",
"'public'",
")",
":",
"query",
"=",
"qualified_name",
"=",
"compile_qualified_name",
"(",
"table",
",",
"schema",
"=",
"schema",
")",
"for",
"record",
"in",
"select_dict... | Returns column data following db.Column parameter specification. | [
"Returns",
"column",
"data",
"following",
"db",
".",
"Column",
"parameter",
"specification",
"."
] | fe26199131b15295fc5f669a0ad2a7f47bf490ee | https://github.com/portfoliome/postpy/blob/fe26199131b15295fc5f669a0ad2a7f47bf490ee/postpy/admin.py#L47-L62 | train |
portfoliome/postpy | postpy/admin.py | reflect_table | def reflect_table(conn, table_name, schema='public'):
"""Reflect basic table attributes."""
column_meta = list(get_column_metadata(conn, table_name, schema=schema))
primary_key_columns = list(get_primary_keys(conn, table_name, schema=schema))
columns = [Column(**column_data) for column_data in column_... | python | def reflect_table(conn, table_name, schema='public'):
"""Reflect basic table attributes."""
column_meta = list(get_column_metadata(conn, table_name, schema=schema))
primary_key_columns = list(get_primary_keys(conn, table_name, schema=schema))
columns = [Column(**column_data) for column_data in column_... | [
"def",
"reflect_table",
"(",
"conn",
",",
"table_name",
",",
"schema",
"=",
"'public'",
")",
":",
"column_meta",
"=",
"list",
"(",
"get_column_metadata",
"(",
"conn",
",",
"table_name",
",",
"schema",
"=",
"schema",
")",
")",
"primary_key_columns",
"=",
"lis... | Reflect basic table attributes. | [
"Reflect",
"basic",
"table",
"attributes",
"."
] | fe26199131b15295fc5f669a0ad2a7f47bf490ee | https://github.com/portfoliome/postpy/blob/fe26199131b15295fc5f669a0ad2a7f47bf490ee/postpy/admin.py#L65-L74 | train |
portfoliome/postpy | postpy/admin.py | reset | def reset(db_name):
"""Reset database."""
conn = psycopg2.connect(database='postgres')
db = Database(db_name)
conn.autocommit = True
with conn.cursor() as cursor:
cursor.execute(db.drop_statement())
cursor.execute(db.create_statement())
conn.close() | python | def reset(db_name):
"""Reset database."""
conn = psycopg2.connect(database='postgres')
db = Database(db_name)
conn.autocommit = True
with conn.cursor() as cursor:
cursor.execute(db.drop_statement())
cursor.execute(db.create_statement())
conn.close() | [
"def",
"reset",
"(",
"db_name",
")",
":",
"conn",
"=",
"psycopg2",
".",
"connect",
"(",
"database",
"=",
"'postgres'",
")",
"db",
"=",
"Database",
"(",
"db_name",
")",
"conn",
".",
"autocommit",
"=",
"True",
"with",
"conn",
".",
"cursor",
"(",
")",
"... | Reset database. | [
"Reset",
"database",
"."
] | fe26199131b15295fc5f669a0ad2a7f47bf490ee | https://github.com/portfoliome/postpy/blob/fe26199131b15295fc5f669a0ad2a7f47bf490ee/postpy/admin.py#L77-L87 | train |
portfoliome/postpy | postpy/admin.py | install_extensions | def install_extensions(extensions, **connection_parameters):
"""Install Postgres extension if available.
Notes
-----
- superuser is generally required for installing extensions.
- Currently does not support specific schema.
"""
from postpy.connections import connect
conn = connect(**c... | python | def install_extensions(extensions, **connection_parameters):
"""Install Postgres extension if available.
Notes
-----
- superuser is generally required for installing extensions.
- Currently does not support specific schema.
"""
from postpy.connections import connect
conn = connect(**c... | [
"def",
"install_extensions",
"(",
"extensions",
",",
"**",
"connection_parameters",
")",
":",
"from",
"postpy",
".",
"connections",
"import",
"connect",
"conn",
"=",
"connect",
"(",
"**",
"connection_parameters",
")",
"conn",
".",
"autocommit",
"=",
"True",
"for... | Install Postgres extension if available.
Notes
-----
- superuser is generally required for installing extensions.
- Currently does not support specific schema. | [
"Install",
"Postgres",
"extension",
"if",
"available",
"."
] | fe26199131b15295fc5f669a0ad2a7f47bf490ee | https://github.com/portfoliome/postpy/blob/fe26199131b15295fc5f669a0ad2a7f47bf490ee/postpy/admin.py#L90-L105 | train |
daskos/mentor | mentor/proxies/executor.py | ExecutorDriverProxy.update | def update(self, status):
"""Sends a status update to the framework scheduler.
Retrying as necessary until an acknowledgement has been received or the
executor is terminated (in which case, a TASK_LOST status update will be
sent).
See Scheduler.statusUpdate for more information ... | python | def update(self, status):
"""Sends a status update to the framework scheduler.
Retrying as necessary until an acknowledgement has been received or the
executor is terminated (in which case, a TASK_LOST status update will be
sent).
See Scheduler.statusUpdate for more information ... | [
"def",
"update",
"(",
"self",
",",
"status",
")",
":",
"logging",
".",
"info",
"(",
"'Executor sends status update {} for task {}'",
".",
"format",
"(",
"status",
".",
"state",
",",
"status",
".",
"task_id",
")",
")",
"return",
"self",
".",
"driver",
".",
... | Sends a status update to the framework scheduler.
Retrying as necessary until an acknowledgement has been received or the
executor is terminated (in which case, a TASK_LOST status update will be
sent).
See Scheduler.statusUpdate for more information about status update
acknowled... | [
"Sends",
"a",
"status",
"update",
"to",
"the",
"framework",
"scheduler",
"."
] | b5fd64e3a3192f5664fa5c03e8517cacb4e0590f | https://github.com/daskos/mentor/blob/b5fd64e3a3192f5664fa5c03e8517cacb4e0590f/mentor/proxies/executor.py#L108-L119 | train |
daskos/mentor | mentor/proxies/executor.py | ExecutorDriverProxy.message | def message(self, data):
"""Sends a message to the framework scheduler.
These messages are best effort; do not expect a framework message to be
retransmitted in any reliable fashion.
"""
logging.info('Driver sends framework message {}'.format(data))
return self.driver.se... | python | def message(self, data):
"""Sends a message to the framework scheduler.
These messages are best effort; do not expect a framework message to be
retransmitted in any reliable fashion.
"""
logging.info('Driver sends framework message {}'.format(data))
return self.driver.se... | [
"def",
"message",
"(",
"self",
",",
"data",
")",
":",
"logging",
".",
"info",
"(",
"'Driver sends framework message {}'",
".",
"format",
"(",
"data",
")",
")",
"return",
"self",
".",
"driver",
".",
"sendFrameworkMessage",
"(",
"data",
")"
] | Sends a message to the framework scheduler.
These messages are best effort; do not expect a framework message to be
retransmitted in any reliable fashion. | [
"Sends",
"a",
"message",
"to",
"the",
"framework",
"scheduler",
"."
] | b5fd64e3a3192f5664fa5c03e8517cacb4e0590f | https://github.com/daskos/mentor/blob/b5fd64e3a3192f5664fa5c03e8517cacb4e0590f/mentor/proxies/executor.py#L121-L128 | train |
centralniak/py-raildriver | raildriver/library.py | RailDriver.get_current_time | def get_current_time(self):
"""
Get current time
:return: datetime.time
"""
hms = [int(self.get_current_controller_value(i)) for i in range(406, 409)]
return datetime.time(*hms) | python | def get_current_time(self):
"""
Get current time
:return: datetime.time
"""
hms = [int(self.get_current_controller_value(i)) for i in range(406, 409)]
return datetime.time(*hms) | [
"def",
"get_current_time",
"(",
"self",
")",
":",
"hms",
"=",
"[",
"int",
"(",
"self",
".",
"get_current_controller_value",
"(",
"i",
")",
")",
"for",
"i",
"in",
"range",
"(",
"406",
",",
"409",
")",
"]",
"return",
"datetime",
".",
"time",
"(",
"*",
... | Get current time
:return: datetime.time | [
"Get",
"current",
"time"
] | c7f5f551e0436451b9507fc63a62e49a229282b9 | https://github.com/centralniak/py-raildriver/blob/c7f5f551e0436451b9507fc63a62e49a229282b9/raildriver/library.py#L134-L141 | train |
centralniak/py-raildriver | raildriver/library.py | RailDriver.get_loco_name | def get_loco_name(self):
"""
Returns the Provider, Product and Engine name.
:return list
"""
ret_str = self.dll.GetLocoName().decode()
if not ret_str:
return
return ret_str.split('.:.') | python | def get_loco_name(self):
"""
Returns the Provider, Product and Engine name.
:return list
"""
ret_str = self.dll.GetLocoName().decode()
if not ret_str:
return
return ret_str.split('.:.') | [
"def",
"get_loco_name",
"(",
"self",
")",
":",
"ret_str",
"=",
"self",
".",
"dll",
".",
"GetLocoName",
"(",
")",
".",
"decode",
"(",
")",
"if",
"not",
"ret_str",
":",
"return",
"return",
"ret_str",
".",
"split",
"(",
"'.:.'",
")"
] | Returns the Provider, Product and Engine name.
:return list | [
"Returns",
"the",
"Provider",
"Product",
"and",
"Engine",
"name",
"."
] | c7f5f551e0436451b9507fc63a62e49a229282b9 | https://github.com/centralniak/py-raildriver/blob/c7f5f551e0436451b9507fc63a62e49a229282b9/raildriver/library.py#L143-L152 | train |
centralniak/py-raildriver | raildriver/library.py | RailDriver.set_controller_value | def set_controller_value(self, index_or_name, value):
"""
Sets controller value
:param index_or_name integer index or string name
:param value float
"""
if not isinstance(index_or_name, int):
index = self.get_controller_index(index_or_name)
else:
... | python | def set_controller_value(self, index_or_name, value):
"""
Sets controller value
:param index_or_name integer index or string name
:param value float
"""
if not isinstance(index_or_name, int):
index = self.get_controller_index(index_or_name)
else:
... | [
"def",
"set_controller_value",
"(",
"self",
",",
"index_or_name",
",",
"value",
")",
":",
"if",
"not",
"isinstance",
"(",
"index_or_name",
",",
"int",
")",
":",
"index",
"=",
"self",
".",
"get_controller_index",
"(",
"index_or_name",
")",
"else",
":",
"index... | Sets controller value
:param index_or_name integer index or string name
:param value float | [
"Sets",
"controller",
"value"
] | c7f5f551e0436451b9507fc63a62e49a229282b9 | https://github.com/centralniak/py-raildriver/blob/c7f5f551e0436451b9507fc63a62e49a229282b9/raildriver/library.py#L172-L183 | train |
daskos/mentor | mentor/proxies/scheduler.py | SchedulerDriverProxy.stop | def stop(self, failover=False):
"""Stops the scheduler driver.
If the 'failover' flag is set to False then it is expected that this
framework will never reconnect to Mesos and all of its executors and
tasks can be terminated. Otherwise, all executors and tasks will
remain runni... | python | def stop(self, failover=False):
"""Stops the scheduler driver.
If the 'failover' flag is set to False then it is expected that this
framework will never reconnect to Mesos and all of its executors and
tasks can be terminated. Otherwise, all executors and tasks will
remain runni... | [
"def",
"stop",
"(",
"self",
",",
"failover",
"=",
"False",
")",
":",
"logging",
".",
"info",
"(",
"'Stops Scheduler Driver'",
")",
"return",
"self",
".",
"driver",
".",
"stop",
"(",
"failover",
")"
] | Stops the scheduler driver.
If the 'failover' flag is set to False then it is expected that this
framework will never reconnect to Mesos and all of its executors and
tasks can be terminated. Otherwise, all executors and tasks will
remain running (for some framework specific failover ti... | [
"Stops",
"the",
"scheduler",
"driver",
"."
] | b5fd64e3a3192f5664fa5c03e8517cacb4e0590f | https://github.com/daskos/mentor/blob/b5fd64e3a3192f5664fa5c03e8517cacb4e0590f/mentor/proxies/scheduler.py#L86-L97 | train |
daskos/mentor | mentor/proxies/scheduler.py | SchedulerDriverProxy.request | def request(self, requests):
"""Requests resources from Mesos.
(see mesos.proto for a description of Request and how, for example, to
request resources from specific slaves.)
Any resources available are offered to the framework via
Scheduler.resourceOffers callback, asynchronou... | python | def request(self, requests):
"""Requests resources from Mesos.
(see mesos.proto for a description of Request and how, for example, to
request resources from specific slaves.)
Any resources available are offered to the framework via
Scheduler.resourceOffers callback, asynchronou... | [
"def",
"request",
"(",
"self",
",",
"requests",
")",
":",
"logging",
".",
"info",
"(",
"'Request resources from Mesos'",
")",
"return",
"self",
".",
"driver",
".",
"requestResources",
"(",
"map",
"(",
"encode",
",",
"requests",
")",
")"
] | Requests resources from Mesos.
(see mesos.proto for a description of Request and how, for example, to
request resources from specific slaves.)
Any resources available are offered to the framework via
Scheduler.resourceOffers callback, asynchronously. | [
"Requests",
"resources",
"from",
"Mesos",
"."
] | b5fd64e3a3192f5664fa5c03e8517cacb4e0590f | https://github.com/daskos/mentor/blob/b5fd64e3a3192f5664fa5c03e8517cacb4e0590f/mentor/proxies/scheduler.py#L121-L131 | train |
daskos/mentor | mentor/proxies/scheduler.py | SchedulerDriverProxy.launch | def launch(self, offer_id, tasks, filters=Filters()):
"""Launches the given set of tasks.
Any resources remaining (i.e., not used by the tasks or their executors)
will be considered declined.
The specified filters are applied on all unused resources (see
mesos.proto for a descri... | python | def launch(self, offer_id, tasks, filters=Filters()):
"""Launches the given set of tasks.
Any resources remaining (i.e., not used by the tasks or their executors)
will be considered declined.
The specified filters are applied on all unused resources (see
mesos.proto for a descri... | [
"def",
"launch",
"(",
"self",
",",
"offer_id",
",",
"tasks",
",",
"filters",
"=",
"Filters",
"(",
")",
")",
":",
"logging",
".",
"info",
"(",
"'Launches tasks {}'",
".",
"format",
"(",
"tasks",
")",
")",
"return",
"self",
".",
"driver",
".",
"launchTas... | Launches the given set of tasks.
Any resources remaining (i.e., not used by the tasks or their executors)
will be considered declined.
The specified filters are applied on all unused resources (see
mesos.proto for a description of Filters). Available resources are
aggregated whe... | [
"Launches",
"the",
"given",
"set",
"of",
"tasks",
"."
] | b5fd64e3a3192f5664fa5c03e8517cacb4e0590f | https://github.com/daskos/mentor/blob/b5fd64e3a3192f5664fa5c03e8517cacb4e0590f/mentor/proxies/scheduler.py#L133-L150 | train |
daskos/mentor | mentor/proxies/scheduler.py | SchedulerDriverProxy.kill | def kill(self, task_id):
"""Kills the specified task.
Note that attempting to kill a task is currently not reliable.
If, for example, a scheduler fails over while it was attempting to kill
a task it will need to retry in the future.
Likewise, if unregistered / disconnected, the ... | python | def kill(self, task_id):
"""Kills the specified task.
Note that attempting to kill a task is currently not reliable.
If, for example, a scheduler fails over while it was attempting to kill
a task it will need to retry in the future.
Likewise, if unregistered / disconnected, the ... | [
"def",
"kill",
"(",
"self",
",",
"task_id",
")",
":",
"logging",
".",
"info",
"(",
"'Kills task {}'",
".",
"format",
"(",
"task_id",
")",
")",
"return",
"self",
".",
"driver",
".",
"killTask",
"(",
"encode",
"(",
"task_id",
")",
")"
] | Kills the specified task.
Note that attempting to kill a task is currently not reliable.
If, for example, a scheduler fails over while it was attempting to kill
a task it will need to retry in the future.
Likewise, if unregistered / disconnected, the request will be dropped
(the... | [
"Kills",
"the",
"specified",
"task",
"."
] | b5fd64e3a3192f5664fa5c03e8517cacb4e0590f | https://github.com/daskos/mentor/blob/b5fd64e3a3192f5664fa5c03e8517cacb4e0590f/mentor/proxies/scheduler.py#L152-L162 | train |
daskos/mentor | mentor/proxies/scheduler.py | SchedulerDriverProxy.reconcile | def reconcile(self, statuses):
"""Allows the framework to query the status for non-terminal tasks.
This causes the master to send back the latest task status for each task
in 'statuses', if possible. Tasks that are no longer known will result
in a TASK_LOST update. If statuses is empty,... | python | def reconcile(self, statuses):
"""Allows the framework to query the status for non-terminal tasks.
This causes the master to send back the latest task status for each task
in 'statuses', if possible. Tasks that are no longer known will result
in a TASK_LOST update. If statuses is empty,... | [
"def",
"reconcile",
"(",
"self",
",",
"statuses",
")",
":",
"logging",
".",
"info",
"(",
"'Reconciles task statuses {}'",
".",
"format",
"(",
"statuses",
")",
")",
"return",
"self",
".",
"driver",
".",
"reconcileTasks",
"(",
"map",
"(",
"encode",
",",
"sta... | Allows the framework to query the status for non-terminal tasks.
This causes the master to send back the latest task status for each task
in 'statuses', if possible. Tasks that are no longer known will result
in a TASK_LOST update. If statuses is empty, then the master will send
the lat... | [
"Allows",
"the",
"framework",
"to",
"query",
"the",
"status",
"for",
"non",
"-",
"terminal",
"tasks",
"."
] | b5fd64e3a3192f5664fa5c03e8517cacb4e0590f | https://github.com/daskos/mentor/blob/b5fd64e3a3192f5664fa5c03e8517cacb4e0590f/mentor/proxies/scheduler.py#L164-L173 | train |
daskos/mentor | mentor/proxies/scheduler.py | SchedulerDriverProxy.accept | def accept(self, offer_ids, operations, filters=Filters()):
"""Accepts the given offers and performs a sequence of operations
on those accepted offers.
See Offer.Operation in mesos.proto for the set of available operations.
Available resources are aggregated when multiple offers are ... | python | def accept(self, offer_ids, operations, filters=Filters()):
"""Accepts the given offers and performs a sequence of operations
on those accepted offers.
See Offer.Operation in mesos.proto for the set of available operations.
Available resources are aggregated when multiple offers are ... | [
"def",
"accept",
"(",
"self",
",",
"offer_ids",
",",
"operations",
",",
"filters",
"=",
"Filters",
"(",
")",
")",
":",
"logging",
".",
"info",
"(",
"'Accepts offers {}'",
".",
"format",
"(",
"offer_ids",
")",
")",
"return",
"self",
".",
"driver",
".",
... | Accepts the given offers and performs a sequence of operations
on those accepted offers.
See Offer.Operation in mesos.proto for the set of available operations.
Available resources are aggregated when multiple offers are provided.
Note that all offers must belong to the same slave. ... | [
"Accepts",
"the",
"given",
"offers",
"and",
"performs",
"a",
"sequence",
"of",
"operations",
"on",
"those",
"accepted",
"offers",
"."
] | b5fd64e3a3192f5664fa5c03e8517cacb4e0590f | https://github.com/daskos/mentor/blob/b5fd64e3a3192f5664fa5c03e8517cacb4e0590f/mentor/proxies/scheduler.py#L187-L201 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.