Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

initial framework for assayclasses dev server #115

Merged
merged 1 commit into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .project
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>
13 changes: 13 additions & 0 deletions .pydevproject
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>
2 changes: 2 additions & 0 deletions dev/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#config file
instance/app.cfg
67 changes: 67 additions & 0 deletions dev/README.md
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": []
}
}
```
40 changes: 40 additions & 0 deletions dev/app.py
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
Loading
Loading