Skip to content

Commit

Permalink
Definition file for an Apptainer container
Browse files Browse the repository at this point in the history
  • Loading branch information
gmarcais committed Mar 19, 2024
1 parent b5d2519 commit 4ae72a8
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 0 deletions.
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,29 @@ sudo apt update
sudo apt install jellyfish
```

### Apptainer container

From the git repository, create a container image (`jellyfish.sif` file) with:

``` Shell
apptainer build jellyfish.sif jellyfish.def
```

By default it builds the code from the `HEAD` branch of the git repository.
This can be change using the `treeish` build argument.
For example, to build version 2.3.1:
``` Shell
apptainer build --build-arg treeish=v2.3.1 jellyfish.sif jellyfish.def
```

The default command is the `jellyfish` command.
Use like this:
``` Shell
apptainer run jellyfish.sif count -m 21 -C -s 10M -o output.jf input.fa
```

Get some help with `apptainer run-help jellyfish.sif`

### From source

To get an easier to compiled packaged tar ball of the source code, download a release from the [github release][3]. You need make and g++ version 4.4 or higher. To install in your home directory, do:
Expand Down
64 changes: 64 additions & 0 deletions jellyfish.def
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
Bootstrap: docker
From: ubuntu:22.04
Stage: devel

%arguments
# Branch to build
treeish=HEAD

%setup
mkdir -p ${APPTAINER_ROOTFS}/usr/local/src/jellyfish
git archive {{ treeish }} | tar -x -C ${APPTAINER_ROOTFS}/usr/local/src/jellyfish

%post
# System installations
apt update
apt install -y --no-install-recommends yaggo build-essential autoconf automake libtool gettext pkg-config swig python3-dev libperl-dev ruby-dev

# Build and install
cd /usr/local/src/jellyfish
autoreconf -fi
PVERSION=$(python3 -V | grep -Po '\b[\d.]+\b' | cut -d. -f1-2)
./configure --enable-swig --enable-all-binding PYTHON_VERSION="$PVERSION"
make -j`nproc`
make install DESTDIR=$(pwd)/inst


Bootstrap: docker
From: ubuntu:22.04
Stage: final

%help
By default runs the jellyfish command. See --help for help.
If the first argument is "python", "perl", "ruby" or "irb", run
these commands. The Jellyfish module (called "jellyfish" for Perl
and Ruby, but "dna_jellyfish" for Python) is available to import/use/require.

%files from devel
/usr/local/src/jellyfish/inst/* /

%post
ldconfig
apt update
apt install -y --no-install-recommends python3 perl ruby
apt-get clean

%test
set -e
echo -n "Jellyfish cmd: "; jellyfish --help > /dev/null && echo "Good"
echo -n "Python import: "; python3 -c 'import dna_jellyfish; print("Good")'
echo -n "Perl use: "; perl -mjellyfish -e 'print("Good\n")'
echo -n "Ruby require: "; ruby -rjellyfish -e 'puts("Good")'

%runscript
#! /bin/bash
CMD=("jellyfish")
case "$1" in
(python) CMD=("python3"); shift ;;
(python3) CMD=("python3"); shift ;;
(perl) CMD=("perl" "-mjellyfish"); shift ;;
(ruby) CMD=("ruby" "-rjellyfish"); shift ;;
(irb) CMD=("irb" "-rjellyfish"); shift ;;
(jellyfish) shift ;;
esac
exec "${CMD[@]}" "$@"

0 comments on commit 4ae72a8

Please sign in to comment.