Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
eadf969
First attempt at API hosting hgvs conversion
PeterKnealeCMRI Aug 10, 2023
99a097e
Add dockerfile
PeterKnealeCMRI Aug 10, 2023
06523a3
Create QuickStart.md
PeterKnealeCMRI Aug 10, 2023
5b011f0
Update QuickStart.md
PeterKnealeCMRI Aug 10, 2023
6e33d34
Update QuickStart.md
PeterKnealeCMRI Aug 10, 2023
fbb7acc
Refactoring
h-joshi Aug 11, 2023
edfe3cc
Testing framework WIP
h-joshi Aug 11, 2023
444d3e4
Added tests and valid, invalid scenarios
h-joshi Aug 13, 2023
2542fea
Merge pull request #2 from kidsneuro-lab/test_data_prep
h-joshi Aug 13, 2023
e99fbdf
API and Docker build fixes
h-joshi Aug 13, 2023
1bab89d
Create docker-image.yml
PeterKnealeCMRI Aug 14, 2023
d574ba9
Setup basic docker action
PeterKnealeCMRI Aug 14, 2023
ec457b3
Add env
PeterKnealeCMRI Aug 14, 2023
396074f
Use var for username
PeterKnealeCMRI Aug 14, 2023
b7d3ad5
Apply docker tags
PeterKnealeCMRI Aug 14, 2023
7649638
Add download_refGene.sh -hg38
PeterKnealeCMRI Aug 14, 2023
e636728
Add notes on pulling images
PeterKnealeCMRI Aug 14, 2023
7274b72
Break on first error and dont run in interactive mode
PeterKnealeCMRI Aug 14, 2023
9c47816
Break on first error and dont run in interactive mode
PeterKnealeCMRI Aug 14, 2023
1113fc9
Isolate error conditions - missing env var vs missing file
PeterKnealeCMRI Aug 14, 2023
f590447
Add env vars to devcontainer environment
PeterKnealeCMRI Aug 14, 2023
a498999
No longer ignore files that are downloaded
PeterKnealeCMRI Aug 14, 2023
c753cef
Use the files copied in at build time rather than those mounted
PeterKnealeCMRI Aug 14, 2023
b255c65
add notes
PeterKnealeCMRI Aug 14, 2023
136a42e
Updated python version, packaging and cli
h-joshi Aug 14, 2023
abb626e
Removing file accidentally added
h-joshi Aug 14, 2023
85e9e88
Add command to run via docker run
PeterKnealeCMRI Aug 14, 2023
6a483d7
Fix paths to assemblies and reference in docker compose
PeterKnealeCMRI Aug 14, 2023
9c971fb
Add graceful shutdown timeout
PeterKnealeCMRI Aug 14, 2023
c7a8c40
Reduced error verbosity in CLI
h-joshi Aug 14, 2023
d382c93
Execute tests on the PR, deploy on merge to master
PeterKnealeCMRI Aug 14, 2023
900d0ac
Merge branch 'master' of github.com:kidsneuro-lab/hgvs
PeterKnealeCMRI Aug 14, 2023
132a806
Always push on master
PeterKnealeCMRI Aug 14, 2023
9f2916b
Rename actions
PeterKnealeCMRI Aug 14, 2023
6cbffaf
tests (#5)
PeterKnealeCMRI Aug 14, 2023
f8a116c
Fixed use of tests fixtures (#7)
h-joshi Aug 14, 2023
2ac776d
Fixed hgvs2vcf header (#8)
h-joshi Aug 14, 2023
5669a8d
Updated assembly and refgene to use non "chr" (#9)
h-joshi Aug 15, 2023
b14e069
Update QuickStart.md (#10)
PeterKnealeCMRI Aug 16, 2023
5544976
Update QuickStart.md (#13)
PeterKnealeCMRI Aug 16, 2023
17e0bcc
Log file names (#12)
PeterKnealeCMRI Aug 16, 2023
5643a4c
Publish under new dockerhub username: kidsneurolab (#14)
PeterKnealeCMRI Sep 20, 2023
075bc7e
update docker file to port 8002 (#15)
PeterKnealeCMRI Sep 21, 2023
5741a64
Update docker repository name again (#16)
PeterKnealeCMRI Sep 21, 2023
f2f540f
Add alive and ready endpoints (#17)
PeterKnealeCMRI Sep 21, 2023
effca07
Update pull_request.yml
PeterKnealeCMRI Nov 27, 2023
070aeea
Issue #18. Add pre-computed outputs for the valid files (#19)
PeterKnealeCMRI Nov 27, 2023
10b0787
Add BCF Tools to dev container
PeterKnealeCMRI Nov 27, 2023
2fbc494
ignore bcf tools folder
PeterKnealeCMRI Nov 27, 2023
0dbf992
normalise and report (#23)
PeterKnealeCMRI Nov 28, 2023
1d2e1f2
Support returning 400 bad request for invalid HGVS input
PeterKnealeCMRI Nov 28, 2023
a9a1b44
Setup dev container better
PeterKnealeCMRI Dec 1, 2023
74d803a
Switch from get to post to mitigate the url encoding issue with +'s
PeterKnealeCMRI Dec 1, 2023
7414bda
Fix logging issue when running integration tests
PeterKnealeCMRI Dec 1, 2023
bb28869
Remove the chr for consistancy
PeterKnealeCMRI Dec 1, 2023
009175a
Updated API, error handling and tests (#29)
h-joshi Jan 23, 2024
2b11a75
hotfix/removed-pytest-env-override (#30)
h-joshi Jan 23, 2024
72c139b
Update .dockerignore (#31)
h-joshi Jan 23, 2024
31d4ba0
Ensuring test fixtures are avail during publish (#32)
h-joshi Jan 23, 2024
126eab2
Update README.md (#33)
h-joshi Jan 23, 2024
bf264a0
Handling of multiple loci for given transcript
h-joshi Mar 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/python
{
"name": "Python 3 + bcftools",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"image": "mcr.microsoft.com/devcontainers/python:3.10-bullseye",
"features": {
"ghcr.io/jungaretti/features/make:1": {}
},
"containerEnv": {
"PIP_DISABLE_PIP_VERSION_CHECK": "1",
"FASTA":"tests/fixtures/Homo_sapiens.GRCh38.dna.chromosome.X.Y.fa",
"REFGENE":"tests/fixtures/genes.refGene"
},

// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
"forwardPorts": [9001],

// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "bash .devcontainer/setup_python.sh; bash .devcontainer/setup_dependencies.sh",
"customizations": {
"vscode": {
"extensions": [
"alexkrechik.cucumberautocomplete"
]
}
}

// Configure tool-specific properties.
// "customizations": {},

// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}
23 changes: 23 additions & 0 deletions .devcontainer/setup_dependencies.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash
set -e

BCFTOOLS_VERSION="1.18"

sudo apt-get update
sudo apt-get install -y wget build-essential bzip2 libz-dev liblzma-dev libbz2-dev libcurl4-openssl-dev

CURRENT_DIR=`pwd`

# Install bcftools
wget -q https://github.com/samtools/bcftools/releases/download/$BCFTOOLS_VERSION/bcftools-$BCFTOOLS_VERSION.tar.bz2
tar -vxjf bcftools-$BCFTOOLS_VERSION.tar.bz2
cd bcftools-$BCFTOOLS_VERSION
sudo make install
cd $CURRENT_DIR
rm -f bcftools-$BCFTOOLS_VERSION.tar.bz2
rm -rf bcftools-$BCFTOOLS_VERSION

# Install vcf_validator_linux
wget -q https://github.com/EBIvariation/vcf-validator/releases/download/v0.9.5/vcf_validator_linux
chmod +x vcf_validator_linux
sudo mv vcf_validator_linux /usr/local/bin
5 changes: 5 additions & 0 deletions .devcontainer/setup_python.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash
set -e

pip3 install --user -r requirements.txt
pip3 install --user -r requirements-dev.txt
52 changes: 52 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
*.py[cod]

# Emacs files
*~
*#

# FASTA files
*.fa.seqlen
*.fa.pureseq
*.fa.fai

# C extensions
*.so

# Packages
*.egg
*.egg-info
dist
build
eggs
parts
var
sdist
develop-eggs
.installed.cfg
lib
lib64
.venv

# Installer logs
pip-log.txt

# Unit test / coverage reports
.coverage
.tox
nosetests.xml

# Translations
*.mo

# Mr Developer
.mr.developer.cfg
.project
.pydevproject
.idea

dist
.git
.devcontainer

# Ignore generated files
**/*.pyc
60 changes: 60 additions & 0 deletions .github/workflows/publish_to_dockerhub.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: publish_to_dockerhub

on:
workflow_dispatch:
push:
branches:
- master

jobs:

publish_to_dockerhub:
runs-on: ubuntu-latest

environment:
name: dev

steps:
- uses: actions/checkout@v3

- name: Download refGene (sample dataset for tests)
run: ./download_refGene.sh -hg38_sample

- name: Run tests
run: ./run-tests.sh

- name: Cleanup
run: |
echo "Removing test fixtures"
rm -f tests/fixtures/Homo_sapiens.GRCh38.dna.chromosome.X.fa*
rm -f tests/fixtures/genes.refGene
rm -f tests/fixtures/LRG_RefSeqGene

- name: Download refGene
run: ./download_refGene.sh -hg38

- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ vars.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ vars.DOCKERHUB_USERNAME }}/hgvs
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=sha

- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
23 changes: 23 additions & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: pull_request

on:
pull_request:
branches:
- master

jobs:

pull_request:
runs-on: ubuntu-latest

environment:
name: dev

steps:
- uses: actions/checkout@v3

- name: Download refGene (sample dataset for tests)
run: ./download_refGene.sh -hg38_sample

- name: Run Tests
run: ./run-tests.sh
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,14 @@ nosetests.xml
.project
.pydevproject
.idea

assemblies
reference
**/genes.refGene
**/LRG_RefSeqGene
tests/fixtures/*.fa**

**/.DS_Store
/bcftools*
/tests/fixtures/hgvs_normalised/vcf_validator_linux
*.vcf
42 changes: 42 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: FastAPI",
"type": "python",
"request": "launch",
"module": "uvicorn",
"env": {
"FASTA": "assemblies/Homo_sapiens.GRCh38.dna.primary_assembly.fa",
"REFGENE": "reference/genes.refGene"
},
"args": [
"pyhgvs.api:app",
"--port", "9001",
"--reload"
],
"jinja": true,
"justMyCode": true
},
{
"name": "Python: FastAPI - chrX",
"type": "python",
"request": "launch",
"module": "uvicorn",
"env": {
"FASTA": "tests/fixtures/Homo_sapiens.GRCh38.dna.chromosome.X.Y.fa",
"REFGENE": "tests/fixtures/genes.refGene"
},
"args": [
"pyhgvs.api:app",
"--port", "9001",
"--reload"
],
"jinja": true,
"justMyCode": true
}
]
}
7 changes: 7 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"python.testing.pytestArgs": [
"tests"
],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true
}
30 changes: 30 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#################################################################################
# STAGE - BUILD
#################################################################################
FROM python:3.10-slim as build

# Keeps Python from generating .pyc files in the container
ENV PYTHONDONTWRITEBYTECODE=1
# Turns off buffering for easier container logging
ENV PYTHONUNBUFFERED=1

WORKDIR /app
COPY requirements.txt .
RUN python -m pip install --no-cache-dir --disable-pip-version-check -r requirements.txt
COPY . /app

#################################################################################
# STAGE - TESTS
#################################################################################
FROM build as tests
RUN python -m pip install --no-cache-dir --disable-pip-version-check -r requirements-dev.txt

#################################################################################
# STAGE - RUNTIME
#################################################################################
FROM python:3.10-slim AS runtime
ENV PYTHONUNBUFFERED=1
WORKDIR /app
COPY --from=build /app /app
COPY --from=build /usr/local /usr/local
CMD ["uvicorn", "pyhgvs.api:app", "--host", "0.0.0.0", "--port", "8002"]
35 changes: 5 additions & 30 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,32 +1,10 @@
#! /usr/bin/make

PACKAGE_NAME=pyhgvs
SCRIPTS=bin/hgvs
TEST_OUTPUT?=nosetests.xml

VENV_DIR?=.venv
VENV_ACTIVATE=$(VENV_DIR)/bin/activate
WITH_VENV=. $(VENV_ACTIVATE);

default:
python setup.py check build

.PHONY: setup clean teardown venv lint test gitlint

setup: venv
default: package

venv: $(VENV_ACTIVATE)

$(VENV_DIR)/bin/activate: requirements-dev.txt
test -d $(VENV_DIR) || virtualenv --python=python2.7 --system-site-packages $(VENV_DIR)
$(WITH_VENV) pip install -r requirements-dev.txt
touch $(VENV_DIR)/bin/activate

teardown:
rm -rf $(VENV_DIR)/
.PHONY: clean lint test

clean:
python setup.py clean
rm -rf build/
rm -rf dist/
rm -rf *.egg*/
Expand All @@ -35,11 +13,8 @@ clean:
rm -f $(TEST_OUTPUT)
find $(PACKAGE_NAME) -type f -name '*.pyc' -delete

lint: venv
$(WITH_VENV) flake8 --jobs=auto $(PACKAGE_NAME)/ $(SCRIPTS)

test: venv
$(WITH_VENV) nosetests --verbosity=2 --with-xunit --xunit-file=$(TEST_OUTPUT)
lint:
flake8 --jobs=auto $(PACKAGE_NAME)/ $(SCRIPTS)

package:
python setup.py sdist
python3 -m build
Loading