<!-- .slide: data-background="https://raw.githubusercontent.com/maxulysse/maxulysse.github.io/main/assets/img/svg/green_white_bg.svg" -->
<a href="https://www.nf-co.re"><img src="https://raw.githubusercontent.com/nf-core/logos/master/byte-size-logos/bytesize-darkbg.svg" width="60%"><img></a>
# \#34: Updates on the new DSL2 syntax
Maxime U Garcia ▸ [<i class="fa fa-twitter" aria-hidden="true"></i>@gau](https://twitter.com/gau/) | [<i class="fa fa-github" aria-hidden="true"></i>@maxulysse](https://github.com/maxulysse/)
Karolinska Institutet | Science for Life Laboratory
Sweden
---
## Overview
- 🍬 What's new?
- 🧙 What can be done?
- 🚀 What should be done?
---
## Disclaimer
- My own takes on the new syntax
- Other developers might have other ideas
- We're trying to forge the best practices
- Syntax and/or logic might (and probably will) evolve
---
## All the new stuff
- Modules are fully self-contained
- No need for any `functions.nf` anymore
- New usage of [`task.ext`](https://www.nextflow.io/docs/latest/process.html#ext) directive:
- `ext.args`
- `ext.args2`
- `ext.args3`
- `ext.prefix`
- `ext.when`
- To be used with a [`withName`](https://www.nextflow.io/docs/latest/config.html#process-selectors) selector
---
## A brand new world
<img src="https://c.tenor.com/eDydgLWPWIsAAAAC/is-this-the-greatest-power-in-the-universe-loki.gif" title="Is this the greatest power in the universe - Loki" alt="Is this the greatest power in the universe - Loki"/>
---
### Closures are your new best friends
- Can be used to decide `args`
- Can be used to decide `prefix`
- Can be used to decide `when` to run modules
---
### What is the downside
<img src="https://i.imgflip.com/65x8c8.jpg" title="Gru's great plan" alt="Whole new syntax for modules > Allow usage of task.ext directive > logic can go in config > logic is also in config"/>
---
## What should be done
- Beware when settings up `task.args`...
- Write comments to explain logic
- Good for future you
- You will forget about it
- Good for other developers
- They need to understand what you did and why
---
## Examples with Sarek
- [`prepare_genome.nf`](https://github.com/nf-core/sarek/blob/096f97d628dd22a16bc67b2a6ab44cdae55b3e51/subworkflows/local/prepare_genome.nf)
- [`modules.config`](https://github.com/nf-core/sarek/blob/096f97d628dd22a16bc67b2a6ab44cdae55b3e51/conf/modules.config#L33-L143)
- [`gatk4_mapping/main.nf`](https://github.com/nf-core/sarek/blob/096f97d628dd22a16bc67b2a6ab44cdae55b3e51/subworkflows/nf-core/gatk4_mapping/main.nf)
- [`modules.config`](https://github.com/nf-core/sarek/blob/096f97d628dd22a16bc67b2a6ab44cdae55b3e51/conf/modules.config#L222-L272)
- [`markduplicates.nf`](https://github.com/nf-core/sarek/blob/096f97d628dd22a16bc67b2a6ab44cdae55b3e51/subworkflows/nf-core/markduplicates.nf)
- [`modules.config`](https://github.com/nf-core/sarek/blob/096f97d628dd22a16bc67b2a6ab44cdae55b3e51/conf/modules.config#L274-L358)
---
## Acknowledgements
<img src="https://raw.githubusercontent.com/maxulysse/maxulysse.github.io/main/assets/img/svg/acknowledgments_2021_dark.svg" title="Institutes acknowledgements" alt="Institutes acknowledgements"/>
---
<a href="https://nf-co.re/community#organisations">
<img src="https://raw.githubusercontent.com/maxulysse/maxulysse.github.io/main/assets/img/svg/institutes_2021_dark.svg" title="Institutes acknowledgements" alt="Institutes acknowledgements"/>
</a>
---
<a href="https://nf-co.re/community#contributors">
<img src="https://raw.githubusercontent.com/maxulysse/maxulysse.github.io/main/assets/img/slides/nf-core_contributors_2021_03.png" title="Contributors acknowledgements" alt="Contributors acknowledgements"/>
</a>
---
<!-- .slide: data-background="https://raw.githubusercontent.com/maxulysse/maxulysse.github.io/main/assets/img/svg/green_white_bg.svg" -->
## Need help?
- bytesize 05: [DSL2 module development](https://nf-co.re/events/2021/bytesize-5-dsl2-module-development)
- bytesize 06: [All about modules](https://nf-co.re/events/2021/bytesize-6-dsl2-using-modules-pipelines)
- bytesize 24: [Where do I start writing my own DSL2 pipeline?!](https://nf-co.re/events/2021/bytesize-24-dsl2-pipeline-starter)
Get involved:
[https://nf-co.re/join](https://nf-co.re/join)
[<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" focusable="false" width="1.6em" height="1.6em" style="-ms-transform: rotate(360deg); -webkit-transform: rotate(360deg); transform: rotate(360deg);" preserveAspectRatio="xMidYMid meet" viewBox="0 0 24 24" class="slack-svg"><path d="M5.042 15.165a2.528 2.528 0 0 1-2.52 2.523A2.528 2.528 0 0 1 0 15.165a2.527 2.527 0 0 1 2.522-2.52h2.52v2.52zm1.271 0a2.527 2.527 0 0 1 2.521-2.52a2.527 2.527 0 0 1 2.521 2.52v6.313A2.528 2.528 0 0 1 8.834 24a2.528 2.528 0 0 1-2.521-2.522v-6.313zM8.834 5.042a2.528 2.528 0 0 1-2.521-2.52A2.528 2.528 0 0 1 8.834 0a2.528 2.528 0 0 1 2.521 2.522v2.52H8.834zm0 1.271a2.528 2.528 0 0 1 2.521 2.521a2.528 2.528 0 0 1-2.521 2.521H2.522A2.528 2.528 0 0 1 0 8.834a2.528 2.528 0 0 1 2.522-2.521h6.312zm10.122 2.521a2.528 2.528 0 0 1 2.522-2.521A2.528 2.528 0 0 1 24 8.834a2.528 2.528 0 0 1-2.522 2.521h-2.522V8.834zm-1.268 0a2.528 2.528 0 0 1-2.523 2.521a2.527 2.527 0 0 1-2.52-2.521V2.522A2.527 2.527 0 0 1 15.165 0a2.528 2.528 0 0 1 2.523 2.522v6.312zm-2.523 10.122a2.528 2.528 0 0 1 2.523 2.522A2.528 2.528 0 0 1 15.165 24a2.527 2.527 0 0 1-2.52-2.522v-2.522h2.52zm0-1.268a2.527 2.527 0 0 1-2.52-2.523a2.526 2.526 0 0 1 2.52-2.52h6.313A2.527 2.527 0 0 1 24 15.165a2.528 2.528 0 0 1-2.522 2.523h-6.313z" fill="white" class="slack-path"/></svg>](https://nfcore.slack.com/) [<i class="fa fa-twitter fa-2x" aria-hidden="true"></i>](https://www.twitter.com/nf_core) [<i class="fa fa-github fa-2x" aria-hidden="true"></i>](https://github.com/nf-core) [<i class="fa fa-youtube fa-2x" aria-hidden="true"></i>](https://www.youtube.com/c/nf-core)
<style>
.reveal section img { background:none; border:none; box-shadow:none; }
body {
background-image: url(https://raw.githubusercontent.com/nf-core/logos/master/nf-core-logos/nf-core-logo-square.svg);
background-size: 7.5%;
background-repeat: no-repeat;
background-position: 3% 96%;
background-color: #181a1b;
}
.reveal body {
font-family: 'Roboto', sans-serif;
font-weight: 300;
color: white;
}
.reveal p {
font-family: 'Roboto', sans-serif;
font-weight: 300;
color: white;
}
.reveal h1 {
font-family: 'Roboto', sans-serif;
font-style: bold;
font-weight: 400;
color: white;
font-size: 62px;
}
.reveal h2 {
font-family: 'Roboto', sans-serif;
font-weight: 300;
color: white;
}
.reveal h3 {
font-family: 'Roboto', sans-serif;
font-style: italic;
font-weight: 300;
color: white;
}
.reveal p {
font-family: 'Roboto', sans-serif;
font-weight: 300;
color: white;
}
.reveal li {
font-family: 'Roboto', sans-serif;
font-weight: 300;
color: white;
}
.reveal pre {
background-color: #272822 !important;
display: inline-block;
border-radius: 7px;
color: #aaaba9;
}
.reveal pre code {
color: #eeeeee;
background-color: #272822;
font-size: 100%;
}
.reveal code {
background-color: #272822;
font-size: 75%;
}
.reveal .progress {
color: #24B064;
}
.reveal .controls button {
color: #24B064;
}
.reveal blockquote {
display: block;
position: relative;
width: 90%;
margin: 20px auto;
padding: 5px;
background: rgba(255, 255, 255, 0.05);
box-shadow: 0px 0px 2px rgb(0 0 0 / 20%);
}
.fa {
color: white;
}
a .fa-github:hover { color: #000000; }
a .fa-spotify:hover { color: #1DB954; }
a .fa-twitter:hover { color: #4099FF; }
a .fa-youtube:hover { color: #FF0000; }
a .slack-svg:hover .slack-path {fill: #000000;}
</style>
{"metaMigratedAt":"2023-06-16T19:56:08.989Z","metaMigratedFrom":"YAML","title":"nf-core/bytesize - Updates on the new DSL2 syntax","breaks":true,"contributors":"[{\"id\":\"fb193497-1111-470c-a594-827d34b6f673\",\"add\":8831,\"del\":805}]"}