# HG changeset patch # User yating-l # Date 1490975649 14400 # Node ID 1e4806330e51798fbf4b0418ef15a46d632c812d # Parent 6fec27968f862b7b0f40a55631f73201d19b67f2 planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit a505d6c97db9d044761b5ce92be4a39cb84eda29-dirty diff -r 6fec27968f86 -r 1e4806330e51 TrackHub.py --- a/TrackHub.py Thu Mar 30 18:03:43 2017 -0400 +++ b/TrackHub.py Fri Mar 31 11:54:09 2017 -0400 @@ -32,8 +32,8 @@ for input_file in self.input_files: self.addTrack(input_file) self.indexName() - self.makeArchive() - self.outHtml() + slink = self.makeArchive() + self.outHtml(slink) print "Success!\n" def prepareRefseq(self): @@ -72,7 +72,18 @@ def makeArchive(self): shutil.make_archive(self.out_path, 'zip', self.out_path) - data_folder = '/var/www/html/JBrowse-1.12.1/jbrowse_hub' + source = os.path.abspath(self.out_path) + slink = source.replace('/', '_') + slink = os.path.join('/home/galaxy/galaxy/static/JBrowse-1.12.1/data', slink) + try: + if os.path.islink(slink): + os.unlink(slink) + except OSError as oserror: + print "Cannot create symlink to the data({0}): {1}".format(oserror.errno, oserror.strerror) + os.symlink(source, slink) + return slink + ''' + data_folder = '/gonramp/static/JBrowse-1.12.1/jbrowse_hub' try: if os.path.exists(data_folder): if os.path.isdir(data_folder): @@ -84,14 +95,15 @@ shutil.copytree(self.out_path, data_folder) subprocess.call(['chmod', '-R', 'o+rx', '/var/www/html/JBrowse-1.12.1/jbrowse_hub']) shutil.rmtree(self.out_path) + ''' #TODO: this will list all zip files in the filedir and sub-dirs. worked in Galaxy but all list zip files in test-data when #run it locally. May need modify - def outHtml(self): + def outHtml(self, slink): with open(self.outfile, 'w') as htmlfile: htmlstr = 'The JBrowse Hub is created:
' zipfiles = '
  • Download
  • ' - jbrowse_hub = '
  • View JBrowse Hub
  • ' + jbrowse_hub = '
  • View JBrowse Hub
  • ' filedir_abs = os.path.abspath(self.outfile) filedir = os.path.dirname(filedir_abs) filedir = os.path.join(filedir, self.outfolder) @@ -101,7 +113,7 @@ relative_directory = os.path.relpath(root, filedir) relative_file_path = os.path.join(relative_directory, file) htmlstr += zipfiles % relative_file_path - htmlstr += jbrowse_hub + htmlstr += jbrowse_hub % slink htmlfile.write(htmlstr) def createTrackList(self):