aboutsummaryrefslogtreecommitdiff
path: root/gn3/db
AgeCommit message (Collapse)Author
2022-02-08db: traits: Enable deletion of individual sample valuesBonfaceKilz
If a user replaces an individual value with an "x", delete that date entry from the respective table. Deletion here is the only option since by default the Nstrain, PublishData and PublishSE don't accept null values. Note that deleting all 3 values is equivalent to removing the sample from the CSV file. * gn3/db/traits.py (update_sample_data): If a value is "x", delete it from the respective table.
2022-02-08db: traits: Allow insertions of "0" in resp. sample values tablesBonfaceKilz
When editing values from "x" to "0"(or any other value) when editing data, an "update" statement was being run; thereby no new value was being inserted. To the end user, modifying an "x" value to something else meant that no value was being inserted. This commit fixes that by doing an insert whenever a change from "x" to "0" is performed. * gn3/db/traits.py (update_sample_data): Add insert statements whenever an "update" statement returns a 0 row-count.
2022-02-08db: traits: Insert "count" instead of "error" in "NStrain" tableBonfaceKilz
2022-02-03db: Fetch correct sample dataBonfaceKilz
2022-02-02Remove PublishFreeze from retrieve_publish_trait_info queryzsloan
The PublishFreeze table isn't necessary in phenotype queries, since PublishFreeze.Id = InbredSet.Id (for the purposes of identifying traits, at least)
2022-02-02Fix bug where sample values of 0 were being treated as Falsezsloan
In line 91 of gn3/db/traits.py, there was an if statement "if record[key] else 'x'" that was treating values of 0 as False, so I changed it to explicitly check that values aren't None
2022-02-02Fix retrieve_publish_trait_data queryzsloan
The PublishFreeeze table is actually unnecessary for this query, since the group ID (inbred_set_id) should be passed in and that ID is in the PublishXRef table (so no neeed to join with PublishFreeze)
2022-01-12Indent code correctlyFrederick Muriuki Muriithi
Indent the code correctly.
2022-01-12Deduplicate query to fetch data for 'Publish' traitsFrederick Muriuki Muriithi
The queries run in the `get_trait_csv_sample_data` and `retrieve_publish_trait_data` functions in the `gn3.db.traits` module were mostly similar. This commit changes that, by making the `get_trait_csv_sample_data` function make use of the results from calling the `retrieve_publish_trait_data` function.
2022-01-10Check for path existenceFrederick Muriuki Muriithi
Issue: https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/partial-correlations.gmi
2022-01-10Fix dataset retrieval query for `Geno` traitsFrederick Muriuki Muriithi
Issue: https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/partial-correlations.gmi
2022-01-10Surround statement with parens for readabilityFrederick Muriuki Muriithi
2022-01-10Convert keys to stringFrederick Muriuki Muriithi
* Some traits have a name composed of all numerals, which leads to the names being interpreted as numbers. This commit forces them to string to avoid subtle bugs where the code fails.
2022-01-10Fix error in query: Replace '=' with 'IN'Frederick Muriuki Muriithi
2022-01-10Rework database functions to fetch multiple itemsFrederick Muriuki Muriithi
Issue: https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/partial-correlations.gmi * In an attempt to optimise the performance of the partial correlations feature, this commit reworks some database access functions to fetch multiple items from the database, per query, unlike their original forms which would fetch a single item per query. This reduces queries to the database, and should hopefully improve the responsiveness of the partial correlations feature.
2022-01-05Merge branch 'main' into fix/check-for-duplicates-before-deletions-or-insertionsBonfaceKilz
2022-01-04traits.py: Don't use "value" to check if a record existsBonfaceKilz
The problem with using the "value" record is that it's a floating point number. See <https://www.bonfacemunyoki.com/post/2021-10-21-comparing-floating-point-numbers/> on why comparing floating point numbers can be an issue.
2022-01-04traits.py: Return early during an insert if the give record existsBonfaceKilz
Sometimes, a user will try to insert data twice, on in some instances, 2 different users will attempt the same inserts of the same records separately. In such cases, ignore the insert, and return early.
2022-01-04traits.py Delete a record only if it existsBonfaceKilz
In the case when the user tries to delete the same data twice, prior to this commit, an error was being generated. This commit remedies this by checking if a record exists prior to deleting it.
2021-12-23db: Assist mypy with explicit type declaration.Arun Isaac
* gn3/db/datasets.py (dataset_metadata): Assist mypy by explicitly declaring type of return dictionary.
2021-12-23db: Fix sparql_query return type.Arun Isaac
* gn3/db/datasets.py: Import List from typing. (sparql_query): Set return type to List[Dict[str, Any]].
2021-12-23db: Fix wrong continued indentation.Arun Isaac
* gn3/db/datasets.py (dataset_metadata): Fix wrong continued indentation.
2021-12-14linting: Fix obvious linting issuesFrederick Muriuki Muriithi
2021-12-14Fix bug: expects int, gets object - Fixed.Frederick Muriuki Muriithi
2021-12-14mypy: ignore some imports and errorsFrederick Muriuki Muriithi
* Ignore some missing library stubs * Ignore some typing errors * Fix obvious typing errors
2021-12-14Set explicit formatting for sequences in queriesFrederick Muriuki Muriithi
Issue: https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/partial-correlations.gmi * the mysqlclient is sometimes finicky with the format specifiers, especially in the `WHERE ... IN ...` clauses where a sequence of values is provided. This commit explicitly sets the format specifiers for such clauses so as to avoid sporadic failures due to differences in the form of data from one query to the next.
2021-12-13Fix errors with queryFrederick Muriuki Muriithi
Issue: https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/partial-correlations.gmi * Use the correct format string paradigm: put f before opening quote. * Provide missing space just before 'FROM' clause
2021-12-10Fix parametersFrederick Muriuki Muriithi
Issue: https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/partial-correlations.gmi * Provide parameters as a dict of items (which works for MySQL), rather than as keywork arguments (as works in PostgreSQL).
2021-12-09Prevent error on no result. Fix indexingFrederick Muriuki Muriithi
Issue: https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/partial-correlations.gmi * If the dataset name is not found, don't cause an exception, instead, return the provided search name. * Use the correct inner object
2021-12-09Provide clearer error messageFrederick Muriuki Muriithi
Issue: https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/partial-correlations.gmi * To help with debugging error conditions, provide the original name to help with figuring out why the error was raised
2021-12-06Merge branch 'main' of github.com:genenetwork/genenetwork3Frederick Muriuki Muriithi
2021-12-02Implement dataset metadata API endpoint.Arun Isaac
* guix.scm: Import (gnu packages rdf). (genenetwork3)[propagated-inputs]: Add python-sparqlwrapper. * gn3/settings.py (SPARQL_ENDPOINT): New variable. * gn3/api/general.py: Import datasets from gn3.db. (dataset_metadata): New API endpoint. * gn3/db/datasets.py: Import re, Template from string, Dict and Optional from typing, JSON and SPARQLWrapper from SPARQLWrapper, SPARQL_ENDPOINT from gn3.settings. (sparql_query, dataset_metadata): New functions.
2021-11-29Merge branch 'main' into partial-correlationsMuriithi Frederick Muriuki
2021-11-29Fix linting errorsFrederick Muriuki Muriithi
Issue: https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/partial-correlations.gmi
2021-11-29Provide entry-point function for the partial correlationsFrederick Muriuki Muriithi
Issue: https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/partial-correlations.gmi * Provide the entry-point function to the partial correlation feature. This is the function that ochestrates the fetching of the data, and processing it for output by the API endpoint (to be implemented).
2021-11-29Fix bugs in dataFrederick Muriuki Muriithi
Issue: https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/partial-correlations.gmi * Process the db_name and db_type values. * Return data correctly
2021-11-29Update return typeFrederick Muriuki Muriithi
Issue: https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/partial-correlations.gmi * Return the complete filename when found, or the boolean value False, when it is not found.
2021-11-29Return only valuesFrederick Muriuki Muriithi
Issue: https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/partial-correlations.gmi * Return the values from the database, not the tuples.
2021-11-29Update typing notations on functionsFrederick Muriuki Muriithi
Issue: https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/partial-correlations.gmi
2021-11-29Fix query parametrisationFrederick Muriuki Muriithi
Issue: https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/partial-correlations.gmi * Pass parameters to the query the way the MySQL driver expects.
2021-11-29Retrieve the species name given the groupFrederick Muriuki Muriithi
Issue: https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/partial-correlations.gmi * Migrate the `web.webqtl.dbFunction.webqtlDatabaseFunction.retrieveSpecies` in GeneNetwork1 to `gn3.db.species.species_name` in GeneNetwork3 to enable the retrieval of the species name, given the group name (formerly RISet).
2021-11-29db: traits: Support additions and deletions from csv fileBonfaceKilz
2021-11-29db: traits: Remove trailing ".0" in int valuesBonfaceKilz
2021-11-29db: traits: Remove "\n\n" when generating csv fileBonfaceKilz
In excel, "\n\n" is replaced with ",,,," during upload.
2021-11-25db: traits: Support additions and deletions from csv fileBonfaceKilz
2021-11-24db: traits: Remove trailing ".0" in int valuesBonfaceKilz
2021-11-23db: traits: Remove "\n\n" when generating csv fileBonfaceKilz
In excel, "\n\n" is replaced with ",,,," during upload.
2021-11-23Fix a myriad of linting errorsFrederick Muriuki Muriithi
* Fix linting errors like: - Unused variables - Undeclared variable errors (mostly caused by typos, and wrong names) - Missing documentation strings for functions etc.
2021-11-23Update documentation for functionsFrederick Muriuki Muriithi
Issue: https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/partial-correlations.gmi * Document functions for posterity.
2021-11-22Add test to query buildersFrederick Muriuki Muriithi
Issue: https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/partial-correlations.gmi * Add some tests for the query builders to ensure that the queries are built up correctly.