Mercurial > repos > yating-l > hubarchivecreatortest
annotate TrackHub.py @ 3:fa990284327b draft default tip
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit ac73da32d59853ca563e7939d05016a6f3a6899e-dirty
| author | yating-l | 
|---|---|
| date | Mon, 30 Oct 2017 11:58:31 -0400 | 
| parents | 85195e0d4b71 | 
| children | 
| rev | line source | 
|---|---|
| 1 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 1 #!/usr/bin/python | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 2 # -*- coding: utf8 -*- | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 3 | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 4 import logging | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 5 import os | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 6 import tempfile | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 7 import shutil | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 8 import zipfile | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 9 from mako.lookup import TemplateLookup | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 10 | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 11 # Internal dependencies | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 12 from datatypes.Datatype import Datatype | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 13 from util import subtools | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 14 from util import santitizer | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 15 | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 16 | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 17 | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 18 | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 19 class TrackHub(object): | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 20 """docstring for TrackHub""" | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 21 | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 22 def __init__(self, inputFastaFile, user_email, outputFile, extra_files_path, tool_directory): | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 23 super(TrackHub, self).__init__() | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 24 self.rootAssemblyHub = None | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 25 | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 26 self.mySpecieFolderPath = None | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 27 self.myTracksFolderPath = None | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 28 self.tool_directory = tool_directory | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 29 | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 30 self.reference_genome = inputFastaFile | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 31 # TODO: Add the specie name | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 32 self.genome_name = inputFastaFile.assembly_id | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 33 self.specie_html = self.genome_name + '.html' | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 34 self.default_pos = None | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 35 self.user_email = user_email | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 36 | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 37 # Set containing the groups already added. Updated by addGroup() | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 38 self.groups = set() | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 39 | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 40 # TODO: Modify according to the files passed in parameter | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 41 # ---- Templates ---- | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 42 # Template trackDb | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 43 mylookup = TemplateLookup(directories=[os.path.join(tool_directory, 'templates/trackDb')], | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 44 output_encoding='utf-8', encoding_errors='replace') | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 45 self.trackDbTemplate = mylookup.get_template("layout.txt") | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 46 | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 47 # Template groups | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 48 mylookup = TemplateLookup(directories=[os.path.join(self.tool_directory, 'templates/groupsTxt')], | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 49 output_encoding='utf-8', encoding_errors='replace') | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 50 self.groupsTemplate = mylookup.get_template("layout.txt") | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 51 | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 52 # ---- End Templates ---- | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 53 | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 54 self.extra_files_path = extra_files_path | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 55 self.outputFile = outputFile | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 56 | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 57 # Create the structure of the Assembly Hub | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 58 # TODO: Merge the following processing into a function as it is also used in twoBitCreator | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 59 self.twoBitName = None | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 60 self.two_bit_final_path = None | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 61 self.chromSizesFile = None | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 62 | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 63 self.default_pos = None | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 64 | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 65 # Set all the missing variables of this class, and create physically the folders/files | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 66 self.rootAssemblyHub = self.__createAssemblyHub__(extra_files_path=extra_files_path) | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 67 | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 68 # Init the Datatype | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 69 Datatype.pre_init(self.reference_genome, self.two_bit_final_path, self.chromSizesFile, | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 70 self.extra_files_path, self.tool_directory, | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 71 self.mySpecieFolderPath, self.myTracksFolderPath) | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 72 ''' | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 73 def createZip(self): | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 74 for root, dirs, files in os.walk(self.rootAssemblyHub): | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 75 # Get all files and construct the dir at the same time | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 76 for file in files: | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 77 self.outputZip.write(os.path.join(root, file)) | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 78 | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 79 self.outputZip.close() | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 80 ''' | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 81 def addTrack(self, trackDbObject=None): | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 82 # Create the trackDb.txt file in the specie folder, if not exists | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 83 # Else append the new track | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 84 # TODO: Get this out of the function | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 85 trackDbTxtFilePath = os.path.join(self.mySpecieFolderPath, 'trackDb.txt') | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 86 # Append to trackDbTxtFilePath the trackDbTemplate populate with the newTrack object | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 87 with open(trackDbTxtFilePath, 'a+') as trackDbFile: | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 88 group_name = trackDbObject["group"] | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 89 trackDbObject["group"] = santitizer.sanitize_group_name(trackDbObject["group"]) | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 90 trackDbs = [trackDbObject] | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 91 # TODO: The addGroup does not belong here. Move it when the group becomes more than just a label | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 92 # Add the group as well, if exists in trackDbObject | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 93 self.addGroup(group_name) | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 94 | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 95 htmlMakoRendered = self.trackDbTemplate.render( | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 96 trackDbs=trackDbs | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 97 ) | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 98 trackDbFile.write(htmlMakoRendered) | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 99 | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 100 #logging.debug("We just added track {0} (in group {1})".format(trackDbObject.trackName, | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 101 # trackDbObject.group_name.lower().replace(' ', '_'))) | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 102 logging.debug("We just added track {0} (in group {1})".format(trackDbObject.get("track"), | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 103 trackDbObject.get("group").lower().replace(' ', '_'))) | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 104 def addGroup(self, group_name="Default"): | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 105 # If not already present in self.groups, add to groups.txt | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 106 # Create the trackDb.txt file in the specie folder, if not exists | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 107 # Else append the new track | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 108 # TODO: Get this out of the function | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 109 groupsTxtFilePath = os.path.join(self.mySpecieFolderPath, 'groups.txt') | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 110 | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 111 # If the group is already present, we don't need to add it | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 112 if group_name in self.groups: | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 113 logging.debug("We DON'T add in {0} the group {1}".format(groupsTxtFilePath, | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 114 group_name)) | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 115 return | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 116 | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 117 # Append to trackDbTxtFilePath the trackDbTemplate populate with the newTrack object | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 118 with open(groupsTxtFilePath, 'a+') as groupFile: | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 119 # Add the group as well, if exists in trackDbObject | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 120 | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 121 htmlMakoRendered = self.groupsTemplate.render( | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 122 label=group_name | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 123 ) | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 124 groupFile.write(htmlMakoRendered) | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 125 logging.debug("We just added in {0} the group {1}".format(groupsTxtFilePath, | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 126 group_name)) | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 127 self.groups.add(group_name) | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 128 | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 129 def terminate(self): | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 130 # Just a test to output a simple HTML | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 131 # TODO: Create a class to handle the file object | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 132 mylookup = TemplateLookup(directories=[os.path.join(self.tool_directory, 'templates')], | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 133 output_encoding='utf-8', encoding_errors='replace') | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 134 | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 135 mytemplate = mylookup.get_template('display.txt') | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 136 with open(self.outputFile, 'w') as htmlOutput: | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 137 # TODO: We are basically looping two times: One time with os.walk, Second time | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 138 # with the template. We could improve that if the number of files begins to be really important | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 139 list_relative_file_path = [ ] | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 140 | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 141 # TODO: Create classes Tree to manage this => Better readibility and maintenability | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 142 def create_tree(array_path, tree, relative_array_file_path, level=0): | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 143 cur_relative_file_path = '/'.join(relative_array_file_path[:level+1]) | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 144 if array_path[0] in tree.keys(): | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 145 create_tree(array_path[1:], tree[array_path[0]][0], | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 146 relative_array_file_path, level+1) | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 147 else: | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 148 tree[array_path[0]] = ({}, cur_relative_file_path) | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 149 # TODO: Manage also the links of the directories => No link? | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 150 # => Managed in display.txt, but could also be managed there | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 151 # If we are don't have any sub-vertices | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 152 if len(array_path) == 1: | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 153 # We create the path to it | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 154 return | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 155 else: | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 156 create_tree(array_path[1:], tree[array_path[0]][0], | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 157 relative_array_file_path, level + 1) | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 158 | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 159 walkable_tree = {} | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 160 for root, dirs, files in os.walk(self.extra_files_path): | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 161 # Prepare the tree from to perform a Depth First Search | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 162 for file in files: | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 163 relative_directory = os.path.relpath(root, self.extra_files_path) | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 164 relative_file_path = os.path.join(relative_directory, file) | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 165 array_path = relative_file_path.split('/') | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 166 create_tree(array_path, walkable_tree, array_path, 0) | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 167 | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 168 htmlMakoRendered = mytemplate.render( | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 169 walkable_tree=walkable_tree | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 170 ) | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 171 htmlOutput.write(htmlMakoRendered) | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 172 | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 173 | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 174 def __createAssemblyHub__(self, extra_files_path): | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 175 # Get all necessaries infos first | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 176 # 2bit file creation from input fasta | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 177 | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 178 # baseNameFasta = os.path.basename(fasta_file_name) | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 179 # suffixTwoBit, extensionTwoBit = os.path.splitext(baseNameFasta) | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 180 # nameTwoBit = suffixTwoBit + '.2bit' | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 181 twoBitFile = tempfile.NamedTemporaryFile(bufsize=0) | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 182 subtools.faToTwoBit(self.reference_genome.false_path, twoBitFile.name) | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 183 | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 184 # Generate the twoBitInfo | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 185 twoBitInfoFile = tempfile.NamedTemporaryFile(bufsize=0) | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 186 subtools.twoBitInfo(twoBitFile.name, twoBitInfoFile.name) | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 187 | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 188 # Then we get the output to generate the chromSizes | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 189 self.chromSizesFile = tempfile.NamedTemporaryFile(bufsize=0, suffix=".chrom.sizes") | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 190 subtools.sortChromSizes(twoBitInfoFile.name, self.chromSizesFile.name) | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 191 | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 192 # We can get the biggest scaffold here, with chromSizesFile | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 193 with open(self.chromSizesFile.name, 'r') as chrom_sizes: | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 194 # TODO: Check if exists | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 195 self.default_pos = chrom_sizes.readline().split()[0] | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 196 | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 197 # TODO: Manage to put every fill Function in a file dedicated for reading reasons | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 198 # Create the root directory | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 199 myHubPath = os.path.join(extra_files_path, "myHub") | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 200 if not os.path.exists(myHubPath): | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 201 os.makedirs(myHubPath) | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 202 | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 203 # Create the specie folder | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 204 # TODO: Generate the name depending on the specie | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 205 mySpecieFolderPath = os.path.join(myHubPath, self.genome_name) | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 206 if not os.path.exists(mySpecieFolderPath): | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 207 os.makedirs(mySpecieFolderPath) | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 208 self.mySpecieFolderPath = mySpecieFolderPath | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 209 | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 210 # We create the 2bit file while we just created the specie folder | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 211 self.twoBitName = self.genome_name + ".2bit" | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 212 self.two_bit_final_path = os.path.join(self.mySpecieFolderPath, self.twoBitName) | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 213 shutil.copyfile(twoBitFile.name, self.two_bit_final_path) | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 214 | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 215 # Add the genomes.txt file | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 216 genomesTxtFilePath = os.path.join(myHubPath, 'genomes.txt') | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 217 self.__fillGenomesTxt__(genomesTxtFilePath) | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 218 | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 219 # Add the hub.txt file | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 220 hubTxtFilePath = os.path.join(myHubPath, 'hub.txt') | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 221 self.__fillHubTxt__(hubTxtFilePath) | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 222 | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 223 # Add the hub.html file | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 224 hubHtmlFilePath = os.path.join(myHubPath, self.specie_html) | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 225 self.__fillHubHtmlFile__(hubHtmlFilePath) | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 226 | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 227 | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 228 # Create the description html file in the specie folder | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 229 descriptionHtmlFilePath = os.path.join(mySpecieFolderPath, 'description.html') | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 230 self.__fillDescriptionHtmlFile__(descriptionHtmlFilePath) | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 231 | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 232 # Create the file groups.txt | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 233 # TODO: If not inputs for this, do no create the file | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 234 # groupsTxtFilePath = os.path.join(mySpecieFolderPath, 'groups.txt') | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 235 # self.__fillGroupsTxtFile__(groupsTxtFilePath) | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 236 | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 237 # Create the folder tracks into the specie folder | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 238 tracksFolderPath = os.path.join(mySpecieFolderPath, "tracks") | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 239 if not os.path.exists(tracksFolderPath): | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 240 os.makedirs(tracksFolderPath) | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 241 self.myTracksFolderPath = tracksFolderPath | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 242 | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 243 return myHubPath | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 244 | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 245 def __fillGenomesTxt__(self, genomesTxtFilePath): | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 246 # TODO: Think about the inputs and outputs | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 247 # TODO: Manage the template of this file | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 248 # renderer = pystache.Renderer(search_dirs="templates/genomesAssembly") | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 249 pathTemplate = os.path.join(self.tool_directory, 'templates/genomesAssembly') | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 250 mylookup = TemplateLookup(directories=[pathTemplate], output_encoding='utf-8', encoding_errors='replace') | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 251 mytemplate = mylookup.get_template("layout.txt") | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 252 with open(genomesTxtFilePath, 'w') as genomesTxtFile: | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 253 # Write the content of the file genomes.txt | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 254 twoBitPath = os.path.join(self.genome_name, self.twoBitName) | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 255 htmlMakoRendered = mytemplate.render( | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 256 genomeName=self.genome_name, | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 257 trackDbPath=os.path.join(self.genome_name, "trackDb.txt"), | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 258 groupsPath=os.path.join(self.genome_name, "groups.txt"), | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 259 genomeDescription=self.genome_name, | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 260 twoBitPath=twoBitPath, | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 261 organismName=self.genome_name, | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 262 defaultPosition=self.default_pos, | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 263 orderKey="4500", | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 264 scientificName=self.genome_name, | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 265 pathAssemblyHtmlDescription=os.path.join(self.genome_name, "description.html") | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 266 ) | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 267 genomesTxtFile.write(htmlMakoRendered) | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 268 | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 269 def __fillHubTxt__(self, hubTxtFilePath): | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 270 # TODO: Think about the inputs and outputs | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 271 # TODO: Manage the template of this file | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 272 mylookup = TemplateLookup(directories=[os.path.join(self.tool_directory, 'templates/hubTxt')], | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 273 output_encoding='utf-8', encoding_errors='replace') | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 274 mytemplate = mylookup.get_template('layout.txt') | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 275 with open(hubTxtFilePath, 'w') as genomesTxtFile: | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 276 # Write the content of the file genomes.txt | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 277 htmlMakoRendered = mytemplate.render( | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 278 hubName=(''.join(['gonramp', self.genome_name.title()])), | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 279 shortLabel=self.genome_name, | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 280 longLabel=self.genome_name, | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 281 genomesFile='genomes.txt', | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 282 email=self.user_email, | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 283 descriptionUrl=self.specie_html | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 284 ) | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 285 genomesTxtFile.write(htmlMakoRendered) | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 286 | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 287 def __fillHubHtmlFile__(self, hubHtmlFilePath): | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 288 # TODO: Think about the inputs and outputs | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 289 # TODO: Manage the template of this file | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 290 # renderer = pystache.Renderer(search_dirs="templates/hubDescription") | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 291 # t = Template(templates.hubDescription.layout.html) | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 292 mylookup = TemplateLookup(directories=[os.path.join(self.tool_directory, 'templates/hubDescription')], | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 293 output_encoding='utf-8', encoding_errors='replace') | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 294 mytemplate = mylookup.get_template("layout.txt") | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 295 with open(hubHtmlFilePath, 'w') as hubHtmlFile: | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 296 htmlMakoRendered = mytemplate.render( | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 297 specie='Dbia', | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 298 toolUsed='Augustus', | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 299 ncbiSpecieUrl='http://www.ncbi.nlm.nih.gov/genome/3499', | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 300 genomeID='3499', | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 301 specieFullName='Drosophila biarmipes' | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 302 ) | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 303 #hubHtmlFile.write(htmlMakoRendered) | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 304 | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 305 def __fillDescriptionHtmlFile__(self, descriptionHtmlFilePath): | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 306 # TODO: Think about the inputs and outputs | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 307 # TODO: Manage the template of this file | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 308 mylookup = TemplateLookup(directories=[os.path.join(self.tool_directory, 'templates/specieDescription')], | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 309 output_encoding='utf-8', encoding_errors='replace') | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 310 mytemplate = mylookup.get_template("layout.txt") | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 311 with open(descriptionHtmlFilePath, 'w') as descriptionHtmlFile: | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 312 # Write the content of the file genomes.txt | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 313 htmlMakoRendered = mytemplate.render( | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 314 specieDescription='This is the description of the dbia', | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 315 ) | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 316 #descriptionHtmlFile.write(htmlMakoRendered) | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 317 | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 318 def __fillGroupsTxtFile__(self, groupsTxtFilePath): | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 319 # TODO: Reenable this function at some point | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 320 mylookup = TemplateLookup(directories=[os.path.join(self.tool_directory, 'templates/groupsTxt')], | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 321 output_encoding='utf-8', encoding_errors='replace') | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 322 mytemplate = mylookup.get_template("layout.txt") | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 323 with open(groupsTxtFilePath, 'w') as groupsTxtFile: | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 324 # Write the content of groups.txt | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 325 # groupsTxtFile.write('name map') | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 326 htmlMakoRendered = mytemplate.render( | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 327 mapName='map', | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 328 labelMapping='Mapping', | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 329 prioriy='2', | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 330 isClosed='0' | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 331 ) | 
| 
85195e0d4b71
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b1ae7349f118a0fe7923d765020dfc684cf84116-dirty
 yating-l parents: diff
changeset | 332 # groupsTxtFile.write(htmlMakoRendered) | 
