 .. include:: substitutions.rst

.. _admin-page:

*******************
Admin
*******************


Structure of the build directory tree
=====================================

Among the different files and folders created in the ``build`` directory, we just focus on the ``workDir`` folder that contains the files that are automatically generated by ``geniac``. For example:

::

   └── workDir
       └── results
           ├── conda
           │   └── environment.yml
           ├── conf
           │   ├── cluster.config
           │   ├── conda.config
           │   ├── docker.config
           │   ├── multiconda.config
           │   ├── multipath.config
           │   ├── path.config
           │   └── singularity.config
           └── singularity
               ├── deffiles
               │   ├── fastqc.def
               │   ├── helloWorld.def
               │   ├── multiqc.def
               │   ├── onlyLinux.def
               │   ├── python.def
               │   └── trickySoftware.def
               └── images
                   ├── alpine.sif
                   ├── fastqc.sif
                   ├── helloworld.sif
                   ├── multiqc.sif
                   ├── onlylinux.sif
                   ├── python.sif
                   └── trickysoftware.sif

The |nextflow|_ scripts that are used to generate the ``*.config`` files and containers are also located in the ``workDir`` folder. There are:

* ``docker.nf``: generates the |docker|_ containers and Dockerfiles.
* ``singularity.nf``: generates the ``*.config`` files, the |singularity|_ images and def files.
* ``nextflow.config``: is used by the above.


Generate preload cache with default values
==========================================

In order to generate the pre-load a script ``geniac/install/cmake-init-default.cmake`` to populate the *cmake* cache, use the ``geniac/cmake/initCmakePreload.sh`` as follows:

::

   export WORK_DIR="${HOME}/tmp/myPipeline"
   export SRC_DIR="${WORK_DIR}/src"
   export BUILD_DIR="${WORK_DIR}/build"
   export GIT_URL="https://github.com/bioinfo-pf-curie/geniac-demo.git"

   mkdir -p ${INSTALL_DIR} ${BUILD_DIR}

   # clone the repository
   # the option --recursive is needed if you use geniac as a submodule
   # the option --remote-submodules will pull the last geniac version
   # using the release branch from https://github.com/bioinfo-pf-curie/geniac 
   git clone --remote-submodules --recursive ${GIT_URL} ${SRC_DIR}
   
   cd {BUILD_DIR}
   bash ${SRC_DIR}/geniac/cmake/initCmakePreload.sh ${SRC_DIR} > cmake-init-default.cmake

Containers
==========

Build
-----

The ``geniac/install/singularity.nf`` and ``geniac/install/docker.nf`` *nextflow* scripts allow the automatic generation of recipes *def files* and *Dockerfiles* respectively. They also allow the building of the containers.


Options can be passed to these scripts and can be seen the ``geniac/install/nextflow.config``. 


These scripts are automatically called during the build step of the project (see :ref:`install-page`), thus you don't have to run them manually.

Labels
------

In order to tack from which repository and version the containers were built, some labels are added in the recipes. Here is an example from a singularity def file:

::

   %labels
       gitUrl ssh://git@gitlab.curie.fr:2222/pipeline_templates/data-analysis_template.git
       gitCommit 80f6511b453a365be39e3bede6d79f0ce7253d16
   

Documentation
=============

Build the documentation locally:

::

    conda create -n readthedocs python=3.7.9
    conda activate readthedocs
    pip install --upgrade --no-cache-dir pip 'setuptools<58.3.0'
    pip install --upgrade --no-cache-dir mock==1.0.1 pillow==5.4.1 'alabaster>=0.7,<0.8,!=0.7.5' commonmark==0.8.1 recommonmark==0.5.0 sphinx sphinx-rtd-theme 'readthedocs-sphinx-ext<2.2'
    cd docs
    python -m sphinx -T -E -b html -d _build/doctrees -D language=en . _build/html
    
