diff options
author | Frederick Muriuki Muriithi | 2023-08-21 09:53:00 +0300 |
---|---|---|
committer | Frederick Muriuki Muriithi | 2023-10-10 11:12:41 +0300 |
commit | 963c226fa61f04efcb36e2a185d829594127c4b4 (patch) | |
tree | a071cfd65b1f734523354c74452302de1b57a8a0 /gn3 | |
parent | 0a8279891190e49867d3a1d72db0f7c7cd275646 (diff) | |
download | genenetwork3-963c226fa61f04efcb36e2a185d829594127c4b4.tar.gz |
Editing: Retrieve case attributes by the related InbredSet
Diffstat (limited to 'gn3')
-rw-r--r-- | gn3/app.py | 2 | ||||
-rw-r--r-- | gn3/case_attributes.py | 17 |
2 files changed, 19 insertions, 0 deletions
@@ -27,6 +27,7 @@ from gn3.api.search import search from gn3.api.metadata import metadata from gn3.api.sampledata import sampledata from gn3.auth import oauth2 +from gn3.case_attributes import caseattr def create_app(config: Union[Dict, str, None] = None) -> Flask: @@ -76,6 +77,7 @@ def create_app(config: Union[Dict, str, None] = None) -> Flask: app.register_blueprint(metadata, url_prefix="/api/metadata") app.register_blueprint(sampledata, url_prefix="/api/sampledata") app.register_blueprint(oauth2, url_prefix="/api/oauth2") + app.register_blueprint(caseattr, url_prefix="/api/case-attribute") register_error_handlers(app) return app diff --git a/gn3/case_attributes.py b/gn3/case_attributes.py new file mode 100644 index 0000000..590052a --- /dev/null +++ b/gn3/case_attributes.py @@ -0,0 +1,17 @@ +"""Implement case-attribute manipulations.""" +from MySQLdb.cursors import DictCursor +from flask import jsonify, Response, Blueprint, current_app + +from gn3.db_utils import database_connection + +caseattr = Blueprint("case-attribute", __name__) + +@caseattr.route("/<int:inbredset_id>", methods=["GET"]) +def inbredset_case_attributes(inbredset_id: int) -> Response: + """Retrieve ALL case-attributes for a specific InbredSet group.""" + with (database_connection(current_app.config["SQL_URI"]) as conn, + conn.cursor(cursorclass=DictCursor) as cursor): + cursor.execute( + "SELECT * FROM CaseAttribute WHERE InbredSetId=%(inbredset_id)s", + {"inbredset_id": inbredset_id}) + return jsonify(tuple(dict(row) for row in cursor.fetchall())) |