repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
alvarogzp/telegram-bot-framework
bot/action/util/format.py
UserFormatter.full_data
def full_data(self): """ Returns all the info available for the user in the following format: name [username] <id> (locale) bot_or_user If any data is not available, it is not added. """ data = [ self.full_name, self._username(), se...
python
def full_data(self): """ Returns all the info available for the user in the following format: name [username] <id> (locale) bot_or_user If any data is not available, it is not added. """ data = [ self.full_name, self._username(), se...
[ "def", "full_data", "(", "self", ")", ":", "data", "=", "[", "self", ".", "full_name", ",", "self", ".", "_username", "(", ")", ",", "self", ".", "_id", "(", ")", ",", "self", ".", "_language_code", "(", ")", ",", "self", ".", "_is_bot", "(", ")"...
Returns all the info available for the user in the following format: name [username] <id> (locale) bot_or_user If any data is not available, it is not added.
[ "Returns", "all", "the", "info", "available", "for", "the", "user", "in", "the", "following", "format", ":", "name", "[", "username", "]", "<id", ">", "(", "locale", ")", "bot_or_user", "If", "any", "data", "is", "not", "available", "it", "is", "not", ...
train
https://github.com/alvarogzp/telegram-bot-framework/blob/7b597a415c1901901c677976cb13100fc3083107/bot/action/util/format.py#L79-L92
alvarogzp/telegram-bot-framework
bot/action/util/format.py
ChatFormatter.full_data
def full_data(self): """ Returns all the info available for the chat in the following format: title [username] (type) <id> If any data is not available, it is not added. """ data = [ self.chat.title, self._username(), self._type(), ...
python
def full_data(self): """ Returns all the info available for the chat in the following format: title [username] (type) <id> If any data is not available, it is not added. """ data = [ self.chat.title, self._username(), self._type(), ...
[ "def", "full_data", "(", "self", ")", ":", "data", "=", "[", "self", ".", "chat", ".", "title", ",", "self", ".", "_username", "(", ")", ",", "self", ".", "_type", "(", ")", ",", "self", ".", "_id", "(", ")", "]", "return", "\" \"", ".", "join"...
Returns all the info available for the chat in the following format: title [username] (type) <id> If any data is not available, it is not added.
[ "Returns", "all", "the", "info", "available", "for", "the", "chat", "in", "the", "following", "format", ":", "title", "[", "username", "]", "(", "type", ")", "<id", ">", "If", "any", "data", "is", "not", "available", "it", "is", "not", "added", "." ]
train
https://github.com/alvarogzp/telegram-bot-framework/blob/7b597a415c1901901c677976cb13100fc3083107/bot/action/util/format.py#L124-L136
hammerlab/cohorts
cohorts/functions.py
use_defaults
def use_defaults(func): """ Decorator for functions that should automatically fall back to the Cohort-default filter_fn and normalized_per_mb if not specified. """ @wraps(func) def wrapper(row, cohort, filter_fn=None, normalized_per_mb=None, **kwargs): filter_fn = first_not_none_param([f...
python
def use_defaults(func): """ Decorator for functions that should automatically fall back to the Cohort-default filter_fn and normalized_per_mb if not specified. """ @wraps(func) def wrapper(row, cohort, filter_fn=None, normalized_per_mb=None, **kwargs): filter_fn = first_not_none_param([f...
[ "def", "use_defaults", "(", "func", ")", ":", "@", "wraps", "(", "func", ")", "def", "wrapper", "(", "row", ",", "cohort", ",", "filter_fn", "=", "None", ",", "normalized_per_mb", "=", "None", ",", "*", "*", "kwargs", ")", ":", "filter_fn", "=", "fir...
Decorator for functions that should automatically fall back to the Cohort-default filter_fn and normalized_per_mb if not specified.
[ "Decorator", "for", "functions", "that", "should", "automatically", "fall", "back", "to", "the", "Cohort", "-", "default", "filter_fn", "and", "normalized_per_mb", "if", "not", "specified", "." ]
train
https://github.com/hammerlab/cohorts/blob/278b05e609e6c4d4a77c57d49446460be53ea33e/cohorts/functions.py#L28-L42
hammerlab/cohorts
cohorts/functions.py
count_function
def count_function(func): """ Decorator for functions that return a collection (technically a dict of collections) that should be counted up. Also automatically falls back to the Cohort-default filter_fn and normalized_per_mb if not specified. """ # Fall back to Cohort-level defaults. @use_d...
python
def count_function(func): """ Decorator for functions that return a collection (technically a dict of collections) that should be counted up. Also automatically falls back to the Cohort-default filter_fn and normalized_per_mb if not specified. """ # Fall back to Cohort-level defaults. @use_d...
[ "def", "count_function", "(", "func", ")", ":", "# Fall back to Cohort-level defaults.", "@", "use_defaults", "@", "wraps", "(", "func", ")", "def", "wrapper", "(", "row", ",", "cohort", ",", "filter_fn", "=", "None", ",", "normalized_per_mb", "=", "None", ","...
Decorator for functions that return a collection (technically a dict of collections) that should be counted up. Also automatically falls back to the Cohort-default filter_fn and normalized_per_mb if not specified.
[ "Decorator", "for", "functions", "that", "return", "a", "collection", "(", "technically", "a", "dict", "of", "collections", ")", "that", "should", "be", "counted", "up", ".", "Also", "automatically", "falls", "back", "to", "the", "Cohort", "-", "default", "f...
train
https://github.com/hammerlab/cohorts/blob/278b05e609e6c4d4a77c57d49446460be53ea33e/cohorts/functions.py#L44-L66
hammerlab/cohorts
cohorts/functions.py
count_variants_function_builder
def count_variants_function_builder(function_name, filterable_variant_function=None): """ Creates a function that counts variants that are filtered by the provided filterable_variant_function. The filterable_variant_function is a function that takes a filterable_variant and returns True or False. Users...
python
def count_variants_function_builder(function_name, filterable_variant_function=None): """ Creates a function that counts variants that are filtered by the provided filterable_variant_function. The filterable_variant_function is a function that takes a filterable_variant and returns True or False. Users...
[ "def", "count_variants_function_builder", "(", "function_name", ",", "filterable_variant_function", "=", "None", ")", ":", "@", "count_function", "def", "count", "(", "row", ",", "cohort", ",", "filter_fn", ",", "normalized_per_mb", ",", "*", "*", "kwargs", ")", ...
Creates a function that counts variants that are filtered by the provided filterable_variant_function. The filterable_variant_function is a function that takes a filterable_variant and returns True or False. Users of this builder need not worry about applying e.g. the Cohort's default `filter_fn`. That will be...
[ "Creates", "a", "function", "that", "counts", "variants", "that", "are", "filtered", "by", "the", "provided", "filterable_variant_function", ".", "The", "filterable_variant_function", "is", "a", "function", "that", "takes", "a", "filterable_variant", "and", "returns",...
train
https://github.com/hammerlab/cohorts/blob/278b05e609e6c4d4a77c57d49446460be53ea33e/cohorts/functions.py#L73-L93
hammerlab/cohorts
cohorts/functions.py
count_effects_function_builder
def count_effects_function_builder(function_name, only_nonsynonymous, filterable_effect_function=None): """ Create a function that counts effects that are filtered by the provided filterable_effect_function. The filterable_effect_function is a function that takes a filterable_effect and returns True or Fals...
python
def count_effects_function_builder(function_name, only_nonsynonymous, filterable_effect_function=None): """ Create a function that counts effects that are filtered by the provided filterable_effect_function. The filterable_effect_function is a function that takes a filterable_effect and returns True or Fals...
[ "def", "count_effects_function_builder", "(", "function_name", ",", "only_nonsynonymous", ",", "filterable_effect_function", "=", "None", ")", ":", "@", "count_function", "def", "count", "(", "row", ",", "cohort", ",", "filter_fn", ",", "normalized_per_mb", ",", "*"...
Create a function that counts effects that are filtered by the provided filterable_effect_function. The filterable_effect_function is a function that takes a filterable_effect and returns True or False. Users of this builder need not worry about applying e.g. the Cohort's default `filter_fn`. That will be appl...
[ "Create", "a", "function", "that", "counts", "effects", "that", "are", "filtered", "by", "the", "provided", "filterable_effect_function", ".", "The", "filterable_effect_function", "is", "a", "function", "that", "takes", "a", "filterable_effect", "and", "returns", "T...
train
https://github.com/hammerlab/cohorts/blob/278b05e609e6c4d4a77c57d49446460be53ea33e/cohorts/functions.py#L95-L121
hammerlab/cohorts
cohorts/functions.py
median_vaf_purity
def median_vaf_purity(row, cohort, **kwargs): """ Estimate purity based on 2 * median VAF. Even if the Cohort has a default filter_fn, ignore it: we want to use all variants for this estimate. """ patient_id = row["patient_id"] patient = cohort.patient_from_id(patient_id) variants = coh...
python
def median_vaf_purity(row, cohort, **kwargs): """ Estimate purity based on 2 * median VAF. Even if the Cohort has a default filter_fn, ignore it: we want to use all variants for this estimate. """ patient_id = row["patient_id"] patient = cohort.patient_from_id(patient_id) variants = coh...
[ "def", "median_vaf_purity", "(", "row", ",", "cohort", ",", "*", "*", "kwargs", ")", ":", "patient_id", "=", "row", "[", "\"patient_id\"", "]", "patient", "=", "cohort", ".", "patient_from_id", "(", "patient_id", ")", "variants", "=", "cohort", ".", "load_...
Estimate purity based on 2 * median VAF. Even if the Cohort has a default filter_fn, ignore it: we want to use all variants for this estimate.
[ "Estimate", "purity", "based", "on", "2", "*", "median", "VAF", "." ]
train
https://github.com/hammerlab/cohorts/blob/278b05e609e6c4d4a77c57d49446460be53ea33e/cohorts/functions.py#L264-L282
hammerlab/cohorts
cohorts/model.py
bootstrap_auc
def bootstrap_auc(df, col, pred_col, n_bootstrap=1000): """ Calculate the boostrapped AUC for a given col trying to predict a pred_col. Parameters ---------- df : pandas.DataFrame col : str column to retrieve the values from pred_col : str the column we're trying to predict ...
python
def bootstrap_auc(df, col, pred_col, n_bootstrap=1000): """ Calculate the boostrapped AUC for a given col trying to predict a pred_col. Parameters ---------- df : pandas.DataFrame col : str column to retrieve the values from pred_col : str the column we're trying to predict ...
[ "def", "bootstrap_auc", "(", "df", ",", "col", ",", "pred_col", ",", "n_bootstrap", "=", "1000", ")", ":", "scores", "=", "np", ".", "zeros", "(", "n_bootstrap", ")", "old_len", "=", "len", "(", "df", ")", "df", ".", "dropna", "(", "subset", "=", "...
Calculate the boostrapped AUC for a given col trying to predict a pred_col. Parameters ---------- df : pandas.DataFrame col : str column to retrieve the values from pred_col : str the column we're trying to predict n_boostrap : int the number of bootstrap samples Re...
[ "Calculate", "the", "boostrapped", "AUC", "for", "a", "given", "col", "trying", "to", "predict", "a", "pred_col", "." ]
train
https://github.com/hammerlab/cohorts/blob/278b05e609e6c4d4a77c57d49446460be53ea33e/cohorts/model.py#L36-L66
alvarogzp/telegram-bot-framework
bot/multithreading/scheduler.py
SchedulerApi.set_callbacks
def set_callbacks(self, worker_start_callback: callable, worker_end_callback: callable, are_async: bool = False): """ :param are_async: True if the callbacks execute asynchronously, posting any heavy work to another thread. """ # We are setting self.worker_start_callback and self.worker_...
python
def set_callbacks(self, worker_start_callback: callable, worker_end_callback: callable, are_async: bool = False): """ :param are_async: True if the callbacks execute asynchronously, posting any heavy work to another thread. """ # We are setting self.worker_start_callback and self.worker_...
[ "def", "set_callbacks", "(", "self", ",", "worker_start_callback", ":", "callable", ",", "worker_end_callback", ":", "callable", ",", "are_async", ":", "bool", "=", "False", ")", ":", "# We are setting self.worker_start_callback and self.worker_end_callback", "# to lambdas ...
:param are_async: True if the callbacks execute asynchronously, posting any heavy work to another thread.
[ ":", "param", "are_async", ":", "True", "if", "the", "callbacks", "execute", "asynchronously", "posting", "any", "heavy", "work", "to", "another", "thread", "." ]
train
https://github.com/alvarogzp/telegram-bot-framework/blob/7b597a415c1901901c677976cb13100fc3083107/bot/multithreading/scheduler.py#L59-L80
alvarogzp/telegram-bot-framework
bot/multithreading/scheduler.py
SchedulerApi._start_worker
def _start_worker(self, worker: Worker): """ Can be safely called multiple times on the same worker (for workers that support it) to start a new thread for it. """ # This function is called from main thread and from worker pools threads to start their children threads wit...
python
def _start_worker(self, worker: Worker): """ Can be safely called multiple times on the same worker (for workers that support it) to start a new thread for it. """ # This function is called from main thread and from worker pools threads to start their children threads wit...
[ "def", "_start_worker", "(", "self", ",", "worker", ":", "Worker", ")", ":", "# This function is called from main thread and from worker pools threads to start their children threads", "with", "self", ".", "running_workers_lock", ":", "self", ".", "running_workers", ".", "app...
Can be safely called multiple times on the same worker (for workers that support it) to start a new thread for it.
[ "Can", "be", "safely", "called", "multiple", "times", "on", "the", "same", "worker", "(", "for", "workers", "that", "support", "it", ")", "to", "start", "a", "new", "thread", "for", "it", "." ]
train
https://github.com/alvarogzp/telegram-bot-framework/blob/7b597a415c1901901c677976cb13100fc3083107/bot/multithreading/scheduler.py#L95-L106
alvarogzp/telegram-bot-framework
bot/multithreading/scheduler.py
SchedulerApi.new_worker
def new_worker(self, name: str): """Creates a new Worker and start a new Thread with it. Returns the Worker.""" if not self.running: return self.immediate_worker worker = self._new_worker(name) self._start_worker(worker) return worker
python
def new_worker(self, name: str): """Creates a new Worker and start a new Thread with it. Returns the Worker.""" if not self.running: return self.immediate_worker worker = self._new_worker(name) self._start_worker(worker) return worker
[ "def", "new_worker", "(", "self", ",", "name", ":", "str", ")", ":", "if", "not", "self", ".", "running", ":", "return", "self", ".", "immediate_worker", "worker", "=", "self", ".", "_new_worker", "(", "name", ")", "self", ".", "_start_worker", "(", "w...
Creates a new Worker and start a new Thread with it. Returns the Worker.
[ "Creates", "a", "new", "Worker", "and", "start", "a", "new", "Thread", "with", "it", ".", "Returns", "the", "Worker", "." ]
train
https://github.com/alvarogzp/telegram-bot-framework/blob/7b597a415c1901901c677976cb13100fc3083107/bot/multithreading/scheduler.py#L148-L154
alvarogzp/telegram-bot-framework
bot/multithreading/scheduler.py
SchedulerApi.new_worker_pool
def new_worker_pool(self, name: str, min_workers: int = 0, max_workers: int = 1, max_seconds_idle: int = DEFAULT_WORKER_POOL_MAX_SECONDS_IDLE): """ Creates a new worker pool and starts it. Returns the Worker that schedules works to the pool. """ if not sel...
python
def new_worker_pool(self, name: str, min_workers: int = 0, max_workers: int = 1, max_seconds_idle: int = DEFAULT_WORKER_POOL_MAX_SECONDS_IDLE): """ Creates a new worker pool and starts it. Returns the Worker that schedules works to the pool. """ if not sel...
[ "def", "new_worker_pool", "(", "self", ",", "name", ":", "str", ",", "min_workers", ":", "int", "=", "0", ",", "max_workers", ":", "int", "=", "1", ",", "max_seconds_idle", ":", "int", "=", "DEFAULT_WORKER_POOL_MAX_SECONDS_IDLE", ")", ":", "if", "not", "se...
Creates a new worker pool and starts it. Returns the Worker that schedules works to the pool.
[ "Creates", "a", "new", "worker", "pool", "and", "starts", "it", ".", "Returns", "the", "Worker", "that", "schedules", "works", "to", "the", "pool", "." ]
train
https://github.com/alvarogzp/telegram-bot-framework/blob/7b597a415c1901901c677976cb13100fc3083107/bot/multithreading/scheduler.py#L156-L166
hammerlab/cohorts
cohorts/cohort.py
Cohort.as_dataframe
def as_dataframe(self, on=None, join_with=None, join_how=None, return_cols=False, rename_cols=False, keep_paren_contents=True, **kwargs): """ Return this Cohort as a DataFrame, and optionally include additional columns using `on`. on : str or fu...
python
def as_dataframe(self, on=None, join_with=None, join_how=None, return_cols=False, rename_cols=False, keep_paren_contents=True, **kwargs): """ Return this Cohort as a DataFrame, and optionally include additional columns using `on`. on : str or fu...
[ "def", "as_dataframe", "(", "self", ",", "on", "=", "None", ",", "join_with", "=", "None", ",", "join_how", "=", "None", ",", "return_cols", "=", "False", ",", "rename_cols", "=", "False", ",", "keep_paren_contents", "=", "True", ",", "*", "*", "kwargs",...
Return this Cohort as a DataFrame, and optionally include additional columns using `on`. on : str or function or list or dict, optional - A column name. - Or a function that creates a new column for comparison, e.g. count.snv_count. - Or a list of column-generating f...
[ "Return", "this", "Cohort", "as", "a", "DataFrame", "and", "optionally", "include", "additional", "columns", "using", "on", "." ]
train
https://github.com/hammerlab/cohorts/blob/278b05e609e6c4d4a77c57d49446460be53ea33e/cohorts/cohort.py#L302-L400
hammerlab/cohorts
cohorts/cohort.py
Cohort.load_dataframe
def load_dataframe(self, df_loader_name): """ Instead of joining a DataFrameJoiner with the Cohort in `as_dataframe`, sometimes we may want to just directly load a particular DataFrame. """ logger.debug("loading dataframe: {}".format(df_loader_name)) # Get the DataFrameLo...
python
def load_dataframe(self, df_loader_name): """ Instead of joining a DataFrameJoiner with the Cohort in `as_dataframe`, sometimes we may want to just directly load a particular DataFrame. """ logger.debug("loading dataframe: {}".format(df_loader_name)) # Get the DataFrameLo...
[ "def", "load_dataframe", "(", "self", ",", "df_loader_name", ")", ":", "logger", ".", "debug", "(", "\"loading dataframe: {}\"", ".", "format", "(", "df_loader_name", ")", ")", "# Get the DataFrameLoader object corresponding to this name.", "df_loaders", "=", "[", "df_l...
Instead of joining a DataFrameJoiner with the Cohort in `as_dataframe`, sometimes we may want to just directly load a particular DataFrame.
[ "Instead", "of", "joining", "a", "DataFrameJoiner", "with", "the", "Cohort", "in", "as_dataframe", "sometimes", "we", "may", "want", "to", "just", "directly", "load", "a", "particular", "DataFrame", "." ]
train
https://github.com/hammerlab/cohorts/blob/278b05e609e6c4d4a77c57d49446460be53ea33e/cohorts/cohort.py#L402-L416
hammerlab/cohorts
cohorts/cohort.py
Cohort._get_function_name
def _get_function_name(self, fn, default="None"): """ Return name of function, using default value if function not defined """ if fn is None: fn_name = default else: fn_name = fn.__name__ return fn_name
python
def _get_function_name(self, fn, default="None"): """ Return name of function, using default value if function not defined """ if fn is None: fn_name = default else: fn_name = fn.__name__ return fn_name
[ "def", "_get_function_name", "(", "self", ",", "fn", ",", "default", "=", "\"None\"", ")", ":", "if", "fn", "is", "None", ":", "fn_name", "=", "default", "else", ":", "fn_name", "=", "fn", ".", "__name__", "return", "fn_name" ]
Return name of function, using default value if function not defined
[ "Return", "name", "of", "function", "using", "default", "value", "if", "function", "not", "defined" ]
train
https://github.com/hammerlab/cohorts/blob/278b05e609e6c4d4a77c57d49446460be53ea33e/cohorts/cohort.py#L502-L509
hammerlab/cohorts
cohorts/cohort.py
Cohort.load_variants
def load_variants(self, patients=None, filter_fn=None, **kwargs): """Load a dictionary of patient_id to varcode.VariantCollection Parameters ---------- patients : str, optional Filter to a subset of patients filter_fn : function Takes a FilterableVariant ...
python
def load_variants(self, patients=None, filter_fn=None, **kwargs): """Load a dictionary of patient_id to varcode.VariantCollection Parameters ---------- patients : str, optional Filter to a subset of patients filter_fn : function Takes a FilterableVariant ...
[ "def", "load_variants", "(", "self", ",", "patients", "=", "None", ",", "filter_fn", "=", "None", ",", "*", "*", "kwargs", ")", ":", "filter_fn", "=", "first_not_none_param", "(", "[", "filter_fn", ",", "self", ".", "filter_fn", "]", ",", "no_filter", ")...
Load a dictionary of patient_id to varcode.VariantCollection Parameters ---------- patients : str, optional Filter to a subset of patients filter_fn : function Takes a FilterableVariant and returns a boolean. Only variants returning True are preserved. ...
[ "Load", "a", "dictionary", "of", "patient_id", "to", "varcode", ".", "VariantCollection" ]
train
https://github.com/hammerlab/cohorts/blob/278b05e609e6c4d4a77c57d49446460be53ea33e/cohorts/cohort.py#L511-L536
hammerlab/cohorts
cohorts/cohort.py
Cohort._hash_filter_fn
def _hash_filter_fn(self, filter_fn, **kwargs): """ Construct string representing state of filter_fn Used to cache filtered variants or effects uniquely depending on filter fn values """ filter_fn_name = self._get_function_name(filter_fn, default="filter-none") logger.debug("...
python
def _hash_filter_fn(self, filter_fn, **kwargs): """ Construct string representing state of filter_fn Used to cache filtered variants or effects uniquely depending on filter fn values """ filter_fn_name = self._get_function_name(filter_fn, default="filter-none") logger.debug("...
[ "def", "_hash_filter_fn", "(", "self", ",", "filter_fn", ",", "*", "*", "kwargs", ")", ":", "filter_fn_name", "=", "self", ".", "_get_function_name", "(", "filter_fn", ",", "default", "=", "\"filter-none\"", ")", "logger", ".", "debug", "(", "\"Computing hash ...
Construct string representing state of filter_fn Used to cache filtered variants or effects uniquely depending on filter fn values
[ "Construct", "string", "representing", "state", "of", "filter_fn", "Used", "to", "cache", "filtered", "variants", "or", "effects", "uniquely", "depending", "on", "filter", "fn", "values" ]
train
https://github.com/hammerlab/cohorts/blob/278b05e609e6c4d4a77c57d49446460be53ea33e/cohorts/cohort.py#L538-L570
hammerlab/cohorts
cohorts/cohort.py
Cohort._load_single_patient_variants
def _load_single_patient_variants(self, patient, filter_fn, use_cache=True, **kwargs): """ Load filtered, merged variants for a single patient, optionally using cache Note that filtered variants are first merged before filtering, and each step is cached independently. Turn on debug ...
python
def _load_single_patient_variants(self, patient, filter_fn, use_cache=True, **kwargs): """ Load filtered, merged variants for a single patient, optionally using cache Note that filtered variants are first merged before filtering, and each step is cached independently. Turn on debug ...
[ "def", "_load_single_patient_variants", "(", "self", ",", "patient", ",", "filter_fn", ",", "use_cache", "=", "True", ",", "*", "*", "kwargs", ")", ":", "if", "filter_fn", "is", "None", ":", "use_filtered_cache", "=", "False", "else", ":", "filter_fn_name", ...
Load filtered, merged variants for a single patient, optionally using cache Note that filtered variants are first merged before filtering, and each step is cached independently. Turn on debug statements for more details about cached files. Use `_load_single_pati...
[ "Load", "filtered", "merged", "variants", "for", "a", "single", "patient", "optionally", "using", "cache" ]
train
https://github.com/hammerlab/cohorts/blob/278b05e609e6c4d4a77c57d49446460be53ea33e/cohorts/cohort.py#L572-L626
hammerlab/cohorts
cohorts/cohort.py
Cohort._load_single_patient_merged_variants
def _load_single_patient_merged_variants(self, patient, use_cache=True): """ Load merged variants for a single patient, optionally using cache Note that merged variants are not filtered. Use `_load_single_patient_variants` to get filtered variants """ logger.debug("loadi...
python
def _load_single_patient_merged_variants(self, patient, use_cache=True): """ Load merged variants for a single patient, optionally using cache Note that merged variants are not filtered. Use `_load_single_patient_variants` to get filtered variants """ logger.debug("loadi...
[ "def", "_load_single_patient_merged_variants", "(", "self", ",", "patient", ",", "use_cache", "=", "True", ")", ":", "logger", ".", "debug", "(", "\"loading merged variants for patient {}\"", ".", "format", "(", "patient", ".", "id", ")", ")", "no_variants", "=", ...
Load merged variants for a single patient, optionally using cache Note that merged variants are not filtered. Use `_load_single_patient_variants` to get filtered variants
[ "Load", "merged", "variants", "for", "a", "single", "patient", "optionally", "using", "cache" ]
train
https://github.com/hammerlab/cohorts/blob/278b05e609e6c4d4a77c57d49446460be53ea33e/cohorts/cohort.py#L628-L695
hammerlab/cohorts
cohorts/cohort.py
Cohort.load_polyphen_annotations
def load_polyphen_annotations(self, as_dataframe=False, filter_fn=None): """Load a dataframe containing polyphen2 annotations for all variants Parameters ---------- database_file : string, sqlite Path to the WHESS/Polyphen2 SQLite database. ...
python
def load_polyphen_annotations(self, as_dataframe=False, filter_fn=None): """Load a dataframe containing polyphen2 annotations for all variants Parameters ---------- database_file : string, sqlite Path to the WHESS/Polyphen2 SQLite database. ...
[ "def", "load_polyphen_annotations", "(", "self", ",", "as_dataframe", "=", "False", ",", "filter_fn", "=", "None", ")", ":", "filter_fn", "=", "first_not_none_param", "(", "[", "filter_fn", ",", "self", ".", "filter_fn", "]", ",", "no_filter", ")", "patient_an...
Load a dataframe containing polyphen2 annotations for all variants Parameters ---------- database_file : string, sqlite Path to the WHESS/Polyphen2 SQLite database. Can be downloaded and bunzip2"ed from http://bit.ly/208mlIU filter_fn : function Takes...
[ "Load", "a", "dataframe", "containing", "polyphen2", "annotations", "for", "all", "variants" ]
train
https://github.com/hammerlab/cohorts/blob/278b05e609e6c4d4a77c57d49446460be53ea33e/cohorts/cohort.py#L708-L738
hammerlab/cohorts
cohorts/cohort.py
Cohort.load_effects
def load_effects(self, patients=None, only_nonsynonymous=False, all_effects=False, filter_fn=None, **kwargs): """Load a dictionary of patient_id to varcode.EffectCollection Note that this only loads one effect per variant. Parameters ---------- patients : s...
python
def load_effects(self, patients=None, only_nonsynonymous=False, all_effects=False, filter_fn=None, **kwargs): """Load a dictionary of patient_id to varcode.EffectCollection Note that this only loads one effect per variant. Parameters ---------- patients : s...
[ "def", "load_effects", "(", "self", ",", "patients", "=", "None", ",", "only_nonsynonymous", "=", "False", ",", "all_effects", "=", "False", ",", "filter_fn", "=", "None", ",", "*", "*", "kwargs", ")", ":", "filter_fn", "=", "first_not_none_param", "(", "[...
Load a dictionary of patient_id to varcode.EffectCollection Note that this only loads one effect per variant. Parameters ---------- patients : str, optional Filter to a subset of patients only_nonsynonymous : bool, optional If true, load only nonsynonymo...
[ "Load", "a", "dictionary", "of", "patient_id", "to", "varcode", ".", "EffectCollection" ]
train
https://github.com/hammerlab/cohorts/blob/278b05e609e6c4d4a77c57d49446460be53ea33e/cohorts/cohort.py#L790-L822
hammerlab/cohorts
cohorts/cohort.py
Cohort.load_kallisto
def load_kallisto(self): """ Load Kallisto transcript quantification data for a cohort Parameters ---------- Returns ------- kallisto_data : Pandas dataframe Pandas dataframe with Kallisto data for all patients columns include patient_id,...
python
def load_kallisto(self): """ Load Kallisto transcript quantification data for a cohort Parameters ---------- Returns ------- kallisto_data : Pandas dataframe Pandas dataframe with Kallisto data for all patients columns include patient_id,...
[ "def", "load_kallisto", "(", "self", ")", ":", "kallisto_data", "=", "pd", ".", "concat", "(", "[", "self", ".", "_load_single_patient_kallisto", "(", "patient", ")", "for", "patient", "in", "self", "]", ",", "copy", "=", "False", ")", "if", "self", ".",...
Load Kallisto transcript quantification data for a cohort Parameters ---------- Returns ------- kallisto_data : Pandas dataframe Pandas dataframe with Kallisto data for all patients columns include patient_id, gene_name, est_counts
[ "Load", "Kallisto", "transcript", "quantification", "data", "for", "a", "cohort" ]
train
https://github.com/hammerlab/cohorts/blob/278b05e609e6c4d4a77c57d49446460be53ea33e/cohorts/cohort.py#L865-L895
hammerlab/cohorts
cohorts/cohort.py
Cohort._load_single_patient_kallisto
def _load_single_patient_kallisto(self, patient): """ Load Kallisto gene quantification given a patient Parameters ---------- patient : Patient Returns ------- data: Pandas dataframe Pandas dataframe of sample's Kallisto data colu...
python
def _load_single_patient_kallisto(self, patient): """ Load Kallisto gene quantification given a patient Parameters ---------- patient : Patient Returns ------- data: Pandas dataframe Pandas dataframe of sample's Kallisto data colu...
[ "def", "_load_single_patient_kallisto", "(", "self", ",", "patient", ")", ":", "data", "=", "pd", ".", "read_csv", "(", "patient", ".", "tumor_sample", ".", "kallisto_path", ",", "sep", "=", "\"\\t\"", ")", "data", "[", "\"patient_id\"", "]", "=", "patient",...
Load Kallisto gene quantification given a patient Parameters ---------- patient : Patient Returns ------- data: Pandas dataframe Pandas dataframe of sample's Kallisto data columns include patient_id, target_id, length, eff_length, est_counts, tpm
[ "Load", "Kallisto", "gene", "quantification", "given", "a", "patient" ]
train
https://github.com/hammerlab/cohorts/blob/278b05e609e6c4d4a77c57d49446460be53ea33e/cohorts/cohort.py#L897-L913
hammerlab/cohorts
cohorts/cohort.py
Cohort.load_cufflinks
def load_cufflinks(self, filter_ok=True): """ Load a Cufflinks gene expression data for a cohort Parameters ---------- filter_ok : bool, optional If true, filter Cufflinks data to row with FPKM_status == "OK" Returns ------- cufflinks_data : ...
python
def load_cufflinks(self, filter_ok=True): """ Load a Cufflinks gene expression data for a cohort Parameters ---------- filter_ok : bool, optional If true, filter Cufflinks data to row with FPKM_status == "OK" Returns ------- cufflinks_data : ...
[ "def", "load_cufflinks", "(", "self", ",", "filter_ok", "=", "True", ")", ":", "return", "pd", ".", "concat", "(", "[", "self", ".", "_load_single_patient_cufflinks", "(", "patient", ",", "filter_ok", ")", "for", "patient", "in", "self", "]", ",", "copy", ...
Load a Cufflinks gene expression data for a cohort Parameters ---------- filter_ok : bool, optional If true, filter Cufflinks data to row with FPKM_status == "OK" Returns ------- cufflinks_data : Pandas dataframe Pandas dataframe with Cufflinks d...
[ "Load", "a", "Cufflinks", "gene", "expression", "data", "for", "a", "cohort" ]
train
https://github.com/hammerlab/cohorts/blob/278b05e609e6c4d4a77c57d49446460be53ea33e/cohorts/cohort.py#L915-L934
hammerlab/cohorts
cohorts/cohort.py
Cohort._load_single_patient_cufflinks
def _load_single_patient_cufflinks(self, patient, filter_ok): """ Load Cufflinks gene quantification given a patient Parameters ---------- patient : Patient filter_ok : bool, optional If true, filter Cufflinks data to row with FPKM_status == "OK" Ret...
python
def _load_single_patient_cufflinks(self, patient, filter_ok): """ Load Cufflinks gene quantification given a patient Parameters ---------- patient : Patient filter_ok : bool, optional If true, filter Cufflinks data to row with FPKM_status == "OK" Ret...
[ "def", "_load_single_patient_cufflinks", "(", "self", ",", "patient", ",", "filter_ok", ")", ":", "data", "=", "pd", ".", "read_csv", "(", "patient", ".", "tumor_sample", ".", "cufflinks_path", ",", "sep", "=", "\"\\t\"", ")", "data", "[", "\"patient_id\"", ...
Load Cufflinks gene quantification given a patient Parameters ---------- patient : Patient filter_ok : bool, optional If true, filter Cufflinks data to row with FPKM_status == "OK" Returns ------- data: Pandas dataframe Pandas dataframe o...
[ "Load", "Cufflinks", "gene", "quantification", "given", "a", "patient" ]
train
https://github.com/hammerlab/cohorts/blob/278b05e609e6c4d4a77c57d49446460be53ea33e/cohorts/cohort.py#L936-L958
hammerlab/cohorts
cohorts/cohort.py
Cohort.get_filtered_isovar_epitopes
def get_filtered_isovar_epitopes(self, epitopes, ic50_cutoff): """ Mostly replicates topiary.build_epitope_collection_from_binding_predictions Note: topiary needs to do fancy stuff like subsequence_protein_offset + binding_prediction.offset in order to figure out whether a variant is in...
python
def get_filtered_isovar_epitopes(self, epitopes, ic50_cutoff): """ Mostly replicates topiary.build_epitope_collection_from_binding_predictions Note: topiary needs to do fancy stuff like subsequence_protein_offset + binding_prediction.offset in order to figure out whether a variant is in...
[ "def", "get_filtered_isovar_epitopes", "(", "self", ",", "epitopes", ",", "ic50_cutoff", ")", ":", "mutant_binding_predictions", "=", "[", "]", "for", "binding_prediction", "in", "epitopes", ":", "peptide", "=", "binding_prediction", ".", "peptide", "peptide_offset", ...
Mostly replicates topiary.build_epitope_collection_from_binding_predictions Note: topiary needs to do fancy stuff like subsequence_protein_offset + binding_prediction.offset in order to figure out whether a variant is in the peptide because it only has the variant's offset into the full protein...
[ "Mostly", "replicates", "topiary", ".", "build_epitope_collection_from_binding_predictions" ]
train
https://github.com/hammerlab/cohorts/blob/278b05e609e6c4d4a77c57d49446460be53ea33e/cohorts/cohort.py#L1064-L1086
hammerlab/cohorts
cohorts/cohort.py
Cohort.plot_roc_curve
def plot_roc_curve(self, on, bootstrap_samples=100, ax=None, **kwargs): """Plot an ROC curve for benefit and a given variable Parameters ---------- on : str or function or list or dict See `cohort.load.as_dataframe` bootstrap_samples : int, optional Numbe...
python
def plot_roc_curve(self, on, bootstrap_samples=100, ax=None, **kwargs): """Plot an ROC curve for benefit and a given variable Parameters ---------- on : str or function or list or dict See `cohort.load.as_dataframe` bootstrap_samples : int, optional Numbe...
[ "def", "plot_roc_curve", "(", "self", ",", "on", ",", "bootstrap_samples", "=", "100", ",", "ax", "=", "None", ",", "*", "*", "kwargs", ")", ":", "plot_col", ",", "df", "=", "self", ".", "as_dataframe", "(", "on", ",", "return_cols", "=", "True", ","...
Plot an ROC curve for benefit and a given variable Parameters ---------- on : str or function or list or dict See `cohort.load.as_dataframe` bootstrap_samples : int, optional Number of boostrap samples to use to compute the AUC ax : Axes, default None ...
[ "Plot", "an", "ROC", "curve", "for", "benefit", "and", "a", "given", "variable" ]
train
https://github.com/hammerlab/cohorts/blob/278b05e609e6c4d4a77c57d49446460be53ea33e/cohorts/cohort.py#L1171-L1193
hammerlab/cohorts
cohorts/cohort.py
Cohort.plot_benefit
def plot_benefit(self, on, benefit_col="benefit", label="Response", ax=None, alternative="two-sided", boolean_value_map={}, order=None, **kwargs): """Plot a comparison of benefit/response in the cohort on a given variable """ no_benefit_plot_name = "No %...
python
def plot_benefit(self, on, benefit_col="benefit", label="Response", ax=None, alternative="two-sided", boolean_value_map={}, order=None, **kwargs): """Plot a comparison of benefit/response in the cohort on a given variable """ no_benefit_plot_name = "No %...
[ "def", "plot_benefit", "(", "self", ",", "on", ",", "benefit_col", "=", "\"benefit\"", ",", "label", "=", "\"Response\"", ",", "ax", "=", "None", ",", "alternative", "=", "\"two-sided\"", ",", "boolean_value_map", "=", "{", "}", ",", "order", "=", "None", ...
Plot a comparison of benefit/response in the cohort on a given variable
[ "Plot", "a", "comparison", "of", "benefit", "/", "response", "in", "the", "cohort", "on", "a", "given", "variable" ]
train
https://github.com/hammerlab/cohorts/blob/278b05e609e6c4d4a77c57d49446460be53ea33e/cohorts/cohort.py#L1195-L1211
hammerlab/cohorts
cohorts/cohort.py
Cohort.plot_boolean
def plot_boolean(self, on, boolean_col, plot_col=None, boolean_label=None, boolean_value_map={}, order=None, ax=None, alternative="two-sided", ...
python
def plot_boolean(self, on, boolean_col, plot_col=None, boolean_label=None, boolean_value_map={}, order=None, ax=None, alternative="two-sided", ...
[ "def", "plot_boolean", "(", "self", ",", "on", ",", "boolean_col", ",", "plot_col", "=", "None", ",", "boolean_label", "=", "None", ",", "boolean_value_map", "=", "{", "}", ",", "order", "=", "None", ",", "ax", "=", "None", ",", "alternative", "=", "\"...
Plot a comparison of `boolean_col` in the cohort on a given variable via `on` or `col`. If the variable (through `on` or `col`) is binary this will compare odds-ratios and perform a Fisher's exact test. If the variable is numeric, this will compare the distributions through a M...
[ "Plot", "a", "comparison", "of", "boolean_col", "in", "the", "cohort", "on", "a", "given", "variable", "via", "on", "or", "col", "." ]
train
https://github.com/hammerlab/cohorts/blob/278b05e609e6c4d4a77c57d49446460be53ea33e/cohorts/cohort.py#L1213-L1293
hammerlab/cohorts
cohorts/cohort.py
Cohort.plot_survival
def plot_survival(self, on, how="os", survival_units="Days", strata=None, ax=None, ci_show=False, with_condition_color="#B38600", no_condition_c...
python
def plot_survival(self, on, how="os", survival_units="Days", strata=None, ax=None, ci_show=False, with_condition_color="#B38600", no_condition_c...
[ "def", "plot_survival", "(", "self", ",", "on", ",", "how", "=", "\"os\"", ",", "survival_units", "=", "\"Days\"", ",", "strata", "=", "None", ",", "ax", "=", "None", ",", "ci_show", "=", "False", ",", "with_condition_color", "=", "\"#B38600\"", ",", "no...
Plot a Kaplan Meier survival curve by splitting the cohort into two groups Parameters ---------- on : str or function or list or dict See `cohort.load.as_dataframe` how : {"os", "pfs"}, optional Whether to plot OS (overall survival) or PFS (progression free surviv...
[ "Plot", "a", "Kaplan", "Meier", "survival", "curve", "by", "splitting", "the", "cohort", "into", "two", "groups", "Parameters", "----------", "on", ":", "str", "or", "function", "or", "list", "or", "dict", "See", "cohort", ".", "load", ".", "as_dataframe", ...
train
https://github.com/hammerlab/cohorts/blob/278b05e609e6c4d4a77c57d49446460be53ea33e/cohorts/cohort.py#L1295-L1349
hammerlab/cohorts
cohorts/cohort.py
Cohort.plot_correlation
def plot_correlation(self, on, x_col=None, plot_type="jointplot", stat_func=pearsonr, show_stat_func=True, plot_kwargs={}, **kwargs): """Plot the correlation between two variables. Parameters ---------- on : list or dict of functions or strings See `cohort.load.as_dataframe`...
python
def plot_correlation(self, on, x_col=None, plot_type="jointplot", stat_func=pearsonr, show_stat_func=True, plot_kwargs={}, **kwargs): """Plot the correlation between two variables. Parameters ---------- on : list or dict of functions or strings See `cohort.load.as_dataframe`...
[ "def", "plot_correlation", "(", "self", ",", "on", ",", "x_col", "=", "None", ",", "plot_type", "=", "\"jointplot\"", ",", "stat_func", "=", "pearsonr", ",", "show_stat_func", "=", "True", ",", "plot_kwargs", "=", "{", "}", ",", "*", "*", "kwargs", ")", ...
Plot the correlation between two variables. Parameters ---------- on : list or dict of functions or strings See `cohort.load.as_dataframe` x_col : str, optional If `on` is a dict, this guarantees we have the expected ordering. plot_type : str, optional ...
[ "Plot", "the", "correlation", "between", "two", "variables", "." ]
train
https://github.com/hammerlab/cohorts/blob/278b05e609e6c4d4a77c57d49446460be53ea33e/cohorts/cohort.py#L1351-L1399
hammerlab/cohorts
cohorts/cohort.py
Cohort._list_patient_ids
def _list_patient_ids(self): """ Utility function to return a list of patient ids in the Cohort """ results = [] for patient in self: results.append(patient.id) return(results)
python
def _list_patient_ids(self): """ Utility function to return a list of patient ids in the Cohort """ results = [] for patient in self: results.append(patient.id) return(results)
[ "def", "_list_patient_ids", "(", "self", ")", ":", "results", "=", "[", "]", "for", "patient", "in", "self", ":", "results", ".", "append", "(", "patient", ".", "id", ")", "return", "(", "results", ")" ]
Utility function to return a list of patient ids in the Cohort
[ "Utility", "function", "to", "return", "a", "list", "of", "patient", "ids", "in", "the", "Cohort" ]
train
https://github.com/hammerlab/cohorts/blob/278b05e609e6c4d4a77c57d49446460be53ea33e/cohorts/cohort.py#L1410-L1416
hammerlab/cohorts
cohorts/cohort.py
Cohort.summarize_provenance_per_cache
def summarize_provenance_per_cache(self): """Utility function to summarize provenance files for cached items used by a Cohort, for each cache_dir that exists. Only existing cache_dirs are summarized. This is a summary of provenance files because the function checks to see whether all pa...
python
def summarize_provenance_per_cache(self): """Utility function to summarize provenance files for cached items used by a Cohort, for each cache_dir that exists. Only existing cache_dirs are summarized. This is a summary of provenance files because the function checks to see whether all pa...
[ "def", "summarize_provenance_per_cache", "(", "self", ")", ":", "provenance_summary", "=", "{", "}", "df", "=", "self", ".", "as_dataframe", "(", ")", "for", "cache", "in", "self", ".", "cache_names", ":", "cache_name", "=", "self", ".", "cache_names", "[", ...
Utility function to summarize provenance files for cached items used by a Cohort, for each cache_dir that exists. Only existing cache_dirs are summarized. This is a summary of provenance files because the function checks to see whether all patients data have the same provenance within the cache...
[ "Utility", "function", "to", "summarize", "provenance", "files", "for", "cached", "items", "used", "by", "a", "Cohort", "for", "each", "cache_dir", "that", "exists", ".", "Only", "existing", "cache_dirs", "are", "summarized", "." ]
train
https://github.com/hammerlab/cohorts/blob/278b05e609e6c4d4a77c57d49446460be53ea33e/cohorts/cohort.py#L1418-L1471
hammerlab/cohorts
cohorts/cohort.py
Cohort.summarize_dataframe
def summarize_dataframe(self): """Summarize default dataframe for this cohort using a hash function. Useful for confirming the version of data used in various reports, e.g. ipynbs """ if self.dataframe_hash: return(self.dataframe_hash) else: df = self._as_...
python
def summarize_dataframe(self): """Summarize default dataframe for this cohort using a hash function. Useful for confirming the version of data used in various reports, e.g. ipynbs """ if self.dataframe_hash: return(self.dataframe_hash) else: df = self._as_...
[ "def", "summarize_dataframe", "(", "self", ")", ":", "if", "self", ".", "dataframe_hash", ":", "return", "(", "self", ".", "dataframe_hash", ")", "else", ":", "df", "=", "self", ".", "_as_dataframe_unmodified", "(", ")", "return", "(", "self", ".", "datafr...
Summarize default dataframe for this cohort using a hash function. Useful for confirming the version of data used in various reports, e.g. ipynbs
[ "Summarize", "default", "dataframe", "for", "this", "cohort", "using", "a", "hash", "function", ".", "Useful", "for", "confirming", "the", "version", "of", "data", "used", "in", "various", "reports", "e", ".", "g", ".", "ipynbs" ]
train
https://github.com/hammerlab/cohorts/blob/278b05e609e6c4d4a77c57d49446460be53ea33e/cohorts/cohort.py#L1473-L1481
hammerlab/cohorts
cohorts/cohort.py
Cohort.summarize_provenance
def summarize_provenance(self): """Utility function to summarize provenance files for cached items used by a Cohort. At the moment, most PROVENANCE files contain details about packages used to generate files. However, this function is generic & so it summarizes the contents of those fil...
python
def summarize_provenance(self): """Utility function to summarize provenance files for cached items used by a Cohort. At the moment, most PROVENANCE files contain details about packages used to generate files. However, this function is generic & so it summarizes the contents of those fil...
[ "def", "summarize_provenance", "(", "self", ")", ":", "provenance_per_cache", "=", "self", ".", "summarize_provenance_per_cache", "(", ")", "summary_provenance", "=", "None", "num_discrepant", "=", "0", "for", "cache", "in", "provenance_per_cache", ":", "if", "not",...
Utility function to summarize provenance files for cached items used by a Cohort. At the moment, most PROVENANCE files contain details about packages used to generate files. However, this function is generic & so it summarizes the contents of those files irrespective of their contents. ...
[ "Utility", "function", "to", "summarize", "provenance", "files", "for", "cached", "items", "used", "by", "a", "Cohort", "." ]
train
https://github.com/hammerlab/cohorts/blob/278b05e609e6c4d4a77c57d49446460be53ea33e/cohorts/cohort.py#L1483-L1523
hammerlab/cohorts
cohorts/cohort.py
Cohort.summarize_data_sources
def summarize_data_sources(self): """Utility function to summarize data source status for this Cohort, useful for confirming the state of data used for an analysis Returns ---------- Dictionary with summary of data sources Currently contains - dataframe_hash: ha...
python
def summarize_data_sources(self): """Utility function to summarize data source status for this Cohort, useful for confirming the state of data used for an analysis Returns ---------- Dictionary with summary of data sources Currently contains - dataframe_hash: ha...
[ "def", "summarize_data_sources", "(", "self", ")", ":", "provenance_file_summary", "=", "self", ".", "summarize_provenance", "(", ")", "dataframe_hash", "=", "self", ".", "summarize_dataframe", "(", ")", "results", "=", "{", "\"provenance_file_summary\"", ":", "prov...
Utility function to summarize data source status for this Cohort, useful for confirming the state of data used for an analysis Returns ---------- Dictionary with summary of data sources Currently contains - dataframe_hash: hash of the dataframe (see `?cohorts.Cohort.sum...
[ "Utility", "function", "to", "summarize", "data", "source", "status", "for", "this", "Cohort", "useful", "for", "confirming", "the", "state", "of", "data", "used", "for", "an", "analysis" ]
train
https://github.com/hammerlab/cohorts/blob/278b05e609e6c4d4a77c57d49446460be53ea33e/cohorts/cohort.py#L1525-L1543
hammerlab/cohorts
cohorts/variant_stats.py
strelka_somatic_variant_stats
def strelka_somatic_variant_stats(variant, variant_metadata): """Parse out the variant calling statistics for a given variant from a Strelka VCF Parameters ---------- variant : varcode.Variant sample_info : dict Dictionary of sample to variant calling statistics, corresponds to the sample c...
python
def strelka_somatic_variant_stats(variant, variant_metadata): """Parse out the variant calling statistics for a given variant from a Strelka VCF Parameters ---------- variant : varcode.Variant sample_info : dict Dictionary of sample to variant calling statistics, corresponds to the sample c...
[ "def", "strelka_somatic_variant_stats", "(", "variant", ",", "variant_metadata", ")", ":", "sample_info", "=", "variant_metadata", "[", "\"sample_info\"", "]", "# Ensure there are exactly two samples in the VCF, a tumor and normal", "assert", "len", "(", "sample_info", ")", "...
Parse out the variant calling statistics for a given variant from a Strelka VCF Parameters ---------- variant : varcode.Variant sample_info : dict Dictionary of sample to variant calling statistics, corresponds to the sample columns in a Strelka VCF Returns ------- SomaticV...
[ "Parse", "out", "the", "variant", "calling", "statistics", "for", "a", "given", "variant", "from", "a", "Strelka", "VCF" ]
train
https://github.com/hammerlab/cohorts/blob/278b05e609e6c4d4a77c57d49446460be53ea33e/cohorts/variant_stats.py#L24-L44
hammerlab/cohorts
cohorts/variant_stats.py
_strelka_variant_stats
def _strelka_variant_stats(variant, sample_info): """Parse a single sample"s variant calling statistics based on Strelka VCF output Parameters ---------- variant : varcode.Variant sample_info : dict Dictionary of Strelka-specific variant calling fields Returns ------- VariantSt...
python
def _strelka_variant_stats(variant, sample_info): """Parse a single sample"s variant calling statistics based on Strelka VCF output Parameters ---------- variant : varcode.Variant sample_info : dict Dictionary of Strelka-specific variant calling fields Returns ------- VariantSt...
[ "def", "_strelka_variant_stats", "(", "variant", ",", "sample_info", ")", ":", "if", "variant", ".", "is_deletion", "or", "variant", ".", "is_insertion", ":", "# ref: https://sites.google.com/site/strelkasomaticvariantcaller/home/somatic-variant-output", "ref_depth", "=", "in...
Parse a single sample"s variant calling statistics based on Strelka VCF output Parameters ---------- variant : varcode.Variant sample_info : dict Dictionary of Strelka-specific variant calling fields Returns ------- VariantStats
[ "Parse", "a", "single", "sample", "s", "variant", "calling", "statistics", "based", "on", "Strelka", "VCF", "output" ]
train
https://github.com/hammerlab/cohorts/blob/278b05e609e6c4d4a77c57d49446460be53ea33e/cohorts/variant_stats.py#L46-L77
hammerlab/cohorts
cohorts/variant_stats.py
mutect_somatic_variant_stats
def mutect_somatic_variant_stats(variant, variant_metadata): """Parse out the variant calling statistics for a given variant from a Mutect VCF Parameters ---------- variant : varcode.Variant sample_info : dict Dictionary of sample to variant calling statistics, corresponds to the sample col...
python
def mutect_somatic_variant_stats(variant, variant_metadata): """Parse out the variant calling statistics for a given variant from a Mutect VCF Parameters ---------- variant : varcode.Variant sample_info : dict Dictionary of sample to variant calling statistics, corresponds to the sample col...
[ "def", "mutect_somatic_variant_stats", "(", "variant", ",", "variant_metadata", ")", ":", "sample_info", "=", "variant_metadata", "[", "\"sample_info\"", "]", "# Ensure there are exactly two samples in the VCF, a tumor and normal", "assert", "len", "(", "sample_info", ")", "=...
Parse out the variant calling statistics for a given variant from a Mutect VCF Parameters ---------- variant : varcode.Variant sample_info : dict Dictionary of sample to variant calling statistics, corresponds to the sample columns in a Mutect VCF Returns ------- SomaticVar...
[ "Parse", "out", "the", "variant", "calling", "statistics", "for", "a", "given", "variant", "from", "a", "Mutect", "VCF" ]
train
https://github.com/hammerlab/cohorts/blob/278b05e609e6c4d4a77c57d49446460be53ea33e/cohorts/variant_stats.py#L79-L109
hammerlab/cohorts
cohorts/variant_stats.py
_mutect_variant_stats
def _mutect_variant_stats(variant, sample_info): """Parse a single sample"s variant calling statistics based on Mutect"s (v1) VCF output Parameters ---------- variant : varcode.Variant sample_info : dict Dictionary of Mutect-specific variant calling fields Returns ------- Varia...
python
def _mutect_variant_stats(variant, sample_info): """Parse a single sample"s variant calling statistics based on Mutect"s (v1) VCF output Parameters ---------- variant : varcode.Variant sample_info : dict Dictionary of Mutect-specific variant calling fields Returns ------- Varia...
[ "def", "_mutect_variant_stats", "(", "variant", ",", "sample_info", ")", ":", "# Parse out the AD (or allele depth field), which is an array of [REF_DEPTH, ALT_DEPTH]", "ref_depth", ",", "alt_depth", "=", "sample_info", "[", "\"AD\"", "]", "depth", "=", "int", "(", "ref_dep...
Parse a single sample"s variant calling statistics based on Mutect"s (v1) VCF output Parameters ---------- variant : varcode.Variant sample_info : dict Dictionary of Mutect-specific variant calling fields Returns ------- VariantStats
[ "Parse", "a", "single", "sample", "s", "variant", "calling", "statistics", "based", "on", "Mutect", "s", "(", "v1", ")", "VCF", "output" ]
train
https://github.com/hammerlab/cohorts/blob/278b05e609e6c4d4a77c57d49446460be53ea33e/cohorts/variant_stats.py#L111-L130
hammerlab/cohorts
cohorts/variant_stats.py
maf_somatic_variant_stats
def maf_somatic_variant_stats(variant, variant_metadata): """ Parse out the variant calling statistics for a given variant from a MAF file Assumes the MAF format described here: https://www.biostars.org/p/161298/#161777 Parameters ---------- variant : varcode.Variant variant_metadata : dic...
python
def maf_somatic_variant_stats(variant, variant_metadata): """ Parse out the variant calling statistics for a given variant from a MAF file Assumes the MAF format described here: https://www.biostars.org/p/161298/#161777 Parameters ---------- variant : varcode.Variant variant_metadata : dic...
[ "def", "maf_somatic_variant_stats", "(", "variant", ",", "variant_metadata", ")", ":", "tumor_stats", "=", "None", "normal_stats", "=", "None", "if", "\"t_ref_count\"", "in", "variant_metadata", ":", "tumor_stats", "=", "_maf_variant_stats", "(", "variant", ",", "va...
Parse out the variant calling statistics for a given variant from a MAF file Assumes the MAF format described here: https://www.biostars.org/p/161298/#161777 Parameters ---------- variant : varcode.Variant variant_metadata : dict Dictionary of metadata for this variant Returns ---...
[ "Parse", "out", "the", "variant", "calling", "statistics", "for", "a", "given", "variant", "from", "a", "MAF", "file" ]
train
https://github.com/hammerlab/cohorts/blob/278b05e609e6c4d4a77c57d49446460be53ea33e/cohorts/variant_stats.py#L139-L161
hammerlab/cohorts
cohorts/variant_stats.py
_vcf_is_strelka
def _vcf_is_strelka(variant_file, variant_metadata): """Return True if variant_file given is in strelka format """ if "strelka" in variant_file.lower(): return True elif "NORMAL" in variant_metadata["sample_info"].keys(): return True else: vcf_reader = vcf.Reader(open(variant...
python
def _vcf_is_strelka(variant_file, variant_metadata): """Return True if variant_file given is in strelka format """ if "strelka" in variant_file.lower(): return True elif "NORMAL" in variant_metadata["sample_info"].keys(): return True else: vcf_reader = vcf.Reader(open(variant...
[ "def", "_vcf_is_strelka", "(", "variant_file", ",", "variant_metadata", ")", ":", "if", "\"strelka\"", "in", "variant_file", ".", "lower", "(", ")", ":", "return", "True", "elif", "\"NORMAL\"", "in", "variant_metadata", "[", "\"sample_info\"", "]", ".", "keys", ...
Return True if variant_file given is in strelka format
[ "Return", "True", "if", "variant_file", "given", "is", "in", "strelka", "format" ]
train
https://github.com/hammerlab/cohorts/blob/278b05e609e6c4d4a77c57d49446460be53ea33e/cohorts/variant_stats.py#L163-L178
hammerlab/cohorts
cohorts/variant_stats.py
variant_stats_from_variant
def variant_stats_from_variant(variant, metadata, merge_fn=(lambda all_stats: \ max(all_stats, key=(lambda stats: stats.tumor_stats.depth)))): """Parse the variant calling stats from a variant called from multiple variant ...
python
def variant_stats_from_variant(variant, metadata, merge_fn=(lambda all_stats: \ max(all_stats, key=(lambda stats: stats.tumor_stats.depth)))): """Parse the variant calling stats from a variant called from multiple variant ...
[ "def", "variant_stats_from_variant", "(", "variant", ",", "metadata", ",", "merge_fn", "=", "(", "lambda", "all_stats", ":", "max", "(", "all_stats", ",", "key", "=", "(", "lambda", "stats", ":", "stats", ".", "tumor_stats", ".", "depth", ")", ")", ")", ...
Parse the variant calling stats from a variant called from multiple variant files. The stats are merged based on `merge_fn` Parameters ---------- variant : varcode.Variant metadata : dict Dictionary of variant file to variant calling metadata from that file merge_fn : function F...
[ "Parse", "the", "variant", "calling", "stats", "from", "a", "variant", "called", "from", "multiple", "variant", "files", ".", "The", "stats", "are", "merged", "based", "on", "merge_fn" ]
train
https://github.com/hammerlab/cohorts/blob/278b05e609e6c4d4a77c57d49446460be53ea33e/cohorts/variant_stats.py#L202-L236
alvarogzp/telegram-bot-framework
bot/multithreading/worker/pool/workers/limited_lifespan.py
LimitedLifespanQueueWorker._get_and_execute
def _get_and_execute(self): """ :return: True if it should continue running, False if it should end its execution. """ try: work = self.queue.get(timeout=self.max_seconds_idle) except queue.Empty: # max_seconds_idle has been exhausted, exiting ...
python
def _get_and_execute(self): """ :return: True if it should continue running, False if it should end its execution. """ try: work = self.queue.get(timeout=self.max_seconds_idle) except queue.Empty: # max_seconds_idle has been exhausted, exiting ...
[ "def", "_get_and_execute", "(", "self", ")", ":", "try", ":", "work", "=", "self", ".", "queue", ".", "get", "(", "timeout", "=", "self", ".", "max_seconds_idle", ")", "except", "queue", ".", "Empty", ":", "# max_seconds_idle has been exhausted, exiting", "sel...
:return: True if it should continue running, False if it should end its execution.
[ ":", "return", ":", "True", "if", "it", "should", "continue", "running", "False", "if", "it", "should", "end", "its", "execution", "." ]
train
https://github.com/alvarogzp/telegram-bot-framework/blob/7b597a415c1901901c677976cb13100fc3083107/bot/multithreading/worker/pool/workers/limited_lifespan.py#L21-L34
alvarogzp/telegram-bot-framework
bot/action/standard/info/formatter/chat.py
ChatInfoFormatter.format
def format(self, full_info: bool = False): """ :param full_info: If True, adds more info about the chat. Please, note that this additional info requires to make up to THREE synchronous api calls. """ chat = self.api_object if full_info: self.__format_full(...
python
def format(self, full_info: bool = False): """ :param full_info: If True, adds more info about the chat. Please, note that this additional info requires to make up to THREE synchronous api calls. """ chat = self.api_object if full_info: self.__format_full(...
[ "def", "format", "(", "self", ",", "full_info", ":", "bool", "=", "False", ")", ":", "chat", "=", "self", ".", "api_object", "if", "full_info", ":", "self", ".", "__format_full", "(", "chat", ")", "else", ":", "self", ".", "__format_simple", "(", "chat...
:param full_info: If True, adds more info about the chat. Please, note that this additional info requires to make up to THREE synchronous api calls.
[ ":", "param", "full_info", ":", "If", "True", "adds", "more", "info", "about", "the", "chat", ".", "Please", "note", "that", "this", "additional", "info", "requires", "to", "make", "up", "to", "THREE", "synchronous", "api", "calls", "." ]
train
https://github.com/alvarogzp/telegram-bot-framework/blob/7b597a415c1901901c677976cb13100fc3083107/bot/action/standard/info/formatter/chat.py#L20-L29
alvarogzp/telegram-bot-framework
bot/action/standard/chatsettings/__init__.py
ChatSettings.list
def list(self): """ :rtype: list(setting_name, value, default_value, is_set, is_supported) """ settings = [] for setting in _SETTINGS: value = self.get(setting) is_set = self.is_set(setting) default_value = self.get_default_value(setting) ...
python
def list(self): """ :rtype: list(setting_name, value, default_value, is_set, is_supported) """ settings = [] for setting in _SETTINGS: value = self.get(setting) is_set = self.is_set(setting) default_value = self.get_default_value(setting) ...
[ "def", "list", "(", "self", ")", ":", "settings", "=", "[", "]", "for", "setting", "in", "_SETTINGS", ":", "value", "=", "self", ".", "get", "(", "setting", ")", "is_set", "=", "self", ".", "is_set", "(", "setting", ")", "default_value", "=", "self",...
:rtype: list(setting_name, value, default_value, is_set, is_supported)
[ ":", "rtype", ":", "list", "(", "setting_name", "value", "default_value", "is_set", "is_supported", ")" ]
train
https://github.com/alvarogzp/telegram-bot-framework/blob/7b597a415c1901901c677976cb13100fc3083107/bot/action/standard/chatsettings/__init__.py#L42-L60
hammerlab/cohorts
cohorts/variant_filters.py
load_ensembl_coverage
def load_ensembl_coverage(cohort, coverage_path, min_tumor_depth, min_normal_depth=0, pageant_dir_fn=None): """ Load in Pageant CoverageDepth results with Ensembl loci. coverage_path is a path to Pageant CoverageDepth output directory, with one subdirectory per patient and a `...
python
def load_ensembl_coverage(cohort, coverage_path, min_tumor_depth, min_normal_depth=0, pageant_dir_fn=None): """ Load in Pageant CoverageDepth results with Ensembl loci. coverage_path is a path to Pageant CoverageDepth output directory, with one subdirectory per patient and a `...
[ "def", "load_ensembl_coverage", "(", "cohort", ",", "coverage_path", ",", "min_tumor_depth", ",", "min_normal_depth", "=", "0", ",", "pageant_dir_fn", "=", "None", ")", ":", "# Function to grab the pageant file name using the Patient", "if", "pageant_dir_fn", "is", "None"...
Load in Pageant CoverageDepth results with Ensembl loci. coverage_path is a path to Pageant CoverageDepth output directory, with one subdirectory per patient and a `cdf.csv` file inside each patient subdir. If min_normal_depth is 0, calculate tumor coverage. Otherwise, calculate join tumor/normal cove...
[ "Load", "in", "Pageant", "CoverageDepth", "results", "with", "Ensembl", "loci", "." ]
train
https://github.com/hammerlab/cohorts/blob/278b05e609e6c4d4a77c57d49446460be53ea33e/cohorts/variant_filters.py#L87-L160
hammerlab/cohorts
cohorts/plot.py
vertical_percent
def vertical_percent(plot, percent=0.1): """ Using the size of the y axis, return a fraction of that size. """ plot_bottom, plot_top = plot.get_ylim() return percent * (plot_top - plot_bottom)
python
def vertical_percent(plot, percent=0.1): """ Using the size of the y axis, return a fraction of that size. """ plot_bottom, plot_top = plot.get_ylim() return percent * (plot_top - plot_bottom)
[ "def", "vertical_percent", "(", "plot", ",", "percent", "=", "0.1", ")", ":", "plot_bottom", ",", "plot_top", "=", "plot", ".", "get_ylim", "(", ")", "return", "percent", "*", "(", "plot_top", "-", "plot_bottom", ")" ]
Using the size of the y axis, return a fraction of that size.
[ "Using", "the", "size", "of", "the", "y", "axis", "return", "a", "fraction", "of", "that", "size", "." ]
train
https://github.com/hammerlab/cohorts/blob/278b05e609e6c4d4a77c57d49446460be53ea33e/cohorts/plot.py#L24-L29
hammerlab/cohorts
cohorts/plot.py
hide_ticks
def hide_ticks(plot, min_tick_value=None, max_tick_value=None): """Hide tick values that are outside of [min_tick_value, max_tick_value]""" for tick, tick_value in zip(plot.get_yticklabels(), plot.get_yticks()): tick_label = as_numeric(tick_value) if tick_label: if (min_tick_value is...
python
def hide_ticks(plot, min_tick_value=None, max_tick_value=None): """Hide tick values that are outside of [min_tick_value, max_tick_value]""" for tick, tick_value in zip(plot.get_yticklabels(), plot.get_yticks()): tick_label = as_numeric(tick_value) if tick_label: if (min_tick_value is...
[ "def", "hide_ticks", "(", "plot", ",", "min_tick_value", "=", "None", ",", "max_tick_value", "=", "None", ")", ":", "for", "tick", ",", "tick_value", "in", "zip", "(", "plot", ".", "get_yticklabels", "(", ")", ",", "plot", ".", "get_yticks", "(", ")", ...
Hide tick values that are outside of [min_tick_value, max_tick_value]
[ "Hide", "tick", "values", "that", "are", "outside", "of", "[", "min_tick_value", "max_tick_value", "]" ]
train
https://github.com/hammerlab/cohorts/blob/278b05e609e6c4d4a77c57d49446460be53ea33e/cohorts/plot.py#L37-L44
hammerlab/cohorts
cohorts/plot.py
add_significance_indicator
def add_significance_indicator(plot, col_a=0, col_b=1, significant=False): """ Add a p-value significance indicator. """ plot_bottom, plot_top = plot.get_ylim() # Give the plot a little room for the significance indicator line_height = vertical_percent(plot, 0.1) # Add some extra spacing bel...
python
def add_significance_indicator(plot, col_a=0, col_b=1, significant=False): """ Add a p-value significance indicator. """ plot_bottom, plot_top = plot.get_ylim() # Give the plot a little room for the significance indicator line_height = vertical_percent(plot, 0.1) # Add some extra spacing bel...
[ "def", "add_significance_indicator", "(", "plot", ",", "col_a", "=", "0", ",", "col_b", "=", "1", ",", "significant", "=", "False", ")", ":", "plot_bottom", ",", "plot_top", "=", "plot", ".", "get_ylim", "(", ")", "# Give the plot a little room for the significa...
Add a p-value significance indicator.
[ "Add", "a", "p", "-", "value", "significance", "indicator", "." ]
train
https://github.com/hammerlab/cohorts/blob/278b05e609e6c4d4a77c57d49446460be53ea33e/cohorts/plot.py#L55-L70
hammerlab/cohorts
cohorts/plot.py
stripboxplot
def stripboxplot(x, y, data, ax=None, significant=None, **kwargs): """ Overlay a stripplot on top of a boxplot. """ ax = sb.boxplot( x=x, y=y, data=data, ax=ax, fliersize=0, **kwargs ) plot = sb.stripplot( x=x, y=y, data=da...
python
def stripboxplot(x, y, data, ax=None, significant=None, **kwargs): """ Overlay a stripplot on top of a boxplot. """ ax = sb.boxplot( x=x, y=y, data=data, ax=ax, fliersize=0, **kwargs ) plot = sb.stripplot( x=x, y=y, data=da...
[ "def", "stripboxplot", "(", "x", ",", "y", ",", "data", ",", "ax", "=", "None", ",", "significant", "=", "None", ",", "*", "*", "kwargs", ")", ":", "ax", "=", "sb", ".", "boxplot", "(", "x", "=", "x", ",", "y", "=", "y", ",", "data", "=", "...
Overlay a stripplot on top of a boxplot.
[ "Overlay", "a", "stripplot", "on", "top", "of", "a", "boxplot", "." ]
train
https://github.com/hammerlab/cohorts/blob/278b05e609e6c4d4a77c57d49446460be53ea33e/cohorts/plot.py#L72-L100
hammerlab/cohorts
cohorts/plot.py
fishers_exact_plot
def fishers_exact_plot(data, condition1, condition2, ax=None, condition1_value=None, alternative="two-sided", **kwargs): """ Perform a Fisher's exact test to compare to binary columns Parameters ---------- data: Pandas dataframe Dataframe to ret...
python
def fishers_exact_plot(data, condition1, condition2, ax=None, condition1_value=None, alternative="two-sided", **kwargs): """ Perform a Fisher's exact test to compare to binary columns Parameters ---------- data: Pandas dataframe Dataframe to ret...
[ "def", "fishers_exact_plot", "(", "data", ",", "condition1", ",", "condition2", ",", "ax", "=", "None", ",", "condition1_value", "=", "None", ",", "alternative", "=", "\"two-sided\"", ",", "*", "*", "kwargs", ")", ":", "plot", "=", "sb", ".", "barplot", ...
Perform a Fisher's exact test to compare to binary columns Parameters ---------- data: Pandas dataframe Dataframe to retrieve information from condition1: str First binary column to compare (and used for test sidedness) condition2: str Second binary column to compare ...
[ "Perform", "a", "Fisher", "s", "exact", "test", "to", "compare", "to", "binary", "columns" ]
train
https://github.com/hammerlab/cohorts/blob/278b05e609e6c4d4a77c57d49446460be53ea33e/cohorts/plot.py#L130-L182
hammerlab/cohorts
cohorts/plot.py
mann_whitney_plot
def mann_whitney_plot(data, condition, distribution, ax=None, condition_value=None, alternative="two-sided", skip_plot=False, **kwargs): """ Create a box plot...
python
def mann_whitney_plot(data, condition, distribution, ax=None, condition_value=None, alternative="two-sided", skip_plot=False, **kwargs): """ Create a box plot...
[ "def", "mann_whitney_plot", "(", "data", ",", "condition", ",", "distribution", ",", "ax", "=", "None", ",", "condition_value", "=", "None", ",", "alternative", "=", "\"two-sided\"", ",", "skip_plot", "=", "False", ",", "*", "*", "kwargs", ")", ":", "condi...
Create a box plot comparing a condition and perform a Mann Whitney test to compare the distribution in condition A v B Parameters ---------- data: Pandas dataframe Dataframe to retrieve information from condition: str Column to use as the splitting criteria distribution: str ...
[ "Create", "a", "box", "plot", "comparing", "a", "condition", "and", "perform", "a", "Mann", "Whitney", "test", "to", "compare", "the", "distribution", "in", "condition", "A", "v", "B" ]
train
https://github.com/hammerlab/cohorts/blob/278b05e609e6c4d4a77c57d49446460be53ea33e/cohorts/plot.py#L192-L253
hammerlab/cohorts
cohorts/plot.py
roc_curve_plot
def roc_curve_plot(data, value_column, outcome_column, bootstrap_samples=100, ax=None): """Create a ROC curve and compute the bootstrap AUC for the given variable and outcome Parameters ---------- data : Pandas dataframe Dataframe to retrieve information from value_column : str Colu...
python
def roc_curve_plot(data, value_column, outcome_column, bootstrap_samples=100, ax=None): """Create a ROC curve and compute the bootstrap AUC for the given variable and outcome Parameters ---------- data : Pandas dataframe Dataframe to retrieve information from value_column : str Colu...
[ "def", "roc_curve_plot", "(", "data", ",", "value_column", ",", "outcome_column", ",", "bootstrap_samples", "=", "100", ",", "ax", "=", "None", ")", ":", "scores", "=", "bootstrap_auc", "(", "df", "=", "data", ",", "col", "=", "value_column", ",", "pred_co...
Create a ROC curve and compute the bootstrap AUC for the given variable and outcome Parameters ---------- data : Pandas dataframe Dataframe to retrieve information from value_column : str Column to retrieve the values from outcome_column : str Column to use as the outcome va...
[ "Create", "a", "ROC", "curve", "and", "compute", "the", "bootstrap", "AUC", "for", "the", "given", "variable", "and", "outcome" ]
train
https://github.com/hammerlab/cohorts/blob/278b05e609e6c4d4a77c57d49446460be53ea33e/cohorts/plot.py#L263-L308
hammerlab/cohorts
cohorts/utils.py
get_cache_dir
def get_cache_dir(cache_dir, cache_root_dir=None, *args, **kwargs): """ Return full cache_dir, according to following logic: - if cache_dir is a full path (per path.isabs), return that value - if not and if cache_root_dir is not None, join two paths - otherwise, log warnings and return N...
python
def get_cache_dir(cache_dir, cache_root_dir=None, *args, **kwargs): """ Return full cache_dir, according to following logic: - if cache_dir is a full path (per path.isabs), return that value - if not and if cache_root_dir is not None, join two paths - otherwise, log warnings and return N...
[ "def", "get_cache_dir", "(", "cache_dir", ",", "cache_root_dir", "=", "None", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "cache_dir", "=", "cache_dir", ".", "format", "(", "*", "args", ",", "*", "*", "kwargs", ")", "if", "path", ".", "isabs...
Return full cache_dir, according to following logic: - if cache_dir is a full path (per path.isabs), return that value - if not and if cache_root_dir is not None, join two paths - otherwise, log warnings and return None Separately, if args or kwargs are given, format cache_dir using kwargs
[ "Return", "full", "cache_dir", "according", "to", "following", "logic", ":", "-", "if", "cache_dir", "is", "a", "full", "path", "(", "per", "path", ".", "isabs", ")", "return", "that", "value", "-", "if", "not", "and", "if", "cache_root_dir", "is", "not"...
train
https://github.com/hammerlab/cohorts/blob/278b05e609e6c4d4a77c57d49446460be53ea33e/cohorts/utils.py#L24-L41
hammerlab/cohorts
cohorts/utils.py
_strip_column_name
def _strip_column_name(col_name, keep_paren_contents=True): """ Utility script applying several regexs to a string. Intended to be used by `strip_column_names`. This function will: 1. replace informative punctuation components with text 2. (optionally) remove text within parentheses ...
python
def _strip_column_name(col_name, keep_paren_contents=True): """ Utility script applying several regexs to a string. Intended to be used by `strip_column_names`. This function will: 1. replace informative punctuation components with text 2. (optionally) remove text within parentheses ...
[ "def", "_strip_column_name", "(", "col_name", ",", "keep_paren_contents", "=", "True", ")", ":", "# start with input", "new_col_name", "=", "col_name", "# replace meaningful punctuation with text equivalents", "# surround each with whitespace to enforce consistent use of _", "punctua...
Utility script applying several regexs to a string. Intended to be used by `strip_column_names`. This function will: 1. replace informative punctuation components with text 2. (optionally) remove text within parentheses 3. replace remaining punctuation/whitespace with _ 4. strip...
[ "Utility", "script", "applying", "several", "regexs", "to", "a", "string", ".", "Intended", "to", "be", "used", "by", "strip_column_names", "." ]
train
https://github.com/hammerlab/cohorts/blob/278b05e609e6c4d4a77c57d49446460be53ea33e/cohorts/utils.py#L84-L142
hammerlab/cohorts
cohorts/utils.py
strip_column_names
def strip_column_names(cols, keep_paren_contents=True): """ Utility script for renaming pandas columns to patsy-friendly names. Revised names have been: - stripped of all punctuation and whitespace (converted to text or `_`) - converted to lower case Takes a list of column names, retur...
python
def strip_column_names(cols, keep_paren_contents=True): """ Utility script for renaming pandas columns to patsy-friendly names. Revised names have been: - stripped of all punctuation and whitespace (converted to text or `_`) - converted to lower case Takes a list of column names, retur...
[ "def", "strip_column_names", "(", "cols", ",", "keep_paren_contents", "=", "True", ")", ":", "# strip/replace punctuation", "new_cols", "=", "[", "_strip_column_name", "(", "col", ",", "keep_paren_contents", "=", "keep_paren_contents", ")", "for", "col", "in", "cols...
Utility script for renaming pandas columns to patsy-friendly names. Revised names have been: - stripped of all punctuation and whitespace (converted to text or `_`) - converted to lower case Takes a list of column names, returns a dict mapping names to revised names. If there are any ...
[ "Utility", "script", "for", "renaming", "pandas", "columns", "to", "patsy", "-", "friendly", "names", "." ]
train
https://github.com/hammerlab/cohorts/blob/278b05e609e6c4d4a77c57d49446460be53ea33e/cohorts/utils.py#L144-L201
hammerlab/cohorts
cohorts/utils.py
set_attributes
def set_attributes(obj, additional_data): """ Given an object and a dictionary, give the object new attributes from that dictionary. Uses _strip_column_name to git rid of whitespace/uppercase/special characters. """ for key, value in additional_data.items(): if hasattr(obj, key): ...
python
def set_attributes(obj, additional_data): """ Given an object and a dictionary, give the object new attributes from that dictionary. Uses _strip_column_name to git rid of whitespace/uppercase/special characters. """ for key, value in additional_data.items(): if hasattr(obj, key): ...
[ "def", "set_attributes", "(", "obj", ",", "additional_data", ")", ":", "for", "key", ",", "value", "in", "additional_data", ".", "items", "(", ")", ":", "if", "hasattr", "(", "obj", ",", "key", ")", ":", "raise", "ValueError", "(", "\"Key %s in additional_...
Given an object and a dictionary, give the object new attributes from that dictionary. Uses _strip_column_name to git rid of whitespace/uppercase/special characters.
[ "Given", "an", "object", "and", "a", "dictionary", "give", "the", "object", "new", "attributes", "from", "that", "dictionary", "." ]
train
https://github.com/hammerlab/cohorts/blob/278b05e609e6c4d4a77c57d49446460be53ea33e/cohorts/utils.py#L210-L219
hammerlab/cohorts
cohorts/utils.py
DataFrameHolder.return_obj
def return_obj(cols, df, return_cols=False): """Construct a DataFrameHolder and then return either that or the DataFrame.""" df_holder = DataFrameHolder(cols=cols, df=df) return df_holder.return_self(return_cols=return_cols)
python
def return_obj(cols, df, return_cols=False): """Construct a DataFrameHolder and then return either that or the DataFrame.""" df_holder = DataFrameHolder(cols=cols, df=df) return df_holder.return_self(return_cols=return_cols)
[ "def", "return_obj", "(", "cols", ",", "df", ",", "return_cols", "=", "False", ")", ":", "df_holder", "=", "DataFrameHolder", "(", "cols", "=", "cols", ",", "df", "=", "df", ")", "return", "df_holder", ".", "return_self", "(", "return_cols", "=", "return...
Construct a DataFrameHolder and then return either that or the DataFrame.
[ "Construct", "a", "DataFrameHolder", "and", "then", "return", "either", "that", "or", "the", "DataFrame", "." ]
train
https://github.com/hammerlab/cohorts/blob/278b05e609e6c4d4a77c57d49446460be53ea33e/cohorts/utils.py#L54-L57
hammerlab/cohorts
cohorts/provenance.py
compare_provenance
def compare_provenance( this_provenance, other_provenance, left_outer_diff = "In current but not comparison", right_outer_diff = "In comparison but not current"): """Utility function to compare two abritrary provenance dicts returns number of discrepancies. Parameters ----------...
python
def compare_provenance( this_provenance, other_provenance, left_outer_diff = "In current but not comparison", right_outer_diff = "In comparison but not current"): """Utility function to compare two abritrary provenance dicts returns number of discrepancies. Parameters ----------...
[ "def", "compare_provenance", "(", "this_provenance", ",", "other_provenance", ",", "left_outer_diff", "=", "\"In current but not comparison\"", ",", "right_outer_diff", "=", "\"In comparison but not current\"", ")", ":", "## if either this or other items is null, return 0", "if", ...
Utility function to compare two abritrary provenance dicts returns number of discrepancies. Parameters ---------- this_provenance: provenance dict (to be compared to "other_provenance") other_provenance: comparison provenance dict (optional) left_outer_diff: description/prefix used when pr...
[ "Utility", "function", "to", "compare", "two", "abritrary", "provenance", "dicts", "returns", "number", "of", "discrepancies", "." ]
train
https://github.com/hammerlab/cohorts/blob/278b05e609e6c4d4a77c57d49446460be53ea33e/cohorts/provenance.py#L22-L65
hammerlab/cohorts
cohorts/survival.py
_plot_kmf_single
def _plot_kmf_single(df, condition_col, survival_col, censor_col, threshold, title, xlabel, ylabel, ax, with_condition_color, ...
python
def _plot_kmf_single(df, condition_col, survival_col, censor_col, threshold, title, xlabel, ylabel, ax, with_condition_color, ...
[ "def", "_plot_kmf_single", "(", "df", ",", "condition_col", ",", "survival_col", ",", "censor_col", ",", "threshold", ",", "title", ",", "xlabel", ",", "ylabel", ",", "ax", ",", "with_condition_color", ",", "no_condition_color", ",", "with_condition_label", ",", ...
Helper function to produce a single KM survival plot, among observations in df by groups defined by condition_col. All inputs are required - this function is intended to be called by `plot_kmf`.
[ "Helper", "function", "to", "produce", "a", "single", "KM", "survival", "plot", "among", "observations", "in", "df", "by", "groups", "defined", "by", "condition_col", "." ]
train
https://github.com/hammerlab/cohorts/blob/278b05e609e6c4d4a77c57d49446460be53ea33e/cohorts/survival.py#L31-L171
hammerlab/cohorts
cohorts/survival.py
plot_kmf
def plot_kmf(df, condition_col, censor_col, survival_col, strata_col=None, threshold=None, title=None, xlabel=None, ylabel=None, ax=None, with_condition_color="#B38600", no_cond...
python
def plot_kmf(df, condition_col, censor_col, survival_col, strata_col=None, threshold=None, title=None, xlabel=None, ylabel=None, ax=None, with_condition_color="#B38600", no_cond...
[ "def", "plot_kmf", "(", "df", ",", "condition_col", ",", "censor_col", ",", "survival_col", ",", "strata_col", "=", "None", ",", "threshold", "=", "None", ",", "title", "=", "None", ",", "xlabel", "=", "None", ",", "ylabel", "=", "None", ",", "ax", "="...
Plot survival curves by splitting the dataset into two groups based on condition_col. Report results for a log-rank test (if two groups are plotted) or CoxPH survival analysis (if >2 groups) for association with survival. Regarding definition of groups: If condition_col is numeric, values are split...
[ "Plot", "survival", "curves", "by", "splitting", "the", "dataset", "into", "two", "groups", "based", "on", "condition_col", ".", "Report", "results", "for", "a", "log", "-", "rank", "test", "(", "if", "two", "groups", "are", "plotted", ")", "or", "CoxPH", ...
train
https://github.com/hammerlab/cohorts/blob/278b05e609e6c4d4a77c57d49446460be53ea33e/cohorts/survival.py#L174-L307
alvarogzp/telegram-bot-framework
bot/action/util/textformat.py
FormattedText.concat
def concat(self, formatted_text): """:type formatted_text: FormattedText""" assert self._is_compatible(formatted_text), "Cannot concat text with different modes" self.text += formatted_text.text return self
python
def concat(self, formatted_text): """:type formatted_text: FormattedText""" assert self._is_compatible(formatted_text), "Cannot concat text with different modes" self.text += formatted_text.text return self
[ "def", "concat", "(", "self", ",", "formatted_text", ")", ":", "assert", "self", ".", "_is_compatible", "(", "formatted_text", ")", ",", "\"Cannot concat text with different modes\"", "self", ".", "text", "+=", "formatted_text", ".", "text", "return", "self" ]
:type formatted_text: FormattedText
[ ":", "type", "formatted_text", ":", "FormattedText" ]
train
https://github.com/alvarogzp/telegram-bot-framework/blob/7b597a415c1901901c677976cb13100fc3083107/bot/action/util/textformat.py#L42-L46
alvarogzp/telegram-bot-framework
bot/action/util/textformat.py
FormattedText.join
def join(self, formatted_texts): """:type formatted_texts: list[FormattedText]""" formatted_texts = list(formatted_texts) # so that after the first iteration elements are not lost if generator for formatted_text in formatted_texts: assert self._is_compatible(formatted_text), "Cannot...
python
def join(self, formatted_texts): """:type formatted_texts: list[FormattedText]""" formatted_texts = list(formatted_texts) # so that after the first iteration elements are not lost if generator for formatted_text in formatted_texts: assert self._is_compatible(formatted_text), "Cannot...
[ "def", "join", "(", "self", ",", "formatted_texts", ")", ":", "formatted_texts", "=", "list", "(", "formatted_texts", ")", "# so that after the first iteration elements are not lost if generator", "for", "formatted_text", "in", "formatted_texts", ":", "assert", "self", "....
:type formatted_texts: list[FormattedText]
[ ":", "type", "formatted_texts", ":", "list", "[", "FormattedText", "]" ]
train
https://github.com/alvarogzp/telegram-bot-framework/blob/7b597a415c1901901c677976cb13100fc3083107/bot/action/util/textformat.py#L48-L54
alvarogzp/telegram-bot-framework
bot/action/util/textformat.py
FormattedTextStringFormat.concat
def concat(self, *args, **kwargs): """ :type args: FormattedText :type kwargs: FormattedText """ for arg in args: assert self.formatted_text._is_compatible(arg), "Cannot concat text with different modes" self.format_args.append(arg.text) for kwarg ...
python
def concat(self, *args, **kwargs): """ :type args: FormattedText :type kwargs: FormattedText """ for arg in args: assert self.formatted_text._is_compatible(arg), "Cannot concat text with different modes" self.format_args.append(arg.text) for kwarg ...
[ "def", "concat", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "for", "arg", "in", "args", ":", "assert", "self", ".", "formatted_text", ".", "_is_compatible", "(", "arg", ")", ",", "\"Cannot concat text with different modes\"", "self", ...
:type args: FormattedText :type kwargs: FormattedText
[ ":", "type", "args", ":", "FormattedText", ":", "type", "kwargs", ":", "FormattedText" ]
train
https://github.com/alvarogzp/telegram-bot-framework/blob/7b597a415c1901901c677976cb13100fc3083107/bot/action/util/textformat.py#L251-L263
hammerlab/cohorts
cohorts/random.py
random_cohort
def random_cohort(size, cache_dir, data_dir=None, min_random_variants=None, max_random_variants=None, seed_val=1234): """ Parameters ---------- min_random_variants: optional, int Minimum number of random variants to be generated per patient. ...
python
def random_cohort(size, cache_dir, data_dir=None, min_random_variants=None, max_random_variants=None, seed_val=1234): """ Parameters ---------- min_random_variants: optional, int Minimum number of random variants to be generated per patient. ...
[ "def", "random_cohort", "(", "size", ",", "cache_dir", ",", "data_dir", "=", "None", ",", "min_random_variants", "=", "None", ",", "max_random_variants", "=", "None", ",", "seed_val", "=", "1234", ")", ":", "seed", "(", "seed_val", ")", "d", "=", "{", "}...
Parameters ---------- min_random_variants: optional, int Minimum number of random variants to be generated per patient. max_random_variants: optional, int Maximum number of random variants to be generated per patient.
[ "Parameters", "----------", "min_random_variants", ":", "optional", "int", "Minimum", "number", "of", "random", "variants", "to", "be", "generated", "per", "patient", ".", "max_random_variants", ":", "optional", "int", "Maximum", "number", "of", "random", "variants"...
train
https://github.com/hammerlab/cohorts/blob/278b05e609e6c4d4a77c57d49446460be53ea33e/cohorts/random.py#L24-L75
hammerlab/cohorts
cohorts/random.py
generate_random_missense_variants
def generate_random_missense_variants(num_variants=10, max_search=100000, reference="GRCh37"): """ Generate a random collection of missense variants by trying random variants repeatedly. """ variants = [] for i in range(max_search): bases = ["A", "C", "T", "G"] random_ref = choice(ba...
python
def generate_random_missense_variants(num_variants=10, max_search=100000, reference="GRCh37"): """ Generate a random collection of missense variants by trying random variants repeatedly. """ variants = [] for i in range(max_search): bases = ["A", "C", "T", "G"] random_ref = choice(ba...
[ "def", "generate_random_missense_variants", "(", "num_variants", "=", "10", ",", "max_search", "=", "100000", ",", "reference", "=", "\"GRCh37\"", ")", ":", "variants", "=", "[", "]", "for", "i", "in", "range", "(", "max_search", ")", ":", "bases", "=", "[...
Generate a random collection of missense variants by trying random variants repeatedly.
[ "Generate", "a", "random", "collection", "of", "missense", "variants", "by", "trying", "random", "variants", "repeatedly", "." ]
train
https://github.com/hammerlab/cohorts/blob/278b05e609e6c4d4a77c57d49446460be53ea33e/cohorts/random.py#L77-L100
hammerlab/cohorts
cohorts/random.py
generate_simple_vcf
def generate_simple_vcf(filename, variant_collection): """ Output a very simple metadata-free VCF for each variant in a variant_collection. """ contigs = [] positions = [] refs = [] alts = [] for variant in variant_collection: contigs.append("chr" + variant.contig) positi...
python
def generate_simple_vcf(filename, variant_collection): """ Output a very simple metadata-free VCF for each variant in a variant_collection. """ contigs = [] positions = [] refs = [] alts = [] for variant in variant_collection: contigs.append("chr" + variant.contig) positi...
[ "def", "generate_simple_vcf", "(", "filename", ",", "variant_collection", ")", ":", "contigs", "=", "[", "]", "positions", "=", "[", "]", "refs", "=", "[", "]", "alts", "=", "[", "]", "for", "variant", "in", "variant_collection", ":", "contigs", ".", "ap...
Output a very simple metadata-free VCF for each variant in a variant_collection.
[ "Output", "a", "very", "simple", "metadata", "-", "free", "VCF", "for", "each", "variant", "in", "a", "variant_collection", "." ]
train
https://github.com/hammerlab/cohorts/blob/278b05e609e6c4d4a77c57d49446460be53ea33e/cohorts/random.py#L102-L140
carletes/mock-ssh-server
mockssh/sftp.py
SFTPServerInterface.list_folder
def list_folder(self, path): """Looks up folder contents of `path.`""" # Inspired by https://github.com/rspivak/sftpserver/blob/0.3/src/sftpserver/stub_sftp.py#L70 try: folder_contents = [] for f in os.listdir(path): attr = paramiko.SFTPAttributes.from_sta...
python
def list_folder(self, path): """Looks up folder contents of `path.`""" # Inspired by https://github.com/rspivak/sftpserver/blob/0.3/src/sftpserver/stub_sftp.py#L70 try: folder_contents = [] for f in os.listdir(path): attr = paramiko.SFTPAttributes.from_sta...
[ "def", "list_folder", "(", "self", ",", "path", ")", ":", "# Inspired by https://github.com/rspivak/sftpserver/blob/0.3/src/sftpserver/stub_sftp.py#L70", "try", ":", "folder_contents", "=", "[", "]", "for", "f", "in", "os", ".", "listdir", "(", "path", ")", ":", "at...
Looks up folder contents of `path.`
[ "Looks", "up", "folder", "contents", "of", "path", "." ]
train
https://github.com/carletes/mock-ssh-server/blob/0d724ad4a43bafcb6a4bbe28b52383528f3460cc/mockssh/sftp.py#L142-L153
hammerlab/cohorts
cohorts/varcode_utils.py
filter_variants
def filter_variants(variant_collection, patient, filter_fn, **kwargs): """Filter variants from the Variant Collection Parameters ---------- variant_collection : varcode.VariantCollection patient : cohorts.Patient filter_fn: function Takes a FilterableVariant and returns a boolean. Only ...
python
def filter_variants(variant_collection, patient, filter_fn, **kwargs): """Filter variants from the Variant Collection Parameters ---------- variant_collection : varcode.VariantCollection patient : cohorts.Patient filter_fn: function Takes a FilterableVariant and returns a boolean. Only ...
[ "def", "filter_variants", "(", "variant_collection", ",", "patient", ",", "filter_fn", ",", "*", "*", "kwargs", ")", ":", "if", "filter_fn", ":", "return", "variant_collection", ".", "clone_with_new_elements", "(", "[", "variant", "for", "variant", "in", "varian...
Filter variants from the Variant Collection Parameters ---------- variant_collection : varcode.VariantCollection patient : cohorts.Patient filter_fn: function Takes a FilterableVariant and returns a boolean. Only variants returning True are preserved. Returns ------- varcode.Va...
[ "Filter", "variants", "from", "the", "Variant", "Collection" ]
train
https://github.com/hammerlab/cohorts/blob/278b05e609e6c4d4a77c57d49446460be53ea33e/cohorts/varcode_utils.py#L79-L105
hammerlab/cohorts
cohorts/varcode_utils.py
filter_effects
def filter_effects(effect_collection, variant_collection, patient, filter_fn, all_effects, **kwargs): """Filter variants from the Effect Collection Parameters ---------- effect_collection : varcode.EffectCollection variant_collection : varcode.VariantCollection patient : cohorts.Patient fil...
python
def filter_effects(effect_collection, variant_collection, patient, filter_fn, all_effects, **kwargs): """Filter variants from the Effect Collection Parameters ---------- effect_collection : varcode.EffectCollection variant_collection : varcode.VariantCollection patient : cohorts.Patient fil...
[ "def", "filter_effects", "(", "effect_collection", ",", "variant_collection", ",", "patient", ",", "filter_fn", ",", "all_effects", ",", "*", "*", "kwargs", ")", ":", "def", "top_priority_maybe", "(", "effect_collection", ")", ":", "\"\"\"\n Always (unless all_...
Filter variants from the Effect Collection Parameters ---------- effect_collection : varcode.EffectCollection variant_collection : varcode.VariantCollection patient : cohorts.Patient filter_fn : function Takes a FilterableEffect and returns a boolean. Only effects returning True are pre...
[ "Filter", "variants", "from", "the", "Effect", "Collection" ]
train
https://github.com/hammerlab/cohorts/blob/278b05e609e6c4d4a77c57d49446460be53ea33e/cohorts/varcode_utils.py#L107-L157
garethr/django-timelog
src/timelog/lib.py
count_lines_in
def count_lines_in(filename): "Count lines in a file" f = open(filename) lines = 0 buf_size = 1024 * 1024 read_f = f.read # loop optimization buf = read_f(buf_size) while buf: lines += buf.count('\n') buf = read_f(buf_size) return lines
python
def count_lines_in(filename): "Count lines in a file" f = open(filename) lines = 0 buf_size = 1024 * 1024 read_f = f.read # loop optimization buf = read_f(buf_size) while buf: lines += buf.count('\n') buf = read_f(buf_size) return lines
[ "def", "count_lines_in", "(", "filename", ")", ":", "f", "=", "open", "(", "filename", ")", "lines", "=", "0", "buf_size", "=", "1024", "*", "1024", "read_f", "=", "f", ".", "read", "# loop optimization", "buf", "=", "read_f", "(", "buf_size", ")", "wh...
Count lines in a file
[ "Count", "lines", "in", "a", "file" ]
train
https://github.com/garethr/django-timelog/blob/84c7015248a82faccb9d3fe4e6014645cc9ec103/src/timelog/lib.py#L16-L28
garethr/django-timelog
src/timelog/lib.py
view_name_from
def view_name_from(path): "Resolve a path to the full python module name of the related view function" try: return CACHED_VIEWS[path] except KeyError: view = resolve(path) module = path name = '' if hasattr(view.func, '__module__'): module = resol...
python
def view_name_from(path): "Resolve a path to the full python module name of the related view function" try: return CACHED_VIEWS[path] except KeyError: view = resolve(path) module = path name = '' if hasattr(view.func, '__module__'): module = resol...
[ "def", "view_name_from", "(", "path", ")", ":", "try", ":", "return", "CACHED_VIEWS", "[", "path", "]", "except", "KeyError", ":", "view", "=", "resolve", "(", "path", ")", "module", "=", "path", "name", "=", "''", "if", "hasattr", "(", "view", ".", ...
Resolve a path to the full python module name of the related view function
[ "Resolve", "a", "path", "to", "the", "full", "python", "module", "name", "of", "the", "related", "view", "function" ]
train
https://github.com/garethr/django-timelog/blob/84c7015248a82faccb9d3fe4e6014645cc9ec103/src/timelog/lib.py#L30-L46
garethr/django-timelog
src/timelog/lib.py
generate_table_from
def generate_table_from(data): "Output a nicely formatted ascii table" table = Texttable(max_width=120) table.add_row(["view", "method", "status", "count", "minimum", "maximum", "mean", "stdev", "queries", "querytime"]) table.set_cols_align(["l", "l", "l", "r", "r", "r", "r", "r", "r", "r"]) for i...
python
def generate_table_from(data): "Output a nicely formatted ascii table" table = Texttable(max_width=120) table.add_row(["view", "method", "status", "count", "minimum", "maximum", "mean", "stdev", "queries", "querytime"]) table.set_cols_align(["l", "l", "l", "r", "r", "r", "r", "r", "r", "r"]) for i...
[ "def", "generate_table_from", "(", "data", ")", ":", "table", "=", "Texttable", "(", "max_width", "=", "120", ")", "table", ".", "add_row", "(", "[", "\"view\"", ",", "\"method\"", ",", "\"status\"", ",", "\"count\"", ",", "\"minimum\"", ",", "\"maximum\"", ...
Output a nicely formatted ascii table
[ "Output", "a", "nicely", "formatted", "ascii", "table" ]
train
https://github.com/garethr/django-timelog/blob/84c7015248a82faccb9d3fe4e6014645cc9ec103/src/timelog/lib.py#L48-L70
garethr/django-timelog
src/timelog/lib.py
analyze_log_file
def analyze_log_file(logfile, pattern, reverse_paths=True, progress=True): "Given a log file and regex group and extract the performance data" if progress: lines = count_lines_in(logfile) pbar = ProgressBar(widgets=[Percentage(), Bar()], maxval=lines+1).start() counter = 0 data ...
python
def analyze_log_file(logfile, pattern, reverse_paths=True, progress=True): "Given a log file and regex group and extract the performance data" if progress: lines = count_lines_in(logfile) pbar = ProgressBar(widgets=[Percentage(), Bar()], maxval=lines+1).start() counter = 0 data ...
[ "def", "analyze_log_file", "(", "logfile", ",", "pattern", ",", "reverse_paths", "=", "True", ",", "progress", "=", "True", ")", ":", "if", "progress", ":", "lines", "=", "count_lines_in", "(", "logfile", ")", "pbar", "=", "ProgressBar", "(", "widgets", "=...
Given a log file and regex group and extract the performance data
[ "Given", "a", "log", "file", "and", "regex", "group", "and", "extract", "the", "performance", "data" ]
train
https://github.com/garethr/django-timelog/blob/84c7015248a82faccb9d3fe4e6014645cc9ec103/src/timelog/lib.py#L72-L132
hammerlab/cohorts
cohorts/collection.py
Collection.to_string
def to_string(self, limit=None): """ Create a string representation of this collection, showing up to `limit` items. """ header = self.short_string() if len(self) == 0: return header contents = "" element_lines = [ " -- %s" % (elem...
python
def to_string(self, limit=None): """ Create a string representation of this collection, showing up to `limit` items. """ header = self.short_string() if len(self) == 0: return header contents = "" element_lines = [ " -- %s" % (elem...
[ "def", "to_string", "(", "self", ",", "limit", "=", "None", ")", ":", "header", "=", "self", ".", "short_string", "(", ")", "if", "len", "(", "self", ")", "==", "0", ":", "return", "header", "contents", "=", "\"\"", "element_lines", "=", "[", "\" --...
Create a string representation of this collection, showing up to `limit` items.
[ "Create", "a", "string", "representation", "of", "this", "collection", "showing", "up", "to", "limit", "items", "." ]
train
https://github.com/hammerlab/cohorts/blob/278b05e609e6c4d4a77c57d49446460be53ea33e/cohorts/collection.py#L29-L46
alvarogzp/telegram-bot-framework
bot/action/standard/userinfo.py
UserStorageHandler.get_instance
def get_instance(cls, state): """:rtype: UserStorageHandler""" if cls.instance is None: cls.instance = UserStorageHandler(state) return cls.instance
python
def get_instance(cls, state): """:rtype: UserStorageHandler""" if cls.instance is None: cls.instance = UserStorageHandler(state) return cls.instance
[ "def", "get_instance", "(", "cls", ",", "state", ")", ":", "if", "cls", ".", "instance", "is", "None", ":", "cls", ".", "instance", "=", "UserStorageHandler", "(", "state", ")", "return", "cls", ".", "instance" ]
:rtype: UserStorageHandler
[ ":", "rtype", ":", "UserStorageHandler" ]
train
https://github.com/alvarogzp/telegram-bot-framework/blob/7b597a415c1901901c677976cb13100fc3083107/bot/action/standard/userinfo.py#L26-L30
alvarogzp/telegram-bot-framework
bot/action/standard/benchmark.py
WorkersAction._get_active_threads_names
def _get_active_threads_names(): """May contain sensitive info (like user ids). Use with care.""" active_threads = threading.enumerate() return FormattedText().join( [ FormattedText().newline().normal(" - {name}").start_format().bold(name=thread.name).end_format() ...
python
def _get_active_threads_names(): """May contain sensitive info (like user ids). Use with care.""" active_threads = threading.enumerate() return FormattedText().join( [ FormattedText().newline().normal(" - {name}").start_format().bold(name=thread.name).end_format() ...
[ "def", "_get_active_threads_names", "(", ")", ":", "active_threads", "=", "threading", ".", "enumerate", "(", ")", "return", "FormattedText", "(", ")", ".", "join", "(", "[", "FormattedText", "(", ")", ".", "newline", "(", ")", ".", "normal", "(", "\" - {n...
May contain sensitive info (like user ids). Use with care.
[ "May", "contain", "sensitive", "info", "(", "like", "user", "ids", ")", ".", "Use", "with", "care", "." ]
train
https://github.com/alvarogzp/telegram-bot-framework/blob/7b597a415c1901901c677976cb13100fc3083107/bot/action/standard/benchmark.py#L164-L172
alvarogzp/telegram-bot-framework
bot/action/standard/benchmark.py
WorkersAction._get_running_workers_names
def _get_running_workers_names(running_workers: list): """May contain sensitive info (like user ids). Use with care.""" return FormattedText().join( [ FormattedText().newline().normal(" - {name}").start_format().bold(name=worker.name).end_format() for worker i...
python
def _get_running_workers_names(running_workers: list): """May contain sensitive info (like user ids). Use with care.""" return FormattedText().join( [ FormattedText().newline().normal(" - {name}").start_format().bold(name=worker.name).end_format() for worker i...
[ "def", "_get_running_workers_names", "(", "running_workers", ":", "list", ")", ":", "return", "FormattedText", "(", ")", ".", "join", "(", "[", "FormattedText", "(", ")", ".", "newline", "(", ")", ".", "normal", "(", "\" - {name}\"", ")", ".", "start_format"...
May contain sensitive info (like user ids). Use with care.
[ "May", "contain", "sensitive", "info", "(", "like", "user", "ids", ")", ".", "Use", "with", "care", "." ]
train
https://github.com/alvarogzp/telegram-bot-framework/blob/7b597a415c1901901c677976cb13100fc3083107/bot/action/standard/benchmark.py#L187-L194
alvarogzp/telegram-bot-framework
bot/action/standard/benchmark.py
WorkersAction._get_worker_pools_names
def _get_worker_pools_names(worker_pools: list): """May contain sensitive info (like user ids). Use with care.""" return FormattedText().join( [ FormattedText().newline().normal(" - {name}").start_format().bold(name=worker.name).end_format() for worker in work...
python
def _get_worker_pools_names(worker_pools: list): """May contain sensitive info (like user ids). Use with care.""" return FormattedText().join( [ FormattedText().newline().normal(" - {name}").start_format().bold(name=worker.name).end_format() for worker in work...
[ "def", "_get_worker_pools_names", "(", "worker_pools", ":", "list", ")", ":", "return", "FormattedText", "(", ")", ".", "join", "(", "[", "FormattedText", "(", ")", ".", "newline", "(", ")", ".", "normal", "(", "\" - {name}\"", ")", ".", "start_format", "(...
May contain sensitive info (like user ids). Use with care.
[ "May", "contain", "sensitive", "info", "(", "like", "user", "ids", ")", ".", "Use", "with", "care", "." ]
train
https://github.com/alvarogzp/telegram-bot-framework/blob/7b597a415c1901901c677976cb13100fc3083107/bot/action/standard/benchmark.py#L209-L216
alvarogzp/telegram-bot-framework
bot/action/standard/info/formatter/user.py
UserInfoFormatter.format
def format(self, member_info: bool = False): """ :param member_info: If True, adds also chat member info. Please, note that this additional info requires to make ONE api call. """ user = self.api_object self.__format_user(user) if member_info and self.chat.typ...
python
def format(self, member_info: bool = False): """ :param member_info: If True, adds also chat member info. Please, note that this additional info requires to make ONE api call. """ user = self.api_object self.__format_user(user) if member_info and self.chat.typ...
[ "def", "format", "(", "self", ",", "member_info", ":", "bool", "=", "False", ")", ":", "user", "=", "self", ".", "api_object", "self", ".", "__format_user", "(", "user", ")", "if", "member_info", "and", "self", ".", "chat", ".", "type", "!=", "CHAT_TYP...
:param member_info: If True, adds also chat member info. Please, note that this additional info requires to make ONE api call.
[ ":", "param", "member_info", ":", "If", "True", "adds", "also", "chat", "member", "info", ".", "Please", "note", "that", "this", "additional", "info", "requires", "to", "make", "ONE", "api", "call", "." ]
train
https://github.com/alvarogzp/telegram-bot-framework/blob/7b597a415c1901901c677976cb13100fc3083107/bot/action/standard/info/formatter/user.py#L19-L28
alvarogzp/telegram-bot-framework
bot/bot.py
UpdatesProcessor.safe_log_error
def safe_log_error(self, error: Exception, *info: str): """Log error failing silently on error""" self.__do_safe(lambda: self.logger.error(error, *info))
python
def safe_log_error(self, error: Exception, *info: str): """Log error failing silently on error""" self.__do_safe(lambda: self.logger.error(error, *info))
[ "def", "safe_log_error", "(", "self", ",", "error", ":", "Exception", ",", "*", "info", ":", "str", ")", ":", "self", ".", "__do_safe", "(", "lambda", ":", "self", ".", "logger", ".", "error", "(", "error", ",", "*", "info", ")", ")" ]
Log error failing silently on error
[ "Log", "error", "failing", "silently", "on", "error" ]
train
https://github.com/alvarogzp/telegram-bot-framework/blob/7b597a415c1901901c677976cb13100fc3083107/bot/bot.py#L173-L175
alvarogzp/telegram-bot-framework
bot/bot.py
UpdatesProcessor.safe_log_info
def safe_log_info(self, *info: str): """Log info failing silently on error""" self.__do_safe(lambda: self.logger.info(*info))
python
def safe_log_info(self, *info: str): """Log info failing silently on error""" self.__do_safe(lambda: self.logger.info(*info))
[ "def", "safe_log_info", "(", "self", ",", "*", "info", ":", "str", ")", ":", "self", ".", "__do_safe", "(", "lambda", ":", "self", ".", "logger", ".", "info", "(", "*", "info", ")", ")" ]
Log info failing silently on error
[ "Log", "info", "failing", "silently", "on", "error" ]
train
https://github.com/alvarogzp/telegram-bot-framework/blob/7b597a415c1901901c677976cb13100fc3083107/bot/bot.py#L177-L179
brentp/skidmarks
skidmarks.py
wald_wolfowitz
def wald_wolfowitz(sequence): """ implements the wald-wolfowitz runs test: http://en.wikipedia.org/wiki/Wald-Wolfowitz_runs_test http://support.sas.com/kb/33/092.html :param sequence: any iterable with at most 2 values. e.g. '1001001' [1, 0, 1, 0, 1] ...
python
def wald_wolfowitz(sequence): """ implements the wald-wolfowitz runs test: http://en.wikipedia.org/wiki/Wald-Wolfowitz_runs_test http://support.sas.com/kb/33/092.html :param sequence: any iterable with at most 2 values. e.g. '1001001' [1, 0, 1, 0, 1] ...
[ "def", "wald_wolfowitz", "(", "sequence", ")", ":", "R", "=", "n_runs", "=", "sum", "(", "1", "for", "s", "in", "groupby", "(", "sequence", ",", "lambda", "a", ":", "a", ")", ")", "n", "=", "float", "(", "sum", "(", "1", "for", "s", "in", "sequ...
implements the wald-wolfowitz runs test: http://en.wikipedia.org/wiki/Wald-Wolfowitz_runs_test http://support.sas.com/kb/33/092.html :param sequence: any iterable with at most 2 values. e.g. '1001001' [1, 0, 1, 0, 1] 'abaaabbba' :rtype: a ...
[ "implements", "the", "wald", "-", "wolfowitz", "runs", "test", ":", "http", ":", "//", "en", ".", "wikipedia", ".", "org", "/", "wiki", "/", "Wald", "-", "Wolfowitz_runs_test", "http", ":", "//", "support", ".", "sas", ".", "com", "/", "kb", "/", "33...
train
https://github.com/brentp/skidmarks/blob/f63b9f1b822cb47991215b655155b5041e86ea39/skidmarks.py#L51-L99
brentp/skidmarks
skidmarks.py
auto_correlation
def auto_correlation(sequence): """ test for the autocorrelation of a sequence between t and t - 1 as the 'auto_correlation' it is less likely that the sequence is generated randomly. :param sequence: any iterable with at most 2 values that can be turned into a float via np.floa...
python
def auto_correlation(sequence): """ test for the autocorrelation of a sequence between t and t - 1 as the 'auto_correlation' it is less likely that the sequence is generated randomly. :param sequence: any iterable with at most 2 values that can be turned into a float via np.floa...
[ "def", "auto_correlation", "(", "sequence", ")", ":", "if", "isinstance", "(", "sequence", ",", "basestring", ")", ":", "sequence", "=", "map", "(", "int", ",", "sequence", ")", "seq", "=", "np", ".", "array", "(", "list", "(", "sequence", ")", ",", ...
test for the autocorrelation of a sequence between t and t - 1 as the 'auto_correlation' it is less likely that the sequence is generated randomly. :param sequence: any iterable with at most 2 values that can be turned into a float via np.float . e.g. '1001001' ...
[ "test", "for", "the", "autocorrelation", "of", "a", "sequence", "between", "t", "and", "t", "-", "1", "as", "the", "auto_correlation", "it", "is", "less", "likely", "that", "the", "sequence", "is", "generated", "randomly", ".", ":", "param", "sequence", ":...
train
https://github.com/brentp/skidmarks/blob/f63b9f1b822cb47991215b655155b5041e86ea39/skidmarks.py#L102-L129
twisted/txacme
src/txacme/client.py
_parse_header_links
def _parse_header_links(response): """ Parse the links from a Link: header field. .. todo:: Links with the same relation collide at the moment. :param bytes value: The header value. :rtype: `dict` :return: A dictionary of parsed links, keyed by ``rel`` or ``url``. """ values = respon...
python
def _parse_header_links(response): """ Parse the links from a Link: header field. .. todo:: Links with the same relation collide at the moment. :param bytes value: The header value. :rtype: `dict` :return: A dictionary of parsed links, keyed by ``rel`` or ``url``. """ values = respon...
[ "def", "_parse_header_links", "(", "response", ")", ":", "values", "=", "response", ".", "headers", ".", "getRawHeaders", "(", "b'link'", ",", "[", "b''", "]", ")", "value", "=", "b','", ".", "join", "(", "values", ")", ".", "decode", "(", "'ascii'", "...
Parse the links from a Link: header field. .. todo:: Links with the same relation collide at the moment. :param bytes value: The header value. :rtype: `dict` :return: A dictionary of parsed links, keyed by ``rel`` or ``url``.
[ "Parse", "the", "links", "from", "a", "Link", ":", "header", "field", "." ]
train
https://github.com/twisted/txacme/blob/9478381cc63c6d53d14bf8db8407c923f472989a/src/txacme/client.py#L37-L69
twisted/txacme
src/txacme/client.py
_default_client
def _default_client(jws_client, reactor, key, alg): """ Make a client if we didn't get one. """ if jws_client is None: pool = HTTPConnectionPool(reactor) agent = Agent(reactor, pool=pool) jws_client = JWSClient(HTTPClient(agent=agent), key, alg) return jws_client
python
def _default_client(jws_client, reactor, key, alg): """ Make a client if we didn't get one. """ if jws_client is None: pool = HTTPConnectionPool(reactor) agent = Agent(reactor, pool=pool) jws_client = JWSClient(HTTPClient(agent=agent), key, alg) return jws_client
[ "def", "_default_client", "(", "jws_client", ",", "reactor", ",", "key", ",", "alg", ")", ":", "if", "jws_client", "is", "None", ":", "pool", "=", "HTTPConnectionPool", "(", "reactor", ")", "agent", "=", "Agent", "(", "reactor", ",", "pool", "=", "pool",...
Make a client if we didn't get one.
[ "Make", "a", "client", "if", "we", "didn", "t", "get", "one", "." ]
train
https://github.com/twisted/txacme/blob/9478381cc63c6d53d14bf8db8407c923f472989a/src/txacme/client.py#L72-L80
twisted/txacme
src/txacme/client.py
_find_supported_challenge
def _find_supported_challenge(authzr, responders): """ Find a challenge combination that consists of a single challenge that the responder can satisfy. :param ~acme.messages.AuthorizationResource auth: The authorization to examine. :type responder: List[`~txacme.interfaces.IResponder`] ...
python
def _find_supported_challenge(authzr, responders): """ Find a challenge combination that consists of a single challenge that the responder can satisfy. :param ~acme.messages.AuthorizationResource auth: The authorization to examine. :type responder: List[`~txacme.interfaces.IResponder`] ...
[ "def", "_find_supported_challenge", "(", "authzr", ",", "responders", ")", ":", "matches", "=", "[", "(", "responder", ",", "challbs", "[", "0", "]", ")", "for", "challbs", "in", "authzr", ".", "body", ".", "resolved_combinations", "for", "responder", "in", ...
Find a challenge combination that consists of a single challenge that the responder can satisfy. :param ~acme.messages.AuthorizationResource auth: The authorization to examine. :type responder: List[`~txacme.interfaces.IResponder`] :param responder: The possible responders to use. :raises...
[ "Find", "a", "challenge", "combination", "that", "consists", "of", "a", "single", "challenge", "that", "the", "responder", "can", "satisfy", "." ]
train
https://github.com/twisted/txacme/blob/9478381cc63c6d53d14bf8db8407c923f472989a/src/txacme/client.py#L505-L531
twisted/txacme
src/txacme/client.py
answer_challenge
def answer_challenge(authzr, client, responders): """ Complete an authorization using a responder. :param ~acme.messages.AuthorizationResource auth: The authorization to complete. :param .Client client: The ACME client. :type responders: List[`~txacme.interfaces.IResponder`] :param res...
python
def answer_challenge(authzr, client, responders): """ Complete an authorization using a responder. :param ~acme.messages.AuthorizationResource auth: The authorization to complete. :param .Client client: The ACME client. :type responders: List[`~txacme.interfaces.IResponder`] :param res...
[ "def", "answer_challenge", "(", "authzr", ",", "client", ",", "responders", ")", ":", "responder", ",", "challb", "=", "_find_supported_challenge", "(", "authzr", ",", "responders", ")", "response", "=", "challb", ".", "response", "(", "client", ".", "key", ...
Complete an authorization using a responder. :param ~acme.messages.AuthorizationResource auth: The authorization to complete. :param .Client client: The ACME client. :type responders: List[`~txacme.interfaces.IResponder`] :param responders: A list of responders that can be used to complete the...
[ "Complete", "an", "authorization", "using", "a", "responder", "." ]
train
https://github.com/twisted/txacme/blob/9478381cc63c6d53d14bf8db8407c923f472989a/src/txacme/client.py#L534-L565
twisted/txacme
src/txacme/client.py
poll_until_valid
def poll_until_valid(authzr, clock, client, timeout=300.0): """ Poll an authorization until it is in a state other than pending or processing. :param ~acme.messages.AuthorizationResource auth: The authorization to complete. :param clock: The ``IReactorTime`` implementation to use; usually t...
python
def poll_until_valid(authzr, clock, client, timeout=300.0): """ Poll an authorization until it is in a state other than pending or processing. :param ~acme.messages.AuthorizationResource auth: The authorization to complete. :param clock: The ``IReactorTime`` implementation to use; usually t...
[ "def", "poll_until_valid", "(", "authzr", ",", "clock", ",", "client", ",", "timeout", "=", "300.0", ")", ":", "def", "repoll", "(", "result", ")", ":", "authzr", ",", "retry_after", "=", "result", "if", "authzr", ".", "body", ".", "status", "in", "{",...
Poll an authorization until it is in a state other than pending or processing. :param ~acme.messages.AuthorizationResource auth: The authorization to complete. :param clock: The ``IReactorTime`` implementation to use; usually the reactor, when not testing. :param .Client client: The ACM...
[ "Poll", "an", "authorization", "until", "it", "is", "in", "a", "state", "other", "than", "pending", "or", "processing", "." ]
train
https://github.com/twisted/txacme/blob/9478381cc63c6d53d14bf8db8407c923f472989a/src/txacme/client.py#L568-L609
twisted/txacme
src/txacme/client.py
Client.from_url
def from_url(cls, reactor, url, key, alg=RS256, jws_client=None): """ Construct a client from an ACME directory at a given URL. :param url: The ``twisted.python.url.URL`` to fetch the directory from. See `txacme.urls` for constants for various well-known public directori...
python
def from_url(cls, reactor, url, key, alg=RS256, jws_client=None): """ Construct a client from an ACME directory at a given URL. :param url: The ``twisted.python.url.URL`` to fetch the directory from. See `txacme.urls` for constants for various well-known public directori...
[ "def", "from_url", "(", "cls", ",", "reactor", ",", "url", ",", "key", ",", "alg", "=", "RS256", ",", "jws_client", "=", "None", ")", ":", "action", "=", "LOG_ACME_CONSUME_DIRECTORY", "(", "url", "=", "url", ",", "key_type", "=", "key", ".", "typ", "...
Construct a client from an ACME directory at a given URL. :param url: The ``twisted.python.url.URL`` to fetch the directory from. See `txacme.urls` for constants for various well-known public directories. :param reactor: The Twisted reactor to use. :param ~josepy.jwk.JWK...
[ "Construct", "a", "client", "from", "an", "ACME", "directory", "at", "a", "given", "URL", "." ]
train
https://github.com/twisted/txacme/blob/9478381cc63c6d53d14bf8db8407c923f472989a/src/txacme/client.py#L109-L138
twisted/txacme
src/txacme/client.py
Client.register
def register(self, new_reg=None): """ Create a new registration with the ACME server. :param ~acme.messages.NewRegistration new_reg: The registration message to use, or ``None`` to construct one. :return: The registration resource. :rtype: Deferred[`~acme.messages.R...
python
def register(self, new_reg=None): """ Create a new registration with the ACME server. :param ~acme.messages.NewRegistration new_reg: The registration message to use, or ``None`` to construct one. :return: The registration resource. :rtype: Deferred[`~acme.messages.R...
[ "def", "register", "(", "self", ",", "new_reg", "=", "None", ")", ":", "if", "new_reg", "is", "None", ":", "new_reg", "=", "messages", ".", "NewRegistration", "(", ")", "action", "=", "LOG_ACME_REGISTER", "(", "registration", "=", "new_reg", ")", "with", ...
Create a new registration with the ACME server. :param ~acme.messages.NewRegistration new_reg: The registration message to use, or ``None`` to construct one. :return: The registration resource. :rtype: Deferred[`~acme.messages.RegistrationResource`]
[ "Create", "a", "new", "registration", "with", "the", "ACME", "server", "." ]
train
https://github.com/twisted/txacme/blob/9478381cc63c6d53d14bf8db8407c923f472989a/src/txacme/client.py#L140-L161
twisted/txacme
src/txacme/client.py
Client._maybe_location
def _maybe_location(cls, response, uri=None): """ Get the Location: if there is one. """ location = response.headers.getRawHeaders(b'location', [None])[0] if location is not None: return location.decode('ascii') return uri
python
def _maybe_location(cls, response, uri=None): """ Get the Location: if there is one. """ location = response.headers.getRawHeaders(b'location', [None])[0] if location is not None: return location.decode('ascii') return uri
[ "def", "_maybe_location", "(", "cls", ",", "response", ",", "uri", "=", "None", ")", ":", "location", "=", "response", ".", "headers", ".", "getRawHeaders", "(", "b'location'", ",", "[", "None", "]", ")", "[", "0", "]", "if", "location", "is", "not", ...
Get the Location: if there is one.
[ "Get", "the", "Location", ":", "if", "there", "is", "one", "." ]
train
https://github.com/twisted/txacme/blob/9478381cc63c6d53d14bf8db8407c923f472989a/src/txacme/client.py#L164-L171
twisted/txacme
src/txacme/client.py
Client._maybe_registered
def _maybe_registered(self, failure, new_reg): """ If the registration already exists, we should just load it. """ failure.trap(ServerError) response = failure.value.response if response.code == http.CONFLICT: reg = new_reg.update( resource=mes...
python
def _maybe_registered(self, failure, new_reg): """ If the registration already exists, we should just load it. """ failure.trap(ServerError) response = failure.value.response if response.code == http.CONFLICT: reg = new_reg.update( resource=mes...
[ "def", "_maybe_registered", "(", "self", ",", "failure", ",", "new_reg", ")", ":", "failure", ".", "trap", "(", "ServerError", ")", "response", "=", "failure", ".", "value", ".", "response", "if", "response", ".", "code", "==", "http", ".", "CONFLICT", "...
If the registration already exists, we should just load it.
[ "If", "the", "registration", "already", "exists", "we", "should", "just", "load", "it", "." ]
train
https://github.com/twisted/txacme/blob/9478381cc63c6d53d14bf8db8407c923f472989a/src/txacme/client.py#L173-L184
twisted/txacme
src/txacme/client.py
Client.agree_to_tos
def agree_to_tos(self, regr): """ Accept the terms-of-service for a registration. :param ~acme.messages.RegistrationResource regr: The registration to update. :return: The updated registration resource. :rtype: Deferred[`~acme.messages.RegistrationResource`] ...
python
def agree_to_tos(self, regr): """ Accept the terms-of-service for a registration. :param ~acme.messages.RegistrationResource regr: The registration to update. :return: The updated registration resource. :rtype: Deferred[`~acme.messages.RegistrationResource`] ...
[ "def", "agree_to_tos", "(", "self", ",", "regr", ")", ":", "return", "self", ".", "update_registration", "(", "regr", ".", "update", "(", "body", "=", "regr", ".", "body", ".", "update", "(", "agreement", "=", "regr", ".", "terms_of_service", ")", ")", ...
Accept the terms-of-service for a registration. :param ~acme.messages.RegistrationResource regr: The registration to update. :return: The updated registration resource. :rtype: Deferred[`~acme.messages.RegistrationResource`]
[ "Accept", "the", "terms", "-", "of", "-", "service", "for", "a", "registration", "." ]
train
https://github.com/twisted/txacme/blob/9478381cc63c6d53d14bf8db8407c923f472989a/src/txacme/client.py#L186-L199
twisted/txacme
src/txacme/client.py
Client.update_registration
def update_registration(self, regr, uri=None): """ Submit a registration to the server to update it. :param ~acme.messages.RegistrationResource regr: The registration to update. Can be a :class:`~acme.messages.NewRegistration` instead, in order to create a new registrat...
python
def update_registration(self, regr, uri=None): """ Submit a registration to the server to update it. :param ~acme.messages.RegistrationResource regr: The registration to update. Can be a :class:`~acme.messages.NewRegistration` instead, in order to create a new registrat...
[ "def", "update_registration", "(", "self", ",", "regr", ",", "uri", "=", "None", ")", ":", "if", "uri", "is", "None", ":", "uri", "=", "regr", ".", "uri", "if", "isinstance", "(", "regr", ",", "messages", ".", "RegistrationResource", ")", ":", "message...
Submit a registration to the server to update it. :param ~acme.messages.RegistrationResource regr: The registration to update. Can be a :class:`~acme.messages.NewRegistration` instead, in order to create a new registration. :param str uri: The url to submit to. Must be ...
[ "Submit", "a", "registration", "to", "the", "server", "to", "update", "it", "." ]
train
https://github.com/twisted/txacme/blob/9478381cc63c6d53d14bf8db8407c923f472989a/src/txacme/client.py#L201-L228
twisted/txacme
src/txacme/client.py
Client._parse_regr_response
def _parse_regr_response(self, response, uri=None, new_authzr_uri=None, terms_of_service=None): """ Parse a registration response from the server. """ links = _parse_header_links(response) if u'terms-of-service' in links: terms_of_service ...
python
def _parse_regr_response(self, response, uri=None, new_authzr_uri=None, terms_of_service=None): """ Parse a registration response from the server. """ links = _parse_header_links(response) if u'terms-of-service' in links: terms_of_service ...
[ "def", "_parse_regr_response", "(", "self", ",", "response", ",", "uri", "=", "None", ",", "new_authzr_uri", "=", "None", ",", "terms_of_service", "=", "None", ")", ":", "links", "=", "_parse_header_links", "(", "response", ")", "if", "u'terms-of-service'", "i...
Parse a registration response from the server.
[ "Parse", "a", "registration", "response", "from", "the", "server", "." ]
train
https://github.com/twisted/txacme/blob/9478381cc63c6d53d14bf8db8407c923f472989a/src/txacme/client.py#L230-L251
twisted/txacme
src/txacme/client.py
Client._check_regr
def _check_regr(self, regr, new_reg): """ Check that a registration response contains the registration we were expecting. """ body = getattr(new_reg, 'body', new_reg) for k, v in body.items(): if k == 'resource' or not v: continue i...
python
def _check_regr(self, regr, new_reg): """ Check that a registration response contains the registration we were expecting. """ body = getattr(new_reg, 'body', new_reg) for k, v in body.items(): if k == 'resource' or not v: continue i...
[ "def", "_check_regr", "(", "self", ",", "regr", ",", "new_reg", ")", ":", "body", "=", "getattr", "(", "new_reg", ",", "'body'", ",", "new_reg", ")", "for", "k", ",", "v", "in", "body", ".", "items", "(", ")", ":", "if", "k", "==", "'resource'", ...
Check that a registration response contains the registration we were expecting.
[ "Check", "that", "a", "registration", "response", "contains", "the", "registration", "we", "were", "expecting", "." ]
train
https://github.com/twisted/txacme/blob/9478381cc63c6d53d14bf8db8407c923f472989a/src/txacme/client.py#L253-L266
twisted/txacme
src/txacme/client.py
Client.request_challenges
def request_challenges(self, identifier): """ Create a new authorization. :param ~acme.messages.Identifier identifier: The identifier to authorize. :return: The new authorization resource. :rtype: Deferred[`~acme.messages.AuthorizationResource`] """ ...
python
def request_challenges(self, identifier): """ Create a new authorization. :param ~acme.messages.Identifier identifier: The identifier to authorize. :return: The new authorization resource. :rtype: Deferred[`~acme.messages.AuthorizationResource`] """ ...
[ "def", "request_challenges", "(", "self", ",", "identifier", ")", ":", "action", "=", "LOG_ACME_CREATE_AUTHORIZATION", "(", "identifier", "=", "identifier", ")", "with", "action", ".", "context", "(", ")", ":", "message", "=", "messages", ".", "NewAuthorization"...
Create a new authorization. :param ~acme.messages.Identifier identifier: The identifier to authorize. :return: The new authorization resource. :rtype: Deferred[`~acme.messages.AuthorizationResource`]
[ "Create", "a", "new", "authorization", "." ]
train
https://github.com/twisted/txacme/blob/9478381cc63c6d53d14bf8db8407c923f472989a/src/txacme/client.py#L268-L289
twisted/txacme
src/txacme/client.py
Client._expect_response
def _expect_response(cls, response, code): """ Ensure we got the expected response code. """ if response.code != code: raise errors.ClientError( 'Expected {!r} response but got {!r}'.format( code, response.code)) return response
python
def _expect_response(cls, response, code): """ Ensure we got the expected response code. """ if response.code != code: raise errors.ClientError( 'Expected {!r} response but got {!r}'.format( code, response.code)) return response
[ "def", "_expect_response", "(", "cls", ",", "response", ",", "code", ")", ":", "if", "response", ".", "code", "!=", "code", ":", "raise", "errors", ".", "ClientError", "(", "'Expected {!r} response but got {!r}'", ".", "format", "(", "code", ",", "response", ...
Ensure we got the expected response code.
[ "Ensure", "we", "got", "the", "expected", "response", "code", "." ]
train
https://github.com/twisted/txacme/blob/9478381cc63c6d53d14bf8db8407c923f472989a/src/txacme/client.py#L292-L300