aboutsummaryrefslogtreecommitdiff
path: root/gn3/db
AgeCommit message (Expand)Author
2022-05-31Extract utility functions from `fetch_all_database_data`...Extract the utility functions to help with understanding the what the `fetch_all_database_data` function is doing. This helps with maintenance. Frederick Muriuki Muriithi
2022-05-27Move sql for CRUD operations on case-attrs from gn2 to gn3BonfaceKilz
2022-05-27Move sql for modifying case-attributes from gn2 to gn3BonfaceKilz
2022-05-27Return all the results from CaseAttributes column as is...* gn3/db/sample_data.py: Remove "collections" import. Add "Optional" import. (get_case_attributes): Return the results of "fetchall" from the case attributes. * tests/unit/db/test_sample_data.py (test_get_case_attributes): Update failing test. BonfaceKilz
2022-05-26Add Endpoint to get menu items for use in UIFrederick Muriuki Muriithi
2022-05-06Fix linting and typing errorsFrederick Muriuki Muriithi
2022-05-05Compute partial correlation with selected traits...Compute partial correlations against a selection of traits rather than against an entire dataset. Frederick Muriuki Muriithi
2022-04-12Strip any newline, tab or carriage-return chars from sample data...* gn3/db/sample_data.py (get_trait_csv_sample_data): Strip out "\n", "\t", or "\r" from the sample data. See: <https://issues.genenetwork.org/issues/csv-error-ITP_10001-longevity-data-set.html> BonfaceKilz
2022-04-07Fix pylint errorsBonfaceKilz
2022-04-07Use case attribute id inside brackets if present during insertions...* gn3/db/sample_data.py (delete_sample_data): If an id is present in the column header, use it. * tests/unit/db/test_sample_data.py (test_delete_sample_data): Update tests to capture the above. BonfaceKilz
2022-04-07Use case attribute id inside brackets if present during insertions...* gn3/db/sample_data.py (insert_sample_data): If an id is present in the column header, use it. * tests/unit/db/test_sample_data.py (test_insert_sample_data): Update tests to capture the above. BonfaceKilz
2022-04-07Use case attribute id inside brackets if present during updates...* gn3/db/sample_data.py: Import "parse_csv_column". (update_sample_data): If an id is present in the column header, use it. * tests/unit/db/test_sample_data.py (test_update_sample_data): Update tests to capture the above. BonfaceKilz
2022-04-07Add method for fetching the case_attributes...* gn3/db/sample_data.py (get_case_attributes): New function. * tests/unit/db/test_sample_data.py (test_get_case_attributes): Test case for the above. BonfaceKilz
2022-04-07Run python black on file...* gn3/db/sample_data.py: Run "python black -l 79 ..." BonfaceKilz
2022-03-14Dummy White Space commit to fix laminarBonfaceKilz
2022-03-12Remove unused importsBonfaceKilz
2022-03-12Fix mypy issuesBonfaceKilz
2022-03-12Fix pylint issuesBonfaceKilz
2022-03-12Store the first element as strain_idBonfaceKilz
2022-03-12Append the strain name when extracting "actions"...* gn3/db/sample_data.py (__extract_actions): During updates, make sure that the strain name is part of the returned string when extracting "actions". * tests/unit/db/test_sample_data.py: Add test cases for the above. BonfaceKilz
2022-03-12Apply auto-pep8 to sample_data.py and it's test fileBonfaceKilz
2022-03-12Add missing return type-annotations...* tests/unit/db/test_sample_data.py (delete_sample_data): Add missing return type for type annotations. (insert_sample_data): Ditto. BonfaceKilz
2022-03-12Update how data is updated by re-using existing functions...* gn3/db/sample_data.py (get_sample_data_ids): Re-use "delete_sample_data" and "insert_sample_data" when updating data; and also add logic for updating modified data. * tests/unit/db/test_sample_data.py: Add tests for the above. BonfaceKilz
2022-03-12Create action dict that's created when updating data...* gn3/db/sample_data.py (__extract_actions): An update on a vector of data can contain: inserts, deletes and updates. This functions extracts these actions during an update. * tests/unit/db/test_sample_data.py (test_extract_actions): Add test-case for the above. BonfaceKilz
2022-03-12Remove check for inserted data when inserting individual data...* gn3/db/sample_data.py (insert_sample_data)[__insert_data]: Move check to the main body. With this check here, you have 3 redundant checks. For a successful insert, it will insert the first value to the `PublishData` table and ignore the rest of the inserts. BonfaceKilz
2022-03-12Make `_map` a constant...* gn3/db/sample_data.py: Now constant, `_MAP`. (delete_sample_data)[__delete_data]: Replace `_map` with `_MAP`. (insert_sample_data)[__insert_data]: Ditto. BonfaceKilz
2022-03-12Fix faulty SQL query string when deleting case-attributesBonfaceKilz
2022-03-12Explicitly get CaseAttributeId and fix broken sql query...* gn3/db/sample_data.py (insert_sample_data): Use correct query string. Also, use CaseAttributeId to determine whether case-attributes were inserted. If so, do not attempt an insert. BonfaceKilz
2022-03-12Remove duplicate params...* gn3/db/sample_data.py (insert_sample_data)[__insert_case_attribute]: Remove extra parameters. BonfaceKilz
2022-03-12Remove dead codeBonfaceKilz
2022-03-12Check whether publish data already exists before inserting...* gn3/db/sample_data.py (insert_sample_data): If data already exists in the table, do not attempt an insert; otherwise, an error will be generated. BonfaceKilz
2022-03-12Fetch id's separately for the insertion edge-case...* gn3/db/sample_data (get_sample_data_ids): Add an extra condition that caters for inserts: during inserts, joins won't work when fetching the strain_id, publishdata_id, and strain_name. In this case, just create 2 separate queries to do that work. BonfaceKilz
2022-03-12Extract a strain name given a csv string and it's header...* gn3/csvcmp.py (extract_strain_name): New function. * gn3/db/sample_data (delete_sample_data): Use the aforementioned function. (insert_sample_data): Ditto. * tests/unit/test_csvcmp: Test cases for above. BonfaceKilz
2022-03-12Allow deleting case-attribute data during deletion...* gn3/db/sample_data.py (delete_sample_data): Modify this function to allow deleting case-attribute values. BonfaceKilz
2022-03-12Allow inserting case-attribute data during inserts...* gn3/db/sample_data.py (insert_sample_data): Modify this function to allow inserting case-attribute values. BonfaceKilz
2022-03-12Fetch InbredSetId...* gn3/db/sample_data.py (get_sample_data_ids): Extend to also fetch InbredSetId. (update_sample_data): Discard the returned value of InbredSetId. (delete_sample_data): Ditto. BonfaceKilz
2022-03-12Create a new function for retrieving strain_id and publishdata_id...* gn3/db/sample_data.py: Import Any, Tuple. (get_sample_data_ids): New function that fetches the strain_id and publishdata_id of a given data point. (update_sample_data): Use `get_sample_data_ids`. (delete_sample_data): Ditto. (insert_sample_data): Ditto. BonfaceKilz
2022-03-12Move operations on sample_data to it's own moduleBonfaceKilz
2022-03-12db: Fix error in SQL query...* gn3/db/traits.py (get_trait_csv_sample_data): Update SQL to fix runtime errors. BonfaceKilz
2022-03-12Fix pylint errorBonfaceKilz
2022-03-12Append case attributes to csv data if they existBonfaceKilz
2022-03-12db: Extend csv query to fetch case attributes...* gn3/db/traits.py (get_trait_csv_sample_data): Fetch case attribute data if it exists. BonfaceKilz
2022-03-12Revert "db: Fetch correct sample data"...This reverts commit 710769e84b3bc6a2bdd66effdbac0659272ed511. BonfaceKilz
2022-03-11Fix typing errorsFrederick Muriuki Muriithi
2022-02-21Fix minor issues introduced while fixing linting errorsFrederick Muriuki Muriithi
2022-02-21Fix a myriad of linter issues...* Use `with` in place of plain `open` * Use f-strings in place of `str.format()` * Remove string interpolation from queries - provide data as query parameters * other minor fixes Frederick Muriuki Muriithi
2022-02-21Test partial corrs API with mix of existing and non-existing control traits...Test that the partial correlations endpoint handles a mix of existing and non-existing control traits gracefully and issues a warning to the user. Summary of changes: * gn3/computations/partial_correlations.py: Issue a warning for all non-existing control traits * gn3/db/partial_correlations.py: update queries - use `INNER JOIN` for tables instead of comma-separated list of tables * tests/integration/conftest.py: Add `db_conn` fixture to provide a database connection to the tests. This will probably be changed in the future to connect to a temporary database for tests. * tests/integration/test_partial_correlations.py: Add test to check for correct behaviour with a mix of existing and non-existing control traits Frederick Muriuki Muriithi
2022-02-19Test partial corrs endpoint with non-existing control traits...Test that if the endpoint is queried and not a single one of the control traits exists in the database, then the endpoint will respond with a 404 (not-found) status code. Summary of changes: * gn3/computations/partial_correlations.py: Check whether any control trait is found. If none is found, return "not-found" message. * gn3/db/partial_correlations.py: Fix bug in Geno query. * tests/integration/test_partial_correlations.py: Add test for non-existing control traits. Rename function to make it clearer what it is testing for. Remove obsoleted comments. Frederick Muriuki Muriithi
2022-02-18Remove code trying to query non-existent `TempFreeze` table...The code was migrated from GN1 with a faulty assumption that all trait types have a corresponding `*Freeze` table in the database. This assumption is not true for the `Temp` traits. This commit removes the buggy code. Frederick Muriuki Muriithi
2022-02-18Test partial correlations endpoint with non-existent primary traits...Test that the partial correlations endpoint responds with an appropriate "not-found" message and the corresponding 404 status code in the case where a request is made and the primary trait requested for does not exist in the database. Summary of the changes in each file: * gn3/api/correlation.py: generalise the building of the response * gn3/computations/partial_correlations.py: return with a "not-found" if the primary trait does not exist in the database * gn3/db/partial_correlations.py: Fix a number of bugs that led to exceptions in the case that the primary trait did not exist * pytest.ini: register a `slow` pytest marker * tests/integration/test_partial_correlations.py: Add a new test to check for an appropriate 404 response in case of a primary trait that does not exist in the database. Frederick Muriuki Muriithi