forked from CAMI-challenge/quast_frc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
icarus.py
executable file
·87 lines (73 loc) · 3.34 KB
/
icarus.py
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
#!/usr/bin/env python
############################################################################
# Copyright (c) 2015-2017 Saint Petersburg State University
# Copyright (c) 2011-2015 Saint Petersburg Academic University
# All Rights Reserved
# See file LICENSE for details.
############################################################################
import sys
from quast_libs import qconfig
qconfig.check_python_version()
from os.path import isdir
from optparse import OptionParser, BadOptionError, AmbiguousOptionError
class PassThroughOptionParser(OptionParser):
"""
An unknown option pass-through implementation of OptionParser.
"""
def _process_args(self, largs, rargs, values):
while rargs:
try:
OptionParser._process_args(self,largs,rargs,values)
except (BadOptionError, AmbiguousOptionError):
exc_value = sys.exc_info()[1]
largs.append(exc_value.opt_str)
def main(args):
sys.stderr.write("\n")
sys.stderr.write("Icarus: visualizer for de novo assembly evaluation\n")
sys.stderr.write("\n")
sys.stderr.write("Icarus is embedded into QUAST and MetaQUAST pipelines\n")
sys.stderr.write("\n")
if not args:
sys.stderr.write("Please run ./quast.py -h or ./metaquast.py -h to see the full list of options\n")
sys.stderr.write("\n")
sys.exit(0)
parser = PassThroughOptionParser()
parser.add_option('-R', '--reference', dest='reference', action='append', default=[])
parser.add_option('--fast', dest='no_icarus', action='store_true', default=False)
parser.add_option('--no-html', dest='no_icarus', action='store_true')
parser.add_option('--unique-mapping', dest='use_metaquast', action='store_true', default=False)
parser.add_option('--max-ref-number', dest='use_metaquast', action='store_true')
parser.add_option('--references-list', dest='use_metaquast', action='store_true')
parser.add_option('--blast-db', dest='use_metaquast', action='store_true')
parser.add_option('--test-no-ref', dest='use_metaquast', action='store_true')
parser.add_option('--test-sv', dest='use_metaquast', action='store_false')
(opts, l_args) = parser.parse_args(args)
if opts.no_icarus:
sys.stderr.write("Please remove --fast and --no-html from options and restart Icarus\n")
sys.exit(0)
if len(opts.reference) > 1:
opts.use_metaquast = True
elif len(opts.reference) == 1:
if ',' in opts.reference[0] or isdir(opts.reference[0]):
opts.use_metaquast = True
if opts.use_metaquast:
import metaquast
quast_fn = metaquast.main
sys.stderr.write("Icarus will run metaquast.py (for metagenomic dataset)\n")
else:
import quast
quast_fn = quast.main
sys.stderr.write("Icarus will run quast.py (for single-genome evaluation)\n")
sys.stderr.write("Icarus main menu will be saved to <output_dir>/icarus.html\n")
sys.stderr.write("Icarus viewers will be saved to <output_dir>/icarus_viewers/\n")
sys.stderr.write("\n")
return quast_fn(args)
if __name__ == '__main__':
try:
return_code = main(sys.argv[1:])
exit(return_code)
except Exception:
_, exc_value, _ = sys.exc_info()
sys.stderr.write(str(exc_value) + '\n')
sys.stderr.write('exception caught!' + '\n')
exit(1)