repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
KarchinLab/probabilistic2020 | prob2020/python/sequence_context.py | SequenceContext._init_context | def _init_context(self, gene_seq):
"""Initializes attributes defining mutation contexts and their position.
The self.context2pos and self.pos2context dictionaries map from
sequence context to sequence position and sequence position to
sequence context, respectively. These attributes all... | python | def _init_context(self, gene_seq):
"""Initializes attributes defining mutation contexts and their position.
The self.context2pos and self.pos2context dictionaries map from
sequence context to sequence position and sequence position to
sequence context, respectively. These attributes all... | [
"def",
"_init_context",
"(",
"self",
",",
"gene_seq",
")",
":",
"self",
".",
"context2pos",
",",
"self",
".",
"pos2context",
"=",
"{",
"}",
",",
"{",
"}",
"gene_len",
"=",
"len",
"(",
"gene_seq",
".",
"exon_seq",
")",
"# get length of CDS",
"five_ss_len",
... | Initializes attributes defining mutation contexts and their position.
The self.context2pos and self.pos2context dictionaries map from
sequence context to sequence position and sequence position to
sequence context, respectively. These attributes allow for randomly
sampling of mutation p... | [
"Initializes",
"attributes",
"defining",
"mutation",
"contexts",
"and",
"their",
"position",
"."
] | train | https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/sequence_context.py#L20-L155 |
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",
")",
":",
"# make sure provide context is valid",
"if",
"not",
"self",
".",
"is_valid_context",
"(",
"context",
")",
":",
"error_msg",
"=",
"'Context ({0}) was never seen in... | 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",
"."
] | train | https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/sequence_context.py#L167-L205 |
KarchinLab/probabilistic2020 | prob2020/python/sequence_context.py | SequenceContext.random_pos | def random_pos(self, context_iterable, num_permutations):
"""Obtains random positions w/ replacement which match sequence context.
Parameters
----------
context_iterable: iterable containing two element tuple
Records number of mutations in each context. context_iterable
... | python | def random_pos(self, context_iterable, num_permutations):
"""Obtains random positions w/ replacement which match sequence context.
Parameters
----------
context_iterable: iterable containing two element tuple
Records number of mutations in each context. context_iterable
... | [
"def",
"random_pos",
"(",
"self",
",",
"context_iterable",
",",
"num_permutations",
")",
":",
"position_list",
"=",
"[",
"]",
"for",
"contxt",
",",
"n",
"in",
"context_iterable",
":",
"pos_array",
"=",
"self",
".",
"random_context_pos",
"(",
"n",
",",
"num_p... | Obtains random positions w/ replacement which match sequence context.
Parameters
----------
context_iterable: iterable containing two element tuple
Records number of mutations in each context. context_iterable
should be something like [('AA', 5), ...].
num_permut... | [
"Obtains",
"random",
"positions",
"w",
"/",
"replacement",
"which",
"match",
"sequence",
"context",
"."
] | train | https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/sequence_context.py#L207-L228 |
KarchinLab/probabilistic2020 | prob2020/console/annotate.py | multiprocess_permutation | def multiprocess_permutation(bed_dict, mut_df, opts, indel_df=None):
"""Handles parallelization of permutations by splitting work
by chromosome.
"""
chroms = sorted(bed_dict.keys(), key=lambda x: len(bed_dict[x]), reverse=True)
multiprocess_flag = opts['processes']>0
if multiprocess_flag:
... | python | def multiprocess_permutation(bed_dict, mut_df, opts, indel_df=None):
"""Handles parallelization of permutations by splitting work
by chromosome.
"""
chroms = sorted(bed_dict.keys(), key=lambda x: len(bed_dict[x]), reverse=True)
multiprocess_flag = opts['processes']>0
if multiprocess_flag:
... | [
"def",
"multiprocess_permutation",
"(",
"bed_dict",
",",
"mut_df",
",",
"opts",
",",
"indel_df",
"=",
"None",
")",
":",
"chroms",
"=",
"sorted",
"(",
"bed_dict",
".",
"keys",
"(",
")",
",",
"key",
"=",
"lambda",
"x",
":",
"len",
"(",
"bed_dict",
"[",
... | Handles parallelization of permutations by splitting work
by chromosome. | [
"Handles",
"parallelization",
"of",
"permutations",
"by",
"splitting",
"work",
"by",
"chromosome",
"."
] | train | https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/console/annotate.py#L32-L155 |
KarchinLab/probabilistic2020 | prob2020/console/simulate_non_silent_ratio.py | multiprocess_permutation | def multiprocess_permutation(bed_dict, mut_df, opts):
"""Handles parallelization of permutations by splitting work
by chromosome.
"""
chroms = sorted(bed_dict.keys())
multiprocess_flag = opts['processes']>0
if multiprocess_flag:
num_processes = opts['processes']
else:
num_pro... | python | def multiprocess_permutation(bed_dict, mut_df, opts):
"""Handles parallelization of permutations by splitting work
by chromosome.
"""
chroms = sorted(bed_dict.keys())
multiprocess_flag = opts['processes']>0
if multiprocess_flag:
num_processes = opts['processes']
else:
num_pro... | [
"def",
"multiprocess_permutation",
"(",
"bed_dict",
",",
"mut_df",
",",
"opts",
")",
":",
"chroms",
"=",
"sorted",
"(",
"bed_dict",
".",
"keys",
"(",
")",
")",
"multiprocess_flag",
"=",
"opts",
"[",
"'processes'",
"]",
">",
"0",
"if",
"multiprocess_flag",
... | Handles parallelization of permutations by splitting work
by chromosome. | [
"Handles",
"parallelization",
"of",
"permutations",
"by",
"splitting",
"work",
"by",
"chromosome",
"."
] | train | https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/console/simulate_non_silent_ratio.py#L32-L109 |
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",
")",
":",
"# get variant types",
"#var_class = cutils.ge... | Retrieves scores from pickle files.
Used by summary script. | [
"Retrieves",
"scores",
"from",
"pickle",
"files",
"."
] | train | https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/scores.py#L15-L79 |
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",
"."
] | train | https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/scores.py#L82-L107 |
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",
")",
":",
"# return default value if VEST scores are missing",
"if",
"vest_dict",
"is",
"Non... | 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",
"."
] | train | https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/scores.py#L110-L151 |
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",
")",
":",
"# return default value if VEST scores are missing",
"if",
"mga_vec",
"is",
"None",
":",
"return",
"default_val",... | 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"
] | train | https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/scores.py#L154-L188 |
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",
")",
")",
":",
"# mak... | 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",
"."
] | train | https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/scores.py#L191-L225 |
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",
")",
":",
"# keep only positions in range of MGAEntropy scores",
"len_mga",
"=",
"len",
"(",
"mga_vec",
")",
"good_codon_pos",
"=",
"[",
"p",
"for",
"p",
"in",
"codon_pos... | 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",
"."
] | train | https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/scores.py#L228-L258 |
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",
"."
] | train | https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/scores.py#L261-L282 |
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",
")",
":",
"# skip if there are no missense mutations",
"if",
"not",
"len",
"(",
"pos_ct",
")",
":",
"return",
"1.0",
",",
"0",
"max_pos",
"=",
"max",
"(",
"gene_graph",
")",... | 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",
"."
] | train | https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/scores.py#L285-L334 |
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",
"."
] | train | https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/count_frameshifts.py#L6-L64 |
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",
"."
] | train | https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/gene_sequence.py#L153-L195 |
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",
"."
] | train | https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/gene_sequence.py#L198-L251 |
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",
"."
] | train | https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/gene_sequence.py#L23-L32 |
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",
"."
] | train | https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/gene_sequence.py#L34-L60 |
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",
"."
] | train | https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/gene_sequence.py#L62-L66 |
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",
"."
] | train | https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/gene_sequence.py#L68-L106 |
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",
":",
"# fix chrom numbering",
"chrom",
"=",
"str",
"(",
"chrom",
")",
"chrom",
"=",
"chrom",
".",
"replace",
"(",
"'23'",
",",
"'X'",
")",... | Make sure chromosome names follow UCSC chr convention. | [
"Make",
"sure",
"chromosome",
"names",
"follow",
"UCSC",
"chr",
"convention",
"."
] | train | https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/scripts/check_mutations.py#L23-L35 |
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",
"."
] | train | https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/p_value.py#L18-L24 |
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"
] | train | https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/p_value.py#L27-L32 |
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",
"."
] | train | https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/p_value.py#L35-L61 |
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",
")",
":",
"#prng = np.random.RandomSta... | 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",
"."
] | train | https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/p_value.py#L64-L145 |
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",
"."
] | train | https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/p_value.py#L291-L369 |
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",
"."
] | train | https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/mymath.py#L7-L19 |
KarchinLab/probabilistic2020 | prob2020/python/mymath.py | normalized_mutation_entropy | def normalized_mutation_entropy(counts, total_cts=None):
"""Calculate the normalized mutation entropy based on a list/array
of mutation counts.
Note: Any grouping of mutation counts together should be done before hand
Parameters
----------
counts : np.array_like
array/list of mutation ... | python | def normalized_mutation_entropy(counts, total_cts=None):
"""Calculate the normalized mutation entropy based on a list/array
of mutation counts.
Note: Any grouping of mutation counts together should be done before hand
Parameters
----------
counts : np.array_like
array/list of mutation ... | [
"def",
"normalized_mutation_entropy",
"(",
"counts",
",",
"total_cts",
"=",
"None",
")",
":",
"cts",
"=",
"np",
".",
"asarray",
"(",
"counts",
",",
"dtype",
"=",
"float",
")",
"if",
"total_cts",
"is",
"None",
":",
"total_cts",
"=",
"np",
".",
"sum",
"(... | Calculate the normalized mutation entropy based on a list/array
of mutation counts.
Note: Any grouping of mutation counts together should be done before hand
Parameters
----------
counts : np.array_like
array/list of mutation counts
Returns
-------
norm_ent : float
nor... | [
"Calculate",
"the",
"normalized",
"mutation",
"entropy",
"based",
"on",
"a",
"list",
"/",
"array",
"of",
"mutation",
"counts",
"."
] | train | https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/mymath.py#L59-L85 |
KarchinLab/probabilistic2020 | prob2020/python/mymath.py | kl_divergence | def kl_divergence(p, q):
"""Compute the Kullback-Leibler (KL) divergence for discrete distributions.
Parameters
----------
p : np.array
"Ideal"/"true" Probability distribution
q : np.array
Approximation of probability distribution p
Returns
-------
kl : float
KL... | python | def kl_divergence(p, q):
"""Compute the Kullback-Leibler (KL) divergence for discrete distributions.
Parameters
----------
p : np.array
"Ideal"/"true" Probability distribution
q : np.array
Approximation of probability distribution p
Returns
-------
kl : float
KL... | [
"def",
"kl_divergence",
"(",
"p",
",",
"q",
")",
":",
"# make sure numpy arrays are floats",
"p",
"=",
"p",
".",
"astype",
"(",
"float",
")",
"q",
"=",
"q",
".",
"astype",
"(",
"float",
")",
"# compute kl divergence",
"kl",
"=",
"np",
".",
"sum",
"(",
... | Compute the Kullback-Leibler (KL) divergence for discrete distributions.
Parameters
----------
p : np.array
"Ideal"/"true" Probability distribution
q : np.array
Approximation of probability distribution p
Returns
-------
kl : float
KL divergence of approximating p w... | [
"Compute",
"the",
"Kullback",
"-",
"Leibler",
"(",
"KL",
")",
"divergence",
"for",
"discrete",
"distributions",
"."
] | train | https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/mymath.py#L88-L109 |
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",
"."
] | train | https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/mymath.py#L112-L129 |
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",
"."
] | train | https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/mymath.py#L132-L151 |
KarchinLab/probabilistic2020 | prob2020/python/bed_line.py | BedLine._filter_utr | def _filter_utr(self, ex):
"""Filter out UTR regions from the exon list (ie retain only coding regions).
Coding regions are defined by the thickStart and thickEnd attributes.
Parameters
----------
ex : list of tuples
list of exon positions, [(ex1_start, ex1_end), ..... | python | def _filter_utr(self, ex):
"""Filter out UTR regions from the exon list (ie retain only coding regions).
Coding regions are defined by the thickStart and thickEnd attributes.
Parameters
----------
ex : list of tuples
list of exon positions, [(ex1_start, ex1_end), ..... | [
"def",
"_filter_utr",
"(",
"self",
",",
"ex",
")",
":",
"# define coding region",
"coding_start",
"=",
"int",
"(",
"self",
".",
"bed_tuple",
".",
"thickStart",
")",
"coding_end",
"=",
"int",
"(",
"self",
".",
"bed_tuple",
".",
"thickEnd",
")",
"if",
"(",
... | Filter out UTR regions from the exon list (ie retain only coding regions).
Coding regions are defined by the thickStart and thickEnd attributes.
Parameters
----------
ex : list of tuples
list of exon positions, [(ex1_start, ex1_end), ...]
Returns
-------
... | [
"Filter",
"out",
"UTR",
"regions",
"from",
"the",
"exon",
"list",
"(",
"ie",
"retain",
"only",
"coding",
"regions",
")",
"."
] | train | https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/bed_line.py#L57-L107 |
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",
"."
] | train | https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/bed_line.py#L109-L129 |
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",
"=",
"{",
"}",
"# record genome positions for each sequence position",
"seq_pos",
"=",
"0",
"for",
"estart",
",",
"eend",
"in",
"self",
".",
"exons",
":",
"for",
"genome_pos",
... | 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",
"."
] | train | https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/bed_line.py#L157-L197 |
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",
")",
":",
"# first check if valid",
"pos",
"=",
"None",
"# initialize to invalid pos",
"if",
"chr",
"!=",
"self",
".",
"chrom",
":",
"#logger.debug('Wrong chromosome queried. You pro... | 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",
"."
] | train | https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/bed_line.py#L199-L260 |
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",
":",
"# create log directory if it doesn't exist",
"log_dir",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"... | 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",
"."
] | train | https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/utils.py#L75-L119 |
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"... | 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",
"."
] | train | https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/utils.py#L122-L138 |
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",
")",
":",
"# indices need to be in reverse order for filtering",
"# to prevent .pop() from yielding eroneous results",
"bad_ixs",
"=",
"sorted",
"(",
"bad_ixs",
",",
"reverse",
"=",
"True",
")",
"for",
"i",
"in",
"bad... | 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",
"."
] | train | https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/utils.py#L149-L171 |
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",
"."
] | train | https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/utils.py#L174-L191 |
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",
"."
] | train | https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/utils.py#L212-L229 |
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",
")",
":",
"# read in entire bed file into a dict with keys as chromsomes",
"bed_dict",
"=",
"OrderedDict",
"(",
")",
"for",
"bed_row",
"in",
"bed_generator",
"(",
"file_path",
")",
":",
"is_res... | 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",
"."
] | train | https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/utils.py#L232-L257 |
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",
")",
":",
"# only keep allowed mutation types",
"orig_len",
"=",
"len",
"(",
"mutation_df",
")",
"# number of mutations before filtering",
"mutation_df",
"=",
"mutation_df",
"[",
"mutation_df... | 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",
"."
] | train | https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/utils.py#L260-L327 |
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",
"."
] | train | https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/utils.py#L359-L426 |
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",
"."
] | train | https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/mutation_context.py#L18-L52 |
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",
")",
":",
"# check if string is correct length",
"if",
"len",
"(",
"tri_nuc",
")",
"!=",
"3",
":",
"raise",
"ValueError",
"(",
"'Chasm context requires a three nucleotide string '",
"'(Provided: \"{0}\")'",
".",
"format",
"(",
... | 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",
"."
] | train | https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/mutation_context.py#L117-L151 |
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 no mutations return empty result",
"if",
"not",
"somatic_base",
":",
"aa_info",
"=",
"{",
"'Reference Codon'",
":",
"[",
"]",
",",
"'Somatic Codon'",
":",
"[",
"]",
... | 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",
"."
] | train | https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/mutation_context.py#L196-L252 |
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",
"."
] | train | https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/process_result.py#L8-L45 |
KarchinLab/probabilistic2020 | prob2020/python/process_result.py | handle_oncogene_results | def handle_oncogene_results(permutation_result, num_permutations):
"""Takes in output from multiprocess_permutation function and converts to
a better formatted dataframe.
Parameters
----------
permutation_result : list
output from multiprocess_permutation
Returns
-------
permut... | python | def handle_oncogene_results(permutation_result, num_permutations):
"""Takes in output from multiprocess_permutation function and converts to
a better formatted dataframe.
Parameters
----------
permutation_result : list
output from multiprocess_permutation
Returns
-------
permut... | [
"def",
"handle_oncogene_results",
"(",
"permutation_result",
",",
"num_permutations",
")",
":",
"mycols",
"=",
"[",
"'gene'",
",",
"'num recurrent'",
",",
"'position entropy'",
",",
"'mean vest score'",
",",
"'entropy p-value'",
",",
"'vest p-value'",
",",
"'Total Mutat... | 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
formatted output suitable to save | [
"Takes",
"in",
"output",
"from",
"multiprocess_permutation",
"function",
"and",
"converts",
"to",
"a",
"better",
"formatted",
"dataframe",
"."
] | train | https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/process_result.py#L48-L90 |
KarchinLab/probabilistic2020 | prob2020/python/process_result.py | handle_hotmaps_results | def handle_hotmaps_results(permutation_result):
"""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.DataF... | python | def handle_hotmaps_results(permutation_result):
"""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.DataF... | [
"def",
"handle_hotmaps_results",
"(",
"permutation_result",
")",
":",
"if",
"len",
"(",
"permutation_result",
"[",
"0",
"]",
")",
"==",
"6",
":",
"mycols",
"=",
"[",
"'gene'",
",",
"'window length'",
",",
"'codon position'",
",",
"'mutation count'",
",",
"'win... | 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
formatted output suitable to save | [
"Takes",
"in",
"output",
"from",
"multiprocess_permutation",
"function",
"and",
"converts",
"to",
"a",
"better",
"formatted",
"dataframe",
"."
] | train | https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/process_result.py#L93-L127 |
KarchinLab/probabilistic2020 | prob2020/python/process_result.py | handle_protein_results | def handle_protein_results(permutation_result):
"""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.DataF... | python | def handle_protein_results(permutation_result):
"""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.DataF... | [
"def",
"handle_protein_results",
"(",
"permutation_result",
")",
":",
"mycols",
"=",
"[",
"'gene'",
",",
"'num recurrent'",
",",
"'normalized graph-smoothed position entropy'",
",",
"'normalized graph-smoothed position entropy p-value'",
",",
"'Total Mutations'",
",",
"'Unmappe... | 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
formatted output suitable to save | [
"Takes",
"in",
"output",
"from",
"multiprocess_permutation",
"function",
"and",
"converts",
"to",
"a",
"better",
"formatted",
"dataframe",
"."
] | train | https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/process_result.py#L130-L160 |
KarchinLab/probabilistic2020 | prob2020/python/process_result.py | handle_effect_results | def handle_effect_results(permutation_result):
"""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.DataFr... | python | def handle_effect_results(permutation_result):
"""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.DataFr... | [
"def",
"handle_effect_results",
"(",
"permutation_result",
")",
":",
"mycols",
"=",
"[",
"'gene'",
",",
"'num recurrent'",
",",
"'num inactivating'",
",",
"'entropy-on-effect'",
",",
"'entropy-on-effect p-value'",
",",
"'Total Mutations'",
",",
"'Unmapped to Ref Tx'",
"]"... | 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
formatted output suitable to save | [
"Takes",
"in",
"output",
"from",
"multiprocess_permutation",
"function",
"and",
"converts",
"to",
"a",
"better",
"formatted",
"dataframe",
"."
] | train | https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/process_result.py#L163-L192 |
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",
")",
"# count the number INDELs with length non-dividable by 3",
"num_indels",
"=",
"[",
"]",
"indel_len",
"=",
"[",
"]",
"num_categories",
"=",
"0... | 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",
"."
] | train | https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/scripts/calc_non_coding_frameshift_rate.py#L14-L49 |
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",
":",
"# user specifies a mutation type",
"self",
".",
"mutation_type",
"=",
"mut_type",
"else",
":",
"# mutation type is taken from object attributes",
"if",
"not",
"self"... | 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",
"."
] | train | https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/amino_acid.py#L52-L93 |
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",
"(",
")",
"# make sure it is upper case",
"aa",
"=",
"aa",
"[",
"2",
":",
"]",
"if",
"aa",
".",
"startswith",
"(",
"'P.'",
")",
"else",
"aa",
"# strip \"p.\"",
... | Set amino acid change and position. | [
"Set",
"amino",
"acid",
"change",
"and",
"position",
"."
] | train | https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/amino_acid.py#L98-L103 |
KarchinLab/probabilistic2020 | prob2020/python/amino_acid.py | AminoAcid.__set_mutation_type | def __set_mutation_type(self, hgvs_string):
"""Interpret the mutation type (missense, etc.) and set appropriate flags.
Args:
hgvs_string (str): hgvs syntax with "p." removed
"""
self.__set_lost_stop_status(hgvs_string)
self.__set_lost_start_status(hgvs_string)
... | python | def __set_mutation_type(self, hgvs_string):
"""Interpret the mutation type (missense, etc.) and set appropriate flags.
Args:
hgvs_string (str): hgvs syntax with "p." removed
"""
self.__set_lost_stop_status(hgvs_string)
self.__set_lost_start_status(hgvs_string)
... | [
"def",
"__set_mutation_type",
"(",
"self",
",",
"hgvs_string",
")",
":",
"self",
".",
"__set_lost_stop_status",
"(",
"hgvs_string",
")",
"self",
".",
"__set_lost_start_status",
"(",
"hgvs_string",
")",
"self",
".",
"__set_missense_status",
"(",
"hgvs_string",
")",
... | Interpret the mutation type (missense, etc.) and set appropriate flags.
Args:
hgvs_string (str): hgvs syntax with "p." removed | [
"Interpret",
"the",
"mutation",
"type",
"(",
"missense",
"etc",
".",
")",
"and",
"set",
"appropriate",
"flags",
"."
] | train | https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/amino_acid.py#L114-L125 |
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",
")",
":",
"# set missense status",
"if",
"re",
".",
"search",
"(",
"'^[A-Z?]\\d+[A-Z?]$'",
",",
"hgvs_string",
")",
":",
"self",
".",
"is_missense",
"=",
"True",
"self",
".",
"is_non_silent",
"=",
... | Sets the self.is_missense flag. | [
"Sets",
"the",
"self",
".",
"is_missense",
"flag",
"."
] | train | https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/amino_acid.py#L127-L134 |
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",
")",
":",
"# set is lost start status",
"mymatch",
"=",
"re",
".",
"search",
"(",
"'^([A-Z?])(\\d+)([A-Z?])$'",
",",
"hgvs_string",
")",
"if",
"mymatch",
":",
"grps",
"=",
"mymatch",
".",
"groups",... | Sets the self.is_lost_start flag. | [
"Sets",
"the",
"self",
".",
"is_lost_start",
"flag",
"."
] | train | https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/amino_acid.py#L136-L148 |
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",
"."
] | train | https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/amino_acid.py#L150-L161 |
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",
"."
] | train | https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/amino_acid.py#L163-L171 |
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",
"."
] | train | https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/amino_acid.py#L173-L186 |
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",
")",
":",
"# set indel status",
"if",
"\"ins\"",
"in",
"self",
".",
"hgvs_original",
":",
"# mutation is insertion",
"self",
".",
"is_insertion",
"=",
"True",
"self",
".",
"is_deletion",
"=",
"False",
"self",
".",
"is_in... | Sets flags related to the mutation being an indel. | [
"Sets",
"flags",
"related",
"to",
"the",
"mutation",
"being",
"an",
"indel",
"."
] | train | https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/amino_acid.py#L188-L207 |
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",
")",
":",
"# Standard use by HGVS of indicating unknown effect.",
"unknown_effect_list",
"=",
"[",
"'?'",
",",
"'(=)'",
",",
"'='",
"]",
"# unknown effect symbols",
"if",
"hgvs_string",
"in",
"unknown_effect_l... | 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",
"."
] | train | https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/amino_acid.py#L209-L233 |
KarchinLab/probabilistic2020 | prob2020/python/amino_acid.py | AminoAcid.__set_no_protein | def __set_no_protein(self, hgvs_string):
"""Set a flag for no protein expected. ("p.0" or "p.0?")
Args:
hgvs_string (str): hgvs syntax with "p." removed
"""
no_protein_list = ['0', '0?'] # no protein symbols
if hgvs_string in no_protein_list:
self.is_no_... | python | def __set_no_protein(self, hgvs_string):
"""Set a flag for no protein expected. ("p.0" or "p.0?")
Args:
hgvs_string (str): hgvs syntax with "p." removed
"""
no_protein_list = ['0', '0?'] # no protein symbols
if hgvs_string in no_protein_list:
self.is_no_... | [
"def",
"__set_no_protein",
"(",
"self",
",",
"hgvs_string",
")",
":",
"no_protein_list",
"=",
"[",
"'0'",
",",
"'0?'",
"]",
"# no protein symbols",
"if",
"hgvs_string",
"in",
"no_protein_list",
":",
"self",
".",
"is_no_protein",
"=",
"True",
"self",
".",
"is_n... | Set a flag for no protein expected. ("p.0" or "p.0?")
Args:
hgvs_string (str): hgvs syntax with "p." removed | [
"Set",
"a",
"flag",
"for",
"no",
"protein",
"expected",
".",
"(",
"p",
".",
"0",
"or",
"p",
".",
"0?",
")"
] | train | https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/amino_acid.py#L235-L246 |
KarchinLab/probabilistic2020 | prob2020/python/amino_acid.py | AminoAcid.__parse_hgvs_syntax | def __parse_hgvs_syntax(self, aa_hgvs):
"""Convert HGVS syntax for amino acid change into attributes.
Specific details of the mutation are stored in attributes like
self.intial (prior to mutation), sel.pos (mutation position),
self.mutated (mutation), and self.stop_pos (position of stop... | python | def __parse_hgvs_syntax(self, aa_hgvs):
"""Convert HGVS syntax for amino acid change into attributes.
Specific details of the mutation are stored in attributes like
self.intial (prior to mutation), sel.pos (mutation position),
self.mutated (mutation), and self.stop_pos (position of stop... | [
"def",
"__parse_hgvs_syntax",
"(",
"self",
",",
"aa_hgvs",
")",
":",
"self",
".",
"is_valid",
"=",
"True",
"# assume initially the syntax is legitimate",
"self",
".",
"is_synonymous",
"=",
"False",
"# assume not synonymous until proven",
"if",
"self",
".",
"unknown_effe... | Convert HGVS syntax for amino acid change into attributes.
Specific details of the mutation are stored in attributes like
self.intial (prior to mutation), sel.pos (mutation position),
self.mutated (mutation), and self.stop_pos (position of stop codon,
if any).
Args:
... | [
"Convert",
"HGVS",
"syntax",
"for",
"amino",
"acid",
"change",
"into",
"attributes",
"."
] | train | https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/amino_acid.py#L248-L341 |
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",
"."
] | train | https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/permutation.py#L9-L96 |
KarchinLab/probabilistic2020 | prob2020/python/permutation.py | position_permutation | def position_permutation(obs_stat,
context_counts,
context_to_mut,
seq_context,
gene_seq,
gene_vest=None,
num_permutations=10000,
stop_criteria=1... | python | def position_permutation(obs_stat,
context_counts,
context_to_mut,
seq_context,
gene_seq,
gene_vest=None,
num_permutations=10000,
stop_criteria=1... | [
"def",
"position_permutation",
"(",
"obs_stat",
",",
"context_counts",
",",
"context_to_mut",
",",
"seq_context",
",",
"gene_seq",
",",
"gene_vest",
"=",
"None",
",",
"num_permutations",
"=",
"10000",
",",
"stop_criteria",
"=",
"100",
",",
"pseudo_count",
"=",
"... | Performs null-permutations for position-based mutation statistics
in a single gene.
Parameters
----------
obs_stat : tuple, (recur ct, entropy, delta entropy, mean vest)
tuple containing the observed statistics
context_counts : pd.Series
number of mutations for each context
cont... | [
"Performs",
"null",
"-",
"permutations",
"for",
"position",
"-",
"based",
"mutation",
"statistics",
"in",
"a",
"single",
"gene",
"."
] | train | https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/permutation.py#L99-L207 |
KarchinLab/probabilistic2020 | prob2020/python/permutation.py | hotmaps_permutation | def hotmaps_permutation(obs_stat,
context_counts,
context_to_mut,
seq_context,
gene_seq,
window,
num_permutations=10000,
stop_criteria=100,
... | python | def hotmaps_permutation(obs_stat,
context_counts,
context_to_mut,
seq_context,
gene_seq,
window,
num_permutations=10000,
stop_criteria=100,
... | [
"def",
"hotmaps_permutation",
"(",
"obs_stat",
",",
"context_counts",
",",
"context_to_mut",
",",
"seq_context",
",",
"gene_seq",
",",
"window",
",",
"num_permutations",
"=",
"10000",
",",
"stop_criteria",
"=",
"100",
",",
"max_batch",
"=",
"25000",
",",
"null_s... | Performs null-permutations for position-based mutation statistics
in a single gene.
Parameters
----------
obs_stat : dict
dictionary mapping codons to the sum of mutations in a window
context_counts : pd.Series
number of mutations for each context
context_to_mut : dict
d... | [
"Performs",
"null",
"-",
"permutations",
"for",
"position",
"-",
"based",
"mutation",
"statistics",
"in",
"a",
"single",
"gene",
"."
] | train | https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/permutation.py#L210-L357 |
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",
"."
] | train | https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/permutation.py#L360-L483 |
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",
"."
] | train | https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/permutation.py#L486-L552 |
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",
"."
] | train | https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/permutation.py#L555-L606 |
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",
"."
] | train | https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/permutation.py#L609-L686 |
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",... | train | https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/permutation.py#L689-L783 |
sv0/django-markdown-app | django_markdown/utils.py | markdown | def markdown(value, extensions=settings.MARKDOWN_EXTENSIONS,
extension_configs=settings.MARKDOWN_EXTENSION_CONFIGS,
safe=False):
""" Render markdown over a given value, optionally using varios extensions.
Default extensions could be defined which MARKDOWN_EXTENSIONS option.
:retu... | python | def markdown(value, extensions=settings.MARKDOWN_EXTENSIONS,
extension_configs=settings.MARKDOWN_EXTENSION_CONFIGS,
safe=False):
""" Render markdown over a given value, optionally using varios extensions.
Default extensions could be defined which MARKDOWN_EXTENSIONS option.
:retu... | [
"def",
"markdown",
"(",
"value",
",",
"extensions",
"=",
"settings",
".",
"MARKDOWN_EXTENSIONS",
",",
"extension_configs",
"=",
"settings",
".",
"MARKDOWN_EXTENSION_CONFIGS",
",",
"safe",
"=",
"False",
")",
":",
"return",
"mark_safe",
"(",
"markdown_module",
".",
... | Render markdown over a given value, optionally using varios extensions.
Default extensions could be defined which MARKDOWN_EXTENSIONS option.
:returns: A rendered markdown | [
"Render",
"markdown",
"over",
"a",
"given",
"value",
"optionally",
"using",
"varios",
"extensions",
"."
] | train | https://github.com/sv0/django-markdown-app/blob/973968c68d79cbe35304e9d6da876ad33f427d2d/django_markdown/utils.py#L27-L39 |
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",
"=",
"... | Return script tag with initialization code. | [
"Return",
"script",
"tag",
"with",
"initialization",
"code",
"."
] | train | https://github.com/sv0/django-markdown-app/blob/973968c68d79cbe35304e9d6da876ad33f427d2d/django_markdown/utils.py#L42-L56 |
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",
"."
] | train | https://github.com/sv0/django-markdown-app/blob/973968c68d79cbe35304e9d6da876ad33f427d2d/django_markdown/views.py#L7-L23 |
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",
"."
] | train | https://github.com/sv0/django-markdown-app/blob/973968c68d79cbe35304e9d6da876ad33f427d2d/django_markdown/flatpages.py#L25-L29 |
RobWin/supervisorclusterctl | supervisorclusterctl/supervisorclusterctl.py | main | def main(argv=None):
"""Command line options."""
program_name = __programm_name__
program_version = "v%s" % __version__
program_descrption = __programm_description__
try:
# Setup argument parser
parser = ArgumentParser(prog=program_name, description=program_descrption)
p... | python | def main(argv=None):
"""Command line options."""
program_name = __programm_name__
program_version = "v%s" % __version__
program_descrption = __programm_description__
try:
# Setup argument parser
parser = ArgumentParser(prog=program_name, description=program_descrption)
p... | [
"def",
"main",
"(",
"argv",
"=",
"None",
")",
":",
"program_name",
"=",
"__programm_name__",
"program_version",
"=",
"\"v%s\"",
"%",
"__version__",
"program_descrption",
"=",
"__programm_description__",
"try",
":",
"# Setup argument parser",
"parser",
"=",
"ArgumentPa... | Command line options. | [
"Command",
"line",
"options",
"."
] | train | https://github.com/RobWin/supervisorclusterctl/blob/00fd6dea3c2195d8666a9031d0b56ed24a12e786/supervisorclusterctl/supervisorclusterctl.py#L16-L78 |
sv0/django-markdown-app | django_markdown/templatetags/django_markdown.py | markdown | def markdown(value, arg=None):
""" Render markdown over a given value, optionally using varios extensions.
Default extensions could be defined which MARKDOWN_EXTENSIONS option.
Syntax: ::
{{value|markdown}}
{{value|markdown:"tables,codehilite"}}
:returns: A rendered markdown
""... | python | def markdown(value, arg=None):
""" Render markdown over a given value, optionally using varios extensions.
Default extensions could be defined which MARKDOWN_EXTENSIONS option.
Syntax: ::
{{value|markdown}}
{{value|markdown:"tables,codehilite"}}
:returns: A rendered markdown
""... | [
"def",
"markdown",
"(",
"value",
",",
"arg",
"=",
"None",
")",
":",
"extensions",
"=",
"(",
"arg",
"and",
"arg",
".",
"split",
"(",
"','",
")",
")",
"or",
"settings",
".",
"MARKDOWN_EXTENSIONS",
"return",
"_markdown",
"(",
"value",
",",
"extensions",
"... | Render markdown over a given value, optionally using varios extensions.
Default extensions could be defined which MARKDOWN_EXTENSIONS option.
Syntax: ::
{{value|markdown}}
{{value|markdown:"tables,codehilite"}}
:returns: A rendered markdown | [
"Render",
"markdown",
"over",
"a",
"given",
"value",
"optionally",
"using",
"varios",
"extensions",
"."
] | train | https://github.com/sv0/django-markdown-app/blob/973968c68d79cbe35304e9d6da876ad33f427d2d/django_markdown/templatetags/django_markdown.py#L22-L37 |
sv0/django-markdown-app | django_markdown/templatetags/django_markdown.py | markdown_safe | def markdown_safe(value, arg=None):
""" Render markdown over a given value, optionally using varios extensions.
Default extensions could be defined which MARKDOWN_EXTENSIONS option.
Enables safe mode, which strips raw HTML and only returns HTML generated
by markdown.
:returns: A rendered markdown... | python | def markdown_safe(value, arg=None):
""" Render markdown over a given value, optionally using varios extensions.
Default extensions could be defined which MARKDOWN_EXTENSIONS option.
Enables safe mode, which strips raw HTML and only returns HTML generated
by markdown.
:returns: A rendered markdown... | [
"def",
"markdown_safe",
"(",
"value",
",",
"arg",
"=",
"None",
")",
":",
"extensions",
"=",
"(",
"arg",
"and",
"arg",
".",
"split",
"(",
"','",
")",
")",
"or",
"settings",
".",
"MARKDOWN_EXTENSIONS",
"return",
"_markdown",
"(",
"value",
",",
"extensions"... | Render markdown over a given value, optionally using varios extensions.
Default extensions could be defined which MARKDOWN_EXTENSIONS option.
Enables safe mode, which strips raw HTML and only returns HTML generated
by markdown.
:returns: A rendered markdown. | [
"Render",
"markdown",
"over",
"a",
"given",
"value",
"optionally",
"using",
"varios",
"extensions",
"."
] | train | https://github.com/sv0/django-markdown-app/blob/973968c68d79cbe35304e9d6da876ad33f427d2d/django_markdown/templatetags/django_markdown.py#L41-L53 |
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",
"."
] | train | https://github.com/sv0/django-markdown-app/blob/973968c68d79cbe35304e9d6da876ad33f427d2d/django_markdown/templatetags/django_markdown.py#L57-L66 |
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",
"."
] | train | https://github.com/sv0/django-markdown-app/blob/973968c68d79cbe35304e9d6da876ad33f427d2d/django_markdown/templatetags/django_markdown.py#L96-L110 |
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",
"."
] | train | https://github.com/sv0/django-markdown-app/blob/973968c68d79cbe35304e9d6da876ad33f427d2d/django_markdown/pypandoc.py#L13-L28 |
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",
"."
] | train | https://github.com/sv0/django-markdown-app/blob/973968c68d79cbe35304e9d6da876ad33f427d2d/django_markdown/pypandoc.py#L89-L109 |
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",
"."
] | train | https://github.com/sv0/django-markdown-app/blob/973968c68d79cbe35304e9d6da876ad33f427d2d/django_markdown/widgets.py#L29-L38 |
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",
"."
] | train | https://github.com/sprin/markdown-inline-graphviz/blob/9664863b3002d88243c9ee5e14c195e037e54618/mdx_inline_graphviz.py#L38-L44 |
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",
"."
] | train | https://github.com/sprin/markdown-inline-graphviz/blob/9664863b3002d88243c9ee5e14c195e037e54618/mdx_inline_graphviz.py#L52-L104 |
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",
"."
] | train | https://github.com/zabuldon/teslajsonpy/blob/673ecdb5c9483160fb1b97e30e62f2c863761c39/teslajsonpy/connection.py#L49-L56 |
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",
"."
] | train | https://github.com/zabuldon/teslajsonpy/blob/673ecdb5c9483160fb1b97e30e62f2c863761c39/teslajsonpy/connection.py#L58-L65 |
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",
"."
] | train | https://github.com/zabuldon/teslajsonpy/blob/673ecdb5c9483160fb1b97e30e62f2c863761c39/teslajsonpy/connection.py#L67-L92 |
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",
"."
] | train | https://github.com/zabuldon/teslajsonpy/blob/673ecdb5c9483160fb1b97e30e62f2c863761c39/teslajsonpy/binary_sensor.py#L48-L56 |
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",
"."
] | train | https://github.com/zabuldon/teslajsonpy/blob/673ecdb5c9483160fb1b97e30e62f2c863761c39/teslajsonpy/climate.py#L76-L98 |
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",
"."
] | train | https://github.com/zabuldon/teslajsonpy/blob/673ecdb5c9483160fb1b97e30e62f2c863761c39/teslajsonpy/climate.py#L100-L110 |
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",
"."
] | train | https://github.com/zabuldon/teslajsonpy/blob/673ecdb5c9483160fb1b97e30e62f2c863761c39/teslajsonpy/climate.py#L112-L129 |
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",
"."
] | train | https://github.com/zabuldon/teslajsonpy/blob/673ecdb5c9483160fb1b97e30e62f2c863761c39/teslajsonpy/climate.py#L181-L189 |
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",
"."
] | train | https://github.com/zabuldon/teslajsonpy/blob/673ecdb5c9483160fb1b97e30e62f2c863761c39/teslajsonpy/charger.py#L44-L52 |
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",
"."
] | train | https://github.com/zabuldon/teslajsonpy/blob/673ecdb5c9483160fb1b97e30e62f2c863761c39/teslajsonpy/charger.py#L54-L61 |
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",
"."
] | train | https://github.com/zabuldon/teslajsonpy/blob/673ecdb5c9483160fb1b97e30e62f2c863761c39/teslajsonpy/charger.py#L63-L70 |
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",
"."
] | train | https://github.com/zabuldon/teslajsonpy/blob/673ecdb5c9483160fb1b97e30e62f2c863761c39/teslajsonpy/charger.py#L97-L102 |
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",
"."
] | train | https://github.com/zabuldon/teslajsonpy/blob/673ecdb5c9483160fb1b97e30e62f2c863761c39/teslajsonpy/charger.py#L104-L111 |
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",
"."
] | train | https://github.com/zabuldon/teslajsonpy/blob/673ecdb5c9483160fb1b97e30e62f2c863761c39/teslajsonpy/charger.py#L113-L120 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.