Mercurial > repos > yating-l > jbrowse_hub
diff TrackHub.py @ 31:d8049deb0c97 draft
planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit faeedda55e23f1197bc454d3db2d52af29d786e8-dirty
author | yating-l |
---|---|
date | Fri, 17 Mar 2017 12:28:32 -0400 |
parents | a4a54b925c73 |
children | 046c5bfc0413 |
line wrap: on
line diff
--- a/TrackHub.py Wed Mar 15 11:46:38 2017 -0400 +++ b/TrackHub.py Fri Mar 17 12:28:32 2017 -0400 @@ -1,14 +1,10 @@ #!/usr/bin/env python import os -import trackObject +import subprocess +import shutil import utils -import subprocess -import string -import shutil -import tempfile -#TODO: package JBrowse file conversion .pl files class TrackHub: def __init__(self, inputFiles, reference, outputDirect, tool_dir, genome, extra_files_path): @@ -21,10 +17,6 @@ self.raw = os.path.join(self.out_path, 'raw') self.json = os.path.join(self.out_path, 'json') try: - if not self.out_path: - raise ValueError('empty output path\n') - if not os.path.exists(self.out_path): - raise ValueError('the output folder has not been created') if os.path.exists(self.json): shutil.rmtree(self.json) os.makedirs(self.json) @@ -39,7 +31,6 @@ self.addTrack(input_file) self.indexName() self.makeArchive() - #shutil.rmtree(self.out_path) self.outHtml() print "Success!\n" @@ -59,7 +50,7 @@ bam_track = dict() bam_track['type'] = 'JBrowse/View/Track/Alignments2' bam_track['storeClass'] = 'JBrowse/Store/SeqFeature/BAM' - bam_track['label'] = track['fileName'] + bam_track['label'] = track['label'] bam_track['urlTemplate'] = os.path.join('../raw', track['fileName']) bam_track['baiUrlTemplate'] = os.path.join('../raw', track['index']) utils.add_tracks_to_json(json_file, bam_track, 'add_tracks') @@ -68,14 +59,14 @@ self.createTrackList() json_file = os.path.join(self.json, "trackList.json") bigwig_track = dict() - bigwig_track['label'] = track['fileName'] + bigwig_track['label'] = track['label'] bigwig_track['urlTemplate'] = os.path.join('../raw', track['fileName']) bigwig_track['type'] = 'JBrowse/View/Track/Wiggle/XYPlot' bigwig_track['storeClass'] = 'JBrowse/Store/SeqFeature/BigWig' utils.add_tracks_to_json(json_file, bigwig_track, 'add_tracks') else: gff3_file = os.path.join(self.raw, track['fileName']) - label = track['fileName'] + label = track['label'] if track['dataType'] == 'bedSpliceJunctions' or track['dataType'] == 'gtf': p = subprocess.Popen(['flatfile-to-json.pl', '--gff', gff3_file, '--trackType', 'CanvasFeatures', '--trackLabel', label, '--config', '{"glyph": "JBrowse/View/FeatureGlyph/Segments"}', '--out', self.json]) elif track['dataType'] == 'gff3_transcript': @@ -98,7 +89,6 @@ #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): - #htmloutput = tempfile.NamedTemporaryFile(self.outfile, suffix = '.html', bufsize=0, delete=False) with open(self.outfile, 'w') as htmlfile: htmlstr = 'The JBrowse Hub is created: <br>' zipfiles = '<li><a href = "%s">Download</a></li>' @@ -112,15 +102,13 @@ relative_file_path = os.path.join(relative_directory, file) htmlstr += zipfiles % relative_file_path - #htmlstr = htmlstr % zipfile htmlfile.write(htmlstr) def createTrackList(self): trackList = os.path.join(self.json, "trackList.json") if not os.path.exists(trackList): os.mknod(trackList) - #open(trackList,'w').close() - +