Skip to content

Commit

Permalink
Merge pull request #43 from UMCUGenetics/feature/refactor_kinship_pri…
Browse files Browse the repository at this point in the history
…nt_to_write

Feature/refactor kinship print to write
  • Loading branch information
ellendejong authored Oct 21, 2024
2 parents d571ef0 + 3f4ef68 commit 12f456a
Show file tree
Hide file tree
Showing 19 changed files with 1,003 additions and 85 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/kinship_lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Kinship Lint
on:
pull_request:
paths: [Kinship/**]
push:
branches: [master, develop]
paths: [Kinship/**]

jobs:
ruff:
runs-on: ubuntu-latest
defaults:
run:
working-directory: Kinship/
steps:
- uses: actions/checkout@v4
- uses: chartboost/ruff-action@v1
63 changes: 63 additions & 0 deletions .github/workflows/kinship_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Source: https://github.com/marketplace/actions/install-poetry-action
name: Kinship Test
on:
pull_request:
paths: [Kinship/**]
push:
branches: [master, develop]
paths: [Kinship/**]

jobs:
pytest:
runs-on: ubuntu-latest
defaults:
run:
working-directory: Kinship/
steps:
#----------------------------------------------
# check-out repo and set-up python
#----------------------------------------------
- name: Check out repository
uses: actions/checkout@v4
- name: Set up python
id: setup-python
uses: actions/setup-python@v5
with:
python-version: '3.11.5'
#----------------------------------------------
# install & configure poetry
#----------------------------------------------
- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: 1.8.3
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true

#----------------------------------------------
# load cached venv if cache exists
#----------------------------------------------
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v4
with:
path: .venv
key: venv_kinship-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
#----------------------------------------------
# install dependencies if cache does not exist
#----------------------------------------------
- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root
#----------------------------------------------
# install root project
#----------------------------------------------
- name: Install project
run: poetry install --no-interaction
#----------------------------------------------
# run pytest
#----------------------------------------------
- name: Run tests
run: |
poetry run pytest .
42 changes: 38 additions & 4 deletions Kinship/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,44 @@
FROM --platform=linux/amd64 continuumio/miniconda3
################## BASE IMAGEs ######################
FROM continuumio/miniconda3:24.5.0-0

LABEL base_image="continuumio/miniconda3"
LABEL version="1.0.0"
LABEL extra.binaries="vcftools, plink, king"
################## METADATA ######################
LABEL base_image="continuumio/miniconda3:24.5.0-0"
LABEL version="1.1.1"
LABEL extra.binaries="vcftools, plink, king, pandas"

################## INSTALLATIONS ######################
# Use conda to install other dependencies.
RUN conda config --add channels bioconda && \
conda config --add channels conda-forge && \
conda install -y vcftools=0.1.14 plink=1.90b4 king=2.2.7

# Use poetry to install virtualenv.
ENV POETRY_VERSION=1.8.3
ENV POETRY_HOME=/opt/poetry
ENV POETRY_VENV=/opt/poetry-venv

# Tell Poetry where to place its cache and virtual environment
ENV POETRY_CACHE_DIR=/tmp/poetry_cache

# Do not ask any interactive question
ENV POETRY_NO_INTERACTION=1

# Make poetry create the virtual environment in the project's root
# it gets named `.venv`
ENV POETRY_VIRTUALENVS_IN_PROJECT=1
ENV POETRY_VIRTUALENVS_CREATE=1

# Set virtual_env variable
ENV VIRTUAL_ENV=/.venv
# Prepend virtual environments path
ENV PATH="${VIRTUAL_ENV}/bin:${POETRY_VENV}/bin:${PATH}"

# Creating a virtual environment just for poetry and install it with pip
RUN python3 -m venv $POETRY_VENV \
&& $POETRY_VENV/bin/pip3 install poetry==${POETRY_VERSION}

# Copy project requirement files here to ensure they will be cached.
COPY pyproject.toml poetry.lock ./

# Install dependencies.
RUN --mount=type=cache,target=$POETRY_CACHE_DIR poetry install --without dev --no-interaction --no-cache
7 changes: 4 additions & 3 deletions Kinship/Kinship.nf
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
process Kinship {
tag {"Kinship ${analysis_id}"}
label 'Kinship'
container = 'docker.io/umcugenbioinf/kinship:1.0.0'
container = 'ghcr.io/umcugenetics/kinship:1.1.1'

shell = ['/bin/bash', '-euo', 'pipefail']

input:
Expand All @@ -17,6 +18,6 @@ process Kinship {
plink --file out --make-bed --noweb
king -b plink.bed --kinship
cp king.kin0 ${analysis_id}.kinship
python ${projectDir}/CustomModules/Kinship/check_kinship.py ${analysis_id}.kinship ${ped_file} > ${analysis_id}.kinship_check.out
python ${projectDir}/CustomModules/Kinship/check_kinship.py ${analysis_id}.kinship ${ped_file} --output_prefix ${analysis_id} --output_path .
"""
}
}
Loading

0 comments on commit 12f456a

Please sign in to comment.