repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
smdabdoub/phylotoast | phylotoast/util.py | split_phylogeny | def split_phylogeny(p, level="s"):
"""
Return either the full or truncated version of a QIIME-formatted taxonomy string.
:type p: str
:param p: A QIIME-formatted taxonomy string: k__Foo; p__Bar; ...
:type level: str
:param level: The different level of identification are kingdom (k), phylum (p... | python | def split_phylogeny(p, level="s"):
"""
Return either the full or truncated version of a QIIME-formatted taxonomy string.
:type p: str
:param p: A QIIME-formatted taxonomy string: k__Foo; p__Bar; ...
:type level: str
:param level: The different level of identification are kingdom (k), phylum (p... | [
"def",
"split_phylogeny",
"(",
"p",
",",
"level",
"=",
"\"s\"",
")",
":",
"level",
"=",
"level",
"+",
"\"__\"",
"result",
"=",
"p",
".",
"split",
"(",
"level",
")",
"return",
"result",
"[",
"0",
"]",
"+",
"level",
"+",
"result",
"[",
"1",
"]",
".... | Return either the full or truncated version of a QIIME-formatted taxonomy string.
:type p: str
:param p: A QIIME-formatted taxonomy string: k__Foo; p__Bar; ...
:type level: str
:param level: The different level of identification are kingdom (k), phylum (p),
class (c),order (o), famil... | [
"Return",
"either",
"the",
"full",
"or",
"truncated",
"version",
"of",
"a",
"QIIME",
"-",
"formatted",
"taxonomy",
"string",
"."
] | 0b74ef171e6a84761710548501dfac71285a58a3 | https://github.com/smdabdoub/phylotoast/blob/0b74ef171e6a84761710548501dfac71285a58a3/phylotoast/util.py#L159-L177 | train |
smdabdoub/phylotoast | phylotoast/util.py | ensure_dir | def ensure_dir(d):
"""
Check to make sure the supplied directory path does not exist, if so, create it. The
method catches OSError exceptions and returns a descriptive message instead of
re-raising the error.
:type d: str
:param d: It is the full path to a directory.
:return: Does not retu... | python | def ensure_dir(d):
"""
Check to make sure the supplied directory path does not exist, if so, create it. The
method catches OSError exceptions and returns a descriptive message instead of
re-raising the error.
:type d: str
:param d: It is the full path to a directory.
:return: Does not retu... | [
"def",
"ensure_dir",
"(",
"d",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"d",
")",
":",
"try",
":",
"os",
".",
"makedirs",
"(",
"d",
")",
"except",
"OSError",
"as",
"oe",
":",
"if",
"os",
".",
"errno",
"==",
"errno",
".",
... | Check to make sure the supplied directory path does not exist, if so, create it. The
method catches OSError exceptions and returns a descriptive message instead of
re-raising the error.
:type d: str
:param d: It is the full path to a directory.
:return: Does not return anything, but creates a dire... | [
"Check",
"to",
"make",
"sure",
"the",
"supplied",
"directory",
"path",
"does",
"not",
"exist",
"if",
"so",
"create",
"it",
".",
"The",
"method",
"catches",
"OSError",
"exceptions",
"and",
"returns",
"a",
"descriptive",
"message",
"instead",
"of",
"re",
"-",
... | 0b74ef171e6a84761710548501dfac71285a58a3 | https://github.com/smdabdoub/phylotoast/blob/0b74ef171e6a84761710548501dfac71285a58a3/phylotoast/util.py#L180-L206 | train |
smdabdoub/phylotoast | phylotoast/util.py | file_handle | def file_handle(fnh, mode="rU"):
"""
Takes either a file path or an open file handle, checks validity and returns an open
file handle or raises an appropriate Exception.
:type fnh: str
:param fnh: It is the full path to a file, or open file handle
:type mode: str
:param mode: The way in wh... | python | def file_handle(fnh, mode="rU"):
"""
Takes either a file path or an open file handle, checks validity and returns an open
file handle or raises an appropriate Exception.
:type fnh: str
:param fnh: It is the full path to a file, or open file handle
:type mode: str
:param mode: The way in wh... | [
"def",
"file_handle",
"(",
"fnh",
",",
"mode",
"=",
"\"rU\"",
")",
":",
"handle",
"=",
"None",
"if",
"isinstance",
"(",
"fnh",
",",
"file",
")",
":",
"if",
"fnh",
".",
"closed",
":",
"raise",
"ValueError",
"(",
"\"Input file is closed.\"",
")",
"handle",... | Takes either a file path or an open file handle, checks validity and returns an open
file handle or raises an appropriate Exception.
:type fnh: str
:param fnh: It is the full path to a file, or open file handle
:type mode: str
:param mode: The way in which this file will be used, for example to re... | [
"Takes",
"either",
"a",
"file",
"path",
"or",
"an",
"open",
"file",
"handle",
"checks",
"validity",
"and",
"returns",
"an",
"open",
"file",
"handle",
"or",
"raises",
"an",
"appropriate",
"Exception",
"."
] | 0b74ef171e6a84761710548501dfac71285a58a3 | https://github.com/smdabdoub/phylotoast/blob/0b74ef171e6a84761710548501dfac71285a58a3/phylotoast/util.py#L209-L231 | train |
smdabdoub/phylotoast | phylotoast/util.py | gather_categories | def gather_categories(imap, header, categories=None):
"""
Find the user specified categories in the map and create a dictionary to contain the
relevant data for each type within the categories. Multiple categories will have their
types combined such that each possible combination will have its own entry... | python | def gather_categories(imap, header, categories=None):
"""
Find the user specified categories in the map and create a dictionary to contain the
relevant data for each type within the categories. Multiple categories will have their
types combined such that each possible combination will have its own entry... | [
"def",
"gather_categories",
"(",
"imap",
",",
"header",
",",
"categories",
"=",
"None",
")",
":",
"if",
"categories",
"is",
"None",
":",
"return",
"{",
"\"default\"",
":",
"DataCategory",
"(",
"set",
"(",
"imap",
".",
"keys",
"(",
")",
")",
",",
"{",
... | Find the user specified categories in the map and create a dictionary to contain the
relevant data for each type within the categories. Multiple categories will have their
types combined such that each possible combination will have its own entry in the
dictionary.
:type imap: dict
:param imap: The... | [
"Find",
"the",
"user",
"specified",
"categories",
"in",
"the",
"map",
"and",
"create",
"a",
"dictionary",
"to",
"contain",
"the",
"relevant",
"data",
"for",
"each",
"type",
"within",
"the",
"categories",
".",
"Multiple",
"categories",
"will",
"have",
"their",
... | 0b74ef171e6a84761710548501dfac71285a58a3 | https://github.com/smdabdoub/phylotoast/blob/0b74ef171e6a84761710548501dfac71285a58a3/phylotoast/util.py#L238-L309 | train |
smdabdoub/phylotoast | phylotoast/util.py | parse_unifrac | def parse_unifrac(unifracFN):
"""
Parses the unifrac results file into a dictionary
:type unifracFN: str
:param unifracFN: The path to the unifrac results file
:rtype: dict
:return: A dictionary with keys: 'pcd' (principle coordinates data) which is a
dictionary of the data keyed ... | python | def parse_unifrac(unifracFN):
"""
Parses the unifrac results file into a dictionary
:type unifracFN: str
:param unifracFN: The path to the unifrac results file
:rtype: dict
:return: A dictionary with keys: 'pcd' (principle coordinates data) which is a
dictionary of the data keyed ... | [
"def",
"parse_unifrac",
"(",
"unifracFN",
")",
":",
"with",
"open",
"(",
"unifracFN",
",",
"\"rU\"",
")",
"as",
"uF",
":",
"first",
"=",
"uF",
".",
"next",
"(",
")",
".",
"split",
"(",
"\"\\t\"",
")",
"lines",
"=",
"[",
"line",
".",
"strip",
"(",
... | Parses the unifrac results file into a dictionary
:type unifracFN: str
:param unifracFN: The path to the unifrac results file
:rtype: dict
:return: A dictionary with keys: 'pcd' (principle coordinates data) which is a
dictionary of the data keyed by sample ID, 'eigvals' (eigenvalues), and... | [
"Parses",
"the",
"unifrac",
"results",
"file",
"into",
"a",
"dictionary"
] | 0b74ef171e6a84761710548501dfac71285a58a3 | https://github.com/smdabdoub/phylotoast/blob/0b74ef171e6a84761710548501dfac71285a58a3/phylotoast/util.py#L311-L334 | train |
smdabdoub/phylotoast | phylotoast/util.py | parse_unifrac_v1_8 | def parse_unifrac_v1_8(unifrac, file_data):
"""
Function to parse data from older version of unifrac file obtained from Qiime version
1.8 and earlier.
:type unifrac: dict
:param unifracFN: The path to the unifrac results file
:type file_data: list
:param file_data: Unifrac data lines after... | python | def parse_unifrac_v1_8(unifrac, file_data):
"""
Function to parse data from older version of unifrac file obtained from Qiime version
1.8 and earlier.
:type unifrac: dict
:param unifracFN: The path to the unifrac results file
:type file_data: list
:param file_data: Unifrac data lines after... | [
"def",
"parse_unifrac_v1_8",
"(",
"unifrac",
",",
"file_data",
")",
":",
"for",
"line",
"in",
"file_data",
":",
"if",
"line",
"==",
"\"\"",
":",
"break",
"line",
"=",
"line",
".",
"split",
"(",
"\"\\t\"",
")",
"unifrac",
"[",
"\"pcd\"",
"]",
"[",
"line... | Function to parse data from older version of unifrac file obtained from Qiime version
1.8 and earlier.
:type unifrac: dict
:param unifracFN: The path to the unifrac results file
:type file_data: list
:param file_data: Unifrac data lines after stripping whitespace characters. | [
"Function",
"to",
"parse",
"data",
"from",
"older",
"version",
"of",
"unifrac",
"file",
"obtained",
"from",
"Qiime",
"version",
"1",
".",
"8",
"and",
"earlier",
"."
] | 0b74ef171e6a84761710548501dfac71285a58a3 | https://github.com/smdabdoub/phylotoast/blob/0b74ef171e6a84761710548501dfac71285a58a3/phylotoast/util.py#L337-L356 | train |
smdabdoub/phylotoast | phylotoast/util.py | parse_unifrac_v1_9 | def parse_unifrac_v1_9(unifrac, file_data):
"""
Function to parse data from newer version of unifrac file obtained from Qiime version
1.9 and later.
:type unifracFN: str
:param unifracFN: The path to the unifrac results file
:type file_data: list
:param file_data: Unifrac data lines after ... | python | def parse_unifrac_v1_9(unifrac, file_data):
"""
Function to parse data from newer version of unifrac file obtained from Qiime version
1.9 and later.
:type unifracFN: str
:param unifracFN: The path to the unifrac results file
:type file_data: list
:param file_data: Unifrac data lines after ... | [
"def",
"parse_unifrac_v1_9",
"(",
"unifrac",
",",
"file_data",
")",
":",
"unifrac",
"[",
"\"eigvals\"",
"]",
"=",
"[",
"float",
"(",
"entry",
")",
"for",
"entry",
"in",
"file_data",
"[",
"0",
"]",
".",
"split",
"(",
"\"\\t\"",
")",
"]",
"unifrac",
"[",... | Function to parse data from newer version of unifrac file obtained from Qiime version
1.9 and later.
:type unifracFN: str
:param unifracFN: The path to the unifrac results file
:type file_data: list
:param file_data: Unifrac data lines after stripping whitespace characters. | [
"Function",
"to",
"parse",
"data",
"from",
"newer",
"version",
"of",
"unifrac",
"file",
"obtained",
"from",
"Qiime",
"version",
"1",
".",
"9",
"and",
"later",
"."
] | 0b74ef171e6a84761710548501dfac71285a58a3 | https://github.com/smdabdoub/phylotoast/blob/0b74ef171e6a84761710548501dfac71285a58a3/phylotoast/util.py#L359-L378 | train |
smdabdoub/phylotoast | phylotoast/util.py | color_mapping | def color_mapping(sample_map, header, group_column, color_column=None):
"""
Determine color-category mapping. If color_column was specified, then map the category
names to color values. Otherwise, use the palettable colors to automatically generate
a set of colors for the group values.
:type sample... | python | def color_mapping(sample_map, header, group_column, color_column=None):
"""
Determine color-category mapping. If color_column was specified, then map the category
names to color values. Otherwise, use the palettable colors to automatically generate
a set of colors for the group values.
:type sample... | [
"def",
"color_mapping",
"(",
"sample_map",
",",
"header",
",",
"group_column",
",",
"color_column",
"=",
"None",
")",
":",
"group_colors",
"=",
"OrderedDict",
"(",
")",
"group_gather",
"=",
"gather_categories",
"(",
"sample_map",
",",
"header",
",",
"[",
"grou... | Determine color-category mapping. If color_column was specified, then map the category
names to color values. Otherwise, use the palettable colors to automatically generate
a set of colors for the group values.
:type sample_map: dict
:param unifracFN: Map associating each line of the mapping file with ... | [
"Determine",
"color",
"-",
"category",
"mapping",
".",
"If",
"color_column",
"was",
"specified",
"then",
"map",
"the",
"category",
"names",
"to",
"color",
"values",
".",
"Otherwise",
"use",
"the",
"palettable",
"colors",
"to",
"automatically",
"generate",
"a",
... | 0b74ef171e6a84761710548501dfac71285a58a3 | https://github.com/smdabdoub/phylotoast/blob/0b74ef171e6a84761710548501dfac71285a58a3/phylotoast/util.py#L380-L419 | train |
christophertbrown/bioscripts | ctbBio/shuffle_genome.py | rev_c | def rev_c(read):
"""
return reverse completment of read
"""
rc = []
rc_nucs = {'A':'T', 'T':'A', 'G':'C', 'C':'G', 'N':'N'}
for base in read:
rc.extend(rc_nucs[base.upper()])
return rc[::-1] | python | def rev_c(read):
"""
return reverse completment of read
"""
rc = []
rc_nucs = {'A':'T', 'T':'A', 'G':'C', 'C':'G', 'N':'N'}
for base in read:
rc.extend(rc_nucs[base.upper()])
return rc[::-1] | [
"def",
"rev_c",
"(",
"read",
")",
":",
"rc",
"=",
"[",
"]",
"rc_nucs",
"=",
"{",
"'A'",
":",
"'T'",
",",
"'T'",
":",
"'A'",
",",
"'G'",
":",
"'C'",
",",
"'C'",
":",
"'G'",
",",
"'N'",
":",
"'N'",
"}",
"for",
"base",
"in",
"read",
":",
"rc",... | return reverse completment of read | [
"return",
"reverse",
"completment",
"of",
"read"
] | 83b2566b3a5745437ec651cd6cafddd056846240 | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/shuffle_genome.py#L27-L35 | train |
christophertbrown/bioscripts | ctbBio/shuffle_genome.py | shuffle_genome | def shuffle_genome(genome, cat, fraction = float(100), plot = True, \
alpha = 0.1, beta = 100000, \
min_length = 1000, max_length = 200000):
"""
randomly shuffle genome
"""
header = '>randomized_%s' % (genome.name)
sequence = list(''.join([i[1] for i in parse_fasta(genome)]))
len... | python | def shuffle_genome(genome, cat, fraction = float(100), plot = True, \
alpha = 0.1, beta = 100000, \
min_length = 1000, max_length = 200000):
"""
randomly shuffle genome
"""
header = '>randomized_%s' % (genome.name)
sequence = list(''.join([i[1] for i in parse_fasta(genome)]))
len... | [
"def",
"shuffle_genome",
"(",
"genome",
",",
"cat",
",",
"fraction",
"=",
"float",
"(",
"100",
")",
",",
"plot",
"=",
"True",
",",
"alpha",
"=",
"0.1",
",",
"beta",
"=",
"100000",
",",
"min_length",
"=",
"1000",
",",
"max_length",
"=",
"200000",
")",... | randomly shuffle genome | [
"randomly",
"shuffle",
"genome"
] | 83b2566b3a5745437ec651cd6cafddd056846240 | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/shuffle_genome.py#L37-L87 | train |
opengridcc/opengrid | opengrid/library/regression.py | MultiVarLinReg._prune | def _prune(self, fit, p_max):
"""
If the fit contains statistically insignificant parameters, remove them.
Returns a pruned fit where all parameters have p-values of the t-statistic below p_max
Parameters
----------
fit: fm.ols fit object
Can contain insignif... | python | def _prune(self, fit, p_max):
"""
If the fit contains statistically insignificant parameters, remove them.
Returns a pruned fit where all parameters have p-values of the t-statistic below p_max
Parameters
----------
fit: fm.ols fit object
Can contain insignif... | [
"def",
"_prune",
"(",
"self",
",",
"fit",
",",
"p_max",
")",
":",
"def",
"remove_from_model_desc",
"(",
"x",
",",
"model_desc",
")",
":",
"rhs_termlist",
"=",
"[",
"]",
"for",
"t",
"in",
"model_desc",
".",
"rhs_termlist",
":",
"if",
"not",
"t",
".",
... | If the fit contains statistically insignificant parameters, remove them.
Returns a pruned fit where all parameters have p-values of the t-statistic below p_max
Parameters
----------
fit: fm.ols fit object
Can contain insignificant parameters
p_max : float
... | [
"If",
"the",
"fit",
"contains",
"statistically",
"insignificant",
"parameters",
"remove",
"them",
".",
"Returns",
"a",
"pruned",
"fit",
"where",
"all",
"parameters",
"have",
"p",
"-",
"values",
"of",
"the",
"t",
"-",
"statistic",
"below",
"p_max"
] | 69b8da3c8fcea9300226c45ef0628cd6d4307651 | https://github.com/opengridcc/opengrid/blob/69b8da3c8fcea9300226c45ef0628cd6d4307651/opengrid/library/regression.py#L222-L272 | train |
opengridcc/opengrid | opengrid/library/regression.py | MultiVarLinReg.find_best_rsquared | def find_best_rsquared(list_of_fits):
"""Return the best fit, based on rsquared"""
res = sorted(list_of_fits, key=lambda x: x.rsquared)
return res[-1] | python | def find_best_rsquared(list_of_fits):
"""Return the best fit, based on rsquared"""
res = sorted(list_of_fits, key=lambda x: x.rsquared)
return res[-1] | [
"def",
"find_best_rsquared",
"(",
"list_of_fits",
")",
":",
"res",
"=",
"sorted",
"(",
"list_of_fits",
",",
"key",
"=",
"lambda",
"x",
":",
"x",
".",
"rsquared",
")",
"return",
"res",
"[",
"-",
"1",
"]"
] | Return the best fit, based on rsquared | [
"Return",
"the",
"best",
"fit",
"based",
"on",
"rsquared"
] | 69b8da3c8fcea9300226c45ef0628cd6d4307651 | https://github.com/opengridcc/opengrid/blob/69b8da3c8fcea9300226c45ef0628cd6d4307651/opengrid/library/regression.py#L275-L278 | train |
opengridcc/opengrid | opengrid/library/regression.py | MultiVarLinReg._predict | def _predict(self, fit, df):
"""
Return a df with predictions and confidence interval
Notes
-----
The df will contain the following columns:
- 'predicted': the model output
- 'interval_u', 'interval_l': upper and lower confidence bounds.
The result will ... | python | def _predict(self, fit, df):
"""
Return a df with predictions and confidence interval
Notes
-----
The df will contain the following columns:
- 'predicted': the model output
- 'interval_u', 'interval_l': upper and lower confidence bounds.
The result will ... | [
"def",
"_predict",
"(",
"self",
",",
"fit",
",",
"df",
")",
":",
"df_res",
"=",
"df",
".",
"copy",
"(",
")",
"if",
"'Intercept'",
"in",
"fit",
".",
"model",
".",
"exog_names",
":",
"df_res",
"[",
"'Intercept'",
"]",
"=",
"1.0",
"df_res",
"[",
"'pre... | Return a df with predictions and confidence interval
Notes
-----
The df will contain the following columns:
- 'predicted': the model output
- 'interval_u', 'interval_l': upper and lower confidence bounds.
The result will depend on the following attributes of self:
... | [
"Return",
"a",
"df",
"with",
"predictions",
"and",
"confidence",
"interval"
] | 69b8da3c8fcea9300226c45ef0628cd6d4307651 | https://github.com/opengridcc/opengrid/blob/69b8da3c8fcea9300226c45ef0628cd6d4307651/opengrid/library/regression.py#L292-L338 | train |
smdabdoub/phylotoast | phylotoast/biom_calc.py | relative_abundance | def relative_abundance(biomf, sampleIDs=None):
"""
Calculate the relative abundance of each OTUID in a Sample.
:type biomf: A BIOM file.
:param biomf: OTU table format.
:type sampleIDs: list
:param sampleIDs: A list of sample id's from BIOM format OTU table.
:rtype: dict
:return: Retu... | python | def relative_abundance(biomf, sampleIDs=None):
"""
Calculate the relative abundance of each OTUID in a Sample.
:type biomf: A BIOM file.
:param biomf: OTU table format.
:type sampleIDs: list
:param sampleIDs: A list of sample id's from BIOM format OTU table.
:rtype: dict
:return: Retu... | [
"def",
"relative_abundance",
"(",
"biomf",
",",
"sampleIDs",
"=",
"None",
")",
":",
"if",
"sampleIDs",
"is",
"None",
":",
"sampleIDs",
"=",
"biomf",
".",
"ids",
"(",
")",
"else",
":",
"try",
":",
"for",
"sid",
"in",
"sampleIDs",
":",
"assert",
"sid",
... | Calculate the relative abundance of each OTUID in a Sample.
:type biomf: A BIOM file.
:param biomf: OTU table format.
:type sampleIDs: list
:param sampleIDs: A list of sample id's from BIOM format OTU table.
:rtype: dict
:return: Returns a keyed on SampleIDs, and the values are dictionaries k... | [
"Calculate",
"the",
"relative",
"abundance",
"of",
"each",
"OTUID",
"in",
"a",
"Sample",
"."
] | 0b74ef171e6a84761710548501dfac71285a58a3 | https://github.com/smdabdoub/phylotoast/blob/0b74ef171e6a84761710548501dfac71285a58a3/phylotoast/biom_calc.py#L11-L41 | train |
smdabdoub/phylotoast | phylotoast/biom_calc.py | mean_otu_pct_abundance | def mean_otu_pct_abundance(ra, otuIDs):
"""
Calculate the mean OTU abundance percentage.
:type ra: Dict
:param ra: 'ra' refers to a dictionary keyed on SampleIDs, and the values are
dictionaries keyed on OTUID's and their values represent the relative
abundance of that OTU... | python | def mean_otu_pct_abundance(ra, otuIDs):
"""
Calculate the mean OTU abundance percentage.
:type ra: Dict
:param ra: 'ra' refers to a dictionary keyed on SampleIDs, and the values are
dictionaries keyed on OTUID's and their values represent the relative
abundance of that OTU... | [
"def",
"mean_otu_pct_abundance",
"(",
"ra",
",",
"otuIDs",
")",
":",
"sids",
"=",
"ra",
".",
"keys",
"(",
")",
"otumeans",
"=",
"defaultdict",
"(",
"int",
")",
"for",
"oid",
"in",
"otuIDs",
":",
"otumeans",
"[",
"oid",
"]",
"=",
"sum",
"(",
"[",
"r... | Calculate the mean OTU abundance percentage.
:type ra: Dict
:param ra: 'ra' refers to a dictionary keyed on SampleIDs, and the values are
dictionaries keyed on OTUID's and their values represent the relative
abundance of that OTUID in that SampleID. 'ra' is the output of
... | [
"Calculate",
"the",
"mean",
"OTU",
"abundance",
"percentage",
"."
] | 0b74ef171e6a84761710548501dfac71285a58a3 | https://github.com/smdabdoub/phylotoast/blob/0b74ef171e6a84761710548501dfac71285a58a3/phylotoast/biom_calc.py#L44-L67 | train |
smdabdoub/phylotoast | phylotoast/biom_calc.py | MRA | def MRA(biomf, sampleIDs=None, transform=None):
"""
Calculate the mean relative abundance percentage.
:type biomf: A BIOM file.
:param biomf: OTU table format.
:type sampleIDs: list
:param sampleIDs: A list of sample id's from BIOM format OTU table.
:param transform: Mathematical function... | python | def MRA(biomf, sampleIDs=None, transform=None):
"""
Calculate the mean relative abundance percentage.
:type biomf: A BIOM file.
:param biomf: OTU table format.
:type sampleIDs: list
:param sampleIDs: A list of sample id's from BIOM format OTU table.
:param transform: Mathematical function... | [
"def",
"MRA",
"(",
"biomf",
",",
"sampleIDs",
"=",
"None",
",",
"transform",
"=",
"None",
")",
":",
"ra",
"=",
"relative_abundance",
"(",
"biomf",
",",
"sampleIDs",
")",
"if",
"transform",
"is",
"not",
"None",
":",
"ra",
"=",
"{",
"sample",
":",
"{",... | Calculate the mean relative abundance percentage.
:type biomf: A BIOM file.
:param biomf: OTU table format.
:type sampleIDs: list
:param sampleIDs: A list of sample id's from BIOM format OTU table.
:param transform: Mathematical function which is used to transform smax to another
... | [
"Calculate",
"the",
"mean",
"relative",
"abundance",
"percentage",
"."
] | 0b74ef171e6a84761710548501dfac71285a58a3 | https://github.com/smdabdoub/phylotoast/blob/0b74ef171e6a84761710548501dfac71285a58a3/phylotoast/biom_calc.py#L70-L92 | train |
smdabdoub/phylotoast | phylotoast/biom_calc.py | raw_abundance | def raw_abundance(biomf, sampleIDs=None, sample_abd=True):
"""
Calculate the total number of sequences in each OTU or SampleID.
:type biomf: A BIOM file.
:param biomf: OTU table format.
:type sampleIDs: List
:param sampleIDs: A list of column id's from BIOM format OTU table. By default, the
... | python | def raw_abundance(biomf, sampleIDs=None, sample_abd=True):
"""
Calculate the total number of sequences in each OTU or SampleID.
:type biomf: A BIOM file.
:param biomf: OTU table format.
:type sampleIDs: List
:param sampleIDs: A list of column id's from BIOM format OTU table. By default, the
... | [
"def",
"raw_abundance",
"(",
"biomf",
",",
"sampleIDs",
"=",
"None",
",",
"sample_abd",
"=",
"True",
")",
":",
"results",
"=",
"defaultdict",
"(",
"int",
")",
"if",
"sampleIDs",
"is",
"None",
":",
"sampleIDs",
"=",
"biomf",
".",
"ids",
"(",
")",
"else"... | Calculate the total number of sequences in each OTU or SampleID.
:type biomf: A BIOM file.
:param biomf: OTU table format.
:type sampleIDs: List
:param sampleIDs: A list of column id's from BIOM format OTU table. By default, the
list has been set to None.
:type sample_abd: B... | [
"Calculate",
"the",
"total",
"number",
"of",
"sequences",
"in",
"each",
"OTU",
"or",
"SampleID",
"."
] | 0b74ef171e6a84761710548501dfac71285a58a3 | https://github.com/smdabdoub/phylotoast/blob/0b74ef171e6a84761710548501dfac71285a58a3/phylotoast/biom_calc.py#L95-L135 | train |
smdabdoub/phylotoast | phylotoast/biom_calc.py | transform_raw_abundance | def transform_raw_abundance(biomf, fn=math.log10, sampleIDs=None, sample_abd=True):
"""
Function to transform the total abundance calculation for each sample ID to another
format based on user given transformation function.
:type biomf: A BIOM file.
:param biomf: OTU table format.
:param fn: M... | python | def transform_raw_abundance(biomf, fn=math.log10, sampleIDs=None, sample_abd=True):
"""
Function to transform the total abundance calculation for each sample ID to another
format based on user given transformation function.
:type biomf: A BIOM file.
:param biomf: OTU table format.
:param fn: M... | [
"def",
"transform_raw_abundance",
"(",
"biomf",
",",
"fn",
"=",
"math",
".",
"log10",
",",
"sampleIDs",
"=",
"None",
",",
"sample_abd",
"=",
"True",
")",
":",
"totals",
"=",
"raw_abundance",
"(",
"biomf",
",",
"sampleIDs",
",",
"sample_abd",
")",
"return",... | Function to transform the total abundance calculation for each sample ID to another
format based on user given transformation function.
:type biomf: A BIOM file.
:param biomf: OTU table format.
:param fn: Mathematical function which is used to transform smax to another format.
By defaul... | [
"Function",
"to",
"transform",
"the",
"total",
"abundance",
"calculation",
"for",
"each",
"sample",
"ID",
"to",
"another",
"format",
"based",
"on",
"user",
"given",
"transformation",
"function",
"."
] | 0b74ef171e6a84761710548501dfac71285a58a3 | https://github.com/smdabdoub/phylotoast/blob/0b74ef171e6a84761710548501dfac71285a58a3/phylotoast/biom_calc.py#L138-L155 | train |
smdabdoub/phylotoast | bin/diversity.py | print_MannWhitneyU | def print_MannWhitneyU(div_calc):
"""
Compute the Mann-Whitney U test for unequal group sample sizes.
"""
try:
x = div_calc.values()[0].values()
y = div_calc.values()[1].values()
except:
return "Error setting up input arrays for Mann-Whitney U Test. Skipping "\
... | python | def print_MannWhitneyU(div_calc):
"""
Compute the Mann-Whitney U test for unequal group sample sizes.
"""
try:
x = div_calc.values()[0].values()
y = div_calc.values()[1].values()
except:
return "Error setting up input arrays for Mann-Whitney U Test. Skipping "\
... | [
"def",
"print_MannWhitneyU",
"(",
"div_calc",
")",
":",
"try",
":",
"x",
"=",
"div_calc",
".",
"values",
"(",
")",
"[",
"0",
"]",
".",
"values",
"(",
")",
"y",
"=",
"div_calc",
".",
"values",
"(",
")",
"[",
"1",
"]",
".",
"values",
"(",
")",
"e... | Compute the Mann-Whitney U test for unequal group sample sizes. | [
"Compute",
"the",
"Mann",
"-",
"Whitney",
"U",
"test",
"for",
"unequal",
"group",
"sample",
"sizes",
"."
] | 0b74ef171e6a84761710548501dfac71285a58a3 | https://github.com/smdabdoub/phylotoast/blob/0b74ef171e6a84761710548501dfac71285a58a3/bin/diversity.py#L54-L66 | train |
smdabdoub/phylotoast | bin/diversity.py | print_KruskalWallisH | def print_KruskalWallisH(div_calc):
"""
Compute the Kruskal-Wallis H-test for independent samples. A typical rule is that
each group must have at least 5 measurements.
"""
calc = defaultdict(list)
try:
for k1, v1 in div_calc.iteritems():
for k2, v2 in v1.iteritems():
... | python | def print_KruskalWallisH(div_calc):
"""
Compute the Kruskal-Wallis H-test for independent samples. A typical rule is that
each group must have at least 5 measurements.
"""
calc = defaultdict(list)
try:
for k1, v1 in div_calc.iteritems():
for k2, v2 in v1.iteritems():
... | [
"def",
"print_KruskalWallisH",
"(",
"div_calc",
")",
":",
"calc",
"=",
"defaultdict",
"(",
"list",
")",
"try",
":",
"for",
"k1",
",",
"v1",
"in",
"div_calc",
".",
"iteritems",
"(",
")",
":",
"for",
"k2",
",",
"v2",
"in",
"v1",
".",
"iteritems",
"(",
... | Compute the Kruskal-Wallis H-test for independent samples. A typical rule is that
each group must have at least 5 measurements. | [
"Compute",
"the",
"Kruskal",
"-",
"Wallis",
"H",
"-",
"test",
"for",
"independent",
"samples",
".",
"A",
"typical",
"rule",
"is",
"that",
"each",
"group",
"must",
"have",
"at",
"least",
"5",
"measurements",
"."
] | 0b74ef171e6a84761710548501dfac71285a58a3 | https://github.com/smdabdoub/phylotoast/blob/0b74ef171e6a84761710548501dfac71285a58a3/bin/diversity.py#L69-L84 | train |
smdabdoub/phylotoast | bin/diversity.py | handle_program_options | def handle_program_options():
"""Parses the given options passed in at the command line."""
parser = argparse.ArgumentParser(description="Calculate the alpha diversity\
of a set of samples using one or more \
metrics and output a kernal d... | python | def handle_program_options():
"""Parses the given options passed in at the command line."""
parser = argparse.ArgumentParser(description="Calculate the alpha diversity\
of a set of samples using one or more \
metrics and output a kernal d... | [
"def",
"handle_program_options",
"(",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"\"Calculate the alpha diversity\\ of a set of samples using one or more \\ metrics and output ... | Parses the given options passed in at the command line. | [
"Parses",
"the",
"given",
"options",
"passed",
"in",
"at",
"the",
"command",
"line",
"."
] | 0b74ef171e6a84761710548501dfac71285a58a3 | https://github.com/smdabdoub/phylotoast/blob/0b74ef171e6a84761710548501dfac71285a58a3/bin/diversity.py#L122-L168 | train |
christophertbrown/bioscripts | ctbBio/search.py | blastdb | def blastdb(fasta, maxfile = 10000000):
"""
make blast db
"""
db = fasta.rsplit('.', 1)[0]
type = check_type(fasta)
if type == 'nucl':
type = ['nhr', type]
else:
type = ['phr', type]
if os.path.exists('%s.%s' % (db, type[0])) is False \
and os.path.exists('%s.... | python | def blastdb(fasta, maxfile = 10000000):
"""
make blast db
"""
db = fasta.rsplit('.', 1)[0]
type = check_type(fasta)
if type == 'nucl':
type = ['nhr', type]
else:
type = ['phr', type]
if os.path.exists('%s.%s' % (db, type[0])) is False \
and os.path.exists('%s.... | [
"def",
"blastdb",
"(",
"fasta",
",",
"maxfile",
"=",
"10000000",
")",
":",
"db",
"=",
"fasta",
".",
"rsplit",
"(",
"'.'",
",",
"1",
")",
"[",
"0",
"]",
"type",
"=",
"check_type",
"(",
"fasta",
")",
"if",
"type",
"==",
"'nucl'",
":",
"type",
"=",
... | make blast db | [
"make",
"blast",
"db"
] | 83b2566b3a5745437ec651cd6cafddd056846240 | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/search.py#L28-L46 | train |
christophertbrown/bioscripts | ctbBio/search.py | usearchdb | def usearchdb(fasta, alignment = 'local', usearch_loc = 'usearch'):
"""
make usearch db
"""
if '.udb' in fasta:
print('# ... database found: %s' % (fasta), file=sys.stderr)
return fasta
type = check_type(fasta)
db = '%s.%s.udb' % (fasta.rsplit('.', 1)[0], type)
if os.path.exi... | python | def usearchdb(fasta, alignment = 'local', usearch_loc = 'usearch'):
"""
make usearch db
"""
if '.udb' in fasta:
print('# ... database found: %s' % (fasta), file=sys.stderr)
return fasta
type = check_type(fasta)
db = '%s.%s.udb' % (fasta.rsplit('.', 1)[0], type)
if os.path.exi... | [
"def",
"usearchdb",
"(",
"fasta",
",",
"alignment",
"=",
"'local'",
",",
"usearch_loc",
"=",
"'usearch'",
")",
":",
"if",
"'.udb'",
"in",
"fasta",
":",
"print",
"(",
"'# ... database found: %s'",
"%",
"(",
"fasta",
")",
",",
"file",
"=",
"sys",
".",
"std... | make usearch db | [
"make",
"usearch",
"db"
] | 83b2566b3a5745437ec651cd6cafddd056846240 | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/search.py#L68-L85 | train |
mkouhei/bootstrap-py | bootstrap_py/control.py | _pp | def _pp(dict_data):
"""Pretty print."""
for key, val in dict_data.items():
# pylint: disable=superfluous-parens
print('{0:<11}: {1}'.format(key, val)) | python | def _pp(dict_data):
"""Pretty print."""
for key, val in dict_data.items():
# pylint: disable=superfluous-parens
print('{0:<11}: {1}'.format(key, val)) | [
"def",
"_pp",
"(",
"dict_data",
")",
":",
"for",
"key",
",",
"val",
"in",
"dict_data",
".",
"items",
"(",
")",
":",
"print",
"(",
"'{0:<11}: {1}'",
".",
"format",
"(",
"key",
",",
"val",
")",
")"
] | Pretty print. | [
"Pretty",
"print",
"."
] | 95d56ed98ef409fd9f019dc352fd1c3711533275 | https://github.com/mkouhei/bootstrap-py/blob/95d56ed98ef409fd9f019dc352fd1c3711533275/bootstrap_py/control.py#L11-L15 | train |
mkouhei/bootstrap-py | bootstrap_py/control.py | print_licences | def print_licences(params, metadata):
"""Print licenses.
:param argparse.Namespace params: parameter
:param bootstrap_py.classifier.Classifiers metadata: package metadata
"""
if hasattr(params, 'licenses'):
if params.licenses:
_pp(metadata.licenses_desc())
sys.exit(0) | python | def print_licences(params, metadata):
"""Print licenses.
:param argparse.Namespace params: parameter
:param bootstrap_py.classifier.Classifiers metadata: package metadata
"""
if hasattr(params, 'licenses'):
if params.licenses:
_pp(metadata.licenses_desc())
sys.exit(0) | [
"def",
"print_licences",
"(",
"params",
",",
"metadata",
")",
":",
"if",
"hasattr",
"(",
"params",
",",
"'licenses'",
")",
":",
"if",
"params",
".",
"licenses",
":",
"_pp",
"(",
"metadata",
".",
"licenses_desc",
"(",
")",
")",
"sys",
".",
"exit",
"(",
... | Print licenses.
:param argparse.Namespace params: parameter
:param bootstrap_py.classifier.Classifiers metadata: package metadata | [
"Print",
"licenses",
"."
] | 95d56ed98ef409fd9f019dc352fd1c3711533275 | https://github.com/mkouhei/bootstrap-py/blob/95d56ed98ef409fd9f019dc352fd1c3711533275/bootstrap_py/control.py#L27-L36 | train |
mkouhei/bootstrap-py | bootstrap_py/control.py | check_repository_existence | def check_repository_existence(params):
"""Check repository existence.
:param argparse.Namespace params: parameters
"""
repodir = os.path.join(params.outdir, params.name)
if os.path.isdir(repodir):
raise Conflict(
'Package repository "{0}" has already exists.'.format(repodir)) | python | def check_repository_existence(params):
"""Check repository existence.
:param argparse.Namespace params: parameters
"""
repodir = os.path.join(params.outdir, params.name)
if os.path.isdir(repodir):
raise Conflict(
'Package repository "{0}" has already exists.'.format(repodir)) | [
"def",
"check_repository_existence",
"(",
"params",
")",
":",
"repodir",
"=",
"os",
".",
"path",
".",
"join",
"(",
"params",
".",
"outdir",
",",
"params",
".",
"name",
")",
"if",
"os",
".",
"path",
".",
"isdir",
"(",
"repodir",
")",
":",
"raise",
"Co... | Check repository existence.
:param argparse.Namespace params: parameters | [
"Check",
"repository",
"existence",
"."
] | 95d56ed98ef409fd9f019dc352fd1c3711533275 | https://github.com/mkouhei/bootstrap-py/blob/95d56ed98ef409fd9f019dc352fd1c3711533275/bootstrap_py/control.py#L39-L47 | train |
mkouhei/bootstrap-py | bootstrap_py/control.py | generate_package | def generate_package(params):
"""Generate package repository.
:param argparse.Namespace params: parameters
"""
pkg_data = package.PackageData(params)
pkg_tree = package.PackageTree(pkg_data)
pkg_tree.generate()
pkg_tree.move()
VCS(os.path.join(pkg_tree.outdir, pkg_tree.name), pkg_tree.p... | python | def generate_package(params):
"""Generate package repository.
:param argparse.Namespace params: parameters
"""
pkg_data = package.PackageData(params)
pkg_tree = package.PackageTree(pkg_data)
pkg_tree.generate()
pkg_tree.move()
VCS(os.path.join(pkg_tree.outdir, pkg_tree.name), pkg_tree.p... | [
"def",
"generate_package",
"(",
"params",
")",
":",
"pkg_data",
"=",
"package",
".",
"PackageData",
"(",
"params",
")",
"pkg_tree",
"=",
"package",
".",
"PackageTree",
"(",
"pkg_data",
")",
"pkg_tree",
".",
"generate",
"(",
")",
"pkg_tree",
".",
"move",
"(... | Generate package repository.
:param argparse.Namespace params: parameters | [
"Generate",
"package",
"repository",
"."
] | 95d56ed98ef409fd9f019dc352fd1c3711533275 | https://github.com/mkouhei/bootstrap-py/blob/95d56ed98ef409fd9f019dc352fd1c3711533275/bootstrap_py/control.py#L59-L68 | train |
christophertbrown/bioscripts | ctbBio/sam2fastq.py | print_single | def print_single(line, rev):
"""
print single reads to stderr
"""
if rev is True:
seq = rc(['', line[9]])[1]
qual = line[10][::-1]
else:
seq = line[9]
qual = line[10]
fq = ['@%s' % line[0], seq, '+%s' % line[0], qual]
print('\n'.join(fq), file = sys.stderr) | python | def print_single(line, rev):
"""
print single reads to stderr
"""
if rev is True:
seq = rc(['', line[9]])[1]
qual = line[10][::-1]
else:
seq = line[9]
qual = line[10]
fq = ['@%s' % line[0], seq, '+%s' % line[0], qual]
print('\n'.join(fq), file = sys.stderr) | [
"def",
"print_single",
"(",
"line",
",",
"rev",
")",
":",
"if",
"rev",
"is",
"True",
":",
"seq",
"=",
"rc",
"(",
"[",
"''",
",",
"line",
"[",
"9",
"]",
"]",
")",
"[",
"1",
"]",
"qual",
"=",
"line",
"[",
"10",
"]",
"[",
":",
":",
"-",
"1",... | print single reads to stderr | [
"print",
"single",
"reads",
"to",
"stderr"
] | 83b2566b3a5745437ec651cd6cafddd056846240 | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/sam2fastq.py#L13-L24 | train |
christophertbrown/bioscripts | ctbBio/sam2fastq.py | sam2fastq | def sam2fastq(sam, singles = False, force = False):
"""
convert sam to fastq
"""
L, R = None, None
for line in sam:
if line.startswith('@') is True:
continue
line = line.strip().split()
bit = [True if i == '1' else False \
for i in bin(int(line[1])... | python | def sam2fastq(sam, singles = False, force = False):
"""
convert sam to fastq
"""
L, R = None, None
for line in sam:
if line.startswith('@') is True:
continue
line = line.strip().split()
bit = [True if i == '1' else False \
for i in bin(int(line[1])... | [
"def",
"sam2fastq",
"(",
"sam",
",",
"singles",
"=",
"False",
",",
"force",
"=",
"False",
")",
":",
"L",
",",
"R",
"=",
"None",
",",
"None",
"for",
"line",
"in",
"sam",
":",
"if",
"line",
".",
"startswith",
"(",
"'@'",
")",
"is",
"True",
":",
"... | convert sam to fastq | [
"convert",
"sam",
"to",
"fastq"
] | 83b2566b3a5745437ec651cd6cafddd056846240 | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/sam2fastq.py#L26-L78 | train |
christophertbrown/bioscripts | ctbBio/subset_sam.py | sort_sam | def sort_sam(sam, sort):
"""
sort sam file
"""
tempdir = '%s/' % (os.path.abspath(sam).rsplit('/', 1)[0])
if sort is True:
mapping = '%s.sorted.sam' % (sam.rsplit('.', 1)[0])
if sam != '-':
if os.path.exists(mapping) is False:
os.system("\
... | python | def sort_sam(sam, sort):
"""
sort sam file
"""
tempdir = '%s/' % (os.path.abspath(sam).rsplit('/', 1)[0])
if sort is True:
mapping = '%s.sorted.sam' % (sam.rsplit('.', 1)[0])
if sam != '-':
if os.path.exists(mapping) is False:
os.system("\
... | [
"def",
"sort_sam",
"(",
"sam",
",",
"sort",
")",
":",
"tempdir",
"=",
"'%s/'",
"%",
"(",
"os",
".",
"path",
".",
"abspath",
"(",
"sam",
")",
".",
"rsplit",
"(",
"'/'",
",",
"1",
")",
"[",
"0",
"]",
")",
"if",
"sort",
"is",
"True",
":",
"mappi... | sort sam file | [
"sort",
"sam",
"file"
] | 83b2566b3a5745437ec651cd6cafddd056846240 | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/subset_sam.py#L14-L37 | train |
christophertbrown/bioscripts | ctbBio/subset_sam.py | sub_sam | def sub_sam(sam, percent, sort = True, sbuffer = False):
"""
randomly subset sam file
"""
mapping = sort_sam(sam, sort)
pool = [1 for i in range(0, percent)] + [0 for i in range(0, 100 - percent)]
c = cycle([1, 2])
for line in mapping:
line = line.strip().split()
if line[0].s... | python | def sub_sam(sam, percent, sort = True, sbuffer = False):
"""
randomly subset sam file
"""
mapping = sort_sam(sam, sort)
pool = [1 for i in range(0, percent)] + [0 for i in range(0, 100 - percent)]
c = cycle([1, 2])
for line in mapping:
line = line.strip().split()
if line[0].s... | [
"def",
"sub_sam",
"(",
"sam",
",",
"percent",
",",
"sort",
"=",
"True",
",",
"sbuffer",
"=",
"False",
")",
":",
"mapping",
"=",
"sort_sam",
"(",
"sam",
",",
"sort",
")",
"pool",
"=",
"[",
"1",
"for",
"i",
"in",
"range",
"(",
"0",
",",
"percent",
... | randomly subset sam file | [
"randomly",
"subset",
"sam",
"file"
] | 83b2566b3a5745437ec651cd6cafddd056846240 | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/subset_sam.py#L39-L60 | train |
christophertbrown/bioscripts | ctbBio/fastq2fasta.py | fq2fa | def fq2fa(fq):
"""
convert fq to fa
"""
c = cycle([1, 2, 3, 4])
for line in fq:
n = next(c)
if n == 1:
seq = ['>%s' % (line.strip().split('@', 1)[1])]
if n == 2:
seq.append(line.strip())
yield seq | python | def fq2fa(fq):
"""
convert fq to fa
"""
c = cycle([1, 2, 3, 4])
for line in fq:
n = next(c)
if n == 1:
seq = ['>%s' % (line.strip().split('@', 1)[1])]
if n == 2:
seq.append(line.strip())
yield seq | [
"def",
"fq2fa",
"(",
"fq",
")",
":",
"c",
"=",
"cycle",
"(",
"[",
"1",
",",
"2",
",",
"3",
",",
"4",
"]",
")",
"for",
"line",
"in",
"fq",
":",
"n",
"=",
"next",
"(",
"c",
")",
"if",
"n",
"==",
"1",
":",
"seq",
"=",
"[",
"'>%s'",
"%",
... | convert fq to fa | [
"convert",
"fq",
"to",
"fa"
] | 83b2566b3a5745437ec651cd6cafddd056846240 | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/fastq2fasta.py#L11-L22 | train |
elbow-jason/Uno-deprecated | uno/decorators.py | change_return_type | def change_return_type(f):
"""
Converts the returned value of wrapped function to the type of the
first arg or to the type specified by a kwarg key return_type's value.
"""
@wraps(f)
def wrapper(*args, **kwargs):
if kwargs.has_key('return_type'):
return_type = kwargs['return_... | python | def change_return_type(f):
"""
Converts the returned value of wrapped function to the type of the
first arg or to the type specified by a kwarg key return_type's value.
"""
@wraps(f)
def wrapper(*args, **kwargs):
if kwargs.has_key('return_type'):
return_type = kwargs['return_... | [
"def",
"change_return_type",
"(",
"f",
")",
":",
"@",
"wraps",
"(",
"f",
")",
"def",
"wrapper",
"(",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"if",
"kwargs",
".",
"has_key",
"(",
"'return_type'",
")",
":",
"return_type",
"=",
"kwargs",
"[",
"'retu... | Converts the returned value of wrapped function to the type of the
first arg or to the type specified by a kwarg key return_type's value. | [
"Converts",
"the",
"returned",
"value",
"of",
"wrapped",
"function",
"to",
"the",
"type",
"of",
"the",
"first",
"arg",
"or",
"to",
"the",
"type",
"specified",
"by",
"a",
"kwarg",
"key",
"return_type",
"s",
"value",
"."
] | 4ad07d7b84e5b6e3e2b2c89db69448906f24b4e4 | https://github.com/elbow-jason/Uno-deprecated/blob/4ad07d7b84e5b6e3e2b2c89db69448906f24b4e4/uno/decorators.py#L11-L27 | train |
elbow-jason/Uno-deprecated | uno/decorators.py | convert_args_to_sets | def convert_args_to_sets(f):
"""
Converts all args to 'set' type via self.setify function.
"""
@wraps(f)
def wrapper(*args, **kwargs):
args = (setify(x) for x in args)
return f(*args, **kwargs)
return wrapper | python | def convert_args_to_sets(f):
"""
Converts all args to 'set' type via self.setify function.
"""
@wraps(f)
def wrapper(*args, **kwargs):
args = (setify(x) for x in args)
return f(*args, **kwargs)
return wrapper | [
"def",
"convert_args_to_sets",
"(",
"f",
")",
":",
"@",
"wraps",
"(",
"f",
")",
"def",
"wrapper",
"(",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"args",
"=",
"(",
"setify",
"(",
"x",
")",
"for",
"x",
"in",
"args",
")",
"return",
"f",
"(",
"*"... | Converts all args to 'set' type via self.setify function. | [
"Converts",
"all",
"args",
"to",
"set",
"type",
"via",
"self",
".",
"setify",
"function",
"."
] | 4ad07d7b84e5b6e3e2b2c89db69448906f24b4e4 | https://github.com/elbow-jason/Uno-deprecated/blob/4ad07d7b84e5b6e3e2b2c89db69448906f24b4e4/uno/decorators.py#L30-L38 | train |
laymonage/kbbi-python | kbbi/kbbi.py | KBBI._init_entri | def _init_entri(self, laman):
"""Membuat objek-objek entri dari laman yang diambil.
:param laman: Laman respons yang dikembalikan oleh KBBI daring.
:type laman: Response
"""
sup = BeautifulSoup(laman.text, 'html.parser')
estr = ''
for label in sup.find('hr').nex... | python | def _init_entri(self, laman):
"""Membuat objek-objek entri dari laman yang diambil.
:param laman: Laman respons yang dikembalikan oleh KBBI daring.
:type laman: Response
"""
sup = BeautifulSoup(laman.text, 'html.parser')
estr = ''
for label in sup.find('hr').nex... | [
"def",
"_init_entri",
"(",
"self",
",",
"laman",
")",
":",
"sup",
"=",
"BeautifulSoup",
"(",
"laman",
".",
"text",
",",
"'html.parser'",
")",
"estr",
"=",
"''",
"for",
"label",
"in",
"sup",
".",
"find",
"(",
"'hr'",
")",
".",
"next_siblings",
":",
"i... | Membuat objek-objek entri dari laman yang diambil.
:param laman: Laman respons yang dikembalikan oleh KBBI daring.
:type laman: Response | [
"Membuat",
"objek",
"-",
"objek",
"entri",
"dari",
"laman",
"yang",
"diambil",
"."
] | 1a52ba8bcc6dc4c5c1215f9e00207aca264287d6 | https://github.com/laymonage/kbbi-python/blob/1a52ba8bcc6dc4c5c1215f9e00207aca264287d6/kbbi/kbbi.py#L46-L63 | train |
laymonage/kbbi-python | kbbi/kbbi.py | Entri._init_kata_dasar | def _init_kata_dasar(self, dasar):
"""Memproses kata dasar yang ada dalam nama entri.
:param dasar: ResultSet untuk label HTML dengan class="rootword"
:type dasar: ResultSet
"""
for tiap in dasar:
kata = tiap.find('a')
dasar_no = kata.find('sup')
... | python | def _init_kata_dasar(self, dasar):
"""Memproses kata dasar yang ada dalam nama entri.
:param dasar: ResultSet untuk label HTML dengan class="rootword"
:type dasar: ResultSet
"""
for tiap in dasar:
kata = tiap.find('a')
dasar_no = kata.find('sup')
... | [
"def",
"_init_kata_dasar",
"(",
"self",
",",
"dasar",
")",
":",
"for",
"tiap",
"in",
"dasar",
":",
"kata",
"=",
"tiap",
".",
"find",
"(",
"'a'",
")",
"dasar_no",
"=",
"kata",
".",
"find",
"(",
"'sup'",
")",
"kata",
"=",
"ambil_teks_dalam_label",
"(",
... | Memproses kata dasar yang ada dalam nama entri.
:param dasar: ResultSet untuk label HTML dengan class="rootword"
:type dasar: ResultSet | [
"Memproses",
"kata",
"dasar",
"yang",
"ada",
"dalam",
"nama",
"entri",
"."
] | 1a52ba8bcc6dc4c5c1215f9e00207aca264287d6 | https://github.com/laymonage/kbbi-python/blob/1a52ba8bcc6dc4c5c1215f9e00207aca264287d6/kbbi/kbbi.py#L126-L139 | train |
laymonage/kbbi-python | kbbi/kbbi.py | Entri.serialisasi | def serialisasi(self):
"""Mengembalikan hasil serialisasi objek Entri ini.
:returns: Dictionary hasil serialisasi
:rtype: dict
"""
return {
"nama": self.nama,
"nomor": self.nomor,
"kata_dasar": self.kata_dasar,
"pelafalan": self.p... | python | def serialisasi(self):
"""Mengembalikan hasil serialisasi objek Entri ini.
:returns: Dictionary hasil serialisasi
:rtype: dict
"""
return {
"nama": self.nama,
"nomor": self.nomor,
"kata_dasar": self.kata_dasar,
"pelafalan": self.p... | [
"def",
"serialisasi",
"(",
"self",
")",
":",
"return",
"{",
"\"nama\"",
":",
"self",
".",
"nama",
",",
"\"nomor\"",
":",
"self",
".",
"nomor",
",",
"\"kata_dasar\"",
":",
"self",
".",
"kata_dasar",
",",
"\"pelafalan\"",
":",
"self",
".",
"pelafalan",
","... | Mengembalikan hasil serialisasi objek Entri ini.
:returns: Dictionary hasil serialisasi
:rtype: dict | [
"Mengembalikan",
"hasil",
"serialisasi",
"objek",
"Entri",
"ini",
"."
] | 1a52ba8bcc6dc4c5c1215f9e00207aca264287d6 | https://github.com/laymonage/kbbi-python/blob/1a52ba8bcc6dc4c5c1215f9e00207aca264287d6/kbbi/kbbi.py#L141-L156 | train |
laymonage/kbbi-python | kbbi/kbbi.py | Entri._makna | def _makna(self):
"""Mengembalikan representasi string untuk semua makna entri ini.
:returns: String representasi makna-makna
:rtype: str
"""
if len(self.makna) > 1:
return '\n'.join(
str(i) + ". " + str(makna)
for i, makna in enumera... | python | def _makna(self):
"""Mengembalikan representasi string untuk semua makna entri ini.
:returns: String representasi makna-makna
:rtype: str
"""
if len(self.makna) > 1:
return '\n'.join(
str(i) + ". " + str(makna)
for i, makna in enumera... | [
"def",
"_makna",
"(",
"self",
")",
":",
"if",
"len",
"(",
"self",
".",
"makna",
")",
">",
"1",
":",
"return",
"'\\n'",
".",
"join",
"(",
"str",
"(",
"i",
")",
"+",
"\". \"",
"+",
"str",
"(",
"makna",
")",
"for",
"i",
",",
"makna",
"in",
"enum... | Mengembalikan representasi string untuk semua makna entri ini.
:returns: String representasi makna-makna
:rtype: str | [
"Mengembalikan",
"representasi",
"string",
"untuk",
"semua",
"makna",
"entri",
"ini",
"."
] | 1a52ba8bcc6dc4c5c1215f9e00207aca264287d6 | https://github.com/laymonage/kbbi-python/blob/1a52ba8bcc6dc4c5c1215f9e00207aca264287d6/kbbi/kbbi.py#L158-L170 | train |
laymonage/kbbi-python | kbbi/kbbi.py | Entri._nama | def _nama(self):
"""Mengembalikan representasi string untuk nama entri ini.
:returns: String representasi nama entri
:rtype: str
"""
hasil = self.nama
if self.nomor:
hasil += " [{}]".format(self.nomor)
if self.kata_dasar:
hasil = " » ".jo... | python | def _nama(self):
"""Mengembalikan representasi string untuk nama entri ini.
:returns: String representasi nama entri
:rtype: str
"""
hasil = self.nama
if self.nomor:
hasil += " [{}]".format(self.nomor)
if self.kata_dasar:
hasil = " » ".jo... | [
"def",
"_nama",
"(",
"self",
")",
":",
"hasil",
"=",
"self",
".",
"nama",
"if",
"self",
".",
"nomor",
":",
"hasil",
"+=",
"\" [{}]\"",
".",
"format",
"(",
"self",
".",
"nomor",
")",
"if",
"self",
".",
"kata_dasar",
":",
"hasil",
"=",
"\" » \".",
"j... | Mengembalikan representasi string untuk nama entri ini.
:returns: String representasi nama entri
:rtype: str | [
"Mengembalikan",
"representasi",
"string",
"untuk",
"nama",
"entri",
"ini",
"."
] | 1a52ba8bcc6dc4c5c1215f9e00207aca264287d6 | https://github.com/laymonage/kbbi-python/blob/1a52ba8bcc6dc4c5c1215f9e00207aca264287d6/kbbi/kbbi.py#L172-L184 | train |
laymonage/kbbi-python | kbbi/kbbi.py | Entri._varian | def _varian(self, varian):
"""Mengembalikan representasi string untuk varian entri ini.
Dapat digunakan untuk "Varian" maupun "Bentuk tidak baku".
:param varian: List bentuk tidak baku atau varian
:type varian: list
:returns: String representasi varian atau bentuk tidak baku
... | python | def _varian(self, varian):
"""Mengembalikan representasi string untuk varian entri ini.
Dapat digunakan untuk "Varian" maupun "Bentuk tidak baku".
:param varian: List bentuk tidak baku atau varian
:type varian: list
:returns: String representasi varian atau bentuk tidak baku
... | [
"def",
"_varian",
"(",
"self",
",",
"varian",
")",
":",
"if",
"varian",
"==",
"self",
".",
"bentuk_tidak_baku",
":",
"nama",
"=",
"\"Bentuk tidak baku\"",
"elif",
"varian",
"==",
"self",
".",
"varian",
":",
"nama",
"=",
"\"Varian\"",
"else",
":",
"return",... | Mengembalikan representasi string untuk varian entri ini.
Dapat digunakan untuk "Varian" maupun "Bentuk tidak baku".
:param varian: List bentuk tidak baku atau varian
:type varian: list
:returns: String representasi varian atau bentuk tidak baku
:rtype: str | [
"Mengembalikan",
"representasi",
"string",
"untuk",
"varian",
"entri",
"ini",
".",
"Dapat",
"digunakan",
"untuk",
"Varian",
"maupun",
"Bentuk",
"tidak",
"baku",
"."
] | 1a52ba8bcc6dc4c5c1215f9e00207aca264287d6 | https://github.com/laymonage/kbbi-python/blob/1a52ba8bcc6dc4c5c1215f9e00207aca264287d6/kbbi/kbbi.py#L186-L202 | train |
laymonage/kbbi-python | kbbi/kbbi.py | Makna._init_kelas | def _init_kelas(self, makna_label):
"""Memproses kelas kata yang ada dalam makna.
:param makna_label: BeautifulSoup untuk makna yang ingin diproses.
:type makna_label: BeautifulSoup
"""
kelas = makna_label.find(color='red')
lain = makna_label.find(color='darkgreen')
... | python | def _init_kelas(self, makna_label):
"""Memproses kelas kata yang ada dalam makna.
:param makna_label: BeautifulSoup untuk makna yang ingin diproses.
:type makna_label: BeautifulSoup
"""
kelas = makna_label.find(color='red')
lain = makna_label.find(color='darkgreen')
... | [
"def",
"_init_kelas",
"(",
"self",
",",
"makna_label",
")",
":",
"kelas",
"=",
"makna_label",
".",
"find",
"(",
"color",
"=",
"'red'",
")",
"lain",
"=",
"makna_label",
".",
"find",
"(",
"color",
"=",
"'darkgreen'",
")",
"info",
"=",
"makna_label",
".",
... | Memproses kelas kata yang ada dalam makna.
:param makna_label: BeautifulSoup untuk makna yang ingin diproses.
:type makna_label: BeautifulSoup | [
"Memproses",
"kelas",
"kata",
"yang",
"ada",
"dalam",
"makna",
"."
] | 1a52ba8bcc6dc4c5c1215f9e00207aca264287d6 | https://github.com/laymonage/kbbi-python/blob/1a52ba8bcc6dc4c5c1215f9e00207aca264287d6/kbbi/kbbi.py#L239-L259 | train |
laymonage/kbbi-python | kbbi/kbbi.py | Makna._init_contoh | def _init_contoh(self, makna_label):
"""Memproses contoh yang ada dalam makna.
:param makna_label: BeautifulSoup untuk makna yang ingin diproses.
:type makna_label: BeautifulSoup
"""
indeks = makna_label.text.find(': ')
if indeks != -1:
contoh = makna_label.... | python | def _init_contoh(self, makna_label):
"""Memproses contoh yang ada dalam makna.
:param makna_label: BeautifulSoup untuk makna yang ingin diproses.
:type makna_label: BeautifulSoup
"""
indeks = makna_label.text.find(': ')
if indeks != -1:
contoh = makna_label.... | [
"def",
"_init_contoh",
"(",
"self",
",",
"makna_label",
")",
":",
"indeks",
"=",
"makna_label",
".",
"text",
".",
"find",
"(",
"': '",
")",
"if",
"indeks",
"!=",
"-",
"1",
":",
"contoh",
"=",
"makna_label",
".",
"text",
"[",
"indeks",
"+",
"2",
":",
... | Memproses contoh yang ada dalam makna.
:param makna_label: BeautifulSoup untuk makna yang ingin diproses.
:type makna_label: BeautifulSoup | [
"Memproses",
"contoh",
"yang",
"ada",
"dalam",
"makna",
"."
] | 1a52ba8bcc6dc4c5c1215f9e00207aca264287d6 | https://github.com/laymonage/kbbi-python/blob/1a52ba8bcc6dc4c5c1215f9e00207aca264287d6/kbbi/kbbi.py#L261-L273 | train |
laymonage/kbbi-python | kbbi/kbbi.py | Makna.serialisasi | def serialisasi(self):
"""Mengembalikan hasil serialisasi objek Makna ini.
:returns: Dictionary hasil serialisasi
:rtype: dict
"""
return {
"kelas": self.kelas,
"submakna": self.submakna,
"info": self.info,
"contoh": self.contoh
... | python | def serialisasi(self):
"""Mengembalikan hasil serialisasi objek Makna ini.
:returns: Dictionary hasil serialisasi
:rtype: dict
"""
return {
"kelas": self.kelas,
"submakna": self.submakna,
"info": self.info,
"contoh": self.contoh
... | [
"def",
"serialisasi",
"(",
"self",
")",
":",
"return",
"{",
"\"kelas\"",
":",
"self",
".",
"kelas",
",",
"\"submakna\"",
":",
"self",
".",
"submakna",
",",
"\"info\"",
":",
"self",
".",
"info",
",",
"\"contoh\"",
":",
"self",
".",
"contoh",
"}"
] | Mengembalikan hasil serialisasi objek Makna ini.
:returns: Dictionary hasil serialisasi
:rtype: dict | [
"Mengembalikan",
"hasil",
"serialisasi",
"objek",
"Makna",
"ini",
"."
] | 1a52ba8bcc6dc4c5c1215f9e00207aca264287d6 | https://github.com/laymonage/kbbi-python/blob/1a52ba8bcc6dc4c5c1215f9e00207aca264287d6/kbbi/kbbi.py#L275-L287 | train |
mkouhei/bootstrap-py | bootstrap_py/docs.py | build_sphinx | def build_sphinx(pkg_data, projectdir):
"""Build sphinx documentation.
:rtype: int
:return: subprocess.call return code
:param `bootstrap_py.control.PackageData` pkg_data: package meta data
:param str projectdir: project root directory
"""
try:
version, _minor_version = pkg_data.ve... | python | def build_sphinx(pkg_data, projectdir):
"""Build sphinx documentation.
:rtype: int
:return: subprocess.call return code
:param `bootstrap_py.control.PackageData` pkg_data: package meta data
:param str projectdir: project root directory
"""
try:
version, _minor_version = pkg_data.ve... | [
"def",
"build_sphinx",
"(",
"pkg_data",
",",
"projectdir",
")",
":",
"try",
":",
"version",
",",
"_minor_version",
"=",
"pkg_data",
".",
"version",
".",
"rsplit",
"(",
"'.'",
",",
"1",
")",
"except",
"ValueError",
":",
"version",
"=",
"pkg_data",
".",
"v... | Build sphinx documentation.
:rtype: int
:return: subprocess.call return code
:param `bootstrap_py.control.PackageData` pkg_data: package meta data
:param str projectdir: project root directory | [
"Build",
"sphinx",
"documentation",
"."
] | 95d56ed98ef409fd9f019dc352fd1c3711533275 | https://github.com/mkouhei/bootstrap-py/blob/95d56ed98ef409fd9f019dc352fd1c3711533275/bootstrap_py/docs.py#L8-L40 | train |
christophertbrown/bioscripts | ctbBio/crossmap.py | bowtiedb | def bowtiedb(fa, keepDB):
"""
make bowtie db
"""
btdir = '%s/bt2' % (os.getcwd())
# make directory for
if not os.path.exists(btdir):
os.mkdir(btdir)
btdb = '%s/%s' % (btdir, fa.rsplit('/', 1)[-1])
if keepDB is True:
if os.path.exists('%s.1.bt2' % (btdb)):
retu... | python | def bowtiedb(fa, keepDB):
"""
make bowtie db
"""
btdir = '%s/bt2' % (os.getcwd())
# make directory for
if not os.path.exists(btdir):
os.mkdir(btdir)
btdb = '%s/%s' % (btdir, fa.rsplit('/', 1)[-1])
if keepDB is True:
if os.path.exists('%s.1.bt2' % (btdb)):
retu... | [
"def",
"bowtiedb",
"(",
"fa",
",",
"keepDB",
")",
":",
"btdir",
"=",
"'%s/bt2'",
"%",
"(",
"os",
".",
"getcwd",
"(",
")",
")",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"btdir",
")",
":",
"os",
".",
"mkdir",
"(",
"btdir",
")",
"btdb",... | make bowtie db | [
"make",
"bowtie",
"db"
] | 83b2566b3a5745437ec651cd6cafddd056846240 | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/crossmap.py#L16-L31 | train |
christophertbrown/bioscripts | ctbBio/crossmap.py | bowtie | def bowtie(sam, btd, f, r, u, opt, no_shrink, threads):
"""
generate bowtie2 command
"""
bt2 = 'bowtie2 -x %s -p %s ' % (btd, threads)
if f is not False:
bt2 += '-1 %s -2 %s ' % (f, r)
if u is not False:
bt2 += '-U %s ' % (u)
bt2 += opt
if no_shrink is False:
if f... | python | def bowtie(sam, btd, f, r, u, opt, no_shrink, threads):
"""
generate bowtie2 command
"""
bt2 = 'bowtie2 -x %s -p %s ' % (btd, threads)
if f is not False:
bt2 += '-1 %s -2 %s ' % (f, r)
if u is not False:
bt2 += '-U %s ' % (u)
bt2 += opt
if no_shrink is False:
if f... | [
"def",
"bowtie",
"(",
"sam",
",",
"btd",
",",
"f",
",",
"r",
",",
"u",
",",
"opt",
",",
"no_shrink",
",",
"threads",
")",
":",
"bt2",
"=",
"'bowtie2 -x %s -p %s '",
"%",
"(",
"btd",
",",
"threads",
")",
"if",
"f",
"is",
"not",
"False",
":",
"bt2"... | generate bowtie2 command | [
"generate",
"bowtie2",
"command"
] | 83b2566b3a5745437ec651cd6cafddd056846240 | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/crossmap.py#L33-L50 | train |
christophertbrown/bioscripts | ctbBio/crossmap.py | crossmap | def crossmap(fas, reads, options, no_shrink, keepDB, threads, cluster, nodes):
"""
map all read sets against all fasta files
"""
if cluster is True:
threads = '48'
btc = []
for fa in fas:
btd = bowtiedb(fa, keepDB)
F, R, U = reads
if F is not False:
if... | python | def crossmap(fas, reads, options, no_shrink, keepDB, threads, cluster, nodes):
"""
map all read sets against all fasta files
"""
if cluster is True:
threads = '48'
btc = []
for fa in fas:
btd = bowtiedb(fa, keepDB)
F, R, U = reads
if F is not False:
if... | [
"def",
"crossmap",
"(",
"fas",
",",
"reads",
",",
"options",
",",
"no_shrink",
",",
"keepDB",
",",
"threads",
",",
"cluster",
",",
"nodes",
")",
":",
"if",
"cluster",
"is",
"True",
":",
"threads",
"=",
"'48'",
"btc",
"=",
"[",
"]",
"for",
"fa",
"in... | map all read sets against all fasta files | [
"map",
"all",
"read",
"sets",
"against",
"all",
"fasta",
"files"
] | 83b2566b3a5745437ec651cd6cafddd056846240 | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/crossmap.py#L55-L96 | train |
disqus/nydus | nydus/db/base.py | BaseCluster.get_conn | def get_conn(self, *args, **kwargs):
"""
Returns a connection object from the router given ``args``.
Useful in cases where a connection cannot be automatically determined
during all steps of the process. An example of this would be
Redis pipelines.
"""
connection... | python | def get_conn(self, *args, **kwargs):
"""
Returns a connection object from the router given ``args``.
Useful in cases where a connection cannot be automatically determined
during all steps of the process. An example of this would be
Redis pipelines.
"""
connection... | [
"def",
"get_conn",
"(",
"self",
",",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"connections",
"=",
"self",
".",
"__connections_for",
"(",
"'get_conn'",
",",
"args",
"=",
"args",
",",
"kwargs",
"=",
"kwargs",
")",
"if",
"len",
"(",
"connections",
")",... | Returns a connection object from the router given ``args``.
Useful in cases where a connection cannot be automatically determined
during all steps of the process. An example of this would be
Redis pipelines. | [
"Returns",
"a",
"connection",
"object",
"from",
"the",
"router",
"given",
"args",
"."
] | 9b505840da47a34f758a830c3992fa5dcb7bb7ad | https://github.com/disqus/nydus/blob/9b505840da47a34f758a830c3992fa5dcb7bb7ad/nydus/db/base.py#L100-L113 | train |
scottrice/pysteam | pysteam/_crc_algorithms.py | Crc.__get_nondirect_init | def __get_nondirect_init(self, init):
"""
return the non-direct init if the direct algorithm has been selected.
"""
crc = init
for i in range(self.Width):
bit = crc & 0x01
if bit:
crc^= self.Poly
crc >>= 1
if bit:
... | python | def __get_nondirect_init(self, init):
"""
return the non-direct init if the direct algorithm has been selected.
"""
crc = init
for i in range(self.Width):
bit = crc & 0x01
if bit:
crc^= self.Poly
crc >>= 1
if bit:
... | [
"def",
"__get_nondirect_init",
"(",
"self",
",",
"init",
")",
":",
"crc",
"=",
"init",
"for",
"i",
"in",
"range",
"(",
"self",
".",
"Width",
")",
":",
"bit",
"=",
"crc",
"&",
"0x01",
"if",
"bit",
":",
"crc",
"^=",
"self",
".",
"Poly",
"crc",
">>=... | return the non-direct init if the direct algorithm has been selected. | [
"return",
"the",
"non",
"-",
"direct",
"init",
"if",
"the",
"direct",
"algorithm",
"has",
"been",
"selected",
"."
] | 1eb2254b5235a053a953e596fa7602d0b110245d | https://github.com/scottrice/pysteam/blob/1eb2254b5235a053a953e596fa7602d0b110245d/pysteam/_crc_algorithms.py#L98-L110 | train |
scottrice/pysteam | pysteam/_crc_algorithms.py | Crc.reflect | def reflect(self, data, width):
"""
reflect a data word, i.e. reverts the bit order.
"""
x = data & 0x01
for i in range(width - 1):
data >>= 1
x = (x << 1) | (data & 0x01)
return x | python | def reflect(self, data, width):
"""
reflect a data word, i.e. reverts the bit order.
"""
x = data & 0x01
for i in range(width - 1):
data >>= 1
x = (x << 1) | (data & 0x01)
return x | [
"def",
"reflect",
"(",
"self",
",",
"data",
",",
"width",
")",
":",
"x",
"=",
"data",
"&",
"0x01",
"for",
"i",
"in",
"range",
"(",
"width",
"-",
"1",
")",
":",
"data",
">>=",
"1",
"x",
"=",
"(",
"x",
"<<",
"1",
")",
"|",
"(",
"data",
"&",
... | reflect a data word, i.e. reverts the bit order. | [
"reflect",
"a",
"data",
"word",
"i",
".",
"e",
".",
"reverts",
"the",
"bit",
"order",
"."
] | 1eb2254b5235a053a953e596fa7602d0b110245d | https://github.com/scottrice/pysteam/blob/1eb2254b5235a053a953e596fa7602d0b110245d/pysteam/_crc_algorithms.py#L115-L123 | train |
scottrice/pysteam | pysteam/_crc_algorithms.py | Crc.bit_by_bit | def bit_by_bit(self, in_data):
"""
Classic simple and slow CRC implementation. This function iterates bit
by bit over the augmented input message and returns the calculated CRC
value at the end.
"""
# If the input data is a string, convert to bytes.
if isinstance... | python | def bit_by_bit(self, in_data):
"""
Classic simple and slow CRC implementation. This function iterates bit
by bit over the augmented input message and returns the calculated CRC
value at the end.
"""
# If the input data is a string, convert to bytes.
if isinstance... | [
"def",
"bit_by_bit",
"(",
"self",
",",
"in_data",
")",
":",
"if",
"isinstance",
"(",
"in_data",
",",
"str",
")",
":",
"in_data",
"=",
"[",
"ord",
"(",
"c",
")",
"for",
"c",
"in",
"in_data",
"]",
"register",
"=",
"self",
".",
"NonDirectInit",
"for",
... | Classic simple and slow CRC implementation. This function iterates bit
by bit over the augmented input message and returns the calculated CRC
value at the end. | [
"Classic",
"simple",
"and",
"slow",
"CRC",
"implementation",
".",
"This",
"function",
"iterates",
"bit",
"by",
"bit",
"over",
"the",
"augmented",
"input",
"message",
"and",
"returns",
"the",
"calculated",
"CRC",
"value",
"at",
"the",
"end",
"."
] | 1eb2254b5235a053a953e596fa7602d0b110245d | https://github.com/scottrice/pysteam/blob/1eb2254b5235a053a953e596fa7602d0b110245d/pysteam/_crc_algorithms.py#L128-L156 | train |
scottrice/pysteam | pysteam/_crc_algorithms.py | Crc.gen_table | def gen_table(self):
"""
This function generates the CRC table used for the table_driven CRC
algorithm. The Python version cannot handle tables of an index width
other than 8. See the generated C code for tables with different sizes
instead.
"""
table_length = 1... | python | def gen_table(self):
"""
This function generates the CRC table used for the table_driven CRC
algorithm. The Python version cannot handle tables of an index width
other than 8. See the generated C code for tables with different sizes
instead.
"""
table_length = 1... | [
"def",
"gen_table",
"(",
"self",
")",
":",
"table_length",
"=",
"1",
"<<",
"self",
".",
"TableIdxWidth",
"tbl",
"=",
"[",
"0",
"]",
"*",
"table_length",
"for",
"i",
"in",
"range",
"(",
"table_length",
")",
":",
"register",
"=",
"i",
"if",
"self",
"."... | This function generates the CRC table used for the table_driven CRC
algorithm. The Python version cannot handle tables of an index width
other than 8. See the generated C code for tables with different sizes
instead. | [
"This",
"function",
"generates",
"the",
"CRC",
"table",
"used",
"for",
"the",
"table_driven",
"CRC",
"algorithm",
".",
"The",
"Python",
"version",
"cannot",
"handle",
"tables",
"of",
"an",
"index",
"width",
"other",
"than",
"8",
".",
"See",
"the",
"generated... | 1eb2254b5235a053a953e596fa7602d0b110245d | https://github.com/scottrice/pysteam/blob/1eb2254b5235a053a953e596fa7602d0b110245d/pysteam/_crc_algorithms.py#L190-L212 | train |
scottrice/pysteam | pysteam/_crc_algorithms.py | Crc.table_driven | def table_driven(self, in_data):
"""
The Standard table_driven CRC algorithm.
"""
# If the input data is a string, convert to bytes.
if isinstance(in_data, str):
in_data = [ord(c) for c in in_data]
tbl = self.gen_table()
register = self.DirectInit <<... | python | def table_driven(self, in_data):
"""
The Standard table_driven CRC algorithm.
"""
# If the input data is a string, convert to bytes.
if isinstance(in_data, str):
in_data = [ord(c) for c in in_data]
tbl = self.gen_table()
register = self.DirectInit <<... | [
"def",
"table_driven",
"(",
"self",
",",
"in_data",
")",
":",
"if",
"isinstance",
"(",
"in_data",
",",
"str",
")",
":",
"in_data",
"=",
"[",
"ord",
"(",
"c",
")",
"for",
"c",
"in",
"in_data",
"]",
"tbl",
"=",
"self",
".",
"gen_table",
"(",
")",
"... | The Standard table_driven CRC algorithm. | [
"The",
"Standard",
"table_driven",
"CRC",
"algorithm",
"."
] | 1eb2254b5235a053a953e596fa7602d0b110245d | https://github.com/scottrice/pysteam/blob/1eb2254b5235a053a953e596fa7602d0b110245d/pysteam/_crc_algorithms.py#L217-L242 | train |
christophertbrown/bioscripts | ctbBio/strip_masked.py | parse_masked | def parse_masked(seq, min_len):
"""
parse masked sequence into non-masked and masked regions
"""
nm, masked = [], [[]]
prev = None
for base in seq[1]:
if base.isupper():
nm.append(base)
if masked != [[]] and len(masked[-1]) < min_len:
nm.extend(mas... | python | def parse_masked(seq, min_len):
"""
parse masked sequence into non-masked and masked regions
"""
nm, masked = [], [[]]
prev = None
for base in seq[1]:
if base.isupper():
nm.append(base)
if masked != [[]] and len(masked[-1]) < min_len:
nm.extend(mas... | [
"def",
"parse_masked",
"(",
"seq",
",",
"min_len",
")",
":",
"nm",
",",
"masked",
"=",
"[",
"]",
",",
"[",
"[",
"]",
"]",
"prev",
"=",
"None",
"for",
"base",
"in",
"seq",
"[",
"1",
"]",
":",
"if",
"base",
".",
"isupper",
"(",
")",
":",
"nm",
... | parse masked sequence into non-masked and masked regions | [
"parse",
"masked",
"sequence",
"into",
"non",
"-",
"masked",
"and",
"masked",
"regions"
] | 83b2566b3a5745437ec651cd6cafddd056846240 | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/strip_masked.py#L13-L31 | train |
christophertbrown/bioscripts | ctbBio/strip_masked.py | strip_masked | def strip_masked(fasta, min_len, print_masked):
"""
remove masked regions from fasta file as long as
they are longer than min_len
"""
for seq in parse_fasta(fasta):
nm, masked = parse_masked(seq, min_len)
nm = ['%s removed_masked >=%s' % (seq[0], min_len), ''.join(nm)]
yield ... | python | def strip_masked(fasta, min_len, print_masked):
"""
remove masked regions from fasta file as long as
they are longer than min_len
"""
for seq in parse_fasta(fasta):
nm, masked = parse_masked(seq, min_len)
nm = ['%s removed_masked >=%s' % (seq[0], min_len), ''.join(nm)]
yield ... | [
"def",
"strip_masked",
"(",
"fasta",
",",
"min_len",
",",
"print_masked",
")",
":",
"for",
"seq",
"in",
"parse_fasta",
"(",
"fasta",
")",
":",
"nm",
",",
"masked",
"=",
"parse_masked",
"(",
"seq",
",",
"min_len",
")",
"nm",
"=",
"[",
"'%s removed_masked ... | remove masked regions from fasta file as long as
they are longer than min_len | [
"remove",
"masked",
"regions",
"from",
"fasta",
"file",
"as",
"long",
"as",
"they",
"are",
"longer",
"than",
"min_len"
] | 83b2566b3a5745437ec651cd6cafddd056846240 | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/strip_masked.py#L33-L45 | train |
smdabdoub/phylotoast | bin/network_plots_gephi.py | get_relative_abundance | def get_relative_abundance(biomfile):
"""
Return arcsine transformed relative abundance from a BIOM format file.
:type biomfile: BIOM format file
:param biomfile: BIOM format file used to obtain relative abundances for each OTU in
a SampleID, which are used as node sizes in network... | python | def get_relative_abundance(biomfile):
"""
Return arcsine transformed relative abundance from a BIOM format file.
:type biomfile: BIOM format file
:param biomfile: BIOM format file used to obtain relative abundances for each OTU in
a SampleID, which are used as node sizes in network... | [
"def",
"get_relative_abundance",
"(",
"biomfile",
")",
":",
"biomf",
"=",
"biom",
".",
"load_table",
"(",
"biomfile",
")",
"norm_biomf",
"=",
"biomf",
".",
"norm",
"(",
"inplace",
"=",
"False",
")",
"rel_abd",
"=",
"{",
"}",
"for",
"sid",
"in",
"norm_bio... | Return arcsine transformed relative abundance from a BIOM format file.
:type biomfile: BIOM format file
:param biomfile: BIOM format file used to obtain relative abundances for each OTU in
a SampleID, which are used as node sizes in network plots.
:type return: Dictionary of dictionar... | [
"Return",
"arcsine",
"transformed",
"relative",
"abundance",
"from",
"a",
"BIOM",
"format",
"file",
"."
] | 0b74ef171e6a84761710548501dfac71285a58a3 | https://github.com/smdabdoub/phylotoast/blob/0b74ef171e6a84761710548501dfac71285a58a3/bin/network_plots_gephi.py#L33-L57 | train |
smdabdoub/phylotoast | bin/iTol.py | find_otu | def find_otu(otuid, tree):
"""
Find an OTU ID in a Newick-format tree.
Return the starting position of the ID or None if not found.
"""
for m in re.finditer(otuid, tree):
before, after = tree[m.start()-1], tree[m.start()+len(otuid)]
if before in ["(", ",", ")"] and after in [":", ";"... | python | def find_otu(otuid, tree):
"""
Find an OTU ID in a Newick-format tree.
Return the starting position of the ID or None if not found.
"""
for m in re.finditer(otuid, tree):
before, after = tree[m.start()-1], tree[m.start()+len(otuid)]
if before in ["(", ",", ")"] and after in [":", ";"... | [
"def",
"find_otu",
"(",
"otuid",
",",
"tree",
")",
":",
"for",
"m",
"in",
"re",
".",
"finditer",
"(",
"otuid",
",",
"tree",
")",
":",
"before",
",",
"after",
"=",
"tree",
"[",
"m",
".",
"start",
"(",
")",
"-",
"1",
"]",
",",
"tree",
"[",
"m",... | Find an OTU ID in a Newick-format tree.
Return the starting position of the ID or None if not found. | [
"Find",
"an",
"OTU",
"ID",
"in",
"a",
"Newick",
"-",
"format",
"tree",
".",
"Return",
"the",
"starting",
"position",
"of",
"the",
"ID",
"or",
"None",
"if",
"not",
"found",
"."
] | 0b74ef171e6a84761710548501dfac71285a58a3 | https://github.com/smdabdoub/phylotoast/blob/0b74ef171e6a84761710548501dfac71285a58a3/bin/iTol.py#L17-L26 | train |
smdabdoub/phylotoast | bin/iTol.py | newick_replace_otuids | def newick_replace_otuids(tree, biomf):
"""
Replace the OTU ids in the Newick phylogenetic tree format with truncated
OTU names
"""
for val, id_, md in biomf.iter(axis="observation"):
otu_loc = find_otu(id_, tree)
if otu_loc is not None:
tree = tree[:otu_loc] + \
... | python | def newick_replace_otuids(tree, biomf):
"""
Replace the OTU ids in the Newick phylogenetic tree format with truncated
OTU names
"""
for val, id_, md in biomf.iter(axis="observation"):
otu_loc = find_otu(id_, tree)
if otu_loc is not None:
tree = tree[:otu_loc] + \
... | [
"def",
"newick_replace_otuids",
"(",
"tree",
",",
"biomf",
")",
":",
"for",
"val",
",",
"id_",
",",
"md",
"in",
"biomf",
".",
"iter",
"(",
"axis",
"=",
"\"observation\"",
")",
":",
"otu_loc",
"=",
"find_otu",
"(",
"id_",
",",
"tree",
")",
"if",
"otu_... | Replace the OTU ids in the Newick phylogenetic tree format with truncated
OTU names | [
"Replace",
"the",
"OTU",
"ids",
"in",
"the",
"Newick",
"phylogenetic",
"tree",
"format",
"with",
"truncated",
"OTU",
"names"
] | 0b74ef171e6a84761710548501dfac71285a58a3 | https://github.com/smdabdoub/phylotoast/blob/0b74ef171e6a84761710548501dfac71285a58a3/bin/iTol.py#L29-L40 | train |
christophertbrown/bioscripts | ctbBio/cluster_ani.py | genome_info | def genome_info(genome, info):
"""
return genome info for choosing representative
if ggKbase table provided - choose rep based on SCGs and genome length
- priority for most SCGs - extra SCGs, then largest genome
otherwise, based on largest genome
"""
try:
scg = info['#SCG... | python | def genome_info(genome, info):
"""
return genome info for choosing representative
if ggKbase table provided - choose rep based on SCGs and genome length
- priority for most SCGs - extra SCGs, then largest genome
otherwise, based on largest genome
"""
try:
scg = info['#SCG... | [
"def",
"genome_info",
"(",
"genome",
",",
"info",
")",
":",
"try",
":",
"scg",
"=",
"info",
"[",
"'#SCGs'",
"]",
"dups",
"=",
"info",
"[",
"'#SCG duplicates'",
"]",
"length",
"=",
"info",
"[",
"'genome size (bp)'",
"]",
"return",
"[",
"scg",
"-",
"dups... | return genome info for choosing representative
if ggKbase table provided - choose rep based on SCGs and genome length
- priority for most SCGs - extra SCGs, then largest genome
otherwise, based on largest genome | [
"return",
"genome",
"info",
"for",
"choosing",
"representative"
] | 83b2566b3a5745437ec651cd6cafddd056846240 | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/cluster_ani.py#L97-L112 | train |
christophertbrown/bioscripts | ctbBio/cluster_ani.py | print_clusters | def print_clusters(fastas, info, ANI):
"""
choose represenative genome and
print cluster information
*if ggKbase table is provided, use SCG info to choose best genome
"""
header = ['#cluster', 'num. genomes', 'rep.', 'genome', '#SCGs', '#SCG duplicates', \
'genome size (bp)', 'fragm... | python | def print_clusters(fastas, info, ANI):
"""
choose represenative genome and
print cluster information
*if ggKbase table is provided, use SCG info to choose best genome
"""
header = ['#cluster', 'num. genomes', 'rep.', 'genome', '#SCGs', '#SCG duplicates', \
'genome size (bp)', 'fragm... | [
"def",
"print_clusters",
"(",
"fastas",
",",
"info",
",",
"ANI",
")",
":",
"header",
"=",
"[",
"'#cluster'",
",",
"'num. genomes'",
",",
"'rep.'",
",",
"'genome'",
",",
"'#SCGs'",
",",
"'#SCG duplicates'",
",",
"'genome size (bp)'",
",",
"'fragments'",
",",
... | choose represenative genome and
print cluster information
*if ggKbase table is provided, use SCG info to choose best genome | [
"choose",
"represenative",
"genome",
"and",
"print",
"cluster",
"information"
] | 83b2566b3a5745437ec651cd6cafddd056846240 | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/cluster_ani.py#L114-L163 | train |
christophertbrown/bioscripts | ctbBio/cluster_ani.py | parse_ggKbase_tables | def parse_ggKbase_tables(tables, id_type):
"""
convert ggKbase genome info tables to dictionary
"""
g2info = {}
for table in tables:
for line in open(table):
line = line.strip().split('\t')
if line[0].startswith('name'):
header = line
h... | python | def parse_ggKbase_tables(tables, id_type):
"""
convert ggKbase genome info tables to dictionary
"""
g2info = {}
for table in tables:
for line in open(table):
line = line.strip().split('\t')
if line[0].startswith('name'):
header = line
h... | [
"def",
"parse_ggKbase_tables",
"(",
"tables",
",",
"id_type",
")",
":",
"g2info",
"=",
"{",
"}",
"for",
"table",
"in",
"tables",
":",
"for",
"line",
"in",
"open",
"(",
"table",
")",
":",
"line",
"=",
"line",
".",
"strip",
"(",
")",
".",
"split",
"(... | convert ggKbase genome info tables to dictionary | [
"convert",
"ggKbase",
"genome",
"info",
"tables",
"to",
"dictionary"
] | 83b2566b3a5745437ec651cd6cafddd056846240 | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/cluster_ani.py#L174-L213 | train |
christophertbrown/bioscripts | ctbBio/cluster_ani.py | parse_checkM_tables | def parse_checkM_tables(tables):
"""
convert checkM genome info tables to dictionary
"""
g2info = {}
for table in tables:
for line in open(table):
line = line.strip().split('\t')
if line[0].startswith('Bin Id'):
header = line
header[8] ... | python | def parse_checkM_tables(tables):
"""
convert checkM genome info tables to dictionary
"""
g2info = {}
for table in tables:
for line in open(table):
line = line.strip().split('\t')
if line[0].startswith('Bin Id'):
header = line
header[8] ... | [
"def",
"parse_checkM_tables",
"(",
"tables",
")",
":",
"g2info",
"=",
"{",
"}",
"for",
"table",
"in",
"tables",
":",
"for",
"line",
"in",
"open",
"(",
"table",
")",
":",
"line",
"=",
"line",
".",
"strip",
"(",
")",
".",
"split",
"(",
"'\\t'",
")",
... | convert checkM genome info tables to dictionary | [
"convert",
"checkM",
"genome",
"info",
"tables",
"to",
"dictionary"
] | 83b2566b3a5745437ec651cd6cafddd056846240 | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/cluster_ani.py#L215-L235 | train |
christophertbrown/bioscripts | ctbBio/cluster_ani.py | genome_lengths | def genome_lengths(fastas, info):
"""
get genome lengths
"""
if info is False:
info = {}
for genome in fastas:
name = genome.rsplit('.', 1)[0].rsplit('/', 1)[-1].rsplit('.contigs')[0]
if name in info:
continue
length = 0
fragments = 0
for s... | python | def genome_lengths(fastas, info):
"""
get genome lengths
"""
if info is False:
info = {}
for genome in fastas:
name = genome.rsplit('.', 1)[0].rsplit('/', 1)[-1].rsplit('.contigs')[0]
if name in info:
continue
length = 0
fragments = 0
for s... | [
"def",
"genome_lengths",
"(",
"fastas",
",",
"info",
")",
":",
"if",
"info",
"is",
"False",
":",
"info",
"=",
"{",
"}",
"for",
"genome",
"in",
"fastas",
":",
"name",
"=",
"genome",
".",
"rsplit",
"(",
"'.'",
",",
"1",
")",
"[",
"0",
"]",
".",
"... | get genome lengths | [
"get",
"genome",
"lengths"
] | 83b2566b3a5745437ec651cd6cafddd056846240 | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/cluster_ani.py#L237-L253 | train |
disqus/nydus | nydus/db/routers/base.py | BaseRouter.get_dbs | def get_dbs(self, attr, args, kwargs, **fkwargs):
"""
Returns a list of db keys to route the given call to.
:param attr: Name of attribute being called on the connection.
:param args: List of arguments being passed to ``attr``.
:param kwargs: Dictionary of keyword arguments bein... | python | def get_dbs(self, attr, args, kwargs, **fkwargs):
"""
Returns a list of db keys to route the given call to.
:param attr: Name of attribute being called on the connection.
:param args: List of arguments being passed to ``attr``.
:param kwargs: Dictionary of keyword arguments bein... | [
"def",
"get_dbs",
"(",
"self",
",",
"attr",
",",
"args",
",",
"kwargs",
",",
"**",
"fkwargs",
")",
":",
"if",
"not",
"self",
".",
"_ready",
":",
"if",
"not",
"self",
".",
"setup_router",
"(",
"args",
"=",
"args",
",",
"kwargs",
"=",
"kwargs",
",",
... | Returns a list of db keys to route the given call to.
:param attr: Name of attribute being called on the connection.
:param args: List of arguments being passed to ``attr``.
:param kwargs: Dictionary of keyword arguments being passed to ``attr``.
>>> redis = Cluster(router=BaseRouter)
... | [
"Returns",
"a",
"list",
"of",
"db",
"keys",
"to",
"route",
"the",
"given",
"call",
"to",
"."
] | 9b505840da47a34f758a830c3992fa5dcb7bb7ad | https://github.com/disqus/nydus/blob/9b505840da47a34f758a830c3992fa5dcb7bb7ad/nydus/db/routers/base.py#L50-L81 | train |
disqus/nydus | nydus/db/routers/base.py | BaseRouter.setup_router | def setup_router(self, args, kwargs, **fkwargs):
"""
Call method to perform any setup
"""
self._ready = self._setup_router(args=args, kwargs=kwargs, **fkwargs)
return self._ready | python | def setup_router(self, args, kwargs, **fkwargs):
"""
Call method to perform any setup
"""
self._ready = self._setup_router(args=args, kwargs=kwargs, **fkwargs)
return self._ready | [
"def",
"setup_router",
"(",
"self",
",",
"args",
",",
"kwargs",
",",
"**",
"fkwargs",
")",
":",
"self",
".",
"_ready",
"=",
"self",
".",
"_setup_router",
"(",
"args",
"=",
"args",
",",
"kwargs",
"=",
"kwargs",
",",
"**",
"fkwargs",
")",
"return",
"se... | Call method to perform any setup | [
"Call",
"method",
"to",
"perform",
"any",
"setup"
] | 9b505840da47a34f758a830c3992fa5dcb7bb7ad | https://github.com/disqus/nydus/blob/9b505840da47a34f758a830c3992fa5dcb7bb7ad/nydus/db/routers/base.py#L87-L93 | train |
disqus/nydus | nydus/db/routers/base.py | BaseRouter._route | def _route(self, attr, args, kwargs, **fkwargs):
"""
Perform routing and return db_nums
"""
return self.cluster.hosts.keys() | python | def _route(self, attr, args, kwargs, **fkwargs):
"""
Perform routing and return db_nums
"""
return self.cluster.hosts.keys() | [
"def",
"_route",
"(",
"self",
",",
"attr",
",",
"args",
",",
"kwargs",
",",
"**",
"fkwargs",
")",
":",
"return",
"self",
".",
"cluster",
".",
"hosts",
".",
"keys",
"(",
")"
] | Perform routing and return db_nums | [
"Perform",
"routing",
"and",
"return",
"db_nums"
] | 9b505840da47a34f758a830c3992fa5dcb7bb7ad | https://github.com/disqus/nydus/blob/9b505840da47a34f758a830c3992fa5dcb7bb7ad/nydus/db/routers/base.py#L111-L115 | train |
disqus/nydus | nydus/db/routers/base.py | RoundRobinRouter.check_down_connections | def check_down_connections(self):
"""
Iterates through all connections which were previously listed as unavailable
and marks any that have expired their retry_timeout as being up.
"""
now = time.time()
for db_num, marked_down_at in self._down_connections.items():
... | python | def check_down_connections(self):
"""
Iterates through all connections which were previously listed as unavailable
and marks any that have expired their retry_timeout as being up.
"""
now = time.time()
for db_num, marked_down_at in self._down_connections.items():
... | [
"def",
"check_down_connections",
"(",
"self",
")",
":",
"now",
"=",
"time",
".",
"time",
"(",
")",
"for",
"db_num",
",",
"marked_down_at",
"in",
"self",
".",
"_down_connections",
".",
"items",
"(",
")",
":",
"if",
"marked_down_at",
"+",
"self",
".",
"ret... | Iterates through all connections which were previously listed as unavailable
and marks any that have expired their retry_timeout as being up. | [
"Iterates",
"through",
"all",
"connections",
"which",
"were",
"previously",
"listed",
"as",
"unavailable",
"and",
"marks",
"any",
"that",
"have",
"expired",
"their",
"retry_timeout",
"as",
"being",
"up",
"."
] | 9b505840da47a34f758a830c3992fa5dcb7bb7ad | https://github.com/disqus/nydus/blob/9b505840da47a34f758a830c3992fa5dcb7bb7ad/nydus/db/routers/base.py#L175-L184 | train |
disqus/nydus | nydus/db/routers/base.py | RoundRobinRouter.flush_down_connections | def flush_down_connections(self):
"""
Marks all connections which were previously listed as unavailable as being up.
"""
self._get_db_attempts = 0
for db_num in self._down_connections.keys():
self.mark_connection_up(db_num) | python | def flush_down_connections(self):
"""
Marks all connections which were previously listed as unavailable as being up.
"""
self._get_db_attempts = 0
for db_num in self._down_connections.keys():
self.mark_connection_up(db_num) | [
"def",
"flush_down_connections",
"(",
"self",
")",
":",
"self",
".",
"_get_db_attempts",
"=",
"0",
"for",
"db_num",
"in",
"self",
".",
"_down_connections",
".",
"keys",
"(",
")",
":",
"self",
".",
"mark_connection_up",
"(",
"db_num",
")"
] | Marks all connections which were previously listed as unavailable as being up. | [
"Marks",
"all",
"connections",
"which",
"were",
"previously",
"listed",
"as",
"unavailable",
"as",
"being",
"up",
"."
] | 9b505840da47a34f758a830c3992fa5dcb7bb7ad | https://github.com/disqus/nydus/blob/9b505840da47a34f758a830c3992fa5dcb7bb7ad/nydus/db/routers/base.py#L186-L192 | train |
opengridcc/opengrid | opengrid/library/analysis.py | standby | def standby(df, resolution='24h', time_window=None):
"""
Compute standby power
Parameters
----------
df : pandas.DataFrame or pandas.Series
Electricity Power
resolution : str, default='d'
Resolution of the computation. Data will be resampled to this resolution (as mean) before ... | python | def standby(df, resolution='24h', time_window=None):
"""
Compute standby power
Parameters
----------
df : pandas.DataFrame or pandas.Series
Electricity Power
resolution : str, default='d'
Resolution of the computation. Data will be resampled to this resolution (as mean) before ... | [
"def",
"standby",
"(",
"df",
",",
"resolution",
"=",
"'24h'",
",",
"time_window",
"=",
"None",
")",
":",
"if",
"df",
".",
"empty",
":",
"raise",
"EmptyDataFrame",
"(",
")",
"df",
"=",
"pd",
".",
"DataFrame",
"(",
"df",
")",
"def",
"parse_time",
"(",
... | Compute standby power
Parameters
----------
df : pandas.DataFrame or pandas.Series
Electricity Power
resolution : str, default='d'
Resolution of the computation. Data will be resampled to this resolution (as mean) before computation
of the minimum.
String that can be pa... | [
"Compute",
"standby",
"power"
] | 69b8da3c8fcea9300226c45ef0628cd6d4307651 | https://github.com/opengridcc/opengrid/blob/69b8da3c8fcea9300226c45ef0628cd6d4307651/opengrid/library/analysis.py#L72-L115 | train |
opengridcc/opengrid | opengrid/library/analysis.py | share_of_standby | def share_of_standby(df, resolution='24h', time_window=None):
"""
Compute the share of the standby power in the total consumption.
Parameters
----------
df : pandas.DataFrame or pandas.Series
Power (typically electricity, can be anything)
resolution : str, default='d'
Resolution... | python | def share_of_standby(df, resolution='24h', time_window=None):
"""
Compute the share of the standby power in the total consumption.
Parameters
----------
df : pandas.DataFrame or pandas.Series
Power (typically electricity, can be anything)
resolution : str, default='d'
Resolution... | [
"def",
"share_of_standby",
"(",
"df",
",",
"resolution",
"=",
"'24h'",
",",
"time_window",
"=",
"None",
")",
":",
"p_sb",
"=",
"standby",
"(",
"df",
",",
"resolution",
",",
"time_window",
")",
"df",
"=",
"df",
".",
"resample",
"(",
"resolution",
")",
"... | Compute the share of the standby power in the total consumption.
Parameters
----------
df : pandas.DataFrame or pandas.Series
Power (typically electricity, can be anything)
resolution : str, default='d'
Resolution of the computation. Data will be resampled to this resolution (as mean) ... | [
"Compute",
"the",
"share",
"of",
"the",
"standby",
"power",
"in",
"the",
"total",
"consumption",
"."
] | 69b8da3c8fcea9300226c45ef0628cd6d4307651 | https://github.com/opengridcc/opengrid/blob/69b8da3c8fcea9300226c45ef0628cd6d4307651/opengrid/library/analysis.py#L118-L146 | train |
opengridcc/opengrid | opengrid/library/analysis.py | count_peaks | def count_peaks(ts):
"""
Toggle counter for gas boilers
Counts the number of times the gas consumption increases with more than 3kW
Parameters
----------
ts: Pandas Series
Gas consumption in minute resolution
Returns
-------
int
"""
on_toggles = ts.diff() > 3000
... | python | def count_peaks(ts):
"""
Toggle counter for gas boilers
Counts the number of times the gas consumption increases with more than 3kW
Parameters
----------
ts: Pandas Series
Gas consumption in minute resolution
Returns
-------
int
"""
on_toggles = ts.diff() > 3000
... | [
"def",
"count_peaks",
"(",
"ts",
")",
":",
"on_toggles",
"=",
"ts",
".",
"diff",
"(",
")",
">",
"3000",
"shifted",
"=",
"np",
".",
"logical_not",
"(",
"on_toggles",
".",
"shift",
"(",
"1",
")",
")",
"result",
"=",
"on_toggles",
"&",
"shifted",
"count... | Toggle counter for gas boilers
Counts the number of times the gas consumption increases with more than 3kW
Parameters
----------
ts: Pandas Series
Gas consumption in minute resolution
Returns
-------
int | [
"Toggle",
"counter",
"for",
"gas",
"boilers"
] | 69b8da3c8fcea9300226c45ef0628cd6d4307651 | https://github.com/opengridcc/opengrid/blob/69b8da3c8fcea9300226c45ef0628cd6d4307651/opengrid/library/analysis.py#L149-L169 | train |
opengridcc/opengrid | opengrid/library/analysis.py | load_factor | def load_factor(ts, resolution=None, norm=None):
"""
Calculate the ratio of input vs. norm over a given interval.
Parameters
----------
ts : pandas.Series
timeseries
resolution : str, optional
interval over which to calculate the ratio
default: resolution of the input ti... | python | def load_factor(ts, resolution=None, norm=None):
"""
Calculate the ratio of input vs. norm over a given interval.
Parameters
----------
ts : pandas.Series
timeseries
resolution : str, optional
interval over which to calculate the ratio
default: resolution of the input ti... | [
"def",
"load_factor",
"(",
"ts",
",",
"resolution",
"=",
"None",
",",
"norm",
"=",
"None",
")",
":",
"if",
"norm",
"is",
"None",
":",
"norm",
"=",
"ts",
".",
"max",
"(",
")",
"if",
"resolution",
"is",
"not",
"None",
":",
"ts",
"=",
"ts",
".",
"... | Calculate the ratio of input vs. norm over a given interval.
Parameters
----------
ts : pandas.Series
timeseries
resolution : str, optional
interval over which to calculate the ratio
default: resolution of the input timeseries
norm : int | float, optional
denominator... | [
"Calculate",
"the",
"ratio",
"of",
"input",
"vs",
".",
"norm",
"over",
"a",
"given",
"interval",
"."
] | 69b8da3c8fcea9300226c45ef0628cd6d4307651 | https://github.com/opengridcc/opengrid/blob/69b8da3c8fcea9300226c45ef0628cd6d4307651/opengrid/library/analysis.py#L172-L199 | train |
christophertbrown/bioscripts | ctbBio/besthits.py | top_hits | def top_hits(hits, num, column, reverse):
"""
get top hits after sorting by column number
"""
hits.sort(key = itemgetter(column), reverse = reverse)
for hit in hits[0:num]:
yield hit | python | def top_hits(hits, num, column, reverse):
"""
get top hits after sorting by column number
"""
hits.sort(key = itemgetter(column), reverse = reverse)
for hit in hits[0:num]:
yield hit | [
"def",
"top_hits",
"(",
"hits",
",",
"num",
",",
"column",
",",
"reverse",
")",
":",
"hits",
".",
"sort",
"(",
"key",
"=",
"itemgetter",
"(",
"column",
")",
",",
"reverse",
"=",
"reverse",
")",
"for",
"hit",
"in",
"hits",
"[",
"0",
":",
"num",
"]... | get top hits after sorting by column number | [
"get",
"top",
"hits",
"after",
"sorting",
"by",
"column",
"number"
] | 83b2566b3a5745437ec651cd6cafddd056846240 | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/besthits.py#L17-L23 | train |
christophertbrown/bioscripts | ctbBio/besthits.py | numBlast_sort | def numBlast_sort(blast, numHits, evalueT, bitT):
"""
parse b6 output with sorting
"""
header = ['#query', 'target', 'pident', 'alen', 'mismatch', 'gapopen',
'qstart', 'qend', 'tstart', 'tend', 'evalue', 'bitscore']
yield header
hmm = {h:[] for h in header}
for line in blast:
... | python | def numBlast_sort(blast, numHits, evalueT, bitT):
"""
parse b6 output with sorting
"""
header = ['#query', 'target', 'pident', 'alen', 'mismatch', 'gapopen',
'qstart', 'qend', 'tstart', 'tend', 'evalue', 'bitscore']
yield header
hmm = {h:[] for h in header}
for line in blast:
... | [
"def",
"numBlast_sort",
"(",
"blast",
",",
"numHits",
",",
"evalueT",
",",
"bitT",
")",
":",
"header",
"=",
"[",
"'#query'",
",",
"'target'",
",",
"'pident'",
",",
"'alen'",
",",
"'mismatch'",
",",
"'gapopen'",
",",
"'qstart'",
",",
"'qend'",
",",
"'tsta... | parse b6 output with sorting | [
"parse",
"b6",
"output",
"with",
"sorting"
] | 83b2566b3a5745437ec651cd6cafddd056846240 | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/besthits.py#L25-L50 | train |
christophertbrown/bioscripts | ctbBio/besthits.py | numBlast | def numBlast(blast, numHits, evalueT = False, bitT = False, sort = False):
"""
parse b6 output
"""
if sort is True:
for hit in numBlast_sort(blast, numHits, evalueT, bitT):
yield hit
return
header = ['#query', 'target', 'pident', 'alen', 'mismatch', 'gapopen',
... | python | def numBlast(blast, numHits, evalueT = False, bitT = False, sort = False):
"""
parse b6 output
"""
if sort is True:
for hit in numBlast_sort(blast, numHits, evalueT, bitT):
yield hit
return
header = ['#query', 'target', 'pident', 'alen', 'mismatch', 'gapopen',
... | [
"def",
"numBlast",
"(",
"blast",
",",
"numHits",
",",
"evalueT",
"=",
"False",
",",
"bitT",
"=",
"False",
",",
"sort",
"=",
"False",
")",
":",
"if",
"sort",
"is",
"True",
":",
"for",
"hit",
"in",
"numBlast_sort",
"(",
"blast",
",",
"numHits",
",",
... | parse b6 output | [
"parse",
"b6",
"output"
] | 83b2566b3a5745437ec651cd6cafddd056846240 | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/besthits.py#L52-L85 | train |
christophertbrown/bioscripts | ctbBio/besthits.py | numDomtblout | def numDomtblout(domtblout, numHits, evalueT, bitT, sort):
"""
parse hmm domain table output
this version is faster but does not work unless the table is sorted
"""
if sort is True:
for hit in numDomtblout_sort(domtblout, numHits, evalueT, bitT):
yield hit
return
head... | python | def numDomtblout(domtblout, numHits, evalueT, bitT, sort):
"""
parse hmm domain table output
this version is faster but does not work unless the table is sorted
"""
if sort is True:
for hit in numDomtblout_sort(domtblout, numHits, evalueT, bitT):
yield hit
return
head... | [
"def",
"numDomtblout",
"(",
"domtblout",
",",
"numHits",
",",
"evalueT",
",",
"bitT",
",",
"sort",
")",
":",
"if",
"sort",
"is",
"True",
":",
"for",
"hit",
"in",
"numDomtblout_sort",
"(",
"domtblout",
",",
"numHits",
",",
"evalueT",
",",
"bitT",
")",
"... | parse hmm domain table output
this version is faster but does not work unless the table is sorted | [
"parse",
"hmm",
"domain",
"table",
"output",
"this",
"version",
"is",
"faster",
"but",
"does",
"not",
"work",
"unless",
"the",
"table",
"is",
"sorted"
] | 83b2566b3a5745437ec651cd6cafddd056846240 | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/besthits.py#L121-L168 | train |
christophertbrown/bioscripts | ctbBio/stockholm2fa.py | stock2fa | def stock2fa(stock):
"""
convert stockholm to fasta
"""
seqs = {}
for line in stock:
if line.startswith('#') is False and line.startswith(' ') is False and len(line) > 3:
id, seq = line.strip().split()
id = id.rsplit('/', 1)[0]
id = re.split('[0-9]\|', id,... | python | def stock2fa(stock):
"""
convert stockholm to fasta
"""
seqs = {}
for line in stock:
if line.startswith('#') is False and line.startswith(' ') is False and len(line) > 3:
id, seq = line.strip().split()
id = id.rsplit('/', 1)[0]
id = re.split('[0-9]\|', id,... | [
"def",
"stock2fa",
"(",
"stock",
")",
":",
"seqs",
"=",
"{",
"}",
"for",
"line",
"in",
"stock",
":",
"if",
"line",
".",
"startswith",
"(",
"'#'",
")",
"is",
"False",
"and",
"line",
".",
"startswith",
"(",
"' '",
")",
"is",
"False",
"and",
"len",
... | convert stockholm to fasta | [
"convert",
"stockholm",
"to",
"fasta"
] | 83b2566b3a5745437ec651cd6cafddd056846240 | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/stockholm2fa.py#L11-L26 | train |
opengridcc/opengrid | opengrid/library/utils.py | week_schedule | def week_schedule(index, on_time=None, off_time=None, off_days=None):
""" Return boolean time series following given week schedule.
Parameters
----------
index : pandas.DatetimeIndex
Datetime index
on_time : str or datetime.time
Daily opening time. Default: '09:00'
off_time : st... | python | def week_schedule(index, on_time=None, off_time=None, off_days=None):
""" Return boolean time series following given week schedule.
Parameters
----------
index : pandas.DatetimeIndex
Datetime index
on_time : str or datetime.time
Daily opening time. Default: '09:00'
off_time : st... | [
"def",
"week_schedule",
"(",
"index",
",",
"on_time",
"=",
"None",
",",
"off_time",
"=",
"None",
",",
"off_days",
"=",
"None",
")",
":",
"if",
"on_time",
"is",
"None",
":",
"on_time",
"=",
"'9:00'",
"if",
"off_time",
"is",
"None",
":",
"off_time",
"=",... | Return boolean time series following given week schedule.
Parameters
----------
index : pandas.DatetimeIndex
Datetime index
on_time : str or datetime.time
Daily opening time. Default: '09:00'
off_time : str or datetime.time
Daily closing time. Default: '17:00'
off_days :... | [
"Return",
"boolean",
"time",
"series",
"following",
"given",
"week",
"schedule",
"."
] | 69b8da3c8fcea9300226c45ef0628cd6d4307651 | https://github.com/opengridcc/opengrid/blob/69b8da3c8fcea9300226c45ef0628cd6d4307651/opengrid/library/utils.py#L10-L47 | train |
opengridcc/opengrid | opengrid/library/plotting.py | carpet | def carpet(timeseries, **kwargs):
"""
Draw a carpet plot of a pandas timeseries.
The carpet plot reads like a letter. Every day one line is added to the
bottom of the figure, minute for minute moving from left (morning) to right
(evening).
The color denotes the level of consumption and is scale... | python | def carpet(timeseries, **kwargs):
"""
Draw a carpet plot of a pandas timeseries.
The carpet plot reads like a letter. Every day one line is added to the
bottom of the figure, minute for minute moving from left (morning) to right
(evening).
The color denotes the level of consumption and is scale... | [
"def",
"carpet",
"(",
"timeseries",
",",
"**",
"kwargs",
")",
":",
"cmap",
"=",
"kwargs",
".",
"pop",
"(",
"'cmap'",
",",
"cm",
".",
"coolwarm",
")",
"norm",
"=",
"kwargs",
".",
"pop",
"(",
"'norm'",
",",
"LogNorm",
"(",
")",
")",
"interpolation",
... | Draw a carpet plot of a pandas timeseries.
The carpet plot reads like a letter. Every day one line is added to the
bottom of the figure, minute for minute moving from left (morning) to right
(evening).
The color denotes the level of consumption and is scaled logarithmically.
If vmin and vmax are no... | [
"Draw",
"a",
"carpet",
"plot",
"of",
"a",
"pandas",
"timeseries",
"."
] | 69b8da3c8fcea9300226c45ef0628cd6d4307651 | https://github.com/opengridcc/opengrid/blob/69b8da3c8fcea9300226c45ef0628cd6d4307651/opengrid/library/plotting.py#L34-L125 | train |
christophertbrown/bioscripts | ctbBio/compare_aligned.py | calc_pident_ignore_gaps | def calc_pident_ignore_gaps(a, b):
"""
calculate percent identity
"""
m = 0 # matches
mm = 0 # mismatches
for A, B in zip(list(a), list(b)):
if A == '-' or A == '.' or B == '-' or B == '.':
continue
if A == B:
m += 1
else:
mm += 1
t... | python | def calc_pident_ignore_gaps(a, b):
"""
calculate percent identity
"""
m = 0 # matches
mm = 0 # mismatches
for A, B in zip(list(a), list(b)):
if A == '-' or A == '.' or B == '-' or B == '.':
continue
if A == B:
m += 1
else:
mm += 1
t... | [
"def",
"calc_pident_ignore_gaps",
"(",
"a",
",",
"b",
")",
":",
"m",
"=",
"0",
"mm",
"=",
"0",
"for",
"A",
",",
"B",
"in",
"zip",
"(",
"list",
"(",
"a",
")",
",",
"list",
"(",
"b",
")",
")",
":",
"if",
"A",
"==",
"'-'",
"or",
"A",
"==",
"... | calculate percent identity | [
"calculate",
"percent",
"identity"
] | 83b2566b3a5745437ec651cd6cafddd056846240 | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/compare_aligned.py#L34-L50 | train |
christophertbrown/bioscripts | ctbBio/compare_aligned.py | remove_gaps | def remove_gaps(A, B):
"""
skip column if either is a gap
"""
a_seq, b_seq = [], []
for a, b in zip(list(A), list(B)):
if a == '-' or a == '.' or b == '-' or b == '.':
continue
a_seq.append(a)
b_seq.append(b)
return ''.join(a_seq), ''.join(b_seq) | python | def remove_gaps(A, B):
"""
skip column if either is a gap
"""
a_seq, b_seq = [], []
for a, b in zip(list(A), list(B)):
if a == '-' or a == '.' or b == '-' or b == '.':
continue
a_seq.append(a)
b_seq.append(b)
return ''.join(a_seq), ''.join(b_seq) | [
"def",
"remove_gaps",
"(",
"A",
",",
"B",
")",
":",
"a_seq",
",",
"b_seq",
"=",
"[",
"]",
",",
"[",
"]",
"for",
"a",
",",
"b",
"in",
"zip",
"(",
"list",
"(",
"A",
")",
",",
"list",
"(",
"B",
")",
")",
":",
"if",
"a",
"==",
"'-'",
"or",
... | skip column if either is a gap | [
"skip",
"column",
"if",
"either",
"is",
"a",
"gap"
] | 83b2566b3a5745437ec651cd6cafddd056846240 | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/compare_aligned.py#L52-L62 | train |
christophertbrown/bioscripts | ctbBio/compare_aligned.py | compare_seqs | def compare_seqs(seqs):
"""
compare pairs of sequences
"""
A, B, ignore_gaps = seqs
a, b = A[1], B[1] # actual sequences
if len(a) != len(b):
print('# reads are not the same length', file=sys.stderr)
exit()
if ignore_gaps is True:
pident = calc_pident_ignore_gaps(a, b... | python | def compare_seqs(seqs):
"""
compare pairs of sequences
"""
A, B, ignore_gaps = seqs
a, b = A[1], B[1] # actual sequences
if len(a) != len(b):
print('# reads are not the same length', file=sys.stderr)
exit()
if ignore_gaps is True:
pident = calc_pident_ignore_gaps(a, b... | [
"def",
"compare_seqs",
"(",
"seqs",
")",
":",
"A",
",",
"B",
",",
"ignore_gaps",
"=",
"seqs",
"a",
",",
"b",
"=",
"A",
"[",
"1",
"]",
",",
"B",
"[",
"1",
"]",
"if",
"len",
"(",
"a",
")",
"!=",
"len",
"(",
"b",
")",
":",
"print",
"(",
"'# ... | compare pairs of sequences | [
"compare",
"pairs",
"of",
"sequences"
] | 83b2566b3a5745437ec651cd6cafddd056846240 | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/compare_aligned.py#L64-L77 | train |
christophertbrown/bioscripts | ctbBio/compare_aligned.py | compare_seqs_leven | def compare_seqs_leven(seqs):
"""
calculate Levenshtein ratio of sequences
"""
A, B, ignore_gaps = seqs
a, b = remove_gaps(A[1], B[1]) # actual sequences
if len(a) != len(b):
print('# reads are not the same length', file=sys.stderr)
exit()
pident = lr(a, b) * 100
return A... | python | def compare_seqs_leven(seqs):
"""
calculate Levenshtein ratio of sequences
"""
A, B, ignore_gaps = seqs
a, b = remove_gaps(A[1], B[1]) # actual sequences
if len(a) != len(b):
print('# reads are not the same length', file=sys.stderr)
exit()
pident = lr(a, b) * 100
return A... | [
"def",
"compare_seqs_leven",
"(",
"seqs",
")",
":",
"A",
",",
"B",
",",
"ignore_gaps",
"=",
"seqs",
"a",
",",
"b",
"=",
"remove_gaps",
"(",
"A",
"[",
"1",
"]",
",",
"B",
"[",
"1",
"]",
")",
"if",
"len",
"(",
"a",
")",
"!=",
"len",
"(",
"b",
... | calculate Levenshtein ratio of sequences | [
"calculate",
"Levenshtein",
"ratio",
"of",
"sequences"
] | 83b2566b3a5745437ec651cd6cafddd056846240 | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/compare_aligned.py#L79-L89 | train |
christophertbrown/bioscripts | ctbBio/compare_aligned.py | pairwise_compare | def pairwise_compare(afa, leven, threads, print_list, ignore_gaps):
"""
make pairwise sequence comparisons between aligned sequences
"""
# load sequences into dictionary
seqs = {seq[0]: seq for seq in nr_fasta([afa], append_index = True)}
num_seqs = len(seqs)
# define all pairs
pairs = (... | python | def pairwise_compare(afa, leven, threads, print_list, ignore_gaps):
"""
make pairwise sequence comparisons between aligned sequences
"""
# load sequences into dictionary
seqs = {seq[0]: seq for seq in nr_fasta([afa], append_index = True)}
num_seqs = len(seqs)
# define all pairs
pairs = (... | [
"def",
"pairwise_compare",
"(",
"afa",
",",
"leven",
",",
"threads",
",",
"print_list",
",",
"ignore_gaps",
")",
":",
"seqs",
"=",
"{",
"seq",
"[",
"0",
"]",
":",
"seq",
"for",
"seq",
"in",
"nr_fasta",
"(",
"[",
"afa",
"]",
",",
"append_index",
"=",
... | make pairwise sequence comparisons between aligned sequences | [
"make",
"pairwise",
"sequence",
"comparisons",
"between",
"aligned",
"sequences"
] | 83b2566b3a5745437ec651cd6cafddd056846240 | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/compare_aligned.py#L91-L110 | train |
christophertbrown/bioscripts | ctbBio/compare_aligned.py | print_pairwise | def print_pairwise(pw, median = False):
"""
print matrix of pidents to stdout
"""
names = sorted(set([i for i in pw]))
if len(names) != 0:
if '>' in names[0]:
yield ['#'] + [i.split('>')[1] for i in names if '>' in i]
else:
yield ['#'] + names
for a in... | python | def print_pairwise(pw, median = False):
"""
print matrix of pidents to stdout
"""
names = sorted(set([i for i in pw]))
if len(names) != 0:
if '>' in names[0]:
yield ['#'] + [i.split('>')[1] for i in names if '>' in i]
else:
yield ['#'] + names
for a in... | [
"def",
"print_pairwise",
"(",
"pw",
",",
"median",
"=",
"False",
")",
":",
"names",
"=",
"sorted",
"(",
"set",
"(",
"[",
"i",
"for",
"i",
"in",
"pw",
"]",
")",
")",
"if",
"len",
"(",
"names",
")",
"!=",
"0",
":",
"if",
"'>'",
"in",
"names",
"... | print matrix of pidents to stdout | [
"print",
"matrix",
"of",
"pidents",
"to",
"stdout"
] | 83b2566b3a5745437ec651cd6cafddd056846240 | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/compare_aligned.py#L132-L155 | train |
christophertbrown/bioscripts | ctbBio/compare_aligned.py | print_comps | def print_comps(comps):
"""
print stats for comparisons
"""
if comps == []:
print('n/a')
else:
print('# min: %s, max: %s, mean: %s' % \
(min(comps), max(comps), np.mean(comps))) | python | def print_comps(comps):
"""
print stats for comparisons
"""
if comps == []:
print('n/a')
else:
print('# min: %s, max: %s, mean: %s' % \
(min(comps), max(comps), np.mean(comps))) | [
"def",
"print_comps",
"(",
"comps",
")",
":",
"if",
"comps",
"==",
"[",
"]",
":",
"print",
"(",
"'n/a'",
")",
"else",
":",
"print",
"(",
"'# min: %s, max: %s, mean: %s'",
"%",
"(",
"min",
"(",
"comps",
")",
",",
"max",
"(",
"comps",
")",
",",
"np",
... | print stats for comparisons | [
"print",
"stats",
"for",
"comparisons"
] | 83b2566b3a5745437ec651cd6cafddd056846240 | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/compare_aligned.py#L157-L165 | train |
christophertbrown/bioscripts | ctbBio/compare_aligned.py | compare_clades | def compare_clades(pw):
"""
print min. pident within each clade and then matrix of between-clade max.
"""
names = sorted(set([i for i in pw]))
for i in range(0, 4):
wi, bt = {}, {}
for a in names:
for b in pw[a]:
if ';' not in a or ';' not in b:
... | python | def compare_clades(pw):
"""
print min. pident within each clade and then matrix of between-clade max.
"""
names = sorted(set([i for i in pw]))
for i in range(0, 4):
wi, bt = {}, {}
for a in names:
for b in pw[a]:
if ';' not in a or ';' not in b:
... | [
"def",
"compare_clades",
"(",
"pw",
")",
":",
"names",
"=",
"sorted",
"(",
"set",
"(",
"[",
"i",
"for",
"i",
"in",
"pw",
"]",
")",
")",
"for",
"i",
"in",
"range",
"(",
"0",
",",
"4",
")",
":",
"wi",
",",
"bt",
"=",
"{",
"}",
",",
"{",
"}"... | print min. pident within each clade and then matrix of between-clade max. | [
"print",
"min",
".",
"pident",
"within",
"each",
"clade",
"and",
"then",
"matrix",
"of",
"between",
"-",
"clade",
"max",
"."
] | 83b2566b3a5745437ec651cd6cafddd056846240 | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/compare_aligned.py#L167-L216 | train |
christophertbrown/bioscripts | ctbBio/compare_aligned.py | matrix2dictionary | def matrix2dictionary(matrix):
"""
convert matrix to dictionary of comparisons
"""
pw = {}
for line in matrix:
line = line.strip().split('\t')
if line[0].startswith('#'):
names = line[1:]
continue
a = line[0]
for i, pident in enumerate(line[1:]... | python | def matrix2dictionary(matrix):
"""
convert matrix to dictionary of comparisons
"""
pw = {}
for line in matrix:
line = line.strip().split('\t')
if line[0].startswith('#'):
names = line[1:]
continue
a = line[0]
for i, pident in enumerate(line[1:]... | [
"def",
"matrix2dictionary",
"(",
"matrix",
")",
":",
"pw",
"=",
"{",
"}",
"for",
"line",
"in",
"matrix",
":",
"line",
"=",
"line",
".",
"strip",
"(",
")",
".",
"split",
"(",
"'\\t'",
")",
"if",
"line",
"[",
"0",
"]",
".",
"startswith",
"(",
"'#'"... | convert matrix to dictionary of comparisons | [
"convert",
"matrix",
"to",
"dictionary",
"of",
"comparisons"
] | 83b2566b3a5745437ec651cd6cafddd056846240 | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/compare_aligned.py#L218-L239 | train |
mkouhei/bootstrap-py | bootstrap_py/commands.py | setoption | def setoption(parser, metadata=None):
"""Set argument parser option."""
parser.add_argument('-v', action='version',
version=__version__)
subparsers = parser.add_subparsers(help='sub commands help')
create_cmd = subparsers.add_parser('create')
create_cmd.add_argument('name',
... | python | def setoption(parser, metadata=None):
"""Set argument parser option."""
parser.add_argument('-v', action='version',
version=__version__)
subparsers = parser.add_subparsers(help='sub commands help')
create_cmd = subparsers.add_parser('create')
create_cmd.add_argument('name',
... | [
"def",
"setoption",
"(",
"parser",
",",
"metadata",
"=",
"None",
")",
":",
"parser",
".",
"add_argument",
"(",
"'-v'",
",",
"action",
"=",
"'version'",
",",
"version",
"=",
"__version__",
")",
"subparsers",
"=",
"parser",
".",
"add_subparsers",
"(",
"help"... | Set argument parser option. | [
"Set",
"argument",
"parser",
"option",
"."
] | 95d56ed98ef409fd9f019dc352fd1c3711533275 | https://github.com/mkouhei/bootstrap-py/blob/95d56ed98ef409fd9f019dc352fd1c3711533275/bootstrap_py/commands.py#L12-L51 | train |
mkouhei/bootstrap-py | bootstrap_py/commands.py | parse_options | def parse_options(metadata):
"""Parse argument options."""
parser = argparse.ArgumentParser(description='%(prog)s usage:',
prog=__prog__)
setoption(parser, metadata=metadata)
return parser | python | def parse_options(metadata):
"""Parse argument options."""
parser = argparse.ArgumentParser(description='%(prog)s usage:',
prog=__prog__)
setoption(parser, metadata=metadata)
return parser | [
"def",
"parse_options",
"(",
"metadata",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"'%(prog)s usage:'",
",",
"prog",
"=",
"__prog__",
")",
"setoption",
"(",
"parser",
",",
"metadata",
"=",
"metadata",
")",
"return",
... | Parse argument options. | [
"Parse",
"argument",
"options",
"."
] | 95d56ed98ef409fd9f019dc352fd1c3711533275 | https://github.com/mkouhei/bootstrap-py/blob/95d56ed98ef409fd9f019dc352fd1c3711533275/bootstrap_py/commands.py#L72-L77 | train |
mkouhei/bootstrap-py | bootstrap_py/commands.py | main | def main():
"""Execute main processes."""
try:
pkg_version = Update()
if pkg_version.updatable():
pkg_version.show_message()
metadata = control.retreive_metadata()
parser = parse_options(metadata)
argvs = sys.argv
if len(argvs) <= 1:
parser... | python | def main():
"""Execute main processes."""
try:
pkg_version = Update()
if pkg_version.updatable():
pkg_version.show_message()
metadata = control.retreive_metadata()
parser = parse_options(metadata)
argvs = sys.argv
if len(argvs) <= 1:
parser... | [
"def",
"main",
"(",
")",
":",
"try",
":",
"pkg_version",
"=",
"Update",
"(",
")",
"if",
"pkg_version",
".",
"updatable",
"(",
")",
":",
"pkg_version",
".",
"show_message",
"(",
")",
"metadata",
"=",
"control",
".",
"retreive_metadata",
"(",
")",
"parser"... | Execute main processes. | [
"Execute",
"main",
"processes",
"."
] | 95d56ed98ef409fd9f019dc352fd1c3711533275 | https://github.com/mkouhei/bootstrap-py/blob/95d56ed98ef409fd9f019dc352fd1c3711533275/bootstrap_py/commands.py#L80-L99 | train |
mkouhei/bootstrap-py | bootstrap_py/package.py | PackageData._check_or_set_default_params | def _check_or_set_default_params(self):
"""Check key and set default vaule when it does not exists."""
if not hasattr(self, 'date'):
self._set_param('date', datetime.utcnow().strftime('%Y-%m-%d'))
if not hasattr(self, 'version'):
self._set_param('version', self.default_ve... | python | def _check_or_set_default_params(self):
"""Check key and set default vaule when it does not exists."""
if not hasattr(self, 'date'):
self._set_param('date', datetime.utcnow().strftime('%Y-%m-%d'))
if not hasattr(self, 'version'):
self._set_param('version', self.default_ve... | [
"def",
"_check_or_set_default_params",
"(",
"self",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"'date'",
")",
":",
"self",
".",
"_set_param",
"(",
"'date'",
",",
"datetime",
".",
"utcnow",
"(",
")",
".",
"strftime",
"(",
"'%Y-%m-%d'",
")",
")",
... | Check key and set default vaule when it does not exists. | [
"Check",
"key",
"and",
"set",
"default",
"vaule",
"when",
"it",
"does",
"not",
"exists",
"."
] | 95d56ed98ef409fd9f019dc352fd1c3711533275 | https://github.com/mkouhei/bootstrap-py/blob/95d56ed98ef409fd9f019dc352fd1c3711533275/bootstrap_py/package.py#L44-L52 | train |
mkouhei/bootstrap-py | bootstrap_py/package.py | PackageTree.move | def move(self):
"""Move directory from working directory to output directory."""
if not os.path.isdir(self.outdir):
os.makedirs(self.outdir)
shutil.move(self.tmpdir, os.path.join(self.outdir, self.name)) | python | def move(self):
"""Move directory from working directory to output directory."""
if not os.path.isdir(self.outdir):
os.makedirs(self.outdir)
shutil.move(self.tmpdir, os.path.join(self.outdir, self.name)) | [
"def",
"move",
"(",
"self",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"isdir",
"(",
"self",
".",
"outdir",
")",
":",
"os",
".",
"makedirs",
"(",
"self",
".",
"outdir",
")",
"shutil",
".",
"move",
"(",
"self",
".",
"tmpdir",
",",
"os",
".",... | Move directory from working directory to output directory. | [
"Move",
"directory",
"from",
"working",
"directory",
"to",
"output",
"directory",
"."
] | 95d56ed98ef409fd9f019dc352fd1c3711533275 | https://github.com/mkouhei/bootstrap-py/blob/95d56ed98ef409fd9f019dc352fd1c3711533275/bootstrap_py/package.py#L169-L173 | train |
mkouhei/bootstrap-py | bootstrap_py/package.py | PackageTree.vcs_init | def vcs_init(self):
"""Initialize VCS repository."""
VCS(os.path.join(self.outdir, self.name), self.pkg_data) | python | def vcs_init(self):
"""Initialize VCS repository."""
VCS(os.path.join(self.outdir, self.name), self.pkg_data) | [
"def",
"vcs_init",
"(",
"self",
")",
":",
"VCS",
"(",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"outdir",
",",
"self",
".",
"name",
")",
",",
"self",
".",
"pkg_data",
")"
] | Initialize VCS repository. | [
"Initialize",
"VCS",
"repository",
"."
] | 95d56ed98ef409fd9f019dc352fd1c3711533275 | https://github.com/mkouhei/bootstrap-py/blob/95d56ed98ef409fd9f019dc352fd1c3711533275/bootstrap_py/package.py#L185-L187 | train |
scottrice/pysteam | pysteam/winutils.py | find_steam_location | def find_steam_location():
"""
Finds the location of the current Steam installation on Windows machines.
Returns None for any non-Windows machines, or for Windows machines where
Steam is not installed.
"""
if registry is None:
return None
key = registry.CreateKey(registry.HKEY_CURRENT_USER,"Software\... | python | def find_steam_location():
"""
Finds the location of the current Steam installation on Windows machines.
Returns None for any non-Windows machines, or for Windows machines where
Steam is not installed.
"""
if registry is None:
return None
key = registry.CreateKey(registry.HKEY_CURRENT_USER,"Software\... | [
"def",
"find_steam_location",
"(",
")",
":",
"if",
"registry",
"is",
"None",
":",
"return",
"None",
"key",
"=",
"registry",
".",
"CreateKey",
"(",
"registry",
".",
"HKEY_CURRENT_USER",
",",
"\"Software\\Valve\\Steam\"",
")",
"return",
"registry",
".",
"QueryValu... | Finds the location of the current Steam installation on Windows machines.
Returns None for any non-Windows machines, or for Windows machines where
Steam is not installed. | [
"Finds",
"the",
"location",
"of",
"the",
"current",
"Steam",
"installation",
"on",
"Windows",
"machines",
".",
"Returns",
"None",
"for",
"any",
"non",
"-",
"Windows",
"machines",
"or",
"for",
"Windows",
"machines",
"where",
"Steam",
"is",
"not",
"installed",
... | 1eb2254b5235a053a953e596fa7602d0b110245d | https://github.com/scottrice/pysteam/blob/1eb2254b5235a053a953e596fa7602d0b110245d/pysteam/winutils.py#L10-L20 | train |
smdabdoub/phylotoast | bin/PCoA_bubble.py | plot_PCoA | def plot_PCoA(cat_data, otu_name, unifrac, names, colors, xr, yr, outDir,
save_as, plot_style):
"""
Plot PCoA principal coordinates scaled by the relative abundances of
otu_name.
"""
fig = plt.figure(figsize=(14, 8))
ax = fig.add_subplot(111)
for i, cat in enumerate(cat_data):... | python | def plot_PCoA(cat_data, otu_name, unifrac, names, colors, xr, yr, outDir,
save_as, plot_style):
"""
Plot PCoA principal coordinates scaled by the relative abundances of
otu_name.
"""
fig = plt.figure(figsize=(14, 8))
ax = fig.add_subplot(111)
for i, cat in enumerate(cat_data):... | [
"def",
"plot_PCoA",
"(",
"cat_data",
",",
"otu_name",
",",
"unifrac",
",",
"names",
",",
"colors",
",",
"xr",
",",
"yr",
",",
"outDir",
",",
"save_as",
",",
"plot_style",
")",
":",
"fig",
"=",
"plt",
".",
"figure",
"(",
"figsize",
"=",
"(",
"14",
"... | Plot PCoA principal coordinates scaled by the relative abundances of
otu_name. | [
"Plot",
"PCoA",
"principal",
"coordinates",
"scaled",
"by",
"the",
"relative",
"abundances",
"of",
"otu_name",
"."
] | 0b74ef171e6a84761710548501dfac71285a58a3 | https://github.com/smdabdoub/phylotoast/blob/0b74ef171e6a84761710548501dfac71285a58a3/bin/PCoA_bubble.py#L36-L65 | train |
smdabdoub/phylotoast | bin/transpose_biom.py | split_by_category | def split_by_category(biom_cols, mapping, category_id):
"""
Split up the column data in a biom table by mapping category value.
"""
columns = defaultdict(list)
for i, col in enumerate(biom_cols):
columns[mapping[col['id']][category_id]].append((i, col))
return columns | python | def split_by_category(biom_cols, mapping, category_id):
"""
Split up the column data in a biom table by mapping category value.
"""
columns = defaultdict(list)
for i, col in enumerate(biom_cols):
columns[mapping[col['id']][category_id]].append((i, col))
return columns | [
"def",
"split_by_category",
"(",
"biom_cols",
",",
"mapping",
",",
"category_id",
")",
":",
"columns",
"=",
"defaultdict",
"(",
"list",
")",
"for",
"i",
",",
"col",
"in",
"enumerate",
"(",
"biom_cols",
")",
":",
"columns",
"[",
"mapping",
"[",
"col",
"["... | Split up the column data in a biom table by mapping category value. | [
"Split",
"up",
"the",
"column",
"data",
"in",
"a",
"biom",
"table",
"by",
"mapping",
"category",
"value",
"."
] | 0b74ef171e6a84761710548501dfac71285a58a3 | https://github.com/smdabdoub/phylotoast/blob/0b74ef171e6a84761710548501dfac71285a58a3/bin/transpose_biom.py#L17-L25 | train |
christophertbrown/bioscripts | ctbBio/stockholm2oneline.py | print_line | def print_line(l):
"""
print line if starts with ...
"""
print_lines = ['# STOCKHOLM', '#=GF', '#=GS', ' ']
if len(l.split()) == 0:
return True
for start in print_lines:
if l.startswith(start):
return True
return False | python | def print_line(l):
"""
print line if starts with ...
"""
print_lines = ['# STOCKHOLM', '#=GF', '#=GS', ' ']
if len(l.split()) == 0:
return True
for start in print_lines:
if l.startswith(start):
return True
return False | [
"def",
"print_line",
"(",
"l",
")",
":",
"print_lines",
"=",
"[",
"'# STOCKHOLM'",
",",
"'#=GF'",
",",
"'#=GS'",
",",
"' '",
"]",
"if",
"len",
"(",
"l",
".",
"split",
"(",
")",
")",
"==",
"0",
":",
"return",
"True",
"for",
"start",
"in",
"print_lin... | print line if starts with ... | [
"print",
"line",
"if",
"starts",
"with",
"..."
] | 83b2566b3a5745437ec651cd6cafddd056846240 | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/stockholm2oneline.py#L11-L21 | train |
christophertbrown/bioscripts | ctbBio/stockholm2oneline.py | stock2one | def stock2one(stock):
"""
convert stockholm to single line format
"""
lines = {}
for line in stock:
line = line.strip()
if print_line(line) is True:
yield line
continue
if line.startswith('//'):
continue
ID, seq = line.rsplit(' ', 1... | python | def stock2one(stock):
"""
convert stockholm to single line format
"""
lines = {}
for line in stock:
line = line.strip()
if print_line(line) is True:
yield line
continue
if line.startswith('//'):
continue
ID, seq = line.rsplit(' ', 1... | [
"def",
"stock2one",
"(",
"stock",
")",
":",
"lines",
"=",
"{",
"}",
"for",
"line",
"in",
"stock",
":",
"line",
"=",
"line",
".",
"strip",
"(",
")",
"if",
"print_line",
"(",
"line",
")",
"is",
"True",
":",
"yield",
"line",
"continue",
"if",
"line",
... | convert stockholm to single line format | [
"convert",
"stockholm",
"to",
"single",
"line",
"format"
] | 83b2566b3a5745437ec651cd6cafddd056846240 | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/stockholm2oneline.py#L23-L44 | train |
elbow-jason/Uno-deprecated | uno/helpers.py | math_func | def math_func(f):
"""
Statics the methods. wut.
"""
@wraps(f)
def wrapper(*args, **kwargs):
if len(args) > 0:
return_type = type(args[0])
if kwargs.has_key('return_type'):
return_type = kwargs['return_type']
kwargs.pop('return_type')
re... | python | def math_func(f):
"""
Statics the methods. wut.
"""
@wraps(f)
def wrapper(*args, **kwargs):
if len(args) > 0:
return_type = type(args[0])
if kwargs.has_key('return_type'):
return_type = kwargs['return_type']
kwargs.pop('return_type')
re... | [
"def",
"math_func",
"(",
"f",
")",
":",
"@",
"wraps",
"(",
"f",
")",
"def",
"wrapper",
"(",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"if",
"len",
"(",
"args",
")",
">",
"0",
":",
"return_type",
"=",
"type",
"(",
"args",
"[",
"0",
"]",
")",... | Statics the methods. wut. | [
"Statics",
"the",
"methods",
".",
"wut",
"."
] | 4ad07d7b84e5b6e3e2b2c89db69448906f24b4e4 | https://github.com/elbow-jason/Uno-deprecated/blob/4ad07d7b84e5b6e3e2b2c89db69448906f24b4e4/uno/helpers.py#L8-L22 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.