Skip to content

Commit 5f4af4c

Browse files
authored
Merge pull request #124 from LANL-Bioinformatics/123-add-assembly-stats-output-html
123 add assembly stats output html
2 parents d04f883 + 3f53fc1 commit 5f4af4c

File tree

3 files changed

+103
-0
lines changed

3 files changed

+103
-0
lines changed
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: Build and push container image to GHCR
2+
3+
# Run this workflow whenever a Dockerfile is updated.
4+
on:
5+
workflow_dispatch:
6+
push:
7+
branches:
8+
- main
9+
paths:
10+
- 'workflows/Nextflow/modules/runAssembly/Dockerfile'
11+
12+
jobs:
13+
build-and-push-image:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout branch
17+
uses: actions/checkout@v4
18+
- name: Get Version
19+
id: get_version
20+
run: |
21+
VERSION=$(grep -oP 'version=\K.*' workflows/Nextflow/modules/runAssembly/Dockerfile)
22+
VERSION=${VERSION:-1.0.0}
23+
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
24+
- name: Authenticate with container registry
25+
uses: docker/login-action@v3
26+
with:
27+
registry: ghcr.io
28+
username: ${{ github.actor }}
29+
password: ${{ secrets.GITHUB_TOKEN }}
30+
# Use the `docker/build-push-action` action to build the image described
31+
# by the specified Dockerfile. If the build succeeds, push the image to GHCR.
32+
# This action uses the `tags` parameters to tag the image with the Git tag name
33+
# the image, respectively, with the output from the "get_version" step above.
34+
# For more info: https://github.com/docker/build-push-action#usage.
35+
- name: Build and push container image
36+
id: push
37+
uses: docker/build-push-action@v5
38+
with:
39+
context: .
40+
file: workflows/Nextflow/modules/runAssembly/Dockerfile
41+
push: true
42+
tags: ghcr.io/lanl-bioinformatics/edge_run_assembly:${{ steps.get_version.outputs.version }}
43+
- name: update image tag ID and version in the config
44+
run: |
45+
imageName="ghcr.io/lanl-bioinformatics/edge_run_assembly:${{ steps.get_version.outputs.version }}"
46+
version="${{ steps.get_version.outputs.version }}"
47+
sed -i -E "s#apwat/run_assembly:[0-9a-zA-Z._-]+#${imageName}#" workflows/Nextflow/configs/container.config
48+
sed -i -E "s#edge_run_assembly:[0-9a-zA-Z._-]+#edge_run_assembly:${version}#" workflows/Nextflow/configs/container.config
49+
#A GitHub Action to detect changed files during a Workflow run and to commit and push them back to the GitHub repository.
50+
#By default, the commit is made in the name of "GitHub Actions" and co-authored by the user that made the last commit.
51+
- name: auto-commit image version update
52+
uses: stefanzweifel/git-auto-commit-action@v5
53+
with:
54+
branch: auto-update-${{ github.run_id }}
55+
create_branch: true
56+
commit_message: "Auto update of run assembly docker image version ${{ steps.get_version.outputs.version }}"
57+
- name: Create Pull Request
58+
run: |
59+
title="Automated PR: update assembly docker image version ${{ steps.get_version.outputs.version }}"
60+
gh pr create \
61+
--base main \
62+
--head auto-update-${{ github.run_id }} \
63+
--title "$title" \
64+
--body "Created by GitHub Action"
65+
env:
66+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

workflows/Nextflow/modules/runAssembly/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
FROM continuumio/miniconda3:23.5.2-0 AS build
2+
ENV version=1.7.0
23

34
ENV container=docker
45

@@ -23,6 +24,7 @@ RUN conda install -n assembly -c bioconda minimap2=2.26
2324
RUN conda install -n assembly -c bioconda megahit=1.2.9
2425
RUN conda install -n assembly -c bioconda idba=1.1.3
2526
RUN conda install -n assembly -c bioconda unicycler=0.5.0
27+
RUN conda install -n assembly -c bioconda quast=5.2.0
2628
RUN wget https://github.com/ruanjue/wtdbg2/releases/download/v2.5/wtdbg-2.5_x64_linux.tgz \
2729
&& tar -xvzf wtdbg-2.5_x64_linux.tgz \
2830
&& cp wtdbg-2.5_x64_linux/* /opt/conda/envs/assembly/bin

workflows/Nextflow/modules/runAssembly/runAssembly.nf

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,38 @@ process bestIncompleteAssembly {
494494

495495
}
496496

497+
process assembly_vis {
498+
label "assembly"
499+
label "tiny"
500+
501+
publishDir(
502+
path: "${settings["assemblyOutDir"]}",
503+
mode: 'copy'
504+
)
505+
506+
input:
507+
val settings
508+
path contigs
509+
510+
output:
511+
path "stats/assembly_stats_report.html" , emit: stats_html
512+
path "stats/assembly_stats_report.txt" , emit: stats_txt
513+
514+
script:
515+
"""
516+
set -euo pipefail
517+
metaquast.py --version > version.txt
518+
metaquast.py -o ./stats -m ${settings["minContigSize"]} --no-icarus --max-ref-number 0 ${contigs}
519+
if [ -f ./stats/report.html ]; then
520+
sed -e 's/.top-panel {/.top-panel {\\n display:none;/' ./stats/report.html > ./stats/assembly_stats_report.html
521+
mv ./stats/report.txt ./stats/assembly_stats_report.txt
522+
else
523+
ERR_MSG="MetaQUAST failed to generate report. Please check the input contigs file. Contigs should >= ${settings["minContigSize"]} bp for the report"
524+
echo "\$ERR_MSG" > stats/assembly_stats_report.html
525+
echo "\$ERR_MSG" > stats/assembly_stats_report.txt
526+
fi
527+
"""
528+
}
497529
//main workflow logic
498530
workflow ASSEMBLY {
499531
take:
@@ -598,6 +630,9 @@ workflow ASSEMBLY {
598630
error "Invalid assembler: ${settings["assembler"]}"
599631
}
600632

633+
//assembly visualization
634+
assembly_vis(settings, outContigs)
635+
601636
emit:
602637
outContigs
603638
annotationContigs

0 commit comments

Comments
 (0)