Mercurial > repos > yating-l > hubarchivecreator
changeset 70:39a32cb31623 draft
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 159730602ff500b59aefc7080fb49b726c88d655-dirty
author | yating-l |
---|---|
date | Tue, 26 Sep 2017 18:46:02 -0400 |
parents | ffbec960dc34 |
children | b724e559907e |
files | Reader.py TrackDb.py TrackHub.py hubArchiveCreator.xml util/Reader.py util/santitizer.py |
diffstat | 6 files changed, 11 insertions(+), 123 deletions(-) [+] |
line wrap: on
line diff
--- a/Reader.py Tue Sep 26 17:56:42 2017 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,117 +0,0 @@ -import json -import logging -import codecs - - -# Internal dependencies -from datatypes.binary.Bam import Bam -from datatypes.binary.BigWig import BigWig -from datatypes.binary.BigBed import BigBed -from datatypes.interval.Bed import Bed -from datatypes.interval.BedSimpleRepeats import BedSimpleRepeats -from datatypes.interval.BedSpliceJunctions import BedSpliceJunctions -from datatypes.interval.CytoBand import CytoBand -from datatypes.interval.BedBlatAlignments import BedBlatAlignments -from datatypes.interval.BedBlastAlignments import BedBlastAlignments -from datatypes.interval.Gff3 import Gff3 -from datatypes.interval.Gtf import Gtf -from datatypes.interval.Psl import Psl -from datatypes.sequence.Fasta import Fasta -from util import santitizer - -class Reader(object): - - DATATYPE_CLASS = [Bam, BigWig, BigBed, Bed, BedSimpleRepeats, BedSpliceJunctions, CytoBand, BedBlatAlignments, BedBlastAlignments, Gff3, Gtf, Psl, Fasta] - - def __init__(self, input_json_file): - self.inputFile = input_json_file - self.args = self.loadJson() - - - def loadJson(self): - try: - data_file = codecs.open(self.inputFile, 'r', 'utf-8') - return json.load(data_file) - except IOError: - print "Cannot find JSON file\n" - exit(1) - - def getToolDir(self): - try: - return self.args["tool_directory"] - except KeyError: - print ("tool_directory is not defined in the input file!") - exit(1) - - def getExtFilesPath(self): - try: - return self.args["extra_files_path"] - except KeyError: - print ("extra_files_path is not defined in the input file!") - exit(1) - - def getUserEmail(self): - try: - return self.args["user_email"] - except KeyError: - print ("user_email is not defined in the input file!") - exit(1) - - def getDebugMode(self): - try: - return self.args["debug_mode"] - except KeyError: - print ("debug_mode is not defined in the input file!") - exit(1) - - - def getRefGenome(self): - array_inputs_reference_genome = self.args["fasta"] - # TODO: Replace these with the object Fasta - input_fasta_file = array_inputs_reference_genome["false_path"] - input_fasta_file_name = santitizer.sanitize_name_input(array_inputs_reference_genome["name"]) - genome_name = santitizer.sanitize_name_input(self.args["genome_name"]) - reference_genome = Fasta(input_fasta_file, - input_fasta_file_name, genome_name) - return reference_genome - - - def getTracksData(self): - self.logger = logging.getLogger(__name__) - all_datatype_dictionary = dict() - for datatype in self.DATATYPE_CLASS: - class_name = datatype.__name__ - array_inputs = self.args.get(str(class_name)) - if array_inputs: - self.logger.debug("Create %s objects\n", class_name) - self.logger.debug("array_inputs: %s", array_inputs) - all_datatype_dictionary.update(self.create_ordered_datatype_objects(datatype, array_inputs)) - - return all_datatype_dictionary - - def create_ordered_datatype_objects(self, ExtensionClass, array_inputs): - """ - Function which executes the creation all the necessary files / folders for a special Datatype, for TrackHub - and update the dictionary of datatype - - :param ExtensionClass: - :param array_inputs: - :type ExtensionClass: Datatype - :type array_inputs: list[string] - """ - - datatype_dictionary = {} - - # TODO: Optimize this double loop - for input_data in array_inputs: - input_false_path = input_data["false_path"] - santitizer.sanitize_name_input(input_data["name"]) - extensionObject = ExtensionClass(input_false_path, input_data) - extensionObject.generateCustomTrack() - datatype_dictionary.update({input_data["order_index"]: extensionObject}) - return datatype_dictionary - - - - -
--- a/TrackDb.py Tue Sep 26 17:56:42 2017 -0400 +++ b/TrackDb.py Tue Sep 26 18:46:02 2017 -0400 @@ -67,8 +67,8 @@ if not "color" in extraSettings: extraSettings["color"] = "#000000" extraSettings["color"] = TrackDb.getRgb(extraSettings["color"]) - if not "group" in extraSettings: - extraSettings["group"] = "Default group" + #if "group" in extraSettings: + #extraSettings["group"] = santitizer.sanitize_group_name(extraSettings["group"]) if not "thickDrawItem" in extraSettings: extraSettings["thickDrawItem"] = "off"
--- a/TrackHub.py Tue Sep 26 17:56:42 2017 -0400 +++ b/TrackHub.py Tue Sep 26 18:46:02 2017 -0400 @@ -11,6 +11,7 @@ # Internal dependencies from datatypes.Datatype import Datatype from util import subtools +from util import santitizer @@ -84,11 +85,12 @@ trackDbTxtFilePath = os.path.join(self.mySpecieFolderPath, 'trackDb.txt') # Append to trackDbTxtFilePath the trackDbTemplate populate with the newTrack object with open(trackDbTxtFilePath, 'a+') as trackDbFile: + group_name = trackDbObject["group"] + trackDbObject["group"] = santitizer.sanitize_group_name(trackDbObject["group"]) trackDbs = [trackDbObject] - # TODO: The addGroup does not belong here. Move it when the group becomes more than just a label # Add the group as well, if exists in trackDbObject - self.addGroup(trackDbObject["group"]) + self.addGroup(group_name) htmlMakoRendered = self.trackDbTemplate.render( trackDbs=trackDbs
--- a/hubArchiveCreator.xml Tue Sep 26 17:56:42 2017 -0400 +++ b/hubArchiveCreator.xml Tue Sep 26 18:46:02 2017 -0400 @@ -1,4 +1,4 @@ -<tool id="hubArchiveCreator" name="Hub Archive Creator" version="2.4.2"> +<tool id="hubArchiveCreator" name="Hub Archive Creator" version="2.5.0"> <description> This Galaxy tool permits to prepare your files to be ready for Assembly Hub visualization.
--- a/util/Reader.py Tue Sep 26 17:56:42 2017 -0400 +++ b/util/Reader.py Tue Sep 26 18:46:02 2017 -0400 @@ -105,6 +105,7 @@ # TODO: Optimize this double loop for input_data in array_inputs: input_false_path = input_data["false_path"] + input_data["name"] = santitizer.sanitize_name_input(input_data["name"]) extensionObject = ExtensionClass(input_false_path, input_data) extensionObject.generateCustomTrack() datatype_dictionary.update({input_data["order_index"]: extensionObject})
--- a/util/santitizer.py Tue Sep 26 17:56:42 2017 -0400 +++ b/util/santitizer.py Tue Sep 26 18:46:02 2017 -0400 @@ -45,7 +45,6 @@ .replace("/", "_") \ .replace(" ", "_") - def sanitize_name_inputs(inputs_data): """ Sanitize value of the keys "name" of the dictionary passed in parameter. @@ -57,3 +56,6 @@ """ for key in inputs_data: inputs_data[key]["name"] = sanitize_name_input(inputs_data[key]["name"]) + +def sanitize_group_name(group_name): + return group_name.lower().replace(' ', '_')