```)
\n",
"- set channel priority to _strict_
\n",
"- save your conda creation environment files with your codes"
]
},
{
"cell_type": "markdown",
"id": "f1202044-aa6f-489a-b48b-3a49ea3a11f5",
"metadata": {
"slideshow": {
"slide_type": "slide"
},
"tags": []
},
"source": [
"## a practical example\n",
"\n",
"You will:\n",
"1. if not yet done, initialize your conda shell
\n",
"2. check that the tool is not present in your environment
\n",
"3. create a config file to get the tool from conda
\n",
"4. create a conda environment for the tool
\n",
"5. activate the environment
\n",
"6. use the tool (version)
\n",
"7. quit
\n",
"
\n",
"\n",
"For example choose the [multiqc](https://multiqc.info/) tool, which is often used in NGS analyses.\n",
"\n",
"Search the tool in the [\"conda hub\"/Anaconda platform](https://anaconda.org/conda-forge/hub), identify the channel & version.\n",
"\n",
"Next, you will use multiqc by the way of conda."
]
},
{
"cell_type": "markdown",
"id": "558274a0-ebed-4f73-9f06-a8442352a7e7",
"metadata": {
"slideshow": {
"slide_type": "subslide"
},
"tags": []
},
"source": [
"## Conda access (practice)\n",
"Conda is so used that it could even be installed by default to your machine. \n",
"Try this: ```conda --version```\n",
"\n",
"Otherwise Conda is: \n",
"- present in the `jupyter/minimal-notebook` docker container
\n",
"- already activated on the IFB cluster, but to manage some environment variables, activate it (`module load conda`)
\n",
"\n",
"Before creating Conda environment, Conda need to know your shell version. But the ```conda init bash``` command need a close and re-open the terminal that doesn't work with the undelying terminal opened at the begining of this notebook.\n",
"\n",
"So for now, **open a term launcher** and copy/paste the notebook command line."
]
},
{
"cell_type": "markdown",
"id": "395283d6-50b5-4465-9876-f0cdc0fa01bf",
"metadata": {
"slideshow": {
"slide_type": "subslide"
},
"tags": []
},
"source": [
"Before getting the tool, if you haven't already done so, initialize your shell for conda (choose bash):\n",
"\n",
"```conda init bash```"
]
},
{
"cell_type": "markdown",
"id": "069e0acc-fc15-4a02-b8a0-199c0d7a0666",
"metadata": {
"slideshow": {
"slide_type": "fragment"
},
"tags": []
},
"source": [
"Check the absence of multiqc:"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "2e24b1e5-f805-4493-b3e2-a2e5839c1cb8",
"metadata": {
"slideshow": {
"slide_type": "fragment"
},
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"multiqc:"
]
}
],
"source": [
"%%sh\n",
"cd ${PWD}\n",
"whereis multiqc"
]
},
{
"cell_type": "markdown",
"id": "c9cb93b0-9455-4d1c-9ec7-6fe25ba4a615",
"metadata": {
"slideshow": {
"slide_type": "subslide"
},
"tags": []
},
"source": [
"Using the channel & version you found on the conda hub, edit a yml file to guide the creation of the conda environment: \n",
"\n",
" cd ${PWD}\n",
" echo \"name: env_multiqc_1.16\\nchannels:\\n - bioconda\\ndependencies:\\n - bioconda::multiqc=1.16\" > env_multiqc_1.16.yml\n",
" more env_multiqc_1.16.yml"
]
},
{
"cell_type": "markdown",
"id": "a347c20a-97b0-4b6f-bc0e-b5dec522b9cf",
"metadata": {
"slideshow": {
"slide_type": "subslide"
},
"tags": []
},
"source": [
"Manage the \"env_multiqc_1.16\" environment: 1) create 2) activate 3) use 4) quit:\n",
"\n",
" conda env list # list all conda env.\n",
" conda env create -f env_multiqc_1.16.yml # create\n",
" conda env list\n",
" conda activate env_multiqc_1.16 # activate \n",
" multiqc --help # use\n",
" conda deactivate # quit\n",
" multiqc --help # check the multiqc tool is not present"
]
},
{
"cell_type": "markdown",
"id": "2f145531-583c-452e-a6bd-27e12ea13d87",
"metadata": {
"slideshow": {
"slide_type": "slide"
},
"tags": []
},
"source": [
"## Conclusion\n",
"You've used conda to add a tool to your environment, and you've used it!\n",
"\n",
"By specifying a **configuration file** for the creation of the conda environment which contains the **version of the tool**, you have a FAIR approach (within the limitations of conda)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.4"
}
},
"nbformat": 4,
"nbformat_minor": 5
}