Skip to main content

Ensembl Python Template

Documentation Status Build Status

Ensembl ValueSet API Project.

This repo contains code for the ValueSets API app. The ValueSets API expose gRPC end points for providing information about Ensembl Value Sets.

An Ensembl ValueSet is a collection of key/value pairs that are related to a given topic. For example, biotypes, APPRIS annotation terms, or transcript support level (TSL) definitions.

A ValueSet item should have the following fields:

  • accession_id (str): value set unique identifier - e.g. "mane.select"
  • label (str): short human friendly name - e.g. "MANE Select"
  • value (str): short machine friendly name - e.g. "select"
  • definition (str): short description - e.g. "A Transcript which is matched between Ensembl/GENCODE and RefSeq as part of the MANE project"
  • description (str|None): optional and verbose definition - e.g. "The Matched Annotation from NCBI and EMBL-EBI is a collaboration between Ensembl/GENCODE and RefSeq. The MANE Select is a default transcript per human gene that is representative of biology, well-supported, expressed and highly-conserved. This transcript set matches GRCh38 and is 100% identical between RefSeq and Ensembl/GENCODE for 5' UTR, CDS, splicing and 3'UTR."

Requirements

  • pyenv (with pyenv-virtualenv plugin)

  • Python 3.10+

  • grpcio

  • grpcio-tools 1.30+

  • openpyxl 3.*+ (optional)

  • poetry

  • Python packages

    • Test
      • pytest
      • pylint
      • mypy
    • Docs
      • Sphinx
      • mock
      • sphinx-rtd-theme
    • Dev
      • ipython
      • black

Getting Started

Clone this repo:

git clone --depth 1 -b main https://github.com/Ensembl/ensembl-valuesets-api.git

Install the python part (of the pipelines) and test it:

pip install ./ensembl-valuesets-api

# test
# do something!

Run the server, listening on default port 50051:

python scripts/run_server.py

Test the server with the provided basic client:

python scripts/client.py

Optional installation

If you need to install "editable" python package use '-e' option

pip install -e ./ensembl-valuesets-api

The following files (or folder names) will need to be modified:

  • docs/conf.py: Change accordigly to project's name
  • docs/install.rst: Change installation instructions accordingly
  • README.md: Write a meaningful README for your project

Once done with the basic customisation, create the initial commit:

cd <NEW_PROJECT_NAME>
git add .
git commit -m 'Initial commit'

Installing the development environment (with Pyenv)

pyenv virtualenv 3.8 <VIRTUAL-ENVIRONMENT-NAME>
cd <NEW_PROJECT_NAME>
pyenv local <VIRTUAL-ENVIRONMENT-NAME>
pip install -r requirements-dev.txt
pip install -e .

Testing

Run test suite:

cd <NEW_PROJECT_NAME>
pytest

To run tests, calculate and display testing coverage stats:

cd <NEW_PROJECT_NAME>
coverage run -m pytest
coverage report -m

Generate documentation

cd <NEW_PROJECT_NAME>
./scripts/build_docs.sh

Open automatically generated documentation page at docs/_build/html/index.html

Automatic Formatting

cd <NEW_PROJECT_NAME>
black --check src tests

Use --diff to print a diff of what Black would change, without actually changing the files.

To actually reformat all files contained in src and test:

cd <NEW_PROJECT_NAME>
black src tests

Linting and type checking

cd <NEW_PROJECT_NAME>
pylint src tests
mypy src tests

Pylint will check the code for syntax, name errors and formatting style. Mypy will use type hints to statically type check the code.

It should be relatively easy (and definitely useful) to integrate both pylint and mypy in your IDE/Text editor.

Project setup with poetry

Clone this repo:

git clone --depth 1 -b main https://github.com/Ensembl/ensembl-valuesets-api.git

Navigate to repo directory and create virtual environment

poetry env use python3

Verify when virtual environment is activated or not

poetry env list

Install the dependencies

poetry install

Run the grpc and rest server from project directory

poetry run python3 -m src.grpc.ensembl.server
poetry run python3 -m uvicorn src.rest.server:app

Test the rest endpoints

curl --location --request GET 'http://localhost:8000/api/valuesets/accession_id/mane.select'
curl --location --request GET 'http://localhost:8000/api/valuesets/value/amino_acid_alphabet?is_current=true'
curl --location --request GET 'http://localhost:8000/api/valuesets?is_current=false'

Installing from pypi

Resources

Python Documentation

Python distributions and virtual environments management

Auto-generating documentation

Linting, type checking and formatting

Testing

Development tools

Distributing

Metadata

Release files for ensembl-valuesets 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ensembl-valuesets 0.1.0
File Size Uploaded Provenance
ensembl_valuesets-0.1.0.tar.gz 23.2 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for ensembl-valuesets 0.1.0
File Interpreter ABI Platform
ensembl_valuesets-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 52.9 kB

Release files / ensembl_valuesets-0.1.0.tar.gz

Download URL ensembl_valuesets-0.1.0.tar.gz
Size 23.2 kB
Tags Source
SHA-256 checksum
How to use checksums
bdda91b5478bb1cda2235438fc1e9648f9f8f71f6a12c56083dbab9e438923b6
BLAKE2b-256 checksum
How to use checksums
c7ad1152468439ea3aa952a4b6d92cfd2753c889d4e450b8e29314607875f367
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.4.2 CPython/3.11.2 Darwin/22.4.0

Release files / ensembl_valuesets-0.1.0-py3-none-any.whl

Download URL ensembl_valuesets-0.1.0-py3-none-any.whl
Size 29.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2c3d8c8227967eab55d8800544fb34951121b131d6132f0d673b33ea5afe5cbd
BLAKE2b-256 checksum
How to use checksums
def5cff2496083cd464cf22e4df63e3e192c841d8f1116adfcd86507a6f0cc28
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.4.2 CPython/3.11.2 Darwin/22.4.0

Security for ensembl-valuesets 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page