repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1
value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
mitsei/dlkit | dlkit/json_/learning/objects.py | ObjectiveBankNode.get_objective_bank | def get_objective_bank(self):
"""Gets the ``ObjectiveBank`` at this node.
return: (osid.learning.ObjectiveBank) - the objective bank
represented by this node
*compliance: mandatory -- This method must be implemented.*
"""
if self._lookup_session is None:
... | python | def get_objective_bank(self):
"""Gets the ``ObjectiveBank`` at this node.
return: (osid.learning.ObjectiveBank) - the objective bank
represented by this node
*compliance: mandatory -- This method must be implemented.*
"""
if self._lookup_session is None:
... | [
"def",
"get_objective_bank",
"(",
"self",
")",
":",
"if",
"self",
".",
"_lookup_session",
"is",
"None",
":",
"mgr",
"=",
"get_provider_manager",
"(",
"'LEARNING'",
",",
"runtime",
"=",
"self",
".",
"_runtime",
",",
"proxy",
"=",
"self",
".",
"_proxy",
")",... | Gets the ``ObjectiveBank`` at this node.
return: (osid.learning.ObjectiveBank) - the objective bank
represented by this node
*compliance: mandatory -- This method must be implemented.* | [
"Gets",
"the",
"ObjectiveBank",
"at",
"this",
"node",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/learning/objects.py#L1596-L1607 |
mitsei/dlkit | dlkit/json_/learning/objects.py | ObjectiveBankNode.get_parent_objective_bank_nodes | def get_parent_objective_bank_nodes(self):
"""Gets the parents of this objective bank.
return: (osid.learning.ObjectiveBankNodeList) - the parents of
the ``id``
*compliance: mandatory -- This method must be implemented.*
"""
parent_objective_bank_nodes = []
... | python | def get_parent_objective_bank_nodes(self):
"""Gets the parents of this objective bank.
return: (osid.learning.ObjectiveBankNodeList) - the parents of
the ``id``
*compliance: mandatory -- This method must be implemented.*
"""
parent_objective_bank_nodes = []
... | [
"def",
"get_parent_objective_bank_nodes",
"(",
"self",
")",
":",
"parent_objective_bank_nodes",
"=",
"[",
"]",
"for",
"node",
"in",
"self",
".",
"_my_map",
"[",
"'parentNodes'",
"]",
":",
"parent_objective_bank_nodes",
".",
"append",
"(",
"ObjectiveBankNode",
"(",
... | Gets the parents of this objective bank.
return: (osid.learning.ObjectiveBankNodeList) - the parents of
the ``id``
*compliance: mandatory -- This method must be implemented.* | [
"Gets",
"the",
"parents",
"of",
"this",
"objective",
"bank",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/learning/objects.py#L1611-L1626 |
mitsei/dlkit | dlkit/authz_adapter/learning/sessions.py | ObjectiveSearchSession.get_objectives_by_search | def get_objectives_by_search(self, objective_query, objective_search):
"""Pass through to provider ObjectiveSearchSession.get_objectives_by_search"""
# Implemented from azosid template for -
# osid.resource.ResourceSearchSession.get_resources_by_search_template
if not self._can('search')... | python | def get_objectives_by_search(self, objective_query, objective_search):
"""Pass through to provider ObjectiveSearchSession.get_objectives_by_search"""
# Implemented from azosid template for -
# osid.resource.ResourceSearchSession.get_resources_by_search_template
if not self._can('search')... | [
"def",
"get_objectives_by_search",
"(",
"self",
",",
"objective_query",
",",
"objective_search",
")",
":",
"# Implemented from azosid template for -",
"# osid.resource.ResourceSearchSession.get_resources_by_search_template",
"if",
"not",
"self",
".",
"_can",
"(",
"'search'",
")... | Pass through to provider ObjectiveSearchSession.get_objectives_by_search | [
"Pass",
"through",
"to",
"provider",
"ObjectiveSearchSession",
".",
"get_objectives_by_search"
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/authz_adapter/learning/sessions.py#L327-L333 |
mitsei/dlkit | dlkit/authz_adapter/learning/sessions.py | ActivitySearchSession.get_activities_by_search | def get_activities_by_search(self, activity_query, activitiesearch):
"""Pass through to provider ActivitySearchSession.get_activities_by_search"""
# Implemented from azosid template for -
# osid.resource.ResourceSearchSession.get_resources_by_search_template
if not self._can('search'):
... | python | def get_activities_by_search(self, activity_query, activitiesearch):
"""Pass through to provider ActivitySearchSession.get_activities_by_search"""
# Implemented from azosid template for -
# osid.resource.ResourceSearchSession.get_resources_by_search_template
if not self._can('search'):
... | [
"def",
"get_activities_by_search",
"(",
"self",
",",
"activity_query",
",",
"activitiesearch",
")",
":",
"# Implemented from azosid template for -",
"# osid.resource.ResourceSearchSession.get_resources_by_search_template",
"if",
"not",
"self",
".",
"_can",
"(",
"'search'",
")",... | Pass through to provider ActivitySearchSession.get_activities_by_search | [
"Pass",
"through",
"to",
"provider",
"ActivitySearchSession",
".",
"get_activities_by_search"
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/authz_adapter/learning/sessions.py#L1444-L1450 |
mitsei/dlkit | dlkit/authz_adapter/learning/sessions.py | ProficiencyLookupSession.get_proficiencies_for_resource_on_date | def get_proficiencies_for_resource_on_date(self, resource_id, from_, to):
"""Pass through to provider ProficiencyLookupSession.get_proficiencies_for_resource_on_date"""
# Implemented from azosid template for -
# osid.relationship.RelationshipLookupSession.get_relationships_for_source_on_date_tem... | python | def get_proficiencies_for_resource_on_date(self, resource_id, from_, to):
"""Pass through to provider ProficiencyLookupSession.get_proficiencies_for_resource_on_date"""
# Implemented from azosid template for -
# osid.relationship.RelationshipLookupSession.get_relationships_for_source_on_date_tem... | [
"def",
"get_proficiencies_for_resource_on_date",
"(",
"self",
",",
"resource_id",
",",
"from_",
",",
"to",
")",
":",
"# Implemented from azosid template for -",
"# osid.relationship.RelationshipLookupSession.get_relationships_for_source_on_date_template",
"if",
"self",
".",
"_can",... | Pass through to provider ProficiencyLookupSession.get_proficiencies_for_resource_on_date | [
"Pass",
"through",
"to",
"provider",
"ProficiencyLookupSession",
".",
"get_proficiencies_for_resource_on_date"
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/authz_adapter/learning/sessions.py#L2102-L2112 |
mitsei/dlkit | dlkit/authz_adapter/learning/sessions.py | ProficiencySearchSession.get_proficiencies_by_search | def get_proficiencies_by_search(self, proficiency_query, proficiency_search):
"""Pass through to provider ProficiencySearchSession.get_proficiencies_by_search"""
# Implemented from azosid template for -
# osid.resource.ResourceSearchSession.get_resources_by_search_template
if not self._c... | python | def get_proficiencies_by_search(self, proficiency_query, proficiency_search):
"""Pass through to provider ProficiencySearchSession.get_proficiencies_by_search"""
# Implemented from azosid template for -
# osid.resource.ResourceSearchSession.get_resources_by_search_template
if not self._c... | [
"def",
"get_proficiencies_by_search",
"(",
"self",
",",
"proficiency_query",
",",
"proficiency_search",
")",
":",
"# Implemented from azosid template for -",
"# osid.resource.ResourceSearchSession.get_resources_by_search_template",
"if",
"not",
"self",
".",
"_can",
"(",
"'search'... | Pass through to provider ProficiencySearchSession.get_proficiencies_by_search | [
"Pass",
"through",
"to",
"provider",
"ProficiencySearchSession",
".",
"get_proficiencies_by_search"
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/authz_adapter/learning/sessions.py#L2298-L2304 |
raamana/hiwenet | hiwenet/pairwise_dist.py | compute_bin_edges | def compute_bin_edges(features, num_bins, edge_range, trim_outliers, trim_percentile, use_orig_distr=False):
"Compute the edges for the histogram bins to keep it the same for all nodes."
if use_orig_distr:
print('Using original distribution (without histogram) to compute edge weights!')
edges=N... | python | def compute_bin_edges(features, num_bins, edge_range, trim_outliers, trim_percentile, use_orig_distr=False):
"Compute the edges for the histogram bins to keep it the same for all nodes."
if use_orig_distr:
print('Using original distribution (without histogram) to compute edge weights!')
edges=N... | [
"def",
"compute_bin_edges",
"(",
"features",
",",
"num_bins",
",",
"edge_range",
",",
"trim_outliers",
",",
"trim_percentile",
",",
"use_orig_distr",
"=",
"False",
")",
":",
"if",
"use_orig_distr",
":",
"print",
"(",
"'Using original distribution (without histogram) to ... | Compute the edges for the histogram bins to keep it the same for all nodes. | [
"Compute",
"the",
"edges",
"for",
"the",
"histogram",
"bins",
"to",
"keep",
"it",
"the",
"same",
"for",
"all",
"nodes",
"."
] | train | https://github.com/raamana/hiwenet/blob/b12699b3722fd0a6a835e7d7ca4baf58fb181809/hiwenet/pairwise_dist.py#L66-L87 |
raamana/hiwenet | hiwenet/pairwise_dist.py | extract | def extract(features, groups,
weight_method=default_weight_method,
num_bins=default_num_bins,
edge_range=default_edge_range,
trim_outliers=default_trim_behaviour,
trim_percentile=default_trim_percentile,
use_original_distribution=False,
... | python | def extract(features, groups,
weight_method=default_weight_method,
num_bins=default_num_bins,
edge_range=default_edge_range,
trim_outliers=default_trim_behaviour,
trim_percentile=default_trim_percentile,
use_original_distribution=False,
... | [
"def",
"extract",
"(",
"features",
",",
"groups",
",",
"weight_method",
"=",
"default_weight_method",
",",
"num_bins",
"=",
"default_num_bins",
",",
"edge_range",
"=",
"default_edge_range",
",",
"trim_outliers",
"=",
"default_trim_behaviour",
",",
"trim_percentile",
"... | Extracts the histogram-distance weighted adjacency matrix.
Parameters
----------
features : ndarray or str
1d array of scalar values, either provided directly as a 1d numpy array,
or as a path to a file containing these values
groups : ndarray or str
Membership array of same le... | [
"Extracts",
"the",
"histogram",
"-",
"distance",
"weighted",
"adjacency",
"matrix",
"."
] | train | https://github.com/raamana/hiwenet/blob/b12699b3722fd0a6a835e7d7ca4baf58fb181809/hiwenet/pairwise_dist.py#L90-L307 |
raamana/hiwenet | hiwenet/pairwise_dist.py | pairwise_extract | def pairwise_extract(features, groups, edges, weight_func, use_orig_distr,
group_ids, num_groups, num_links,
non_symmetric, return_networkx_graph, out_weights_path):
"""
Core function to compute the pair-wise histogram distance between all ROIs.
Parameters
----... | python | def pairwise_extract(features, groups, edges, weight_func, use_orig_distr,
group_ids, num_groups, num_links,
non_symmetric, return_networkx_graph, out_weights_path):
"""
Core function to compute the pair-wise histogram distance between all ROIs.
Parameters
----... | [
"def",
"pairwise_extract",
"(",
"features",
",",
"groups",
",",
"edges",
",",
"weight_func",
",",
"use_orig_distr",
",",
"group_ids",
",",
"num_groups",
",",
"num_links",
",",
"non_symmetric",
",",
"return_networkx_graph",
",",
"out_weights_path",
")",
":",
"# the... | Core function to compute the pair-wise histogram distance between all ROIs.
Parameters
----------
features
groups
edges
weight_func
use_orig_distr
group_ids
num_groups
num_links
non_symmetric
return_networkx_graph
out_weights_path
Returns
-------
result ... | [
"Core",
"function",
"to",
"compute",
"the",
"pair",
"-",
"wise",
"histogram",
"distance",
"between",
"all",
"ROIs",
"."
] | train | https://github.com/raamana/hiwenet/blob/b12699b3722fd0a6a835e7d7ca4baf58fb181809/hiwenet/pairwise_dist.py#L310-L397 |
raamana/hiwenet | hiwenet/pairwise_dist.py | identify_groups | def identify_groups(groups):
"""
To compute number of unique elements in a given membership specification.
Parameters
----------
groups : numpy 1d array of length p, each value specifying which group that particular node belongs to.
For examlpe, if you have a cortical thickness values for 1... | python | def identify_groups(groups):
"""
To compute number of unique elements in a given membership specification.
Parameters
----------
groups : numpy 1d array of length p, each value specifying which group that particular node belongs to.
For examlpe, if you have a cortical thickness values for 1... | [
"def",
"identify_groups",
"(",
"groups",
")",
":",
"group_ids",
"=",
"np",
".",
"unique",
"(",
"groups",
")",
"num_groups",
"=",
"len",
"(",
"group_ids",
")",
"if",
"num_groups",
"<",
"2",
":",
"raise",
"ValueError",
"(",
"'There must be atleast two nodes or g... | To compute number of unique elements in a given membership specification.
Parameters
----------
groups : numpy 1d array of length p, each value specifying which group that particular node belongs to.
For examlpe, if you have a cortical thickness values for 1000 vertices belonging to 100 patches,
... | [
"To",
"compute",
"number",
"of",
"unique",
"elements",
"in",
"a",
"given",
"membership",
"specification",
"."
] | train | https://github.com/raamana/hiwenet/blob/b12699b3722fd0a6a835e7d7ca4baf58fb181809/hiwenet/pairwise_dist.py#L400-L425 |
raamana/hiwenet | hiwenet/pairwise_dist.py | check_param_ranges | def check_param_ranges(num_bins, num_groups, num_values, trim_outliers, trim_percentile):
"""Ensuring the parameters are in valid ranges."""
if num_bins < minimum_num_bins:
raise ValueError('Too few bins! The number of bins must be >= 5')
if num_values < num_groups:
raise ValueError('Insuf... | python | def check_param_ranges(num_bins, num_groups, num_values, trim_outliers, trim_percentile):
"""Ensuring the parameters are in valid ranges."""
if num_bins < minimum_num_bins:
raise ValueError('Too few bins! The number of bins must be >= 5')
if num_values < num_groups:
raise ValueError('Insuf... | [
"def",
"check_param_ranges",
"(",
"num_bins",
",",
"num_groups",
",",
"num_values",
",",
"trim_outliers",
",",
"trim_percentile",
")",
":",
"if",
"num_bins",
"<",
"minimum_num_bins",
":",
"raise",
"ValueError",
"(",
"'Too few bins! The number of bins must be >= 5'",
")"... | Ensuring the parameters are in valid ranges. | [
"Ensuring",
"the",
"parameters",
"are",
"in",
"valid",
"ranges",
"."
] | train | https://github.com/raamana/hiwenet/blob/b12699b3722fd0a6a835e7d7ca4baf58fb181809/hiwenet/pairwise_dist.py#L428-L443 |
raamana/hiwenet | hiwenet/pairwise_dist.py | type_cast_params | def type_cast_params(num_bins, edge_range_spec, features, groups):
"""Casting inputs to required types."""
if isinstance(num_bins, str):
# possible when called from CLI
num_bins = np.float(num_bins)
# rounding it to ensure it is int
num_bins = np.rint(num_bins)
if np.isnan(num_bin... | python | def type_cast_params(num_bins, edge_range_spec, features, groups):
"""Casting inputs to required types."""
if isinstance(num_bins, str):
# possible when called from CLI
num_bins = np.float(num_bins)
# rounding it to ensure it is int
num_bins = np.rint(num_bins)
if np.isnan(num_bin... | [
"def",
"type_cast_params",
"(",
"num_bins",
",",
"edge_range_spec",
",",
"features",
",",
"groups",
")",
":",
"if",
"isinstance",
"(",
"num_bins",
",",
"str",
")",
":",
"# possible when called from CLI",
"num_bins",
"=",
"np",
".",
"float",
"(",
"num_bins",
")... | Casting inputs to required types. | [
"Casting",
"inputs",
"to",
"required",
"types",
"."
] | train | https://github.com/raamana/hiwenet/blob/b12699b3722fd0a6a835e7d7ca4baf58fb181809/hiwenet/pairwise_dist.py#L446-L480 |
raamana/hiwenet | hiwenet/pairwise_dist.py | make_random_histogram | def make_random_histogram(length=100, num_bins=10):
"Returns a sequence of histogram density values that sum to 1.0"
hist, bin_edges = np.histogram(np.random.random(length),
bins=num_bins, density=True)
# to ensure they sum to 1.0
hist = hist / sum(hist)
if len(... | python | def make_random_histogram(length=100, num_bins=10):
"Returns a sequence of histogram density values that sum to 1.0"
hist, bin_edges = np.histogram(np.random.random(length),
bins=num_bins, density=True)
# to ensure they sum to 1.0
hist = hist / sum(hist)
if len(... | [
"def",
"make_random_histogram",
"(",
"length",
"=",
"100",
",",
"num_bins",
"=",
"10",
")",
":",
"hist",
",",
"bin_edges",
"=",
"np",
".",
"histogram",
"(",
"np",
".",
"random",
".",
"random",
"(",
"length",
")",
",",
"bins",
"=",
"num_bins",
",",
"d... | Returns a sequence of histogram density values that sum to 1.0 | [
"Returns",
"a",
"sequence",
"of",
"histogram",
"density",
"values",
"that",
"sum",
"to",
"1",
".",
"0"
] | train | https://github.com/raamana/hiwenet/blob/b12699b3722fd0a6a835e7d7ca4baf58fb181809/hiwenet/pairwise_dist.py#L483-L495 |
raamana/hiwenet | hiwenet/pairwise_dist.py | check_weight_method | def check_weight_method(weight_method_spec,
use_orig_distr=False,
allow_non_symmetric=False):
"Check if weight_method is recognized and implemented, or ensure it is callable."
if not isinstance(use_orig_distr, bool):
raise TypeError('use_original_distribu... | python | def check_weight_method(weight_method_spec,
use_orig_distr=False,
allow_non_symmetric=False):
"Check if weight_method is recognized and implemented, or ensure it is callable."
if not isinstance(use_orig_distr, bool):
raise TypeError('use_original_distribu... | [
"def",
"check_weight_method",
"(",
"weight_method_spec",
",",
"use_orig_distr",
"=",
"False",
",",
"allow_non_symmetric",
"=",
"False",
")",
":",
"if",
"not",
"isinstance",
"(",
"use_orig_distr",
",",
"bool",
")",
":",
"raise",
"TypeError",
"(",
"'use_original_dis... | Check if weight_method is recognized and implemented, or ensure it is callable. | [
"Check",
"if",
"weight_method",
"is",
"recognized",
"and",
"implemented",
"or",
"ensure",
"it",
"is",
"callable",
"."
] | train | https://github.com/raamana/hiwenet/blob/b12699b3722fd0a6a835e7d7ca4baf58fb181809/hiwenet/pairwise_dist.py#L498-L554 |
raamana/hiwenet | hiwenet/pairwise_dist.py | check_params | def check_params(features_spec, groups_spec, num_bins, edge_range_spec, trim_outliers, trim_percentile):
"""Necessary check on values, ranges, and types."""
if isinstance(features_spec, str) and isinstance(groups_spec, str):
features, groups = read_features_and_groups(features_spec, groups_spec)
el... | python | def check_params(features_spec, groups_spec, num_bins, edge_range_spec, trim_outliers, trim_percentile):
"""Necessary check on values, ranges, and types."""
if isinstance(features_spec, str) and isinstance(groups_spec, str):
features, groups = read_features_and_groups(features_spec, groups_spec)
el... | [
"def",
"check_params",
"(",
"features_spec",
",",
"groups_spec",
",",
"num_bins",
",",
"edge_range_spec",
",",
"trim_outliers",
",",
"trim_percentile",
")",
":",
"if",
"isinstance",
"(",
"features_spec",
",",
"str",
")",
"and",
"isinstance",
"(",
"groups_spec",
... | Necessary check on values, ranges, and types. | [
"Necessary",
"check",
"on",
"values",
"ranges",
"and",
"types",
"."
] | train | https://github.com/raamana/hiwenet/blob/b12699b3722fd0a6a835e7d7ca4baf58fb181809/hiwenet/pairwise_dist.py#L557-L574 |
raamana/hiwenet | hiwenet/pairwise_dist.py | run_cli | def run_cli():
"Command line interface to hiwenet."
features_path, groups_path, weight_method, num_bins, edge_range, \
trim_outliers, trim_percentile, return_networkx_graph, out_weights_path = parse_args()
# TODO add the possibility to process multiple combinations of parameters: diff subjects, diff m... | python | def run_cli():
"Command line interface to hiwenet."
features_path, groups_path, weight_method, num_bins, edge_range, \
trim_outliers, trim_percentile, return_networkx_graph, out_weights_path = parse_args()
# TODO add the possibility to process multiple combinations of parameters: diff subjects, diff m... | [
"def",
"run_cli",
"(",
")",
":",
"features_path",
",",
"groups_path",
",",
"weight_method",
",",
"num_bins",
",",
"edge_range",
",",
"trim_outliers",
",",
"trim_percentile",
",",
"return_networkx_graph",
",",
"out_weights_path",
"=",
"parse_args",
"(",
")",
"# TOD... | Command line interface to hiwenet. | [
"Command",
"line",
"interface",
"to",
"hiwenet",
"."
] | train | https://github.com/raamana/hiwenet/blob/b12699b3722fd0a6a835e7d7ca4baf58fb181809/hiwenet/pairwise_dist.py#L577-L592 |
raamana/hiwenet | hiwenet/pairwise_dist.py | read_features_and_groups | def read_features_and_groups(features_path, groups_path):
"Reader for data and groups"
try:
if not pexists(features_path):
raise ValueError('non-existent features file')
if not pexists(groups_path):
raise ValueError('non-existent groups file')
if isinstance(fea... | python | def read_features_and_groups(features_path, groups_path):
"Reader for data and groups"
try:
if not pexists(features_path):
raise ValueError('non-existent features file')
if not pexists(groups_path):
raise ValueError('non-existent groups file')
if isinstance(fea... | [
"def",
"read_features_and_groups",
"(",
"features_path",
",",
"groups_path",
")",
":",
"try",
":",
"if",
"not",
"pexists",
"(",
"features_path",
")",
":",
"raise",
"ValueError",
"(",
"'non-existent features file'",
")",
"if",
"not",
"pexists",
"(",
"groups_path",
... | Reader for data and groups | [
"Reader",
"for",
"data",
"and",
"groups"
] | train | https://github.com/raamana/hiwenet/blob/b12699b3722fd0a6a835e7d7ca4baf58fb181809/hiwenet/pairwise_dist.py#L595-L621 |
raamana/hiwenet | hiwenet/pairwise_dist.py | get_parser | def get_parser():
"Specifies the arguments and defaults, and returns the parser."
parser = argparse.ArgumentParser(prog="hiwenet")
parser.add_argument("-f", "--in_features_path", action="store", dest="in_features_path",
required=True,
help="Abs. path to file... | python | def get_parser():
"Specifies the arguments and defaults, and returns the parser."
parser = argparse.ArgumentParser(prog="hiwenet")
parser.add_argument("-f", "--in_features_path", action="store", dest="in_features_path",
required=True,
help="Abs. path to file... | [
"def",
"get_parser",
"(",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"prog",
"=",
"\"hiwenet\"",
")",
"parser",
".",
"add_argument",
"(",
"\"-f\"",
",",
"\"--in_features_path\"",
",",
"action",
"=",
"\"store\"",
",",
"dest",
"=",
"\"in_... | Specifies the arguments and defaults, and returns the parser. | [
"Specifies",
"the",
"arguments",
"and",
"defaults",
"and",
"returns",
"the",
"parser",
"."
] | train | https://github.com/raamana/hiwenet/blob/b12699b3722fd0a6a835e7d7ca4baf58fb181809/hiwenet/pairwise_dist.py#L624-L671 |
raamana/hiwenet | hiwenet/pairwise_dist.py | parse_args | def parse_args():
"""Parser/validator for the cmd line args."""
parser = get_parser()
if len(sys.argv) < 2:
parser.print_help()
warnings.warn('Too few arguments!', UserWarning)
parser.exit(1)
# parsing
try:
params = parser.parse_args()
except Exception as exc:
... | python | def parse_args():
"""Parser/validator for the cmd line args."""
parser = get_parser()
if len(sys.argv) < 2:
parser.print_help()
warnings.warn('Too few arguments!', UserWarning)
parser.exit(1)
# parsing
try:
params = parser.parse_args()
except Exception as exc:
... | [
"def",
"parse_args",
"(",
")",
":",
"parser",
"=",
"get_parser",
"(",
")",
"if",
"len",
"(",
"sys",
".",
"argv",
")",
"<",
"2",
":",
"parser",
".",
"print_help",
"(",
")",
"warnings",
".",
"warn",
"(",
"'Too few arguments!'",
",",
"UserWarning",
")",
... | Parser/validator for the cmd line args. | [
"Parser",
"/",
"validator",
"for",
"the",
"cmd",
"line",
"args",
"."
] | train | https://github.com/raamana/hiwenet/blob/b12699b3722fd0a6a835e7d7ca4baf58fb181809/hiwenet/pairwise_dist.py#L674-L700 |
OpenAgInitiative/openag_python | openag/cli/firmware/__init__.py | _init | def _init(board, project_dir):
"""
Initialize an OpenAg-based project.
Internal function we use for both init and flash commands.
"""
project_dir = os.path.abspath(project_dir)
# Initialize the platformio project
pio_config_path = os.path.join(project_dir, "platformio.ini")
if not os.pa... | python | def _init(board, project_dir):
"""
Initialize an OpenAg-based project.
Internal function we use for both init and flash commands.
"""
project_dir = os.path.abspath(project_dir)
# Initialize the platformio project
pio_config_path = os.path.join(project_dir, "platformio.ini")
if not os.pa... | [
"def",
"_init",
"(",
"board",
",",
"project_dir",
")",
":",
"project_dir",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"project_dir",
")",
"# Initialize the platformio project",
"pio_config_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"project_dir",
",",
... | Initialize an OpenAg-based project.
Internal function we use for both init and flash commands. | [
"Initialize",
"an",
"OpenAg",
"-",
"based",
"project",
".",
"Internal",
"function",
"we",
"use",
"for",
"both",
"init",
"and",
"flash",
"commands",
"."
] | train | https://github.com/OpenAgInitiative/openag_python/blob/f6202340292bbf7185e1a7d4290188c0dacbb8d0/openag/cli/firmware/__init__.py#L69-L93 |
OpenAgInitiative/openag_python | openag/cli/firmware/__init__.py | _run | def _run(
categories, param_file, project_dir, plugin, target,
status_update_interval
):
"""
Generate code for this project and run it.
Internal function we use for both run and flash commands.
"""
project_dir = os.path.abspath(project_dir)
# Make sure the project has been initialized
... | python | def _run(
categories, param_file, project_dir, plugin, target,
status_update_interval
):
"""
Generate code for this project and run it.
Internal function we use for both run and flash commands.
"""
project_dir = os.path.abspath(project_dir)
# Make sure the project has been initialized
... | [
"def",
"_run",
"(",
"categories",
",",
"param_file",
",",
"project_dir",
",",
"plugin",
",",
"target",
",",
"status_update_interval",
")",
":",
"project_dir",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"project_dir",
")",
"# Make sure the project has been initia... | Generate code for this project and run it.
Internal function we use for both run and flash commands. | [
"Generate",
"code",
"for",
"this",
"project",
"and",
"run",
"it",
".",
"Internal",
"function",
"we",
"use",
"for",
"both",
"run",
"and",
"flash",
"commands",
"."
] | train | https://github.com/OpenAgInitiative/openag_python/blob/f6202340292bbf7185e1a7d4290188c0dacbb8d0/openag/cli/firmware/__init__.py#L102-L217 |
OpenAgInitiative/openag_python | openag/cli/firmware/__init__.py | run | def run(
categories, param_file, project_dir, plugin, target,
status_update_interval
):
""" Generate code for this project and run it """
return _run(
categories, param_file, project_dir, plugin, target,
status_update_interval
) | python | def run(
categories, param_file, project_dir, plugin, target,
status_update_interval
):
""" Generate code for this project and run it """
return _run(
categories, param_file, project_dir, plugin, target,
status_update_interval
) | [
"def",
"run",
"(",
"categories",
",",
"param_file",
",",
"project_dir",
",",
"plugin",
",",
"target",
",",
"status_update_interval",
")",
":",
"return",
"_run",
"(",
"categories",
",",
"param_file",
",",
"project_dir",
",",
"plugin",
",",
"target",
",",
"sta... | Generate code for this project and run it | [
"Generate",
"code",
"for",
"this",
"project",
"and",
"run",
"it"
] | train | https://github.com/OpenAgInitiative/openag_python/blob/f6202340292bbf7185e1a7d4290188c0dacbb8d0/openag/cli/firmware/__init__.py#L222-L230 |
OpenAgInitiative/openag_python | openag/cli/firmware/__init__.py | run_module | def run_module(
ctx, arguments, project_dir, board, **kwargs
):
"""
Run a single instance of this module. [ARGUMENTS] specifies a list of
implementation-specific arguments to the module (for example, configuring
Arduino pin numbers for the module).
Example:
\b
openag firmware run_modul... | python | def run_module(
ctx, arguments, project_dir, board, **kwargs
):
"""
Run a single instance of this module. [ARGUMENTS] specifies a list of
implementation-specific arguments to the module (for example, configuring
Arduino pin numbers for the module).
Example:
\b
openag firmware run_modul... | [
"def",
"run_module",
"(",
"ctx",
",",
"arguments",
",",
"project_dir",
",",
"board",
",",
"*",
"*",
"kwargs",
")",
":",
"# Read the module config",
"here",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"project_dir",
")",
"module_json_path",
"=",
"os",
".",... | Run a single instance of this module. [ARGUMENTS] specifies a list of
implementation-specific arguments to the module (for example, configuring
Arduino pin numbers for the module).
Example:
\b
openag firmware run_module -t upload 4
This command fetches module definitions from CouchDB. CouchDB... | [
"Run",
"a",
"single",
"instance",
"of",
"this",
"module",
".",
"[",
"ARGUMENTS",
"]",
"specifies",
"a",
"list",
"of",
"implementation",
"-",
"specific",
"arguments",
"to",
"the",
"module",
"(",
"for",
"example",
"configuring",
"Arduino",
"pin",
"numbers",
"f... | train | https://github.com/OpenAgInitiative/openag_python/blob/f6202340292bbf7185e1a7d4290188c0dacbb8d0/openag/cli/firmware/__init__.py#L239-L337 |
OpenAgInitiative/openag_python | openag/cli/firmware/__init__.py | flash | def flash(
categories, param_file, project_dir, plugin, target,
status_update_interval, board
):
"""
Flashes firmware to device (init + run).
Initializes a pio project and runs the result, flashing it to the device.
"""
_init(board, project_dir)
_run(
categories, param_file, proj... | python | def flash(
categories, param_file, project_dir, plugin, target,
status_update_interval, board
):
"""
Flashes firmware to device (init + run).
Initializes a pio project and runs the result, flashing it to the device.
"""
_init(board, project_dir)
_run(
categories, param_file, proj... | [
"def",
"flash",
"(",
"categories",
",",
"param_file",
",",
"project_dir",
",",
"plugin",
",",
"target",
",",
"status_update_interval",
",",
"board",
")",
":",
"_init",
"(",
"board",
",",
"project_dir",
")",
"_run",
"(",
"categories",
",",
"param_file",
",",
... | Flashes firmware to device (init + run).
Initializes a pio project and runs the result, flashing it to the device. | [
"Flashes",
"firmware",
"to",
"device",
"(",
"init",
"+",
"run",
")",
".",
"Initializes",
"a",
"pio",
"project",
"and",
"runs",
"the",
"result",
"flashing",
"it",
"to",
"the",
"device",
"."
] | train | https://github.com/OpenAgInitiative/openag_python/blob/f6202340292bbf7185e1a7d4290188c0dacbb8d0/openag/cli/firmware/__init__.py#L343-L356 |
OpenAgInitiative/openag_python | openag/cli/firmware/__init__.py | prune_unspecified_categories | def prune_unspecified_categories(modules, categories):
"""
Removes unspecified module categories.
Mutates dictionary and returns it.
"""
res = {}
for mod_name, mod_info in modules.items():
mod_categories = mod_info.get("categories", all_categories)
for category in categories:
... | python | def prune_unspecified_categories(modules, categories):
"""
Removes unspecified module categories.
Mutates dictionary and returns it.
"""
res = {}
for mod_name, mod_info in modules.items():
mod_categories = mod_info.get("categories", all_categories)
for category in categories:
... | [
"def",
"prune_unspecified_categories",
"(",
"modules",
",",
"categories",
")",
":",
"res",
"=",
"{",
"}",
"for",
"mod_name",
",",
"mod_info",
"in",
"modules",
".",
"items",
"(",
")",
":",
"mod_categories",
"=",
"mod_info",
".",
"get",
"(",
"\"categories\"",
... | Removes unspecified module categories.
Mutates dictionary and returns it. | [
"Removes",
"unspecified",
"module",
"categories",
".",
"Mutates",
"dictionary",
"and",
"returns",
"it",
"."
] | train | https://github.com/OpenAgInitiative/openag_python/blob/f6202340292bbf7185e1a7d4290188c0dacbb8d0/openag/cli/firmware/__init__.py#L358-L384 |
OpenAgInitiative/openag_python | openag/cli/firmware/__init__.py | load_plugin | def load_plugin(plugin_name):
"""
Given a plugin name, load plugin cls from plugin directory.
Will throw an exception if no plugin can be found.
"""
plugin_cls = plugin_map.get(plugin_name, None)
if not plugin_cls:
try:
plugin_module_name, plugin_cls_name = plugin_name.split(... | python | def load_plugin(plugin_name):
"""
Given a plugin name, load plugin cls from plugin directory.
Will throw an exception if no plugin can be found.
"""
plugin_cls = plugin_map.get(plugin_name, None)
if not plugin_cls:
try:
plugin_module_name, plugin_cls_name = plugin_name.split(... | [
"def",
"load_plugin",
"(",
"plugin_name",
")",
":",
"plugin_cls",
"=",
"plugin_map",
".",
"get",
"(",
"plugin_name",
",",
"None",
")",
"if",
"not",
"plugin_cls",
":",
"try",
":",
"plugin_module_name",
",",
"plugin_cls_name",
"=",
"plugin_name",
".",
"split",
... | Given a plugin name, load plugin cls from plugin directory.
Will throw an exception if no plugin can be found. | [
"Given",
"a",
"plugin",
"name",
"load",
"plugin",
"cls",
"from",
"plugin",
"directory",
".",
"Will",
"throw",
"an",
"exception",
"if",
"no",
"plugin",
"can",
"be",
"found",
"."
] | train | https://github.com/OpenAgInitiative/openag_python/blob/f6202340292bbf7185e1a7d4290188c0dacbb8d0/openag/cli/firmware/__init__.py#L386-L413 |
vimalkvn/riboplot | riboplot/ribocore.py | lengths_offsets | def lengths_offsets(value):
"""Split the given comma separated value to multiple integer values. """
values = []
for item in value.split(','):
item = int(item)
values.append(item)
return values | python | def lengths_offsets(value):
"""Split the given comma separated value to multiple integer values. """
values = []
for item in value.split(','):
item = int(item)
values.append(item)
return values | [
"def",
"lengths_offsets",
"(",
"value",
")",
":",
"values",
"=",
"[",
"]",
"for",
"item",
"in",
"value",
".",
"split",
"(",
"','",
")",
":",
"item",
"=",
"int",
"(",
"item",
")",
"values",
".",
"append",
"(",
"item",
")",
"return",
"values"
] | Split the given comma separated value to multiple integer values. | [
"Split",
"the",
"given",
"comma",
"separated",
"value",
"to",
"multiple",
"integer",
"values",
"."
] | train | https://github.com/vimalkvn/riboplot/blob/914515df54eccc2e726ba71e751c3260f2066d97/riboplot/ribocore.py#L46-L52 |
vimalkvn/riboplot | riboplot/ribocore.py | open_pysam_file | def open_pysam_file(fname, ftype):
"""Open a BAM or FASTA file with pysam (for use with "with" statement)"""
try:
if ftype == 'bam':
fpysam = pysam.AlignmentFile(fname, 'rb')
elif ftype == 'fasta':
fpysam = pysam.FastaFile(fname)
yield fpysam
except:
r... | python | def open_pysam_file(fname, ftype):
"""Open a BAM or FASTA file with pysam (for use with "with" statement)"""
try:
if ftype == 'bam':
fpysam = pysam.AlignmentFile(fname, 'rb')
elif ftype == 'fasta':
fpysam = pysam.FastaFile(fname)
yield fpysam
except:
r... | [
"def",
"open_pysam_file",
"(",
"fname",
",",
"ftype",
")",
":",
"try",
":",
"if",
"ftype",
"==",
"'bam'",
":",
"fpysam",
"=",
"pysam",
".",
"AlignmentFile",
"(",
"fname",
",",
"'rb'",
")",
"elif",
"ftype",
"==",
"'fasta'",
":",
"fpysam",
"=",
"pysam",
... | Open a BAM or FASTA file with pysam (for use with "with" statement) | [
"Open",
"a",
"BAM",
"or",
"FASTA",
"file",
"with",
"pysam",
"(",
"for",
"use",
"with",
"with",
"statement",
")"
] | train | https://github.com/vimalkvn/riboplot/blob/914515df54eccc2e726ba71e751c3260f2066d97/riboplot/ribocore.py#L56-L67 |
vimalkvn/riboplot | riboplot/ribocore.py | is_bam_valid | def is_bam_valid(bam_file):
"""Check if bam file is valid. Raises a ValueError if pysam cannot read the file.
#TODO: pysam does not differentiate between BAM and SAM
"""
try:
f = pysam.AlignmentFile(bam_file)
except ValueError:
raise
except:
raise
else:
f.cl... | python | def is_bam_valid(bam_file):
"""Check if bam file is valid. Raises a ValueError if pysam cannot read the file.
#TODO: pysam does not differentiate between BAM and SAM
"""
try:
f = pysam.AlignmentFile(bam_file)
except ValueError:
raise
except:
raise
else:
f.cl... | [
"def",
"is_bam_valid",
"(",
"bam_file",
")",
":",
"try",
":",
"f",
"=",
"pysam",
".",
"AlignmentFile",
"(",
"bam_file",
")",
"except",
"ValueError",
":",
"raise",
"except",
":",
"raise",
"else",
":",
"f",
".",
"close",
"(",
")",
"return",
"True"
] | Check if bam file is valid. Raises a ValueError if pysam cannot read the file.
#TODO: pysam does not differentiate between BAM and SAM | [
"Check",
"if",
"bam",
"file",
"is",
"valid",
".",
"Raises",
"a",
"ValueError",
"if",
"pysam",
"cannot",
"read",
"the",
"file",
"."
] | train | https://github.com/vimalkvn/riboplot/blob/914515df54eccc2e726ba71e751c3260f2066d97/riboplot/ribocore.py#L70-L84 |
vimalkvn/riboplot | riboplot/ribocore.py | bam_has_index | def bam_has_index(bam_file):
"""Check if bam file has an index. Returns True/False."""
has_index = None
with pysam.AlignmentFile(bam_file, 'rb') as bam_fileobj:
try:
bam_fileobj.fetch(bam_fileobj.references[0])
except ValueError as err:
if err.message == 'fetch called... | python | def bam_has_index(bam_file):
"""Check if bam file has an index. Returns True/False."""
has_index = None
with pysam.AlignmentFile(bam_file, 'rb') as bam_fileobj:
try:
bam_fileobj.fetch(bam_fileobj.references[0])
except ValueError as err:
if err.message == 'fetch called... | [
"def",
"bam_has_index",
"(",
"bam_file",
")",
":",
"has_index",
"=",
"None",
"with",
"pysam",
".",
"AlignmentFile",
"(",
"bam_file",
",",
"'rb'",
")",
"as",
"bam_fileobj",
":",
"try",
":",
"bam_fileobj",
".",
"fetch",
"(",
"bam_fileobj",
".",
"references",
... | Check if bam file has an index. Returns True/False. | [
"Check",
"if",
"bam",
"file",
"has",
"an",
"index",
".",
"Returns",
"True",
"/",
"False",
"."
] | train | https://github.com/vimalkvn/riboplot/blob/914515df54eccc2e726ba71e751c3260f2066d97/riboplot/ribocore.py#L87-L99 |
vimalkvn/riboplot | riboplot/ribocore.py | is_fasta_valid | def is_fasta_valid(fasta_file):
"""Check if fasta file is valid. Raises a ValueError if pysam cannot read the file.
#TODO: pysam does not differentiate between BAM and SAM
"""
try:
f = pysam.FastaFile(fasta_file)
except IOError:
raise
else:
f.close()
return True | python | def is_fasta_valid(fasta_file):
"""Check if fasta file is valid. Raises a ValueError if pysam cannot read the file.
#TODO: pysam does not differentiate between BAM and SAM
"""
try:
f = pysam.FastaFile(fasta_file)
except IOError:
raise
else:
f.close()
return True | [
"def",
"is_fasta_valid",
"(",
"fasta_file",
")",
":",
"try",
":",
"f",
"=",
"pysam",
".",
"FastaFile",
"(",
"fasta_file",
")",
"except",
"IOError",
":",
"raise",
"else",
":",
"f",
".",
"close",
"(",
")",
"return",
"True"
] | Check if fasta file is valid. Raises a ValueError if pysam cannot read the file.
#TODO: pysam does not differentiate between BAM and SAM | [
"Check",
"if",
"fasta",
"file",
"is",
"valid",
".",
"Raises",
"a",
"ValueError",
"if",
"pysam",
"cannot",
"read",
"the",
"file",
"."
] | train | https://github.com/vimalkvn/riboplot/blob/914515df54eccc2e726ba71e751c3260f2066d97/riboplot/ribocore.py#L107-L118 |
vimalkvn/riboplot | riboplot/ribocore.py | get_first_transcript_name | def get_first_transcript_name(fasta_file):
"""Return the first FASTA sequence from the given FASTA file.
Keyword arguments:
fasta_file -- FASTA format file of the transcriptome
"""
with open_pysam_file(fname=fasta_file, ftype='fasta') as f:
transcript_name = f.references[0]
return tran... | python | def get_first_transcript_name(fasta_file):
"""Return the first FASTA sequence from the given FASTA file.
Keyword arguments:
fasta_file -- FASTA format file of the transcriptome
"""
with open_pysam_file(fname=fasta_file, ftype='fasta') as f:
transcript_name = f.references[0]
return tran... | [
"def",
"get_first_transcript_name",
"(",
"fasta_file",
")",
":",
"with",
"open_pysam_file",
"(",
"fname",
"=",
"fasta_file",
",",
"ftype",
"=",
"'fasta'",
")",
"as",
"f",
":",
"transcript_name",
"=",
"f",
".",
"references",
"[",
"0",
"]",
"return",
"transcri... | Return the first FASTA sequence from the given FASTA file.
Keyword arguments:
fasta_file -- FASTA format file of the transcriptome | [
"Return",
"the",
"first",
"FASTA",
"sequence",
"from",
"the",
"given",
"FASTA",
"file",
"."
] | train | https://github.com/vimalkvn/riboplot/blob/914515df54eccc2e726ba71e751c3260f2066d97/riboplot/ribocore.py#L121-L130 |
vimalkvn/riboplot | riboplot/ribocore.py | get_fasta_record | def get_fasta_record(fasta_file, transcript_name):
"""Return a single transcript from a valid fasta file as a record.
record[transcript_name] = sequence
Keyword arguments:
fasta_file -- FASTA format file of the transcriptome
transcript_name -- Name of the transcript as in the FASTA header
"""... | python | def get_fasta_record(fasta_file, transcript_name):
"""Return a single transcript from a valid fasta file as a record.
record[transcript_name] = sequence
Keyword arguments:
fasta_file -- FASTA format file of the transcriptome
transcript_name -- Name of the transcript as in the FASTA header
"""... | [
"def",
"get_fasta_record",
"(",
"fasta_file",
",",
"transcript_name",
")",
":",
"with",
"open_pysam_file",
"(",
"fname",
"=",
"fasta_file",
",",
"ftype",
"=",
"'fasta'",
")",
"as",
"f",
":",
"sequence",
"=",
"f",
".",
"fetch",
"(",
"transcript_name",
")",
... | Return a single transcript from a valid fasta file as a record.
record[transcript_name] = sequence
Keyword arguments:
fasta_file -- FASTA format file of the transcriptome
transcript_name -- Name of the transcript as in the FASTA header | [
"Return",
"a",
"single",
"transcript",
"from",
"a",
"valid",
"fasta",
"file",
"as",
"a",
"record",
"."
] | train | https://github.com/vimalkvn/riboplot/blob/914515df54eccc2e726ba71e751c3260f2066d97/riboplot/ribocore.py#L133-L145 |
vimalkvn/riboplot | riboplot/ribocore.py | get_fasta_records | def get_fasta_records(fasta, transcripts):
"""Return list of transcript records from the given fasta file.
Each record will be of the form {'sequence_id': {'sequence': 'AAA', 'length': 3}}
trascripts should be provided as a list of sequence id's.
"""
records = {}
f = pysam.FastaFile(fasta)
... | python | def get_fasta_records(fasta, transcripts):
"""Return list of transcript records from the given fasta file.
Each record will be of the form {'sequence_id': {'sequence': 'AAA', 'length': 3}}
trascripts should be provided as a list of sequence id's.
"""
records = {}
f = pysam.FastaFile(fasta)
... | [
"def",
"get_fasta_records",
"(",
"fasta",
",",
"transcripts",
")",
":",
"records",
"=",
"{",
"}",
"f",
"=",
"pysam",
".",
"FastaFile",
"(",
"fasta",
")",
"for",
"transcript",
"in",
"transcripts",
":",
"try",
":",
"sequence",
",",
"length",
"=",
"f",
".... | Return list of transcript records from the given fasta file.
Each record will be of the form {'sequence_id': {'sequence': 'AAA', 'length': 3}}
trascripts should be provided as a list of sequence id's. | [
"Return",
"list",
"of",
"transcript",
"records",
"from",
"the",
"given",
"fasta",
"file",
".",
"Each",
"record",
"will",
"be",
"of",
"the",
"form",
"{",
"sequence_id",
":",
"{",
"sequence",
":",
"AAA",
"length",
":",
"3",
"}}"
] | train | https://github.com/vimalkvn/riboplot/blob/914515df54eccc2e726ba71e751c3260f2066d97/riboplot/ribocore.py#L148-L166 |
vimalkvn/riboplot | riboplot/ribocore.py | get_three_frame_orfs | def get_three_frame_orfs(sequence, starts=None, stops=None):
"""Find ORF's in frames 1, 2 and 3 for the given sequence.
Positions returned are 1-based (not 0)
Return format [{'start': start_position, 'stop': stop_position, 'sequence': sequence}, ]
Keyword arguments:
sequence -- sequence for the t... | python | def get_three_frame_orfs(sequence, starts=None, stops=None):
"""Find ORF's in frames 1, 2 and 3 for the given sequence.
Positions returned are 1-based (not 0)
Return format [{'start': start_position, 'stop': stop_position, 'sequence': sequence}, ]
Keyword arguments:
sequence -- sequence for the t... | [
"def",
"get_three_frame_orfs",
"(",
"sequence",
",",
"starts",
"=",
"None",
",",
"stops",
"=",
"None",
")",
":",
"if",
"not",
"starts",
":",
"starts",
"=",
"[",
"'ATG'",
"]",
"if",
"not",
"stops",
":",
"stops",
"=",
"[",
"'TAG'",
",",
"'TGA'",
",",
... | Find ORF's in frames 1, 2 and 3 for the given sequence.
Positions returned are 1-based (not 0)
Return format [{'start': start_position, 'stop': stop_position, 'sequence': sequence}, ]
Keyword arguments:
sequence -- sequence for the transcript
starts -- List of codons to be considered as start (De... | [
"Find",
"ORF",
"s",
"in",
"frames",
"1",
"2",
"and",
"3",
"for",
"the",
"given",
"sequence",
"."
] | train | https://github.com/vimalkvn/riboplot/blob/914515df54eccc2e726ba71e751c3260f2066d97/riboplot/ribocore.py#L169-L218 |
vimalkvn/riboplot | riboplot/ribocore.py | get_longest_orf | def get_longest_orf(orfs):
"""Find longest ORF from the given list of ORFs."""
sorted_orf = sorted(orfs, key=lambda x: len(x['sequence']), reverse=True)[0]
return sorted_orf | python | def get_longest_orf(orfs):
"""Find longest ORF from the given list of ORFs."""
sorted_orf = sorted(orfs, key=lambda x: len(x['sequence']), reverse=True)[0]
return sorted_orf | [
"def",
"get_longest_orf",
"(",
"orfs",
")",
":",
"sorted_orf",
"=",
"sorted",
"(",
"orfs",
",",
"key",
"=",
"lambda",
"x",
":",
"len",
"(",
"x",
"[",
"'sequence'",
"]",
")",
",",
"reverse",
"=",
"True",
")",
"[",
"0",
"]",
"return",
"sorted_orf"
] | Find longest ORF from the given list of ORFs. | [
"Find",
"longest",
"ORF",
"from",
"the",
"given",
"list",
"of",
"ORFs",
"."
] | train | https://github.com/vimalkvn/riboplot/blob/914515df54eccc2e726ba71e751c3260f2066d97/riboplot/ribocore.py#L221-L224 |
vimalkvn/riboplot | riboplot/ribocore.py | filter_ribo_counts | def filter_ribo_counts(counts, orf_start=None, orf_stop=None):
"""Filter read counts and return only upstream of orf_start or downstream
of orf_stop.
Keyword arguments:
counts -- Ribo-Seq read counts obtained from get_ribo_counts.
orf_start -- Start position of the longest ORF.
orf_stop -- Sto... | python | def filter_ribo_counts(counts, orf_start=None, orf_stop=None):
"""Filter read counts and return only upstream of orf_start or downstream
of orf_stop.
Keyword arguments:
counts -- Ribo-Seq read counts obtained from get_ribo_counts.
orf_start -- Start position of the longest ORF.
orf_stop -- Sto... | [
"def",
"filter_ribo_counts",
"(",
"counts",
",",
"orf_start",
"=",
"None",
",",
"orf_stop",
"=",
"None",
")",
":",
"filtered_counts",
"=",
"dict",
".",
"copy",
"(",
"counts",
")",
"for",
"position",
"in",
"counts",
":",
"if",
"orf_start",
"and",
"orf_stop"... | Filter read counts and return only upstream of orf_start or downstream
of orf_stop.
Keyword arguments:
counts -- Ribo-Seq read counts obtained from get_ribo_counts.
orf_start -- Start position of the longest ORF.
orf_stop -- Stop position of the longest ORF. | [
"Filter",
"read",
"counts",
"and",
"return",
"only",
"upstream",
"of",
"orf_start",
"or",
"downstream",
"of",
"orf_stop",
"."
] | train | https://github.com/vimalkvn/riboplot/blob/914515df54eccc2e726ba71e751c3260f2066d97/riboplot/ribocore.py#L227-L257 |
vimalkvn/riboplot | riboplot/ribocore.py | get_ribo_counts | def get_ribo_counts(ribo_fileobj, transcript_name, read_lengths, read_offsets):
"""For each mapped read of the given transcript in the BAM file
(pysam AlignmentFile object), return the position (+1) and the
corresponding frame (1, 2 or 3) to which it aligns.
Keyword arguments:
ribo_fileobj -- file ... | python | def get_ribo_counts(ribo_fileobj, transcript_name, read_lengths, read_offsets):
"""For each mapped read of the given transcript in the BAM file
(pysam AlignmentFile object), return the position (+1) and the
corresponding frame (1, 2 or 3) to which it aligns.
Keyword arguments:
ribo_fileobj -- file ... | [
"def",
"get_ribo_counts",
"(",
"ribo_fileobj",
",",
"transcript_name",
",",
"read_lengths",
",",
"read_offsets",
")",
":",
"read_counts",
"=",
"{",
"}",
"total_reads",
"=",
"0",
"for",
"record",
"in",
"ribo_fileobj",
".",
"fetch",
"(",
"transcript_name",
")",
... | For each mapped read of the given transcript in the BAM file
(pysam AlignmentFile object), return the position (+1) and the
corresponding frame (1, 2 or 3) to which it aligns.
Keyword arguments:
ribo_fileobj -- file object - BAM file opened using pysam AlignmentFile
transcript_name -- Name of trans... | [
"For",
"each",
"mapped",
"read",
"of",
"the",
"given",
"transcript",
"in",
"the",
"BAM",
"file",
"(",
"pysam",
"AlignmentFile",
"object",
")",
"return",
"the",
"position",
"(",
"+",
"1",
")",
"and",
"the",
"corresponding",
"frame",
"(",
"1",
"2",
"or",
... | train | https://github.com/vimalkvn/riboplot/blob/914515df54eccc2e726ba71e751c3260f2066d97/riboplot/ribocore.py#L260-L299 |
vimalkvn/riboplot | riboplot/ribocore.py | check_required_arguments | def check_required_arguments(ribo_file, transcriptome_fasta, transcript_name=None):
"""Check required arguments of both riboplot and ribocount."""
# Is this a valid BAM file? i.e., can pysam read it?
try:
is_bam_valid(ribo_file)
except ValueError:
log.error('The given RiboSeq BAM file is... | python | def check_required_arguments(ribo_file, transcriptome_fasta, transcript_name=None):
"""Check required arguments of both riboplot and ribocount."""
# Is this a valid BAM file? i.e., can pysam read it?
try:
is_bam_valid(ribo_file)
except ValueError:
log.error('The given RiboSeq BAM file is... | [
"def",
"check_required_arguments",
"(",
"ribo_file",
",",
"transcriptome_fasta",
",",
"transcript_name",
"=",
"None",
")",
":",
"# Is this a valid BAM file? i.e., can pysam read it?",
"try",
":",
"is_bam_valid",
"(",
"ribo_file",
")",
"except",
"ValueError",
":",
"log",
... | Check required arguments of both riboplot and ribocount. | [
"Check",
"required",
"arguments",
"of",
"both",
"riboplot",
"and",
"ribocount",
"."
] | train | https://github.com/vimalkvn/riboplot/blob/914515df54eccc2e726ba71e751c3260f2066d97/riboplot/ribocore.py#L302-L347 |
vimalkvn/riboplot | riboplot/ribocore.py | check_rna_file | def check_rna_file(rna_file):
"""Check if bedtools is available and if the given RNA-Seq bam file is valid. """
try:
subprocess.check_output(['bedtools', '--version'])
except OSError:
log.error('Could not find bedtools in PATH. bedtools is required '
'for generating RNA cov... | python | def check_rna_file(rna_file):
"""Check if bedtools is available and if the given RNA-Seq bam file is valid. """
try:
subprocess.check_output(['bedtools', '--version'])
except OSError:
log.error('Could not find bedtools in PATH. bedtools is required '
'for generating RNA cov... | [
"def",
"check_rna_file",
"(",
"rna_file",
")",
":",
"try",
":",
"subprocess",
".",
"check_output",
"(",
"[",
"'bedtools'",
",",
"'--version'",
"]",
")",
"except",
"OSError",
":",
"log",
".",
"error",
"(",
"'Could not find bedtools in PATH. bedtools is required '",
... | Check if bedtools is available and if the given RNA-Seq bam file is valid. | [
"Check",
"if",
"bedtools",
"is",
"available",
"and",
"if",
"the",
"given",
"RNA",
"-",
"Seq",
"bam",
"file",
"is",
"valid",
"."
] | train | https://github.com/vimalkvn/riboplot/blob/914515df54eccc2e726ba71e751c3260f2066d97/riboplot/ribocore.py#L350-L363 |
vimalkvn/riboplot | riboplot/ribocore.py | check_read_lengths | def check_read_lengths(ribo_file, read_lengths):
"""Check if read lengths are valid (positive). """
# check if there are any valid read lengths to check i.e., not equal to 0
valid_lengths = list(set(read_lengths))
# if read length is 0, all read lengths are requested so we skip further
# checks.
... | python | def check_read_lengths(ribo_file, read_lengths):
"""Check if read lengths are valid (positive). """
# check if there are any valid read lengths to check i.e., not equal to 0
valid_lengths = list(set(read_lengths))
# if read length is 0, all read lengths are requested so we skip further
# checks.
... | [
"def",
"check_read_lengths",
"(",
"ribo_file",
",",
"read_lengths",
")",
":",
"# check if there are any valid read lengths to check i.e., not equal to 0",
"valid_lengths",
"=",
"list",
"(",
"set",
"(",
"read_lengths",
")",
")",
"# if read length is 0, all read lengths are request... | Check if read lengths are valid (positive). | [
"Check",
"if",
"read",
"lengths",
"are",
"valid",
"(",
"positive",
")",
"."
] | train | https://github.com/vimalkvn/riboplot/blob/914515df54eccc2e726ba71e751c3260f2066d97/riboplot/ribocore.py#L366-L378 |
vimalkvn/riboplot | riboplot/ribocore.py | check_read_offsets | def check_read_offsets(read_offsets):
"""Check if read offsets are valid (positive)."""
for read_offset in read_offsets:
if read_offset < 0:
msg = 'Read offset must be 0 or greater'
log.error(msg)
raise ArgumentError(msg) | python | def check_read_offsets(read_offsets):
"""Check if read offsets are valid (positive)."""
for read_offset in read_offsets:
if read_offset < 0:
msg = 'Read offset must be 0 or greater'
log.error(msg)
raise ArgumentError(msg) | [
"def",
"check_read_offsets",
"(",
"read_offsets",
")",
":",
"for",
"read_offset",
"in",
"read_offsets",
":",
"if",
"read_offset",
"<",
"0",
":",
"msg",
"=",
"'Read offset must be 0 or greater'",
"log",
".",
"error",
"(",
"msg",
")",
"raise",
"ArgumentError",
"("... | Check if read offsets are valid (positive). | [
"Check",
"if",
"read",
"offsets",
"are",
"valid",
"(",
"positive",
")",
"."
] | train | https://github.com/vimalkvn/riboplot/blob/914515df54eccc2e726ba71e751c3260f2066d97/riboplot/ribocore.py#L381-L387 |
jason-weirather/py-seq-tools | seqtools/format/sam/__init__.py | is_header | def is_header(line):
"""true if we are in a header"""
if re.match('^@',line):
f = line.rstrip().split("\t")
if(len(f) > 9):
return False
return True
return False | python | def is_header(line):
"""true if we are in a header"""
if re.match('^@',line):
f = line.rstrip().split("\t")
if(len(f) > 9):
return False
return True
return False | [
"def",
"is_header",
"(",
"line",
")",
":",
"if",
"re",
".",
"match",
"(",
"'^@'",
",",
"line",
")",
":",
"f",
"=",
"line",
".",
"rstrip",
"(",
")",
".",
"split",
"(",
"\"\\t\"",
")",
"if",
"(",
"len",
"(",
"f",
")",
">",
"9",
")",
":",
"ret... | true if we are in a header | [
"true",
"if",
"we",
"are",
"in",
"a",
"header"
] | train | https://github.com/jason-weirather/py-seq-tools/blob/f642c2c73ffef2acc83656a78059a476fc734ca1/seqtools/format/sam/__init__.py#L511-L518 |
jason-weirather/py-seq-tools | seqtools/format/sam/__init__.py | sort_header | def sort_header(header_text):
"""sort the chromosomes in a header text"""
lines = header_text.rstrip().split("\n")
rlens = {}
for ln in lines:
m = re.match('@SQ\tSN:(\S+)\tLN:(\S+)',ln)
if m:
rlens[m.group(1)] = m.group(2)
output = ''
done_lens = False
for ln in lines:
if re.match('@SQ\t... | python | def sort_header(header_text):
"""sort the chromosomes in a header text"""
lines = header_text.rstrip().split("\n")
rlens = {}
for ln in lines:
m = re.match('@SQ\tSN:(\S+)\tLN:(\S+)',ln)
if m:
rlens[m.group(1)] = m.group(2)
output = ''
done_lens = False
for ln in lines:
if re.match('@SQ\t... | [
"def",
"sort_header",
"(",
"header_text",
")",
":",
"lines",
"=",
"header_text",
".",
"rstrip",
"(",
")",
".",
"split",
"(",
"\"\\n\"",
")",
"rlens",
"=",
"{",
"}",
"for",
"ln",
"in",
"lines",
":",
"m",
"=",
"re",
".",
"match",
"(",
"'@SQ\\tSN:(\\S+)... | sort the chromosomes in a header text | [
"sort",
"the",
"chromosomes",
"in",
"a",
"header",
"text"
] | train | https://github.com/jason-weirather/py-seq-tools/blob/f642c2c73ffef2acc83656a78059a476fc734ca1/seqtools/format/sam/__init__.py#L520-L538 |
jason-weirather/py-seq-tools | seqtools/format/sam/__init__.py | SAM.alignment_ranges | def alignment_ranges(self):
"""Put the heavy alignment ranges calculation called on demand and then cached"""
if not self.is_aligned(): raise ValueError("you can't get alignment ranges from something that didn't align")
if self._alignment_ranges: return self._alignment_ranges
self._alignment_ranges ... | python | def alignment_ranges(self):
"""Put the heavy alignment ranges calculation called on demand and then cached"""
if not self.is_aligned(): raise ValueError("you can't get alignment ranges from something that didn't align")
if self._alignment_ranges: return self._alignment_ranges
self._alignment_ranges ... | [
"def",
"alignment_ranges",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"is_aligned",
"(",
")",
":",
"raise",
"ValueError",
"(",
"\"you can't get alignment ranges from something that didn't align\"",
")",
"if",
"self",
".",
"_alignment_ranges",
":",
"return",
"s... | Put the heavy alignment ranges calculation called on demand and then cached | [
"Put",
"the",
"heavy",
"alignment",
"ranges",
"calculation",
"called",
"on",
"demand",
"and",
"then",
"cached"
] | train | https://github.com/jason-weirather/py-seq-tools/blob/f642c2c73ffef2acc83656a78059a476fc734ca1/seqtools/format/sam/__init__.py#L76-L81 |
jason-weirather/py-seq-tools | seqtools/format/sam/__init__.py | SAM.target_sequence_length | def target_sequence_length(self):
""" Get the length of the target sequence. length of the entire chromosome
throws an error if there is no information available
:return: length
:rtype: int
"""
if not self.is_aligned():
raise ValueError("no length for reference when read is not not alig... | python | def target_sequence_length(self):
""" Get the length of the target sequence. length of the entire chromosome
throws an error if there is no information available
:return: length
:rtype: int
"""
if not self.is_aligned():
raise ValueError("no length for reference when read is not not alig... | [
"def",
"target_sequence_length",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"is_aligned",
"(",
")",
":",
"raise",
"ValueError",
"(",
"\"no length for reference when read is not not aligned\"",
")",
"if",
"self",
".",
"entries",
".",
"tlen",
":",
"return",
... | Get the length of the target sequence. length of the entire chromosome
throws an error if there is no information available
:return: length
:rtype: int | [
"Get",
"the",
"length",
"of",
"the",
"target",
"sequence",
".",
"length",
"of",
"the",
"entire",
"chromosome"
] | train | https://github.com/jason-weirather/py-seq-tools/blob/f642c2c73ffef2acc83656a78059a476fc734ca1/seqtools/format/sam/__init__.py#L145-L163 |
jason-weirather/py-seq-tools | seqtools/format/sam/__init__.py | SAM.query_sequence | def query_sequence(self):
""" Overrides align. corrects orientation with reverse complement if on negative strand
.. warning:: this returns the full query sequence, not just the aligned portion, but i also does not include hard clipped portions (only soft clipped)
"""
if not self.entries.seq: return No... | python | def query_sequence(self):
""" Overrides align. corrects orientation with reverse complement if on negative strand
.. warning:: this returns the full query sequence, not just the aligned portion, but i also does not include hard clipped portions (only soft clipped)
"""
if not self.entries.seq: return No... | [
"def",
"query_sequence",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"entries",
".",
"seq",
":",
"return",
"None",
"if",
"self",
".",
"check_flag",
"(",
"0x10",
")",
":",
"return",
"rc",
"(",
"self",
".",
"entries",
".",
"seq",
")",
"return",
... | Overrides align. corrects orientation with reverse complement if on negative strand
.. warning:: this returns the full query sequence, not just the aligned portion, but i also does not include hard clipped portions (only soft clipped) | [
"Overrides",
"align",
".",
"corrects",
"orientation",
"with",
"reverse",
"complement",
"if",
"on",
"negative",
"strand"
] | train | https://github.com/jason-weirather/py-seq-tools/blob/f642c2c73ffef2acc83656a78059a476fc734ca1/seqtools/format/sam/__init__.py#L166-L173 |
jason-weirather/py-seq-tools | seqtools/format/sam/__init__.py | SAM.query_quality | def query_quality(self):
""" Overrides align
.. warning:: this returns the full query quality, not just the aligned portion
"""
if not self.entries.qual: return None
if self.entries.qual == '*': return None
if self.check_flag(0x10): return self.entries.qual[::-1]
return self.entries.qual | python | def query_quality(self):
""" Overrides align
.. warning:: this returns the full query quality, not just the aligned portion
"""
if not self.entries.qual: return None
if self.entries.qual == '*': return None
if self.check_flag(0x10): return self.entries.qual[::-1]
return self.entries.qual | [
"def",
"query_quality",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"entries",
".",
"qual",
":",
"return",
"None",
"if",
"self",
".",
"entries",
".",
"qual",
"==",
"'*'",
":",
"return",
"None",
"if",
"self",
".",
"check_flag",
"(",
"0x10",
")",
... | Overrides align
.. warning:: this returns the full query quality, not just the aligned portion | [
"Overrides",
"align"
] | train | https://github.com/jason-weirather/py-seq-tools/blob/f642c2c73ffef2acc83656a78059a476fc734ca1/seqtools/format/sam/__init__.py#L176-L184 |
jason-weirather/py-seq-tools | seqtools/format/sam/__init__.py | SAM.query_sequence_length | def query_sequence_length(self):
""" does not include hard clipped"""
if self.entries.seq: return len(self.entries.seq)
if not self.entries.cigar:
raise ValueError('Cannot give a query length if no cigar and no query sequence are present')
return sum([x[0] for x in self.cigar_array if re.match('[... | python | def query_sequence_length(self):
""" does not include hard clipped"""
if self.entries.seq: return len(self.entries.seq)
if not self.entries.cigar:
raise ValueError('Cannot give a query length if no cigar and no query sequence are present')
return sum([x[0] for x in self.cigar_array if re.match('[... | [
"def",
"query_sequence_length",
"(",
"self",
")",
":",
"if",
"self",
".",
"entries",
".",
"seq",
":",
"return",
"len",
"(",
"self",
".",
"entries",
".",
"seq",
")",
"if",
"not",
"self",
".",
"entries",
".",
"cigar",
":",
"raise",
"ValueError",
"(",
"... | does not include hard clipped | [
"does",
"not",
"include",
"hard",
"clipped"
] | train | https://github.com/jason-weirather/py-seq-tools/blob/f642c2c73ffef2acc83656a78059a476fc734ca1/seqtools/format/sam/__init__.py#L187-L192 |
jason-weirather/py-seq-tools | seqtools/format/sam/__init__.py | SAM.original_query_sequence_length | def original_query_sequence_length(self):
"""Similar to get_get_query_sequence_length, but it also includes
hard clipped bases
if there is no cigar, then default to trying the sequence
:return: the length of the query before any clipping
:rtype: int
"""
if not self.is_aligned() or not self.... | python | def original_query_sequence_length(self):
"""Similar to get_get_query_sequence_length, but it also includes
hard clipped bases
if there is no cigar, then default to trying the sequence
:return: the length of the query before any clipping
:rtype: int
"""
if not self.is_aligned() or not self.... | [
"def",
"original_query_sequence_length",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"is_aligned",
"(",
")",
"or",
"not",
"self",
".",
"entries",
".",
"cigar",
":",
"return",
"self",
".",
"query_sequence_length",
"# take the naive approach",
"# we are here wi... | Similar to get_get_query_sequence_length, but it also includes
hard clipped bases
if there is no cigar, then default to trying the sequence
:return: the length of the query before any clipping
:rtype: int | [
"Similar",
"to",
"get_get_query_sequence_length",
"but",
"it",
"also",
"includes",
"hard",
"clipped",
"bases",
"if",
"there",
"is",
"no",
"cigar",
"then",
"default",
"to",
"trying",
"the",
"sequence"
] | train | https://github.com/jason-weirather/py-seq-tools/blob/f642c2c73ffef2acc83656a78059a476fc734ca1/seqtools/format/sam/__init__.py#L195-L206 |
jason-weirather/py-seq-tools | seqtools/format/sam/__init__.py | SAM.actual_original_query_range | def actual_original_query_range(self):
""" This accounts for hard clipped bases
and a query sequence that hasnt been reverse complemented
:return: the range covered on the original query sequence
:rtype: GenomicRange
"""
l = self.original_query_sequence_length
a = self.alignment_ranges
... | python | def actual_original_query_range(self):
""" This accounts for hard clipped bases
and a query sequence that hasnt been reverse complemented
:return: the range covered on the original query sequence
:rtype: GenomicRange
"""
l = self.original_query_sequence_length
a = self.alignment_ranges
... | [
"def",
"actual_original_query_range",
"(",
"self",
")",
":",
"l",
"=",
"self",
".",
"original_query_sequence_length",
"a",
"=",
"self",
".",
"alignment_ranges",
"qname",
"=",
"a",
"[",
"0",
"]",
"[",
"1",
"]",
".",
"chr",
"qstart",
"=",
"a",
"[",
"0",
... | This accounts for hard clipped bases
and a query sequence that hasnt been reverse complemented
:return: the range covered on the original query sequence
:rtype: GenomicRange | [
"This",
"accounts",
"for",
"hard",
"clipped",
"bases",
"and",
"a",
"query",
"sequence",
"that",
"hasnt",
"been",
"reverse",
"complemented"
] | train | https://github.com/jason-weirather/py-seq-tools/blob/f642c2c73ffef2acc83656a78059a476fc734ca1/seqtools/format/sam/__init__.py#L209-L227 |
jason-weirather/py-seq-tools | seqtools/format/sam/__init__.py | SAM._get_alignment_ranges | def _get_alignment_ranges(self):
"""A key method to extract the alignment data from the line"""
if not self.is_aligned(): return None
alignment_ranges = []
cig = [x[:] for x in self.cigar_array]
target_pos = self.entries.pos
query_pos = 1
while len(cig) > 0:
c = cig.pop(0)
if re.... | python | def _get_alignment_ranges(self):
"""A key method to extract the alignment data from the line"""
if not self.is_aligned(): return None
alignment_ranges = []
cig = [x[:] for x in self.cigar_array]
target_pos = self.entries.pos
query_pos = 1
while len(cig) > 0:
c = cig.pop(0)
if re.... | [
"def",
"_get_alignment_ranges",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"is_aligned",
"(",
")",
":",
"return",
"None",
"alignment_ranges",
"=",
"[",
"]",
"cig",
"=",
"[",
"x",
"[",
":",
"]",
"for",
"x",
"in",
"self",
".",
"cigar_array",
"]",... | A key method to extract the alignment data from the line | [
"A",
"key",
"method",
"to",
"extract",
"the",
"alignment",
"data",
"from",
"the",
"line"
] | train | https://github.com/jason-weirather/py-seq-tools/blob/f642c2c73ffef2acc83656a78059a476fc734ca1/seqtools/format/sam/__init__.py#L243-L266 |
jason-weirather/py-seq-tools | seqtools/format/sam/__init__.py | SAM.target_range | def target_range(self):
"""Get the range on the target strand
:return: target range
:rtype: GenomicRange
"""
if not self.is_aligned(): return None
if self._target_range: return self._target_range # check cache
global _sam_cigar_target_add
tlen = sum([x[0] for x in self.cigar_array if _s... | python | def target_range(self):
"""Get the range on the target strand
:return: target range
:rtype: GenomicRange
"""
if not self.is_aligned(): return None
if self._target_range: return self._target_range # check cache
global _sam_cigar_target_add
tlen = sum([x[0] for x in self.cigar_array if _s... | [
"def",
"target_range",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"is_aligned",
"(",
")",
":",
"return",
"None",
"if",
"self",
".",
"_target_range",
":",
"return",
"self",
".",
"_target_range",
"# check cache",
"global",
"_sam_cigar_target_add",
"tlen",
... | Get the range on the target strand
:return: target range
:rtype: GenomicRange | [
"Get",
"the",
"range",
"on",
"the",
"target",
"strand"
] | train | https://github.com/jason-weirather/py-seq-tools/blob/f642c2c73ffef2acc83656a78059a476fc734ca1/seqtools/format/sam/__init__.py#L279-L290 |
jason-weirather/py-seq-tools | seqtools/format/sam/__init__.py | SAM.cigar_array | def cigar_array(self):
"""cache this one to speed things up a bit"""
if self._cigar: return self._cigar
self._cigar = [CIGARDatum(int(m[0]),m[1]) for m in re.findall('([0-9]+)([MIDNSHP=X]+)',self.entries.cigar)]
return self._cigar | python | def cigar_array(self):
"""cache this one to speed things up a bit"""
if self._cigar: return self._cigar
self._cigar = [CIGARDatum(int(m[0]),m[1]) for m in re.findall('([0-9]+)([MIDNSHP=X]+)',self.entries.cigar)]
return self._cigar | [
"def",
"cigar_array",
"(",
"self",
")",
":",
"if",
"self",
".",
"_cigar",
":",
"return",
"self",
".",
"_cigar",
"self",
".",
"_cigar",
"=",
"[",
"CIGARDatum",
"(",
"int",
"(",
"m",
"[",
"0",
"]",
")",
",",
"m",
"[",
"1",
"]",
")",
"for",
"m",
... | cache this one to speed things up a bit | [
"cache",
"this",
"one",
"to",
"speed",
"things",
"up",
"a",
"bit"
] | train | https://github.com/jason-weirather/py-seq-tools/blob/f642c2c73ffef2acc83656a78059a476fc734ca1/seqtools/format/sam/__init__.py#L323-L327 |
jason-weirather/py-seq-tools | seqtools/format/sam/__init__.py | SAM.tags | def tags(self):
"""Access the auxillary data here"""
if self._tags: return self._tags
tags = {}
if not tags: return {}
for m in [[y.group(1),y.group(2),y.group(3)] for y in [re.match('([^:]{2,2}):([^:]):(.+)$',x) for x in self.entries.optional_fields.split("\t")]]:
if m[1] == 'i': m[2] ... | python | def tags(self):
"""Access the auxillary data here"""
if self._tags: return self._tags
tags = {}
if not tags: return {}
for m in [[y.group(1),y.group(2),y.group(3)] for y in [re.match('([^:]{2,2}):([^:]):(.+)$',x) for x in self.entries.optional_fields.split("\t")]]:
if m[1] == 'i': m[2] ... | [
"def",
"tags",
"(",
"self",
")",
":",
"if",
"self",
".",
"_tags",
":",
"return",
"self",
".",
"_tags",
"tags",
"=",
"{",
"}",
"if",
"not",
"tags",
":",
"return",
"{",
"}",
"for",
"m",
"in",
"[",
"[",
"y",
".",
"group",
"(",
"1",
")",
",",
"... | Access the auxillary data here | [
"Access",
"the",
"auxillary",
"data",
"here"
] | train | https://github.com/jason-weirather/py-seq-tools/blob/f642c2c73ffef2acc83656a78059a476fc734ca1/seqtools/format/sam/__init__.py#L352-L362 |
theosysbio/means | src/means/approximation/mea/eq_central_moments.py | eq_central_moments | def eq_central_moments(n_counter, k_counter, dmu_over_dt, species, propensities, stoichiometry_matrix, max_order):
r"""
Function used to calculate the terms required for use in equations giving the time dependence of central moments.
The function returns the list Containing the sum of the following terms i... | python | def eq_central_moments(n_counter, k_counter, dmu_over_dt, species, propensities, stoichiometry_matrix, max_order):
r"""
Function used to calculate the terms required for use in equations giving the time dependence of central moments.
The function returns the list Containing the sum of the following terms i... | [
"def",
"eq_central_moments",
"(",
"n_counter",
",",
"k_counter",
",",
"dmu_over_dt",
",",
"species",
",",
"propensities",
",",
"stoichiometry_matrix",
",",
"max_order",
")",
":",
"central_moments",
"=",
"[",
"]",
"# Loops through required combinations of moments (n1,...,n... | r"""
Function used to calculate the terms required for use in equations giving the time dependence of central moments.
The function returns the list Containing the sum of the following terms in in equation 9,
for each of the :math:`[n_1, ..., n_d]` combinations in eq. 9 where ... is ... # FIXME
.. mat... | [
"r",
"Function",
"used",
"to",
"calculate",
"the",
"terms",
"required",
"for",
"use",
"in",
"equations",
"giving",
"the",
"time",
"dependence",
"of",
"central",
"moments",
"."
] | train | https://github.com/theosysbio/means/blob/fe164916a1d84ab2a4fa039871d38ccdf638b1db/src/means/approximation/mea/eq_central_moments.py#L6-L89 |
joequant/cryptoexchange | cryptoexchange/bitmex.py | BitMEX.authenticate | def authenticate(self):
"""Set BitMEX authentication information."""
if self.apiKey:
return
loginResponse = self._curl_bitmex(
api="user/login",
postdict={'email': self.login, 'password': self.password, 'token': self.otpToken})
self.token = loginRespon... | python | def authenticate(self):
"""Set BitMEX authentication information."""
if self.apiKey:
return
loginResponse = self._curl_bitmex(
api="user/login",
postdict={'email': self.login, 'password': self.password, 'token': self.otpToken})
self.token = loginRespon... | [
"def",
"authenticate",
"(",
"self",
")",
":",
"if",
"self",
".",
"apiKey",
":",
"return",
"loginResponse",
"=",
"self",
".",
"_curl_bitmex",
"(",
"api",
"=",
"\"user/login\"",
",",
"postdict",
"=",
"{",
"'email'",
":",
"self",
".",
"login",
",",
"'passwo... | Set BitMEX authentication information. | [
"Set",
"BitMEX",
"authentication",
"information",
"."
] | train | https://github.com/joequant/cryptoexchange/blob/6690fbd9a2ba00e40d7484425808c84d44233f0c/cryptoexchange/bitmex.py#L115-L123 |
joequant/cryptoexchange | cryptoexchange/bitmex.py | BitMEX.authentication_required | def authentication_required(function):
"""Annotation for methods that require auth."""
def wrapped(self, *args, **kwargs):
if not (self.token or self.apiKey):
msg = "You must be authenticated to use this method"
raise AuthenticationError(msg)
else:... | python | def authentication_required(function):
"""Annotation for methods that require auth."""
def wrapped(self, *args, **kwargs):
if not (self.token or self.apiKey):
msg = "You must be authenticated to use this method"
raise AuthenticationError(msg)
else:... | [
"def",
"authentication_required",
"(",
"function",
")",
":",
"def",
"wrapped",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"(",
"self",
".",
"token",
"or",
"self",
".",
"apiKey",
")",
":",
"msg",
"=",
"\"You must be... | Annotation for methods that require auth. | [
"Annotation",
"for",
"methods",
"that",
"require",
"auth",
"."
] | train | https://github.com/joequant/cryptoexchange/blob/6690fbd9a2ba00e40d7484425808c84d44233f0c/cryptoexchange/bitmex.py#L125-L133 |
joequant/cryptoexchange | cryptoexchange/bitmex.py | BitMEX.place_order | def place_order(self, quantity, symbol, price):
"""Place an order."""
if price < 0:
raise Exception("Price must be positive.")
endpoint = "order"
# Generate a unique clOrdID with our prefix so we can identify it.
clOrdID = self.orderIDPrefix + base64.b64encode(uuid.u... | python | def place_order(self, quantity, symbol, price):
"""Place an order."""
if price < 0:
raise Exception("Price must be positive.")
endpoint = "order"
# Generate a unique clOrdID with our prefix so we can identify it.
clOrdID = self.orderIDPrefix + base64.b64encode(uuid.u... | [
"def",
"place_order",
"(",
"self",
",",
"quantity",
",",
"symbol",
",",
"price",
")",
":",
"if",
"price",
"<",
"0",
":",
"raise",
"Exception",
"(",
"\"Price must be positive.\"",
")",
"endpoint",
"=",
"\"order\"",
"# Generate a unique clOrdID with our prefix so we c... | Place an order. | [
"Place",
"an",
"order",
"."
] | train | https://github.com/joequant/cryptoexchange/blob/6690fbd9a2ba00e40d7484425808c84d44233f0c/cryptoexchange/bitmex.py#L140-L154 |
joequant/cryptoexchange | cryptoexchange/bitmex.py | BitMEX.open_orders | def open_orders(self, symbol=None):
"""Get open orders via HTTP. Used on close to ensure we catch them all."""
api = "order"
query = {'ordStatus.isTerminated': False }
if symbol != None:
query['symbol'] =symbol
orders = self._curl_bitmex(
api=api,
... | python | def open_orders(self, symbol=None):
"""Get open orders via HTTP. Used on close to ensure we catch them all."""
api = "order"
query = {'ordStatus.isTerminated': False }
if symbol != None:
query['symbol'] =symbol
orders = self._curl_bitmex(
api=api,
... | [
"def",
"open_orders",
"(",
"self",
",",
"symbol",
"=",
"None",
")",
":",
"api",
"=",
"\"order\"",
"query",
"=",
"{",
"'ordStatus.isTerminated'",
":",
"False",
"}",
"if",
"symbol",
"!=",
"None",
":",
"query",
"[",
"'symbol'",
"]",
"=",
"symbol",
"orders",... | Get open orders via HTTP. Used on close to ensure we catch them all. | [
"Get",
"open",
"orders",
"via",
"HTTP",
".",
"Used",
"on",
"close",
"to",
"ensure",
"we",
"catch",
"them",
"all",
"."
] | train | https://github.com/joequant/cryptoexchange/blob/6690fbd9a2ba00e40d7484425808c84d44233f0c/cryptoexchange/bitmex.py#L157-L168 |
joequant/cryptoexchange | cryptoexchange/bitmex.py | BitMEX.cancel | def cancel(self, orderID):
"""Cancel an existing order."""
api = "order"
postdict = {
'orderID': orderID,
}
return self._curl_bitmex(api=api, postdict=postdict, verb="DELETE") | python | def cancel(self, orderID):
"""Cancel an existing order."""
api = "order"
postdict = {
'orderID': orderID,
}
return self._curl_bitmex(api=api, postdict=postdict, verb="DELETE") | [
"def",
"cancel",
"(",
"self",
",",
"orderID",
")",
":",
"api",
"=",
"\"order\"",
"postdict",
"=",
"{",
"'orderID'",
":",
"orderID",
",",
"}",
"return",
"self",
".",
"_curl_bitmex",
"(",
"api",
"=",
"api",
",",
"postdict",
"=",
"postdict",
",",
"verb",
... | Cancel an existing order. | [
"Cancel",
"an",
"existing",
"order",
"."
] | train | https://github.com/joequant/cryptoexchange/blob/6690fbd9a2ba00e40d7484425808c84d44233f0c/cryptoexchange/bitmex.py#L173-L179 |
joequant/cryptoexchange | cryptoexchange/bitmex.py | BitMEX._curl_bitmex | def _curl_bitmex(self, api, query=None, postdict=None, timeout=3, verb=None):
"""Send a request to BitMEX Servers."""
# Handle URL
url = self.base_url + api
# Default to POST if data is attached, GET otherwise
if not verb:
verb = 'POST' if postdict else 'GET'
... | python | def _curl_bitmex(self, api, query=None, postdict=None, timeout=3, verb=None):
"""Send a request to BitMEX Servers."""
# Handle URL
url = self.base_url + api
# Default to POST if data is attached, GET otherwise
if not verb:
verb = 'POST' if postdict else 'GET'
... | [
"def",
"_curl_bitmex",
"(",
"self",
",",
"api",
",",
"query",
"=",
"None",
",",
"postdict",
"=",
"None",
",",
"timeout",
"=",
"3",
",",
"verb",
"=",
"None",
")",
":",
"# Handle URL",
"url",
"=",
"self",
".",
"base_url",
"+",
"api",
"# Default to POST i... | Send a request to BitMEX Servers. | [
"Send",
"a",
"request",
"to",
"BitMEX",
"Servers",
"."
] | train | https://github.com/joequant/cryptoexchange/blob/6690fbd9a2ba00e40d7484425808c84d44233f0c/cryptoexchange/bitmex.py#L181-L253 |
peopledoc/django-agnocomplete | agnocomplete/decorators.py | allow_create | def allow_create(function):
"""
Decorate the `form_valid` method in a Create/Update class to create new
values if necessary.
.. warning::
Make sure that this decorator **only** decorates the ``form_valid()``
method and **only** this one.
"""
@wraps(function)
def _wrapped_f... | python | def allow_create(function):
"""
Decorate the `form_valid` method in a Create/Update class to create new
values if necessary.
.. warning::
Make sure that this decorator **only** decorates the ``form_valid()``
method and **only** this one.
"""
@wraps(function)
def _wrapped_f... | [
"def",
"allow_create",
"(",
"function",
")",
":",
"@",
"wraps",
"(",
"function",
")",
"def",
"_wrapped_func",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"form",
"=",
"args",
"[",
"0",
"]",
"# If this argument is not a form, there are a lot of chances... | Decorate the `form_valid` method in a Create/Update class to create new
values if necessary.
.. warning::
Make sure that this decorator **only** decorates the ``form_valid()``
method and **only** this one. | [
"Decorate",
"the",
"form_valid",
"method",
"in",
"a",
"Create",
"/",
"Update",
"class",
"to",
"create",
"new",
"values",
"if",
"necessary",
"."
] | train | https://github.com/peopledoc/django-agnocomplete/blob/9bf21db2f2036ba5059b843acd32902a09192053/agnocomplete/decorators.py#L8-L38 |
ayust/kitnirc | kitnirc/modular.py | Module.add_handler | def add_handler(self, event, handler):
"""Adds a handler function for an event.
Note: Only one handler function is allowed per event on the module
level (different modules can provide handlers for the same event).
This is because ordering of handler functions is not guaranteed to
... | python | def add_handler(self, event, handler):
"""Adds a handler function for an event.
Note: Only one handler function is allowed per event on the module
level (different modules can provide handlers for the same event).
This is because ordering of handler functions is not guaranteed to
... | [
"def",
"add_handler",
"(",
"self",
",",
"event",
",",
"handler",
")",
":",
"if",
"event",
"in",
"self",
".",
"event_handlers",
":",
"raise",
"ValueError",
"(",
"\"Cannot register handler for '%s' twice.\"",
"%",
"event",
")",
"self",
".",
"event_handlers",
"[",
... | Adds a handler function for an event.
Note: Only one handler function is allowed per event on the module
level (different modules can provide handlers for the same event).
This is because ordering of handler functions is not guaranteed to
be preserved at the module level.
Also ... | [
"Adds",
"a",
"handler",
"function",
"for",
"an",
"event",
"."
] | train | https://github.com/ayust/kitnirc/blob/cf19fe39219da75f053e1a3976bf21331b6fefea/kitnirc/modular.py#L25-L38 |
ayust/kitnirc | kitnirc/modular.py | Module.handle | def handle(event):
"""Decorator for indicating that a given method handles an event.
Note: while multiple instances of this decorator may be applied to a
single method, it is not recommended.
"""
def dec(func):
if not hasattr(func, '_handle_events'):
... | python | def handle(event):
"""Decorator for indicating that a given method handles an event.
Note: while multiple instances of this decorator may be applied to a
single method, it is not recommended.
"""
def dec(func):
if not hasattr(func, '_handle_events'):
... | [
"def",
"handle",
"(",
"event",
")",
":",
"def",
"dec",
"(",
"func",
")",
":",
"if",
"not",
"hasattr",
"(",
"func",
",",
"'_handle_events'",
")",
":",
"func",
".",
"_handle_events",
"=",
"set",
"(",
")",
"func",
".",
"_handle_events",
".",
"add",
"(",... | Decorator for indicating that a given method handles an event.
Note: while multiple instances of this decorator may be applied to a
single method, it is not recommended. | [
"Decorator",
"for",
"indicating",
"that",
"a",
"given",
"method",
"handles",
"an",
"event",
"."
] | train | https://github.com/ayust/kitnirc/blob/cf19fe39219da75f053e1a3976bf21331b6fefea/kitnirc/modular.py#L41-L53 |
ayust/kitnirc | kitnirc/modular.py | Module.start | def start(self, reloading=False):
"""Called when the module is loaded.
If the load is due to a reload of the module, then the 'reloading'
argument will be set to True. By default, this method calls the
controller's listen() for each event in the self.event_handlers dict.
"""
... | python | def start(self, reloading=False):
"""Called when the module is loaded.
If the load is due to a reload of the module, then the 'reloading'
argument will be set to True. By default, this method calls the
controller's listen() for each event in the self.event_handlers dict.
"""
... | [
"def",
"start",
"(",
"self",
",",
"reloading",
"=",
"False",
")",
":",
"for",
"event",
"in",
"self",
".",
"event_handlers",
":",
"self",
".",
"controller",
".",
"listen",
"(",
"event",
")"
] | Called when the module is loaded.
If the load is due to a reload of the module, then the 'reloading'
argument will be set to True. By default, this method calls the
controller's listen() for each event in the self.event_handlers dict. | [
"Called",
"when",
"the",
"module",
"is",
"loaded",
"."
] | train | https://github.com/ayust/kitnirc/blob/cf19fe39219da75f053e1a3976bf21331b6fefea/kitnirc/modular.py#L55-L63 |
ayust/kitnirc | kitnirc/modular.py | Module.handle_event | def handle_event(self, event, client, args):
"""Dispatch an event to its handler.
Note: the handler does not receive the event which triggered its call.
If you want to handle more than one event, it's recommended to put the
shared handling in a separate function, and create wrapper hand... | python | def handle_event(self, event, client, args):
"""Dispatch an event to its handler.
Note: the handler does not receive the event which triggered its call.
If you want to handle more than one event, it's recommended to put the
shared handling in a separate function, and create wrapper hand... | [
"def",
"handle_event",
"(",
"self",
",",
"event",
",",
"client",
",",
"args",
")",
":",
"handler",
"=",
"self",
".",
"event_handlers",
".",
"get",
"(",
"event",
")",
"if",
"handler",
":",
"return",
"handler",
"(",
"client",
",",
"*",
"args",
")"
] | Dispatch an event to its handler.
Note: the handler does not receive the event which triggered its call.
If you want to handle more than one event, it's recommended to put the
shared handling in a separate function, and create wrapper handlers
that call the shared function. | [
"Dispatch",
"an",
"event",
"to",
"its",
"handler",
"."
] | train | https://github.com/ayust/kitnirc/blob/cf19fe39219da75f053e1a3976bf21331b6fefea/kitnirc/modular.py#L73-L83 |
ayust/kitnirc | kitnirc/modular.py | Module.trigger_event | def trigger_event(self, event, client, args, force_dispatch=False):
"""Trigger a new event that will be dispatched to all modules."""
self.controller.process_event(event, client, args, force_dispatch=force_dispatch) | python | def trigger_event(self, event, client, args, force_dispatch=False):
"""Trigger a new event that will be dispatched to all modules."""
self.controller.process_event(event, client, args, force_dispatch=force_dispatch) | [
"def",
"trigger_event",
"(",
"self",
",",
"event",
",",
"client",
",",
"args",
",",
"force_dispatch",
"=",
"False",
")",
":",
"self",
".",
"controller",
".",
"process_event",
"(",
"event",
",",
"client",
",",
"args",
",",
"force_dispatch",
"=",
"force_disp... | Trigger a new event that will be dispatched to all modules. | [
"Trigger",
"a",
"new",
"event",
"that",
"will",
"be",
"dispatched",
"to",
"all",
"modules",
"."
] | train | https://github.com/ayust/kitnirc/blob/cf19fe39219da75f053e1a3976bf21331b6fefea/kitnirc/modular.py#L85-L87 |
ayust/kitnirc | kitnirc/modular.py | Controller.listen | def listen(self, event):
"""Request that the Controller listen for and dispatch an event.
Note: Even if the module that requested the listening is later
unloaded, the Controller will continue to dispatch the event, there
just might not be anything that cares about it. That's okay.
... | python | def listen(self, event):
"""Request that the Controller listen for and dispatch an event.
Note: Even if the module that requested the listening is later
unloaded, the Controller will continue to dispatch the event, there
just might not be anything that cares about it. That's okay.
... | [
"def",
"listen",
"(",
"self",
",",
"event",
")",
":",
"if",
"event",
"in",
"self",
".",
"registered",
":",
"# Already listening to this event",
"return",
"def",
"handler",
"(",
"client",
",",
"*",
"args",
")",
":",
"return",
"self",
".",
"process_event",
"... | Request that the Controller listen for and dispatch an event.
Note: Even if the module that requested the listening is later
unloaded, the Controller will continue to dispatch the event, there
just might not be anything that cares about it. That's okay. | [
"Request",
"that",
"the",
"Controller",
"listen",
"for",
"and",
"dispatch",
"an",
"event",
"."
] | train | https://github.com/ayust/kitnirc/blob/cf19fe39219da75f053e1a3976bf21331b6fefea/kitnirc/modular.py#L123-L137 |
ayust/kitnirc | kitnirc/modular.py | Controller.start | def start(self):
"""Begin listening for events from the Client and acting upon them.
Note: If configuration has not already been loaded, it will be loaded
immediately before starting to listen for events. Calling this method
without having specified and/or loaded a configuration will re... | python | def start(self):
"""Begin listening for events from the Client and acting upon them.
Note: If configuration has not already been loaded, it will be loaded
immediately before starting to listen for events. Calling this method
without having specified and/or loaded a configuration will re... | [
"def",
"start",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"config",
"and",
"self",
".",
"config_path",
"is",
"not",
"None",
":",
"self",
".",
"load_config",
"(",
")",
"self",
".",
"running",
"=",
"True",
"self",
".",
"process_event",
"(",
"\"S... | Begin listening for events from the Client and acting upon them.
Note: If configuration has not already been loaded, it will be loaded
immediately before starting to listen for events. Calling this method
without having specified and/or loaded a configuration will result in
completely d... | [
"Begin",
"listening",
"for",
"events",
"from",
"the",
"Client",
"and",
"acting",
"upon",
"them",
"."
] | train | https://github.com/ayust/kitnirc/blob/cf19fe39219da75f053e1a3976bf21331b6fefea/kitnirc/modular.py#L139-L153 |
ayust/kitnirc | kitnirc/modular.py | Controller.process_event | def process_event(self, event, client, args, force_dispatch=False):
"""Process an incoming event.
Offers it to each module according to self.module_ordering,
continuing to the next unless the module inhibits propagation.
Returns True if a module inhibited propagation, otherwise False.
... | python | def process_event(self, event, client, args, force_dispatch=False):
"""Process an incoming event.
Offers it to each module according to self.module_ordering,
continuing to the next unless the module inhibits propagation.
Returns True if a module inhibited propagation, otherwise False.
... | [
"def",
"process_event",
"(",
"self",
",",
"event",
",",
"client",
",",
"args",
",",
"force_dispatch",
"=",
"False",
")",
":",
"if",
"not",
"self",
".",
"running",
":",
"_log",
".",
"debug",
"(",
"\"Ignoring '%s' event - controller not running.\"",
",",
"event"... | Process an incoming event.
Offers it to each module according to self.module_ordering,
continuing to the next unless the module inhibits propagation.
Returns True if a module inhibited propagation, otherwise False. | [
"Process",
"an",
"incoming",
"event",
"."
] | train | https://github.com/ayust/kitnirc/blob/cf19fe39219da75f053e1a3976bf21331b6fefea/kitnirc/modular.py#L155-L185 |
ayust/kitnirc | kitnirc/modular.py | Controller.load_config | def load_config(self, config_path=None):
"""Load configuration from the specified path, or self.config_path"""
if config_path is None:
config_path = self.config_path
else:
self.config_path = config_path
config = ConfigParser.SafeConfigParser(self.DEFAULT_SUBSTITU... | python | def load_config(self, config_path=None):
"""Load configuration from the specified path, or self.config_path"""
if config_path is None:
config_path = self.config_path
else:
self.config_path = config_path
config = ConfigParser.SafeConfigParser(self.DEFAULT_SUBSTITU... | [
"def",
"load_config",
"(",
"self",
",",
"config_path",
"=",
"None",
")",
":",
"if",
"config_path",
"is",
"None",
":",
"config_path",
"=",
"self",
".",
"config_path",
"else",
":",
"self",
".",
"config_path",
"=",
"config_path",
"config",
"=",
"ConfigParser",
... | Load configuration from the specified path, or self.config_path | [
"Load",
"configuration",
"from",
"the",
"specified",
"path",
"or",
"self",
".",
"config_path"
] | train | https://github.com/ayust/kitnirc/blob/cf19fe39219da75f053e1a3976bf21331b6fefea/kitnirc/modular.py#L195-L216 |
ayust/kitnirc | kitnirc/modular.py | Controller.save_config | def save_config(self, config_path=None):
"""Save configuration to the specified path, or self.config_path"""
if config_path is None:
config_path = self.config_path
else:
self.config_path = config_path
with open(config_path, 'w') as f:
self.config.writ... | python | def save_config(self, config_path=None):
"""Save configuration to the specified path, or self.config_path"""
if config_path is None:
config_path = self.config_path
else:
self.config_path = config_path
with open(config_path, 'w') as f:
self.config.writ... | [
"def",
"save_config",
"(",
"self",
",",
"config_path",
"=",
"None",
")",
":",
"if",
"config_path",
"is",
"None",
":",
"config_path",
"=",
"self",
".",
"config_path",
"else",
":",
"self",
".",
"config_path",
"=",
"config_path",
"with",
"open",
"(",
"config_... | Save configuration to the specified path, or self.config_path | [
"Save",
"configuration",
"to",
"the",
"specified",
"path",
"or",
"self",
".",
"config_path"
] | train | https://github.com/ayust/kitnirc/blob/cf19fe39219da75f053e1a3976bf21331b6fefea/kitnirc/modular.py#L218-L226 |
ayust/kitnirc | kitnirc/modular.py | Controller.reload_modules | def reload_modules(self):
"""(Re)load all of the configured modules.
1. Calls stop(reloading=True) on each loaded module
2. Clears .loaded_modules and .module_ordering
3. Loads each module specified in the config
4. Calls start() on each loaded module, with reloading set dependi... | python | def reload_modules(self):
"""(Re)load all of the configured modules.
1. Calls stop(reloading=True) on each loaded module
2. Clears .loaded_modules and .module_ordering
3. Loads each module specified in the config
4. Calls start() on each loaded module, with reloading set dependi... | [
"def",
"reload_modules",
"(",
"self",
")",
":",
"old_modules",
"=",
"set",
"(",
"self",
".",
"loaded_modules",
")",
"for",
"module",
"in",
"self",
".",
"loaded_modules",
".",
"itervalues",
"(",
")",
":",
"module",
".",
"stop",
"(",
"reloading",
"=",
"Tru... | (Re)load all of the configured modules.
1. Calls stop(reloading=True) on each loaded module
2. Clears .loaded_modules and .module_ordering
3. Loads each module specified in the config
4. Calls start() on each loaded module, with reloading set depending
on whether the module w... | [
"(",
"Re",
")",
"load",
"all",
"of",
"the",
"configured",
"modules",
"."
] | train | https://github.com/ayust/kitnirc/blob/cf19fe39219da75f053e1a3976bf21331b6fefea/kitnirc/modular.py#L228-L274 |
ayust/kitnirc | kitnirc/modular.py | Controller.reload_module | def reload_module(self, module_name):
"""Reloads the specified module without changing its ordering.
1. Calls stop(reloading=True) on the module
2. Reloads the Module object into .loaded_modules
3. Calls start(reloading=True) on the new object
If called with a module na... | python | def reload_module(self, module_name):
"""Reloads the specified module without changing its ordering.
1. Calls stop(reloading=True) on the module
2. Reloads the Module object into .loaded_modules
3. Calls start(reloading=True) on the new object
If called with a module na... | [
"def",
"reload_module",
"(",
"self",
",",
"module_name",
")",
":",
"module",
"=",
"self",
".",
"loaded_modules",
".",
"get",
"(",
"module_name",
")",
"if",
"module",
":",
"module",
".",
"stop",
"(",
"reloading",
"=",
"True",
")",
"else",
":",
"_log",
"... | Reloads the specified module without changing its ordering.
1. Calls stop(reloading=True) on the module
2. Reloads the Module object into .loaded_modules
3. Calls start(reloading=True) on the new object
If called with a module name that is not currently loaded, it will load it.... | [
"Reloads",
"the",
"specified",
"module",
"without",
"changing",
"its",
"ordering",
"."
] | train | https://github.com/ayust/kitnirc/blob/cf19fe39219da75f053e1a3976bf21331b6fefea/kitnirc/modular.py#L276-L303 |
ayust/kitnirc | kitnirc/modular.py | Controller.load_module | def load_module(self, module_name):
"""Attempts to load the specified module.
If successful, .loaded_modules[module_name] will be populated, and
module_name will be added to the end of .module_ordering as well if
it is not already present. Note that this function does NOT call
s... | python | def load_module(self, module_name):
"""Attempts to load the specified module.
If successful, .loaded_modules[module_name] will be populated, and
module_name will be added to the end of .module_ordering as well if
it is not already present. Note that this function does NOT call
s... | [
"def",
"load_module",
"(",
"self",
",",
"module_name",
")",
":",
"if",
"module_name",
"in",
"self",
".",
"currently_loading",
":",
"_log",
".",
"warning",
"(",
"\"Ignoring request to load module '%s' because it \"",
"\"is already currently being loaded.\"",
",",
"module_n... | Attempts to load the specified module.
If successful, .loaded_modules[module_name] will be populated, and
module_name will be added to the end of .module_ordering as well if
it is not already present. Note that this function does NOT call
start()/stop() on the module - in general, you d... | [
"Attempts",
"to",
"load",
"the",
"specified",
"module",
"."
] | train | https://github.com/ayust/kitnirc/blob/cf19fe39219da75f053e1a3976bf21331b6fefea/kitnirc/modular.py#L305-L355 |
ayust/kitnirc | kitnirc/modular.py | Controller.unload_module | def unload_module(self, module_name):
"""Unload the specified module, if it is loaded."""
module = self.loaded_modules.get(module_name)
if not module:
_log.warning("Ignoring request to unload non-existant module '%s'",
module_name)
return False
... | python | def unload_module(self, module_name):
"""Unload the specified module, if it is loaded."""
module = self.loaded_modules.get(module_name)
if not module:
_log.warning("Ignoring request to unload non-existant module '%s'",
module_name)
return False
... | [
"def",
"unload_module",
"(",
"self",
",",
"module_name",
")",
":",
"module",
"=",
"self",
".",
"loaded_modules",
".",
"get",
"(",
"module_name",
")",
"if",
"not",
"module",
":",
"_log",
".",
"warning",
"(",
"\"Ignoring request to unload non-existant module '%s'\""... | Unload the specified module, if it is loaded. | [
"Unload",
"the",
"specified",
"module",
"if",
"it",
"is",
"loaded",
"."
] | train | https://github.com/ayust/kitnirc/blob/cf19fe39219da75f053e1a3976bf21331b6fefea/kitnirc/modular.py#L357-L368 |
juju/juju-bundlelib | jujubundlelib/references.py | _parse_url | def _parse_url(url, fully_qualified=False):
"""Parse the given charm or bundle URL, provided as a string.
Return a tuple containing the entity reference fragments: schema, user,
series, name and revision.
Each fragment is a string except revision (int).
Raise a ValueError with a descriptive messag... | python | def _parse_url(url, fully_qualified=False):
"""Parse the given charm or bundle URL, provided as a string.
Return a tuple containing the entity reference fragments: schema, user,
series, name and revision.
Each fragment is a string except revision (int).
Raise a ValueError with a descriptive messag... | [
"def",
"_parse_url",
"(",
"url",
",",
"fully_qualified",
"=",
"False",
")",
":",
"# Retrieve the schema.",
"try",
":",
"schema",
",",
"remaining",
"=",
"url",
".",
"split",
"(",
"':'",
",",
"1",
")",
"except",
"ValueError",
":",
"if",
"fully_qualified",
":... | Parse the given charm or bundle URL, provided as a string.
Return a tuple containing the entity reference fragments: schema, user,
series, name and revision.
Each fragment is a string except revision (int).
Raise a ValueError with a descriptive message if the given URL is not
valid. If fully_quali... | [
"Parse",
"the",
"given",
"charm",
"or",
"bundle",
"URL",
"provided",
"as",
"a",
"string",
"."
] | train | https://github.com/juju/juju-bundlelib/blob/c2efa614f53675ed9526027776448bfbb0454ca6/jujubundlelib/references.py#L204-L276 |
delfick/harpoon | harpoon/option_spec/harpoon_specs.py | HarpoonSpec.tasks_spec | def tasks_spec(self, available_actions, default_action="run"):
"""Tasks for a particular image"""
return dictof(
self.task_name_spec
, create_spec(task_objs.Task, validators.deprecated_key("spec", "Use ``action`` and ``options`` instead (note that ``action`` defaults to run)")
... | python | def tasks_spec(self, available_actions, default_action="run"):
"""Tasks for a particular image"""
return dictof(
self.task_name_spec
, create_spec(task_objs.Task, validators.deprecated_key("spec", "Use ``action`` and ``options`` instead (note that ``action`` defaults to run)")
... | [
"def",
"tasks_spec",
"(",
"self",
",",
"available_actions",
",",
"default_action",
"=",
"\"run\"",
")",
":",
"return",
"dictof",
"(",
"self",
".",
"task_name_spec",
",",
"create_spec",
"(",
"task_objs",
".",
"Task",
",",
"validators",
".",
"deprecated_key",
"(... | Tasks for a particular image | [
"Tasks",
"for",
"a",
"particular",
"image"
] | train | https://github.com/delfick/harpoon/blob/a2d39311d6127b7da2e15f40468bf320d598e461/harpoon/option_spec/harpoon_specs.py#L118-L128 |
delfick/harpoon | harpoon/option_spec/harpoon_specs.py | HarpoonSpec.authentications_spec | def authentications_spec(self):
"""Spec for a group of authentication options"""
return container_spec(authentication_objs.Authentication
, dictof(string_spec(), set_options(
reading = optional_spec(authentication_spec())
, writing = optional_spec(authenti... | python | def authentications_spec(self):
"""Spec for a group of authentication options"""
return container_spec(authentication_objs.Authentication
, dictof(string_spec(), set_options(
reading = optional_spec(authentication_spec())
, writing = optional_spec(authenti... | [
"def",
"authentications_spec",
"(",
"self",
")",
":",
"return",
"container_spec",
"(",
"authentication_objs",
".",
"Authentication",
",",
"dictof",
"(",
"string_spec",
"(",
")",
",",
"set_options",
"(",
"reading",
"=",
"optional_spec",
"(",
"authentication_spec",
... | Spec for a group of authentication options | [
"Spec",
"for",
"a",
"group",
"of",
"authentication",
"options"
] | train | https://github.com/delfick/harpoon/blob/a2d39311d6127b7da2e15f40468bf320d598e461/harpoon/option_spec/harpoon_specs.py#L131-L139 |
delfick/harpoon | harpoon/option_spec/harpoon_specs.py | HarpoonSpec.wait_condition_spec | def wait_condition_spec(self):
"""Spec for a wait_condition block"""
from harpoon.option_spec import image_objs
formatted_string = formatted(string_spec(), formatter=MergedOptionStringFormatter)
return create_spec(image_objs.WaitCondition
, harpoon = formatted(overridden("{ha... | python | def wait_condition_spec(self):
"""Spec for a wait_condition block"""
from harpoon.option_spec import image_objs
formatted_string = formatted(string_spec(), formatter=MergedOptionStringFormatter)
return create_spec(image_objs.WaitCondition
, harpoon = formatted(overridden("{ha... | [
"def",
"wait_condition_spec",
"(",
"self",
")",
":",
"from",
"harpoon",
".",
"option_spec",
"import",
"image_objs",
"formatted_string",
"=",
"formatted",
"(",
"string_spec",
"(",
")",
",",
"formatter",
"=",
"MergedOptionStringFormatter",
")",
"return",
"create_spec"... | Spec for a wait_condition block | [
"Spec",
"for",
"a",
"wait_condition",
"block"
] | train | https://github.com/delfick/harpoon/blob/a2d39311d6127b7da2e15f40468bf320d598e461/harpoon/option_spec/harpoon_specs.py#L142-L157 |
delfick/harpoon | harpoon/option_spec/harpoon_specs.py | HarpoonSpec.context_spec | def context_spec(self):
"""Spec for specifying context options"""
from harpoon.option_spec import image_objs
return dict_from_bool_spec(lambda meta, val: {"enabled": val}
, create_spec(image_objs.Context
, validators.deprecated_key("use_git_timestamps", "Since docker ... | python | def context_spec(self):
"""Spec for specifying context options"""
from harpoon.option_spec import image_objs
return dict_from_bool_spec(lambda meta, val: {"enabled": val}
, create_spec(image_objs.Context
, validators.deprecated_key("use_git_timestamps", "Since docker ... | [
"def",
"context_spec",
"(",
"self",
")",
":",
"from",
"harpoon",
".",
"option_spec",
"import",
"image_objs",
"return",
"dict_from_bool_spec",
"(",
"lambda",
"meta",
",",
"val",
":",
"{",
"\"enabled\"",
":",
"val",
"}",
",",
"create_spec",
"(",
"image_objs",
... | Spec for specifying context options | [
"Spec",
"for",
"specifying",
"context",
"options"
] | train | https://github.com/delfick/harpoon/blob/a2d39311d6127b7da2e15f40468bf320d598e461/harpoon/option_spec/harpoon_specs.py#L160-L176 |
delfick/harpoon | harpoon/option_spec/harpoon_specs.py | HarpoonSpec.image_spec | def image_spec(self):
"""Spec for each image"""
from harpoon.option_spec import image_specs as specs
from harpoon.option_spec import image_objs
class persistence_shell_spec(Spec):
"""Make the persistence shell default to the shell on the image"""
def normalise(sel... | python | def image_spec(self):
"""Spec for each image"""
from harpoon.option_spec import image_specs as specs
from harpoon.option_spec import image_objs
class persistence_shell_spec(Spec):
"""Make the persistence shell default to the shell on the image"""
def normalise(sel... | [
"def",
"image_spec",
"(",
"self",
")",
":",
"from",
"harpoon",
".",
"option_spec",
"import",
"image_specs",
"as",
"specs",
"from",
"harpoon",
".",
"option_spec",
"import",
"image_objs",
"class",
"persistence_shell_spec",
"(",
"Spec",
")",
":",
"\"\"\"Make the pers... | Spec for each image | [
"Spec",
"for",
"each",
"image"
] | train | https://github.com/delfick/harpoon/blob/a2d39311d6127b7da2e15f40468bf320d598e461/harpoon/option_spec/harpoon_specs.py#L179-L290 |
delfick/harpoon | harpoon/option_spec/harpoon_specs.py | HarpoonSpec.harpoon_spec | def harpoon_spec(self):
"""Spec for harpoon options"""
formatted_string = formatted(string_spec(), MergedOptionStringFormatter, expected_type=six.string_types)
formatted_boolean = formatted(boolean(), MergedOptionStringFormatter, expected_type=bool)
return create_spec(Harpoon
... | python | def harpoon_spec(self):
"""Spec for harpoon options"""
formatted_string = formatted(string_spec(), MergedOptionStringFormatter, expected_type=six.string_types)
formatted_boolean = formatted(boolean(), MergedOptionStringFormatter, expected_type=bool)
return create_spec(Harpoon
... | [
"def",
"harpoon_spec",
"(",
"self",
")",
":",
"formatted_string",
"=",
"formatted",
"(",
"string_spec",
"(",
")",
",",
"MergedOptionStringFormatter",
",",
"expected_type",
"=",
"six",
".",
"string_types",
")",
"formatted_boolean",
"=",
"formatted",
"(",
"boolean",... | Spec for harpoon options | [
"Spec",
"for",
"harpoon",
"options"
] | train | https://github.com/delfick/harpoon/blob/a2d39311d6127b7da2e15f40468bf320d598e461/harpoon/option_spec/harpoon_specs.py#L293-L328 |
5monkeys/content-io | cio/node.py | Node.namespace_uri | def namespace_uri(self):
"""
Finds and returns first applied URI of this node that has a namespace.
:return str: uri
"""
try:
return next(
iter(filter(lambda uri: URI(uri).namespace, self._uri))
)
except StopIteration:
... | python | def namespace_uri(self):
"""
Finds and returns first applied URI of this node that has a namespace.
:return str: uri
"""
try:
return next(
iter(filter(lambda uri: URI(uri).namespace, self._uri))
)
except StopIteration:
... | [
"def",
"namespace_uri",
"(",
"self",
")",
":",
"try",
":",
"return",
"next",
"(",
"iter",
"(",
"filter",
"(",
"lambda",
"uri",
":",
"URI",
"(",
"uri",
")",
".",
"namespace",
",",
"self",
".",
"_uri",
")",
")",
")",
"except",
"StopIteration",
":",
"... | Finds and returns first applied URI of this node that has a namespace.
:return str: uri | [
"Finds",
"and",
"returns",
"first",
"applied",
"URI",
"of",
"this",
"node",
"that",
"has",
"a",
"namespace",
"."
] | train | https://github.com/5monkeys/content-io/blob/8c8519c74cbadab871f7151c0e02252cb5753759/cio/node.py#L70-L81 |
mitsei/dlkit | dlkit/records/assessment/edx/drag_and_drop_records.py | EdXDragAndDropQuestionFormRecord._init_map | def _init_map(self):
"""stub"""
super(EdXDragAndDropQuestionFormRecord, self)._init_map()
QuestionTextFormRecord._init_map(self)
QuestionFilesFormRecord._init_map(self)
self.my_osid_object_form._my_map['text']['text'] = '' | python | def _init_map(self):
"""stub"""
super(EdXDragAndDropQuestionFormRecord, self)._init_map()
QuestionTextFormRecord._init_map(self)
QuestionFilesFormRecord._init_map(self)
self.my_osid_object_form._my_map['text']['text'] = '' | [
"def",
"_init_map",
"(",
"self",
")",
":",
"super",
"(",
"EdXDragAndDropQuestionFormRecord",
",",
"self",
")",
".",
"_init_map",
"(",
")",
"QuestionTextFormRecord",
".",
"_init_map",
"(",
"self",
")",
"QuestionFilesFormRecord",
".",
"_init_map",
"(",
"self",
")"... | stub | [
"stub"
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/records/assessment/edx/drag_and_drop_records.py#L74-L79 |
mitsei/dlkit | dlkit/records/assessment/edx/drag_and_drop_records.py | EdXDragAndDropQuestionFormRecord._init_metadata | def _init_metadata(self):
"""stub"""
super(EdXDragAndDropQuestionFormRecord, self)._init_metadata()
QuestionTextFormRecord._init_metadata(self)
QuestionFilesFormRecord._init_metadata(self) | python | def _init_metadata(self):
"""stub"""
super(EdXDragAndDropQuestionFormRecord, self)._init_metadata()
QuestionTextFormRecord._init_metadata(self)
QuestionFilesFormRecord._init_metadata(self) | [
"def",
"_init_metadata",
"(",
"self",
")",
":",
"super",
"(",
"EdXDragAndDropQuestionFormRecord",
",",
"self",
")",
".",
"_init_metadata",
"(",
")",
"QuestionTextFormRecord",
".",
"_init_metadata",
"(",
"self",
")",
"QuestionFilesFormRecord",
".",
"_init_metadata",
... | stub | [
"stub"
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/records/assessment/edx/drag_and_drop_records.py#L81-L85 |
mitsei/dlkit | dlkit/records/assessment/edx/drag_and_drop_records.py | EdXDragAndDropAnswerFormRecord._init_map | def _init_map(self):
"""call these all manually because non-cooperative"""
DecimalAnswerFormRecord._init_map(self)
DecimalValuesFormRecord._init_map(self)
TextAnswerFormRecord._init_map(self)
TextsFormRecord._init_map(self)
super(edXNumericResponseAnswerFormRecord, self).... | python | def _init_map(self):
"""call these all manually because non-cooperative"""
DecimalAnswerFormRecord._init_map(self)
DecimalValuesFormRecord._init_map(self)
TextAnswerFormRecord._init_map(self)
TextsFormRecord._init_map(self)
super(edXNumericResponseAnswerFormRecord, self).... | [
"def",
"_init_map",
"(",
"self",
")",
":",
"DecimalAnswerFormRecord",
".",
"_init_map",
"(",
"self",
")",
"DecimalValuesFormRecord",
".",
"_init_map",
"(",
"self",
")",
"TextAnswerFormRecord",
".",
"_init_map",
"(",
"self",
")",
"TextsFormRecord",
".",
"_init_map"... | call these all manually because non-cooperative | [
"call",
"these",
"all",
"manually",
"because",
"non",
"-",
"cooperative"
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/records/assessment/edx/drag_and_drop_records.py#L133-L139 |
mitsei/dlkit | dlkit/records/assessment/edx/drag_and_drop_records.py | EdXDragAndDropAnswerFormRecord._init_metadata | def _init_metadata(self):
"""stub"""
DecimalAnswerFormRecord._init_metadata(self)
DecimalValuesFormRecord._init_metadata(self)
TextAnswerFormRecord._init_metadata(self)
TextsFormRecord._init_metadata(self)
super(edXNumericResponseAnswerFormRecord, self)._init_metadata() | python | def _init_metadata(self):
"""stub"""
DecimalAnswerFormRecord._init_metadata(self)
DecimalValuesFormRecord._init_metadata(self)
TextAnswerFormRecord._init_metadata(self)
TextsFormRecord._init_metadata(self)
super(edXNumericResponseAnswerFormRecord, self)._init_metadata() | [
"def",
"_init_metadata",
"(",
"self",
")",
":",
"DecimalAnswerFormRecord",
".",
"_init_metadata",
"(",
"self",
")",
"DecimalValuesFormRecord",
".",
"_init_metadata",
"(",
"self",
")",
"TextAnswerFormRecord",
".",
"_init_metadata",
"(",
"self",
")",
"TextsFormRecord",
... | stub | [
"stub"
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/records/assessment/edx/drag_and_drop_records.py#L141-L147 |
mitsei/dlkit | dlkit/records/assessment/edx/drag_and_drop_records.py | EdXDragAndDropAnswerFormRecord.set_tolerance_value | def set_tolerance_value(self, tolerance):
"""stub"""
# include index because could be multiple response / tolerance pairs
if not isinstance(tolerance, float):
raise InvalidArgument('tolerance value must be a decimal')
self.add_decimal_value(tolerance, 'tolerance') | python | def set_tolerance_value(self, tolerance):
"""stub"""
# include index because could be multiple response / tolerance pairs
if not isinstance(tolerance, float):
raise InvalidArgument('tolerance value must be a decimal')
self.add_decimal_value(tolerance, 'tolerance') | [
"def",
"set_tolerance_value",
"(",
"self",
",",
"tolerance",
")",
":",
"# include index because could be multiple response / tolerance pairs",
"if",
"not",
"isinstance",
"(",
"tolerance",
",",
"float",
")",
":",
"raise",
"InvalidArgument",
"(",
"'tolerance value must be a d... | stub | [
"stub"
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/records/assessment/edx/drag_and_drop_records.py#L153-L158 |
python-odin/odinweb | odinweb/middleware/signing.py | SignedAuthBase.pre_dispatch | def pre_dispatch(self, request, path_args):
"""
Pre dispatch hook
"""
secret_key = self.get_secret_key(request, path_args)
if not secret_key:
raise PermissionDenied('Signature not valid.')
try:
signing.verify_url_path(request.path, request.GET, se... | python | def pre_dispatch(self, request, path_args):
"""
Pre dispatch hook
"""
secret_key = self.get_secret_key(request, path_args)
if not secret_key:
raise PermissionDenied('Signature not valid.')
try:
signing.verify_url_path(request.path, request.GET, se... | [
"def",
"pre_dispatch",
"(",
"self",
",",
"request",
",",
"path_args",
")",
":",
"secret_key",
"=",
"self",
".",
"get_secret_key",
"(",
"request",
",",
"path_args",
")",
"if",
"not",
"secret_key",
":",
"raise",
"PermissionDenied",
"(",
"'Signature not valid.'",
... | Pre dispatch hook | [
"Pre",
"dispatch",
"hook"
] | train | https://github.com/python-odin/odinweb/blob/198424133584acc18cb41c8d18d91f803abc810f/odinweb/middleware/signing.py#L42-L53 |
mitsei/dlkit | dlkit/json_/cataloging/searches.py | CatalogSearchResults.get_catalogs | def get_catalogs(self):
"""Gets the catalog list resulting from the search.
return: (osid.cataloging.CatalogList) - the catalogs list
raise: IllegalState - list has already been retrieved
*compliance: mandatory -- This method must be implemented.*
"""
if self.retrieved... | python | def get_catalogs(self):
"""Gets the catalog list resulting from the search.
return: (osid.cataloging.CatalogList) - the catalogs list
raise: IllegalState - list has already been retrieved
*compliance: mandatory -- This method must be implemented.*
"""
if self.retrieved... | [
"def",
"get_catalogs",
"(",
"self",
")",
":",
"if",
"self",
".",
"retrieved",
":",
"raise",
"errors",
".",
"IllegalState",
"(",
"'List has already been retrieved.'",
")",
"self",
".",
"retrieved",
"=",
"True",
"return",
"objects",
".",
"CatalogList",
"(",
"sel... | Gets the catalog list resulting from the search.
return: (osid.cataloging.CatalogList) - the catalogs list
raise: IllegalState - list has already been retrieved
*compliance: mandatory -- This method must be implemented.* | [
"Gets",
"the",
"catalog",
"list",
"resulting",
"from",
"the",
"search",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/cataloging/searches.py#L97-L108 |
mitsei/dlkit | dlkit/json_/authorization/managers.py | AuthorizationManager.get_authorization_session | def get_authorization_session(self):
"""Gets an ``AuthorizationSession`` which is responsible for performing authorization checks.
return: (osid.authorization.AuthorizationSession) - an
authorization session for this service
raise: OperationFailed - unable to complete request
... | python | def get_authorization_session(self):
"""Gets an ``AuthorizationSession`` which is responsible for performing authorization checks.
return: (osid.authorization.AuthorizationSession) - an
authorization session for this service
raise: OperationFailed - unable to complete request
... | [
"def",
"get_authorization_session",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"supports_authorization",
"(",
")",
":",
"raise",
"errors",
".",
"Unimplemented",
"(",
")",
"# pylint: disable=no-member",
"return",
"sessions",
".",
"AuthorizationSession",
"(",
... | Gets an ``AuthorizationSession`` which is responsible for performing authorization checks.
return: (osid.authorization.AuthorizationSession) - an
authorization session for this service
raise: OperationFailed - unable to complete request
raise: Unimplemented - ``supports_author... | [
"Gets",
"an",
"AuthorizationSession",
"which",
"is",
"responsible",
"for",
"performing",
"authorization",
"checks",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/authorization/managers.py#L401-L416 |
mitsei/dlkit | dlkit/json_/authorization/managers.py | AuthorizationManager.get_authorization_session_for_vault | def get_authorization_session_for_vault(self, vault_id):
"""Gets an ``AuthorizationSession`` which is responsible for performing authorization checks for the given vault.
arg: vault_id (osid.id.Id): the ``Id`` of the vault
return: (osid.authorization.AuthorizationSession) - ``an
... | python | def get_authorization_session_for_vault(self, vault_id):
"""Gets an ``AuthorizationSession`` which is responsible for performing authorization checks for the given vault.
arg: vault_id (osid.id.Id): the ``Id`` of the vault
return: (osid.authorization.AuthorizationSession) - ``an
... | [
"def",
"get_authorization_session_for_vault",
"(",
"self",
",",
"vault_id",
")",
":",
"if",
"not",
"self",
".",
"supports_authorization",
"(",
")",
":",
"raise",
"errors",
".",
"Unimplemented",
"(",
")",
"##",
"# Also include check to see if the catalog Id is found othe... | Gets an ``AuthorizationSession`` which is responsible for performing authorization checks for the given vault.
arg: vault_id (osid.id.Id): the ``Id`` of the vault
return: (osid.authorization.AuthorizationSession) - ``an
_authorization_session``
raise: NotFound - ``vault_id``... | [
"Gets",
"an",
"AuthorizationSession",
"which",
"is",
"responsible",
"for",
"performing",
"authorization",
"checks",
"for",
"the",
"given",
"vault",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/authorization/managers.py#L422-L444 |
mitsei/dlkit | dlkit/json_/authorization/managers.py | AuthorizationManager.get_authorization_lookup_session | def get_authorization_lookup_session(self):
"""Gets the ``OsidSession`` associated with the authorization lookup service.
return: (osid.authorization.AuthorizationLookupSession) - an
``AuthorizationLookupSession``
raise: OperationFailed - unable to complete request
rais... | python | def get_authorization_lookup_session(self):
"""Gets the ``OsidSession`` associated with the authorization lookup service.
return: (osid.authorization.AuthorizationLookupSession) - an
``AuthorizationLookupSession``
raise: OperationFailed - unable to complete request
rais... | [
"def",
"get_authorization_lookup_session",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"supports_authorization_lookup",
"(",
")",
":",
"raise",
"errors",
".",
"Unimplemented",
"(",
")",
"# pylint: disable=no-member",
"return",
"sessions",
".",
"AuthorizationLooku... | Gets the ``OsidSession`` associated with the authorization lookup service.
return: (osid.authorization.AuthorizationLookupSession) - an
``AuthorizationLookupSession``
raise: OperationFailed - unable to complete request
raise: Unimplemented - ``supports_authorization_lookup()``... | [
"Gets",
"the",
"OsidSession",
"associated",
"with",
"the",
"authorization",
"lookup",
"service",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/authorization/managers.py#L447-L462 |
mitsei/dlkit | dlkit/json_/authorization/managers.py | AuthorizationManager.get_authorization_query_session | def get_authorization_query_session(self):
"""Gets the ``OsidSession`` associated with the authorization query service.
return: (osid.authorization.AuthorizationQuerySession) - an
``AuthorizationQuerySession``
raise: OperationFailed - unable to complete request
raise: ... | python | def get_authorization_query_session(self):
"""Gets the ``OsidSession`` associated with the authorization query service.
return: (osid.authorization.AuthorizationQuerySession) - an
``AuthorizationQuerySession``
raise: OperationFailed - unable to complete request
raise: ... | [
"def",
"get_authorization_query_session",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"supports_authorization_query",
"(",
")",
":",
"raise",
"errors",
".",
"Unimplemented",
"(",
")",
"# pylint: disable=no-member",
"return",
"sessions",
".",
"AuthorizationQuerySe... | Gets the ``OsidSession`` associated with the authorization query service.
return: (osid.authorization.AuthorizationQuerySession) - an
``AuthorizationQuerySession``
raise: OperationFailed - unable to complete request
raise: Unimplemented - ``supports_authorization_query()`` is
... | [
"Gets",
"the",
"OsidSession",
"associated",
"with",
"the",
"authorization",
"query",
"service",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/authorization/managers.py#L493-L508 |
mitsei/dlkit | dlkit/json_/authorization/managers.py | AuthorizationManager.get_authorization_query_session_for_vault | def get_authorization_query_session_for_vault(self, vault_id):
"""Gets the ``OsidSession`` associated with the authorization query service for the given vault.
arg: vault_id (osid.id.Id): the ``Id`` of the vault
return: (osid.authorization.AuthorizationQuerySession) - ``an
_a... | python | def get_authorization_query_session_for_vault(self, vault_id):
"""Gets the ``OsidSession`` associated with the authorization query service for the given vault.
arg: vault_id (osid.id.Id): the ``Id`` of the vault
return: (osid.authorization.AuthorizationQuerySession) - ``an
_a... | [
"def",
"get_authorization_query_session_for_vault",
"(",
"self",
",",
"vault_id",
")",
":",
"if",
"not",
"self",
".",
"supports_authorization_query",
"(",
")",
":",
"raise",
"errors",
".",
"Unimplemented",
"(",
")",
"##",
"# Also include check to see if the catalog Id i... | Gets the ``OsidSession`` associated with the authorization query service for the given vault.
arg: vault_id (osid.id.Id): the ``Id`` of the vault
return: (osid.authorization.AuthorizationQuerySession) - ``an
_authorization_query_session``
raise: NotFound - ``vault_id`` not f... | [
"Gets",
"the",
"OsidSession",
"associated",
"with",
"the",
"authorization",
"query",
"service",
"for",
"the",
"given",
"vault",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/authorization/managers.py#L514-L536 |
mitsei/dlkit | dlkit/json_/authorization/managers.py | AuthorizationManager.get_authorization_admin_session | def get_authorization_admin_session(self):
"""Gets the ``OsidSession`` associated with the authorization administration service.
return: (osid.authorization.AuthorizationAdminSession) - an
``AuthorizationAdminSession``
raise: OperationFailed - unable to complete request
... | python | def get_authorization_admin_session(self):
"""Gets the ``OsidSession`` associated with the authorization administration service.
return: (osid.authorization.AuthorizationAdminSession) - an
``AuthorizationAdminSession``
raise: OperationFailed - unable to complete request
... | [
"def",
"get_authorization_admin_session",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"supports_authorization_admin",
"(",
")",
":",
"raise",
"errors",
".",
"Unimplemented",
"(",
")",
"# pylint: disable=no-member",
"return",
"sessions",
".",
"AuthorizationAdminSe... | Gets the ``OsidSession`` associated with the authorization administration service.
return: (osid.authorization.AuthorizationAdminSession) - an
``AuthorizationAdminSession``
raise: OperationFailed - unable to complete request
raise: Unimplemented - ``supports_authorization_admi... | [
"Gets",
"the",
"OsidSession",
"associated",
"with",
"the",
"authorization",
"administration",
"service",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/authorization/managers.py#L539-L554 |
mitsei/dlkit | dlkit/json_/authorization/managers.py | AuthorizationManager.get_authorization_admin_session_for_vault | def get_authorization_admin_session_for_vault(self, vault_id):
"""Gets the ``OsidSession`` associated with the authorization admin service for the given vault.
arg: vault_id (osid.id.Id): the ``Id`` of the vault
return: (osid.authorization.AuthorizationAdminSession) - ``an
_a... | python | def get_authorization_admin_session_for_vault(self, vault_id):
"""Gets the ``OsidSession`` associated with the authorization admin service for the given vault.
arg: vault_id (osid.id.Id): the ``Id`` of the vault
return: (osid.authorization.AuthorizationAdminSession) - ``an
_a... | [
"def",
"get_authorization_admin_session_for_vault",
"(",
"self",
",",
"vault_id",
")",
":",
"if",
"not",
"self",
".",
"supports_authorization_admin",
"(",
")",
":",
"raise",
"errors",
".",
"Unimplemented",
"(",
")",
"##",
"# Also include check to see if the catalog Id i... | Gets the ``OsidSession`` associated with the authorization admin service for the given vault.
arg: vault_id (osid.id.Id): the ``Id`` of the vault
return: (osid.authorization.AuthorizationAdminSession) - ``an
_authorization_admin_session``
raise: NotFound - ``vault_id`` not f... | [
"Gets",
"the",
"OsidSession",
"associated",
"with",
"the",
"authorization",
"admin",
"service",
"for",
"the",
"given",
"vault",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/authorization/managers.py#L560-L582 |
mitsei/dlkit | dlkit/json_/authorization/managers.py | AuthorizationManager.get_authorization_vault_session | def get_authorization_vault_session(self):
"""Gets the session for retrieving authorization to vault mappings.
return: (osid.authorization.AuthorizationVaultSession) - an
``AuthorizationVaultSession``
raise: OperationFailed - unable to complete request
raise: Unimpleme... | python | def get_authorization_vault_session(self):
"""Gets the session for retrieving authorization to vault mappings.
return: (osid.authorization.AuthorizationVaultSession) - an
``AuthorizationVaultSession``
raise: OperationFailed - unable to complete request
raise: Unimpleme... | [
"def",
"get_authorization_vault_session",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"supports_authorization_vault",
"(",
")",
":",
"raise",
"errors",
".",
"Unimplemented",
"(",
")",
"# pylint: disable=no-member",
"return",
"sessions",
".",
"AuthorizationVaultSe... | Gets the session for retrieving authorization to vault mappings.
return: (osid.authorization.AuthorizationVaultSession) - an
``AuthorizationVaultSession``
raise: OperationFailed - unable to complete request
raise: Unimplemented - ``supports_authorization_vault()`` is
... | [
"Gets",
"the",
"session",
"for",
"retrieving",
"authorization",
"to",
"vault",
"mappings",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/authorization/managers.py#L585-L600 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.