Mercurial > repos > yating-l > gonramp_apollo_tools
comparison jbrowsehubToApollo.py @ 2:4be6fcac4bf2 draft default tip
planemo upload for repository https://github.com/Yating-L/suite_gonramp_apollo.git commit 5367a00befb467f162d1870edb91f9face72e894
author | yating-l |
---|---|
date | Wed, 29 Nov 2017 15:39:32 -0500 |
parents | 1da8b9042af4 |
children |
comparison
equal
deleted
inserted
replaced
1:78af01d73add | 2:4be6fcac4bf2 |
---|---|
23 ##Parse JSON file with Reader | 23 ##Parse JSON file with Reader |
24 reader = Reader(json_inputs_data) | 24 reader = Reader(json_inputs_data) |
25 | 25 |
26 # Begin init variables | 26 # Begin init variables |
27 extra_files_path = reader.getExtFilesPath() | 27 extra_files_path = reader.getExtFilesPath() |
28 jbrowse_hub = reader.getJBrowseHubDir() | |
28 #user_email = reader.getUserEmail() | 29 #user_email = reader.getUserEmail() |
29 species_name = reader.getSpeciesName() | 30 species_name = reader.getSpeciesName() |
30 #apollo_host = reader.getApolloHost() | 31 #apollo_host = reader.getApolloHost() |
31 apollo_port = reader.getPortNum() | 32 apollo_port = reader.getPortNum() |
32 apollo_host = "http://localhost:"+ apollo_port + "/apollo" | 33 apollo_host = "http://localhost:"+ apollo_port + "/apollo" |
33 #apollo_host = "http://localhost:8080/apollo" | 34 #apollo_host = "http://localhost:8080/apollo" |
34 #apollo_user = reader.getApolloUser() | 35 #apollo_user = reader.getApolloUser() |
35 apollo_admin_user = reader.getAdminUser() | 36 apollo_admin_user = reader.getAdminUser() |
36 toolDirectory = reader.getToolDir() | 37 toolDirectory = reader.getToolDir() |
37 #jbrowse_hub = reader.getJBrowseHubDir() | |
38 debug_mode = reader.getDebugMode() | 38 debug_mode = reader.getDebugMode() |
39 action = reader.getAction() | 39 action = reader.getAction() |
40 | 40 |
41 #### Logging management #### | 41 #### Logging management #### |
42 # If we are in Debug mode, also print in stdout the debug dump | 42 # If we are in Debug mode, also print in stdout the debug dump |
43 log = Logger(tool_directory=toolDirectory, debug=debug_mode) | 43 log = Logger(tool_directory=toolDirectory, debug=debug_mode, extra_files_path=extra_files_path) |
44 log.setup_logging() | 44 log.setup_logging() |
45 | 45 |
46 <<<<<<< HEAD | |
47 logging.info("#### JBrowsehub To Apollo: Start to %s JBrowse Hub to Apollo instance: %s #### ", action, apollo_host) | 46 logging.info("#### JBrowsehub To Apollo: Start to %s JBrowse Hub to Apollo instance: %s #### ", action, apollo_host) |
48 ======= | |
49 logging.info("#### JBrowseArchiveCreator: Start to %s JBrowse Hub to Apollo instance: %s #### ", action, apollo_host) | |
50 >>>>>>> 8b9a3b41d4dd4689764592d278ec2d67f67fbca4 | |
51 logging.debug('JSON parameters: %s\n\n', json.dumps(reader.args)) | 47 logging.debug('JSON parameters: %s\n\n', json.dumps(reader.args)) |
52 | 48 |
53 # Set up apollo | 49 # Set up apollo |
54 apollo = ApolloInstance(apollo_host, apollo_admin_user, toolDirectory) | 50 apollo = ApolloInstance(apollo_host, apollo_admin_user, toolDirectory) |
55 jbrowse_hub_dir = _getHubDir(extra_files_path) | 51 jbrowse_hub_dir = _getHubDir(jbrowse_hub) |
56 <<<<<<< HEAD | |
57 apollo.manageApolloOrganism(species_name, jbrowse_hub_dir, action) | 52 apollo.manageApolloOrganism(species_name, jbrowse_hub_dir, action) |
58 ======= | 53 outHtml(outputFile, apollo_host, species_name, action) |
59 apollo.loadHubToApollo(species_name, jbrowse_hub_dir, action) | |
60 >>>>>>> 8b9a3b41d4dd4689764592d278ec2d67f67fbca4 | |
61 outHtml(outputFile, apollo_host, species_name) | |
62 | 54 |
63 logging.info('#### JBrowsehub To Apollo: Congratulation! JBrowse Hub is uploaded! ####\n') | 55 logging.info('#### JBrowsehub To Apollo: Congratulation! JBrowse Hub is uploaded! ####\n') |
64 | 56 |
65 def _getHubDir(extra_files_path): | 57 def _getHubDir(extra_files_path): |
66 for root, dirs, files in os.walk(extra_files_path): | 58 for root, dirs, files in os.walk(extra_files_path): |
69 logging.debug("JBrowse hub directory: %s", root) | 61 logging.debug("JBrowse hub directory: %s", root) |
70 return root | 62 return root |
71 logging.error("Cannot find jbrowsehub") | 63 logging.error("Cannot find jbrowsehub") |
72 exit(-1) | 64 exit(-1) |
73 | 65 |
74 def outHtml(outputFile, host_name, species_name): | 66 def outHtml(outputFile, host_name, species_name, action): |
75 with open(outputFile, 'w') as htmlfile: | 67 with open(outputFile, 'w') as htmlfile: |
76 htmlstr = 'The new Organism "%s" is created on Apollo: <br>' % species_name | 68 if action == "add": |
69 htmlstr = 'The Organism "%s" is added on Apollo: <br>' % species_name | |
70 elif action == "overwrite": | |
71 htmlstr = 'The Organism "%s" is overwritten on Apollo: <br>' % species_name | |
77 jbrowse_hub = '<li><a href = "%s" target="_blank">View JBrowse Hub on Apollo</a></li>' % host_name | 72 jbrowse_hub = '<li><a href = "%s" target="_blank">View JBrowse Hub on Apollo</a></li>' % host_name |
78 htmlstr += jbrowse_hub | 73 htmlstr += jbrowse_hub |
79 htmlfile.write(htmlstr) | 74 htmlfile.write(htmlstr) |
80 | 75 |
81 if __name__ == "__main__": | 76 if __name__ == "__main__": |