Mercurial > repos > galaxyp > data_manager_eggnog_mapper
comparison data_manager/data_manager_eggnog.py @ 1:077cf0a99144 draft
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/eggnog_mapper/eggnog_mapper_data_manager commit 2200885b5049b2d952959001c8a9b5ae5c62bee5"
author | galaxyp |
---|---|
date | Fri, 04 Sep 2020 21:38:59 +0000 |
parents | 6d8144eef202 |
children | 3d82020b1e3b |
comparison
equal
deleted
inserted
replaced
0:6d8144eef202 | 1:077cf0a99144 |
---|---|
9 import sys | 9 import sys |
10 from sqlite3 import OperationalError | 10 from sqlite3 import OperationalError |
11 | 11 |
12 | 12 |
13 def _get_db_version(sqlitedb_path): | 13 def _get_db_version(sqlitedb_path): |
14 version = '4.5' | 14 version = '5.0' |
15 try: | 15 try: |
16 query = 'select version from version' | 16 query = 'select version from version' |
17 conn = sqlite3.connect(sqlitedb_path) | 17 conn = sqlite3.connect(sqlitedb_path) |
18 cur = conn.cursor() | 18 cur = conn.cursor() |
19 cur.execute(query) | 19 cur.execute(query) |
26 | 26 |
27 def main(): | 27 def main(): |
28 parser = argparse.ArgumentParser() | 28 parser = argparse.ArgumentParser() |
29 parser.add_argument('--config_file') | 29 parser.add_argument('--config_file') |
30 parser.add_argument('--install_path') | 30 parser.add_argument('--install_path') |
31 parser.add_argument('--dbs', default='') | |
32 args = parser.parse_args() | 31 args = parser.parse_args() |
33 | 32 |
34 eggnog_db_path = os.path.join(args.install_path, 'eggnog.db') | 33 eggnog_db_path = os.path.join(args.install_path, 'eggnog.db') |
35 if not os.path.exists(eggnog_db_path): | 34 if not os.path.exists(eggnog_db_path): |
36 print('Can not open: %s' % eggnog_db_path, file=sys.stderr) | 35 print('Can not open: %s' % eggnog_db_path, file=sys.stderr) |
44 dm_dict['data_tables'][data_table]\ | 43 dm_dict['data_tables'][data_table]\ |
45 = dm_dict['data_tables'].get(data_table, []) | 44 = dm_dict['data_tables'].get(data_table, []) |
46 data_table_entry = dict(value=db_version, name=db_version, | 45 data_table_entry = dict(value=db_version, name=db_version, |
47 path=args.install_path) | 46 path=args.install_path) |
48 dm_dict['data_tables'][data_table].append(data_table_entry) | 47 dm_dict['data_tables'][data_table].append(data_table_entry) |
49 data_table = 'eggnog_mapper_hmm_dbs' | |
50 dm_dict['data_tables'][data_table]\ | |
51 = dm_dict['data_tables'].get(data_table, []) | |
52 if args.dbs: | |
53 dbs = [x.strip() for x in args.dbs.split(',')] | |
54 for db in dbs: | |
55 key = '%s_%s' % (db_version, db) | |
56 data_table_entry = dict(key=key, db_version=db_version, | |
57 value=db, name=db, path=db) | |
58 dm_dict['data_tables'][data_table].append(data_table_entry) | |
59 | 48 |
60 # save info to json file | 49 # save info to json file |
61 open(args.config_file, 'wb').write(json.dumps(dm_dict)) | 50 open(args.config_file, 'w').write(json.dumps(dm_dict)) |
62 | 51 |
63 | 52 |
64 if __name__ == "__main__": | 53 if __name__ == "__main__": |
65 main() | 54 main() |