Mercurial > repos > pimarin > data_manager_fetch_plasmidfinder
comparison plasmidfinder-db/INSTALL.py @ 3:5ffc68b4ec04 draft
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_fetch_plasmidfinder commit 5c04f6f49deca3735a752e5ac29027ba9d5ff000-dirty
author | pimarin |
---|---|
date | Fri, 17 Feb 2023 14:03:19 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
2:bd56ac4cca16 | 3:5ffc68b4ec04 |
---|---|
1 #!/usr/bin/python3 | |
2 import shutil, os, sys | |
3 | |
4 # This scripts installs the PlasmidFinder database for using KMA | |
5 # KMA should be installed before running this script | |
6 # The scripts is assumed to be located together with plasmidfinder's '.fsa' files | |
7 # | |
8 # First clone the repository: git clone https://bitbucket.org/genomicepidemiology/plasmidfinder_db.git | |
9 | |
10 # Check if executable kma_index program is installed, if not promt the user for path | |
11 | |
12 interactive = True | |
13 if len(sys.argv) >= 2: | |
14 kma_index = sys.argv[1] | |
15 if "non_interactive" in sys.argv: | |
16 interactive = False | |
17 else: | |
18 kma_index = "kma_index" | |
19 | |
20 while shutil.which(kma_index) is None: | |
21 if not interactive: | |
22 sys.exit("KMA index program, {}, does not exist or is not executable".format(kma_index)) | |
23 ans = input("Please input path to executable kma_index program or enter 'q'/'quit' to exit:") | |
24 if ans == "q" or ans == "quit": | |
25 print("Exiting!\n\n \ | |
26 Please install executable KMA programs in order to install this database.\n\n \ | |
27 KMA can be obtained from bitbucked:\n\n\ | |
28 git clone https://bitbucket.org/genomicepidemiology/kma.git\n\n\ | |
29 KMA programs must afterwards be compiled:\n\n\ | |
30 gcc -O3 -o kma KMA.c -lm -lpthread\n\ | |
31 gcc -O3 -o kma_index KMA_index.c -lm") | |
32 sys.exit() | |
33 | |
34 kma_index = ans | |
35 | |
36 if shutil.which(kma_index) is None: | |
37 print("Path, {}, is not an executable path. Please provide absolute path\n".format(ans)) | |
38 | |
39 | |
40 # Index databases | |
41 | |
42 # Use config_file to go through database dirs | |
43 config_file = open("config", "r") | |
44 for line in config_file: | |
45 if line.startswith("#"): | |
46 continue | |
47 else: | |
48 line = line.rstrip().split("\t") | |
49 species = line[0] | |
50 # for each dir index the fasta files | |
51 os.system("{0} -i {1}.fsa -o {1}".format(kma_index, species)) | |
52 config_file.close() | |
53 | |
54 print("Done") |