A REST interface wrapping matchms for MassBank.
This server was generated by the OpenAPI Generator project and uses the Connexion library on top of Flask.
Tested on Python 3.13
This microservice is configured with environment variables. The reference
spectra are initialized from a local file directory (root directory). The directory location needs to be
configured in the environment variable DATA_DIR
. For MassBank we configure the
service with the latest MassBank-data release in file format.
# get the latest release artifact of MassBank-data (reference data) and put it into MassBank-data folder
version=$(curl -s https://api.github.com/repos/MassBank/MassBank-data/releases/latest \
| grep "tag_name" | sed "s/\"tag_name\": //g" | sed "s/\"//g" | sed "s/,//g" | sed "s/ //g")
mkdir -p MassBank-data
wget -qO- https://github.com/MassBank/MassBank-data/archive/refs/tags/$version.tar.gz | \
tar -xzf - -C ./MassBank-data --strip-components=1
Now we set the environment variable:
export DATA_DIR="./MassBank-data"
A more verbose logging can be activated by setting environment variable VERBOSE to "true".
export VERBOSE=true
The application context path can be configured with the environment variable CONTEXT_PATH. If not set / is used by default.
To run the server, install the requirements, generate the server code and start the server like this:
python3 -m venv venv && \
venv/bin/pip3 install -r requirements.txt && \
bash generate.sh && \
python3 -m similarity_api_impl
You can find the swagger ui at http://localhost:8080/ui/ and the OpenAPI definition at http://localhost:8080/openapi.json in your browser.
To run the server in a Docker container, execute the following commands:
# get the latest release artifact of MassBank-data (reference data) and put it into MassBank-data folder
version=$(curl -s https://api.github.com/repos/MassBank/MassBank-data/releases/latest \
| grep "tag_name" | sed "s/\"tag_name\": //g" | sed "s/\"//g" | sed "s/,//g" | sed "s/ //g") && \
wget -O MassBank-data-$version.tar.gz https://github.com/MassBank/MassBank-data/archive/refs/tags/$version.tar.gz && \
tar -xzf MassBank-data-$version.tar.gz && \
mv MassBank-data-$version MassBank-data
# building the image
docker build -t massbank-similarity-api .
# starting up a container with directory to MassBank data (reference)
docker run -p 8080:8080 \
-v $(pwd)/MassBank-data:/MassBank-data \
-e DATA_DIR='/MassBank-data' \
massbank-similarity-api
Prebuild docker images are available from
quay.io/massbank/massbank-similarity-api.
The fastest way to get things running is:
# get the latest reference data (as described above)
# ...
# starting up a container
docker run -p 8080:8080 \
-v $(pwd)/MassBank-data:/MassBank-data \
-e DATA_DIR='/MassBank-data' \
quay.io/massbank/massbank-similarity-api:latest