-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathle_conformers.nf
102 lines (82 loc) · 2.89 KB
/
le_conformers.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
102
/* Copyright 2024 Informatics Matters Ltd.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
nextflow.enable.dsl=2
params.input = 'molecules.sdf'
params.output = 'conformers.sdf'
params.publish_dir = './'
/* Useful params of the modules
params.chunk_size = 1000 // chunk size for splitting
params.header = false // smiles input has header line
params.num_conformers = null
params.removehs = false
params.minimize_cycles = 500
params.rms_threshold = 1.0
params.delimiter = null
params.id_column = null
*/
inputs = file(params.input)
// includes
if (inputs.name.endsWith('.sdf') || inputs.name.endsWith('.sdf.gz')) {
include { split_sdf as splitter } from './nf-processes/file/split_sdf.nf'
} else {
include { split_txt as splitter } from './nf-processes/file/split_txt.nf' addParams(suffix: '.smi')
}
include { gen_conformers } from './nf-processes/rdkit/gen_confs.nf'
include { concatenate_files } from './nf-processes/file/concatenate_files.nf' addParams(
outputfile: params.output,
glob: 'confs-*.sdf')
dateFormat = new java.text.SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'+00:00'", Locale.UK)
dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"))
def curr_t() { dateFormat.format(new java.util.Date()) }
int splits = 0
def now = curr_t()
def wrkflw = 'generate_conformers'
log.info("$now # PROGRESS -START- $wrkflw:splitter 1")
// workflow definitions
workflow generate_conformers {
take:
inputs
main:
splitter(inputs)
gen_conformers(splitter.out.flatten())
concatenate_files(gen_conformers.out[0].collect())
split_count = 0
splitter.out.flatten().subscribe {
now = curr_t()
if (split_count == 0) {
log.info("$now # PROGRESS -DONE- $wrkflw:splitter 1")
}
split_count++
log.info("$now # PROGRESS -START- $wrkflw:gen_conformers $split_count")
}
int cost = 0
int count = 0
gen_conformers.out[1].subscribe {
count += 1
cost += new Integer(it)
now = curr_t()
log.info("$now # INFO -COST- $cost $count")
log.info("$now # PROGRESS -DONE- $wrkflw:gen_conformers $count")
if (count == split_count) {
log.info("$now # PROGRESS -START- $wrkflw:concatenate_files 1")
}
}
concatenate_files.out.subscribe {
now = curr_t()
log.info("$now # PROGRESS -DONE- $wrkflw:concatenate_files 1")
}
emit:
concatenate_files.out
}
workflow {
generate_conformers(inputs)
}