repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
sgaynetdinov/py-vkontakte
vk/auth.py
get_url_authcode_flow_user
def get_url_authcode_flow_user(client_id, redirect_uri, display="page", scope=None, state=None): """Authorization Code Flow for User Access Token Use Authorization Code Flow to run VK API methods from the server side of an application. Access token received this way is not bound to an ip address but set of...
python
def get_url_authcode_flow_user(client_id, redirect_uri, display="page", scope=None, state=None): """Authorization Code Flow for User Access Token Use Authorization Code Flow to run VK API methods from the server side of an application. Access token received this way is not bound to an ip address but set of...
[ "def", "get_url_authcode_flow_user", "(", "client_id", ",", "redirect_uri", ",", "display", "=", "\"page\"", ",", "scope", "=", "None", ",", "state", "=", "None", ")", ":", "url", "=", "\"https://oauth.vk.com/authorize\"", "params", "=", "{", "\"client_id\"", ":...
Authorization Code Flow for User Access Token Use Authorization Code Flow to run VK API methods from the server side of an application. Access token received this way is not bound to an ip address but set of permissions that can be granted is limited for security reasons. Args: client_id (int): Ap...
[ "Authorization", "Code", "Flow", "for", "User", "Access", "Token" ]
c09654f89008b5847418bb66f1f9c408cd7aa128
https://github.com/sgaynetdinov/py-vkontakte/blob/c09654f89008b5847418bb66f1f9c408cd7aa128/vk/auth.py#L35-L76
train
Spinmob/spinmob
egg/example_from_wiki.py
get_fake_data
def get_fake_data(*a): """ Called whenever someone presses the "fire" button. """ # add columns of data to the databox d['x'] = _n.linspace(0,10,100) d['y'] = _n.cos(d['x']) + 0.1*_n.random.rand(100) # update the curve c.setData(d['x'], d['y'])
python
def get_fake_data(*a): """ Called whenever someone presses the "fire" button. """ # add columns of data to the databox d['x'] = _n.linspace(0,10,100) d['y'] = _n.cos(d['x']) + 0.1*_n.random.rand(100) # update the curve c.setData(d['x'], d['y'])
[ "def", "get_fake_data", "(", "*", "a", ")", ":", "d", "[", "'x'", "]", "=", "_n", ".", "linspace", "(", "0", ",", "10", ",", "100", ")", "d", "[", "'y'", "]", "=", "_n", ".", "cos", "(", "d", "[", "'x'", "]", ")", "+", "0.1", "*", "_n", ...
Called whenever someone presses the "fire" button.
[ "Called", "whenever", "someone", "presses", "the", "fire", "button", "." ]
f037f5df07f194bcd4a01f4d9916e57b9e8fb45a
https://github.com/Spinmob/spinmob/blob/f037f5df07f194bcd4a01f4d9916e57b9e8fb45a/egg/example_from_wiki.py#L49-L58
train
Spinmob/spinmob
egg/_temporary_fixes.py
SpinBox.selectNumber
def selectNumber(self): """ Select the numerical portion of the text to allow quick editing by the user. """ le = self.lineEdit() text = asUnicode(le.text()) if self.opts['suffix'] == '': le.setSelection(0, len(text)) else: try: ...
python
def selectNumber(self): """ Select the numerical portion of the text to allow quick editing by the user. """ le = self.lineEdit() text = asUnicode(le.text()) if self.opts['suffix'] == '': le.setSelection(0, len(text)) else: try: ...
[ "def", "selectNumber", "(", "self", ")", ":", "le", "=", "self", ".", "lineEdit", "(", ")", "text", "=", "asUnicode", "(", "le", ".", "text", "(", ")", ")", "if", "self", ".", "opts", "[", "'suffix'", "]", "==", "''", ":", "le", ".", "setSelectio...
Select the numerical portion of the text to allow quick editing by the user.
[ "Select", "the", "numerical", "portion", "of", "the", "text", "to", "allow", "quick", "editing", "by", "the", "user", "." ]
f037f5df07f194bcd4a01f4d9916e57b9e8fb45a
https://github.com/Spinmob/spinmob/blob/f037f5df07f194bcd4a01f4d9916e57b9e8fb45a/egg/_temporary_fixes.py#L236-L249
train
Spinmob/spinmob
egg/_temporary_fixes.py
SpinBox.value
def value(self): """ Return the value of this SpinBox. """ if self.opts['int']: return int(self.val) else: return float(self.val)
python
def value(self): """ Return the value of this SpinBox. """ if self.opts['int']: return int(self.val) else: return float(self.val)
[ "def", "value", "(", "self", ")", ":", "if", "self", ".", "opts", "[", "'int'", "]", ":", "return", "int", "(", "self", ".", "val", ")", "else", ":", "return", "float", "(", "self", ".", "val", ")" ]
Return the value of this SpinBox.
[ "Return", "the", "value", "of", "this", "SpinBox", "." ]
f037f5df07f194bcd4a01f4d9916e57b9e8fb45a
https://github.com/Spinmob/spinmob/blob/f037f5df07f194bcd4a01f4d9916e57b9e8fb45a/egg/_temporary_fixes.py#L251-L259
train
Spinmob/spinmob
egg/_temporary_fixes.py
SpinBox.interpret
def interpret(self): """Return value of text. Return False if text is invalid, raise exception if text is intermediate""" strn = self.lineEdit().text() suf = self.opts['suffix'] if len(suf) > 0: if strn[-len(suf):] != suf: return False #raise Excep...
python
def interpret(self): """Return value of text. Return False if text is invalid, raise exception if text is intermediate""" strn = self.lineEdit().text() suf = self.opts['suffix'] if len(suf) > 0: if strn[-len(suf):] != suf: return False #raise Excep...
[ "def", "interpret", "(", "self", ")", ":", "strn", "=", "self", ".", "lineEdit", "(", ")", ".", "text", "(", ")", "suf", "=", "self", ".", "opts", "[", "'suffix'", "]", "if", "len", "(", "suf", ")", ">", "0", ":", "if", "strn", "[", "-", "len...
Return value of text. Return False if text is invalid, raise exception if text is intermediate
[ "Return", "value", "of", "text", ".", "Return", "False", "if", "text", "is", "invalid", "raise", "exception", "if", "text", "is", "intermediate" ]
f037f5df07f194bcd4a01f4d9916e57b9e8fb45a
https://github.com/Spinmob/spinmob/blob/f037f5df07f194bcd4a01f4d9916e57b9e8fb45a/egg/_temporary_fixes.py#L473-L489
train
Spinmob/spinmob
egg/_temporary_fixes.py
SpinBox.editingFinishedEvent
def editingFinishedEvent(self): """Edit has finished; set value.""" #print "Edit finished." if asUnicode(self.lineEdit().text()) == self.lastText: #print "no text change." return try: val = self.interpret() except: return ...
python
def editingFinishedEvent(self): """Edit has finished; set value.""" #print "Edit finished." if asUnicode(self.lineEdit().text()) == self.lastText: #print "no text change." return try: val = self.interpret() except: return ...
[ "def", "editingFinishedEvent", "(", "self", ")", ":", "if", "asUnicode", "(", "self", ".", "lineEdit", "(", ")", ".", "text", "(", ")", ")", "==", "self", ".", "lastText", ":", "return", "try", ":", "val", "=", "self", ".", "interpret", "(", ")", "...
Edit has finished; set value.
[ "Edit", "has", "finished", ";", "set", "value", "." ]
f037f5df07f194bcd4a01f4d9916e57b9e8fb45a
https://github.com/Spinmob/spinmob/blob/f037f5df07f194bcd4a01f4d9916e57b9e8fb45a/egg/_temporary_fixes.py#L499-L516
train
sbaechler/django-scaffolding
scaffolding/management/commands/scaffold.py
Command.make_factory
def make_factory(self, cls, count): """ Get the generators from the Scaffolding class within the model. """ field_names = cls._meta.get_all_field_names() fields = {} text = [] finalizer = None scaffold = scaffolding.scaffold_for_model(cls) for field_name ...
python
def make_factory(self, cls, count): """ Get the generators from the Scaffolding class within the model. """ field_names = cls._meta.get_all_field_names() fields = {} text = [] finalizer = None scaffold = scaffolding.scaffold_for_model(cls) for field_name ...
[ "def", "make_factory", "(", "self", ",", "cls", ",", "count", ")", ":", "field_names", "=", "cls", ".", "_meta", ".", "get_all_field_names", "(", ")", "fields", "=", "{", "}", "text", "=", "[", "]", "finalizer", "=", "None", "scaffold", "=", "scaffoldi...
Get the generators from the Scaffolding class within the model.
[ "Get", "the", "generators", "from", "the", "Scaffolding", "class", "within", "the", "model", "." ]
db78d99efe4fa1f3ef452fd0afd55fcdfdaea6db
https://github.com/sbaechler/django-scaffolding/blob/db78d99efe4fa1f3ef452fd0afd55fcdfdaea6db/scaffolding/management/commands/scaffold.py#L42-L66
train
KarchinLab/probabilistic2020
prob2020/python/indel.py
compute_indel_length
def compute_indel_length(fs_df): """Computes the indel length accounting for wether it is an insertion or deletion. Parameters ---------- fs_df : pd.DataFrame mutation input as dataframe only containing indel mutations Returns ------- indel_len : pd.Series length of ind...
python
def compute_indel_length(fs_df): """Computes the indel length accounting for wether it is an insertion or deletion. Parameters ---------- fs_df : pd.DataFrame mutation input as dataframe only containing indel mutations Returns ------- indel_len : pd.Series length of ind...
[ "def", "compute_indel_length", "(", "fs_df", ")", ":", "indel_len", "=", "pd", ".", "Series", "(", "index", "=", "fs_df", ".", "index", ")", "indel_len", "[", "fs_df", "[", "'Reference_Allele'", "]", "==", "'-'", "]", "=", "fs_df", "[", "'Tumor_Allele'", ...
Computes the indel length accounting for wether it is an insertion or deletion. Parameters ---------- fs_df : pd.DataFrame mutation input as dataframe only containing indel mutations Returns ------- indel_len : pd.Series length of indels
[ "Computes", "the", "indel", "length", "accounting", "for", "wether", "it", "is", "an", "insertion", "or", "deletion", "." ]
5d70583b0a7c07cfe32e95f3a70e05df412acb84
https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/indel.py#L125-L143
train
KarchinLab/probabilistic2020
prob2020/python/indel.py
keep_indels
def keep_indels(mut_df, indel_len_col=True, indel_type_col=True): """Filters out all mutations that are not indels. Requires that one of the alleles have '-' indicating either an insertion or deletion depending if found in reference allele or somatic allele columns, resp...
python
def keep_indels(mut_df, indel_len_col=True, indel_type_col=True): """Filters out all mutations that are not indels. Requires that one of the alleles have '-' indicating either an insertion or deletion depending if found in reference allele or somatic allele columns, resp...
[ "def", "keep_indels", "(", "mut_df", ",", "indel_len_col", "=", "True", ",", "indel_type_col", "=", "True", ")", ":", "mut_df", "=", "mut_df", "[", "is_indel_annotation", "(", "mut_df", ")", "]", "if", "indel_len_col", ":", "mut_df", ".", "loc", "[", ":", ...
Filters out all mutations that are not indels. Requires that one of the alleles have '-' indicating either an insertion or deletion depending if found in reference allele or somatic allele columns, respectively. Parameters ---------- mut_df : pd.DataFrame mutation input file as a dataf...
[ "Filters", "out", "all", "mutations", "that", "are", "not", "indels", "." ]
5d70583b0a7c07cfe32e95f3a70e05df412acb84
https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/indel.py#L146-L181
train
KarchinLab/probabilistic2020
prob2020/python/indel.py
keep_frameshifts
def keep_frameshifts(mut_df, indel_len_col=True): """Filters out all mutations that are not frameshift indels. Requires that one of the alleles have '-' indicating either an insertion or deletion depending if found in reference allele or somatic allele columns, respectively. P...
python
def keep_frameshifts(mut_df, indel_len_col=True): """Filters out all mutations that are not frameshift indels. Requires that one of the alleles have '-' indicating either an insertion or deletion depending if found in reference allele or somatic allele columns, respectively. P...
[ "def", "keep_frameshifts", "(", "mut_df", ",", "indel_len_col", "=", "True", ")", ":", "mut_df", "=", "mut_df", "[", "is_frameshift_annotation", "(", "mut_df", ")", "]", "if", "indel_len_col", ":", "mut_df", ".", "loc", "[", ":", ",", "'indel len'", "]", "...
Filters out all mutations that are not frameshift indels. Requires that one of the alleles have '-' indicating either an insertion or deletion depending if found in reference allele or somatic allele columns, respectively. Parameters ---------- mut_df : pd.DataFrame mutation input file...
[ "Filters", "out", "all", "mutations", "that", "are", "not", "frameshift", "indels", "." ]
5d70583b0a7c07cfe32e95f3a70e05df412acb84
https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/indel.py#L184-L210
train
KarchinLab/probabilistic2020
prob2020/python/indel.py
is_frameshift_len
def is_frameshift_len(mut_df): """Simply returns a series indicating whether each corresponding mutation is a frameshift. This is based on the length of the indel. Thus may be fooled by frameshifts at exon-intron boundaries or other odd cases. Parameters ---------- mut_df : pd.DataFrame ...
python
def is_frameshift_len(mut_df): """Simply returns a series indicating whether each corresponding mutation is a frameshift. This is based on the length of the indel. Thus may be fooled by frameshifts at exon-intron boundaries or other odd cases. Parameters ---------- mut_df : pd.DataFrame ...
[ "def", "is_frameshift_len", "(", "mut_df", ")", ":", "if", "'indel len'", "in", "mut_df", ".", "columns", ":", "indel_len", "=", "mut_df", "[", "'indel len'", "]", "else", ":", "indel_len", "=", "compute_indel_length", "(", "mut_df", ")", "is_fs", "=", "(", ...
Simply returns a series indicating whether each corresponding mutation is a frameshift. This is based on the length of the indel. Thus may be fooled by frameshifts at exon-intron boundaries or other odd cases. Parameters ---------- mut_df : pd.DataFrame mutation input file as a datafra...
[ "Simply", "returns", "a", "series", "indicating", "whether", "each", "corresponding", "mutation", "is", "a", "frameshift", "." ]
5d70583b0a7c07cfe32e95f3a70e05df412acb84
https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/indel.py#L213-L243
train
KarchinLab/probabilistic2020
prob2020/python/indel.py
get_frameshift_lengths
def get_frameshift_lengths(num_bins): """Simple function that returns the lengths for each frameshift category if `num_bins` number of frameshift categories are requested. """ fs_len = [] i = 1 tmp_bins = 0 while(tmp_bins<num_bins): if i%3: fs_len.append(i) tm...
python
def get_frameshift_lengths(num_bins): """Simple function that returns the lengths for each frameshift category if `num_bins` number of frameshift categories are requested. """ fs_len = [] i = 1 tmp_bins = 0 while(tmp_bins<num_bins): if i%3: fs_len.append(i) tm...
[ "def", "get_frameshift_lengths", "(", "num_bins", ")", ":", "fs_len", "=", "[", "]", "i", "=", "1", "tmp_bins", "=", "0", "while", "(", "tmp_bins", "<", "num_bins", ")", ":", "if", "i", "%", "3", ":", "fs_len", ".", "append", "(", "i", ")", "tmp_bi...
Simple function that returns the lengths for each frameshift category if `num_bins` number of frameshift categories are requested.
[ "Simple", "function", "that", "returns", "the", "lengths", "for", "each", "frameshift", "category", "if", "num_bins", "number", "of", "frameshift", "categories", "are", "requested", "." ]
5d70583b0a7c07cfe32e95f3a70e05df412acb84
https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/indel.py#L289-L301
train
KarchinLab/probabilistic2020
prob2020/python/sequence_context.py
SequenceContext.random_context_pos
def random_context_pos(self, num, num_permutations, context): """Samples with replacement available positions matching the sequence context. Note: this method does random sampling only for an individual sequence context. Parameters ---------- num : int ...
python
def random_context_pos(self, num, num_permutations, context): """Samples with replacement available positions matching the sequence context. Note: this method does random sampling only for an individual sequence context. Parameters ---------- num : int ...
[ "def", "random_context_pos", "(", "self", ",", "num", ",", "num_permutations", ",", "context", ")", ":", "if", "not", "self", ".", "is_valid_context", "(", "context", ")", ":", "error_msg", "=", "'Context ({0}) was never seen in sequence.'", ".", "format", "(", ...
Samples with replacement available positions matching the sequence context. Note: this method does random sampling only for an individual sequence context. Parameters ---------- num : int Number of positions to sample for each permutation. This i...
[ "Samples", "with", "replacement", "available", "positions", "matching", "the", "sequence", "context", "." ]
5d70583b0a7c07cfe32e95f3a70e05df412acb84
https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/sequence_context.py#L167-L205
train
KarchinLab/probabilistic2020
prob2020/python/scores.py
retrieve_scores
def retrieve_scores(gname, sdir, codon_pos, germ_aa, somatic_aa, default_mga=5., default_vest=0, no_file_flag=-1): """Retrieves scores from pickle files. Used by summary script. """ # get variant types #var_class = cutils.get_variant_clas...
python
def retrieve_scores(gname, sdir, codon_pos, germ_aa, somatic_aa, default_mga=5., default_vest=0, no_file_flag=-1): """Retrieves scores from pickle files. Used by summary script. """ # get variant types #var_class = cutils.get_variant_clas...
[ "def", "retrieve_scores", "(", "gname", ",", "sdir", ",", "codon_pos", ",", "germ_aa", ",", "somatic_aa", ",", "default_mga", "=", "5.", ",", "default_vest", "=", "0", ",", "no_file_flag", "=", "-", "1", ")", ":", "mga_path", "=", "os", ".", "path", "....
Retrieves scores from pickle files. Used by summary script.
[ "Retrieves", "scores", "from", "pickle", "files", "." ]
5d70583b0a7c07cfe32e95f3a70e05df412acb84
https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/scores.py#L15-L79
train
KarchinLab/probabilistic2020
prob2020/python/scores.py
read_vest_pickle
def read_vest_pickle(gname, score_dir): """Read in VEST scores for given gene. Parameters ---------- gname : str name of gene score_dir : str directory containing vest scores Returns ------- gene_vest : dict or None dict containing vest scores for gene. Returns ...
python
def read_vest_pickle(gname, score_dir): """Read in VEST scores for given gene. Parameters ---------- gname : str name of gene score_dir : str directory containing vest scores Returns ------- gene_vest : dict or None dict containing vest scores for gene. Returns ...
[ "def", "read_vest_pickle", "(", "gname", ",", "score_dir", ")", ":", "vest_path", "=", "os", ".", "path", ".", "join", "(", "score_dir", ",", "gname", "+", "\".vest.pickle\"", ")", "if", "os", ".", "path", ".", "exists", "(", "vest_path", ")", ":", "if...
Read in VEST scores for given gene. Parameters ---------- gname : str name of gene score_dir : str directory containing vest scores Returns ------- gene_vest : dict or None dict containing vest scores for gene. Returns None if not found.
[ "Read", "in", "VEST", "scores", "for", "given", "gene", "." ]
5d70583b0a7c07cfe32e95f3a70e05df412acb84
https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/scores.py#L82-L107
train
KarchinLab/probabilistic2020
prob2020/python/scores.py
compute_vest_stat
def compute_vest_stat(vest_dict, ref_aa, somatic_aa, codon_pos, stat_func=np.mean, default_val=0.0): """Compute missense VEST score statistic. Note: non-missense mutations are intentially not filtered out and will take a default value of zero. Parameters ...
python
def compute_vest_stat(vest_dict, ref_aa, somatic_aa, codon_pos, stat_func=np.mean, default_val=0.0): """Compute missense VEST score statistic. Note: non-missense mutations are intentially not filtered out and will take a default value of zero. Parameters ...
[ "def", "compute_vest_stat", "(", "vest_dict", ",", "ref_aa", ",", "somatic_aa", ",", "codon_pos", ",", "stat_func", "=", "np", ".", "mean", ",", "default_val", "=", "0.0", ")", ":", "if", "vest_dict", "is", "None", ":", "return", "default_val", "myscores", ...
Compute missense VEST score statistic. Note: non-missense mutations are intentially not filtered out and will take a default value of zero. Parameters ---------- vest_dict : dict dictionary containing vest scores across the gene of interest ref_aa: list of str list of reference...
[ "Compute", "missense", "VEST", "score", "statistic", "." ]
5d70583b0a7c07cfe32e95f3a70e05df412acb84
https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/scores.py#L110-L151
train
KarchinLab/probabilistic2020
prob2020/python/scores.py
compute_mga_entropy_stat
def compute_mga_entropy_stat(mga_vec, codon_pos, stat_func=np.mean, default_val=0.0): """Compute MGA entropy conservation statistic Parameters ---------- mga_vec : np.array numpy vector containing MGA Entropy conservation scores for resi...
python
def compute_mga_entropy_stat(mga_vec, codon_pos, stat_func=np.mean, default_val=0.0): """Compute MGA entropy conservation statistic Parameters ---------- mga_vec : np.array numpy vector containing MGA Entropy conservation scores for resi...
[ "def", "compute_mga_entropy_stat", "(", "mga_vec", ",", "codon_pos", ",", "stat_func", "=", "np", ".", "mean", ",", "default_val", "=", "0.0", ")", ":", "if", "mga_vec", "is", "None", ":", "return", "default_val", "myscores", "=", "fetch_mga_scores", "(", "m...
Compute MGA entropy conservation statistic Parameters ---------- mga_vec : np.array numpy vector containing MGA Entropy conservation scores for residues codon_pos : list of int position of codon in protein sequence stat_func : function, default=np.mean function that calculat...
[ "Compute", "MGA", "entropy", "conservation", "statistic" ]
5d70583b0a7c07cfe32e95f3a70e05df412acb84
https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/scores.py#L154-L188
train
KarchinLab/probabilistic2020
prob2020/python/scores.py
fetch_vest_scores
def fetch_vest_scores(vest_dict, ref_aa, somatic_aa, codon_pos, default_vest=0.0): """Get VEST scores from pre-computed scores in dictionary. Note: either all mutations should be missense or non-missense intended to have value equal to default. Parameters ...
python
def fetch_vest_scores(vest_dict, ref_aa, somatic_aa, codon_pos, default_vest=0.0): """Get VEST scores from pre-computed scores in dictionary. Note: either all mutations should be missense or non-missense intended to have value equal to default. Parameters ...
[ "def", "fetch_vest_scores", "(", "vest_dict", ",", "ref_aa", ",", "somatic_aa", ",", "codon_pos", ",", "default_vest", "=", "0.0", ")", ":", "vest_score_list", "=", "[", "]", "for", "i", "in", "range", "(", "len", "(", "somatic_aa", ")", ")", ":", "if", ...
Get VEST scores from pre-computed scores in dictionary. Note: either all mutations should be missense or non-missense intended to have value equal to default. Parameters ---------- vest_dict : dict dictionary containing vest scores across the gene of interest ref_aa: list of str ...
[ "Get", "VEST", "scores", "from", "pre", "-", "computed", "scores", "in", "dictionary", "." ]
5d70583b0a7c07cfe32e95f3a70e05df412acb84
https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/scores.py#L191-L225
train
KarchinLab/probabilistic2020
prob2020/python/scores.py
fetch_mga_scores
def fetch_mga_scores(mga_vec, codon_pos, default_mga=None): """Get MGAEntropy scores from pre-computed scores in array. Parameters ---------- mga_vec : np.array numpy vector containing MGA Entropy conservation scores for residues codon_pos: list of ...
python
def fetch_mga_scores(mga_vec, codon_pos, default_mga=None): """Get MGAEntropy scores from pre-computed scores in array. Parameters ---------- mga_vec : np.array numpy vector containing MGA Entropy conservation scores for residues codon_pos: list of ...
[ "def", "fetch_mga_scores", "(", "mga_vec", ",", "codon_pos", ",", "default_mga", "=", "None", ")", ":", "len_mga", "=", "len", "(", "mga_vec", ")", "good_codon_pos", "=", "[", "p", "for", "p", "in", "codon_pos", "if", "p", "<", "len_mga", "]", "if", "g...
Get MGAEntropy scores from pre-computed scores in array. Parameters ---------- mga_vec : np.array numpy vector containing MGA Entropy conservation scores for residues codon_pos: list of int position of codon in protein sequence default_mga: float or None, default=None value ...
[ "Get", "MGAEntropy", "scores", "from", "pre", "-", "computed", "scores", "in", "array", "." ]
5d70583b0a7c07cfe32e95f3a70e05df412acb84
https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/scores.py#L228-L258
train
KarchinLab/probabilistic2020
prob2020/python/scores.py
read_neighbor_graph_pickle
def read_neighbor_graph_pickle(gname, graph_dir): """Read in neighbor graph for given gene. Parameters ---------- gname : str name of gene graph_dir : str directory containing gene graphs Returns ------- gene_graph : dict or None neighbor graph as dict for gene....
python
def read_neighbor_graph_pickle(gname, graph_dir): """Read in neighbor graph for given gene. Parameters ---------- gname : str name of gene graph_dir : str directory containing gene graphs Returns ------- gene_graph : dict or None neighbor graph as dict for gene....
[ "def", "read_neighbor_graph_pickle", "(", "gname", ",", "graph_dir", ")", ":", "graph_path", "=", "os", ".", "path", ".", "join", "(", "graph_dir", ",", "gname", "+", "\".pickle\"", ")", "if", "os", ".", "path", ".", "exists", "(", "graph_path", ")", ":"...
Read in neighbor graph for given gene. Parameters ---------- gname : str name of gene graph_dir : str directory containing gene graphs Returns ------- gene_graph : dict or None neighbor graph as dict for gene. Returns None if not found.
[ "Read", "in", "neighbor", "graph", "for", "given", "gene", "." ]
5d70583b0a7c07cfe32e95f3a70e05df412acb84
https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/scores.py#L261-L282
train
KarchinLab/probabilistic2020
prob2020/python/scores.py
compute_ng_stat
def compute_ng_stat(gene_graph, pos_ct, alpha=.5): """Compute the clustering score for the gene on its neighbor graph. Parameters ---------- gene_graph : dict Graph of spatially near codons. keys = nodes, edges = key -> value. pos_ct : dict missense mutation count for each codon ...
python
def compute_ng_stat(gene_graph, pos_ct, alpha=.5): """Compute the clustering score for the gene on its neighbor graph. Parameters ---------- gene_graph : dict Graph of spatially near codons. keys = nodes, edges = key -> value. pos_ct : dict missense mutation count for each codon ...
[ "def", "compute_ng_stat", "(", "gene_graph", ",", "pos_ct", ",", "alpha", "=", ".5", ")", ":", "if", "not", "len", "(", "pos_ct", ")", ":", "return", "1.0", ",", "0", "max_pos", "=", "max", "(", "gene_graph", ")", "codon_vals", "=", "np", ".", "zeros...
Compute the clustering score for the gene on its neighbor graph. Parameters ---------- gene_graph : dict Graph of spatially near codons. keys = nodes, edges = key -> value. pos_ct : dict missense mutation count for each codon alpha : float smoothing factor Returns -...
[ "Compute", "the", "clustering", "score", "for", "the", "gene", "on", "its", "neighbor", "graph", "." ]
5d70583b0a7c07cfe32e95f3a70e05df412acb84
https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/scores.py#L285-L334
train
KarchinLab/probabilistic2020
prob2020/python/count_frameshifts.py
count_frameshift_total
def count_frameshift_total(mut_df, bed_path, use_unmapped=False, to_zero_based=False): """Count frameshifts for each gene. Parameters ---------- mut_df : pd.DataFrame mutation input bed_path : str path ...
python
def count_frameshift_total(mut_df, bed_path, use_unmapped=False, to_zero_based=False): """Count frameshifts for each gene. Parameters ---------- mut_df : pd.DataFrame mutation input bed_path : str path ...
[ "def", "count_frameshift_total", "(", "mut_df", ",", "bed_path", ",", "use_unmapped", "=", "False", ",", "to_zero_based", "=", "False", ")", ":", "if", "to_zero_based", ":", "mut_df", "[", "'Start_Position'", "]", "=", "mut_df", "[", "'Start_Position'", "]", "...
Count frameshifts for each gene. Parameters ---------- mut_df : pd.DataFrame mutation input bed_path : str path to BED file containing reference tx for genes use_unmapped : Bool flag indicating whether to include frameshifts not mapping to reference tx to_zero_ba...
[ "Count", "frameshifts", "for", "each", "gene", "." ]
5d70583b0a7c07cfe32e95f3a70e05df412acb84
https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/count_frameshifts.py#L6-L64
train
KarchinLab/probabilistic2020
prob2020/python/gene_sequence.py
_fetch_3ss_fasta
def _fetch_3ss_fasta(fasta, gene_name, exon_num, chrom, strand, start, end): """Retreives the 3' SS sequence flanking the specified exon. Returns a string in fasta format with the first line containing a ">" and the second line contains the two base pairs of 3' SS. Parameters ...
python
def _fetch_3ss_fasta(fasta, gene_name, exon_num, chrom, strand, start, end): """Retreives the 3' SS sequence flanking the specified exon. Returns a string in fasta format with the first line containing a ">" and the second line contains the two base pairs of 3' SS. Parameters ...
[ "def", "_fetch_3ss_fasta", "(", "fasta", ",", "gene_name", ",", "exon_num", ",", "chrom", ",", "strand", ",", "start", ",", "end", ")", ":", "if", "strand", "==", "'-'", ":", "ss_seq", "=", "fasta", ".", "fetch", "(", "reference", "=", "chrom", ",", ...
Retreives the 3' SS sequence flanking the specified exon. Returns a string in fasta format with the first line containing a ">" and the second line contains the two base pairs of 3' SS. Parameters ---------- fasta : pysam.Fastafile fasta object from pysam gene_name : str gene n...
[ "Retreives", "the", "3", "SS", "sequence", "flanking", "the", "specified", "exon", "." ]
5d70583b0a7c07cfe32e95f3a70e05df412acb84
https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/gene_sequence.py#L153-L195
train
KarchinLab/probabilistic2020
prob2020/python/gene_sequence.py
fetch_gene_fasta
def fetch_gene_fasta(gene_bed, fasta_obj): """Retreive gene sequences in FASTA format. Parameters ---------- gene_bed : BedLine BedLine object representing a single gene fasta_obj : pysam.Fastafile fasta object for index retreival of sequence Returns ------- gene_fasta ...
python
def fetch_gene_fasta(gene_bed, fasta_obj): """Retreive gene sequences in FASTA format. Parameters ---------- gene_bed : BedLine BedLine object representing a single gene fasta_obj : pysam.Fastafile fasta object for index retreival of sequence Returns ------- gene_fasta ...
[ "def", "fetch_gene_fasta", "(", "gene_bed", ",", "fasta_obj", ")", ":", "gene_fasta", "=", "''", "strand", "=", "gene_bed", ".", "strand", "exons", "=", "gene_bed", ".", "get_exons", "(", ")", "if", "strand", "==", "'-'", ":", "exons", ".", "reverse", "(...
Retreive gene sequences in FASTA format. Parameters ---------- gene_bed : BedLine BedLine object representing a single gene fasta_obj : pysam.Fastafile fasta object for index retreival of sequence Returns ------- gene_fasta : str sequence of gene in FASTA format
[ "Retreive", "gene", "sequences", "in", "FASTA", "format", "." ]
5d70583b0a7c07cfe32e95f3a70e05df412acb84
https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/gene_sequence.py#L198-L251
train
KarchinLab/probabilistic2020
prob2020/python/gene_sequence.py
GeneSequence._reset_seq
def _reset_seq(self): """Updates attributes for gene represented in the self.bed attribute. Sequences are always upper case. """ exon_seq_list, five_ss_seq_list, three_ss_seq_list = self._fetch_seq() self.exon_seq = ''.join(exon_seq_list) self.three_prime_seq = three_ss_...
python
def _reset_seq(self): """Updates attributes for gene represented in the self.bed attribute. Sequences are always upper case. """ exon_seq_list, five_ss_seq_list, three_ss_seq_list = self._fetch_seq() self.exon_seq = ''.join(exon_seq_list) self.three_prime_seq = three_ss_...
[ "def", "_reset_seq", "(", "self", ")", ":", "exon_seq_list", ",", "five_ss_seq_list", ",", "three_ss_seq_list", "=", "self", ".", "_fetch_seq", "(", ")", "self", ".", "exon_seq", "=", "''", ".", "join", "(", "exon_seq_list", ")", "self", ".", "three_prime_se...
Updates attributes for gene represented in the self.bed attribute. Sequences are always upper case.
[ "Updates", "attributes", "for", "gene", "represented", "in", "the", "self", ".", "bed", "attribute", "." ]
5d70583b0a7c07cfe32e95f3a70e05df412acb84
https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/gene_sequence.py#L23-L32
train
KarchinLab/probabilistic2020
prob2020/python/gene_sequence.py
GeneSequence.add_germline_variants
def add_germline_variants(self, germline_nucs, coding_pos): """Add potential germline variants into the nucleotide sequence. Sequenced individuals may potentially have a SNP at a somatic mutation position. Therefore they may differ from the reference genome. This method updates the gene ...
python
def add_germline_variants(self, germline_nucs, coding_pos): """Add potential germline variants into the nucleotide sequence. Sequenced individuals may potentially have a SNP at a somatic mutation position. Therefore they may differ from the reference genome. This method updates the gene ...
[ "def", "add_germline_variants", "(", "self", ",", "germline_nucs", ",", "coding_pos", ")", ":", "if", "len", "(", "germline_nucs", ")", "!=", "len", "(", "coding_pos", ")", ":", "raise", "ValueError", "(", "'Each germline nucleotide should have a coding position'", ...
Add potential germline variants into the nucleotide sequence. Sequenced individuals may potentially have a SNP at a somatic mutation position. Therefore they may differ from the reference genome. This method updates the gene germline gene sequence to match the actual individual. Parame...
[ "Add", "potential", "germline", "variants", "into", "the", "nucleotide", "sequence", "." ]
5d70583b0a7c07cfe32e95f3a70e05df412acb84
https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/gene_sequence.py#L34-L60
train
KarchinLab/probabilistic2020
prob2020/python/gene_sequence.py
GeneSequence._to_upper
def _to_upper(self): """Convert sequences to upper case.""" self.exon_seq = self.exon_seq.upper() self.three_prime_seq = [s.upper() for s in self.three_prime_seq] self.five_prime_seq = [s.upper() for s in self.five_prime_seq]
python
def _to_upper(self): """Convert sequences to upper case.""" self.exon_seq = self.exon_seq.upper() self.three_prime_seq = [s.upper() for s in self.three_prime_seq] self.five_prime_seq = [s.upper() for s in self.five_prime_seq]
[ "def", "_to_upper", "(", "self", ")", ":", "self", ".", "exon_seq", "=", "self", ".", "exon_seq", ".", "upper", "(", ")", "self", ".", "three_prime_seq", "=", "[", "s", ".", "upper", "(", ")", "for", "s", "in", "self", ".", "three_prime_seq", "]", ...
Convert sequences to upper case.
[ "Convert", "sequences", "to", "upper", "case", "." ]
5d70583b0a7c07cfe32e95f3a70e05df412acb84
https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/gene_sequence.py#L62-L66
train
KarchinLab/probabilistic2020
prob2020/python/gene_sequence.py
GeneSequence._fetch_seq
def _fetch_seq(self): """Fetches gene sequence from PySAM fasta object. Returns ------- exons : list of str list of exon nucleotide sequences five_prime_ss : list of str list of 5' splice site sequences three_prime_ss : list of str lis...
python
def _fetch_seq(self): """Fetches gene sequence from PySAM fasta object. Returns ------- exons : list of str list of exon nucleotide sequences five_prime_ss : list of str list of 5' splice site sequences three_prime_ss : list of str lis...
[ "def", "_fetch_seq", "(", "self", ")", ":", "exons", "=", "[", "]", "three_prime_ss", "=", "[", "]", "five_prime_ss", "=", "[", "]", "num_exons", "=", "self", ".", "bed", ".", "get_num_exons", "(", ")", "for", "i", "in", "range", "(", "num_exons", ")...
Fetches gene sequence from PySAM fasta object. Returns ------- exons : list of str list of exon nucleotide sequences five_prime_ss : list of str list of 5' splice site sequences three_prime_ss : list of str list of 3' splice site sequences
[ "Fetches", "gene", "sequence", "from", "PySAM", "fasta", "object", "." ]
5d70583b0a7c07cfe32e95f3a70e05df412acb84
https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/gene_sequence.py#L68-L106
train
KarchinLab/probabilistic2020
scripts/check_mutations.py
correct_chrom_names
def correct_chrom_names(chroms): """Make sure chromosome names follow UCSC chr convention.""" chrom_list = [] for chrom in chroms: # fix chrom numbering chrom = str(chrom) chrom = chrom.replace('23', 'X') chrom = chrom.replace('24', 'Y') chrom = chrom.replace('25', 'M...
python
def correct_chrom_names(chroms): """Make sure chromosome names follow UCSC chr convention.""" chrom_list = [] for chrom in chroms: # fix chrom numbering chrom = str(chrom) chrom = chrom.replace('23', 'X') chrom = chrom.replace('24', 'Y') chrom = chrom.replace('25', 'M...
[ "def", "correct_chrom_names", "(", "chroms", ")", ":", "chrom_list", "=", "[", "]", "for", "chrom", "in", "chroms", ":", "chrom", "=", "str", "(", "chrom", ")", "chrom", "=", "chrom", ".", "replace", "(", "'23'", ",", "'X'", ")", "chrom", "=", "chrom...
Make sure chromosome names follow UCSC chr convention.
[ "Make", "sure", "chromosome", "names", "follow", "UCSC", "chr", "convention", "." ]
5d70583b0a7c07cfe32e95f3a70e05df412acb84
https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/scripts/check_mutations.py#L23-L35
train
KarchinLab/probabilistic2020
prob2020/python/p_value.py
fishers_method
def fishers_method(pvals): """Fisher's method for combining independent p-values.""" pvals = np.asarray(pvals) degrees_of_freedom = 2 * pvals.size chisq_stat = np.sum(-2*np.log(pvals)) fishers_pval = stats.chi2.sf(chisq_stat, degrees_of_freedom) return fishers_pval
python
def fishers_method(pvals): """Fisher's method for combining independent p-values.""" pvals = np.asarray(pvals) degrees_of_freedom = 2 * pvals.size chisq_stat = np.sum(-2*np.log(pvals)) fishers_pval = stats.chi2.sf(chisq_stat, degrees_of_freedom) return fishers_pval
[ "def", "fishers_method", "(", "pvals", ")", ":", "pvals", "=", "np", ".", "asarray", "(", "pvals", ")", "degrees_of_freedom", "=", "2", "*", "pvals", ".", "size", "chisq_stat", "=", "np", ".", "sum", "(", "-", "2", "*", "np", ".", "log", "(", "pval...
Fisher's method for combining independent p-values.
[ "Fisher", "s", "method", "for", "combining", "independent", "p", "-", "values", "." ]
5d70583b0a7c07cfe32e95f3a70e05df412acb84
https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/p_value.py#L18-L24
train
KarchinLab/probabilistic2020
prob2020/python/p_value.py
cummin
def cummin(x): """A python implementation of the cummin function in R""" for i in range(1, len(x)): if x[i-1] < x[i]: x[i] = x[i-1] return x
python
def cummin(x): """A python implementation of the cummin function in R""" for i in range(1, len(x)): if x[i-1] < x[i]: x[i] = x[i-1] return x
[ "def", "cummin", "(", "x", ")", ":", "for", "i", "in", "range", "(", "1", ",", "len", "(", "x", ")", ")", ":", "if", "x", "[", "i", "-", "1", "]", "<", "x", "[", "i", "]", ":", "x", "[", "i", "]", "=", "x", "[", "i", "-", "1", "]", ...
A python implementation of the cummin function in R
[ "A", "python", "implementation", "of", "the", "cummin", "function", "in", "R" ]
5d70583b0a7c07cfe32e95f3a70e05df412acb84
https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/p_value.py#L27-L32
train
KarchinLab/probabilistic2020
prob2020/python/p_value.py
bh_fdr
def bh_fdr(pval): """A python implementation of the Benjamani-Hochberg FDR method. This code should always give precisely the same answer as using p.adjust(pval, method="BH") in R. Parameters ---------- pval : list or array list/array of p-values Returns ------- pval_adj :...
python
def bh_fdr(pval): """A python implementation of the Benjamani-Hochberg FDR method. This code should always give precisely the same answer as using p.adjust(pval, method="BH") in R. Parameters ---------- pval : list or array list/array of p-values Returns ------- pval_adj :...
[ "def", "bh_fdr", "(", "pval", ")", ":", "pval_array", "=", "np", ".", "array", "(", "pval", ")", "sorted_order", "=", "np", ".", "argsort", "(", "pval_array", ")", "original_order", "=", "np", ".", "argsort", "(", "sorted_order", ")", "pval_array", "=", ...
A python implementation of the Benjamani-Hochberg FDR method. This code should always give precisely the same answer as using p.adjust(pval, method="BH") in R. Parameters ---------- pval : list or array list/array of p-values Returns ------- pval_adj : np.array adjuste...
[ "A", "python", "implementation", "of", "the", "Benjamani", "-", "Hochberg", "FDR", "method", "." ]
5d70583b0a7c07cfe32e95f3a70e05df412acb84
https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/p_value.py#L35-L61
train
KarchinLab/probabilistic2020
prob2020/python/p_value.py
calc_deleterious_p_value
def calc_deleterious_p_value(mut_info, unmapped_mut_info, sc, gs, bed, num_permutations, stop_thresh, del_threshold, ...
python
def calc_deleterious_p_value(mut_info, unmapped_mut_info, sc, gs, bed, num_permutations, stop_thresh, del_threshold, ...
[ "def", "calc_deleterious_p_value", "(", "mut_info", ",", "unmapped_mut_info", ",", "sc", ",", "gs", ",", "bed", ",", "num_permutations", ",", "stop_thresh", ",", "del_threshold", ",", "pseudo_count", ",", "seed", "=", "None", ")", ":", "if", "len", "(", "mut...
Calculates the p-value for the number of inactivating SNV mutations. Calculates p-value based on how many simulations exceed the observed value. Parameters ---------- mut_info : dict contains codon and amino acid residue information for mutations mappable to provided reference tx. ...
[ "Calculates", "the", "p", "-", "value", "for", "the", "number", "of", "inactivating", "SNV", "mutations", "." ]
5d70583b0a7c07cfe32e95f3a70e05df412acb84
https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/p_value.py#L64-L145
train
KarchinLab/probabilistic2020
prob2020/python/p_value.py
calc_protein_p_value
def calc_protein_p_value(mut_info, unmapped_mut_info, sc, gs, bed, graph_dir, num_permutations, stop_thresh, min_recurre...
python
def calc_protein_p_value(mut_info, unmapped_mut_info, sc, gs, bed, graph_dir, num_permutations, stop_thresh, min_recurre...
[ "def", "calc_protein_p_value", "(", "mut_info", ",", "unmapped_mut_info", ",", "sc", ",", "gs", ",", "bed", ",", "graph_dir", ",", "num_permutations", ",", "stop_thresh", ",", "min_recurrent", ",", "min_fraction", ")", ":", "if", "len", "(", "mut_info", ")", ...
Computes the p-value for clustering on a neighbor graph composed of codons connected with edges if they are spatially near in 3D protein structure. Parameters ---------- Returns -------
[ "Computes", "the", "p", "-", "value", "for", "clustering", "on", "a", "neighbor", "graph", "composed", "of", "codons", "connected", "with", "edges", "if", "they", "are", "spatially", "near", "in", "3D", "protein", "structure", "." ]
5d70583b0a7c07cfe32e95f3a70e05df412acb84
https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/p_value.py#L291-L369
train
KarchinLab/probabilistic2020
prob2020/python/mymath.py
shannon_entropy
def shannon_entropy(p): """Calculates shannon entropy in bits. Parameters ---------- p : np.array array of probabilities Returns ------- shannon entropy in bits """ return -np.sum(np.where(p!=0, p * np.log2(p), 0))
python
def shannon_entropy(p): """Calculates shannon entropy in bits. Parameters ---------- p : np.array array of probabilities Returns ------- shannon entropy in bits """ return -np.sum(np.where(p!=0, p * np.log2(p), 0))
[ "def", "shannon_entropy", "(", "p", ")", ":", "return", "-", "np", ".", "sum", "(", "np", ".", "where", "(", "p", "!=", "0", ",", "p", "*", "np", ".", "log2", "(", "p", ")", ",", "0", ")", ")" ]
Calculates shannon entropy in bits. Parameters ---------- p : np.array array of probabilities Returns ------- shannon entropy in bits
[ "Calculates", "shannon", "entropy", "in", "bits", "." ]
5d70583b0a7c07cfe32e95f3a70e05df412acb84
https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/mymath.py#L7-L19
train
KarchinLab/probabilistic2020
prob2020/python/mymath.py
js_divergence
def js_divergence(p, q): """Compute the Jensen-Shannon Divergence between two discrete distributions. Parameters ---------- p : np.array probability mass array (sums to 1) q : np.array probability mass array (sums to 1) Returns ------- js_div : float js divergen...
python
def js_divergence(p, q): """Compute the Jensen-Shannon Divergence between two discrete distributions. Parameters ---------- p : np.array probability mass array (sums to 1) q : np.array probability mass array (sums to 1) Returns ------- js_div : float js divergen...
[ "def", "js_divergence", "(", "p", ",", "q", ")", ":", "m", "=", ".5", "*", "(", "p", "+", "q", ")", "js_div", "=", ".5", "*", "kl_divergence", "(", "p", ",", "m", ")", "+", ".5", "*", "kl_divergence", "(", "q", ",", "m", ")", "return", "js_di...
Compute the Jensen-Shannon Divergence between two discrete distributions. Parameters ---------- p : np.array probability mass array (sums to 1) q : np.array probability mass array (sums to 1) Returns ------- js_div : float js divergence between the two distrubtions
[ "Compute", "the", "Jensen", "-", "Shannon", "Divergence", "between", "two", "discrete", "distributions", "." ]
5d70583b0a7c07cfe32e95f3a70e05df412acb84
https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/mymath.py#L112-L129
train
KarchinLab/probabilistic2020
prob2020/python/mymath.py
js_distance
def js_distance(p, q): """Compute the Jensen-Shannon distance between two discrete distributions. NOTE: JS divergence is not a metric but the sqrt of JS divergence is a metric and is called the JS distance. Parameters ---------- p : np.array probability mass array (sums to 1) q : n...
python
def js_distance(p, q): """Compute the Jensen-Shannon distance between two discrete distributions. NOTE: JS divergence is not a metric but the sqrt of JS divergence is a metric and is called the JS distance. Parameters ---------- p : np.array probability mass array (sums to 1) q : n...
[ "def", "js_distance", "(", "p", ",", "q", ")", ":", "js_dist", "=", "np", ".", "sqrt", "(", "js_divergence", "(", "p", ",", "q", ")", ")", "return", "js_dist" ]
Compute the Jensen-Shannon distance between two discrete distributions. NOTE: JS divergence is not a metric but the sqrt of JS divergence is a metric and is called the JS distance. Parameters ---------- p : np.array probability mass array (sums to 1) q : np.array probability ma...
[ "Compute", "the", "Jensen", "-", "Shannon", "distance", "between", "two", "discrete", "distributions", "." ]
5d70583b0a7c07cfe32e95f3a70e05df412acb84
https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/mymath.py#L132-L151
train
KarchinLab/probabilistic2020
prob2020/python/bed_line.py
BedLine._init_exons
def _init_exons(self): """Sets a list of position intervals for each exon. Only coding regions as defined by thickStart and thickEnd are kept. Exons are stored in the self.exons attribute. """ exon_starts = [self.chrom_start + int(s) for s in self.bed_tupl...
python
def _init_exons(self): """Sets a list of position intervals for each exon. Only coding regions as defined by thickStart and thickEnd are kept. Exons are stored in the self.exons attribute. """ exon_starts = [self.chrom_start + int(s) for s in self.bed_tupl...
[ "def", "_init_exons", "(", "self", ")", ":", "exon_starts", "=", "[", "self", ".", "chrom_start", "+", "int", "(", "s", ")", "for", "s", "in", "self", ".", "bed_tuple", ".", "blockStarts", ".", "strip", "(", "','", ")", ".", "split", "(", "','", ")...
Sets a list of position intervals for each exon. Only coding regions as defined by thickStart and thickEnd are kept. Exons are stored in the self.exons attribute.
[ "Sets", "a", "list", "of", "position", "intervals", "for", "each", "exon", "." ]
5d70583b0a7c07cfe32e95f3a70e05df412acb84
https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/bed_line.py#L109-L129
train
KarchinLab/probabilistic2020
prob2020/python/bed_line.py
BedLine.init_genome_coordinates
def init_genome_coordinates(self) : """Creates the self.seqpos2genome dictionary that converts positions relative to the sequence to genome coordinates.""" self.seqpos2genome = {} # record genome positions for each sequence position seq_pos = 0 for estart, eend in self.e...
python
def init_genome_coordinates(self) : """Creates the self.seqpos2genome dictionary that converts positions relative to the sequence to genome coordinates.""" self.seqpos2genome = {} # record genome positions for each sequence position seq_pos = 0 for estart, eend in self.e...
[ "def", "init_genome_coordinates", "(", "self", ")", ":", "self", ".", "seqpos2genome", "=", "{", "}", "seq_pos", "=", "0", "for", "estart", ",", "eend", "in", "self", ".", "exons", ":", "for", "genome_pos", "in", "range", "(", "estart", ",", "eend", ")...
Creates the self.seqpos2genome dictionary that converts positions relative to the sequence to genome coordinates.
[ "Creates", "the", "self", ".", "seqpos2genome", "dictionary", "that", "converts", "positions", "relative", "to", "the", "sequence", "to", "genome", "coordinates", "." ]
5d70583b0a7c07cfe32e95f3a70e05df412acb84
https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/bed_line.py#L157-L197
train
KarchinLab/probabilistic2020
prob2020/python/bed_line.py
BedLine.query_position
def query_position(self, strand, chr, genome_coord): """Provides the relative position on the coding sequence for a given genomic position. Parameters ---------- chr : str chromosome, provided to check validity of query genome_coord : int 0-based ...
python
def query_position(self, strand, chr, genome_coord): """Provides the relative position on the coding sequence for a given genomic position. Parameters ---------- chr : str chromosome, provided to check validity of query genome_coord : int 0-based ...
[ "def", "query_position", "(", "self", ",", "strand", ",", "chr", ",", "genome_coord", ")", ":", "pos", "=", "None", "if", "chr", "!=", "self", ".", "chrom", ":", "pass", "if", "type", "(", "genome_coord", ")", "is", "list", ":", "pos_left", "=", "sel...
Provides the relative position on the coding sequence for a given genomic position. Parameters ---------- chr : str chromosome, provided to check validity of query genome_coord : int 0-based position for mutation, actually used to get relative coding pos ...
[ "Provides", "the", "relative", "position", "on", "the", "coding", "sequence", "for", "a", "given", "genomic", "position", "." ]
5d70583b0a7c07cfe32e95f3a70e05df412acb84
https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/bed_line.py#L199-L260
train
KarchinLab/probabilistic2020
prob2020/python/utils.py
start_logging
def start_logging(log_file='', log_level='INFO', verbose=False): """Start logging information into the log directory. If os.devnull is specified as the log_file then the log file will not actually be written to a file. """ if not log_file: # create log directory if it doesn't exist ...
python
def start_logging(log_file='', log_level='INFO', verbose=False): """Start logging information into the log directory. If os.devnull is specified as the log_file then the log file will not actually be written to a file. """ if not log_file: # create log directory if it doesn't exist ...
[ "def", "start_logging", "(", "log_file", "=", "''", ",", "log_level", "=", "'INFO'", ",", "verbose", "=", "False", ")", ":", "if", "not", "log_file", ":", "log_dir", "=", "os", ".", "path", ".", "abspath", "(", "'log'", ")", "+", "'/'", "if", "not", ...
Start logging information into the log directory. If os.devnull is specified as the log_file then the log file will not actually be written to a file.
[ "Start", "logging", "information", "into", "the", "log", "directory", "." ]
5d70583b0a7c07cfe32e95f3a70e05df412acb84
https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/utils.py#L75-L119
train
KarchinLab/probabilistic2020
prob2020/python/utils.py
log_error_decorator
def log_error_decorator(f): """Writes exception to log file if occured in decorated function. This decorator wrapper is needed for multiprocess logging since otherwise the python multiprocessing module will obscure the actual line of the error. """ @wraps(f) def wrapper(*args, **kwds): ...
python
def log_error_decorator(f): """Writes exception to log file if occured in decorated function. This decorator wrapper is needed for multiprocess logging since otherwise the python multiprocessing module will obscure the actual line of the error. """ @wraps(f) def wrapper(*args, **kwds): ...
[ "def", "log_error_decorator", "(", "f", ")", ":", "@", "wraps", "(", "f", ")", "def", "wrapper", "(", "*", "args", ",", "**", "kwds", ")", ":", "try", ":", "result", "=", "f", "(", "*", "args", ",", "**", "kwds", ")", "return", "result", "except"...
Writes exception to log file if occured in decorated function. This decorator wrapper is needed for multiprocess logging since otherwise the python multiprocessing module will obscure the actual line of the error.
[ "Writes", "exception", "to", "log", "file", "if", "occured", "in", "decorated", "function", "." ]
5d70583b0a7c07cfe32e95f3a70e05df412acb84
https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/utils.py#L122-L138
train
KarchinLab/probabilistic2020
prob2020/python/utils.py
filter_list
def filter_list(mylist, bad_ixs): """Removes indices from a list. All elements in bad_ixs will be removed from the list. Parameters ---------- mylist : list list to filter out specific indices bad_ixs : list of ints indices to remove from list Returns ------- mylis...
python
def filter_list(mylist, bad_ixs): """Removes indices from a list. All elements in bad_ixs will be removed from the list. Parameters ---------- mylist : list list to filter out specific indices bad_ixs : list of ints indices to remove from list Returns ------- mylis...
[ "def", "filter_list", "(", "mylist", ",", "bad_ixs", ")", ":", "bad_ixs", "=", "sorted", "(", "bad_ixs", ",", "reverse", "=", "True", ")", "for", "i", "in", "bad_ixs", ":", "mylist", ".", "pop", "(", "i", ")", "return", "mylist" ]
Removes indices from a list. All elements in bad_ixs will be removed from the list. Parameters ---------- mylist : list list to filter out specific indices bad_ixs : list of ints indices to remove from list Returns ------- mylist : list list with elements filte...
[ "Removes", "indices", "from", "a", "list", "." ]
5d70583b0a7c07cfe32e95f3a70e05df412acb84
https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/utils.py#L149-L171
train
KarchinLab/probabilistic2020
prob2020/python/utils.py
rev_comp
def rev_comp(seq): """Get reverse complement of sequence. rev_comp will maintain the case of the sequence. Parameters ---------- seq : str nucleotide sequence. valid {a, c, t, g, n} Returns ------- rev_comp_seq : str reverse complement of sequence """ rev_seq =...
python
def rev_comp(seq): """Get reverse complement of sequence. rev_comp will maintain the case of the sequence. Parameters ---------- seq : str nucleotide sequence. valid {a, c, t, g, n} Returns ------- rev_comp_seq : str reverse complement of sequence """ rev_seq =...
[ "def", "rev_comp", "(", "seq", ")", ":", "rev_seq", "=", "seq", "[", ":", ":", "-", "1", "]", "rev_comp_seq", "=", "''", ".", "join", "(", "[", "base_pairing", "[", "s", "]", "for", "s", "in", "rev_seq", "]", ")", "return", "rev_comp_seq" ]
Get reverse complement of sequence. rev_comp will maintain the case of the sequence. Parameters ---------- seq : str nucleotide sequence. valid {a, c, t, g, n} Returns ------- rev_comp_seq : str reverse complement of sequence
[ "Get", "reverse", "complement", "of", "sequence", "." ]
5d70583b0a7c07cfe32e95f3a70e05df412acb84
https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/utils.py#L174-L191
train
KarchinLab/probabilistic2020
prob2020/python/utils.py
bed_generator
def bed_generator(bed_path): """Iterates through a BED file yielding parsed BED lines. Parameters ---------- bed_path : str path to BED file Yields ------ BedLine(line) : BedLine A BedLine object which has parsed the individual line in a BED file. """ with o...
python
def bed_generator(bed_path): """Iterates through a BED file yielding parsed BED lines. Parameters ---------- bed_path : str path to BED file Yields ------ BedLine(line) : BedLine A BedLine object which has parsed the individual line in a BED file. """ with o...
[ "def", "bed_generator", "(", "bed_path", ")", ":", "with", "open", "(", "bed_path", ")", "as", "handle", ":", "bed_reader", "=", "csv", ".", "reader", "(", "handle", ",", "delimiter", "=", "'\\t'", ")", "for", "line", "in", "bed_reader", ":", "yield", ...
Iterates through a BED file yielding parsed BED lines. Parameters ---------- bed_path : str path to BED file Yields ------ BedLine(line) : BedLine A BedLine object which has parsed the individual line in a BED file.
[ "Iterates", "through", "a", "BED", "file", "yielding", "parsed", "BED", "lines", "." ]
5d70583b0a7c07cfe32e95f3a70e05df412acb84
https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/utils.py#L212-L229
train
KarchinLab/probabilistic2020
prob2020/python/utils.py
read_bed
def read_bed(file_path, restricted_genes=None): """Reads BED file and populates a dictionary separating genes by chromosome. Parameters ---------- file_path : str path to BED file filtered_genes: list list of gene names to not use Returns ------- bed_dict: dict ...
python
def read_bed(file_path, restricted_genes=None): """Reads BED file and populates a dictionary separating genes by chromosome. Parameters ---------- file_path : str path to BED file filtered_genes: list list of gene names to not use Returns ------- bed_dict: dict ...
[ "def", "read_bed", "(", "file_path", ",", "restricted_genes", "=", "None", ")", ":", "bed_dict", "=", "OrderedDict", "(", ")", "for", "bed_row", "in", "bed_generator", "(", "file_path", ")", ":", "is_restrict_flag", "=", "restricted_genes", "is", "None", "or",...
Reads BED file and populates a dictionary separating genes by chromosome. Parameters ---------- file_path : str path to BED file filtered_genes: list list of gene names to not use Returns ------- bed_dict: dict dictionary mapping chromosome keys to a list of BED...
[ "Reads", "BED", "file", "and", "populates", "a", "dictionary", "separating", "genes", "by", "chromosome", "." ]
5d70583b0a7c07cfe32e95f3a70e05df412acb84
https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/utils.py#L232-L257
train
KarchinLab/probabilistic2020
prob2020/python/utils.py
_fix_mutation_df
def _fix_mutation_df(mutation_df, only_unique=False): """Drops invalid mutations and corrects for 1-based coordinates. TODO: Be smarter about what coordinate system is put in the provided mutations. Parameters ---------- mutation_df : pd.DataFrame user provided mutations only_uniqu...
python
def _fix_mutation_df(mutation_df, only_unique=False): """Drops invalid mutations and corrects for 1-based coordinates. TODO: Be smarter about what coordinate system is put in the provided mutations. Parameters ---------- mutation_df : pd.DataFrame user provided mutations only_uniqu...
[ "def", "_fix_mutation_df", "(", "mutation_df", ",", "only_unique", "=", "False", ")", ":", "orig_len", "=", "len", "(", "mutation_df", ")", "mutation_df", "=", "mutation_df", "[", "mutation_df", ".", "Variant_Classification", ".", "isin", "(", "variant_snv", ")"...
Drops invalid mutations and corrects for 1-based coordinates. TODO: Be smarter about what coordinate system is put in the provided mutations. Parameters ---------- mutation_df : pd.DataFrame user provided mutations only_unique : bool flag indicating whether only unique mutation...
[ "Drops", "invalid", "mutations", "and", "corrects", "for", "1", "-", "based", "coordinates", "." ]
5d70583b0a7c07cfe32e95f3a70e05df412acb84
https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/utils.py#L260-L327
train
KarchinLab/probabilistic2020
prob2020/python/utils.py
calc_windowed_sum
def calc_windowed_sum(aa_mut_pos, germ_aa, somatic_aa, window=[3]): """Calculate the sum of mutations within a window around a particular mutated codon. Parameters ---------- aa_mut_pos : list list of mutated amino acid posit...
python
def calc_windowed_sum(aa_mut_pos, germ_aa, somatic_aa, window=[3]): """Calculate the sum of mutations within a window around a particular mutated codon. Parameters ---------- aa_mut_pos : list list of mutated amino acid posit...
[ "def", "calc_windowed_sum", "(", "aa_mut_pos", ",", "germ_aa", ",", "somatic_aa", ",", "window", "=", "[", "3", "]", ")", ":", "pos_ctr", ",", "pos_sum", "=", "{", "}", ",", "{", "w", ":", "{", "}", "for", "w", "in", "window", "}", "num_pos", "=", ...
Calculate the sum of mutations within a window around a particular mutated codon. Parameters ---------- aa_mut_pos : list list of mutated amino acid positions germ_aa : list Reference amino acid somatic_aa : list Somatic amino acid (if missense) window : list ...
[ "Calculate", "the", "sum", "of", "mutations", "within", "a", "window", "around", "a", "particular", "mutated", "codon", "." ]
5d70583b0a7c07cfe32e95f3a70e05df412acb84
https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/utils.py#L359-L426
train
KarchinLab/probabilistic2020
prob2020/python/mutation_context.py
get_all_context_names
def get_all_context_names(context_num): """Based on the nucleotide base context number, return a list of strings representing each context. Parameters ---------- context_num : int number representing the amount of nucleotide base context to use. Returns ------- a list of st...
python
def get_all_context_names(context_num): """Based on the nucleotide base context number, return a list of strings representing each context. Parameters ---------- context_num : int number representing the amount of nucleotide base context to use. Returns ------- a list of st...
[ "def", "get_all_context_names", "(", "context_num", ")", ":", "if", "context_num", "==", "0", ":", "return", "[", "'None'", "]", "elif", "context_num", "==", "1", ":", "return", "[", "'A'", ",", "'C'", ",", "'T'", ",", "'G'", "]", "elif", "context_num", ...
Based on the nucleotide base context number, return a list of strings representing each context. Parameters ---------- context_num : int number representing the amount of nucleotide base context to use. Returns ------- a list of strings containing the names of the base contexts
[ "Based", "on", "the", "nucleotide", "base", "context", "number", "return", "a", "list", "of", "strings", "representing", "each", "context", "." ]
5d70583b0a7c07cfe32e95f3a70e05df412acb84
https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/mutation_context.py#L18-L52
train
KarchinLab/probabilistic2020
prob2020/python/mutation_context.py
get_chasm_context
def get_chasm_context(tri_nuc): """Returns the mutation context acording to CHASM. For more information about CHASM's mutation context, look at http://wiki.chasmsoftware.org/index.php/CHASM_Overview. Essentially CHASM uses a few specified di-nucleotide contexts followed by single nucleotide context...
python
def get_chasm_context(tri_nuc): """Returns the mutation context acording to CHASM. For more information about CHASM's mutation context, look at http://wiki.chasmsoftware.org/index.php/CHASM_Overview. Essentially CHASM uses a few specified di-nucleotide contexts followed by single nucleotide context...
[ "def", "get_chasm_context", "(", "tri_nuc", ")", ":", "if", "len", "(", "tri_nuc", ")", "!=", "3", ":", "raise", "ValueError", "(", "'Chasm context requires a three nucleotide string '", "'(Provided: \"{0}\")'", ".", "format", "(", "tri_nuc", ")", ")", "if", "tri_...
Returns the mutation context acording to CHASM. For more information about CHASM's mutation context, look at http://wiki.chasmsoftware.org/index.php/CHASM_Overview. Essentially CHASM uses a few specified di-nucleotide contexts followed by single nucleotide context. Parameters ---------- tr...
[ "Returns", "the", "mutation", "context", "acording", "to", "CHASM", "." ]
5d70583b0a7c07cfe32e95f3a70e05df412acb84
https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/mutation_context.py#L117-L151
train
KarchinLab/probabilistic2020
prob2020/python/mutation_context.py
get_aa_mut_info
def get_aa_mut_info(coding_pos, somatic_base, gene_seq): """Retrieves relevant information about the effect of a somatic SNV on the amino acid of a gene. Information includes the germline codon, somatic codon, codon position, germline AA, and somatic AA. Parameters ---------- coding_pos : ...
python
def get_aa_mut_info(coding_pos, somatic_base, gene_seq): """Retrieves relevant information about the effect of a somatic SNV on the amino acid of a gene. Information includes the germline codon, somatic codon, codon position, germline AA, and somatic AA. Parameters ---------- coding_pos : ...
[ "def", "get_aa_mut_info", "(", "coding_pos", ",", "somatic_base", ",", "gene_seq", ")", ":", "if", "not", "somatic_base", ":", "aa_info", "=", "{", "'Reference Codon'", ":", "[", "]", ",", "'Somatic Codon'", ":", "[", "]", ",", "'Codon Pos'", ":", "[", "]"...
Retrieves relevant information about the effect of a somatic SNV on the amino acid of a gene. Information includes the germline codon, somatic codon, codon position, germline AA, and somatic AA. Parameters ---------- coding_pos : iterable of ints Contains the base position (0-based) of...
[ "Retrieves", "relevant", "information", "about", "the", "effect", "of", "a", "somatic", "SNV", "on", "the", "amino", "acid", "of", "a", "gene", "." ]
5d70583b0a7c07cfe32e95f3a70e05df412acb84
https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/mutation_context.py#L196-L252
train
KarchinLab/probabilistic2020
prob2020/python/process_result.py
handle_tsg_results
def handle_tsg_results(permutation_result): """Handles result from TSG results. Takes in output from multiprocess_permutation function and converts to a better formatted dataframe. Parameters ---------- permutation_result : list output from multiprocess_permutation Returns ---...
python
def handle_tsg_results(permutation_result): """Handles result from TSG results. Takes in output from multiprocess_permutation function and converts to a better formatted dataframe. Parameters ---------- permutation_result : list output from multiprocess_permutation Returns ---...
[ "def", "handle_tsg_results", "(", "permutation_result", ")", ":", "permutation_df", "=", "pd", ".", "DataFrame", "(", "sorted", "(", "permutation_result", ",", "key", "=", "lambda", "x", ":", "x", "[", "2", "]", "if", "x", "[", "2", "]", "is", "not", "...
Handles result from TSG results. Takes in output from multiprocess_permutation function and converts to a better formatted dataframe. Parameters ---------- permutation_result : list output from multiprocess_permutation Returns ------- permutation_df : pd.DataFrame form...
[ "Handles", "result", "from", "TSG", "results", "." ]
5d70583b0a7c07cfe32e95f3a70e05df412acb84
https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/process_result.py#L8-L45
train
KarchinLab/probabilistic2020
scripts/calc_non_coding_frameshift_rate.py
get_frameshift_info
def get_frameshift_info(fs_df, bins): """Counts frameshifts stratified by a given length. Parameters ---------- fs_df : pd.DataFrame indel mutations from non-coding portion bins : int number of different length categories for frameshifts Returns ------- indel_len : list...
python
def get_frameshift_info(fs_df, bins): """Counts frameshifts stratified by a given length. Parameters ---------- fs_df : pd.DataFrame indel mutations from non-coding portion bins : int number of different length categories for frameshifts Returns ------- indel_len : list...
[ "def", "get_frameshift_info", "(", "fs_df", ",", "bins", ")", ":", "fs_df", "=", "compute_indel_length", "(", "fs_df", ")", "num_indels", "=", "[", "]", "indel_len", "=", "[", "]", "num_categories", "=", "0", "i", "=", "1", "while", "(", "num_categories", ...
Counts frameshifts stratified by a given length. Parameters ---------- fs_df : pd.DataFrame indel mutations from non-coding portion bins : int number of different length categories for frameshifts Returns ------- indel_len : list length of specific frameshift length...
[ "Counts", "frameshifts", "stratified", "by", "a", "given", "length", "." ]
5d70583b0a7c07cfe32e95f3a70e05df412acb84
https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/scripts/calc_non_coding_frameshift_rate.py#L14-L49
train
KarchinLab/probabilistic2020
prob2020/python/amino_acid.py
AminoAcid.set_mutation_type
def set_mutation_type(self, mut_type=''): """Sets the mutation type attribute to a single label based on attribute flags. Kwargs: mut_type (str): value to set self.mut_type """ if mut_type: # user specifies a mutation type self.mutation_type =...
python
def set_mutation_type(self, mut_type=''): """Sets the mutation type attribute to a single label based on attribute flags. Kwargs: mut_type (str): value to set self.mut_type """ if mut_type: # user specifies a mutation type self.mutation_type =...
[ "def", "set_mutation_type", "(", "self", ",", "mut_type", "=", "''", ")", ":", "if", "mut_type", ":", "self", ".", "mutation_type", "=", "mut_type", "else", ":", "if", "not", "self", ".", "is_valid", ":", "self", ".", "mutation_type", "=", "'not valid'", ...
Sets the mutation type attribute to a single label based on attribute flags. Kwargs: mut_type (str): value to set self.mut_type
[ "Sets", "the", "mutation", "type", "attribute", "to", "a", "single", "label", "based", "on", "attribute", "flags", "." ]
5d70583b0a7c07cfe32e95f3a70e05df412acb84
https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/amino_acid.py#L52-L93
train
KarchinLab/probabilistic2020
prob2020/python/amino_acid.py
AminoAcid.set_amino_acid
def set_amino_acid(self, aa): """Set amino acid change and position.""" aa = aa.upper() # make sure it is upper case aa = aa[2:] if aa.startswith('P.') else aa # strip "p." self.__set_mutation_status() # set flags detailing the type of mutation self.__parse_hgvs_syntax(aa)
python
def set_amino_acid(self, aa): """Set amino acid change and position.""" aa = aa.upper() # make sure it is upper case aa = aa[2:] if aa.startswith('P.') else aa # strip "p." self.__set_mutation_status() # set flags detailing the type of mutation self.__parse_hgvs_syntax(aa)
[ "def", "set_amino_acid", "(", "self", ",", "aa", ")", ":", "aa", "=", "aa", ".", "upper", "(", ")", "aa", "=", "aa", "[", "2", ":", "]", "if", "aa", ".", "startswith", "(", "'P.'", ")", "else", "aa", "self", ".", "__set_mutation_status", "(", ")"...
Set amino acid change and position.
[ "Set", "amino", "acid", "change", "and", "position", "." ]
5d70583b0a7c07cfe32e95f3a70e05df412acb84
https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/amino_acid.py#L98-L103
train
KarchinLab/probabilistic2020
prob2020/python/amino_acid.py
AminoAcid.__set_missense_status
def __set_missense_status(self, hgvs_string): """Sets the self.is_missense flag.""" # set missense status if re.search('^[A-Z?]\d+[A-Z?]$', hgvs_string): self.is_missense = True self.is_non_silent = True else: self.is_missense = False
python
def __set_missense_status(self, hgvs_string): """Sets the self.is_missense flag.""" # set missense status if re.search('^[A-Z?]\d+[A-Z?]$', hgvs_string): self.is_missense = True self.is_non_silent = True else: self.is_missense = False
[ "def", "__set_missense_status", "(", "self", ",", "hgvs_string", ")", ":", "if", "re", ".", "search", "(", "'^[A-Z?]\\d+[A-Z?]$'", ",", "hgvs_string", ")", ":", "self", ".", "is_missense", "=", "True", "self", ".", "is_non_silent", "=", "True", "else", ":", ...
Sets the self.is_missense flag.
[ "Sets", "the", "self", ".", "is_missense", "flag", "." ]
5d70583b0a7c07cfe32e95f3a70e05df412acb84
https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/amino_acid.py#L127-L134
train
KarchinLab/probabilistic2020
prob2020/python/amino_acid.py
AminoAcid.__set_lost_start_status
def __set_lost_start_status(self, hgvs_string): """Sets the self.is_lost_start flag.""" # set is lost start status mymatch = re.search('^([A-Z?])(\d+)([A-Z?])$', hgvs_string) if mymatch: grps = mymatch.groups() if int(grps[1]) == 1 and grps[0] != grps[2]: ...
python
def __set_lost_start_status(self, hgvs_string): """Sets the self.is_lost_start flag.""" # set is lost start status mymatch = re.search('^([A-Z?])(\d+)([A-Z?])$', hgvs_string) if mymatch: grps = mymatch.groups() if int(grps[1]) == 1 and grps[0] != grps[2]: ...
[ "def", "__set_lost_start_status", "(", "self", ",", "hgvs_string", ")", ":", "mymatch", "=", "re", ".", "search", "(", "'^([A-Z?])(\\d+)([A-Z?])$'", ",", "hgvs_string", ")", "if", "mymatch", ":", "grps", "=", "mymatch", ".", "groups", "(", ")", "if", "int", ...
Sets the self.is_lost_start flag.
[ "Sets", "the", "self", ".", "is_lost_start", "flag", "." ]
5d70583b0a7c07cfe32e95f3a70e05df412acb84
https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/amino_acid.py#L136-L148
train
KarchinLab/probabilistic2020
prob2020/python/amino_acid.py
AminoAcid.__set_frame_shift_status
def __set_frame_shift_status(self): """Check for frame shift and set the self.is_frame_shift flag.""" if 'fs' in self.hgvs_original: self.is_frame_shift = True self.is_non_silent = True elif re.search('[A-Z]\d+[A-Z]+\*', self.hgvs_original): # it looks like so...
python
def __set_frame_shift_status(self): """Check for frame shift and set the self.is_frame_shift flag.""" if 'fs' in self.hgvs_original: self.is_frame_shift = True self.is_non_silent = True elif re.search('[A-Z]\d+[A-Z]+\*', self.hgvs_original): # it looks like so...
[ "def", "__set_frame_shift_status", "(", "self", ")", ":", "if", "'fs'", "in", "self", ".", "hgvs_original", ":", "self", ".", "is_frame_shift", "=", "True", "self", ".", "is_non_silent", "=", "True", "elif", "re", ".", "search", "(", "'[A-Z]\\d+[A-Z]+\\*'", ...
Check for frame shift and set the self.is_frame_shift flag.
[ "Check", "for", "frame", "shift", "and", "set", "the", "self", ".", "is_frame_shift", "flag", "." ]
5d70583b0a7c07cfe32e95f3a70e05df412acb84
https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/amino_acid.py#L150-L161
train
KarchinLab/probabilistic2020
prob2020/python/amino_acid.py
AminoAcid.__set_lost_stop_status
def __set_lost_stop_status(self, hgvs_string): """Check if the stop codon was mutated to something other than a stop codon.""" lost_stop_pattern = '^\*\d+[A-Z?]+\*?$' if re.search(lost_stop_pattern, hgvs_string): self.is_lost_stop = True self.is_non_silent = True ...
python
def __set_lost_stop_status(self, hgvs_string): """Check if the stop codon was mutated to something other than a stop codon.""" lost_stop_pattern = '^\*\d+[A-Z?]+\*?$' if re.search(lost_stop_pattern, hgvs_string): self.is_lost_stop = True self.is_non_silent = True ...
[ "def", "__set_lost_stop_status", "(", "self", ",", "hgvs_string", ")", ":", "lost_stop_pattern", "=", "'^\\*\\d+[A-Z?]+\\*?$'", "if", "re", ".", "search", "(", "lost_stop_pattern", ",", "hgvs_string", ")", ":", "self", ".", "is_lost_stop", "=", "True", "self", "...
Check if the stop codon was mutated to something other than a stop codon.
[ "Check", "if", "the", "stop", "codon", "was", "mutated", "to", "something", "other", "than", "a", "stop", "codon", "." ]
5d70583b0a7c07cfe32e95f3a70e05df412acb84
https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/amino_acid.py#L163-L171
train
KarchinLab/probabilistic2020
prob2020/python/amino_acid.py
AminoAcid.__set_premature_stop_codon_status
def __set_premature_stop_codon_status(self, hgvs_string): """Set whether there is a premature stop codon.""" if re.search('.+\*(\d+)?$', hgvs_string): self.is_premature_stop_codon = True self.is_non_silent = True # check if it is also a nonsense mutation ...
python
def __set_premature_stop_codon_status(self, hgvs_string): """Set whether there is a premature stop codon.""" if re.search('.+\*(\d+)?$', hgvs_string): self.is_premature_stop_codon = True self.is_non_silent = True # check if it is also a nonsense mutation ...
[ "def", "__set_premature_stop_codon_status", "(", "self", ",", "hgvs_string", ")", ":", "if", "re", ".", "search", "(", "'.+\\*(\\d+)?$'", ",", "hgvs_string", ")", ":", "self", ".", "is_premature_stop_codon", "=", "True", "self", ".", "is_non_silent", "=", "True"...
Set whether there is a premature stop codon.
[ "Set", "whether", "there", "is", "a", "premature", "stop", "codon", "." ]
5d70583b0a7c07cfe32e95f3a70e05df412acb84
https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/amino_acid.py#L173-L186
train
KarchinLab/probabilistic2020
prob2020/python/amino_acid.py
AminoAcid.__set_indel_status
def __set_indel_status(self): """Sets flags related to the mutation being an indel.""" # set indel status if "ins" in self.hgvs_original: # mutation is insertion self.is_insertion = True self.is_deletion = False self.is_indel = True sel...
python
def __set_indel_status(self): """Sets flags related to the mutation being an indel.""" # set indel status if "ins" in self.hgvs_original: # mutation is insertion self.is_insertion = True self.is_deletion = False self.is_indel = True sel...
[ "def", "__set_indel_status", "(", "self", ")", ":", "if", "\"ins\"", "in", "self", ".", "hgvs_original", ":", "self", ".", "is_insertion", "=", "True", "self", ".", "is_deletion", "=", "False", "self", ".", "is_indel", "=", "True", "self", ".", "is_non_sil...
Sets flags related to the mutation being an indel.
[ "Sets", "flags", "related", "to", "the", "mutation", "being", "an", "indel", "." ]
5d70583b0a7c07cfe32e95f3a70e05df412acb84
https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/amino_acid.py#L188-L207
train
KarchinLab/probabilistic2020
prob2020/python/amino_acid.py
AminoAcid.__set_unkown_effect
def __set_unkown_effect(self, hgvs_string): """Sets a flag for unkown effect according to HGVS syntax. The COSMIC database also uses unconventional questionmarks to denote missing information. Args: hgvs_string (str): hgvs syntax with "p." removed """ # Stand...
python
def __set_unkown_effect(self, hgvs_string): """Sets a flag for unkown effect according to HGVS syntax. The COSMIC database also uses unconventional questionmarks to denote missing information. Args: hgvs_string (str): hgvs syntax with "p." removed """ # Stand...
[ "def", "__set_unkown_effect", "(", "self", ",", "hgvs_string", ")", ":", "unknown_effect_list", "=", "[", "'?'", ",", "'(=)'", ",", "'='", "]", "if", "hgvs_string", "in", "unknown_effect_list", ":", "self", ".", "unknown_effect", "=", "True", "elif", "\"(\"", ...
Sets a flag for unkown effect according to HGVS syntax. The COSMIC database also uses unconventional questionmarks to denote missing information. Args: hgvs_string (str): hgvs syntax with "p." removed
[ "Sets", "a", "flag", "for", "unkown", "effect", "according", "to", "HGVS", "syntax", ".", "The", "COSMIC", "database", "also", "uses", "unconventional", "questionmarks", "to", "denote", "missing", "information", "." ]
5d70583b0a7c07cfe32e95f3a70e05df412acb84
https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/amino_acid.py#L209-L233
train
KarchinLab/probabilistic2020
prob2020/python/permutation.py
deleterious_permutation
def deleterious_permutation(obs_del, context_counts, context_to_mut, seq_context, gene_seq, num_permutations=10000, stop_criteria=100, ...
python
def deleterious_permutation(obs_del, context_counts, context_to_mut, seq_context, gene_seq, num_permutations=10000, stop_criteria=100, ...
[ "def", "deleterious_permutation", "(", "obs_del", ",", "context_counts", ",", "context_to_mut", ",", "seq_context", ",", "gene_seq", ",", "num_permutations", "=", "10000", ",", "stop_criteria", "=", "100", ",", "pseudo_count", "=", "0", ",", "max_batch", "=", "2...
Performs null-permutations for deleterious mutation statistics in a single gene. Parameters ---------- context_counts : pd.Series number of mutations for each context context_to_mut : dict dictionary mapping nucleotide context to a list of observed somatic base changes. ...
[ "Performs", "null", "-", "permutations", "for", "deleterious", "mutation", "statistics", "in", "a", "single", "gene", "." ]
5d70583b0a7c07cfe32e95f3a70e05df412acb84
https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/permutation.py#L9-L96
train
KarchinLab/probabilistic2020
prob2020/python/permutation.py
protein_permutation
def protein_permutation(graph_score, num_codons_obs, context_counts, context_to_mut, seq_context, gene_seq, gene_graph, num_permutations=10000, ...
python
def protein_permutation(graph_score, num_codons_obs, context_counts, context_to_mut, seq_context, gene_seq, gene_graph, num_permutations=10000, ...
[ "def", "protein_permutation", "(", "graph_score", ",", "num_codons_obs", ",", "context_counts", ",", "context_to_mut", ",", "seq_context", ",", "gene_seq", ",", "gene_graph", ",", "num_permutations", "=", "10000", ",", "stop_criteria", "=", "100", ",", "pseudo_count...
Performs null-simulations for position-based mutation statistics in a single gene. Parameters ---------- graph_score : float clustering score for observed data num_codons_obs : int number of codons with missense mutation in observed data context_counts : pd.Series number...
[ "Performs", "null", "-", "simulations", "for", "position", "-", "based", "mutation", "statistics", "in", "a", "single", "gene", "." ]
5d70583b0a7c07cfe32e95f3a70e05df412acb84
https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/permutation.py#L360-L483
train
KarchinLab/probabilistic2020
prob2020/python/permutation.py
effect_permutation
def effect_permutation(context_counts, context_to_mut, seq_context, gene_seq, num_permutations=10000, pseudo_count=0): """Performs null-permutations for effect-based mutation statistics in a single...
python
def effect_permutation(context_counts, context_to_mut, seq_context, gene_seq, num_permutations=10000, pseudo_count=0): """Performs null-permutations for effect-based mutation statistics in a single...
[ "def", "effect_permutation", "(", "context_counts", ",", "context_to_mut", ",", "seq_context", ",", "gene_seq", ",", "num_permutations", "=", "10000", ",", "pseudo_count", "=", "0", ")", ":", "mycontexts", "=", "context_counts", ".", "index", ".", "tolist", "(",...
Performs null-permutations for effect-based mutation statistics in a single gene. Parameters ---------- context_counts : pd.Series number of mutations for each context context_to_mut : dict dictionary mapping nucleotide context to a list of observed somatic base changes. ...
[ "Performs", "null", "-", "permutations", "for", "effect", "-", "based", "mutation", "statistics", "in", "a", "single", "gene", "." ]
5d70583b0a7c07cfe32e95f3a70e05df412acb84
https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/permutation.py#L486-L552
train
KarchinLab/probabilistic2020
prob2020/python/permutation.py
non_silent_ratio_permutation
def non_silent_ratio_permutation(context_counts, context_to_mut, seq_context, gene_seq, num_permutations=10000): """Performs null-permutations for non-silent ratio across all genes. ...
python
def non_silent_ratio_permutation(context_counts, context_to_mut, seq_context, gene_seq, num_permutations=10000): """Performs null-permutations for non-silent ratio across all genes. ...
[ "def", "non_silent_ratio_permutation", "(", "context_counts", ",", "context_to_mut", ",", "seq_context", ",", "gene_seq", ",", "num_permutations", "=", "10000", ")", ":", "mycontexts", "=", "context_counts", ".", "index", ".", "tolist", "(", ")", "somatic_base", "...
Performs null-permutations for non-silent ratio across all genes. Parameters ---------- context_counts : pd.Series number of mutations for each context context_to_mut : dict dictionary mapping nucleotide context to a list of observed somatic base changes. seq_context : Seque...
[ "Performs", "null", "-", "permutations", "for", "non", "-", "silent", "ratio", "across", "all", "genes", "." ]
5d70583b0a7c07cfe32e95f3a70e05df412acb84
https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/permutation.py#L555-L606
train
KarchinLab/probabilistic2020
prob2020/python/permutation.py
summary_permutation
def summary_permutation(context_counts, context_to_mut, seq_context, gene_seq, score_dir, num_permutations=10000, min_frac=0.0, min_recur=2, ...
python
def summary_permutation(context_counts, context_to_mut, seq_context, gene_seq, score_dir, num_permutations=10000, min_frac=0.0, min_recur=2, ...
[ "def", "summary_permutation", "(", "context_counts", ",", "context_to_mut", ",", "seq_context", ",", "gene_seq", ",", "score_dir", ",", "num_permutations", "=", "10000", ",", "min_frac", "=", "0.0", ",", "min_recur", "=", "2", ",", "drop_silent", "=", "False", ...
Performs null-permutations and summarizes the results as features over the gene. Parameters ---------- context_counts : pd.Series number of mutations for each context context_to_mut : dict dictionary mapping nucleotide context to a list of observed somatic base changes. ...
[ "Performs", "null", "-", "permutations", "and", "summarizes", "the", "results", "as", "features", "over", "the", "gene", "." ]
5d70583b0a7c07cfe32e95f3a70e05df412acb84
https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/permutation.py#L609-L686
train
KarchinLab/probabilistic2020
prob2020/python/permutation.py
maf_permutation
def maf_permutation(context_counts, context_to_mut, seq_context, gene_seq, num_permutations=10000, drop_silent=False): """Performs null-permutations across all genes and records the results in a format like a MAF...
python
def maf_permutation(context_counts, context_to_mut, seq_context, gene_seq, num_permutations=10000, drop_silent=False): """Performs null-permutations across all genes and records the results in a format like a MAF...
[ "def", "maf_permutation", "(", "context_counts", ",", "context_to_mut", ",", "seq_context", ",", "gene_seq", ",", "num_permutations", "=", "10000", ",", "drop_silent", "=", "False", ")", ":", "mycontexts", "=", "context_counts", ".", "index", ".", "tolist", "(",...
Performs null-permutations across all genes and records the results in a format like a MAF file. This could be useful for examining the null permutations because the alternative approaches always summarize the results. With the simulated null-permutations, novel metrics can be applied to create an empir...
[ "Performs", "null", "-", "permutations", "across", "all", "genes", "and", "records", "the", "results", "in", "a", "format", "like", "a", "MAF", "file", ".", "This", "could", "be", "useful", "for", "examining", "the", "null", "permutations", "because", "the",...
5d70583b0a7c07cfe32e95f3a70e05df412acb84
https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/permutation.py#L689-L783
train
sv0/django-markdown-app
django_markdown/utils.py
editor_js_initialization
def editor_js_initialization(selector, **extra_settings): """ Return script tag with initialization code. """ init_template = loader.get_template( settings.MARKDOWN_EDITOR_INIT_TEMPLATE) options = dict( previewParserPath=reverse('django_markdown_preview'), **settings.MARKDOWN_EDITO...
python
def editor_js_initialization(selector, **extra_settings): """ Return script tag with initialization code. """ init_template = loader.get_template( settings.MARKDOWN_EDITOR_INIT_TEMPLATE) options = dict( previewParserPath=reverse('django_markdown_preview'), **settings.MARKDOWN_EDITO...
[ "def", "editor_js_initialization", "(", "selector", ",", "**", "extra_settings", ")", ":", "init_template", "=", "loader", ".", "get_template", "(", "settings", ".", "MARKDOWN_EDITOR_INIT_TEMPLATE", ")", "options", "=", "dict", "(", "previewParserPath", "=", "revers...
Return script tag with initialization code.
[ "Return", "script", "tag", "with", "initialization", "code", "." ]
973968c68d79cbe35304e9d6da876ad33f427d2d
https://github.com/sv0/django-markdown-app/blob/973968c68d79cbe35304e9d6da876ad33f427d2d/django_markdown/utils.py#L42-L56
train
sv0/django-markdown-app
django_markdown/views.py
preview
def preview(request): """ Render preview page. :returns: A rendered preview """ if settings.MARKDOWN_PROTECT_PREVIEW: user = getattr(request, 'user', None) if not user or not user.is_staff: from django.contrib.auth.views import redirect_to_login return redirect_...
python
def preview(request): """ Render preview page. :returns: A rendered preview """ if settings.MARKDOWN_PROTECT_PREVIEW: user = getattr(request, 'user', None) if not user or not user.is_staff: from django.contrib.auth.views import redirect_to_login return redirect_...
[ "def", "preview", "(", "request", ")", ":", "if", "settings", ".", "MARKDOWN_PROTECT_PREVIEW", ":", "user", "=", "getattr", "(", "request", ",", "'user'", ",", "None", ")", "if", "not", "user", "or", "not", "user", ".", "is_staff", ":", "from", "django",...
Render preview page. :returns: A rendered preview
[ "Render", "preview", "page", "." ]
973968c68d79cbe35304e9d6da876ad33f427d2d
https://github.com/sv0/django-markdown-app/blob/973968c68d79cbe35304e9d6da876ad33f427d2d/django_markdown/views.py#L7-L23
train
sv0/django-markdown-app
django_markdown/flatpages.py
register
def register(): """ Register markdown for flatpages. """ admin.site.unregister(FlatPage) admin.site.register(FlatPage, LocalFlatPageAdmin)
python
def register(): """ Register markdown for flatpages. """ admin.site.unregister(FlatPage) admin.site.register(FlatPage, LocalFlatPageAdmin)
[ "def", "register", "(", ")", ":", "admin", ".", "site", ".", "unregister", "(", "FlatPage", ")", "admin", ".", "site", ".", "register", "(", "FlatPage", ",", "LocalFlatPageAdmin", ")" ]
Register markdown for flatpages.
[ "Register", "markdown", "for", "flatpages", "." ]
973968c68d79cbe35304e9d6da876ad33f427d2d
https://github.com/sv0/django-markdown-app/blob/973968c68d79cbe35304e9d6da876ad33f427d2d/django_markdown/flatpages.py#L25-L29
train
sv0/django-markdown-app
django_markdown/templatetags/django_markdown.py
markdown_editor
def markdown_editor(selector): """ Enable markdown editor for given textarea. :returns: Editor template context. """ return dict( selector=selector, extra_settings=mark_safe(simplejson.dumps( dict(previewParserPath=reverse('django_markdown_preview')))))
python
def markdown_editor(selector): """ Enable markdown editor for given textarea. :returns: Editor template context. """ return dict( selector=selector, extra_settings=mark_safe(simplejson.dumps( dict(previewParserPath=reverse('django_markdown_preview')))))
[ "def", "markdown_editor", "(", "selector", ")", ":", "return", "dict", "(", "selector", "=", "selector", ",", "extra_settings", "=", "mark_safe", "(", "simplejson", ".", "dumps", "(", "dict", "(", "previewParserPath", "=", "reverse", "(", "'django_markdown_previ...
Enable markdown editor for given textarea. :returns: Editor template context.
[ "Enable", "markdown", "editor", "for", "given", "textarea", "." ]
973968c68d79cbe35304e9d6da876ad33f427d2d
https://github.com/sv0/django-markdown-app/blob/973968c68d79cbe35304e9d6da876ad33f427d2d/django_markdown/templatetags/django_markdown.py#L57-L66
train
sv0/django-markdown-app
django_markdown/templatetags/django_markdown.py
markdown_media_css
def markdown_media_css(): """ Add css requirements to HTML. :returns: Editor template context. """ return dict( CSS_SET=posixpath.join( settings.MARKDOWN_SET_PATH, settings.MARKDOWN_SET_NAME, 'style.css' ), CSS_SKIN=posixpath.join( 'django_markdown', 'sk...
python
def markdown_media_css(): """ Add css requirements to HTML. :returns: Editor template context. """ return dict( CSS_SET=posixpath.join( settings.MARKDOWN_SET_PATH, settings.MARKDOWN_SET_NAME, 'style.css' ), CSS_SKIN=posixpath.join( 'django_markdown', 'sk...
[ "def", "markdown_media_css", "(", ")", ":", "return", "dict", "(", "CSS_SET", "=", "posixpath", ".", "join", "(", "settings", ".", "MARKDOWN_SET_PATH", ",", "settings", ".", "MARKDOWN_SET_NAME", ",", "'style.css'", ")", ",", "CSS_SKIN", "=", "posixpath", ".", ...
Add css requirements to HTML. :returns: Editor template context.
[ "Add", "css", "requirements", "to", "HTML", "." ]
973968c68d79cbe35304e9d6da876ad33f427d2d
https://github.com/sv0/django-markdown-app/blob/973968c68d79cbe35304e9d6da876ad33f427d2d/django_markdown/templatetags/django_markdown.py#L96-L110
train
sv0/django-markdown-app
django_markdown/pypandoc.py
convert
def convert(source, to, format=None, extra_args=(), encoding='utf-8'): """Convert given `source` from `format` `to` another. `source` may be either a file path or a string to be converted. It's possible to pass `extra_args` if needed. In case `format` is not provided, it will try to invert the format ...
python
def convert(source, to, format=None, extra_args=(), encoding='utf-8'): """Convert given `source` from `format` `to` another. `source` may be either a file path or a string to be converted. It's possible to pass `extra_args` if needed. In case `format` is not provided, it will try to invert the format ...
[ "def", "convert", "(", "source", ",", "to", ",", "format", "=", "None", ",", "extra_args", "=", "(", ")", ",", "encoding", "=", "'utf-8'", ")", ":", "return", "_convert", "(", "_read_file", ",", "_process_file", ",", "source", ",", "to", ",", "format",...
Convert given `source` from `format` `to` another. `source` may be either a file path or a string to be converted. It's possible to pass `extra_args` if needed. In case `format` is not provided, it will try to invert the format based on given `source`. Raises OSError if pandoc is not found! Make sure...
[ "Convert", "given", "source", "from", "format", "to", "another", "." ]
973968c68d79cbe35304e9d6da876ad33f427d2d
https://github.com/sv0/django-markdown-app/blob/973968c68d79cbe35304e9d6da876ad33f427d2d/django_markdown/pypandoc.py#L13-L28
train
sv0/django-markdown-app
django_markdown/pypandoc.py
get_pandoc_formats
def get_pandoc_formats(): """ Dynamic preprocessor for Pandoc formats. Return 2 lists. "from_formats" and "to_formats". """ try: p = subprocess.Popen( ['pandoc', '-h'], stdin=subprocess.PIPE, stdout=subprocess.PIPE) except OSError: raise OSError("...
python
def get_pandoc_formats(): """ Dynamic preprocessor for Pandoc formats. Return 2 lists. "from_formats" and "to_formats". """ try: p = subprocess.Popen( ['pandoc', '-h'], stdin=subprocess.PIPE, stdout=subprocess.PIPE) except OSError: raise OSError("...
[ "def", "get_pandoc_formats", "(", ")", ":", "try", ":", "p", "=", "subprocess", ".", "Popen", "(", "[", "'pandoc'", ",", "'-h'", "]", ",", "stdin", "=", "subprocess", ".", "PIPE", ",", "stdout", "=", "subprocess", ".", "PIPE", ")", "except", "OSError",...
Dynamic preprocessor for Pandoc formats. Return 2 lists. "from_formats" and "to_formats".
[ "Dynamic", "preprocessor", "for", "Pandoc", "formats", "." ]
973968c68d79cbe35304e9d6da876ad33f427d2d
https://github.com/sv0/django-markdown-app/blob/973968c68d79cbe35304e9d6da876ad33f427d2d/django_markdown/pypandoc.py#L89-L109
train
sv0/django-markdown-app
django_markdown/widgets.py
MarkdownWidget.render
def render(self, name, value, attrs=None, renderer=None): """ Render widget. :returns: A rendered HTML """ html = super(MarkdownWidget, self).render(name, value, attrs, renderer) attrs = self.build_attrs(attrs) html += editor_js_initialization("#%s" % attrs['id']) ...
python
def render(self, name, value, attrs=None, renderer=None): """ Render widget. :returns: A rendered HTML """ html = super(MarkdownWidget, self).render(name, value, attrs, renderer) attrs = self.build_attrs(attrs) html += editor_js_initialization("#%s" % attrs['id']) ...
[ "def", "render", "(", "self", ",", "name", ",", "value", ",", "attrs", "=", "None", ",", "renderer", "=", "None", ")", ":", "html", "=", "super", "(", "MarkdownWidget", ",", "self", ")", ".", "render", "(", "name", ",", "value", ",", "attrs", ",", ...
Render widget. :returns: A rendered HTML
[ "Render", "widget", "." ]
973968c68d79cbe35304e9d6da876ad33f427d2d
https://github.com/sv0/django-markdown-app/blob/973968c68d79cbe35304e9d6da876ad33f427d2d/django_markdown/widgets.py#L29-L38
train
sprin/markdown-inline-graphviz
mdx_inline_graphviz.py
InlineGraphvizExtension.extendMarkdown
def extendMarkdown(self, md, md_globals): """ Add InlineGraphvizPreprocessor to the Markdown instance. """ md.registerExtension(self) md.preprocessors.add('graphviz_block', InlineGraphvizPreprocessor(md), "_begin")
python
def extendMarkdown(self, md, md_globals): """ Add InlineGraphvizPreprocessor to the Markdown instance. """ md.registerExtension(self) md.preprocessors.add('graphviz_block', InlineGraphvizPreprocessor(md), "_begin")
[ "def", "extendMarkdown", "(", "self", ",", "md", ",", "md_globals", ")", ":", "md", ".", "registerExtension", "(", "self", ")", "md", ".", "preprocessors", ".", "add", "(", "'graphviz_block'", ",", "InlineGraphvizPreprocessor", "(", "md", ")", ",", "\"_begin...
Add InlineGraphvizPreprocessor to the Markdown instance.
[ "Add", "InlineGraphvizPreprocessor", "to", "the", "Markdown", "instance", "." ]
9664863b3002d88243c9ee5e14c195e037e54618
https://github.com/sprin/markdown-inline-graphviz/blob/9664863b3002d88243c9ee5e14c195e037e54618/mdx_inline_graphviz.py#L38-L44
train
sprin/markdown-inline-graphviz
mdx_inline_graphviz.py
InlineGraphvizPreprocessor.run
def run(self, lines): """ Match and generate dot code blocks.""" text = "\n".join(lines) while 1: m = BLOCK_RE.search(text) if m: command = m.group('command') # Whitelist command, prevent command injection. if command not i...
python
def run(self, lines): """ Match and generate dot code blocks.""" text = "\n".join(lines) while 1: m = BLOCK_RE.search(text) if m: command = m.group('command') # Whitelist command, prevent command injection. if command not i...
[ "def", "run", "(", "self", ",", "lines", ")", ":", "text", "=", "\"\\n\"", ".", "join", "(", "lines", ")", "while", "1", ":", "m", "=", "BLOCK_RE", ".", "search", "(", "text", ")", "if", "m", ":", "command", "=", "m", ".", "group", "(", "'comma...
Match and generate dot code blocks.
[ "Match", "and", "generate", "dot", "code", "blocks", "." ]
9664863b3002d88243c9ee5e14c195e037e54618
https://github.com/sprin/markdown-inline-graphviz/blob/9664863b3002d88243c9ee5e14c195e037e54618/mdx_inline_graphviz.py#L52-L104
train
zabuldon/teslajsonpy
teslajsonpy/connection.py
Connection.post
def post(self, command, data=None): """Post data to API.""" now = calendar.timegm(datetime.datetime.now().timetuple()) if now > self.expiration: auth = self.__open("/oauth/token", data=self.oauth) self.__sethead(auth['access_token']) return self.__open("%s%s" % (s...
python
def post(self, command, data=None): """Post data to API.""" now = calendar.timegm(datetime.datetime.now().timetuple()) if now > self.expiration: auth = self.__open("/oauth/token", data=self.oauth) self.__sethead(auth['access_token']) return self.__open("%s%s" % (s...
[ "def", "post", "(", "self", ",", "command", ",", "data", "=", "None", ")", ":", "now", "=", "calendar", ".", "timegm", "(", "datetime", ".", "datetime", ".", "now", "(", ")", ".", "timetuple", "(", ")", ")", "if", "now", ">", "self", ".", "expira...
Post data to API.
[ "Post", "data", "to", "API", "." ]
673ecdb5c9483160fb1b97e30e62f2c863761c39
https://github.com/zabuldon/teslajsonpy/blob/673ecdb5c9483160fb1b97e30e62f2c863761c39/teslajsonpy/connection.py#L49-L56
train
zabuldon/teslajsonpy
teslajsonpy/connection.py
Connection.__sethead
def __sethead(self, access_token): """Set HTTP header.""" self.access_token = access_token now = calendar.timegm(datetime.datetime.now().timetuple()) self.expiration = now + 1800 self.head = {"Authorization": "Bearer %s" % access_token, "User-Agent": self.use...
python
def __sethead(self, access_token): """Set HTTP header.""" self.access_token = access_token now = calendar.timegm(datetime.datetime.now().timetuple()) self.expiration = now + 1800 self.head = {"Authorization": "Bearer %s" % access_token, "User-Agent": self.use...
[ "def", "__sethead", "(", "self", ",", "access_token", ")", ":", "self", ".", "access_token", "=", "access_token", "now", "=", "calendar", ".", "timegm", "(", "datetime", ".", "datetime", ".", "now", "(", ")", ".", "timetuple", "(", ")", ")", "self", "....
Set HTTP header.
[ "Set", "HTTP", "header", "." ]
673ecdb5c9483160fb1b97e30e62f2c863761c39
https://github.com/zabuldon/teslajsonpy/blob/673ecdb5c9483160fb1b97e30e62f2c863761c39/teslajsonpy/connection.py#L58-L65
train
zabuldon/teslajsonpy
teslajsonpy/connection.py
Connection.__open
def __open(self, url, headers=None, data=None, baseurl=""): """Use raw urlopen command.""" headers = headers or {} if not baseurl: baseurl = self.baseurl req = Request("%s%s" % (baseurl, url), headers=headers) _LOGGER.debug(url) try: req.data = ur...
python
def __open(self, url, headers=None, data=None, baseurl=""): """Use raw urlopen command.""" headers = headers or {} if not baseurl: baseurl = self.baseurl req = Request("%s%s" % (baseurl, url), headers=headers) _LOGGER.debug(url) try: req.data = ur...
[ "def", "__open", "(", "self", ",", "url", ",", "headers", "=", "None", ",", "data", "=", "None", ",", "baseurl", "=", "\"\"", ")", ":", "headers", "=", "headers", "or", "{", "}", "if", "not", "baseurl", ":", "baseurl", "=", "self", ".", "baseurl", ...
Use raw urlopen command.
[ "Use", "raw", "urlopen", "command", "." ]
673ecdb5c9483160fb1b97e30e62f2c863761c39
https://github.com/zabuldon/teslajsonpy/blob/673ecdb5c9483160fb1b97e30e62f2c863761c39/teslajsonpy/connection.py#L67-L92
train
zabuldon/teslajsonpy
teslajsonpy/binary_sensor.py
ParkingSensor.update
def update(self): """Update the parking brake sensor.""" self._controller.update(self._id, wake_if_asleep=False) data = self._controller.get_drive_params(self._id) if data: if not data['shift_state'] or data['shift_state'] == 'P': self.__state = True ...
python
def update(self): """Update the parking brake sensor.""" self._controller.update(self._id, wake_if_asleep=False) data = self._controller.get_drive_params(self._id) if data: if not data['shift_state'] or data['shift_state'] == 'P': self.__state = True ...
[ "def", "update", "(", "self", ")", ":", "self", ".", "_controller", ".", "update", "(", "self", ".", "_id", ",", "wake_if_asleep", "=", "False", ")", "data", "=", "self", ".", "_controller", ".", "get_drive_params", "(", "self", ".", "_id", ")", "if", ...
Update the parking brake sensor.
[ "Update", "the", "parking", "brake", "sensor", "." ]
673ecdb5c9483160fb1b97e30e62f2c863761c39
https://github.com/zabuldon/teslajsonpy/blob/673ecdb5c9483160fb1b97e30e62f2c863761c39/teslajsonpy/binary_sensor.py#L48-L56
train
zabuldon/teslajsonpy
teslajsonpy/climate.py
Climate.update
def update(self): """Update the HVAC state.""" self._controller.update(self._id, wake_if_asleep=False) data = self._controller.get_climate_params(self._id) if data: if time.time() - self.__manual_update_time > 60: self.__is_auto_conditioning_on = (data ...
python
def update(self): """Update the HVAC state.""" self._controller.update(self._id, wake_if_asleep=False) data = self._controller.get_climate_params(self._id) if data: if time.time() - self.__manual_update_time > 60: self.__is_auto_conditioning_on = (data ...
[ "def", "update", "(", "self", ")", ":", "self", ".", "_controller", ".", "update", "(", "self", ".", "_id", ",", "wake_if_asleep", "=", "False", ")", "data", "=", "self", ".", "_controller", ".", "get_climate_params", "(", "self", ".", "_id", ")", "if"...
Update the HVAC state.
[ "Update", "the", "HVAC", "state", "." ]
673ecdb5c9483160fb1b97e30e62f2c863761c39
https://github.com/zabuldon/teslajsonpy/blob/673ecdb5c9483160fb1b97e30e62f2c863761c39/teslajsonpy/climate.py#L76-L98
train
zabuldon/teslajsonpy
teslajsonpy/climate.py
Climate.set_temperature
def set_temperature(self, temp): """Set both the driver and passenger temperature to temp.""" temp = round(temp, 1) self.__manual_update_time = time.time() data = self._controller.command(self._id, 'set_temps', {"driver_temp": temp, ...
python
def set_temperature(self, temp): """Set both the driver and passenger temperature to temp.""" temp = round(temp, 1) self.__manual_update_time = time.time() data = self._controller.command(self._id, 'set_temps', {"driver_temp": temp, ...
[ "def", "set_temperature", "(", "self", ",", "temp", ")", ":", "temp", "=", "round", "(", "temp", ",", "1", ")", "self", ".", "__manual_update_time", "=", "time", ".", "time", "(", ")", "data", "=", "self", ".", "_controller", ".", "command", "(", "se...
Set both the driver and passenger temperature to temp.
[ "Set", "both", "the", "driver", "and", "passenger", "temperature", "to", "temp", "." ]
673ecdb5c9483160fb1b97e30e62f2c863761c39
https://github.com/zabuldon/teslajsonpy/blob/673ecdb5c9483160fb1b97e30e62f2c863761c39/teslajsonpy/climate.py#L100-L110
train
zabuldon/teslajsonpy
teslajsonpy/climate.py
Climate.set_status
def set_status(self, enabled): """Enable or disable the HVAC.""" self.__manual_update_time = time.time() if enabled: data = self._controller.command(self._id, 'auto_conditioning_start', wake_if_as...
python
def set_status(self, enabled): """Enable or disable the HVAC.""" self.__manual_update_time = time.time() if enabled: data = self._controller.command(self._id, 'auto_conditioning_start', wake_if_as...
[ "def", "set_status", "(", "self", ",", "enabled", ")", ":", "self", ".", "__manual_update_time", "=", "time", ".", "time", "(", ")", "if", "enabled", ":", "data", "=", "self", ".", "_controller", ".", "command", "(", "self", ".", "_id", ",", "'auto_con...
Enable or disable the HVAC.
[ "Enable", "or", "disable", "the", "HVAC", "." ]
673ecdb5c9483160fb1b97e30e62f2c863761c39
https://github.com/zabuldon/teslajsonpy/blob/673ecdb5c9483160fb1b97e30e62f2c863761c39/teslajsonpy/climate.py#L112-L129
train
zabuldon/teslajsonpy
teslajsonpy/climate.py
TempSensor.update
def update(self): """Update the temperature.""" self._controller.update(self._id, wake_if_asleep=False) data = self._controller.get_climate_params(self._id) if data: self.__inside_temp = (data['inside_temp'] if data['inside_temp'] else self._...
python
def update(self): """Update the temperature.""" self._controller.update(self._id, wake_if_asleep=False) data = self._controller.get_climate_params(self._id) if data: self.__inside_temp = (data['inside_temp'] if data['inside_temp'] else self._...
[ "def", "update", "(", "self", ")", ":", "self", ".", "_controller", ".", "update", "(", "self", ".", "_id", ",", "wake_if_asleep", "=", "False", ")", "data", "=", "self", ".", "_controller", ".", "get_climate_params", "(", "self", ".", "_id", ")", "if"...
Update the temperature.
[ "Update", "the", "temperature", "." ]
673ecdb5c9483160fb1b97e30e62f2c863761c39
https://github.com/zabuldon/teslajsonpy/blob/673ecdb5c9483160fb1b97e30e62f2c863761c39/teslajsonpy/climate.py#L181-L189
train
zabuldon/teslajsonpy
teslajsonpy/charger.py
ChargerSwitch.update
def update(self): """Update the charging state of the Tesla Vehicle.""" self._controller.update(self._id, wake_if_asleep=False) data = self._controller.get_charging_params(self._id) if data and (time.time() - self.__manual_update_time > 60): if data['charging_state'] != "Char...
python
def update(self): """Update the charging state of the Tesla Vehicle.""" self._controller.update(self._id, wake_if_asleep=False) data = self._controller.get_charging_params(self._id) if data and (time.time() - self.__manual_update_time > 60): if data['charging_state'] != "Char...
[ "def", "update", "(", "self", ")", ":", "self", ".", "_controller", ".", "update", "(", "self", ".", "_id", ",", "wake_if_asleep", "=", "False", ")", "data", "=", "self", ".", "_controller", ".", "get_charging_params", "(", "self", ".", "_id", ")", "if...
Update the charging state of the Tesla Vehicle.
[ "Update", "the", "charging", "state", "of", "the", "Tesla", "Vehicle", "." ]
673ecdb5c9483160fb1b97e30e62f2c863761c39
https://github.com/zabuldon/teslajsonpy/blob/673ecdb5c9483160fb1b97e30e62f2c863761c39/teslajsonpy/charger.py#L44-L52
train
zabuldon/teslajsonpy
teslajsonpy/charger.py
ChargerSwitch.start_charge
def start_charge(self): """Start charging the Tesla Vehicle.""" if not self.__charger_state: data = self._controller.command(self._id, 'charge_start', wake_if_asleep=True) if data and data['response']['result']: self.__c...
python
def start_charge(self): """Start charging the Tesla Vehicle.""" if not self.__charger_state: data = self._controller.command(self._id, 'charge_start', wake_if_asleep=True) if data and data['response']['result']: self.__c...
[ "def", "start_charge", "(", "self", ")", ":", "if", "not", "self", ".", "__charger_state", ":", "data", "=", "self", ".", "_controller", ".", "command", "(", "self", ".", "_id", ",", "'charge_start'", ",", "wake_if_asleep", "=", "True", ")", "if", "data"...
Start charging the Tesla Vehicle.
[ "Start", "charging", "the", "Tesla", "Vehicle", "." ]
673ecdb5c9483160fb1b97e30e62f2c863761c39
https://github.com/zabuldon/teslajsonpy/blob/673ecdb5c9483160fb1b97e30e62f2c863761c39/teslajsonpy/charger.py#L54-L61
train
zabuldon/teslajsonpy
teslajsonpy/charger.py
ChargerSwitch.stop_charge
def stop_charge(self): """Stop charging the Tesla Vehicle.""" if self.__charger_state: data = self._controller.command(self._id, 'charge_stop', wake_if_asleep=True) if data and data['response']['result']: self.__charger_...
python
def stop_charge(self): """Stop charging the Tesla Vehicle.""" if self.__charger_state: data = self._controller.command(self._id, 'charge_stop', wake_if_asleep=True) if data and data['response']['result']: self.__charger_...
[ "def", "stop_charge", "(", "self", ")", ":", "if", "self", ".", "__charger_state", ":", "data", "=", "self", ".", "_controller", ".", "command", "(", "self", ".", "_id", ",", "'charge_stop'", ",", "wake_if_asleep", "=", "True", ")", "if", "data", "and", ...
Stop charging the Tesla Vehicle.
[ "Stop", "charging", "the", "Tesla", "Vehicle", "." ]
673ecdb5c9483160fb1b97e30e62f2c863761c39
https://github.com/zabuldon/teslajsonpy/blob/673ecdb5c9483160fb1b97e30e62f2c863761c39/teslajsonpy/charger.py#L63-L70
train
zabuldon/teslajsonpy
teslajsonpy/charger.py
RangeSwitch.update
def update(self): """Update the status of the range setting.""" self._controller.update(self._id, wake_if_asleep=False) data = self._controller.get_charging_params(self._id) if data and (time.time() - self.__manual_update_time > 60): self.__maxrange_state = data['charge_to_ma...
python
def update(self): """Update the status of the range setting.""" self._controller.update(self._id, wake_if_asleep=False) data = self._controller.get_charging_params(self._id) if data and (time.time() - self.__manual_update_time > 60): self.__maxrange_state = data['charge_to_ma...
[ "def", "update", "(", "self", ")", ":", "self", ".", "_controller", ".", "update", "(", "self", ".", "_id", ",", "wake_if_asleep", "=", "False", ")", "data", "=", "self", ".", "_controller", ".", "get_charging_params", "(", "self", ".", "_id", ")", "if...
Update the status of the range setting.
[ "Update", "the", "status", "of", "the", "range", "setting", "." ]
673ecdb5c9483160fb1b97e30e62f2c863761c39
https://github.com/zabuldon/teslajsonpy/blob/673ecdb5c9483160fb1b97e30e62f2c863761c39/teslajsonpy/charger.py#L97-L102
train
zabuldon/teslajsonpy
teslajsonpy/charger.py
RangeSwitch.set_max
def set_max(self): """Set the charger to max range for trips.""" if not self.__maxrange_state: data = self._controller.command(self._id, 'charge_max_range', wake_if_asleep=True) if data['response']['result']: self.__maxr...
python
def set_max(self): """Set the charger to max range for trips.""" if not self.__maxrange_state: data = self._controller.command(self._id, 'charge_max_range', wake_if_asleep=True) if data['response']['result']: self.__maxr...
[ "def", "set_max", "(", "self", ")", ":", "if", "not", "self", ".", "__maxrange_state", ":", "data", "=", "self", ".", "_controller", ".", "command", "(", "self", ".", "_id", ",", "'charge_max_range'", ",", "wake_if_asleep", "=", "True", ")", "if", "data"...
Set the charger to max range for trips.
[ "Set", "the", "charger", "to", "max", "range", "for", "trips", "." ]
673ecdb5c9483160fb1b97e30e62f2c863761c39
https://github.com/zabuldon/teslajsonpy/blob/673ecdb5c9483160fb1b97e30e62f2c863761c39/teslajsonpy/charger.py#L104-L111
train
zabuldon/teslajsonpy
teslajsonpy/charger.py
RangeSwitch.set_standard
def set_standard(self): """Set the charger to standard range for daily commute.""" if self.__maxrange_state: data = self._controller.command(self._id, 'charge_standard', wake_if_asleep=True) if data and data['response']['result']: ...
python
def set_standard(self): """Set the charger to standard range for daily commute.""" if self.__maxrange_state: data = self._controller.command(self._id, 'charge_standard', wake_if_asleep=True) if data and data['response']['result']: ...
[ "def", "set_standard", "(", "self", ")", ":", "if", "self", ".", "__maxrange_state", ":", "data", "=", "self", ".", "_controller", ".", "command", "(", "self", ".", "_id", ",", "'charge_standard'", ",", "wake_if_asleep", "=", "True", ")", "if", "data", "...
Set the charger to standard range for daily commute.
[ "Set", "the", "charger", "to", "standard", "range", "for", "daily", "commute", "." ]
673ecdb5c9483160fb1b97e30e62f2c863761c39
https://github.com/zabuldon/teslajsonpy/blob/673ecdb5c9483160fb1b97e30e62f2c863761c39/teslajsonpy/charger.py#L113-L120
train
zabuldon/teslajsonpy
teslajsonpy/lock.py
Lock.unlock
def unlock(self): """Unlock the doors and extend handles where applicable.""" if self.__lock_state: data = self._controller.command(self._id, 'door_unlock', wake_if_asleep=True) if data['response']['result']: self.__lock...
python
def unlock(self): """Unlock the doors and extend handles where applicable.""" if self.__lock_state: data = self._controller.command(self._id, 'door_unlock', wake_if_asleep=True) if data['response']['result']: self.__lock...
[ "def", "unlock", "(", "self", ")", ":", "if", "self", ".", "__lock_state", ":", "data", "=", "self", ".", "_controller", ".", "command", "(", "self", ".", "_id", ",", "'door_unlock'", ",", "wake_if_asleep", "=", "True", ")", "if", "data", "[", "'respon...
Unlock the doors and extend handles where applicable.
[ "Unlock", "the", "doors", "and", "extend", "handles", "where", "applicable", "." ]
673ecdb5c9483160fb1b97e30e62f2c863761c39
https://github.com/zabuldon/teslajsonpy/blob/673ecdb5c9483160fb1b97e30e62f2c863761c39/teslajsonpy/lock.py#L66-L73
train
zabuldon/teslajsonpy
teslajsonpy/lock.py
ChargerLock.lock
def lock(self): """Close the charger door.""" if not self.__lock_state: data = self._controller.command(self._id, 'charge_port_door_close', wake_if_asleep=True) if data['response']['result']: self.__lock_state = True ...
python
def lock(self): """Close the charger door.""" if not self.__lock_state: data = self._controller.command(self._id, 'charge_port_door_close', wake_if_asleep=True) if data['response']['result']: self.__lock_state = True ...
[ "def", "lock", "(", "self", ")", ":", "if", "not", "self", ".", "__lock_state", ":", "data", "=", "self", ".", "_controller", ".", "command", "(", "self", ".", "_id", ",", "'charge_port_door_close'", ",", "wake_if_asleep", "=", "True", ")", "if", "data",...
Close the charger door.
[ "Close", "the", "charger", "door", "." ]
673ecdb5c9483160fb1b97e30e62f2c863761c39
https://github.com/zabuldon/teslajsonpy/blob/673ecdb5c9483160fb1b97e30e62f2c863761c39/teslajsonpy/lock.py#L128-L135
train
zabuldon/teslajsonpy
teslajsonpy/controller.py
Controller.wake_up
def wake_up(func): # pylint: disable=no-self-argument # issue is use of wraps on classmethods which should be replaced: # https://hynek.me/articles/decorators/ """Wrap a API f so it will attempt to wake the vehicle if asleep. The command f is run once if the vehicle_id was la...
python
def wake_up(func): # pylint: disable=no-self-argument # issue is use of wraps on classmethods which should be replaced: # https://hynek.me/articles/decorators/ """Wrap a API f so it will attempt to wake the vehicle if asleep. The command f is run once if the vehicle_id was la...
[ "def", "wake_up", "(", "func", ")", ":", "@", "wraps", "(", "func", ")", "def", "wrapped", "(", "*", "args", ",", "**", "kwargs", ")", ":", "def", "valid_result", "(", "result", ")", ":", "try", ":", "return", "(", "result", "is", "not", "None", ...
Wrap a API f so it will attempt to wake the vehicle if asleep. The command f is run once if the vehicle_id was last reported online. Assuming f returns None and wake_if_asleep is True, 5 attempts will be made to wake the vehicle to reissue the command. In addition, if there is a `could_...
[ "Wrap", "a", "API", "f", "so", "it", "will", "attempt", "to", "wake", "the", "vehicle", "if", "asleep", "." ]
673ecdb5c9483160fb1b97e30e62f2c863761c39
https://github.com/zabuldon/teslajsonpy/blob/673ecdb5c9483160fb1b97e30e62f2c863761c39/teslajsonpy/controller.py#L95-L209
train
zabuldon/teslajsonpy
teslajsonpy/controller.py
Controller.post
def post(self, vehicle_id, command, data=None, wake_if_asleep=True): # pylint: disable=unused-argument """Send post command to the vehicle_id. This is a wrapped function by wake_up. Parameters ---------- vehicle_id : string Identifier for the car on the own...
python
def post(self, vehicle_id, command, data=None, wake_if_asleep=True): # pylint: disable=unused-argument """Send post command to the vehicle_id. This is a wrapped function by wake_up. Parameters ---------- vehicle_id : string Identifier for the car on the own...
[ "def", "post", "(", "self", ",", "vehicle_id", ",", "command", ",", "data", "=", "None", ",", "wake_if_asleep", "=", "True", ")", ":", "data", "=", "data", "or", "{", "}", "return", "self", ".", "__connection", ".", "post", "(", "'vehicles/%i/%s'", "%"...
Send post command to the vehicle_id. This is a wrapped function by wake_up. Parameters ---------- vehicle_id : string Identifier for the car on the owner-api endpoint. Confusingly it is not the vehicle_id field for identifying the car across differen...
[ "Send", "post", "command", "to", "the", "vehicle_id", "." ]
673ecdb5c9483160fb1b97e30e62f2c863761c39
https://github.com/zabuldon/teslajsonpy/blob/673ecdb5c9483160fb1b97e30e62f2c863761c39/teslajsonpy/controller.py#L216-L245
train
zabuldon/teslajsonpy
teslajsonpy/controller.py
Controller.get
def get(self, vehicle_id, command, wake_if_asleep=False): # pylint: disable=unused-argument """Send get command to the vehicle_id. This is a wrapped function by wake_up. Parameters ---------- vehicle_id : string Identifier for the car on the owner-api endpo...
python
def get(self, vehicle_id, command, wake_if_asleep=False): # pylint: disable=unused-argument """Send get command to the vehicle_id. This is a wrapped function by wake_up. Parameters ---------- vehicle_id : string Identifier for the car on the owner-api endpo...
[ "def", "get", "(", "self", ",", "vehicle_id", ",", "command", ",", "wake_if_asleep", "=", "False", ")", ":", "return", "self", ".", "__connection", ".", "get", "(", "'vehicles/%i/%s'", "%", "(", "vehicle_id", ",", "command", ")", ")" ]
Send get command to the vehicle_id. This is a wrapped function by wake_up. Parameters ---------- vehicle_id : string Identifier for the car on the owner-api endpoint. Confusingly it is not the vehicle_id field for identifying the car across different...
[ "Send", "get", "command", "to", "the", "vehicle_id", "." ]
673ecdb5c9483160fb1b97e30e62f2c863761c39
https://github.com/zabuldon/teslajsonpy/blob/673ecdb5c9483160fb1b97e30e62f2c863761c39/teslajsonpy/controller.py#L248-L273
train
zabuldon/teslajsonpy
teslajsonpy/controller.py
Controller.data_request
def data_request(self, vehicle_id, name, wake_if_asleep=False): """Get requested data from vehicle_id. Parameters ---------- vehicle_id : string Identifier for the car on the owner-api endpoint. Confusingly it is not the vehicle_id field for identifying the car a...
python
def data_request(self, vehicle_id, name, wake_if_asleep=False): """Get requested data from vehicle_id. Parameters ---------- vehicle_id : string Identifier for the car on the owner-api endpoint. Confusingly it is not the vehicle_id field for identifying the car a...
[ "def", "data_request", "(", "self", ",", "vehicle_id", ",", "name", ",", "wake_if_asleep", "=", "False", ")", ":", "return", "self", ".", "get", "(", "vehicle_id", ",", "'vehicle_data/%s'", "%", "name", ",", "wake_if_asleep", "=", "wake_if_asleep", ")", "[",...
Get requested data from vehicle_id. Parameters ---------- vehicle_id : string Identifier for the car on the owner-api endpoint. Confusingly it is not the vehicle_id field for identifying the car across different endpoints. https://tesla-api.timdor...
[ "Get", "requested", "data", "from", "vehicle_id", "." ]
673ecdb5c9483160fb1b97e30e62f2c863761c39
https://github.com/zabuldon/teslajsonpy/blob/673ecdb5c9483160fb1b97e30e62f2c863761c39/teslajsonpy/controller.py#L275-L300
train
zabuldon/teslajsonpy
teslajsonpy/controller.py
Controller.command
def command(self, vehicle_id, name, data=None, wake_if_asleep=True): """Post name command to the vehicle_id. Parameters ---------- vehicle_id : string Identifier for the car on the owner-api endpoint. Confusingly it is not the vehicle_id field for identifying the...
python
def command(self, vehicle_id, name, data=None, wake_if_asleep=True): """Post name command to the vehicle_id. Parameters ---------- vehicle_id : string Identifier for the car on the owner-api endpoint. Confusingly it is not the vehicle_id field for identifying the...
[ "def", "command", "(", "self", ",", "vehicle_id", ",", "name", ",", "data", "=", "None", ",", "wake_if_asleep", "=", "True", ")", ":", "data", "=", "data", "or", "{", "}", "return", "self", ".", "post", "(", "vehicle_id", ",", "'command/%s'", "%", "n...
Post name command to the vehicle_id. Parameters ---------- vehicle_id : string Identifier for the car on the owner-api endpoint. Confusingly it is not the vehicle_id field for identifying the car across different endpoints. https://tesla-api.timdo...
[ "Post", "name", "command", "to", "the", "vehicle_id", "." ]
673ecdb5c9483160fb1b97e30e62f2c863761c39
https://github.com/zabuldon/teslajsonpy/blob/673ecdb5c9483160fb1b97e30e62f2c863761c39/teslajsonpy/controller.py#L302-L328
train
zabuldon/teslajsonpy
teslajsonpy/controller.py
Controller.update
def update(self, car_id=None, wake_if_asleep=False, force=False): """Update all vehicle attributes in the cache. This command will connect to the Tesla API and first update the list of online vehicles assuming no attempt for at least the [update_interval]. It will then update all the ca...
python
def update(self, car_id=None, wake_if_asleep=False, force=False): """Update all vehicle attributes in the cache. This command will connect to the Tesla API and first update the list of online vehicles assuming no attempt for at least the [update_interval]. It will then update all the ca...
[ "def", "update", "(", "self", ",", "car_id", "=", "None", ",", "wake_if_asleep", "=", "False", ",", "force", "=", "False", ")", ":", "cur_time", "=", "time", ".", "time", "(", ")", "with", "self", ".", "__lock", ":", "last_update", "=", "self", ".", ...
Update all vehicle attributes in the cache. This command will connect to the Tesla API and first update the list of online vehicles assuming no attempt for at least the [update_interval]. It will then update all the cached values for cars that are awake assuming no update has occurred f...
[ "Update", "all", "vehicle", "attributes", "in", "the", "cache", "." ]
673ecdb5c9483160fb1b97e30e62f2c863761c39
https://github.com/zabuldon/teslajsonpy/blob/673ecdb5c9483160fb1b97e30e62f2c863761c39/teslajsonpy/controller.py#L351-L413
train