-
Notifications
You must be signed in to change notification settings - Fork 3
/
pull_containers.nf
60 lines (49 loc) · 1.5 KB
/
pull_containers.nf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/env nextflow
import nextflow.util.Escape
import nextflow.container.SingularityCache
//Auxiliary container images
def containers = []
session.getConfig().process.each {k, v ->
if((k.startsWith('withLabel:') || k.startsWith('withName:')) && v.containsKey('container') && !(k.endsWith('rrender'))) { //skipping rrender for CI
// println "$k -> $v.container"
containers << v.container
}
}
//Mappers container images
Channel.from(params.mappersDefinitions)
.filter{ params.mappers == 'all' || it.tool.matches(params.mappers) }
.map {
it.container
}
.set { mapperContainers }
SingularityCache scache = new SingularityCache() //to get NF-consitent image file names
process pull_container {
tag { remote }
maxForks 1
publishDir "${params.singularitydir}"
echo true
input:
val(remote) from mapperContainers.mix(Channel.from(containers)).unique()
output:
file(img)
script:
img = scache.simpleName(remote)
"""
singularity pull --name ${img} docker://${Escape.path(remote)}
"""
}
// String simpleName(String imageUrl) {
// def p = imageUrl.indexOf('://')
// def name = p != -1 ? imageUrl.substring(p+3) : imageUrl
// String extension = '.img'
// if( name.contains('.sif:') ) {
// extension = '.sif'
// name = name.replace('.sif:','-')
// }
// else if( name.endsWith('.sif') ) {
// extension = '.sif'
// name = name.substring(0,name.length()-4)
// }
// name = name.replace(':','-').replace('/','-')
// return name + extension
// }