forked from darcyabjones/pclust
-
Notifications
You must be signed in to change notification settings - Fork 0
/
psearch.nf
executable file
·165 lines (129 loc) · 3.38 KB
/
psearch.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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
#!/usr/bin/env nextflow
/*
vim: syntax=groovy
-*- mode: groovy;-*-
*/
def helpMessage() {
log.info"""
=================================
pclust/pupdate
=================================
Usage:
abaaab
Mandatory Arguments:
--query_profile description
--query_clusters
--query_seqs
--target_seqs
--target_db
Options:
--trees
--nomsa
Outputs:
""".stripIndent()
}
if (params.help){
helpMessage()
exit 0
}
params.query_profile = false
params.query_clusters = false
params.query_seqs = false
params.target_seqs = false
params.target_db = false
if ( !params.query_profile && !(params.query_clusters && params.query_seqs) ) {
log.info "Need either the query profile or query clusters + seqdb"
exit 1
}
if (params.target_db) {
targetSeqs = Channel.fromPath( params.target_db )
} else if (params.target_seqs) {
proteins = Channel.fromPath( params.target_seqs )
/*
* Create the mmseqs2 sequence database
*/
process createSequenceDB {
label 'mmseqs'
publishDir "${params.outdir}/sequences"
input:
file fasta from proteins
output:
file "proteins" into targetSeqs
"""
mkdir -p proteins
mmseqs createdb "${fasta}" proteins/db --max-seq-len 14000
"""
}
} else {
log.info "Need either --target_seqs or --target_db"
exit 1
}
if ( params.query_profile ) {
queryProfile = Channel.fromPath( params.query_profile )
} else {
queryClusters = Channel.fromPath( params.query_clusters )
querySeqs = Channel.fromPath( params.query_seqs )
/*
* Create profile to search against target.
*/
process createGlobalProfile {
label "mmseqs"
publishDir "${params.outdir}/search"
input:
file "clusters" from queryClusters
file "seqs" from querySeqs
output:
file "global_profile" into queryProfile
"""
mkdir -p global_profile
# Create profiles for each cluster.
# Generates the profile_consensus file too.
mmseqs result2profile \
seqs/db \
seqs/db \
clusters/db \
global_profile/db \
--threads ${task.cpus}
"""
}
}
/*
* Search the query profile against the target seqs.
*/
process searchTarget {
label "mmseqs"
publishDir "${params.outdir}/search"
input:
file "profile" from queryProfile
file "seqs" from targetSeqs
output:
file "search" into searchResults
file "search.tsv" into searchResultsTsv
"""
mkdir -p tmp
mkdir -p search
mmseqs search \
profile/db \
seqs/db \
search/db \
tmp \
-a \
--start-sens 5.0 \
--sens-steps 2 \
-s 7.0 \
--max-seqs 1000 \
--e-profile 0.01 \
--rescore-mode 1 \
--num-iterations 3
mmseqs convertalis \
profile/db \
seqs/db \
search/db \
"search.tsv" \
--threads ${task.cpus} \
--format-mode 0 \
--format-output "query target evalue qcov tcov gapopen pident nident mismatch raw bits qstart qend tstart tend qlen tlen alnlen cigar"
sed -i '1i query\ttarget\tevalue\tqcov\ttcov\tgapopen\tpident\tnident\tmismatch\traw\tbits\tqstart\tqend\ttstart\ttend\tqlen\ttlen\talnlen\tcigar' search.tsv
rm -rf -- tmp
"""
}