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