-
Notifications
You must be signed in to change notification settings - Fork 146
/
Copy pathanvi-script-run-eggnog-mapper
executable file
·83 lines (64 loc) · 3.53 KB
/
anvi-script-run-eggnog-mapper
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
#!/usr/bin/env python
# -*- coding: utf-8
import sys
import shutil
import anvio
import anvio.terminal as terminal
import anvio.filesnpaths as filesnpaths
from anvio.drivers.emapper import EggNOGMapper
from anvio.errors import ConfigError, FilesNPathsError
__author__ = "Developers of anvi'o (see AUTHORS.txt)"
__copyright__ = "Copyleft 2015-2018, the Meren Lab (http://merenlab.org/)"
__license__ = "GPL 3.0"
__version__ = anvio.__version__
__authors__ = ['meren']
__description__ = "Run eggnog-mapper on a contigs database, and store results"
run = terminal.Run()
progress = terminal.Progress()
pp = terminal.pretty_print
def main(args):
if args.annotation:
if not args.use_version:
raise ConfigError("If you would like to use a pre-existing annotation file to import from,\
you must also declare a version.")
args.num_threads = 1
emapper = EggNOGMapper(args, use_version=args.use_version)
emapper.populate_annotations_dict(args.annotation)
emapper.store_annotations_in_db(drop_previous_annotations=args.drop_previous_annotations)
else:
raise ConfigError("Although the codebase is ready on the anvi'o side (at least when this note was written on "
"December 2016, the eggnog-mapper will not run properly due to some technical issues beyond "
"anvi'o. Although you can still run it by hand, and then use this script with the resulting "
"output file usin gthe '--annotation' parameter. That way you can still import EggNOG "
"annotations into your contigs database. Meanwhile we will try to address this problem, and "
"hopoefully remove this note.")
output_dir = filesnpaths.get_temp_directory_path()
emapper = EggNOGMapper(args)
emapper.process(output_dir, drop_previous_annotations=args.drop_previous_annotations)
if not anvio.DEBUG:
shutil.rmtree(output_dir)
if __name__ == '__main__':
from anvio.argparse import ArgumentParser
parser = ArgumentParser(description=__description__)
parser.add_argument(*anvio.A('contigs-db'), **anvio.K('contigs-db'))
parser.add_argument('--cog-data-dir', default=None, type=str, help="The directory path for your COG setup\
if you did not use the default directory.")
parser.add_argument(*anvio.A('num-threads'), **anvio.K('num-threads', {'default': None}))
parser.add_argument('--drop-previous-annotations', default=False, action="store_true",
help='When declared, previous annotations in the database will be dropped.')
parser.add_argument('--annotation', default=None, metavar='EMAPPER_ANNOTATION_FILE',
help="If you have an annotation file from a previous run, you can call this program to\
import the contents of that file into the database instead of a run from scratch.\
In that case, you must also use the `--use-version` parameter to clarify which\
parser version should be used to parse it.")
parser.add_argument('--use-version', default='0.12.6', metavar="EMAPPER_VERSION",
help='The version of eggnog-mapper that generated the annotation file.')
args = parser.get_args(parser)
try:
main(args)
except ConfigError as e:
print(e)
sys.exit(-1)
except FilesNPathsError as e:
print(e)
sys.exit(-1)