Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
511 changes: 0 additions & 511 deletions .github/workflows/install_nextflow_v24.10.5.sh

This file was deleted.

44 changes: 20 additions & 24 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ jobs:

test_rain:

# Avoid running twice for a push + PR
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
# Avoid running twice: skip push events if there's an open PR for this branch
if: github.event_name != 'push' || github.event.pull_request == null

runs-on: ubuntu-24.04

Expand All @@ -40,48 +40,44 @@ jobs:
key: ${{ runner.os }}-openjdk-11
restore-keys: |
${{ runner.os }}-openjdk-11

- name: Install OpenJDK
if: ${{ steps.cache-openjdk.outputs.cache-hit != 'true' }}
run: sudo apt-get install openjdk-11-jdk
if: steps.cache-openjdk.outputs.cache-hit != 'true'
run: sudo apt-get update && sudo apt-get install -y openjdk-11-jdk

# Install/cache Nextflow
- name: Cache Nextflow
id: cache-nextflow
uses: actions/cache@v4
with:
path: /usr/local/bin/nextflow
key: ${{ runner.os }}-nextflow
key: ${{ runner.os }}-nextflow-24.10.6
restore-keys: |
${{ runner.os }}-nextflow
${{ runner.os }}-nextflow-24.10.6

- name: Install Nextflow
if: ${{ steps.cache-nextflow.outputs.cache-hit != 'true' }}
run: cat .github/workflows/install_nextflow_v24.10.5.sh | bash && mv nextflow /usr/local/bin && chmod +x /usr/local/bin/nextflow

# Check-out the repo under $GITHUB_WORKSPACE so that the job can access it
- uses: actions/checkout@v4
if: steps.cache-nextflow.outputs.cache-hit != 'true'
run: export NXF_VER=24.10.6 && curl -s https://get.nextflow.io | bash && sudo mv nextflow /usr/local/bin && sudo chmod +x /usr/local/bin/nextflow

- name: Cache Dockerfiles and TAR
# Cache Docker images
- name: Cache Docker images
id: cache-dockerfiles
uses: actions/cache@v4
with:
path: docker-images.tar
key: ${{ runner.os }}-dockerfiles-${{ hashFiles('docker/**/*') }}
restore-keys: |
${{ runner.os }}-dockerfiles-

- name: Load cached Docker images
id: load-cache
if: steps.cache-dockerfiles.outputs.cache-hit == 'true'
run: |
if [ -f docker-images.tar ]; then
echo "Loading cached Docker images..."
docker load -i docker-images.tar || true
echo "build=false" >> $GITHUB_ENV
else
echo "No Docker cache found"
echo "build=true" >> $GITHUB_ENV
fi
echo "Loading cached Docker images..."
docker load -i docker-images.tar

- name: Build images
if: env.build == 'true' || steps.cache-dockerfiles.outputs.cache-hit != 'true'
run: bash build_images.sh github_action
- name: Build Docker images
if: steps.cache-dockerfiles.outputs.cache-hit != 'true'
run: bash build_containers.sh --docker --github_action

# Run test(s)
- name: test short single
Expand Down
52 changes: 36 additions & 16 deletions bin/rna_site_variant_readers.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,22 +107,8 @@ def close(self) -> None:
class ReditoolsXReader(RNASiteVariantReader):
"""Abstract base class defining common methods for the readers for the Reditools2 and Reditools3 formats"""

header_strings = (
"Region",
"Position",
"Reference",
"Strand",
"Coverage-q30",
"MeanQ",
"BaseCount[A,C,G,T]",
"AllSubs",
"Frequency",
"gCoverage-q30",
"gMeanQ",
"gBaseCount[A,C,G,T]",
"gAllSubs",
"gFrequency",
)
# header_strings should be defined in subclasses
header_strings = ()

def __init__(self, file_handle: TextIO) -> None:
self.file_handle: TextIO = file_handle
Expand Down Expand Up @@ -227,6 +213,23 @@ def close(self) -> None:
self.file_handle.close()

class Reditools2Reader(ReditoolsXReader):
header_strings = (
"Region",
"Position",
"Reference",
"Strand",
"Coverage-q30",
"MeanQ",
"BaseCount[A,C,G,T]",
"AllSubs",
"Frequency",
"gCoverage-q30",
"gMeanQ",
"gBaseCount[A,C,G,T]",
"gAllSubs",
"gFrequency",
)

def parse_strand(self) -> int:
strand = int(self.parts[REDITOOLS_FIELD_INDEX["Strand"]])
match strand:
Expand All @@ -240,6 +243,23 @@ def parse_strand(self) -> int:
raise Exception(f"Invalid strand value: {strand}")

class Reditools3Reader(ReditoolsXReader):
header_strings = (
"Region",
"Position",
"Reference",
"Strand",
"Coverage",
"MeanQ",
"BaseCount[A,C,G,T]",
"AllSubs",
"Frequency",
"gCoverage",
"gMeanQ",
"gBaseCount[A,C,G,T]",
"gAllSubs",
"gFrequency",
)

def parse_strand(self) -> int:
strand_str = self.parts[REDITOOLS_FIELD_INDEX["Strand"]]
match strand_str:
Expand Down
193 changes: 193 additions & 0 deletions build_containers.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,193 @@
#!/usr/bin/env bash

# Unified container build script
# Usage:
# ./build_containers.sh # Build both Docker and Singularity (default)
# ./build_containers.sh --docker # Build only Docker images
# ./build_containers.sh --singularity # Build only Singularity images
# ./build_containers.sh --all # Build both (explicit)
# ./build_containers.sh --github_action # Build both for GitHub Actions
# ./build_containers.sh --docker github_action # Build Docker for GitHub Actions
# ./build_containers.sh --singularity github_action # Build Singularity for GitHub Actions

set -e

# Parse arguments
build_docker=false
build_singularity=false
github_action_mode=""
auto_detect=false

# If no arguments provided, auto-detect available tools
if [ $# -eq 0 ]; then
auto_detect=true
fi

# Parse all arguments
while [ $# -gt 0 ]; do
case "$1" in
--docker)
build_docker=true
;;
--singularity|--apptainer)
build_singularity=true
;;
--all)
build_docker=true
build_singularity=true
;;
--github_action)
github_action_mode="github_action"
# If --github_action is used without --docker or --singularity, enable auto-detect
if [ "$build_docker" = false ] && [ "$build_singularity" = false ]; then
auto_detect=true
fi
;;
-h|--help)
echo "Usage: $0 [OPTIONS] [github_action]"
echo ""
echo "Options:"
echo " --docker Build Docker images only"
echo " --singularity Build Singularity/Apptainer images only"
echo " --apptainer Alias for --singularity"
echo " --all Build both Docker and Singularity images"
echo " (no options) Build both by default"
echo ""
echo "Additional arguments:"
echo " github_action Enable GitHub Actions mode (saves to archive)"
echo ""
echo "Examples:"
echo " $0 # Build both (default)"
echo " $0 --docker # Build only Docker"
echo " $0 --singularity github_action # Build Singularity for CI"
exit 0
;;
*)
echo "Unknown option: $1"
echo "Use --help for usage information"
exit 1
;;
esac
shift
done

# Auto-detect available tools if no specific option was provided
if [ "$auto_detect" = true ]; then
echo "Auto-detecting available container tools..."

if command -v docker &> /dev/null; then
echo " ✓ Docker found"
build_docker=true
else
echo " ✗ Docker not found"
fi

if command -v singularity &> /dev/null; then
echo " ✓ Singularity/Apptainer found"
build_singularity=true
else
echo " ✗ Singularity/Apptainer not found"
fi

# Check if at least one tool is available
if [ "$build_docker" = false ] && [ "$build_singularity" = false ]; then
echo ""
echo "❌ Error: Neither Docker nor Singularity/Apptainer found on this system."
echo "Please install at least one container tool to proceed."
exit 1
fi

echo ""
fi

# Save original working directory
wd=$(pwd)

# Get architecture for Docker builds
arch=$(uname -m)

# Build Docker images if requested
if [ "$build_docker" = true ]; then
echo "════════════════════════════════════════════════════════════════"
echo " Building Docker images..."
echo "════════════════════════════════════════════════════════════════"

# List of image names
image_list=( )

for dir in docker/*; do
cd "${dir}"
imgname=$(echo $dir | rev | cut -d/ -f1 | rev)
image_list+=(${imgname})

echo ██████████████████▓▒░ Building ${imgname} ░▒▓██████████████████

# Set architecture to docker buildx
docker_arch_option=""

# Reditools2 and Pluviometer do not compile on arm64, force using amd64 compilation
if [[ "$arch" == arm* || "$arch" == "aarch64" ]]; then
if [[ $dir =~ "reditools2" ]] || [[ $dir =~ "pluviometer" ]]; then
echo "$imgname does not compile on arm64, force using amd64 compilation"
docker_arch_option=" --platform linux/amd64"
fi
fi

docker build ${docker_arch_option} -t ${imgname} .

# Back to the original working directory
cd "$wd"
done

if [[ ${github_action_mode} == 'github_action' ]]; then
echo "Saving docker images to cache..."
docker save ${image_list[@]} -o docker-images.tar
echo Archive size: $(stat --printf="%s" docker-images.tar)
fi

echo ""
fi

# Build Singularity images if requested
if [ "$build_singularity" = true ]; then
echo "════════════════════════════════════════════════════════════════"
echo " Building Singularity/Apptainer images..."
echo "════════════════════════════════════════════════════════════════"

# Create output directory for .sif images
mkdir -p sif_images

# List to store built images
sif_list=( )

# Loop through all .def files in singularity/ subdirectories
for def_file in singularity/*/*.def; do
# Extract image name from directory
imgname=$(basename "$(dirname "$def_file")")
sif_output="sif_images/${imgname}.sif"
sif_list+=("$sif_output")

echo ██████████████████▓▒░ Building ${imgname} ░▒▓██████████████████

# Build with fakeroot if available
if command -v singularity &> /dev/null; then
singularity build --fakeroot "$sif_output" "$def_file"
else
echo "❌ Singularity not found! Aborting."
exit 1
fi
done

# If used in GitHub Actions, create an archive
if [[ ${github_action_mode} == 'github_action' ]]; then
echo "Saving SIF images to cache archive..."
tar -cf singularity-images.tar "${sif_list[@]}"
echo Archive size: $(stat --printf="%s" singularity-images.tar)
fi

echo ""
fi

echo "════════════════════════════════════════════════════════════════"
echo " ✓ Build complete!"
echo "════════════════════════════════════════════════════════════════"
46 changes: 0 additions & 46 deletions build_images.sh

This file was deleted.

Loading