Mercurial > repos > rmarenco > hubarchivecreator
diff TrackHub.py @ 29:7e8a8b732db3 draft
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1a81ebd0ddea950b84af3fc830e9267a4814b29f
author | yating-l |
---|---|
date | Wed, 16 May 2018 18:04:20 -0400 |
parents | d786bca6a75d |
children |
line wrap: on
line diff
--- a/TrackHub.py Mon Jul 10 17:08:38 2017 -0400 +++ b/TrackHub.py Wed May 16 18:04:20 2018 -0400 @@ -6,12 +6,14 @@ import tempfile import shutil import zipfile +from mako.lookup import TemplateLookup # Internal dependencies -from Datatype import Datatype +from datatypes.Datatype import Datatype from util import subtools +from util import santitizer -from mako.lookup import TemplateLookup + class TrackHub(object): @@ -19,7 +21,6 @@ def __init__(self, inputFastaFile, user_email, outputFile, extra_files_path, tool_directory): super(TrackHub, self).__init__() - self.rootAssemblyHub = None self.mySpecieFolderPath = None @@ -68,7 +69,7 @@ Datatype.pre_init(self.reference_genome, self.two_bit_final_path, self.chromSizesFile, self.extra_files_path, self.tool_directory, self.mySpecieFolderPath, self.myTracksFolderPath) - + ''' def createZip(self): for root, dirs, files in os.walk(self.rootAssemblyHub): # Get all files and construct the dir at the same time @@ -76,29 +77,30 @@ self.outputZip.write(os.path.join(root, file)) self.outputZip.close() - + ''' def addTrack(self, trackDbObject=None): # Create the trackDb.txt file in the specie folder, if not exists # Else append the new track # TODO: Get this out of the function 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_name) + self.addGroup(group_name) htmlMakoRendered = self.trackDbTemplate.render( trackDbs=trackDbs ) trackDbFile.write(htmlMakoRendered) - logging.debug("We just added track {0} (in group {1})".format(trackDbObject.trackName, - trackDbObject.group_name.lower().replace(' ', '_'))) - + #logging.debug("We just added track {0} (in group {1})".format(trackDbObject.trackName, + # trackDbObject.group_name.lower().replace(' ', '_'))) + logging.debug("We just added track {0} (in group {1})".format(trackDbObject.get("track"), + trackDbObject.get("group").lower().replace(' ', '_'))) def addGroup(self, group_name="Default"): # If not already present in self.groups, add to groups.txt # Create the trackDb.txt file in the specie folder, if not exists @@ -168,6 +170,7 @@ ) htmlOutput.write(htmlMakoRendered) + def __createAssemblyHub__(self, extra_files_path): # Get all necessaries infos first # 2bit file creation from input fasta