Python Modules¶
The beacon_api
package contains code to start an EGA Beacon API.
Note
In this file the information about the Beacon
is registered.
The information is parsed from beacon_api.conf.config.ini
beacon_api.schemas |
Load JSON Schemas. |
beacon_api.api |
Beacon API endpoints. |
beacon_api.permissions |
Permissions Module. |
beacon_api.utils |
Utilities Module. |
beacon_api.conf |
Beacon Python Application Configuration. |
beacon_api.extensions |
Extensions Module. |
API Schemas¶
Load JSON Schemas.
The JSON schemas represent a good method of checking that an endpoint’s requests/responses adhere to the API specification. Schemas available:
info.json
- for the/info
endpoint response;query.json
- for the/query
endpoint request;response.json
- beacon API JSON response.
Example snippets from query.json
:
"referenceName": {
"type": "string",
"enum": ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12",
"13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "X", "Y", "MT"
]
"start": {
"type": "integer",
"minimum": 0
},
"end": {
"type": "integer",
"minimum": 0
},
"startMin": {
"type": "integer",
"minimum": 0
},
"startMax": {
"type": "integer",
"minimum": 0
},
"endMin": {
"type": "integer",
"minimum": 0
},
"endMax": {
"type": "integer",
"minimum": 0
},
"dependencies": {
"end": [
"start"
],
"startMin": [
"startMax"
],
"endMin": [
"endMax"
],
"startMax": ["startMin"],
"endMax": ["endMin"],
"mateName": {
"oneOf": [{
"required": [
"start"
]
},
{
"required": [
"startMin"
],
"not": {
"required": [
"endMin"
]
}
}
]
}
},
Beacon API¶
Beacon API endpoints.
The endpoints reflect the specification provided by: https://github.com/ga4gh-beacon/specification/blob/develop/beacon.md Endpoints:
/
- Information about the datasets in the Beacon;/service-info
- Information about the Beacon in GA4GH format (extra endpoint);/query
- querying/filtering datasets in the Beacon;
beacon_api.api.info |
Info Endpoint. |
beacon_api.api.query |
Query Endpoint. |
beacon_api.api.exceptions |
Custom API exception reponses. |
Utility Functions¶
Utilities Module.
Contains utilities such as database create/load, JSON schema validation, token authentication.
Also contains necessary functions for querying the DB and retrieving and transforming data to desired format.
Other functions include logging formatter.
beacon_api.utils.logging |
Logging formatting. |
beacon_api.utils.db_load |
Beacon Database Loader. |
beacon_api.utils.validate |
JSON Request/Response Validation and Token authentication. |
beacon_api.utils.data_query |
Query DB and prepare data for reponse. |
Permissions Addons¶
Permissions Module.
Module for getting permissions to datasets, more precisely CONTROLLED
datasets.
This module was designed to be addon based, where users of the beacon-python
app can
write their implementation for parsing a specific JWT token claim
that contains CONTROLLED
permissions to datasets.
Each file added in this module will consist of a function for parsing a permissions claim
from a JWT token. Then this function MUST be added to utils.validate
module in order
to pass permissions when retrieving datasets from the database.
To avoid collisions check that your claim for permissions does not conflict with existing ones: https://www.iana.org/assignments/jwt/jwt.xhtml
beacon_api.permissions.ga4gh |
Parse permissions and statuses from ELIXIR token for GA4GH claim. |
Extensions¶
Extensions Module.
This module contains optional extensions to the Beacon Python Server. Currently we have two extensions:
- handover - used to convey extra information regarding the Beacon service, or the dataset response;
- mate fusion - used for finding breakend records.
beacon_api.extensions.handover |
Prepare Handover. |
beacon_api.extensions.mate_name |
Prepare mate. |