File tree 2 files changed +54
-7
lines changed
2 files changed +54
-7
lines changed Original file line number Diff line number Diff line change @@ -465,6 +465,58 @@ def setup_configuration():
465
465
return config
466
466
467
467
468
+ def test_database ( config ):
469
+ """Test if database directory exists, is accessible and contains necessary files."""
470
+
471
+ if ( 'db' not in config ):
472
+ sys .exit ( 'ERROR: database directory not detected! Please provide a valid path to the database directory.' )
473
+
474
+ if ( not os .access (config ['db' ], os .R_OK & os .X_OK ) ):
475
+ sys .exit ( 'ERROR: database directory (' + config ['db' ]+ ') not readable/accessible!' )
476
+
477
+ file_names = [
478
+ 'conjugation.h3f' ,
479
+ 'conjugation.h3i' ,
480
+ 'conjugation.h3m' ,
481
+ 'conjugation.h3p' ,
482
+ 'mobilization.h3f' ,
483
+ 'mobilization.h3i' ,
484
+ 'mobilization.h3m' ,
485
+ 'mobilization.h3p' ,
486
+ 'replication.h3f' ,
487
+ 'replication.h3i' ,
488
+ 'replication.h3m' ,
489
+ 'replication.h3p' ,
490
+ 'ncbifam-amr.h3f' ,
491
+ 'ncbifam-amr.h3i' ,
492
+ 'ncbifam-amr.h3m' ,
493
+ 'ncbifam-amr.h3p' ,
494
+ 'ncbifam-amr.tsv' ,
495
+ 'rRNA.i1f' ,
496
+ 'rRNA.i1i' ,
497
+ 'rRNA.i1m' ,
498
+ 'rRNA.i1p' ,
499
+ 'protein-scores.tsv' ,
500
+ 'refseq-plasmids.tsv' ,
501
+ 'inc-types.fasta' ,
502
+ 'refseq-plasmids.nhr' ,
503
+ 'refseq-plasmids.nin' ,
504
+ 'refseq-plasmids.nsq' ,
505
+ 'refseq-bacteria-nrpc-reps.inf' ,
506
+ 'refseq-bacteria-nrpc-reps_0.inf' ,
507
+ 'refseq-bacteria-nrpc-reps_0.nam' ,
508
+ 'refseq-bacteria-nrpc-reps_0.off' ,
509
+ 'refseq-bacteria-nrpc-reps_0.seq' ,
510
+ 'refseq-bacteria-nrpc-reps_0.src'
511
+ ]
512
+
513
+ for file_name in file_names :
514
+ path = config ['db' ] + '/' + file_name
515
+ if ( not os .access (path , os .R_OK ) or not os .path .isfile (path ) ):
516
+ sys .exit ( 'ERROR: database file (' + file_name + ') not readable!' )
517
+ return
518
+
519
+
468
520
def test_binaries ():
469
521
"""Test the proper installation of necessary 3rd party executables."""
470
522
Original file line number Diff line number Diff line change @@ -39,11 +39,7 @@ def main():
39
39
40
40
if ( args .db ):
41
41
config ['db' ] = os .path .abspath (args .db )
42
- elif ( 'db' not in config ):
43
- sys .exit ( 'ERROR: database directory not detected nor provided! Please provide a valid path to the database directory.' )
44
-
45
- if ( not os .access ( config ['db' ], os .R_OK & os .X_OK ) ):
46
- sys .exit ( 'ERROR: database directory (' + config ['db' ]+ ') not readable/accessible!' )
42
+ test_database ( config )
47
43
48
44
if ( 'bundled-binaries' not in config ):
49
45
test_binaries ()
@@ -106,8 +102,7 @@ def main():
106
102
107
103
108
104
if ( len (raw_contigs ) == 0 ):
109
- print ( 'Error: input file contains no valid contigs.' )
110
- sys .exit (1 )
105
+ sys .exit ( 'Error: input file contains no valid contigs.' )
111
106
112
107
if ( len (contigs ) == 0 ):
113
108
print ( HEADER )
You can’t perform that action at this time.
0 commit comments