repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
monarch-initiative/dipper | dipper/sources/Decipher.py | Decipher.make_allele_by_consequence | def make_allele_by_consequence(self, consequence, gene_id, gene_symbol):
"""
Given a "consequence" label that describes a variation type,
create an anonymous variant of the specified gene as an instance of
that consequence type.
:param consequence:
:param gene_id:
... | python | def make_allele_by_consequence(self, consequence, gene_id, gene_symbol):
"""
Given a "consequence" label that describes a variation type,
create an anonymous variant of the specified gene as an instance of
that consequence type.
:param consequence:
:param gene_id:
... | [
"def",
"make_allele_by_consequence",
"(",
"self",
",",
"consequence",
",",
"gene_id",
",",
"gene_symbol",
")",
":",
"allele_id",
"=",
"None",
"type_id",
"=",
"self",
".",
"resolve",
"(",
"consequence",
",",
"mandatory",
"=",
"False",
")",
"if",
"type_id",
"=... | Given a "consequence" label that describes a variation type,
create an anonymous variant of the specified gene as an instance of
that consequence type.
:param consequence:
:param gene_id:
:param gene_symbol:
:return: allele_id | [
"Given",
"a",
"consequence",
"label",
"that",
"describes",
"a",
"variation",
"type",
"create",
"an",
"anonymous",
"variant",
"of",
"the",
"specified",
"gene",
"as",
"an",
"instance",
"of",
"that",
"consequence",
"type",
"."
] | 24cc80db355bbe15776edc5c7b41e0886959ba41 | https://github.com/monarch-initiative/dipper/blob/24cc80db355bbe15776edc5c7b41e0886959ba41/dipper/sources/Decipher.py#L228-L277 | train |
monarch-initiative/dipper | dipper/sources/EBIGene2Phen.py | EBIGene2Phen.parse | def parse(self, limit: Optional[int]=None):
"""
Here we parse each row of the gene to phenotype file
We create anonymous variants along with their attributes
(allelic requirement, functional consequence)
and connect these to genes and diseases
genes are connected to var... | python | def parse(self, limit: Optional[int]=None):
"""
Here we parse each row of the gene to phenotype file
We create anonymous variants along with their attributes
(allelic requirement, functional consequence)
and connect these to genes and diseases
genes are connected to var... | [
"def",
"parse",
"(",
"self",
",",
"limit",
":",
"Optional",
"[",
"int",
"]",
"=",
"None",
")",
":",
"if",
"limit",
"is",
"not",
"None",
":",
"LOG",
".",
"info",
"(",
"\"Only parsing first %d rows\"",
",",
"limit",
")",
"LOG",
".",
"info",
"(",
"\"Par... | Here we parse each row of the gene to phenotype file
We create anonymous variants along with their attributes
(allelic requirement, functional consequence)
and connect these to genes and diseases
genes are connected to variants via
global_terms['has_affected_locus']
va... | [
"Here",
"we",
"parse",
"each",
"row",
"of",
"the",
"gene",
"to",
"phenotype",
"file"
] | 24cc80db355bbe15776edc5c7b41e0886959ba41 | https://github.com/monarch-initiative/dipper/blob/24cc80db355bbe15776edc5c7b41e0886959ba41/dipper/sources/EBIGene2Phen.py#L104-L147 | train |
monarch-initiative/dipper | dipper/sources/EBIGene2Phen.py | EBIGene2Phen._add_gene_disease | def _add_gene_disease(self, row): # ::List getting syntax error here
"""
Parse and add gene variant disease model
Model building happens in _build_gene_disease_model
:param row {List}: single row from DDG2P.csv
:return: None
"""
col = self.files['developmental_... | python | def _add_gene_disease(self, row): # ::List getting syntax error here
"""
Parse and add gene variant disease model
Model building happens in _build_gene_disease_model
:param row {List}: single row from DDG2P.csv
:return: None
"""
col = self.files['developmental_... | [
"def",
"_add_gene_disease",
"(",
"self",
",",
"row",
")",
":",
"col",
"=",
"self",
".",
"files",
"[",
"'developmental_disorders'",
"]",
"[",
"'columns'",
"]",
"if",
"len",
"(",
"row",
")",
"!=",
"len",
"(",
"col",
")",
":",
"raise",
"ValueError",
"(",
... | Parse and add gene variant disease model
Model building happens in _build_gene_disease_model
:param row {List}: single row from DDG2P.csv
:return: None | [
"Parse",
"and",
"add",
"gene",
"variant",
"disease",
"model",
"Model",
"building",
"happens",
"in",
"_build_gene_disease_model"
] | 24cc80db355bbe15776edc5c7b41e0886959ba41 | https://github.com/monarch-initiative/dipper/blob/24cc80db355bbe15776edc5c7b41e0886959ba41/dipper/sources/EBIGene2Phen.py#L149-L211 | train |
monarch-initiative/dipper | dipper/sources/EBIGene2Phen.py | EBIGene2Phen._build_gene_disease_model | def _build_gene_disease_model(
self,
gene_id,
relation_id,
disease_id,
variant_label,
consequence_predicate=None,
consequence_id=None,
allelic_requirement=None,
pmids=None):
"""
Builds gene varian... | python | def _build_gene_disease_model(
self,
gene_id,
relation_id,
disease_id,
variant_label,
consequence_predicate=None,
consequence_id=None,
allelic_requirement=None,
pmids=None):
"""
Builds gene varian... | [
"def",
"_build_gene_disease_model",
"(",
"self",
",",
"gene_id",
",",
"relation_id",
",",
"disease_id",
",",
"variant_label",
",",
"consequence_predicate",
"=",
"None",
",",
"consequence_id",
"=",
"None",
",",
"allelic_requirement",
"=",
"None",
",",
"pmids",
"=",... | Builds gene variant disease model
:return: None | [
"Builds",
"gene",
"variant",
"disease",
"model"
] | 24cc80db355bbe15776edc5c7b41e0886959ba41 | https://github.com/monarch-initiative/dipper/blob/24cc80db355bbe15776edc5c7b41e0886959ba41/dipper/sources/EBIGene2Phen.py#L213-L274 | train |
monarch-initiative/dipper | dipper/sources/BioGrid.py | BioGrid._get_identifiers | def _get_identifiers(self, limit):
"""
This will process the id mapping file provided by Biogrid.
The file has a very large header, which we scan past,
then pull the identifiers, and make equivalence axioms
:param limit:
:return:
"""
LOG.info("getting i... | python | def _get_identifiers(self, limit):
"""
This will process the id mapping file provided by Biogrid.
The file has a very large header, which we scan past,
then pull the identifiers, and make equivalence axioms
:param limit:
:return:
"""
LOG.info("getting i... | [
"def",
"_get_identifiers",
"(",
"self",
",",
"limit",
")",
":",
"LOG",
".",
"info",
"(",
"\"getting identifier mapping\"",
")",
"line_counter",
"=",
"0",
"f",
"=",
"'/'",
".",
"join",
"(",
"(",
"self",
".",
"rawdir",
",",
"self",
".",
"files",
"[",
"'i... | This will process the id mapping file provided by Biogrid.
The file has a very large header, which we scan past,
then pull the identifiers, and make equivalence axioms
:param limit:
:return: | [
"This",
"will",
"process",
"the",
"id",
"mapping",
"file",
"provided",
"by",
"Biogrid",
".",
"The",
"file",
"has",
"a",
"very",
"large",
"header",
"which",
"we",
"scan",
"past",
"then",
"pull",
"the",
"identifiers",
"and",
"make",
"equivalence",
"axioms"
] | 24cc80db355bbe15776edc5c7b41e0886959ba41 | https://github.com/monarch-initiative/dipper/blob/24cc80db355bbe15776edc5c7b41e0886959ba41/dipper/sources/BioGrid.py#L201-L281 | train |
monarch-initiative/dipper | dipper/models/Evidence.py | Evidence.add_supporting_evidence | def add_supporting_evidence(self, evidence_line, evidence_type=None, label=None):
"""
Add supporting line of evidence node to association id
:param evidence_line: curie or iri, evidence line
:param evidence_type: curie or iri, evidence type if available
:return: None
"""... | python | def add_supporting_evidence(self, evidence_line, evidence_type=None, label=None):
"""
Add supporting line of evidence node to association id
:param evidence_line: curie or iri, evidence line
:param evidence_type: curie or iri, evidence type if available
:return: None
"""... | [
"def",
"add_supporting_evidence",
"(",
"self",
",",
"evidence_line",
",",
"evidence_type",
"=",
"None",
",",
"label",
"=",
"None",
")",
":",
"self",
".",
"graph",
".",
"addTriple",
"(",
"self",
".",
"association",
",",
"self",
".",
"globaltt",
"[",
"'has_s... | Add supporting line of evidence node to association id
:param evidence_line: curie or iri, evidence line
:param evidence_type: curie or iri, evidence type if available
:return: None | [
"Add",
"supporting",
"line",
"of",
"evidence",
"node",
"to",
"association",
"id"
] | 24cc80db355bbe15776edc5c7b41e0886959ba41 | https://github.com/monarch-initiative/dipper/blob/24cc80db355bbe15776edc5c7b41e0886959ba41/dipper/models/Evidence.py#L34-L47 | train |
monarch-initiative/dipper | dipper/models/assoc/G2PAssoc.py | G2PAssoc.add_association_to_graph | def add_association_to_graph(self):
"""
Overrides Association by including bnode support
The reified relationship between a genotype (or any genotype part)
and a phenotype is decorated with some provenance information.
This makes the assumption that
both the genotype an... | python | def add_association_to_graph(self):
"""
Overrides Association by including bnode support
The reified relationship between a genotype (or any genotype part)
and a phenotype is decorated with some provenance information.
This makes the assumption that
both the genotype an... | [
"def",
"add_association_to_graph",
"(",
"self",
")",
":",
"Assoc",
".",
"add_association_to_graph",
"(",
"self",
")",
"if",
"self",
".",
"start_stage_id",
"or",
"self",
".",
"end_stage_id",
"is",
"not",
"None",
":",
"stage_process_id",
"=",
"'-'",
".",
"join",... | Overrides Association by including bnode support
The reified relationship between a genotype (or any genotype part)
and a phenotype is decorated with some provenance information.
This makes the assumption that
both the genotype and phenotype are classes.
currently hardcoded to... | [
"Overrides",
"Association",
"by",
"including",
"bnode",
"support"
] | 24cc80db355bbe15776edc5c7b41e0886959ba41 | https://github.com/monarch-initiative/dipper/blob/24cc80db355bbe15776edc5c7b41e0886959ba41/dipper/models/assoc/G2PAssoc.py#L66-L103 | train |
monarch-initiative/dipper | dipper/sources/MPD.py | MPD.parse | def parse(self, limit=None):
"""
MPD data is delivered in four separate csv files and one xml file,
which we process iteratively and write out as
one large graph.
:param limit:
:return:
"""
if limit is not None:
LOG.info("Only parsing first %s... | python | def parse(self, limit=None):
"""
MPD data is delivered in four separate csv files and one xml file,
which we process iteratively and write out as
one large graph.
:param limit:
:return:
"""
if limit is not None:
LOG.info("Only parsing first %s... | [
"def",
"parse",
"(",
"self",
",",
"limit",
"=",
"None",
")",
":",
"if",
"limit",
"is",
"not",
"None",
":",
"LOG",
".",
"info",
"(",
"\"Only parsing first %s rows fo each file\"",
",",
"str",
"(",
"limit",
")",
")",
"LOG",
".",
"info",
"(",
"\"Parsing fil... | MPD data is delivered in four separate csv files and one xml file,
which we process iteratively and write out as
one large graph.
:param limit:
:return: | [
"MPD",
"data",
"is",
"delivered",
"in",
"four",
"separate",
"csv",
"files",
"and",
"one",
"xml",
"file",
"which",
"we",
"process",
"iteratively",
"and",
"write",
"out",
"as",
"one",
"large",
"graph",
"."
] | 24cc80db355bbe15776edc5c7b41e0886959ba41 | https://github.com/monarch-initiative/dipper/blob/24cc80db355bbe15776edc5c7b41e0886959ba41/dipper/sources/MPD.py#L112-L142 | train |
monarch-initiative/dipper | dipper/sources/MPD.py | MPD._add_g2p_assoc | def _add_g2p_assoc(self, graph, strain_id, sex, assay_id, phenotypes, comment):
"""
Create an association between a sex-specific strain id
and each of the phenotypes.
Here, we create a genotype from the strain,
and a sex-specific genotype.
Each of those genotypes are crea... | python | def _add_g2p_assoc(self, graph, strain_id, sex, assay_id, phenotypes, comment):
"""
Create an association between a sex-specific strain id
and each of the phenotypes.
Here, we create a genotype from the strain,
and a sex-specific genotype.
Each of those genotypes are crea... | [
"def",
"_add_g2p_assoc",
"(",
"self",
",",
"graph",
",",
"strain_id",
",",
"sex",
",",
"assay_id",
",",
"phenotypes",
",",
"comment",
")",
":",
"geno",
"=",
"Genotype",
"(",
"graph",
")",
"model",
"=",
"Model",
"(",
"graph",
")",
"eco_id",
"=",
"self",... | Create an association between a sex-specific strain id
and each of the phenotypes.
Here, we create a genotype from the strain,
and a sex-specific genotype.
Each of those genotypes are created as anonymous nodes.
The evidence code is hardcoded to be:
ECO:experimental_... | [
"Create",
"an",
"association",
"between",
"a",
"sex",
"-",
"specific",
"strain",
"id",
"and",
"each",
"of",
"the",
"phenotypes",
".",
"Here",
"we",
"create",
"a",
"genotype",
"from",
"the",
"strain",
"and",
"a",
"sex",
"-",
"specific",
"genotype",
".",
"... | 24cc80db355bbe15776edc5c7b41e0886959ba41 | https://github.com/monarch-initiative/dipper/blob/24cc80db355bbe15776edc5c7b41e0886959ba41/dipper/sources/MPD.py#L385-L457 | train |
monarch-initiative/dipper | dipper/sources/IMPC.py | IMPC.parse | def parse(self, limit=None):
"""
IMPC data is delivered in three separate csv files OR
in one integrated file, each with the same file format.
:param limit:
:return:
"""
if limit is not None:
LOG.info("Only parsing first %s rows fo each file", str(li... | python | def parse(self, limit=None):
"""
IMPC data is delivered in three separate csv files OR
in one integrated file, each with the same file format.
:param limit:
:return:
"""
if limit is not None:
LOG.info("Only parsing first %s rows fo each file", str(li... | [
"def",
"parse",
"(",
"self",
",",
"limit",
"=",
"None",
")",
":",
"if",
"limit",
"is",
"not",
"None",
":",
"LOG",
".",
"info",
"(",
"\"Only parsing first %s rows fo each file\"",
",",
"str",
"(",
"limit",
")",
")",
"LOG",
".",
"info",
"(",
"\"Parsing fil... | IMPC data is delivered in three separate csv files OR
in one integrated file, each with the same file format.
:param limit:
:return: | [
"IMPC",
"data",
"is",
"delivered",
"in",
"three",
"separate",
"csv",
"files",
"OR",
"in",
"one",
"integrated",
"file",
"each",
"with",
"the",
"same",
"file",
"format",
"."
] | 24cc80db355bbe15776edc5c7b41e0886959ba41 | https://github.com/monarch-initiative/dipper/blob/24cc80db355bbe15776edc5c7b41e0886959ba41/dipper/sources/IMPC.py#L119-L143 | train |
monarch-initiative/dipper | dipper/models/Pathway.py | Pathway.addGeneToPathway | def addGeneToPathway(self, gene_id, pathway_id):
"""
When adding a gene to a pathway, we create an intermediate
'gene product' that is involved in
the pathway, through a blank node.
gene_id RO:has_gene_product _gene_product
_gene_product RO:involved_in pathway_id
... | python | def addGeneToPathway(self, gene_id, pathway_id):
"""
When adding a gene to a pathway, we create an intermediate
'gene product' that is involved in
the pathway, through a blank node.
gene_id RO:has_gene_product _gene_product
_gene_product RO:involved_in pathway_id
... | [
"def",
"addGeneToPathway",
"(",
"self",
",",
"gene_id",
",",
"pathway_id",
")",
":",
"gene_product",
"=",
"'_:'",
"+",
"re",
".",
"sub",
"(",
"r':'",
",",
"''",
",",
"gene_id",
")",
"+",
"'product'",
"self",
".",
"model",
".",
"addIndividualToGraph",
"("... | When adding a gene to a pathway, we create an intermediate
'gene product' that is involved in
the pathway, through a blank node.
gene_id RO:has_gene_product _gene_product
_gene_product RO:involved_in pathway_id
:param pathway_id:
:param gene_id:
:return: | [
"When",
"adding",
"a",
"gene",
"to",
"a",
"pathway",
"we",
"create",
"an",
"intermediate",
"gene",
"product",
"that",
"is",
"involved",
"in",
"the",
"pathway",
"through",
"a",
"blank",
"node",
"."
] | 24cc80db355bbe15776edc5c7b41e0886959ba41 | https://github.com/monarch-initiative/dipper/blob/24cc80db355bbe15776edc5c7b41e0886959ba41/dipper/models/Pathway.py#L50-L71 | train |
monarch-initiative/dipper | dipper/models/Pathway.py | Pathway.addComponentToPathway | def addComponentToPathway(self, component_id, pathway_id):
"""
This can be used directly when the component is directly involved in
the pathway. If a transforming event is performed on the component
first, then the addGeneToPathway should be used instead.
:param pathway_id:
... | python | def addComponentToPathway(self, component_id, pathway_id):
"""
This can be used directly when the component is directly involved in
the pathway. If a transforming event is performed on the component
first, then the addGeneToPathway should be used instead.
:param pathway_id:
... | [
"def",
"addComponentToPathway",
"(",
"self",
",",
"component_id",
",",
"pathway_id",
")",
":",
"self",
".",
"graph",
".",
"addTriple",
"(",
"component_id",
",",
"self",
".",
"globaltt",
"[",
"'involved in'",
"]",
",",
"pathway_id",
")",
"return"
] | This can be used directly when the component is directly involved in
the pathway. If a transforming event is performed on the component
first, then the addGeneToPathway should be used instead.
:param pathway_id:
:param component_id:
:return: | [
"This",
"can",
"be",
"used",
"directly",
"when",
"the",
"component",
"is",
"directly",
"involved",
"in",
"the",
"pathway",
".",
"If",
"a",
"transforming",
"event",
"is",
"performed",
"on",
"the",
"component",
"first",
"then",
"the",
"addGeneToPathway",
"should... | 24cc80db355bbe15776edc5c7b41e0886959ba41 | https://github.com/monarch-initiative/dipper/blob/24cc80db355bbe15776edc5c7b41e0886959ba41/dipper/models/Pathway.py#L73-L85 | train |
monarch-initiative/dipper | dipper/sources/Source.py | Source.write | def write(self, fmt='turtle', stream=None):
"""
This convenience method will write out all of the graphs
associated with the source.
Right now these are hardcoded to be a single "graph"
and a "src_dataset.ttl" and a "src_test.ttl"
If you do not supply stream='stdout'
... | python | def write(self, fmt='turtle', stream=None):
"""
This convenience method will write out all of the graphs
associated with the source.
Right now these are hardcoded to be a single "graph"
and a "src_dataset.ttl" and a "src_test.ttl"
If you do not supply stream='stdout'
... | [
"def",
"write",
"(",
"self",
",",
"fmt",
"=",
"'turtle'",
",",
"stream",
"=",
"None",
")",
":",
"fmt_ext",
"=",
"{",
"'rdfxml'",
":",
"'xml'",
",",
"'turtle'",
":",
"'ttl'",
",",
"'nt'",
":",
"'nt'",
",",
"'nquads'",
":",
"'nq'",
",",
"'n3'",
":",
... | This convenience method will write out all of the graphs
associated with the source.
Right now these are hardcoded to be a single "graph"
and a "src_dataset.ttl" and a "src_test.ttl"
If you do not supply stream='stdout'
it will default write these to files.
In addition, ... | [
"This",
"convenience",
"method",
"will",
"write",
"out",
"all",
"of",
"the",
"graphs",
"associated",
"with",
"the",
"source",
".",
"Right",
"now",
"these",
"are",
"hardcoded",
"to",
"be",
"a",
"single",
"graph",
"and",
"a",
"src_dataset",
".",
"ttl",
"and"... | 24cc80db355bbe15776edc5c7b41e0886959ba41 | https://github.com/monarch-initiative/dipper/blob/24cc80db355bbe15776edc5c7b41e0886959ba41/dipper/sources/Source.py#L161-L223 | train |
monarch-initiative/dipper | dipper/sources/Source.py | Source.declareAsOntology | def declareAsOntology(self, graph):
"""
The file we output needs to be declared as an ontology,
including it's version information.
TEC: I am not convinced dipper reformating external data as RDF triples
makes an OWL ontology (nor that it should be considered a goal).
P... | python | def declareAsOntology(self, graph):
"""
The file we output needs to be declared as an ontology,
including it's version information.
TEC: I am not convinced dipper reformating external data as RDF triples
makes an OWL ontology (nor that it should be considered a goal).
P... | [
"def",
"declareAsOntology",
"(",
"self",
",",
"graph",
")",
":",
"model",
"=",
"Model",
"(",
"graph",
")",
"ontology_file_id",
"=",
"'MonarchData:'",
"+",
"self",
".",
"name",
"+",
"\".ttl\"",
"model",
".",
"addOntologyDeclaration",
"(",
"ontology_file_id",
")... | The file we output needs to be declared as an ontology,
including it's version information.
TEC: I am not convinced dipper reformating external data as RDF triples
makes an OWL ontology (nor that it should be considered a goal).
Proper ontologies are built by ontologists. Dipper reform... | [
"The",
"file",
"we",
"output",
"needs",
"to",
"be",
"declared",
"as",
"an",
"ontology",
"including",
"it",
"s",
"version",
"information",
"."
] | 24cc80db355bbe15776edc5c7b41e0886959ba41 | https://github.com/monarch-initiative/dipper/blob/24cc80db355bbe15776edc5c7b41e0886959ba41/dipper/sources/Source.py#L614-L660 | train |
monarch-initiative/dipper | dipper/sources/Source.py | Source.remove_backslash_r | def remove_backslash_r(filename, encoding):
"""
A helpful utility to remove Carriage Return from any file.
This will read a file into memory,
and overwrite the contents of the original file.
TODO: This function may be a liability
:param filename:
:return:
... | python | def remove_backslash_r(filename, encoding):
"""
A helpful utility to remove Carriage Return from any file.
This will read a file into memory,
and overwrite the contents of the original file.
TODO: This function may be a liability
:param filename:
:return:
... | [
"def",
"remove_backslash_r",
"(",
"filename",
",",
"encoding",
")",
":",
"with",
"open",
"(",
"filename",
",",
"'r'",
",",
"encoding",
"=",
"encoding",
",",
"newline",
"=",
"r'\\n'",
")",
"as",
"filereader",
":",
"contents",
"=",
"filereader",
".",
"read",... | A helpful utility to remove Carriage Return from any file.
This will read a file into memory,
and overwrite the contents of the original file.
TODO: This function may be a liability
:param filename:
:return: | [
"A",
"helpful",
"utility",
"to",
"remove",
"Carriage",
"Return",
"from",
"any",
"file",
".",
"This",
"will",
"read",
"a",
"file",
"into",
"memory",
"and",
"overwrite",
"the",
"contents",
"of",
"the",
"original",
"file",
"."
] | 24cc80db355bbe15776edc5c7b41e0886959ba41 | https://github.com/monarch-initiative/dipper/blob/24cc80db355bbe15776edc5c7b41e0886959ba41/dipper/sources/Source.py#L664-L683 | train |
monarch-initiative/dipper | dipper/sources/Source.py | Source.load_local_translationtable | def load_local_translationtable(self, name):
'''
Load "ingest specific" translation from whatever they called something
to the ontology label we need to map it to.
To facilitate seeing more ontology lables in dipper ingests
a reverse mapping from ontology lables to external strin... | python | def load_local_translationtable(self, name):
'''
Load "ingest specific" translation from whatever they called something
to the ontology label we need to map it to.
To facilitate seeing more ontology lables in dipper ingests
a reverse mapping from ontology lables to external strin... | [
"def",
"load_local_translationtable",
"(",
"self",
",",
"name",
")",
":",
"localtt_file",
"=",
"'translationtable/'",
"+",
"name",
"+",
"'.yaml'",
"try",
":",
"with",
"open",
"(",
"localtt_file",
")",
":",
"pass",
"except",
"IOError",
":",
"with",
"open",
"(... | Load "ingest specific" translation from whatever they called something
to the ontology label we need to map it to.
To facilitate seeing more ontology lables in dipper ingests
a reverse mapping from ontology lables to external strings is also generated
and available as a dict localtcid | [
"Load",
"ingest",
"specific",
"translation",
"from",
"whatever",
"they",
"called",
"something",
"to",
"the",
"ontology",
"label",
"we",
"need",
"to",
"map",
"it",
"to",
".",
"To",
"facilitate",
"seeing",
"more",
"ontology",
"lables",
"in",
"dipper",
"ingests",... | 24cc80db355bbe15776edc5c7b41e0886959ba41 | https://github.com/monarch-initiative/dipper/blob/24cc80db355bbe15776edc5c7b41e0886959ba41/dipper/sources/Source.py#L739-L767 | train |
monarch-initiative/dipper | dipper/models/Genotype.py | Genotype.addGene | def addGene(
self, gene_id, gene_label, gene_type=None, gene_description=None
):
''' genes are classes '''
if gene_type is None:
gene_type = self.globaltt['gene']
self.model.addClassToGraph(gene_id, gene_label, gene_type, gene_description)
return | python | def addGene(
self, gene_id, gene_label, gene_type=None, gene_description=None
):
''' genes are classes '''
if gene_type is None:
gene_type = self.globaltt['gene']
self.model.addClassToGraph(gene_id, gene_label, gene_type, gene_description)
return | [
"def",
"addGene",
"(",
"self",
",",
"gene_id",
",",
"gene_label",
",",
"gene_type",
"=",
"None",
",",
"gene_description",
"=",
"None",
")",
":",
"if",
"gene_type",
"is",
"None",
":",
"gene_type",
"=",
"self",
".",
"globaltt",
"[",
"'gene'",
"]",
"self",
... | genes are classes | [
"genes",
"are",
"classes"
] | 24cc80db355bbe15776edc5c7b41e0886959ba41 | https://github.com/monarch-initiative/dipper/blob/24cc80db355bbe15776edc5c7b41e0886959ba41/dipper/models/Genotype.py#L79-L87 | train |
monarch-initiative/dipper | dipper/utils/DipperUtil.py | DipperUtil.get_ncbi_taxon_num_by_label | def get_ncbi_taxon_num_by_label(label):
"""
Here we want to look up the NCBI Taxon id using some kind of label.
It will only return a result if there is a unique hit.
:return:
"""
req = {'db': 'taxonomy', 'retmode': 'json', 'term': label}
req.update(EREQ)
... | python | def get_ncbi_taxon_num_by_label(label):
"""
Here we want to look up the NCBI Taxon id using some kind of label.
It will only return a result if there is a unique hit.
:return:
"""
req = {'db': 'taxonomy', 'retmode': 'json', 'term': label}
req.update(EREQ)
... | [
"def",
"get_ncbi_taxon_num_by_label",
"(",
"label",
")",
":",
"req",
"=",
"{",
"'db'",
":",
"'taxonomy'",
",",
"'retmode'",
":",
"'json'",
",",
"'term'",
":",
"label",
"}",
"req",
".",
"update",
"(",
"EREQ",
")",
"request",
"=",
"SESSION",
".",
"get",
... | Here we want to look up the NCBI Taxon id using some kind of label.
It will only return a result if there is a unique hit.
:return: | [
"Here",
"we",
"want",
"to",
"look",
"up",
"the",
"NCBI",
"Taxon",
"id",
"using",
"some",
"kind",
"of",
"label",
".",
"It",
"will",
"only",
"return",
"a",
"result",
"if",
"there",
"is",
"a",
"unique",
"hit",
"."
] | 24cc80db355bbe15776edc5c7b41e0886959ba41 | https://github.com/monarch-initiative/dipper/blob/24cc80db355bbe15776edc5c7b41e0886959ba41/dipper/utils/DipperUtil.py#L47-L78 | train |
monarch-initiative/dipper | dipper/models/assoc/Association.py | Assoc.set_association_id | def set_association_id(self, assoc_id=None):
"""
This will set the association ID based on the internal parts
of the association.
To be used in cases where an external association identifier
should be used.
:param assoc_id:
:return:
"""
if assoc... | python | def set_association_id(self, assoc_id=None):
"""
This will set the association ID based on the internal parts
of the association.
To be used in cases where an external association identifier
should be used.
:param assoc_id:
:return:
"""
if assoc... | [
"def",
"set_association_id",
"(",
"self",
",",
"assoc_id",
"=",
"None",
")",
":",
"if",
"assoc_id",
"is",
"None",
":",
"self",
".",
"assoc_id",
"=",
"self",
".",
"make_association_id",
"(",
"self",
".",
"definedby",
",",
"self",
".",
"sub",
",",
"self",
... | This will set the association ID based on the internal parts
of the association.
To be used in cases where an external association identifier
should be used.
:param assoc_id:
:return: | [
"This",
"will",
"set",
"the",
"association",
"ID",
"based",
"on",
"the",
"internal",
"parts",
"of",
"the",
"association",
".",
"To",
"be",
"used",
"in",
"cases",
"where",
"an",
"external",
"association",
"identifier",
"should",
"be",
"used",
"."
] | 24cc80db355bbe15776edc5c7b41e0886959ba41 | https://github.com/monarch-initiative/dipper/blob/24cc80db355bbe15776edc5c7b41e0886959ba41/dipper/models/assoc/Association.py#L166-L184 | train |
monarch-initiative/dipper | dipper/models/assoc/Association.py | Assoc.make_association_id | def make_association_id(definedby, sub, pred, obj, attributes=None):
"""
A method to create unique identifiers for OBAN-style associations,
based on all the parts of the association
If any of the items is empty or None, it will convert it to blank.
It effectively digests the str... | python | def make_association_id(definedby, sub, pred, obj, attributes=None):
"""
A method to create unique identifiers for OBAN-style associations,
based on all the parts of the association
If any of the items is empty or None, it will convert it to blank.
It effectively digests the str... | [
"def",
"make_association_id",
"(",
"definedby",
",",
"sub",
",",
"pred",
",",
"obj",
",",
"attributes",
"=",
"None",
")",
":",
"items_to_hash",
"=",
"[",
"definedby",
",",
"sub",
",",
"pred",
",",
"obj",
"]",
"if",
"attributes",
"is",
"not",
"None",
"a... | A method to create unique identifiers for OBAN-style associations,
based on all the parts of the association
If any of the items is empty or None, it will convert it to blank.
It effectively digests the string of concatonated values.
Subclasses of Assoc can submit an additional array of... | [
"A",
"method",
"to",
"create",
"unique",
"identifiers",
"for",
"OBAN",
"-",
"style",
"associations",
"based",
"on",
"all",
"the",
"parts",
"of",
"the",
"association",
"If",
"any",
"of",
"the",
"items",
"is",
"empty",
"or",
"None",
"it",
"will",
"convert",
... | 24cc80db355bbe15776edc5c7b41e0886959ba41 | https://github.com/monarch-initiative/dipper/blob/24cc80db355bbe15776edc5c7b41e0886959ba41/dipper/models/assoc/Association.py#L250-L279 | train |
monarch-initiative/dipper | dipper/utils/romanplus.py | toRoman | def toRoman(num):
"""convert integer to Roman numeral"""
if not 0 < num < 5000:
raise ValueError("number %n out of range (must be 1..4999)", num)
if int(num) != num:
raise TypeError("decimals %n can not be converted", num)
result = ""
for numeral, integer in romanNumeralMap:
... | python | def toRoman(num):
"""convert integer to Roman numeral"""
if not 0 < num < 5000:
raise ValueError("number %n out of range (must be 1..4999)", num)
if int(num) != num:
raise TypeError("decimals %n can not be converted", num)
result = ""
for numeral, integer in romanNumeralMap:
... | [
"def",
"toRoman",
"(",
"num",
")",
":",
"if",
"not",
"0",
"<",
"num",
"<",
"5000",
":",
"raise",
"ValueError",
"(",
"\"number %n out of range (must be 1..4999)\"",
",",
"num",
")",
"if",
"int",
"(",
"num",
")",
"!=",
"num",
":",
"raise",
"TypeError",
"("... | convert integer to Roman numeral | [
"convert",
"integer",
"to",
"Roman",
"numeral"
] | 24cc80db355bbe15776edc5c7b41e0886959ba41 | https://github.com/monarch-initiative/dipper/blob/24cc80db355bbe15776edc5c7b41e0886959ba41/dipper/utils/romanplus.py#L38-L50 | train |
monarch-initiative/dipper | dipper/utils/romanplus.py | fromRoman | def fromRoman(strng):
"""convert Roman numeral to integer"""
if not strng:
raise TypeError('Input can not be blank')
if not romanNumeralPattern.search(strng):
raise ValueError('Invalid Roman numeral: %s', strng)
result = 0
index = 0
for numeral, integer in romanNumeralMap:
... | python | def fromRoman(strng):
"""convert Roman numeral to integer"""
if not strng:
raise TypeError('Input can not be blank')
if not romanNumeralPattern.search(strng):
raise ValueError('Invalid Roman numeral: %s', strng)
result = 0
index = 0
for numeral, integer in romanNumeralMap:
... | [
"def",
"fromRoman",
"(",
"strng",
")",
":",
"if",
"not",
"strng",
":",
"raise",
"TypeError",
"(",
"'Input can not be blank'",
")",
"if",
"not",
"romanNumeralPattern",
".",
"search",
"(",
"strng",
")",
":",
"raise",
"ValueError",
"(",
"'Invalid Roman numeral: %s'... | convert Roman numeral to integer | [
"convert",
"Roman",
"numeral",
"to",
"integer"
] | 24cc80db355bbe15776edc5c7b41e0886959ba41 | https://github.com/monarch-initiative/dipper/blob/24cc80db355bbe15776edc5c7b41e0886959ba41/dipper/utils/romanplus.py#L70-L83 | train |
monarch-initiative/dipper | dipper/sources/ZFIN.py | ZFIN._process_genotype_backgrounds | def _process_genotype_backgrounds(self, limit=None):
"""
This table provides a mapping of genotypes to background genotypes
Note that the background_id is also a genotype_id.
Makes these triples:
<ZFIN:genotype_id> GENO:has_reference_part <ZFIN:background_id>
<ZFIN:backg... | python | def _process_genotype_backgrounds(self, limit=None):
"""
This table provides a mapping of genotypes to background genotypes
Note that the background_id is also a genotype_id.
Makes these triples:
<ZFIN:genotype_id> GENO:has_reference_part <ZFIN:background_id>
<ZFIN:backg... | [
"def",
"_process_genotype_backgrounds",
"(",
"self",
",",
"limit",
"=",
"None",
")",
":",
"if",
"self",
".",
"test_mode",
":",
"graph",
"=",
"self",
".",
"testgraph",
"else",
":",
"graph",
"=",
"self",
".",
"graph",
"model",
"=",
"Model",
"(",
"graph",
... | This table provides a mapping of genotypes to background genotypes
Note that the background_id is also a genotype_id.
Makes these triples:
<ZFIN:genotype_id> GENO:has_reference_part <ZFIN:background_id>
<ZFIN:background_id> a GENO:genomic_background
<ZFIN:background_id> in_taxon... | [
"This",
"table",
"provides",
"a",
"mapping",
"of",
"genotypes",
"to",
"background",
"genotypes",
"Note",
"that",
"the",
"background_id",
"is",
"also",
"a",
"genotype_id",
"."
] | 24cc80db355bbe15776edc5c7b41e0886959ba41 | https://github.com/monarch-initiative/dipper/blob/24cc80db355bbe15776edc5c7b41e0886959ba41/dipper/sources/ZFIN.py#L1048-L1113 | train |
monarch-initiative/dipper | dipper/sources/ZFIN.py | ZFIN._process_stages | def _process_stages(self, limit=None):
"""
This table provides mappings between ZFIN stage IDs and ZFS terms,
and includes the starting and ending hours for the developmental stage.
Currently only processing the mapping from the ZFIN stage ID
to the ZFS ID.
:param limit:... | python | def _process_stages(self, limit=None):
"""
This table provides mappings between ZFIN stage IDs and ZFS terms,
and includes the starting and ending hours for the developmental stage.
Currently only processing the mapping from the ZFIN stage ID
to the ZFS ID.
:param limit:... | [
"def",
"_process_stages",
"(",
"self",
",",
"limit",
"=",
"None",
")",
":",
"if",
"self",
".",
"test_mode",
":",
"graph",
"=",
"self",
".",
"testgraph",
"else",
":",
"graph",
"=",
"self",
".",
"graph",
"model",
"=",
"Model",
"(",
"graph",
")",
"LOG",... | This table provides mappings between ZFIN stage IDs and ZFS terms,
and includes the starting and ending hours for the developmental stage.
Currently only processing the mapping from the ZFIN stage ID
to the ZFS ID.
:param limit:
:return: | [
"This",
"table",
"provides",
"mappings",
"between",
"ZFIN",
"stage",
"IDs",
"and",
"ZFS",
"terms",
"and",
"includes",
"the",
"starting",
"and",
"ending",
"hours",
"for",
"the",
"developmental",
"stage",
".",
"Currently",
"only",
"processing",
"the",
"mapping",
... | 24cc80db355bbe15776edc5c7b41e0886959ba41 | https://github.com/monarch-initiative/dipper/blob/24cc80db355bbe15776edc5c7b41e0886959ba41/dipper/sources/ZFIN.py#L1174-L1211 | train |
monarch-initiative/dipper | dipper/sources/ZFIN.py | ZFIN._process_genes | def _process_genes(self, limit=None):
"""
This table provides the ZFIN gene id, the SO type of the gene,
the gene symbol, and the NCBI Gene ID.
Triples created:
<gene id> a class
<gene id> rdfs:label gene_symbol
<gene id> equivalent class <ncbi_gene_id>
:... | python | def _process_genes(self, limit=None):
"""
This table provides the ZFIN gene id, the SO type of the gene,
the gene symbol, and the NCBI Gene ID.
Triples created:
<gene id> a class
<gene id> rdfs:label gene_symbol
<gene id> equivalent class <ncbi_gene_id>
:... | [
"def",
"_process_genes",
"(",
"self",
",",
"limit",
"=",
"None",
")",
":",
"LOG",
".",
"info",
"(",
"\"Processing genes\"",
")",
"if",
"self",
".",
"test_mode",
":",
"graph",
"=",
"self",
".",
"testgraph",
"else",
":",
"graph",
"=",
"self",
".",
"graph... | This table provides the ZFIN gene id, the SO type of the gene,
the gene symbol, and the NCBI Gene ID.
Triples created:
<gene id> a class
<gene id> rdfs:label gene_symbol
<gene id> equivalent class <ncbi_gene_id>
:param limit:
:return: | [
"This",
"table",
"provides",
"the",
"ZFIN",
"gene",
"id",
"the",
"SO",
"type",
"of",
"the",
"gene",
"the",
"gene",
"symbol",
"and",
"the",
"NCBI",
"Gene",
"ID",
"."
] | 24cc80db355bbe15776edc5c7b41e0886959ba41 | https://github.com/monarch-initiative/dipper/blob/24cc80db355bbe15776edc5c7b41e0886959ba41/dipper/sources/ZFIN.py#L1390-L1437 | train |
monarch-initiative/dipper | dipper/sources/ZFIN.py | ZFIN._process_features | def _process_features(self, limit=None):
"""
This module provides information for the intrinsic
and extrinsic genotype features of zebrafish.
All items here are 'alterations', and are therefore instances.
sequence alteration ID, SO type, abbreviation, and relationship to
... | python | def _process_features(self, limit=None):
"""
This module provides information for the intrinsic
and extrinsic genotype features of zebrafish.
All items here are 'alterations', and are therefore instances.
sequence alteration ID, SO type, abbreviation, and relationship to
... | [
"def",
"_process_features",
"(",
"self",
",",
"limit",
"=",
"None",
")",
":",
"if",
"self",
".",
"test_mode",
":",
"graph",
"=",
"self",
".",
"testgraph",
"else",
":",
"graph",
"=",
"self",
".",
"graph",
"model",
"=",
"Model",
"(",
"graph",
")",
"LOG... | This module provides information for the intrinsic
and extrinsic genotype features of zebrafish.
All items here are 'alterations', and are therefore instances.
sequence alteration ID, SO type, abbreviation, and relationship to
the affected gene, with the gene's ID, symbol,
and S... | [
"This",
"module",
"provides",
"information",
"for",
"the",
"intrinsic",
"and",
"extrinsic",
"genotype",
"features",
"of",
"zebrafish",
".",
"All",
"items",
"here",
"are",
"alterations",
"and",
"are",
"therefore",
"instances",
"."
] | 24cc80db355bbe15776edc5c7b41e0886959ba41 | https://github.com/monarch-initiative/dipper/blob/24cc80db355bbe15776edc5c7b41e0886959ba41/dipper/sources/ZFIN.py#L1439-L1505 | train |
monarch-initiative/dipper | dipper/sources/ZFIN.py | ZFIN._process_pubinfo | def _process_pubinfo(self, limit=None):
"""
This will pull the zfin internal publication information,
and map them to their equivalent pmid, and make labels.
Triples created:
<pub_id> is an individual
<pub_id> rdfs:label <pub_label>
<pubmed_id> is an individual
... | python | def _process_pubinfo(self, limit=None):
"""
This will pull the zfin internal publication information,
and map them to their equivalent pmid, and make labels.
Triples created:
<pub_id> is an individual
<pub_id> rdfs:label <pub_label>
<pubmed_id> is an individual
... | [
"def",
"_process_pubinfo",
"(",
"self",
",",
"limit",
"=",
"None",
")",
":",
"line_counter",
"=",
"0",
"if",
"self",
".",
"test_mode",
":",
"graph",
"=",
"self",
".",
"testgraph",
"else",
":",
"graph",
"=",
"self",
".",
"graph",
"model",
"=",
"Model",
... | This will pull the zfin internal publication information,
and map them to their equivalent pmid, and make labels.
Triples created:
<pub_id> is an individual
<pub_id> rdfs:label <pub_label>
<pubmed_id> is an individual
<pubmed_id> rdfs:label <pub_label>
<pub_id> ... | [
"This",
"will",
"pull",
"the",
"zfin",
"internal",
"publication",
"information",
"and",
"map",
"them",
"to",
"their",
"equivalent",
"pmid",
"and",
"make",
"labels",
"."
] | 24cc80db355bbe15776edc5c7b41e0886959ba41 | https://github.com/monarch-initiative/dipper/blob/24cc80db355bbe15776edc5c7b41e0886959ba41/dipper/sources/ZFIN.py#L1775-L1851 | train |
monarch-initiative/dipper | dipper/sources/ZFIN.py | ZFIN._process_pub2pubmed | def _process_pub2pubmed(self, limit=None):
"""
This will pull the zfin internal publication to pubmed mappings.
Somewhat redundant with the process_pubinfo method,
but this includes additional mappings.
<pub_id> is an individual
<pub_id> rdfs:label <pub_label>
<p... | python | def _process_pub2pubmed(self, limit=None):
"""
This will pull the zfin internal publication to pubmed mappings.
Somewhat redundant with the process_pubinfo method,
but this includes additional mappings.
<pub_id> is an individual
<pub_id> rdfs:label <pub_label>
<p... | [
"def",
"_process_pub2pubmed",
"(",
"self",
",",
"limit",
"=",
"None",
")",
":",
"line_counter",
"=",
"0",
"if",
"self",
".",
"test_mode",
":",
"graph",
"=",
"self",
".",
"testgraph",
"else",
":",
"graph",
"=",
"self",
".",
"graph",
"model",
"=",
"Model... | This will pull the zfin internal publication to pubmed mappings.
Somewhat redundant with the process_pubinfo method,
but this includes additional mappings.
<pub_id> is an individual
<pub_id> rdfs:label <pub_label>
<pubmed_id> is an individual
<pubmed_id> rdfs:label <pub_... | [
"This",
"will",
"pull",
"the",
"zfin",
"internal",
"publication",
"to",
"pubmed",
"mappings",
".",
"Somewhat",
"redundant",
"with",
"the",
"process_pubinfo",
"method",
"but",
"this",
"includes",
"additional",
"mappings",
"."
] | 24cc80db355bbe15776edc5c7b41e0886959ba41 | https://github.com/monarch-initiative/dipper/blob/24cc80db355bbe15776edc5c7b41e0886959ba41/dipper/sources/ZFIN.py#L1853-L1901 | train |
monarch-initiative/dipper | dipper/sources/ZFIN.py | ZFIN._process_targeting_reagents | def _process_targeting_reagents(self, reagent_type, limit=None):
"""
This method processes the gene targeting knockdown reagents,
such as morpholinos, talens, and crisprs.
We create triples for the reagents and pass the data into a hash map
for use in the pheno_enviro method.
... | python | def _process_targeting_reagents(self, reagent_type, limit=None):
"""
This method processes the gene targeting knockdown reagents,
such as morpholinos, talens, and crisprs.
We create triples for the reagents and pass the data into a hash map
for use in the pheno_enviro method.
... | [
"def",
"_process_targeting_reagents",
"(",
"self",
",",
"reagent_type",
",",
"limit",
"=",
"None",
")",
":",
"LOG",
".",
"info",
"(",
"\"Processing Gene Targeting Reagents\"",
")",
"if",
"self",
".",
"test_mode",
":",
"graph",
"=",
"self",
".",
"testgraph",
"e... | This method processes the gene targeting knockdown reagents,
such as morpholinos, talens, and crisprs.
We create triples for the reagents and pass the data into a hash map
for use in the pheno_enviro method.
Morpholinos work similar to RNAi.
TALENs are artificial restriction enz... | [
"This",
"method",
"processes",
"the",
"gene",
"targeting",
"knockdown",
"reagents",
"such",
"as",
"morpholinos",
"talens",
"and",
"crisprs",
".",
"We",
"create",
"triples",
"for",
"the",
"reagents",
"and",
"pass",
"the",
"data",
"into",
"a",
"hash",
"map",
"... | 24cc80db355bbe15776edc5c7b41e0886959ba41 | https://github.com/monarch-initiative/dipper/blob/24cc80db355bbe15776edc5c7b41e0886959ba41/dipper/sources/ZFIN.py#L1903-L2014 | train |
monarch-initiative/dipper | dipper/sources/ZFIN.py | ZFIN._process_uniprot_ids | def _process_uniprot_ids(self, limit=None):
"""
This method processes the mappings from ZFIN gene IDs to UniProtKB IDs.
Triples created:
<zfin_gene_id> a class
<zfin_gene_id> rdfs:label gene_symbol
<uniprot_id> is an Individual
<uniprot_id> has type <polypeptide... | python | def _process_uniprot_ids(self, limit=None):
"""
This method processes the mappings from ZFIN gene IDs to UniProtKB IDs.
Triples created:
<zfin_gene_id> a class
<zfin_gene_id> rdfs:label gene_symbol
<uniprot_id> is an Individual
<uniprot_id> has type <polypeptide... | [
"def",
"_process_uniprot_ids",
"(",
"self",
",",
"limit",
"=",
"None",
")",
":",
"LOG",
".",
"info",
"(",
"\"Processing UniProt IDs\"",
")",
"if",
"self",
".",
"test_mode",
":",
"graph",
"=",
"self",
".",
"testgraph",
"else",
":",
"graph",
"=",
"self",
"... | This method processes the mappings from ZFIN gene IDs to UniProtKB IDs.
Triples created:
<zfin_gene_id> a class
<zfin_gene_id> rdfs:label gene_symbol
<uniprot_id> is an Individual
<uniprot_id> has type <polypeptide>
<zfin_gene_id> has_gene_product <uniprot_id>
... | [
"This",
"method",
"processes",
"the",
"mappings",
"from",
"ZFIN",
"gene",
"IDs",
"to",
"UniProtKB",
"IDs",
"."
] | 24cc80db355bbe15776edc5c7b41e0886959ba41 | https://github.com/monarch-initiative/dipper/blob/24cc80db355bbe15776edc5c7b41e0886959ba41/dipper/sources/ZFIN.py#L2235-L2287 | train |
monarch-initiative/dipper | dipper/sources/ZFIN.py | ZFIN.get_orthology_evidence_code | def get_orthology_evidence_code(self, abbrev):
'''
move to localtt & globltt
'''
# AA Amino acid sequence comparison.
# CE Coincident expression.
# CL Conserved genome location (synteny).
# FC Functional complementation.
# FH Formation of functional he... | python | def get_orthology_evidence_code(self, abbrev):
'''
move to localtt & globltt
'''
# AA Amino acid sequence comparison.
# CE Coincident expression.
# CL Conserved genome location (synteny).
# FC Functional complementation.
# FH Formation of functional he... | [
"def",
"get_orthology_evidence_code",
"(",
"self",
",",
"abbrev",
")",
":",
"eco_abbrev_map",
"=",
"{",
"'AA'",
":",
"'ECO:0000031'",
",",
"'CE'",
":",
"'ECO:0000008'",
",",
"'CL'",
":",
"'ECO:0000044'",
",",
"'FC'",
":",
"'ECO:0000012'",
",",
"'FH'",
":",
"... | move to localtt & globltt | [
"move",
"to",
"localtt",
"&",
"globltt"
] | 24cc80db355bbe15776edc5c7b41e0886959ba41 | https://github.com/monarch-initiative/dipper/blob/24cc80db355bbe15776edc5c7b41e0886959ba41/dipper/sources/ZFIN.py#L2798-L2840 | train |
monarch-initiative/dipper | dipper/sources/KEGG.py | KEGG._process_diseases | def _process_diseases(self, limit=None):
"""
This method processes the KEGG disease IDs.
Triples created:
<disease_id> is a class
<disease_id> rdfs:label <disease_name>
:param limit:
:return:
"""
LOG.info("Processing diseases")
if self.t... | python | def _process_diseases(self, limit=None):
"""
This method processes the KEGG disease IDs.
Triples created:
<disease_id> is a class
<disease_id> rdfs:label <disease_name>
:param limit:
:return:
"""
LOG.info("Processing diseases")
if self.t... | [
"def",
"_process_diseases",
"(",
"self",
",",
"limit",
"=",
"None",
")",
":",
"LOG",
".",
"info",
"(",
"\"Processing diseases\"",
")",
"if",
"self",
".",
"test_mode",
":",
"graph",
"=",
"self",
".",
"testgraph",
"else",
":",
"graph",
"=",
"self",
".",
... | This method processes the KEGG disease IDs.
Triples created:
<disease_id> is a class
<disease_id> rdfs:label <disease_name>
:param limit:
:return: | [
"This",
"method",
"processes",
"the",
"KEGG",
"disease",
"IDs",
"."
] | 24cc80db355bbe15776edc5c7b41e0886959ba41 | https://github.com/monarch-initiative/dipper/blob/24cc80db355bbe15776edc5c7b41e0886959ba41/dipper/sources/KEGG.py#L224-L269 | train |
monarch-initiative/dipper | dipper/sources/KEGG.py | KEGG._process_genes | def _process_genes(self, limit=None):
"""
This method processes the KEGG gene IDs.
The label for the gene is pulled as
the first symbol in the list of gene symbols;
the rest are added as synonyms.
The long-form of the gene name is added as a definition.
This is ha... | python | def _process_genes(self, limit=None):
"""
This method processes the KEGG gene IDs.
The label for the gene is pulled as
the first symbol in the list of gene symbols;
the rest are added as synonyms.
The long-form of the gene name is added as a definition.
This is ha... | [
"def",
"_process_genes",
"(",
"self",
",",
"limit",
"=",
"None",
")",
":",
"LOG",
".",
"info",
"(",
"\"Processing genes\"",
")",
"if",
"self",
".",
"test_mode",
":",
"graph",
"=",
"self",
".",
"testgraph",
"else",
":",
"graph",
"=",
"self",
".",
"graph... | This method processes the KEGG gene IDs.
The label for the gene is pulled as
the first symbol in the list of gene symbols;
the rest are added as synonyms.
The long-form of the gene name is added as a definition.
This is hardcoded to just processes human genes.
Triples cr... | [
"This",
"method",
"processes",
"the",
"KEGG",
"gene",
"IDs",
".",
"The",
"label",
"for",
"the",
"gene",
"is",
"pulled",
"as",
"the",
"first",
"symbol",
"in",
"the",
"list",
"of",
"gene",
"symbols",
";",
"the",
"rest",
"are",
"added",
"as",
"synonyms",
... | 24cc80db355bbe15776edc5c7b41e0886959ba41 | https://github.com/monarch-initiative/dipper/blob/24cc80db355bbe15776edc5c7b41e0886959ba41/dipper/sources/KEGG.py#L271-L352 | train |
monarch-initiative/dipper | dipper/sources/KEGG.py | KEGG._process_ortholog_classes | def _process_ortholog_classes(self, limit=None):
"""
This method add the KEGG orthology classes to the graph.
If there's an embedded enzyme commission number,
that is added as an xref.
Triples created:
<orthology_class_id> is a class
<orthology_class_id> has lab... | python | def _process_ortholog_classes(self, limit=None):
"""
This method add the KEGG orthology classes to the graph.
If there's an embedded enzyme commission number,
that is added as an xref.
Triples created:
<orthology_class_id> is a class
<orthology_class_id> has lab... | [
"def",
"_process_ortholog_classes",
"(",
"self",
",",
"limit",
"=",
"None",
")",
":",
"LOG",
".",
"info",
"(",
"\"Processing ortholog classes\"",
")",
"if",
"self",
".",
"test_mode",
":",
"graph",
"=",
"self",
".",
"testgraph",
"else",
":",
"graph",
"=",
"... | This method add the KEGG orthology classes to the graph.
If there's an embedded enzyme commission number,
that is added as an xref.
Triples created:
<orthology_class_id> is a class
<orthology_class_id> has label <orthology_symbols>
<orthology_class_id> has description <... | [
"This",
"method",
"add",
"the",
"KEGG",
"orthology",
"classes",
"to",
"the",
"graph",
"."
] | 24cc80db355bbe15776edc5c7b41e0886959ba41 | https://github.com/monarch-initiative/dipper/blob/24cc80db355bbe15776edc5c7b41e0886959ba41/dipper/sources/KEGG.py#L354-L423 | train |
monarch-initiative/dipper | dipper/sources/KEGG.py | KEGG._process_orthologs | def _process_orthologs(self, raw, limit=None):
"""
This method maps orthologs for a species to the KEGG orthology classes.
Triples created:
<gene_id> is a class
<orthology_class_id> is a class
<assoc_id> has subject <gene_id>
<assoc_id> has object <orthology_cla... | python | def _process_orthologs(self, raw, limit=None):
"""
This method maps orthologs for a species to the KEGG orthology classes.
Triples created:
<gene_id> is a class
<orthology_class_id> is a class
<assoc_id> has subject <gene_id>
<assoc_id> has object <orthology_cla... | [
"def",
"_process_orthologs",
"(",
"self",
",",
"raw",
",",
"limit",
"=",
"None",
")",
":",
"LOG",
".",
"info",
"(",
"\"Processing orthologs\"",
")",
"if",
"self",
".",
"test_mode",
":",
"graph",
"=",
"self",
".",
"testgraph",
"else",
":",
"graph",
"=",
... | This method maps orthologs for a species to the KEGG orthology classes.
Triples created:
<gene_id> is a class
<orthology_class_id> is a class
<assoc_id> has subject <gene_id>
<assoc_id> has object <orthology_class_id>
:param limit:
:return: | [
"This",
"method",
"maps",
"orthologs",
"for",
"a",
"species",
"to",
"the",
"KEGG",
"orthology",
"classes",
"."
] | 24cc80db355bbe15776edc5c7b41e0886959ba41 | https://github.com/monarch-initiative/dipper/blob/24cc80db355bbe15776edc5c7b41e0886959ba41/dipper/sources/KEGG.py#L425-L473 | train |
monarch-initiative/dipper | dipper/sources/KEGG.py | KEGG._process_kegg_disease2gene | def _process_kegg_disease2gene(self, limit=None):
"""
This method creates an association between diseases and
their associated genes. We are being conservative here, and only
processing those diseases for which there is no mapping to OMIM.
Triples created:
<alternate_loc... | python | def _process_kegg_disease2gene(self, limit=None):
"""
This method creates an association between diseases and
their associated genes. We are being conservative here, and only
processing those diseases for which there is no mapping to OMIM.
Triples created:
<alternate_loc... | [
"def",
"_process_kegg_disease2gene",
"(",
"self",
",",
"limit",
"=",
"None",
")",
":",
"LOG",
".",
"info",
"(",
"\"Processing KEGG disease to gene\"",
")",
"if",
"self",
".",
"test_mode",
":",
"graph",
"=",
"self",
".",
"testgraph",
"else",
":",
"graph",
"="... | This method creates an association between diseases and
their associated genes. We are being conservative here, and only
processing those diseases for which there is no mapping to OMIM.
Triples created:
<alternate_locus> is an Individual
<alternate_locus> has type <variant_locus... | [
"This",
"method",
"creates",
"an",
"association",
"between",
"diseases",
"and",
"their",
"associated",
"genes",
".",
"We",
"are",
"being",
"conservative",
"here",
"and",
"only",
"processing",
"those",
"diseases",
"for",
"which",
"there",
"is",
"no",
"mapping",
... | 24cc80db355bbe15776edc5c7b41e0886959ba41 | https://github.com/monarch-initiative/dipper/blob/24cc80db355bbe15776edc5c7b41e0886959ba41/dipper/sources/KEGG.py#L475-L551 | train |
monarch-initiative/dipper | dipper/sources/KEGG.py | KEGG._process_omim2gene | def _process_omim2gene(self, limit=None):
"""
This method maps the OMIM IDs and KEGG gene ID.
Currently split based on the link_type field.
Equivalent link types are mapped as gene XRefs.
Reverse link types are mapped as disease to gene associations.
Original link types a... | python | def _process_omim2gene(self, limit=None):
"""
This method maps the OMIM IDs and KEGG gene ID.
Currently split based on the link_type field.
Equivalent link types are mapped as gene XRefs.
Reverse link types are mapped as disease to gene associations.
Original link types a... | [
"def",
"_process_omim2gene",
"(",
"self",
",",
"limit",
"=",
"None",
")",
":",
"LOG",
".",
"info",
"(",
"\"Processing OMIM to KEGG gene\"",
")",
"if",
"self",
".",
"test_mode",
":",
"graph",
"=",
"self",
".",
"testgraph",
"else",
":",
"graph",
"=",
"self",... | This method maps the OMIM IDs and KEGG gene ID.
Currently split based on the link_type field.
Equivalent link types are mapped as gene XRefs.
Reverse link types are mapped as disease to gene associations.
Original link types are currently skipped.
Triples created:
<kegg_... | [
"This",
"method",
"maps",
"the",
"OMIM",
"IDs",
"and",
"KEGG",
"gene",
"ID",
".",
"Currently",
"split",
"based",
"on",
"the",
"link_type",
"field",
".",
"Equivalent",
"link",
"types",
"are",
"mapped",
"as",
"gene",
"XRefs",
".",
"Reverse",
"link",
"types",... | 24cc80db355bbe15776edc5c7b41e0886959ba41 | https://github.com/monarch-initiative/dipper/blob/24cc80db355bbe15776edc5c7b41e0886959ba41/dipper/sources/KEGG.py#L553-L634 | train |
monarch-initiative/dipper | dipper/sources/KEGG.py | KEGG._process_genes_kegg2ncbi | def _process_genes_kegg2ncbi(self, limit=None):
"""
This method maps the KEGG human gene IDs
to the corresponding NCBI Gene IDs.
Triples created:
<kegg_gene_id> is a class
<ncbi_gene_id> is a class
<kegg_gene_id> equivalentClass <ncbi_gene_id>
:param ... | python | def _process_genes_kegg2ncbi(self, limit=None):
"""
This method maps the KEGG human gene IDs
to the corresponding NCBI Gene IDs.
Triples created:
<kegg_gene_id> is a class
<ncbi_gene_id> is a class
<kegg_gene_id> equivalentClass <ncbi_gene_id>
:param ... | [
"def",
"_process_genes_kegg2ncbi",
"(",
"self",
",",
"limit",
"=",
"None",
")",
":",
"LOG",
".",
"info",
"(",
"\"Processing KEGG gene IDs to NCBI gene IDs\"",
")",
"if",
"self",
".",
"test_mode",
":",
"graph",
"=",
"self",
".",
"testgraph",
"else",
":",
"graph... | This method maps the KEGG human gene IDs
to the corresponding NCBI Gene IDs.
Triples created:
<kegg_gene_id> is a class
<ncbi_gene_id> is a class
<kegg_gene_id> equivalentClass <ncbi_gene_id>
:param limit:
:return: | [
"This",
"method",
"maps",
"the",
"KEGG",
"human",
"gene",
"IDs",
"to",
"the",
"corresponding",
"NCBI",
"Gene",
"IDs",
"."
] | 24cc80db355bbe15776edc5c7b41e0886959ba41 | https://github.com/monarch-initiative/dipper/blob/24cc80db355bbe15776edc5c7b41e0886959ba41/dipper/sources/KEGG.py#L706-L754 | train |
monarch-initiative/dipper | dipper/sources/KEGG.py | KEGG._process_pathway_disease | def _process_pathway_disease(self, limit):
"""
We make a link between the pathway identifiers,
and any diseases associated with them.
Since we model diseases as processes, we make a triple saying that
the pathway may be causally upstream of or within the disease process.
... | python | def _process_pathway_disease(self, limit):
"""
We make a link between the pathway identifiers,
and any diseases associated with them.
Since we model diseases as processes, we make a triple saying that
the pathway may be causally upstream of or within the disease process.
... | [
"def",
"_process_pathway_disease",
"(",
"self",
",",
"limit",
")",
":",
"LOG",
".",
"info",
"(",
"\"Processing KEGG pathways to disease ids\"",
")",
"if",
"self",
".",
"test_mode",
":",
"graph",
"=",
"self",
".",
"testgraph",
"else",
":",
"graph",
"=",
"self",... | We make a link between the pathway identifiers,
and any diseases associated with them.
Since we model diseases as processes, we make a triple saying that
the pathway may be causally upstream of or within the disease process.
:param limit:
:return: | [
"We",
"make",
"a",
"link",
"between",
"the",
"pathway",
"identifiers",
"and",
"any",
"diseases",
"associated",
"with",
"them",
".",
"Since",
"we",
"model",
"diseases",
"as",
"processes",
"we",
"make",
"a",
"triple",
"saying",
"that",
"the",
"pathway",
"may",... | 24cc80db355bbe15776edc5c7b41e0886959ba41 | https://github.com/monarch-initiative/dipper/blob/24cc80db355bbe15776edc5c7b41e0886959ba41/dipper/sources/KEGG.py#L792-L832 | train |
monarch-initiative/dipper | dipper/sources/KEGG.py | KEGG._make_variant_locus_id | def _make_variant_locus_id(self, gene_id, disease_id):
"""
We actually want the association between the gene and the disease
to be via an alternate locus not the "wildtype" gene itself.
so we make an anonymous alternate locus,
and put that in the association
We also make ... | python | def _make_variant_locus_id(self, gene_id, disease_id):
"""
We actually want the association between the gene and the disease
to be via an alternate locus not the "wildtype" gene itself.
so we make an anonymous alternate locus,
and put that in the association
We also make ... | [
"def",
"_make_variant_locus_id",
"(",
"self",
",",
"gene_id",
",",
"disease_id",
")",
":",
"alt_locus_id",
"=",
"'_:'",
"+",
"re",
".",
"sub",
"(",
"r':'",
",",
"''",
",",
"gene_id",
")",
"+",
"'-'",
"+",
"re",
".",
"sub",
"(",
"r':'",
",",
"''",
"... | We actually want the association between the gene and the disease
to be via an alternate locus not the "wildtype" gene itself.
so we make an anonymous alternate locus,
and put that in the association
We also make the label for the anonymous class,
and add it to the label hash
... | [
"We",
"actually",
"want",
"the",
"association",
"between",
"the",
"gene",
"and",
"the",
"disease",
"to",
"be",
"via",
"an",
"alternate",
"locus",
"not",
"the",
"wildtype",
"gene",
"itself",
".",
"so",
"we",
"make",
"an",
"anonymous",
"alternate",
"locus",
... | 24cc80db355bbe15776edc5c7b41e0886959ba41 | https://github.com/monarch-initiative/dipper/blob/24cc80db355bbe15776edc5c7b41e0886959ba41/dipper/sources/KEGG.py#L906-L933 | train |
monarch-initiative/dipper | dipper/sources/CTD.py | CTD._fetch_disambiguating_assoc | def _fetch_disambiguating_assoc(self):
"""
For any of the items in the chemical-disease association file that have
ambiguous association types we fetch the disambiguated associations
using the batch query API, and store these in a file. Elsewhere, we can
loop through the file and... | python | def _fetch_disambiguating_assoc(self):
"""
For any of the items in the chemical-disease association file that have
ambiguous association types we fetch the disambiguated associations
using the batch query API, and store these in a file. Elsewhere, we can
loop through the file and... | [
"def",
"_fetch_disambiguating_assoc",
"(",
"self",
")",
":",
"disambig_file",
"=",
"'/'",
".",
"join",
"(",
"(",
"self",
".",
"rawdir",
",",
"self",
".",
"static_files",
"[",
"'publications'",
"]",
"[",
"'file'",
"]",
")",
")",
"assoc_file",
"=",
"'/'",
... | For any of the items in the chemical-disease association file that have
ambiguous association types we fetch the disambiguated associations
using the batch query API, and store these in a file. Elsewhere, we can
loop through the file and create the appropriate associations.
:return: | [
"For",
"any",
"of",
"the",
"items",
"in",
"the",
"chemical",
"-",
"disease",
"association",
"file",
"that",
"have",
"ambiguous",
"association",
"types",
"we",
"fetch",
"the",
"disambiguated",
"associations",
"using",
"the",
"batch",
"query",
"API",
"and",
"sto... | 24cc80db355bbe15776edc5c7b41e0886959ba41 | https://github.com/monarch-initiative/dipper/blob/24cc80db355bbe15776edc5c7b41e0886959ba41/dipper/sources/CTD.py#L243-L323 | train |
monarch-initiative/dipper | dipper/sources/CTD.py | CTD._make_association | def _make_association(self, subject_id, object_id, rel_id, pubmed_ids):
"""
Make a reified association given an array of pubmed identifiers.
Args:
:param subject_id id of the subject of the association (gene/chem)
:param object_id id of the object of the association (d... | python | def _make_association(self, subject_id, object_id, rel_id, pubmed_ids):
"""
Make a reified association given an array of pubmed identifiers.
Args:
:param subject_id id of the subject of the association (gene/chem)
:param object_id id of the object of the association (d... | [
"def",
"_make_association",
"(",
"self",
",",
"subject_id",
",",
"object_id",
",",
"rel_id",
",",
"pubmed_ids",
")",
":",
"assoc",
"=",
"G2PAssoc",
"(",
"self",
".",
"graph",
",",
"self",
".",
"name",
",",
"subject_id",
",",
"object_id",
",",
"rel_id",
"... | Make a reified association given an array of pubmed identifiers.
Args:
:param subject_id id of the subject of the association (gene/chem)
:param object_id id of the object of the association (disease)
:param rel_id relationship id
:param pubmed_ids an array of... | [
"Make",
"a",
"reified",
"association",
"given",
"an",
"array",
"of",
"pubmed",
"identifiers",
"."
] | 24cc80db355bbe15776edc5c7b41e0886959ba41 | https://github.com/monarch-initiative/dipper/blob/24cc80db355bbe15776edc5c7b41e0886959ba41/dipper/sources/CTD.py#L485-L510 | train |
monarch-initiative/dipper | dipper/sources/Bgee.py | Bgee.checkIfRemoteIsNewer | def checkIfRemoteIsNewer(self, localfile, remote_size, remote_modify):
"""
Overrides checkIfRemoteIsNewer in Source class
:param localfile: str file path
:param remote_size: str bytes
:param remote_modify: str last modify date in the form 20160705042714
:return: boolean ... | python | def checkIfRemoteIsNewer(self, localfile, remote_size, remote_modify):
"""
Overrides checkIfRemoteIsNewer in Source class
:param localfile: str file path
:param remote_size: str bytes
:param remote_modify: str last modify date in the form 20160705042714
:return: boolean ... | [
"def",
"checkIfRemoteIsNewer",
"(",
"self",
",",
"localfile",
",",
"remote_size",
",",
"remote_modify",
")",
":",
"is_remote_newer",
"=",
"False",
"status",
"=",
"os",
".",
"stat",
"(",
"localfile",
")",
"LOG",
".",
"info",
"(",
"\"\\nLocal file size: %i\"",
"... | Overrides checkIfRemoteIsNewer in Source class
:param localfile: str file path
:param remote_size: str bytes
:param remote_modify: str last modify date in the form 20160705042714
:return: boolean True if remote file is newer else False | [
"Overrides",
"checkIfRemoteIsNewer",
"in",
"Source",
"class"
] | 24cc80db355bbe15776edc5c7b41e0886959ba41 | https://github.com/monarch-initiative/dipper/blob/24cc80db355bbe15776edc5c7b41e0886959ba41/dipper/sources/Bgee.py#L232-L256 | train |
monarch-initiative/dipper | dipper/sources/Bgee.py | Bgee._convert_ftp_time_to_iso | def _convert_ftp_time_to_iso(ftp_time):
"""
Convert datetime in the format 20160705042714 to a datetime object
:return: datetime object
"""
date_time = datetime(
int(ftp_time[:4]), int(ftp_time[4:6]), int(ftp_time[6:8]),
int(ftp_time[8:10]), int(ftp_time[... | python | def _convert_ftp_time_to_iso(ftp_time):
"""
Convert datetime in the format 20160705042714 to a datetime object
:return: datetime object
"""
date_time = datetime(
int(ftp_time[:4]), int(ftp_time[4:6]), int(ftp_time[6:8]),
int(ftp_time[8:10]), int(ftp_time[... | [
"def",
"_convert_ftp_time_to_iso",
"(",
"ftp_time",
")",
":",
"date_time",
"=",
"datetime",
"(",
"int",
"(",
"ftp_time",
"[",
":",
"4",
"]",
")",
",",
"int",
"(",
"ftp_time",
"[",
"4",
":",
"6",
"]",
")",
",",
"int",
"(",
"ftp_time",
"[",
"6",
":",... | Convert datetime in the format 20160705042714 to a datetime object
:return: datetime object | [
"Convert",
"datetime",
"in",
"the",
"format",
"20160705042714",
"to",
"a",
"datetime",
"object"
] | 24cc80db355bbe15776edc5c7b41e0886959ba41 | https://github.com/monarch-initiative/dipper/blob/24cc80db355bbe15776edc5c7b41e0886959ba41/dipper/sources/Bgee.py#L259-L268 | train |
monarch-initiative/dipper | dipper/sources/EOM.py | EOM.fetch | def fetch(self, is_dl_forced=False):
'''connection details for DISCO'''
cxn = {}
cxn['host'] = 'nif-db.crbs.ucsd.edu'
cxn['database'] = 'disco_crawler'
cxn['port'] = '5432'
cxn['user'] = config.get_config()['user']['disco']
cxn['password'] = config.get_config()['k... | python | def fetch(self, is_dl_forced=False):
'''connection details for DISCO'''
cxn = {}
cxn['host'] = 'nif-db.crbs.ucsd.edu'
cxn['database'] = 'disco_crawler'
cxn['port'] = '5432'
cxn['user'] = config.get_config()['user']['disco']
cxn['password'] = config.get_config()['k... | [
"def",
"fetch",
"(",
"self",
",",
"is_dl_forced",
"=",
"False",
")",
":",
"cxn",
"=",
"{",
"}",
"cxn",
"[",
"'host'",
"]",
"=",
"'nif-db.crbs.ucsd.edu'",
"cxn",
"[",
"'database'",
"]",
"=",
"'disco_crawler'",
"cxn",
"[",
"'port'",
"]",
"=",
"'5432'",
"... | connection details for DISCO | [
"connection",
"details",
"for",
"DISCO"
] | 24cc80db355bbe15776edc5c7b41e0886959ba41 | https://github.com/monarch-initiative/dipper/blob/24cc80db355bbe15776edc5c7b41e0886959ba41/dipper/sources/EOM.py#L63-L87 | train |
monarch-initiative/dipper | dipper/sources/EOM.py | EOM.parse | def parse(self, limit=None):
'''
Over ride Source.parse inherited via PostgreSQLSource
'''
if limit is not None:
LOG.info("Only parsing first %s rows of each file", limit)
if self.test_only:
self.test_mode = True
LOG.info("Parsing files...")... | python | def parse(self, limit=None):
'''
Over ride Source.parse inherited via PostgreSQLSource
'''
if limit is not None:
LOG.info("Only parsing first %s rows of each file", limit)
if self.test_only:
self.test_mode = True
LOG.info("Parsing files...")... | [
"def",
"parse",
"(",
"self",
",",
"limit",
"=",
"None",
")",
":",
"if",
"limit",
"is",
"not",
"None",
":",
"LOG",
".",
"info",
"(",
"\"Only parsing first %s rows of each file\"",
",",
"limit",
")",
"if",
"self",
".",
"test_only",
":",
"self",
".",
"test_... | Over ride Source.parse inherited via PostgreSQLSource | [
"Over",
"ride",
"Source",
".",
"parse",
"inherited",
"via",
"PostgreSQLSource"
] | 24cc80db355bbe15776edc5c7b41e0886959ba41 | https://github.com/monarch-initiative/dipper/blob/24cc80db355bbe15776edc5c7b41e0886959ba41/dipper/sources/EOM.py#L89-L113 | train |
monarch-initiative/dipper | dipper/sources/MGI.py | MGI._process_gxd_genotype_view | def _process_gxd_genotype_view(self, limit=None):
"""
This table indicates the relationship between a genotype
and it's background strain. It leverages the Genotype class methods
to do this.
Makes these triples:
<MGI:genotypeid> GENO:has_reference_part <MGI:strainid>
... | python | def _process_gxd_genotype_view(self, limit=None):
"""
This table indicates the relationship between a genotype
and it's background strain. It leverages the Genotype class methods
to do this.
Makes these triples:
<MGI:genotypeid> GENO:has_reference_part <MGI:strainid>
... | [
"def",
"_process_gxd_genotype_view",
"(",
"self",
",",
"limit",
"=",
"None",
")",
":",
"line_counter",
"=",
"0",
"if",
"self",
".",
"test_mode",
":",
"graph",
"=",
"self",
".",
"testgraph",
"else",
":",
"graph",
"=",
"self",
".",
"graph",
"geno",
"=",
... | This table indicates the relationship between a genotype
and it's background strain. It leverages the Genotype class methods
to do this.
Makes these triples:
<MGI:genotypeid> GENO:has_reference_part <MGI:strainid>
<MGI:strainid> a GENO:genomic_background
If the genotyp... | [
"This",
"table",
"indicates",
"the",
"relationship",
"between",
"a",
"genotype",
"and",
"it",
"s",
"background",
"strain",
".",
"It",
"leverages",
"the",
"Genotype",
"class",
"methods",
"to",
"do",
"this",
"."
] | 24cc80db355bbe15776edc5c7b41e0886959ba41 | https://github.com/monarch-initiative/dipper/blob/24cc80db355bbe15776edc5c7b41e0886959ba41/dipper/sources/MGI.py#L335-L430 | train |
monarch-initiative/dipper | dipper/sources/MGI.py | MGI._process_gxd_genotype_summary_view | def _process_gxd_genotype_summary_view(self, limit=None):
"""
Add the genotype internal id to mgiid mapping to the idhashmap.
Also, add them as individuals to the graph.
We re-format the label to put the background strain in brackets
after the gvc.
We must pass through t... | python | def _process_gxd_genotype_summary_view(self, limit=None):
"""
Add the genotype internal id to mgiid mapping to the idhashmap.
Also, add them as individuals to the graph.
We re-format the label to put the background strain in brackets
after the gvc.
We must pass through t... | [
"def",
"_process_gxd_genotype_summary_view",
"(",
"self",
",",
"limit",
"=",
"None",
")",
":",
"if",
"self",
".",
"test_mode",
":",
"graph",
"=",
"self",
".",
"testgraph",
"else",
":",
"graph",
"=",
"self",
".",
"graph",
"model",
"=",
"Model",
"(",
"grap... | Add the genotype internal id to mgiid mapping to the idhashmap.
Also, add them as individuals to the graph.
We re-format the label to put the background strain in brackets
after the gvc.
We must pass through the file once to get the ids and
aggregate the vslcs into a hashmap int... | [
"Add",
"the",
"genotype",
"internal",
"id",
"to",
"mgiid",
"mapping",
"to",
"the",
"idhashmap",
".",
"Also",
"add",
"them",
"as",
"individuals",
"to",
"the",
"graph",
".",
"We",
"re",
"-",
"format",
"the",
"label",
"to",
"put",
"the",
"background",
"stra... | 24cc80db355bbe15776edc5c7b41e0886959ba41 | https://github.com/monarch-initiative/dipper/blob/24cc80db355bbe15776edc5c7b41e0886959ba41/dipper/sources/MGI.py#L432-L503 | train |
monarch-initiative/dipper | dipper/sources/MGI.py | MGI.process_mgi_relationship_transgene_genes | def process_mgi_relationship_transgene_genes(self, limit=None):
"""
Here, we have the relationship between MGI transgene alleles,
and the non-mouse gene ids that are part of them.
We augment the allele with the transgene parts.
:param limit:
:return:
"""
... | python | def process_mgi_relationship_transgene_genes(self, limit=None):
"""
Here, we have the relationship between MGI transgene alleles,
and the non-mouse gene ids that are part of them.
We augment the allele with the transgene parts.
:param limit:
:return:
"""
... | [
"def",
"process_mgi_relationship_transgene_genes",
"(",
"self",
",",
"limit",
"=",
"None",
")",
":",
"if",
"self",
".",
"test_mode",
":",
"graph",
"=",
"self",
".",
"testgraph",
"else",
":",
"graph",
"=",
"self",
".",
"graph",
"LOG",
".",
"info",
"(",
"\... | Here, we have the relationship between MGI transgene alleles,
and the non-mouse gene ids that are part of them.
We augment the allele with the transgene parts.
:param limit:
:return: | [
"Here",
"we",
"have",
"the",
"relationship",
"between",
"MGI",
"transgene",
"alleles",
"and",
"the",
"non",
"-",
"mouse",
"gene",
"ids",
"that",
"are",
"part",
"of",
"them",
".",
"We",
"augment",
"the",
"allele",
"with",
"the",
"transgene",
"parts",
"."
] | 24cc80db355bbe15776edc5c7b41e0886959ba41 | https://github.com/monarch-initiative/dipper/blob/24cc80db355bbe15776edc5c7b41e0886959ba41/dipper/sources/MGI.py#L1891-L1944 | train |
monarch-initiative/dipper | dipper/graph/RDFGraph.py | RDFGraph._getnode | def _getnode(self, curie): # convention is lowercase names
"""
This is a wrapper for creating a URIRef or Bnode object
with a given a curie or iri as a string.
If an id starts with an underscore, it assigns it to a BNode, otherwise
it creates it with a standard URIRef.
... | python | def _getnode(self, curie): # convention is lowercase names
"""
This is a wrapper for creating a URIRef or Bnode object
with a given a curie or iri as a string.
If an id starts with an underscore, it assigns it to a BNode, otherwise
it creates it with a standard URIRef.
... | [
"def",
"_getnode",
"(",
"self",
",",
"curie",
")",
":",
"node",
"=",
"None",
"if",
"curie",
"[",
"0",
"]",
"==",
"'_'",
":",
"if",
"self",
".",
"are_bnodes_skized",
"is",
"True",
":",
"node",
"=",
"self",
".",
"skolemizeBlankNode",
"(",
"curie",
")",... | This is a wrapper for creating a URIRef or Bnode object
with a given a curie or iri as a string.
If an id starts with an underscore, it assigns it to a BNode, otherwise
it creates it with a standard URIRef.
Alternatively, self.skolemize_blank_node is True,
it will skolemize the ... | [
"This",
"is",
"a",
"wrapper",
"for",
"creating",
"a",
"URIRef",
"or",
"Bnode",
"object",
"with",
"a",
"given",
"a",
"curie",
"or",
"iri",
"as",
"a",
"string",
"."
] | 24cc80db355bbe15776edc5c7b41e0886959ba41 | https://github.com/monarch-initiative/dipper/blob/24cc80db355bbe15776edc5c7b41e0886959ba41/dipper/graph/RDFGraph.py#L92-L126 | train |
monarch-initiative/dipper | dipper/models/assoc/D2PAssoc.py | D2PAssoc.add_association_to_graph | def add_association_to_graph(self):
"""
The reified relationship between a disease and a phenotype is decorated
with some provenance information.
This makes the assumption that both the disease and phenotype
are classes.
:param g:
:return:
"""
... | python | def add_association_to_graph(self):
"""
The reified relationship between a disease and a phenotype is decorated
with some provenance information.
This makes the assumption that both the disease and phenotype
are classes.
:param g:
:return:
"""
... | [
"def",
"add_association_to_graph",
"(",
"self",
")",
":",
"Assoc",
".",
"add_association_to_graph",
"(",
"self",
")",
"if",
"self",
".",
"onset",
"is",
"not",
"None",
"and",
"self",
".",
"onset",
"!=",
"''",
":",
"self",
".",
"graph",
".",
"addTriple",
"... | The reified relationship between a disease and a phenotype is decorated
with some provenance information.
This makes the assumption that both the disease and phenotype
are classes.
:param g:
:return: | [
"The",
"reified",
"relationship",
"between",
"a",
"disease",
"and",
"a",
"phenotype",
"is",
"decorated",
"with",
"some",
"provenance",
"information",
".",
"This",
"makes",
"the",
"assumption",
"that",
"both",
"the",
"disease",
"and",
"phenotype",
"are",
"classes... | 24cc80db355bbe15776edc5c7b41e0886959ba41 | https://github.com/monarch-initiative/dipper/blob/24cc80db355bbe15776edc5c7b41e0886959ba41/dipper/models/assoc/D2PAssoc.py#L50-L75 | train |
monarch-initiative/dipper | dipper/sources/Monochrom.py | Monochrom.make_parent_bands | def make_parent_bands(self, band, child_bands):
"""
this will determine the grouping bands that it belongs to, recursively
13q21.31 ==> 13, 13q, 13q2, 13q21, 13q21.3, 13q21.31
:param band:
:param child_bands:
:return:
"""
m = re.match(r'([pq][A-H\d]+(?:... | python | def make_parent_bands(self, band, child_bands):
"""
this will determine the grouping bands that it belongs to, recursively
13q21.31 ==> 13, 13q, 13q2, 13q21, 13q21.3, 13q21.31
:param band:
:param child_bands:
:return:
"""
m = re.match(r'([pq][A-H\d]+(?:... | [
"def",
"make_parent_bands",
"(",
"self",
",",
"band",
",",
"child_bands",
")",
":",
"m",
"=",
"re",
".",
"match",
"(",
"r'([pq][A-H\\d]+(?:\\.\\d+)?)'",
",",
"band",
")",
"if",
"len",
"(",
"band",
")",
">",
"0",
":",
"if",
"m",
":",
"p",
"=",
"str",
... | this will determine the grouping bands that it belongs to, recursively
13q21.31 ==> 13, 13q, 13q2, 13q21, 13q21.3, 13q21.31
:param band:
:param child_bands:
:return: | [
"this",
"will",
"determine",
"the",
"grouping",
"bands",
"that",
"it",
"belongs",
"to",
"recursively",
"13q21",
".",
"31",
"==",
">",
"13",
"13q",
"13q2",
"13q21",
"13q21",
".",
"3",
"13q21",
".",
"31"
] | 24cc80db355bbe15776edc5c7b41e0886959ba41 | https://github.com/monarch-initiative/dipper/blob/24cc80db355bbe15776edc5c7b41e0886959ba41/dipper/sources/Monochrom.py#L334-L354 | train |
monarch-initiative/dipper | dipper/utils/CurieUtil.py | CurieUtil.get_curie | def get_curie(self, uri):
'''Get a CURIE from a URI '''
prefix = self.get_curie_prefix(uri)
if prefix is not None:
key = self.curie_map[prefix]
return '%s:%s' % (prefix, uri[len(key):len(uri)])
return None | python | def get_curie(self, uri):
'''Get a CURIE from a URI '''
prefix = self.get_curie_prefix(uri)
if prefix is not None:
key = self.curie_map[prefix]
return '%s:%s' % (prefix, uri[len(key):len(uri)])
return None | [
"def",
"get_curie",
"(",
"self",
",",
"uri",
")",
":",
"prefix",
"=",
"self",
".",
"get_curie_prefix",
"(",
"uri",
")",
"if",
"prefix",
"is",
"not",
"None",
":",
"key",
"=",
"self",
".",
"curie_map",
"[",
"prefix",
"]",
"return",
"'%s:%s'",
"%",
"(",... | Get a CURIE from a URI | [
"Get",
"a",
"CURIE",
"from",
"a",
"URI"
] | 24cc80db355bbe15776edc5c7b41e0886959ba41 | https://github.com/monarch-initiative/dipper/blob/24cc80db355bbe15776edc5c7b41e0886959ba41/dipper/utils/CurieUtil.py#L31-L37 | train |
monarch-initiative/dipper | dipper/utils/CurieUtil.py | CurieUtil.get_uri | def get_uri(self, curie):
''' Get a URI from a CURIE '''
if curie is None:
return None
parts = curie.split(':')
if len(parts) == 1:
if curie != '':
LOG.error("Not a properly formed curie: \"%s\"", curie)
return None
prefix = par... | python | def get_uri(self, curie):
''' Get a URI from a CURIE '''
if curie is None:
return None
parts = curie.split(':')
if len(parts) == 1:
if curie != '':
LOG.error("Not a properly formed curie: \"%s\"", curie)
return None
prefix = par... | [
"def",
"get_uri",
"(",
"self",
",",
"curie",
")",
":",
"if",
"curie",
"is",
"None",
":",
"return",
"None",
"parts",
"=",
"curie",
".",
"split",
"(",
"':'",
")",
"if",
"len",
"(",
"parts",
")",
"==",
"1",
":",
"if",
"curie",
"!=",
"''",
":",
"LO... | Get a URI from a CURIE | [
"Get",
"a",
"URI",
"from",
"a",
"CURIE"
] | 24cc80db355bbe15776edc5c7b41e0886959ba41 | https://github.com/monarch-initiative/dipper/blob/24cc80db355bbe15776edc5c7b41e0886959ba41/dipper/utils/CurieUtil.py#L46-L60 | train |
monarch-initiative/dipper | dipper/sources/Coriell.py | Coriell.fetch | def fetch(self, is_dl_forced=False):
"""
Here we connect to the coriell sftp server using private connection
details. They dump bi-weekly files with a timestamp in the filename.
For each catalog, we ping the remote site and pull the most-recently
updated file, renaming it to our... | python | def fetch(self, is_dl_forced=False):
"""
Here we connect to the coriell sftp server using private connection
details. They dump bi-weekly files with a timestamp in the filename.
For each catalog, we ping the remote site and pull the most-recently
updated file, renaming it to our... | [
"def",
"fetch",
"(",
"self",
",",
"is_dl_forced",
"=",
"False",
")",
":",
"host",
"=",
"config",
".",
"get_config",
"(",
")",
"[",
"'dbauth'",
"]",
"[",
"'coriell'",
"]",
"[",
"'host'",
"]",
"key",
"=",
"config",
".",
"get_config",
"(",
")",
"[",
"... | Here we connect to the coriell sftp server using private connection
details. They dump bi-weekly files with a timestamp in the filename.
For each catalog, we ping the remote site and pull the most-recently
updated file, renaming it to our local latest.csv.
Be sure to have pg user/pass... | [
"Here",
"we",
"connect",
"to",
"the",
"coriell",
"sftp",
"server",
"using",
"private",
"connection",
"details",
".",
"They",
"dump",
"bi",
"-",
"weekly",
"files",
"with",
"a",
"timestamp",
"in",
"the",
"filename",
".",
"For",
"each",
"catalog",
"we",
"ping... | 24cc80db355bbe15776edc5c7b41e0886959ba41 | https://github.com/monarch-initiative/dipper/blob/24cc80db355bbe15776edc5c7b41e0886959ba41/dipper/sources/Coriell.py#L150-L224 | train |
monarch-initiative/dipper | dipper/sources/Coriell.py | Coriell._process_collection | def _process_collection(self, collection_id, label, page):
"""
This function will process the data supplied internally
about the repository from Coriell.
Triples:
Repository a ERO:collection
rdf:label Literal(label)
foaf:page Literal(page)
:p... | python | def _process_collection(self, collection_id, label, page):
"""
This function will process the data supplied internally
about the repository from Coriell.
Triples:
Repository a ERO:collection
rdf:label Literal(label)
foaf:page Literal(page)
:p... | [
"def",
"_process_collection",
"(",
"self",
",",
"collection_id",
",",
"label",
",",
"page",
")",
":",
"for",
"graph",
"in",
"[",
"self",
".",
"graph",
",",
"self",
".",
"testgraph",
"]",
":",
"model",
"=",
"Model",
"(",
"graph",
")",
"reference",
"=",
... | This function will process the data supplied internally
about the repository from Coriell.
Triples:
Repository a ERO:collection
rdf:label Literal(label)
foaf:page Literal(page)
:param collection_id:
:param label:
:param page:
:return: | [
"This",
"function",
"will",
"process",
"the",
"data",
"supplied",
"internally",
"about",
"the",
"repository",
"from",
"Coriell",
"."
] | 24cc80db355bbe15776edc5c7b41e0886959ba41 | https://github.com/monarch-initiative/dipper/blob/24cc80db355bbe15776edc5c7b41e0886959ba41/dipper/sources/Coriell.py#L760-L788 | train |
monarch-initiative/dipper | dipper/sources/FlyBase.py | FlyBase._process_genotypes | def _process_genotypes(self, limit):
"""
Add the genotype internal id to flybase mapping to the idhashmap.
Also, add them as individuals to the graph.
Triples created:
<genotype id> a GENO:intrinsic_genotype
<genotype id> rdfs:label "<gvc> [bkgd]"
:param limit:
... | python | def _process_genotypes(self, limit):
"""
Add the genotype internal id to flybase mapping to the idhashmap.
Also, add them as individuals to the graph.
Triples created:
<genotype id> a GENO:intrinsic_genotype
<genotype id> rdfs:label "<gvc> [bkgd]"
:param limit:
... | [
"def",
"_process_genotypes",
"(",
"self",
",",
"limit",
")",
":",
"if",
"self",
".",
"test_mode",
":",
"graph",
"=",
"self",
".",
"testgraph",
"else",
":",
"graph",
"=",
"self",
".",
"graph",
"model",
"=",
"Model",
"(",
"graph",
")",
"line_counter",
"=... | Add the genotype internal id to flybase mapping to the idhashmap.
Also, add them as individuals to the graph.
Triples created:
<genotype id> a GENO:intrinsic_genotype
<genotype id> rdfs:label "<gvc> [bkgd]"
:param limit:
:return: | [
"Add",
"the",
"genotype",
"internal",
"id",
"to",
"flybase",
"mapping",
"to",
"the",
"idhashmap",
".",
"Also",
"add",
"them",
"as",
"individuals",
"to",
"the",
"graph",
"."
] | 24cc80db355bbe15776edc5c7b41e0886959ba41 | https://github.com/monarch-initiative/dipper/blob/24cc80db355bbe15776edc5c7b41e0886959ba41/dipper/sources/FlyBase.py#L358-L423 | train |
monarch-initiative/dipper | dipper/sources/FlyBase.py | FlyBase._process_stocks | def _process_stocks(self, limit):
"""
Stock definitions.
Here we instantiate them as instances of the given taxon.
:param limit:
:return:
"""
if self.test_mode:
graph = self.testgraph
else:
graph = self.graph
model = Model... | python | def _process_stocks(self, limit):
"""
Stock definitions.
Here we instantiate them as instances of the given taxon.
:param limit:
:return:
"""
if self.test_mode:
graph = self.testgraph
else:
graph = self.graph
model = Model... | [
"def",
"_process_stocks",
"(",
"self",
",",
"limit",
")",
":",
"if",
"self",
".",
"test_mode",
":",
"graph",
"=",
"self",
".",
"testgraph",
"else",
":",
"graph",
"=",
"self",
".",
"graph",
"model",
"=",
"Model",
"(",
"graph",
")",
"line_counter",
"=",
... | Stock definitions.
Here we instantiate them as instances of the given taxon.
:param limit:
:return: | [
"Stock",
"definitions",
".",
"Here",
"we",
"instantiate",
"them",
"as",
"instances",
"of",
"the",
"given",
"taxon",
"."
] | 24cc80db355bbe15776edc5c7b41e0886959ba41 | https://github.com/monarch-initiative/dipper/blob/24cc80db355bbe15776edc5c7b41e0886959ba41/dipper/sources/FlyBase.py#L426-L480 | train |
monarch-initiative/dipper | dipper/sources/FlyBase.py | FlyBase._process_pubs | def _process_pubs(self, limit):
"""
Flybase publications.
:param limit:
:return:
"""
if self.test_mode:
graph = self.testgraph
else:
graph = self.graph
model = Model(graph)
line_counter = 0
raw = '/'.join((self.ra... | python | def _process_pubs(self, limit):
"""
Flybase publications.
:param limit:
:return:
"""
if self.test_mode:
graph = self.testgraph
else:
graph = self.graph
model = Model(graph)
line_counter = 0
raw = '/'.join((self.ra... | [
"def",
"_process_pubs",
"(",
"self",
",",
"limit",
")",
":",
"if",
"self",
".",
"test_mode",
":",
"graph",
"=",
"self",
".",
"testgraph",
"else",
":",
"graph",
"=",
"self",
".",
"graph",
"model",
"=",
"Model",
"(",
"graph",
")",
"line_counter",
"=",
... | Flybase publications.
:param limit:
:return: | [
"Flybase",
"publications",
"."
] | 24cc80db355bbe15776edc5c7b41e0886959ba41 | https://github.com/monarch-initiative/dipper/blob/24cc80db355bbe15776edc5c7b41e0886959ba41/dipper/sources/FlyBase.py#L483-L539 | train |
monarch-initiative/dipper | dipper/sources/FlyBase.py | FlyBase._process_environments | def _process_environments(self):
"""
There's only about 30 environments in which the phenotypes
are recorded.
There are no externally accessible identifiers for environments,
so we make anonymous nodes for now.
Some of the environments are comprised of >1 of the other env... | python | def _process_environments(self):
"""
There's only about 30 environments in which the phenotypes
are recorded.
There are no externally accessible identifiers for environments,
so we make anonymous nodes for now.
Some of the environments are comprised of >1 of the other env... | [
"def",
"_process_environments",
"(",
"self",
")",
":",
"if",
"self",
".",
"test_mode",
":",
"graph",
"=",
"self",
".",
"testgraph",
"else",
":",
"graph",
"=",
"self",
".",
"graph",
"raw",
"=",
"'/'",
".",
"join",
"(",
"(",
"self",
".",
"rawdir",
",",... | There's only about 30 environments in which the phenotypes
are recorded.
There are no externally accessible identifiers for environments,
so we make anonymous nodes for now.
Some of the environments are comprised of >1 of the other environments;
we do some simple parsing to match... | [
"There",
"s",
"only",
"about",
"30",
"environments",
"in",
"which",
"the",
"phenotypes",
"are",
"recorded",
".",
"There",
"are",
"no",
"externally",
"accessible",
"identifiers",
"for",
"environments",
"so",
"we",
"make",
"anonymous",
"nodes",
"for",
"now",
"."... | 24cc80db355bbe15776edc5c7b41e0886959ba41 | https://github.com/monarch-initiative/dipper/blob/24cc80db355bbe15776edc5c7b41e0886959ba41/dipper/sources/FlyBase.py#L542-L604 | train |
monarch-initiative/dipper | dipper/sources/FlyBase.py | FlyBase._process_stock_genotype | def _process_stock_genotype(self, limit):
"""
The genotypes of the stocks.
:param limit:
:return:
"""
if self.test_mode:
graph = self.testgraph
else:
graph = self.graph
raw = '/'.join((self.rawdir, 'stock_genotype'))
LOG.... | python | def _process_stock_genotype(self, limit):
"""
The genotypes of the stocks.
:param limit:
:return:
"""
if self.test_mode:
graph = self.testgraph
else:
graph = self.graph
raw = '/'.join((self.rawdir, 'stock_genotype'))
LOG.... | [
"def",
"_process_stock_genotype",
"(",
"self",
",",
"limit",
")",
":",
"if",
"self",
".",
"test_mode",
":",
"graph",
"=",
"self",
".",
"testgraph",
"else",
":",
"graph",
"=",
"self",
".",
"graph",
"raw",
"=",
"'/'",
".",
"join",
"(",
"(",
"self",
"."... | The genotypes of the stocks.
:param limit:
:return: | [
"The",
"genotypes",
"of",
"the",
"stocks",
"."
] | 24cc80db355bbe15776edc5c7b41e0886959ba41 | https://github.com/monarch-initiative/dipper/blob/24cc80db355bbe15776edc5c7b41e0886959ba41/dipper/sources/FlyBase.py#L926-L965 | train |
monarch-initiative/dipper | dipper/sources/FlyBase.py | FlyBase._process_dbxref | def _process_dbxref(self):
"""
We bring in the dbxref identifiers and store them in a hashmap for
lookup in other functions.
Note that some dbxrefs aren't mapped to identifiers.
For example, 5004018 is mapped to a string,
"endosome & imaginal disc epithelial cell | so... | python | def _process_dbxref(self):
"""
We bring in the dbxref identifiers and store them in a hashmap for
lookup in other functions.
Note that some dbxrefs aren't mapped to identifiers.
For example, 5004018 is mapped to a string,
"endosome & imaginal disc epithelial cell | so... | [
"def",
"_process_dbxref",
"(",
"self",
")",
":",
"raw",
"=",
"'/'",
".",
"join",
"(",
"(",
"self",
".",
"rawdir",
",",
"'dbxref'",
")",
")",
"LOG",
".",
"info",
"(",
"\"processing dbxrefs\"",
")",
"line_counter",
"=",
"0",
"with",
"open",
"(",
"raw",
... | We bring in the dbxref identifiers and store them in a hashmap for
lookup in other functions.
Note that some dbxrefs aren't mapped to identifiers.
For example, 5004018 is mapped to a string,
"endosome & imaginal disc epithelial cell | somatic clone..."
In those cases, there j... | [
"We",
"bring",
"in",
"the",
"dbxref",
"identifiers",
"and",
"store",
"them",
"in",
"a",
"hashmap",
"for",
"lookup",
"in",
"other",
"functions",
".",
"Note",
"that",
"some",
"dbxrefs",
"aren",
"t",
"mapped",
"to",
"identifiers",
".",
"For",
"example",
"5004... | 24cc80db355bbe15776edc5c7b41e0886959ba41 | https://github.com/monarch-initiative/dipper/blob/24cc80db355bbe15776edc5c7b41e0886959ba41/dipper/sources/FlyBase.py#L1033-L1103 | train |
monarch-initiative/dipper | dipper/sources/FlyBase.py | FlyBase._process_phenotype | def _process_phenotype(self, limit):
"""
Get the phenotypes, and declare the classes.
If the "observable" is "unspecified", then we assign the phenotype to
the "cvalue" id; otherwise we convert the phenotype into a
uberpheno-style identifier, simply based on the anatomical part t... | python | def _process_phenotype(self, limit):
"""
Get the phenotypes, and declare the classes.
If the "observable" is "unspecified", then we assign the phenotype to
the "cvalue" id; otherwise we convert the phenotype into a
uberpheno-style identifier, simply based on the anatomical part t... | [
"def",
"_process_phenotype",
"(",
"self",
",",
"limit",
")",
":",
"if",
"self",
".",
"test_mode",
":",
"graph",
"=",
"self",
".",
"testgraph",
"else",
":",
"graph",
"=",
"self",
".",
"graph",
"model",
"=",
"Model",
"(",
"graph",
")",
"raw",
"=",
"'/'... | Get the phenotypes, and declare the classes.
If the "observable" is "unspecified", then we assign the phenotype to
the "cvalue" id; otherwise we convert the phenotype into a
uberpheno-style identifier, simply based on the anatomical part that's
affected...that is listed as the observable... | [
"Get",
"the",
"phenotypes",
"and",
"declare",
"the",
"classes",
".",
"If",
"the",
"observable",
"is",
"unspecified",
"then",
"we",
"assign",
"the",
"phenotype",
"to",
"the",
"cvalue",
"id",
";",
"otherwise",
"we",
"convert",
"the",
"phenotype",
"into",
"a",
... | 24cc80db355bbe15776edc5c7b41e0886959ba41 | https://github.com/monarch-initiative/dipper/blob/24cc80db355bbe15776edc5c7b41e0886959ba41/dipper/sources/FlyBase.py#L1105-L1195 | train |
monarch-initiative/dipper | dipper/sources/FlyBase.py | FlyBase._process_cvterm | def _process_cvterm(self):
"""
CVterms are the internal identifiers for any controlled vocab
or ontology term. Many are xrefd to actual ontologies. The actual
external id is stored in the dbxref table, which we place into
the internal hashmap for lookup with the cvterm id. The... | python | def _process_cvterm(self):
"""
CVterms are the internal identifiers for any controlled vocab
or ontology term. Many are xrefd to actual ontologies. The actual
external id is stored in the dbxref table, which we place into
the internal hashmap for lookup with the cvterm id. The... | [
"def",
"_process_cvterm",
"(",
"self",
")",
":",
"line_counter",
"=",
"0",
"raw",
"=",
"'/'",
".",
"join",
"(",
"(",
"self",
".",
"rawdir",
",",
"'cvterm'",
")",
")",
"LOG",
".",
"info",
"(",
"\"processing cvterms\"",
")",
"with",
"open",
"(",
"raw",
... | CVterms are the internal identifiers for any controlled vocab
or ontology term. Many are xrefd to actual ontologies. The actual
external id is stored in the dbxref table, which we place into
the internal hashmap for lookup with the cvterm id. The name of
the external term is stored in... | [
"CVterms",
"are",
"the",
"internal",
"identifiers",
"for",
"any",
"controlled",
"vocab",
"or",
"ontology",
"term",
".",
"Many",
"are",
"xrefd",
"to",
"actual",
"ontologies",
".",
"The",
"actual",
"external",
"id",
"is",
"stored",
"in",
"the",
"dbxref",
"tabl... | 24cc80db355bbe15776edc5c7b41e0886959ba41 | https://github.com/monarch-initiative/dipper/blob/24cc80db355bbe15776edc5c7b41e0886959ba41/dipper/sources/FlyBase.py#L1324-L1389 | train |
monarch-initiative/dipper | dipper/sources/FlyBase.py | FlyBase._process_organisms | def _process_organisms(self, limit):
"""
The internal identifiers for the organisms in flybase
:param limit:
:return:
"""
if self.test_mode:
graph = self.testgraph
else:
graph = self.graph
model = Model(graph)
raw = '/'.j... | python | def _process_organisms(self, limit):
"""
The internal identifiers for the organisms in flybase
:param limit:
:return:
"""
if self.test_mode:
graph = self.testgraph
else:
graph = self.graph
model = Model(graph)
raw = '/'.j... | [
"def",
"_process_organisms",
"(",
"self",
",",
"limit",
")",
":",
"if",
"self",
".",
"test_mode",
":",
"graph",
"=",
"self",
".",
"testgraph",
"else",
":",
"graph",
"=",
"self",
".",
"graph",
"model",
"=",
"Model",
"(",
"graph",
")",
"raw",
"=",
"'/'... | The internal identifiers for the organisms in flybase
:param limit:
:return: | [
"The",
"internal",
"identifiers",
"for",
"the",
"organisms",
"in",
"flybase"
] | 24cc80db355bbe15776edc5c7b41e0886959ba41 | https://github.com/monarch-initiative/dipper/blob/24cc80db355bbe15776edc5c7b41e0886959ba41/dipper/sources/FlyBase.py#L1792-L1844 | train |
monarch-initiative/dipper | dipper/sources/NCBIGene.py | NCBIGene._add_gene_equivalencies | def _add_gene_equivalencies(self, xrefs, gene_id, taxon):
"""
Add equivalentClass and sameAs relationships
Uses external resource map located in
/resources/clique_leader.yaml to determine
if an NCBITaxon ID space is a clique leader
"""
clique_map = self.open_and... | python | def _add_gene_equivalencies(self, xrefs, gene_id, taxon):
"""
Add equivalentClass and sameAs relationships
Uses external resource map located in
/resources/clique_leader.yaml to determine
if an NCBITaxon ID space is a clique leader
"""
clique_map = self.open_and... | [
"def",
"_add_gene_equivalencies",
"(",
"self",
",",
"xrefs",
",",
"gene_id",
",",
"taxon",
")",
":",
"clique_map",
"=",
"self",
".",
"open_and_parse_yaml",
"(",
"self",
".",
"resources",
"[",
"'clique_leader'",
"]",
")",
"if",
"self",
".",
"test_mode",
":",
... | Add equivalentClass and sameAs relationships
Uses external resource map located in
/resources/clique_leader.yaml to determine
if an NCBITaxon ID space is a clique leader | [
"Add",
"equivalentClass",
"and",
"sameAs",
"relationships"
] | 24cc80db355bbe15776edc5c7b41e0886959ba41 | https://github.com/monarch-initiative/dipper/blob/24cc80db355bbe15776edc5c7b41e0886959ba41/dipper/sources/NCBIGene.py#L377-L430 | train |
monarch-initiative/dipper | dipper/sources/NCBIGene.py | NCBIGene._get_gene2pubmed | def _get_gene2pubmed(self, limit):
"""
Loops through the gene2pubmed file and adds a simple triple to say
that a given publication is_about a gene.
Publications are added as NamedIndividuals.
These are filtered on the taxon.
:param limit:
:return:
"""
... | python | def _get_gene2pubmed(self, limit):
"""
Loops through the gene2pubmed file and adds a simple triple to say
that a given publication is_about a gene.
Publications are added as NamedIndividuals.
These are filtered on the taxon.
:param limit:
:return:
"""
... | [
"def",
"_get_gene2pubmed",
"(",
"self",
",",
"limit",
")",
":",
"src_key",
"=",
"'gene2pubmed'",
"if",
"self",
".",
"test_mode",
":",
"graph",
"=",
"self",
".",
"testgraph",
"else",
":",
"graph",
"=",
"self",
".",
"graph",
"model",
"=",
"Model",
"(",
"... | Loops through the gene2pubmed file and adds a simple triple to say
that a given publication is_about a gene.
Publications are added as NamedIndividuals.
These are filtered on the taxon.
:param limit:
:return: | [
"Loops",
"through",
"the",
"gene2pubmed",
"file",
"and",
"adds",
"a",
"simple",
"triple",
"to",
"say",
"that",
"a",
"given",
"publication",
"is_about",
"a",
"gene",
".",
"Publications",
"are",
"added",
"as",
"NamedIndividuals",
"."
] | 24cc80db355bbe15776edc5c7b41e0886959ba41 | https://github.com/monarch-initiative/dipper/blob/24cc80db355bbe15776edc5c7b41e0886959ba41/dipper/sources/NCBIGene.py#L516-L598 | train |
monarch-initiative/dipper | dipper/sources/OMIM.py | OMIM.process_entries | def process_entries(
self, omimids, transform, included_fields=None, graph=None, limit=None,
globaltt=None
):
"""
Given a list of omim ids,
this will use the omim API to fetch the entries, according to the
```included_fields``` passed as a parameter.
I... | python | def process_entries(
self, omimids, transform, included_fields=None, graph=None, limit=None,
globaltt=None
):
"""
Given a list of omim ids,
this will use the omim API to fetch the entries, according to the
```included_fields``` passed as a parameter.
I... | [
"def",
"process_entries",
"(",
"self",
",",
"omimids",
",",
"transform",
",",
"included_fields",
"=",
"None",
",",
"graph",
"=",
"None",
",",
"limit",
"=",
"None",
",",
"globaltt",
"=",
"None",
")",
":",
"omimparams",
"=",
"{",
"}",
"if",
"included_field... | Given a list of omim ids,
this will use the omim API to fetch the entries, according to the
```included_fields``` passed as a parameter.
If a transformation function is supplied,
this will iterate over each entry,
and either add the results to the supplied ```graph```
or ... | [
"Given",
"a",
"list",
"of",
"omim",
"ids",
"this",
"will",
"use",
"the",
"omim",
"API",
"to",
"fetch",
"the",
"entries",
"according",
"to",
"the",
"included_fields",
"passed",
"as",
"a",
"parameter",
".",
"If",
"a",
"transformation",
"function",
"is",
"sup... | 24cc80db355bbe15776edc5c7b41e0886959ba41 | https://github.com/monarch-initiative/dipper/blob/24cc80db355bbe15776edc5c7b41e0886959ba41/dipper/sources/OMIM.py#L253-L367 | train |
monarch-initiative/dipper | dipper/sources/OMIM.py | OMIM._process_all | def _process_all(self, limit):
"""
This takes the list of omim identifiers from the omim.txt.Z file,
and iteratively queries the omim api for the json-formatted data.
This will create OMIM classes, with the label,
definition, and some synonyms.
If an entry is "removed",
... | python | def _process_all(self, limit):
"""
This takes the list of omim identifiers from the omim.txt.Z file,
and iteratively queries the omim api for the json-formatted data.
This will create OMIM classes, with the label,
definition, and some synonyms.
If an entry is "removed",
... | [
"def",
"_process_all",
"(",
"self",
",",
"limit",
")",
":",
"omimids",
"=",
"self",
".",
"_get_omim_ids",
"(",
")",
"LOG",
".",
"info",
"(",
"'Have %i omim numbers to fetch records from their API'",
",",
"len",
"(",
"omimids",
")",
")",
"LOG",
".",
"info",
"... | This takes the list of omim identifiers from the omim.txt.Z file,
and iteratively queries the omim api for the json-formatted data.
This will create OMIM classes, with the label,
definition, and some synonyms.
If an entry is "removed",
it is added as a deprecated class.
... | [
"This",
"takes",
"the",
"list",
"of",
"omim",
"identifiers",
"from",
"the",
"omim",
".",
"txt",
".",
"Z",
"file",
"and",
"iteratively",
"queries",
"the",
"omim",
"api",
"for",
"the",
"json",
"-",
"formatted",
"data",
".",
"This",
"will",
"create",
"OMIM"... | 24cc80db355bbe15776edc5c7b41e0886959ba41 | https://github.com/monarch-initiative/dipper/blob/24cc80db355bbe15776edc5c7b41e0886959ba41/dipper/sources/OMIM.py#L369-L412 | train |
ethereum/py-trie | trie/smt.py | SparseMerkleProof.update | def update(self, key: bytes, value: bytes, node_updates: Sequence[Hash32]):
"""
Merge an update for another key with the one we are tracking internally.
:param key: keypath of the update we are processing
:param value: value of the update we are processing
:param node_updates: s... | python | def update(self, key: bytes, value: bytes, node_updates: Sequence[Hash32]):
"""
Merge an update for another key with the one we are tracking internally.
:param key: keypath of the update we are processing
:param value: value of the update we are processing
:param node_updates: s... | [
"def",
"update",
"(",
"self",
",",
"key",
":",
"bytes",
",",
"value",
":",
"bytes",
",",
"node_updates",
":",
"Sequence",
"[",
"Hash32",
"]",
")",
":",
"validate_is_bytes",
"(",
"key",
")",
"validate_length",
"(",
"key",
",",
"self",
".",
"_key_size",
... | Merge an update for another key with the one we are tracking internally.
:param key: keypath of the update we are processing
:param value: value of the update we are processing
:param node_updates: sequence of sibling nodes (in root->leaf order)
must be at least as ... | [
"Merge",
"an",
"update",
"for",
"another",
"key",
"with",
"the",
"one",
"we",
"are",
"tracking",
"internally",
"."
] | d33108d21b54d59ee311f61d978496c84a6f1f8b | https://github.com/ethereum/py-trie/blob/d33108d21b54d59ee311f61d978496c84a6f1f8b/trie/smt.py#L144-L186 | train |
ethereum/py-trie | trie/smt.py | SparseMerkleTree._get | def _get(self, key: bytes) -> Tuple[bytes, Tuple[Hash32]]:
"""
Returns db value and branch in root->leaf order
"""
validate_is_bytes(key)
validate_length(key, self._key_size)
branch = []
target_bit = 1 << (self.depth - 1)
path = to_int(key)
node_h... | python | def _get(self, key: bytes) -> Tuple[bytes, Tuple[Hash32]]:
"""
Returns db value and branch in root->leaf order
"""
validate_is_bytes(key)
validate_length(key, self._key_size)
branch = []
target_bit = 1 << (self.depth - 1)
path = to_int(key)
node_h... | [
"def",
"_get",
"(",
"self",
",",
"key",
":",
"bytes",
")",
"->",
"Tuple",
"[",
"bytes",
",",
"Tuple",
"[",
"Hash32",
"]",
"]",
":",
"validate_is_bytes",
"(",
"key",
")",
"validate_length",
"(",
"key",
",",
"self",
".",
"_key_size",
")",
"branch",
"="... | Returns db value and branch in root->leaf order | [
"Returns",
"db",
"value",
"and",
"branch",
"in",
"root",
"-",
">",
"leaf",
"order"
] | d33108d21b54d59ee311f61d978496c84a6f1f8b | https://github.com/ethereum/py-trie/blob/d33108d21b54d59ee311f61d978496c84a6f1f8b/trie/smt.py#L271-L297 | train |
ethereum/py-trie | trie/smt.py | SparseMerkleTree.set | def set(self, key: bytes, value: bytes) -> Tuple[Hash32]:
"""
Returns all updated hashes in root->leaf order
"""
validate_is_bytes(key)
validate_length(key, self._key_size)
validate_is_bytes(value)
path = to_int(key)
node = value
_, branch = self.... | python | def set(self, key: bytes, value: bytes) -> Tuple[Hash32]:
"""
Returns all updated hashes in root->leaf order
"""
validate_is_bytes(key)
validate_length(key, self._key_size)
validate_is_bytes(value)
path = to_int(key)
node = value
_, branch = self.... | [
"def",
"set",
"(",
"self",
",",
"key",
":",
"bytes",
",",
"value",
":",
"bytes",
")",
"->",
"Tuple",
"[",
"Hash32",
"]",
":",
"validate_is_bytes",
"(",
"key",
")",
"validate_length",
"(",
"key",
",",
"self",
".",
"_key_size",
")",
"validate_is_bytes",
... | Returns all updated hashes in root->leaf order | [
"Returns",
"all",
"updated",
"hashes",
"in",
"root",
"-",
">",
"leaf",
"order"
] | d33108d21b54d59ee311f61d978496c84a6f1f8b | https://github.com/ethereum/py-trie/blob/d33108d21b54d59ee311f61d978496c84a6f1f8b/trie/smt.py#L299-L333 | train |
ethereum/py-trie | trie/smt.py | SparseMerkleTree.delete | def delete(self, key: bytes) -> Tuple[Hash32]:
"""
Equals to setting the value to None
Returns all updated hashes in root->leaf order
"""
validate_is_bytes(key)
validate_length(key, self._key_size)
return self.set(key, self._default) | python | def delete(self, key: bytes) -> Tuple[Hash32]:
"""
Equals to setting the value to None
Returns all updated hashes in root->leaf order
"""
validate_is_bytes(key)
validate_length(key, self._key_size)
return self.set(key, self._default) | [
"def",
"delete",
"(",
"self",
",",
"key",
":",
"bytes",
")",
"->",
"Tuple",
"[",
"Hash32",
"]",
":",
"validate_is_bytes",
"(",
"key",
")",
"validate_length",
"(",
"key",
",",
"self",
".",
"_key_size",
")",
"return",
"self",
".",
"set",
"(",
"key",
",... | Equals to setting the value to None
Returns all updated hashes in root->leaf order | [
"Equals",
"to",
"setting",
"the",
"value",
"to",
"None",
"Returns",
"all",
"updated",
"hashes",
"in",
"root",
"-",
">",
"leaf",
"order"
] | d33108d21b54d59ee311f61d978496c84a6f1f8b | https://github.com/ethereum/py-trie/blob/d33108d21b54d59ee311f61d978496c84a6f1f8b/trie/smt.py#L345-L353 | train |
ethereum/py-trie | trie/sync.py | HexaryTrieSync.next_batch | def next_batch(self, n=1):
"""Return the next requests that should be dispatched."""
if len(self.queue) == 0:
return []
batch = list(reversed((self.queue[-n:])))
self.queue = self.queue[:-n]
return batch | python | def next_batch(self, n=1):
"""Return the next requests that should be dispatched."""
if len(self.queue) == 0:
return []
batch = list(reversed((self.queue[-n:])))
self.queue = self.queue[:-n]
return batch | [
"def",
"next_batch",
"(",
"self",
",",
"n",
"=",
"1",
")",
":",
"if",
"len",
"(",
"self",
".",
"queue",
")",
"==",
"0",
":",
"return",
"[",
"]",
"batch",
"=",
"list",
"(",
"reversed",
"(",
"(",
"self",
".",
"queue",
"[",
"-",
"n",
":",
"]",
... | Return the next requests that should be dispatched. | [
"Return",
"the",
"next",
"requests",
"that",
"should",
"be",
"dispatched",
"."
] | d33108d21b54d59ee311f61d978496c84a6f1f8b | https://github.com/ethereum/py-trie/blob/d33108d21b54d59ee311f61d978496c84a6f1f8b/trie/sync.py#L120-L126 | train |
ethereum/py-trie | trie/sync.py | HexaryTrieSync.schedule | def schedule(self, node_key, parent, depth, leaf_callback, is_raw=False):
"""Schedule a request for the node with the given key."""
if node_key in self._existing_nodes:
self.logger.debug("Node %s already exists in db" % encode_hex(node_key))
return
if node_key in self.db... | python | def schedule(self, node_key, parent, depth, leaf_callback, is_raw=False):
"""Schedule a request for the node with the given key."""
if node_key in self._existing_nodes:
self.logger.debug("Node %s already exists in db" % encode_hex(node_key))
return
if node_key in self.db... | [
"def",
"schedule",
"(",
"self",
",",
"node_key",
",",
"parent",
",",
"depth",
",",
"leaf_callback",
",",
"is_raw",
"=",
"False",
")",
":",
"if",
"node_key",
"in",
"self",
".",
"_existing_nodes",
":",
"self",
".",
"logger",
".",
"debug",
"(",
"\"Node %s a... | Schedule a request for the node with the given key. | [
"Schedule",
"a",
"request",
"for",
"the",
"node",
"with",
"the",
"given",
"key",
"."
] | d33108d21b54d59ee311f61d978496c84a6f1f8b | https://github.com/ethereum/py-trie/blob/d33108d21b54d59ee311f61d978496c84a6f1f8b/trie/sync.py#L128-L155 | train |
ethereum/py-trie | trie/sync.py | HexaryTrieSync.get_children | def get_children(self, request):
"""Return all children of the node retrieved by the given request.
:rtype: A two-tuple with one list containing the children that reference other nodes and
another containing the leaf children.
"""
node = decode_node(request.data)
return ... | python | def get_children(self, request):
"""Return all children of the node retrieved by the given request.
:rtype: A two-tuple with one list containing the children that reference other nodes and
another containing the leaf children.
"""
node = decode_node(request.data)
return ... | [
"def",
"get_children",
"(",
"self",
",",
"request",
")",
":",
"node",
"=",
"decode_node",
"(",
"request",
".",
"data",
")",
"return",
"_get_children",
"(",
"node",
",",
"request",
".",
"depth",
")"
] | Return all children of the node retrieved by the given request.
:rtype: A two-tuple with one list containing the children that reference other nodes and
another containing the leaf children. | [
"Return",
"all",
"children",
"of",
"the",
"node",
"retrieved",
"by",
"the",
"given",
"request",
"."
] | d33108d21b54d59ee311f61d978496c84a6f1f8b | https://github.com/ethereum/py-trie/blob/d33108d21b54d59ee311f61d978496c84a6f1f8b/trie/sync.py#L157-L164 | train |
ethereum/py-trie | trie/sync.py | HexaryTrieSync.process | def process(self, results):
"""Process request results.
:param results: A list of two-tuples containing the node's key and data.
"""
for node_key, data in results:
request = self.requests.get(node_key)
if request is None:
# This may happen if we r... | python | def process(self, results):
"""Process request results.
:param results: A list of two-tuples containing the node's key and data.
"""
for node_key, data in results:
request = self.requests.get(node_key)
if request is None:
# This may happen if we r... | [
"def",
"process",
"(",
"self",
",",
"results",
")",
":",
"for",
"node_key",
",",
"data",
"in",
"results",
":",
"request",
"=",
"self",
".",
"requests",
".",
"get",
"(",
"node_key",
")",
"if",
"request",
"is",
"None",
":",
"self",
".",
"logger",
".",
... | Process request results.
:param results: A list of two-tuples containing the node's key and data. | [
"Process",
"request",
"results",
"."
] | d33108d21b54d59ee311f61d978496c84a6f1f8b | https://github.com/ethereum/py-trie/blob/d33108d21b54d59ee311f61d978496c84a6f1f8b/trie/sync.py#L166-L199 | train |
ethereum/py-trie | trie/branches.py | check_if_branch_exist | def check_if_branch_exist(db, root_hash, key_prefix):
"""
Given a key prefix, return whether this prefix is
the prefix of an existing key in the trie.
"""
validate_is_bytes(key_prefix)
return _check_if_branch_exist(db, root_hash, encode_to_bin(key_prefix)) | python | def check_if_branch_exist(db, root_hash, key_prefix):
"""
Given a key prefix, return whether this prefix is
the prefix of an existing key in the trie.
"""
validate_is_bytes(key_prefix)
return _check_if_branch_exist(db, root_hash, encode_to_bin(key_prefix)) | [
"def",
"check_if_branch_exist",
"(",
"db",
",",
"root_hash",
",",
"key_prefix",
")",
":",
"validate_is_bytes",
"(",
"key_prefix",
")",
"return",
"_check_if_branch_exist",
"(",
"db",
",",
"root_hash",
",",
"encode_to_bin",
"(",
"key_prefix",
")",
")"
] | Given a key prefix, return whether this prefix is
the prefix of an existing key in the trie. | [
"Given",
"a",
"key",
"prefix",
"return",
"whether",
"this",
"prefix",
"is",
"the",
"prefix",
"of",
"an",
"existing",
"key",
"in",
"the",
"trie",
"."
] | d33108d21b54d59ee311f61d978496c84a6f1f8b | https://github.com/ethereum/py-trie/blob/d33108d21b54d59ee311f61d978496c84a6f1f8b/trie/branches.py#L30-L37 | train |
ethereum/py-trie | trie/branches.py | get_branch | def get_branch(db, root_hash, key):
"""
Get a long-format Merkle branch
"""
validate_is_bytes(key)
return tuple(_get_branch(db, root_hash, encode_to_bin(key))) | python | def get_branch(db, root_hash, key):
"""
Get a long-format Merkle branch
"""
validate_is_bytes(key)
return tuple(_get_branch(db, root_hash, encode_to_bin(key))) | [
"def",
"get_branch",
"(",
"db",
",",
"root_hash",
",",
"key",
")",
":",
"validate_is_bytes",
"(",
"key",
")",
"return",
"tuple",
"(",
"_get_branch",
"(",
"db",
",",
"root_hash",
",",
"encode_to_bin",
"(",
"key",
")",
")",
")"
] | Get a long-format Merkle branch | [
"Get",
"a",
"long",
"-",
"format",
"Merkle",
"branch"
] | d33108d21b54d59ee311f61d978496c84a6f1f8b | https://github.com/ethereum/py-trie/blob/d33108d21b54d59ee311f61d978496c84a6f1f8b/trie/branches.py#L71-L77 | train |
ethereum/py-trie | trie/branches.py | get_witness_for_key_prefix | def get_witness_for_key_prefix(db, node_hash, key):
"""
Get all witness given a keypath prefix.
Include
1. witness along the keypath and
2. witness in the subtrie of the last node in keypath
"""
validate_is_bytes(key)
return tuple(_get_witness_for_key_prefix(db, node_hash, encode_to_bi... | python | def get_witness_for_key_prefix(db, node_hash, key):
"""
Get all witness given a keypath prefix.
Include
1. witness along the keypath and
2. witness in the subtrie of the last node in keypath
"""
validate_is_bytes(key)
return tuple(_get_witness_for_key_prefix(db, node_hash, encode_to_bi... | [
"def",
"get_witness_for_key_prefix",
"(",
"db",
",",
"node_hash",
",",
"key",
")",
":",
"validate_is_bytes",
"(",
"key",
")",
"return",
"tuple",
"(",
"_get_witness_for_key_prefix",
"(",
"db",
",",
"node_hash",
",",
"encode_to_bin",
"(",
"key",
")",
")",
")"
] | Get all witness given a keypath prefix.
Include
1. witness along the keypath and
2. witness in the subtrie of the last node in keypath | [
"Get",
"all",
"witness",
"given",
"a",
"keypath",
"prefix",
".",
"Include"
] | d33108d21b54d59ee311f61d978496c84a6f1f8b | https://github.com/ethereum/py-trie/blob/d33108d21b54d59ee311f61d978496c84a6f1f8b/trie/branches.py#L155-L165 | train |
ethereum/py-trie | trie/utils/nodes.py | encode_branch_node | def encode_branch_node(left_child_node_hash, right_child_node_hash):
"""
Serializes a branch node
"""
validate_is_bytes(left_child_node_hash)
validate_length(left_child_node_hash, 32)
validate_is_bytes(right_child_node_hash)
validate_length(right_child_node_hash, 32)
return BRANCH_TYPE_P... | python | def encode_branch_node(left_child_node_hash, right_child_node_hash):
"""
Serializes a branch node
"""
validate_is_bytes(left_child_node_hash)
validate_length(left_child_node_hash, 32)
validate_is_bytes(right_child_node_hash)
validate_length(right_child_node_hash, 32)
return BRANCH_TYPE_P... | [
"def",
"encode_branch_node",
"(",
"left_child_node_hash",
",",
"right_child_node_hash",
")",
":",
"validate_is_bytes",
"(",
"left_child_node_hash",
")",
"validate_length",
"(",
"left_child_node_hash",
",",
"32",
")",
"validate_is_bytes",
"(",
"right_child_node_hash",
")",
... | Serializes a branch node | [
"Serializes",
"a",
"branch",
"node"
] | d33108d21b54d59ee311f61d978496c84a6f1f8b | https://github.com/ethereum/py-trie/blob/d33108d21b54d59ee311f61d978496c84a6f1f8b/trie/utils/nodes.py#L157-L165 | train |
ethereum/py-trie | trie/utils/nodes.py | encode_leaf_node | def encode_leaf_node(value):
"""
Serializes a leaf node
"""
validate_is_bytes(value)
if value is None or value == b'':
raise ValidationError("Value of leaf node can not be empty")
return LEAF_TYPE_PREFIX + value | python | def encode_leaf_node(value):
"""
Serializes a leaf node
"""
validate_is_bytes(value)
if value is None or value == b'':
raise ValidationError("Value of leaf node can not be empty")
return LEAF_TYPE_PREFIX + value | [
"def",
"encode_leaf_node",
"(",
"value",
")",
":",
"validate_is_bytes",
"(",
"value",
")",
"if",
"value",
"is",
"None",
"or",
"value",
"==",
"b''",
":",
"raise",
"ValidationError",
"(",
"\"Value of leaf node can not be empty\"",
")",
"return",
"LEAF_TYPE_PREFIX",
... | Serializes a leaf node | [
"Serializes",
"a",
"leaf",
"node"
] | d33108d21b54d59ee311f61d978496c84a6f1f8b | https://github.com/ethereum/py-trie/blob/d33108d21b54d59ee311f61d978496c84a6f1f8b/trie/utils/nodes.py#L168-L175 | train |
ethereum/py-trie | trie/utils/db.py | ScratchDB.batch_commit | def batch_commit(self, *, do_deletes=False):
'''
Batch and commit and end of context
'''
try:
yield
except Exception as exc:
raise exc
else:
for key, value in self.cache.items():
if value is not DELETED:
... | python | def batch_commit(self, *, do_deletes=False):
'''
Batch and commit and end of context
'''
try:
yield
except Exception as exc:
raise exc
else:
for key, value in self.cache.items():
if value is not DELETED:
... | [
"def",
"batch_commit",
"(",
"self",
",",
"*",
",",
"do_deletes",
"=",
"False",
")",
":",
"try",
":",
"yield",
"except",
"Exception",
"as",
"exc",
":",
"raise",
"exc",
"else",
":",
"for",
"key",
",",
"value",
"in",
"self",
".",
"cache",
".",
"items",
... | Batch and commit and end of context | [
"Batch",
"and",
"commit",
"and",
"end",
"of",
"context"
] | d33108d21b54d59ee311f61d978496c84a6f1f8b | https://github.com/ethereum/py-trie/blob/d33108d21b54d59ee311f61d978496c84a6f1f8b/trie/utils/db.py#L48-L64 | train |
ethereum/py-trie | trie/hexary.py | HexaryTrie._prune_node | def _prune_node(self, node):
"""
Prune the given node if context exits cleanly.
"""
if self.is_pruning:
# node is mutable, so capture the key for later pruning now
prune_key, node_body = self._node_to_db_mapping(node)
should_prune = (node_body is not N... | python | def _prune_node(self, node):
"""
Prune the given node if context exits cleanly.
"""
if self.is_pruning:
# node is mutable, so capture the key for later pruning now
prune_key, node_body = self._node_to_db_mapping(node)
should_prune = (node_body is not N... | [
"def",
"_prune_node",
"(",
"self",
",",
"node",
")",
":",
"if",
"self",
".",
"is_pruning",
":",
"prune_key",
",",
"node_body",
"=",
"self",
".",
"_node_to_db_mapping",
"(",
"node",
")",
"should_prune",
"=",
"(",
"node_body",
"is",
"not",
"None",
")",
"el... | Prune the given node if context exits cleanly. | [
"Prune",
"the",
"given",
"node",
"if",
"context",
"exits",
"cleanly",
"."
] | d33108d21b54d59ee311f61d978496c84a6f1f8b | https://github.com/ethereum/py-trie/blob/d33108d21b54d59ee311f61d978496c84a6f1f8b/trie/hexary.py#L231-L246 | train |
ethereum/py-trie | trie/hexary.py | HexaryTrie._normalize_branch_node | def _normalize_branch_node(self, node):
"""
A branch node which is left with only a single non-blank item should be
turned into either a leaf or extension node.
"""
iter_node = iter(node)
if any(iter_node) and any(iter_node):
return node
if node[16]:
... | python | def _normalize_branch_node(self, node):
"""
A branch node which is left with only a single non-blank item should be
turned into either a leaf or extension node.
"""
iter_node = iter(node)
if any(iter_node) and any(iter_node):
return node
if node[16]:
... | [
"def",
"_normalize_branch_node",
"(",
"self",
",",
"node",
")",
":",
"iter_node",
"=",
"iter",
"(",
"node",
")",
"if",
"any",
"(",
"iter_node",
")",
"and",
"any",
"(",
"iter_node",
")",
":",
"return",
"node",
"if",
"node",
"[",
"16",
"]",
":",
"retur... | A branch node which is left with only a single non-blank item should be
turned into either a leaf or extension node. | [
"A",
"branch",
"node",
"which",
"is",
"left",
"with",
"only",
"a",
"single",
"non",
"-",
"blank",
"item",
"should",
"be",
"turned",
"into",
"either",
"a",
"leaf",
"or",
"extension",
"node",
"."
] | d33108d21b54d59ee311f61d978496c84a6f1f8b | https://github.com/ethereum/py-trie/blob/d33108d21b54d59ee311f61d978496c84a6f1f8b/trie/hexary.py#L324-L356 | train |
ethereum/py-trie | trie/hexary.py | HexaryTrie._delete_branch_node | def _delete_branch_node(self, node, trie_key):
"""
Delete a key from inside or underneath a branch node
"""
if not trie_key:
node[-1] = BLANK_NODE
return self._normalize_branch_node(node)
node_to_delete = self.get_node(node[trie_key[0]])
sub_node... | python | def _delete_branch_node(self, node, trie_key):
"""
Delete a key from inside or underneath a branch node
"""
if not trie_key:
node[-1] = BLANK_NODE
return self._normalize_branch_node(node)
node_to_delete = self.get_node(node[trie_key[0]])
sub_node... | [
"def",
"_delete_branch_node",
"(",
"self",
",",
"node",
",",
"trie_key",
")",
":",
"if",
"not",
"trie_key",
":",
"node",
"[",
"-",
"1",
"]",
"=",
"BLANK_NODE",
"return",
"self",
".",
"_normalize_branch_node",
"(",
"node",
")",
"node_to_delete",
"=",
"self"... | Delete a key from inside or underneath a branch node | [
"Delete",
"a",
"key",
"from",
"inside",
"or",
"underneath",
"a",
"branch",
"node"
] | d33108d21b54d59ee311f61d978496c84a6f1f8b | https://github.com/ethereum/py-trie/blob/d33108d21b54d59ee311f61d978496c84a6f1f8b/trie/hexary.py#L361-L381 | train |
ethereum/py-trie | trie/binary.py | BinaryTrie.get | def get(self, key):
"""
Fetches the value with a given keypath from the given node.
Key will be encoded into binary array format first.
"""
validate_is_bytes(key)
return self._get(self.root_hash, encode_to_bin(key)) | python | def get(self, key):
"""
Fetches the value with a given keypath from the given node.
Key will be encoded into binary array format first.
"""
validate_is_bytes(key)
return self._get(self.root_hash, encode_to_bin(key)) | [
"def",
"get",
"(",
"self",
",",
"key",
")",
":",
"validate_is_bytes",
"(",
"key",
")",
"return",
"self",
".",
"_get",
"(",
"self",
".",
"root_hash",
",",
"encode_to_bin",
"(",
"key",
")",
")"
] | Fetches the value with a given keypath from the given node.
Key will be encoded into binary array format first. | [
"Fetches",
"the",
"value",
"with",
"a",
"given",
"keypath",
"from",
"the",
"given",
"node",
"."
] | d33108d21b54d59ee311f61d978496c84a6f1f8b | https://github.com/ethereum/py-trie/blob/d33108d21b54d59ee311f61d978496c84a6f1f8b/trie/binary.py#L38-L46 | train |
ethereum/py-trie | trie/binary.py | BinaryTrie.set | def set(self, key, value):
"""
Sets the value at the given keypath from the given node
Key will be encoded into binary array format first.
"""
validate_is_bytes(key)
validate_is_bytes(value)
self.root_hash = self._set(self.root_hash, encode_to_bin(key), value) | python | def set(self, key, value):
"""
Sets the value at the given keypath from the given node
Key will be encoded into binary array format first.
"""
validate_is_bytes(key)
validate_is_bytes(value)
self.root_hash = self._set(self.root_hash, encode_to_bin(key), value) | [
"def",
"set",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"validate_is_bytes",
"(",
"key",
")",
"validate_is_bytes",
"(",
"value",
")",
"self",
".",
"root_hash",
"=",
"self",
".",
"_set",
"(",
"self",
".",
"root_hash",
",",
"encode_to_bin",
"(",
"... | Sets the value at the given keypath from the given node
Key will be encoded into binary array format first. | [
"Sets",
"the",
"value",
"at",
"the",
"given",
"keypath",
"from",
"the",
"given",
"node"
] | d33108d21b54d59ee311f61d978496c84a6f1f8b | https://github.com/ethereum/py-trie/blob/d33108d21b54d59ee311f61d978496c84a6f1f8b/trie/binary.py#L79-L88 | train |
ethereum/py-trie | trie/binary.py | BinaryTrie._set | def _set(self, node_hash, keypath, value, if_delete_subtrie=False):
"""
If if_delete_subtrie is set to True, what it will do is that it take in a keypath
and traverse til the end of keypath, then delete the whole subtrie of that node.
Note: keypath should be in binary array format, i.e.... | python | def _set(self, node_hash, keypath, value, if_delete_subtrie=False):
"""
If if_delete_subtrie is set to True, what it will do is that it take in a keypath
and traverse til the end of keypath, then delete the whole subtrie of that node.
Note: keypath should be in binary array format, i.e.... | [
"def",
"_set",
"(",
"self",
",",
"node_hash",
",",
"keypath",
",",
"value",
",",
"if_delete_subtrie",
"=",
"False",
")",
":",
"if",
"node_hash",
"==",
"BLANK_HASH",
":",
"if",
"value",
":",
"return",
"self",
".",
"_hash_and_save",
"(",
"encode_kv_node",
"(... | If if_delete_subtrie is set to True, what it will do is that it take in a keypath
and traverse til the end of keypath, then delete the whole subtrie of that node.
Note: keypath should be in binary array format, i.e., encoded by encode_to_bin() | [
"If",
"if_delete_subtrie",
"is",
"set",
"to",
"True",
"what",
"it",
"will",
"do",
"is",
"that",
"it",
"take",
"in",
"a",
"keypath",
"and",
"traverse",
"til",
"the",
"end",
"of",
"keypath",
"then",
"delete",
"the",
"whole",
"subtrie",
"of",
"that",
"node"... | d33108d21b54d59ee311f61d978496c84a6f1f8b | https://github.com/ethereum/py-trie/blob/d33108d21b54d59ee311f61d978496c84a6f1f8b/trie/binary.py#L90-L153 | train |
ethereum/py-trie | trie/binary.py | BinaryTrie.delete | def delete(self, key):
"""
Equals to setting the value to None
"""
validate_is_bytes(key)
self.root_hash = self._set(self.root_hash, encode_to_bin(key), b'') | python | def delete(self, key):
"""
Equals to setting the value to None
"""
validate_is_bytes(key)
self.root_hash = self._set(self.root_hash, encode_to_bin(key), b'') | [
"def",
"delete",
"(",
"self",
",",
"key",
")",
":",
"validate_is_bytes",
"(",
"key",
")",
"self",
".",
"root_hash",
"=",
"self",
".",
"_set",
"(",
"self",
".",
"root_hash",
",",
"encode_to_bin",
"(",
"key",
")",
",",
"b''",
")"
] | Equals to setting the value to None | [
"Equals",
"to",
"setting",
"the",
"value",
"to",
"None"
] | d33108d21b54d59ee311f61d978496c84a6f1f8b | https://github.com/ethereum/py-trie/blob/d33108d21b54d59ee311f61d978496c84a6f1f8b/trie/binary.py#L297-L303 | train |
ethereum/py-trie | trie/binary.py | BinaryTrie.delete_subtrie | def delete_subtrie(self, key):
"""
Given a key prefix, delete the whole subtrie that starts with the key prefix.
Key will be encoded into binary array format first.
It will call `_set` with `if_delete_subtrie` set to True.
"""
validate_is_bytes(key)
self.root_h... | python | def delete_subtrie(self, key):
"""
Given a key prefix, delete the whole subtrie that starts with the key prefix.
Key will be encoded into binary array format first.
It will call `_set` with `if_delete_subtrie` set to True.
"""
validate_is_bytes(key)
self.root_h... | [
"def",
"delete_subtrie",
"(",
"self",
",",
"key",
")",
":",
"validate_is_bytes",
"(",
"key",
")",
"self",
".",
"root_hash",
"=",
"self",
".",
"_set",
"(",
"self",
".",
"root_hash",
",",
"encode_to_bin",
"(",
"key",
")",
",",
"value",
"=",
"b''",
",",
... | Given a key prefix, delete the whole subtrie that starts with the key prefix.
Key will be encoded into binary array format first.
It will call `_set` with `if_delete_subtrie` set to True. | [
"Given",
"a",
"key",
"prefix",
"delete",
"the",
"whole",
"subtrie",
"that",
"starts",
"with",
"the",
"key",
"prefix",
"."
] | d33108d21b54d59ee311f61d978496c84a6f1f8b | https://github.com/ethereum/py-trie/blob/d33108d21b54d59ee311f61d978496c84a6f1f8b/trie/binary.py#L305-L320 | train |
ethereum/py-trie | trie/binary.py | BinaryTrie._hash_and_save | def _hash_and_save(self, node):
"""
Saves a node into the database and returns its hash
"""
validate_is_bin_node(node)
node_hash = keccak(node)
self.db[node_hash] = node
return node_hash | python | def _hash_and_save(self, node):
"""
Saves a node into the database and returns its hash
"""
validate_is_bin_node(node)
node_hash = keccak(node)
self.db[node_hash] = node
return node_hash | [
"def",
"_hash_and_save",
"(",
"self",
",",
"node",
")",
":",
"validate_is_bin_node",
"(",
"node",
")",
"node_hash",
"=",
"keccak",
"(",
"node",
")",
"self",
".",
"db",
"[",
"node_hash",
"]",
"=",
"node",
"return",
"node_hash"
] | Saves a node into the database and returns its hash | [
"Saves",
"a",
"node",
"into",
"the",
"database",
"and",
"returns",
"its",
"hash"
] | d33108d21b54d59ee311f61d978496c84a6f1f8b | https://github.com/ethereum/py-trie/blob/d33108d21b54d59ee311f61d978496c84a6f1f8b/trie/binary.py#L338-L346 | train |
ethereum/py-trie | trie/utils/binaries.py | decode_from_bin | def decode_from_bin(input_bin):
"""
0100000101010111010000110100100101001001 -> ASCII
"""
for chunk in partition_all(8, input_bin):
yield sum(
2**exp * bit
for exp, bit
in enumerate(reversed(chunk))
) | python | def decode_from_bin(input_bin):
"""
0100000101010111010000110100100101001001 -> ASCII
"""
for chunk in partition_all(8, input_bin):
yield sum(
2**exp * bit
for exp, bit
in enumerate(reversed(chunk))
) | [
"def",
"decode_from_bin",
"(",
"input_bin",
")",
":",
"for",
"chunk",
"in",
"partition_all",
"(",
"8",
",",
"input_bin",
")",
":",
"yield",
"sum",
"(",
"2",
"**",
"exp",
"*",
"bit",
"for",
"exp",
",",
"bit",
"in",
"enumerate",
"(",
"reversed",
"(",
"... | 0100000101010111010000110100100101001001 -> ASCII | [
"0100000101010111010000110100100101001001",
"-",
">",
"ASCII"
] | d33108d21b54d59ee311f61d978496c84a6f1f8b | https://github.com/ethereum/py-trie/blob/d33108d21b54d59ee311f61d978496c84a6f1f8b/trie/utils/binaries.py#L18-L27 | train |
ethereum/py-trie | trie/utils/binaries.py | encode_to_bin | def encode_to_bin(value):
"""
ASCII -> 0100000101010111010000110100100101001001
"""
for char in value:
for exp in EXP:
if char & exp:
yield True
else:
yield False | python | def encode_to_bin(value):
"""
ASCII -> 0100000101010111010000110100100101001001
"""
for char in value:
for exp in EXP:
if char & exp:
yield True
else:
yield False | [
"def",
"encode_to_bin",
"(",
"value",
")",
":",
"for",
"char",
"in",
"value",
":",
"for",
"exp",
"in",
"EXP",
":",
"if",
"char",
"&",
"exp",
":",
"yield",
"True",
"else",
":",
"yield",
"False"
] | ASCII -> 0100000101010111010000110100100101001001 | [
"ASCII",
"-",
">",
"0100000101010111010000110100100101001001"
] | d33108d21b54d59ee311f61d978496c84a6f1f8b | https://github.com/ethereum/py-trie/blob/d33108d21b54d59ee311f61d978496c84a6f1f8b/trie/utils/binaries.py#L31-L40 | train |
ethereum/py-trie | trie/utils/binaries.py | encode_from_bin_keypath | def encode_from_bin_keypath(input_bin):
"""
Encodes a sequence of 0s and 1s into tightly packed bytes
Used in encoding key path of a KV-NODE
"""
padded_bin = bytes((4 - len(input_bin)) % 4) + input_bin
prefix = TWO_BITS[len(input_bin) % 4]
if len(padded_bin) % 8 == 4:
return decode_f... | python | def encode_from_bin_keypath(input_bin):
"""
Encodes a sequence of 0s and 1s into tightly packed bytes
Used in encoding key path of a KV-NODE
"""
padded_bin = bytes((4 - len(input_bin)) % 4) + input_bin
prefix = TWO_BITS[len(input_bin) % 4]
if len(padded_bin) % 8 == 4:
return decode_f... | [
"def",
"encode_from_bin_keypath",
"(",
"input_bin",
")",
":",
"padded_bin",
"=",
"bytes",
"(",
"(",
"4",
"-",
"len",
"(",
"input_bin",
")",
")",
"%",
"4",
")",
"+",
"input_bin",
"prefix",
"=",
"TWO_BITS",
"[",
"len",
"(",
"input_bin",
")",
"%",
"4",
... | Encodes a sequence of 0s and 1s into tightly packed bytes
Used in encoding key path of a KV-NODE | [
"Encodes",
"a",
"sequence",
"of",
"0s",
"and",
"1s",
"into",
"tightly",
"packed",
"bytes",
"Used",
"in",
"encoding",
"key",
"path",
"of",
"a",
"KV",
"-",
"NODE"
] | d33108d21b54d59ee311f61d978496c84a6f1f8b | https://github.com/ethereum/py-trie/blob/d33108d21b54d59ee311f61d978496c84a6f1f8b/trie/utils/binaries.py#L43-L53 | train |
ethereum/py-trie | trie/utils/binaries.py | decode_to_bin_keypath | def decode_to_bin_keypath(path):
"""
Decodes bytes into a sequence of 0s and 1s
Used in decoding key path of a KV-NODE
"""
path = encode_to_bin(path)
if path[0] == 1:
path = path[4:]
assert path[0:2] == PREFIX_00
padded_len = TWO_BITS.index(path[2:4])
return path[4+((4 - padd... | python | def decode_to_bin_keypath(path):
"""
Decodes bytes into a sequence of 0s and 1s
Used in decoding key path of a KV-NODE
"""
path = encode_to_bin(path)
if path[0] == 1:
path = path[4:]
assert path[0:2] == PREFIX_00
padded_len = TWO_BITS.index(path[2:4])
return path[4+((4 - padd... | [
"def",
"decode_to_bin_keypath",
"(",
"path",
")",
":",
"path",
"=",
"encode_to_bin",
"(",
"path",
")",
"if",
"path",
"[",
"0",
"]",
"==",
"1",
":",
"path",
"=",
"path",
"[",
"4",
":",
"]",
"assert",
"path",
"[",
"0",
":",
"2",
"]",
"==",
"PREFIX_... | Decodes bytes into a sequence of 0s and 1s
Used in decoding key path of a KV-NODE | [
"Decodes",
"bytes",
"into",
"a",
"sequence",
"of",
"0s",
"and",
"1s",
"Used",
"in",
"decoding",
"key",
"path",
"of",
"a",
"KV",
"-",
"NODE"
] | d33108d21b54d59ee311f61d978496c84a6f1f8b | https://github.com/ethereum/py-trie/blob/d33108d21b54d59ee311f61d978496c84a6f1f8b/trie/utils/binaries.py#L56-L66 | train |
ethereum/py-trie | trie/utils/nibbles.py | encode_nibbles | def encode_nibbles(nibbles):
"""
The Hex Prefix function
"""
if is_nibbles_terminated(nibbles):
flag = HP_FLAG_2
else:
flag = HP_FLAG_0
raw_nibbles = remove_nibbles_terminator(nibbles)
is_odd = len(raw_nibbles) % 2
if is_odd:
flagged_nibbles = tuple(itertools.c... | python | def encode_nibbles(nibbles):
"""
The Hex Prefix function
"""
if is_nibbles_terminated(nibbles):
flag = HP_FLAG_2
else:
flag = HP_FLAG_0
raw_nibbles = remove_nibbles_terminator(nibbles)
is_odd = len(raw_nibbles) % 2
if is_odd:
flagged_nibbles = tuple(itertools.c... | [
"def",
"encode_nibbles",
"(",
"nibbles",
")",
":",
"if",
"is_nibbles_terminated",
"(",
"nibbles",
")",
":",
"flag",
"=",
"HP_FLAG_2",
"else",
":",
"flag",
"=",
"HP_FLAG_0",
"raw_nibbles",
"=",
"remove_nibbles_terminator",
"(",
"nibbles",
")",
"is_odd",
"=",
"l... | The Hex Prefix function | [
"The",
"Hex",
"Prefix",
"function"
] | d33108d21b54d59ee311f61d978496c84a6f1f8b | https://github.com/ethereum/py-trie/blob/d33108d21b54d59ee311f61d978496c84a6f1f8b/trie/utils/nibbles.py#L78-L104 | train |
ethereum/py-trie | trie/utils/nibbles.py | decode_nibbles | def decode_nibbles(value):
"""
The inverse of the Hex Prefix function
"""
nibbles_with_flag = bytes_to_nibbles(value)
flag = nibbles_with_flag[0]
needs_terminator = flag in {HP_FLAG_2, HP_FLAG_2 + 1}
is_odd_length = flag in {HP_FLAG_0 + 1, HP_FLAG_2 + 1}
if is_odd_length:
raw_n... | python | def decode_nibbles(value):
"""
The inverse of the Hex Prefix function
"""
nibbles_with_flag = bytes_to_nibbles(value)
flag = nibbles_with_flag[0]
needs_terminator = flag in {HP_FLAG_2, HP_FLAG_2 + 1}
is_odd_length = flag in {HP_FLAG_0 + 1, HP_FLAG_2 + 1}
if is_odd_length:
raw_n... | [
"def",
"decode_nibbles",
"(",
"value",
")",
":",
"nibbles_with_flag",
"=",
"bytes_to_nibbles",
"(",
"value",
")",
"flag",
"=",
"nibbles_with_flag",
"[",
"0",
"]",
"needs_terminator",
"=",
"flag",
"in",
"{",
"HP_FLAG_2",
",",
"HP_FLAG_2",
"+",
"1",
"}",
"is_o... | The inverse of the Hex Prefix function | [
"The",
"inverse",
"of",
"the",
"Hex",
"Prefix",
"function"
] | d33108d21b54d59ee311f61d978496c84a6f1f8b | https://github.com/ethereum/py-trie/blob/d33108d21b54d59ee311f61d978496c84a6f1f8b/trie/utils/nibbles.py#L107-L127 | train |
neon-jungle/wagtailvideos | wagtailvideos/models.py | get_local_file | def get_local_file(file):
"""
Get a local version of the file, downloading it from the remote storage if
required. The returned value should be used as a context manager to
ensure any temporary files are cleaned up afterwards.
"""
try:
with open(file.path):
yield file.path
... | python | def get_local_file(file):
"""
Get a local version of the file, downloading it from the remote storage if
required. The returned value should be used as a context manager to
ensure any temporary files are cleaned up afterwards.
"""
try:
with open(file.path):
yield file.path
... | [
"def",
"get_local_file",
"(",
"file",
")",
":",
"try",
":",
"with",
"open",
"(",
"file",
".",
"path",
")",
":",
"yield",
"file",
".",
"path",
"except",
"NotImplementedError",
":",
"_",
",",
"ext",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"file",... | Get a local version of the file, downloading it from the remote storage if
required. The returned value should be used as a context manager to
ensure any temporary files are cleaned up afterwards. | [
"Get",
"a",
"local",
"version",
"of",
"the",
"file",
"downloading",
"it",
"from",
"the",
"remote",
"storage",
"if",
"required",
".",
"The",
"returned",
"value",
"should",
"be",
"used",
"as",
"a",
"context",
"manager",
"to",
"ensure",
"any",
"temporary",
"f... | 05a43571ac4b5e7cf07fbb89e804e53447b699c2 | https://github.com/neon-jungle/wagtailvideos/blob/05a43571ac4b5e7cf07fbb89e804e53447b699c2/wagtailvideos/models.py#L292-L311 | train |
getsentry/semaphore | py/semaphore/utils.py | rustcall | def rustcall(func, *args):
"""Calls rust method and does some error handling."""
lib.semaphore_err_clear()
rv = func(*args)
err = lib.semaphore_err_get_last_code()
if not err:
return rv
msg = lib.semaphore_err_get_last_message()
cls = exceptions_by_code.get(err, SemaphoreError)
e... | python | def rustcall(func, *args):
"""Calls rust method and does some error handling."""
lib.semaphore_err_clear()
rv = func(*args)
err = lib.semaphore_err_get_last_code()
if not err:
return rv
msg = lib.semaphore_err_get_last_message()
cls = exceptions_by_code.get(err, SemaphoreError)
e... | [
"def",
"rustcall",
"(",
"func",
",",
"*",
"args",
")",
":",
"lib",
".",
"semaphore_err_clear",
"(",
")",
"rv",
"=",
"func",
"(",
"*",
"args",
")",
"err",
"=",
"lib",
".",
"semaphore_err_get_last_code",
"(",
")",
"if",
"not",
"err",
":",
"return",
"rv... | Calls rust method and does some error handling. | [
"Calls",
"rust",
"method",
"and",
"does",
"some",
"error",
"handling",
"."
] | 6f260b4092261e893b4debd9a3a7a78232f46c5e | https://github.com/getsentry/semaphore/blob/6f260b4092261e893b4debd9a3a7a78232f46c5e/py/semaphore/utils.py#L17-L30 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.