Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
wolthuisr authored Jun 12, 2024
0 parents commit bfb6bca
Show file tree
Hide file tree
Showing 16 changed files with 447 additions and 0 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
on:
push:
branches:
- main

name: Release

jobs:
bump-version:
name: Release version
runs-on: ubuntu-latest

steps:
- uses: GoogleCloudPlatform/release-please-action@v3
id: release
with:
release-type: python # just keep a changelog, no version anywhere outside of git tags
package-name: juno_template
lint:
name: Lint Code Base
runs-on: ubuntu-latest

steps:
- name: Checkout Code
uses: actions/checkout@v3

- name: Lint Code Base
uses: github/super-linter@v4
env:
VALIDATE_ALL_CODEBASE: false
DEFAULT_BRANCH: main
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

VALIDATE_SNAKEMAKE_SNAKEFMT: true
144 changes: 144 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Vscode stuff:
.vscode

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# Added stuff
.snakemake
envs/src
input
output
sample_sheet.yaml
config/sample_sheet.yaml
config/variables.yaml
config/juno_call.txt
config/user_parameters.yaml
core.*
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "juno-library"]
path = base_juno_pipeline
url = https://github.com/RIVM-bioinformatics/base_juno_pipeline.git
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Changelog

## [1.0.1](https://github.com/RIVM-bioinformatics/juno-template/compare/v1.0.0...v1.0.1) (2023-07-12)


### Dependencies

* remove anaconda and defaults and add no defaults channel ([0b4fccb](https://github.com/RIVM-bioinformatics/juno-template/commit/0b4fccb29d192570060ed81f6222b78293e195a7))
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Juno-Template
A template pipeline where the other juno pipelines are based on.

## Contribution guidelines
Juno pipelines use a [feature branch workflow](https://www.atlassian.com/git/tutorials/comparing-workflows/feature-branch-workflow). To work on features, create a branch from the `main` branch to make changes to. This branch can be merged to the main branch via a pull request. Hotfixes for bugs can be committed to the `main` branch.

Please adhere to the [conventional commits](https://www.conventionalcommits.org/) specification for commit messages. These commit messages can be picked up by [release please](https://github.com/googleapis/release-please) to create meaningful release messages.
25 changes: 25 additions & 0 deletions Snakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import yaml


sample_sheet=config["sample_sheet"]
with open(sample_sheet) as f:
SAMPLES = yaml.safe_load(f)

for param in ["threads", "mem_gb"]:
for k in config[param]:
config[param][k] = int(config[param][k])

# print(SAMPLES)

OUT = config["output_dir"]

localrules:
all,


include: "workflow/rules/rule.smk"


rule all:
input:
expand(OUT + "/{sample}_combined.fastq", sample=SAMPLES),
1 change: 1 addition & 0 deletions base_juno_pipeline
Submodule base_juno_pipeline added at 3d05d8
5 changes: 5 additions & 0 deletions config/pipeline_parameters.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
threads:
template_rule: 1

mem_gb:
template_rule: 1
5 changes: 5 additions & 0 deletions envs/mamba.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
name: mamba
channels:
- conda-forge
dependencies:
- mamba
15 changes: 15 additions & 0 deletions envs/template_master.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: juno_template
channels:
- conda-forge
- bioconda
- biocore
- nodefaults
dependencies:
- git=2.40.*
- mamba=1.3.*
- pandas=1.5.*
- snakemake=7.18.*
- pip=23.*
- python=3.11.*
- pip:
- "--editable=git+https://github.com/RIVM-bioinformatics/[email protected]#egg=juno_library"
86 changes: 86 additions & 0 deletions run_pipeline.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
#!/bin/bash

set -euo pipefail

#----------------------------------------------#
# User parameters
if [ ! -z "${1}" ] || [ ! -z "${2}" ] #|| [ ! -z "${irods_input_projectID}" ]
then
input_dir="${1}"
output_dir="${2}"
# PROJECT_NAME="${irods_input_projectID}"
else
echo "One of the parameters is missing, make sure there is an input directory, output directory and project name(param 1, 2 or irods_input_projectID)."
exit 1
fi

if [ ! -d "${input_dir}" ] || [ ! -d "${output_dir}" ]
then
echo "The input directory $input_dir, output directory $output_dir or fastq dir ${input_dir}/clean_fastq does not exist"
exit 1
else
input_fastq="${input_dir}/clean_fastq"
fi

#----------------------------------------------#
# Create/update necessary environments
PATH_MAMBA_YAML="envs/mamba.yaml"
PATH_MASTER_YAML="envs/template_master.yaml"
MAMBA_NAME=$(head -n 1 ${PATH_MAMBA_YAML} | cut -f2 -d ' ')
MASTER_NAME=$(head -n 1 ${PATH_MASTER_YAML} | cut -f2 -d ' ')

echo -e "\nUpdating necessary environments to run the pipeline..."

# Removing strict mode because it sometimes breaks the code for
# activating an environment and for testing whether some variables
# are set or not
set +euo pipefail

conda env update -f "${PATH_MAMBA_YAML}"
source activate "${MAMBA_NAME}"

mamba env update -f "${PATH_MASTER_YAML}"

source activate "${MASTER_NAME}"

#----------------------------------------------#
# Run the pipeline

echo -e "\nRun pipeline..."

if [ ! -z ${irods_runsheet_sys__runsheet__lsf_queue} ]; then
QUEUE="${irods_runsheet_sys__runsheet__lsf_queue}"
else
QUEUE="bio"
fi

set -euo pipefail

python template.py --queue "${QUEUE}" -i "${input_dir}" -o "${output_dir}"

result=$?

# Propagate metadata

set +euo pipefail

SEQ_KEYS=
SEQ_ENV=`env | grep irods_input_sequencing`
for SEQ_AVU in ${SEQ_ENV}
do
SEQ_KEYS="${SEQ_KEYS} ${SEQ_AVU%%=*}"
done

for key in $SEQ_KEYS irods_input_illumina__Flowcell irods_input_illumina__Instrument \
irods_input_illumina__Date irods_input_illumina__Run_number irods_input_illumina__Run_Id
do
if [ ! -z ${!key} ] ; then
attrname=${key:12}
attrname=${attrname/__/::}
echo "${attrname}: '${!key}'" >> ${OUTPUTDIR}/metadata.yml
fi
done

set -euo pipefail

exit ${result}
Loading

0 comments on commit bfb6bca

Please sign in to comment.