aboutsummaryrefslogtreecommitdiff
path: root/gn3/db/rdf.py
AgeCommit message (Collapse)Author
2024-08-29Fetch the latest comment by the versionId.Munyoki Kilyungi
* gn3/db/rdf.py (get_wiki_entries_by_symbol): Update query to fetch the latest query by the version. Signed-off-by: Munyoki Kilyungi <me@bonfacemunyoki.com>
2024-08-29Make fetching wiki entries by symbol case insensitive.Munyoki Kilyungi
Signed-off-by: Munyoki Kilyungi <me@bonfacemunyoki.com>
2024-08-29Add "created" to wiki return.Munyoki Kilyungi
* gn3/db/rdf.py (get_wiki_entries_by_symbol): Add "created" to dictionary. Signed-off-by: Munyoki Kilyungi <me@bonfacemunyoki.com>
2024-08-26Fix pylint errors.Munyoki Kilyungi
* gn3/api/metadata.py: Remove duplicate imports. * gn3/db/constants.py: Add docstring. * gn3/db/rdf.py (get_wiki_entries_by_symbol): Remove duplicate dictionary key. Signed-off-by: Munyoki Kilyungi <me@bonfacemunyoki.com>
2024-08-26If there's no data, return a 404.Munyoki Kilyungi
* gn3/api/metadata.py (get_wiki_entries): Return an empty {} when there's no data. * gn3/db/rdf.py (query_frame_and_compact): Delete check for empty results. Instead just return the context as is. (query_and_compact): Ditto. (query_and_frame): Ditto. Signed-off-by: Munyoki Kilyungi <me@bonfacemunyoki.com>
2024-08-26Replace map with list comprehension.Munyoki Kilyungi
* gn3/db/rdf.py (get_wiki_entries_by_symbol): Use list comprehensions. Signed-off-by: Munyoki Kilyungi <me@bonfacemunyoki.com>
2024-08-26Fetch all the wiki entries by symbol.Munyoki Kilyungi
* gn3/api/metadata.py: Import "get_wiki_entries_by_symbol". (get_gn_genewiki_entries): Rename this to... (get_wiki_entries): this; and update the URL endpoint. * gn3/db/rdf.py: Import constants.BASE_CONTEXT. (get_wiki_entries_by_symbol): New function. Signed-off-by: Munyoki Kilyungi <me@bonfacemunyoki.com>
2024-08-26Move constants to their own file.Munyoki Kilyungi
* gn3/api/metadata.py: Move constants from here... * gn3/db/rdf.py: ... and here, to... * gn3/db/constants.py: ... here. Signed-off-by: Munyoki Kilyungi <me@bonfacemunyoki.com>
2023-10-27Fix pylint error.Munyoki Kilyungi
Signed-off-by: Munyoki Kilyungi <me@bonfacemunyoki.com>
2023-10-27Add functions that wrap around the common jsonld patterns.Munyoki Kilyungi
* gn3/db/rdf.py: Import jsonld. (query_frame_and_compact, query_and_compact, query_and_frame): New functions. Signed-off-by: Munyoki Kilyungi <me@bonfacemunyoki.com>
2023-10-27Break up long line.Munyoki Kilyungi
Signed-off-by: Munyoki Kilyungi <me@bonfacemunyoki.com>
2023-10-27Ignore construct result for mypy complianceMunyoki Kilyungi
This commit addresses the mypy issue below by ignoring the construct result. ``` error: Item "None" of "bytes | str | dict[Any, Any] | Graph | Document | None" has no attribute "serialize" [union-attr] ```
2023-10-27Abstract out (sparql) CONSTRUCT into a function.Munyoki Kilyungi
Signed-off-by: Munyoki Kilyungi <me@bonfacemunyoki.com>
2023-10-27Delete gn3.db.rdf.sparql_query.Munyoki Kilyungi
* gn3/api/metadata.py: Remove sparql_query import. * gn3/db/rdf.py: Remove unused imports. (sparql_query): Delete. Signed-off-by: Munyoki Kilyungi <me@bonfacemunyoki.com>
2023-10-27Delete db.rdf.get_url_local_name.Munyoki Kilyungi
Signed-off-by: Munyoki Kilyungi <me@bonfacemunyoki.com>
2023-10-27Implement "GET /metadata/phenotypes/:name".Munyoki Kilyungi
* gn3/api/metadata.py: Delete gn3.db.rdf.get_phenotype_metadata. (phenotype): Rename this to ... (phenotypes): ... this and implement update logic. * gn3/db/rdf.py (get_phenotype_metadata): Delete. Signed-off-by: Munyoki Kilyungi <me@bonfacemunyoki.com>
2023-10-27Delete get_dataset_metadata.Munyoki Kilyungi
* gn3/db/rdf.py (get_dataset_metadata): Delete. Signed-off-by: Munyoki Kilyungi <me@bonfacemunyoki.com>
2023-10-27Implement "GET /metadata/publications/:name".Munyoki Kilyungi
* gn3/api/metadata.py: Delete gn3.db.rdf.get_publication_metadata. (publication): Rename this ... (publications): ... to this. Return a json-ld result. * gn3/db/rdf.py (get_publication_metadata): Delete. Signed-off-by: Munyoki Kilyungi <me@bonfacemunyoki.com>
2023-10-27Add fabio: and prism: to PREFIXES.Munyoki Kilyungi
Signed-off-by: Munyoki Kilyungi <me@bonfacemunyoki.com>
2023-10-27Implement "GET /metadata/datasets/:name".Munyoki Kilyungi
* gn3/api/metadata.py: Import json, SPARQLWrapper.{JSON, JSONLD}. (dataset): Rename this to ... (datasets): ... this. Return a well formatted JSONLD result from a dataset. Signed-off-by: Munyoki Kilyungi <me@bonfacemunyoki.com>
2023-10-27Add missing dcat: prefix.Munyoki Kilyungi
2023-10-27Derive RDF_PREFIXES string from PREFIXES.Munyoki Kilyungi
Signed-off-by: Munyoki Kilyungi <me@bonfacemunyoki.com>
2023-10-27Remove get_url_local_name when processing result keys.Munyoki Kilyungi
* gn3/db/rdf.py (sparql_query): Delete "get_url_local_name". Signed-off-by: Munyoki Kilyungi <me@bonfacemunyoki.com>
2023-10-27Simplify CONSTRUCT query when fetching a dataset's metadata.Munyoki Kilyungi
* gn3/api/metadata.py (dataset): Update docstring. * gn3/db/rdf.py (get_dataset_metadata): Simplify CONSTRUCT query. Also, now you can fetch metadata using either an accession_id or the dataset's name. Signed-off-by: Munyoki Kilyungi <me@bonfacemunyoki.com>
2023-10-27Update RDF prefixes.Munyoki Kilyungi
Signed-off-by: Munyoki Kilyungi <me@bonfacemunyoki.com>
2023-06-15Fetch genotypes from virtuosoMunyoki Kilyungi
* gn3/api/metadata.py: Import get_genotype_metadata. (genotype): New end-point. * gn3/db/rdf.py (get_phenotype_metadata): New function. Signed-off-by: Munyoki Kilyungi <me@bonfacemunyoki.com>
2023-06-12Delete unused importMunyoki Kilyungi
Signed-off-by: Munyoki Kilyungi <me@bonfacemunyoki.com>
2023-06-12Fetch phenotypes from virtuosoMunyoki Kilyungi
* gn3/api/metadata.py: Import get_phenotype_metadata. (phenotype): New end-point. * gn3/db/rdf.py (get_phenotype_metadata): New function. Signed-off-by: Munyoki Kilyungi <me@bonfacemunyoki.com>
2023-06-12Delete unused get_trait_metadata functionMunyoki Kilyungi
Signed-off-by: Munyoki Kilyungi <me@bonfacemunyoki.com>
2023-06-07Add publication end-pointMunyoki Kilyungi
* gn3/api/metadata.py: Import get_publication_metadata (publication): New endpoint. * gn3/db/rdf.py (get_dataset_metadata): New function. Signed-off-by: Munyoki Kilyungi <me@bonfacemunyoki.com>
2023-06-07Nest duplicate entries into a list from a sparql resultMunyoki Kilyungi
Signed-off-by: Munyoki Kilyungi <me@bonfacemunyoki.com>
2023-06-06Pass geoSeries as a URLMunyoki Kilyungi
Signed-off-by: Munyoki Kilyungi <me@bonfacemunyoki.com>
2023-06-06Rename gn:geoPlatform -> gn:geoPlatformUrlMunyoki Kilyungi
Signed-off-by: Munyoki Kilyungi <me@bonfacemunyoki.com>
2023-06-06Match how dataset metadata is fetched with GN1Munyoki Kilyungi
* gn3/db/rdf.py (sparql_query): Parse CONSTRUCTS and SELECTS differently. (strip_url): Rename to ... (get_url_local_name): ... this. (get_dataset_metadata): Fetch extra fields in RDF. Signed-off-by: Munyoki Kilyungi <me@bonfacemunyoki.com>
2023-06-06Replace taxon prefix with ncbiTaxon which references NCBIMunyoki Kilyungi
Signed-off-by: Munyoki Kilyungi <me@bonfacemunyoki.com>
2023-06-02Replace SELECT with CONSTRUCT when fetching a dataset's metadataMunyoki Kilyungi
* gn3/db/rdf.py: Importh pymonad.Nothing. (get_dataset_metadata): Replace SELECT with CONSTRUCT. Signed-off-by: Munyoki Kilyungi <me@bonfacemunyoki.com>
2023-06-02Create a function for stripping the last bit from a URLMunyoki Kilyungi
* gn3/db/rdf.py: Import unquote and urlparse. (strip_url): New function. Signed-off-by: Munyoki Kilyungi <me@bonfacemunyoki.com>
2023-04-17Create new endpoint for fetching GeneRIF entriesMunyoki Kilyungi
* gn3/api/metadata.py: Import Template, sparql_query and RDF_PREFIXES. (get_genewiki_entries): New endpoint. * gn3/db/rdf.py: Add new constant for storing rdf prefixes. Signed-off-by: Munyoki Kilyungi <me@bonfacemunyoki.com>
2023-03-01Fetch trait metadata from RDFMunyoki Kilyungi
* gn3/db/rdf.py (get_dataset_metadata): New function. Signed-off-by: Munyoki Kilyungi <me@bonfacemunyoki.com>
2022-12-08Remove unused importFrederick Muriuki Muriithi
2022-12-06Use a dataset's name to fetch it's metadata from RDFMunyoki Kilyungi
* gn3/api/metadata.py (jsonify_dataset_metadata): Rewrite metadata end-point to use a dataset's name instead of it's accession_id. * gn3/db/rdf.py (get_dataset_metadata): Replace accession_id with name. Use one single RDF query instead of multiple queries.
2022-11-16Inject SPARQLWrapper as a parameterMunyoki Kilyungi
* gn3/db/rdf.py: Delete gn3.setting.SPARQL_ENDPOINT import. (sparql_query): Inject SPARQLWrapper. (get_dataset_metadata): Ditto.
2022-11-02Re-implement RDF related code to use monads in its own moduleMunyoki Kilyungi
* gn3/api/general.py: Replace gn3.db.datasets import with gn3.db.rdf. (dataset_metadata) <jsonify>: Replace datasets.dataset_metadata with rdf.get_dataset_metadata. * gn3/db/datasets.py: Remove unused imports. (sparql_query, dataset_metadata): Delete. * gn3/db/rdf.py: (sparql_query, get_dataset_metadata): New functions.