-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
initial framework for assayclasses dev server
- Loading branch information
Showing
8 changed files
with
5,355 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>hs-ontology-api</name> | ||
<comment></comment> | ||
<projects> | ||
<project>ubkg-api</project> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.python.pydev.PyDevBuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.python.pydev.pythonNature</nature> | ||
</natures> | ||
</projectDescription> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||
<?eclipse-pydev version="1.0"?><pydev_project> | ||
|
||
<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python interpreter</pydev_property> | ||
|
||
<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property> | ||
|
||
<pydev_pathproperty name="org.python.pydev.PROJECT_SOURCE_PATH"> | ||
<path>/${PROJECT_DIR_NAME}/src</path> | ||
<path>/${PROJECT_DIR_NAME}/dev</path> | ||
</pydev_pathproperty> | ||
|
||
</pydev_project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#config file | ||
instance/app.cfg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
## Development AssayClasses RESTful service | ||
|
||
The service contained within this directory exposes two endpoints: | ||
- /assayclasses?application_context=HUBMAP | ||
- assayclasses/<assay-code>?application_context=HUBMAP | ||
|
||
To run this service, in this directory: | ||
- copy instance/app.cfg.example to instance/app.cfg | ||
- create a python virtual environment with the contents of requirements.txt imported into the environment | ||
- source/activage the virtual environment | ||
- execute `python app.py` | ||
The service will be available on port 8181. | ||
|
||
Both endpoints require the `application_context=HUBMAP` parameter. (A future version will allow SENNET context as well, which will read results from a different file). | ||
|
||
The `/assayclasses` endpoint simply returns the contents of the file https://raw.githubusercontent.com/x-atlas-consortia/hs-ontology-api/dev-integrate/dev/assayclasses.json as a json response. | ||
|
||
The `/assayclasses/<assay-code>` endpoint searches the same [assayclasses.json file](https://raw.githubusercontent.com/x-atlas-consortia/hs-ontology-api/dev-integrate/dev/assayclasses.json) for an assayclass item matching `rule_description.code` and returns the full matching assayclass item as a json response. If the code is not found a 404 is returned. For example if `/assayclasses/C200001?application_context=HUBMAP` is called the return value is: | ||
|
||
``` | ||
{ | ||
"rule_description": { | ||
"application_context": "HUBMAP", | ||
"code": "C200150", | ||
"name": "non-DCWG primary IMC2D" | ||
}, | ||
"value": { | ||
"active_status": "active", | ||
"assaytype": "IMC2D", | ||
"dataset_type": { | ||
"PDR_category": "MxNF", | ||
"dataset_type": "2D Imaging Mass Cytometry", | ||
"fig2": { | ||
"aggregated_assaytype": "LC-MS", | ||
"category": "bulk", | ||
"modality": "Proteomics" | ||
} | ||
}, | ||
"description": "2D Imaging Mass Cytometry", | ||
"dir_schema": "imc-v0", | ||
"is_multiassay": false, | ||
"measurement_assay": { | ||
"codes": [ | ||
{ | ||
"code": "SENNET:C006901", | ||
"term": "Imaging Mass Cytometry Measurement Assay" | ||
}, | ||
{ | ||
"code": "HUBMAP:C006901", | ||
"term": "Imaging Mass Cytometry Measurement Assay" | ||
}, | ||
{ | ||
"code": "OBI:0003096", | ||
"term": "imaging mass cytometry assay" | ||
} | ||
], | ||
"contains_full_genetic_sequences": false | ||
}, | ||
"must_contain": [], | ||
"pipeline_shorthand": null, | ||
"process_state": "primary", | ||
"provider": "IEC", | ||
"tbl_schema": "imc-v", | ||
"vitessce_hints": [] | ||
} | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import os | ||
import json | ||
from flask import Flask, Response | ||
|
||
# Specify the absolute path of the instance folder and use the config file relative to the instance path | ||
app = Flask(__name__, | ||
instance_path=os.path.join(os.path.abspath(os.path.dirname(__file__)), 'instance'), | ||
instance_relative_config=True) | ||
app.config.from_pyfile('app.cfg') | ||
|
||
@app.route('/', methods=['GET']) | ||
def index(): | ||
return "Hello! This is the DEV AssayClass service :)" | ||
|
||
@app.route('/assayclasses/<code>', methods=['GET']) | ||
def assayclasses(code): | ||
response_code = 200 | ||
response_data = { | ||
'message': f'This endpoint not yet implemented code: {code}' | ||
} | ||
|
||
return Response(json.dumps(response_data), response_code, mimetype='application/json') | ||
|
||
@app.route('/assayclasses', methods=['GET']) | ||
def assayclass_by_code(): | ||
response_code = 200 | ||
response_data = { | ||
'message': 'This endpoint not yet implemented' | ||
} | ||
|
||
return Response(json.dumps(response_data), response_code, mimetype='application/json') | ||
|
||
|
||
# For development/testing only | ||
if __name__ == '__main__': | ||
try: | ||
port = 8181 | ||
app.run(port=port, host='0.0.0.0') | ||
finally: | ||
pass |
Oops, something went wrong.