@@ -186,13 +186,17 @@ def check_install():
186
186
if dep == 'mmseqs' :
187
187
has_mmseqs = True
188
188
if not has_diamond and not has_mmseqs :
189
- sys .stderr .write ('GMSC-mapper Error: Neither diamond nor mmseqs appear to be available!\n '
190
- 'At least one of them is necessary to run GMSC-mapper.\n ' )
191
- sys .exit (1 )
192
- elif has_diamond and not has_mmseqs :
193
- logger .warning ('Warning: mmseqs does not appear to be available.You can only use the `--tool diamond` option(default).' )
194
- elif not has_diamond and has_mmseqs :
195
- logger .warning ('Warning: diamond does not appear to be available.You can only use the `--tool mmseqs` option.' )
189
+ logger .warning ('GMSC-mapper Warning: Neither diamond nor mmseqs appear to be available! It will download diamond and mmseqs.\n ' )
190
+ subprocess .check_call (['wget' ,'https://mmseqs.com/latest/mmseqs-linux-avx2.tar.gz' ,
191
+ '-P' ,'./bin' ])
192
+ subprocess .check_call (['tar' ,'xvfz' ,
193
+ './bin/mmseqs-linux-avx2.tar.gz' ,
194
+ '-C' ,'./bin' ])
195
+ subprocess .check_call (['wget' ,'http://github.com/bbuchfink/diamond/releases/download/v2.1.8/diamond-linux64.tar.gz' ,
196
+ '-P' ,'./bin' ])
197
+ subprocess .check_call (['tar' ,'xvfz' ,
198
+ './bin/diamond-linux64.tar.gz' ,
199
+ '-C' ,'./bin' ])
196
200
else :
197
201
logger .info ('Dependencies installation is OK\n ' )
198
202
return has_diamond ,has_mmseqs
@@ -216,11 +220,19 @@ def expect_file(f):
216
220
sys .exit (1 )
217
221
218
222
if args .tool == "diamond" and not has_diamond :
219
- sys .stderr .write ("GMSC-mapper Error:diamond is not available.Please add diamond into your path or use the `--tool mmseqs` option.\n " )
220
- sys .exit (1 )
223
+ logger .warning ("GMSC-mapper Warning:mmseqs is not available.It will download diamond.\n " )
224
+ subprocess .check_call (['wget' ,'http://github.com/bbuchfink/diamond/releases/download/v2.1.8/diamond-linux64.tar.gz' ,
225
+ '-P' ,'./bin' ])
226
+ subprocess .check_call (['tar' ,'xvfz' ,
227
+ './bin/diamond-linux64.tar.gz' ,
228
+ '-C' ,'./bin' ])
221
229
if args .tool == "mmseqs" and not has_mmseqs :
222
- sys .stderr .write ("GMSC-mapper Error:mmseqs is not available.Please add mmseqs into your path or use the `--tool diamond` option(default).\n " )
223
- sys .exit (1 )
230
+ logger .warning ("GMSC-mapper Warning:mmseqs is not available.It will download mmseqs.\n " )
231
+ subprocess .check_call (['wget' ,'https://mmseqs.com/latest/mmseqs-linux-avx2.tar.gz' ,
232
+ '-P' ,'./bin' ])
233
+ subprocess .check_call (['tar' ,'xvfz' ,
234
+ './bin/mmseqs-linux-avx2.tar.gz' ,
235
+ '-C' ,'./bin' ])
224
236
225
237
if args .database :
226
238
expect_file (args .database )
@@ -300,26 +312,38 @@ def download_db(args):
300
312
print ('Conserved domain index file already exists. Skip downloading conserved domain index file. Use -f to force download' )
301
313
302
314
def create_db (args ):
315
+ from shutil import which
316
+
303
317
if not os .path .exists (args .output ):
304
318
os .makedirs (args .output )
305
319
306
320
diamond_out_db = path .join (args .output ,"diamond_targetdb" )
307
321
mmseqs_out_db = path .join (args .output ,"mmseqs_targetdb" )
322
+
323
+ if which ('diamond' ):
324
+ diamond = 'diamond'
325
+ else :
326
+ diamond = './bin/diamond'
327
+
328
+ if which ('mmseqs' ):
329
+ mmseqs = 'mmseqs'
330
+ else :
331
+ mmseqs = './bin/mmseqs/bin/mmseqs'
308
332
309
333
if args .quiet :
310
- diamond_cmd = [' diamond' ,'makedb' ,
334
+ diamond_cmd = [diamond ,'makedb' ,
311
335
'--in' ,args .target_faa ,
312
336
'-d' ,diamond_out_db ,
313
337
'--quiet' ]
314
- mmseqs_cmd = [' mmseqs' ,'createdb' ,
338
+ mmseqs_cmd = [mmseqs ,'createdb' ,
315
339
args .target_faa ,
316
340
mmseqs_out_db ,
317
341
'-v' ,'0' ]
318
342
else :
319
- diamond_cmd = [' diamond' ,'makedb' ,
343
+ diamond_cmd = [diamond ,'makedb' ,
320
344
'--in' ,args .target_faa ,
321
345
'-d' ,diamond_out_db ]
322
- mmseqs_cmd = [' mmseqs' ,'createdb' ,
346
+ mmseqs_cmd = [mmseqs ,'createdb' ,
323
347
args .target_faa ,
324
348
mmseqs_out_db ]
325
349
@@ -380,12 +404,19 @@ def filter_length(queryfile,tmpdir,N):
380
404
return filtered_file
381
405
382
406
def mapdb_diamond (args ,queryfile ):
407
+ from shutil import which
408
+
383
409
logger .debug ('Starting smORF mapping...' )
384
410
385
411
resultfile = path .join (args .output ,"alignment.out.smorfs.tsv" )
386
412
outfmt = '6,qseqid,sseqid,full_qseq,full_sseq,qlen,slen,length,qstart,qend,sstart,send,bitscore,pident,evalue,qcovhsp,scovhsp'
387
413
388
- diamond_cmd = ['diamond' ,'blastp' ,
414
+ if which ('diamond' ):
415
+ diamond = 'diamond'
416
+ else :
417
+ diamond = './bin/diamond'
418
+
419
+ diamond_cmd = [diamond ,'blastp' ,
389
420
'-q' ,queryfile ,
390
421
'-d' ,args .database ,
391
422
'-o' ,resultfile ,
@@ -405,6 +436,8 @@ def mapdb_diamond(args,queryfile):
405
436
return resultfile
406
437
407
438
def mapdb_mmseqs (args , queryfile , tmpdir ):
439
+ from shutil import which
440
+
408
441
logger .info ('Start smORF mapping...' )
409
442
410
443
querydb = path .join (tmpdir ,"query.db" )
@@ -413,8 +446,13 @@ def mapdb_mmseqs(args, queryfile, tmpdir):
413
446
resultfile = path .join (args .output ,"alignment.out.smorfs.tsv" )
414
447
outfmt = 'query,target,qseq,tseq,qlen,tlen,alnlen,qstart,qend,tstart,tend,bits,pident,evalue,qcov,tcov'
415
448
416
- mmseqs_cmd_db = ['mmseqs' , 'createdb' , queryfile , querydb ]
417
- mmseqs_cmd_search = ['mmseqs' ,'search' ,
449
+ if which ('mmseqs' ):
450
+ mmseqs = 'mmseqs'
451
+ else :
452
+ mmseqs = './bin/mmseqs/bin/mmseqs'
453
+
454
+ mmseqs_cmd_db = [mmseqs , 'createdb' , queryfile , querydb ]
455
+ mmseqs_cmd_search = [mmseqs ,'search' ,
418
456
querydb ,
419
457
args .database ,
420
458
resultdb ,
@@ -424,7 +462,7 @@ def mapdb_mmseqs(args, queryfile, tmpdir):
424
462
'--min-seq-id' ,str (args .identity ),
425
463
'-c' ,str (args .coverage ),
426
464
'--threads' ,str (args .threads )]
427
- mmseqs_cmd_out = [' mmseqs' ,'convertalis' ,
465
+ mmseqs_cmd_out = [mmseqs ,'convertalis' ,
428
466
querydb ,
429
467
args .database ,
430
468
resultdb ,
@@ -510,7 +548,7 @@ def main(args=None):
510
548
511
549
if not args .cmd :
512
550
validate_args (args ,has_diamond ,has_mmseqs )
513
-
551
+
514
552
if args .tool == 'diamond' :
515
553
if args .database is None :
516
554
args .database = path .join (_ROOT , 'db/diamond_targetdb.dmnd' )
0 commit comments