hexsha stringlengths 40 40 | repo stringlengths 7 114 | path stringlengths 4 124 | license listlengths 1 9 | language stringclasses 1
value | identifier stringlengths 1 71 | return_type stringlengths 1 749 ⌀ | original_string stringlengths 76 22.7k | original_docstring stringlengths 16 7.61k | docstring stringlengths 16 2.47k | docstring_tokens listlengths 6 477 | code stringlengths 14 10.2k | code_tokens listlengths 6 996 | short_docstring stringlengths 2 644 | short_docstring_tokens listlengths 1 116 | comment listlengths 1 89 | parameters listlengths 0 64 | docstring_params dict |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
dbe5dc350559245d705834c57b9c3eeeb261b5d3 | wbazant/humann | humann/store.py | [
"MIT"
] | Python | add_annotated | null | def add_annotated(self, query, matches, annotated_reference, read_length=None):
"""
Add an alignment with an annotated reference
"""
# Obtain the reference id length and bug
[referenceid,length,bug]=self.process_reference_annotation(annotated_reference)
... |
Add an alignment with an annotated reference
| Add an alignment with an annotated reference | [
"Add",
"an",
"alignment",
"with",
"an",
"annotated",
"reference"
] | def add_annotated(self, query, matches, annotated_reference, read_length=None):
[referenceid,length,bug]=self.process_reference_annotation(annotated_reference)
self.add(referenceid, length, query, matches, bug, read_length) | [
"def",
"add_annotated",
"(",
"self",
",",
"query",
",",
"matches",
",",
"annotated_reference",
",",
"read_length",
"=",
"None",
")",
":",
"[",
"referenceid",
",",
"length",
",",
"bug",
"]",
"=",
"self",
".",
"process_reference_annotation",
"(",
"annotated_refe... | Add an alignment with an annotated reference | [
"Add",
"an",
"alignment",
"with",
"an",
"annotated",
"reference"
] | [
"\"\"\"\n Add an alignment with an annotated reference\n \"\"\"",
"# Obtain the reference id length and bug"
] | [
{
"param": "self",
"type": null
},
{
"param": "query",
"type": null
},
{
"param": "matches",
"type": null
},
{
"param": "annotated_reference",
"type": null
},
{
"param": "read_length",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "query",
"type": null,
"docstring": null,
"docstring_tokens": ... |
dbe5dc350559245d705834c57b9c3eeeb261b5d3 | wbazant/humann | humann/store.py | [
"MIT"
] | Python | add | null | def add(self, reference, reference_length, query, matches, bug, read_length=None):
"""
Add the hit to the list
Add the index of the hit to the bugs list and gene list
"""
# set default read length
if read_length is None:
read_length = 1
... |
Add the hit to the list
Add the index of the hit to the bugs list and gene list
| Add the hit to the list
Add the index of the hit to the bugs list and gene list | [
"Add",
"the",
"hit",
"to",
"the",
"list",
"Add",
"the",
"index",
"of",
"the",
"hit",
"to",
"the",
"bugs",
"list",
"and",
"gene",
"list"
] | def add(self, reference, reference_length, query, matches, bug, read_length=None):
if read_length is None:
read_length = 1
if reference_length==0:
reference_length=config.default_reference_length
logger.debug("Default gene length used for alignment to gene: " + refer... | [
"def",
"add",
"(",
"self",
",",
"reference",
",",
"reference_length",
",",
"query",
",",
"matches",
",",
"bug",
",",
"read_length",
"=",
"None",
")",
":",
"if",
"read_length",
"is",
"None",
":",
"read_length",
"=",
"1",
"if",
"reference_length",
"==",
"0... | Add the hit to the list
Add the index of the hit to the bugs list and gene list | [
"Add",
"the",
"hit",
"to",
"the",
"list",
"Add",
"the",
"index",
"of",
"the",
"hit",
"to",
"the",
"bugs",
"list",
"and",
"gene",
"list"
] | [
"\"\"\" \n Add the hit to the list\n Add the index of the hit to the bugs list and gene list\n \"\"\"",
"# set default read length",
"# store the score instead of the number of matches",
"# Store the scores by bug and gene",
"# write the information for the hit"
] | [
{
"param": "self",
"type": null
},
{
"param": "reference",
"type": null
},
{
"param": "reference_length",
"type": null
},
{
"param": "query",
"type": null
},
{
"param": "matches",
"type": null
},
{
"param": "bug",
"type": null
},
{
"param":... | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "reference",
"type": null,
"docstring": null,
"docstring_token... |
dbe5dc350559245d705834c57b9c3eeeb261b5d3 | wbazant/humann | humann/store.py | [
"MIT"
] | Python | counts_by_bug | <not_specific> | def counts_by_bug(self):
"""
Return each bug and the total number of hits
"""
return "\n".join(["{0}: {1} hits".format(row[0], row[1]) for row in self.query('select bug, count(*) as c from alignment group by bug order by -c')]) |
Return each bug and the total number of hits
| Return each bug and the total number of hits | [
"Return",
"each",
"bug",
"and",
"the",
"total",
"number",
"of",
"hits"
] | def counts_by_bug(self):
return "\n".join(["{0}: {1} hits".format(row[0], row[1]) for row in self.query('select bug, count(*) as c from alignment group by bug order by -c')]) | [
"def",
"counts_by_bug",
"(",
"self",
")",
":",
"return",
"\"\\n\"",
".",
"join",
"(",
"[",
"\"{0}: {1} hits\"",
".",
"format",
"(",
"row",
"[",
"0",
"]",
",",
"row",
"[",
"1",
"]",
")",
"for",
"row",
"in",
"self",
".",
"query",
"(",
"'select bug, cou... | Return each bug and the total number of hits | [
"Return",
"each",
"bug",
"and",
"the",
"total",
"number",
"of",
"hits"
] | [
"\"\"\"\n Return each bug and the total number of hits\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
dbe5dc350559245d705834c57b9c3eeeb261b5d3 | wbazant/humann | humann/store.py | [
"MIT"
] | Python | gene_list | <not_specific> | def gene_list(self):
"""
Return a list of all of the gene families
"""
return [row[0] for row in self.query('select distinct reference from alignment')] |
Return a list of all of the gene families
| Return a list of all of the gene families | [
"Return",
"a",
"list",
"of",
"all",
"of",
"the",
"gene",
"families"
] | def gene_list(self):
return [row[0] for row in self.query('select distinct reference from alignment')] | [
"def",
"gene_list",
"(",
"self",
")",
":",
"return",
"[",
"row",
"[",
"0",
"]",
"for",
"row",
"in",
"self",
".",
"query",
"(",
"'select distinct reference from alignment'",
")",
"]"
] | Return a list of all of the gene families | [
"Return",
"a",
"list",
"of",
"all",
"of",
"the",
"gene",
"families"
] | [
"\"\"\"\n Return a list of all of the gene families\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
dbe5dc350559245d705834c57b9c3eeeb261b5d3 | wbazant/humann | humann/store.py | [
"MIT"
] | Python | bug_list | <not_specific> | def bug_list(self):
"""
Return a list of all of the bugs
"""
return [row[0] for row in self.query('select distinct bug from alignment')] |
Return a list of all of the bugs
| Return a list of all of the bugs | [
"Return",
"a",
"list",
"of",
"all",
"of",
"the",
"bugs"
] | def bug_list(self):
return [row[0] for row in self.query('select distinct bug from alignment')] | [
"def",
"bug_list",
"(",
"self",
")",
":",
"return",
"[",
"row",
"[",
"0",
"]",
"for",
"row",
"in",
"self",
".",
"query",
"(",
"'select distinct bug from alignment'",
")",
"]"
] | Return a list of all of the bugs | [
"Return",
"a",
"list",
"of",
"all",
"of",
"the",
"bugs"
] | [
"\"\"\"\n Return a list of all of the bugs\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
dbe5dc350559245d705834c57b9c3eeeb261b5d3 | wbazant/humann | humann/store.py | [
"MIT"
] | Python | hits_for_gene | <not_specific> | def hits_for_gene(self,gene):
"""
Return a list of all of the hits for a specific gene
"""
return [row for row in self.query('select query, bug, reference, score, length from alignment where reference=?', [gene])] |
Return a list of all of the hits for a specific gene
| Return a list of all of the hits for a specific gene | [
"Return",
"a",
"list",
"of",
"all",
"of",
"the",
"hits",
"for",
"a",
"specific",
"gene"
] | def hits_for_gene(self,gene):
return [row for row in self.query('select query, bug, reference, score, length from alignment where reference=?', [gene])] | [
"def",
"hits_for_gene",
"(",
"self",
",",
"gene",
")",
":",
"return",
"[",
"row",
"for",
"row",
"in",
"self",
".",
"query",
"(",
"'select query, bug, reference, score, length from alignment where reference=?'",
",",
"[",
"gene",
"]",
")",
"]"
] | Return a list of all of the hits for a specific gene | [
"Return",
"a",
"list",
"of",
"all",
"of",
"the",
"hits",
"for",
"a",
"specific",
"gene"
] | [
"\"\"\"\n Return a list of all of the hits for a specific gene\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "gene",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "gene",
"type": null,
"docstring": null,
"docstring_tokens": [... |
dbe5dc350559245d705834c57b9c3eeeb261b5d3 | wbazant/humann | humann/store.py | [
"MIT"
] | Python | convert_alignments_to_gene_scores | null | def convert_alignments_to_gene_scores(self,gene_scores_store):
"""
Computes the scores for all genes per bug
Add to the gene_scores store
"""
# calculate the score per bug and gene
# for a single query result, it is 1/a.length
# if a query matches multipl... |
Computes the scores for all genes per bug
Add to the gene_scores store
| Computes the scores for all genes per bug
Add to the gene_scores store | [
"Computes",
"the",
"scores",
"for",
"all",
"genes",
"per",
"bug",
"Add",
"to",
"the",
"gene_scores",
"store"
] | def convert_alignments_to_gene_scores(self,gene_scores_store):
result={}
resultAll={}
for bug, gene, score in self.query('''
select bug, reference, sum(normalized_score_partial) as score from (
select
a.query,
a.bug,
... | [
"def",
"convert_alignments_to_gene_scores",
"(",
"self",
",",
"gene_scores_store",
")",
":",
"result",
"=",
"{",
"}",
"resultAll",
"=",
"{",
"}",
"for",
"bug",
",",
"gene",
",",
"score",
"in",
"self",
".",
"query",
"(",
"'''\n select bug, reference,... | Computes the scores for all genes per bug
Add to the gene_scores store | [
"Computes",
"the",
"scores",
"for",
"all",
"genes",
"per",
"bug",
"Add",
"to",
"the",
"gene_scores",
"store"
] | [
"\"\"\"\n Computes the scores for all genes per bug\n Add to the gene_scores store\n \"\"\"",
"# calculate the score per bug and gene",
"# for a single query result, it is 1/a.length",
"# if a query matches multiple bugs and genes, its score is distributed by weighted average",
"# score... | [
{
"param": "self",
"type": null
},
{
"param": "gene_scores_store",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "gene_scores_store",
"type": null,
"docstring": null,
"docstri... |
dbe5dc350559245d705834c57b9c3eeeb261b5d3 | wbazant/humann | humann/store.py | [
"MIT"
] | Python | add | null | def add(self,gene_scores,bug):
"""
Add gene scores for a specific bug
"""
if bug in self.__scores:
self.__scores[bug]=dict(list(self.__scores[bug].items()) + list(gene_scores.items()))
else:
self.__scores[bug]=gene_scores |
Add gene scores for a specific bug
| Add gene scores for a specific bug | [
"Add",
"gene",
"scores",
"for",
"a",
"specific",
"bug"
] | def add(self,gene_scores,bug):
if bug in self.__scores:
self.__scores[bug]=dict(list(self.__scores[bug].items()) + list(gene_scores.items()))
else:
self.__scores[bug]=gene_scores | [
"def",
"add",
"(",
"self",
",",
"gene_scores",
",",
"bug",
")",
":",
"if",
"bug",
"in",
"self",
".",
"__scores",
":",
"self",
".",
"__scores",
"[",
"bug",
"]",
"=",
"dict",
"(",
"list",
"(",
"self",
".",
"__scores",
"[",
"bug",
"]",
".",
"items",... | Add gene scores for a specific bug | [
"Add",
"gene",
"scores",
"for",
"a",
"specific",
"bug"
] | [
"\"\"\" \n Add gene scores for a specific bug\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "gene_scores",
"type": null
},
{
"param": "bug",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "gene_scores",
"type": null,
"docstring": null,
"docstring_tok... |
dbe5dc350559245d705834c57b9c3eeeb261b5d3 | wbazant/humann | humann/store.py | [
"MIT"
] | Python | add_single_score | null | def add_single_score(self,bug,gene,score):
"""
Add a score for a specific bug and gene
"""
if bug in self.__scores:
self.__scores[bug][gene]=score
else:
self.__scores[bug]={gene:score} |
Add a score for a specific bug and gene
| Add a score for a specific bug and gene | [
"Add",
"a",
"score",
"for",
"a",
"specific",
"bug",
"and",
"gene"
] | def add_single_score(self,bug,gene,score):
if bug in self.__scores:
self.__scores[bug][gene]=score
else:
self.__scores[bug]={gene:score} | [
"def",
"add_single_score",
"(",
"self",
",",
"bug",
",",
"gene",
",",
"score",
")",
":",
"if",
"bug",
"in",
"self",
".",
"__scores",
":",
"self",
".",
"__scores",
"[",
"bug",
"]",
"[",
"gene",
"]",
"=",
"score",
"else",
":",
"self",
".",
"__scores"... | Add a score for a specific bug and gene | [
"Add",
"a",
"score",
"for",
"a",
"specific",
"bug",
"and",
"gene"
] | [
"\"\"\" \n Add a score for a specific bug and gene\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "bug",
"type": null
},
{
"param": "gene",
"type": null
},
{
"param": "score",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "bug",
"type": null,
"docstring": null,
"docstring_tokens": []... |
dbe5dc350559245d705834c57b9c3eeeb261b5d3 | wbazant/humann | humann/store.py | [
"MIT"
] | Python | count_genes_for_bug | <not_specific> | def count_genes_for_bug(self,bug):
"""
Count the total number of genes stored for all bugs
"""
return len(self.__scores[bug]) |
Count the total number of genes stored for all bugs
| Count the total number of genes stored for all bugs | [
"Count",
"the",
"total",
"number",
"of",
"genes",
"stored",
"for",
"all",
"bugs"
] | def count_genes_for_bug(self,bug):
return len(self.__scores[bug]) | [
"def",
"count_genes_for_bug",
"(",
"self",
",",
"bug",
")",
":",
"return",
"len",
"(",
"self",
".",
"__scores",
"[",
"bug",
"]",
")"
] | Count the total number of genes stored for all bugs | [
"Count",
"the",
"total",
"number",
"of",
"genes",
"stored",
"for",
"all",
"bugs"
] | [
"\"\"\"\n Count the total number of genes stored for all bugs\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "bug",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "bug",
"type": null,
"docstring": null,
"docstring_tokens": []... |
dbe5dc350559245d705834c57b9c3eeeb261b5d3 | wbazant/humann | humann/store.py | [
"MIT"
] | Python | bug_list | <not_specific> | def bug_list(self):
"""
Return a list of the bugs including "all"
"""
return list(self.__scores.keys()) |
Return a list of the bugs including "all"
| Return a list of the bugs including "all" | [
"Return",
"a",
"list",
"of",
"the",
"bugs",
"including",
"\"",
"all",
"\""
] | def bug_list(self):
return list(self.__scores.keys()) | [
"def",
"bug_list",
"(",
"self",
")",
":",
"return",
"list",
"(",
"self",
".",
"__scores",
".",
"keys",
"(",
")",
")"
] | Return a list of the bugs including "all" | [
"Return",
"a",
"list",
"of",
"the",
"bugs",
"including",
"\"",
"all",
"\""
] | [
"\"\"\"\n Return a list of the bugs including \"all\"\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
dbe5dc350559245d705834c57b9c3eeeb261b5d3 | wbazant/humann | humann/store.py | [
"MIT"
] | Python | gene_list | <not_specific> | def gene_list(self):
"""
Return a list of the genes
"""
genes={}
for bug in self.__scores:
for gene in self.__scores[bug]:
genes[gene]=1
return list(genes.keys()) |
Return a list of the genes
| Return a list of the genes | [
"Return",
"a",
"list",
"of",
"the",
"genes"
] | def gene_list(self):
genes={}
for bug in self.__scores:
for gene in self.__scores[bug]:
genes[gene]=1
return list(genes.keys()) | [
"def",
"gene_list",
"(",
"self",
")",
":",
"genes",
"=",
"{",
"}",
"for",
"bug",
"in",
"self",
".",
"__scores",
":",
"for",
"gene",
"in",
"self",
".",
"__scores",
"[",
"bug",
"]",
":",
"genes",
"[",
"gene",
"]",
"=",
"1",
"return",
"list",
"(",
... | Return a list of the genes | [
"Return",
"a",
"list",
"of",
"the",
"genes"
] | [
"\"\"\"\n Return a list of the genes\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
dbe5dc350559245d705834c57b9c3eeeb261b5d3 | wbazant/humann | humann/store.py | [
"MIT"
] | Python | gene_list_sorted_by_score | <not_specific> | def gene_list_sorted_by_score(self,bug):
"""
Return a list of the genes sorted by score for the bug
"""
return utilities.double_sort(self.__scores.get(bug,{})) |
Return a list of the genes sorted by score for the bug
| Return a list of the genes sorted by score for the bug | [
"Return",
"a",
"list",
"of",
"the",
"genes",
"sorted",
"by",
"score",
"for",
"the",
"bug"
] | def gene_list_sorted_by_score(self,bug):
return utilities.double_sort(self.__scores.get(bug,{})) | [
"def",
"gene_list_sorted_by_score",
"(",
"self",
",",
"bug",
")",
":",
"return",
"utilities",
".",
"double_sort",
"(",
"self",
".",
"__scores",
".",
"get",
"(",
"bug",
",",
"{",
"}",
")",
")"
] | Return a list of the genes sorted by score for the bug | [
"Return",
"a",
"list",
"of",
"the",
"genes",
"sorted",
"by",
"score",
"for",
"the",
"bug"
] | [
"\"\"\"\n Return a list of the genes sorted by score for the bug\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "bug",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "bug",
"type": null,
"docstring": null,
"docstring_tokens": []... |
dbe5dc350559245d705834c57b9c3eeeb261b5d3 | wbazant/humann | humann/store.py | [
"MIT"
] | Python | scores_for_bug | <not_specific> | def scores_for_bug(self,bug):
"""
Return the gene scores for a specific bug
"""
scores={}
if bug in self.__scores:
scores=copy.copy(self.__scores[bug])
else:
logger.debug("Request for scores for bug that does not exist.")
... |
Return the gene scores for a specific bug
| Return the gene scores for a specific bug | [
"Return",
"the",
"gene",
"scores",
"for",
"a",
"specific",
"bug"
] | def scores_for_bug(self,bug):
scores={}
if bug in self.__scores:
scores=copy.copy(self.__scores[bug])
else:
logger.debug("Request for scores for bug that does not exist.")
return scores | [
"def",
"scores_for_bug",
"(",
"self",
",",
"bug",
")",
":",
"scores",
"=",
"{",
"}",
"if",
"bug",
"in",
"self",
".",
"__scores",
":",
"scores",
"=",
"copy",
".",
"copy",
"(",
"self",
".",
"__scores",
"[",
"bug",
"]",
")",
"else",
":",
"logger",
"... | Return the gene scores for a specific bug | [
"Return",
"the",
"gene",
"scores",
"for",
"a",
"specific",
"bug"
] | [
"\"\"\"\n Return the gene scores for a specific bug\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "bug",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "bug",
"type": null,
"docstring": null,
"docstring_tokens": []... |
dbe5dc350559245d705834c57b9c3eeeb261b5d3 | wbazant/humann | humann/store.py | [
"MIT"
] | Python | add_from_file | <not_specific> | def add_from_file(self,file,id_mapping_file=None):
"""
Add all of the gene scores from the file
Use id mapping if provided
"""
# Process the id mapping file if present
id_mapping={}
if id_mapping_file:
id_mapping=store_id_mapping(id_mapping_fi... |
Add all of the gene scores from the file
Use id mapping if provided
| Add all of the gene scores from the file
Use id mapping if provided | [
"Add",
"all",
"of",
"the",
"gene",
"scores",
"from",
"the",
"file",
"Use",
"id",
"mapping",
"if",
"provided"
] | def add_from_file(self,file,id_mapping_file=None):
id_mapping={}
if id_mapping_file:
id_mapping=store_id_mapping(id_mapping_file)
unaligned_reads_count=0
utilities.file_exists_readable(file)
file_handle=open(file,"rt")
line=file_handle.readline()
while... | [
"def",
"add_from_file",
"(",
"self",
",",
"file",
",",
"id_mapping_file",
"=",
"None",
")",
":",
"id_mapping",
"=",
"{",
"}",
"if",
"id_mapping_file",
":",
"id_mapping",
"=",
"store_id_mapping",
"(",
"id_mapping_file",
")",
"unaligned_reads_count",
"=",
"0",
"... | Add all of the gene scores from the file
Use id mapping if provided | [
"Add",
"all",
"of",
"the",
"gene",
"scores",
"from",
"the",
"file",
"Use",
"id",
"mapping",
"if",
"provided"
] | [
"\"\"\"\n Add all of the gene scores from the file\n Use id mapping if provided\n \"\"\"",
"# Process the id mapping file if present",
"# Check the file exists and is readable",
"# Ignore comment lines",
"# Use id mapping if present",
"# If gene not set with id mapping, then process",... | [
{
"param": "self",
"type": null
},
{
"param": "file",
"type": null
},
{
"param": "id_mapping_file",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "file",
"type": null,
"docstring": null,
"docstring_tokens": [... |
dbe5dc350559245d705834c57b9c3eeeb261b5d3 | wbazant/humann | humann/store.py | [
"MIT"
] | Python | add | null | def add(self, bug, reaction, pathway, score):
"""
Add the pathway data to the dictionary
"""
if not bug in self.__pathways:
self.__pathways[bug]={}
if pathway in self.__pathways[bug]:
if reaction in self.__pathways[bug][pathway]:
... |
Add the pathway data to the dictionary
| Add the pathway data to the dictionary | [
"Add",
"the",
"pathway",
"data",
"to",
"the",
"dictionary"
] | def add(self, bug, reaction, pathway, score):
if not bug in self.__pathways:
self.__pathways[bug]={}
if pathway in self.__pathways[bug]:
if reaction in self.__pathways[bug][pathway]:
logger.debug("Overwrite of pathway/reaction score: %s %s", pathway, reaction)
... | [
"def",
"add",
"(",
"self",
",",
"bug",
",",
"reaction",
",",
"pathway",
",",
"score",
")",
":",
"if",
"not",
"bug",
"in",
"self",
".",
"__pathways",
":",
"self",
".",
"__pathways",
"[",
"bug",
"]",
"=",
"{",
"}",
"if",
"pathway",
"in",
"self",
".... | Add the pathway data to the dictionary | [
"Add",
"the",
"pathway",
"data",
"to",
"the",
"dictionary"
] | [
"\"\"\" \n Add the pathway data to the dictionary\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "bug",
"type": null
},
{
"param": "reaction",
"type": null
},
{
"param": "pathway",
"type": null
},
{
"param": "score",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "bug",
"type": null,
"docstring": null,
"docstring_tokens": []... |
dbe5dc350559245d705834c57b9c3eeeb261b5d3 | wbazant/humann | humann/store.py | [
"MIT"
] | Python | bug_list | <not_specific> | def bug_list(self):
"""
Get a list of the bugs
"""
return list(self.__pathways.keys()) |
Get a list of the bugs
| Get a list of the bugs | [
"Get",
"a",
"list",
"of",
"the",
"bugs"
] | def bug_list(self):
return list(self.__pathways.keys()) | [
"def",
"bug_list",
"(",
"self",
")",
":",
"return",
"list",
"(",
"self",
".",
"__pathways",
".",
"keys",
"(",
")",
")"
] | Get a list of the bugs | [
"Get",
"a",
"list",
"of",
"the",
"bugs"
] | [
"\"\"\"\n Get a list of the bugs\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
dbe5dc350559245d705834c57b9c3eeeb261b5d3 | wbazant/humann | humann/store.py | [
"MIT"
] | Python | pathway_list | <not_specific> | def pathway_list(self, bug):
"""
Return the keys in the pathways dictionary for a bug
"""
return list(self.__pathways.get(bug,{}).keys()) |
Return the keys in the pathways dictionary for a bug
| Return the keys in the pathways dictionary for a bug | [
"Return",
"the",
"keys",
"in",
"the",
"pathways",
"dictionary",
"for",
"a",
"bug"
] | def pathway_list(self, bug):
return list(self.__pathways.get(bug,{}).keys()) | [
"def",
"pathway_list",
"(",
"self",
",",
"bug",
")",
":",
"return",
"list",
"(",
"self",
".",
"__pathways",
".",
"get",
"(",
"bug",
",",
"{",
"}",
")",
".",
"keys",
"(",
")",
")"
] | Return the keys in the pathways dictionary for a bug | [
"Return",
"the",
"keys",
"in",
"the",
"pathways",
"dictionary",
"for",
"a",
"bug"
] | [
"\"\"\"\n Return the keys in the pathways dictionary for a bug\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "bug",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "bug",
"type": null,
"docstring": null,
"docstring_tokens": []... |
dbe5dc350559245d705834c57b9c3eeeb261b5d3 | wbazant/humann | humann/store.py | [
"MIT"
] | Python | reaction_scores | <not_specific> | def reaction_scores(self, bug, pathway):
"""
Return the reactions in the pathways dictionary for a pathway and bug
"""
return copy.copy(self.__pathways.get(bug,{}).get(pathway,{})) |
Return the reactions in the pathways dictionary for a pathway and bug
| Return the reactions in the pathways dictionary for a pathway and bug | [
"Return",
"the",
"reactions",
"in",
"the",
"pathways",
"dictionary",
"for",
"a",
"pathway",
"and",
"bug"
] | def reaction_scores(self, bug, pathway):
return copy.copy(self.__pathways.get(bug,{}).get(pathway,{})) | [
"def",
"reaction_scores",
"(",
"self",
",",
"bug",
",",
"pathway",
")",
":",
"return",
"copy",
".",
"copy",
"(",
"self",
".",
"__pathways",
".",
"get",
"(",
"bug",
",",
"{",
"}",
")",
".",
"get",
"(",
"pathway",
",",
"{",
"}",
")",
")"
] | Return the reactions in the pathways dictionary for a pathway and bug | [
"Return",
"the",
"reactions",
"in",
"the",
"pathways",
"dictionary",
"for",
"a",
"pathway",
"and",
"bug"
] | [
"\"\"\"\n Return the reactions in the pathways dictionary for a pathway and bug\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "bug",
"type": null
},
{
"param": "pathway",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "bug",
"type": null,
"docstring": null,
"docstring_tokens": []... |
dbe5dc350559245d705834c57b9c3eeeb261b5d3 | wbazant/humann | humann/store.py | [
"MIT"
] | Python | median_score | <not_specific> | def median_score(self, bug):
"""
Compute the median score for all scores in all pathways for one bug
"""
# Create a list of all of the scores in all pathways
all_scores=[]
for item in self.__pathways.get(bug,{}).values():
all_scores+=item.values()
... |
Compute the median score for all scores in all pathways for one bug
| Compute the median score for all scores in all pathways for one bug | [
"Compute",
"the",
"median",
"score",
"for",
"all",
"scores",
"in",
"all",
"pathways",
"for",
"one",
"bug"
] | def median_score(self, bug):
all_scores=[]
for item in self.__pathways.get(bug,{}).values():
all_scores+=item.values()
all_scores.sort()
median_score_value=0
if all_scores:
if len(all_scores) % 2 == 0:
index1=int(len(all_scores)/2)
... | [
"def",
"median_score",
"(",
"self",
",",
"bug",
")",
":",
"all_scores",
"=",
"[",
"]",
"for",
"item",
"in",
"self",
".",
"__pathways",
".",
"get",
"(",
"bug",
",",
"{",
"}",
")",
".",
"values",
"(",
")",
":",
"all_scores",
"+=",
"item",
".",
"val... | Compute the median score for all scores in all pathways for one bug | [
"Compute",
"the",
"median",
"score",
"for",
"all",
"scores",
"in",
"all",
"pathways",
"for",
"one",
"bug"
] | [
"\"\"\"\n Compute the median score for all scores in all pathways for one bug\n \"\"\"",
"# Create a list of all of the scores in all pathways",
"# Find the median score value"
] | [
{
"param": "self",
"type": null
},
{
"param": "bug",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "bug",
"type": null,
"docstring": null,
"docstring_tokens": []... |
dbe5dc350559245d705834c57b9c3eeeb261b5d3 | wbazant/humann | humann/store.py | [
"MIT"
] | Python | max_median_score | <not_specific> | def max_median_score(self,bug):
"""
Compute an alternative median score using the max values for the reactions for each pathway
"""
# Create a list of the max scores for each of the pathways
all_scores=[]
for item in self.__pathways.get(bug,{}).values():
... |
Compute an alternative median score using the max values for the reactions for each pathway
| Compute an alternative median score using the max values for the reactions for each pathway | [
"Compute",
"an",
"alternative",
"median",
"score",
"using",
"the",
"max",
"values",
"for",
"the",
"reactions",
"for",
"each",
"pathway"
] | def max_median_score(self,bug):
all_scores=[]
for item in self.__pathways.get(bug,{}).values():
all_scores.append(max(item.values()))
all_scores.sort()
median_score_value=0
if all_scores:
if len(all_scores) % 2 == 0:
index1=int(len(all_scor... | [
"def",
"max_median_score",
"(",
"self",
",",
"bug",
")",
":",
"all_scores",
"=",
"[",
"]",
"for",
"item",
"in",
"self",
".",
"__pathways",
".",
"get",
"(",
"bug",
",",
"{",
"}",
")",
".",
"values",
"(",
")",
":",
"all_scores",
".",
"append",
"(",
... | Compute an alternative median score using the max values for the reactions for each pathway | [
"Compute",
"an",
"alternative",
"median",
"score",
"using",
"the",
"max",
"values",
"for",
"the",
"reactions",
"for",
"each",
"pathway"
] | [
"\"\"\"\n Compute an alternative median score using the max values for the reactions for each pathway\n \"\"\"",
"# Create a list of the max scores for each of the pathways",
"# Find the median score value from the list of max scores per reaction"
] | [
{
"param": "self",
"type": null
},
{
"param": "bug",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "bug",
"type": null,
"docstring": null,
"docstring_tokens": []... |
dbe5dc350559245d705834c57b9c3eeeb261b5d3 | wbazant/humann | humann/store.py | [
"MIT"
] | Python | count_pathways | <not_specific> | def count_pathways(self,bug):
"""
Return the total number of pathways for a bug
"""
return len(self.__pathways.get(bug,{}).keys()) |
Return the total number of pathways for a bug
| Return the total number of pathways for a bug | [
"Return",
"the",
"total",
"number",
"of",
"pathways",
"for",
"a",
"bug"
] | def count_pathways(self,bug):
return len(self.__pathways.get(bug,{}).keys()) | [
"def",
"count_pathways",
"(",
"self",
",",
"bug",
")",
":",
"return",
"len",
"(",
"self",
".",
"__pathways",
".",
"get",
"(",
"bug",
",",
"{",
"}",
")",
".",
"keys",
"(",
")",
")"
] | Return the total number of pathways for a bug | [
"Return",
"the",
"total",
"number",
"of",
"pathways",
"for",
"a",
"bug"
] | [
"\"\"\"\n Return the total number of pathways for a bug\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "bug",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "bug",
"type": null,
"docstring": null,
"docstring_tokens": []... |
dbe5dc350559245d705834c57b9c3eeeb261b5d3 | wbazant/humann | humann/store.py | [
"MIT"
] | Python | add | null | def add(self, bug, pathway, score):
"""
Add the pathway score for the bug
"""
# Try to convert the score to a float
try:
score=float(score)
except ValueError:
score=0
logger.debug("Non-float value found for pathway: " + pathway... |
Add the pathway score for the bug
| Add the pathway score for the bug | [
"Add",
"the",
"pathway",
"score",
"for",
"the",
"bug"
] | def add(self, bug, pathway, score):
try:
score=float(score)
except ValueError:
score=0
logger.debug("Non-float value found for pathway: " + pathway)
if score>0:
if bug == "all":
self.__pathways[pathway]=score
else:
... | [
"def",
"add",
"(",
"self",
",",
"bug",
",",
"pathway",
",",
"score",
")",
":",
"try",
":",
"score",
"=",
"float",
"(",
"score",
")",
"except",
"ValueError",
":",
"score",
"=",
"0",
"logger",
".",
"debug",
"(",
"\"Non-float value found for pathway: \"",
"... | Add the pathway score for the bug | [
"Add",
"the",
"pathway",
"score",
"for",
"the",
"bug"
] | [
"\"\"\"\n Add the pathway score for the bug\n \"\"\"",
"# Try to convert the score to a float",
"# Store all scores greater than 0"
] | [
{
"param": "self",
"type": null
},
{
"param": "bug",
"type": null
},
{
"param": "pathway",
"type": null
},
{
"param": "score",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "bug",
"type": null,
"docstring": null,
"docstring_tokens": []... |
dbe5dc350559245d705834c57b9c3eeeb261b5d3 | wbazant/humann | humann/store.py | [
"MIT"
] | Python | delete | null | def delete(self, bug, pathway):
"""
Delete the pathway for the bug
"""
try:
if bug == "all":
del self.__pathways[pathway]
else:
del self.__pathways_per_bug[pathway][bug]
except (KeyError,TypeError):
pass |
Delete the pathway for the bug
| Delete the pathway for the bug | [
"Delete",
"the",
"pathway",
"for",
"the",
"bug"
] | def delete(self, bug, pathway):
try:
if bug == "all":
del self.__pathways[pathway]
else:
del self.__pathways_per_bug[pathway][bug]
except (KeyError,TypeError):
pass | [
"def",
"delete",
"(",
"self",
",",
"bug",
",",
"pathway",
")",
":",
"try",
":",
"if",
"bug",
"==",
"\"all\"",
":",
"del",
"self",
".",
"__pathways",
"[",
"pathway",
"]",
"else",
":",
"del",
"self",
".",
"__pathways_per_bug",
"[",
"pathway",
"]",
"[",... | Delete the pathway for the bug | [
"Delete",
"the",
"pathway",
"for",
"the",
"bug"
] | [
"\"\"\"\n Delete the pathway for the bug\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "bug",
"type": null
},
{
"param": "pathway",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "bug",
"type": null,
"docstring": null,
"docstring_tokens": []... |
dbe5dc350559245d705834c57b9c3eeeb261b5d3 | wbazant/humann | humann/store.py | [
"MIT"
] | Python | find_reactions | <not_specific> | def find_reactions(self,gene):
"""
Return the list of reactions associated with the gene
"""
return copy.copy(self.__genes_to_reactions.get(gene,[])) |
Return the list of reactions associated with the gene
| Return the list of reactions associated with the gene | [
"Return",
"the",
"list",
"of",
"reactions",
"associated",
"with",
"the",
"gene"
] | def find_reactions(self,gene):
return copy.copy(self.__genes_to_reactions.get(gene,[])) | [
"def",
"find_reactions",
"(",
"self",
",",
"gene",
")",
":",
"return",
"copy",
".",
"copy",
"(",
"self",
".",
"__genes_to_reactions",
".",
"get",
"(",
"gene",
",",
"[",
"]",
")",
")"
] | Return the list of reactions associated with the gene | [
"Return",
"the",
"list",
"of",
"reactions",
"associated",
"with",
"the",
"gene"
] | [
"\"\"\"\n Return the list of reactions associated with the gene\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "gene",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "gene",
"type": null,
"docstring": null,
"docstring_tokens": [... |
dbe5dc350559245d705834c57b9c3eeeb261b5d3 | wbazant/humann | humann/store.py | [
"MIT"
] | Python | find_genes | <not_specific> | def find_genes(self,reaction):
"""
Return the list of genes associated with the reaction
"""
return copy.copy(self.__reactions_to_genes.get(reaction,[])) |
Return the list of genes associated with the reaction
| Return the list of genes associated with the reaction | [
"Return",
"the",
"list",
"of",
"genes",
"associated",
"with",
"the",
"reaction"
] | def find_genes(self,reaction):
return copy.copy(self.__reactions_to_genes.get(reaction,[])) | [
"def",
"find_genes",
"(",
"self",
",",
"reaction",
")",
":",
"return",
"copy",
".",
"copy",
"(",
"self",
".",
"__reactions_to_genes",
".",
"get",
"(",
"reaction",
",",
"[",
"]",
")",
")"
] | Return the list of genes associated with the reaction | [
"Return",
"the",
"list",
"of",
"genes",
"associated",
"with",
"the",
"reaction"
] | [
"\"\"\"\n Return the list of genes associated with the reaction\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "reaction",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "reaction",
"type": null,
"docstring": null,
"docstring_tokens... |
dbe5dc350559245d705834c57b9c3eeeb261b5d3 | wbazant/humann | humann/store.py | [
"MIT"
] | Python | reaction_list | <not_specific> | def reaction_list(self):
"""
Return the list of all the reactions in the database
"""
return self.__reactions_to_genes.keys() |
Return the list of all the reactions in the database
| Return the list of all the reactions in the database | [
"Return",
"the",
"list",
"of",
"all",
"the",
"reactions",
"in",
"the",
"database"
] | def reaction_list(self):
return self.__reactions_to_genes.keys() | [
"def",
"reaction_list",
"(",
"self",
")",
":",
"return",
"self",
".",
"__reactions_to_genes",
".",
"keys",
"(",
")"
] | Return the list of all the reactions in the database | [
"Return",
"the",
"list",
"of",
"all",
"the",
"reactions",
"in",
"the",
"database"
] | [
"\"\"\"\n Return the list of all the reactions in the database\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
dbe5dc350559245d705834c57b9c3eeeb261b5d3 | wbazant/humann | humann/store.py | [
"MIT"
] | Python | gene_list | <not_specific> | def gene_list(self):
"""
Return the list of all the genes in the database
"""
return self.__genes_to_reactions.keys() |
Return the list of all the genes in the database
| Return the list of all the genes in the database | [
"Return",
"the",
"list",
"of",
"all",
"the",
"genes",
"in",
"the",
"database"
] | def gene_list(self):
return self.__genes_to_reactions.keys() | [
"def",
"gene_list",
"(",
"self",
")",
":",
"return",
"self",
".",
"__genes_to_reactions",
".",
"keys",
"(",
")"
] | Return the list of all the genes in the database | [
"Return",
"the",
"list",
"of",
"all",
"the",
"genes",
"in",
"the",
"database"
] | [
"\"\"\"\n Return the list of all the genes in the database\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
dbe5dc350559245d705834c57b9c3eeeb261b5d3 | wbazant/humann | humann/store.py | [
"MIT"
] | Python | gene_present | <not_specific> | def gene_present(self, gene):
"""
Check if the gene is included in the database
"""
present=False
if gene in self.__genes_to_reactions:
present=True
return present |
Check if the gene is included in the database
| Check if the gene is included in the database | [
"Check",
"if",
"the",
"gene",
"is",
"included",
"in",
"the",
"database"
] | def gene_present(self, gene):
present=False
if gene in self.__genes_to_reactions:
present=True
return present | [
"def",
"gene_present",
"(",
"self",
",",
"gene",
")",
":",
"present",
"=",
"False",
"if",
"gene",
"in",
"self",
".",
"__genes_to_reactions",
":",
"present",
"=",
"True",
"return",
"present"
] | Check if the gene is included in the database | [
"Check",
"if",
"the",
"gene",
"is",
"included",
"in",
"the",
"database"
] | [
"\"\"\"\n Check if the gene is included in the database\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "gene",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "gene",
"type": null,
"docstring": null,
"docstring_tokens": [... |
dbe5dc350559245d705834c57b9c3eeeb261b5d3 | wbazant/humann | humann/store.py | [
"MIT"
] | Python | _is_optional_reaction | <not_specific> | def _is_optional_reaction(self, item, reaction_names=None):
"""
Check if this reaction is optional
"""
if reaction_names is None:
reaction_names=[]
# count the number of indicators at the beginning of the name
char=item[0]
index=0
... |
Check if this reaction is optional
| Check if this reaction is optional | [
"Check",
"if",
"this",
"reaction",
"is",
"optional"
] | def _is_optional_reaction(self, item, reaction_names=None):
if reaction_names is None:
reaction_names=[]
char=item[0]
index=0
optional_indicator_count=0
while char == config.pathway_reaction_optional:
optional_indicator_count+=1
index+=1
... | [
"def",
"_is_optional_reaction",
"(",
"self",
",",
"item",
",",
"reaction_names",
"=",
"None",
")",
":",
"if",
"reaction_names",
"is",
"None",
":",
"reaction_names",
"=",
"[",
"]",
"char",
"=",
"item",
"[",
"0",
"]",
"index",
"=",
"0",
"optional_indicator_c... | Check if this reaction is optional | [
"Check",
"if",
"this",
"reaction",
"is",
"optional"
] | [
"\"\"\"\n Check if this reaction is optional\n \"\"\"",
"# count the number of indicators at the beginning of the name",
"# this reaction has an optional indicator only if it is",
"# not part of the original reaction name",
"# original names can start with \"--\" ",
"# first check for the o... | [
{
"param": "self",
"type": null
},
{
"param": "item",
"type": null
},
{
"param": "reaction_names",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "item",
"type": null,
"docstring": null,
"docstring_tokens": [... |
dbe5dc350559245d705834c57b9c3eeeb261b5d3 | wbazant/humann | humann/store.py | [
"MIT"
] | Python | _find_reaction_list_and_key_reactions | <not_specific> | def _find_reaction_list_and_key_reactions(self,items,reaction_names=None):
"""
Find the reactions in the pathways items and also the key reactions
"""
reaction_list=[]
key_reactions=[]
for item in items:
# ignore items that are not reactions as they a... |
Find the reactions in the pathways items and also the key reactions
| Find the reactions in the pathways items and also the key reactions | [
"Find",
"the",
"reactions",
"in",
"the",
"pathways",
"items",
"and",
"also",
"the",
"key",
"reactions"
] | def _find_reaction_list_and_key_reactions(self,items,reaction_names=None):
reaction_list=[]
key_reactions=[]
for item in items:
if not item in ["(",")","",config.pathway_AND,config.pathway_OR]:
if self._is_optional_reaction(item, reaction_names):
i... | [
"def",
"_find_reaction_list_and_key_reactions",
"(",
"self",
",",
"items",
",",
"reaction_names",
"=",
"None",
")",
":",
"reaction_list",
"=",
"[",
"]",
"key_reactions",
"=",
"[",
"]",
"for",
"item",
"in",
"items",
":",
"if",
"not",
"item",
"in",
"[",
"\"(... | Find the reactions in the pathways items and also the key reactions | [
"Find",
"the",
"reactions",
"in",
"the",
"pathways",
"items",
"and",
"also",
"the",
"key",
"reactions"
] | [
"\"\"\"\n Find the reactions in the pathways items and also the key reactions\n \"\"\"",
"# ignore items that are not reactions as they are part of pathway structure",
"# check if the item name indicates an optional reaction",
"# if so remove the optional reaction indicator at the beginning of t... | [
{
"param": "self",
"type": null
},
{
"param": "items",
"type": null
},
{
"param": "reaction_names",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "items",
"type": null,
"docstring": null,
"docstring_tokens": ... |
dbe5dc350559245d705834c57b9c3eeeb261b5d3 | wbazant/humann | humann/store.py | [
"MIT"
] | Python | _find_structure | <not_specific> | def _find_structure(self,items,reaction_names=None):
"""
Find the structure of the pathway from the string
"""
structure=[config.pathways_database_stucture_delimiter]
levels={ 0: structure}
current_level=0
# Process through the list of string... |
Find the structure of the pathway from the string
| Find the structure of the pathway from the string | [
"Find",
"the",
"structure",
"of",
"the",
"pathway",
"from",
"the",
"string"
] | def _find_structure(self,items,reaction_names=None):
structure=[config.pathways_database_stucture_delimiter]
levels={ 0: structure}
current_level=0
for item in items:
if item:
if self._is_optional_reaction(item, reaction_names):
item=item[1... | [
"def",
"_find_structure",
"(",
"self",
",",
"items",
",",
"reaction_names",
"=",
"None",
")",
":",
"structure",
"=",
"[",
"config",
".",
"pathways_database_stucture_delimiter",
"]",
"levels",
"=",
"{",
"0",
":",
"structure",
"}",
"current_level",
"=",
"0",
"... | Find the structure of the pathway from the string | [
"Find",
"the",
"structure",
"of",
"the",
"pathway",
"from",
"the",
"string"
] | [
"\"\"\"\n Find the structure of the pathway from the string\n \"\"\"",
"# Process through the list of strings",
"# check if the item name indicates an optional reaction",
"# if so remove the optional reaction indicator at the beginning of the name ",
"# Check if this is the star... | [
{
"param": "self",
"type": null
},
{
"param": "items",
"type": null
},
{
"param": "reaction_names",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "items",
"type": null,
"docstring": null,
"docstring_tokens": ... |
dbe5dc350559245d705834c57b9c3eeeb261b5d3 | wbazant/humann | humann/store.py | [
"MIT"
] | Python | _set_pathways_structure | <not_specific> | def _set_pathways_structure(self,reactions,reaction_names=None):
"""
Determine the pathways structure from the input string
"""
for pathway in reactions:
# Check if the item is a list of items
if isinstance(reactions[pathway], list):
react... |
Determine the pathways structure from the input string
| Determine the pathways structure from the input string | [
"Determine",
"the",
"pathways",
"structure",
"from",
"the",
"input",
"string"
] | def _set_pathways_structure(self,reactions,reaction_names=None):
for pathway in reactions:
if isinstance(reactions[pathway], list):
reactions[pathway]=config.pathways_database_stucture_delimiter.join(reactions[pathway])
reactions[pathway]=reactions[pathway].split(config.p... | [
"def",
"_set_pathways_structure",
"(",
"self",
",",
"reactions",
",",
"reaction_names",
"=",
"None",
")",
":",
"for",
"pathway",
"in",
"reactions",
":",
"if",
"isinstance",
"(",
"reactions",
"[",
"pathway",
"]",
",",
"list",
")",
":",
"reactions",
"[",
"pa... | Determine the pathways structure from the input string | [
"Determine",
"the",
"pathways",
"structure",
"from",
"the",
"input",
"string"
] | [
"\"\"\"\n Determine the pathways structure from the input string\n \"\"\"",
"# Check if the item is a list of items",
"# Split the reactions information by the structured pathways delimiter",
"# Find and store the structure for the pathway",
"# Find the list of reactions and the key reactions"... | [
{
"param": "self",
"type": null
},
{
"param": "reactions",
"type": null
},
{
"param": "reaction_names",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "reactions",
"type": null,
"docstring": null,
"docstring_token... |
dbe5dc350559245d705834c57b9c3eeeb261b5d3 | wbazant/humann | humann/store.py | [
"MIT"
] | Python | _store_pathways | null | def _store_pathways(self, reactions):
"""
Create the dictionaries of reactions to pathways and pathways to reactions
"""
for pathway in reactions:
for reaction in reactions[pathway]:
self.__pathways_to_reactions[pathway]=self.__pathways_to_reactions.g... |
Create the dictionaries of reactions to pathways and pathways to reactions
| Create the dictionaries of reactions to pathways and pathways to reactions | [
"Create",
"the",
"dictionaries",
"of",
"reactions",
"to",
"pathways",
"and",
"pathways",
"to",
"reactions"
] | def _store_pathways(self, reactions):
for pathway in reactions:
for reaction in reactions[pathway]:
self.__pathways_to_reactions[pathway]=self.__pathways_to_reactions.get(
pathway,[]) + [reaction]
self.__reactions_to_pathways[reaction]=self.__react... | [
"def",
"_store_pathways",
"(",
"self",
",",
"reactions",
")",
":",
"for",
"pathway",
"in",
"reactions",
":",
"for",
"reaction",
"in",
"reactions",
"[",
"pathway",
"]",
":",
"self",
".",
"__pathways_to_reactions",
"[",
"pathway",
"]",
"=",
"self",
".",
"__p... | Create the dictionaries of reactions to pathways and pathways to reactions | [
"Create",
"the",
"dictionaries",
"of",
"reactions",
"to",
"pathways",
"and",
"pathways",
"to",
"reactions"
] | [
"\"\"\"\n Create the dictionaries of reactions to pathways and pathways to reactions\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "reactions",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "reactions",
"type": null,
"docstring": null,
"docstring_token... |
dbe5dc350559245d705834c57b9c3eeeb261b5d3 | wbazant/humann | humann/store.py | [
"MIT"
] | Python | is_structured | <not_specific> | def is_structured(self):
"""
Return True if this is a set of structured pathways
"""
if self.__pathways_structure:
return True
else:
return False |
Return True if this is a set of structured pathways
| Return True if this is a set of structured pathways | [
"Return",
"True",
"if",
"this",
"is",
"a",
"set",
"of",
"structured",
"pathways"
] | def is_structured(self):
if self.__pathways_structure:
return True
else:
return False | [
"def",
"is_structured",
"(",
"self",
")",
":",
"if",
"self",
".",
"__pathways_structure",
":",
"return",
"True",
"else",
":",
"return",
"False"
] | Return True if this is a set of structured pathways | [
"Return",
"True",
"if",
"this",
"is",
"a",
"set",
"of",
"structured",
"pathways"
] | [
"\"\"\"\n Return True if this is a set of structured pathways\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
dbe5dc350559245d705834c57b9c3eeeb261b5d3 | wbazant/humann | humann/store.py | [
"MIT"
] | Python | add_pathway_structure | null | def add_pathway_structure(self, pathway, structure, reactions_database=None):
"""
Add the string structure for a pathway
"""
reaction_names=None
if not reactions_database is None:
reaction_names=reactions_database.reaction_list()
reactions=se... |
Add the string structure for a pathway
| Add the string structure for a pathway | [
"Add",
"the",
"string",
"structure",
"for",
"a",
"pathway"
] | def add_pathway_structure(self, pathway, structure, reactions_database=None):
reaction_names=None
if not reactions_database is None:
reaction_names=reactions_database.reaction_list()
reactions=self._set_pathways_structure({pathway: structure},reaction_names)
self._store_pathw... | [
"def",
"add_pathway_structure",
"(",
"self",
",",
"pathway",
",",
"structure",
",",
"reactions_database",
"=",
"None",
")",
":",
"reaction_names",
"=",
"None",
"if",
"not",
"reactions_database",
"is",
"None",
":",
"reaction_names",
"=",
"reactions_database",
".",
... | Add the string structure for a pathway | [
"Add",
"the",
"string",
"structure",
"for",
"a",
"pathway"
] | [
"\"\"\"\n Add the string structure for a pathway\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "pathway",
"type": null
},
{
"param": "structure",
"type": null
},
{
"param": "reactions_database",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "pathway",
"type": null,
"docstring": null,
"docstring_tokens"... |
dbe5dc350559245d705834c57b9c3eeeb261b5d3 | wbazant/humann | humann/store.py | [
"MIT"
] | Python | find_reactions | <not_specific> | def find_reactions(self,pathway):
"""
Return the list of reactions associated with the pathway
"""
return copy.copy(self.__pathways_to_reactions.get(pathway, [])) |
Return the list of reactions associated with the pathway
| Return the list of reactions associated with the pathway | [
"Return",
"the",
"list",
"of",
"reactions",
"associated",
"with",
"the",
"pathway"
] | def find_reactions(self,pathway):
return copy.copy(self.__pathways_to_reactions.get(pathway, [])) | [
"def",
"find_reactions",
"(",
"self",
",",
"pathway",
")",
":",
"return",
"copy",
".",
"copy",
"(",
"self",
".",
"__pathways_to_reactions",
".",
"get",
"(",
"pathway",
",",
"[",
"]",
")",
")"
] | Return the list of reactions associated with the pathway | [
"Return",
"the",
"list",
"of",
"reactions",
"associated",
"with",
"the",
"pathway"
] | [
"\"\"\"\n Return the list of reactions associated with the pathway\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "pathway",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "pathway",
"type": null,
"docstring": null,
"docstring_tokens"... |
dbe5dc350559245d705834c57b9c3eeeb261b5d3 | wbazant/humann | humann/store.py | [
"MIT"
] | Python | find_pathways | <not_specific> | def find_pathways(self,reaction):
"""
Return the list of pathways associated with the reaction
"""
return copy.copy(self.__reactions_to_pathways.get(reaction, [])) |
Return the list of pathways associated with the reaction
| Return the list of pathways associated with the reaction | [
"Return",
"the",
"list",
"of",
"pathways",
"associated",
"with",
"the",
"reaction"
] | def find_pathways(self,reaction):
return copy.copy(self.__reactions_to_pathways.get(reaction, [])) | [
"def",
"find_pathways",
"(",
"self",
",",
"reaction",
")",
":",
"return",
"copy",
".",
"copy",
"(",
"self",
".",
"__reactions_to_pathways",
".",
"get",
"(",
"reaction",
",",
"[",
"]",
")",
")"
] | Return the list of pathways associated with the reaction | [
"Return",
"the",
"list",
"of",
"pathways",
"associated",
"with",
"the",
"reaction"
] | [
"\"\"\"\n Return the list of pathways associated with the reaction\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "reaction",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "reaction",
"type": null,
"docstring": null,
"docstring_tokens... |
dbe5dc350559245d705834c57b9c3eeeb261b5d3 | wbazant/humann | humann/store.py | [
"MIT"
] | Python | reaction_list | <not_specific> | def reaction_list(self):
"""
Return the list of reactions included in the database
"""
return list(self.__reactions_to_pathways.keys()) |
Return the list of reactions included in the database
| Return the list of reactions included in the database | [
"Return",
"the",
"list",
"of",
"reactions",
"included",
"in",
"the",
"database"
] | def reaction_list(self):
return list(self.__reactions_to_pathways.keys()) | [
"def",
"reaction_list",
"(",
"self",
")",
":",
"return",
"list",
"(",
"self",
".",
"__reactions_to_pathways",
".",
"keys",
"(",
")",
")"
] | Return the list of reactions included in the database | [
"Return",
"the",
"list",
"of",
"reactions",
"included",
"in",
"the",
"database"
] | [
"\"\"\"\n Return the list of reactions included in the database\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
dbe5dc350559245d705834c57b9c3eeeb261b5d3 | wbazant/humann | humann/store.py | [
"MIT"
] | Python | pathway_list | <not_specific> | def pathway_list(self):
"""
Return the list of pathways included in the database
"""
return list(self.__pathways_to_reactions.keys()) |
Return the list of pathways included in the database
| Return the list of pathways included in the database | [
"Return",
"the",
"list",
"of",
"pathways",
"included",
"in",
"the",
"database"
] | def pathway_list(self):
return list(self.__pathways_to_reactions.keys()) | [
"def",
"pathway_list",
"(",
"self",
")",
":",
"return",
"list",
"(",
"self",
".",
"__pathways_to_reactions",
".",
"keys",
"(",
")",
")"
] | Return the list of pathways included in the database | [
"Return",
"the",
"list",
"of",
"pathways",
"included",
"in",
"the",
"database"
] | [
"\"\"\"\n Return the list of pathways included in the database\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
dbe5dc350559245d705834c57b9c3eeeb261b5d3 | wbazant/humann | humann/store.py | [
"MIT"
] | Python | add | null | def add(self, id, sequence):
"""
Store the sequence and id which should correspond to the following:
>id
sequence
"""
self.do('insert or ignore into read (id, sequence) values (?,?)', [id, sequence]) |
Store the sequence and id which should correspond to the following:
>id
sequence
| Store the sequence and id which should correspond to the following:
>id
sequence | [
"Store",
"the",
"sequence",
"and",
"id",
"which",
"should",
"correspond",
"to",
"the",
"following",
":",
">",
"id",
"sequence"
] | def add(self, id, sequence):
self.do('insert or ignore into read (id, sequence) values (?,?)', [id, sequence]) | [
"def",
"add",
"(",
"self",
",",
"id",
",",
"sequence",
")",
":",
"self",
".",
"do",
"(",
"'insert or ignore into read (id, sequence) values (?,?)'",
",",
"[",
"id",
",",
"sequence",
"]",
")"
] | Store the sequence and id which should correspond to the following:
>id
sequence | [
"Store",
"the",
"sequence",
"and",
"id",
"which",
"should",
"correspond",
"to",
"the",
"following",
":",
">",
"id",
"sequence"
] | [
"\"\"\"\n Store the sequence and id which should correspond to the following:\n >id\n sequence\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "id",
"type": null
},
{
"param": "sequence",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "id",
"type": null,
"docstring": null,
"docstring_tokens": [],... |
dbe5dc350559245d705834c57b9c3eeeb261b5d3 | wbazant/humann | humann/store.py | [
"MIT"
] | Python | process_file | null | def process_file(self, file):
"""
Process the file and yield ids and sequences
"""
# Check the file exists and is readable
utilities.file_exists_readable(file)
# Check that the file of reads is fasta
# If it is fastq, then convert the file to... |
Process the file and yield ids and sequences
| Process the file and yield ids and sequences | [
"Process",
"the",
"file",
"and",
"yield",
"ids",
"and",
"sequences"
] | def process_file(self, file):
utilities.file_exists_readable(file)
temp_file=""
if utilities.fasta_or_fastq(file) == "fastq":
input_fasta=utilities.fastq_to_fasta(file)
temp_file=input_fasta
else:
input_fasta=file
file_handle=open(input_fasta,"... | [
"def",
"process_file",
"(",
"self",
",",
"file",
")",
":",
"utilities",
".",
"file_exists_readable",
"(",
"file",
")",
"temp_file",
"=",
"\"\"",
"if",
"utilities",
".",
"fasta_or_fastq",
"(",
"file",
")",
"==",
"\"fastq\"",
":",
"input_fasta",
"=",
"utilitie... | Process the file and yield ids and sequences | [
"Process",
"the",
"file",
"and",
"yield",
"ids",
"and",
"sequences"
] | [
"\"\"\"\n Process the file and yield ids and sequences\n \"\"\"",
"# Check the file exists and is readable",
"# Check that the file of reads is fasta",
"# If it is fastq, then convert the file to fasta",
"# store the prior sequence",
"# only store the first id if multiple separated by spaces... | [
{
"param": "self",
"type": null
},
{
"param": "file",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "file",
"type": null,
"docstring": null,
"docstring_tokens": [... |
dbe5dc350559245d705834c57b9c3eeeb261b5d3 | wbazant/humann | humann/store.py | [
"MIT"
] | Python | remove_id | null | def remove_id(self, id):
"""
Remove the id and sequence from the read structure
"""
self.do('delete from read where id = ? or id = ?', [id, utilities.remove_length_annotation(id)]) |
Remove the id and sequence from the read structure
| Remove the id and sequence from the read structure | [
"Remove",
"the",
"id",
"and",
"sequence",
"from",
"the",
"read",
"structure"
] | def remove_id(self, id):
self.do('delete from read where id = ? or id = ?', [id, utilities.remove_length_annotation(id)]) | [
"def",
"remove_id",
"(",
"self",
",",
"id",
")",
":",
"self",
".",
"do",
"(",
"'delete from read where id = ? or id = ?'",
",",
"[",
"id",
",",
"utilities",
".",
"remove_length_annotation",
"(",
"id",
")",
"]",
")"
] | Remove the id and sequence from the read structure | [
"Remove",
"the",
"id",
"and",
"sequence",
"from",
"the",
"read",
"structure"
] | [
"\"\"\"\n Remove the id and sequence from the read structure\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "id",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "id",
"type": null,
"docstring": null,
"docstring_tokens": [],... |
dbe5dc350559245d705834c57b9c3eeeb261b5d3 | wbazant/humann | humann/store.py | [
"MIT"
] | Python | id_list | <not_specific> | def id_list(self):
"""
Return a list of all of the fasta ids
"""
return [row[0] for row in self.query('select id from read')] |
Return a list of all of the fasta ids
| Return a list of all of the fasta ids | [
"Return",
"a",
"list",
"of",
"all",
"of",
"the",
"fasta",
"ids"
] | def id_list(self):
return [row[0] for row in self.query('select id from read')] | [
"def",
"id_list",
"(",
"self",
")",
":",
"return",
"[",
"row",
"[",
"0",
"]",
"for",
"row",
"in",
"self",
".",
"query",
"(",
"'select id from read'",
")",
"]"
] | Return a list of all of the fasta ids | [
"Return",
"a",
"list",
"of",
"all",
"of",
"the",
"fasta",
"ids"
] | [
"\"\"\"\n Return a list of all of the fasta ids\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
dbe5dc350559245d705834c57b9c3eeeb261b5d3 | wbazant/humann | humann/store.py | [
"MIT"
] | Python | count_reads | <not_specific> | def count_reads(self):
"""
Return the total number of reads stored
"""
return self.query("select count(*) from read").fetchone()[0] |
Return the total number of reads stored
| Return the total number of reads stored | [
"Return",
"the",
"total",
"number",
"of",
"reads",
"stored"
] | def count_reads(self):
return self.query("select count(*) from read").fetchone()[0] | [
"def",
"count_reads",
"(",
"self",
")",
":",
"return",
"self",
".",
"query",
"(",
"\"select count(*) from read\"",
")",
".",
"fetchone",
"(",
")",
"[",
"0",
"]"
] | Return the total number of reads stored | [
"Return",
"the",
"total",
"number",
"of",
"reads",
"stored"
] | [
"\"\"\"\n Return the total number of reads stored\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
4c75c12d3b32bfcc927b62a96974caed5e25d3eb | wbazant/humann | humann/tools/build_custom_database.py | [
"MIT"
] | Python | format_diamond_database | null | def format_diamond_database(fasta_file, output_folder):
""" Format the input file into a diamond database """
database=os.path.join(output_folder,os.path.splitext(os.path.basename(fasta_file))[0])
command=["diamond","makedb","--in",fasta_file,"--db",database]
print("RUNNING: "+" ".join(co... | Format the input file into a diamond database | Format the input file into a diamond database | [
"Format",
"the",
"input",
"file",
"into",
"a",
"diamond",
"database"
] | def format_diamond_database(fasta_file, output_folder):
database=os.path.join(output_folder,os.path.splitext(os.path.basename(fasta_file))[0])
command=["diamond","makedb","--in",fasta_file,"--db",database]
print("RUNNING: "+" ".join(command))
try:
subprocess.check_call(command)
except (Envir... | [
"def",
"format_diamond_database",
"(",
"fasta_file",
",",
"output_folder",
")",
":",
"database",
"=",
"os",
".",
"path",
".",
"join",
"(",
"output_folder",
",",
"os",
".",
"path",
".",
"splitext",
"(",
"os",
".",
"path",
".",
"basename",
"(",
"fasta_file",... | Format the input file into a diamond database | [
"Format",
"the",
"input",
"file",
"into",
"a",
"diamond",
"database"
] | [
"\"\"\" Format the input file into a diamond database \"\"\""
] | [
{
"param": "fasta_file",
"type": null
},
{
"param": "output_folder",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "fasta_file",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "output_folder",
"type": null,
"docstring": null,
"docst... |
4c75c12d3b32bfcc927b62a96974caed5e25d3eb | wbazant/humann | humann/tools/build_custom_database.py | [
"MIT"
] | Python | filter_fasta_file | <not_specific> | def filter_fasta_file(fasta_file, output_folder, genus, id_mapping):
""" Read through each sequence in the fasta file filtering by genus """
try:
file_handle=open(fasta_file, "rt")
except EnvironmentError:
sys.exit("ERROR: Unable to read input fasta file: " + fasta_file)
# ... | Read through each sequence in the fasta file filtering by genus | Read through each sequence in the fasta file filtering by genus | [
"Read",
"through",
"each",
"sequence",
"in",
"the",
"fasta",
"file",
"filtering",
"by",
"genus"
] | def filter_fasta_file(fasta_file, output_folder, genus, id_mapping):
try:
file_handle=open(fasta_file, "rt")
except EnvironmentError:
sys.exit("ERROR: Unable to read input fasta file: " + fasta_file)
try:
input_file_basename=os.path.splitext(os.path.basename(fasta_file))
new_... | [
"def",
"filter_fasta_file",
"(",
"fasta_file",
",",
"output_folder",
",",
"genus",
",",
"id_mapping",
")",
":",
"try",
":",
"file_handle",
"=",
"open",
"(",
"fasta_file",
",",
"\"rt\"",
")",
"except",
"EnvironmentError",
":",
"sys",
".",
"exit",
"(",
"\"ERRO... | Read through each sequence in the fasta file filtering by genus | [
"Read",
"through",
"each",
"sequence",
"in",
"the",
"fasta",
"file",
"filtering",
"by",
"genus"
] | [
"\"\"\" Read through each sequence in the fasta file filtering by genus \"\"\"",
"# Create a file in the output folder that is the filtered fasta file",
"# Try to open the new file to write",
"# Get the possible mapping id",
"# Apply id mapping if included",
"# Determine if write sequence based on genus i... | [
{
"param": "fasta_file",
"type": null
},
{
"param": "output_folder",
"type": null
},
{
"param": "genus",
"type": null
},
{
"param": "id_mapping",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "fasta_file",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "output_folder",
"type": null,
"docstring": null,
"docst... |
4c75c12d3b32bfcc927b62a96974caed5e25d3eb | wbazant/humann | humann/tools/build_custom_database.py | [
"MIT"
] | Python | process_taxonomic_profile | <not_specific> | def process_taxonomic_profile(taxonomic_profile, abundance_threshold):
""" Store those genus which pass the threshold """
# The taxonomic profile will be formatted like the metaphlan2 output file
try:
file_handle=open(taxonomic_profile, "rt")
except EnvironmentError:
sys.exit("... | Store those genus which pass the threshold | Store those genus which pass the threshold | [
"Store",
"those",
"genus",
"which",
"pass",
"the",
"threshold"
] | def process_taxonomic_profile(taxonomic_profile, abundance_threshold):
try:
file_handle=open(taxonomic_profile, "rt")
except EnvironmentError:
sys.exit("ERROR: Unable to read taxonomic profile: " + taxonomic_profile)
print("Reading taxonomic profile")
genus_found=set()
for line in fi... | [
"def",
"process_taxonomic_profile",
"(",
"taxonomic_profile",
",",
"abundance_threshold",
")",
":",
"try",
":",
"file_handle",
"=",
"open",
"(",
"taxonomic_profile",
",",
"\"rt\"",
")",
"except",
"EnvironmentError",
":",
"sys",
".",
"exit",
"(",
"\"ERROR: Unable to ... | Store those genus which pass the threshold | [
"Store",
"those",
"genus",
"which",
"pass",
"the",
"threshold"
] | [
"\"\"\" Store those genus which pass the threshold \"\"\"",
"# The taxonomic profile will be formatted like the metaphlan2 output file",
"# search for the lines that have the genus-level information",
"# check threshold"
] | [
{
"param": "taxonomic_profile",
"type": null
},
{
"param": "abundance_threshold",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "taxonomic_profile",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "abundance_threshold",
"type": null,
"docstring": null,... |
4c75c12d3b32bfcc927b62a96974caed5e25d3eb | wbazant/humann | humann/tools/build_custom_database.py | [
"MIT"
] | Python | parse_arguments | <not_specific> | def parse_arguments(args):
"""
Parse the arguments from the user
"""
parser = argparse.ArgumentParser(
description= "Create a custom database file\n",
formatter_class=argparse.RawTextHelpFormatter)
parser.add_argument(
"-i","--input",
help="the fasta input file\... |
Parse the arguments from the user
| Parse the arguments from the user | [
"Parse",
"the",
"arguments",
"from",
"the",
"user"
] | def parse_arguments(args):
parser = argparse.ArgumentParser(
description= "Create a custom database file\n",
formatter_class=argparse.RawTextHelpFormatter)
parser.add_argument(
"-i","--input",
help="the fasta input file\n",
required=True)
parser.add_argument(
... | [
"def",
"parse_arguments",
"(",
"args",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"\"Create a custom database file\\n\"",
",",
"formatter_class",
"=",
"argparse",
".",
"RawTextHelpFormatter",
")",
"parser",
".",
"add_argument"... | Parse the arguments from the user | [
"Parse",
"the",
"arguments",
"from",
"the",
"user"
] | [
"\"\"\" \n Parse the arguments from the user\n \"\"\""
] | [
{
"param": "args",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "args",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
cf9fb73148764e836ab10b5c81110cddf64b7646 | wbazant/humann | humann/tools/join_tables.py | [
"MIT"
] | Python | join_gene_tables | null | def join_gene_tables(gene_tables,output,verbose=None):
"""
Join the gene tables to a single gene table
"""
gene_table_data={}
start_column_id=""
samples=[]
file_basenames=[]
index=0
for gene_table in gene_tables:
if verbose:
print("Reading file: " + ... |
Join the gene tables to a single gene table
| Join the gene tables to a single gene table | [
"Join",
"the",
"gene",
"tables",
"to",
"a",
"single",
"gene",
"table"
] | def join_gene_tables(gene_tables,output,verbose=None):
gene_table_data={}
start_column_id=""
samples=[]
file_basenames=[]
index=0
for gene_table in gene_tables:
if verbose:
print("Reading file: " + gene_table)
lines=util.process_gene_table_with_header(gene_table, allo... | [
"def",
"join_gene_tables",
"(",
"gene_tables",
",",
"output",
",",
"verbose",
"=",
"None",
")",
":",
"gene_table_data",
"=",
"{",
"}",
"start_column_id",
"=",
"\"\"",
"samples",
"=",
"[",
"]",
"file_basenames",
"=",
"[",
"]",
"index",
"=",
"0",
"for",
"g... | Join the gene tables to a single gene table | [
"Join",
"the",
"gene",
"tables",
"to",
"a",
"single",
"gene",
"table"
] | [
"\"\"\"\n Join the gene tables to a single gene table\n \"\"\"",
"# get the basename of the file",
"# allow for multiple samples",
"# if there is no header in the file then use the file name as the sample name",
"# if the header names multiple samples, merge all samples",
"# this prevents extra colu... | [
{
"param": "gene_tables",
"type": null
},
{
"param": "output",
"type": null
},
{
"param": "verbose",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "gene_tables",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "output",
"type": null,
"docstring": null,
"docstring_t... |
cf9fb73148764e836ab10b5c81110cddf64b7646 | wbazant/humann | humann/tools/join_tables.py | [
"MIT"
] | Python | parse_arguments | <not_specific> | def parse_arguments(args):
"""
Parse the arguments from the user
"""
parser = argparse.ArgumentParser(
description= "Join gene, pathway, or taxonomy tables\n",
formatter_class=argparse.RawTextHelpFormatter)
parser.add_argument(
"-v","--verbose",
help="additiona... |
Parse the arguments from the user
| Parse the arguments from the user | [
"Parse",
"the",
"arguments",
"from",
"the",
"user"
] | def parse_arguments(args):
parser = argparse.ArgumentParser(
description= "Join gene, pathway, or taxonomy tables\n",
formatter_class=argparse.RawTextHelpFormatter)
parser.add_argument(
"-v","--verbose",
help="additional output is printed\n",
action="store_true",
... | [
"def",
"parse_arguments",
"(",
"args",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"\"Join gene, pathway, or taxonomy tables\\n\"",
",",
"formatter_class",
"=",
"argparse",
".",
"RawTextHelpFormatter",
")",
"parser",
".",
"add_... | Parse the arguments from the user | [
"Parse",
"the",
"arguments",
"from",
"the",
"user"
] | [
"\"\"\" \n Parse the arguments from the user\n \"\"\""
] | [
{
"param": "args",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "args",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
af673e700281e362bcb0e6b998f6caa3533857b8 | wbazant/humann | humann/quantify/families.py | [
"MIT"
] | Python | gene_families | <not_specific> | def gene_families(alignments,gene_scores,unaligned_reads_count):
"""
Compute the gene families from the alignments
"""
logger.debug("Compute gene families")
# Compute scores for each gene family for each bug set
alignments.convert_alignments_to_gene_scores(gene_scores)
# P... |
Compute the gene families from the alignments
| Compute the gene families from the alignments | [
"Compute",
"the",
"gene",
"families",
"from",
"the",
"alignments"
] | def gene_families(alignments,gene_scores,unaligned_reads_count):
logger.debug("Compute gene families")
alignments.convert_alignments_to_gene_scores(gene_scores)
gene_names=store.Names(config.gene_family_name_mapping_file)
delimiter=config.output_file_column_delimiter
category_delimiter=config.output... | [
"def",
"gene_families",
"(",
"alignments",
",",
"gene_scores",
",",
"unaligned_reads_count",
")",
":",
"logger",
".",
"debug",
"(",
"\"Compute gene families\"",
")",
"alignments",
".",
"convert_alignments_to_gene_scores",
"(",
"gene_scores",
")",
"gene_names",
"=",
"s... | Compute the gene families from the alignments | [
"Compute",
"the",
"gene",
"families",
"from",
"the",
"alignments"
] | [
"\"\"\"\n Compute the gene families from the alignments\n \"\"\"",
"# Compute scores for each gene family for each bug set",
"# Process the gene id to names mappings",
"# Write the scores ordered with the top first",
"# Add the unaligned reads count",
"# Print out the gene families with those with t... | [
{
"param": "alignments",
"type": null
},
{
"param": "gene_scores",
"type": null
},
{
"param": "unaligned_reads_count",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "alignments",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "gene_scores",
"type": null,
"docstring": null,
"docstri... |
2cfd1d21096e416daae602372ac10394cc0a9822 | wbazant/humann | humann/tools/split_table.py | [
"MIT"
] | Python | split_gene_table | <not_specific> | def split_gene_table(gene_table,output_dir, verbose=None, taxonomy_index=None,
taxonomy_level=None):
"""
Split the gene table into a table per sample
"""
# try to open the file
try:
file_handle=open(gene_table,"rt")
line=file_handle.readline()
except Env... |
Split the gene table into a table per sample
| Split the gene table into a table per sample | [
"Split",
"the",
"gene",
"table",
"into",
"a",
"table",
"per",
"sample"
] | def split_gene_table(gene_table,output_dir, verbose=None, taxonomy_index=None,
taxonomy_level=None):
try:
file_handle=open(gene_table,"rt")
line=file_handle.readline()
except EnvironmentError:
sys.exit("Unable to read file: " + gene_table)
header_flag=False
h... | [
"def",
"split_gene_table",
"(",
"gene_table",
",",
"output_dir",
",",
"verbose",
"=",
"None",
",",
"taxonomy_index",
"=",
"None",
",",
"taxonomy_level",
"=",
"None",
")",
":",
"try",
":",
"file_handle",
"=",
"open",
"(",
"gene_table",
",",
"\"rt\"",
")",
"... | Split the gene table into a table per sample | [
"Split",
"the",
"gene",
"table",
"into",
"a",
"table",
"per",
"sample"
] | [
"\"\"\"\n Split the gene table into a table per sample\n \"\"\"",
"# try to open the file",
"# find the headers",
"# if no headers are present, then use the first line as the header",
"# check for picrust metagenome file format"
] | [
{
"param": "gene_table",
"type": null
},
{
"param": "output_dir",
"type": null
},
{
"param": "verbose",
"type": null
},
{
"param": "taxonomy_index",
"type": null
},
{
"param": "taxonomy_level",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "gene_table",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "output_dir",
"type": null,
"docstring": null,
"docstrin... |
2cfd1d21096e416daae602372ac10394cc0a9822 | wbazant/humann | humann/tools/split_table.py | [
"MIT"
] | Python | split_table_sample_rows | <not_specific> | def split_table_sample_rows(file_handle, line, output_dir, verbose, taxonomy_level):
"""
Split a table where the samples are indicated in each row
"""
# create files for each sample
new_file_names=[]
# get the index to use for the taxonomy
taxonomy_options=PICRUST_METAGENOME_HEADER... |
Split a table where the samples are indicated in each row
| Split a table where the samples are indicated in each row | [
"Split",
"a",
"table",
"where",
"the",
"samples",
"are",
"indicated",
"in",
"each",
"row"
] | def split_table_sample_rows(file_handle, line, output_dir, verbose, taxonomy_level):
new_file_names=[]
taxonomy_options=PICRUST_METAGENOME_HEADER.split("\t")
taxonomy_index=taxonomy_options.index(taxonomy_level)-len(taxonomy_options)
gene_table_data_by_sample_bug={}
while line:
data=line.rst... | [
"def",
"split_table_sample_rows",
"(",
"file_handle",
",",
"line",
",",
"output_dir",
",",
"verbose",
",",
"taxonomy_level",
")",
":",
"new_file_names",
"=",
"[",
"]",
"taxonomy_options",
"=",
"PICRUST_METAGENOME_HEADER",
".",
"split",
"(",
"\"\\t\"",
")",
"taxono... | Split a table where the samples are indicated in each row | [
"Split",
"a",
"table",
"where",
"the",
"samples",
"are",
"indicated",
"in",
"each",
"row"
] | [
"\"\"\"\n Split a table where the samples are indicated in each row\n \"\"\"",
"# create files for each sample",
"# get the index to use for the taxonomy",
"# read in each line of data",
"# check for unclassified bugs (ie g__ ) and rename as \"unclassified\"",
"# sum the abundance data by sample and... | [
{
"param": "file_handle",
"type": null
},
{
"param": "line",
"type": null
},
{
"param": "output_dir",
"type": null
},
{
"param": "verbose",
"type": null
},
{
"param": "taxonomy_level",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "file_handle",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "line",
"type": null,
"docstring": null,
"docstring_tok... |
2cfd1d21096e416daae602372ac10394cc0a9822 | wbazant/humann | humann/tools/split_table.py | [
"MIT"
] | Python | split_table_sample_columns | <not_specific> | def split_table_sample_columns(file_handle, header, line, output_dir, taxonomy_index, verbose):
"""
Split a table where the abundances of genes are organized by sample in columns
"""
samples=header.rstrip().split(GENE_TABLE_DELIMITER)
# if taxonomy is set the last column is not a sampl... |
Split a table where the abundances of genes are organized by sample in columns
| Split a table where the abundances of genes are organized by sample in columns | [
"Split",
"a",
"table",
"where",
"the",
"abundances",
"of",
"genes",
"are",
"organized",
"by",
"sample",
"in",
"columns"
] | def split_table_sample_columns(file_handle, header, line, output_dir, taxonomy_index, verbose):
samples=header.rstrip().split(GENE_TABLE_DELIMITER)
if taxonomy_index != None:
header_taxonomy=samples.pop()
gene_table_data={}
while line:
data=line.rstrip().split(GENE_TABLE_DELIMITER) ... | [
"def",
"split_table_sample_columns",
"(",
"file_handle",
",",
"header",
",",
"line",
",",
"output_dir",
",",
"taxonomy_index",
",",
"verbose",
")",
":",
"samples",
"=",
"header",
".",
"rstrip",
"(",
")",
".",
"split",
"(",
"GENE_TABLE_DELIMITER",
")",
"if",
... | Split a table where the abundances of genes are organized by sample in columns | [
"Split",
"a",
"table",
"where",
"the",
"abundances",
"of",
"genes",
"are",
"organized",
"by",
"sample",
"in",
"columns"
] | [
"\"\"\"\n Split a table where the abundances of genes are organized by sample in columns\n \"\"\"",
"# if taxonomy is set the last column is not a sample but taxonomy",
"# taxonomy_index can be set to zero",
"# write the data to each of the new files",
"# process the taxonomy",
"# taxonomy_index can... | [
{
"param": "file_handle",
"type": null
},
{
"param": "header",
"type": null
},
{
"param": "line",
"type": null
},
{
"param": "output_dir",
"type": null
},
{
"param": "taxonomy_index",
"type": null
},
{
"param": "verbose",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "file_handle",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "header",
"type": null,
"docstring": null,
"docstring_t... |
2cfd1d21096e416daae602372ac10394cc0a9822 | wbazant/humann | humann/tools/split_table.py | [
"MIT"
] | Python | parse_arguments | <not_specific> | def parse_arguments(args):
"""
Parse the arguments from the user
"""
parser = argparse.ArgumentParser(
description= "Split gene table to input to HUMAnN\n",
formatter_class=argparse.RawTextHelpFormatter)
parser.add_argument(
"-v","--verbose",
help="additional o... |
Parse the arguments from the user
| Parse the arguments from the user | [
"Parse",
"the",
"arguments",
"from",
"the",
"user"
] | def parse_arguments(args):
parser = argparse.ArgumentParser(
description= "Split gene table to input to HUMAnN\n",
formatter_class=argparse.RawTextHelpFormatter)
parser.add_argument(
"-v","--verbose",
help="additional output is printed\n",
action="store_true",
d... | [
"def",
"parse_arguments",
"(",
"args",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"\"Split gene table to input to HUMAnN\\n\"",
",",
"formatter_class",
"=",
"argparse",
".",
"RawTextHelpFormatter",
")",
"parser",
".",
"add_arg... | Parse the arguments from the user | [
"Parse",
"the",
"arguments",
"from",
"the",
"user"
] | [
"\"\"\" \n Parse the arguments from the user\n \"\"\""
] | [
{
"param": "args",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "args",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
5c2210c237a9b8d2ec2d19e407350b8c35231ae6 | wbazant/humann | humann/tools/humann_config.py | [
"MIT"
] | Python | parse_arguments | <not_specific> | def parse_arguments(args):
"""
Parse the arguments from the user
"""
parser = argparse.ArgumentParser(
description= "HUMAnN Configuration\n",
formatter_class=argparse.RawTextHelpFormatter)
parser.add_argument(
"--print",
dest="print_config",
action="store_tr... |
Parse the arguments from the user
| Parse the arguments from the user | [
"Parse",
"the",
"arguments",
"from",
"the",
"user"
] | def parse_arguments(args):
parser = argparse.ArgumentParser(
description= "HUMAnN Configuration\n",
formatter_class=argparse.RawTextHelpFormatter)
parser.add_argument(
"--print",
dest="print_config",
action="store_true",
help="print the configuration\n")
pars... | [
"def",
"parse_arguments",
"(",
"args",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"\"HUMAnN Configuration\\n\"",
",",
"formatter_class",
"=",
"argparse",
".",
"RawTextHelpFormatter",
")",
"parser",
".",
"add_argument",
"(",
... | Parse the arguments from the user | [
"Parse",
"the",
"arguments",
"from",
"the",
"user"
] | [
"\"\"\" \n Parse the arguments from the user\n \"\"\""
] | [
{
"param": "args",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "args",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
518a6edd8861fff088820314b2ac0f6f282eec7d | wbazant/humann | humann/tests/utils.py | [
"MIT"
] | Python | return_exe_path | <not_specific> | def return_exe_path(exe):
"""
Return the location of the exe in $PATH
"""
paths = os.environ["PATH"].split(os.pathsep)
full_path=""
for path in paths:
fullexe = os.path.join(path,exe)
if os.path.exists(fullexe):
if os.access(fullexe,os.X_OK):
full_path... |
Return the location of the exe in $PATH
| Return the location of the exe in $PATH | [
"Return",
"the",
"location",
"of",
"the",
"exe",
"in",
"$PATH"
] | def return_exe_path(exe):
paths = os.environ["PATH"].split(os.pathsep)
full_path=""
for path in paths:
fullexe = os.path.join(path,exe)
if os.path.exists(fullexe):
if os.access(fullexe,os.X_OK):
full_path=path
return full_path | [
"def",
"return_exe_path",
"(",
"exe",
")",
":",
"paths",
"=",
"os",
".",
"environ",
"[",
"\"PATH\"",
"]",
".",
"split",
"(",
"os",
".",
"pathsep",
")",
"full_path",
"=",
"\"\"",
"for",
"path",
"in",
"paths",
":",
"fullexe",
"=",
"os",
".",
"path",
... | Return the location of the exe in $PATH | [
"Return",
"the",
"location",
"of",
"the",
"exe",
"in",
"$PATH"
] | [
"\"\"\"\n Return the location of the exe in $PATH\n \"\"\""
] | [
{
"param": "exe",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "exe",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
518a6edd8861fff088820314b2ac0f6f282eec7d | wbazant/humann | humann/tests/utils.py | [
"MIT"
] | Python | run_humann | null | def run_humann(command):
"""
Run the humann command
Use the demo chocophlan and uniref databases """
command+=["--nucleotide-database",cfg.chocophlan_example_demo_folder,
"--protein-database", cfg.uniref_example_demo_folder]
run_command(command) |
Run the humann command
Use the demo chocophlan and uniref databases | Run the humann command
Use the demo chocophlan and uniref databases | [
"Run",
"the",
"humann",
"command",
"Use",
"the",
"demo",
"chocophlan",
"and",
"uniref",
"databases"
] | def run_humann(command):
command+=["--nucleotide-database",cfg.chocophlan_example_demo_folder,
"--protein-database", cfg.uniref_example_demo_folder]
run_command(command) | [
"def",
"run_humann",
"(",
"command",
")",
":",
"command",
"+=",
"[",
"\"--nucleotide-database\"",
",",
"cfg",
".",
"chocophlan_example_demo_folder",
",",
"\"--protein-database\"",
",",
"cfg",
".",
"uniref_example_demo_folder",
"]",
"run_command",
"(",
"command",
")"
] | Run the humann command
Use the demo chocophlan and uniref databases | [
"Run",
"the",
"humann",
"command",
"Use",
"the",
"demo",
"chocophlan",
"and",
"uniref",
"databases"
] | [
"\"\"\"\n Run the humann command \n Use the demo chocophlan and uniref databases \"\"\""
] | [
{
"param": "command",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "command",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
518a6edd8861fff088820314b2ac0f6f282eec7d | wbazant/humann | humann/tests/utils.py | [
"MIT"
] | Python | check_output | null | def check_output(output_files_expected,output_folder=None):
""" Check the output folder has the expected file and they are all non-zero """
for file in output_files_expected:
if output_folder:
expected_file = os.path.join(output_folder,file)
else:
expected_file = fil... | Check the output folder has the expected file and they are all non-zero | Check the output folder has the expected file and they are all non-zero | [
"Check",
"the",
"output",
"folder",
"has",
"the",
"expected",
"file",
"and",
"they",
"are",
"all",
"non",
"-",
"zero"
] | def check_output(output_files_expected,output_folder=None):
for file in output_files_expected:
if output_folder:
expected_file = os.path.join(output_folder,file)
else:
expected_file = file
yield (os.path.isfile(os.path.join(expected_file)), "File does not exist: " + f... | [
"def",
"check_output",
"(",
"output_files_expected",
",",
"output_folder",
"=",
"None",
")",
":",
"for",
"file",
"in",
"output_files_expected",
":",
"if",
"output_folder",
":",
"expected_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"output_folder",
",",
"f... | Check the output folder has the expected file and they are all non-zero | [
"Check",
"the",
"output",
"folder",
"has",
"the",
"expected",
"file",
"and",
"they",
"are",
"all",
"non",
"-",
"zero"
] | [
"\"\"\" Check the output folder has the expected file and they are all non-zero \"\"\"",
"# check the file exists",
"# check the file is not empty"
] | [
{
"param": "output_files_expected",
"type": null
},
{
"param": "output_folder",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "output_files_expected",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "output_folder",
"type": null,
"docstring": null,
... |
518a6edd8861fff088820314b2ac0f6f282eec7d | wbazant/humann | humann/tests/utils.py | [
"MIT"
] | Python | read_table_rows | <not_specific> | def read_table_rows(file):
""" Read in the table from a file, storing by rows """
# The first line of the file is the header of column ids
data=[]
rows=[]
with open(file) as file_handle:
columns=file_handle.readline().rstrip()
for line in file_handle:
line_info=line.... | Read in the table from a file, storing by rows | Read in the table from a file, storing by rows | [
"Read",
"in",
"the",
"table",
"from",
"a",
"file",
"storing",
"by",
"rows"
] | def read_table_rows(file):
data=[]
rows=[]
with open(file) as file_handle:
columns=file_handle.readline().rstrip()
for line in file_handle:
line_info=line.rstrip().split("\t")
rows.append(line_info[0])
data.append(line_info[1:])
rows="\t".join(rows) ... | [
"def",
"read_table_rows",
"(",
"file",
")",
":",
"data",
"=",
"[",
"]",
"rows",
"=",
"[",
"]",
"with",
"open",
"(",
"file",
")",
"as",
"file_handle",
":",
"columns",
"=",
"file_handle",
".",
"readline",
"(",
")",
".",
"rstrip",
"(",
")",
"for",
"li... | Read in the table from a file, storing by rows | [
"Read",
"in",
"the",
"table",
"from",
"a",
"file",
"storing",
"by",
"rows"
] | [
"\"\"\" Read in the table from a file, storing by rows \"\"\"",
"# The first line of the file is the header of column ids",
"# reduce rows to string so it will be the same format as columns"
] | [
{
"param": "file",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "file",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
518a6edd8861fff088820314b2ac0f6f282eec7d | wbazant/humann | humann/tests/utils.py | [
"MIT"
] | Python | files_almost_equal | <not_specific> | def files_almost_equal(file1, file2, precision=None):
""" Check that the files have data that is almost equal to allow for rounding """
if not precision:
precision=7
# read the files
columns1, rows1, data1 = read_table_rows(file1)
columns2, rows2, data2 = read_table_rows(file2)... | Check that the files have data that is almost equal to allow for rounding | Check that the files have data that is almost equal to allow for rounding | [
"Check",
"that",
"the",
"files",
"have",
"data",
"that",
"is",
"almost",
"equal",
"to",
"allow",
"for",
"rounding"
] | def files_almost_equal(file1, file2, precision=None):
if not precision:
precision=7
columns1, rows1, data1 = read_table_rows(file1)
columns2, rows2, data2 = read_table_rows(file2)
if not columns1 == columns2:
return False, "Column names in files differ"
if not rows1 == rows2:
... | [
"def",
"files_almost_equal",
"(",
"file1",
",",
"file2",
",",
"precision",
"=",
"None",
")",
":",
"if",
"not",
"precision",
":",
"precision",
"=",
"7",
"columns1",
",",
"rows1",
",",
"data1",
"=",
"read_table_rows",
"(",
"file1",
")",
"columns2",
",",
"r... | Check that the files have data that is almost equal to allow for rounding | [
"Check",
"that",
"the",
"files",
"have",
"data",
"that",
"is",
"almost",
"equal",
"to",
"allow",
"for",
"rounding"
] | [
"\"\"\" Check that the files have data that is almost equal to allow for rounding \"\"\"",
"# read the files",
"# check the headers are the same",
"# check the row names are the same",
"# check the data is almost the same to allow for rounding"
] | [
{
"param": "file1",
"type": null
},
{
"param": "file2",
"type": null
},
{
"param": "precision",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "file1",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "file2",
"type": null,
"docstring": null,
"docstring_tokens":... |
518a6edd8861fff088820314b2ac0f6f282eec7d | wbazant/humann | humann/tests/utils.py | [
"MIT"
] | Python | read_biom_table | <not_specific> | def read_biom_table( path ):
"""
return the lines in the biom file
"""
try:
import biom
except ImportError:
raise ImportError("ERROR: Could not find the biom software."+
" This software is required since the input file is a biom file.")
try:
tsv_tabl... |
return the lines in the biom file
| return the lines in the biom file | [
"return",
"the",
"lines",
"in",
"the",
"biom",
"file"
] | def read_biom_table( path ):
try:
import biom
except ImportError:
raise ImportError("ERROR: Could not find the biom software."+
" This software is required since the input file is a biom file.")
try:
tsv_table = biom.load_table( path ).to_tsv().split("\n")
except (Env... | [
"def",
"read_biom_table",
"(",
"path",
")",
":",
"try",
":",
"import",
"biom",
"except",
"ImportError",
":",
"raise",
"ImportError",
"(",
"\"ERROR: Could not find the biom software.\"",
"+",
"\" This software is required since the input file is a biom file.\"",
")",
"try",
... | return the lines in the biom file | [
"return",
"the",
"lines",
"in",
"the",
"biom",
"file"
] | [
"\"\"\"\n return the lines in the biom file\n \"\"\""
] | [
{
"param": "path",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "path",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
1eb8d7027efff71c31f139e74ff2ba9ca2a4fe45 | wbazant/humann | humann/tools/split_stratified_table.py | [
"MIT"
] | Python | split_line | <not_specific> | def split_line(line):
"""
Split the table line into data tokens
"""
return line.split(COLUMN_DELIMITER) |
Split the table line into data tokens
| Split the table line into data tokens | [
"Split",
"the",
"table",
"line",
"into",
"data",
"tokens"
] | def split_line(line):
return line.split(COLUMN_DELIMITER) | [
"def",
"split_line",
"(",
"line",
")",
":",
"return",
"line",
".",
"split",
"(",
"COLUMN_DELIMITER",
")"
] | Split the table line into data tokens | [
"Split",
"the",
"table",
"line",
"into",
"data",
"tokens"
] | [
"\"\"\"\n Split the table line into data tokens\n \"\"\""
] | [
{
"param": "line",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "line",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
1eb8d7027efff71c31f139e74ff2ba9ca2a4fe45 | wbazant/humann | humann/tools/split_stratified_table.py | [
"MIT"
] | Python | parse_arguments | <not_specific> | def parse_arguments(args):
"""
Parse the arguments from the user
"""
parser = argparse.ArgumentParser(
description= "Split stratified table\n",
formatter_class=argparse.RawTextHelpFormatter)
parser.add_argument(
"-i","--input",
help="the stratified input table (... |
Parse the arguments from the user
| Parse the arguments from the user | [
"Parse",
"the",
"arguments",
"from",
"the",
"user"
] | def parse_arguments(args):
parser = argparse.ArgumentParser(
description= "Split stratified table\n",
formatter_class=argparse.RawTextHelpFormatter)
parser.add_argument(
"-i","--input",
help="the stratified input table (tsv, tsv.gzip, tsv.bzip2, or biom format)\n",
requir... | [
"def",
"parse_arguments",
"(",
"args",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"\"Split stratified table\\n\"",
",",
"formatter_class",
"=",
"argparse",
".",
"RawTextHelpFormatter",
")",
"parser",
".",
"add_argument",
"("... | Parse the arguments from the user | [
"Parse",
"the",
"arguments",
"from",
"the",
"user"
] | [
"\"\"\" \n Parse the arguments from the user\n \"\"\""
] | [
{
"param": "args",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "args",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
1cde5f1824040a999f72821c639512be9a751ae5 | wbazant/humann | humann/search/blastx_coverage.py | [
"MIT"
] | Python | parse_arguments | <not_specific> | def parse_arguments(args):
"""
Parse the arguments from the user
"""
parser = argparse.ArgumentParser(
description= "Compute blastx coverage\n",
formatter_class=argparse.RawTextHelpFormatter)
parser.add_argument(
"-i","--input",
help="the blastx formatted input file\... |
Parse the arguments from the user
| Parse the arguments from the user | [
"Parse",
"the",
"arguments",
"from",
"the",
"user"
] | def parse_arguments(args):
parser = argparse.ArgumentParser(
description= "Compute blastx coverage\n",
formatter_class=argparse.RawTextHelpFormatter)
parser.add_argument(
"-i","--input",
help="the blastx formatted input file\n",
required=True)
parser.add_argument(
... | [
"def",
"parse_arguments",
"(",
"args",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"\"Compute blastx coverage\\n\"",
",",
"formatter_class",
"=",
"argparse",
".",
"RawTextHelpFormatter",
")",
"parser",
".",
"add_argument",
"(... | Parse the arguments from the user | [
"Parse",
"the",
"arguments",
"from",
"the",
"user"
] | [
"\"\"\" \n Parse the arguments from the user\n \"\"\""
] | [
{
"param": "args",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "args",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
c990793dcfd2ca3072b492dd0bdf8395f8b9814a | wbazant/humann | humann/tests/humann_test.py | [
"MIT"
] | Python | parse_arguments | <not_specific> | def parse_arguments(args):
"""
Parse the arguments from the user
"""
parser = argparse.ArgumentParser(
description= "HUMAnN Test\n",
formatter_class=argparse.RawTextHelpFormatter,
prog="humann_test")
parser.add_argument(
"--run-functional-tests-tools",
help=... |
Parse the arguments from the user
| Parse the arguments from the user | [
"Parse",
"the",
"arguments",
"from",
"the",
"user"
] | def parse_arguments(args):
parser = argparse.ArgumentParser(
description= "HUMAnN Test\n",
formatter_class=argparse.RawTextHelpFormatter,
prog="humann_test")
parser.add_argument(
"--run-functional-tests-tools",
help="run the functional tests for tools\n",
action... | [
"def",
"parse_arguments",
"(",
"args",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"\"HUMAnN Test\\n\"",
",",
"formatter_class",
"=",
"argparse",
".",
"RawTextHelpFormatter",
",",
"prog",
"=",
"\"humann_test\"",
")",
"parse... | Parse the arguments from the user | [
"Parse",
"the",
"arguments",
"from",
"the",
"user"
] | [
"\"\"\" \n Parse the arguments from the user\n \"\"\""
] | [
{
"param": "args",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "args",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
019b7b214bb84feeade7526c341c8b2a92f7326d | wbazant/humann | humann/quantify/modules.py | [
"MIT"
] | Python | minpath_command | <not_specific> | def minpath_command(reactions_file,metacyc_datafile):
"""
Return the minpath command and the name of the output file
"""
# Create temp files for the results
tmpfile=utilities.unnamed_temp_file()
tmpfile2=utilities.unnamed_temp_file()
tmpfile3=utilities.unnamed_temp_file()
tmpfi... |
Return the minpath command and the name of the output file
| Return the minpath command and the name of the output file | [
"Return",
"the",
"minpath",
"command",
"and",
"the",
"name",
"of",
"the",
"output",
"file"
] | def minpath_command(reactions_file,metacyc_datafile):
tmpfile=utilities.unnamed_temp_file()
tmpfile2=utilities.unnamed_temp_file()
tmpfile3=utilities.unnamed_temp_file()
tmpfile4=utilities.unnamed_temp_file()
minpath_script=os.path.join(os.path.dirname(os.path.abspath(__file__)),
conf... | [
"def",
"minpath_command",
"(",
"reactions_file",
",",
"metacyc_datafile",
")",
":",
"tmpfile",
"=",
"utilities",
".",
"unnamed_temp_file",
"(",
")",
"tmpfile2",
"=",
"utilities",
".",
"unnamed_temp_file",
"(",
")",
"tmpfile3",
"=",
"utilities",
".",
"unnamed_temp_... | Return the minpath command and the name of the output file | [
"Return",
"the",
"minpath",
"command",
"and",
"the",
"name",
"of",
"the",
"output",
"file"
] | [
"\"\"\"\n Return the minpath command and the name of the output file\n \"\"\"",
"# Create temp files for the results"
] | [
{
"param": "reactions_file",
"type": null
},
{
"param": "metacyc_datafile",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "reactions_file",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "metacyc_datafile",
"type": null,
"docstring": null,
... |
019b7b214bb84feeade7526c341c8b2a92f7326d | wbazant/humann | humann/quantify/modules.py | [
"MIT"
] | Python | xipe_command | <not_specific> | def xipe_command(infile):
"""
Return the xipe command and the name of the output files
"""
xipe_exe=os.path.join(os.path.dirname(os.path.abspath(__file__)),
config.xipe_script)
args=[xipe_exe,"--file1",infile,"--file2",config.xipe_percent]
stdout_file=utilities... |
Return the xipe command and the name of the output files
| Return the xipe command and the name of the output files | [
"Return",
"the",
"xipe",
"command",
"and",
"the",
"name",
"of",
"the",
"output",
"files"
] | def xipe_command(infile):
xipe_exe=os.path.join(os.path.dirname(os.path.abspath(__file__)),
config.xipe_script)
args=[xipe_exe,"--file1",infile,"--file2",config.xipe_percent]
stdout_file=utilities.unnamed_temp_file()
stderr_file=utilities.unnamed_temp_file()
command=[sys.executable,args,[infile]... | [
"def",
"xipe_command",
"(",
"infile",
")",
":",
"xipe_exe",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"os",
".",
"path",
".",
"abspath",
"(",
"__file__",
")",
")",
",",
"config",
".",
"xipe_script",
")",
"arg... | Return the xipe command and the name of the output files | [
"Return",
"the",
"xipe",
"command",
"and",
"the",
"name",
"of",
"the",
"output",
"files"
] | [
"\"\"\"\n Return the xipe command and the name of the output files\n \"\"\""
] | [
{
"param": "infile",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "infile",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
019b7b214bb84feeade7526c341c8b2a92f7326d | wbazant/humann | humann/quantify/modules.py | [
"MIT"
] | Python | identify_reactions_and_pathways | <not_specific> | def identify_reactions_and_pathways(gene_scores, reactions_database, pathways_database):
"""
Identify the reactions and then pathways from the hits found
"""
if config.minpath_toggle == "on":
# Write a flat reactions to pathways file
logger.debug("Write flat reactions to pat... |
Identify the reactions and then pathways from the hits found
| Identify the reactions and then pathways from the hits found | [
"Identify",
"the",
"reactions",
"and",
"then",
"pathways",
"from",
"the",
"hits",
"found"
] | def identify_reactions_and_pathways(gene_scores, reactions_database, pathways_database):
if config.minpath_toggle == "on":
logger.debug("Write flat reactions to pathways file for Minpath")
pathways_database_file=utilities.unnamed_temp_file()
file_handle=open(pathways_database_file,"w")
... | [
"def",
"identify_reactions_and_pathways",
"(",
"gene_scores",
",",
"reactions_database",
",",
"pathways_database",
")",
":",
"if",
"config",
".",
"minpath_toggle",
"==",
"\"on\"",
":",
"logger",
".",
"debug",
"(",
"\"Write flat reactions to pathways file for Minpath\"",
"... | Identify the reactions and then pathways from the hits found | [
"Identify",
"the",
"reactions",
"and",
"then",
"pathways",
"from",
"the",
"hits",
"found"
] | [
"\"\"\"\n Identify the reactions and then pathways from the hits found\n \"\"\"",
"# Write a flat reactions to pathways file",
"# Create a store for the pathways and reactions by bug",
"# Run through each of the score sets by bug",
"# Merge the gene scores to reaction scores ",
"# Add the scores f... | [
{
"param": "gene_scores",
"type": null
},
{
"param": "reactions_database",
"type": null
},
{
"param": "pathways_database",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "gene_scores",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "reactions_database",
"type": null,
"docstring": null,
... |
019b7b214bb84feeade7526c341c8b2a92f7326d | wbazant/humann | humann/quantify/modules.py | [
"MIT"
] | Python | compute_pathways_coverage | <not_specific> | def compute_pathways_coverage(pathways_and_reactions_store,pathways_database):
"""
Compute the coverage of pathways for each bug
"""
pathways_coverage_store=store.Pathways()
xipe_stdout_results={}
xipe_stderr_results={}
xipe_commands=[]
for bug in pathways_and_reactions_store.bug_list()... |
Compute the coverage of pathways for each bug
| Compute the coverage of pathways for each bug | [
"Compute",
"the",
"coverage",
"of",
"pathways",
"for",
"each",
"bug"
] | def compute_pathways_coverage(pathways_and_reactions_store,pathways_database):
pathways_coverage_store=store.Pathways()
xipe_stdout_results={}
xipe_stderr_results={}
xipe_commands=[]
for bug in pathways_and_reactions_store.bug_list():
logger.debug("Compute pathway coverage for bug: " + bug)
... | [
"def",
"compute_pathways_coverage",
"(",
"pathways_and_reactions_store",
",",
"pathways_database",
")",
":",
"pathways_coverage_store",
"=",
"store",
".",
"Pathways",
"(",
")",
"xipe_stdout_results",
"=",
"{",
"}",
"xipe_stderr_results",
"=",
"{",
"}",
"xipe_commands",
... | Compute the coverage of pathways for each bug | [
"Compute",
"the",
"coverage",
"of",
"pathways",
"for",
"each",
"bug"
] | [
"\"\"\"\n Compute the coverage of pathways for each bug\n \"\"\"",
"# Process through each pathway to compute coverage",
"# Check if the pathways database is structured",
"# Apply gap fill",
"# Compute the structured pathway coverage",
"# Count the reactions with scores greater than the median",
"... | [
{
"param": "pathways_and_reactions_store",
"type": null
},
{
"param": "pathways_database",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "pathways_and_reactions_store",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "pathways_database",
"type": null,
"docstrin... |
019b7b214bb84feeade7526c341c8b2a92f7326d | wbazant/humann | humann/quantify/modules.py | [
"MIT"
] | Python | harmonic_mean | <not_specific> | def harmonic_mean(values):
"""
Return the harmonic mean for the values
"""
# If there are no values or if one of the values is zero, then the harmonic mean is zero
mean=0
if values and min(values) > 0:
reciprocal_sum=sum((1.0/v) for v in values)
mean=len(values)/reciprocal_s... |
Return the harmonic mean for the values
| Return the harmonic mean for the values | [
"Return",
"the",
"harmonic",
"mean",
"for",
"the",
"values"
] | def harmonic_mean(values):
mean=0
if values and min(values) > 0:
reciprocal_sum=sum((1.0/v) for v in values)
mean=len(values)/reciprocal_sum
return mean | [
"def",
"harmonic_mean",
"(",
"values",
")",
":",
"mean",
"=",
"0",
"if",
"values",
"and",
"min",
"(",
"values",
")",
">",
"0",
":",
"reciprocal_sum",
"=",
"sum",
"(",
"(",
"1.0",
"/",
"v",
")",
"for",
"v",
"in",
"values",
")",
"mean",
"=",
"len",... | Return the harmonic mean for the values | [
"Return",
"the",
"harmonic",
"mean",
"for",
"the",
"values"
] | [
"\"\"\"\n Return the harmonic mean for the values\n \"\"\"",
"# If there are no values or if one of the values is zero, then the harmonic mean is zero"
] | [
{
"param": "values",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "values",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
019b7b214bb84feeade7526c341c8b2a92f7326d | wbazant/humann | humann/quantify/modules.py | [
"MIT"
] | Python | compute_structured_pathway_abundance_or_coverage | <not_specific> | def compute_structured_pathway_abundance_or_coverage(structure, key_reactions, reaction_scores,
coverage_computation, median_value):
"""
Compute the abundance or coverage for a structured pathway
"""
# Process through the structure to compute the abundance
required_reaction_abundances=[]
... |
Compute the abundance or coverage for a structured pathway
| Compute the abundance or coverage for a structured pathway | [
"Compute",
"the",
"abundance",
"or",
"coverage",
"for",
"a",
"structured",
"pathway"
] | def compute_structured_pathway_abundance_or_coverage(structure, key_reactions, reaction_scores,
coverage_computation, median_value):
required_reaction_abundances=[]
optional_reaction_abundances=[]
join=structure[0]
for item in structure[1:]:
if isinstance(item, list):
required_r... | [
"def",
"compute_structured_pathway_abundance_or_coverage",
"(",
"structure",
",",
"key_reactions",
",",
"reaction_scores",
",",
"coverage_computation",
",",
"median_value",
")",
":",
"required_reaction_abundances",
"=",
"[",
"]",
"optional_reaction_abundances",
"=",
"[",
"]... | Compute the abundance or coverage for a structured pathway | [
"Compute",
"the",
"abundance",
"or",
"coverage",
"for",
"a",
"structured",
"pathway"
] | [
"\"\"\"\n Compute the abundance or coverage for a structured pathway\n \"\"\"",
"# Process through the structure to compute the abundance",
"# Select the join instead of removing from the list to not alter the list for",
"# the calling function",
"# Update the score for the reaction if this is a cover... | [
{
"param": "structure",
"type": null
},
{
"param": "key_reactions",
"type": null
},
{
"param": "reaction_scores",
"type": null
},
{
"param": "coverage_computation",
"type": null
},
{
"param": "median_value",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "structure",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "key_reactions",
"type": null,
"docstring": null,
"docstr... |
019b7b214bb84feeade7526c341c8b2a92f7326d | wbazant/humann | humann/quantify/modules.py | [
"MIT"
] | Python | gap_fill | <not_specific> | def gap_fill(key_reactions, reaction_scores):
"""
If all but one of the key reactions have abundance scores, then fill gap
Boost the lowest abundance score
"""
reaction_scores_gap_filled=reaction_scores.copy()
# do not apply gap fill, if set to off
if config.gap_fill_toggle == "off... |
If all but one of the key reactions have abundance scores, then fill gap
Boost the lowest abundance score
| If all but one of the key reactions have abundance scores, then fill gap
Boost the lowest abundance score | [
"If",
"all",
"but",
"one",
"of",
"the",
"key",
"reactions",
"have",
"abundance",
"scores",
"then",
"fill",
"gap",
"Boost",
"the",
"lowest",
"abundance",
"score"
] | def gap_fill(key_reactions, reaction_scores):
reaction_scores_gap_filled=reaction_scores.copy()
if config.gap_fill_toggle == "off":
return reaction_scores_gap_filled
key_reactions_nonzero_scores=[]
for reaction in key_reactions:
score=reaction_scores.get(reaction,0)
if score > 0:... | [
"def",
"gap_fill",
"(",
"key_reactions",
",",
"reaction_scores",
")",
":",
"reaction_scores_gap_filled",
"=",
"reaction_scores",
".",
"copy",
"(",
")",
"if",
"config",
".",
"gap_fill_toggle",
"==",
"\"off\"",
":",
"return",
"reaction_scores_gap_filled",
"key_reactions... | If all but one of the key reactions have abundance scores, then fill gap
Boost the lowest abundance score | [
"If",
"all",
"but",
"one",
"of",
"the",
"key",
"reactions",
"have",
"abundance",
"scores",
"then",
"fill",
"gap",
"Boost",
"the",
"lowest",
"abundance",
"score"
] | [
"\"\"\"\n If all but one of the key reactions have abundance scores, then fill gap\n Boost the lowest abundance score\n \"\"\"",
"# do not apply gap fill, if set to off",
"# get the scores for all of the key reactions",
"# fill single zero gap with lowest key reaction score",
"# boost lowest abunda... | [
{
"param": "key_reactions",
"type": null
},
{
"param": "reaction_scores",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "key_reactions",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "reaction_scores",
"type": null,
"docstring": null,
"... |
019b7b214bb84feeade7526c341c8b2a92f7326d | wbazant/humann | humann/quantify/modules.py | [
"MIT"
] | Python | compute_pathways_abundance | <not_specific> | def compute_pathways_abundance(pathways_and_reactions_store, pathways_database):
"""
Compute the abundance of pathways for each bug
Also find the set of the reactions with abundance in all pathways present
"""
# Store the reactions which have abundance in the pathways with abundance
reactio... |
Compute the abundance of pathways for each bug
Also find the set of the reactions with abundance in all pathways present
| Compute the abundance of pathways for each bug
Also find the set of the reactions with abundance in all pathways present | [
"Compute",
"the",
"abundance",
"of",
"pathways",
"for",
"each",
"bug",
"Also",
"find",
"the",
"set",
"of",
"the",
"reactions",
"with",
"abundance",
"in",
"all",
"pathways",
"present"
] | def compute_pathways_abundance(pathways_and_reactions_store, pathways_database):
reactions_in_pathways_present={}
pathways_abundance_store=store.Pathways()
for bug in pathways_and_reactions_store.bug_list():
logger.debug("Compute pathway abundance for bug: " + bug)
reactions_in_pathways_pres... | [
"def",
"compute_pathways_abundance",
"(",
"pathways_and_reactions_store",
",",
"pathways_database",
")",
":",
"reactions_in_pathways_present",
"=",
"{",
"}",
"pathways_abundance_store",
"=",
"store",
".",
"Pathways",
"(",
")",
"for",
"bug",
"in",
"pathways_and_reactions_s... | Compute the abundance of pathways for each bug
Also find the set of the reactions with abundance in all pathways present | [
"Compute",
"the",
"abundance",
"of",
"pathways",
"for",
"each",
"bug",
"Also",
"find",
"the",
"set",
"of",
"the",
"reactions",
"with",
"abundance",
"in",
"all",
"pathways",
"present"
] | [
"\"\"\"\n Compute the abundance of pathways for each bug\n Also find the set of the reactions with abundance in all pathways present\n \"\"\"",
"# Store the reactions which have abundance in the pathways with abundance",
"# Process through each pathway for each bug to compute abundance",
"# Check if ... | [
{
"param": "pathways_and_reactions_store",
"type": null
},
{
"param": "pathways_database",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "pathways_and_reactions_store",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "pathways_database",
"type": null,
"docstrin... |
019b7b214bb84feeade7526c341c8b2a92f7326d | wbazant/humann | humann/quantify/modules.py | [
"MIT"
] | Python | print_pathways | null | def print_pathways(pathways, file, header, pathway_names, sorted_pathways_and_bugs,
unmapped_all, unintegrated_all, unintegrated_per_bug):
"""
Print the pathways data to a file organized by pathway
"""
logger.debug("Print pathways %s", header)
delimiter=config.output_fil... |
Print the pathways data to a file organized by pathway
| Print the pathways data to a file organized by pathway | [
"Print",
"the",
"pathways",
"data",
"to",
"a",
"file",
"organized",
"by",
"pathway"
] | def print_pathways(pathways, file, header, pathway_names, sorted_pathways_and_bugs,
unmapped_all, unintegrated_all, unintegrated_per_bug):
logger.debug("Print pathways %s", header)
delimiter=config.output_file_column_delimiter
category_delimiter=config.output_file_category_delimiter ... | [
"def",
"print_pathways",
"(",
"pathways",
",",
"file",
",",
"header",
",",
"pathway_names",
",",
"sorted_pathways_and_bugs",
",",
"unmapped_all",
",",
"unintegrated_all",
",",
"unintegrated_per_bug",
")",
":",
"logger",
".",
"debug",
"(",
"\"Print pathways %s\"",
",... | Print the pathways data to a file organized by pathway | [
"Print",
"the",
"pathways",
"data",
"to",
"a",
"file",
"organized",
"by",
"pathway"
] | [
"\"\"\"\n Print the pathways data to a file organized by pathway\n \"\"\"",
"# Create the header",
"# Add the unmapped and unintegrated values",
"# Process and print per bug if selected",
"# Print out all pathways sorted",
"# Print the computation of all bugs for pathway",
"# Process and print per... | [
{
"param": "pathways",
"type": null
},
{
"param": "file",
"type": null
},
{
"param": "header",
"type": null
},
{
"param": "pathway_names",
"type": null
},
{
"param": "sorted_pathways_and_bugs",
"type": null
},
{
"param": "unmapped_all",
"type": nul... | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "pathways",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "file",
"type": null,
"docstring": null,
"docstring_tokens... |
019b7b214bb84feeade7526c341c8b2a92f7326d | wbazant/humann | humann/quantify/modules.py | [
"MIT"
] | Python | compute_gene_abundance_in_pathways | <not_specific> | def compute_gene_abundance_in_pathways(gene_scores, reactions_database, reactions_in_pathways_present):
"""
Compute the abundance of genes present in pathways found
Also compute the remaining gene abundance that did not contribute to any pathways present
"""
# From each of the reactions present... |
Compute the abundance of genes present in pathways found
Also compute the remaining gene abundance that did not contribute to any pathways present
| Compute the abundance of genes present in pathways found
Also compute the remaining gene abundance that did not contribute to any pathways present | [
"Compute",
"the",
"abundance",
"of",
"genes",
"present",
"in",
"pathways",
"found",
"Also",
"compute",
"the",
"remaining",
"gene",
"abundance",
"that",
"did",
"not",
"contribute",
"to",
"any",
"pathways",
"present"
] | def compute_gene_abundance_in_pathways(gene_scores, reactions_database, reactions_in_pathways_present):
genes_in_pathways_present={}
for bug in reactions_in_pathways_present:
genes_in_pathways_present[bug]=set()
for reaction in reactions_in_pathways_present[bug]:
if reactions_databas... | [
"def",
"compute_gene_abundance_in_pathways",
"(",
"gene_scores",
",",
"reactions_database",
",",
"reactions_in_pathways_present",
")",
":",
"genes_in_pathways_present",
"=",
"{",
"}",
"for",
"bug",
"in",
"reactions_in_pathways_present",
":",
"genes_in_pathways_present",
"[",
... | Compute the abundance of genes present in pathways found
Also compute the remaining gene abundance that did not contribute to any pathways present | [
"Compute",
"the",
"abundance",
"of",
"genes",
"present",
"in",
"pathways",
"found",
"Also",
"compute",
"the",
"remaining",
"gene",
"abundance",
"that",
"did",
"not",
"contribute",
"to",
"any",
"pathways",
"present"
] | [
"\"\"\"\n Compute the abundance of genes present in pathways found\n Also compute the remaining gene abundance that did not contribute to any pathways present\n \"\"\"",
"# From each of the reactions present in pathways, find the list of all genes",
"# that contributed to the pathway abundance (for eac... | [
{
"param": "gene_scores",
"type": null
},
{
"param": "reactions_database",
"type": null
},
{
"param": "reactions_in_pathways_present",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "gene_scores",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "reactions_database",
"type": null,
"docstring": null,
... |
019b7b214bb84feeade7526c341c8b2a92f7326d | wbazant/humann | humann/quantify/modules.py | [
"MIT"
] | Python | compute_unmapped_and_unintegrated | <not_specific> | def compute_unmapped_and_unintegrated(gene_abundance_in_pathways, remaining_gene_abundance, unaligned_reads_count, pathways_abundance):
"""
Compute the unmapped and unintegrated pathway values
The compression constant is defined as the total abundance of all pathways divided by the total abundance of genes ... |
Compute the unmapped and unintegrated pathway values
The compression constant is defined as the total abundance of all pathways divided by the total abundance of genes in pathways
| Compute the unmapped and unintegrated pathway values
The compression constant is defined as the total abundance of all pathways divided by the total abundance of genes in pathways | [
"Compute",
"the",
"unmapped",
"and",
"unintegrated",
"pathway",
"values",
"The",
"compression",
"constant",
"is",
"defined",
"as",
"the",
"total",
"abundance",
"of",
"all",
"pathways",
"divided",
"by",
"the",
"total",
"abundance",
"of",
"genes",
"in",
"pathways"... | def compute_unmapped_and_unintegrated(gene_abundance_in_pathways, remaining_gene_abundance, unaligned_reads_count, pathways_abundance):
pathways_list=pathways_abundance.get_pathways_list()
total_abundance_all_pathways=sum([pathways_abundance.get_score(pathway) for pathway in pathways_list])
try:
com... | [
"def",
"compute_unmapped_and_unintegrated",
"(",
"gene_abundance_in_pathways",
",",
"remaining_gene_abundance",
",",
"unaligned_reads_count",
",",
"pathways_abundance",
")",
":",
"pathways_list",
"=",
"pathways_abundance",
".",
"get_pathways_list",
"(",
")",
"total_abundance_al... | Compute the unmapped and unintegrated pathway values
The compression constant is defined as the total abundance of all pathways divided by the total abundance of genes in pathways | [
"Compute",
"the",
"unmapped",
"and",
"unintegrated",
"pathway",
"values",
"The",
"compression",
"constant",
"is",
"defined",
"as",
"the",
"total",
"abundance",
"of",
"all",
"pathways",
"divided",
"by",
"the",
"total",
"abundance",
"of",
"genes",
"in",
"pathways"... | [
"\"\"\"\n Compute the unmapped and unintegrated pathway values\n The compression constant is defined as the total abundance of all pathways divided by the total abundance of genes in pathways\n \"\"\"",
"# Compute the overall compression constant",
"# Compute unmapped",
"# Compute unintegrated"
] | [
{
"param": "gene_abundance_in_pathways",
"type": null
},
{
"param": "remaining_gene_abundance",
"type": null
},
{
"param": "unaligned_reads_count",
"type": null
},
{
"param": "pathways_abundance",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "gene_abundance_in_pathways",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "remaining_gene_abundance",
"type": null,
"doc... |
019b7b214bb84feeade7526c341c8b2a92f7326d | wbazant/humann | humann/quantify/modules.py | [
"MIT"
] | Python | compute_pathways_abundance_and_coverage | <not_specific> | def compute_pathways_abundance_and_coverage(gene_scores, reactions_database,
pathways_and_reactions_store, pathways_database, unaligned_reads_count):
"""
Compute the abundance and coverage of the pathways
"""
# Read in and store the pathway id to name ma... |
Compute the abundance and coverage of the pathways
| Compute the abundance and coverage of the pathways | [
"Compute",
"the",
"abundance",
"and",
"coverage",
"of",
"the",
"pathways"
] | def compute_pathways_abundance_and_coverage(gene_scores, reactions_database,
pathways_and_reactions_store, pathways_database, unaligned_reads_count):
pathway_names=store.Names(config.pathway_name_mapping_file)
pathways_abundance, reactions_in_pathways_present=compute... | [
"def",
"compute_pathways_abundance_and_coverage",
"(",
"gene_scores",
",",
"reactions_database",
",",
"pathways_and_reactions_store",
",",
"pathways_database",
",",
"unaligned_reads_count",
")",
":",
"pathway_names",
"=",
"store",
".",
"Names",
"(",
"config",
".",
"pathwa... | Compute the abundance and coverage of the pathways | [
"Compute",
"the",
"abundance",
"and",
"coverage",
"of",
"the",
"pathways"
] | [
"\"\"\"\n Compute the abundance and coverage of the pathways\n \"\"\"",
"# Read in and store the pathway id to name mappings",
"# Compute abundance for all pathways",
"# Compute the abundance of genes in pathways and not in pathways",
"# Compute the unmapped and unintegrated values",
"# Compute cove... | [
{
"param": "gene_scores",
"type": null
},
{
"param": "reactions_database",
"type": null
},
{
"param": "pathways_and_reactions_store",
"type": null
},
{
"param": "pathways_database",
"type": null
},
{
"param": "unaligned_reads_count",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "gene_scores",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "reactions_database",
"type": null,
"docstring": null,
... |
20b413c8d16d0ef4d7760b86e85c332cbcf43825 | wbazant/humann | humann/tools/reduce_table.py | [
"MIT"
] | Python | parse_arguments | <not_specific> | def parse_arguments(args):
"""
Parse the arguments from the user
"""
parser = argparse.ArgumentParser(
description= "Reduce table\n",
formatter_class=argparse.RawTextHelpFormatter)
parser.add_argument(
"-v","--verbose",
help="additional output is printed\n",
... |
Parse the arguments from the user
| Parse the arguments from the user | [
"Parse",
"the",
"arguments",
"from",
"the",
"user"
] | def parse_arguments(args):
parser = argparse.ArgumentParser(
description= "Reduce table\n",
formatter_class=argparse.RawTextHelpFormatter)
parser.add_argument(
"-v","--verbose",
help="additional output is printed\n",
action="store_true",
default=False)
parse... | [
"def",
"parse_arguments",
"(",
"args",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"\"Reduce table\\n\"",
",",
"formatter_class",
"=",
"argparse",
".",
"RawTextHelpFormatter",
")",
"parser",
".",
"add_argument",
"(",
"\"-v\... | Parse the arguments from the user | [
"Parse",
"the",
"arguments",
"from",
"the",
"user"
] | [
"\"\"\" \n Parse the arguments from the user\n \"\"\""
] | [
{
"param": "args",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "args",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
f661b53fe708f2c4889f9421bdbcc4352012af46 | wbazant/humann | humann/check.py | [
"MIT"
] | Python | python_version | null | def python_version():
"""
Check the current version of python
"""
# required python versions (2.7+ or 3.0+)
required_python_version_major = [2,3]
required_python_version_minor = [7,0]
# check for either of the required versions
pass_check=False
try:
for major, minor... |
Check the current version of python
| Check the current version of python | [
"Check",
"the",
"current",
"version",
"of",
"python"
] | def python_version():
required_python_version_major = [2,3]
required_python_version_minor = [7,0]
pass_check=False
try:
for major, minor in zip(required_python_version_major, required_python_version_minor):
if (sys.version_info[0] == major and sys.version_info[1] >= minor):
... | [
"def",
"python_version",
"(",
")",
":",
"required_python_version_major",
"=",
"[",
"2",
",",
"3",
"]",
"required_python_version_minor",
"=",
"[",
"7",
",",
"0",
"]",
"pass_check",
"=",
"False",
"try",
":",
"for",
"major",
",",
"minor",
"in",
"zip",
"(",
... | Check the current version of python | [
"Check",
"the",
"current",
"version",
"of",
"python"
] | [
"\"\"\"\n Check the current version of python\n \"\"\"",
"# required python versions (2.7+ or 3.0+)",
"# check for either of the required versions"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
7c2749d3889992594ecf37be8da949d9f1c512d8 | wbazant/humann | humann/tools/merge_abundance.py | [
"MIT"
] | Python | merge_abundances | null | def merge_abundances(gene_table,pathways_to_genes,input_pathways,output,additional_gene_info,remove_taxonomy):
"""
Read through the pathway abundances file
Write the merged abundances
"""
lines=util.process_gene_table_with_header(input_pathways, allow_for_missing_header=True)
header=next(li... |
Read through the pathway abundances file
Write the merged abundances
| Read through the pathway abundances file
Write the merged abundances | [
"Read",
"through",
"the",
"pathway",
"abundances",
"file",
"Write",
"the",
"merged",
"abundances"
] | def merge_abundances(gene_table,pathways_to_genes,input_pathways,output,additional_gene_info,remove_taxonomy):
lines=util.process_gene_table_with_header(input_pathways, allow_for_missing_header=True)
header=next(lines)
try:
write_file_handle=open(output,"w")
except EnvironmentError:
sys.... | [
"def",
"merge_abundances",
"(",
"gene_table",
",",
"pathways_to_genes",
",",
"input_pathways",
",",
"output",
",",
"additional_gene_info",
",",
"remove_taxonomy",
")",
":",
"lines",
"=",
"util",
".",
"process_gene_table_with_header",
"(",
"input_pathways",
",",
"allow... | Read through the pathway abundances file
Write the merged abundances | [
"Read",
"through",
"the",
"pathway",
"abundances",
"file",
"Write",
"the",
"merged",
"abundances"
] | [
"\"\"\"\n Read through the pathway abundances file\n Write the merged abundances\n \"\"\"",
"# open the output file",
"# read through the pathways mapping file, then merge in the gene families information",
"# read thorugh the file first to allow for unordered input files",
"# remove pathway name i... | [
{
"param": "gene_table",
"type": null
},
{
"param": "pathways_to_genes",
"type": null
},
{
"param": "input_pathways",
"type": null
},
{
"param": "output",
"type": null
},
{
"param": "additional_gene_info",
"type": null
},
{
"param": "remove_taxonomy",
... | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "gene_table",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "pathways_to_genes",
"type": null,
"docstring": null,
"d... |
7c2749d3889992594ecf37be8da949d9f1c512d8 | wbazant/humann | humann/tools/merge_abundance.py | [
"MIT"
] | Python | read_mapping | <not_specific> | def read_mapping(gene_mapping_file,pathway_mapping_file):
"""
Read the gene to reaction and then reaction to pathway mappings
"""
# read the gene to reaction mappings
reactions_to_genes={}
reactions_to_ecs={}
try:
if gene_mapping_file.endswith(".gz"):
file_handle=gz... |
Read the gene to reaction and then reaction to pathway mappings
| Read the gene to reaction and then reaction to pathway mappings | [
"Read",
"the",
"gene",
"to",
"reaction",
"and",
"then",
"reaction",
"to",
"pathway",
"mappings"
] | def read_mapping(gene_mapping_file,pathway_mapping_file):
reactions_to_genes={}
reactions_to_ecs={}
try:
if gene_mapping_file.endswith(".gz"):
file_handle=gzip.open(gene_mapping_file, "rt")
readlines = file_handle.readlines()
elif gene_mapping_file.endswith(".bz2"):
... | [
"def",
"read_mapping",
"(",
"gene_mapping_file",
",",
"pathway_mapping_file",
")",
":",
"reactions_to_genes",
"=",
"{",
"}",
"reactions_to_ecs",
"=",
"{",
"}",
"try",
":",
"if",
"gene_mapping_file",
".",
"endswith",
"(",
"\".gz\"",
")",
":",
"file_handle",
"=",
... | Read the gene to reaction and then reaction to pathway mappings | [
"Read",
"the",
"gene",
"to",
"reaction",
"and",
"then",
"reaction",
"to",
"pathway",
"mappings"
] | [
"\"\"\"\n Read the gene to reaction and then reaction to pathway mappings\n \"\"\"",
"# read the gene to reaction mappings",
"# read through the mapping lines",
"# read the reaction to pathway mappings",
"# get the reactions from the structure"
] | [
{
"param": "gene_mapping_file",
"type": null
},
{
"param": "pathway_mapping_file",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "gene_mapping_file",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "pathway_mapping_file",
"type": null,
"docstring": null... |
7c2749d3889992594ecf37be8da949d9f1c512d8 | wbazant/humann | humann/tools/merge_abundance.py | [
"MIT"
] | Python | read_gene_table | <not_specific> | def read_gene_table(gene_table):
"""
Read the input gene table
Store the abundances related to each bug
"""
gene_table_data={}
gene_names={}
lines=util.process_gene_table_with_header(gene_table, allow_for_missing_header=True)
header=next(lines)
for line in lines:
... |
Read the input gene table
Store the abundances related to each bug
| Read the input gene table
Store the abundances related to each bug | [
"Read",
"the",
"input",
"gene",
"table",
"Store",
"the",
"abundances",
"related",
"to",
"each",
"bug"
] | def read_gene_table(gene_table):
gene_table_data={}
gene_names={}
lines=util.process_gene_table_with_header(gene_table, allow_for_missing_header=True)
header=next(lines)
for line in lines:
if not re.match("#",line):
data=line.split(TABLE_DELIMITER)
try:
... | [
"def",
"read_gene_table",
"(",
"gene_table",
")",
":",
"gene_table_data",
"=",
"{",
"}",
"gene_names",
"=",
"{",
"}",
"lines",
"=",
"util",
".",
"process_gene_table_with_header",
"(",
"gene_table",
",",
"allow_for_missing_header",
"=",
"True",
")",
"header",
"="... | Read the input gene table
Store the abundances related to each bug | [
"Read",
"the",
"input",
"gene",
"table",
"Store",
"the",
"abundances",
"related",
"to",
"each",
"bug"
] | [
"\"\"\"\n Read the input gene table\n Store the abundances related to each bug\n \"\"\"",
"# process if not a comment",
"# remove the gene name if present and store",
"# check for an EC set"
] | [
{
"param": "gene_table",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "gene_table",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
7c2749d3889992594ecf37be8da949d9f1c512d8 | wbazant/humann | humann/tools/merge_abundance.py | [
"MIT"
] | Python | determine_mapping_type | <not_specific> | def determine_mapping_type(gene_table,pathways_to_genes,pathways_to_ecs):
"""
Determine if the input file is of gene families or EC abundance type
"""
all_genes=set()
all_ecs=set()
for pathway,genes in pathways_to_genes.items():
all_genes.update(genes)
all_ecs.update(pathway... |
Determine if the input file is of gene families or EC abundance type
| Determine if the input file is of gene families or EC abundance type | [
"Determine",
"if",
"the",
"input",
"file",
"is",
"of",
"gene",
"families",
"or",
"EC",
"abundance",
"type"
] | def determine_mapping_type(gene_table,pathways_to_genes,pathways_to_ecs):
all_genes=set()
all_ecs=set()
for pathway,genes in pathways_to_genes.items():
all_genes.update(genes)
all_ecs.update(pathways_to_ecs[pathway])
for gene in gene_table:
if gene in all_genes:
retur... | [
"def",
"determine_mapping_type",
"(",
"gene_table",
",",
"pathways_to_genes",
",",
"pathways_to_ecs",
")",
":",
"all_genes",
"=",
"set",
"(",
")",
"all_ecs",
"=",
"set",
"(",
")",
"for",
"pathway",
",",
"genes",
"in",
"pathways_to_genes",
".",
"items",
"(",
... | Determine if the input file is of gene families or EC abundance type | [
"Determine",
"if",
"the",
"input",
"file",
"is",
"of",
"gene",
"families",
"or",
"EC",
"abundance",
"type"
] | [
"\"\"\"\n Determine if the input file is of gene families or EC abundance type\n \"\"\""
] | [
{
"param": "gene_table",
"type": null
},
{
"param": "pathways_to_genes",
"type": null
},
{
"param": "pathways_to_ecs",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "gene_table",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "pathways_to_genes",
"type": null,
"docstring": null,
"d... |
7c2749d3889992594ecf37be8da949d9f1c512d8 | wbazant/humann | humann/tools/merge_abundance.py | [
"MIT"
] | Python | parse_arguments | <not_specific> | def parse_arguments(args):
"""
Parse the arguments from the user
"""
parser = argparse.ArgumentParser(
description= "Unpack pathway abundances to show genes included\n",
formatter_class=argparse.RawTextHelpFormatter)
parser.add_argument(
"--input-genes",
help="t... |
Parse the arguments from the user
| Parse the arguments from the user | [
"Parse",
"the",
"arguments",
"from",
"the",
"user"
] | def parse_arguments(args):
parser = argparse.ArgumentParser(
description= "Unpack pathway abundances to show genes included\n",
formatter_class=argparse.RawTextHelpFormatter)
parser.add_argument(
"--input-genes",
help="the gene family or EC abundance file\n",
required=Tru... | [
"def",
"parse_arguments",
"(",
"args",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"\"Unpack pathway abundances to show genes included\\n\"",
",",
"formatter_class",
"=",
"argparse",
".",
"RawTextHelpFormatter",
")",
"parser",
".... | Parse the arguments from the user | [
"Parse",
"the",
"arguments",
"from",
"the",
"user"
] | [
"\"\"\" \n Parse the arguments from the user\n \"\"\""
] | [
{
"param": "args",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "args",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
a6cca4cfcd85e2d4843924ab376d5e7decbfbde2 | wbazant/humann | humann/tools/humann_benchmark.py | [
"MIT"
] | Python | main | null | def main():
""" Capture time and memory from command run """
known_args, unknown_args = parse_known_args()
if not unknown_args:
# return an error message if no command is provided
sys.exit("Please provide a command to benchmark: $ humann_benchmark COMMAND")
try:
process = subproc... | Capture time and memory from command run | Capture time and memory from command run | [
"Capture",
"time",
"and",
"memory",
"from",
"command",
"run"
] | def main():
known_args, unknown_args = parse_known_args()
if not unknown_args:
sys.exit("Please provide a command to benchmark: $ humann_benchmark COMMAND")
try:
process = subprocess.Popen(" ".join(unknown_args),shell=True)
except (EnvironmentError, subprocess.CalledProcessError):
... | [
"def",
"main",
"(",
")",
":",
"known_args",
",",
"unknown_args",
"=",
"parse_known_args",
"(",
")",
"if",
"not",
"unknown_args",
":",
"sys",
".",
"exit",
"(",
"\"Please provide a command to benchmark: $ humann_benchmark COMMAND\"",
")",
"try",
":",
"process",
"=",
... | Capture time and memory from command run | [
"Capture",
"time",
"and",
"memory",
"from",
"command",
"run"
] | [
"\"\"\" Capture time and memory from command run \"\"\"",
"# return an error message if no command is provided",
"# while the process is running check on the memory use",
"# get the pids of the main process and all children (and their children)",
"# remove the header from the process output",
"# memory is... | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
62099bbf7b4837d22c33f0ea197cf63171b8328a | talkingscott/xpgdiff | xpgdiff.py | [
"MIT"
] | Python | column_name_list | <not_specific> | def column_name_list(columns):
"""
Gets a comma-separated list of column names.
:param columns: The list of columns.
:returns: A comma-separated list of column names.
"""
if not columns:
return ''
return ', '.join([column.name for column in columns]) |
Gets a comma-separated list of column names.
:param columns: The list of columns.
:returns: A comma-separated list of column names.
| Gets a comma-separated list of column names. | [
"Gets",
"a",
"comma",
"-",
"separated",
"list",
"of",
"column",
"names",
"."
] | def column_name_list(columns):
if not columns:
return ''
return ', '.join([column.name for column in columns]) | [
"def",
"column_name_list",
"(",
"columns",
")",
":",
"if",
"not",
"columns",
":",
"return",
"''",
"return",
"', '",
".",
"join",
"(",
"[",
"column",
".",
"name",
"for",
"column",
"in",
"columns",
"]",
")"
] | Gets a comma-separated list of column names. | [
"Gets",
"a",
"comma",
"-",
"separated",
"list",
"of",
"column",
"names",
"."
] | [
"\"\"\"\n Gets a comma-separated list of column names.\n\n :param columns: The list of columns.\n :returns: A comma-separated list of column names.\n \"\"\""
] | [
{
"param": "columns",
"type": null
}
] | {
"returns": [
{
"docstring": "A comma-separated list of column names.",
"docstring_tokens": [
"A",
"comma",
"-",
"separated",
"list",
"of",
"column",
"names",
"."
],
"type": null
}
],
"raises": [],
"params":... |
62099bbf7b4837d22c33f0ea197cf63171b8328a | talkingscott/xpgdiff | xpgdiff.py | [
"MIT"
] | Python | fk_action | <not_specific> | def fk_action(action):
"""
Gets the full name for a foreign key action abbreviation.
:param action: Action abbreviation.
:returns: Action full name.
"""
return _FK_ACTIONS[action] |
Gets the full name for a foreign key action abbreviation.
:param action: Action abbreviation.
:returns: Action full name.
| Gets the full name for a foreign key action abbreviation. | [
"Gets",
"the",
"full",
"name",
"for",
"a",
"foreign",
"key",
"action",
"abbreviation",
"."
] | def fk_action(action):
return _FK_ACTIONS[action] | [
"def",
"fk_action",
"(",
"action",
")",
":",
"return",
"_FK_ACTIONS",
"[",
"action",
"]"
] | Gets the full name for a foreign key action abbreviation. | [
"Gets",
"the",
"full",
"name",
"for",
"a",
"foreign",
"key",
"action",
"abbreviation",
"."
] | [
"\"\"\"\n Gets the full name for a foreign key action abbreviation.\n\n :param action: Action abbreviation.\n :returns: Action full name.\n \"\"\""
] | [
{
"param": "action",
"type": null
}
] | {
"returns": [
{
"docstring": "Action full name.",
"docstring_tokens": [
"Action",
"full",
"name",
"."
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "action",
"type": null,
"docstring": null,
"docstring_... |
62099bbf7b4837d22c33f0ea197cf63171b8328a | talkingscott/xpgdiff | xpgdiff.py | [
"MIT"
] | Python | fk_matchtype | <not_specific> | def fk_matchtype(matchtype):
"""
Gets the full name for a foreign key match type abbreviation.
:param matchtype: The match type abbreviation.
:returns: Match type full name
"""
return _FK_MATCHTYPE[matchtype] |
Gets the full name for a foreign key match type abbreviation.
:param matchtype: The match type abbreviation.
:returns: Match type full name
| Gets the full name for a foreign key match type abbreviation. | [
"Gets",
"the",
"full",
"name",
"for",
"a",
"foreign",
"key",
"match",
"type",
"abbreviation",
"."
] | def fk_matchtype(matchtype):
return _FK_MATCHTYPE[matchtype] | [
"def",
"fk_matchtype",
"(",
"matchtype",
")",
":",
"return",
"_FK_MATCHTYPE",
"[",
"matchtype",
"]"
] | Gets the full name for a foreign key match type abbreviation. | [
"Gets",
"the",
"full",
"name",
"for",
"a",
"foreign",
"key",
"match",
"type",
"abbreviation",
"."
] | [
"\"\"\"\n Gets the full name for a foreign key match type abbreviation.\n\n :param matchtype: The match type abbreviation.\n :returns: Match type full name\n \"\"\""
] | [
{
"param": "matchtype",
"type": null
}
] | {
"returns": [
{
"docstring": "Match type full name",
"docstring_tokens": [
"Match",
"type",
"full",
"name"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "matchtype",
"type": null,
"docstring": "The match type... |
62099bbf7b4837d22c33f0ea197cf63171b8328a | talkingscott/xpgdiff | xpgdiff.py | [
"MIT"
] | Python | grant_privileges | <not_specific> | def grant_privileges(perms):
"""
Gets a comma-separated list of privilege full names for a string of abbreviations.
:param perms: The string of privilege abbreviations.
:returns: A comma-separated list of privilege full names.
"""
return ', '.join([_GRANT_PRIVS[perm] for perm in perms]) |
Gets a comma-separated list of privilege full names for a string of abbreviations.
:param perms: The string of privilege abbreviations.
:returns: A comma-separated list of privilege full names.
| Gets a comma-separated list of privilege full names for a string of abbreviations. | [
"Gets",
"a",
"comma",
"-",
"separated",
"list",
"of",
"privilege",
"full",
"names",
"for",
"a",
"string",
"of",
"abbreviations",
"."
] | def grant_privileges(perms):
return ', '.join([_GRANT_PRIVS[perm] for perm in perms]) | [
"def",
"grant_privileges",
"(",
"perms",
")",
":",
"return",
"', '",
".",
"join",
"(",
"[",
"_GRANT_PRIVS",
"[",
"perm",
"]",
"for",
"perm",
"in",
"perms",
"]",
")"
] | Gets a comma-separated list of privilege full names for a string of abbreviations. | [
"Gets",
"a",
"comma",
"-",
"separated",
"list",
"of",
"privilege",
"full",
"names",
"for",
"a",
"string",
"of",
"abbreviations",
"."
] | [
"\"\"\"\n Gets a comma-separated list of privilege full names for a string of abbreviations.\n\n :param perms: The string of privilege abbreviations.\n :returns: A comma-separated list of privilege full names.\n \"\"\""
] | [
{
"param": "perms",
"type": null
}
] | {
"returns": [
{
"docstring": "A comma-separated list of privilege full names.",
"docstring_tokens": [
"A",
"comma",
"-",
"separated",
"list",
"of",
"privilege",
"full",
"names",
"."
],
"type": null
}
],
... |
62099bbf7b4837d22c33f0ea197cf63171b8328a | talkingscott/xpgdiff | xpgdiff.py | [
"MIT"
] | Python | grants_for_acl | <not_specific> | def grants_for_acl(obj, acl):
"""
Gets a list of grants (Grant instances) for an ACL string.
:param obj: The object the ACL applies to.
:param acl: The ACL as a string.
:returns: The list of grants.
"""
if not isinstance(acl, str) or len(acl) <= 2:
return []
if acl[0] != '{' or ... |
Gets a list of grants (Grant instances) for an ACL string.
:param obj: The object the ACL applies to.
:param acl: The ACL as a string.
:returns: The list of grants.
| Gets a list of grants (Grant instances) for an ACL string. | [
"Gets",
"a",
"list",
"of",
"grants",
"(",
"Grant",
"instances",
")",
"for",
"an",
"ACL",
"string",
"."
] | def grants_for_acl(obj, acl):
if not isinstance(acl, str) or len(acl) <= 2:
return []
if acl[0] != '{' or acl[-1] != '}':
return []
acls = acl[1:-2].split(',')
grants = []
for _acl in acls:
role_privileges, owner = _acl.split('/')
role, privilegestr = role_privileges.... | [
"def",
"grants_for_acl",
"(",
"obj",
",",
"acl",
")",
":",
"if",
"not",
"isinstance",
"(",
"acl",
",",
"str",
")",
"or",
"len",
"(",
"acl",
")",
"<=",
"2",
":",
"return",
"[",
"]",
"if",
"acl",
"[",
"0",
"]",
"!=",
"'{'",
"or",
"acl",
"[",
"-... | Gets a list of grants (Grant instances) for an ACL string. | [
"Gets",
"a",
"list",
"of",
"grants",
"(",
"Grant",
"instances",
")",
"for",
"an",
"ACL",
"string",
"."
] | [
"\"\"\"\n Gets a list of grants (Grant instances) for an ACL string.\n\n :param obj: The object the ACL applies to.\n :param acl: The ACL as a string.\n :returns: The list of grants.\n \"\"\""
] | [
{
"param": "obj",
"type": null
},
{
"param": "acl",
"type": null
}
] | {
"returns": [
{
"docstring": "The list of grants.",
"docstring_tokens": [
"The",
"list",
"of",
"grants",
"."
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "obj",
"type": null,
"docstring": "The object... |
62099bbf7b4837d22c33f0ea197cf63171b8328a | talkingscott/xpgdiff | xpgdiff.py | [
"MIT"
] | Python | next_or_none | <not_specific> | def next_or_none(seq):
"""
Gets an iterator-like function for sequence. Instead of raising a
StopIteration exception, the function returns None when the sequence
is exhausted.
:param seq: The sequence to iterate over.
:returns: The iterator-like function.
"""
def _next():
try:
... |
Gets an iterator-like function for sequence. Instead of raising a
StopIteration exception, the function returns None when the sequence
is exhausted.
:param seq: The sequence to iterate over.
:returns: The iterator-like function.
| Gets an iterator-like function for sequence. Instead of raising a
StopIteration exception, the function returns None when the sequence
is exhausted. | [
"Gets",
"an",
"iterator",
"-",
"like",
"function",
"for",
"sequence",
".",
"Instead",
"of",
"raising",
"a",
"StopIteration",
"exception",
"the",
"function",
"returns",
"None",
"when",
"the",
"sequence",
"is",
"exhausted",
"."
] | def next_or_none(seq):
def _next():
try:
return next(_iter)
except StopIteration:
return None
_iter = iter(seq)
return _next | [
"def",
"next_or_none",
"(",
"seq",
")",
":",
"def",
"_next",
"(",
")",
":",
"try",
":",
"return",
"next",
"(",
"_iter",
")",
"except",
"StopIteration",
":",
"return",
"None",
"_iter",
"=",
"iter",
"(",
"seq",
")",
"return",
"_next"
] | Gets an iterator-like function for sequence. | [
"Gets",
"an",
"iterator",
"-",
"like",
"function",
"for",
"sequence",
"."
] | [
"\"\"\"\n Gets an iterator-like function for sequence. Instead of raising a\n StopIteration exception, the function returns None when the sequence\n is exhausted.\n\n :param seq: The sequence to iterate over.\n :returns: The iterator-like function.\n \"\"\""
] | [
{
"param": "seq",
"type": null
}
] | {
"returns": [
{
"docstring": "The iterator-like function.",
"docstring_tokens": [
"The",
"iterator",
"-",
"like",
"function",
"."
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "seq",
"type": null,
... |
62099bbf7b4837d22c33f0ea197cf63171b8328a | talkingscott/xpgdiff | xpgdiff.py | [
"MIT"
] | Python | print_column_migration_ddl | null | def print_column_migration_ddl(source_table, source_column, target_column):
"""
Prints the migration DDL for a column.
N.B. This does not check that the DDL will work on data in the column.
:param source_table: The table in the source schema.
:param source_column: The column in the source schema.
... |
Prints the migration DDL for a column.
N.B. This does not check that the DDL will work on data in the column.
:param source_table: The table in the source schema.
:param source_column: The column in the source schema.
:param target_column: The column in the target schema.
| Prints the migration DDL for a column. | [
"Prints",
"the",
"migration",
"DDL",
"for",
"a",
"column",
"."
] | def print_column_migration_ddl(source_table, source_column, target_column):
if source_column != target_column:
print(target_column.alterstr()) | [
"def",
"print_column_migration_ddl",
"(",
"source_table",
",",
"source_column",
",",
"target_column",
")",
":",
"if",
"source_column",
"!=",
"target_column",
":",
"print",
"(",
"target_column",
".",
"alterstr",
"(",
")",
")"
] | Prints the migration DDL for a column. | [
"Prints",
"the",
"migration",
"DDL",
"for",
"a",
"column",
"."
] | [
"\"\"\"\n Prints the migration DDL for a column.\n\n N.B. This does not check that the DDL will work on data in the column.\n\n :param source_table: The table in the source schema.\n :param source_column: The column in the source schema.\n :param target_column: The column in the target schema.\n \... | [
{
"param": "source_table",
"type": null
},
{
"param": "source_column",
"type": null
},
{
"param": "target_column",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "source_table",
"type": null,
"docstring": "The table in the source schema.",
"docstring_tokens": [
"The",
"table",
"in",
"the",
"source",
"schema",
"."
],
"de... |
62099bbf7b4837d22c33f0ea197cf63171b8328a | talkingscott/xpgdiff | xpgdiff.py | [
"MIT"
] | Python | print_grant_migration_ddl | null | def print_grant_migration_ddl(source_object, source_grant, target_grant):
"""
Prints the migration DDL for a single grant on an object.
:param source_object: The object in the source schema.
:param source_grant: The grant on the object in the source schema.
:param target_grant: The grant on the obj... |
Prints the migration DDL for a single grant on an object.
:param source_object: The object in the source schema.
:param source_grant: The grant on the object in the source schema.
:param target_grant: The grant on the object in the target schema.
| Prints the migration DDL for a single grant on an object. | [
"Prints",
"the",
"migration",
"DDL",
"for",
"a",
"single",
"grant",
"on",
"an",
"object",
"."
] | def print_grant_migration_ddl(source_object, source_grant, target_grant):
revokes = set(source_grant.privilegestr) - set(target_grant.privilegestr)
grants = set(target_grant.privilegestr) - set(source_grant.privilegestr)
if revokes:
print(Grant(source_object, source_grant.role, "".join(revokes)).rev... | [
"def",
"print_grant_migration_ddl",
"(",
"source_object",
",",
"source_grant",
",",
"target_grant",
")",
":",
"revokes",
"=",
"set",
"(",
"source_grant",
".",
"privilegestr",
")",
"-",
"set",
"(",
"target_grant",
".",
"privilegestr",
")",
"grants",
"=",
"set",
... | Prints the migration DDL for a single grant on an object. | [
"Prints",
"the",
"migration",
"DDL",
"for",
"a",
"single",
"grant",
"on",
"an",
"object",
"."
] | [
"\"\"\"\n Prints the migration DDL for a single grant on an object.\n\n :param source_object: The object in the source schema.\n :param source_grant: The grant on the object in the source schema.\n :param target_grant: The grant on the object in the target schema.\n \"\"\""
] | [
{
"param": "source_object",
"type": null
},
{
"param": "source_grant",
"type": null
},
{
"param": "target_grant",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "source_object",
"type": null,
"docstring": "The object in the source schema.",
"docstring_tokens": [
"The",
"object",
"in",
"the",
"source",
"schema",
"."
],
... |
62099bbf7b4837d22c33f0ea197cf63171b8328a | talkingscott/xpgdiff | xpgdiff.py | [
"MIT"
] | Python | print_grants_migration_ddl | null | def print_grants_migration_ddl(source_object, target_object):
"""
Prints the migration DDL for grants on an object.
:param source_object: The object in the source schema.
:param target_object: The object in the target schema.
"""
next_source_grant = next_or_none(sorted(source_object.grants, key... |
Prints the migration DDL for grants on an object.
:param source_object: The object in the source schema.
:param target_object: The object in the target schema.
| Prints the migration DDL for grants on an object. | [
"Prints",
"the",
"migration",
"DDL",
"for",
"grants",
"on",
"an",
"object",
"."
] | def print_grants_migration_ddl(source_object, target_object):
next_source_grant = next_or_none(sorted(source_object.grants, key=lambda g: g.role))
next_target_grant = next_or_none(sorted(target_object.grants, key=lambda g: g.role))
source_grant = next_source_grant()
target_grant = next_target_grant()
... | [
"def",
"print_grants_migration_ddl",
"(",
"source_object",
",",
"target_object",
")",
":",
"next_source_grant",
"=",
"next_or_none",
"(",
"sorted",
"(",
"source_object",
".",
"grants",
",",
"key",
"=",
"lambda",
"g",
":",
"g",
".",
"role",
")",
")",
"next_targ... | Prints the migration DDL for grants on an object. | [
"Prints",
"the",
"migration",
"DDL",
"for",
"grants",
"on",
"an",
"object",
"."
] | [
"\"\"\"\n Prints the migration DDL for grants on an object.\n\n :param source_object: The object in the source schema.\n :param target_object: The object in the target schema.\n \"\"\""
] | [
{
"param": "source_object",
"type": null
},
{
"param": "target_object",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "source_object",
"type": null,
"docstring": "The object in the source schema.",
"docstring_tokens": [
"The",
"object",
"in",
"the",
"source",
"schema",
"."
],
... |
62099bbf7b4837d22c33f0ea197cf63171b8328a | talkingscott/xpgdiff | xpgdiff.py | [
"MIT"
] | Python | print_dropadd_migration_ddl | null | def print_dropadd_migration_ddl(source_objs, target_objs):
"""
Prints migration DDL for objects that are always drop or add.
The class for the objects must have a name field; addstr and dropstr
methods; and a meaningful implementation of __eq__.
The passed sequences must already be sorted by name.
... |
Prints migration DDL for objects that are always drop or add.
The class for the objects must have a name field; addstr and dropstr
methods; and a meaningful implementation of __eq__.
The passed sequences must already be sorted by name.
:param source_objs: The objects in the source schema.
:pa... | Prints migration DDL for objects that are always drop or add.
The class for the objects must have a name field; addstr and dropstr
methods; and a meaningful implementation of __eq__.
The passed sequences must already be sorted by name. | [
"Prints",
"migration",
"DDL",
"for",
"objects",
"that",
"are",
"always",
"drop",
"or",
"add",
".",
"The",
"class",
"for",
"the",
"objects",
"must",
"have",
"a",
"name",
"field",
";",
"addstr",
"and",
"dropstr",
"methods",
";",
"and",
"a",
"meaningful",
"... | def print_dropadd_migration_ddl(source_objs, target_objs):
next_source_obj = next_or_none(source_objs)
next_target_obj = next_or_none(target_objs)
source_obj = next_source_obj()
target_obj = next_target_obj()
while source_obj or target_obj:
if not target_obj:
print(source_obj.dro... | [
"def",
"print_dropadd_migration_ddl",
"(",
"source_objs",
",",
"target_objs",
")",
":",
"next_source_obj",
"=",
"next_or_none",
"(",
"source_objs",
")",
"next_target_obj",
"=",
"next_or_none",
"(",
"target_objs",
")",
"source_obj",
"=",
"next_source_obj",
"(",
")",
... | Prints migration DDL for objects that are always drop or add. | [
"Prints",
"migration",
"DDL",
"for",
"objects",
"that",
"are",
"always",
"drop",
"or",
"add",
"."
] | [
"\"\"\"\n Prints migration DDL for objects that are always drop or add.\n The class for the objects must have a name field; addstr and dropstr\n methods; and a meaningful implementation of __eq__.\n\n The passed sequences must already be sorted by name.\n\n :param source_objs: The objects in the sour... | [
{
"param": "source_objs",
"type": null
},
{
"param": "target_objs",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "source_objs",
"type": null,
"docstring": "The objects in the source schema.",
"docstring_tokens": [
"The",
"objects",
"in",
"the",
"source",
"schema",
"."
],
... |
62099bbf7b4837d22c33f0ea197cf63171b8328a | talkingscott/xpgdiff | xpgdiff.py | [
"MIT"
] | Python | print_table_migration_ddl | null | def print_table_migration_ddl(source_table, target_table):
"""
Prints DDL to migrate a table in one schema to the structure in
another schema, including columns, constraints, indexes, triggers
and permissions.
N.B. The migration does not enforce identical column ordering.
:param source_table: ... |
Prints DDL to migrate a table in one schema to the structure in
another schema, including columns, constraints, indexes, triggers
and permissions.
N.B. The migration does not enforce identical column ordering.
:param source_table: The source table.
:param target_table: The target table.
| Prints DDL to migrate a table in one schema to the structure in
another schema, including columns, constraints, indexes, triggers
and permissions.
| [
"Prints",
"DDL",
"to",
"migrate",
"a",
"table",
"in",
"one",
"schema",
"to",
"the",
"structure",
"in",
"another",
"schema",
"including",
"columns",
"constraints",
"indexes",
"triggers",
"and",
"permissions",
"."
] | def print_table_migration_ddl(source_table, target_table):
next_source_column = next_or_none(sorted(source_table.columns, key=lambda c: c.name))
next_target_column = next_or_none(sorted(target_table.columns, key=lambda c: c.name))
source_column = next_source_column()
target_column = next_target_column()... | [
"def",
"print_table_migration_ddl",
"(",
"source_table",
",",
"target_table",
")",
":",
"next_source_column",
"=",
"next_or_none",
"(",
"sorted",
"(",
"source_table",
".",
"columns",
",",
"key",
"=",
"lambda",
"c",
":",
"c",
".",
"name",
")",
")",
"next_target... | Prints DDL to migrate a table in one schema to the structure in
another schema, including columns, constraints, indexes, triggers
and permissions. | [
"Prints",
"DDL",
"to",
"migrate",
"a",
"table",
"in",
"one",
"schema",
"to",
"the",
"structure",
"in",
"another",
"schema",
"including",
"columns",
"constraints",
"indexes",
"triggers",
"and",
"permissions",
"."
] | [
"\"\"\"\n Prints DDL to migrate a table in one schema to the structure in\n another schema, including columns, constraints, indexes, triggers\n and permissions.\n\n N.B. The migration does not enforce identical column ordering.\n\n :param source_table: The source table.\n :param target_table: The ... | [
{
"param": "source_table",
"type": null
},
{
"param": "target_table",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "source_table",
"type": null,
"docstring": "The source table.",
"docstring_tokens": [
"The",
"source",
"table",
"."
],
"default": null,
"is_optional": null
},
{
"i... |
62099bbf7b4837d22c33f0ea197cf63171b8328a | talkingscott/xpgdiff | xpgdiff.py | [
"MIT"
] | Python | print_tables_migration_ddl | null | def print_tables_migration_ddl(source_schema, target_schema):
"""
Prints DDL to migrate the tables in two schemas.
:param source_schema: The source schema.
:param target_schema: The target schema.
"""
print('--')
print('-- TABLES')
print('--')
next_source_table = next_or_none(source... |
Prints DDL to migrate the tables in two schemas.
:param source_schema: The source schema.
:param target_schema: The target schema.
| Prints DDL to migrate the tables in two schemas. | [
"Prints",
"DDL",
"to",
"migrate",
"the",
"tables",
"in",
"two",
"schemas",
"."
] | def print_tables_migration_ddl(source_schema, target_schema):
print('--')
print('-- TABLES')
print('--')
next_source_table = next_or_none(source_schema.tables)
next_target_table = next_or_none(target_schema.tables)
source_table = next_source_table()
target_table = next_target_table()
whi... | [
"def",
"print_tables_migration_ddl",
"(",
"source_schema",
",",
"target_schema",
")",
":",
"print",
"(",
"'--'",
")",
"print",
"(",
"'-- TABLES'",
")",
"print",
"(",
"'--'",
")",
"next_source_table",
"=",
"next_or_none",
"(",
"source_schema",
".",
"tables",
")",... | Prints DDL to migrate the tables in two schemas. | [
"Prints",
"DDL",
"to",
"migrate",
"the",
"tables",
"in",
"two",
"schemas",
"."
] | [
"\"\"\"\n Prints DDL to migrate the tables in two schemas.\n\n :param source_schema: The source schema.\n :param target_schema: The target schema.\n \"\"\""
] | [
{
"param": "source_schema",
"type": null
},
{
"param": "target_schema",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "source_schema",
"type": null,
"docstring": "The source schema.",
"docstring_tokens": [
"The",
"source",
"schema",
"."
],
"default": null,
"is_optional": null
},
{
... |
62099bbf7b4837d22c33f0ea197cf63171b8328a | talkingscott/xpgdiff | xpgdiff.py | [
"MIT"
] | Python | print_views_migration_ddl | null | def print_views_migration_ddl(source_schema, target_schema):
"""
Prints DDL to migrate the views in two schemas.
:param source_schema: The source schema.
:param target_schema: The target schema.
"""
print('--')
print('-- VIEWS')
print('--')
next_source_view = next_or_none(source_sch... |
Prints DDL to migrate the views in two schemas.
:param source_schema: The source schema.
:param target_schema: The target schema.
| Prints DDL to migrate the views in two schemas. | [
"Prints",
"DDL",
"to",
"migrate",
"the",
"views",
"in",
"two",
"schemas",
"."
] | def print_views_migration_ddl(source_schema, target_schema):
print('--')
print('-- VIEWS')
print('--')
next_source_view = next_or_none(source_schema.views)
next_target_view = next_or_none(target_schema.views)
source_view = next_source_view()
target_view = next_target_view()
while source_... | [
"def",
"print_views_migration_ddl",
"(",
"source_schema",
",",
"target_schema",
")",
":",
"print",
"(",
"'--'",
")",
"print",
"(",
"'-- VIEWS'",
")",
"print",
"(",
"'--'",
")",
"next_source_view",
"=",
"next_or_none",
"(",
"source_schema",
".",
"views",
")",
"... | Prints DDL to migrate the views in two schemas. | [
"Prints",
"DDL",
"to",
"migrate",
"the",
"views",
"in",
"two",
"schemas",
"."
] | [
"\"\"\"\n Prints DDL to migrate the views in two schemas.\n\n :param source_schema: The source schema.\n :param target_schema: The target schema.\n \"\"\""
] | [
{
"param": "source_schema",
"type": null
},
{
"param": "target_schema",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "source_schema",
"type": null,
"docstring": "The source schema.",
"docstring_tokens": [
"The",
"source",
"schema",
"."
],
"default": null,
"is_optional": null
},
{
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.