comparison TrackHub.py @ 37:046c5bfc0413 draft

planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit faeedda55e23f1197bc454d3db2d52af29d786e8-dirty
author yating-l
date Fri, 17 Mar 2017 16:21:25 -0400
parents d8049deb0c97
children 75edbc203532
comparison
equal deleted inserted replaced
36:d5ec43607f66 37:046c5bfc0413
42 p.communicate() 42 p.communicate()
43 except OSError as e: 43 except OSError as e:
44 print "Cannot prepare reference error({0}): {1}".format(e.errno, e.strerror) 44 print "Cannot prepare reference error({0}): {1}".format(e.errno, e.strerror)
45 #TODO: hard coded the bam and bigwig tracks. Need to allow users to customize the settings 45 #TODO: hard coded the bam and bigwig tracks. Need to allow users to customize the settings
46 def addTrack(self, track): 46 def addTrack(self, track):
47 track_label = track['label']
48 track_color = track['track_color']
49 track_type = track['track_type']
47 if track['dataType'] == 'bam': 50 if track['dataType'] == 'bam':
48 self.createTrackList() 51 self.createTrackList()
49 json_file = os.path.join(self.json, "trackList.json") 52 json_file = os.path.join(self.json, "trackList.json")
50 bam_track = dict() 53 bam_track = dict()
51 bam_track['type'] = 'JBrowse/View/Track/Alignments2' 54 bam_track['type'] = 'JBrowse/View/Track/Alignments2'
52 bam_track['storeClass'] = 'JBrowse/Store/SeqFeature/BAM' 55 bam_track['storeClass'] = 'JBrowse/Store/SeqFeature/BAM'
53 bam_track['label'] = track['label'] 56 bam_track['label'] = track_label
57 bam_track['color'] = track_color
54 bam_track['urlTemplate'] = os.path.join('../raw', track['fileName']) 58 bam_track['urlTemplate'] = os.path.join('../raw', track['fileName'])
55 bam_track['baiUrlTemplate'] = os.path.join('../raw', track['index']) 59 bam_track['baiUrlTemplate'] = os.path.join('../raw', track['index'])
56 utils.add_tracks_to_json(json_file, bam_track, 'add_tracks') 60 utils.add_tracks_to_json(json_file, bam_track, 'add_tracks')
57 print "add bam track\n" 61 # print "add bam track\n"
58 elif track['dataType'] == 'bigwig': 62 elif track['dataType'] == 'bigwig':
59 self.createTrackList() 63 self.createTrackList()
60 json_file = os.path.join(self.json, "trackList.json") 64 json_file = os.path.join(self.json, "trackList.json")
61 bigwig_track = dict() 65 bigwig_track = dict()
62 bigwig_track['label'] = track['label'] 66 bigwig_track['label'] = track_label
67 bigwig_track['color'] = track_color
63 bigwig_track['urlTemplate'] = os.path.join('../raw', track['fileName']) 68 bigwig_track['urlTemplate'] = os.path.join('../raw', track['fileName'])
64 bigwig_track['type'] = 'JBrowse/View/Track/Wiggle/XYPlot' 69 bigwig_track['type'] = 'JBrowse/View/Track/Wiggle/XYPlot'
65 bigwig_track['storeClass'] = 'JBrowse/Store/SeqFeature/BigWig' 70 bigwig_track['storeClass'] = 'JBrowse/Store/SeqFeature/BigWig'
66 utils.add_tracks_to_json(json_file, bigwig_track, 'add_tracks') 71 utils.add_tracks_to_json(json_file, bigwig_track, 'add_tracks')
67 else: 72 else:
68 gff3_file = os.path.join(self.raw, track['fileName']) 73 gff3_file = os.path.join(self.raw, track['fileName'])
69 label = track['label']
70 if track['dataType'] == 'bedSpliceJunctions' or track['dataType'] == 'gtf': 74 if track['dataType'] == 'bedSpliceJunctions' or track['dataType'] == 'gtf':
71 p = subprocess.Popen(['flatfile-to-json.pl', '--gff', gff3_file, '--trackType', 'CanvasFeatures', '--trackLabel', label, '--config', '{"glyph": "JBrowse/View/FeatureGlyph/Segments"}', '--out', self.json]) 75 p = subprocess.Popen(['flatfile-to-json.pl', '--gff', gff3_file, '--trackType', track_type, '--trackLabel', track_label, '--config', '{"glyph": "JBrowse/View/FeatureGlyph/Segments", "color" : "%s"}' % track_color, '--out', self.json])
72 elif track['dataType'] == 'gff3_transcript': 76 elif track['dataType'] == 'gff3_transcript':
73 p = subprocess.Popen(['flatfile-to-json.pl', '--gff', gff3_file, '--trackType', 'MyPlugin/GenePred', '--trackLabel', label, '--config', '{"transcriptType": "transcript"}', '--out', self.json]) 77 p = subprocess.Popen(['flatfile-to-json.pl', '--gff', gff3_file, '--trackType', track_type, '--trackLabel', track_label, '--config', '{"transcriptType": "transcript", "color" : "%s"}' % track_color, '--out', self.json])
74 elif track['dataType'] == 'gff3_mrna': 78 elif track['dataType'] == 'gff3_mrna':
75 p = subprocess.Popen(['flatfile-to-json.pl', '--gff', gff3_file, '--trackType', 'MyPlugin/GenePred', '--trackLabel', label, '--out', self.json]) 79 p = subprocess.Popen(['flatfile-to-json.pl', '--gff', gff3_file, '--trackType', track_type, '--trackLabel', track_label, '--config', '{"color" : "%s"}' % track_color, '--out', self.json])
80 elif track['dataType'] == 'blastxml':
81 p = subprocess.Popen(['flatfile-to-json.pl', '--gff', gff3_file, '--trackType', track_type, '--trackLabel', track_label, '--config', '{"color" : "%s"}' % track_color, '--out', self.json])
76 else: 82 else:
77 p = subprocess.Popen(['flatfile-to-json.pl', '--gff', gff3_file, '--trackType', 'CanvasFeatures', '--trackLabel', label, '--out', self.json]) 83 p = subprocess.Popen(['flatfile-to-json.pl', '--gff', gff3_file, '--trackType', track_type, '--trackLabel', track_label, '--config', '{"color" : "%s"}' % track_color, '--out', self.json])
78 p.communicate() 84 p.communicate()
79 85
80 def indexName(self): 86 def indexName(self):
81 p = subprocess.Popen(['generate-names.pl', '-v', '--out', self.json]) 87 p = subprocess.Popen(['generate-names.pl', '-v', '--out', self.json])
82 p.communicate() 88 p.communicate()