Mercurial > repos > yating-l > jbrowsearchivecreator
comparison jbrowseArchiveCreator.py @ 25:31a41ce128cc draft
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
| author | yating-l |
|---|---|
| date | Fri, 13 Oct 2017 12:44:31 -0400 |
| parents | |
| children | 127037c49bc8 |
comparison
equal
deleted
inserted
replaced
| 24:bb6fdccef474 | 25:31a41ce128cc |
|---|---|
| 1 #!/usr/bin/env python | |
| 2 # -*- coding: utf8 -*- | |
| 3 | |
| 4 """ | |
| 5 This Galaxy tool permits to prepare your files to be ready for JBrowse visualization. | |
| 6 """ | |
| 7 | |
| 8 import sys | |
| 9 import argparse | |
| 10 import json | |
| 11 import logging | |
| 12 import collections | |
| 13 | |
| 14 | |
| 15 # Internal dependencies | |
| 16 from util.Reader import Reader | |
| 17 from util.Logger import Logger | |
| 18 from TrackHub import TrackHub | |
| 19 | |
| 20 | |
| 21 def main(argv): | |
| 22 parser = argparse.ArgumentParser(description='Create a hub to display in jbrowse.') | |
| 23 parser.add_argument('-j', '--data_json', help='JSON file containing the metadata of the inputs') | |
| 24 parser.add_argument('-o', '--output', help='Name of the HTML summarizing the content of the JBrowse Hub Archive') | |
| 25 | |
| 26 # Get the args passed in parameter | |
| 27 args = parser.parse_args() | |
| 28 json_inputs_data = args.data_json | |
| 29 outputFile = args.output | |
| 30 | |
| 31 ##Parse JSON file with Reader | |
| 32 reader = Reader(json_inputs_data) | |
| 33 | |
| 34 # Begin init variables | |
| 35 extra_files_path = reader.getExtFilesPath() | |
| 36 toolDirectory = reader.getToolDir() | |
| 37 #outputFile = reader.getOutputDir() | |
| 38 user_email = reader.getUserEmail() | |
| 39 reference_genome = reader.getRefGenome() | |
| 40 debug_mode = reader.getDebugMode() | |
| 41 track_type = reader.getTrackType() | |
| 42 #jbrowse_path = reader.getJBrowsePath() | |
| 43 apollo_host = reader.getApolloHost() | |
| 44 apollo_user = reader.getApolloUser() | |
| 45 | |
| 46 #### Logging management #### | |
| 47 # If we are in Debug mode, also print in stdout the debug dump | |
| 48 log = Logger(tool_directory=toolDirectory, debug=debug_mode, extra_files_path=extra_files_path) | |
| 49 log.setup_logging() | |
| 50 logging.info('#### JBrowseArchiveCreator: Start ####\n') | |
| 51 logging.debug('---- Welcome in JBrowseArchiveCreator Debug Mode ----\n') | |
| 52 logging.debug('JSON parameters: %s\n\n', json.dumps(reader.args)) | |
| 53 #### END Logging management #### | |
| 54 | |
| 55 # Create the Track Hub folder | |
| 56 logging.info('#### JBrowseArchiveCreator: Creating the Track Hub folder ####\n') | |
| 57 trackHub = TrackHub(reference_genome, apollo_user, outputFile, extra_files_path, toolDirectory, track_type, apollo_host) | |
| 58 | |
| 59 # Create Ordered Dictionary to add the tracks in the tool form order | |
| 60 logging.info('#### JBrowseArchiveCreator: Preparing track data ####\n') | |
| 61 all_datatype_dictionary = reader.getTracksData() | |
| 62 all_datatype_ordered_dictionary = collections.OrderedDict(all_datatype_dictionary) | |
| 63 | |
| 64 logging.debug("----- End of all_datatype_dictionary processing -----") | |
| 65 #logging.debug("all_datatype_ordered_dictionary are: %s", json.dumps(all_datatype_ordered_dictionary)) | |
| 66 | |
| 67 logging.info('#### JBrowseArchiveCreator: Adding tracks to Track Hub ####\n') | |
| 68 logging.debug("----- Beginning of Track adding processing -----") | |
| 69 | |
| 70 for index, datatypeObject in all_datatype_ordered_dictionary.iteritems(): | |
| 71 trackHub.addTrack(datatypeObject.track.track_db) | |
| 72 | |
| 73 logging.debug("----- End of Track adding processing -----") | |
| 74 | |
| 75 # We terminate the process and so create a HTML file summarizing all the files | |
| 76 logging.info('#### JBrowseArchiveCreator: Creating the HTML file ####\n') | |
| 77 trackHub.terminate(debug_mode) | |
| 78 | |
| 79 logging.debug('---- End of JBrowseArchiveCreator Debug Mode: Bye! ----\n') | |
| 80 logging.info('#### JBrowseArchiveCreator: Congratulation! Assembly Hub is created! ####\n') | |
| 81 | |
| 82 sys.exit(0) | |
| 83 | |
| 84 if __name__ == "__main__": | |
| 85 main(sys.argv) |
