Mercurial > repos > iuc > jbrowse
diff jbrowse.py @ 31:2bb2e07a7a21 draft
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 12dff0abf006f6c81f6462cdf4ea9c0c740d1e9c
author | iuc |
---|---|
date | Mon, 15 Apr 2019 10:31:26 -0400 |
parents | d0743cb18ed8 |
children | 0ae74c70b267 |
line wrap: on
line diff
--- a/jbrowse.py Thu Apr 11 09:35:00 2019 -0400 +++ b/jbrowse.py Mon Apr 15 10:31:26 2019 -0400 @@ -80,8 +80,7 @@ var opacity = (score - ({min})) / (({max}) - ({min})); """, 'logarithmic': """ - var opacity = (score - ({min})) / (({max}) - ({min})); - opacity = Math.log10(opacity) + Math.log10({max}); + var opacity = Math.log10(score - ({min})) / Math.log10(({max}) - ({min})); """, 'blast': """ var opacity = 0; @@ -682,6 +681,36 @@ } self._add_track_json(data) + def traverse_to_option_parent(self, splitKey, outputTrackConfig): + trackConfigSubDict = outputTrackConfig + for part in splitKey[:-1]: + if trackConfigSubDict.get(part) is None: + trackConfigSubDict[part] = dict() + trackConfigSubDict = trackConfigSubDict[part] + assert isinstance(trackConfigSubDict, dict), 'Config element {} is not a dict'.format(trackConfigSubDict) + return trackConfigSubDict + + def get_formatted_option(self, valType2ValDict, mapped_chars): + assert isinstance(valType2ValDict, dict) and len(valType2ValDict.items()) == 1 + for valType, value in valType2ValDict.items(): + if valType == "text": + for char, mapped_char in mapped_chars.items(): + value = value.replace(mapped_char, char) + elif valType == "integer": + value = int(value) + elif valType == "float": + value = float(value) + else: # boolean + value = {'true': True, 'false': False}[value] + return value + + def set_custom_track_options(self, customTrackConfig, outputTrackConfig, mapped_chars): + for optKey, optType2ValDict in customTrackConfig.items(): + splitKey = optKey.split('.') + trackConfigOptionParent = self.traverse_to_option_parent(splitKey, outputTrackConfig) + optVal = self.get_formatted_option(optType2ValDict, mapped_chars) + trackConfigOptionParent[splitKey[-1]] = optVal + def process_annotations(self, track): category = track['category'].replace('__pd__date__pd__', TODAY) outputTrackConfig = { @@ -747,6 +776,10 @@ menus = self.cs.parse_menus(track['conf']['options']) outputTrackConfig.update(menus) + customTrackConfig = track['conf']['options'].get('custom_config', {}) + if customTrackConfig: + self.set_custom_track_options(customTrackConfig, outputTrackConfig, mapped_chars) + # import pprint; pprint.pprint(track) # import sys; sys.exit() if dataset_ext in ('gff', 'gff3', 'bed'):