This is a Go microservice to convert CX stream into other formats.
(TBD)
You can run this service as a single RESTful API server independent from Cytoscape CI.
-
Requirments
- Go 1.5.x and later
-
Clone this repository
-
cd data
-
Run this command to download and create mapping tables from NCBI and Uniprot:
python ./data_table_generator.py
-
cd ..
-
go build app.go
-
./app
Then access http://localhost:3000/
to check the server is actually working or not.
The easiest way to run this application is using Docker. Suppose you are using Docker host running on 192.168.99.100
.
This service works in two modes:
If you run this service without elsa instance, it works as a simple RESTful API server. You can use your server by directly send your POST requests to it.
If you have a running instance of elsa, the registration process is (semi) automatic. You can specify the following command-line options to register the service to elsa.
(TBD)
Options
- id - ID of this service (e.g., idmapping)
- ver - version of this API (e.g., v1)
- port - Port number of this service
- agent - Location of elsa instance
- Function - Show service information
- Supported Methods - GET
- Output
{
}
- Function - Convert CX into Cytoscape.js
- Supported Methods - POST
{
}
import json, requests
SERVICE_URL = "http://192.168.99.100:3000/converter/cx2cyjs" # Replace this to your server location.
res = requests.post(SERVICE_URL, json=query)
print(res.json())
If the query does not contain required parameters (for this version, ids is the only required field) the service returns this error.
-
Code: 400
-
Body:
{ "code": 400, "message": "Invalid query. Probably you missed ids parameter?", "error": "(Any error massage from the system.)" }
-
Example
You will see this when you use unsupported HTTP method for an endpoint. For example you need to use POST method to call this ID Mapping service, and you will get this error when you simply call the URL with GET method.
-
Code: 405
-
Body:
{ "code": 405, "message": "Unsupported HTTP request type.", "error": "You need to use POST method to use this endpoint." }
-
Example
If the service cannot find any result, it returns this error.
-
Code: 404
-
Body:
{ "code": 404, "message": "No resource found for your query.", "error": "No maching IDs for your inputs" }
Usually this should not happen. In Go, if critical panic happens due to bugs, this will be returned to the user.
-
Code: 500
-
Body:
{ "code": 500, "message": "Something wrong happened to the service. Now is the good time to call admin...", "error": "(stack trace, panic message, heap dump, etc.)" }