Skip to content

Commit

Permalink
4.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
tdayris committed Dec 4, 2024
1 parent 7497e2c commit 54bd685
Show file tree
Hide file tree
Showing 37 changed files with 1,113 additions and 78 deletions.
291 changes: 291 additions & 0 deletions .test/tasks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,291 @@
# coding: utf-8

from invoke import task
from github import Github
from datetime import datetime

import os.path as op
import os
import yaml


def get_latest_release(address: str) -> str:
git = Github()
repo = git.get_repo(address)
releases = repo.get_releases()
return releases[0].tag_name


snakemake_wrappers_version = os.environ.get("SNAKEMAKE_WRAPPERS_VERSION")
if not snakemake_wrappers_version:
print("Searching snakemake wrappers version on the web...")
snakemake_wrappers_version = get_latest_release("snakemake/snakemake-wrappers")

fair_genome_indexer_version = os.environ.get("FAIR_GENOME_INDEXER_VERSION")
if not fair_genome_indexer_version:
print("Searching fair-genome-indexer version on the web...")
fair_genome_indexer_version = get_latest_release("tdayris/fair_genome_indexer")


fair_fastqc_multiqc_version = os.environ.get("FAIR_FASTQC_MULTIQC_VERSION")
if not fair_fastqc_multiqc_version:
print("Searching fair-fastqc-multiqc version on the web...")
fair_fastqc_multiqc_version = get_latest_release("tdayris/fair_fastqc_multiqc")

fair_bowtie2_mapping_version = os.environ.get("FAIR_BOWTIE2_MAPPING_VERSION")
if not fair_bowtie2_mapping_version:
print("Searching fair-bowtie2-mapping version on the web...")
fair_bowtie2_mapping_version = get_latest_release("tdayris/fair_bowtie2_mapping")

locations = {
"snakefile": "../workflow/Snakefile",
"rules": "../workflow/rules/",
"scripts": "../workflow/scripts",
"envs": "../workflow/envs",
"changelog": "../CHANGELOG.md",
"cff": "../CITATION.cff",
}
for location in locations.values():
if not op.exists(location):
raise FileNotFoundError(f"Could not find {location=}")


def get_future_version(
changelog: str = locations["changelog"],
) -> str:
with open(changelog, "r") as changelog_stream:
line = next(changelog_stream)
version = line.strip("#").strip()

print(f"Future version is: {version=}")
return version


future_version = get_future_version()


@task
def clean(
c,
conda: bool = False,
extra: str = "",
):
patterns = [
"black.txt",
"format.txt",
"linter_info.txt",
"pipeline.txt",
"results",
"resources",
"report.txt",
"report.zip",
"resources.md",
"resources.tsv",
"resources.txt",
"summary.tsv",
"summary_small.tsv",
"docs_update.txt",
"logs",
"reference",
"report",
"tmp",
"Snakefile",
"wrappers_update.txt",
"conda_update.txt",
"docs_update.txt",
]
if conda:
patterns.append(".snakemake")
patterns.append(".conda")

for pattern in patterns:
if op.exists(pattern):
print(f"Removing {pattern=}")
c.run(f"rm -rf '{pattern}'")
else:
print(f"Skipping {pattern=}")


@task
def update_docs_cff(
c,
to: str = future_version,
cff_path: str = locations["cff"],
):
today = datetime.today().strftime("%Y-%m-%d")
cff = {
"cff-version": "1.2.0",
"message": "If you use this software, please cite it as below.",
"authors": [
{
"family-names": "Dayris",
"given-names": "Thibault",
"orcid": "https://orcid.org/0009-0009-2758-8450",
}
],
"title": "fair-bowtie2-mapping",
"version": future_version,
"date-released": today,
"url": "https://github.com/tdayris/fair_bowtie2_mapping",
}
print(cff)
with open(cff_path, "w") as yaml_cff_stream:
yaml.dump(cff, yaml_cff_stream, default_flow_style=False)


@task(update_docs_cff)
def update_docs_wrappers(c, to: str = snakemake_wrappers_version, future_version: str = future_version):
today = datetime.today().strftime("%Y-%m-%d")
regex = rf"s|v[0-9]\+\.[0-9]\+\.[0-9]\+/wrappers|{to}/wrappers|g"
print(f"Updating snakemake wrappers in README.md to {to=}")
c.run(f"sed -i '{regex}' ../README.md >> docs_update.txt 2>&1")

for root, dirs, files in os.walk("../workflow/report"):
for file in files:
if file.endswith(".rst"):
print(f"Updating snakemake wrappers in '{root}/{file}'...")
c.run(f"sed -i '{regex}' '{root}/{file}' >> docs_update.txt 2>&1")

regex = (
's|snakemake_wrappers_prefix: str = "v4.5.0"|'
f'snakemake_wrappers_prefix: str = "{to}"|g'
)
print("Updating '../workflow/rules/common.smk'...")
c.run(f"sed -i '{regex}' '../workflow/rules/common.smk' >> update_docs.txt 2>&1")

regex = (
r's|fair-genome-indexer (Version v\?[0-9]\+\.[0-9]\+\.[0-9]\+)'
f'|fair-genome-indexer (Version {fair_genome_indexer_version})|g;'
r's|fair-fastqc-multiqc (Version v\?[0-9]\+\.[0-9]\+\.[0-9]\+)'
f'|fair-fastqc-multiqc (Version {fair_fastqc_multiqc_version})|g;'
r's|fair-bowtie2-mapping (Version v\?[0-9]\+\.[0-9]\+\.[0-9]\+)'
f'|fair-bowtie2-mapping (Version {future_version})|g'
)
print("Updating '../workflow/report/material_methods.rst'...")
c.run(f"sed -i '{regex}' '../workflow/report/material_methods.rst' >> update_docs.txt 2>&1")

regex = (
r's|\:Version\: [0-9]\+\.[0-9]\+\.[0-9]\+ of [0-9]\+\-[0-9]\+\-[0-9]\+$'
fr'|\:Version\: {future_version} of {today}|g'
)
c.run(f"sed -i '{regex}' '../workflow/report/material_methods.rst' >> update_docs.txt 2>&1")



@task(update_docs_wrappers)
def update_wrappers_rules(
c,
to: str = snakemake_wrappers_version,
snakefile: str = locations["snakefile"],
rules: str = locations["rules"],
):
print(f"Updating {snakefile=}...")
c.run(
"snakedeploy update-snakemake-wrappers "
f"--git-ref '{snakemake_wrappers_version}' '{snakefile}' "
">> wrappers_update.txt 2>&1"
)

for root, dirs, files in os.walk(rules):
for file in files:
if file == "fair_genome_indexer.smk":
print("Updating fair_genome_indexer...")
c.run(fr"""sed -i 's|tag="[0-9]\+\.[0-9]\+\.[0-9]\+"|tag="{fair_genome_indexer_version}"|g' '{root}/{file}' >> wrappers_update.txt 2>&1""")
elif file == "fair_fastqc_multiqc.smk":
print("Updating fair_fastq_multiqc...")
c.run(fr"""sed -i 's|tag="[0-9]\+\.[0-9]\+\.[0-9]\+"|tag="{fair_fastqc_multiqc_version}"|g' '{root}/{file}' >> wrappers_update.txt 2>&1""")
elif file == "fair_bowtie2_mapping.smk":
print("Updating fair_bowtie2_mapping...")
c.run(fr"""sed -i 's|tag="[0-9]\+\.[0-9]\+\.[0-9]\+"|tag="{fair_bowtie2_mapping_version}"|g' '{root}/{file}' >> wrappers_update.txt 2>&1""")
elif file.endswith(".smk"):
print(f"Updating '{root}/{file}'...")
c.run(
"snakedeploy update-snakemake-wrappers --git-ref "
f"'{snakemake_wrappers_version}' '{root}/{file}' "
">> wrappers_update.txt 2>&1"
)
else:
print(f"Skipping '{root}/{file}'...")


@task(update_wrappers_rules)
def update_conda(
c,
envs: str = locations["envs"],
):
for root, dirs, files in os.walk(envs):
for file in files:
if file.endswith(".yaml"):
print(f"Updating '{root}/{file}'. This may take some time...")
c.run(
"snakedeploy update-conda-envs --conda-frontend mamba "
f"--pin-envs '{root}/{file}' > conda_update.txt 2>&1"
)


@task
def black(c, scripts: str = locations["scripts"]):
log: str = "black.txt"
for root, dirs, files in os.walk(scripts):
for file in files:
if file.endswith(".py"):
print(f"Formatting '{root}/{file}'...")
c.run(f"black '{root}/{file}' >> {log} 2>&1")


@task(black)
def snakefmt(
c,
snakefile: str = locations["snakefile"],
rules: str = locations["rules"],
):
log: str = "format.txt"
print(f"Formatting {snakefile=}...")
c.run(f"snakefmt '{snakefile}' >> '{log}' 2>&1")

for root, dirs, files in os.walk(rules):
for file in files:
if file.endswith(".smk"):
print(f"Formatting '{root}/{file}'...")
c.run(f"snakefmt '{root}/{file}' >> '{log}' 2>&1")


@task(snakefmt)
def linter(
c,
snakefile: str = locations["snakefile"],
):
print(f"Linting {snakefile=}...")
c.run(f"snakemake --lint -s '{snakefile}' > linter_info.txt 2>&1")


@task(linter)
def pipeline(
c,
snakefile: str = locations["snakefile"],
):
print("Running pipeline...")
cmd = (
f"snakemake -s '{snakefile}' "
"--cores 7 --restart-times 0 "
"--rerun-incomplete --printshellcmds "
"--shadow-prefix 'tmp' --rerun-triggers 'mtime' "
"--software-deployment-method conda "
"--benchmark-extended > pipeline.txt 2>&1"
)
print(cmd)
c.run(cmd)


@task(pipeline)
def report(
c,
snakefile: str = locations["snakefile"],
):
print("Building test report...")
c.run(f"snakemake -s '{snakefile}' --report report.zip > report.txt 2>&1")

@task(clean, update_conda, report)
def all(c):
print("All done.")

14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# 4.4.0

## Features:

* Snakemake-wrappers update to 5.3.0
* MTNucRatioCalculator added to QC
* Easy snakemake-wrappers update
* Easy conda envs update
* New testing pipeline with additional format checks

## Doc:

* Citation cff file added

# 4.3.1

## Features:
Expand Down
10 changes: 10 additions & 0 deletions CITATION.cff
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
authors:
- family-names: Dayris
given-names: Thibault
orcid: https://orcid.org/0009-0009-2758-8450
cff-version: 1.2.0
date-released: '2024-12-04'
message: If you use this software, please cite it as below.
title: fair-bowtie2-mapping
url: https://github.com/tdayris/fair_bowtie2_mapping
version: 4.4.0
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ See [`fair_fastqc_multiqc`](https://github.com/tdayris/fair_fastqc_multiqc/) do

| Step | Meta-Wrapper | Wrapper |
| ------------- | ------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- |
| Bowtie2-build | [bowtie2-sambamba meta-wrapper](https://snakemake-wrappers.readthedocs.io/en/v4.6.0/meta-wrappers/bowtie2_sambamba.html) | [bowtie2-build](https://snakemake-wrappers.readthedocs.io/en/v4.6.0/wrappers/bowtie2/build.html) |
| Fastp | | [fastp](https://snakemake-wrappers.readthedocs.io/en/v4.6.0/wrappers/fastp.html) |
| Bowtie2-align | [bowtie2-sambamba meta-wrapper](https://snakemake-wrappers.readthedocs.io/en/v4.6.0/meta-wrappers/bowtie2_sambamba.html) | [bowtie2-align](https://snakemake-wrappers.readthedocs.io/en/v4.6.0/wrappers/bowtie2/align.html) |
| Sambamba sort | [bowtie2-sambamba meta-wrapper](https://snakemake-wrappers.readthedocs.io/en/v4.6.0/meta-wrappers/bowtie2_sambamba.html) | [sambamba-sort](https://snakemake-wrappers.readthedocs.io/en/v4.6.0/wrappers/sambamba/sort.html) |
| Bowtie2-build | [bowtie2-sambamba meta-wrapper](https://snakemake-wrappers.readthedocs.io/en/v4.6.0/meta-wrappers/bowtie2_sambamba.html) | [bowtie2-build](https://snakemake-wrappers.readthedocs.io/en/v5.3.0/wrappers/bowtie2/build.html) |
| Fastp | | [fastp](https://snakemake-wrappers.readthedocs.io/en/v5.3.0/wrappers/fastp.html) |
| Bowtie2-align | [bowtie2-sambamba meta-wrapper](https://snakemake-wrappers.readthedocs.io/en/v4.6.0/meta-wrappers/bowtie2_sambamba.html) | [bowtie2-align](https://snakemake-wrappers.readthedocs.io/en/v5.3.0/wrappers/bowtie2/align.html) |
| Sambamba sort | [bowtie2-sambamba meta-wrapper](https://snakemake-wrappers.readthedocs.io/en/v4.6.0/meta-wrappers/bowtie2_sambamba.html) | [sambamba-sort](https://snakemake-wrappers.readthedocs.io/en/v5.3.0/wrappers/sambamba/sort.html) |

```
┌───────────────────────────┐ ┌─────────────────────────┐
Expand All @@ -54,9 +54,9 @@ See [`fair_fastqc_multiqc`](https://github.com/tdayris/fair_fastqc_multiqc/) do

| Step | Meta-Wrapper | Wrapper |
| ---------------- | ------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------- |
| Sambamba-view | [bowtie2-sambamba meta-wrapper](https://snakemake-wrappers.readthedocs.io/en/v4.6.0/meta-wrappers/bowtie2_sambamba.html) | [sambamba-view](https://snakemake-wrappers.readthedocs.io/en/v4.6.0/wrappers/sambamba/view.html) |
| Sambamba-markdup | [bowtie2-sambamba meta-wrapper](https://snakemake-wrappers.readthedocs.io/en/v4.6.0/meta-wrappers/bowtie2_sambamba.html) | [sambamba-markdup](https://snakemake-wrappers.readthedocs.io/en/v4.6.0/wrappers/sambamba/markdup.html) |
| Sambamba-index | [bowtie2-sambamba meta-wrapper](https://snakemake-wrappers.readthedocs.io/en/v4.6.0/meta-wrappers/bowtie2_sambamba.html) | [sambamba-index](https://snakemake-wrappers.readthedocs.io/en/v4.6.0/wrappers/sambamba/index.html) |
| Sambamba-view | [bowtie2-sambamba meta-wrapper](https://snakemake-wrappers.readthedocs.io/en/v4.6.0/meta-wrappers/bowtie2_sambamba.html) | [sambamba-view](https://snakemake-wrappers.readthedocs.io/en/v5.3.0/wrappers/sambamba/view.html) |
| Sambamba-markdup | [bowtie2-sambamba meta-wrapper](https://snakemake-wrappers.readthedocs.io/en/v4.6.0/meta-wrappers/bowtie2_sambamba.html) | [sambamba-markdup](https://snakemake-wrappers.readthedocs.io/en/v5.3.0/wrappers/sambamba/markdup.html) |
| Sambamba-index | [bowtie2-sambamba meta-wrapper](https://snakemake-wrappers.readthedocs.io/en/v4.6.0/meta-wrappers/bowtie2_sambamba.html) | [sambamba-index](https://snakemake-wrappers.readthedocs.io/en/v5.3.0/wrappers/sambamba/index.html) |
| Deeptools | | [deeptools-alignment-sieve](https://snakemake-wrappers.readthedocs.io/en/v4.6.0/bio/deeptools/alignmentsieve) |

```
Expand Down Expand Up @@ -89,9 +89,9 @@ See [`fair_fastqc_multiqc`](https://github.com/tdayris/fair_fastqc_multiqc/) do

| Step | Wrapper |
| -------- | --------------------------------------------------------------------------------------------------------------------------------- |
| Picard | [picard-collectmultiplemetrics](https://snakemake-wrappers.readthedocs.io/en/v4.6.0/wrappers/picard/collectmultiplemetrics.html) |
| Samtools | [samtools-stats](https://snakemake-wrappers.readthedocs.io/en/v4.6.0/wrappers/samtools/stats.html) |
| MultiQC | [multiqc-wrapper](https://snakemake-wrappers.readthedocs.io/en/v4.6.0/wrappers/multiqc.html) |
| Picard | [picard-collectmultiplemetrics](https://snakemake-wrappers.readthedocs.io/en/v5.3.0/wrappers/picard/collectmultiplemetrics.html) |
| Samtools | [samtools-stats](https://snakemake-wrappers.readthedocs.io/en/v5.3.0/wrappers/samtools/stats.html) |
| MultiQC | [multiqc-wrapper](https://snakemake-wrappers.readthedocs.io/en/v5.3.0/wrappers/multiqc.html) |

```
┌──────────────────────┐ ┌─────────────────────┐ ┌─────────────────────────┐
Expand Down
1 change: 1 addition & 0 deletions workflow/Snakefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ include: "rules/deeptools.smk"
include: "rules/fastp.smk"
include: "rules/goleft.smk"
include: "rules/mosdepth.smk"
include: "rules/mtnucratio.smk"
include: "rules/multiqc.smk"
include: "rules/ngsderive.smk"
include: "rules/picard_metrics.smk"
Expand Down
15 changes: 15 additions & 0 deletions workflow/envs/bash.linux-64.pin.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# This file may be used to create an environment using:
# $ conda create --name <env> --file <this file>
# platform: linux-64
# created-by: conda 24.9.2
@EXPLICIT
https://conda.anaconda.org/conda-forge/linux-64/_libgcc_mutex-0.1-conda_forge.tar.bz2#d7c89558ba9fa0495403155b64376d81
https://conda.anaconda.org/conda-forge/linux-64/libgomp-14.2.0-h77fa898_1.conda#cc3573974587f12dda90d96e3e55a702
https://conda.anaconda.org/conda-forge/linux-64/_openmp_mutex-4.5-2_gnu.tar.bz2#73aaf86a425cc6e73fcf236a5a46396d
https://conda.anaconda.org/conda-forge/linux-64/libgcc-14.2.0-h77fa898_1.conda#3cb76c3f10d3bc7f1105b2fc9db984df
https://conda.anaconda.org/conda-forge/linux-64/libgcc-ng-14.2.0-h69a702a_1.conda#e39480b9ca41323497b05492a63bc35b
https://conda.anaconda.org/conda-forge/linux-64/bzip2-1.0.8-h4bc722e_7.conda#62ee74e96c5ebb0af99386de58cf9553
https://conda.anaconda.org/conda-forge/linux-64/gzip-1.13-hd590300_0.conda#cb8143aa2e59e9684c41dfdf74af38ac
https://conda.anaconda.org/conda-forge/linux-64/libzlib-1.2.13-h4ab18f5_6.conda#27329162c0dc732bcf67a4e0cd488125
https://conda.anaconda.org/conda-forge/linux-64/zlib-1.2.13-h4ab18f5_6.conda#559d338a4234c2ad6e676f460a093e67
https://conda.anaconda.org/bioconda/linux-64/pbgzip-2016.08.04-h9d449c0_5.tar.bz2#0da92a60578bf5de747bd240bde395fc
4 changes: 2 additions & 2 deletions workflow/envs/bash.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ channels:
- bioconda
- nodefaults
dependencies:
- gzip=1.13
- pbgzip=2016.08.04
- gzip =1.13
- pbgzip =2016.08.04
Loading

0 comments on commit 54bd685

Please sign in to comment.