partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
test | ClockTree.date_uncertainty_due_to_rate | use previously calculated variation of the rate to estimate
the uncertainty in a particular numdate due to rate variation.
Parameters
----------
node : PhyloTree.Clade
node for which the confidence interval is to be calculated
interval : tuple, optional
A... | treetime/clock_tree.py | def date_uncertainty_due_to_rate(self, node, interval=(0.05, 0.095)):
"""use previously calculated variation of the rate to estimate
the uncertainty in a particular numdate due to rate variation.
Parameters
----------
node : PhyloTree.Clade
node for which the confide... | def date_uncertainty_due_to_rate(self, node, interval=(0.05, 0.095)):
"""use previously calculated variation of the rate to estimate
the uncertainty in a particular numdate due to rate variation.
Parameters
----------
node : PhyloTree.Clade
node for which the confide... | [
"use",
"previously",
"calculated",
"variation",
"of",
"the",
"rate",
"to",
"estimate",
"the",
"uncertainty",
"in",
"a",
"particular",
"numdate",
"due",
"to",
"rate",
"variation",
"."
] | neherlab/treetime | python | https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/clock_tree.py#L760-L780 | [
"def",
"date_uncertainty_due_to_rate",
"(",
"self",
",",
"node",
",",
"interval",
"=",
"(",
"0.05",
",",
"0.095",
")",
")",
":",
"if",
"hasattr",
"(",
"node",
",",
"\"numdate_rate_variation\"",
")",
":",
"from",
"scipy",
".",
"special",
"import",
"erfinv",
... | f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0 |
test | ClockTree.get_confidence_interval | If temporal reconstruction was done using the marginal ML mode, the entire distribution of
times is available. This function determines the 90% (or other) confidence interval, defined as the
range where 5% of probability is below and above. Note that this does not necessarily contain
the highest... | treetime/clock_tree.py | def get_confidence_interval(self, node, interval = (0.05, 0.95)):
'''
If temporal reconstruction was done using the marginal ML mode, the entire distribution of
times is available. This function determines the 90% (or other) confidence interval, defined as the
range where 5% of probabili... | def get_confidence_interval(self, node, interval = (0.05, 0.95)):
'''
If temporal reconstruction was done using the marginal ML mode, the entire distribution of
times is available. This function determines the 90% (or other) confidence interval, defined as the
range where 5% of probabili... | [
"If",
"temporal",
"reconstruction",
"was",
"done",
"using",
"the",
"marginal",
"ML",
"mode",
"the",
"entire",
"distribution",
"of",
"times",
"is",
"available",
".",
"This",
"function",
"determines",
"the",
"90%",
"(",
"or",
"other",
")",
"confidence",
"interva... | neherlab/treetime | python | https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/clock_tree.py#L798-L836 | [
"def",
"get_confidence_interval",
"(",
"self",
",",
"node",
",",
"interval",
"=",
"(",
"0.05",
",",
"0.95",
")",
")",
":",
"rate_contribution",
"=",
"self",
".",
"date_uncertainty_due_to_rate",
"(",
"node",
",",
"interval",
")",
"if",
"hasattr",
"(",
"node",... | f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0 |
test | ClockTree.get_max_posterior_region | If temporal reconstruction was done using the marginal ML mode, the entire distribution of
times is available. This function determines the interval around the highest
posterior probability region that contains the specified fraction of the probability mass.
In absense of marginal reconstruction... | treetime/clock_tree.py | def get_max_posterior_region(self, node, fraction = 0.9):
'''
If temporal reconstruction was done using the marginal ML mode, the entire distribution of
times is available. This function determines the interval around the highest
posterior probability region that contains the specified f... | def get_max_posterior_region(self, node, fraction = 0.9):
'''
If temporal reconstruction was done using the marginal ML mode, the entire distribution of
times is available. This function determines the interval around the highest
posterior probability region that contains the specified f... | [
"If",
"temporal",
"reconstruction",
"was",
"done",
"using",
"the",
"marginal",
"ML",
"mode",
"the",
"entire",
"distribution",
"of",
"times",
"is",
"available",
".",
"This",
"function",
"determines",
"the",
"interval",
"around",
"the",
"highest",
"posterior",
"pr... | neherlab/treetime | python | https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/clock_tree.py#L838-L899 | [
"def",
"get_max_posterior_region",
"(",
"self",
",",
"node",
",",
"fraction",
"=",
"0.9",
")",
":",
"if",
"node",
".",
"marginal_inverse_cdf",
"==",
"\"delta\"",
":",
"return",
"np",
".",
"array",
"(",
"[",
"node",
".",
"numdate",
",",
"node",
".",
"numd... | f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0 |
test | read_vcf | Reads in a vcf/vcf.gz file and associated
reference sequence fasta (to which the VCF file is mapped).
Parses mutations, insertions, and deletions and stores them in a nested dict,
see 'returns' for the dict structure.
Calls with heterozygous values 0/1, 0/2, etc and no-calls (./.) are
repla... | treetime/vcf_utils.py | def read_vcf(vcf_file, ref_file):
"""
Reads in a vcf/vcf.gz file and associated
reference sequence fasta (to which the VCF file is mapped).
Parses mutations, insertions, and deletions and stores them in a nested dict,
see 'returns' for the dict structure.
Calls with heterozygous values... | def read_vcf(vcf_file, ref_file):
"""
Reads in a vcf/vcf.gz file and associated
reference sequence fasta (to which the VCF file is mapped).
Parses mutations, insertions, and deletions and stores them in a nested dict,
see 'returns' for the dict structure.
Calls with heterozygous values... | [
"Reads",
"in",
"a",
"vcf",
"/",
"vcf",
".",
"gz",
"file",
"and",
"associated",
"reference",
"sequence",
"fasta",
"(",
"to",
"which",
"the",
"VCF",
"file",
"is",
"mapped",
")",
".",
"Parses",
"mutations",
"insertions",
"and",
"deletions",
"and",
"stores",
... | neherlab/treetime | python | https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/vcf_utils.py#L6-L269 | [
"def",
"read_vcf",
"(",
"vcf_file",
",",
"ref_file",
")",
":",
"#Programming Note:\r",
"# Note on VCF Format\r",
"# -------------------\r",
"# 'Insertion where there are also deletions' (special handling)\r",
"# Ex:\r",
"# REF ALT Seq1 Seq2\r",
"# GC G... | f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0 |
test | write_vcf | Writes out a VCF-style file (which seems to be minimally handleable
by vcftools and pyvcf) of the alignment. This is created from a dict
in a similar format to what's created by :py:meth:`treetime.vcf_utils.read_vcf`
Positions of variable sites are transformed to start at 1 to match
VCF convention... | treetime/vcf_utils.py | def write_vcf(tree_dict, file_name):#, compress=False):
"""
Writes out a VCF-style file (which seems to be minimally handleable
by vcftools and pyvcf) of the alignment. This is created from a dict
in a similar format to what's created by :py:meth:`treetime.vcf_utils.read_vcf`
Positions of var... | def write_vcf(tree_dict, file_name):#, compress=False):
"""
Writes out a VCF-style file (which seems to be minimally handleable
by vcftools and pyvcf) of the alignment. This is created from a dict
in a similar format to what's created by :py:meth:`treetime.vcf_utils.read_vcf`
Positions of var... | [
"Writes",
"out",
"a",
"VCF",
"-",
"style",
"file",
"(",
"which",
"seems",
"to",
"be",
"minimally",
"handleable",
"by",
"vcftools",
"and",
"pyvcf",
")",
"of",
"the",
"alignment",
".",
"This",
"is",
"created",
"from",
"a",
"dict",
"in",
"a",
"similar",
"... | neherlab/treetime | python | https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/vcf_utils.py#L272-L518 | [
"def",
"write_vcf",
"(",
"tree_dict",
",",
"file_name",
")",
":",
"#, compress=False):\r",
"# Programming Logic Note:\r",
"#\r",
"# For a sequence like:\r",
"# Pos 1 2 3 4 5 6\r",
"# Ref A C T T A C\r",
"# Seq1 A C - - - G\r",
"#\r",
"# In a dict it is sto... | f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0 |
test | _convolution_integrand | Evaluates int_tau f(t+tau)*g(tau) or int_tau f(t-tau)g(tau) if inverse time is TRUE
Parameters
-----------
t_val : double
Time point
f : Interpolation object
First multiplier in convolution
g : Interpolation object
Second multiplier in convolution
inverse_time : ... | treetime/node_interpolator.py | def _convolution_integrand(t_val, f, g,
inverse_time=None, return_log=False):
'''
Evaluates int_tau f(t+tau)*g(tau) or int_tau f(t-tau)g(tau) if inverse time is TRUE
Parameters
-----------
t_val : double
Time point
f : Interpolation object
First mu... | def _convolution_integrand(t_val, f, g,
inverse_time=None, return_log=False):
'''
Evaluates int_tau f(t+tau)*g(tau) or int_tau f(t-tau)g(tau) if inverse time is TRUE
Parameters
-----------
t_val : double
Time point
f : Interpolation object
First mu... | [
"Evaluates",
"int_tau",
"f",
"(",
"t",
"+",
"tau",
")",
"*",
"g",
"(",
"tau",
")",
"or",
"int_tau",
"f",
"(",
"t",
"-",
"tau",
")",
"g",
"(",
"tau",
")",
"if",
"inverse",
"time",
"is",
"TRUE"
] | neherlab/treetime | python | https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/node_interpolator.py#L9-L84 | [
"def",
"_convolution_integrand",
"(",
"t_val",
",",
"f",
",",
"g",
",",
"inverse_time",
"=",
"None",
",",
"return_log",
"=",
"False",
")",
":",
"if",
"inverse_time",
"is",
"None",
":",
"raise",
"Exception",
"(",
"\"Inverse time argument must be set!\"",
")",
"... | f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0 |
test | _max_of_integrand | Evaluates max_tau f(t+tau)*g(tau) or max_tau f(t-tau)g(tau) if inverse time is TRUE
Parameters
-----------
t_val : double
Time point
f : Interpolation object
First multiplier in convolution
g : Interpolation object
Second multiplier in convolution
inverse_time : ... | treetime/node_interpolator.py | def _max_of_integrand(t_val, f, g, inverse_time=None, return_log=False):
'''
Evaluates max_tau f(t+tau)*g(tau) or max_tau f(t-tau)g(tau) if inverse time is TRUE
Parameters
-----------
t_val : double
Time point
f : Interpolation object
First multiplier in convolution
g... | def _max_of_integrand(t_val, f, g, inverse_time=None, return_log=False):
'''
Evaluates max_tau f(t+tau)*g(tau) or max_tau f(t-tau)g(tau) if inverse time is TRUE
Parameters
-----------
t_val : double
Time point
f : Interpolation object
First multiplier in convolution
g... | [
"Evaluates",
"max_tau",
"f",
"(",
"t",
"+",
"tau",
")",
"*",
"g",
"(",
"tau",
")",
"or",
"max_tau",
"f",
"(",
"t",
"-",
"tau",
")",
"g",
"(",
"tau",
")",
"if",
"inverse",
"time",
"is",
"TRUE"
] | neherlab/treetime | python | https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/node_interpolator.py#L88-L135 | [
"def",
"_max_of_integrand",
"(",
"t_val",
",",
"f",
",",
"g",
",",
"inverse_time",
"=",
"None",
",",
"return_log",
"=",
"False",
")",
":",
"# return log is always True",
"FG",
"=",
"_convolution_integrand",
"(",
"t_val",
",",
"f",
",",
"g",
",",
"inverse_tim... | f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0 |
test | _evaluate_convolution | Calculate convolution F(t) = int { f(tau)g(t-tau) } dtau | treetime/node_interpolator.py | def _evaluate_convolution(t_val, f, g, n_integral = 100, inverse_time=None, return_log=False):
"""
Calculate convolution F(t) = int { f(tau)g(t-tau) } dtau
"""
FG = _convolution_integrand(t_val, f, g, inverse_time, return_log)
#integrate the interpolation object, return log, make neg_log
... | def _evaluate_convolution(t_val, f, g, n_integral = 100, inverse_time=None, return_log=False):
"""
Calculate convolution F(t) = int { f(tau)g(t-tau) } dtau
"""
FG = _convolution_integrand(t_val, f, g, inverse_time, return_log)
#integrate the interpolation object, return log, make neg_log
... | [
"Calculate",
"convolution",
"F",
"(",
"t",
")",
"=",
"int",
"{",
"f",
"(",
"tau",
")",
"g",
"(",
"t",
"-",
"tau",
")",
"}",
"dtau"
] | neherlab/treetime | python | https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/node_interpolator.py#L137-L155 | [
"def",
"_evaluate_convolution",
"(",
"t_val",
",",
"f",
",",
"g",
",",
"n_integral",
"=",
"100",
",",
"inverse_time",
"=",
"None",
",",
"return_log",
"=",
"False",
")",
":",
"FG",
"=",
"_convolution_integrand",
"(",
"t_val",
",",
"f",
",",
"g",
",",
"i... | f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0 |
test | NodeInterpolator.convolve | calculate H(t) = \int_tau f(t-tau)g(tau) if inverse_time=True
H(t) = \int_tau f(t+tau)g(tau) if inverse_time=False
This function determines the time points of the grid of the result to
ensure an accurate approximation. | treetime/node_interpolator.py | def convolve(cls, node_interp, branch_interp, max_or_integral='integral',
n_grid_points = ttconf.NODE_GRID_SIZE, n_integral=ttconf.N_INTEGRAL,
inverse_time=True, rel_tol=0.05, yc=10):
'''
calculate H(t) = \int_tau f(t-tau)g(tau) if inverse_time=True
H... | def convolve(cls, node_interp, branch_interp, max_or_integral='integral',
n_grid_points = ttconf.NODE_GRID_SIZE, n_integral=ttconf.N_INTEGRAL,
inverse_time=True, rel_tol=0.05, yc=10):
'''
calculate H(t) = \int_tau f(t-tau)g(tau) if inverse_time=True
H... | [
"calculate",
"H",
"(",
"t",
")",
"=",
"\\",
"int_tau",
"f",
"(",
"t",
"-",
"tau",
")",
"g",
"(",
"tau",
")",
"if",
"inverse_time",
"=",
"True",
"H",
"(",
"t",
")",
"=",
"\\",
"int_tau",
"f",
"(",
"t",
"+",
"tau",
")",
"g",
"(",
"tau",
")",
... | neherlab/treetime | python | https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/node_interpolator.py#L165-L281 | [
"def",
"convolve",
"(",
"cls",
",",
"node_interp",
",",
"branch_interp",
",",
"max_or_integral",
"=",
"'integral'",
",",
"n_grid_points",
"=",
"ttconf",
".",
"NODE_GRID_SIZE",
",",
"n_integral",
"=",
"ttconf",
".",
"N_INTEGRAL",
",",
"inverse_time",
"=",
"True",... | f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0 |
test | min_interp | Find the global minimum of a function represented as an interpolation object. | treetime/utils.py | def min_interp(interp_object):
"""
Find the global minimum of a function represented as an interpolation object.
"""
try:
return interp_object.x[interp_object(interp_object.x).argmin()]
except Exception as e:
s = "Cannot find minimum of the interpolation object" + str(interp_object.x... | def min_interp(interp_object):
"""
Find the global minimum of a function represented as an interpolation object.
"""
try:
return interp_object.x[interp_object(interp_object.x).argmin()]
except Exception as e:
s = "Cannot find minimum of the interpolation object" + str(interp_object.x... | [
"Find",
"the",
"global",
"minimum",
"of",
"a",
"function",
"represented",
"as",
"an",
"interpolation",
"object",
"."
] | neherlab/treetime | python | https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/utils.py#L117-L126 | [
"def",
"min_interp",
"(",
"interp_object",
")",
":",
"try",
":",
"return",
"interp_object",
".",
"x",
"[",
"interp_object",
"(",
"interp_object",
".",
"x",
")",
".",
"argmin",
"(",
")",
"]",
"except",
"Exception",
"as",
"e",
":",
"s",
"=",
"\"Cannot find... | f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0 |
test | median_interp | Find the median of the function represented as an interpolation object. | treetime/utils.py | def median_interp(interp_object):
"""
Find the median of the function represented as an interpolation object.
"""
new_grid = np.sort(np.concatenate([interp_object.x[:-1] + 0.1*ii*np.diff(interp_object.x)
for ii in range(10)]).flatten())
tmp_prop = np.exp(-(int... | def median_interp(interp_object):
"""
Find the median of the function represented as an interpolation object.
"""
new_grid = np.sort(np.concatenate([interp_object.x[:-1] + 0.1*ii*np.diff(interp_object.x)
for ii in range(10)]).flatten())
tmp_prop = np.exp(-(int... | [
"Find",
"the",
"median",
"of",
"the",
"function",
"represented",
"as",
"an",
"interpolation",
"object",
"."
] | neherlab/treetime | python | https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/utils.py#L129-L139 | [
"def",
"median_interp",
"(",
"interp_object",
")",
":",
"new_grid",
"=",
"np",
".",
"sort",
"(",
"np",
".",
"concatenate",
"(",
"[",
"interp_object",
".",
"x",
"[",
":",
"-",
"1",
"]",
"+",
"0.1",
"*",
"ii",
"*",
"np",
".",
"diff",
"(",
"interp_obj... | f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0 |
test | numeric_date | Convert datetime object to the numeric date.
The numeric date format is YYYY.F, where F is the fraction of the year passed
Parameters
----------
dt: datetime.datetime, None
date of to be converted. if None, assume today | treetime/utils.py | def numeric_date(dt=None):
"""
Convert datetime object to the numeric date.
The numeric date format is YYYY.F, where F is the fraction of the year passed
Parameters
----------
dt: datetime.datetime, None
date of to be converted. if None, assume today
"""
if dt is None:
... | def numeric_date(dt=None):
"""
Convert datetime object to the numeric date.
The numeric date format is YYYY.F, where F is the fraction of the year passed
Parameters
----------
dt: datetime.datetime, None
date of to be converted. if None, assume today
"""
if dt is None:
... | [
"Convert",
"datetime",
"object",
"to",
"the",
"numeric",
"date",
".",
"The",
"numeric",
"date",
"format",
"is",
"YYYY",
".",
"F",
"where",
"F",
"is",
"the",
"fraction",
"of",
"the",
"year",
"passed"
] | neherlab/treetime | python | https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/utils.py#L142-L161 | [
"def",
"numeric_date",
"(",
"dt",
"=",
"None",
")",
":",
"if",
"dt",
"is",
"None",
":",
"dt",
"=",
"datetime",
".",
"datetime",
".",
"now",
"(",
")",
"try",
":",
"res",
"=",
"dt",
".",
"year",
"+",
"dt",
".",
"timetuple",
"(",
")",
".",
"tm_yda... | f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0 |
test | parse_dates | parse dates from the arguments and return a dictionary mapping
taxon names to numerical dates.
Parameters
----------
date_file : str
name of file to parse meta data from
Returns
-------
dict
dictionary linking fields in a column interpreted as taxon name
(first colu... | treetime/utils.py | def parse_dates(date_file):
"""
parse dates from the arguments and return a dictionary mapping
taxon names to numerical dates.
Parameters
----------
date_file : str
name of file to parse meta data from
Returns
-------
dict
dictionary linking fields in a column inter... | def parse_dates(date_file):
"""
parse dates from the arguments and return a dictionary mapping
taxon names to numerical dates.
Parameters
----------
date_file : str
name of file to parse meta data from
Returns
-------
dict
dictionary linking fields in a column inter... | [
"parse",
"dates",
"from",
"the",
"arguments",
"and",
"return",
"a",
"dictionary",
"mapping",
"taxon",
"names",
"to",
"numerical",
"dates",
"."
] | neherlab/treetime | python | https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/utils.py#L165-L266 | [
"def",
"parse_dates",
"(",
"date_file",
")",
":",
"print",
"(",
"\"\\nAttempting to parse dates...\"",
")",
"dates",
"=",
"{",
"}",
"if",
"not",
"os",
".",
"path",
".",
"isfile",
"(",
"date_file",
")",
":",
"print",
"(",
"\"\\n\\tERROR: file %s does not exist, e... | f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0 |
test | ambiguous_date_to_date_range | parse an abiguous date such as 2017-XX-XX to [2017,2017.999]
Parameters
----------
mydate : str
date string to be parsed
fmt : str
format descriptor. default is %Y-%m-%d
min_max_year : None, optional
if date is completely unknown, use this as bounds.
Returns
-------... | treetime/utils.py | def ambiguous_date_to_date_range(mydate, fmt="%Y-%m-%d", min_max_year=None):
"""parse an abiguous date such as 2017-XX-XX to [2017,2017.999]
Parameters
----------
mydate : str
date string to be parsed
fmt : str
format descriptor. default is %Y-%m-%d
min_max_year : None, optional... | def ambiguous_date_to_date_range(mydate, fmt="%Y-%m-%d", min_max_year=None):
"""parse an abiguous date such as 2017-XX-XX to [2017,2017.999]
Parameters
----------
mydate : str
date string to be parsed
fmt : str
format descriptor. default is %Y-%m-%d
min_max_year : None, optional... | [
"parse",
"an",
"abiguous",
"date",
"such",
"as",
"2017",
"-",
"XX",
"-",
"XX",
"to",
"[",
"2017",
"2017",
".",
"999",
"]"
] | neherlab/treetime | python | https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/utils.py#L269-L320 | [
"def",
"ambiguous_date_to_date_range",
"(",
"mydate",
",",
"fmt",
"=",
"\"%Y-%m-%d\"",
",",
"min_max_year",
"=",
"None",
")",
":",
"from",
"datetime",
"import",
"datetime",
"sep",
"=",
"fmt",
".",
"split",
"(",
"'%'",
")",
"[",
"1",
"]",
"[",
"-",
"1",
... | f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0 |
test | DateConversion.from_regression | Create the conversion object automatically from the tree
Parameters
----------
clock_model : dict
dictionary as returned from TreeRegression with fields intercept and slope | treetime/utils.py | def from_regression(cls, clock_model):
"""
Create the conversion object automatically from the tree
Parameters
----------
clock_model : dict
dictionary as returned from TreeRegression with fields intercept and slope
"""
dc = cls()
dc.clock_... | def from_regression(cls, clock_model):
"""
Create the conversion object automatically from the tree
Parameters
----------
clock_model : dict
dictionary as returned from TreeRegression with fields intercept and slope
"""
dc = cls()
dc.clock_... | [
"Create",
"the",
"conversion",
"object",
"automatically",
"from",
"the",
"tree"
] | neherlab/treetime | python | https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/utils.py#L41-L60 | [
"def",
"from_regression",
"(",
"cls",
",",
"clock_model",
")",
":",
"dc",
"=",
"cls",
"(",
")",
"dc",
".",
"clock_rate",
"=",
"clock_model",
"[",
"'slope'",
"]",
"dc",
".",
"intercept",
"=",
"clock_model",
"[",
"'intercept'",
"]",
"dc",
".",
"chisq",
"... | f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0 |
test | GuacamoleClient.client | Socket connection. | guacamole/client.py | def client(self):
"""
Socket connection.
"""
if not self._client:
self._client = socket.create_connection(
(self.host, self.port), self.timeout)
self.logger.debug('Client connected with guacd server (%s, %s, %s)'
% (se... | def client(self):
"""
Socket connection.
"""
if not self._client:
self._client = socket.create_connection(
(self.host, self.port), self.timeout)
self.logger.debug('Client connected with guacd server (%s, %s, %s)'
% (se... | [
"Socket",
"connection",
"."
] | mohabusama/pyguacamole | python | https://github.com/mohabusama/pyguacamole/blob/344dccc6cb3a9a045afeaf337677e5d0001aa83a/guacamole/client.py#L65-L75 | [
"def",
"client",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_client",
":",
"self",
".",
"_client",
"=",
"socket",
".",
"create_connection",
"(",
"(",
"self",
".",
"host",
",",
"self",
".",
"port",
")",
",",
"self",
".",
"timeout",
")",
"self... | 344dccc6cb3a9a045afeaf337677e5d0001aa83a |
test | GuacamoleClient.close | Terminate connection with Guacamole guacd server. | guacamole/client.py | def close(self):
"""
Terminate connection with Guacamole guacd server.
"""
self.client.close()
self._client = None
self.connected = False
self.logger.debug('Connection closed.') | def close(self):
"""
Terminate connection with Guacamole guacd server.
"""
self.client.close()
self._client = None
self.connected = False
self.logger.debug('Connection closed.') | [
"Terminate",
"connection",
"with",
"Guacamole",
"guacd",
"server",
"."
] | mohabusama/pyguacamole | python | https://github.com/mohabusama/pyguacamole/blob/344dccc6cb3a9a045afeaf337677e5d0001aa83a/guacamole/client.py#L82-L89 | [
"def",
"close",
"(",
"self",
")",
":",
"self",
".",
"client",
".",
"close",
"(",
")",
"self",
".",
"_client",
"=",
"None",
"self",
".",
"connected",
"=",
"False",
"self",
".",
"logger",
".",
"debug",
"(",
"'Connection closed.'",
")"
] | 344dccc6cb3a9a045afeaf337677e5d0001aa83a |
test | GuacamoleClient.receive | Receive instructions from Guacamole guacd server. | guacamole/client.py | def receive(self):
"""
Receive instructions from Guacamole guacd server.
"""
start = 0
while True:
idx = self._buffer.find(INST_TERM.encode(), start)
if idx != -1:
# instruction was fully received!
line = self._buffer[:idx ... | def receive(self):
"""
Receive instructions from Guacamole guacd server.
"""
start = 0
while True:
idx = self._buffer.find(INST_TERM.encode(), start)
if idx != -1:
# instruction was fully received!
line = self._buffer[:idx ... | [
"Receive",
"instructions",
"from",
"Guacamole",
"guacd",
"server",
"."
] | mohabusama/pyguacamole | python | https://github.com/mohabusama/pyguacamole/blob/344dccc6cb3a9a045afeaf337677e5d0001aa83a/guacamole/client.py#L91-L115 | [
"def",
"receive",
"(",
"self",
")",
":",
"start",
"=",
"0",
"while",
"True",
":",
"idx",
"=",
"self",
".",
"_buffer",
".",
"find",
"(",
"INST_TERM",
".",
"encode",
"(",
")",
",",
"start",
")",
"if",
"idx",
"!=",
"-",
"1",
":",
"# instruction was fu... | 344dccc6cb3a9a045afeaf337677e5d0001aa83a |
test | GuacamoleClient.send | Send encoded instructions to Guacamole guacd server. | guacamole/client.py | def send(self, data):
"""
Send encoded instructions to Guacamole guacd server.
"""
self.logger.debug('Sending data: %s' % data)
self.client.sendall(data.encode()) | def send(self, data):
"""
Send encoded instructions to Guacamole guacd server.
"""
self.logger.debug('Sending data: %s' % data)
self.client.sendall(data.encode()) | [
"Send",
"encoded",
"instructions",
"to",
"Guacamole",
"guacd",
"server",
"."
] | mohabusama/pyguacamole | python | https://github.com/mohabusama/pyguacamole/blob/344dccc6cb3a9a045afeaf337677e5d0001aa83a/guacamole/client.py#L117-L122 | [
"def",
"send",
"(",
"self",
",",
"data",
")",
":",
"self",
".",
"logger",
".",
"debug",
"(",
"'Sending data: %s'",
"%",
"data",
")",
"self",
".",
"client",
".",
"sendall",
"(",
"data",
".",
"encode",
"(",
")",
")"
] | 344dccc6cb3a9a045afeaf337677e5d0001aa83a |
test | GuacamoleClient.send_instruction | Send instruction after encoding. | guacamole/client.py | def send_instruction(self, instruction):
"""
Send instruction after encoding.
"""
self.logger.debug('Sending instruction: %s' % str(instruction))
return self.send(instruction.encode()) | def send_instruction(self, instruction):
"""
Send instruction after encoding.
"""
self.logger.debug('Sending instruction: %s' % str(instruction))
return self.send(instruction.encode()) | [
"Send",
"instruction",
"after",
"encoding",
"."
] | mohabusama/pyguacamole | python | https://github.com/mohabusama/pyguacamole/blob/344dccc6cb3a9a045afeaf337677e5d0001aa83a/guacamole/client.py#L131-L136 | [
"def",
"send_instruction",
"(",
"self",
",",
"instruction",
")",
":",
"self",
".",
"logger",
".",
"debug",
"(",
"'Sending instruction: %s'",
"%",
"str",
"(",
"instruction",
")",
")",
"return",
"self",
".",
"send",
"(",
"instruction",
".",
"encode",
"(",
")... | 344dccc6cb3a9a045afeaf337677e5d0001aa83a |
test | GuacamoleClient.handshake | Establish connection with Guacamole guacd server via handshake. | guacamole/client.py | def handshake(self, protocol='vnc', width=1024, height=768, dpi=96,
audio=None, video=None, image=None, **kwargs):
"""
Establish connection with Guacamole guacd server via handshake.
"""
if protocol not in PROTOCOLS:
self.logger.debug('Invalid protocol: %s' ... | def handshake(self, protocol='vnc', width=1024, height=768, dpi=96,
audio=None, video=None, image=None, **kwargs):
"""
Establish connection with Guacamole guacd server via handshake.
"""
if protocol not in PROTOCOLS:
self.logger.debug('Invalid protocol: %s' ... | [
"Establish",
"connection",
"with",
"Guacamole",
"guacd",
"server",
"via",
"handshake",
"."
] | mohabusama/pyguacamole | python | https://github.com/mohabusama/pyguacamole/blob/344dccc6cb3a9a045afeaf337677e5d0001aa83a/guacamole/client.py#L138-L213 | [
"def",
"handshake",
"(",
"self",
",",
"protocol",
"=",
"'vnc'",
",",
"width",
"=",
"1024",
",",
"height",
"=",
"768",
",",
"dpi",
"=",
"96",
",",
"audio",
"=",
"None",
",",
"video",
"=",
"None",
",",
"image",
"=",
"None",
",",
"*",
"*",
"kwargs",... | 344dccc6cb3a9a045afeaf337677e5d0001aa83a |
test | utf8 | Return a utf-8 encoded string from a valid unicode string.
:param unicode_str: Unicode string.
:return: str | guacamole/instruction.py | def utf8(unicode_str):
"""
Return a utf-8 encoded string from a valid unicode string.
:param unicode_str: Unicode string.
:return: str
"""
if six.PY2 and isinstance(unicode_str, __unicode__):
return unicode_str.encode('utf-8')
return unicode_str | def utf8(unicode_str):
"""
Return a utf-8 encoded string from a valid unicode string.
:param unicode_str: Unicode string.
:return: str
"""
if six.PY2 and isinstance(unicode_str, __unicode__):
return unicode_str.encode('utf-8')
return unicode_str | [
"Return",
"a",
"utf",
"-",
"8",
"encoded",
"string",
"from",
"a",
"valid",
"unicode",
"string",
"."
] | mohabusama/pyguacamole | python | https://github.com/mohabusama/pyguacamole/blob/344dccc6cb3a9a045afeaf337677e5d0001aa83a/guacamole/instruction.py#L40-L51 | [
"def",
"utf8",
"(",
"unicode_str",
")",
":",
"if",
"six",
".",
"PY2",
"and",
"isinstance",
"(",
"unicode_str",
",",
"__unicode__",
")",
":",
"return",
"unicode_str",
".",
"encode",
"(",
"'utf-8'",
")",
"return",
"unicode_str"
] | 344dccc6cb3a9a045afeaf337677e5d0001aa83a |
test | GuacamoleInstruction.load | Loads a new GuacamoleInstruction from encoded instruction string.
:param instruction: Instruction string.
:return: GuacamoleInstruction() | guacamole/instruction.py | def load(cls, instruction):
"""
Loads a new GuacamoleInstruction from encoded instruction string.
:param instruction: Instruction string.
:return: GuacamoleInstruction()
"""
if not instruction.endswith(INST_TERM):
raise InvalidInstruction('Instruction termin... | def load(cls, instruction):
"""
Loads a new GuacamoleInstruction from encoded instruction string.
:param instruction: Instruction string.
:return: GuacamoleInstruction()
"""
if not instruction.endswith(INST_TERM):
raise InvalidInstruction('Instruction termin... | [
"Loads",
"a",
"new",
"GuacamoleInstruction",
"from",
"encoded",
"instruction",
"string",
"."
] | mohabusama/pyguacamole | python | https://github.com/mohabusama/pyguacamole/blob/344dccc6cb3a9a045afeaf337677e5d0001aa83a/guacamole/instruction.py#L61-L74 | [
"def",
"load",
"(",
"cls",
",",
"instruction",
")",
":",
"if",
"not",
"instruction",
".",
"endswith",
"(",
"INST_TERM",
")",
":",
"raise",
"InvalidInstruction",
"(",
"'Instruction termination not found.'",
")",
"args",
"=",
"cls",
".",
"decode_instruction",
"(",... | 344dccc6cb3a9a045afeaf337677e5d0001aa83a |
test | GuacamoleInstruction.decode_instruction | Decode whole instruction and return list of args.
Usually, returned arg[0] is the instruction opcode.
example:
>> args = decode_instruction('4.size,4.1024;')
>> args == ['size', '1024']
>> True
:param instruction: Instruction string.
:return: list | guacamole/instruction.py | def decode_instruction(instruction):
"""
Decode whole instruction and return list of args.
Usually, returned arg[0] is the instruction opcode.
example:
>> args = decode_instruction('4.size,4.1024;')
>> args == ['size', '1024']
>> True
:param instruction:... | def decode_instruction(instruction):
"""
Decode whole instruction and return list of args.
Usually, returned arg[0] is the instruction opcode.
example:
>> args = decode_instruction('4.size,4.1024;')
>> args == ['size', '1024']
>> True
:param instruction:... | [
"Decode",
"whole",
"instruction",
"and",
"return",
"list",
"of",
"args",
".",
"Usually",
"returned",
"arg",
"[",
"0",
"]",
"is",
"the",
"instruction",
"opcode",
"."
] | mohabusama/pyguacamole | python | https://github.com/mohabusama/pyguacamole/blob/344dccc6cb3a9a045afeaf337677e5d0001aa83a/guacamole/instruction.py#L77-L130 | [
"def",
"decode_instruction",
"(",
"instruction",
")",
":",
"if",
"not",
"instruction",
".",
"endswith",
"(",
"INST_TERM",
")",
":",
"raise",
"InvalidInstruction",
"(",
"'Instruction termination not found.'",
")",
"# Use proper encoding",
"instruction",
"=",
"utf8",
"(... | 344dccc6cb3a9a045afeaf337677e5d0001aa83a |
test | GuacamoleInstruction.encode_arg | Encode argument to be sent in a valid GuacamoleInstruction.
example:
>> arg = encode_arg('size')
>> arg == '4.size'
>> True
:param arg: arg string.
:return: str | guacamole/instruction.py | def encode_arg(arg):
"""
Encode argument to be sent in a valid GuacamoleInstruction.
example:
>> arg = encode_arg('size')
>> arg == '4.size'
>> True
:param arg: arg string.
:return: str
"""
arg_utf8 = utf8(arg)
return ELEM_SEP.j... | def encode_arg(arg):
"""
Encode argument to be sent in a valid GuacamoleInstruction.
example:
>> arg = encode_arg('size')
>> arg == '4.size'
>> True
:param arg: arg string.
:return: str
"""
arg_utf8 = utf8(arg)
return ELEM_SEP.j... | [
"Encode",
"argument",
"to",
"be",
"sent",
"in",
"a",
"valid",
"GuacamoleInstruction",
"."
] | mohabusama/pyguacamole | python | https://github.com/mohabusama/pyguacamole/blob/344dccc6cb3a9a045afeaf337677e5d0001aa83a/guacamole/instruction.py#L133-L148 | [
"def",
"encode_arg",
"(",
"arg",
")",
":",
"arg_utf8",
"=",
"utf8",
"(",
"arg",
")",
"return",
"ELEM_SEP",
".",
"join",
"(",
"[",
"str",
"(",
"len",
"(",
"str",
"(",
"arg_utf8",
")",
")",
")",
",",
"str",
"(",
"arg_utf8",
")",
"]",
")"
] | 344dccc6cb3a9a045afeaf337677e5d0001aa83a |
test | GuacamoleInstruction.encode | Prepare the instruction to be sent over the wire.
:return: str | guacamole/instruction.py | def encode(self):
"""
Prepare the instruction to be sent over the wire.
:return: str
"""
instruction_iter = itertools.chain([self.opcode], self.args)
elems = ARG_SEP.join(self.encode_arg(arg) for arg in instruction_iter)
return elems + INST_TERM | def encode(self):
"""
Prepare the instruction to be sent over the wire.
:return: str
"""
instruction_iter = itertools.chain([self.opcode], self.args)
elems = ARG_SEP.join(self.encode_arg(arg) for arg in instruction_iter)
return elems + INST_TERM | [
"Prepare",
"the",
"instruction",
"to",
"be",
"sent",
"over",
"the",
"wire",
"."
] | mohabusama/pyguacamole | python | https://github.com/mohabusama/pyguacamole/blob/344dccc6cb3a9a045afeaf337677e5d0001aa83a/guacamole/instruction.py#L150-L160 | [
"def",
"encode",
"(",
"self",
")",
":",
"instruction_iter",
"=",
"itertools",
".",
"chain",
"(",
"[",
"self",
".",
"opcode",
"]",
",",
"self",
".",
"args",
")",
"elems",
"=",
"ARG_SEP",
".",
"join",
"(",
"self",
".",
"encode_arg",
"(",
"arg",
")",
... | 344dccc6cb3a9a045afeaf337677e5d0001aa83a |
test | APIResource.class_url | Returns a versioned URI string for this class | solvebio/resource/apiresource.py | def class_url(cls):
"""Returns a versioned URI string for this class"""
base = 'v{0}'.format(getattr(cls, 'RESOURCE_VERSION', '1'))
return "/{0}/{1}".format(base, class_to_api_name(cls.class_name())) | def class_url(cls):
"""Returns a versioned URI string for this class"""
base = 'v{0}'.format(getattr(cls, 'RESOURCE_VERSION', '1'))
return "/{0}/{1}".format(base, class_to_api_name(cls.class_name())) | [
"Returns",
"a",
"versioned",
"URI",
"string",
"for",
"this",
"class"
] | solvebio/solvebio-python | python | https://github.com/solvebio/solvebio-python/blob/b29614643043afd19c1d8074e8f25c6700d51a73/solvebio/resource/apiresource.py#L49-L52 | [
"def",
"class_url",
"(",
"cls",
")",
":",
"base",
"=",
"'v{0}'",
".",
"format",
"(",
"getattr",
"(",
"cls",
",",
"'RESOURCE_VERSION'",
",",
"'1'",
")",
")",
"return",
"\"/{0}/{1}\"",
".",
"format",
"(",
"base",
",",
"class_to_api_name",
"(",
"cls",
".",
... | b29614643043afd19c1d8074e8f25c6700d51a73 |
test | APIResource.instance_url | Get instance URL by ID | solvebio/resource/apiresource.py | def instance_url(self):
"""Get instance URL by ID"""
id_ = self.get(self.ID_ATTR)
base = self.class_url()
if id_:
return '/'.join([base, six.text_type(id_)])
else:
raise Exception(
'Could not determine which URL to request: %s instance '
... | def instance_url(self):
"""Get instance URL by ID"""
id_ = self.get(self.ID_ATTR)
base = self.class_url()
if id_:
return '/'.join([base, six.text_type(id_)])
else:
raise Exception(
'Could not determine which URL to request: %s instance '
... | [
"Get",
"instance",
"URL",
"by",
"ID"
] | solvebio/solvebio-python | python | https://github.com/solvebio/solvebio-python/blob/b29614643043afd19c1d8074e8f25c6700d51a73/solvebio/resource/apiresource.py#L54-L65 | [
"def",
"instance_url",
"(",
"self",
")",
":",
"id_",
"=",
"self",
".",
"get",
"(",
"self",
".",
"ID_ATTR",
")",
"base",
"=",
"self",
".",
"class_url",
"(",
")",
"if",
"id_",
":",
"return",
"'/'",
".",
"join",
"(",
"[",
"base",
",",
"six",
".",
... | b29614643043afd19c1d8074e8f25c6700d51a73 |
test | SingletonAPIResource.class_url | Returns a versioned URI string for this class,
and don't pluralize the class name. | solvebio/resource/apiresource.py | def class_url(cls):
"""
Returns a versioned URI string for this class,
and don't pluralize the class name.
"""
base = 'v{0}'.format(getattr(cls, 'RESOURCE_VERSION', '1'))
return "/{0}/{1}".format(base, class_to_api_name(
cls.class_name(), pluralize=False)) | def class_url(cls):
"""
Returns a versioned URI string for this class,
and don't pluralize the class name.
"""
base = 'v{0}'.format(getattr(cls, 'RESOURCE_VERSION', '1'))
return "/{0}/{1}".format(base, class_to_api_name(
cls.class_name(), pluralize=False)) | [
"Returns",
"a",
"versioned",
"URI",
"string",
"for",
"this",
"class",
"and",
"don",
"t",
"pluralize",
"the",
"class",
"name",
"."
] | solvebio/solvebio-python | python | https://github.com/solvebio/solvebio-python/blob/b29614643043afd19c1d8074e8f25c6700d51a73/solvebio/resource/apiresource.py#L146-L153 | [
"def",
"class_url",
"(",
"cls",
")",
":",
"base",
"=",
"'v{0}'",
".",
"format",
"(",
"getattr",
"(",
"cls",
",",
"'RESOURCE_VERSION'",
",",
"'1'",
")",
")",
"return",
"\"/{0}/{1}\"",
".",
"format",
"(",
"base",
",",
"class_to_api_name",
"(",
"cls",
".",
... | b29614643043afd19c1d8074e8f25c6700d51a73 |
test | DownloadableAPIResource.download | Download the file to the specified directory or file path.
Downloads to a temporary directory if no path is specified.
Returns the absolute path to the file. | solvebio/resource/apiresource.py | def download(self, path=None, **kwargs):
"""
Download the file to the specified directory or file path.
Downloads to a temporary directory if no path is specified.
Returns the absolute path to the file.
"""
download_url = self.download_url(**kwargs)
try:
... | def download(self, path=None, **kwargs):
"""
Download the file to the specified directory or file path.
Downloads to a temporary directory if no path is specified.
Returns the absolute path to the file.
"""
download_url = self.download_url(**kwargs)
try:
... | [
"Download",
"the",
"file",
"to",
"the",
"specified",
"directory",
"or",
"file",
"path",
".",
"Downloads",
"to",
"a",
"temporary",
"directory",
"if",
"no",
"path",
"is",
"specified",
"."
] | solvebio/solvebio-python | python | https://github.com/solvebio/solvebio-python/blob/b29614643043afd19c1d8074e8f25c6700d51a73/solvebio/resource/apiresource.py#L187-L226 | [
"def",
"download",
"(",
"self",
",",
"path",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"download_url",
"=",
"self",
".",
"download_url",
"(",
"*",
"*",
"kwargs",
")",
"try",
":",
"# For vault objects, use the object's filename",
"# as the fallback if none ... | b29614643043afd19c1d8074e8f25c6700d51a73 |
test | DatasetCommit.parent_object | Get the commit objects parent Import or Migration | solvebio/resource/datasetcommit.py | def parent_object(self):
""" Get the commit objects parent Import or Migration """
from . import types
parent_klass = types.get(self.parent_job_model.split('.')[1])
return parent_klass.retrieve(self.parent_job_id, client=self._client) | def parent_object(self):
""" Get the commit objects parent Import or Migration """
from . import types
parent_klass = types.get(self.parent_job_model.split('.')[1])
return parent_klass.retrieve(self.parent_job_id, client=self._client) | [
"Get",
"the",
"commit",
"objects",
"parent",
"Import",
"or",
"Migration"
] | solvebio/solvebio-python | python | https://github.com/solvebio/solvebio-python/blob/b29614643043afd19c1d8074e8f25c6700d51a73/solvebio/resource/datasetcommit.py#L29-L33 | [
"def",
"parent_object",
"(",
"self",
")",
":",
"from",
".",
"import",
"types",
"parent_klass",
"=",
"types",
".",
"get",
"(",
"self",
".",
"parent_job_model",
".",
"split",
"(",
"'.'",
")",
"[",
"1",
"]",
")",
"return",
"parent_klass",
".",
"retrieve",
... | b29614643043afd19c1d8074e8f25c6700d51a73 |
test | _ask_for_credentials | Asks the user for their email and password. | solvebio/cli/auth.py | def _ask_for_credentials():
"""
Asks the user for their email and password.
"""
_print_msg('Please enter your SolveBio credentials')
domain = raw_input('Domain (e.g. <domain>.solvebio.com): ')
# Check to see if this domain supports password authentication
try:
account = client.reques... | def _ask_for_credentials():
"""
Asks the user for their email and password.
"""
_print_msg('Please enter your SolveBio credentials')
domain = raw_input('Domain (e.g. <domain>.solvebio.com): ')
# Check to see if this domain supports password authentication
try:
account = client.reques... | [
"Asks",
"the",
"user",
"for",
"their",
"email",
"and",
"password",
"."
] | solvebio/solvebio-python | python | https://github.com/solvebio/solvebio-python/blob/b29614643043afd19c1d8074e8f25c6700d51a73/solvebio/cli/auth.py#L22-L45 | [
"def",
"_ask_for_credentials",
"(",
")",
":",
"_print_msg",
"(",
"'Please enter your SolveBio credentials'",
")",
"domain",
"=",
"raw_input",
"(",
"'Domain (e.g. <domain>.solvebio.com): '",
")",
"# Check to see if this domain supports password authentication",
"try",
":",
"accoun... | b29614643043afd19c1d8074e8f25c6700d51a73 |
test | login | Prompt user for login information (domain/email/password).
Domain, email and password are used to get the user's API key.
Always updates the stored credentials file. | solvebio/cli/auth.py | def login(*args, **kwargs):
"""
Prompt user for login information (domain/email/password).
Domain, email and password are used to get the user's API key.
Always updates the stored credentials file.
"""
if args and args[0].api_key:
# Handle command-line arguments if provided.
sol... | def login(*args, **kwargs):
"""
Prompt user for login information (domain/email/password).
Domain, email and password are used to get the user's API key.
Always updates the stored credentials file.
"""
if args and args[0].api_key:
# Handle command-line arguments if provided.
sol... | [
"Prompt",
"user",
"for",
"login",
"information",
"(",
"domain",
"/",
"email",
"/",
"password",
")",
".",
"Domain",
"email",
"and",
"password",
"are",
"used",
"to",
"get",
"the",
"user",
"s",
"API",
"key",
"."
] | solvebio/solvebio-python | python | https://github.com/solvebio/solvebio-python/blob/b29614643043afd19c1d8074e8f25c6700d51a73/solvebio/cli/auth.py#L48-L75 | [
"def",
"login",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"args",
"and",
"args",
"[",
"0",
"]",
".",
"api_key",
":",
"# Handle command-line arguments if provided.",
"solvebio",
".",
"login",
"(",
"api_key",
"=",
"args",
"[",
"0",
"]",
... | b29614643043afd19c1d8074e8f25c6700d51a73 |
test | interactive_login | Force an interactive login via the command line.
Sets the global API key and updates the client auth. | solvebio/cli/auth.py | def interactive_login():
"""
Force an interactive login via the command line.
Sets the global API key and updates the client auth.
"""
solvebio.access_token = None
solvebio.api_key = None
client.set_token()
domain, email, password = _ask_for_credentials()
if not all([domain, email, ... | def interactive_login():
"""
Force an interactive login via the command line.
Sets the global API key and updates the client auth.
"""
solvebio.access_token = None
solvebio.api_key = None
client.set_token()
domain, email, password = _ask_for_credentials()
if not all([domain, email, ... | [
"Force",
"an",
"interactive",
"login",
"via",
"the",
"command",
"line",
".",
"Sets",
"the",
"global",
"API",
"key",
"and",
"updates",
"the",
"client",
"auth",
"."
] | solvebio/solvebio-python | python | https://github.com/solvebio/solvebio-python/blob/b29614643043afd19c1d8074e8f25c6700d51a73/solvebio/cli/auth.py#L78-L102 | [
"def",
"interactive_login",
"(",
")",
":",
"solvebio",
".",
"access_token",
"=",
"None",
"solvebio",
".",
"api_key",
"=",
"None",
"client",
".",
"set_token",
"(",
")",
"domain",
",",
"email",
",",
"password",
"=",
"_ask_for_credentials",
"(",
")",
"if",
"n... | b29614643043afd19c1d8074e8f25c6700d51a73 |
test | whoami | Prints information about the current user.
Assumes the user is already logged-in. | solvebio/cli/auth.py | def whoami(*args, **kwargs):
"""
Prints information about the current user.
Assumes the user is already logged-in.
"""
user = client.whoami()
if user:
print_user(user)
else:
print('You are not logged-in.') | def whoami(*args, **kwargs):
"""
Prints information about the current user.
Assumes the user is already logged-in.
"""
user = client.whoami()
if user:
print_user(user)
else:
print('You are not logged-in.') | [
"Prints",
"information",
"about",
"the",
"current",
"user",
".",
"Assumes",
"the",
"user",
"is",
"already",
"logged",
"-",
"in",
"."
] | solvebio/solvebio-python | python | https://github.com/solvebio/solvebio-python/blob/b29614643043afd19c1d8074e8f25c6700d51a73/solvebio/cli/auth.py#L116-L126 | [
"def",
"whoami",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"user",
"=",
"client",
".",
"whoami",
"(",
")",
"if",
"user",
":",
"print_user",
"(",
"user",
")",
"else",
":",
"print",
"(",
"'You are not logged-in.'",
")"
] | b29614643043afd19c1d8074e8f25c6700d51a73 |
test | print_user | Prints information about the current user. | solvebio/cli/auth.py | def print_user(user):
"""
Prints information about the current user.
"""
email = user['email']
domain = user['account']['domain']
role = user['role']
print('You are logged-in to the "{0}" domain '
'as {1} with role {2}.'
.format(domain, email, role)) | def print_user(user):
"""
Prints information about the current user.
"""
email = user['email']
domain = user['account']['domain']
role = user['role']
print('You are logged-in to the "{0}" domain '
'as {1} with role {2}.'
.format(domain, email, role)) | [
"Prints",
"information",
"about",
"the",
"current",
"user",
"."
] | solvebio/solvebio-python | python | https://github.com/solvebio/solvebio-python/blob/b29614643043afd19c1d8074e8f25c6700d51a73/solvebio/cli/auth.py#L129-L138 | [
"def",
"print_user",
"(",
"user",
")",
":",
"email",
"=",
"user",
"[",
"'email'",
"]",
"domain",
"=",
"user",
"[",
"'account'",
"]",
"[",
"'domain'",
"]",
"role",
"=",
"user",
"[",
"'role'",
"]",
"print",
"(",
"'You are logged-in to the \"{0}\" domain '",
... | b29614643043afd19c1d8074e8f25c6700d51a73 |
test | GenomicFilter.from_string | Handles UCSC-style range queries (chr1:100-200) | solvebio/query.py | def from_string(cls, string, exact=False):
"""
Handles UCSC-style range queries (chr1:100-200)
"""
try:
chromosome, pos = string.split(':')
except ValueError:
raise ValueError('Please use UCSC-style format: "chr2:1000-2000"')
if '-' in pos:
... | def from_string(cls, string, exact=False):
"""
Handles UCSC-style range queries (chr1:100-200)
"""
try:
chromosome, pos = string.split(':')
except ValueError:
raise ValueError('Please use UCSC-style format: "chr2:1000-2000"')
if '-' in pos:
... | [
"Handles",
"UCSC",
"-",
"style",
"range",
"queries",
"(",
"chr1",
":",
"100",
"-",
"200",
")"
] | solvebio/solvebio-python | python | https://github.com/solvebio/solvebio-python/blob/b29614643043afd19c1d8074e8f25c6700d51a73/solvebio/query.py#L160-L174 | [
"def",
"from_string",
"(",
"cls",
",",
"string",
",",
"exact",
"=",
"False",
")",
":",
"try",
":",
"chromosome",
",",
"pos",
"=",
"string",
".",
"split",
"(",
"':'",
")",
"except",
"ValueError",
":",
"raise",
"ValueError",
"(",
"'Please use UCSC-style form... | b29614643043afd19c1d8074e8f25c6700d51a73 |
test | Query.filter | Returns this Query instance with the query args combined with
existing set with AND.
kwargs are simply passed to a new Filter object and combined to any
other filters with AND.
By default, everything is combined using AND. If you provide
multiple filters in a single filter call... | solvebio/query.py | def filter(self, *filters, **kwargs):
"""
Returns this Query instance with the query args combined with
existing set with AND.
kwargs are simply passed to a new Filter object and combined to any
other filters with AND.
By default, everything is combined using AND. If yo... | def filter(self, *filters, **kwargs):
"""
Returns this Query instance with the query args combined with
existing set with AND.
kwargs are simply passed to a new Filter object and combined to any
other filters with AND.
By default, everything is combined using AND. If yo... | [
"Returns",
"this",
"Query",
"instance",
"with",
"the",
"query",
"args",
"combined",
"with",
"existing",
"set",
"with",
"AND",
"."
] | solvebio/solvebio-python | python | https://github.com/solvebio/solvebio-python/blob/b29614643043afd19c1d8074e8f25c6700d51a73/solvebio/query.py#L340-L362 | [
"def",
"filter",
"(",
"self",
",",
"*",
"filters",
",",
"*",
"*",
"kwargs",
")",
":",
"f",
"=",
"list",
"(",
"filters",
")",
"if",
"kwargs",
":",
"f",
"+=",
"[",
"Filter",
"(",
"*",
"*",
"kwargs",
")",
"]",
"return",
"self",
".",
"_clone",
"(",... | b29614643043afd19c1d8074e8f25c6700d51a73 |
test | Query.range | Shortcut to do range filters on genomic datasets. | solvebio/query.py | def range(self, chromosome, start, stop, exact=False):
"""
Shortcut to do range filters on genomic datasets.
"""
return self._clone(
filters=[GenomicFilter(chromosome, start, stop, exact)]) | def range(self, chromosome, start, stop, exact=False):
"""
Shortcut to do range filters on genomic datasets.
"""
return self._clone(
filters=[GenomicFilter(chromosome, start, stop, exact)]) | [
"Shortcut",
"to",
"do",
"range",
"filters",
"on",
"genomic",
"datasets",
"."
] | solvebio/solvebio-python | python | https://github.com/solvebio/solvebio-python/blob/b29614643043afd19c1d8074e8f25c6700d51a73/solvebio/query.py#L364-L369 | [
"def",
"range",
"(",
"self",
",",
"chromosome",
",",
"start",
",",
"stop",
",",
"exact",
"=",
"False",
")",
":",
"return",
"self",
".",
"_clone",
"(",
"filters",
"=",
"[",
"GenomicFilter",
"(",
"chromosome",
",",
"start",
",",
"stop",
",",
"exact",
"... | b29614643043afd19c1d8074e8f25c6700d51a73 |
test | Query.position | Shortcut to do a single position filter on genomic datasets. | solvebio/query.py | def position(self, chromosome, position, exact=False):
"""
Shortcut to do a single position filter on genomic datasets.
"""
return self._clone(
filters=[GenomicFilter(chromosome, position, exact=exact)]) | def position(self, chromosome, position, exact=False):
"""
Shortcut to do a single position filter on genomic datasets.
"""
return self._clone(
filters=[GenomicFilter(chromosome, position, exact=exact)]) | [
"Shortcut",
"to",
"do",
"a",
"single",
"position",
"filter",
"on",
"genomic",
"datasets",
"."
] | solvebio/solvebio-python | python | https://github.com/solvebio/solvebio-python/blob/b29614643043afd19c1d8074e8f25c6700d51a73/solvebio/query.py#L371-L376 | [
"def",
"position",
"(",
"self",
",",
"chromosome",
",",
"position",
",",
"exact",
"=",
"False",
")",
":",
"return",
"self",
".",
"_clone",
"(",
"filters",
"=",
"[",
"GenomicFilter",
"(",
"chromosome",
",",
"position",
",",
"exact",
"=",
"exact",
")",
"... | b29614643043afd19c1d8074e8f25c6700d51a73 |
test | Query.facets | Returns a dictionary with the requested facets.
The facets function supports string args, and keyword
args.
q.facets('field_1', 'field_2') will return facets for
field_1 and field_2.
q.facets(field_1={'limit': 0}, field_2={'limit': 10})
will return all facets for field_... | solvebio/query.py | def facets(self, *args, **kwargs):
"""
Returns a dictionary with the requested facets.
The facets function supports string args, and keyword
args.
q.facets('field_1', 'field_2') will return facets for
field_1 and field_2.
q.facets(field_1={'limit': 0}, field_2={... | def facets(self, *args, **kwargs):
"""
Returns a dictionary with the requested facets.
The facets function supports string args, and keyword
args.
q.facets('field_1', 'field_2') will return facets for
field_1 and field_2.
q.facets(field_1={'limit': 0}, field_2={... | [
"Returns",
"a",
"dictionary",
"with",
"the",
"requested",
"facets",
"."
] | solvebio/solvebio-python | python | https://github.com/solvebio/solvebio-python/blob/b29614643043afd19c1d8074e8f25c6700d51a73/solvebio/query.py#L389-L415 | [
"def",
"facets",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# Combine args and kwargs into facet format.",
"facets",
"=",
"dict",
"(",
"(",
"a",
",",
"{",
"}",
")",
"for",
"a",
"in",
"args",
")",
"facets",
".",
"update",
"(",
... | b29614643043afd19c1d8074e8f25c6700d51a73 |
test | Query._process_filters | Takes a list of filters and returns JSON
:Parameters:
- `filters`: List of Filters, (key, val) tuples, or dicts
Returns: List of JSON API filters | solvebio/query.py | def _process_filters(cls, filters):
"""Takes a list of filters and returns JSON
:Parameters:
- `filters`: List of Filters, (key, val) tuples, or dicts
Returns: List of JSON API filters
"""
data = []
# Filters should always be a list
for f in filters:
... | def _process_filters(cls, filters):
"""Takes a list of filters and returns JSON
:Parameters:
- `filters`: List of Filters, (key, val) tuples, or dicts
Returns: List of JSON API filters
"""
data = []
# Filters should always be a list
for f in filters:
... | [
"Takes",
"a",
"list",
"of",
"filters",
"and",
"returns",
"JSON"
] | solvebio/solvebio-python | python | https://github.com/solvebio/solvebio-python/blob/b29614643043afd19c1d8074e8f25c6700d51a73/solvebio/query.py#L442-L473 | [
"def",
"_process_filters",
"(",
"cls",
",",
"filters",
")",
":",
"data",
"=",
"[",
"]",
"# Filters should always be a list",
"for",
"f",
"in",
"filters",
":",
"if",
"isinstance",
"(",
"f",
",",
"Filter",
")",
":",
"if",
"f",
".",
"filters",
":",
"data",
... | b29614643043afd19c1d8074e8f25c6700d51a73 |
test | Query.next | Allows the Query object to be an iterable.
This method will iterate through a cached result set
and fetch successive pages as required.
A `StopIteration` exception will be raised when there aren't
any more results available or when the requested result
slice range or limit has ... | solvebio/query.py | def next(self):
"""
Allows the Query object to be an iterable.
This method will iterate through a cached result set
and fetch successive pages as required.
A `StopIteration` exception will be raised when there aren't
any more results available or when the requested resu... | def next(self):
"""
Allows the Query object to be an iterable.
This method will iterate through a cached result set
and fetch successive pages as required.
A `StopIteration` exception will be raised when there aren't
any more results available or when the requested resu... | [
"Allows",
"the",
"Query",
"object",
"to",
"be",
"an",
"iterable",
"."
] | solvebio/solvebio-python | python | https://github.com/solvebio/solvebio-python/blob/b29614643043afd19c1d8074e8f25c6700d51a73/solvebio/query.py#L590-L617 | [
"def",
"next",
"(",
"self",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"'_cursor'",
")",
":",
"# Iterator not initialized yet",
"self",
".",
"__iter__",
"(",
")",
"# len(self) returns `min(limit, total)` results",
"if",
"self",
".",
"_cursor",
"==",
"le... | b29614643043afd19c1d8074e8f25c6700d51a73 |
test | Query.execute | Executes a query. Additional query parameters can be passed
as keyword arguments.
Returns: The request parameters and the raw query response. | solvebio/query.py | def execute(self, offset=0, **query):
"""
Executes a query. Additional query parameters can be passed
as keyword arguments.
Returns: The request parameters and the raw query response.
"""
_params = self._build_query(**query)
self._page_offset = offset
_p... | def execute(self, offset=0, **query):
"""
Executes a query. Additional query parameters can be passed
as keyword arguments.
Returns: The request parameters and the raw query response.
"""
_params = self._build_query(**query)
self._page_offset = offset
_p... | [
"Executes",
"a",
"query",
".",
"Additional",
"query",
"parameters",
"can",
"be",
"passed",
"as",
"keyword",
"arguments",
"."
] | solvebio/solvebio-python | python | https://github.com/solvebio/solvebio-python/blob/b29614643043afd19c1d8074e8f25c6700d51a73/solvebio/query.py#L656-L683 | [
"def",
"execute",
"(",
"self",
",",
"offset",
"=",
"0",
",",
"*",
"*",
"query",
")",
":",
"_params",
"=",
"self",
".",
"_build_query",
"(",
"*",
"*",
"query",
")",
"self",
".",
"_page_offset",
"=",
"offset",
"_params",
".",
"update",
"(",
"offset",
... | b29614643043afd19c1d8074e8f25c6700d51a73 |
test | Query.migrate | Migrate the data from the Query to a target dataset.
Valid optional kwargs include:
* target_fields
* include_errors
* validation_params
* metadata
* commit_mode | solvebio/query.py | def migrate(self, target, follow=True, **kwargs):
"""
Migrate the data from the Query to a target dataset.
Valid optional kwargs include:
* target_fields
* include_errors
* validation_params
* metadata
* commit_mode
"""
from solvebio imp... | def migrate(self, target, follow=True, **kwargs):
"""
Migrate the data from the Query to a target dataset.
Valid optional kwargs include:
* target_fields
* include_errors
* validation_params
* metadata
* commit_mode
"""
from solvebio imp... | [
"Migrate",
"the",
"data",
"from",
"the",
"Query",
"to",
"a",
"target",
"dataset",
"."
] | solvebio/solvebio-python | python | https://github.com/solvebio/solvebio-python/blob/b29614643043afd19c1d8074e8f25c6700d51a73/solvebio/query.py#L711-L753 | [
"def",
"migrate",
"(",
"self",
",",
"target",
",",
"follow",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"from",
"solvebio",
"import",
"Dataset",
"from",
"solvebio",
"import",
"DatasetMigration",
"# Target can be provided as a Dataset, or as an ID.",
"if",
"is... | b29614643043afd19c1d8074e8f25c6700d51a73 |
test | login | Sets up the auth credentials using the provided key/token,
or checks the credentials file (if no token provided).
Lookup order:
1. access_token
2. api_key
3. local credentials
No errors are raised if no key is found. | solvebio/__init__.py | def login(**kwargs):
"""
Sets up the auth credentials using the provided key/token,
or checks the credentials file (if no token provided).
Lookup order:
1. access_token
2. api_key
3. local credentials
No errors are raised if no key is found.
"""
from .cli.auth impor... | def login(**kwargs):
"""
Sets up the auth credentials using the provided key/token,
or checks the credentials file (if no token provided).
Lookup order:
1. access_token
2. api_key
3. local credentials
No errors are raised if no key is found.
"""
from .cli.auth impor... | [
"Sets",
"up",
"the",
"auth",
"credentials",
"using",
"the",
"provided",
"key",
"/",
"token",
"or",
"checks",
"the",
"credentials",
"file",
"(",
"if",
"no",
"token",
"provided",
")",
"."
] | solvebio/solvebio-python | python | https://github.com/solvebio/solvebio-python/blob/b29614643043afd19c1d8074e8f25c6700d51a73/solvebio/__init__.py#L120-L153 | [
"def",
"login",
"(",
"*",
"*",
"kwargs",
")",
":",
"from",
".",
"cli",
".",
"auth",
"import",
"get_credentials",
"global",
"access_token",
",",
"api_key",
",",
"api_host",
"# Clear any existing auth keys",
"access_token",
",",
"api_key",
"=",
"None",
",",
"Non... | b29614643043afd19c1d8074e8f25c6700d51a73 |
test | main | Main entry point for SolveBio CLI | solvebio/cli/main.py | def main(argv=sys.argv[1:]):
""" Main entry point for SolveBio CLI """
parser = SolveArgumentParser()
args = parser.parse_solvebio_args(argv)
if args.api_host:
solvebio.api_host = args.api_host
if args.api_key:
solvebio.api_key = args.api_key
if not solvebio.api_key:
#... | def main(argv=sys.argv[1:]):
""" Main entry point for SolveBio CLI """
parser = SolveArgumentParser()
args = parser.parse_solvebio_args(argv)
if args.api_host:
solvebio.api_host = args.api_host
if args.api_key:
solvebio.api_key = args.api_key
if not solvebio.api_key:
#... | [
"Main",
"entry",
"point",
"for",
"SolveBio",
"CLI"
] | solvebio/solvebio-python | python | https://github.com/solvebio/solvebio-python/blob/b29614643043afd19c1d8074e8f25c6700d51a73/solvebio/cli/main.py#L285-L309 | [
"def",
"main",
"(",
"argv",
"=",
"sys",
".",
"argv",
"[",
"1",
":",
"]",
")",
":",
"parser",
"=",
"SolveArgumentParser",
"(",
")",
"args",
"=",
"parser",
".",
"parse_solvebio_args",
"(",
"argv",
")",
"if",
"args",
".",
"api_host",
":",
"solvebio",
".... | b29614643043afd19c1d8074e8f25c6700d51a73 |
test | SolveArgumentParser._add_subcommands | The _add_subcommands method must be separate from the __init__
method, as infinite recursion will occur otherwise, due to the fact
that the __init__ method itself will be called when instantiating
a subparser, as we do below | solvebio/cli/main.py | def _add_subcommands(self):
"""
The _add_subcommands method must be separate from the __init__
method, as infinite recursion will occur otherwise, due to the fact
that the __init__ method itself will be called when instantiating
a subparser, as we do below
... | def _add_subcommands(self):
"""
The _add_subcommands method must be separate from the __init__
method, as infinite recursion will occur otherwise, due to the fact
that the __init__ method itself will be called when instantiating
a subparser, as we do below
... | [
"The",
"_add_subcommands",
"method",
"must",
"be",
"separate",
"from",
"the",
"__init__",
"method",
"as",
"infinite",
"recursion",
"will",
"occur",
"otherwise",
"due",
"to",
"the",
"fact",
"that",
"the",
"__init__",
"method",
"itself",
"will",
"be",
"called",
... | solvebio/solvebio-python | python | https://github.com/solvebio/solvebio-python/blob/b29614643043afd19c1d8074e8f25c6700d51a73/solvebio/cli/main.py#L232-L252 | [
"def",
"_add_subcommands",
"(",
"self",
")",
":",
"subcmd_params",
"=",
"{",
"'title'",
":",
"'SolveBio Commands'",
",",
"'dest'",
":",
"'subcommands'",
"}",
"subcmd",
"=",
"self",
".",
"add_subparsers",
"(",
"*",
"*",
"subcmd_params",
")",
"# pylint: disable=st... | b29614643043afd19c1d8074e8f25c6700d51a73 |
test | SolveArgumentParser.parse_solvebio_args | Try to parse the args first, and then add the subparsers. We want
to do this so that we can check to see if there are any unknown
args. We can assume that if, by this point, there are no unknown
args, we can append shell to the unknown args as a default.
However, to do th... | solvebio/cli/main.py | def parse_solvebio_args(self, args=None, namespace=None):
"""
Try to parse the args first, and then add the subparsers. We want
to do this so that we can check to see if there are any unknown
args. We can assume that if, by this point, there are no unknown
args, w... | def parse_solvebio_args(self, args=None, namespace=None):
"""
Try to parse the args first, and then add the subparsers. We want
to do this so that we can check to see if there are any unknown
args. We can assume that if, by this point, there are no unknown
args, w... | [
"Try",
"to",
"parse",
"the",
"args",
"first",
"and",
"then",
"add",
"the",
"subparsers",
".",
"We",
"want",
"to",
"do",
"this",
"so",
"that",
"we",
"can",
"check",
"to",
"see",
"if",
"there",
"are",
"any",
"unknown",
"args",
".",
"We",
"can",
"assume... | solvebio/solvebio-python | python | https://github.com/solvebio/solvebio-python/blob/b29614643043afd19c1d8074e8f25c6700d51a73/solvebio/cli/main.py#L254-L278 | [
"def",
"parse_solvebio_args",
"(",
"self",
",",
"args",
"=",
"None",
",",
"namespace",
"=",
"None",
")",
":",
"try",
":",
"sys",
".",
"stdout",
"=",
"sys",
".",
"stderr",
"=",
"open",
"(",
"os",
".",
"devnull",
",",
"'w'",
")",
"_",
",",
"unknown_a... | b29614643043afd19c1d8074e8f25c6700d51a73 |
test | download_vault_folder | Recursively downloads a folder in a vault to a local directory.
Only downloads files, not datasets. | examples/download_vault_folder.py | def download_vault_folder(remote_path, local_path, dry_run=False, force=False):
"""Recursively downloads a folder in a vault to a local directory.
Only downloads files, not datasets."""
local_path = os.path.normpath(os.path.expanduser(local_path))
if not os.access(local_path, os.W_OK):
raise Ex... | def download_vault_folder(remote_path, local_path, dry_run=False, force=False):
"""Recursively downloads a folder in a vault to a local directory.
Only downloads files, not datasets."""
local_path = os.path.normpath(os.path.expanduser(local_path))
if not os.access(local_path, os.W_OK):
raise Ex... | [
"Recursively",
"downloads",
"a",
"folder",
"in",
"a",
"vault",
"to",
"a",
"local",
"directory",
".",
"Only",
"downloads",
"files",
"not",
"datasets",
"."
] | solvebio/solvebio-python | python | https://github.com/solvebio/solvebio-python/blob/b29614643043afd19c1d8074e8f25c6700d51a73/examples/download_vault_folder.py#L6-L56 | [
"def",
"download_vault_folder",
"(",
"remote_path",
",",
"local_path",
",",
"dry_run",
"=",
"False",
",",
"force",
"=",
"False",
")",
":",
"local_path",
"=",
"os",
".",
"path",
".",
"normpath",
"(",
"os",
".",
"path",
".",
"expanduser",
"(",
"local_path",
... | b29614643043afd19c1d8074e8f25c6700d51a73 |
test | SolveObject.construct_from | Used to create a new object from an HTTP response | solvebio/resource/solveobject.py | def construct_from(cls, values, **kwargs):
"""Used to create a new object from an HTTP response"""
instance = cls(values.get(cls.ID_ATTR), **kwargs)
instance.refresh_from(values)
return instance | def construct_from(cls, values, **kwargs):
"""Used to create a new object from an HTTP response"""
instance = cls(values.get(cls.ID_ATTR), **kwargs)
instance.refresh_from(values)
return instance | [
"Used",
"to",
"create",
"a",
"new",
"object",
"from",
"an",
"HTTP",
"response"
] | solvebio/solvebio-python | python | https://github.com/solvebio/solvebio-python/blob/b29614643043afd19c1d8074e8f25c6700d51a73/solvebio/resource/solveobject.py#L68-L72 | [
"def",
"construct_from",
"(",
"cls",
",",
"values",
",",
"*",
"*",
"kwargs",
")",
":",
"instance",
"=",
"cls",
"(",
"values",
".",
"get",
"(",
"cls",
".",
"ID_ATTR",
")",
",",
"*",
"*",
"kwargs",
")",
"instance",
".",
"refresh_from",
"(",
"values",
... | b29614643043afd19c1d8074e8f25c6700d51a73 |
test | SolveBioAuth.logout | Revoke the token and remove the cookie. | solvebio/contrib/dash/solvebio_auth.py | def logout(self):
"""Revoke the token and remove the cookie."""
if self._oauth_client_secret:
try:
oauth_token = flask.request.cookies[self.TOKEN_COOKIE_NAME]
# Revoke the token
requests.post(
urljoin(self._api_host, self.OA... | def logout(self):
"""Revoke the token and remove the cookie."""
if self._oauth_client_secret:
try:
oauth_token = flask.request.cookies[self.TOKEN_COOKIE_NAME]
# Revoke the token
requests.post(
urljoin(self._api_host, self.OA... | [
"Revoke",
"the",
"token",
"and",
"remove",
"the",
"cookie",
"."
] | solvebio/solvebio-python | python | https://github.com/solvebio/solvebio-python/blob/b29614643043afd19c1d8074e8f25c6700d51a73/solvebio/contrib/dash/solvebio_auth.py#L185-L203 | [
"def",
"logout",
"(",
"self",
")",
":",
"if",
"self",
".",
"_oauth_client_secret",
":",
"try",
":",
"oauth_token",
"=",
"flask",
".",
"request",
".",
"cookies",
"[",
"self",
".",
"TOKEN_COOKIE_NAME",
"]",
"# Revoke the token",
"requests",
".",
"post",
"(",
... | b29614643043afd19c1d8074e8f25c6700d51a73 |
test | launch_ipython_shell | Open the SolveBio shell (IPython wrapper) | solvebio/cli/ipython.py | def launch_ipython_shell(args): # pylint: disable=unused-argument
"""Open the SolveBio shell (IPython wrapper)"""
try:
import IPython # noqa
except ImportError:
_print("The SolveBio Python shell requires IPython.\n"
"To install, type: 'pip install ipython'")
return F... | def launch_ipython_shell(args): # pylint: disable=unused-argument
"""Open the SolveBio shell (IPython wrapper)"""
try:
import IPython # noqa
except ImportError:
_print("The SolveBio Python shell requires IPython.\n"
"To install, type: 'pip install ipython'")
return F... | [
"Open",
"the",
"SolveBio",
"shell",
"(",
"IPython",
"wrapper",
")"
] | solvebio/solvebio-python | python | https://github.com/solvebio/solvebio-python/blob/b29614643043afd19c1d8074e8f25c6700d51a73/solvebio/cli/ipython.py#L14-L29 | [
"def",
"launch_ipython_shell",
"(",
"args",
")",
":",
"# pylint: disable=unused-argument",
"try",
":",
"import",
"IPython",
"# noqa",
"except",
"ImportError",
":",
"_print",
"(",
"\"The SolveBio Python shell requires IPython.\\n\"",
"\"To install, type: 'pip install ipython'\"",
... | b29614643043afd19c1d8074e8f25c6700d51a73 |
test | launch_ipython_5_shell | Open the SolveBio shell (IPython wrapper) with IPython 5+ | solvebio/cli/ipython.py | def launch_ipython_5_shell(args):
"""Open the SolveBio shell (IPython wrapper) with IPython 5+"""
import IPython # noqa
from traitlets.config import Config
c = Config()
path = os.path.dirname(os.path.abspath(__file__))
try:
# see if we're already inside IPython
get_ipython # ... | def launch_ipython_5_shell(args):
"""Open the SolveBio shell (IPython wrapper) with IPython 5+"""
import IPython # noqa
from traitlets.config import Config
c = Config()
path = os.path.dirname(os.path.abspath(__file__))
try:
# see if we're already inside IPython
get_ipython # ... | [
"Open",
"the",
"SolveBio",
"shell",
"(",
"IPython",
"wrapper",
")",
"with",
"IPython",
"5",
"+"
] | solvebio/solvebio-python | python | https://github.com/solvebio/solvebio-python/blob/b29614643043afd19c1d8074e8f25c6700d51a73/solvebio/cli/ipython.py#L32-L48 | [
"def",
"launch_ipython_5_shell",
"(",
"args",
")",
":",
"import",
"IPython",
"# noqa",
"from",
"traitlets",
".",
"config",
"import",
"Config",
"c",
"=",
"Config",
"(",
")",
"path",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"os",
".",
"path",
".",
"a... | b29614643043afd19c1d8074e8f25c6700d51a73 |
test | launch_ipython_legacy_shell | Open the SolveBio shell (IPython wrapper) for older IPython versions | solvebio/cli/ipython.py | def launch_ipython_legacy_shell(args): # pylint: disable=unused-argument
"""Open the SolveBio shell (IPython wrapper) for older IPython versions"""
try:
from IPython.config.loader import Config
except ImportError:
_print("The SolveBio Python shell requires IPython.\n"
"To ins... | def launch_ipython_legacy_shell(args): # pylint: disable=unused-argument
"""Open the SolveBio shell (IPython wrapper) for older IPython versions"""
try:
from IPython.config.loader import Config
except ImportError:
_print("The SolveBio Python shell requires IPython.\n"
"To ins... | [
"Open",
"the",
"SolveBio",
"shell",
"(",
"IPython",
"wrapper",
")",
"for",
"older",
"IPython",
"versions"
] | solvebio/solvebio-python | python | https://github.com/solvebio/solvebio-python/blob/b29614643043afd19c1d8074e8f25c6700d51a73/solvebio/cli/ipython.py#L51-L89 | [
"def",
"launch_ipython_legacy_shell",
"(",
"args",
")",
":",
"# pylint: disable=unused-argument",
"try",
":",
"from",
"IPython",
".",
"config",
".",
"loader",
"import",
"Config",
"except",
"ImportError",
":",
"_print",
"(",
"\"The SolveBio Python shell requires IPython.\\... | b29614643043afd19c1d8074e8f25c6700d51a73 |
test | SolveClient.get | Issues an HTTP GET across the wire via the Python requests
library. See *request()* for information on keyword args. | solvebio/client.py | def get(self, url, params, **kwargs):
"""Issues an HTTP GET across the wire via the Python requests
library. See *request()* for information on keyword args."""
kwargs['params'] = params
return self.request('GET', url, **kwargs) | def get(self, url, params, **kwargs):
"""Issues an HTTP GET across the wire via the Python requests
library. See *request()* for information on keyword args."""
kwargs['params'] = params
return self.request('GET', url, **kwargs) | [
"Issues",
"an",
"HTTP",
"GET",
"across",
"the",
"wire",
"via",
"the",
"Python",
"requests",
"library",
".",
"See",
"*",
"request",
"()",
"*",
"for",
"information",
"on",
"keyword",
"args",
"."
] | solvebio/solvebio-python | python | https://github.com/solvebio/solvebio-python/blob/b29614643043afd19c1d8074e8f25c6700d51a73/solvebio/client.py#L146-L150 | [
"def",
"get",
"(",
"self",
",",
"url",
",",
"params",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
"[",
"'params'",
"]",
"=",
"params",
"return",
"self",
".",
"request",
"(",
"'GET'",
",",
"url",
",",
"*",
"*",
"kwargs",
")"
] | b29614643043afd19c1d8074e8f25c6700d51a73 |
test | SolveClient.delete | Issues an HTTP DELETE across the wire via the Python requests
library. See *request* for information on keyword args. | solvebio/client.py | def delete(self, url, data, **kwargs):
"""Issues an HTTP DELETE across the wire via the Python requests
library. See *request* for information on keyword args."""
kwargs['data'] = data
return self.request('DELETE', url, **kwargs) | def delete(self, url, data, **kwargs):
"""Issues an HTTP DELETE across the wire via the Python requests
library. See *request* for information on keyword args."""
kwargs['data'] = data
return self.request('DELETE', url, **kwargs) | [
"Issues",
"an",
"HTTP",
"DELETE",
"across",
"the",
"wire",
"via",
"the",
"Python",
"requests",
"library",
".",
"See",
"*",
"request",
"*",
"for",
"information",
"on",
"keyword",
"args",
"."
] | solvebio/solvebio-python | python | https://github.com/solvebio/solvebio-python/blob/b29614643043afd19c1d8074e8f25c6700d51a73/solvebio/client.py#L158-L162 | [
"def",
"delete",
"(",
"self",
",",
"url",
",",
"data",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
"[",
"'data'",
"]",
"=",
"data",
"return",
"self",
".",
"request",
"(",
"'DELETE'",
",",
"url",
",",
"*",
"*",
"kwargs",
")"
] | b29614643043afd19c1d8074e8f25c6700d51a73 |
test | SolveClient.request | Issues an HTTP Request across the wire via the Python requests
library.
Parameters
----------
method : str
an HTTP method: GET, PUT, POST, DELETE, ...
url : str
the place to connect to. If the url doesn't start
with a protocol (https:// or http... | solvebio/client.py | def request(self, method, url, **kwargs):
"""
Issues an HTTP Request across the wire via the Python requests
library.
Parameters
----------
method : str
an HTTP method: GET, PUT, POST, DELETE, ...
url : str
the place to connect to. If the ... | def request(self, method, url, **kwargs):
"""
Issues an HTTP Request across the wire via the Python requests
library.
Parameters
----------
method : str
an HTTP method: GET, PUT, POST, DELETE, ...
url : str
the place to connect to. If the ... | [
"Issues",
"an",
"HTTP",
"Request",
"across",
"the",
"wire",
"via",
"the",
"Python",
"requests",
"library",
"."
] | solvebio/solvebio-python | python | https://github.com/solvebio/solvebio-python/blob/b29614643043afd19c1d8074e8f25c6700d51a73/solvebio/client.py#L164-L258 | [
"def",
"request",
"(",
"self",
",",
"method",
",",
"url",
",",
"*",
"*",
"kwargs",
")",
":",
"opts",
"=",
"{",
"'allow_redirects'",
":",
"True",
",",
"'auth'",
":",
"self",
".",
"_auth",
",",
"'data'",
":",
"{",
"}",
",",
"'files'",
":",
"None",
... | b29614643043afd19c1d8074e8f25c6700d51a73 |
test | Task.child_object | Get Task child object class | solvebio/resource/task.py | def child_object(self):
""" Get Task child object class """
from . import types
child_klass = types.get(self.task_type.split('.')[1])
return child_klass.retrieve(self.task_id, client=self._client) | def child_object(self):
""" Get Task child object class """
from . import types
child_klass = types.get(self.task_type.split('.')[1])
return child_klass.retrieve(self.task_id, client=self._client) | [
"Get",
"Task",
"child",
"object",
"class"
] | solvebio/solvebio-python | python | https://github.com/solvebio/solvebio-python/blob/b29614643043afd19c1d8074e8f25c6700d51a73/solvebio/resource/task.py#L22-L26 | [
"def",
"child_object",
"(",
"self",
")",
":",
"from",
".",
"import",
"types",
"child_klass",
"=",
"types",
".",
"get",
"(",
"self",
".",
"task_type",
".",
"split",
"(",
"'.'",
")",
"[",
"1",
"]",
")",
"return",
"child_klass",
".",
"retrieve",
"(",
"s... | b29614643043afd19c1d8074e8f25c6700d51a73 |
test | Task.cancel | Cancel a task | solvebio/resource/task.py | def cancel(self):
""" Cancel a task """
_status = self.status
self.status = "canceled"
try:
self.save()
except:
# Reset status to what it was before
# status update failure
self.status = _status
raise | def cancel(self):
""" Cancel a task """
_status = self.status
self.status = "canceled"
try:
self.save()
except:
# Reset status to what it was before
# status update failure
self.status = _status
raise | [
"Cancel",
"a",
"task"
] | solvebio/solvebio-python | python | https://github.com/solvebio/solvebio-python/blob/b29614643043afd19c1d8074e8f25c6700d51a73/solvebio/resource/task.py#L32-L42 | [
"def",
"cancel",
"(",
"self",
")",
":",
"_status",
"=",
"self",
".",
"status",
"self",
".",
"status",
"=",
"\"canceled\"",
"try",
":",
"self",
".",
"save",
"(",
")",
"except",
":",
"# Reset status to what it was before",
"# status update failure",
"self",
".",... | b29614643043afd19c1d8074e8f25c6700d51a73 |
test | ExpandingVCFParser._parse_info_snpeff | Specialized INFO field parser for SnpEff ANN fields.
Requires self._snpeff_ann_fields to be set. | solvebio/contrib/vcf_parser/vcf_parser.py | def _parse_info_snpeff(self, info):
"""
Specialized INFO field parser for SnpEff ANN fields.
Requires self._snpeff_ann_fields to be set.
"""
ann = info.pop('ANN', []) or []
# Overwrite the existing ANN with something parsed
# Split on '|', merge with the ANN keys ... | def _parse_info_snpeff(self, info):
"""
Specialized INFO field parser for SnpEff ANN fields.
Requires self._snpeff_ann_fields to be set.
"""
ann = info.pop('ANN', []) or []
# Overwrite the existing ANN with something parsed
# Split on '|', merge with the ANN keys ... | [
"Specialized",
"INFO",
"field",
"parser",
"for",
"SnpEff",
"ANN",
"fields",
".",
"Requires",
"self",
".",
"_snpeff_ann_fields",
"to",
"be",
"set",
"."
] | solvebio/solvebio-python | python | https://github.com/solvebio/solvebio-python/blob/b29614643043afd19c1d8074e8f25c6700d51a73/solvebio/contrib/vcf_parser/vcf_parser.py#L140-L167 | [
"def",
"_parse_info_snpeff",
"(",
"self",
",",
"info",
")",
":",
"ann",
"=",
"info",
".",
"pop",
"(",
"'ANN'",
",",
"[",
"]",
")",
"or",
"[",
"]",
"# Overwrite the existing ANN with something parsed",
"# Split on '|', merge with the ANN keys parsed above.",
"# Ensure ... | b29614643043afd19c1d8074e8f25c6700d51a73 |
test | ExpandingVCFParser.next | Expands multiple alleles into one record each
using an internal buffer (_next). | solvebio/contrib/vcf_parser/vcf_parser.py | def next(self):
"""
Expands multiple alleles into one record each
using an internal buffer (_next).
"""
def _alt(alt):
"""Parses the VCF row ALT object."""
# If alt is '.' in VCF, PyVCF returns None, convert back to '.'
if not alt:
... | def next(self):
"""
Expands multiple alleles into one record each
using an internal buffer (_next).
"""
def _alt(alt):
"""Parses the VCF row ALT object."""
# If alt is '.' in VCF, PyVCF returns None, convert back to '.'
if not alt:
... | [
"Expands",
"multiple",
"alleles",
"into",
"one",
"record",
"each",
"using",
"an",
"internal",
"buffer",
"(",
"_next",
")",
"."
] | solvebio/solvebio-python | python | https://github.com/solvebio/solvebio-python/blob/b29614643043afd19c1d8074e8f25c6700d51a73/solvebio/contrib/vcf_parser/vcf_parser.py#L190-L218 | [
"def",
"next",
"(",
"self",
")",
":",
"def",
"_alt",
"(",
"alt",
")",
":",
"\"\"\"Parses the VCF row ALT object.\"\"\"",
"# If alt is '.' in VCF, PyVCF returns None, convert back to '.'",
"if",
"not",
"alt",
":",
"return",
"'.'",
"else",
":",
"return",
"str",
"(",
"... | b29614643043afd19c1d8074e8f25c6700d51a73 |
test | ExpandingVCFParser.row_to_dict | Return a parsed dictionary for JSON. | solvebio/contrib/vcf_parser/vcf_parser.py | def row_to_dict(self, row, allele, alternate_alleles):
"""Return a parsed dictionary for JSON."""
def _variant_sbid(**kwargs):
"""Generates a SolveBio variant ID (SBID)."""
return '{build}-{chromosome}-{start}-{stop}-{allele}'\
.format(**kwargs).upper()
... | def row_to_dict(self, row, allele, alternate_alleles):
"""Return a parsed dictionary for JSON."""
def _variant_sbid(**kwargs):
"""Generates a SolveBio variant ID (SBID)."""
return '{build}-{chromosome}-{start}-{stop}-{allele}'\
.format(**kwargs).upper()
... | [
"Return",
"a",
"parsed",
"dictionary",
"for",
"JSON",
"."
] | solvebio/solvebio-python | python | https://github.com/solvebio/solvebio-python/blob/b29614643043afd19c1d8074e8f25c6700d51a73/solvebio/contrib/vcf_parser/vcf_parser.py#L220-L253 | [
"def",
"row_to_dict",
"(",
"self",
",",
"row",
",",
"allele",
",",
"alternate_alleles",
")",
":",
"def",
"_variant_sbid",
"(",
"*",
"*",
"kwargs",
")",
":",
"\"\"\"Generates a SolveBio variant ID (SBID).\"\"\"",
"return",
"'{build}-{chromosome}-{start}-{stop}-{allele}'",
... | b29614643043afd19c1d8074e8f25c6700d51a73 |
test | get_credentials | Returns the user's stored API key if a valid credentials file is found.
Raises CredentialsError if no valid credentials file is found. | solvebio/cli/credentials.py | def get_credentials():
"""
Returns the user's stored API key if a valid credentials file is found.
Raises CredentialsError if no valid credentials file is found.
"""
try:
netrc_path = netrc.path()
auths = netrc(netrc_path).authenticators(
urlparse(solvebio.api_host).netlo... | def get_credentials():
"""
Returns the user's stored API key if a valid credentials file is found.
Raises CredentialsError if no valid credentials file is found.
"""
try:
netrc_path = netrc.path()
auths = netrc(netrc_path).authenticators(
urlparse(solvebio.api_host).netlo... | [
"Returns",
"the",
"user",
"s",
"stored",
"API",
"key",
"if",
"a",
"valid",
"credentials",
"file",
"is",
"found",
".",
"Raises",
"CredentialsError",
"if",
"no",
"valid",
"credentials",
"file",
"is",
"found",
"."
] | solvebio/solvebio-python | python | https://github.com/solvebio/solvebio-python/blob/b29614643043afd19c1d8074e8f25c6700d51a73/solvebio/cli/credentials.py#L76-L93 | [
"def",
"get_credentials",
"(",
")",
":",
"try",
":",
"netrc_path",
"=",
"netrc",
".",
"path",
"(",
")",
"auths",
"=",
"netrc",
"(",
"netrc_path",
")",
".",
"authenticators",
"(",
"urlparse",
"(",
"solvebio",
".",
"api_host",
")",
".",
"netloc",
")",
"e... | b29614643043afd19c1d8074e8f25c6700d51a73 |
test | netrc.save | Dump the class data in the format of a .netrc file. | solvebio/cli/credentials.py | def save(self, path):
"""Dump the class data in the format of a .netrc file."""
rep = ""
for host in self.hosts.keys():
attrs = self.hosts[host]
rep = rep + "machine " + host + "\n\tlogin " \
+ six.text_type(attrs[0]) + "\n"
if attrs[1]:
... | def save(self, path):
"""Dump the class data in the format of a .netrc file."""
rep = ""
for host in self.hosts.keys():
attrs = self.hosts[host]
rep = rep + "machine " + host + "\n\tlogin " \
+ six.text_type(attrs[0]) + "\n"
if attrs[1]:
... | [
"Dump",
"the",
"class",
"data",
"in",
"the",
"format",
"of",
"a",
".",
"netrc",
"file",
"."
] | solvebio/solvebio-python | python | https://github.com/solvebio/solvebio-python/blob/b29614643043afd19c1d8074e8f25c6700d51a73/solvebio/cli/credentials.py#L48-L66 | [
"def",
"save",
"(",
"self",
",",
"path",
")",
":",
"rep",
"=",
"\"\"",
"for",
"host",
"in",
"self",
".",
"hosts",
".",
"keys",
"(",
")",
":",
"attrs",
"=",
"self",
".",
"hosts",
"[",
"host",
"]",
"rep",
"=",
"rep",
"+",
"\"machine \"",
"+",
"ho... | b29614643043afd19c1d8074e8f25c6700d51a73 |
test | _isint | >>> _isint("123")
True
>>> _isint("123.45")
False | solvebio/utils/tabulate.py | def _isint(string):
"""
>>> _isint("123")
True
>>> _isint("123.45")
False
"""
return type(string) is int or \
(isinstance(string, _binary_type) or
isinstance(string, string_types)) and \
_isconvertible(int, string) | def _isint(string):
"""
>>> _isint("123")
True
>>> _isint("123.45")
False
"""
return type(string) is int or \
(isinstance(string, _binary_type) or
isinstance(string, string_types)) and \
_isconvertible(int, string) | [
">>>",
"_isint",
"(",
"123",
")",
"True",
">>>",
"_isint",
"(",
"123",
".",
"45",
")",
"False"
] | solvebio/solvebio-python | python | https://github.com/solvebio/solvebio-python/blob/b29614643043afd19c1d8074e8f25c6700d51a73/solvebio/utils/tabulate.py#L160-L170 | [
"def",
"_isint",
"(",
"string",
")",
":",
"return",
"type",
"(",
"string",
")",
"is",
"int",
"or",
"(",
"isinstance",
"(",
"string",
",",
"_binary_type",
")",
"or",
"isinstance",
"(",
"string",
",",
"string_types",
")",
")",
"and",
"_isconvertible",
"(",... | b29614643043afd19c1d8074e8f25c6700d51a73 |
test | _align_column | [string] -> [padded_string]
>>> list(map(str,_align_column( \
["12.345", "-1234.5", "1.23", "1234.5", \
"1e+234", "1.0e234"], "decimal")))
[' 12.345 ', '-1234.5 ', ' 1.23 ', \
' 1234.5 ', ' 1e+234 ', ' 1.0e234'] | solvebio/utils/tabulate.py | def _align_column(strings, alignment, minwidth=0, has_invisible=True):
"""
[string] -> [padded_string]
>>> list(map(str,_align_column( \
["12.345", "-1234.5", "1.23", "1234.5", \
"1e+234", "1.0e234"], "decimal")))
[' 12.345 ', '-1234.5 ', ' 1.23 ', \
' 1234.5 ', ' ... | def _align_column(strings, alignment, minwidth=0, has_invisible=True):
"""
[string] -> [padded_string]
>>> list(map(str,_align_column( \
["12.345", "-1234.5", "1.23", "1234.5", \
"1e+234", "1.0e234"], "decimal")))
[' 12.345 ', '-1234.5 ', ' 1.23 ', \
' 1234.5 ', ' ... | [
"[",
"string",
"]",
"-",
">",
"[",
"padded_string",
"]"
] | solvebio/solvebio-python | python | https://github.com/solvebio/solvebio-python/blob/b29614643043afd19c1d8074e8f25c6700d51a73/solvebio/utils/tabulate.py#L298-L332 | [
"def",
"_align_column",
"(",
"strings",
",",
"alignment",
",",
"minwidth",
"=",
"0",
",",
"has_invisible",
"=",
"True",
")",
":",
"if",
"alignment",
"==",
"\"right\"",
":",
"strings",
"=",
"[",
"s",
".",
"strip",
"(",
")",
"for",
"s",
"in",
"strings",
... | b29614643043afd19c1d8074e8f25c6700d51a73 |
test | _format | Format a value accoding to its type.
Unicode is supported:
>>> hrow = ['\u0431\u0443\u043a\u0432\u0430', \
'\u0446\u0438\u0444\u0440\u0430'] ; \
tbl = [['\u0430\u0437', 2], ['\u0431\u0443\u043a\u0438', 4]] ; \
good_result = '\\u0431\\u0443\\u043a\\u0432\\u0430 \
... | solvebio/utils/tabulate.py | def _format(val, valtype, floatfmt, missingval=""):
"""
Format a value accoding to its type.
Unicode is supported:
>>> hrow = ['\u0431\u0443\u043a\u0432\u0430', \
'\u0446\u0438\u0444\u0440\u0430'] ; \
tbl = [['\u0430\u0437', 2], ['\u0431\u0443\u043a\u0438', 4]] ; \
good... | def _format(val, valtype, floatfmt, missingval=""):
"""
Format a value accoding to its type.
Unicode is supported:
>>> hrow = ['\u0431\u0443\u043a\u0432\u0430', \
'\u0446\u0438\u0444\u0440\u0430'] ; \
tbl = [['\u0430\u0437', 2], ['\u0431\u0443\u043a\u0438', 4]] ; \
good... | [
"Format",
"a",
"value",
"accoding",
"to",
"its",
"type",
"."
] | solvebio/solvebio-python | python | https://github.com/solvebio/solvebio-python/blob/b29614643043afd19c1d8074e8f25c6700d51a73/solvebio/utils/tabulate.py#L364-L389 | [
"def",
"_format",
"(",
"val",
",",
"valtype",
",",
"floatfmt",
",",
"missingval",
"=",
"\"\"",
")",
":",
"if",
"val",
"is",
"None",
":",
"return",
"missingval",
"if",
"valtype",
"in",
"[",
"int",
",",
"_binary_type",
",",
"_text_type",
"]",
":",
"retur... | b29614643043afd19c1d8074e8f25c6700d51a73 |
test | _normalize_tabular_data | Transform a supported data type to a list of lists, and a list of headers.
Supported tabular data types:
* list-of-lists or another iterable of iterables
* 2D NumPy arrays
* dict of iterables (usually used with headers="keys")
* pandas.DataFrame (usually used with headers="keys")
The first... | solvebio/utils/tabulate.py | def _normalize_tabular_data(tabular_data, headers, sort=True):
"""
Transform a supported data type to a list of lists, and a list of headers.
Supported tabular data types:
* list-of-lists or another iterable of iterables
* 2D NumPy arrays
* dict of iterables (usually used with headers="keys"... | def _normalize_tabular_data(tabular_data, headers, sort=True):
"""
Transform a supported data type to a list of lists, and a list of headers.
Supported tabular data types:
* list-of-lists or another iterable of iterables
* 2D NumPy arrays
* dict of iterables (usually used with headers="keys"... | [
"Transform",
"a",
"supported",
"data",
"type",
"to",
"a",
"list",
"of",
"lists",
"and",
"a",
"list",
"of",
"headers",
"."
] | solvebio/solvebio-python | python | https://github.com/solvebio/solvebio-python/blob/b29614643043afd19c1d8074e8f25c6700d51a73/solvebio/utils/tabulate.py#L401-L467 | [
"def",
"_normalize_tabular_data",
"(",
"tabular_data",
",",
"headers",
",",
"sort",
"=",
"True",
")",
":",
"if",
"hasattr",
"(",
"tabular_data",
",",
"\"keys\"",
")",
"and",
"hasattr",
"(",
"tabular_data",
",",
"\"values\"",
")",
":",
"# dict-like and pandas.Dat... | b29614643043afd19c1d8074e8f25c6700d51a73 |
test | _build_row | Return a string which represents a row of data cells. | solvebio/utils/tabulate.py | def _build_row(cells, padding, begin, sep, end):
"Return a string which represents a row of data cells."
pad = " " * padding
padded_cells = [pad + cell + pad for cell in cells]
# SolveBio: we're only displaying Key-Value tuples (dimension of 2).
# enforce that we don't wrap lines by setting a max... | def _build_row(cells, padding, begin, sep, end):
"Return a string which represents a row of data cells."
pad = " " * padding
padded_cells = [pad + cell + pad for cell in cells]
# SolveBio: we're only displaying Key-Value tuples (dimension of 2).
# enforce that we don't wrap lines by setting a max... | [
"Return",
"a",
"string",
"which",
"represents",
"a",
"row",
"of",
"data",
"cells",
"."
] | solvebio/solvebio-python | python | https://github.com/solvebio/solvebio-python/blob/b29614643043afd19c1d8074e8f25c6700d51a73/solvebio/utils/tabulate.py#L470-L489 | [
"def",
"_build_row",
"(",
"cells",
",",
"padding",
",",
"begin",
",",
"sep",
",",
"end",
")",
":",
"pad",
"=",
"\" \"",
"*",
"padding",
"padded_cells",
"=",
"[",
"pad",
"+",
"cell",
"+",
"pad",
"for",
"cell",
"in",
"cells",
"]",
"# SolveBio: we're only... | b29614643043afd19c1d8074e8f25c6700d51a73 |
test | _build_line | Return a string which represents a horizontal line. | solvebio/utils/tabulate.py | def _build_line(colwidths, padding, begin, fill, sep, end):
"Return a string which represents a horizontal line."
cells = [fill * (w + 2 * padding) for w in colwidths]
return _build_row(cells, 0, begin, sep, end) | def _build_line(colwidths, padding, begin, fill, sep, end):
"Return a string which represents a horizontal line."
cells = [fill * (w + 2 * padding) for w in colwidths]
return _build_row(cells, 0, begin, sep, end) | [
"Return",
"a",
"string",
"which",
"represents",
"a",
"horizontal",
"line",
"."
] | solvebio/solvebio-python | python | https://github.com/solvebio/solvebio-python/blob/b29614643043afd19c1d8074e8f25c6700d51a73/solvebio/utils/tabulate.py#L492-L495 | [
"def",
"_build_line",
"(",
"colwidths",
",",
"padding",
",",
"begin",
",",
"fill",
",",
"sep",
",",
"end",
")",
":",
"cells",
"=",
"[",
"fill",
"*",
"(",
"w",
"+",
"2",
"*",
"padding",
")",
"for",
"w",
"in",
"colwidths",
"]",
"return",
"_build_row"... | b29614643043afd19c1d8074e8f25c6700d51a73 |
test | _mediawiki_cell_attrs | Prefix every cell in a row with an HTML alignment attribute. | solvebio/utils/tabulate.py | def _mediawiki_cell_attrs(row, colaligns):
"Prefix every cell in a row with an HTML alignment attribute."
alignment = {"left": '',
"right": 'align="right"| ',
"center": 'align="center"| ',
"decimal": 'align="right"| '}
row2 = [alignment[a] + c for c, a in z... | def _mediawiki_cell_attrs(row, colaligns):
"Prefix every cell in a row with an HTML alignment attribute."
alignment = {"left": '',
"right": 'align="right"| ',
"center": 'align="center"| ',
"decimal": 'align="right"| '}
row2 = [alignment[a] + c for c, a in z... | [
"Prefix",
"every",
"cell",
"in",
"a",
"row",
"with",
"an",
"HTML",
"alignment",
"attribute",
"."
] | solvebio/solvebio-python | python | https://github.com/solvebio/solvebio-python/blob/b29614643043afd19c1d8074e8f25c6700d51a73/solvebio/utils/tabulate.py#L498-L505 | [
"def",
"_mediawiki_cell_attrs",
"(",
"row",
",",
"colaligns",
")",
":",
"alignment",
"=",
"{",
"\"left\"",
":",
"''",
",",
"\"right\"",
":",
"'align=\"right\"| '",
",",
"\"center\"",
":",
"'align=\"center\"| '",
",",
"\"decimal\"",
":",
"'align=\"right\"| '",
"}",... | b29614643043afd19c1d8074e8f25c6700d51a73 |
test | _line_segment_with_colons | Return a segment of a horizontal line with optional colons which
indicate column's alignment (as in `pipe` output format). | solvebio/utils/tabulate.py | def _line_segment_with_colons(linefmt, align, colwidth):
"""Return a segment of a horizontal line with optional colons which
indicate column's alignment (as in `pipe` output format)."""
fill = linefmt.hline
w = colwidth
if align in ["right", "decimal"]:
return (fill[0] * (w - 1)) + ":"
e... | def _line_segment_with_colons(linefmt, align, colwidth):
"""Return a segment of a horizontal line with optional colons which
indicate column's alignment (as in `pipe` output format)."""
fill = linefmt.hline
w = colwidth
if align in ["right", "decimal"]:
return (fill[0] * (w - 1)) + ":"
e... | [
"Return",
"a",
"segment",
"of",
"a",
"horizontal",
"line",
"with",
"optional",
"colons",
"which",
"indicate",
"column",
"s",
"alignment",
"(",
"as",
"in",
"pipe",
"output",
"format",
")",
"."
] | solvebio/solvebio-python | python | https://github.com/solvebio/solvebio-python/blob/b29614643043afd19c1d8074e8f25c6700d51a73/solvebio/utils/tabulate.py#L508-L520 | [
"def",
"_line_segment_with_colons",
"(",
"linefmt",
",",
"align",
",",
"colwidth",
")",
":",
"fill",
"=",
"linefmt",
".",
"hline",
"w",
"=",
"colwidth",
"if",
"align",
"in",
"[",
"\"right\"",
",",
"\"decimal\"",
"]",
":",
"return",
"(",
"fill",
"[",
"0",... | b29614643043afd19c1d8074e8f25c6700d51a73 |
test | _format_table | Produce a plain-text representation of the table. | solvebio/utils/tabulate.py | def _format_table(fmt, headers, rows, colwidths, colaligns):
"""Produce a plain-text representation of the table."""
lines = []
hidden = fmt.with_header_hide if headers else fmt.without_header_hide
pad = fmt.padding
headerrow = fmt.headerrow if fmt.headerrow else fmt.datarow
if fmt.lineabove an... | def _format_table(fmt, headers, rows, colwidths, colaligns):
"""Produce a plain-text representation of the table."""
lines = []
hidden = fmt.with_header_hide if headers else fmt.without_header_hide
pad = fmt.padding
headerrow = fmt.headerrow if fmt.headerrow else fmt.datarow
if fmt.lineabove an... | [
"Produce",
"a",
"plain",
"-",
"text",
"representation",
"of",
"the",
"table",
"."
] | solvebio/solvebio-python | python | https://github.com/solvebio/solvebio-python/blob/b29614643043afd19c1d8074e8f25c6700d51a73/solvebio/utils/tabulate.py#L523-L560 | [
"def",
"_format_table",
"(",
"fmt",
",",
"headers",
",",
"rows",
",",
"colwidths",
",",
"colaligns",
")",
":",
"lines",
"=",
"[",
"]",
"hidden",
"=",
"fmt",
".",
"with_header_hide",
"if",
"headers",
"else",
"fmt",
".",
"without_header_hide",
"pad",
"=",
... | b29614643043afd19c1d8074e8f25c6700d51a73 |
test | Dataset.import_file | This is a shortcut to creating a DatasetImport. Can't use "import()"
because of Python. | solvebio/resource/dataset.py | def import_file(self, path, **kwargs):
"""
This is a shortcut to creating a DatasetImport. Can't use "import()"
because of Python.
"""
from . import Manifest
from . import DatasetImport
if 'id' not in self or not self['id']:
raise Exception(
... | def import_file(self, path, **kwargs):
"""
This is a shortcut to creating a DatasetImport. Can't use "import()"
because of Python.
"""
from . import Manifest
from . import DatasetImport
if 'id' not in self or not self['id']:
raise Exception(
... | [
"This",
"is",
"a",
"shortcut",
"to",
"creating",
"a",
"DatasetImport",
".",
"Can",
"t",
"use",
"import",
"()",
"because",
"of",
"Python",
"."
] | solvebio/solvebio-python | python | https://github.com/solvebio/solvebio-python/blob/b29614643043afd19c1d8074e8f25c6700d51a73/solvebio/resource/dataset.py#L264-L283 | [
"def",
"import_file",
"(",
"self",
",",
"path",
",",
"*",
"*",
"kwargs",
")",
":",
"from",
".",
"import",
"Manifest",
"from",
".",
"import",
"DatasetImport",
"if",
"'id'",
"not",
"in",
"self",
"or",
"not",
"self",
"[",
"'id'",
"]",
":",
"raise",
"Exc... | b29614643043afd19c1d8074e8f25c6700d51a73 |
test | Dataset.migrate | Migrate the data from this dataset to a target dataset.
Valid optional kwargs include:
* source_params
* target_fields
* include_errors
* commit_mode | solvebio/resource/dataset.py | def migrate(self, target, follow=True, **kwargs):
"""
Migrate the data from this dataset to a target dataset.
Valid optional kwargs include:
* source_params
* target_fields
* include_errors
* commit_mode
"""
if 'id' not in self or not self['id']... | def migrate(self, target, follow=True, **kwargs):
"""
Migrate the data from this dataset to a target dataset.
Valid optional kwargs include:
* source_params
* target_fields
* include_errors
* commit_mode
"""
if 'id' not in self or not self['id']... | [
"Migrate",
"the",
"data",
"from",
"this",
"dataset",
"to",
"a",
"target",
"dataset",
"."
] | solvebio/solvebio-python | python | https://github.com/solvebio/solvebio-python/blob/b29614643043afd19c1d8074e8f25c6700d51a73/solvebio/resource/dataset.py#L302-L334 | [
"def",
"migrate",
"(",
"self",
",",
"target",
",",
"follow",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"'id'",
"not",
"in",
"self",
"or",
"not",
"self",
"[",
"'id'",
"]",
":",
"raise",
"Exception",
"(",
"'No source dataset ID found. '",
"'P... | b29614643043afd19c1d8074e8f25c6700d51a73 |
test | Object.validate_full_path | Helper method to parse a full or partial path and
return a full path as well as a dict containing path parts.
Uses the following rules when processing the path:
* If no domain, uses the current user's account domain
* If no vault, uses the current user's personal vault.
... | solvebio/resource/object.py | def validate_full_path(cls, full_path, **kwargs):
"""Helper method to parse a full or partial path and
return a full path as well as a dict containing path parts.
Uses the following rules when processing the path:
* If no domain, uses the current user's account domain
*... | def validate_full_path(cls, full_path, **kwargs):
"""Helper method to parse a full or partial path and
return a full path as well as a dict containing path parts.
Uses the following rules when processing the path:
* If no domain, uses the current user's account domain
*... | [
"Helper",
"method",
"to",
"parse",
"a",
"full",
"or",
"partial",
"path",
"and",
"return",
"a",
"full",
"path",
"as",
"well",
"as",
"a",
"dict",
"containing",
"path",
"parts",
"."
] | solvebio/solvebio-python | python | https://github.com/solvebio/solvebio-python/blob/b29614643043afd19c1d8074e8f25c6700d51a73/solvebio/resource/object.py#L46-L135 | [
"def",
"validate_full_path",
"(",
"cls",
",",
"full_path",
",",
"*",
"*",
"kwargs",
")",
":",
"from",
"solvebio",
".",
"resource",
".",
"vault",
"import",
"Vault",
"_client",
"=",
"kwargs",
".",
"pop",
"(",
"'client'",
",",
"None",
")",
"or",
"cls",
".... | b29614643043afd19c1d8074e8f25c6700d51a73 |
test | create_dataset | Attempt to create a new dataset given the following params:
* template_id
* template_file
* capacity
* create_vault
* [argument] dataset name or full path
NOTE: genome_build has been deprecated and is no longer used. | solvebio/cli/data.py | def create_dataset(args):
"""
Attempt to create a new dataset given the following params:
* template_id
* template_file
* capacity
* create_vault
* [argument] dataset name or full path
NOTE: genome_build has been deprecated and is no longer used.
"""
# For ... | def create_dataset(args):
"""
Attempt to create a new dataset given the following params:
* template_id
* template_file
* capacity
* create_vault
* [argument] dataset name or full path
NOTE: genome_build has been deprecated and is no longer used.
"""
# For ... | [
"Attempt",
"to",
"create",
"a",
"new",
"dataset",
"given",
"the",
"following",
"params",
":"
] | solvebio/solvebio-python | python | https://github.com/solvebio/solvebio-python/blob/b29614643043afd19c1d8074e8f25c6700d51a73/solvebio/cli/data.py#L112-L189 | [
"def",
"create_dataset",
"(",
"args",
")",
":",
"# For backwards compatibility, the \"full_path\" argument",
"# can be a dataset filename, but only if vault and path",
"# are set. If vault/path are both provided and there",
"# are no forward-slashes in the \"full_path\", assume",
"# the user has... | b29614643043afd19c1d8074e8f25c6700d51a73 |
test | upload | Given a folder or file, upload all the folders and files contained
within it, skipping ones that already exist on the remote. | solvebio/cli/data.py | def upload(args):
"""
Given a folder or file, upload all the folders and files contained
within it, skipping ones that already exist on the remote.
"""
base_remote_path, path_dict = Object.validate_full_path(
args.full_path, vault=args.vault, path=args.path)
# Assert the vault exists an... | def upload(args):
"""
Given a folder or file, upload all the folders and files contained
within it, skipping ones that already exist on the remote.
"""
base_remote_path, path_dict = Object.validate_full_path(
args.full_path, vault=args.vault, path=args.path)
# Assert the vault exists an... | [
"Given",
"a",
"folder",
"or",
"file",
"upload",
"all",
"the",
"folders",
"and",
"files",
"contained",
"within",
"it",
"skipping",
"ones",
"that",
"already",
"exist",
"on",
"the",
"remote",
"."
] | solvebio/solvebio-python | python | https://github.com/solvebio/solvebio-python/blob/b29614643043afd19c1d8074e8f25c6700d51a73/solvebio/cli/data.py#L192-L216 | [
"def",
"upload",
"(",
"args",
")",
":",
"base_remote_path",
",",
"path_dict",
"=",
"Object",
".",
"validate_full_path",
"(",
"args",
".",
"full_path",
",",
"vault",
"=",
"args",
".",
"vault",
",",
"path",
"=",
"args",
".",
"path",
")",
"# Assert the vault ... | b29614643043afd19c1d8074e8f25c6700d51a73 |
test | import_file | Given a dataset and a local path, upload and import the file(s).
Command arguments (args):
* create_dataset
* template_id
* full_path
* vault (optional, overrides the vault in full_path)
* path (optional, overrides the path in full_path)
* commit_mode
* capa... | solvebio/cli/data.py | def import_file(args):
"""
Given a dataset and a local path, upload and import the file(s).
Command arguments (args):
* create_dataset
* template_id
* full_path
* vault (optional, overrides the vault in full_path)
* path (optional, overrides the path in full_path)
... | def import_file(args):
"""
Given a dataset and a local path, upload and import the file(s).
Command arguments (args):
* create_dataset
* template_id
* full_path
* vault (optional, overrides the vault in full_path)
* path (optional, overrides the path in full_path)
... | [
"Given",
"a",
"dataset",
"and",
"a",
"local",
"path",
"upload",
"and",
"import",
"the",
"file",
"(",
"s",
")",
"."
] | solvebio/solvebio-python | python | https://github.com/solvebio/solvebio-python/blob/b29614643043afd19c1d8074e8f25c6700d51a73/solvebio/cli/data.py#L219-L270 | [
"def",
"import_file",
"(",
"args",
")",
":",
"full_path",
",",
"path_dict",
"=",
"Object",
".",
"validate_full_path",
"(",
"args",
".",
"full_path",
",",
"vault",
"=",
"args",
".",
"vault",
",",
"path",
"=",
"args",
".",
"path",
")",
"# Ensure the dataset ... | b29614643043afd19c1d8074e8f25c6700d51a73 |
test | Vault.validate_full_path | Helper method to return a full path from a full or partial path.
If no domain, assumes user's account domain
If the vault is "~", assumes personal vault.
Valid vault paths include:
domain:vault
domain:vault:/path
domain:vault/path
vault:... | solvebio/resource/vault.py | def validate_full_path(cls, full_path, **kwargs):
"""Helper method to return a full path from a full or partial path.
If no domain, assumes user's account domain
If the vault is "~", assumes personal vault.
Valid vault paths include:
domain:vault
domain... | def validate_full_path(cls, full_path, **kwargs):
"""Helper method to return a full path from a full or partial path.
If no domain, assumes user's account domain
If the vault is "~", assumes personal vault.
Valid vault paths include:
domain:vault
domain... | [
"Helper",
"method",
"to",
"return",
"a",
"full",
"path",
"from",
"a",
"full",
"or",
"partial",
"path",
"."
] | solvebio/solvebio-python | python | https://github.com/solvebio/solvebio-python/blob/b29614643043afd19c1d8074e8f25c6700d51a73/solvebio/resource/vault.py#L57-L115 | [
"def",
"validate_full_path",
"(",
"cls",
",",
"full_path",
",",
"*",
"*",
"kwargs",
")",
":",
"_client",
"=",
"kwargs",
".",
"pop",
"(",
"'client'",
",",
"None",
")",
"or",
"cls",
".",
"_client",
"or",
"client",
"full_path",
"=",
"full_path",
".",
"str... | b29614643043afd19c1d8074e8f25c6700d51a73 |
test | validate_api_host_url | Validate SolveBio API host url.
Valid urls must not be empty and
must contain either HTTP or HTTPS scheme. | solvebio/utils/validators.py | def validate_api_host_url(url):
"""
Validate SolveBio API host url.
Valid urls must not be empty and
must contain either HTTP or HTTPS scheme.
"""
if not url:
raise SolveError('No SolveBio API host is set')
parsed = urlparse(url)
if parsed.scheme not in ['http', 'https']:
... | def validate_api_host_url(url):
"""
Validate SolveBio API host url.
Valid urls must not be empty and
must contain either HTTP or HTTPS scheme.
"""
if not url:
raise SolveError('No SolveBio API host is set')
parsed = urlparse(url)
if parsed.scheme not in ['http', 'https']:
... | [
"Validate",
"SolveBio",
"API",
"host",
"url",
"."
] | solvebio/solvebio-python | python | https://github.com/solvebio/solvebio-python/blob/b29614643043afd19c1d8074e8f25c6700d51a73/solvebio/utils/validators.py#L8-L28 | [
"def",
"validate_api_host_url",
"(",
"url",
")",
":",
"if",
"not",
"url",
":",
"raise",
"SolveError",
"(",
"'No SolveBio API host is set'",
")",
"parsed",
"=",
"urlparse",
"(",
"url",
")",
"if",
"parsed",
".",
"scheme",
"not",
"in",
"[",
"'http'",
",",
"'h... | b29614643043afd19c1d8074e8f25c6700d51a73 |
test | Manifest.add | Add one or more files or URLs to the manifest.
If files contains a glob, it is expanded.
All files are uploaded to SolveBio. The Upload
object is used to fill the manifest. | solvebio/resource/manifest.py | def add(self, *args):
"""
Add one or more files or URLs to the manifest.
If files contains a glob, it is expanded.
All files are uploaded to SolveBio. The Upload
object is used to fill the manifest.
"""
def _is_url(path):
p = urlparse(path)
... | def add(self, *args):
"""
Add one or more files or URLs to the manifest.
If files contains a glob, it is expanded.
All files are uploaded to SolveBio. The Upload
object is used to fill the manifest.
"""
def _is_url(path):
p = urlparse(path)
... | [
"Add",
"one",
"or",
"more",
"files",
"or",
"URLs",
"to",
"the",
"manifest",
".",
"If",
"files",
"contains",
"a",
"glob",
"it",
"is",
"expanded",
"."
] | solvebio/solvebio-python | python | https://github.com/solvebio/solvebio-python/blob/b29614643043afd19c1d8074e8f25c6700d51a73/solvebio/resource/manifest.py#L47-L76 | [
"def",
"add",
"(",
"self",
",",
"*",
"args",
")",
":",
"def",
"_is_url",
"(",
"path",
")",
":",
"p",
"=",
"urlparse",
"(",
"path",
")",
"return",
"bool",
"(",
"p",
".",
"scheme",
")",
"for",
"path",
"in",
"args",
":",
"path",
"=",
"os",
".",
... | b29614643043afd19c1d8074e8f25c6700d51a73 |
test | Annotator.annotate | Annotate a set of records with stored fields.
Args:
records: A list or iterator (can be a Query object)
chunk_size: The number of records to annotate at once (max 500).
Returns:
A generator that yields one annotated record at a time. | solvebio/annotate.py | def annotate(self, records, **kwargs):
"""Annotate a set of records with stored fields.
Args:
records: A list or iterator (can be a Query object)
chunk_size: The number of records to annotate at once (max 500).
Returns:
A generator that yields one annotated ... | def annotate(self, records, **kwargs):
"""Annotate a set of records with stored fields.
Args:
records: A list or iterator (can be a Query object)
chunk_size: The number of records to annotate at once (max 500).
Returns:
A generator that yields one annotated ... | [
"Annotate",
"a",
"set",
"of",
"records",
"with",
"stored",
"fields",
"."
] | solvebio/solvebio-python | python | https://github.com/solvebio/solvebio-python/blob/b29614643043afd19c1d8074e8f25c6700d51a73/solvebio/annotate.py#L39-L64 | [
"def",
"annotate",
"(",
"self",
",",
"records",
",",
"*",
"*",
"kwargs",
")",
":",
"# Update annotator_params with any kwargs",
"self",
".",
"annotator_params",
".",
"update",
"(",
"*",
"*",
"kwargs",
")",
"chunk_size",
"=",
"self",
".",
"annotator_params",
".... | b29614643043afd19c1d8074e8f25c6700d51a73 |
test | Expression.evaluate | Evaluates the expression with the provided context and format. | solvebio/annotate.py | def evaluate(self, data=None, data_type='string', is_list=False):
"""Evaluates the expression with the provided context and format."""
payload = {
'data': data,
'expression': self.expr,
'data_type': data_type,
'is_list': is_list
}
res = sel... | def evaluate(self, data=None, data_type='string', is_list=False):
"""Evaluates the expression with the provided context and format."""
payload = {
'data': data,
'expression': self.expr,
'data_type': data_type,
'is_list': is_list
}
res = sel... | [
"Evaluates",
"the",
"expression",
"with",
"the",
"provided",
"context",
"and",
"format",
"."
] | solvebio/solvebio-python | python | https://github.com/solvebio/solvebio-python/blob/b29614643043afd19c1d8074e8f25c6700d51a73/solvebio/annotate.py#L88-L97 | [
"def",
"evaluate",
"(",
"self",
",",
"data",
"=",
"None",
",",
"data_type",
"=",
"'string'",
",",
"is_list",
"=",
"False",
")",
":",
"payload",
"=",
"{",
"'data'",
":",
"data",
",",
"'expression'",
":",
"self",
".",
"expr",
",",
"'data_type'",
":",
"... | b29614643043afd19c1d8074e8f25c6700d51a73 |
test | format_output | Format output using *format_name*.
This is a wrapper around the :class:`TabularOutputFormatter` class.
:param iterable data: An :term:`iterable` (e.g. list) of rows.
:param iterable headers: The column headers.
:param str format_name: The display format to use.
:param \*\*kwargs: Optional argument... | cli_helpers/tabular_output/output_formatter.py | def format_output(data, headers, format_name, **kwargs):
"""Format output using *format_name*.
This is a wrapper around the :class:`TabularOutputFormatter` class.
:param iterable data: An :term:`iterable` (e.g. list) of rows.
:param iterable headers: The column headers.
:param str format_name: The... | def format_output(data, headers, format_name, **kwargs):
"""Format output using *format_name*.
This is a wrapper around the :class:`TabularOutputFormatter` class.
:param iterable data: An :term:`iterable` (e.g. list) of rows.
:param iterable headers: The column headers.
:param str format_name: The... | [
"Format",
"output",
"using",
"*",
"format_name",
"*",
"."
] | dbcli/cli_helpers | python | https://github.com/dbcli/cli_helpers/blob/3ebd891ac0c02bad061182dbcb54a47fb21980ae/cli_helpers/tabular_output/output_formatter.py#L181-L195 | [
"def",
"format_output",
"(",
"data",
",",
"headers",
",",
"format_name",
",",
"*",
"*",
"kwargs",
")",
":",
"formatter",
"=",
"TabularOutputFormatter",
"(",
"format_name",
"=",
"format_name",
")",
"return",
"formatter",
".",
"format_output",
"(",
"data",
",",
... | 3ebd891ac0c02bad061182dbcb54a47fb21980ae |
test | TabularOutputFormatter.format_name | Set the default format name.
:param str format_name: The display format name.
:raises ValueError: if the format is not recognized. | cli_helpers/tabular_output/output_formatter.py | def format_name(self, format_name):
"""Set the default format name.
:param str format_name: The display format name.
:raises ValueError: if the format is not recognized.
"""
if format_name in self.supported_formats:
self._format_name = format_name
else:
... | def format_name(self, format_name):
"""Set the default format name.
:param str format_name: The display format name.
:raises ValueError: if the format is not recognized.
"""
if format_name in self.supported_formats:
self._format_name = format_name
else:
... | [
"Set",
"the",
"default",
"format",
"name",
"."
] | dbcli/cli_helpers | python | https://github.com/dbcli/cli_helpers/blob/3ebd891ac0c02bad061182dbcb54a47fb21980ae/cli_helpers/tabular_output/output_formatter.py#L89-L100 | [
"def",
"format_name",
"(",
"self",
",",
"format_name",
")",
":",
"if",
"format_name",
"in",
"self",
".",
"supported_formats",
":",
"self",
".",
"_format_name",
"=",
"format_name",
"else",
":",
"raise",
"ValueError",
"(",
"'unrecognized format_name \"{}\"'",
".",
... | 3ebd891ac0c02bad061182dbcb54a47fb21980ae |
test | TabularOutputFormatter.register_new_formatter | Register a new output formatter.
:param str format_name: The name of the format.
:param callable handler: The function that formats the data.
:param tuple preprocessors: The preprocessors to call before
formatting.
:param dict kwargs: Keys/values for keyword argument default... | cli_helpers/tabular_output/output_formatter.py | def register_new_formatter(cls, format_name, handler, preprocessors=(),
kwargs=None):
"""Register a new output formatter.
:param str format_name: The name of the format.
:param callable handler: The function that formats the data.
:param tuple preprocessor... | def register_new_formatter(cls, format_name, handler, preprocessors=(),
kwargs=None):
"""Register a new output formatter.
:param str format_name: The name of the format.
:param callable handler: The function that formats the data.
:param tuple preprocessor... | [
"Register",
"a",
"new",
"output",
"formatter",
"."
] | dbcli/cli_helpers | python | https://github.com/dbcli/cli_helpers/blob/3ebd891ac0c02bad061182dbcb54a47fb21980ae/cli_helpers/tabular_output/output_formatter.py#L108-L120 | [
"def",
"register_new_formatter",
"(",
"cls",
",",
"format_name",
",",
"handler",
",",
"preprocessors",
"=",
"(",
")",
",",
"kwargs",
"=",
"None",
")",
":",
"cls",
".",
"_output_formats",
"[",
"format_name",
"]",
"=",
"OutputFormatHandler",
"(",
"format_name",
... | 3ebd891ac0c02bad061182dbcb54a47fb21980ae |
test | TabularOutputFormatter.format_output | Format the headers and data using a specific formatter.
*format_name* must be a supported formatter (see
:attr:`supported_formats`).
:param iterable data: An :term:`iterable` (e.g. list) of rows.
:param iterable headers: The column headers.
:param str format_name: The display f... | cli_helpers/tabular_output/output_formatter.py | def format_output(self, data, headers, format_name=None,
preprocessors=(), column_types=None, **kwargs):
"""Format the headers and data using a specific formatter.
*format_name* must be a supported formatter (see
:attr:`supported_formats`).
:param iterable data: A... | def format_output(self, data, headers, format_name=None,
preprocessors=(), column_types=None, **kwargs):
"""Format the headers and data using a specific formatter.
*format_name* must be a supported formatter (see
:attr:`supported_formats`).
:param iterable data: A... | [
"Format",
"the",
"headers",
"and",
"data",
"using",
"a",
"specific",
"formatter",
"."
] | dbcli/cli_helpers | python | https://github.com/dbcli/cli_helpers/blob/3ebd891ac0c02bad061182dbcb54a47fb21980ae/cli_helpers/tabular_output/output_formatter.py#L122-L154 | [
"def",
"format_output",
"(",
"self",
",",
"data",
",",
"headers",
",",
"format_name",
"=",
"None",
",",
"preprocessors",
"=",
"(",
")",
",",
"column_types",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"format_name",
"=",
"format_name",
"or",
"self",
... | 3ebd891ac0c02bad061182dbcb54a47fb21980ae |
test | TabularOutputFormatter._get_column_types | Get a list of the data types for each column in *data*. | cli_helpers/tabular_output/output_formatter.py | def _get_column_types(self, data):
"""Get a list of the data types for each column in *data*."""
columns = list(zip_longest(*data))
return [self._get_column_type(column) for column in columns] | def _get_column_types(self, data):
"""Get a list of the data types for each column in *data*."""
columns = list(zip_longest(*data))
return [self._get_column_type(column) for column in columns] | [
"Get",
"a",
"list",
"of",
"the",
"data",
"types",
"for",
"each",
"column",
"in",
"*",
"data",
"*",
"."
] | dbcli/cli_helpers | python | https://github.com/dbcli/cli_helpers/blob/3ebd891ac0c02bad061182dbcb54a47fb21980ae/cli_helpers/tabular_output/output_formatter.py#L156-L159 | [
"def",
"_get_column_types",
"(",
"self",
",",
"data",
")",
":",
"columns",
"=",
"list",
"(",
"zip_longest",
"(",
"*",
"data",
")",
")",
"return",
"[",
"self",
".",
"_get_column_type",
"(",
"column",
")",
"for",
"column",
"in",
"columns",
"]"
] | 3ebd891ac0c02bad061182dbcb54a47fb21980ae |
test | TabularOutputFormatter._get_column_type | Get the most generic data type for iterable *column*. | cli_helpers/tabular_output/output_formatter.py | def _get_column_type(self, column):
"""Get the most generic data type for iterable *column*."""
type_values = [TYPES[self._get_type(v)] for v in column]
inverse_types = {v: k for k, v in TYPES.items()}
return inverse_types[max(type_values)] | def _get_column_type(self, column):
"""Get the most generic data type for iterable *column*."""
type_values = [TYPES[self._get_type(v)] for v in column]
inverse_types = {v: k for k, v in TYPES.items()}
return inverse_types[max(type_values)] | [
"Get",
"the",
"most",
"generic",
"data",
"type",
"for",
"iterable",
"*",
"column",
"*",
"."
] | dbcli/cli_helpers | python | https://github.com/dbcli/cli_helpers/blob/3ebd891ac0c02bad061182dbcb54a47fb21980ae/cli_helpers/tabular_output/output_formatter.py#L161-L165 | [
"def",
"_get_column_type",
"(",
"self",
",",
"column",
")",
":",
"type_values",
"=",
"[",
"TYPES",
"[",
"self",
".",
"_get_type",
"(",
"v",
")",
"]",
"for",
"v",
"in",
"column",
"]",
"inverse_types",
"=",
"{",
"v",
":",
"k",
"for",
"k",
",",
"v",
... | 3ebd891ac0c02bad061182dbcb54a47fb21980ae |
test | TabularOutputFormatter._get_type | Get the data type for *value*. | cli_helpers/tabular_output/output_formatter.py | def _get_type(self, value):
"""Get the data type for *value*."""
if value is None:
return type(None)
elif type(value) in int_types:
return int
elif type(value) in float_types:
return float
elif isinstance(value, binary_type):
return... | def _get_type(self, value):
"""Get the data type for *value*."""
if value is None:
return type(None)
elif type(value) in int_types:
return int
elif type(value) in float_types:
return float
elif isinstance(value, binary_type):
return... | [
"Get",
"the",
"data",
"type",
"for",
"*",
"value",
"*",
"."
] | dbcli/cli_helpers | python | https://github.com/dbcli/cli_helpers/blob/3ebd891ac0c02bad061182dbcb54a47fb21980ae/cli_helpers/tabular_output/output_formatter.py#L167-L178 | [
"def",
"_get_type",
"(",
"self",
",",
"value",
")",
":",
"if",
"value",
"is",
"None",
":",
"return",
"type",
"(",
"None",
")",
"elif",
"type",
"(",
"value",
")",
"in",
"int_types",
":",
"return",
"int",
"elif",
"type",
"(",
"value",
")",
"in",
"flo... | 3ebd891ac0c02bad061182dbcb54a47fb21980ae |
test | adapter | Wrap tabulate inside a function for TabularOutputFormatter. | cli_helpers/tabular_output/tabulate_adapter.py | def adapter(data, headers, table_format=None, preserve_whitespace=False,
**kwargs):
"""Wrap tabulate inside a function for TabularOutputFormatter."""
keys = ('floatfmt', 'numalign', 'stralign', 'showindex', 'disable_numparse')
tkwargs = {'tablefmt': table_format}
tkwargs.update(filter_dict_b... | def adapter(data, headers, table_format=None, preserve_whitespace=False,
**kwargs):
"""Wrap tabulate inside a function for TabularOutputFormatter."""
keys = ('floatfmt', 'numalign', 'stralign', 'showindex', 'disable_numparse')
tkwargs = {'tablefmt': table_format}
tkwargs.update(filter_dict_b... | [
"Wrap",
"tabulate",
"inside",
"a",
"function",
"for",
"TabularOutputFormatter",
"."
] | dbcli/cli_helpers | python | https://github.com/dbcli/cli_helpers/blob/3ebd891ac0c02bad061182dbcb54a47fb21980ae/cli_helpers/tabular_output/tabulate_adapter.py#L86-L98 | [
"def",
"adapter",
"(",
"data",
",",
"headers",
",",
"table_format",
"=",
"None",
",",
"preserve_whitespace",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"keys",
"=",
"(",
"'floatfmt'",
",",
"'numalign'",
",",
"'stralign'",
",",
"'showindex'",
",",
"... | 3ebd891ac0c02bad061182dbcb54a47fb21980ae |
test | get_user_config_dir | Returns the config folder for the application. The default behavior
is to return whatever is most appropriate for the operating system.
For an example application called ``"My App"`` by ``"Acme"``,
something like the following folders could be returned:
macOS (non-XDG):
``~/Library/Application ... | cli_helpers/config.py | def get_user_config_dir(app_name, app_author, roaming=True, force_xdg=True):
"""Returns the config folder for the application. The default behavior
is to return whatever is most appropriate for the operating system.
For an example application called ``"My App"`` by ``"Acme"``,
something like the follo... | def get_user_config_dir(app_name, app_author, roaming=True, force_xdg=True):
"""Returns the config folder for the application. The default behavior
is to return whatever is most appropriate for the operating system.
For an example application called ``"My App"`` by ``"Acme"``,
something like the follo... | [
"Returns",
"the",
"config",
"folder",
"for",
"the",
"application",
".",
"The",
"default",
"behavior",
"is",
"to",
"return",
"whatever",
"is",
"most",
"appropriate",
"for",
"the",
"operating",
"system",
"."
] | dbcli/cli_helpers | python | https://github.com/dbcli/cli_helpers/blob/3ebd891ac0c02bad061182dbcb54a47fb21980ae/cli_helpers/config.py#L193-L231 | [
"def",
"get_user_config_dir",
"(",
"app_name",
",",
"app_author",
",",
"roaming",
"=",
"True",
",",
"force_xdg",
"=",
"True",
")",
":",
"if",
"WIN",
":",
"key",
"=",
"'APPDATA'",
"if",
"roaming",
"else",
"'LOCALAPPDATA'",
"folder",
"=",
"os",
".",
"path",
... | 3ebd891ac0c02bad061182dbcb54a47fb21980ae |
test | get_system_config_dirs | r"""Returns a list of system-wide config folders for the application.
For an example application called ``"My App"`` by ``"Acme"``,
something like the following folders could be returned:
macOS (non-XDG):
``['/Library/Application Support/My App']``
Mac OS X (XDG):
``['/etc/xdg/my-app']``
... | cli_helpers/config.py | def get_system_config_dirs(app_name, app_author, force_xdg=True):
r"""Returns a list of system-wide config folders for the application.
For an example application called ``"My App"`` by ``"Acme"``,
something like the following folders could be returned:
macOS (non-XDG):
``['/Library/Application ... | def get_system_config_dirs(app_name, app_author, force_xdg=True):
r"""Returns a list of system-wide config folders for the application.
For an example application called ``"My App"`` by ``"Acme"``,
something like the following folders could be returned:
macOS (non-XDG):
``['/Library/Application ... | [
"r",
"Returns",
"a",
"list",
"of",
"system",
"-",
"wide",
"config",
"folders",
"for",
"the",
"application",
"."
] | dbcli/cli_helpers | python | https://github.com/dbcli/cli_helpers/blob/3ebd891ac0c02bad061182dbcb54a47fb21980ae/cli_helpers/config.py#L234-L265 | [
"def",
"get_system_config_dirs",
"(",
"app_name",
",",
"app_author",
",",
"force_xdg",
"=",
"True",
")",
":",
"if",
"WIN",
":",
"folder",
"=",
"os",
".",
"environ",
".",
"get",
"(",
"'PROGRAMDATA'",
")",
"return",
"[",
"os",
".",
"path",
".",
"join",
"... | 3ebd891ac0c02bad061182dbcb54a47fb21980ae |
test | Config.read_default_config | Read the default config file.
:raises DefaultConfigValidationError: There was a validation error with
the *default* file. | cli_helpers/config.py | def read_default_config(self):
"""Read the default config file.
:raises DefaultConfigValidationError: There was a validation error with
the *default* file.
"""
if self.validate:
self.default_config = ConfigObj(configspec=self.def... | def read_default_config(self):
"""Read the default config file.
:raises DefaultConfigValidationError: There was a validation error with
the *default* file.
"""
if self.validate:
self.default_config = ConfigObj(configspec=self.def... | [
"Read",
"the",
"default",
"config",
"file",
"."
] | dbcli/cli_helpers | python | https://github.com/dbcli/cli_helpers/blob/3ebd891ac0c02bad061182dbcb54a47fb21980ae/cli_helpers/config.py#L77-L101 | [
"def",
"read_default_config",
"(",
"self",
")",
":",
"if",
"self",
".",
"validate",
":",
"self",
".",
"default_config",
"=",
"ConfigObj",
"(",
"configspec",
"=",
"self",
".",
"default_file",
",",
"list_values",
"=",
"False",
",",
"_inspec",
"=",
"True",
",... | 3ebd891ac0c02bad061182dbcb54a47fb21980ae |
test | Config.read | Read the default, additional, system, and user config files.
:raises DefaultConfigValidationError: There was a validation error with
the *default* file. | cli_helpers/config.py | def read(self):
"""Read the default, additional, system, and user config files.
:raises DefaultConfigValidationError: There was a validation error with
the *default* file.
"""
if self.default_file:
self.read_default_config()
... | def read(self):
"""Read the default, additional, system, and user config files.
:raises DefaultConfigValidationError: There was a validation error with
the *default* file.
"""
if self.default_file:
self.read_default_config()
... | [
"Read",
"the",
"default",
"additional",
"system",
"and",
"user",
"config",
"files",
"."
] | dbcli/cli_helpers | python | https://github.com/dbcli/cli_helpers/blob/3ebd891ac0c02bad061182dbcb54a47fb21980ae/cli_helpers/config.py#L103-L111 | [
"def",
"read",
"(",
"self",
")",
":",
"if",
"self",
".",
"default_file",
":",
"self",
".",
"read_default_config",
"(",
")",
"return",
"self",
".",
"read_config_files",
"(",
"self",
".",
"all_config_files",
"(",
")",
")"
] | 3ebd891ac0c02bad061182dbcb54a47fb21980ae |
test | Config.user_config_file | Get the absolute path to the user config file. | cli_helpers/config.py | def user_config_file(self):
"""Get the absolute path to the user config file."""
return os.path.join(
get_user_config_dir(self.app_name, self.app_author),
self.filename) | def user_config_file(self):
"""Get the absolute path to the user config file."""
return os.path.join(
get_user_config_dir(self.app_name, self.app_author),
self.filename) | [
"Get",
"the",
"absolute",
"path",
"to",
"the",
"user",
"config",
"file",
"."
] | dbcli/cli_helpers | python | https://github.com/dbcli/cli_helpers/blob/3ebd891ac0c02bad061182dbcb54a47fb21980ae/cli_helpers/config.py#L113-L117 | [
"def",
"user_config_file",
"(",
"self",
")",
":",
"return",
"os",
".",
"path",
".",
"join",
"(",
"get_user_config_dir",
"(",
"self",
".",
"app_name",
",",
"self",
".",
"app_author",
")",
",",
"self",
".",
"filename",
")"
] | 3ebd891ac0c02bad061182dbcb54a47fb21980ae |
test | Config.system_config_files | Get a list of absolute paths to the system config files. | cli_helpers/config.py | def system_config_files(self):
"""Get a list of absolute paths to the system config files."""
return [os.path.join(f, self.filename) for f in get_system_config_dirs(
self.app_name, self.app_author)] | def system_config_files(self):
"""Get a list of absolute paths to the system config files."""
return [os.path.join(f, self.filename) for f in get_system_config_dirs(
self.app_name, self.app_author)] | [
"Get",
"a",
"list",
"of",
"absolute",
"paths",
"to",
"the",
"system",
"config",
"files",
"."
] | dbcli/cli_helpers | python | https://github.com/dbcli/cli_helpers/blob/3ebd891ac0c02bad061182dbcb54a47fb21980ae/cli_helpers/config.py#L119-L122 | [
"def",
"system_config_files",
"(",
"self",
")",
":",
"return",
"[",
"os",
".",
"path",
".",
"join",
"(",
"f",
",",
"self",
".",
"filename",
")",
"for",
"f",
"in",
"get_system_config_dirs",
"(",
"self",
".",
"app_name",
",",
"self",
".",
"app_author",
"... | 3ebd891ac0c02bad061182dbcb54a47fb21980ae |
test | Config.additional_files | Get a list of absolute paths to the additional config files. | cli_helpers/config.py | def additional_files(self):
"""Get a list of absolute paths to the additional config files."""
return [os.path.join(f, self.filename) for f in self.additional_dirs] | def additional_files(self):
"""Get a list of absolute paths to the additional config files."""
return [os.path.join(f, self.filename) for f in self.additional_dirs] | [
"Get",
"a",
"list",
"of",
"absolute",
"paths",
"to",
"the",
"additional",
"config",
"files",
"."
] | dbcli/cli_helpers | python | https://github.com/dbcli/cli_helpers/blob/3ebd891ac0c02bad061182dbcb54a47fb21980ae/cli_helpers/config.py#L124-L126 | [
"def",
"additional_files",
"(",
"self",
")",
":",
"return",
"[",
"os",
".",
"path",
".",
"join",
"(",
"f",
",",
"self",
".",
"filename",
")",
"for",
"f",
"in",
"self",
".",
"additional_dirs",
"]"
] | 3ebd891ac0c02bad061182dbcb54a47fb21980ae |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.