Mercurial > repos > yating-l > jbrowsearchivecreator
comparison TrackHub.py @ 24:bb6fdccef474 draft
Uploaded
author | yating-l |
---|---|
date | Wed, 12 Jul 2017 12:55:27 -0400 |
parents | df2a55f071fc |
children | 31a41ce128cc |
comparison
equal
deleted
inserted
replaced
23:cf607cd87659 | 24:bb6fdccef474 |
---|---|
54 self.SetMetadata(track, metadata) | 54 self.SetMetadata(track, metadata) |
55 if track['dataType'] == 'bam': | 55 if track['dataType'] == 'bam': |
56 self.Bam(track, metadata) | 56 self.Bam(track, metadata) |
57 # print "add bam track\n" | 57 # print "add bam track\n" |
58 elif track['dataType'] == 'bigwig': | 58 elif track['dataType'] == 'bigwig': |
59 self.BigWig(track, metadata) | 59 #create trackList.json if not exist |
60 self.createTrackList() | |
61 json_file = os.path.join(self.json, "trackList.json") | |
62 bigwig_file = os.path.join(self.raw, track['fileName']) | |
63 subprocess.call(['add-bw-track.pl', '--label', metadata['label'], '--bw_url', bigwig_file, '--pos_color', metadata['style']['pos_color'], '--neg_color', metadata['style']['neg_color'], '--plot', 'JBrowse/View/Track/Wiggle/XYPlot', '--out', json_file, '--in', json_file]) | |
60 else: | 64 else: |
61 flat_file = os.path.join(self.raw, track['fileName']) | 65 flat_file = os.path.join(self.raw, track['fileName']) |
62 if track['dataType'] == 'bed': | 66 if track['dataType'] == 'bed': |
63 subprocess.call(['flatfile-to-json.pl', '--bed', flat_file, '--trackType', metadata['type'], '--trackLabel', metadata['label'], '--Config', '{"category" : "%s"}' % metadata['category'], '--clientConfig', '{"color" : "%s"}' % metadata['color'], '--out', self.json]) | 67 subprocess.call(['flatfile-to-json.pl', '--bed', flat_file, '--trackType', metadata['type'], '--trackLabel', metadata['label'], '--Config', '{"category" : "%s"}' % metadata['category'], '--clientConfig', '{"color" : "%s"}' % metadata['color'], '--out', self.json]) |
64 elif track['dataType'] == 'bedSpliceJunctions' or track['dataType'] == 'gtf' or track['dataType'] == 'blastxml': | 68 elif track['dataType'] == 'bedSpliceJunctions' or track['dataType'] == 'gtf' or track['dataType'] == 'blastxml': |
116 bam_track['category'] = metadata['category'] | 120 bam_track['category'] = metadata['category'] |
117 bam_track = json.dumps(bam_track) | 121 bam_track = json.dumps(bam_track) |
118 #Use add-track-json.pl to add bam track to json file | 122 #Use add-track-json.pl to add bam track to json file |
119 new_track = subprocess.Popen(['echo', bam_track], stdout=subprocess.PIPE) | 123 new_track = subprocess.Popen(['echo', bam_track], stdout=subprocess.PIPE) |
120 subprocess.call(['add-track-json.pl', json_file], stdin=new_track.stdout) | 124 subprocess.call(['add-track-json.pl', json_file], stdin=new_track.stdout) |
121 | 125 ''' |
122 def BigWig(self, track, metadata): | 126 def BigWig(self, track, metadata): |
123 #create trackList.json if not exist | 127 #create trackList.json if not exist |
124 self.createTrackList() | 128 self.createTrackList() |
125 json_file = os.path.join(self.json, "trackList.json") | 129 json_file = os.path.join(self.json, "trackList.json") |
126 bigwig_track = dict() | 130 bigwig_track = dict() |
133 bigwig_track = json.dumps(bigwig_track) | 137 bigwig_track = json.dumps(bigwig_track) |
134 #Use add-track-json.pl to add bigwig track to json file | 138 #Use add-track-json.pl to add bigwig track to json file |
135 new_track = subprocess.Popen(['echo', bigwig_track], stdout=subprocess.PIPE) | 139 new_track = subprocess.Popen(['echo', bigwig_track], stdout=subprocess.PIPE) |
136 #output = new_track.communicate()[0] | 140 #output = new_track.communicate()[0] |
137 subprocess.call(['add-track-json.pl', json_file], stdin=new_track.stdout) | 141 subprocess.call(['add-track-json.pl', json_file], stdin=new_track.stdout) |
138 | 142 ''' |
143 def BigWig | |
139 #If the metadata is not set, use the default value | 144 #If the metadata is not set, use the default value |
140 def SetMetadata(self, track, metadata): | 145 def SetMetadata(self, track, metadata): |
141 if 'label' not in metadata.keys() or metadata['label'] == '': | 146 if 'label' not in metadata.keys() or metadata['label'] == '': |
142 metadata['label'] = track['fileName'] | 147 metadata['label'] = track['fileName'] |
143 if 'color' not in metadata.keys() or metadata['color'] == '': | 148 if 'color' not in metadata.keys() or metadata['color'] == '': |