-
Notifications
You must be signed in to change notification settings - Fork 0
/
bs-movers.nf
101 lines (75 loc) · 2.26 KB
/
bs-movers.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#!/usr/bin/env nextflow
params.outDir = false
params.biosample = false
params.help = false
params.config = 'default'
def helpMessage() {
log.info"""
Usage:
The typical command for running the pipeline is as follows:
ba-movers.nf --biosample bisample1,biosample2,biosample3 --outDir ~/ebs/ref_push/prodEpi/myExpName
Mandatory arguments:
--outDir [pathOfDir] Path of where to publish the data, can be local or an S3 accessible bucket
--biosample [str] Comma seperated list of BaseSpace biosamples.
basespce token:
--config [config] if using a basespce config file different from ~/.basename/default.cfg pass ~/.basespace/<config>.cfg
""".stripIndent()
}
if (params.help){
helpMessage()
exit 0
}
if ( !(params.biosample) ){
exit 1, "You need to use either --biosample aBaseSpace-biosample or --fastqDir path/to/bam/files or --genewizMap mappingFiles.csv. Use --help to get the full usage."
}
if ( !(params.outDir) ){
exit 1, "--outDir is a required arguments. Use --help to get the full usage."
}
Channel
.from(params.biosample)
.splitCsv()
.flatten()
.set { biosample_ch }
/////
// Get BS tokent from config file
////
/// TODO: Add some logic if things are not working
bsConfig = file("${HOME}/.basespace/${params.config}.cfg", checkIfExists:true)
for ( line : bsConfig.readLines() ) {
if (m = line =~ /apiServer.+=(.+)/) {
host = m[0][1].replaceAll(' ','')
} else if ( m = line =~ /accessToken.+=(.+)/){
token = m [0][1].replaceAll(' ','')
}
}
process get_bs_files {
cpus 1
memory '1G'
container 'mblanche/basespace-cli'
input:
val bs from biosample_ch
output:
stdout into bs_id_ch
script:
"""
findNewestBS.sh ${bs} ${token} ${host}
"""
}
process download_bs {
label "movers"
cpus 4
memory '4G'
container 'mblanche/basespace-cli'
queue 'moversQ'
publishDir "${params.outDir}",
mode: 'copy'
input:
tuple id, val(bs) from bs_id_ch
.splitCsv(header: false)
output:
tuple bs, file("*.fastq.gz") into fastqs_ch
script:
"""
bs file download --api-server ${host} --access-token ${token} -i ${id} -o .
"""
}