Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Containerized Bohra installation #72

Open
tetedange13 opened this issue Jul 5, 2023 · 1 comment
Open

Containerized Bohra installation #72

tetedange13 opened this issue Jul 5, 2023 · 1 comment
Assignees

Comments

@tetedange13
Copy link

Hi,

Context

I did not want to mess up my good old Conda install and Biocontainers' Docker image for Bohra only has bohra itself (and conda is absent so impossible to install all tools through bohra init)
=> So I tried to set up everything for Bohra inside a Singularity image
=> It took me ages but it eventually worked, so I thought it would be useful to share it here

Disclaimer: I am not an expert in Singularity (neither in "Conda inside Singularity"), so surely some parts can be improved

Singularity definition file

Bootstrap: docker
From: condaforge/mambaforge:22.11.1-4
# Don't know why but above never worked for me...
# (instead had to create a local "mambaforge" Sing img and "bootstrap" from it)

%post
    ## 1) Enable 'activation' of Conda envs (also add '$CONDA_PREFIX/bin' to $PATH)
    . "/opt/conda/etc/profile.d/conda.sh"

    ## 2) Configure Conda channels that will be used later by "bohra init"
    # (order matters: "conda-forge" should be added last to be prior used channel)
    # (good to also add 'defaults' channel as "mambaforge" image does not have it configured natively)
    conda config --add channels defaults && \
        conda config --add channels bioconda && \
        conda config --add channels conda-forge

    ## 3) Install "bohra" itself (alone)
    # (had to pin Python version, otherwise env cannot be solved)
    mamba install --quiet --name base --yes python=3.8 bohra=2.3.2
    conda activate base

    ## 4) Fix packages issues 
    # * "altair" package missing from bohra's Bioconda recipe ?
    pip install altair==4.2.2
    # * Manually change installed version of Moba-suite, to avoid write of ".lock" file by "mob_recon" process
    #   (incompatible with Sing img which are read-only ; see: https://github.com/phac-nml/mob-suite/issues/82)
    sed --in-place 's/mob_suite=3.0.2/mob_suite=3.0.3/' "$CONDA_PREFIX"/lib/python3.8/site-packages/bohra/bohra_install.sh

    ## 5) Let bohra install everything
    bohra init

    ## 6) Clean-up to make final image smaller (actually saves 3 GB)
    mamba clean --all --yes

    ## 7) Fix activation of local Conda env by Nextflow
    # Cmd used: "source $(conda info --json | awk '/conda_prefix/ { gsub(/"|,/, "", $2); print $2 }')/bin/activate /opt/conda/envs/bohra-${TOOL}"
    # Which results (don't know why) in "source /bin/activate /opt/conda/envs/bohra-{TOOL}"
    # -> Dirty solution is to create a symlink
    ln -s /opt/conda/bin/activate/opt/conda/bin/activate /bin/activate

%environment
    # Required to have "base" env with "bohra" inside activated at runtime
    . "/opt/conda/etc/profile.d/conda.sh"
    conda activate base

%runscript
    exec "$@"

Misc

  • Build image : singularity build --fakeroot bohra-2.3.2.sif bohra.def (final size =~ 6.3 GB)
  • Check installed tools: singularity run bohra-2.3.2.sif bohra check (a prompt asks for download of "babykraken" -> have to answer "[n]o")
  • Run pipeline : singularity run bohra-2.3.2.sif bohra run -i isolates.tab --pipeline preview --conda_prefix /opt/conda/envs

Hope this helps !
Have a nice day,
Felix.

@kristyhoran
Copy link
Collaborator

@tetedange13 thank you so much for taking the time!! Impressive effort getting all the dependencies to play nicely together!! I will attempt to add this as a recipe and some instructions to the repo for others to use!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants