comparison jbrowseArchiveCreator.py @ 6:237707a6b74d draft

planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit a500f7ab2119cc5faaf80393bd87428389d06880-dirty
author yating-l
date Thu, 15 Feb 2018 17:05:05 -0500
parents
children 62dee5369e80
comparison
equal deleted inserted replaced
5:e762f4b9e4bd 6:237707a6b74d
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
43
44 #### Logging management ####
45 # If we are in Debug mode, also print in stdout the debug dump
46 log = Logger(tool_directory=toolDirectory, debug=debug_mode, extra_files_path=extra_files_path)
47 log.setup_logging()
48 logging.info('#### JBrowseArchiveCreator: Start ####\n')
49 logging.debug('---- Welcome in JBrowseArchiveCreator Debug Mode ----\n')
50 logging.debug('JSON parameters: %s\n\n', json.dumps(reader.args))
51 #### END Logging management ####
52
53 # Create the Track Hub folder
54 logging.info('#### JBrowseArchiveCreator: Creating the Track Hub folder ####\n')
55 trackHub = TrackHub(reference_genome, outputFile, extra_files_path, toolDirectory, track_type)
56
57 # Create Ordered Dictionary to add the tracks in the tool form order
58 logging.info('#### JBrowseArchiveCreator: Preparing track data ####\n')
59 all_datatype_dictionary = reader.getTracksData()
60 all_datatype_ordered_dictionary = collections.OrderedDict(all_datatype_dictionary)
61
62 logging.debug("----- End of all_datatype_dictionary processing -----")
63 #logging.debug("all_datatype_ordered_dictionary are: %s", json.dumps(all_datatype_ordered_dictionary))
64
65 logging.info('#### JBrowseArchiveCreator: Adding tracks to Track Hub ####\n')
66 logging.debug("----- Beginning of Track adding processing -----")
67
68 for index, datatypeObject in all_datatype_ordered_dictionary.iteritems():
69 trackHub.addTrack(datatypeObject.track.track_db)
70
71 logging.debug("----- End of Track adding processing -----")
72
73 # We terminate the process and so create a HTML file summarizing all the files
74 logging.info('#### JBrowseArchiveCreator: Creating the HTML file ####\n')
75 trackHub.terminate(debug_mode)
76
77 logging.debug('---- End of JBrowseArchiveCreator Debug Mode: Bye! ----\n')
78 logging.info('#### JBrowseArchiveCreator: Congratulation! Assembly Hub is created! ####\n')
79
80 sys.exit(0)
81
82 if __name__ == "__main__":
83 main(sys.argv)