@@ -128,8 +128,7 @@ aa2rbh <- function(aa1, aa2,
128128 dbfile1 = NULL ,
129129 dbfile2 = NULL ,
130130 searchtool = " last" ,
131- lastpath = paste0(find.package(" CRBHits" ),
132- " /extdata/last-1639/bin/" ),
131+ lastpath = file.path(find.package(" CRBHits" ), " extdata" , " last-1639" , " bin" ),
133132 lastD = 1e6 ,
134133 lastm = 10 ,
135134 mmseqs2path = NULL ,
@@ -200,57 +199,32 @@ aa2rbh <- function(aa1, aa2,
200199 return (fitMatrixfun )
201200 }
202201 if (searchtool == " last" ){
203- if (! dir.exists(lastpath )){
204- stop(" Error: last PATH does not exist. Please specify correct
205- PATH and/or look into package installation prerequisites.
206- Try to use make_last() function." )
207- }
208- if (! file.exists(paste0(lastpath , " lastdb" ))){
209- stop(" Error: lastdb binary does not exist. Please specify
210- correct PATH and/or look into package installation
211- prerequisites. Try to use make_last() function." )
212- }
213- if (! file.exists(paste0(lastpath , " lastal" ))){
214- stop(" Error: lastal binary does not exist. Please specify
215- correct PATH and/or look into package installation
216- prerequisites. Try to use make_last() function." )
217- }
202+ check_ext_install(
203+ ext_name = " last" ,
204+ ext_dir = lastpath ,
205+ binary_name = " lastdb" )
206+ check_ext_install(
207+ ext_name = " last" ,
208+ ext_dir = lastpath ,
209+ binary_name = " lastal" )
218210 }
219211 if (searchtool == " mmseqs2" ){
220- if (! dir.exists(mmseqs2path )){
221- stop(" Error: mmseqs2 PATH does not exist. Please specify
222- correct PATH and/or look into package installation
223- prerequisites." )
224- }
225- if (! file.exists(paste0(mmseqs2path , " mmseqs" ))){
226- stop(" Error: mmseqs2 binary does not exist. Please specify
227- correct PATH and/or look into package installation
228- prerequisites." )
229- }
212+ check_ext_install(
213+ ext_name = " mmseqs2" ,
214+ ext_dir = mmseqs2path ,
215+ binary_name = " mmseqs" )
230216 }
231217 if (searchtool == " diamond" ){
232- if (! dir.exists(diamondpath )){
233- stop(" Error: diamond PATH does not exist. Please specify
234- correct PATH and/or look into package installation
235- prerequisites." )
236- }
237- if (! file.exists(paste0(diamondpath , " diamond" ))){
238- stop(" Error: diamond binary does not exist. Please specify
239- correct PATH and/or look into package installation
240- prerequisites." )
241- }
218+ check_ext_install(
219+ ext_name = " diamond" ,
220+ ext_dir = diamondpath ,
221+ binary_name = " diamond" )
242222 }
243223 if (searchtool == " lambda3" ){
244- if (! dir.exists(lambda3path )){
245- stop(" Error: lambda3 PATH does not exist. Please specify
246- correct PATH and/or look into package installation
247- prerequisites." )
248- }
249- if (! file.exists(paste0(lambda3path , " lambda3" ))){
250- stop(" Error: lambda3 binary does not exist. Please specify
251- correct PATH and/or look into package installation
252- prerequisites." )
253- }
224+ check_ext_install(
225+ ext_name = " lambda" ,
226+ ext_dir = lambda3path ,
227+ binary_name = " lambda3" )
254228 }
255229 selfblast <- FALSE
256230 if (suppressWarnings(all(aa1 == aa2 ))){
@@ -293,26 +267,26 @@ aa2rbh <- function(aa1, aa2,
293267 Biostrings :: writeXStringSet(aa1 , file = aa1file )
294268 Biostrings :: writeXStringSet(aa2 , file = aa2file )
295269 if (searchtool == " last" ){
296- system2(command = paste0 (lastpath , " lastdb" ),
270+ system2(command = file.path (lastpath , " lastdb" ),
297271 args = c(" -p" , " -cR01" , " -P" , threads , aa1dbfile , aa1file ))
298- system2(command = paste0 (lastpath , " lastdb" ),
272+ system2(command = file.path (lastpath , " lastdb" ),
299273 args = c(" -p" , " -cR01" , " -P" , threads , aa2dbfile , aa2file ))
300- system2(command = paste0 (lastpath , " lastal" ),
274+ system2(command = file.path (lastpath , " lastal" ),
301275 args = c(" -f" , " BlastTab+" , " -P" , threads , " -D" , lastD , " -m" , lastm ,
302276 aa1dbfile , aa2file , " >" , aa2_aa1_lastout ))
303- system2(command = paste0 (lastpath , " lastal" ),
277+ system2(command = file.path (lastpath , " lastal" ),
304278 args = c(" -f" , " BlastTab+" , " -P" , threads , " -D" , lastD , " -m" , lastm ,
305279 aa2dbfile , aa1file , " >" , aa1_aa2_lastout ))
306280 }
307281 if (searchtool == " mmseqs2" ){
308- system2(command = paste0 (mmseqs2path , " mmseqs" ),
282+ system2(command = file.path (mmseqs2path , " mmseqs" ),
309283 args = c(" easy-search" , aa1file , aa2file , aa1_aa2_lastout , outpath ,
310284 " --threads" , threads , " -s" , mmseqs2sensitivity ,
311285 " --max-seqs" , mmseqs2maxseqs ,
312286 " --format-output" , paste0(" query,target,fident,alnlen," ,
313287 " mismatch,gapopen,qstart,qend,tstart,tend,evalue,bits,qlen," ,
314288 " tlen,raw" )))
315- system2(command = paste0 (mmseqs2path , " mmseqs" ),
289+ system2(command = file.path (mmseqs2path , " mmseqs" ),
316290 args = c(" easy-search" , aa2file , aa1file , aa2_aa1_lastout , outpath ,
317291 " --threads" , threads , " -s" , mmseqs2sensitivity ,
318292 " --max-seqs" , mmseqs2maxseqs ,
@@ -321,20 +295,20 @@ aa2rbh <- function(aa1, aa2,
321295 " tlen,raw" )))
322296 }
323297 if (searchtool == " diamond" ){
324- system2(command = paste0 (diamondpath , " diamond" ),
298+ system2(command = file.path (diamondpath , " diamond" ),
325299 args = c(" makedb" , " --in" , aa1file ,
326300 " -d" , aa1dbfile ))
327- system2(command = paste0 (diamondpath , " diamond" ),
301+ system2(command = file.path (diamondpath , " diamond" ),
328302 args = c(" makedb" , " --in" , aa2file ,
329303 " -d" , aa2dbfile ))
330- system2(command = paste0 (diamondpath , " diamond" ),
304+ system2(command = file.path (diamondpath , " diamond" ),
331305 args = c(" blastp" , " --ignore-warnings" , " -d" , aa2dbfile ,
332306 " -q" , aa1file , " -o" , aa1_aa2_lastout , diamondsensitivity ,
333307 " --max-target-seqs" , diamondmaxtargetseqs ,
334308 " -f" , " 6" , " qseqid" , " sseqid" , " pident" , " length" , " mismatch" ,
335309 " gapopen" , " qstart" , " qend" , " sstart" , " send" , " evalue" ,
336310 " bitscore" , " qlen" , " slen" , " score" , " --threads" , threads ))
337- system2(command = paste0 (diamondpath , " diamond" ),
311+ system2(command = file.path (diamondpath , " diamond" ),
338312 args = c(" blastp" , " --ignore-warnings" , " -d" , aa1dbfile ,
339313 " -q" , aa2file , " -o" , aa2_aa1_lastout , diamondsensitivity ,
340314 " --max-target-seqs" , diamondmaxtargetseqs ,
@@ -343,18 +317,18 @@ aa2rbh <- function(aa1, aa2,
343317 " bitscore" , " qlen" , " slen" , " score" , " --threads" , threads ))
344318 }
345319 if (searchtool == " lambda3" ){
346- system2(command = paste0 (lambda3path , " lambda3" ),
320+ system2(command = file.path (lambda3path , " lambda3" ),
347321 args = c(" mkindexp" , " -d" , aa1file , " -i" , aa1dbfile ,
348322 " --threads" , threads ))
349- system2(command = paste0 (lambda3path , " lambda3" ),
323+ system2(command = file.path (lambda3path , " lambda3" ),
350324 args = c(" mkindexp" , " -d" , aa2file , " -i" , aa2dbfile ,
351325 " --threads" , threads ))
352- system2(command = paste0 (lambda3path , " lambda3" ),
326+ system2(command = file.path (lambda3path , " lambda3" ),
353327 args = c(" searchp" , " -i" , aa2dbfile , " -q" , aa1file ,
354328 " -o" , aa1_aa2_lastout , " -p" , lambda3sensitivity ,
355329 " --num-matches" , lambda3nummatches , " --output-columns" ,
356330 " 'std qlen slen score'" , " --threads" , threads ))
357- system2(command = paste0 (lambda3path , " lambda3" ),
331+ system2(command = file.path (lambda3path , " lambda3" ),
358332 args = c(" searchp" , " -i" , aa1dbfile , " -q" , aa2file ,
359333 " -o" , aa2_aa1_lastout , " -p" , lambda3sensitivity ,
360334 " --num-matches" , lambda3nummatches , " --output-columns" ,
0 commit comments