-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathcleandups.nf
69 lines (46 loc) · 1.32 KB
/
cleandups.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
process getIDs {
input:
path(input)
output:
path("ids")
path("11.bim") // obviously not best way to do things
script:
" cut -f 2 $input | sort > ids "
}
process getDups {
input:
path(input)
output:
path("dups")
script:
"""
uniq -d $input > dups
touch ignore # file we create but don't stage out
"""
}
process removeDups {
input:
path badids
path orig
output:
path "clean.bim"
script:
"grep -v -f $badids $orig > clean.bim "
}
workflow {
main:
input = Channel.fromPath("data/*bim")
getIDs(input)
getDups(getIDs.out[0])
removeDups(input, getDups.out)
removeDups.out.subscribe { println "Done!" }
}
// Two problems with this code
// -- silly mistake in that the parameters for removeDups should be switched
// -- more serious -- only works for one bim file channels. If you put multiple bim files
// there is no guaranteed that the inputs on the two channels coming in removeDups will
// by synchronised
//
// Note that the Nextflow comment indicator is // -- the rest of the line is a comment
// But if you have a script and have a comment in that you must use the comment character for
// the language concerned -- see getDups