-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathclassifier_module.nf
90 lines (72 loc) · 2.41 KB
/
classifier_module.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
process feature_extract {
label 'cpu'
label 'lofar_feature_lab'
time '1h'
errorStrategy 'retry'
maxRetries 1
input:
tuple path(pfd), path(bestprof), path(ps), path(png)
output:
tuple path(pfd), path(bestprof), path(ps), path(png), path("*.arff")
"""
ls
cat `ls ./ | head -n 1`
python `which PulsarFeatureLab.py` -d `pwd` -f feature_extraction.arff -t 6 -c 3 --meta --arff
"""
}
process classify {
label 'lofar_ml'
input:
tuple path(pfd), path(bestprof), path(ps), path(png), path(fex_out)
output:
tuple path(pfd), path(bestprof), path(ps), path(png), path(fex_out), path("feature_extraction*")
"""
REALPATH=`realpath ${fex_out}`
for i in {1..5}; do
java -jar `which LOTAASClassifier.jar` -m \${LOTAAS_MLC_MODEL_DIR}/V1.3.1model\${i}.model -p `realpath ${fex_out}` -a 1 -d
if [ -f "\${REALPATH%arff}positive" ]; then
mv \${REALPATH%arff}positive feature_extraction_m\${i}.positive
fi
if [ -f "\${REALPATH%arff}negative" ]; then
mv \${REALPATH%arff}negative feature_extraction_m\${i}.negative
fi
done
"""
}
process sort_detections {
label 'lofar_feature_lab'
publishDir params.out_dir, mode: 'copy', enabled: params.publish_all_classifer_cands
input:
tuple path(pfd), path(bestprof), path(ps), path(png), path(fex_out), path(classifier_files)
output:
path "positive_detections/*", optional: true, emit: positive
path "negative_detections/*", optional: true, emit: negative
"""
LOTAAS_wrapper.py
if [ -f LOTAAS_positive_detections.txt ]; then
mkdir positive_detections
for i in \$(cat LOTAAS_positive_detections.txt); do
mv \${i}* positive_detections
done
fi
if [ -f LOTAAS_negative_detections.txt ]; then
mkdir negative_detections
for i in \$(cat LOTAAS_negative_detections.txt); do
mv \${i}* negative_detections
done
fi
"""
}
workflow classifier {
take:
presto_candiates
main:
// Collate into groups of 30 candidates
collated_cands = presto_candiates.transpose().collate( 30 ).map{ it.transpose() }
feature_extract( collated_cands )
classify( feature_extract.out )
sort_detections( classify.out )
emit:
positive = sort_detections.out.positive
negative = sort_detections.out.negative
}