partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
train | MultiVarLinReg._modeldesc_to_dict | Return a string representation of a patsy ModelDesc object | opengrid/library/regression.py | def _modeldesc_to_dict(self, md):
"""Return a string representation of a patsy ModelDesc object"""
d = {'lhs_termlist': [md.lhs_termlist[0].factors[0].name()]}
rhs_termlist = []
# add other terms, if any
for term in md.rhs_termlist[:]:
if len(term.factors) == 0:
... | def _modeldesc_to_dict(self, md):
"""Return a string representation of a patsy ModelDesc object"""
d = {'lhs_termlist': [md.lhs_termlist[0].factors[0].name()]}
rhs_termlist = []
# add other terms, if any
for term in md.rhs_termlist[:]:
if len(term.factors) == 0:
... | [
"Return",
"a",
"string",
"representation",
"of",
"a",
"patsy",
"ModelDesc",
"object"
] | opengridcc/opengrid | python | https://github.com/opengridcc/opengrid/blob/69b8da3c8fcea9300226c45ef0628cd6d4307651/opengrid/library/regression.py#L459-L473 | [
"def",
"_modeldesc_to_dict",
"(",
"self",
",",
"md",
")",
":",
"d",
"=",
"{",
"'lhs_termlist'",
":",
"[",
"md",
".",
"lhs_termlist",
"[",
"0",
"]",
".",
"factors",
"[",
"0",
"]",
".",
"name",
"(",
")",
"]",
"}",
"rhs_termlist",
"=",
"[",
"]",
"# ... | 69b8da3c8fcea9300226c45ef0628cd6d4307651 |
train | MultiVarLinReg._modeldesc_from_dict | Return a string representation of a patsy ModelDesc object | opengrid/library/regression.py | def _modeldesc_from_dict(self, d):
"""Return a string representation of a patsy ModelDesc object"""
lhs_termlist = [Term([LookupFactor(d['lhs_termlist'][0])])]
rhs_termlist = []
for name in d['rhs_termlist']:
if name == '':
rhs_termlist.append(Term([]))
... | def _modeldesc_from_dict(self, d):
"""Return a string representation of a patsy ModelDesc object"""
lhs_termlist = [Term([LookupFactor(d['lhs_termlist'][0])])]
rhs_termlist = []
for name in d['rhs_termlist']:
if name == '':
rhs_termlist.append(Term([]))
... | [
"Return",
"a",
"string",
"representation",
"of",
"a",
"patsy",
"ModelDesc",
"object"
] | opengridcc/opengrid | python | https://github.com/opengridcc/opengrid/blob/69b8da3c8fcea9300226c45ef0628cd6d4307651/opengrid/library/regression.py#L475-L486 | [
"def",
"_modeldesc_from_dict",
"(",
"self",
",",
"d",
")",
":",
"lhs_termlist",
"=",
"[",
"Term",
"(",
"[",
"LookupFactor",
"(",
"d",
"[",
"'lhs_termlist'",
"]",
"[",
"0",
"]",
")",
"]",
")",
"]",
"rhs_termlist",
"=",
"[",
"]",
"for",
"name",
"in",
... | 69b8da3c8fcea9300226c45ef0628cd6d4307651 |
train | relative_abundance | 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... | phylotoast/biom_calc.py | 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):
"""
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... | [
"Calculate",
"the",
"relative",
"abundance",
"of",
"each",
"OTUID",
"in",
"a",
"Sample",
"."
] | smdabdoub/phylotoast | python | https://github.com/smdabdoub/phylotoast/blob/0b74ef171e6a84761710548501dfac71285a58a3/phylotoast/biom_calc.py#L11-L41 | [
"def",
"relative_abundance",
"(",
"biomf",
",",
"sampleIDs",
"=",
"None",
")",
":",
"if",
"sampleIDs",
"is",
"None",
":",
"sampleIDs",
"=",
"biomf",
".",
"ids",
"(",
")",
"else",
":",
"try",
":",
"for",
"sid",
"in",
"sampleIDs",
":",
"assert",
"sid",
... | 0b74ef171e6a84761710548501dfac71285a58a3 |
train | mean_otu_pct_abundance | 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
... | phylotoast/biom_calc.py | 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):
"""
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... | [
"Calculate",
"the",
"mean",
"OTU",
"abundance",
"percentage",
"."
] | smdabdoub/phylotoast | python | https://github.com/smdabdoub/phylotoast/blob/0b74ef171e6a84761710548501dfac71285a58a3/phylotoast/biom_calc.py#L44-L67 | [
"def",
"mean_otu_pct_abundance",
"(",
"ra",
",",
"otuIDs",
")",
":",
"sids",
"=",
"ra",
".",
"keys",
"(",
")",
"otumeans",
"=",
"defaultdict",
"(",
"int",
")",
"for",
"oid",
"in",
"otuIDs",
":",
"otumeans",
"[",
"oid",
"]",
"=",
"sum",
"(",
"[",
"r... | 0b74ef171e6a84761710548501dfac71285a58a3 |
train | MRA | 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
... | phylotoast/biom_calc.py | 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):
"""
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... | [
"Calculate",
"the",
"mean",
"relative",
"abundance",
"percentage",
"."
] | smdabdoub/phylotoast | python | https://github.com/smdabdoub/phylotoast/blob/0b74ef171e6a84761710548501dfac71285a58a3/phylotoast/biom_calc.py#L70-L92 | [
"def",
"MRA",
"(",
"biomf",
",",
"sampleIDs",
"=",
"None",
",",
"transform",
"=",
"None",
")",
":",
"ra",
"=",
"relative_abundance",
"(",
"biomf",
",",
"sampleIDs",
")",
"if",
"transform",
"is",
"not",
"None",
":",
"ra",
"=",
"{",
"sample",
":",
"{",... | 0b74ef171e6a84761710548501dfac71285a58a3 |
train | raw_abundance | 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... | phylotoast/biom_calc.py | 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):
"""
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
... | [
"Calculate",
"the",
"total",
"number",
"of",
"sequences",
"in",
"each",
"OTU",
"or",
"SampleID",
"."
] | smdabdoub/phylotoast | python | https://github.com/smdabdoub/phylotoast/blob/0b74ef171e6a84761710548501dfac71285a58a3/phylotoast/biom_calc.py#L95-L135 | [
"def",
"raw_abundance",
"(",
"biomf",
",",
"sampleIDs",
"=",
"None",
",",
"sample_abd",
"=",
"True",
")",
":",
"results",
"=",
"defaultdict",
"(",
"int",
")",
"if",
"sampleIDs",
"is",
"None",
":",
"sampleIDs",
"=",
"biomf",
".",
"ids",
"(",
")",
"else"... | 0b74ef171e6a84761710548501dfac71285a58a3 |
train | transform_raw_abundance | 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... | phylotoast/biom_calc.py | 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):
"""
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... | [
"Function",
"to",
"transform",
"the",
"total",
"abundance",
"calculation",
"for",
"each",
"sample",
"ID",
"to",
"another",
"format",
"based",
"on",
"user",
"given",
"transformation",
"function",
"."
] | smdabdoub/phylotoast | python | https://github.com/smdabdoub/phylotoast/blob/0b74ef171e6a84761710548501dfac71285a58a3/phylotoast/biom_calc.py#L138-L155 | [
"def",
"transform_raw_abundance",
"(",
"biomf",
",",
"fn",
"=",
"math",
".",
"log10",
",",
"sampleIDs",
"=",
"None",
",",
"sample_abd",
"=",
"True",
")",
":",
"totals",
"=",
"raw_abundance",
"(",
"biomf",
",",
"sampleIDs",
",",
"sample_abd",
")",
"return",... | 0b74ef171e6a84761710548501dfac71285a58a3 |
train | arcsine_sqrt_transform | Takes the proportion data from relative_abundance() and applies the
variance stabilizing arcsine square root transformation:
X = sin^{-1} \sqrt p | phylotoast/biom_calc.py | def arcsine_sqrt_transform(rel_abd):
"""
Takes the proportion data from relative_abundance() and applies the
variance stabilizing arcsine square root transformation:
X = sin^{-1} \sqrt p
"""
arcsint = lambda p: math.asin(math.sqrt(p))
return {col_id: {row_id: arcsint(rel_abd[col_id][row_id]... | def arcsine_sqrt_transform(rel_abd):
"""
Takes the proportion data from relative_abundance() and applies the
variance stabilizing arcsine square root transformation:
X = sin^{-1} \sqrt p
"""
arcsint = lambda p: math.asin(math.sqrt(p))
return {col_id: {row_id: arcsint(rel_abd[col_id][row_id]... | [
"Takes",
"the",
"proportion",
"data",
"from",
"relative_abundance",
"()",
"and",
"applies",
"the",
"variance",
"stabilizing",
"arcsine",
"square",
"root",
"transformation",
":"
] | smdabdoub/phylotoast | python | https://github.com/smdabdoub/phylotoast/blob/0b74ef171e6a84761710548501dfac71285a58a3/phylotoast/biom_calc.py#L158-L167 | [
"def",
"arcsine_sqrt_transform",
"(",
"rel_abd",
")",
":",
"arcsint",
"=",
"lambda",
"p",
":",
"math",
".",
"asin",
"(",
"math",
".",
"sqrt",
"(",
"p",
")",
")",
"return",
"{",
"col_id",
":",
"{",
"row_id",
":",
"arcsint",
"(",
"rel_abd",
"[",
"col_i... | 0b74ef171e6a84761710548501dfac71285a58a3 |
train | f2lookup | find and replace elements in lookup within file | ctbBio/lookup-word.py | def f2lookup(f, lookup):
"""
find and replace elements in lookup within file
"""
lookup = {i: r for i, r in [l.strip().split('\t')[0:2] for l in lookup]}
for line in f:
line = line.strip().split()
for i, w in enumerate(line):
if w in lookup:
line[i] = look... | def f2lookup(f, lookup):
"""
find and replace elements in lookup within file
"""
lookup = {i: r for i, r in [l.strip().split('\t')[0:2] for l in lookup]}
for line in f:
line = line.strip().split()
for i, w in enumerate(line):
if w in lookup:
line[i] = look... | [
"find",
"and",
"replace",
"elements",
"in",
"lookup",
"within",
"file"
] | christophertbrown/bioscripts | python | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/lookup-word.py#L10-L20 | [
"def",
"f2lookup",
"(",
"f",
",",
"lookup",
")",
":",
"lookup",
"=",
"{",
"i",
":",
"r",
"for",
"i",
",",
"r",
"in",
"[",
"l",
".",
"strip",
"(",
")",
".",
"split",
"(",
"'\\t'",
")",
"[",
"0",
":",
"2",
"]",
"for",
"l",
"in",
"lookup",
"... | 83b2566b3a5745437ec651cd6cafddd056846240 |
train | print_MannWhitneyU | Compute the Mann-Whitney U test for unequal group sample sizes. | bin/diversity.py | 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):
"""
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 "\
... | [
"Compute",
"the",
"Mann",
"-",
"Whitney",
"U",
"test",
"for",
"unequal",
"group",
"sample",
"sizes",
"."
] | smdabdoub/phylotoast | python | https://github.com/smdabdoub/phylotoast/blob/0b74ef171e6a84761710548501dfac71285a58a3/bin/diversity.py#L54-L66 | [
"def",
"print_MannWhitneyU",
"(",
"div_calc",
")",
":",
"try",
":",
"x",
"=",
"div_calc",
".",
"values",
"(",
")",
"[",
"0",
"]",
".",
"values",
"(",
")",
"y",
"=",
"div_calc",
".",
"values",
"(",
")",
"[",
"1",
"]",
".",
"values",
"(",
")",
"e... | 0b74ef171e6a84761710548501dfac71285a58a3 |
train | print_KruskalWallisH | Compute the Kruskal-Wallis H-test for independent samples. A typical rule is that
each group must have at least 5 measurements. | bin/diversity.py | 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):
"""
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():
... | [
"Compute",
"the",
"Kruskal",
"-",
"Wallis",
"H",
"-",
"test",
"for",
"independent",
"samples",
".",
"A",
"typical",
"rule",
"is",
"that",
"each",
"group",
"must",
"have",
"at",
"least",
"5",
"measurements",
"."
] | smdabdoub/phylotoast | python | https://github.com/smdabdoub/phylotoast/blob/0b74ef171e6a84761710548501dfac71285a58a3/bin/diversity.py#L69-L84 | [
"def",
"print_KruskalWallisH",
"(",
"div_calc",
")",
":",
"calc",
"=",
"defaultdict",
"(",
"list",
")",
"try",
":",
"for",
"k1",
",",
"v1",
"in",
"div_calc",
".",
"iteritems",
"(",
")",
":",
"for",
"k2",
",",
"v2",
"in",
"v1",
".",
"iteritems",
"(",
... | 0b74ef171e6a84761710548501dfac71285a58a3 |
train | write_diversity_metrics | Given a dictionary of diversity calculations (keyed by method)
write out the data to a file. | bin/diversity.py | def write_diversity_metrics(data, sample_ids, fp=None):
"""
Given a dictionary of diversity calculations (keyed by method)
write out the data to a file.
"""
if fp is None:
fp = "./diversity_data.txt"
with open(fp, "w") as outf:
out = csv.writer(outf, delimiter="\t")
out.... | def write_diversity_metrics(data, sample_ids, fp=None):
"""
Given a dictionary of diversity calculations (keyed by method)
write out the data to a file.
"""
if fp is None:
fp = "./diversity_data.txt"
with open(fp, "w") as outf:
out = csv.writer(outf, delimiter="\t")
out.... | [
"Given",
"a",
"dictionary",
"of",
"diversity",
"calculations",
"(",
"keyed",
"by",
"method",
")",
"write",
"out",
"the",
"data",
"to",
"a",
"file",
"."
] | smdabdoub/phylotoast | python | https://github.com/smdabdoub/phylotoast/blob/0b74ef171e6a84761710548501dfac71285a58a3/bin/diversity.py#L106-L119 | [
"def",
"write_diversity_metrics",
"(",
"data",
",",
"sample_ids",
",",
"fp",
"=",
"None",
")",
":",
"if",
"fp",
"is",
"None",
":",
"fp",
"=",
"\"./diversity_data.txt\"",
"with",
"open",
"(",
"fp",
",",
"\"w\"",
")",
"as",
"outf",
":",
"out",
"=",
"csv"... | 0b74ef171e6a84761710548501dfac71285a58a3 |
train | handle_program_options | Parses the given options passed in at the command line. | bin/diversity.py | 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():
"""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... | [
"Parses",
"the",
"given",
"options",
"passed",
"in",
"at",
"the",
"command",
"line",
"."
] | smdabdoub/phylotoast | python | https://github.com/smdabdoub/phylotoast/blob/0b74ef171e6a84761710548501dfac71285a58a3/bin/diversity.py#L122-L168 | [
"def",
"handle_program_options",
"(",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"\"Calculate the alpha diversity\\\n of a set of samples using one or more \\\n metrics and out... | 0b74ef171e6a84761710548501dfac71285a58a3 |
train | blastdb | make blast db | ctbBio/search.py | 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):
"""
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.... | [
"make",
"blast",
"db"
] | christophertbrown/bioscripts | python | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/search.py#L28-L46 | [
"def",
"blastdb",
"(",
"fasta",
",",
"maxfile",
"=",
"10000000",
")",
":",
"db",
"=",
"fasta",
".",
"rsplit",
"(",
"'.'",
",",
"1",
")",
"[",
"0",
"]",
"type",
"=",
"check_type",
"(",
"fasta",
")",
"if",
"type",
"==",
"'nucl'",
":",
"type",
"=",
... | 83b2566b3a5745437ec651cd6cafddd056846240 |
train | usearchdb | make usearch db | ctbBio/search.py | 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'):
"""
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... | [
"make",
"usearch",
"db"
] | christophertbrown/bioscripts | python | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/search.py#L68-L85 | [
"def",
"usearchdb",
"(",
"fasta",
",",
"alignment",
"=",
"'local'",
",",
"usearch_loc",
"=",
"'usearch'",
")",
":",
"if",
"'.udb'",
"in",
"fasta",
":",
"print",
"(",
"'# ... database found: %s'",
"%",
"(",
"fasta",
")",
",",
"file",
"=",
"sys",
".",
"std... | 83b2566b3a5745437ec651cd6cafddd056846240 |
train | phmmer | run phmmer | ctbBio/search.py | def phmmer(query, db, type, out, threads = '4', evalue = '0.01'):
"""
run phmmer
"""
if os.path.exists(out) is False:
print('# ... running phmmer with %s as query and %s as database' % (query, db))
os.system('phmmer -o %s.ph1 --tblout %s.ph2 --acc --noali --notextw -E %s --cpu %s %s %s' ... | def phmmer(query, db, type, out, threads = '4', evalue = '0.01'):
"""
run phmmer
"""
if os.path.exists(out) is False:
print('# ... running phmmer with %s as query and %s as database' % (query, db))
os.system('phmmer -o %s.ph1 --tblout %s.ph2 --acc --noali --notextw -E %s --cpu %s %s %s' ... | [
"run",
"phmmer"
] | christophertbrown/bioscripts | python | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/search.py#L100-L109 | [
"def",
"phmmer",
"(",
"query",
",",
"db",
",",
"type",
",",
"out",
",",
"threads",
"=",
"'4'",
",",
"evalue",
"=",
"'0.01'",
")",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"out",
")",
"is",
"False",
":",
"print",
"(",
"'# ... running phmmer... | 83b2566b3a5745437ec651cd6cafddd056846240 |
train | blast | run blast | ctbBio/search.py | def blast(query, db, type, out, threads = '4', maxtargets = '100', megablast = False):
"""
run blast
"""
if os.path.exists(out) is False:
db = blastdb(db) # make the database file, if necessary
print('# ... running blast with %s as query and %s as database' % (query, db))
if typ... | def blast(query, db, type, out, threads = '4', maxtargets = '100', megablast = False):
"""
run blast
"""
if os.path.exists(out) is False:
db = blastdb(db) # make the database file, if necessary
print('# ... running blast with %s as query and %s as database' % (query, db))
if typ... | [
"run",
"blast"
] | christophertbrown/bioscripts | python | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/search.py#L111-L129 | [
"def",
"blast",
"(",
"query",
",",
"db",
",",
"type",
",",
"out",
",",
"threads",
"=",
"'4'",
",",
"maxtargets",
"=",
"'100'",
",",
"megablast",
"=",
"False",
")",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"out",
")",
"is",
"False",
":",
... | 83b2566b3a5745437ec651cd6cafddd056846240 |
train | usearch5 | run usearch | ctbBio/search.py | def usearch5(query, db, type, out, threads = '4', evalue = '100', alignment = 'local'):
"""
run usearch
"""
if os.path.exists(out) is False:
print('# ... running usearch with %s as query and %s as database' % (query, db))
if type[1] == 'nucl':
threads = ''
else:
... | def usearch5(query, db, type, out, threads = '4', evalue = '100', alignment = 'local'):
"""
run usearch
"""
if os.path.exists(out) is False:
print('# ... running usearch with %s as query and %s as database' % (query, db))
if type[1] == 'nucl':
threads = ''
else:
... | [
"run",
"usearch"
] | christophertbrown/bioscripts | python | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/search.py#L131-L146 | [
"def",
"usearch5",
"(",
"query",
",",
"db",
",",
"type",
",",
"out",
",",
"threads",
"=",
"'4'",
",",
"evalue",
"=",
"'100'",
",",
"alignment",
"=",
"'local'",
")",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"out",
")",
"is",
"False",
":",... | 83b2566b3a5745437ec651cd6cafddd056846240 |
train | usearch | run usearch | ctbBio/search.py | def usearch(query, db, type, out, threads = '6', evalue = '100', alignment = 'local', max_hits = 100, cluster = False):
"""
run usearch
"""
if 'usearch64' in os.environ:
usearch_loc = os.environ['usearch64']
else:
usearch_loc = 'usearch'
if os.path.exists(out) is False:
d... | def usearch(query, db, type, out, threads = '6', evalue = '100', alignment = 'local', max_hits = 100, cluster = False):
"""
run usearch
"""
if 'usearch64' in os.environ:
usearch_loc = os.environ['usearch64']
else:
usearch_loc = 'usearch'
if os.path.exists(out) is False:
d... | [
"run",
"usearch"
] | christophertbrown/bioscripts | python | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/search.py#L148-L181 | [
"def",
"usearch",
"(",
"query",
",",
"db",
",",
"type",
",",
"out",
",",
"threads",
"=",
"'6'",
",",
"evalue",
"=",
"'100'",
",",
"alignment",
"=",
"'local'",
",",
"max_hits",
"=",
"100",
",",
"cluster",
"=",
"False",
")",
":",
"if",
"'usearch64'",
... | 83b2566b3a5745437ec651cd6cafddd056846240 |
train | WorkerToProcessPackets.run | run | network_pipeline/worker_to_process_packets.py | def run(self):
"""run"""
if self.callback:
log.info(("{} - using callback={}")
.format(self.name,
self.callback))
self.callback(name=self.response_name,
task_queue=self.task_queue,
... | def run(self):
"""run"""
if self.callback:
log.info(("{} - using callback={}")
.format(self.name,
self.callback))
self.callback(name=self.response_name,
task_queue=self.task_queue,
... | [
"run"
] | jay-johnson/network-pipeline | python | https://github.com/jay-johnson/network-pipeline/blob/4e53ae13fe12085e0cf2e5e1aff947368f4f1ffa/network_pipeline/worker_to_process_packets.py#L38-L73 | [
"def",
"run",
"(",
"self",
")",
":",
"if",
"self",
".",
"callback",
":",
"log",
".",
"info",
"(",
"(",
"\"{} - using callback={}\"",
")",
".",
"format",
"(",
"self",
".",
"name",
",",
"self",
".",
"callback",
")",
")",
"self",
".",
"callback",
"(",
... | 4e53ae13fe12085e0cf2e5e1aff947368f4f1ffa |
train | _pp | Pretty print. | bootstrap_py/control.py | 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):
"""Pretty print."""
for key, val in dict_data.items():
# pylint: disable=superfluous-parens
print('{0:<11}: {1}'.format(key, val)) | [
"Pretty",
"print",
"."
] | mkouhei/bootstrap-py | python | https://github.com/mkouhei/bootstrap-py/blob/95d56ed98ef409fd9f019dc352fd1c3711533275/bootstrap_py/control.py#L11-L15 | [
"def",
"_pp",
"(",
"dict_data",
")",
":",
"for",
"key",
",",
"val",
"in",
"dict_data",
".",
"items",
"(",
")",
":",
"# pylint: disable=superfluous-parens",
"print",
"(",
"'{0:<11}: {1}'",
".",
"format",
"(",
"key",
",",
"val",
")",
")"
] | 95d56ed98ef409fd9f019dc352fd1c3711533275 |
train | print_licences | Print licenses.
:param argparse.Namespace params: parameter
:param bootstrap_py.classifier.Classifiers metadata: package metadata | bootstrap_py/control.py | 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):
"""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) | [
"Print",
"licenses",
"."
] | mkouhei/bootstrap-py | python | https://github.com/mkouhei/bootstrap-py/blob/95d56ed98ef409fd9f019dc352fd1c3711533275/bootstrap_py/control.py#L27-L36 | [
"def",
"print_licences",
"(",
"params",
",",
"metadata",
")",
":",
"if",
"hasattr",
"(",
"params",
",",
"'licenses'",
")",
":",
"if",
"params",
".",
"licenses",
":",
"_pp",
"(",
"metadata",
".",
"licenses_desc",
"(",
")",
")",
"sys",
".",
"exit",
"(",
... | 95d56ed98ef409fd9f019dc352fd1c3711533275 |
train | check_repository_existence | Check repository existence.
:param argparse.Namespace params: parameters | bootstrap_py/control.py | 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):
"""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)) | [
"Check",
"repository",
"existence",
"."
] | mkouhei/bootstrap-py | python | https://github.com/mkouhei/bootstrap-py/blob/95d56ed98ef409fd9f019dc352fd1c3711533275/bootstrap_py/control.py#L39-L47 | [
"def",
"check_repository_existence",
"(",
"params",
")",
":",
"repodir",
"=",
"os",
".",
"path",
".",
"join",
"(",
"params",
".",
"outdir",
",",
"params",
".",
"name",
")",
"if",
"os",
".",
"path",
".",
"isdir",
"(",
"repodir",
")",
":",
"raise",
"Co... | 95d56ed98ef409fd9f019dc352fd1c3711533275 |
train | generate_package | Generate package repository.
:param argparse.Namespace params: parameters | bootstrap_py/control.py | 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):
"""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... | [
"Generate",
"package",
"repository",
"."
] | mkouhei/bootstrap-py | python | https://github.com/mkouhei/bootstrap-py/blob/95d56ed98ef409fd9f019dc352fd1c3711533275/bootstrap_py/control.py#L59-L68 | [
"def",
"generate_package",
"(",
"params",
")",
":",
"pkg_data",
"=",
"package",
".",
"PackageData",
"(",
"params",
")",
"pkg_tree",
"=",
"package",
".",
"PackageTree",
"(",
"pkg_data",
")",
"pkg_tree",
".",
"generate",
"(",
")",
"pkg_tree",
".",
"move",
"(... | 95d56ed98ef409fd9f019dc352fd1c3711533275 |
train | print_single | print single reads to stderr | ctbBio/sam2fastq.py | 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):
"""
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) | [
"print",
"single",
"reads",
"to",
"stderr"
] | christophertbrown/bioscripts | python | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/sam2fastq.py#L13-L24 | [
"def",
"print_single",
"(",
"line",
",",
"rev",
")",
":",
"if",
"rev",
"is",
"True",
":",
"seq",
"=",
"rc",
"(",
"[",
"''",
",",
"line",
"[",
"9",
"]",
"]",
")",
"[",
"1",
"]",
"qual",
"=",
"line",
"[",
"10",
"]",
"[",
":",
":",
"-",
"1",... | 83b2566b3a5745437ec651cd6cafddd056846240 |
train | sam2fastq | convert sam to fastq | ctbBio/sam2fastq.py | 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):
"""
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])... | [
"convert",
"sam",
"to",
"fastq"
] | christophertbrown/bioscripts | python | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/sam2fastq.py#L26-L78 | [
"def",
"sam2fastq",
"(",
"sam",
",",
"singles",
"=",
"False",
",",
"force",
"=",
"False",
")",
":",
"L",
",",
"R",
"=",
"None",
",",
"None",
"for",
"line",
"in",
"sam",
":",
"if",
"line",
".",
"startswith",
"(",
"'@'",
")",
"is",
"True",
":",
"... | 83b2566b3a5745437ec651cd6cafddd056846240 |
train | sort_sam | sort sam file | ctbBio/subset_sam.py | 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):
"""
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("\
... | [
"sort",
"sam",
"file"
] | christophertbrown/bioscripts | python | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/subset_sam.py#L14-L37 | [
"def",
"sort_sam",
"(",
"sam",
",",
"sort",
")",
":",
"tempdir",
"=",
"'%s/'",
"%",
"(",
"os",
".",
"path",
".",
"abspath",
"(",
"sam",
")",
".",
"rsplit",
"(",
"'/'",
",",
"1",
")",
"[",
"0",
"]",
")",
"if",
"sort",
"is",
"True",
":",
"mappi... | 83b2566b3a5745437ec651cd6cafddd056846240 |
train | sub_sam | randomly subset sam file | ctbBio/subset_sam.py | 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):
"""
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... | [
"randomly",
"subset",
"sam",
"file"
] | christophertbrown/bioscripts | python | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/subset_sam.py#L39-L60 | [
"def",
"sub_sam",
"(",
"sam",
",",
"percent",
",",
"sort",
"=",
"True",
",",
"sbuffer",
"=",
"False",
")",
":",
"mapping",
"=",
"sort_sam",
"(",
"sam",
",",
"sort",
")",
"pool",
"=",
"[",
"1",
"for",
"i",
"in",
"range",
"(",
"0",
",",
"percent",
... | 83b2566b3a5745437ec651cd6cafddd056846240 |
train | fq2fa | convert fq to fa | ctbBio/fastq2fasta.py | 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):
"""
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 | [
"convert",
"fq",
"to",
"fa"
] | christophertbrown/bioscripts | python | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/fastq2fasta.py#L11-L22 | [
"def",
"fq2fa",
"(",
"fq",
")",
":",
"c",
"=",
"cycle",
"(",
"[",
"1",
",",
"2",
",",
"3",
",",
"4",
"]",
")",
"for",
"line",
"in",
"fq",
":",
"n",
"=",
"next",
"(",
"c",
")",
"if",
"n",
"==",
"1",
":",
"seq",
"=",
"[",
"'>%s'",
"%",
... | 83b2566b3a5745437ec651cd6cafddd056846240 |
train | f2lookup | find and replace elements in lookup within file | ctbBio/lookup.py | def f2lookup(f, lookup):
"""
find and replace elements in lookup within file
"""
lookup = {i: r for i, r in [l.strip().split('\t')[0:2] for l in lookup]}
for line in f:
line = line.strip()
for find, replace in list(lookup.items()):
line = line.replace(find, replace)
yield line | def f2lookup(f, lookup):
"""
find and replace elements in lookup within file
"""
lookup = {i: r for i, r in [l.strip().split('\t')[0:2] for l in lookup]}
for line in f:
line = line.strip()
for find, replace in list(lookup.items()):
line = line.replace(find, replace)
yield line | [
"find",
"and",
"replace",
"elements",
"in",
"lookup",
"within",
"file"
] | christophertbrown/bioscripts | python | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/lookup.py#L10-L19 | [
"def",
"f2lookup",
"(",
"f",
",",
"lookup",
")",
":",
"lookup",
"=",
"{",
"i",
":",
"r",
"for",
"i",
",",
"r",
"in",
"[",
"l",
".",
"strip",
"(",
")",
".",
"split",
"(",
"'\\t'",
")",
"[",
"0",
":",
"2",
"]",
"for",
"l",
"in",
"lookup",
"... | 83b2566b3a5745437ec651cd6cafddd056846240 |
train | change_return_type | 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. | uno/decorators.py | 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):
"""
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_... | [
"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",
"."
] | elbow-jason/Uno-deprecated | python | https://github.com/elbow-jason/Uno-deprecated/blob/4ad07d7b84e5b6e3e2b2c89db69448906f24b4e4/uno/decorators.py#L11-L27 | [
"def",
"change_return_type",
"(",
"f",
")",
":",
"@",
"wraps",
"(",
"f",
")",
"def",
"wrapper",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"kwargs",
".",
"has_key",
"(",
"'return_type'",
")",
":",
"return_type",
"=",
"kwargs",
"[",
... | 4ad07d7b84e5b6e3e2b2c89db69448906f24b4e4 |
train | convert_args_to_sets | Converts all args to 'set' type via self.setify function. | uno/decorators.py | 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):
"""
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 | [
"Converts",
"all",
"args",
"to",
"set",
"type",
"via",
"self",
".",
"setify",
"function",
"."
] | elbow-jason/Uno-deprecated | python | https://github.com/elbow-jason/Uno-deprecated/blob/4ad07d7b84e5b6e3e2b2c89db69448906f24b4e4/uno/decorators.py#L30-L38 | [
"def",
"convert_args_to_sets",
"(",
"f",
")",
":",
"@",
"wraps",
"(",
"f",
")",
"def",
"wrapper",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"args",
"=",
"(",
"setify",
"(",
"x",
")",
"for",
"x",
"in",
"args",
")",
"return",
"f",
"(",... | 4ad07d7b84e5b6e3e2b2c89db69448906f24b4e4 |
train | accessible | Makes class properties accessible to self.__class__ (i hope) to via creation of an '_accessible_<property>' attr. | uno/decorators.py | def accessible(f):
"""
Makes class properties accessible to self.__class__ (i hope) to via creation of an '_accessible_<property>' attr.
"""
@wraps(f)
def wrapper(*args, **kwargs):
print 'KWARGS= ', kwargs
setattr(args[0], kwargs['name'], args[1])
print "property: ", str(geta... | def accessible(f):
"""
Makes class properties accessible to self.__class__ (i hope) to via creation of an '_accessible_<property>' attr.
"""
@wraps(f)
def wrapper(*args, **kwargs):
print 'KWARGS= ', kwargs
setattr(args[0], kwargs['name'], args[1])
print "property: ", str(geta... | [
"Makes",
"class",
"properties",
"accessible",
"to",
"self",
".",
"__class__",
"(",
"i",
"hope",
")",
"to",
"via",
"creation",
"of",
"an",
"_accessible_<property",
">",
"attr",
"."
] | elbow-jason/Uno-deprecated | python | https://github.com/elbow-jason/Uno-deprecated/blob/4ad07d7b84e5b6e3e2b2c89db69448906f24b4e4/uno/decorators.py#L41-L51 | [
"def",
"accessible",
"(",
"f",
")",
":",
"@",
"wraps",
"(",
"f",
")",
"def",
"wrapper",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"print",
"'KWARGS= '",
",",
"kwargs",
"setattr",
"(",
"args",
"[",
"0",
"]",
",",
"kwargs",
"[",
"'name'"... | 4ad07d7b84e5b6e3e2b2c89db69448906f24b4e4 |
train | tokenize | Tokenize a string (passed as argument or read from stdin)
segments [--profile=PATH/TO/PROFILE] tokenize [STRING] | src/segments/__main__.py | def tokenize(args):
"""
Tokenize a string (passed as argument or read from stdin)
segments [--profile=PATH/TO/PROFILE] tokenize [STRING]
"""
if args.profile and not Path(args.profile).exists(): # pragma: no cover
raise ParserError('--profile must be a path for an existing file')
_write... | def tokenize(args):
"""
Tokenize a string (passed as argument or read from stdin)
segments [--profile=PATH/TO/PROFILE] tokenize [STRING]
"""
if args.profile and not Path(args.profile).exists(): # pragma: no cover
raise ParserError('--profile must be a path for an existing file')
_write... | [
"Tokenize",
"a",
"string",
"(",
"passed",
"as",
"argument",
"or",
"read",
"from",
"stdin",
")"
] | cldf/segments | python | https://github.com/cldf/segments/blob/9136a4ec89555bf9b574399ffbb07f3cc9a9f45f/src/segments/__main__.py#L27-L35 | [
"def",
"tokenize",
"(",
"args",
")",
":",
"if",
"args",
".",
"profile",
"and",
"not",
"Path",
"(",
"args",
".",
"profile",
")",
".",
"exists",
"(",
")",
":",
"# pragma: no cover",
"raise",
"ParserError",
"(",
"'--profile must be a path for an existing file'",
... | 9136a4ec89555bf9b574399ffbb07f3cc9a9f45f |
train | ambil_teks_dalam_label | Mengambil semua teks dalam sup label HTML (tanpa anak-anaknya).
:param sup: BeautifulSoup dari suatu label HTML
:type sup: BeautifulSoup
:returns: String semua teks dalam sup label HTML
:rtype: str | kbbi/kbbi.py | def ambil_teks_dalam_label(sup):
"""Mengambil semua teks dalam sup label HTML (tanpa anak-anaknya).
:param sup: BeautifulSoup dari suatu label HTML
:type sup: BeautifulSoup
:returns: String semua teks dalam sup label HTML
:rtype: str
"""
return ''.join(i.strip() for i in sup.find_all(text=T... | def ambil_teks_dalam_label(sup):
"""Mengambil semua teks dalam sup label HTML (tanpa anak-anaknya).
:param sup: BeautifulSoup dari suatu label HTML
:type sup: BeautifulSoup
:returns: String semua teks dalam sup label HTML
:rtype: str
"""
return ''.join(i.strip() for i in sup.find_all(text=T... | [
"Mengambil",
"semua",
"teks",
"dalam",
"sup",
"label",
"HTML",
"(",
"tanpa",
"anak",
"-",
"anaknya",
")",
"."
] | laymonage/kbbi-python | python | https://github.com/laymonage/kbbi-python/blob/1a52ba8bcc6dc4c5c1215f9e00207aca264287d6/kbbi/kbbi.py#L324-L332 | [
"def",
"ambil_teks_dalam_label",
"(",
"sup",
")",
":",
"return",
"''",
".",
"join",
"(",
"i",
".",
"strip",
"(",
")",
"for",
"i",
"in",
"sup",
".",
"find_all",
"(",
"text",
"=",
"True",
",",
"recursive",
"=",
"False",
")",
")"
] | 1a52ba8bcc6dc4c5c1215f9e00207aca264287d6 |
train | KBBI._init_entri | Membuat objek-objek entri dari laman yang diambil.
:param laman: Laman respons yang dikembalikan oleh KBBI daring.
:type laman: Response | kbbi/kbbi.py | 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):
"""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... | [
"Membuat",
"objek",
"-",
"objek",
"entri",
"dari",
"laman",
"yang",
"diambil",
"."
] | laymonage/kbbi-python | python | https://github.com/laymonage/kbbi-python/blob/1a52ba8bcc6dc4c5c1215f9e00207aca264287d6/kbbi/kbbi.py#L46-L63 | [
"def",
"_init_entri",
"(",
"self",
",",
"laman",
")",
":",
"sup",
"=",
"BeautifulSoup",
"(",
"laman",
".",
"text",
",",
"'html.parser'",
")",
"estr",
"=",
"''",
"for",
"label",
"in",
"sup",
".",
"find",
"(",
"'hr'",
")",
".",
"next_siblings",
":",
"i... | 1a52ba8bcc6dc4c5c1215f9e00207aca264287d6 |
train | Entri._init_kata_dasar | Memproses kata dasar yang ada dalam nama entri.
:param dasar: ResultSet untuk label HTML dengan class="rootword"
:type dasar: ResultSet | kbbi/kbbi.py | 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):
"""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')
... | [
"Memproses",
"kata",
"dasar",
"yang",
"ada",
"dalam",
"nama",
"entri",
"."
] | laymonage/kbbi-python | python | https://github.com/laymonage/kbbi-python/blob/1a52ba8bcc6dc4c5c1215f9e00207aca264287d6/kbbi/kbbi.py#L126-L139 | [
"def",
"_init_kata_dasar",
"(",
"self",
",",
"dasar",
")",
":",
"for",
"tiap",
"in",
"dasar",
":",
"kata",
"=",
"tiap",
".",
"find",
"(",
"'a'",
")",
"dasar_no",
"=",
"kata",
".",
"find",
"(",
"'sup'",
")",
"kata",
"=",
"ambil_teks_dalam_label",
"(",
... | 1a52ba8bcc6dc4c5c1215f9e00207aca264287d6 |
train | Entri.serialisasi | Mengembalikan hasil serialisasi objek Entri ini.
:returns: Dictionary hasil serialisasi
:rtype: dict | kbbi/kbbi.py | 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):
"""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... | [
"Mengembalikan",
"hasil",
"serialisasi",
"objek",
"Entri",
"ini",
"."
] | laymonage/kbbi-python | python | https://github.com/laymonage/kbbi-python/blob/1a52ba8bcc6dc4c5c1215f9e00207aca264287d6/kbbi/kbbi.py#L141-L156 | [
"def",
"serialisasi",
"(",
"self",
")",
":",
"return",
"{",
"\"nama\"",
":",
"self",
".",
"nama",
",",
"\"nomor\"",
":",
"self",
".",
"nomor",
",",
"\"kata_dasar\"",
":",
"self",
".",
"kata_dasar",
",",
"\"pelafalan\"",
":",
"self",
".",
"pelafalan",
","... | 1a52ba8bcc6dc4c5c1215f9e00207aca264287d6 |
train | Entri._makna | Mengembalikan representasi string untuk semua makna entri ini.
:returns: String representasi makna-makna
:rtype: str | kbbi/kbbi.py | 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):
"""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... | [
"Mengembalikan",
"representasi",
"string",
"untuk",
"semua",
"makna",
"entri",
"ini",
"."
] | laymonage/kbbi-python | python | https://github.com/laymonage/kbbi-python/blob/1a52ba8bcc6dc4c5c1215f9e00207aca264287d6/kbbi/kbbi.py#L158-L170 | [
"def",
"_makna",
"(",
"self",
")",
":",
"if",
"len",
"(",
"self",
".",
"makna",
")",
">",
"1",
":",
"return",
"'\\n'",
".",
"join",
"(",
"str",
"(",
"i",
")",
"+",
"\". \"",
"+",
"str",
"(",
"makna",
")",
"for",
"i",
",",
"makna",
"in",
"enum... | 1a52ba8bcc6dc4c5c1215f9e00207aca264287d6 |
train | Entri._nama | Mengembalikan representasi string untuk nama entri ini.
:returns: String representasi nama entri
:rtype: str | kbbi/kbbi.py | 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):
"""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... | [
"Mengembalikan",
"representasi",
"string",
"untuk",
"nama",
"entri",
"ini",
"."
] | laymonage/kbbi-python | python | https://github.com/laymonage/kbbi-python/blob/1a52ba8bcc6dc4c5c1215f9e00207aca264287d6/kbbi/kbbi.py#L172-L184 | [
"def",
"_nama",
"(",
"self",
")",
":",
"hasil",
"=",
"self",
".",
"nama",
"if",
"self",
".",
"nomor",
":",
"hasil",
"+=",
"\" [{}]\"",
".",
"format",
"(",
"self",
".",
"nomor",
")",
"if",
"self",
".",
"kata_dasar",
":",
"hasil",
"=",
"\" » \".",
"j... | 1a52ba8bcc6dc4c5c1215f9e00207aca264287d6 |
train | Entri._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
:rtype: str | kbbi/kbbi.py | 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):
"""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
... | [
"Mengembalikan",
"representasi",
"string",
"untuk",
"varian",
"entri",
"ini",
".",
"Dapat",
"digunakan",
"untuk",
"Varian",
"maupun",
"Bentuk",
"tidak",
"baku",
"."
] | laymonage/kbbi-python | python | https://github.com/laymonage/kbbi-python/blob/1a52ba8bcc6dc4c5c1215f9e00207aca264287d6/kbbi/kbbi.py#L186-L202 | [
"def",
"_varian",
"(",
"self",
",",
"varian",
")",
":",
"if",
"varian",
"==",
"self",
".",
"bentuk_tidak_baku",
":",
"nama",
"=",
"\"Bentuk tidak baku\"",
"elif",
"varian",
"==",
"self",
".",
"varian",
":",
"nama",
"=",
"\"Varian\"",
"else",
":",
"return",... | 1a52ba8bcc6dc4c5c1215f9e00207aca264287d6 |
train | Makna._init_kelas | Memproses kelas kata yang ada dalam makna.
:param makna_label: BeautifulSoup untuk makna yang ingin diproses.
:type makna_label: BeautifulSoup | kbbi/kbbi.py | 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):
"""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')
... | [
"Memproses",
"kelas",
"kata",
"yang",
"ada",
"dalam",
"makna",
"."
] | laymonage/kbbi-python | python | https://github.com/laymonage/kbbi-python/blob/1a52ba8bcc6dc4c5c1215f9e00207aca264287d6/kbbi/kbbi.py#L239-L259 | [
"def",
"_init_kelas",
"(",
"self",
",",
"makna_label",
")",
":",
"kelas",
"=",
"makna_label",
".",
"find",
"(",
"color",
"=",
"'red'",
")",
"lain",
"=",
"makna_label",
".",
"find",
"(",
"color",
"=",
"'darkgreen'",
")",
"info",
"=",
"makna_label",
".",
... | 1a52ba8bcc6dc4c5c1215f9e00207aca264287d6 |
train | Makna._init_contoh | Memproses contoh yang ada dalam makna.
:param makna_label: BeautifulSoup untuk makna yang ingin diproses.
:type makna_label: BeautifulSoup | kbbi/kbbi.py | 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):
"""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.... | [
"Memproses",
"contoh",
"yang",
"ada",
"dalam",
"makna",
"."
] | laymonage/kbbi-python | python | https://github.com/laymonage/kbbi-python/blob/1a52ba8bcc6dc4c5c1215f9e00207aca264287d6/kbbi/kbbi.py#L261-L273 | [
"def",
"_init_contoh",
"(",
"self",
",",
"makna_label",
")",
":",
"indeks",
"=",
"makna_label",
".",
"text",
".",
"find",
"(",
"': '",
")",
"if",
"indeks",
"!=",
"-",
"1",
":",
"contoh",
"=",
"makna_label",
".",
"text",
"[",
"indeks",
"+",
"2",
":",
... | 1a52ba8bcc6dc4c5c1215f9e00207aca264287d6 |
train | Makna.serialisasi | Mengembalikan hasil serialisasi objek Makna ini.
:returns: Dictionary hasil serialisasi
:rtype: dict | kbbi/kbbi.py | 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):
"""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
... | [
"Mengembalikan",
"hasil",
"serialisasi",
"objek",
"Makna",
"ini",
"."
] | laymonage/kbbi-python | python | https://github.com/laymonage/kbbi-python/blob/1a52ba8bcc6dc4c5c1215f9e00207aca264287d6/kbbi/kbbi.py#L275-L287 | [
"def",
"serialisasi",
"(",
"self",
")",
":",
"return",
"{",
"\"kelas\"",
":",
"self",
".",
"kelas",
",",
"\"submakna\"",
":",
"self",
".",
"submakna",
",",
"\"info\"",
":",
"self",
".",
"info",
",",
"\"contoh\"",
":",
"self",
".",
"contoh",
"}"
] | 1a52ba8bcc6dc4c5c1215f9e00207aca264287d6 |
train | send_tcp_message | send_tcp_message
Send a ``TCP`` message to port 80 by default. | network_pipeline/scripts/tcp_send_msg.py | def send_tcp_message():
"""send_tcp_message
Send a ``TCP`` message to port 80 by default.
"""
need_response = os.getenv("NEED_RESPONSE", "0") == "1"
msg = os.getenv(
"MSG",
"testing msg time={} - {}".format(
datetime.datetime.now().strftime("%Y-%m-%d %H:%M:... | def send_tcp_message():
"""send_tcp_message
Send a ``TCP`` message to port 80 by default.
"""
need_response = os.getenv("NEED_RESPONSE", "0") == "1"
msg = os.getenv(
"MSG",
"testing msg time={} - {}".format(
datetime.datetime.now().strftime("%Y-%m-%d %H:%M:... | [
"send_tcp_message"
] | jay-johnson/network-pipeline | python | https://github.com/jay-johnson/network-pipeline/blob/4e53ae13fe12085e0cf2e5e1aff947368f4f1ffa/network_pipeline/scripts/tcp_send_msg.py#L9-L34 | [
"def",
"send_tcp_message",
"(",
")",
":",
"need_response",
"=",
"os",
".",
"getenv",
"(",
"\"NEED_RESPONSE\"",
",",
"\"0\"",
")",
"==",
"\"1\"",
"msg",
"=",
"os",
".",
"getenv",
"(",
"\"MSG\"",
",",
"\"testing msg time={} - {}\"",
".",
"format",
"(",
"dateti... | 4e53ae13fe12085e0cf2e5e1aff947368f4f1ffa |
train | build_sphinx | 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 | bootstrap_py/docs.py | 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):
"""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... | [
"Build",
"sphinx",
"documentation",
"."
] | mkouhei/bootstrap-py | python | https://github.com/mkouhei/bootstrap-py/blob/95d56ed98ef409fd9f019dc352fd1c3711533275/bootstrap_py/docs.py#L8-L40 | [
"def",
"build_sphinx",
"(",
"pkg_data",
",",
"projectdir",
")",
":",
"try",
":",
"version",
",",
"_minor_version",
"=",
"pkg_data",
".",
"version",
".",
"rsplit",
"(",
"'.'",
",",
"1",
")",
"except",
"ValueError",
":",
"version",
"=",
"pkg_data",
".",
"v... | 95d56ed98ef409fd9f019dc352fd1c3711533275 |
train | promise_method | A decorator which ensures that once a method has been marked as resolved
(via Class.__resolved)) will then propagate the attribute (function) call
upstream. | nydus/db/promise.py | def promise_method(func):
"""
A decorator which ensures that once a method has been marked as resolved
(via Class.__resolved)) will then propagate the attribute (function) call
upstream.
"""
name = func.__name__
@wraps(func)
def wrapped(self, *args, **kwargs):
cls_name = type(se... | def promise_method(func):
"""
A decorator which ensures that once a method has been marked as resolved
(via Class.__resolved)) will then propagate the attribute (function) call
upstream.
"""
name = func.__name__
@wraps(func)
def wrapped(self, *args, **kwargs):
cls_name = type(se... | [
"A",
"decorator",
"which",
"ensures",
"that",
"once",
"a",
"method",
"has",
"been",
"marked",
"as",
"resolved",
"(",
"via",
"Class",
".",
"__resolved",
"))",
"will",
"then",
"propagate",
"the",
"attribute",
"(",
"function",
")",
"call",
"upstream",
"."
] | disqus/nydus | python | https://github.com/disqus/nydus/blob/9b505840da47a34f758a830c3992fa5dcb7bb7ad/nydus/db/promise.py#L13-L27 | [
"def",
"promise_method",
"(",
"func",
")",
":",
"name",
"=",
"func",
".",
"__name__",
"@",
"wraps",
"(",
"func",
")",
"def",
"wrapped",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"cls_name",
"=",
"type",
"(",
"self",
")",
"... | 9b505840da47a34f758a830c3992fa5dcb7bb7ad |
train | bowtiedb | make bowtie db | ctbBio/crossmap.py | 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):
"""
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... | [
"make",
"bowtie",
"db"
] | christophertbrown/bioscripts | python | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/crossmap.py#L16-L31 | [
"def",
"bowtiedb",
"(",
"fa",
",",
"keepDB",
")",
":",
"btdir",
"=",
"'%s/bt2'",
"%",
"(",
"os",
".",
"getcwd",
"(",
")",
")",
"# make directory for",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"btdir",
")",
":",
"os",
".",
"mkdir",
"(",
... | 83b2566b3a5745437ec651cd6cafddd056846240 |
train | bowtie | generate bowtie2 command | ctbBio/crossmap.py | 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):
"""
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... | [
"generate",
"bowtie2",
"command"
] | christophertbrown/bioscripts | python | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/crossmap.py#L33-L50 | [
"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"... | 83b2566b3a5745437ec651cd6cafddd056846240 |
train | crossmap | map all read sets against all fasta files | ctbBio/crossmap.py | 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):
"""
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... | [
"map",
"all",
"read",
"sets",
"against",
"all",
"fasta",
"files"
] | christophertbrown/bioscripts | python | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/crossmap.py#L55-L96 | [
"def",
"crossmap",
"(",
"fas",
",",
"reads",
",",
"options",
",",
"no_shrink",
",",
"keepDB",
",",
"threads",
",",
"cluster",
",",
"nodes",
")",
":",
"if",
"cluster",
"is",
"True",
":",
"threads",
"=",
"'48'",
"btc",
"=",
"[",
"]",
"for",
"fa",
"in... | 83b2566b3a5745437ec651cd6cafddd056846240 |
train | BaseCluster.get_conn | 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. | nydus/db/base.py | 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):
"""
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... | [
"Returns",
"a",
"connection",
"object",
"from",
"the",
"router",
"given",
"args",
"."
] | disqus/nydus | python | https://github.com/disqus/nydus/blob/9b505840da47a34f758a830c3992fa5dcb7bb7ad/nydus/db/base.py#L100-L113 | [
"def",
"get_conn",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"connections",
"=",
"self",
".",
"__connections_for",
"(",
"'get_conn'",
",",
"args",
"=",
"args",
",",
"kwargs",
"=",
"kwargs",
")",
"if",
"len",
"(",
"connections",
... | 9b505840da47a34f758a830c3992fa5dcb7bb7ad |
train | mask_sequence | mask (make lower case) regions of sequence found in gaps between model alignments | ctbBio/23SfromHMM.py | def mask_sequence(seq, gaps):
"""
mask (make lower case) regions of sequence found in gaps between model alignments
"""
seq = [i.upper() for i in seq]
for gap in gaps:
for i in range(gap[0] - 1, gap[1]):
seq[i] = seq[i].lower()
return ''.join(seq) | def mask_sequence(seq, gaps):
"""
mask (make lower case) regions of sequence found in gaps between model alignments
"""
seq = [i.upper() for i in seq]
for gap in gaps:
for i in range(gap[0] - 1, gap[1]):
seq[i] = seq[i].lower()
return ''.join(seq) | [
"mask",
"(",
"make",
"lower",
"case",
")",
"regions",
"of",
"sequence",
"found",
"in",
"gaps",
"between",
"model",
"alignments"
] | christophertbrown/bioscripts | python | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/23SfromHMM.py#L176-L184 | [
"def",
"mask_sequence",
"(",
"seq",
",",
"gaps",
")",
":",
"seq",
"=",
"[",
"i",
".",
"upper",
"(",
")",
"for",
"i",
"in",
"seq",
"]",
"for",
"gap",
"in",
"gaps",
":",
"for",
"i",
"in",
"range",
"(",
"gap",
"[",
"0",
"]",
"-",
"1",
",",
"ga... | 83b2566b3a5745437ec651cd6cafddd056846240 |
train | find_23S | 1) parse hmm output into dictionary (sequence must pass bit_thresh and inc == '!')
seq2hmm[seq] = {model: [sstart, ssend, length, strand, score]}
2) determine which model (archaea, bacteria, eukarya) the sequence most closely matches
seq2hmm[seq] = [model, sstart, send, length, strand, score], [mod... | ctbBio/23SfromHMM.py | def find_23S(fastas, hmms, bit_thresh = float(20), length_thresh = 500, masking = True, buffer = 0):
"""
1) parse hmm output into dictionary (sequence must pass bit_thresh and inc == '!')
seq2hmm[seq] = {model: [sstart, ssend, length, strand, score]}
2) determine which model (archaea, bacteria, euk... | def find_23S(fastas, hmms, bit_thresh = float(20), length_thresh = 500, masking = True, buffer = 0):
"""
1) parse hmm output into dictionary (sequence must pass bit_thresh and inc == '!')
seq2hmm[seq] = {model: [sstart, ssend, length, strand, score]}
2) determine which model (archaea, bacteria, euk... | [
"1",
")",
"parse",
"hmm",
"output",
"into",
"dictionary",
"(",
"sequence",
"must",
"pass",
"bit_thresh",
"and",
"inc",
"==",
"!",
")",
"seq2hmm",
"[",
"seq",
"]",
"=",
"{",
"model",
":",
"[",
"sstart",
"ssend",
"length",
"strand",
"score",
"]",
"}",
... | christophertbrown/bioscripts | python | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/23SfromHMM.py#L194-L243 | [
"def",
"find_23S",
"(",
"fastas",
",",
"hmms",
",",
"bit_thresh",
"=",
"float",
"(",
"20",
")",
",",
"length_thresh",
"=",
"500",
",",
"masking",
"=",
"True",
",",
"buffer",
"=",
"0",
")",
":",
"# identify start/stop positions",
"# group2hmm[seq][group] = [mod... | 83b2566b3a5745437ec651cd6cafddd056846240 |
train | run_cmsearch | run cmsearch: comapre 23S sequences to ssu-align's CM | ctbBio/23SfromHMM.py | def run_cmsearch(fastas, threads, cm):
"""
run cmsearch: comapre 23S sequences to ssu-align's CM
"""
out = []
for fasta in fastas:
cmsearch = '%s.23S.cmsearch' % (fasta.name.rsplit('.', 1)[0])
if os.path.exists(cmsearch) is False:
p = Popen('\
cmsearch... | def run_cmsearch(fastas, threads, cm):
"""
run cmsearch: comapre 23S sequences to ssu-align's CM
"""
out = []
for fasta in fastas:
cmsearch = '%s.23S.cmsearch' % (fasta.name.rsplit('.', 1)[0])
if os.path.exists(cmsearch) is False:
p = Popen('\
cmsearch... | [
"run",
"cmsearch",
":",
"comapre",
"23S",
"sequences",
"to",
"ssu",
"-",
"align",
"s",
"CM"
] | christophertbrown/bioscripts | python | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/23SfromHMM.py#L245-L260 | [
"def",
"run_cmsearch",
"(",
"fastas",
",",
"threads",
",",
"cm",
")",
":",
"out",
"=",
"[",
"]",
"for",
"fasta",
"in",
"fastas",
":",
"cmsearch",
"=",
"'%s.23S.cmsearch'",
"%",
"(",
"fasta",
".",
"name",
".",
"rsplit",
"(",
"'.'",
",",
"1",
")",
"[... | 83b2566b3a5745437ec651cd6cafddd056846240 |
train | Crc.__get_nondirect_init | return the non-direct init if the direct algorithm has been selected. | pysteam/_crc_algorithms.py | 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):
"""
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:
... | [
"return",
"the",
"non",
"-",
"direct",
"init",
"if",
"the",
"direct",
"algorithm",
"has",
"been",
"selected",
"."
] | scottrice/pysteam | python | https://github.com/scottrice/pysteam/blob/1eb2254b5235a053a953e596fa7602d0b110245d/pysteam/_crc_algorithms.py#L98-L110 | [
"def",
"__get_nondirect_init",
"(",
"self",
",",
"init",
")",
":",
"crc",
"=",
"init",
"for",
"i",
"in",
"range",
"(",
"self",
".",
"Width",
")",
":",
"bit",
"=",
"crc",
"&",
"0x01",
"if",
"bit",
":",
"crc",
"^=",
"self",
".",
"Poly",
"crc",
">>=... | 1eb2254b5235a053a953e596fa7602d0b110245d |
train | Crc.reflect | reflect a data word, i.e. reverts the bit order. | pysteam/_crc_algorithms.py | 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):
"""
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 | [
"reflect",
"a",
"data",
"word",
"i",
".",
"e",
".",
"reverts",
"the",
"bit",
"order",
"."
] | scottrice/pysteam | python | https://github.com/scottrice/pysteam/blob/1eb2254b5235a053a953e596fa7602d0b110245d/pysteam/_crc_algorithms.py#L115-L123 | [
"def",
"reflect",
"(",
"self",
",",
"data",
",",
"width",
")",
":",
"x",
"=",
"data",
"&",
"0x01",
"for",
"i",
"in",
"range",
"(",
"width",
"-",
"1",
")",
":",
"data",
">>=",
"1",
"x",
"=",
"(",
"x",
"<<",
"1",
")",
"|",
"(",
"data",
"&",
... | 1eb2254b5235a053a953e596fa7602d0b110245d |
train | Crc.bit_by_bit | 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. | pysteam/_crc_algorithms.py | 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):
"""
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... | [
"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",
"."
] | scottrice/pysteam | python | https://github.com/scottrice/pysteam/blob/1eb2254b5235a053a953e596fa7602d0b110245d/pysteam/_crc_algorithms.py#L128-L156 | [
"def",
"bit_by_bit",
"(",
"self",
",",
"in_data",
")",
":",
"# If the input data is a string, convert to bytes.",
"if",
"isinstance",
"(",
"in_data",
",",
"str",
")",
":",
"in_data",
"=",
"[",
"ord",
"(",
"c",
")",
"for",
"c",
"in",
"in_data",
"]",
"register... | 1eb2254b5235a053a953e596fa7602d0b110245d |
train | Crc.gen_table | 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. | pysteam/_crc_algorithms.py | 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):
"""
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... | [
"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... | scottrice/pysteam | python | https://github.com/scottrice/pysteam/blob/1eb2254b5235a053a953e596fa7602d0b110245d/pysteam/_crc_algorithms.py#L190-L212 | [
"def",
"gen_table",
"(",
"self",
")",
":",
"table_length",
"=",
"1",
"<<",
"self",
".",
"TableIdxWidth",
"tbl",
"=",
"[",
"0",
"]",
"*",
"table_length",
"for",
"i",
"in",
"range",
"(",
"table_length",
")",
":",
"register",
"=",
"i",
"if",
"self",
"."... | 1eb2254b5235a053a953e596fa7602d0b110245d |
train | Crc.table_driven | The Standard table_driven CRC algorithm. | pysteam/_crc_algorithms.py | 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):
"""
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 <<... | [
"The",
"Standard",
"table_driven",
"CRC",
"algorithm",
"."
] | scottrice/pysteam | python | https://github.com/scottrice/pysteam/blob/1eb2254b5235a053a953e596fa7602d0b110245d/pysteam/_crc_algorithms.py#L217-L242 | [
"def",
"table_driven",
"(",
"self",
",",
"in_data",
")",
":",
"# 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",
... | 1eb2254b5235a053a953e596fa7602d0b110245d |
train | prune_taxonomy | :type taxF: file
:param taxF: The taxonomy output file to parse
:type level: string
:param level: The level of the phylogenetic assignment at which to cut off
every assigned taxonomic string.
:rtype: dict
:return: A dictionary of taxonomy strings keyed on OTU ID | bin/otu_condense.py | def prune_taxonomy(taxF, level):
"""
:type taxF: file
:param taxF: The taxonomy output file to parse
:type level: string
:param level: The level of the phylogenetic assignment at which to cut off
every assigned taxonomic string.
:rtype: dict
:return: A dictionary of taxon... | def prune_taxonomy(taxF, level):
"""
:type taxF: file
:param taxF: The taxonomy output file to parse
:type level: string
:param level: The level of the phylogenetic assignment at which to cut off
every assigned taxonomic string.
:rtype: dict
:return: A dictionary of taxon... | [
":",
"type",
"taxF",
":",
"file",
":",
"param",
"taxF",
":",
"The",
"taxonomy",
"output",
"file",
"to",
"parse",
":",
"type",
"level",
":",
"string",
":",
"param",
"level",
":",
"The",
"level",
"of",
"the",
"phylogenetic",
"assignment",
"at",
"which",
... | smdabdoub/phylotoast | python | https://github.com/smdabdoub/phylotoast/blob/0b74ef171e6a84761710548501dfac71285a58a3/bin/otu_condense.py#L30-L60 | [
"def",
"prune_taxonomy",
"(",
"taxF",
",",
"level",
")",
":",
"uniqueTax",
"=",
"{",
"}",
"nuTax",
"=",
"{",
"}",
"# non-unique taxonomies",
"for",
"i",
",",
"line",
"in",
"enumerate",
"(",
"taxF",
")",
":",
"try",
":",
"otuID",
",",
"tax",
",",
"flo... | 0b74ef171e6a84761710548501dfac71285a58a3 |
train | get_publisher | get_publisher | network_pipeline/publisher.py | def get_publisher():
"""get_publisher"""
log.info("initializing publisher")
pub = None
auth_url = ""
if FORWARD_ENDPOINT_TYPE == "redis":
auth_url = FORWARD_BROKER_URL
else:
auth_url = FORWARD_BROKER_URL
pub = Publisher(name="{}_{}".format(SOURCE, "-redis"),
... | def get_publisher():
"""get_publisher"""
log.info("initializing publisher")
pub = None
auth_url = ""
if FORWARD_ENDPOINT_TYPE == "redis":
auth_url = FORWARD_BROKER_URL
else:
auth_url = FORWARD_BROKER_URL
pub = Publisher(name="{}_{}".format(SOURCE, "-redis"),
... | [
"get_publisher"
] | jay-johnson/network-pipeline | python | https://github.com/jay-johnson/network-pipeline/blob/4e53ae13fe12085e0cf2e5e1aff947368f4f1ffa/network_pipeline/publisher.py#L13-L28 | [
"def",
"get_publisher",
"(",
")",
":",
"log",
".",
"info",
"(",
"\"initializing publisher\"",
")",
"pub",
"=",
"None",
"auth_url",
"=",
"\"\"",
"if",
"FORWARD_ENDPOINT_TYPE",
"==",
"\"redis\"",
":",
"auth_url",
"=",
"FORWARD_BROKER_URL",
"else",
":",
"auth_url",... | 4e53ae13fe12085e0cf2e5e1aff947368f4f1ffa |
train | recv_msg | recv_msg
Handler method - fires when a messages is consumed from
the ``FORWARD_QUEUE`` queue running in the ``FORWARD_BROKER_URL``
broker.
:param body: message body
:param message: message object can ack, requeue or reject | network_pipeline/scripts/packets_redis.py | def recv_msg(body,
message):
"""recv_msg
Handler method - fires when a messages is consumed from
the ``FORWARD_QUEUE`` queue running in the ``FORWARD_BROKER_URL``
broker.
:param body: message body
:param message: message object can ack, requeue or reject
"""
log.info(("ca... | def recv_msg(body,
message):
"""recv_msg
Handler method - fires when a messages is consumed from
the ``FORWARD_QUEUE`` queue running in the ``FORWARD_BROKER_URL``
broker.
:param body: message body
:param message: message object can ack, requeue or reject
"""
log.info(("ca... | [
"recv_msg"
] | jay-johnson/network-pipeline | python | https://github.com/jay-johnson/network-pipeline/blob/4e53ae13fe12085e0cf2e5e1aff947368f4f1ffa/network_pipeline/scripts/packets_redis.py#L21-L37 | [
"def",
"recv_msg",
"(",
"body",
",",
"message",
")",
":",
"log",
".",
"info",
"(",
"(",
"\"callback received msg \"",
")",
")",
"agg",
".",
"handle_msg",
"(",
"body",
"=",
"body",
",",
"org_message",
"=",
"message",
")"
] | 4e53ae13fe12085e0cf2e5e1aff947368f4f1ffa |
train | consume_network_packet_messages_from_redis | consume_network_packet_messages_from_redis
Setup a ``celery_connectors.KombuSubscriber`` to consume meessages
from the ``FORWARD_BROKER_URL`` broker in the ``FORWARD_QUEUE``
queue. | network_pipeline/scripts/packets_redis.py | def consume_network_packet_messages_from_redis():
"""consume_network_packet_messages_from_redis
Setup a ``celery_connectors.KombuSubscriber`` to consume meessages
from the ``FORWARD_BROKER_URL`` broker in the ``FORWARD_QUEUE``
queue.
"""
# end of recv_message
# Initialize KombuSubscriber
... | def consume_network_packet_messages_from_redis():
"""consume_network_packet_messages_from_redis
Setup a ``celery_connectors.KombuSubscriber`` to consume meessages
from the ``FORWARD_BROKER_URL`` broker in the ``FORWARD_QUEUE``
queue.
"""
# end of recv_message
# Initialize KombuSubscriber
... | [
"consume_network_packet_messages_from_redis"
] | jay-johnson/network-pipeline | python | https://github.com/jay-johnson/network-pipeline/blob/4e53ae13fe12085e0cf2e5e1aff947368f4f1ffa/network_pipeline/scripts/packets_redis.py#L41-L70 | [
"def",
"consume_network_packet_messages_from_redis",
"(",
")",
":",
"# end of recv_message",
"# Initialize KombuSubscriber",
"sub",
"=",
"KombuSubscriber",
"(",
"name",
",",
"FORWARD_BROKER_URL",
",",
"FORWARD_SSL_OPTIONS",
")",
"# Now consume:",
"seconds_to_consume",
"=",
"1... | 4e53ae13fe12085e0cf2e5e1aff947368f4f1ffa |
train | parse_masked | parse masked sequence into non-masked and masked regions | ctbBio/strip_masked.py | 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):
"""
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... | [
"parse",
"masked",
"sequence",
"into",
"non",
"-",
"masked",
"and",
"masked",
"regions"
] | christophertbrown/bioscripts | python | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/strip_masked.py#L13-L31 | [
"def",
"parse_masked",
"(",
"seq",
",",
"min_len",
")",
":",
"nm",
",",
"masked",
"=",
"[",
"]",
",",
"[",
"[",
"]",
"]",
"prev",
"=",
"None",
"for",
"base",
"in",
"seq",
"[",
"1",
"]",
":",
"if",
"base",
".",
"isupper",
"(",
")",
":",
"nm",
... | 83b2566b3a5745437ec651cd6cafddd056846240 |
train | strip_masked | remove masked regions from fasta file as long as
they are longer than min_len | ctbBio/strip_masked.py | 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):
"""
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 ... | [
"remove",
"masked",
"regions",
"from",
"fasta",
"file",
"as",
"long",
"as",
"they",
"are",
"longer",
"than",
"min_len"
] | christophertbrown/bioscripts | python | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/strip_masked.py#L33-L45 | [
"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 ... | 83b2566b3a5745437ec651cd6cafddd056846240 |
train | get_relative_abundance | 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... | bin/network_plots_gephi.py | 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):
"""
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... | [
"Return",
"arcsine",
"transformed",
"relative",
"abundance",
"from",
"a",
"BIOM",
"format",
"file",
"."
] | smdabdoub/phylotoast | python | https://github.com/smdabdoub/phylotoast/blob/0b74ef171e6a84761710548501dfac71285a58a3/bin/network_plots_gephi.py#L33-L57 | [
"def",
"get_relative_abundance",
"(",
"biomfile",
")",
":",
"biomf",
"=",
"biom",
".",
"load_table",
"(",
"biomfile",
")",
"norm_biomf",
"=",
"biomf",
".",
"norm",
"(",
"inplace",
"=",
"False",
")",
"rel_abd",
"=",
"{",
"}",
"for",
"sid",
"in",
"norm_bio... | 0b74ef171e6a84761710548501dfac71285a58a3 |
train | build_training_request | build_training_request
:param csv_file: csv file built with prepare_dataset.py
:param meta_file: metadata file built with prepare_dataset.py
:param predict_feature: feature (column) to predict
:param ignore_features: features to remove from the csv
before the split of test +... | network_pipeline/build_training_request.py | def build_training_request(
csv_file=ev(
"CSV_FILE",
"/tmp/cleaned_attack_scans.csv"),
meta_file=ev(
"CSV_META_FILE",
"/tmp/cleaned_metadata.json"),
predict_feature=ev(
"PREDICT_FEATURE",
"label_value"),
ignore_featu... | def build_training_request(
csv_file=ev(
"CSV_FILE",
"/tmp/cleaned_attack_scans.csv"),
meta_file=ev(
"CSV_META_FILE",
"/tmp/cleaned_metadata.json"),
predict_feature=ev(
"PREDICT_FEATURE",
"label_value"),
ignore_featu... | [
"build_training_request"
] | jay-johnson/network-pipeline | python | https://github.com/jay-johnson/network-pipeline/blob/4e53ae13fe12085e0cf2e5e1aff947368f4f1ffa/network_pipeline/build_training_request.py#L17-L216 | [
"def",
"build_training_request",
"(",
"csv_file",
"=",
"ev",
"(",
"\"CSV_FILE\"",
",",
"\"/tmp/cleaned_attack_scans.csv\"",
")",
",",
"meta_file",
"=",
"ev",
"(",
"\"CSV_META_FILE\"",
",",
"\"/tmp/cleaned_metadata.json\"",
")",
",",
"predict_feature",
"=",
"ev",
"(",
... | 4e53ae13fe12085e0cf2e5e1aff947368f4f1ffa |
train | find_otu | Find an OTU ID in a Newick-format tree.
Return the starting position of the ID or None if not found. | bin/iTol.py | 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):
"""
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 [":", ";"... | [
"Find",
"an",
"OTU",
"ID",
"in",
"a",
"Newick",
"-",
"format",
"tree",
".",
"Return",
"the",
"starting",
"position",
"of",
"the",
"ID",
"or",
"None",
"if",
"not",
"found",
"."
] | smdabdoub/phylotoast | python | https://github.com/smdabdoub/phylotoast/blob/0b74ef171e6a84761710548501dfac71285a58a3/bin/iTol.py#L17-L26 | [
"def",
"find_otu",
"(",
"otuid",
",",
"tree",
")",
":",
"for",
"m",
"in",
"re",
".",
"finditer",
"(",
"otuid",
",",
"tree",
")",
":",
"before",
",",
"after",
"=",
"tree",
"[",
"m",
".",
"start",
"(",
")",
"-",
"1",
"]",
",",
"tree",
"[",
"m",... | 0b74ef171e6a84761710548501dfac71285a58a3 |
train | newick_replace_otuids | Replace the OTU ids in the Newick phylogenetic tree format with truncated
OTU names | bin/iTol.py | 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):
"""
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] + \
... | [
"Replace",
"the",
"OTU",
"ids",
"in",
"the",
"Newick",
"phylogenetic",
"tree",
"format",
"with",
"truncated",
"OTU",
"names"
] | smdabdoub/phylotoast | python | https://github.com/smdabdoub/phylotoast/blob/0b74ef171e6a84761710548501dfac71285a58a3/bin/iTol.py#L29-L40 | [
"def",
"newick_replace_otuids",
"(",
"tree",
",",
"biomf",
")",
":",
"for",
"val",
",",
"id_",
",",
"md",
"in",
"biomf",
".",
"iter",
"(",
"axis",
"=",
"\"observation\"",
")",
":",
"otu_loc",
"=",
"find_otu",
"(",
"id_",
",",
"tree",
")",
"if",
"otu_... | 0b74ef171e6a84761710548501dfac71285a58a3 |
train | start_consumers_for_queue | start_consumers_for_queue
:param prefix_name:
:param num_workers:
:param tasks:
:param queue_to_consume:
:param shutdown_msg:
:param consumer_class:
:param need_response:
:param callback: | network_pipeline/start_consumers_for_queue.py | def start_consumers_for_queue(prefix_name="worker",
num_workers=2,
tasks=None,
queue_to_consume=None,
shutdown_msg="SHUTDOWN",
consumer_class=None,
... | def start_consumers_for_queue(prefix_name="worker",
num_workers=2,
tasks=None,
queue_to_consume=None,
shutdown_msg="SHUTDOWN",
consumer_class=None,
... | [
"start_consumers_for_queue"
] | jay-johnson/network-pipeline | python | https://github.com/jay-johnson/network-pipeline/blob/4e53ae13fe12085e0cf2e5e1aff947368f4f1ffa/network_pipeline/start_consumers_for_queue.py#L9-L63 | [
"def",
"start_consumers_for_queue",
"(",
"prefix_name",
"=",
"\"worker\"",
",",
"num_workers",
"=",
"2",
",",
"tasks",
"=",
"None",
",",
"queue_to_consume",
"=",
"None",
",",
"shutdown_msg",
"=",
"\"SHUTDOWN\"",
",",
"consumer_class",
"=",
"None",
",",
"need_res... | 4e53ae13fe12085e0cf2e5e1aff947368f4f1ffa |
train | make_mashes | Create mash files for multiple fasta files
Input:
fastas <list[str]> -- paths to fasta files
mash_file <str> -- path to output mash file
threads <int> -- # threads for parallelization
kmer <int> -- kmer size for mash sketching
force <boolean> -- force ... | ctbBio/cluster_ani.py | def make_mashes(fastas, mash_file, threads, kmer = 21, force = False):
"""
Create mash files for multiple fasta files
Input:
fastas <list[str]> -- paths to fasta files
mash_file <str> -- path to output mash file
threads <int> -- # threads for parallelization
kmer <... | def make_mashes(fastas, mash_file, threads, kmer = 21, force = False):
"""
Create mash files for multiple fasta files
Input:
fastas <list[str]> -- paths to fasta files
mash_file <str> -- path to output mash file
threads <int> -- # threads for parallelization
kmer <... | [
"Create",
"mash",
"files",
"for",
"multiple",
"fasta",
"files",
"Input",
":",
"fastas",
"<list",
"[",
"str",
"]",
">",
"--",
"paths",
"to",
"fasta",
"files",
"mash_file",
"<str",
">",
"--",
"path",
"to",
"output",
"mash",
"file",
"threads",
"<int",
">",
... | christophertbrown/bioscripts | python | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/cluster_ani.py#L17-L45 | [
"def",
"make_mashes",
"(",
"fastas",
",",
"mash_file",
",",
"threads",
",",
"kmer",
"=",
"21",
",",
"force",
"=",
"False",
")",
":",
"mash_processes",
"=",
"set",
"(",
")",
"sketches",
"=",
"[",
"fasta",
"+",
"'.msh'",
"for",
"fasta",
"in",
"fastas",
... | 83b2566b3a5745437ec651cd6cafddd056846240 |
train | paste_mashes | Combine mash files into single sketch
Input:
sketches <list[str]> -- paths to sketch files
pasted_mash <str> -- path to output mash file
force <boolean> -- force overwrite of all mash file | ctbBio/cluster_ani.py | def paste_mashes(sketches, pasted_mash, force = False):
"""
Combine mash files into single sketch
Input:
sketches <list[str]> -- paths to sketch files
pasted_mash <str> -- path to output mash file
force <boolean> -- force overwrite of all mash file
"""
if os.path.isf... | def paste_mashes(sketches, pasted_mash, force = False):
"""
Combine mash files into single sketch
Input:
sketches <list[str]> -- paths to sketch files
pasted_mash <str> -- path to output mash file
force <boolean> -- force overwrite of all mash file
"""
if os.path.isf... | [
"Combine",
"mash",
"files",
"into",
"single",
"sketch",
"Input",
":",
"sketches",
"<list",
"[",
"str",
"]",
">",
"--",
"paths",
"to",
"sketch",
"files",
"pasted_mash",
"<str",
">",
"--",
"path",
"to",
"output",
"mash",
"file",
"force",
"<boolean",
">",
"... | christophertbrown/bioscripts | python | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/cluster_ani.py#L47-L65 | [
"def",
"paste_mashes",
"(",
"sketches",
",",
"pasted_mash",
",",
"force",
"=",
"False",
")",
":",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"pasted_mash",
")",
":",
"if",
"force",
":",
"subprocess",
".",
"Popen",
"(",
"[",
"'rm'",
",",
"pasted_mash"... | 83b2566b3a5745437ec651cd6cafddd056846240 |
train | ani | Use mash to estimate ANI of genomes
Input:
fastas <list[str]> -- paths to fasta files
sim_threshold <float> -- fractional cutoff % identity for cluster joining
mash_file <str> -- pasted sketch file of all fastas being compared
threads <int> -- number threads ... | ctbBio/cluster_ani.py | def ani(fastas, mash_file, sim_threshold, threads):
"""
Use mash to estimate ANI of genomes
Input:
fastas <list[str]> -- paths to fasta files
sim_threshold <float> -- fractional cutoff % identity for cluster joining
mash_file <str> -- pasted sketch file of all fastas b... | def ani(fastas, mash_file, sim_threshold, threads):
"""
Use mash to estimate ANI of genomes
Input:
fastas <list[str]> -- paths to fasta files
sim_threshold <float> -- fractional cutoff % identity for cluster joining
mash_file <str> -- pasted sketch file of all fastas b... | [
"Use",
"mash",
"to",
"estimate",
"ANI",
"of",
"genomes",
"Input",
":",
"fastas",
"<list",
"[",
"str",
"]",
">",
"--",
"paths",
"to",
"fasta",
"files",
"sim_threshold",
"<float",
">",
"--",
"fractional",
"cutoff",
"%",
"identity",
"for",
"cluster",
"joining... | christophertbrown/bioscripts | python | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/cluster_ani.py#L67-L95 | [
"def",
"ani",
"(",
"fastas",
",",
"mash_file",
",",
"sim_threshold",
",",
"threads",
")",
":",
"ANI",
"=",
"Graph",
"(",
")",
"# use Mash to estimate ANI",
"for",
"fasta",
"in",
"fastas",
":",
"indiv_mash",
"=",
"fasta",
"+",
"'.msh'",
"if",
"os",
".",
"... | 83b2566b3a5745437ec651cd6cafddd056846240 |
train | 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 | ctbBio/cluster_ani.py | 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):
"""
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... | [
"return",
"genome",
"info",
"for",
"choosing",
"representative"
] | christophertbrown/bioscripts | python | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/cluster_ani.py#L97-L112 | [
"def",
"genome_info",
"(",
"genome",
",",
"info",
")",
":",
"try",
":",
"scg",
"=",
"info",
"[",
"'#SCGs'",
"]",
"dups",
"=",
"info",
"[",
"'#SCG duplicates'",
"]",
"length",
"=",
"info",
"[",
"'genome size (bp)'",
"]",
"return",
"[",
"scg",
"-",
"dups... | 83b2566b3a5745437ec651cd6cafddd056846240 |
train | print_clusters | choose represenative genome and
print cluster information
*if ggKbase table is provided, use SCG info to choose best genome | ctbBio/cluster_ani.py | 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):
"""
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... | [
"choose",
"represenative",
"genome",
"and",
"print",
"cluster",
"information"
] | christophertbrown/bioscripts | python | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/cluster_ani.py#L114-L163 | [
"def",
"print_clusters",
"(",
"fastas",
",",
"info",
",",
"ANI",
")",
":",
"header",
"=",
"[",
"'#cluster'",
",",
"'num. genomes'",
",",
"'rep.'",
",",
"'genome'",
",",
"'#SCGs'",
",",
"'#SCG duplicates'",
",",
"'genome size (bp)'",
",",
"'fragments'",
",",
... | 83b2566b3a5745437ec651cd6cafddd056846240 |
train | parse_ggKbase_tables | convert ggKbase genome info tables to dictionary | ctbBio/cluster_ani.py | 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):
"""
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... | [
"convert",
"ggKbase",
"genome",
"info",
"tables",
"to",
"dictionary"
] | christophertbrown/bioscripts | python | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/cluster_ani.py#L174-L213 | [
"def",
"parse_ggKbase_tables",
"(",
"tables",
",",
"id_type",
")",
":",
"g2info",
"=",
"{",
"}",
"for",
"table",
"in",
"tables",
":",
"for",
"line",
"in",
"open",
"(",
"table",
")",
":",
"line",
"=",
"line",
".",
"strip",
"(",
")",
".",
"split",
"(... | 83b2566b3a5745437ec651cd6cafddd056846240 |
train | parse_checkM_tables | convert checkM genome info tables to dictionary | ctbBio/cluster_ani.py | 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):
"""
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] ... | [
"convert",
"checkM",
"genome",
"info",
"tables",
"to",
"dictionary"
] | christophertbrown/bioscripts | python | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/cluster_ani.py#L215-L235 | [
"def",
"parse_checkM_tables",
"(",
"tables",
")",
":",
"g2info",
"=",
"{",
"}",
"for",
"table",
"in",
"tables",
":",
"for",
"line",
"in",
"open",
"(",
"table",
")",
":",
"line",
"=",
"line",
".",
"strip",
"(",
")",
".",
"split",
"(",
"'\\t'",
")",
... | 83b2566b3a5745437ec651cd6cafddd056846240 |
train | genome_lengths | get genome lengths | ctbBio/cluster_ani.py | 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):
"""
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... | [
"get",
"genome",
"lengths"
] | christophertbrown/bioscripts | python | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/cluster_ani.py#L237-L253 | [
"def",
"genome_lengths",
"(",
"fastas",
",",
"info",
")",
":",
"if",
"info",
"is",
"False",
":",
"info",
"=",
"{",
"}",
"for",
"genome",
"in",
"fastas",
":",
"name",
"=",
"genome",
".",
"rsplit",
"(",
"'.'",
",",
"1",
")",
"[",
"0",
"]",
".",
"... | 83b2566b3a5745437ec651cd6cafddd056846240 |
train | listen_on_tcp_port | listen_on_tcp_port
Run a simple server for processing messages over ``TCP``.
``LISTEN_ON_HOST`` - listen on this host ip address
``LISTEN_ON_PORT`` - listen on this ``TCP`` port
``LISTEN_SIZE`` - listen on to packets of this size
``LISTEN_SLEEP`` - sleep this number of seconds per loop
``L... | network_pipeline/scripts/listen_tcp_port.py | def listen_on_tcp_port():
"""listen_on_tcp_port
Run a simple server for processing messages over ``TCP``.
``LISTEN_ON_HOST`` - listen on this host ip address
``LISTEN_ON_PORT`` - listen on this ``TCP`` port
``LISTEN_SIZE`` - listen on to packets of this size
``LISTEN_SLEEP`` - sleep this nu... | def listen_on_tcp_port():
"""listen_on_tcp_port
Run a simple server for processing messages over ``TCP``.
``LISTEN_ON_HOST`` - listen on this host ip address
``LISTEN_ON_PORT`` - listen on this ``TCP`` port
``LISTEN_SIZE`` - listen on to packets of this size
``LISTEN_SLEEP`` - sleep this nu... | [
"listen_on_tcp_port"
] | jay-johnson/network-pipeline | python | https://github.com/jay-johnson/network-pipeline/blob/4e53ae13fe12085e0cf2e5e1aff947368f4f1ffa/network_pipeline/scripts/listen_tcp_port.py#L10-L104 | [
"def",
"listen_on_tcp_port",
"(",
")",
":",
"host",
"=",
"os",
".",
"getenv",
"(",
"\"LISTEN_ON_HOST\"",
",",
"\"127.0.0.1\"",
")",
".",
"strip",
"(",
")",
".",
"lstrip",
"(",
")",
"port",
"=",
"int",
"(",
"os",
".",
"getenv",
"(",
"\"LISTEN_ON_PORT\"",
... | 4e53ae13fe12085e0cf2e5e1aff947368f4f1ffa |
train | BaseRouter.get_dbs | 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)
... | nydus/db/routers/base.py | 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):
"""
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... | [
"Returns",
"a",
"list",
"of",
"db",
"keys",
"to",
"route",
"the",
"given",
"call",
"to",
"."
] | disqus/nydus | python | https://github.com/disqus/nydus/blob/9b505840da47a34f758a830c3992fa5dcb7bb7ad/nydus/db/routers/base.py#L50-L81 | [
"def",
"get_dbs",
"(",
"self",
",",
"attr",
",",
"args",
",",
"kwargs",
",",
"*",
"*",
"fkwargs",
")",
":",
"if",
"not",
"self",
".",
"_ready",
":",
"if",
"not",
"self",
".",
"setup_router",
"(",
"args",
"=",
"args",
",",
"kwargs",
"=",
"kwargs",
... | 9b505840da47a34f758a830c3992fa5dcb7bb7ad |
train | BaseRouter.setup_router | Call method to perform any setup | nydus/db/routers/base.py | 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):
"""
Call method to perform any setup
"""
self._ready = self._setup_router(args=args, kwargs=kwargs, **fkwargs)
return self._ready | [
"Call",
"method",
"to",
"perform",
"any",
"setup"
] | disqus/nydus | python | https://github.com/disqus/nydus/blob/9b505840da47a34f758a830c3992fa5dcb7bb7ad/nydus/db/routers/base.py#L87-L93 | [
"def",
"setup_router",
"(",
"self",
",",
"args",
",",
"kwargs",
",",
"*",
"*",
"fkwargs",
")",
":",
"self",
".",
"_ready",
"=",
"self",
".",
"_setup_router",
"(",
"args",
"=",
"args",
",",
"kwargs",
"=",
"kwargs",
",",
"*",
"*",
"fkwargs",
")",
"re... | 9b505840da47a34f758a830c3992fa5dcb7bb7ad |
train | BaseRouter._route | Perform routing and return db_nums | nydus/db/routers/base.py | 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):
"""
Perform routing and return db_nums
"""
return self.cluster.hosts.keys() | [
"Perform",
"routing",
"and",
"return",
"db_nums"
] | disqus/nydus | python | https://github.com/disqus/nydus/blob/9b505840da47a34f758a830c3992fa5dcb7bb7ad/nydus/db/routers/base.py#L111-L115 | [
"def",
"_route",
"(",
"self",
",",
"attr",
",",
"args",
",",
"kwargs",
",",
"*",
"*",
"fkwargs",
")",
":",
"return",
"self",
".",
"cluster",
".",
"hosts",
".",
"keys",
"(",
")"
] | 9b505840da47a34f758a830c3992fa5dcb7bb7ad |
train | RoundRobinRouter.check_down_connections | Iterates through all connections which were previously listed as unavailable
and marks any that have expired their retry_timeout as being up. | nydus/db/routers/base.py | 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):
"""
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():
... | [
"Iterates",
"through",
"all",
"connections",
"which",
"were",
"previously",
"listed",
"as",
"unavailable",
"and",
"marks",
"any",
"that",
"have",
"expired",
"their",
"retry_timeout",
"as",
"being",
"up",
"."
] | disqus/nydus | python | https://github.com/disqus/nydus/blob/9b505840da47a34f758a830c3992fa5dcb7bb7ad/nydus/db/routers/base.py#L175-L184 | [
"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... | 9b505840da47a34f758a830c3992fa5dcb7bb7ad |
train | RoundRobinRouter.flush_down_connections | Marks all connections which were previously listed as unavailable as being up. | nydus/db/routers/base.py | 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):
"""
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) | [
"Marks",
"all",
"connections",
"which",
"were",
"previously",
"listed",
"as",
"unavailable",
"as",
"being",
"up",
"."
] | disqus/nydus | python | https://github.com/disqus/nydus/blob/9b505840da47a34f758a830c3992fa5dcb7bb7ad/nydus/db/routers/base.py#L186-L192 | [
"def",
"flush_down_connections",
"(",
"self",
")",
":",
"self",
".",
"_get_db_attempts",
"=",
"0",
"for",
"db_num",
"in",
"self",
".",
"_down_connections",
".",
"keys",
"(",
")",
":",
"self",
".",
"mark_connection_up",
"(",
"db_num",
")"
] | 9b505840da47a34f758a830c3992fa5dcb7bb7ad |
train | standby | 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... | opengrid/library/analysis.py | 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):
"""
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 ... | [
"Compute",
"standby",
"power"
] | opengridcc/opengrid | python | https://github.com/opengridcc/opengrid/blob/69b8da3c8fcea9300226c45ef0628cd6d4307651/opengrid/library/analysis.py#L72-L115 | [
"def",
"standby",
"(",
"df",
",",
"resolution",
"=",
"'24h'",
",",
"time_window",
"=",
"None",
")",
":",
"if",
"df",
".",
"empty",
":",
"raise",
"EmptyDataFrame",
"(",
")",
"df",
"=",
"pd",
".",
"DataFrame",
"(",
"df",
")",
"# if df was a pd.Series, conv... | 69b8da3c8fcea9300226c45ef0628cd6d4307651 |
train | share_of_standby | 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) ... | opengrid/library/analysis.py | 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):
"""
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... | [
"Compute",
"the",
"share",
"of",
"the",
"standby",
"power",
"in",
"the",
"total",
"consumption",
"."
] | opengridcc/opengrid | python | https://github.com/opengridcc/opengrid/blob/69b8da3c8fcea9300226c45ef0628cd6d4307651/opengrid/library/analysis.py#L118-L146 | [
"def",
"share_of_standby",
"(",
"df",
",",
"resolution",
"=",
"'24h'",
",",
"time_window",
"=",
"None",
")",
":",
"p_sb",
"=",
"standby",
"(",
"df",
",",
"resolution",
",",
"time_window",
")",
"df",
"=",
"df",
".",
"resample",
"(",
"resolution",
")",
"... | 69b8da3c8fcea9300226c45ef0628cd6d4307651 |
train | count_peaks | 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 | opengrid/library/analysis.py | 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):
"""
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
... | [
"Toggle",
"counter",
"for",
"gas",
"boilers"
] | opengridcc/opengrid | python | https://github.com/opengridcc/opengrid/blob/69b8da3c8fcea9300226c45ef0628cd6d4307651/opengrid/library/analysis.py#L149-L169 | [
"def",
"count_peaks",
"(",
"ts",
")",
":",
"on_toggles",
"=",
"ts",
".",
"diff",
"(",
")",
">",
"3000",
"shifted",
"=",
"np",
".",
"logical_not",
"(",
"on_toggles",
".",
"shift",
"(",
"1",
")",
")",
"result",
"=",
"on_toggles",
"&",
"shifted",
"count... | 69b8da3c8fcea9300226c45ef0628cd6d4307651 |
train | load_factor | 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... | opengrid/library/analysis.py | 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):
"""
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... | [
"Calculate",
"the",
"ratio",
"of",
"input",
"vs",
".",
"norm",
"over",
"a",
"given",
"interval",
"."
] | opengridcc/opengrid | python | https://github.com/opengridcc/opengrid/blob/69b8da3c8fcea9300226c45ef0628cd6d4307651/opengrid/library/analysis.py#L172-L199 | [
"def",
"load_factor",
"(",
"ts",
",",
"resolution",
"=",
"None",
",",
"norm",
"=",
"None",
")",
":",
"if",
"norm",
"is",
"None",
":",
"norm",
"=",
"ts",
".",
"max",
"(",
")",
"if",
"resolution",
"is",
"not",
"None",
":",
"ts",
"=",
"ts",
".",
"... | 69b8da3c8fcea9300226c45ef0628cd6d4307651 |
train | build_new_deep_neural_network_from_env_variables | build_new_deep_neural_network_from_env_variables
Build a new deep neural network from environment variables:
``CSV_FILE`` - file to process created during prepare dataset
``CSV_META_FILE`` - metadata header file created during prepare dataset
``PREDICT_FEATURE`` - column to predict
``TEST_SIZE`` -... | network_pipeline/scripts/modelers/keras_dnn.py | def build_new_deep_neural_network_from_env_variables():
"""build_new_deep_neural_network_from_env_variables
Build a new deep neural network from environment variables:
``CSV_FILE`` - file to process created during prepare dataset
``CSV_META_FILE`` - metadata header file created during prepare dataset
... | def build_new_deep_neural_network_from_env_variables():
"""build_new_deep_neural_network_from_env_variables
Build a new deep neural network from environment variables:
``CSV_FILE`` - file to process created during prepare dataset
``CSV_META_FILE`` - metadata header file created during prepare dataset
... | [
"build_new_deep_neural_network_from_env_variables"
] | jay-johnson/network-pipeline | python | https://github.com/jay-johnson/network-pipeline/blob/4e53ae13fe12085e0cf2e5e1aff947368f4f1ffa/network_pipeline/scripts/modelers/keras_dnn.py#L21-L116 | [
"def",
"build_new_deep_neural_network_from_env_variables",
"(",
")",
":",
"csv_file",
"=",
"ev",
"(",
"\"CSV_FILE\"",
",",
"\"/tmp/cleaned_attack_scans.csv\"",
")",
"meta_file",
"=",
"ev",
"(",
"\"CSV_META_FILE\"",
",",
"\"/tmp/cleaned_metadata.json\"",
")",
"predict_featur... | 4e53ae13fe12085e0cf2e5e1aff947368f4f1ffa |
train | create_layer_2_socket | create_layer_2_socket | network_pipeline/create_layer_2_socket.py | def create_layer_2_socket():
"""create_layer_2_socket"""
# create a socket for recording layer 2, 3 and 4 frames
s = None
try:
log.info("Creating l234 socket")
s = socket.socket(socket.AF_PACKET,
socket.SOCK_RAW,
socket.ntohs(0x0003))
... | def create_layer_2_socket():
"""create_layer_2_socket"""
# create a socket for recording layer 2, 3 and 4 frames
s = None
try:
log.info("Creating l234 socket")
s = socket.socket(socket.AF_PACKET,
socket.SOCK_RAW,
socket.ntohs(0x0003))
... | [
"create_layer_2_socket"
] | jay-johnson/network-pipeline | python | https://github.com/jay-johnson/network-pipeline/blob/4e53ae13fe12085e0cf2e5e1aff947368f4f1ffa/network_pipeline/create_layer_2_socket.py#L9-L22 | [
"def",
"create_layer_2_socket",
"(",
")",
":",
"# create a socket for recording layer 2, 3 and 4 frames",
"s",
"=",
"None",
"try",
":",
"log",
".",
"info",
"(",
"\"Creating l234 socket\"",
")",
"s",
"=",
"socket",
".",
"socket",
"(",
"socket",
".",
"AF_PACKET",
",... | 4e53ae13fe12085e0cf2e5e1aff947368f4f1ffa |
train | top_hits | get top hits after sorting by column number | ctbBio/besthits.py | 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):
"""
get top hits after sorting by column number
"""
hits.sort(key = itemgetter(column), reverse = reverse)
for hit in hits[0:num]:
yield hit | [
"get",
"top",
"hits",
"after",
"sorting",
"by",
"column",
"number"
] | christophertbrown/bioscripts | python | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/besthits.py#L17-L23 | [
"def",
"top_hits",
"(",
"hits",
",",
"num",
",",
"column",
",",
"reverse",
")",
":",
"hits",
".",
"sort",
"(",
"key",
"=",
"itemgetter",
"(",
"column",
")",
",",
"reverse",
"=",
"reverse",
")",
"for",
"hit",
"in",
"hits",
"[",
"0",
":",
"num",
"]... | 83b2566b3a5745437ec651cd6cafddd056846240 |
train | numBlast_sort | parse b6 output with sorting | ctbBio/besthits.py | 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):
"""
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:
... | [
"parse",
"b6",
"output",
"with",
"sorting"
] | christophertbrown/bioscripts | python | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/besthits.py#L25-L50 | [
"def",
"numBlast_sort",
"(",
"blast",
",",
"numHits",
",",
"evalueT",
",",
"bitT",
")",
":",
"header",
"=",
"[",
"'#query'",
",",
"'target'",
",",
"'pident'",
",",
"'alen'",
",",
"'mismatch'",
",",
"'gapopen'",
",",
"'qstart'",
",",
"'qend'",
",",
"'tsta... | 83b2566b3a5745437ec651cd6cafddd056846240 |
train | numBlast | parse b6 output | ctbBio/besthits.py | 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):
"""
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',
... | [
"parse",
"b6",
"output"
] | christophertbrown/bioscripts | python | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/besthits.py#L52-L85 | [
"def",
"numBlast",
"(",
"blast",
",",
"numHits",
",",
"evalueT",
"=",
"False",
",",
"bitT",
"=",
"False",
",",
"sort",
"=",
"False",
")",
":",
"if",
"sort",
"is",
"True",
":",
"for",
"hit",
"in",
"numBlast_sort",
"(",
"blast",
",",
"numHits",
",",
... | 83b2566b3a5745437ec651cd6cafddd056846240 |
train | numDomtblout | parse hmm domain table output
this version is faster but does not work unless the table is sorted | ctbBio/besthits.py | 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):
"""
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... | [
"parse",
"hmm",
"domain",
"table",
"output",
"this",
"version",
"is",
"faster",
"but",
"does",
"not",
"work",
"unless",
"the",
"table",
"is",
"sorted"
] | christophertbrown/bioscripts | python | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/besthits.py#L121-L168 | [
"def",
"numDomtblout",
"(",
"domtblout",
",",
"numHits",
",",
"evalueT",
",",
"bitT",
",",
"sort",
")",
":",
"if",
"sort",
"is",
"True",
":",
"for",
"hit",
"in",
"numDomtblout_sort",
"(",
"domtblout",
",",
"numHits",
",",
"evalueT",
",",
"bitT",
")",
"... | 83b2566b3a5745437ec651cd6cafddd056846240 |
train | stock2fa | convert stockholm to fasta | ctbBio/stockholm2fa.py | 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):
"""
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,... | [
"convert",
"stockholm",
"to",
"fasta"
] | christophertbrown/bioscripts | python | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/stockholm2fa.py#L11-L26 | [
"def",
"stock2fa",
"(",
"stock",
")",
":",
"seqs",
"=",
"{",
"}",
"for",
"line",
"in",
"stock",
":",
"if",
"line",
".",
"startswith",
"(",
"'#'",
")",
"is",
"False",
"and",
"line",
".",
"startswith",
"(",
"' '",
")",
"is",
"False",
"and",
"len",
... | 83b2566b3a5745437ec651cd6cafddd056846240 |
train | concat_align | concatenate alignments | ctbBio/concat_align.py | def concat_align(fastas):
"""
concatenate alignments
"""
# read in sequences
fa2len = {}
seqs = {}
IDs = []
for fasta in fastas:
seqs[fasta] = {}
for seq in parse_fasta(fasta):
ID = seq[0].split('>')[1].split()[0]
IDs.append(ID)
seqs[fa... | def concat_align(fastas):
"""
concatenate alignments
"""
# read in sequences
fa2len = {}
seqs = {}
IDs = []
for fasta in fastas:
seqs[fasta] = {}
for seq in parse_fasta(fasta):
ID = seq[0].split('>')[1].split()[0]
IDs.append(ID)
seqs[fa... | [
"concatenate",
"alignments"
] | christophertbrown/bioscripts | python | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/concat_align.py#L11-L37 | [
"def",
"concat_align",
"(",
"fastas",
")",
":",
"# read in sequences",
"fa2len",
"=",
"{",
"}",
"seqs",
"=",
"{",
"}",
"IDs",
"=",
"[",
"]",
"for",
"fasta",
"in",
"fastas",
":",
"seqs",
"[",
"fasta",
"]",
"=",
"{",
"}",
"for",
"seq",
"in",
"parse_f... | 83b2566b3a5745437ec651cd6cafddd056846240 |
train | week_schedule | 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 :... | opengrid/library/utils.py | 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):
""" 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... | [
"Return",
"boolean",
"time",
"series",
"following",
"given",
"week",
"schedule",
"."
] | opengridcc/opengrid | python | https://github.com/opengridcc/opengrid/blob/69b8da3c8fcea9300226c45ef0628cd6d4307651/opengrid/library/utils.py#L10-L47 | [
"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",
"=",... | 69b8da3c8fcea9300226c45ef0628cd6d4307651 |
train | carpet | 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... | opengrid/library/plotting.py | 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):
"""
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... | [
"Draw",
"a",
"carpet",
"plot",
"of",
"a",
"pandas",
"timeseries",
"."
] | opengridcc/opengrid | python | https://github.com/opengridcc/opengrid/blob/69b8da3c8fcea9300226c45ef0628cd6d4307651/opengrid/library/plotting.py#L34-L125 | [
"def",
"carpet",
"(",
"timeseries",
",",
"*",
"*",
"kwargs",
")",
":",
"# define optional input parameters",
"cmap",
"=",
"kwargs",
".",
"pop",
"(",
"'cmap'",
",",
"cm",
".",
"coolwarm",
")",
"norm",
"=",
"kwargs",
".",
"pop",
"(",
"'norm'",
",",
"LogNor... | 69b8da3c8fcea9300226c45ef0628cd6d4307651 |
train | boxplot | Plot boxplots
Plot the boxplots of a dataframe in time
Parameters
----------
df: Pandas Dataframe
Every collumn is a timeseries
plot_mean: bool
Wether or not to plot the means
plot_ids: [str]
List of id's to plot
Returns
-------
matplotlib figure | opengrid/library/plotting.py | def boxplot(df, plot_mean=False, plot_ids=None, title=None, xlabel=None, ylabel=None):
"""
Plot boxplots
Plot the boxplots of a dataframe in time
Parameters
----------
df: Pandas Dataframe
Every collumn is a timeseries
plot_mean: bool
Wether or not to plot the means
plo... | def boxplot(df, plot_mean=False, plot_ids=None, title=None, xlabel=None, ylabel=None):
"""
Plot boxplots
Plot the boxplots of a dataframe in time
Parameters
----------
df: Pandas Dataframe
Every collumn is a timeseries
plot_mean: bool
Wether or not to plot the means
plo... | [
"Plot",
"boxplots"
] | opengridcc/opengrid | python | https://github.com/opengridcc/opengrid/blob/69b8da3c8fcea9300226c45ef0628cd6d4307651/opengrid/library/plotting.py#L128-L177 | [
"def",
"boxplot",
"(",
"df",
",",
"plot_mean",
"=",
"False",
",",
"plot_ids",
"=",
"None",
",",
"title",
"=",
"None",
",",
"xlabel",
"=",
"None",
",",
"ylabel",
"=",
"None",
")",
":",
"df",
"=",
"df",
".",
"applymap",
"(",
"float",
")",
"descriptio... | 69b8da3c8fcea9300226c45ef0628cd6d4307651 |
train | calc_pident_ignore_gaps | calculate percent identity | ctbBio/compare_aligned.py | 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):
"""
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... | [
"calculate",
"percent",
"identity"
] | christophertbrown/bioscripts | python | https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/compare_aligned.py#L34-L50 | [
"def",
"calc_pident_ignore_gaps",
"(",
"a",
",",
"b",
")",
":",
"m",
"=",
"0",
"# matches",
"mm",
"=",
"0",
"# mismatches",
"for",
"A",
",",
"B",
"in",
"zip",
"(",
"list",
"(",
"a",
")",
",",
"list",
"(",
"b",
")",
")",
":",
"if",
"A",
"==",
... | 83b2566b3a5745437ec651cd6cafddd056846240 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.