aboutsummaryrefslogtreecommitdiff
path: root/gn3/api
AgeCommit message (Collapse)Author
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.
2022-10-28Use Xapian index path from app settings.Arun Isaac
App settings should be accessed from current_app. It should not be hard-coded to a variable in a module. * gn3/db_utils.py: Do not import XAPIAN_DB_PATH from gn3.settings. (xapian_database): Accept path argument. * gn3/api/search.py: Import current_app from flask. (search_results): Pass Xapian index path to xapian_database.
2022-10-28Add search.Arun Isaac
* gn3/api/search.py: New file. * gn3/app.py: Register the search blueprint.
2022-07-28Add command to run the sample correlations in an external processFrederick Muriuki Muriithi
2022-05-26Add Endpoint to get menu items for use in UIFrederick Muriuki Muriithi
2022-05-24Run partial correlations with external scriptFrederick Muriuki Muriithi
Use new external script to run the partial correlations for both cases, i.e. - against an entire dataset, or - against selected traits
2022-05-24New script to compute partial correlationsFrederick Muriuki Muriithi
* Add a new script to compute the partial correlations against: - a select list of traits, or - an entire dataset depending on the specified subcommand. This new script is meant to supercede the `scripts/partial_correlations.py` script. * Fix the check for errors * Reorganise the order of arguments for the `partial_correlations_with_target_traits` function: move the `method` argument before the `target_trait_names` argument so that the common arguments in the partial correlation computation functions share the same order.
2022-05-21Fix linting errorsFrederick Muriuki Muriithi
2022-05-16Run computation in one-shot asynchronous processFrederick Muriuki Muriithi
After reworking the worker/runner to have a one-shot mode, add a function that queues up the task and then runs the worker in the one-shot mode to process the computation in the background.
2022-05-06Fix linting and typing errorsFrederick Muriuki Muriithi
2022-05-06Hook up pcorrs with target traits computationsFrederick Muriuki Muriithi
Enable the endpoint to actually compute partial correlations with selected target traits rather than against an entire dataset. Fix some issues caused by recent refactor that broke pcorrs against a dataset
2022-03-30Revert "Run json.loads on request.get_json, since request.get_json was just ↵Frederick Muriuki Muriithi
returning a string" This reverts commit b93b22386056347d8002dd2e403425beeb4657cd. The appropriate fix should have been in GN2. The original statement args = request.get_json() was correct, since `request.get_json()` should return a python object parsed from the JSON string in the request. Unfortunately, GN2 was encoding the request data two times, which led to the call returning a JSON-encoded string instead of the expected object. The issue has been fixed in GN2 and therefore, the "fix" here can be reverted.
2022-03-28Run json.loads on request.get_json, since request.get_json was just ↵zsloan
returning a string
2022-03-22Fixes pylint errorszsloan
2022-03-22Fix issue that causes R/qtl to always run pair-scan even if pair-scan isn't ↵zsloan
selected
2022-03-22Added genofile name to inputs for processing R/qtl pair-scan results, since ↵zsloan
it's needed to store the proximal/distal markers for each position
2022-03-22Fix imports to import both process_rqtl_mapping and process_rqtl_pairscan in ↵zsloan
api/rqtl.py
2022-03-22Added pairscan boolean kwarg and process_rqtl_pairscan function for reading ↵zsloan
in pairscan results + renamed process_rqtl_output to process_rqtl_mapping to distinguish between that and pairscan
2022-03-11Fix some linting issuesFrederick Muriuki Muriithi
2022-03-08Fix tests, and issues caught by testsFrederick Muriuki Muriithi
Fix some issues caught by tests due to changes introducing the hand-off of the partial correlations computations to an external process Fix some issues due to the changes that introduce context managers for database connections Update some tests to take the above two changes into consideration
2022-03-08Create database connections within context managersFrederick Muriuki Muriithi
Use the `with` context manager to open database connections, so as to ensure that those connections are closed once the call is completed. This hopefully avoids the 'too many connections' error
2022-03-04Automatically decode Redis stringsFrederick Muriuki Muriithi
2022-03-03Add endpoint for checking state of external processesFrederick Muriuki Muriithi
Long-running computations are handed off to external processes. This avoids timeouts in the webserver, and also reduces chances of instability of the webserver. The results of these long-running computations are needed eventually, so this commit provides a way to check for the state of the computation, and the results if any.
2022-03-03Run partial correlations in an external processFrederick Muriuki Muriithi
Run the partial correlations code in an external python process decoupling it from the server and making it asynchronous. Summary of changes: * gn3/api/correlation.py: - Remove response processing code - Queue partial corrs processing - Create new endpoint to get results * gn3/commands.py - Compose the pcorrs command to be run in an external process - Enable running of subprocess commands with list args * gn3/responses/__init__.py: new module indicator file * gn3/responses/pcorrs_responses.py: Hold response processing code extracted from ~gn3.api.correlations.py~ file * scripts/partial_correlations.py: CLI script to process the pcorrs * sheepdog/worker.py: - Add the *genenetwork3* path at the beginning of the ~sys.path~ list to override any GN3 in the site-packages - Add any environment variables to be set for the command to be run
2022-02-21Fix a myriad of linter issuesFrederick Muriuki Muriithi
* 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
2022-02-18Test partial correlations endpoint with non-existent primary traitsFrederick Muriuki Muriithi
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.
2022-02-17Test partial correlations endpoint with missing data in POST requestFrederick Muriuki Muriithi
Add a test for the partial correlations endpoint, with: - no data in the request - missing items in the data Fix the bugs caught by the test
2022-02-02response object error fixAlexander Kabui
2022-02-02pep8 formattingAlexander Kabui
2022-02-02return 401 on request failAlexander Kabui
2022-02-02pep8 formattingAlexander Kabui
2022-02-02new line fixAlexander Kabui
2022-01-22generate required json data for ctl apiAlexander Kabui
2022-01-22add endpoint for ctlAlexander Kabui
2022-01-10Convert NaN to NoneFrederick Muriuki Muriithi
Issue: https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/partial-correlations.gmi Comment: https://github.com/genenetwork/genenetwork3/pull/67#issuecomment-1000828159 * Convert NaN values to None to avoid possible bugs with the string replace method used before.
2021-12-24Replace `NaN` with `null` in JSON stringFrederick Muriuki Muriithi
Issue: https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/partial-correlations.gmi * `NaN` is not a valid JSON value, and leads to errors in the code. This commit replaces all `NaN` values with `null`.
2021-12-24Encode the data to JSON and set the status codeFrederick Muriuki Muriithi
Issue: https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/partial-correlations.gmi * Encode bytes objects to string * Encode NaN values to "null" * gn3/api/correlation.py:
2021-12-24Add API endpoint for partial correlationsFrederick Muriuki Muriithi
Issue: https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/partial-correlations.gmi * Add an API endpoint for the partial correlation. * gn3/api/correlation.py:
2021-12-17Add API endpoint for partial correlationsFrederick Muriuki Muriithi
Issue: https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/partial-correlations.gmi * Add an API endpoint for the partial correlation.
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-10-19Enable vertical and horizontal heatmapsFrederick Muriuki Muriithi
Issue: https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/non-clustered-heatmaps-and-flipping.gmi * Update the request endpoint, so that it produces a vertical or horizontal heatmap depending on the user's request.
2021-10-12Merge branch 'main' of https://github.com/genenetwork/genenetwork3 into ↵zsloan
bug/fix_rqtl_covariates
2021-09-27fix merge conflictsAlexander Kabui
2021-09-27Remove unnecessary variable.Frederick Muriuki Muriithi
Issue: https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/clustering.gmi * Fix issue according to review https://github.com/genenetwork/genenetwork3/pull/37#discussion_r714549781
2021-09-23minor fixes for endpointAlexander Kabui
2021-09-22Fix pylint errorsFrederick Muriuki Muriithi
* Add missing function and module docstrings * Remove unused imports * Fix import order * Rework some code sections to fix issues * Disable some pylint errors.
2021-09-22Update check: Heatmaps need at least 2 itemsFrederick Muriuki Muriithi
Issue: https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/clustering.gmi * Update the check to look for at least 2 traits before trying to generate the heatmap.
2021-09-22Return serialized plotly figureFrederick Muriuki Muriithi
Issue: https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/clustering.gmi * gn3/api/heatmaps.py: Serialize the figure to JSON * gn3/heatmaps.py: Return the figure object Serialize the Plotly figure into JSON, and return that, so that it can be used on the client to display the image.
2021-09-22jsonify resultsAlexander Kabui
2021-09-20Enable Cross-Origin Resource SharingFrederick Muriuki Muriithi
Issue: https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/clustering.gmi * gn3/api/heatmaps.py: Fix bugs in data parsing * gn3/app.py: enable CORS * gn3/settings.py: add flask-cors configurations * guix.scm: Add flask-cors dependency For easier testing of the heatmaps generation feature, this commit activates the cross-origin resource sharing for all "localhost" origins.