Note: At the time of writing this, the working version of CellProfiler was 4.2.1
- Build the singularity image with
sudo singularity build cellprofiler4.sif cp4_ubuntu20.def
- Build a sandbox version from
.def
file
sudo singularity build --sandbox cellprofiler4 cp4_ubuntu20.def
- Enter the sandbox with
sudo singularity shell --writable cellprofiler4
- Install necessary packages into the sandbox
apt-get install -y package_name
- Exit the singularity shell mode with
exit
sudo singularity build cellprofiler4.sif cellprofiler4
- Enter singularity container with
singularity shell cellprofiler4.sif
- Inside the singularity shell, check
CellProfiler
version with
cellprofiler --version
- Run
CellProfiler
with
cellprofiler
- Create two directories
mkdir libexec bin
- Pull the singularity image with
singularity pull --arch amd64 libexec/cellprofiler4.sif library://pranjaldhole/cv/cellprofiler4:latest
You can find the image on singularity hub here.
- Create an executable and make it executable and put it in the same folder as
.sif
file:
cat >libexec/cellprofiler.sh<<"EOF"
#!/bin/bash
export SINGULARITY_BINDPATH="$HOME/fileservers/chd"
dir="$(dirname $(readlink -f ${BASH_SOURCE[0]}))"
img="cellprofiler4.sif"
cmd=$(basename "$0")
arg="$@"
singularity exec "${dir}/${img}" $cmd $arg
EOF
chmod 755 libexec/cellprofiler.sh
- Create symlinks in bin directory for apps within image you want to run
ln -s ../libexec/cellprofiler.sh bin/cellprofiler
- Here is how the directory structure should look like
.
├── bin
│ └── cellprofiler -> ../libexec/cellprofiler.sh
└── libexec
├── cellprofiler4.sif
└── cellprofiler.sh
- Add the following line to your
.bashrc
and source the.bashrc
file or open a new terminal. Change the path to appropriatebin
directory.
export PATH=$PATH:$HOME/path_to_repo/cellprofiler/bin
- Test the location of the app with
$ which cellprofiler
> export /home/user/path_to_cellprofiler_dir/bin/cellprofiler
- Now you can run
cellprofiler
from the image as if its native app. TestCellProfiler
with
$ cellprofiler --version
> 4.2.1
or run CellProfiler
with
cellprofiler