forked from porchard/2021-03-sn-muscle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
find-disrupted-motifs.nf
81 lines (55 loc) · 1.64 KB
/
find-disrupted-motifs.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
#!/usr/bin/env nextflow
FIMO_BACKGROUND = params.fimo_background
MEME_GLOB = params.meme_glob
PLAIN_MOTIF_GLOB = params.plain_motif_glob
explain_channel = Channel.fromPath(params.snp_file)
process make_fastas {
container "${params.containers.mkfasta}"
publishDir "${params.results}/fastas"
input:
file(snps) from explain_channel
output:
set file("ref.fa"), file("alt.fa") into fastas
file("*.fa") into fastas_for_fimo
"""
make_ref_alt_flanking_fastas.py $snps ${params.fasta['hg19']} --flank_size 50
"""
}
process fimo_scan {
publishDir "${params.results}/fimo/scan"
maxForks 50
input:
file(bg) from Channel.fromPath(FIMO_BACKGROUND)
each file(fasta) from fastas_for_fimo.flatten()
each file(motif) from Channel.fromPath(MEME_GLOB)
output:
set val("${ref_or_alt}"), file("${ref_or_alt}.${motif_name}.fimo.txt") into concat_in
script:
ref_or_alt = fasta.getName().replaceAll('.fa', '')
motif_name = motif.getName().replaceAll('.meme', '').replaceAll('::', '_')
"""
fimo --text --bgfile $bg $motif $fasta > ${ref_or_alt}.${motif_name}.fimo.txt
"""
}
process fimo_concat {
publishDir "${params.results}/concat"
executor 'local'
input:
set val(ref_or_alt), file(fimo) from concat_in.groupTuple()
output:
file("${ref_or_alt}.fimo.txt") into fimo_out
"""
cat ${fimo.join(' ')} > ${ref_or_alt}.fimo.txt
"""
}
process diffs {
publishDir "${params.results}/diffs"
executor 'local'
input:
file(x) from fimo_out.toSortedList()
output:
file('diffs.txt')
"""
find-disrupted-motifs.py ref.fimo.txt alt.fimo.txt > diffs.txt
"""
}