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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
robinandeer/puzzle | puzzle/plugins/gemini/mixins/variant.py | VariantMixin._format_variant | def _format_variant(self, case_id, gemini_variant, individual_objs,
index=0, add_all_info=False):
"""Make a puzzle variant from a gemini variant
Args:
case_id (str): related case id
gemini_variant (GeminiQueryRow): The gemini variant
... | python | def _format_variant(self, case_id, gemini_variant, individual_objs,
index=0, add_all_info=False):
"""Make a puzzle variant from a gemini variant
Args:
case_id (str): related case id
gemini_variant (GeminiQueryRow): The gemini variant
... | [
"def",
"_format_variant",
"(",
"self",
",",
"case_id",
",",
"gemini_variant",
",",
"individual_objs",
",",
"index",
"=",
"0",
",",
"add_all_info",
"=",
"False",
")",
":",
"chrom",
"=",
"gemini_variant",
"[",
"'chrom'",
"]",
"if",
"chrom",
".",
"startswith",
... | Make a puzzle variant from a gemini variant
Args:
case_id (str): related case id
gemini_variant (GeminiQueryRow): The gemini variant
individual_objs (list(dict)): A list of Individuals
index(int): The index of the variant
Returns:... | [
"Make",
"a",
"puzzle",
"variant",
"from",
"a",
"gemini",
"variant"
] | 9476f05b416d3a5135d25492cb31411fdf831c58 | https://github.com/robinandeer/puzzle/blob/9476f05b416d3a5135d25492cb31411fdf831c58/puzzle/plugins/gemini/mixins/variant.py#L237-L323 | train |
robinandeer/puzzle | puzzle/plugins/gemini/mixins/variant.py | VariantMixin._is_variant | def _is_variant(self, gemini_variant, ind_objs):
"""Check if the variant is a variation in any of the individuals
Args:
gemini_variant (GeminiQueryRow): The gemini variant
ind_objs (list(puzzle.models.individual)): A list of individuals to check
Returns:
boo... | python | def _is_variant(self, gemini_variant, ind_objs):
"""Check if the variant is a variation in any of the individuals
Args:
gemini_variant (GeminiQueryRow): The gemini variant
ind_objs (list(puzzle.models.individual)): A list of individuals to check
Returns:
boo... | [
"def",
"_is_variant",
"(",
"self",
",",
"gemini_variant",
",",
"ind_objs",
")",
":",
"indexes",
"=",
"(",
"ind",
".",
"ind_index",
"for",
"ind",
"in",
"ind_objs",
")",
"for",
"index",
"in",
"indexes",
":",
"gt_call",
"=",
"gemini_variant",
"[",
"'gt_types'... | Check if the variant is a variation in any of the individuals
Args:
gemini_variant (GeminiQueryRow): The gemini variant
ind_objs (list(puzzle.models.individual)): A list of individuals to check
Returns:
bool : If any of the individuals has the variant | [
"Check",
"if",
"the",
"variant",
"is",
"a",
"variation",
"in",
"any",
"of",
"the",
"individuals"
] | 9476f05b416d3a5135d25492cb31411fdf831c58 | https://github.com/robinandeer/puzzle/blob/9476f05b416d3a5135d25492cb31411fdf831c58/puzzle/plugins/gemini/mixins/variant.py#L325-L343 | train |
robinandeer/puzzle | puzzle/models/mixins.py | PedigreeHumanMixin.is_affected | def is_affected(self):
"""Boolean for telling if the sample is affected."""
phenotype = self.phenotype
if phenotype == '1':
return False
elif phenotype == '2':
return True
else:
return False | python | def is_affected(self):
"""Boolean for telling if the sample is affected."""
phenotype = self.phenotype
if phenotype == '1':
return False
elif phenotype == '2':
return True
else:
return False | [
"def",
"is_affected",
"(",
"self",
")",
":",
"phenotype",
"=",
"self",
".",
"phenotype",
"if",
"phenotype",
"==",
"'1'",
":",
"return",
"False",
"elif",
"phenotype",
"==",
"'2'",
":",
"return",
"True",
"else",
":",
"return",
"False"
] | Boolean for telling if the sample is affected. | [
"Boolean",
"for",
"telling",
"if",
"the",
"sample",
"is",
"affected",
"."
] | 9476f05b416d3a5135d25492cb31411fdf831c58 | https://github.com/robinandeer/puzzle/blob/9476f05b416d3a5135d25492cb31411fdf831c58/puzzle/models/mixins.py#L17-L25 | train |
robinandeer/puzzle | puzzle/plugins/sql/mixins/actions/genelist.py | GeneListActions.gene_list | def gene_list(self, list_id):
"""Get a gene list from the database."""
return self.query(GeneList).filter_by(list_id=list_id).first() | python | def gene_list(self, list_id):
"""Get a gene list from the database."""
return self.query(GeneList).filter_by(list_id=list_id).first() | [
"def",
"gene_list",
"(",
"self",
",",
"list_id",
")",
":",
"return",
"self",
".",
"query",
"(",
"GeneList",
")",
".",
"filter_by",
"(",
"list_id",
"=",
"list_id",
")",
".",
"first",
"(",
")"
] | Get a gene list from the database. | [
"Get",
"a",
"gene",
"list",
"from",
"the",
"database",
"."
] | 9476f05b416d3a5135d25492cb31411fdf831c58 | https://github.com/robinandeer/puzzle/blob/9476f05b416d3a5135d25492cb31411fdf831c58/puzzle/plugins/sql/mixins/actions/genelist.py#L6-L8 | train |
robinandeer/puzzle | puzzle/plugins/sql/mixins/actions/genelist.py | GeneListActions.add_genelist | def add_genelist(self, list_id, gene_ids, case_obj=None):
"""Create a new gene list and optionally link to cases."""
new_genelist = GeneList(list_id=list_id)
new_genelist.gene_ids = gene_ids
if case_obj:
new_genelist.cases.append(case_obj)
self.session.add(new_geneli... | python | def add_genelist(self, list_id, gene_ids, case_obj=None):
"""Create a new gene list and optionally link to cases."""
new_genelist = GeneList(list_id=list_id)
new_genelist.gene_ids = gene_ids
if case_obj:
new_genelist.cases.append(case_obj)
self.session.add(new_geneli... | [
"def",
"add_genelist",
"(",
"self",
",",
"list_id",
",",
"gene_ids",
",",
"case_obj",
"=",
"None",
")",
":",
"new_genelist",
"=",
"GeneList",
"(",
"list_id",
"=",
"list_id",
")",
"new_genelist",
".",
"gene_ids",
"=",
"gene_ids",
"if",
"case_obj",
":",
"new... | Create a new gene list and optionally link to cases. | [
"Create",
"a",
"new",
"gene",
"list",
"and",
"optionally",
"link",
"to",
"cases",
"."
] | 9476f05b416d3a5135d25492cb31411fdf831c58 | https://github.com/robinandeer/puzzle/blob/9476f05b416d3a5135d25492cb31411fdf831c58/puzzle/plugins/sql/mixins/actions/genelist.py#L14-L23 | train |
robinandeer/puzzle | puzzle/plugins/sql/mixins/actions/genelist.py | GeneListActions.remove_genelist | def remove_genelist(self, list_id, case_obj=None):
"""Remove a gene list and links to cases."""
gene_list = self.gene_list(list_id)
if case_obj:
# remove a single link between case and gene list
case_ids = [case_obj.id]
else:
# remove all links and th... | python | def remove_genelist(self, list_id, case_obj=None):
"""Remove a gene list and links to cases."""
gene_list = self.gene_list(list_id)
if case_obj:
# remove a single link between case and gene list
case_ids = [case_obj.id]
else:
# remove all links and th... | [
"def",
"remove_genelist",
"(",
"self",
",",
"list_id",
",",
"case_obj",
"=",
"None",
")",
":",
"gene_list",
"=",
"self",
".",
"gene_list",
"(",
"list_id",
")",
"if",
"case_obj",
":",
"case_ids",
"=",
"[",
"case_obj",
".",
"id",
"]",
"else",
":",
"case_... | Remove a gene list and links to cases. | [
"Remove",
"a",
"gene",
"list",
"and",
"links",
"to",
"cases",
"."
] | 9476f05b416d3a5135d25492cb31411fdf831c58 | https://github.com/robinandeer/puzzle/blob/9476f05b416d3a5135d25492cb31411fdf831c58/puzzle/plugins/sql/mixins/actions/genelist.py#L25-L44 | train |
robinandeer/puzzle | puzzle/plugins/sql/mixins/actions/genelist.py | GeneListActions.case_genelist | def case_genelist(self, case_obj):
"""Get or create a new case specific gene list record."""
list_id = "{}-HPO".format(case_obj.case_id)
gene_list = self.gene_list(list_id)
if gene_list is None:
gene_list = GeneList(list_id=list_id)
case_obj.gene_lists.append(gen... | python | def case_genelist(self, case_obj):
"""Get or create a new case specific gene list record."""
list_id = "{}-HPO".format(case_obj.case_id)
gene_list = self.gene_list(list_id)
if gene_list is None:
gene_list = GeneList(list_id=list_id)
case_obj.gene_lists.append(gen... | [
"def",
"case_genelist",
"(",
"self",
",",
"case_obj",
")",
":",
"list_id",
"=",
"\"{}-HPO\"",
".",
"format",
"(",
"case_obj",
".",
"case_id",
")",
"gene_list",
"=",
"self",
".",
"gene_list",
"(",
"list_id",
")",
"if",
"gene_list",
"is",
"None",
":",
"gen... | Get or create a new case specific gene list record. | [
"Get",
"or",
"create",
"a",
"new",
"case",
"specific",
"gene",
"list",
"record",
"."
] | 9476f05b416d3a5135d25492cb31411fdf831c58 | https://github.com/robinandeer/puzzle/blob/9476f05b416d3a5135d25492cb31411fdf831c58/puzzle/plugins/sql/mixins/actions/genelist.py#L46-L56 | train |
ldomic/lintools | lintools/figure.py | Figure.add_bigger_box | def add_bigger_box(self):
"""
Sets the size of the figure by expanding the space of molecule.svg file. These dimension have been
previously determined. Also makes the lines of the molecule thicker.
"""
start1 = "width='"+str(int(self.molecule.molsize1))+"px' height='"+str(int(sel... | python | def add_bigger_box(self):
"""
Sets the size of the figure by expanding the space of molecule.svg file. These dimension have been
previously determined. Also makes the lines of the molecule thicker.
"""
start1 = "width='"+str(int(self.molecule.molsize1))+"px' height='"+str(int(sel... | [
"def",
"add_bigger_box",
"(",
"self",
")",
":",
"start1",
"=",
"\"width='\"",
"+",
"str",
"(",
"int",
"(",
"self",
".",
"molecule",
".",
"molsize1",
")",
")",
"+",
"\"px' height='\"",
"+",
"str",
"(",
"int",
"(",
"self",
".",
"molecule",
".",
"molsize2... | Sets the size of the figure by expanding the space of molecule.svg file. These dimension have been
previously determined. Also makes the lines of the molecule thicker. | [
"Sets",
"the",
"size",
"of",
"the",
"figure",
"by",
"expanding",
"the",
"space",
"of",
"molecule",
".",
"svg",
"file",
".",
"These",
"dimension",
"have",
"been",
"previously",
"determined",
".",
"Also",
"makes",
"the",
"lines",
"of",
"the",
"molecule",
"th... | d825a4a7b35f3f857d3b81b46c9aee72b0ec697a | https://github.com/ldomic/lintools/blob/d825a4a7b35f3f857d3b81b46c9aee72b0ec697a/lintools/figure.py#L57-L80 | train |
ellethee/argparseinator | argparseinator/__init__.py | extend_with | def extend_with(func):
"""Extends with class or function"""
if not func.__name__ in ArgParseInator._plugins:
ArgParseInator._plugins[func.__name__] = func | python | def extend_with(func):
"""Extends with class or function"""
if not func.__name__ in ArgParseInator._plugins:
ArgParseInator._plugins[func.__name__] = func | [
"def",
"extend_with",
"(",
"func",
")",
":",
"if",
"not",
"func",
".",
"__name__",
"in",
"ArgParseInator",
".",
"_plugins",
":",
"ArgParseInator",
".",
"_plugins",
"[",
"func",
".",
"__name__",
"]",
"=",
"func"
] | Extends with class or function | [
"Extends",
"with",
"class",
"or",
"function"
] | 05e9c00dfaa938b9c4ee2aadc6206f5e0918e24e | https://github.com/ellethee/argparseinator/blob/05e9c00dfaa938b9c4ee2aadc6206f5e0918e24e/argparseinator/__init__.py#L599-L602 | train |
ellethee/argparseinator | argparseinator/__init__.py | arg | def arg(*args, **kwargs):
"""
Dcorates a function or a class method to add to the argument parser
"""
def decorate(func):
"""
Decorate
"""
# we'll set the command name with the passed cmd_name argument, if
# exist, else the command name will be the function name
... | python | def arg(*args, **kwargs):
"""
Dcorates a function or a class method to add to the argument parser
"""
def decorate(func):
"""
Decorate
"""
# we'll set the command name with the passed cmd_name argument, if
# exist, else the command name will be the function name
... | [
"def",
"arg",
"(",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"def",
"decorate",
"(",
"func",
")",
":",
"func",
".",
"__cmd_name__",
"=",
"kwargs",
".",
"pop",
"(",
"'cmd_name'",
",",
"getattr",
"(",
"func",
",",
"'__cmd_name__'",
",",
"func",
".",
... | Dcorates a function or a class method to add to the argument parser | [
"Dcorates",
"a",
"function",
"or",
"a",
"class",
"method",
"to",
"add",
"to",
"the",
"argument",
"parser"
] | 05e9c00dfaa938b9c4ee2aadc6206f5e0918e24e | https://github.com/ellethee/argparseinator/blob/05e9c00dfaa938b9c4ee2aadc6206f5e0918e24e/argparseinator/__init__.py#L605-L648 | train |
ellethee/argparseinator | argparseinator/__init__.py | class_args | def class_args(cls):
"""
Decorates a class to handle the arguments parser.
"""
# get the Singleton
ap_ = ArgParseInator(skip_init=True)
# collect special vars (really need?)
utils.collect_appendvars(ap_, cls)
# set class reference
cls.__cls__ = cls
cmds = {}
# get eventual cl... | python | def class_args(cls):
"""
Decorates a class to handle the arguments parser.
"""
# get the Singleton
ap_ = ArgParseInator(skip_init=True)
# collect special vars (really need?)
utils.collect_appendvars(ap_, cls)
# set class reference
cls.__cls__ = cls
cmds = {}
# get eventual cl... | [
"def",
"class_args",
"(",
"cls",
")",
":",
"ap_",
"=",
"ArgParseInator",
"(",
"skip_init",
"=",
"True",
")",
"utils",
".",
"collect_appendvars",
"(",
"ap_",
",",
"cls",
")",
"cls",
".",
"__cls__",
"=",
"cls",
"cmds",
"=",
"{",
"}",
"cls",
".",
"__arg... | Decorates a class to handle the arguments parser. | [
"Decorates",
"a",
"class",
"to",
"handle",
"the",
"arguments",
"parser",
"."
] | 05e9c00dfaa938b9c4ee2aadc6206f5e0918e24e | https://github.com/ellethee/argparseinator/blob/05e9c00dfaa938b9c4ee2aadc6206f5e0918e24e/argparseinator/__init__.py#L651-L687 | train |
ellethee/argparseinator | argparseinator/__init__.py | cmd_auth | def cmd_auth(auth_phrase=None):
"""
set authorization for command or subcommand.
"""
def decorate(func):
"""
decorates the funcion
"""
# get the Singleton
ap_ = ArgParseInator(skip_init=True)
# set the authorization name
auth_name = id(func)
... | python | def cmd_auth(auth_phrase=None):
"""
set authorization for command or subcommand.
"""
def decorate(func):
"""
decorates the funcion
"""
# get the Singleton
ap_ = ArgParseInator(skip_init=True)
# set the authorization name
auth_name = id(func)
... | [
"def",
"cmd_auth",
"(",
"auth_phrase",
"=",
"None",
")",
":",
"def",
"decorate",
"(",
"func",
")",
":",
"ap_",
"=",
"ArgParseInator",
"(",
"skip_init",
"=",
"True",
")",
"auth_name",
"=",
"id",
"(",
"func",
")",
"if",
"auth_phrase",
"is",
"None",
":",
... | set authorization for command or subcommand. | [
"set",
"authorization",
"for",
"command",
"or",
"subcommand",
"."
] | 05e9c00dfaa938b9c4ee2aadc6206f5e0918e24e | https://github.com/ellethee/argparseinator/blob/05e9c00dfaa938b9c4ee2aadc6206f5e0918e24e/argparseinator/__init__.py#L697-L718 | train |
ellethee/argparseinator | argparseinator/__init__.py | ArgParseInator.parse_args | def parse_args(self):
"""
Parse our arguments.
"""
# compile the parser
self._compile()
# clear the args
self.args = None
self._self_event('before_parse', 'parse', *sys.argv[1:], **{})
# list commands/subcommands in argv
cmds = [cmd for cmd... | python | def parse_args(self):
"""
Parse our arguments.
"""
# compile the parser
self._compile()
# clear the args
self.args = None
self._self_event('before_parse', 'parse', *sys.argv[1:], **{})
# list commands/subcommands in argv
cmds = [cmd for cmd... | [
"def",
"parse_args",
"(",
"self",
")",
":",
"self",
".",
"_compile",
"(",
")",
"self",
".",
"args",
"=",
"None",
"self",
".",
"_self_event",
"(",
"'before_parse'",
",",
"'parse'",
",",
"*",
"sys",
".",
"argv",
"[",
"1",
":",
"]",
",",
"**",
"{",
... | Parse our arguments. | [
"Parse",
"our",
"arguments",
"."
] | 05e9c00dfaa938b9c4ee2aadc6206f5e0918e24e | https://github.com/ellethee/argparseinator/blob/05e9c00dfaa938b9c4ee2aadc6206f5e0918e24e/argparseinator/__init__.py#L318-L362 | train |
ellethee/argparseinator | argparseinator/__init__.py | ArgParseInator.check_auth | def check_auth(self, name):
"""
Check the authorization for the command
"""
if name in self.auths:
# if the command name is in the **need authorization list**
# get the authorization for the command
auth = self.auths[name]
if self.args.auth... | python | def check_auth(self, name):
"""
Check the authorization for the command
"""
if name in self.auths:
# if the command name is in the **need authorization list**
# get the authorization for the command
auth = self.auths[name]
if self.args.auth... | [
"def",
"check_auth",
"(",
"self",
",",
"name",
")",
":",
"if",
"name",
"in",
"self",
".",
"auths",
":",
"auth",
"=",
"self",
".",
"auths",
"[",
"name",
"]",
"if",
"self",
".",
"args",
".",
"auth",
"is",
"None",
":",
"raise",
"exceptions",
".",
"A... | Check the authorization for the command | [
"Check",
"the",
"authorization",
"for",
"the",
"command"
] | 05e9c00dfaa938b9c4ee2aadc6206f5e0918e24e | https://github.com/ellethee/argparseinator/blob/05e9c00dfaa938b9c4ee2aadc6206f5e0918e24e/argparseinator/__init__.py#L364-L380 | train |
ellethee/argparseinator | argparseinator/__init__.py | ArgParseInator.check_command | def check_command(self, **new_attributes):
"""
Check if 'was passed a valid action in the command line and if so,
executes it by passing parameters and returning the result.
:return: (Any) Return the result of the called function, if provided,
or None.
"""
... | python | def check_command(self, **new_attributes):
"""
Check if 'was passed a valid action in the command line and if so,
executes it by passing parameters and returning the result.
:return: (Any) Return the result of the called function, if provided,
or None.
"""
... | [
"def",
"check_command",
"(",
"self",
",",
"**",
"new_attributes",
")",
":",
"if",
"not",
"self",
".",
"_is_parsed",
":",
"self",
".",
"parse_args",
"(",
")",
"if",
"not",
"self",
".",
"commands",
":",
"raise",
"exceptions",
".",
"ArgParseInatorNoCommandsFoun... | Check if 'was passed a valid action in the command line and if so,
executes it by passing parameters and returning the result.
:return: (Any) Return the result of the called function, if provided,
or None. | [
"Check",
"if",
"was",
"passed",
"a",
"valid",
"action",
"in",
"the",
"command",
"line",
"and",
"if",
"so",
"executes",
"it",
"by",
"passing",
"parameters",
"and",
"returning",
"the",
"result",
"."
] | 05e9c00dfaa938b9c4ee2aadc6206f5e0918e24e | https://github.com/ellethee/argparseinator/blob/05e9c00dfaa938b9c4ee2aadc6206f5e0918e24e/argparseinator/__init__.py#L382-L417 | train |
ellethee/argparseinator | argparseinator/__init__.py | ArgParseInator._call_event | def _call_event(self, event_name, cmd, pargs, kwargs, **kws):
"""
Try to call events for cmd.
"""
def get_result_params(res):
"""return the right list of params"""
if not isinstance(res, (list, tuple)):
return res, pargs, kwargs
elif le... | python | def _call_event(self, event_name, cmd, pargs, kwargs, **kws):
"""
Try to call events for cmd.
"""
def get_result_params(res):
"""return the right list of params"""
if not isinstance(res, (list, tuple)):
return res, pargs, kwargs
elif le... | [
"def",
"_call_event",
"(",
"self",
",",
"event_name",
",",
"cmd",
",",
"pargs",
",",
"kwargs",
",",
"**",
"kws",
")",
":",
"def",
"get_result_params",
"(",
"res",
")",
":",
"if",
"not",
"isinstance",
"(",
"res",
",",
"(",
"list",
",",
"tuple",
")",
... | Try to call events for cmd. | [
"Try",
"to",
"call",
"events",
"for",
"cmd",
"."
] | 05e9c00dfaa938b9c4ee2aadc6206f5e0918e24e | https://github.com/ellethee/argparseinator/blob/05e9c00dfaa938b9c4ee2aadc6206f5e0918e24e/argparseinator/__init__.py#L531-L550 | train |
ellethee/argparseinator | argparseinator/__init__.py | ArgParseInator._self_event | def _self_event(self, event_name, cmd, *pargs, **kwargs):
"""Call self event"""
if hasattr(self, event_name):
getattr(self, event_name)(cmd, *pargs, **kwargs) | python | def _self_event(self, event_name, cmd, *pargs, **kwargs):
"""Call self event"""
if hasattr(self, event_name):
getattr(self, event_name)(cmd, *pargs, **kwargs) | [
"def",
"_self_event",
"(",
"self",
",",
"event_name",
",",
"cmd",
",",
"*",
"pargs",
",",
"**",
"kwargs",
")",
":",
"if",
"hasattr",
"(",
"self",
",",
"event_name",
")",
":",
"getattr",
"(",
"self",
",",
"event_name",
")",
"(",
"cmd",
",",
"*",
"pa... | Call self event | [
"Call",
"self",
"event"
] | 05e9c00dfaa938b9c4ee2aadc6206f5e0918e24e | https://github.com/ellethee/argparseinator/blob/05e9c00dfaa938b9c4ee2aadc6206f5e0918e24e/argparseinator/__init__.py#L552-L555 | train |
ellethee/argparseinator | argparseinator/__init__.py | ArgParseInator.write | def write(self, *string):
"""
Writes to the output
"""
self._output.write(' '.join([six.text_type(s) for s in string]))
return self | python | def write(self, *string):
"""
Writes to the output
"""
self._output.write(' '.join([six.text_type(s) for s in string]))
return self | [
"def",
"write",
"(",
"self",
",",
"*",
"string",
")",
":",
"self",
".",
"_output",
".",
"write",
"(",
"' '",
".",
"join",
"(",
"[",
"six",
".",
"text_type",
"(",
"s",
")",
"for",
"s",
"in",
"string",
"]",
")",
")",
"return",
"self"
] | Writes to the output | [
"Writes",
"to",
"the",
"output"
] | 05e9c00dfaa938b9c4ee2aadc6206f5e0918e24e | https://github.com/ellethee/argparseinator/blob/05e9c00dfaa938b9c4ee2aadc6206f5e0918e24e/argparseinator/__init__.py#L565-L570 | train |
ellethee/argparseinator | argparseinator/__init__.py | ArgParseInator.exit | def exit(self, status=EXIT_OK, message=None):
"""
Terminate the script.
"""
if not self.parser:
self.parser = argparse.ArgumentParser()
if self.msg_on_error_only:
# if msg_on_error_only is True
if status != EXIT_OK:
# if we have... | python | def exit(self, status=EXIT_OK, message=None):
"""
Terminate the script.
"""
if not self.parser:
self.parser = argparse.ArgumentParser()
if self.msg_on_error_only:
# if msg_on_error_only is True
if status != EXIT_OK:
# if we have... | [
"def",
"exit",
"(",
"self",
",",
"status",
"=",
"EXIT_OK",
",",
"message",
"=",
"None",
")",
":",
"if",
"not",
"self",
".",
"parser",
":",
"self",
".",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
")",
"if",
"self",
".",
"msg_on_error_only",
... | Terminate the script. | [
"Terminate",
"the",
"script",
"."
] | 05e9c00dfaa938b9c4ee2aadc6206f5e0918e24e | https://github.com/ellethee/argparseinator/blob/05e9c00dfaa938b9c4ee2aadc6206f5e0918e24e/argparseinator/__init__.py#L580-L597 | train |
ldomic/lintools | lintools/analysis/sasa.py | SASA.analyse_ligand_sasa | def analyse_ligand_sasa(self):
"""Analysis of ligand SASA."""
i=0
start = timer()
if self.trajectory == []:
self.trajectory = [self.topology_data.universe.filename]
try:
for traj in self.trajectory:
new_traj = mdtraj.load(traj,top=self.topology_data.universe.filename)
#Analyse only non-H ligand
... | python | def analyse_ligand_sasa(self):
"""Analysis of ligand SASA."""
i=0
start = timer()
if self.trajectory == []:
self.trajectory = [self.topology_data.universe.filename]
try:
for traj in self.trajectory:
new_traj = mdtraj.load(traj,top=self.topology_data.universe.filename)
#Analyse only non-H ligand
... | [
"def",
"analyse_ligand_sasa",
"(",
"self",
")",
":",
"i",
"=",
"0",
"start",
"=",
"timer",
"(",
")",
"if",
"self",
".",
"trajectory",
"==",
"[",
"]",
":",
"self",
".",
"trajectory",
"=",
"[",
"self",
".",
"topology_data",
".",
"universe",
".",
"filen... | Analysis of ligand SASA. | [
"Analysis",
"of",
"ligand",
"SASA",
"."
] | d825a4a7b35f3f857d3b81b46c9aee72b0ec697a | https://github.com/ldomic/lintools/blob/d825a4a7b35f3f857d3b81b46c9aee72b0ec697a/lintools/analysis/sasa.py#L23-L43 | train |
ldomic/lintools | lintools/analysis/sasa.py | SASA.assign_per_atom_sasa | def assign_per_atom_sasa(self):
"""Make a dictionary with SASA assigned to each ligand atom, stored as list of SASA values over
the simulation time."""
atom_names= [atom.name for atom in self.topology_data.universe.ligand_noH.atoms]
sasa_dict = {}
for atom in range(0,self.topology_data.universe.ligand_noH.n_a... | python | def assign_per_atom_sasa(self):
"""Make a dictionary with SASA assigned to each ligand atom, stored as list of SASA values over
the simulation time."""
atom_names= [atom.name for atom in self.topology_data.universe.ligand_noH.atoms]
sasa_dict = {}
for atom in range(0,self.topology_data.universe.ligand_noH.n_a... | [
"def",
"assign_per_atom_sasa",
"(",
"self",
")",
":",
"atom_names",
"=",
"[",
"atom",
".",
"name",
"for",
"atom",
"in",
"self",
".",
"topology_data",
".",
"universe",
".",
"ligand_noH",
".",
"atoms",
"]",
"sasa_dict",
"=",
"{",
"}",
"for",
"atom",
"in",
... | Make a dictionary with SASA assigned to each ligand atom, stored as list of SASA values over
the simulation time. | [
"Make",
"a",
"dictionary",
"with",
"SASA",
"assigned",
"to",
"each",
"ligand",
"atom",
"stored",
"as",
"list",
"of",
"SASA",
"values",
"over",
"the",
"simulation",
"time",
"."
] | d825a4a7b35f3f857d3b81b46c9aee72b0ec697a | https://github.com/ldomic/lintools/blob/d825a4a7b35f3f857d3b81b46c9aee72b0ec697a/lintools/analysis/sasa.py#L46-L53 | train |
ldomic/lintools | lintools/analysis/sasa.py | SASA.get_total_per_atom_sasa | def get_total_per_atom_sasa(self):
"""Return average SASA of the atoms."""
total_sasa = defaultdict(int)
for traj in range(len(self.atom_sasa)):
for atom in self.atom_sasa[traj]:
total_sasa[atom]+=float(sum((self.atom_sasa[traj][atom])))/len(self.atom_sasa[traj][atom])
for atom in total_sasa:
total_sa... | python | def get_total_per_atom_sasa(self):
"""Return average SASA of the atoms."""
total_sasa = defaultdict(int)
for traj in range(len(self.atom_sasa)):
for atom in self.atom_sasa[traj]:
total_sasa[atom]+=float(sum((self.atom_sasa[traj][atom])))/len(self.atom_sasa[traj][atom])
for atom in total_sasa:
total_sa... | [
"def",
"get_total_per_atom_sasa",
"(",
"self",
")",
":",
"total_sasa",
"=",
"defaultdict",
"(",
"int",
")",
"for",
"traj",
"in",
"range",
"(",
"len",
"(",
"self",
".",
"atom_sasa",
")",
")",
":",
"for",
"atom",
"in",
"self",
".",
"atom_sasa",
"[",
"tra... | Return average SASA of the atoms. | [
"Return",
"average",
"SASA",
"of",
"the",
"atoms",
"."
] | d825a4a7b35f3f857d3b81b46c9aee72b0ec697a | https://github.com/ldomic/lintools/blob/d825a4a7b35f3f857d3b81b46c9aee72b0ec697a/lintools/analysis/sasa.py#L55-L63 | train |
thautwarm/Redy | Redy/Async/Accompany.py | Accompany.run | def run(self, *args):
"""
You can choose whether to use lock method when running threads.
"""
if self.running:
return self
self._mut_finished(False) # in case of recovery from a disaster.
self._mut_running(True)
stream = self.target(*args)
... | python | def run(self, *args):
"""
You can choose whether to use lock method when running threads.
"""
if self.running:
return self
self._mut_finished(False) # in case of recovery from a disaster.
self._mut_running(True)
stream = self.target(*args)
... | [
"def",
"run",
"(",
"self",
",",
"*",
"args",
")",
":",
"if",
"self",
".",
"running",
":",
"return",
"self",
"self",
".",
"_mut_finished",
"(",
"False",
")",
"self",
".",
"_mut_running",
"(",
"True",
")",
"stream",
"=",
"self",
".",
"target",
"(",
"... | You can choose whether to use lock method when running threads. | [
"You",
"can",
"choose",
"whether",
"to",
"use",
"lock",
"method",
"when",
"running",
"threads",
"."
] | 8beee5c5f752edfd2754bb1e6b5f4acb016a7770 | https://github.com/thautwarm/Redy/blob/8beee5c5f752edfd2754bb1e6b5f4acb016a7770/Redy/Async/Accompany.py#L114-L144 | train |
robinandeer/puzzle | puzzle/plugins/gemini/mixins/variant_extras/consequences.py | ConsequenceExtras._add_consequences | def _add_consequences(self, variant_obj):
"""Add the consequences found in all transcripts
Args:
variant_obj (puzzle.models.Variant)
"""
consequences = set()
for transcript in variant_obj.transcripts:
for consequence in transcript.consequence.split('&'):... | python | def _add_consequences(self, variant_obj):
"""Add the consequences found in all transcripts
Args:
variant_obj (puzzle.models.Variant)
"""
consequences = set()
for transcript in variant_obj.transcripts:
for consequence in transcript.consequence.split('&'):... | [
"def",
"_add_consequences",
"(",
"self",
",",
"variant_obj",
")",
":",
"consequences",
"=",
"set",
"(",
")",
"for",
"transcript",
"in",
"variant_obj",
".",
"transcripts",
":",
"for",
"consequence",
"in",
"transcript",
".",
"consequence",
".",
"split",
"(",
"... | Add the consequences found in all transcripts
Args:
variant_obj (puzzle.models.Variant) | [
"Add",
"the",
"consequences",
"found",
"in",
"all",
"transcripts"
] | 9476f05b416d3a5135d25492cb31411fdf831c58 | https://github.com/robinandeer/puzzle/blob/9476f05b416d3a5135d25492cb31411fdf831c58/puzzle/plugins/gemini/mixins/variant_extras/consequences.py#L8-L20 | train |
robinandeer/puzzle | puzzle/plugins/vcf/mixins/variant_extras/genes.py | GeneExtras._add_hgnc_symbols | def _add_hgnc_symbols(self, variant_obj):
"""Add hgnc symbols to the variant
If there are transcripts use the symbols found here,
otherwise use phizz to get the gene ids.
"""
hgnc_symbols = set()
if variant_obj.transcripts:
for transcript in v... | python | def _add_hgnc_symbols(self, variant_obj):
"""Add hgnc symbols to the variant
If there are transcripts use the symbols found here,
otherwise use phizz to get the gene ids.
"""
hgnc_symbols = set()
if variant_obj.transcripts:
for transcript in v... | [
"def",
"_add_hgnc_symbols",
"(",
"self",
",",
"variant_obj",
")",
":",
"hgnc_symbols",
"=",
"set",
"(",
")",
"if",
"variant_obj",
".",
"transcripts",
":",
"for",
"transcript",
"in",
"variant_obj",
".",
"transcripts",
":",
"if",
"transcript",
".",
"hgnc_symbol"... | Add hgnc symbols to the variant
If there are transcripts use the symbols found here,
otherwise use phizz to get the gene ids. | [
"Add",
"hgnc",
"symbols",
"to",
"the",
"variant",
"If",
"there",
"are",
"transcripts",
"use",
"the",
"symbols",
"found",
"here",
"otherwise",
"use",
"phizz",
"to",
"get",
"the",
"gene",
"ids",
"."
] | 9476f05b416d3a5135d25492cb31411fdf831c58 | https://github.com/robinandeer/puzzle/blob/9476f05b416d3a5135d25492cb31411fdf831c58/puzzle/plugins/vcf/mixins/variant_extras/genes.py#L7-L25 | train |
robinandeer/puzzle | puzzle/plugins/vcf/mixins/variant_extras/genes.py | GeneExtras._add_genes | def _add_genes(self, variant_obj):
"""Add the Gene objects for a variant"""
genes = []
ensembl_ids = []
hgnc_symbols = []
if variant_obj.transcripts:
for transcript in variant_obj.transcripts:
if transcript.ensembl_id:
ense... | python | def _add_genes(self, variant_obj):
"""Add the Gene objects for a variant"""
genes = []
ensembl_ids = []
hgnc_symbols = []
if variant_obj.transcripts:
for transcript in variant_obj.transcripts:
if transcript.ensembl_id:
ense... | [
"def",
"_add_genes",
"(",
"self",
",",
"variant_obj",
")",
":",
"genes",
"=",
"[",
"]",
"ensembl_ids",
"=",
"[",
"]",
"hgnc_symbols",
"=",
"[",
"]",
"if",
"variant_obj",
".",
"transcripts",
":",
"for",
"transcript",
"in",
"variant_obj",
".",
"transcripts",... | Add the Gene objects for a variant | [
"Add",
"the",
"Gene",
"objects",
"for",
"a",
"variant"
] | 9476f05b416d3a5135d25492cb31411fdf831c58 | https://github.com/robinandeer/puzzle/blob/9476f05b416d3a5135d25492cb31411fdf831c58/puzzle/plugins/vcf/mixins/variant_extras/genes.py#L27-L49 | train |
eleme/meepo | meepo/apps/eventsourcing/prepare_commit.py | _redis_strict_pc | def _redis_strict_pc(func):
"""Strict deco for RedisPrepareCommit
The deco will choose whether to silent exception or not based on the
strict attr in RedisPrepareCommit object.
"""
phase = "session_%s" % func.__name__
@functools.wraps(func)
def wrapper(self, session, *args, **kwargs):
... | python | def _redis_strict_pc(func):
"""Strict deco for RedisPrepareCommit
The deco will choose whether to silent exception or not based on the
strict attr in RedisPrepareCommit object.
"""
phase = "session_%s" % func.__name__
@functools.wraps(func)
def wrapper(self, session, *args, **kwargs):
... | [
"def",
"_redis_strict_pc",
"(",
"func",
")",
":",
"phase",
"=",
"\"session_%s\"",
"%",
"func",
".",
"__name__",
"@",
"functools",
".",
"wraps",
"(",
"func",
")",
"def",
"wrapper",
"(",
"self",
",",
"session",
",",
"*",
"args",
",",
"**",
"kwargs",
")",... | Strict deco for RedisPrepareCommit
The deco will choose whether to silent exception or not based on the
strict attr in RedisPrepareCommit object. | [
"Strict",
"deco",
"for",
"RedisPrepareCommit"
] | 8212f0fe9b1d44be0c5de72d221a31c1d24bfe7a | https://github.com/eleme/meepo/blob/8212f0fe9b1d44be0c5de72d221a31c1d24bfe7a/meepo/apps/eventsourcing/prepare_commit.py#L45-L68 | train |
eleme/meepo | meepo/apps/eventsourcing/prepare_commit.py | RedisPrepareCommit.phase | def phase(self, session):
"""Determine the session phase in prepare commit.
:param session: sqlalchemy session
:return: phase "prepare" or "commit"
"""
sp_key, _ = self._keygen(session)
if self.r.sismember(sp_key, session.meepo_unique_id):
return "prepare"
... | python | def phase(self, session):
"""Determine the session phase in prepare commit.
:param session: sqlalchemy session
:return: phase "prepare" or "commit"
"""
sp_key, _ = self._keygen(session)
if self.r.sismember(sp_key, session.meepo_unique_id):
return "prepare"
... | [
"def",
"phase",
"(",
"self",
",",
"session",
")",
":",
"sp_key",
",",
"_",
"=",
"self",
".",
"_keygen",
"(",
"session",
")",
"if",
"self",
".",
"r",
".",
"sismember",
"(",
"sp_key",
",",
"session",
".",
"meepo_unique_id",
")",
":",
"return",
"\"prepa... | Determine the session phase in prepare commit.
:param session: sqlalchemy session
:return: phase "prepare" or "commit" | [
"Determine",
"the",
"session",
"phase",
"in",
"prepare",
"commit",
"."
] | 8212f0fe9b1d44be0c5de72d221a31c1d24bfe7a | https://github.com/eleme/meepo/blob/8212f0fe9b1d44be0c5de72d221a31c1d24bfe7a/meepo/apps/eventsourcing/prepare_commit.py#L113-L123 | train |
eleme/meepo | meepo/apps/eventsourcing/prepare_commit.py | RedisPrepareCommit.prepare | def prepare(self, session, event):
"""Prepare phase for session.
:param session: sqlalchemy session
"""
if not event:
self.logger.warn("event empty!")
return
sp_key, sp_hkey = self._keygen(session)
def _pk(obj):
pk_values = tuple(get... | python | def prepare(self, session, event):
"""Prepare phase for session.
:param session: sqlalchemy session
"""
if not event:
self.logger.warn("event empty!")
return
sp_key, sp_hkey = self._keygen(session)
def _pk(obj):
pk_values = tuple(get... | [
"def",
"prepare",
"(",
"self",
",",
"session",
",",
"event",
")",
":",
"if",
"not",
"event",
":",
"self",
".",
"logger",
".",
"warn",
"(",
"\"event empty!\"",
")",
"return",
"sp_key",
",",
"sp_hkey",
"=",
"self",
".",
"_keygen",
"(",
"session",
")",
... | Prepare phase for session.
:param session: sqlalchemy session | [
"Prepare",
"phase",
"for",
"session",
"."
] | 8212f0fe9b1d44be0c5de72d221a31c1d24bfe7a | https://github.com/eleme/meepo/blob/8212f0fe9b1d44be0c5de72d221a31c1d24bfe7a/meepo/apps/eventsourcing/prepare_commit.py#L126-L154 | train |
eleme/meepo | meepo/apps/eventsourcing/prepare_commit.py | RedisPrepareCommit.commit | def commit(self, session):
"""Commit phase for session.
:param session: sqlalchemy session
"""
sp_key, sp_hkey = self._keygen(session)
with self.r.pipeline(transaction=False) as p:
p.srem(sp_key, session.meepo_unique_id)
p.expire(sp_hkey, 60 * 60)
... | python | def commit(self, session):
"""Commit phase for session.
:param session: sqlalchemy session
"""
sp_key, sp_hkey = self._keygen(session)
with self.r.pipeline(transaction=False) as p:
p.srem(sp_key, session.meepo_unique_id)
p.expire(sp_hkey, 60 * 60)
... | [
"def",
"commit",
"(",
"self",
",",
"session",
")",
":",
"sp_key",
",",
"sp_hkey",
"=",
"self",
".",
"_keygen",
"(",
"session",
")",
"with",
"self",
".",
"r",
".",
"pipeline",
"(",
"transaction",
"=",
"False",
")",
"as",
"p",
":",
"p",
".",
"srem",
... | Commit phase for session.
:param session: sqlalchemy session | [
"Commit",
"phase",
"for",
"session",
"."
] | 8212f0fe9b1d44be0c5de72d221a31c1d24bfe7a | https://github.com/eleme/meepo/blob/8212f0fe9b1d44be0c5de72d221a31c1d24bfe7a/meepo/apps/eventsourcing/prepare_commit.py#L157-L166 | train |
eleme/meepo | meepo/apps/eventsourcing/prepare_commit.py | RedisPrepareCommit.clear | def clear(self, ts=None):
"""Clear all session in prepare phase.
:param ts: timestamp used locate the namespace
"""
sp_key = "%s:session_prepare" % self.namespace(ts or int(time.time()))
return self.r.delete(sp_key) | python | def clear(self, ts=None):
"""Clear all session in prepare phase.
:param ts: timestamp used locate the namespace
"""
sp_key = "%s:session_prepare" % self.namespace(ts or int(time.time()))
return self.r.delete(sp_key) | [
"def",
"clear",
"(",
"self",
",",
"ts",
"=",
"None",
")",
":",
"sp_key",
"=",
"\"%s:session_prepare\"",
"%",
"self",
".",
"namespace",
"(",
"ts",
"or",
"int",
"(",
"time",
".",
"time",
"(",
")",
")",
")",
"return",
"self",
".",
"r",
".",
"delete",
... | Clear all session in prepare phase.
:param ts: timestamp used locate the namespace | [
"Clear",
"all",
"session",
"in",
"prepare",
"phase",
"."
] | 8212f0fe9b1d44be0c5de72d221a31c1d24bfe7a | https://github.com/eleme/meepo/blob/8212f0fe9b1d44be0c5de72d221a31c1d24bfe7a/meepo/apps/eventsourcing/prepare_commit.py#L190-L196 | train |
robinandeer/puzzle | puzzle/cli/cases.py | cases | def cases(ctx, root):
"""
Show all cases in the database.
If no database was found run puzzle init first.
"""
root = root or ctx.obj.get('root') or os.path.expanduser("~/.puzzle")
if os.path.isfile(root):
logger.error("'root' can't be a file")
ctx.abort()
logger.info("Root... | python | def cases(ctx, root):
"""
Show all cases in the database.
If no database was found run puzzle init first.
"""
root = root or ctx.obj.get('root') or os.path.expanduser("~/.puzzle")
if os.path.isfile(root):
logger.error("'root' can't be a file")
ctx.abort()
logger.info("Root... | [
"def",
"cases",
"(",
"ctx",
",",
"root",
")",
":",
"root",
"=",
"root",
"or",
"ctx",
".",
"obj",
".",
"get",
"(",
"'root'",
")",
"or",
"os",
".",
"path",
".",
"expanduser",
"(",
"\"~/.puzzle\"",
")",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
... | Show all cases in the database.
If no database was found run puzzle init first. | [
"Show",
"all",
"cases",
"in",
"the",
"database",
"."
] | 9476f05b416d3a5135d25492cb31411fdf831c58 | https://github.com/robinandeer/puzzle/blob/9476f05b416d3a5135d25492cb31411fdf831c58/puzzle/cli/cases.py#L16-L39 | train |
ellethee/argparseinator | argparseinator/__main__.py | init | def init(name, subnames, dest, skeleton, description, project_type, skip_core):
"""Creates a standalone, subprojects or submodules script sctrucure"""
dest = dest or CUR_DIR
skeleton = join(skeleton or SKEL_PATH, project_type)
project = join(dest, name)
script = join(project, name + '.py')
core ... | python | def init(name, subnames, dest, skeleton, description, project_type, skip_core):
"""Creates a standalone, subprojects or submodules script sctrucure"""
dest = dest or CUR_DIR
skeleton = join(skeleton or SKEL_PATH, project_type)
project = join(dest, name)
script = join(project, name + '.py')
core ... | [
"def",
"init",
"(",
"name",
",",
"subnames",
",",
"dest",
",",
"skeleton",
",",
"description",
",",
"project_type",
",",
"skip_core",
")",
":",
"dest",
"=",
"dest",
"or",
"CUR_DIR",
"skeleton",
"=",
"join",
"(",
"skeleton",
"or",
"SKEL_PATH",
",",
"proje... | Creates a standalone, subprojects or submodules script sctrucure | [
"Creates",
"a",
"standalone",
"subprojects",
"or",
"submodules",
"script",
"sctrucure"
] | 05e9c00dfaa938b9c4ee2aadc6206f5e0918e24e | https://github.com/ellethee/argparseinator/blob/05e9c00dfaa938b9c4ee2aadc6206f5e0918e24e/argparseinator/__main__.py#L115-L145 | train |
jwodder/javaproperties | javaproperties/propfile.py | PropertiesFile._check | def _check(self):
"""
Assert the internal consistency of the instance's data structures.
This method is for debugging only.
"""
for k,ix in six.iteritems(self._indices):
assert k is not None, 'null key'
assert ix, 'Key does not map to any indices'
... | python | def _check(self):
"""
Assert the internal consistency of the instance's data structures.
This method is for debugging only.
"""
for k,ix in six.iteritems(self._indices):
assert k is not None, 'null key'
assert ix, 'Key does not map to any indices'
... | [
"def",
"_check",
"(",
"self",
")",
":",
"for",
"k",
",",
"ix",
"in",
"six",
".",
"iteritems",
"(",
"self",
".",
"_indices",
")",
":",
"assert",
"k",
"is",
"not",
"None",
",",
"'null key'",
"assert",
"ix",
",",
"'Key does not map to any indices'",
"assert... | Assert the internal consistency of the instance's data structures.
This method is for debugging only. | [
"Assert",
"the",
"internal",
"consistency",
"of",
"the",
"instance",
"s",
"data",
"structures",
".",
"This",
"method",
"is",
"for",
"debugging",
"only",
"."
] | 8b48f040305217ebeb80c98c4354691bbb01429b | https://github.com/jwodder/javaproperties/blob/8b48f040305217ebeb80c98c4354691bbb01429b/javaproperties/propfile.py#L64-L93 | train |
jwodder/javaproperties | javaproperties/propfile.py | PropertiesFile.load | def load(cls, fp):
"""
Parse the contents of the `~io.IOBase.readline`-supporting file-like
object ``fp`` as a simple line-oriented ``.properties`` file and return
a `PropertiesFile` instance.
``fp`` may be either a text or binary filehandle, with or without
universal ne... | python | def load(cls, fp):
"""
Parse the contents of the `~io.IOBase.readline`-supporting file-like
object ``fp`` as a simple line-oriented ``.properties`` file and return
a `PropertiesFile` instance.
``fp`` may be either a text or binary filehandle, with or without
universal ne... | [
"def",
"load",
"(",
"cls",
",",
"fp",
")",
":",
"obj",
"=",
"cls",
"(",
")",
"for",
"i",
",",
"(",
"k",
",",
"v",
",",
"src",
")",
"in",
"enumerate",
"(",
"parse",
"(",
"fp",
")",
")",
":",
"if",
"k",
"is",
"not",
"None",
":",
"obj",
".",... | Parse the contents of the `~io.IOBase.readline`-supporting file-like
object ``fp`` as a simple line-oriented ``.properties`` file and return
a `PropertiesFile` instance.
``fp`` may be either a text or binary filehandle, with or without
universal newlines enabled. If it is a binary file... | [
"Parse",
"the",
"contents",
"of",
"the",
"~io",
".",
"IOBase",
".",
"readline",
"-",
"supporting",
"file",
"-",
"like",
"object",
"fp",
"as",
"a",
"simple",
"line",
"-",
"oriented",
".",
"properties",
"file",
"and",
"return",
"a",
"PropertiesFile",
"instan... | 8b48f040305217ebeb80c98c4354691bbb01429b | https://github.com/jwodder/javaproperties/blob/8b48f040305217ebeb80c98c4354691bbb01429b/javaproperties/propfile.py#L170-L195 | train |
jwodder/javaproperties | javaproperties/propfile.py | PropertiesFile.loads | def loads(cls, s):
"""
Parse the contents of the string ``s`` as a simple line-oriented
``.properties`` file and return a `PropertiesFile` instance.
``s`` may be either a text string or bytes string. If it is a bytes
string, its contents are decoded as Latin-1.
.. vers... | python | def loads(cls, s):
"""
Parse the contents of the string ``s`` as a simple line-oriented
``.properties`` file and return a `PropertiesFile` instance.
``s`` may be either a text string or bytes string. If it is a bytes
string, its contents are decoded as Latin-1.
.. vers... | [
"def",
"loads",
"(",
"cls",
",",
"s",
")",
":",
"if",
"isinstance",
"(",
"s",
",",
"six",
".",
"binary_type",
")",
":",
"fp",
"=",
"six",
".",
"BytesIO",
"(",
"s",
")",
"else",
":",
"fp",
"=",
"six",
".",
"StringIO",
"(",
"s",
")",
"return",
... | Parse the contents of the string ``s`` as a simple line-oriented
``.properties`` file and return a `PropertiesFile` instance.
``s`` may be either a text string or bytes string. If it is a bytes
string, its contents are decoded as Latin-1.
.. versionchanged:: 0.5.0
Invalid ... | [
"Parse",
"the",
"contents",
"of",
"the",
"string",
"s",
"as",
"a",
"simple",
"line",
"-",
"oriented",
".",
"properties",
"file",
"and",
"return",
"a",
"PropertiesFile",
"instance",
"."
] | 8b48f040305217ebeb80c98c4354691bbb01429b | https://github.com/jwodder/javaproperties/blob/8b48f040305217ebeb80c98c4354691bbb01429b/javaproperties/propfile.py#L198-L220 | train |
jwodder/javaproperties | javaproperties/propfile.py | PropertiesFile.dump | def dump(self, fp, separator='='):
"""
Write the mapping to a file in simple line-oriented ``.properties``
format.
If the instance was originally created from a file or string with
`PropertiesFile.load()` or `PropertiesFile.loads()`, then the output
will include the comm... | python | def dump(self, fp, separator='='):
"""
Write the mapping to a file in simple line-oriented ``.properties``
format.
If the instance was originally created from a file or string with
`PropertiesFile.load()` or `PropertiesFile.loads()`, then the output
will include the comm... | [
"def",
"dump",
"(",
"self",
",",
"fp",
",",
"separator",
"=",
"'='",
")",
":",
"for",
"line",
"in",
"six",
".",
"itervalues",
"(",
"self",
".",
"_lines",
")",
":",
"if",
"line",
".",
"source",
"is",
"None",
":",
"print",
"(",
"join_key_value",
"(",... | Write the mapping to a file in simple line-oriented ``.properties``
format.
If the instance was originally created from a file or string with
`PropertiesFile.load()` or `PropertiesFile.loads()`, then the output
will include the comments and whitespace from the original input, and
... | [
"Write",
"the",
"mapping",
"to",
"a",
"file",
"in",
"simple",
"line",
"-",
"oriented",
".",
"properties",
"format",
"."
] | 8b48f040305217ebeb80c98c4354691bbb01429b | https://github.com/jwodder/javaproperties/blob/8b48f040305217ebeb80c98c4354691bbb01429b/javaproperties/propfile.py#L222-L256 | train |
jwodder/javaproperties | javaproperties/propfile.py | PropertiesFile.dumps | def dumps(self, separator='='):
"""
Convert the mapping to a text string in simple line-oriented
``.properties`` format.
If the instance was originally created from a file or string with
`PropertiesFile.load()` or `PropertiesFile.loads()`, then the output
will include th... | python | def dumps(self, separator='='):
"""
Convert the mapping to a text string in simple line-oriented
``.properties`` format.
If the instance was originally created from a file or string with
`PropertiesFile.load()` or `PropertiesFile.loads()`, then the output
will include th... | [
"def",
"dumps",
"(",
"self",
",",
"separator",
"=",
"'='",
")",
":",
"s",
"=",
"six",
".",
"StringIO",
"(",
")",
"self",
".",
"dump",
"(",
"s",
",",
"separator",
"=",
"separator",
")",
"return",
"s",
".",
"getvalue",
"(",
")"
] | Convert the mapping to a text string in simple line-oriented
``.properties`` format.
If the instance was originally created from a file or string with
`PropertiesFile.load()` or `PropertiesFile.loads()`, then the output
will include the comments and whitespace from the original input, a... | [
"Convert",
"the",
"mapping",
"to",
"a",
"text",
"string",
"in",
"simple",
"line",
"-",
"oriented",
".",
"properties",
"format",
"."
] | 8b48f040305217ebeb80c98c4354691bbb01429b | https://github.com/jwodder/javaproperties/blob/8b48f040305217ebeb80c98c4354691bbb01429b/javaproperties/propfile.py#L258-L287 | train |
jwodder/javaproperties | javaproperties/propfile.py | PropertiesFile.copy | def copy(self):
""" Create a copy of the mapping, including formatting information """
dup = type(self)()
dup._indices = OrderedDict(
(k, list(v)) for k,v in six.iteritems(self._indices)
)
dup._lines = self._lines.copy()
return dup | python | def copy(self):
""" Create a copy of the mapping, including formatting information """
dup = type(self)()
dup._indices = OrderedDict(
(k, list(v)) for k,v in six.iteritems(self._indices)
)
dup._lines = self._lines.copy()
return dup | [
"def",
"copy",
"(",
"self",
")",
":",
"dup",
"=",
"type",
"(",
"self",
")",
"(",
")",
"dup",
".",
"_indices",
"=",
"OrderedDict",
"(",
"(",
"k",
",",
"list",
"(",
"v",
")",
")",
"for",
"k",
",",
"v",
"in",
"six",
".",
"iteritems",
"(",
"self"... | Create a copy of the mapping, including formatting information | [
"Create",
"a",
"copy",
"of",
"the",
"mapping",
"including",
"formatting",
"information"
] | 8b48f040305217ebeb80c98c4354691bbb01429b | https://github.com/jwodder/javaproperties/blob/8b48f040305217ebeb80c98c4354691bbb01429b/javaproperties/propfile.py#L289-L296 | train |
ldomic/lintools | lintools/analysis/maths_functions.py | prepare_normal_vectors | def prepare_normal_vectors(atomselection):
"""Create and normalize a vector across ring plane."""
ring_atomselection = [atomselection.coordinates()[a] for a in [0,2,4]]
vect1 = self.vector(ring_atomselection[0],ring_atomselection[1])
vect2 = self.vector(ring_atomselection[2],ring_atomselection[0])
r... | python | def prepare_normal_vectors(atomselection):
"""Create and normalize a vector across ring plane."""
ring_atomselection = [atomselection.coordinates()[a] for a in [0,2,4]]
vect1 = self.vector(ring_atomselection[0],ring_atomselection[1])
vect2 = self.vector(ring_atomselection[2],ring_atomselection[0])
r... | [
"def",
"prepare_normal_vectors",
"(",
"atomselection",
")",
":",
"ring_atomselection",
"=",
"[",
"atomselection",
".",
"coordinates",
"(",
")",
"[",
"a",
"]",
"for",
"a",
"in",
"[",
"0",
",",
"2",
",",
"4",
"]",
"]",
"vect1",
"=",
"self",
".",
"vector"... | Create and normalize a vector across ring plane. | [
"Create",
"and",
"normalize",
"a",
"vector",
"across",
"ring",
"plane",
"."
] | d825a4a7b35f3f857d3b81b46c9aee72b0ec697a | https://github.com/ldomic/lintools/blob/d825a4a7b35f3f857d3b81b46c9aee72b0ec697a/lintools/analysis/maths_functions.py#L3-L8 | train |
rycus86/ghost-client | ghost_client/helpers.py | refresh_session_if_necessary | def refresh_session_if_necessary(f):
"""
Decorator to use on methods that are allowed
to retry the request after reauthenticating the client.
:param f: The original function
:return: The decorated function
"""
@functools.wraps(f)
def wrapped(self, *args, **kwargs):
try:
... | python | def refresh_session_if_necessary(f):
"""
Decorator to use on methods that are allowed
to retry the request after reauthenticating the client.
:param f: The original function
:return: The decorated function
"""
@functools.wraps(f)
def wrapped(self, *args, **kwargs):
try:
... | [
"def",
"refresh_session_if_necessary",
"(",
"f",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"f",
")",
"def",
"wrapped",
"(",
"self",
",",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"try",
":",
"result",
"=",
"f",
"(",
"self",
",",
"*",
"args",... | Decorator to use on methods that are allowed
to retry the request after reauthenticating the client.
:param f: The original function
:return: The decorated function | [
"Decorator",
"to",
"use",
"on",
"methods",
"that",
"are",
"allowed",
"to",
"retry",
"the",
"request",
"after",
"reauthenticating",
"the",
"client",
"."
] | 863d332801d2c1b8e7ad4573c7b16db78a7f8c8d | https://github.com/rycus86/ghost-client/blob/863d332801d2c1b8e7ad4573c7b16db78a7f8c8d/ghost_client/helpers.py#L4-L27 | train |
robinandeer/puzzle | puzzle/utils/puzzle_database.py | init_db | def init_db(db_path):
"""Build the sqlite database"""
logger.info("Creating database")
with closing(connect_database(db_path)) as db:
with open(SCHEMA, 'r') as f:
db.cursor().executescript(f.read())
db.commit()
return | python | def init_db(db_path):
"""Build the sqlite database"""
logger.info("Creating database")
with closing(connect_database(db_path)) as db:
with open(SCHEMA, 'r') as f:
db.cursor().executescript(f.read())
db.commit()
return | [
"def",
"init_db",
"(",
"db_path",
")",
":",
"logger",
".",
"info",
"(",
"\"Creating database\"",
")",
"with",
"closing",
"(",
"connect_database",
"(",
"db_path",
")",
")",
"as",
"db",
":",
"with",
"open",
"(",
"SCHEMA",
",",
"'r'",
")",
"as",
"f",
":",... | Build the sqlite database | [
"Build",
"the",
"sqlite",
"database"
] | 9476f05b416d3a5135d25492cb31411fdf831c58 | https://github.com/robinandeer/puzzle/blob/9476f05b416d3a5135d25492cb31411fdf831c58/puzzle/utils/puzzle_database.py#L15-L22 | train |
inveniosoftware-contrib/json-merger | json_merger/merger.py | Merger.merge | def merge(self):
"""Populates result members.
Performs the merge algorithm using the specified config and fills in
the members that provide stats about the merging procedure.
Attributes:
merged_root: The result of the merge.
aligned_root, aligned_head, aligned_... | python | def merge(self):
"""Populates result members.
Performs the merge algorithm using the specified config and fills in
the members that provide stats about the merging procedure.
Attributes:
merged_root: The result of the merge.
aligned_root, aligned_head, aligned_... | [
"def",
"merge",
"(",
"self",
")",
":",
"self",
".",
"merged_root",
"=",
"self",
".",
"_recursive_merge",
"(",
"self",
".",
"root",
",",
"self",
".",
"head",
",",
"self",
".",
"update",
")",
"if",
"self",
".",
"conflicts",
":",
"raise",
"MergeError",
... | Populates result members.
Performs the merge algorithm using the specified config and fills in
the members that provide stats about the merging procedure.
Attributes:
merged_root: The result of the merge.
aligned_root, aligned_head, aligned_update: Copies of root, head... | [
"Populates",
"result",
"members",
"."
] | adc6d372da018427e1db7b92424d3471e01a4118 | https://github.com/inveniosoftware-contrib/json-merger/blob/adc6d372da018427e1db7b92424d3471e01a4118/json_merger/merger.py#L135-L224 | train |
robinandeer/puzzle | puzzle/utils/phenomizer.py | hpo_genes | def hpo_genes(phenotype_ids, username, password):
"""Return list of HGNC symbols matching HPO phenotype ids.
Args:
phenotype_ids (list): list of phenotype ids
username (str): username to connect to phenomizer
password (str): password to connect to phenomizer
Returns:
query_... | python | def hpo_genes(phenotype_ids, username, password):
"""Return list of HGNC symbols matching HPO phenotype ids.
Args:
phenotype_ids (list): list of phenotype ids
username (str): username to connect to phenomizer
password (str): password to connect to phenomizer
Returns:
query_... | [
"def",
"hpo_genes",
"(",
"phenotype_ids",
",",
"username",
",",
"password",
")",
":",
"if",
"phenotype_ids",
":",
"try",
":",
"results",
"=",
"query_phenomizer",
".",
"query",
"(",
"username",
",",
"password",
",",
"phenotype_ids",
")",
"return",
"[",
"resul... | Return list of HGNC symbols matching HPO phenotype ids.
Args:
phenotype_ids (list): list of phenotype ids
username (str): username to connect to phenomizer
password (str): password to connect to phenomizer
Returns:
query_result: a list of dictionaries on the form
{
... | [
"Return",
"list",
"of",
"HGNC",
"symbols",
"matching",
"HPO",
"phenotype",
"ids",
"."
] | 9476f05b416d3a5135d25492cb31411fdf831c58 | https://github.com/robinandeer/puzzle/blob/9476f05b416d3a5135d25492cb31411fdf831c58/puzzle/utils/phenomizer.py#L5-L34 | train |
Colorless-Green-Ideas/MaterialDjango | materialdjango/forms.py | mangle_form | def mangle_form(form):
"Utility to monkeypatch forms into paperinputs, untested"
for field, widget in form.fields.iteritems():
if type(widget) is forms.widgets.TextInput:
form.fields[field].widget = PaperTextInput()
form.fields[field].label = ''
if type(widget) is forms.w... | python | def mangle_form(form):
"Utility to monkeypatch forms into paperinputs, untested"
for field, widget in form.fields.iteritems():
if type(widget) is forms.widgets.TextInput:
form.fields[field].widget = PaperTextInput()
form.fields[field].label = ''
if type(widget) is forms.w... | [
"def",
"mangle_form",
"(",
"form",
")",
":",
"\"Utility to monkeypatch forms into paperinputs, untested\"",
"for",
"field",
",",
"widget",
"in",
"form",
".",
"fields",
".",
"iteritems",
"(",
")",
":",
"if",
"type",
"(",
"widget",
")",
"is",
"forms",
".",
"widg... | Utility to monkeypatch forms into paperinputs, untested | [
"Utility",
"to",
"monkeypatch",
"forms",
"into",
"paperinputs",
"untested"
] | e7a69e968965d25198d90318623a828cff67f5dc | https://github.com/Colorless-Green-Ideas/MaterialDjango/blob/e7a69e968965d25198d90318623a828cff67f5dc/materialdjango/forms.py#L14-L23 | train |
eleme/meepo | meepo/apps/eventsourcing/event_store.py | RedisEventStore._keygen | def _keygen(self, event, ts=None):
"""Generate redis key for event at timestamp.
:param event: event name
:param ts: timestamp, default to current timestamp if left as None
"""
return "%s:%s" % (self.namespace(ts or time.time()), event) | python | def _keygen(self, event, ts=None):
"""Generate redis key for event at timestamp.
:param event: event name
:param ts: timestamp, default to current timestamp if left as None
"""
return "%s:%s" % (self.namespace(ts or time.time()), event) | [
"def",
"_keygen",
"(",
"self",
",",
"event",
",",
"ts",
"=",
"None",
")",
":",
"return",
"\"%s:%s\"",
"%",
"(",
"self",
".",
"namespace",
"(",
"ts",
"or",
"time",
".",
"time",
"(",
")",
")",
",",
"event",
")"
] | Generate redis key for event at timestamp.
:param event: event name
:param ts: timestamp, default to current timestamp if left as None | [
"Generate",
"redis",
"key",
"for",
"event",
"at",
"timestamp",
"."
] | 8212f0fe9b1d44be0c5de72d221a31c1d24bfe7a | https://github.com/eleme/meepo/blob/8212f0fe9b1d44be0c5de72d221a31c1d24bfe7a/meepo/apps/eventsourcing/event_store.py#L140-L146 | train |
eleme/meepo | meepo/apps/eventsourcing/event_store.py | RedisEventStore._zadd | def _zadd(self, key, pk, ts=None, ttl=None):
"""Redis lua func to add an event to the corresponding sorted set.
:param key: the key to be stored in redis server
:param pk: the primary key of event
:param ts: timestamp of the event, default to redis_server's
current timestamp
... | python | def _zadd(self, key, pk, ts=None, ttl=None):
"""Redis lua func to add an event to the corresponding sorted set.
:param key: the key to be stored in redis server
:param pk: the primary key of event
:param ts: timestamp of the event, default to redis_server's
current timestamp
... | [
"def",
"_zadd",
"(",
"self",
",",
"key",
",",
"pk",
",",
"ts",
"=",
"None",
",",
"ttl",
"=",
"None",
")",
":",
"return",
"self",
".",
"r",
".",
"eval",
"(",
"self",
".",
"LUA_ZADD",
",",
"1",
",",
"key",
",",
"ts",
"or",
"self",
".",
"_time",... | Redis lua func to add an event to the corresponding sorted set.
:param key: the key to be stored in redis server
:param pk: the primary key of event
:param ts: timestamp of the event, default to redis_server's
current timestamp
:param ttl: the expiration time of event since the... | [
"Redis",
"lua",
"func",
"to",
"add",
"an",
"event",
"to",
"the",
"corresponding",
"sorted",
"set",
"."
] | 8212f0fe9b1d44be0c5de72d221a31c1d24bfe7a | https://github.com/eleme/meepo/blob/8212f0fe9b1d44be0c5de72d221a31c1d24bfe7a/meepo/apps/eventsourcing/event_store.py#L154-L163 | train |
eleme/meepo | meepo/apps/eventsourcing/event_store.py | RedisEventStore.add | def add(self, event, pk, ts=None, ttl=None):
"""Add an event to event store.
All events were stored in a sorted set in redis with timestamp as
rank score.
:param event: the event to be added, format should be ``table_action``
:param pk: the primary key of event
:param ... | python | def add(self, event, pk, ts=None, ttl=None):
"""Add an event to event store.
All events were stored in a sorted set in redis with timestamp as
rank score.
:param event: the event to be added, format should be ``table_action``
:param pk: the primary key of event
:param ... | [
"def",
"add",
"(",
"self",
",",
"event",
",",
"pk",
",",
"ts",
"=",
"None",
",",
"ttl",
"=",
"None",
")",
":",
"key",
"=",
"self",
".",
"_keygen",
"(",
"event",
",",
"ts",
")",
"try",
":",
"self",
".",
"_zadd",
"(",
"key",
",",
"pk",
",",
"... | Add an event to event store.
All events were stored in a sorted set in redis with timestamp as
rank score.
:param event: the event to be added, format should be ``table_action``
:param pk: the primary key of event
:param ts: timestamp of the event, default to redis_server's
... | [
"Add",
"an",
"event",
"to",
"event",
"store",
"."
] | 8212f0fe9b1d44be0c5de72d221a31c1d24bfe7a | https://github.com/eleme/meepo/blob/8212f0fe9b1d44be0c5de72d221a31c1d24bfe7a/meepo/apps/eventsourcing/event_store.py#L165-L188 | train |
eleme/meepo | meepo/apps/eventsourcing/event_store.py | RedisEventStore.replay | def replay(self, event, ts=0, end_ts=None, with_ts=False):
"""Replay events based on timestamp.
If you split namespace with ts, the replay will only return events
within the same namespace.
:param event: event name
:param ts: replay events after ts, default from 0.
:par... | python | def replay(self, event, ts=0, end_ts=None, with_ts=False):
"""Replay events based on timestamp.
If you split namespace with ts, the replay will only return events
within the same namespace.
:param event: event name
:param ts: replay events after ts, default from 0.
:par... | [
"def",
"replay",
"(",
"self",
",",
"event",
",",
"ts",
"=",
"0",
",",
"end_ts",
"=",
"None",
",",
"with_ts",
"=",
"False",
")",
":",
"key",
"=",
"self",
".",
"_keygen",
"(",
"event",
",",
"ts",
")",
"end_ts",
"=",
"end_ts",
"if",
"end_ts",
"else"... | Replay events based on timestamp.
If you split namespace with ts, the replay will only return events
within the same namespace.
:param event: event name
:param ts: replay events after ts, default from 0.
:param end_ts: replay events to ts, default to "+inf".
:param with... | [
"Replay",
"events",
"based",
"on",
"timestamp",
"."
] | 8212f0fe9b1d44be0c5de72d221a31c1d24bfe7a | https://github.com/eleme/meepo/blob/8212f0fe9b1d44be0c5de72d221a31c1d24bfe7a/meepo/apps/eventsourcing/event_store.py#L190-L210 | train |
eleme/meepo | meepo/apps/eventsourcing/event_store.py | RedisEventStore.query | def query(self, event, pk, ts=None):
"""Query the last update timestamp of an event pk.
You can pass a timestamp to only look for events later than that
within the same namespace.
:param event: the event name.
:param pk: the pk value for query.
:param ts: query event pk... | python | def query(self, event, pk, ts=None):
"""Query the last update timestamp of an event pk.
You can pass a timestamp to only look for events later than that
within the same namespace.
:param event: the event name.
:param pk: the pk value for query.
:param ts: query event pk... | [
"def",
"query",
"(",
"self",
",",
"event",
",",
"pk",
",",
"ts",
"=",
"None",
")",
":",
"key",
"=",
"self",
".",
"_keygen",
"(",
"event",
",",
"ts",
")",
"pk_ts",
"=",
"self",
".",
"r",
".",
"zscore",
"(",
"key",
",",
"pk",
")",
"return",
"in... | Query the last update timestamp of an event pk.
You can pass a timestamp to only look for events later than that
within the same namespace.
:param event: the event name.
:param pk: the pk value for query.
:param ts: query event pk after ts, default to None which will query
... | [
"Query",
"the",
"last",
"update",
"timestamp",
"of",
"an",
"event",
"pk",
"."
] | 8212f0fe9b1d44be0c5de72d221a31c1d24bfe7a | https://github.com/eleme/meepo/blob/8212f0fe9b1d44be0c5de72d221a31c1d24bfe7a/meepo/apps/eventsourcing/event_store.py#L212-L225 | train |
eleme/meepo | meepo/apps/eventsourcing/event_store.py | RedisEventStore.clear | def clear(self, event, ts=None):
"""Clear all stored record of event.
:param event: event name to be cleared.
:param ts: timestamp used locate the namespace
"""
return self.r.delete(self._keygen(event, ts)) | python | def clear(self, event, ts=None):
"""Clear all stored record of event.
:param event: event name to be cleared.
:param ts: timestamp used locate the namespace
"""
return self.r.delete(self._keygen(event, ts)) | [
"def",
"clear",
"(",
"self",
",",
"event",
",",
"ts",
"=",
"None",
")",
":",
"return",
"self",
".",
"r",
".",
"delete",
"(",
"self",
".",
"_keygen",
"(",
"event",
",",
"ts",
")",
")"
] | Clear all stored record of event.
:param event: event name to be cleared.
:param ts: timestamp used locate the namespace | [
"Clear",
"all",
"stored",
"record",
"of",
"event",
"."
] | 8212f0fe9b1d44be0c5de72d221a31c1d24bfe7a | https://github.com/eleme/meepo/blob/8212f0fe9b1d44be0c5de72d221a31c1d24bfe7a/meepo/apps/eventsourcing/event_store.py#L227-L233 | train |
alunduil/crumbs | crumbs/__init__.py | Parameters.add_configuration_file | def add_configuration_file(self, file_name):
'''Register a file path from which to read parameter values.
This method can be called multiple times to register multiple files for
querying. Files are expected to be ``ini`` formatted.
No assumptions should be made about the order that th... | python | def add_configuration_file(self, file_name):
'''Register a file path from which to read parameter values.
This method can be called multiple times to register multiple files for
querying. Files are expected to be ``ini`` formatted.
No assumptions should be made about the order that th... | [
"def",
"add_configuration_file",
"(",
"self",
",",
"file_name",
")",
":",
"logger",
".",
"info",
"(",
"'adding %s to configuration files'",
",",
"file_name",
")",
"if",
"file_name",
"not",
"in",
"self",
".",
"configuration_files",
"and",
"self",
".",
"_inotify",
... | Register a file path from which to read parameter values.
This method can be called multiple times to register multiple files for
querying. Files are expected to be ``ini`` formatted.
No assumptions should be made about the order that the registered files
are read and values defined i... | [
"Register",
"a",
"file",
"path",
"from",
"which",
"to",
"read",
"parameter",
"values",
"."
] | 94b23f45db3054000d16968a44400780c6cff5ba | https://github.com/alunduil/crumbs/blob/94b23f45db3054000d16968a44400780c6cff5ba/crumbs/__init__.py#L328-L354 | train |
alunduil/crumbs | crumbs/__init__.py | Parameters.add_parameter | def add_parameter(self, **kwargs):
'''Add the parameter to ``Parameters``.
**Arguments**
The arguments are lumped into two groups:``Parameters.add_parameter``
and ``argparse.ArgumentParser.add_argument``. Parameters that are only
used by ``Parameters.add_parameter`` are remove... | python | def add_parameter(self, **kwargs):
'''Add the parameter to ``Parameters``.
**Arguments**
The arguments are lumped into two groups:``Parameters.add_parameter``
and ``argparse.ArgumentParser.add_argument``. Parameters that are only
used by ``Parameters.add_parameter`` are remove... | [
"def",
"add_parameter",
"(",
"self",
",",
"**",
"kwargs",
")",
":",
"parameter_name",
"=",
"max",
"(",
"kwargs",
"[",
"'options'",
"]",
",",
"key",
"=",
"len",
")",
".",
"lstrip",
"(",
"'-'",
")",
"if",
"'dest'",
"in",
"kwargs",
":",
"parameter_name",
... | Add the parameter to ``Parameters``.
**Arguments**
The arguments are lumped into two groups:``Parameters.add_parameter``
and ``argparse.ArgumentParser.add_argument``. Parameters that are only
used by ``Parameters.add_parameter`` are removed before ``kwargs`` is
passed directly... | [
"Add",
"the",
"parameter",
"to",
"Parameters",
"."
] | 94b23f45db3054000d16968a44400780c6cff5ba | https://github.com/alunduil/crumbs/blob/94b23f45db3054000d16968a44400780c6cff5ba/crumbs/__init__.py#L356-L464 | train |
alunduil/crumbs | crumbs/__init__.py | Parameters.parse | def parse(self, only_known = False):
'''Ensure all sources are ready to be queried.
Parses ``sys.argv`` with the contained ``argparse.ArgumentParser`` and
sets ``parsed`` to True if ``only_known`` is False. Once ``parsed`` is
set to True, it is inadvisable to add more parameters (cf.
... | python | def parse(self, only_known = False):
'''Ensure all sources are ready to be queried.
Parses ``sys.argv`` with the contained ``argparse.ArgumentParser`` and
sets ``parsed`` to True if ``only_known`` is False. Once ``parsed`` is
set to True, it is inadvisable to add more parameters (cf.
... | [
"def",
"parse",
"(",
"self",
",",
"only_known",
"=",
"False",
")",
":",
"self",
".",
"parsed",
"=",
"not",
"only_known",
"or",
"self",
".",
"parsed",
"logger",
".",
"info",
"(",
"'parsing parameters'",
")",
"logger",
".",
"debug",
"(",
"'sys.argv: %s'",
... | Ensure all sources are ready to be queried.
Parses ``sys.argv`` with the contained ``argparse.ArgumentParser`` and
sets ``parsed`` to True if ``only_known`` is False. Once ``parsed`` is
set to True, it is inadvisable to add more parameters (cf.
``add_parameter``). Also, if ``parsed`` ... | [
"Ensure",
"all",
"sources",
"are",
"ready",
"to",
"be",
"queried",
"."
] | 94b23f45db3054000d16968a44400780c6cff5ba | https://github.com/alunduil/crumbs/blob/94b23f45db3054000d16968a44400780c6cff5ba/crumbs/__init__.py#L466-L501 | train |
alunduil/crumbs | crumbs/__init__.py | Parameters.read_configuration_files | def read_configuration_files(self):
'''Explicitly read the configuration files.
Reads all configuration files in this Parameters object. Even if
inotify is watching or a read has already occurred.
.. note::
The order that the configuration files are read is not guaranteed.... | python | def read_configuration_files(self):
'''Explicitly read the configuration files.
Reads all configuration files in this Parameters object. Even if
inotify is watching or a read has already occurred.
.. note::
The order that the configuration files are read is not guaranteed.... | [
"def",
"read_configuration_files",
"(",
"self",
")",
":",
"for",
"file_name",
",",
"configuration_parser",
"in",
"self",
".",
"configuration_files",
".",
"items",
"(",
")",
":",
"if",
"os",
".",
"access",
"(",
"file_name",
",",
"os",
".",
"R_OK",
")",
":",... | Explicitly read the configuration files.
Reads all configuration files in this Parameters object. Even if
inotify is watching or a read has already occurred.
.. note::
The order that the configuration files are read is not guaranteed. | [
"Explicitly",
"read",
"the",
"configuration",
"files",
"."
] | 94b23f45db3054000d16968a44400780c6cff5ba | https://github.com/alunduil/crumbs/blob/94b23f45db3054000d16968a44400780c6cff5ba/crumbs/__init__.py#L503-L520 | train |
robinandeer/puzzle | puzzle/models/variant.py | Variant.nr_genes | def nr_genes(self):
"""Return the number of genes"""
if self['genes']:
nr_genes = len(self['genes'])
else:
nr_genes = len(self['gene_symbols'])
return nr_genes | python | def nr_genes(self):
"""Return the number of genes"""
if self['genes']:
nr_genes = len(self['genes'])
else:
nr_genes = len(self['gene_symbols'])
return nr_genes | [
"def",
"nr_genes",
"(",
"self",
")",
":",
"if",
"self",
"[",
"'genes'",
"]",
":",
"nr_genes",
"=",
"len",
"(",
"self",
"[",
"'genes'",
"]",
")",
"else",
":",
"nr_genes",
"=",
"len",
"(",
"self",
"[",
"'gene_symbols'",
"]",
")",
"return",
"nr_genes"
] | Return the number of genes | [
"Return",
"the",
"number",
"of",
"genes"
] | 9476f05b416d3a5135d25492cb31411fdf831c58 | https://github.com/robinandeer/puzzle/blob/9476f05b416d3a5135d25492cb31411fdf831c58/puzzle/models/variant.py#L44-L50 | train |
robinandeer/puzzle | puzzle/models/variant.py | Variant.display_name | def display_name(self):
"""Readable name for the variant."""
if self.is_snv:
gene_ids = self.gene_symbols[:2]
return ', '.join(gene_ids)
else:
return "{this.cytoband_start} ({this.sv_len})".format(this=self) | python | def display_name(self):
"""Readable name for the variant."""
if self.is_snv:
gene_ids = self.gene_symbols[:2]
return ', '.join(gene_ids)
else:
return "{this.cytoband_start} ({this.sv_len})".format(this=self) | [
"def",
"display_name",
"(",
"self",
")",
":",
"if",
"self",
".",
"is_snv",
":",
"gene_ids",
"=",
"self",
".",
"gene_symbols",
"[",
":",
"2",
"]",
"return",
"', '",
".",
"join",
"(",
"gene_ids",
")",
"else",
":",
"return",
"\"{this.cytoband_start} ({this.sv... | Readable name for the variant. | [
"Readable",
"name",
"for",
"the",
"variant",
"."
] | 9476f05b416d3a5135d25492cb31411fdf831c58 | https://github.com/robinandeer/puzzle/blob/9476f05b416d3a5135d25492cb31411fdf831c58/puzzle/models/variant.py#L58-L64 | train |
robinandeer/puzzle | puzzle/models/variant.py | Variant.md5 | def md5(self):
"""Return a md5 key string based on position, ref and alt"""
return hashlib.md5('_'.join([self.CHROM, str(self.POS), self.REF,
self.ALT])).hexdigest() | python | def md5(self):
"""Return a md5 key string based on position, ref and alt"""
return hashlib.md5('_'.join([self.CHROM, str(self.POS), self.REF,
self.ALT])).hexdigest() | [
"def",
"md5",
"(",
"self",
")",
":",
"return",
"hashlib",
".",
"md5",
"(",
"'_'",
".",
"join",
"(",
"[",
"self",
".",
"CHROM",
",",
"str",
"(",
"self",
".",
"POS",
")",
",",
"self",
".",
"REF",
",",
"self",
".",
"ALT",
"]",
")",
")",
".",
"... | Return a md5 key string based on position, ref and alt | [
"Return",
"a",
"md5",
"key",
"string",
"based",
"on",
"position",
"ref",
"and",
"alt"
] | 9476f05b416d3a5135d25492cb31411fdf831c58 | https://github.com/robinandeer/puzzle/blob/9476f05b416d3a5135d25492cb31411fdf831c58/puzzle/models/variant.py#L67-L70 | train |
robinandeer/puzzle | puzzle/models/variant.py | Variant.add_frequency | def add_frequency(self, name, value):
"""Add a frequency that will be displayed on the variant level
Args:
name (str): The name of the frequency field
"""
logger.debug("Adding frequency {0} with value {1} to variant {2}".format(
name, value, self['variant... | python | def add_frequency(self, name, value):
"""Add a frequency that will be displayed on the variant level
Args:
name (str): The name of the frequency field
"""
logger.debug("Adding frequency {0} with value {1} to variant {2}".format(
name, value, self['variant... | [
"def",
"add_frequency",
"(",
"self",
",",
"name",
",",
"value",
")",
":",
"logger",
".",
"debug",
"(",
"\"Adding frequency {0} with value {1} to variant {2}\"",
".",
"format",
"(",
"name",
",",
"value",
",",
"self",
"[",
"'variant_id'",
"]",
")",
")",
"self",
... | Add a frequency that will be displayed on the variant level
Args:
name (str): The name of the frequency field | [
"Add",
"a",
"frequency",
"that",
"will",
"be",
"displayed",
"on",
"the",
"variant",
"level"
] | 9476f05b416d3a5135d25492cb31411fdf831c58 | https://github.com/robinandeer/puzzle/blob/9476f05b416d3a5135d25492cb31411fdf831c58/puzzle/models/variant.py#L81-L89 | train |
robinandeer/puzzle | puzzle/models/variant.py | Variant.set_max_freq | def set_max_freq(self, max_freq=None):
"""Set the max frequency for the variant
If max_freq use this, otherwise go through all frequencies and
set the highest as self['max_freq']
Args:
max_freq (float): The max frequency
"""
if max_freq:
... | python | def set_max_freq(self, max_freq=None):
"""Set the max frequency for the variant
If max_freq use this, otherwise go through all frequencies and
set the highest as self['max_freq']
Args:
max_freq (float): The max frequency
"""
if max_freq:
... | [
"def",
"set_max_freq",
"(",
"self",
",",
"max_freq",
"=",
"None",
")",
":",
"if",
"max_freq",
":",
"self",
"[",
"'max_freq'",
"]",
"=",
"max_freq",
"else",
":",
"for",
"frequency",
"in",
"self",
"[",
"'frequencies'",
"]",
":",
"if",
"self",
"[",
"'max_... | Set the max frequency for the variant
If max_freq use this, otherwise go through all frequencies and
set the highest as self['max_freq']
Args:
max_freq (float): The max frequency | [
"Set",
"the",
"max",
"frequency",
"for",
"the",
"variant"
] | 9476f05b416d3a5135d25492cb31411fdf831c58 | https://github.com/robinandeer/puzzle/blob/9476f05b416d3a5135d25492cb31411fdf831c58/puzzle/models/variant.py#L91-L109 | train |
robinandeer/puzzle | puzzle/models/variant.py | Variant.add_severity | def add_severity(self, name, value):
"""Add a severity to the variant
Args:
name (str): The name of the severity
value : The value of the severity
"""
logger.debug("Adding severity {0} with value {1} to variant {2}".format(
name, value, se... | python | def add_severity(self, name, value):
"""Add a severity to the variant
Args:
name (str): The name of the severity
value : The value of the severity
"""
logger.debug("Adding severity {0} with value {1} to variant {2}".format(
name, value, se... | [
"def",
"add_severity",
"(",
"self",
",",
"name",
",",
"value",
")",
":",
"logger",
".",
"debug",
"(",
"\"Adding severity {0} with value {1} to variant {2}\"",
".",
"format",
"(",
"name",
",",
"value",
",",
"self",
"[",
"'variant_id'",
"]",
")",
")",
"self",
... | Add a severity to the variant
Args:
name (str): The name of the severity
value : The value of the severity | [
"Add",
"a",
"severity",
"to",
"the",
"variant"
] | 9476f05b416d3a5135d25492cb31411fdf831c58 | https://github.com/robinandeer/puzzle/blob/9476f05b416d3a5135d25492cb31411fdf831c58/puzzle/models/variant.py#L111-L120 | train |
robinandeer/puzzle | puzzle/models/variant.py | Variant.add_individual | def add_individual(self, genotype):
"""Add the information for a individual
This adds a genotype dict to variant['individuals']
Args:
genotype (dict): A genotype dictionary
"""
logger.debug("Adding genotype {0} to variant {1}".format(
genotyp... | python | def add_individual(self, genotype):
"""Add the information for a individual
This adds a genotype dict to variant['individuals']
Args:
genotype (dict): A genotype dictionary
"""
logger.debug("Adding genotype {0} to variant {1}".format(
genotyp... | [
"def",
"add_individual",
"(",
"self",
",",
"genotype",
")",
":",
"logger",
".",
"debug",
"(",
"\"Adding genotype {0} to variant {1}\"",
".",
"format",
"(",
"genotype",
",",
"self",
"[",
"'variant_id'",
"]",
")",
")",
"self",
"[",
"'individuals'",
"]",
".",
"... | Add the information for a individual
This adds a genotype dict to variant['individuals']
Args:
genotype (dict): A genotype dictionary | [
"Add",
"the",
"information",
"for",
"a",
"individual"
] | 9476f05b416d3a5135d25492cb31411fdf831c58 | https://github.com/robinandeer/puzzle/blob/9476f05b416d3a5135d25492cb31411fdf831c58/puzzle/models/variant.py#L122-L132 | train |
robinandeer/puzzle | puzzle/models/variant.py | Variant.add_transcript | def add_transcript(self, transcript):
"""Add the information transcript
This adds a transcript dict to variant['transcripts']
Args:
transcript (dict): A transcript dictionary
"""
logger.debug("Adding transcript {0} to variant {1}".format(
tra... | python | def add_transcript(self, transcript):
"""Add the information transcript
This adds a transcript dict to variant['transcripts']
Args:
transcript (dict): A transcript dictionary
"""
logger.debug("Adding transcript {0} to variant {1}".format(
tra... | [
"def",
"add_transcript",
"(",
"self",
",",
"transcript",
")",
":",
"logger",
".",
"debug",
"(",
"\"Adding transcript {0} to variant {1}\"",
".",
"format",
"(",
"transcript",
",",
"self",
"[",
"'variant_id'",
"]",
")",
")",
"self",
"[",
"'transcripts'",
"]",
".... | Add the information transcript
This adds a transcript dict to variant['transcripts']
Args:
transcript (dict): A transcript dictionary | [
"Add",
"the",
"information",
"transcript"
] | 9476f05b416d3a5135d25492cb31411fdf831c58 | https://github.com/robinandeer/puzzle/blob/9476f05b416d3a5135d25492cb31411fdf831c58/puzzle/models/variant.py#L134-L144 | train |
robinandeer/puzzle | puzzle/models/variant.py | Variant.add_gene | def add_gene(self, gene):
"""Add the information of a gene
This adds a gene dict to variant['genes']
Args:
gene (dict): A gene dictionary
"""
logger.debug("Adding gene {0} to variant {1}".format(
gene, self['variant_id']))
self['gene... | python | def add_gene(self, gene):
"""Add the information of a gene
This adds a gene dict to variant['genes']
Args:
gene (dict): A gene dictionary
"""
logger.debug("Adding gene {0} to variant {1}".format(
gene, self['variant_id']))
self['gene... | [
"def",
"add_gene",
"(",
"self",
",",
"gene",
")",
":",
"logger",
".",
"debug",
"(",
"\"Adding gene {0} to variant {1}\"",
".",
"format",
"(",
"gene",
",",
"self",
"[",
"'variant_id'",
"]",
")",
")",
"self",
"[",
"'genes'",
"]",
".",
"append",
"(",
"gene"... | Add the information of a gene
This adds a gene dict to variant['genes']
Args:
gene (dict): A gene dictionary | [
"Add",
"the",
"information",
"of",
"a",
"gene"
] | 9476f05b416d3a5135d25492cb31411fdf831c58 | https://github.com/robinandeer/puzzle/blob/9476f05b416d3a5135d25492cb31411fdf831c58/puzzle/models/variant.py#L146-L157 | train |
robinandeer/puzzle | puzzle/models/variant.py | Variant.add_compound | def add_compound(self, compound):
"""Add the information of a compound variant
This adds a compound dict to variant['compounds']
Args:
compound (dict): A compound dictionary
"""
logger.debug("Adding compound {0} to variant {1}".format(
compo... | python | def add_compound(self, compound):
"""Add the information of a compound variant
This adds a compound dict to variant['compounds']
Args:
compound (dict): A compound dictionary
"""
logger.debug("Adding compound {0} to variant {1}".format(
compo... | [
"def",
"add_compound",
"(",
"self",
",",
"compound",
")",
":",
"logger",
".",
"debug",
"(",
"\"Adding compound {0} to variant {1}\"",
".",
"format",
"(",
"compound",
",",
"self",
"[",
"'variant_id'",
"]",
")",
")",
"self",
"[",
"'compounds'",
"]",
".",
"appe... | Add the information of a compound variant
This adds a compound dict to variant['compounds']
Args:
compound (dict): A compound dictionary | [
"Add",
"the",
"information",
"of",
"a",
"compound",
"variant"
] | 9476f05b416d3a5135d25492cb31411fdf831c58 | https://github.com/robinandeer/puzzle/blob/9476f05b416d3a5135d25492cb31411fdf831c58/puzzle/models/variant.py#L159-L170 | train |
robinandeer/puzzle | puzzle/models/variant.py | Variant._set_variant_id | def _set_variant_id(self, variant_id=None):
"""Set the variant id for this variant"""
if not variant_id:
variant_id = '_'.join([
self.CHROM,
str(self.POS),
self.REF,
self.ALT
])
logger.debug("Updating va... | python | def _set_variant_id(self, variant_id=None):
"""Set the variant id for this variant"""
if not variant_id:
variant_id = '_'.join([
self.CHROM,
str(self.POS),
self.REF,
self.ALT
])
logger.debug("Updating va... | [
"def",
"_set_variant_id",
"(",
"self",
",",
"variant_id",
"=",
"None",
")",
":",
"if",
"not",
"variant_id",
":",
"variant_id",
"=",
"'_'",
".",
"join",
"(",
"[",
"self",
".",
"CHROM",
",",
"str",
"(",
"self",
".",
"POS",
")",
",",
"self",
".",
"REF... | Set the variant id for this variant | [
"Set",
"the",
"variant",
"id",
"for",
"this",
"variant"
] | 9476f05b416d3a5135d25492cb31411fdf831c58 | https://github.com/robinandeer/puzzle/blob/9476f05b416d3a5135d25492cb31411fdf831c58/puzzle/models/variant.py#L181-L194 | train |
inveniosoftware-contrib/json-merger | json_merger/stats.py | ListMatchStats.move_to_result | def move_to_result(self, lst_idx):
"""Moves element from lst available at lst_idx."""
self.in_result_idx.add(lst_idx)
if lst_idx in self.not_in_result_root_match_idx:
self.not_in_result_root_match_idx.remove(lst_idx) | python | def move_to_result(self, lst_idx):
"""Moves element from lst available at lst_idx."""
self.in_result_idx.add(lst_idx)
if lst_idx in self.not_in_result_root_match_idx:
self.not_in_result_root_match_idx.remove(lst_idx) | [
"def",
"move_to_result",
"(",
"self",
",",
"lst_idx",
")",
":",
"self",
".",
"in_result_idx",
".",
"add",
"(",
"lst_idx",
")",
"if",
"lst_idx",
"in",
"self",
".",
"not_in_result_root_match_idx",
":",
"self",
".",
"not_in_result_root_match_idx",
".",
"remove",
... | Moves element from lst available at lst_idx. | [
"Moves",
"element",
"from",
"lst",
"available",
"at",
"lst_idx",
"."
] | adc6d372da018427e1db7b92424d3471e01a4118 | https://github.com/inveniosoftware-contrib/json-merger/blob/adc6d372da018427e1db7b92424d3471e01a4118/json_merger/stats.py#L72-L77 | train |
inveniosoftware-contrib/json-merger | json_merger/stats.py | ListMatchStats.add_root_match | def add_root_match(self, lst_idx, root_idx):
"""Adds a match for the elements avaialble at lst_idx and root_idx."""
self.root_matches[lst_idx] = root_idx
if lst_idx in self.in_result_idx:
return
self.not_in_result_root_match_idx.add(lst_idx) | python | def add_root_match(self, lst_idx, root_idx):
"""Adds a match for the elements avaialble at lst_idx and root_idx."""
self.root_matches[lst_idx] = root_idx
if lst_idx in self.in_result_idx:
return
self.not_in_result_root_match_idx.add(lst_idx) | [
"def",
"add_root_match",
"(",
"self",
",",
"lst_idx",
",",
"root_idx",
")",
":",
"self",
".",
"root_matches",
"[",
"lst_idx",
"]",
"=",
"root_idx",
"if",
"lst_idx",
"in",
"self",
".",
"in_result_idx",
":",
"return",
"self",
".",
"not_in_result_root_match_idx",... | Adds a match for the elements avaialble at lst_idx and root_idx. | [
"Adds",
"a",
"match",
"for",
"the",
"elements",
"avaialble",
"at",
"lst_idx",
"and",
"root_idx",
"."
] | adc6d372da018427e1db7b92424d3471e01a4118 | https://github.com/inveniosoftware-contrib/json-merger/blob/adc6d372da018427e1db7b92424d3471e01a4118/json_merger/stats.py#L79-L85 | train |
robinandeer/puzzle | puzzle/plugins/gemini/mixins/variant_extras/transcripts.py | TranscriptExtras._add_transcripts | def _add_transcripts(self, variant_obj, gemini_variant):
"""
Add all transcripts for a variant
Go through all transcripts found for the variant
Args:
gemini_variant (GeminiQueryRow): The gemini variant
Yields:
transcript (puzzle.models.T... | python | def _add_transcripts(self, variant_obj, gemini_variant):
"""
Add all transcripts for a variant
Go through all transcripts found for the variant
Args:
gemini_variant (GeminiQueryRow): The gemini variant
Yields:
transcript (puzzle.models.T... | [
"def",
"_add_transcripts",
"(",
"self",
",",
"variant_obj",
",",
"gemini_variant",
")",
":",
"query",
"=",
"\"SELECT * from variant_impacts WHERE variant_id = {0}\"",
".",
"format",
"(",
"gemini_variant",
"[",
"'variant_id'",
"]",
")",
"gq",
"=",
"GeminiQuery",
"(",
... | Add all transcripts for a variant
Go through all transcripts found for the variant
Args:
gemini_variant (GeminiQueryRow): The gemini variant
Yields:
transcript (puzzle.models.Transcript) | [
"Add",
"all",
"transcripts",
"for",
"a",
"variant"
] | 9476f05b416d3a5135d25492cb31411fdf831c58 | https://github.com/robinandeer/puzzle/blob/9476f05b416d3a5135d25492cb31411fdf831c58/puzzle/plugins/gemini/mixins/variant_extras/transcripts.py#L8-L39 | train |
eleme/meepo | meepo/pub/mysql.py | mysql_pub | def mysql_pub(mysql_dsn, tables=None, blocking=False, **kwargs):
"""MySQL row-based binlog events pub.
**General Usage**
Listen and pub all tables events::
mysql_pub(mysql_dsn)
Listen and pub only some tables events::
mysql_pub(mysql_dsn, tables=["test"])
By default the ``mysql... | python | def mysql_pub(mysql_dsn, tables=None, blocking=False, **kwargs):
"""MySQL row-based binlog events pub.
**General Usage**
Listen and pub all tables events::
mysql_pub(mysql_dsn)
Listen and pub only some tables events::
mysql_pub(mysql_dsn, tables=["test"])
By default the ``mysql... | [
"def",
"mysql_pub",
"(",
"mysql_dsn",
",",
"tables",
"=",
"None",
",",
"blocking",
"=",
"False",
",",
"**",
"kwargs",
")",
":",
"parsed",
"=",
"urlparse",
"(",
"mysql_dsn",
")",
"mysql_settings",
"=",
"{",
"\"host\"",
":",
"parsed",
".",
"hostname",
",",... | MySQL row-based binlog events pub.
**General Usage**
Listen and pub all tables events::
mysql_pub(mysql_dsn)
Listen and pub only some tables events::
mysql_pub(mysql_dsn, tables=["test"])
By default the ``mysql_pub`` will process and pub all existing
row-based binlog (starting ... | [
"MySQL",
"row",
"-",
"based",
"binlog",
"events",
"pub",
"."
] | 8212f0fe9b1d44be0c5de72d221a31c1d24bfe7a | https://github.com/eleme/meepo/blob/8212f0fe9b1d44be0c5de72d221a31c1d24bfe7a/meepo/pub/mysql.py#L50-L180 | train |
ldomic/lintools | lintools/molecule.py | Molecule.load_molecule_in_rdkit_smiles | def load_molecule_in_rdkit_smiles(self, molSize,kekulize=True,bonds=[],bond_color=None,atom_color = {}, size= {} ):
"""
Loads mol file in rdkit without the hydrogens - they do not have to appear in the final
figure. Once loaded, the molecule is converted to SMILES format which RDKit appears to
... | python | def load_molecule_in_rdkit_smiles(self, molSize,kekulize=True,bonds=[],bond_color=None,atom_color = {}, size= {} ):
"""
Loads mol file in rdkit without the hydrogens - they do not have to appear in the final
figure. Once loaded, the molecule is converted to SMILES format which RDKit appears to
... | [
"def",
"load_molecule_in_rdkit_smiles",
"(",
"self",
",",
"molSize",
",",
"kekulize",
"=",
"True",
",",
"bonds",
"=",
"[",
"]",
",",
"bond_color",
"=",
"None",
",",
"atom_color",
"=",
"{",
"}",
",",
"size",
"=",
"{",
"}",
")",
":",
"mol_in_rdkit",
"=",... | Loads mol file in rdkit without the hydrogens - they do not have to appear in the final
figure. Once loaded, the molecule is converted to SMILES format which RDKit appears to
draw best - since we do not care about the actual coordinates of the original molecule, it
is sufficient to have just 2D ... | [
"Loads",
"mol",
"file",
"in",
"rdkit",
"without",
"the",
"hydrogens",
"-",
"they",
"do",
"not",
"have",
"to",
"appear",
"in",
"the",
"final",
"figure",
".",
"Once",
"loaded",
"the",
"molecule",
"is",
"converted",
"to",
"SMILES",
"format",
"which",
"RDKit",... | d825a4a7b35f3f857d3b81b46c9aee72b0ec697a | https://github.com/ldomic/lintools/blob/d825a4a7b35f3f857d3b81b46c9aee72b0ec697a/lintools/molecule.py#L48-L94 | train |
ldomic/lintools | lintools/molecule.py | Molecule.calc_2d_forces | def calc_2d_forces(self,x1,y1,x2,y2,width):
"""Calculate overlap in 2D space"""
#calculate a
if x1>x2:
a = x1-x2
else:
a = x2-x1
a_sq=a*a
#calculate b
if y1>y2:
b = y1-y2
else:
b = y2-y1
b_sq=b*b
... | python | def calc_2d_forces(self,x1,y1,x2,y2,width):
"""Calculate overlap in 2D space"""
#calculate a
if x1>x2:
a = x1-x2
else:
a = x2-x1
a_sq=a*a
#calculate b
if y1>y2:
b = y1-y2
else:
b = y2-y1
b_sq=b*b
... | [
"def",
"calc_2d_forces",
"(",
"self",
",",
"x1",
",",
"y1",
",",
"x2",
",",
"y2",
",",
"width",
")",
":",
"if",
"x1",
">",
"x2",
":",
"a",
"=",
"x1",
"-",
"x2",
"else",
":",
"a",
"=",
"x2",
"-",
"x1",
"a_sq",
"=",
"a",
"*",
"a",
"if",
"y1... | Calculate overlap in 2D space | [
"Calculate",
"overlap",
"in",
"2D",
"space"
] | d825a4a7b35f3f857d3b81b46c9aee72b0ec697a | https://github.com/ldomic/lintools/blob/d825a4a7b35f3f857d3b81b46c9aee72b0ec697a/lintools/molecule.py#L162-L189 | train |
ldomic/lintools | lintools/molecule.py | Molecule.do_step | def do_step(self, values, xy_values,coeff, width):
"""Calculates forces between two diagrams and pushes them apart by tenth of width"""
forces = {k:[] for k,i in enumerate(xy_values)}
for (index1, value1), (index2,value2) in combinations(enumerate(xy_values),2):
f = self.calc_2d_forc... | python | def do_step(self, values, xy_values,coeff, width):
"""Calculates forces between two diagrams and pushes them apart by tenth of width"""
forces = {k:[] for k,i in enumerate(xy_values)}
for (index1, value1), (index2,value2) in combinations(enumerate(xy_values),2):
f = self.calc_2d_forc... | [
"def",
"do_step",
"(",
"self",
",",
"values",
",",
"xy_values",
",",
"coeff",
",",
"width",
")",
":",
"forces",
"=",
"{",
"k",
":",
"[",
"]",
"for",
"k",
",",
"i",
"in",
"enumerate",
"(",
"xy_values",
")",
"}",
"for",
"(",
"index1",
",",
"value1"... | Calculates forces between two diagrams and pushes them apart by tenth of width | [
"Calculates",
"forces",
"between",
"two",
"diagrams",
"and",
"pushes",
"them",
"apart",
"by",
"tenth",
"of",
"width"
] | d825a4a7b35f3f857d3b81b46c9aee72b0ec697a | https://github.com/ldomic/lintools/blob/d825a4a7b35f3f857d3b81b46c9aee72b0ec697a/lintools/molecule.py#L192-L217 | train |
robinandeer/puzzle | puzzle/plugins/sql/mixins/variant.py | VariantMixin.variants | def variants(self, case_id, skip=0, count=1000, filters=None):
"""Fetch variants for a case."""
filters = filters or {}
logger.debug("Fetching case with case_id: {0}".format(case_id))
case_obj = self.case(case_id)
plugin, case_id = self.select_plugin(case_obj)
self.filter... | python | def variants(self, case_id, skip=0, count=1000, filters=None):
"""Fetch variants for a case."""
filters = filters or {}
logger.debug("Fetching case with case_id: {0}".format(case_id))
case_obj = self.case(case_id)
plugin, case_id = self.select_plugin(case_obj)
self.filter... | [
"def",
"variants",
"(",
"self",
",",
"case_id",
",",
"skip",
"=",
"0",
",",
"count",
"=",
"1000",
",",
"filters",
"=",
"None",
")",
":",
"filters",
"=",
"filters",
"or",
"{",
"}",
"logger",
".",
"debug",
"(",
"\"Fetching case with case_id: {0}\"",
".",
... | Fetch variants for a case. | [
"Fetch",
"variants",
"for",
"a",
"case",
"."
] | 9476f05b416d3a5135d25492cb31411fdf831c58 | https://github.com/robinandeer/puzzle/blob/9476f05b416d3a5135d25492cb31411fdf831c58/puzzle/plugins/sql/mixins/variant.py#L11-L29 | train |
robinandeer/puzzle | puzzle/plugins/sql/mixins/variant.py | VariantMixin.variant | def variant(self, case_id, variant_id):
"""Fetch a single variant from variant source."""
case_obj = self.case(case_id)
plugin, case_id = self.select_plugin(case_obj)
variant = plugin.variant(case_id, variant_id)
return variant | python | def variant(self, case_id, variant_id):
"""Fetch a single variant from variant source."""
case_obj = self.case(case_id)
plugin, case_id = self.select_plugin(case_obj)
variant = plugin.variant(case_id, variant_id)
return variant | [
"def",
"variant",
"(",
"self",
",",
"case_id",
",",
"variant_id",
")",
":",
"case_obj",
"=",
"self",
".",
"case",
"(",
"case_id",
")",
"plugin",
",",
"case_id",
"=",
"self",
".",
"select_plugin",
"(",
"case_obj",
")",
"variant",
"=",
"plugin",
".",
"va... | Fetch a single variant from variant source. | [
"Fetch",
"a",
"single",
"variant",
"from",
"variant",
"source",
"."
] | 9476f05b416d3a5135d25492cb31411fdf831c58 | https://github.com/robinandeer/puzzle/blob/9476f05b416d3a5135d25492cb31411fdf831c58/puzzle/plugins/sql/mixins/variant.py#L31-L36 | train |
eleme/meepo | meepo/apps/eventsourcing/sub.py | redis_es_sub | def redis_es_sub(session, tables, redis_dsn, strict=False,
namespace=None, ttl=3600*24*3, socket_timeout=1):
"""Redis EventSourcing sub.
This sub should be used together with sqlalchemy_es_pub, it will
use RedisEventStore as events storage layer and use the prepare-commit
pattern in :f... | python | def redis_es_sub(session, tables, redis_dsn, strict=False,
namespace=None, ttl=3600*24*3, socket_timeout=1):
"""Redis EventSourcing sub.
This sub should be used together with sqlalchemy_es_pub, it will
use RedisEventStore as events storage layer and use the prepare-commit
pattern in :f... | [
"def",
"redis_es_sub",
"(",
"session",
",",
"tables",
",",
"redis_dsn",
",",
"strict",
"=",
"False",
",",
"namespace",
"=",
"None",
",",
"ttl",
"=",
"3600",
"*",
"24",
"*",
"3",
",",
"socket_timeout",
"=",
"1",
")",
":",
"logger",
"=",
"logging",
"."... | Redis EventSourcing sub.
This sub should be used together with sqlalchemy_es_pub, it will
use RedisEventStore as events storage layer and use the prepare-commit
pattern in :func:`sqlalchemy_es_pub` to ensure 100% security on
events recording.
:param session: the sqlalchemy to bind the signal
:... | [
"Redis",
"EventSourcing",
"sub",
"."
] | 8212f0fe9b1d44be0c5de72d221a31c1d24bfe7a | https://github.com/eleme/meepo/blob/8212f0fe9b1d44be0c5de72d221a31c1d24bfe7a/meepo/apps/eventsourcing/sub.py#L16-L71 | train |
jalmeroth/pymusiccast | musiccast.py | setup_parser | def setup_parser():
"""Setup an ArgumentParser."""
parser = argparse.ArgumentParser()
parser.add_argument('-p', '--port', type=int, default=5005)
parser.add_argument('-i', '--interval', type=int, default=480)
parser.add_argument('host', type=str, help='hostname')
return parser | python | def setup_parser():
"""Setup an ArgumentParser."""
parser = argparse.ArgumentParser()
parser.add_argument('-p', '--port', type=int, default=5005)
parser.add_argument('-i', '--interval', type=int, default=480)
parser.add_argument('host', type=str, help='hostname')
return parser | [
"def",
"setup_parser",
"(",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
")",
"parser",
".",
"add_argument",
"(",
"'-p'",
",",
"'--port'",
",",
"type",
"=",
"int",
",",
"default",
"=",
"5005",
")",
"parser",
".",
"add_argument",
"(",
... | Setup an ArgumentParser. | [
"Setup",
"an",
"ArgumentParser",
"."
] | 616379ae22d6b518c61042d58be6d18a46242168 | https://github.com/jalmeroth/pymusiccast/blob/616379ae22d6b518c61042d58be6d18a46242168/musiccast.py#L13-L19 | train |
jalmeroth/pymusiccast | musiccast.py | main | def main():
"""Connect to a McDevice"""
args = setup_parser().parse_args()
host = getattr(args, "host")
port = getattr(args, "port")
ipv4 = socket.gethostbyname(host)
interval = getattr(args, "interval")
receiver = McDevice(ipv4, udp_port=port, mc_interval=interval)
receiver.handle_stat... | python | def main():
"""Connect to a McDevice"""
args = setup_parser().parse_args()
host = getattr(args, "host")
port = getattr(args, "port")
ipv4 = socket.gethostbyname(host)
interval = getattr(args, "interval")
receiver = McDevice(ipv4, udp_port=port, mc_interval=interval)
receiver.handle_stat... | [
"def",
"main",
"(",
")",
":",
"args",
"=",
"setup_parser",
"(",
")",
".",
"parse_args",
"(",
")",
"host",
"=",
"getattr",
"(",
"args",
",",
"\"host\"",
")",
"port",
"=",
"getattr",
"(",
"args",
",",
"\"port\"",
")",
"ipv4",
"=",
"socket",
".",
"get... | Connect to a McDevice | [
"Connect",
"to",
"a",
"McDevice"
] | 616379ae22d6b518c61042d58be6d18a46242168 | https://github.com/jalmeroth/pymusiccast/blob/616379ae22d6b518c61042d58be6d18a46242168/musiccast.py#L22-L35 | train |
rycus86/ghost-client | ghost_client/api.py | Ghost.from_sqlite | def from_sqlite(cls, database_path, base_url, version='auto', client_id='ghost-admin'):
"""
Initialize a new Ghost API client,
reading the client ID and secret from the SQlite database.
:param database_path: The path to the database file.
:param base_url: The base url of the ser... | python | def from_sqlite(cls, database_path, base_url, version='auto', client_id='ghost-admin'):
"""
Initialize a new Ghost API client,
reading the client ID and secret from the SQlite database.
:param database_path: The path to the database file.
:param base_url: The base url of the ser... | [
"def",
"from_sqlite",
"(",
"cls",
",",
"database_path",
",",
"base_url",
",",
"version",
"=",
"'auto'",
",",
"client_id",
"=",
"'ghost-admin'",
")",
":",
"import",
"os",
"import",
"sqlite3",
"fd",
"=",
"os",
".",
"open",
"(",
"database_path",
",",
"os",
... | Initialize a new Ghost API client,
reading the client ID and secret from the SQlite database.
:param database_path: The path to the database file.
:param base_url: The base url of the server
:param version: The server version to use (default: `auto`)
:param client_id: The client... | [
"Initialize",
"a",
"new",
"Ghost",
"API",
"client",
"reading",
"the",
"client",
"ID",
"and",
"secret",
"from",
"the",
"SQlite",
"database",
"."
] | 863d332801d2c1b8e7ad4573c7b16db78a7f8c8d | https://github.com/rycus86/ghost-client/blob/863d332801d2c1b8e7ad4573c7b16db78a7f8c8d/ghost_client/api.py#L142-L180 | train |
rycus86/ghost-client | ghost_client/api.py | Ghost.login | def login(self, username, password):
"""
Authenticate with the server.
:param username: The username of an existing user
:param password: The password for the user
:return: The authentication response from the REST endpoint
"""
data = self._authenticate(
... | python | def login(self, username, password):
"""
Authenticate with the server.
:param username: The username of an existing user
:param password: The password for the user
:return: The authentication response from the REST endpoint
"""
data = self._authenticate(
... | [
"def",
"login",
"(",
"self",
",",
"username",
",",
"password",
")",
":",
"data",
"=",
"self",
".",
"_authenticate",
"(",
"grant_type",
"=",
"'password'",
",",
"username",
"=",
"username",
",",
"password",
"=",
"password",
",",
"client_id",
"=",
"self",
"... | Authenticate with the server.
:param username: The username of an existing user
:param password: The password for the user
:return: The authentication response from the REST endpoint | [
"Authenticate",
"with",
"the",
"server",
"."
] | 863d332801d2c1b8e7ad4573c7b16db78a7f8c8d | https://github.com/rycus86/ghost-client/blob/863d332801d2c1b8e7ad4573c7b16db78a7f8c8d/ghost_client/api.py#L201-L221 | train |
rycus86/ghost-client | ghost_client/api.py | Ghost.refresh_session | def refresh_session(self):
"""
Re-authenticate using the refresh token if available.
Otherwise log in using the username and password
if it was used to authenticate initially.
:return: The authentication response or `None` if not available
"""
if not self._refre... | python | def refresh_session(self):
"""
Re-authenticate using the refresh token if available.
Otherwise log in using the username and password
if it was used to authenticate initially.
:return: The authentication response or `None` if not available
"""
if not self._refre... | [
"def",
"refresh_session",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_refresh_token",
":",
"if",
"self",
".",
"_username",
"and",
"self",
".",
"_password",
":",
"return",
"self",
".",
"login",
"(",
"self",
".",
"_username",
",",
"self",
".",
"_p... | Re-authenticate using the refresh token if available.
Otherwise log in using the username and password
if it was used to authenticate initially.
:return: The authentication response or `None` if not available | [
"Re",
"-",
"authenticate",
"using",
"the",
"refresh",
"token",
"if",
"available",
".",
"Otherwise",
"log",
"in",
"using",
"the",
"username",
"and",
"password",
"if",
"it",
"was",
"used",
"to",
"authenticate",
"initially",
"."
] | 863d332801d2c1b8e7ad4573c7b16db78a7f8c8d | https://github.com/rycus86/ghost-client/blob/863d332801d2c1b8e7ad4573c7b16db78a7f8c8d/ghost_client/api.py#L223-L243 | train |
rycus86/ghost-client | ghost_client/api.py | Ghost.revoke_access_token | def revoke_access_token(self):
"""
Revoke the access token currently in use.
"""
if not self._access_token:
return
self.execute_post('authentication/revoke', json=dict(
token_type_hint='access_token',
token=self._access_token
))
... | python | def revoke_access_token(self):
"""
Revoke the access token currently in use.
"""
if not self._access_token:
return
self.execute_post('authentication/revoke', json=dict(
token_type_hint='access_token',
token=self._access_token
))
... | [
"def",
"revoke_access_token",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_access_token",
":",
"return",
"self",
".",
"execute_post",
"(",
"'authentication/revoke'",
",",
"json",
"=",
"dict",
"(",
"token_type_hint",
"=",
"'access_token'",
",",
"token",
"... | Revoke the access token currently in use. | [
"Revoke",
"the",
"access",
"token",
"currently",
"in",
"use",
"."
] | 863d332801d2c1b8e7ad4573c7b16db78a7f8c8d | https://github.com/rycus86/ghost-client/blob/863d332801d2c1b8e7ad4573c7b16db78a7f8c8d/ghost_client/api.py#L260-L273 | train |
rycus86/ghost-client | ghost_client/api.py | Ghost.revoke_refresh_token | def revoke_refresh_token(self):
"""
Revoke the refresh token currently active.
"""
if not self._refresh_token:
return
self.execute_post('authentication/revoke', json=dict(
token_type_hint='refresh_token',
token=self._refresh_token
))
... | python | def revoke_refresh_token(self):
"""
Revoke the refresh token currently active.
"""
if not self._refresh_token:
return
self.execute_post('authentication/revoke', json=dict(
token_type_hint='refresh_token',
token=self._refresh_token
))
... | [
"def",
"revoke_refresh_token",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_refresh_token",
":",
"return",
"self",
".",
"execute_post",
"(",
"'authentication/revoke'",
",",
"json",
"=",
"dict",
"(",
"token_type_hint",
"=",
"'refresh_token'",
",",
"token",
... | Revoke the refresh token currently active. | [
"Revoke",
"the",
"refresh",
"token",
"currently",
"active",
"."
] | 863d332801d2c1b8e7ad4573c7b16db78a7f8c8d | https://github.com/rycus86/ghost-client/blob/863d332801d2c1b8e7ad4573c7b16db78a7f8c8d/ghost_client/api.py#L275-L288 | train |
rycus86/ghost-client | ghost_client/api.py | Ghost.logout | def logout(self):
"""
Log out, revoking the access tokens
and forgetting the login details if they were given.
"""
self.revoke_refresh_token()
self.revoke_access_token()
self._username, self._password = None, None | python | def logout(self):
"""
Log out, revoking the access tokens
and forgetting the login details if they were given.
"""
self.revoke_refresh_token()
self.revoke_access_token()
self._username, self._password = None, None | [
"def",
"logout",
"(",
"self",
")",
":",
"self",
".",
"revoke_refresh_token",
"(",
")",
"self",
".",
"revoke_access_token",
"(",
")",
"self",
".",
"_username",
",",
"self",
".",
"_password",
"=",
"None",
",",
"None"
] | Log out, revoking the access tokens
and forgetting the login details if they were given. | [
"Log",
"out",
"revoking",
"the",
"access",
"tokens",
"and",
"forgetting",
"the",
"login",
"details",
"if",
"they",
"were",
"given",
"."
] | 863d332801d2c1b8e7ad4573c7b16db78a7f8c8d | https://github.com/rycus86/ghost-client/blob/863d332801d2c1b8e7ad4573c7b16db78a7f8c8d/ghost_client/api.py#L290-L299 | train |
rycus86/ghost-client | ghost_client/api.py | Ghost.upload | def upload(self, file_obj=None, file_path=None, name=None, data=None):
"""
Upload an image and return its path on the server.
Either `file_obj` or `file_path` or `name` and `data` has to be specified.
:param file_obj: A file object to upload
:param file_path: A file path to uplo... | python | def upload(self, file_obj=None, file_path=None, name=None, data=None):
"""
Upload an image and return its path on the server.
Either `file_obj` or `file_path` or `name` and `data` has to be specified.
:param file_obj: A file object to upload
:param file_path: A file path to uplo... | [
"def",
"upload",
"(",
"self",
",",
"file_obj",
"=",
"None",
",",
"file_path",
"=",
"None",
",",
"name",
"=",
"None",
",",
"data",
"=",
"None",
")",
":",
"close",
"=",
"False",
"if",
"file_obj",
":",
"file_name",
",",
"content",
"=",
"os",
".",
"pat... | Upload an image and return its path on the server.
Either `file_obj` or `file_path` or `name` and `data` has to be specified.
:param file_obj: A file object to upload
:param file_path: A file path to upload from
:param name: A file name for uploading
:param data: The file conten... | [
"Upload",
"an",
"image",
"and",
"return",
"its",
"path",
"on",
"the",
"server",
".",
"Either",
"file_obj",
"or",
"file_path",
"or",
"name",
"and",
"data",
"has",
"to",
"be",
"specified",
"."
] | 863d332801d2c1b8e7ad4573c7b16db78a7f8c8d | https://github.com/rycus86/ghost-client/blob/863d332801d2c1b8e7ad4573c7b16db78a7f8c8d/ghost_client/api.py#L301-L343 | train |
rycus86/ghost-client | ghost_client/api.py | Ghost.execute_get | def execute_get(self, resource, **kwargs):
"""
Execute an HTTP GET request against the API endpoints.
This method is meant for internal use.
:param resource: The last part of the URI
:param kwargs: Additional query parameters (and optionally headers)
:return: The HTTP re... | python | def execute_get(self, resource, **kwargs):
"""
Execute an HTTP GET request against the API endpoints.
This method is meant for internal use.
:param resource: The last part of the URI
:param kwargs: Additional query parameters (and optionally headers)
:return: The HTTP re... | [
"def",
"execute_get",
"(",
"self",
",",
"resource",
",",
"**",
"kwargs",
")",
":",
"url",
"=",
"'%s/%s'",
"%",
"(",
"self",
".",
"base_url",
",",
"resource",
")",
"headers",
"=",
"kwargs",
".",
"pop",
"(",
"'headers'",
",",
"dict",
"(",
")",
")",
"... | Execute an HTTP GET request against the API endpoints.
This method is meant for internal use.
:param resource: The last part of the URI
:param kwargs: Additional query parameters (and optionally headers)
:return: The HTTP response as JSON or `GhostException` if unsuccessful | [
"Execute",
"an",
"HTTP",
"GET",
"request",
"against",
"the",
"API",
"endpoints",
".",
"This",
"method",
"is",
"meant",
"for",
"internal",
"use",
"."
] | 863d332801d2c1b8e7ad4573c7b16db78a7f8c8d | https://github.com/rycus86/ghost-client/blob/863d332801d2c1b8e7ad4573c7b16db78a7f8c8d/ghost_client/api.py#L346-L389 | train |
rycus86/ghost-client | ghost_client/api.py | Ghost.execute_post | def execute_post(self, resource, **kwargs):
"""
Execute an HTTP POST request against the API endpoints.
This method is meant for internal use.
:param resource: The last part of the URI
:param kwargs: Additional parameters for the HTTP call (`request` library)
:return: Th... | python | def execute_post(self, resource, **kwargs):
"""
Execute an HTTP POST request against the API endpoints.
This method is meant for internal use.
:param resource: The last part of the URI
:param kwargs: Additional parameters for the HTTP call (`request` library)
:return: Th... | [
"def",
"execute_post",
"(",
"self",
",",
"resource",
",",
"**",
"kwargs",
")",
":",
"return",
"self",
".",
"_request",
"(",
"resource",
",",
"requests",
".",
"post",
",",
"**",
"kwargs",
")",
".",
"json",
"(",
")"
] | Execute an HTTP POST request against the API endpoints.
This method is meant for internal use.
:param resource: The last part of the URI
:param kwargs: Additional parameters for the HTTP call (`request` library)
:return: The HTTP response as JSON or `GhostException` if unsuccessful | [
"Execute",
"an",
"HTTP",
"POST",
"request",
"against",
"the",
"API",
"endpoints",
".",
"This",
"method",
"is",
"meant",
"for",
"internal",
"use",
"."
] | 863d332801d2c1b8e7ad4573c7b16db78a7f8c8d | https://github.com/rycus86/ghost-client/blob/863d332801d2c1b8e7ad4573c7b16db78a7f8c8d/ghost_client/api.py#L391-L401 | train |
rycus86/ghost-client | ghost_client/api.py | Ghost.execute_put | def execute_put(self, resource, **kwargs):
"""
Execute an HTTP PUT request against the API endpoints.
This method is meant for internal use.
:param resource: The last part of the URI
:param kwargs: Additional parameters for the HTTP call (`request` library)
:return: The ... | python | def execute_put(self, resource, **kwargs):
"""
Execute an HTTP PUT request against the API endpoints.
This method is meant for internal use.
:param resource: The last part of the URI
:param kwargs: Additional parameters for the HTTP call (`request` library)
:return: The ... | [
"def",
"execute_put",
"(",
"self",
",",
"resource",
",",
"**",
"kwargs",
")",
":",
"return",
"self",
".",
"_request",
"(",
"resource",
",",
"requests",
".",
"put",
",",
"**",
"kwargs",
")",
".",
"json",
"(",
")"
] | Execute an HTTP PUT request against the API endpoints.
This method is meant for internal use.
:param resource: The last part of the URI
:param kwargs: Additional parameters for the HTTP call (`request` library)
:return: The HTTP response as JSON or `GhostException` if unsuccessful | [
"Execute",
"an",
"HTTP",
"PUT",
"request",
"against",
"the",
"API",
"endpoints",
".",
"This",
"method",
"is",
"meant",
"for",
"internal",
"use",
"."
] | 863d332801d2c1b8e7ad4573c7b16db78a7f8c8d | https://github.com/rycus86/ghost-client/blob/863d332801d2c1b8e7ad4573c7b16db78a7f8c8d/ghost_client/api.py#L403-L413 | train |
rycus86/ghost-client | ghost_client/api.py | Ghost.execute_delete | def execute_delete(self, resource, **kwargs):
"""
Execute an HTTP DELETE request against the API endpoints.
This method is meant for internal use.
Does not return anything but raises an exception when failed.
:param resource: The last part of the URI
:param kwargs: Addit... | python | def execute_delete(self, resource, **kwargs):
"""
Execute an HTTP DELETE request against the API endpoints.
This method is meant for internal use.
Does not return anything but raises an exception when failed.
:param resource: The last part of the URI
:param kwargs: Addit... | [
"def",
"execute_delete",
"(",
"self",
",",
"resource",
",",
"**",
"kwargs",
")",
":",
"self",
".",
"_request",
"(",
"resource",
",",
"requests",
".",
"delete",
",",
"**",
"kwargs",
")"
] | Execute an HTTP DELETE request against the API endpoints.
This method is meant for internal use.
Does not return anything but raises an exception when failed.
:param resource: The last part of the URI
:param kwargs: Additional parameters for the HTTP call (`request` library) | [
"Execute",
"an",
"HTTP",
"DELETE",
"request",
"against",
"the",
"API",
"endpoints",
".",
"This",
"method",
"is",
"meant",
"for",
"internal",
"use",
".",
"Does",
"not",
"return",
"anything",
"but",
"raises",
"an",
"exception",
"when",
"failed",
"."
] | 863d332801d2c1b8e7ad4573c7b16db78a7f8c8d | https://github.com/rycus86/ghost-client/blob/863d332801d2c1b8e7ad4573c7b16db78a7f8c8d/ghost_client/api.py#L415-L425 | train |
inveniosoftware-contrib/json-merger | json_merger/contrib/inspirehep/author_util.py | token_distance | def token_distance(t1, t2, initial_match_penalization):
"""Calculates the edit distance between two tokens."""
if isinstance(t1, NameInitial) or isinstance(t2, NameInitial):
if t1.token == t2.token:
return 0
if t1 == t2:
return initial_match_penalization
return 1.... | python | def token_distance(t1, t2, initial_match_penalization):
"""Calculates the edit distance between two tokens."""
if isinstance(t1, NameInitial) or isinstance(t2, NameInitial):
if t1.token == t2.token:
return 0
if t1 == t2:
return initial_match_penalization
return 1.... | [
"def",
"token_distance",
"(",
"t1",
",",
"t2",
",",
"initial_match_penalization",
")",
":",
"if",
"isinstance",
"(",
"t1",
",",
"NameInitial",
")",
"or",
"isinstance",
"(",
"t2",
",",
"NameInitial",
")",
":",
"if",
"t1",
".",
"token",
"==",
"t2",
".",
... | Calculates the edit distance between two tokens. | [
"Calculates",
"the",
"edit",
"distance",
"between",
"two",
"tokens",
"."
] | adc6d372da018427e1db7b92424d3471e01a4118 | https://github.com/inveniosoftware-contrib/json-merger/blob/adc6d372da018427e1db7b92424d3471e01a4118/json_merger/contrib/inspirehep/author_util.py#L60-L68 | train |
inveniosoftware-contrib/json-merger | json_merger/contrib/inspirehep/author_util.py | simple_tokenize | def simple_tokenize(name):
"""Simple tokenizer function to be used with the normalizers."""
last_names, first_names = name.split(',')
last_names = _RE_NAME_TOKEN_SEPARATOR.split(last_names)
first_names = _RE_NAME_TOKEN_SEPARATOR.split(first_names)
first_names = [NameToken(n) if len(n) > 1 else Name... | python | def simple_tokenize(name):
"""Simple tokenizer function to be used with the normalizers."""
last_names, first_names = name.split(',')
last_names = _RE_NAME_TOKEN_SEPARATOR.split(last_names)
first_names = _RE_NAME_TOKEN_SEPARATOR.split(first_names)
first_names = [NameToken(n) if len(n) > 1 else Name... | [
"def",
"simple_tokenize",
"(",
"name",
")",
":",
"last_names",
",",
"first_names",
"=",
"name",
".",
"split",
"(",
"','",
")",
"last_names",
"=",
"_RE_NAME_TOKEN_SEPARATOR",
".",
"split",
"(",
"last_names",
")",
"first_names",
"=",
"_RE_NAME_TOKEN_SEPARATOR",
".... | Simple tokenizer function to be used with the normalizers. | [
"Simple",
"tokenizer",
"function",
"to",
"be",
"used",
"with",
"the",
"normalizers",
"."
] | adc6d372da018427e1db7b92424d3471e01a4118 | https://github.com/inveniosoftware-contrib/json-merger/blob/adc6d372da018427e1db7b92424d3471e01a4118/json_merger/contrib/inspirehep/author_util.py#L71-L82 | train |
ldomic/lintools | lintools/ligand_description.py | LigDescr.calculate_descriptors | def calculate_descriptors(self,mol):
"""Calculates descriptors such as logP, charges and MR and saves that in a dictionary."""
#make dictionary
self.ligand_atoms = {index:{"name":x.name} for index,x in enumerate(self.topology_data.universe.ligand_noH.atoms)}
#Calculate logP and MR
contribs = self.calculate_l... | python | def calculate_descriptors(self,mol):
"""Calculates descriptors such as logP, charges and MR and saves that in a dictionary."""
#make dictionary
self.ligand_atoms = {index:{"name":x.name} for index,x in enumerate(self.topology_data.universe.ligand_noH.atoms)}
#Calculate logP and MR
contribs = self.calculate_l... | [
"def",
"calculate_descriptors",
"(",
"self",
",",
"mol",
")",
":",
"self",
".",
"ligand_atoms",
"=",
"{",
"index",
":",
"{",
"\"name\"",
":",
"x",
".",
"name",
"}",
"for",
"index",
",",
"x",
"in",
"enumerate",
"(",
"self",
".",
"topology_data",
".",
... | Calculates descriptors such as logP, charges and MR and saves that in a dictionary. | [
"Calculates",
"descriptors",
"such",
"as",
"logP",
"charges",
"and",
"MR",
"and",
"saves",
"that",
"in",
"a",
"dictionary",
"."
] | d825a4a7b35f3f857d3b81b46c9aee72b0ec697a | https://github.com/ldomic/lintools/blob/d825a4a7b35f3f857d3b81b46c9aee72b0ec697a/lintools/ligand_description.py#L23-L44 | train |
robinandeer/puzzle | puzzle/plugins/vcf/mixins/variant_mixin.py | VariantMixin.variants | def variants(self, case_id, skip=0, count=1000, filters=None):
"""Return all variants in the VCF.
This function will apply the given filter and return the 'count' first
variants. If skip the first 'skip' variants will not be regarded.
Args:
case_id (str): Path to a ... | python | def variants(self, case_id, skip=0, count=1000, filters=None):
"""Return all variants in the VCF.
This function will apply the given filter and return the 'count' first
variants. If skip the first 'skip' variants will not be regarded.
Args:
case_id (str): Path to a ... | [
"def",
"variants",
"(",
"self",
",",
"case_id",
",",
"skip",
"=",
"0",
",",
"count",
"=",
"1000",
",",
"filters",
"=",
"None",
")",
":",
"filters",
"=",
"filters",
"or",
"{",
"}",
"case_obj",
"=",
"self",
".",
"case",
"(",
"case_id",
"=",
"case_id"... | Return all variants in the VCF.
This function will apply the given filter and return the 'count' first
variants. If skip the first 'skip' variants will not be regarded.
Args:
case_id (str): Path to a vcf file (for this adapter)
skip (int): Skip first variant... | [
"Return",
"all",
"variants",
"in",
"the",
"VCF",
"."
] | 9476f05b416d3a5135d25492cb31411fdf831c58 | https://github.com/robinandeer/puzzle/blob/9476f05b416d3a5135d25492cb31411fdf831c58/puzzle/plugins/vcf/mixins/variant_mixin.py#L54-L164 | train |
robinandeer/puzzle | puzzle/plugins/vcf/mixins/variant_mixin.py | VariantMixin._get_filtered_variants | def _get_filtered_variants(self, vcf_file_path, filters={}):
"""Check if variants follows the filters
This function will try to make filters faster for the vcf adapter
Args:
vcf_file_path(str): Path to vcf
filters (dict): A dictionary with filters
... | python | def _get_filtered_variants(self, vcf_file_path, filters={}):
"""Check if variants follows the filters
This function will try to make filters faster for the vcf adapter
Args:
vcf_file_path(str): Path to vcf
filters (dict): A dictionary with filters
... | [
"def",
"_get_filtered_variants",
"(",
"self",
",",
"vcf_file_path",
",",
"filters",
"=",
"{",
"}",
")",
":",
"genes",
"=",
"set",
"(",
")",
"consequences",
"=",
"set",
"(",
")",
"sv_types",
"=",
"set",
"(",
")",
"if",
"filters",
".",
"get",
"(",
"'ge... | Check if variants follows the filters
This function will try to make filters faster for the vcf adapter
Args:
vcf_file_path(str): Path to vcf
filters (dict): A dictionary with filters
Yields:
varian_line (str): A vcf variant line | [
"Check",
"if",
"variants",
"follows",
"the",
"filters"
] | 9476f05b416d3a5135d25492cb31411fdf831c58 | https://github.com/robinandeer/puzzle/blob/9476f05b416d3a5135d25492cb31411fdf831c58/puzzle/plugins/vcf/mixins/variant_mixin.py#L166-L231 | train |
znerol/py-fnvhash | fnvhash/__init__.py | fnv | def fnv(data, hval_init, fnv_prime, fnv_size):
"""
Core FNV hash algorithm used in FNV0 and FNV1.
"""
assert isinstance(data, bytes)
hval = hval_init
for byte in data:
hval = (hval * fnv_prime) % fnv_size
hval = hval ^ _get_byte(byte)
return hval | python | def fnv(data, hval_init, fnv_prime, fnv_size):
"""
Core FNV hash algorithm used in FNV0 and FNV1.
"""
assert isinstance(data, bytes)
hval = hval_init
for byte in data:
hval = (hval * fnv_prime) % fnv_size
hval = hval ^ _get_byte(byte)
return hval | [
"def",
"fnv",
"(",
"data",
",",
"hval_init",
",",
"fnv_prime",
",",
"fnv_size",
")",
":",
"assert",
"isinstance",
"(",
"data",
",",
"bytes",
")",
"hval",
"=",
"hval_init",
"for",
"byte",
"in",
"data",
":",
"hval",
"=",
"(",
"hval",
"*",
"fnv_prime",
... | Core FNV hash algorithm used in FNV0 and FNV1. | [
"Core",
"FNV",
"hash",
"algorithm",
"used",
"in",
"FNV0",
"and",
"FNV1",
"."
] | ea6d6993e1082dee2ca3b9aba7a7eb2b7ab6a52a | https://github.com/znerol/py-fnvhash/blob/ea6d6993e1082dee2ca3b9aba7a7eb2b7ab6a52a/fnvhash/__init__.py#L26-L36 | train |
eleme/meepo | meepo/apps/eventsourcing/pub.py | sqlalchemy_es_pub.session_prepare | def session_prepare(self, session, _):
"""Send session_prepare signal in session "before_commit".
The signal contains another event argument, which records whole info
of what's changed in this session, so the signal receiver can receive
and record the event.
"""
if not h... | python | def session_prepare(self, session, _):
"""Send session_prepare signal in session "before_commit".
The signal contains another event argument, which records whole info
of what's changed in this session, so the signal receiver can receive
and record the event.
"""
if not h... | [
"def",
"session_prepare",
"(",
"self",
",",
"session",
",",
"_",
")",
":",
"if",
"not",
"hasattr",
"(",
"session",
",",
"'meepo_unique_id'",
")",
":",
"self",
".",
"_session_init",
"(",
"session",
")",
"evt",
"=",
"collections",
".",
"defaultdict",
"(",
... | Send session_prepare signal in session "before_commit".
The signal contains another event argument, which records whole info
of what's changed in this session, so the signal receiver can receive
and record the event. | [
"Send",
"session_prepare",
"signal",
"in",
"session",
"before_commit",
"."
] | 8212f0fe9b1d44be0c5de72d221a31c1d24bfe7a | https://github.com/eleme/meepo/blob/8212f0fe9b1d44be0c5de72d221a31c1d24bfe7a/meepo/apps/eventsourcing/pub.py#L75-L100 | train |
eleme/meepo | meepo/apps/eventsourcing/pub.py | sqlalchemy_es_pub.session_commit | def session_commit(self, session):
"""Send session_commit signal in sqlalchemy ``before_commit``.
This marks the success of session so the session may enter commit
state.
"""
# this may happen when there's nothing to commit
if not hasattr(session, 'meepo_unique_id'):
... | python | def session_commit(self, session):
"""Send session_commit signal in sqlalchemy ``before_commit``.
This marks the success of session so the session may enter commit
state.
"""
# this may happen when there's nothing to commit
if not hasattr(session, 'meepo_unique_id'):
... | [
"def",
"session_commit",
"(",
"self",
",",
"session",
")",
":",
"if",
"not",
"hasattr",
"(",
"session",
",",
"'meepo_unique_id'",
")",
":",
"self",
".",
"logger",
".",
"debug",
"(",
"\"skipped - session_commit\"",
")",
"return",
"self",
".",
"logger",
".",
... | Send session_commit signal in sqlalchemy ``before_commit``.
This marks the success of session so the session may enter commit
state. | [
"Send",
"session_commit",
"signal",
"in",
"sqlalchemy",
"before_commit",
"."
] | 8212f0fe9b1d44be0c5de72d221a31c1d24bfe7a | https://github.com/eleme/meepo/blob/8212f0fe9b1d44be0c5de72d221a31c1d24bfe7a/meepo/apps/eventsourcing/pub.py#L102-L117 | train |
eleme/meepo | meepo/apps/eventsourcing/pub.py | sqlalchemy_es_pub.session_rollback | def session_rollback(self, session):
"""Send session_rollback signal in sqlalchemy ``after_rollback``.
This marks the failure of session so the session may enter commit
phase.
"""
# this may happen when there's nothing to rollback
if not hasattr(session, 'meepo_unique_id... | python | def session_rollback(self, session):
"""Send session_rollback signal in sqlalchemy ``after_rollback``.
This marks the failure of session so the session may enter commit
phase.
"""
# this may happen when there's nothing to rollback
if not hasattr(session, 'meepo_unique_id... | [
"def",
"session_rollback",
"(",
"self",
",",
"session",
")",
":",
"if",
"not",
"hasattr",
"(",
"session",
",",
"'meepo_unique_id'",
")",
":",
"self",
".",
"logger",
".",
"debug",
"(",
"\"skipped - session_rollback\"",
")",
"return",
"self",
".",
"logger",
".... | Send session_rollback signal in sqlalchemy ``after_rollback``.
This marks the failure of session so the session may enter commit
phase. | [
"Send",
"session_rollback",
"signal",
"in",
"sqlalchemy",
"after_rollback",
"."
] | 8212f0fe9b1d44be0c5de72d221a31c1d24bfe7a | https://github.com/eleme/meepo/blob/8212f0fe9b1d44be0c5de72d221a31c1d24bfe7a/meepo/apps/eventsourcing/pub.py#L119-L133 | train |
jam31118/vis | vis/plot.py | process_fig_and_ax_argument | def process_fig_and_ax_argument(fig, ax, default_figsize=None):
"""Process 'fig' and 'ax' arguments.
'fig' is of type: 'matplotlib.figure.Figure' (or its child object)
'ax' is of type: 'matplotlib.axes._base._AxesBase' (or its child object)
'fig' and 'ax' should be simultaneously None or of respective... | python | def process_fig_and_ax_argument(fig, ax, default_figsize=None):
"""Process 'fig' and 'ax' arguments.
'fig' is of type: 'matplotlib.figure.Figure' (or its child object)
'ax' is of type: 'matplotlib.axes._base._AxesBase' (or its child object)
'fig' and 'ax' should be simultaneously None or of respective... | [
"def",
"process_fig_and_ax_argument",
"(",
"fig",
",",
"ax",
",",
"default_figsize",
"=",
"None",
")",
":",
"if",
"default_figsize",
"is",
"not",
"None",
":",
"assert",
"type",
"(",
"default_figsize",
")",
"in",
"[",
"tuple",
",",
"list",
"]",
"assert",
"l... | Process 'fig' and 'ax' arguments.
'fig' is of type: 'matplotlib.figure.Figure' (or its child object)
'ax' is of type: 'matplotlib.axes._base._AxesBase' (or its child object)
'fig' and 'ax' should be simultaneously None or of respective proper type. | [
"Process",
"fig",
"and",
"ax",
"arguments",
"."
] | 965ebec102c539b323d5756fef04153ac71e50d9 | https://github.com/jam31118/vis/blob/965ebec102c539b323d5756fef04153ac71e50d9/vis/plot.py#L123-L139 | train |
jam31118/vis | vis/plot.py | get_square_axes_limits | def get_square_axes_limits(coords, margin=0.05):
"""Return N-dimensional square's limits
## Arguments
# 'coords': list of coordinates of poins to be plotted
# 'margin': margin to be added from boundaries of the square.
- 'margin' can be negative if one wants to reduce the square size.
## Examp... | python | def get_square_axes_limits(coords, margin=0.05):
"""Return N-dimensional square's limits
## Arguments
# 'coords': list of coordinates of poins to be plotted
# 'margin': margin to be added from boundaries of the square.
- 'margin' can be negative if one wants to reduce the square size.
## Examp... | [
"def",
"get_square_axes_limits",
"(",
"coords",
",",
"margin",
"=",
"0.05",
")",
":",
"try",
":",
"coords",
"=",
"[",
"np",
".",
"array",
"(",
"coord",
")",
"for",
"coord",
"in",
"coords",
"]",
"except",
":",
"raise",
"Exception",
"(",
"\"Failed to conve... | Return N-dimensional square's limits
## Arguments
# 'coords': list of coordinates of poins to be plotted
# 'margin': margin to be added from boundaries of the square.
- 'margin' can be negative if one wants to reduce the square size.
## Example
if 'coords' was given as [x,y,z],
then the r... | [
"Return",
"N",
"-",
"dimensional",
"square",
"s",
"limits"
] | 965ebec102c539b323d5756fef04153ac71e50d9 | https://github.com/jam31118/vis/blob/965ebec102c539b323d5756fef04153ac71e50d9/vis/plot.py#L209-L246 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.