@@ -146,12 +146,12 @@ def parse_args(args):
146
146
dest = 'quality' ,
147
147
default = path .join (_ROOT , 'db/ref_quality.tsv.xz' ))
148
148
149
- return parser .parse_args ()
149
+ return parser .parse_args (args [ 1 :] )
150
150
151
151
def check_install ():
152
152
from shutil import which
153
153
import sys
154
-
154
+
155
155
has_mmseqs = False
156
156
has_diamond = False
157
157
dependencies = ['diamond' , 'mmseqs' ]
@@ -275,10 +275,10 @@ def translate_gene(args,tmpdir):
275
275
276
276
def check_length (queryfile ):
277
277
from gmsc_mapper .fasta import fasta_iter
278
- logger .debug ('Start length checking ...' )
278
+ logger .debug ('Start length check ...' )
279
279
if all (len (seq ) < 303
280
280
for _ , seq in fasta_iter (queryfile )):
281
- logger .warning ('GMSC-mapper Warning: Input sequences are all more than 303nt. '
281
+ logger .warning ('GMSC-mapper Warning: Input sequences are all greater than 300bps. \n '
282
282
'Please check if your input consists of contigs, which should use -i not --nt-genes or --aa-genes as input. '
283
283
'However, we will regard your input sequences as nucleotide genes and continue to process.\n ' )
284
284
@@ -375,17 +375,17 @@ def generate_fasta(output,queryfile,resultfile):
375
375
def habitat (args ,resultfile ):
376
376
from gmsc_mapper .map_habitat import smorf_habitat
377
377
logger .debug ('Starting habitat annotation...' )
378
- single_number , single_percentage , multi_number , multi_percentage = smorf_habitat (args .habitatindex ,args .output ,args .habitat ,resultfile )
378
+ r_habitat = smorf_habitat (args .habitatindex ,args .output ,args .habitat ,resultfile )
379
379
logger .info ('habitat annotation has done.' )
380
- return single_number , single_percentage , multi_number , multi_percentage
380
+ return r_habitat
381
381
382
382
def taxonomy (args ,resultfile ,tmpdirname ):
383
383
from gmsc_mapper .map_taxonomy import deep_lca ,taxa_summary
384
384
logger .debug ('Start taxonomy annotation...' )
385
385
deep_lca (args .taxonomyindex ,args .taxonomy ,args .output ,resultfile ,tmpdirname )
386
- annotated_number , rank_number , rank_percentage = taxa_summary (args .output )
386
+ r_summary = taxa_summary (args .output )
387
387
logger .info ('Taxonomy annotation complete.' )
388
- return annotated_number , rank_number , rank_percentage
388
+ return r_summary
389
389
390
390
def quality (args ,resultfile ):
391
391
from gmsc_mapper .map_quality import smorf_quality
@@ -401,9 +401,9 @@ def main(args=None):
401
401
if args is None :
402
402
args = sys .argv
403
403
args = parse_args (args )
404
- if not args .cmd and ( not args .genome_fasta and not args .aa_input and not args .nt_input ) :
405
- sys .stderr .write ("GMSC-mapper Error: Please see gmsc-mapper -h. Assign the subcommand or input file.\n " )
406
- sys .exit (1 )
404
+ if not args .cmd and not args .genome_fasta and not args .aa_input and not args .nt_input :
405
+ sys .stderr .write ("GMSC-mapper Error: Please see gmsc-mapper -h. Choose a subcommand or input file.\n " )
406
+ sys .exit (1 )
407
407
has_diamond ,has_mmseqs = check_install ()
408
408
409
409
if args .cmd == 'createdb' :
@@ -475,15 +475,19 @@ def main(args=None):
475
475
476
476
if not args .notaxonomy :
477
477
summary .append (f'# Taxonomy' )
478
- annotated_number ,rank_number ,rank_percentage = taxonomy (args ,resultfile ,tmpdir )
479
- summary .append (str (annotated_number )+ ' (' + str (round ((1 - rank_percentage ['no rank' ])* 100 ,2 ))+ '%) aligned smORFs have taxonomy annotation.' )
480
- summary .append (str (rank_number ['kingdom' ])+ ' (' + str (round (rank_percentage ['kingdom' ]* 100 ,2 ))+ '%) aligned smORFs are annotated on kingdom.' )
481
- summary .append (str (rank_number ['phylum' ])+ ' (' + str (round (rank_percentage ['phylum' ]* 100 ,2 ))+ '%) aligned smORFs are annotated on phylum.' )
482
- summary .append (str (rank_number ['class' ])+ ' (' + str (round (rank_percentage ['class' ]* 100 ,2 ))+ '%) aligned smORFs are annotated on class.' )
483
- summary .append (str (rank_number ['order' ])+ ' (' + str (round (rank_percentage ['order' ]* 100 ,2 ))+ '%) aligned smORFs are annotated on order.' )
484
- summary .append (str (rank_number ['family' ])+ ' (' + str (round (rank_percentage ['family' ]* 100 ,2 ))+ '%) aligned smORFs are annotated on family.' )
485
- summary .append (str (rank_number ['genus' ])+ ' (' + str (round (rank_percentage ['genus' ]* 100 ,2 ))+ '%) aligned smORFs are annotated on genus.' )
486
- summary .append (str (rank_number ['species' ])+ ' (' + str (round (rank_percentage ['species' ]* 100 ,2 ))+ '%) aligned smORFs are annotated on species.' )
478
+ annotated_number ,rank_number ,rank_percentage = taxonomy (args ,resultfile ,tmpdir )
479
+ summary .append (
480
+ f'{ annotated_number } ({ 1 - rank_percentage ["no rank" ]:.2%} ) aligned smORFs have taxonomy annotation.' )
481
+ for rank in [
482
+ 'superkingdom' ,
483
+ 'phylum' ,
484
+ 'class' ,
485
+ 'order' ,
486
+ 'family' ,
487
+ 'genus' ,
488
+ 'species' ]:
489
+ summary .append (
490
+ f'{ rank_number [rank ]} ({ rank_percentage ["superkingdom" ]:.2%} ) aligned smORFs are annotated at level of { rank } .' )
487
491
488
492
with atomic_write (f'{ args .output } /summary.txt' , overwrite = True ) as ofile :
489
493
for s in summary :
0 commit comments