/3d-beacons-hub-api

Primary LanguagePythonApache License 2.0Apache-2.0

3D Beacons Hub API

Welcome to the 3D Beacons Hub API

codecov build license

3D Beacons Hub API is a programmatic way to obtain information of available experimental and theoretical models for a protein of interest.

Background

3D-Beacons is an open collaboration between providers of macromolecular structure models. The goal of this collaboration is to provide model coordinates and meta-information from all the contributing data resources in a standardized data format and on a unified platform.

Image

Schematical overview of the 3D-Beacons infrastructure

3D-Beacons consists of a Registry, a Hub and Beacons who host Clients. The Registry is used by the Hub to look up which API endpoints are supported by the various Beacons. The Beacons provide data according to the 3D-Beacons data specifications (Current version: 0.3.1). The Hub collates the data from the Beacons and expose it via Hub API endpoints.

Current 3D-Beacons

About the 3D-Beacons Hub API

The 3D-Beacons Hub API is an integrator that makes API requests to Beacon APIs and collates, ranks and exposes data. The Hub API is using the 3D-Beacons Registry to look up which Beacons support what API endpoint.

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.

Prerequisites

Below are the list of softwares/tools for the utilities to properly run in the environment.

Python 3.7+

Note

Because Python 2.7 supports ended January 1, 2020, new projects should consider supporting Python 3 only, which is simpler than trying to support both. As a result, support for Python 2.7 in this project has been dropped.

Setup the environment

Setup a Python virtual environment and install required packages.

$ python3 -m venv venv
$ source venv/bin/activate

Once activated, it is good practice to update core packaging tools (pip, setuptools, and wheel) to the latest versions.

(venv) $ python -m pip install --upgrade pip setuptools wheel

Now install the project dependencies.

(venv) $ pip install -r dev-requirements.txt
(venv) $ pip install -r requirements.txt

Provide registry data

This API works on a registry which includes the details of data services and the respective providers which is configured in app/config/data.json. It can be overriden to be picked from a URL. For doing so, set the environmental variable REGISTRY_DATA_JSON as the URL.

Run the instance

To run the API locally, run below commands.

source venv/bin/activate
(venv) $ uvicorn app.app:app --reload

This spawns a local uvicorn server and hosts the API on it.

Use http://127.0.0.1:8000/docs to access swagger documentation. Alternatively use http://127.0.0.1:8000/redoc to use ReDoc version of the documentation.

Alternatively, the API can be run from the Dockerfile. To do so, follow below steps.

# build the docker image
docker build -t 3dbeacons-hub-api .

# run the application
docker run -p 8000:8000 3dbeacons-hub-api

Unit Testing

Unit testing is performed with pytest.

pytest will automatically discover and run tests by recursively searching for folders and .py files prefixed with test for any functions prefixed by test.

Code coverage is provided by the pytest-cov plugin.

Code coverage is configured in pyproject.toml.

Workflow automation using pre-commit hooks

Code formatting and PEP8 compliance are automated using pre-commit hooks. This is configured in .pre-commit-config.yaml which will run these hooks before commit ting anything to the repository.

Please note that this is already installed via dev-requirements.txt.

Contributors

See also the list of contributors who participated in this project.

How to contribute

This repository is open to contributions. Please fork the repository and send pull requests.