comparison 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
comparison
equal deleted inserted replaced
30:ca2def38369c 31:2bb2e07a7a21
78 OPACITY_MATH = { 78 OPACITY_MATH = {
79 'linear': """ 79 'linear': """
80 var opacity = (score - ({min})) / (({max}) - ({min})); 80 var opacity = (score - ({min})) / (({max}) - ({min}));
81 """, 81 """,
82 'logarithmic': """ 82 'logarithmic': """
83 var opacity = (score - ({min})) / (({max}) - ({min})); 83 var opacity = Math.log10(score - ({min})) / Math.log10(({max}) - ({min}));
84 opacity = Math.log10(opacity) + Math.log10({max});
85 """, 84 """,
86 'blast': """ 85 'blast': """
87 var opacity = 0; 86 var opacity = 0;
88 if(score == 0.0) {{ 87 if(score == 0.0) {{
89 opacity = 1; 88 opacity = 1;
680 "urlTemplate": url, 679 "urlTemplate": url,
681 "queryTemplate": query 680 "queryTemplate": query
682 } 681 }
683 self._add_track_json(data) 682 self._add_track_json(data)
684 683
684 def traverse_to_option_parent(self, splitKey, outputTrackConfig):
685 trackConfigSubDict = outputTrackConfig
686 for part in splitKey[:-1]:
687 if trackConfigSubDict.get(part) is None:
688 trackConfigSubDict[part] = dict()
689 trackConfigSubDict = trackConfigSubDict[part]
690 assert isinstance(trackConfigSubDict, dict), 'Config element {} is not a dict'.format(trackConfigSubDict)
691 return trackConfigSubDict
692
693 def get_formatted_option(self, valType2ValDict, mapped_chars):
694 assert isinstance(valType2ValDict, dict) and len(valType2ValDict.items()) == 1
695 for valType, value in valType2ValDict.items():
696 if valType == "text":
697 for char, mapped_char in mapped_chars.items():
698 value = value.replace(mapped_char, char)
699 elif valType == "integer":
700 value = int(value)
701 elif valType == "float":
702 value = float(value)
703 else: # boolean
704 value = {'true': True, 'false': False}[value]
705 return value
706
707 def set_custom_track_options(self, customTrackConfig, outputTrackConfig, mapped_chars):
708 for optKey, optType2ValDict in customTrackConfig.items():
709 splitKey = optKey.split('.')
710 trackConfigOptionParent = self.traverse_to_option_parent(splitKey, outputTrackConfig)
711 optVal = self.get_formatted_option(optType2ValDict, mapped_chars)
712 trackConfigOptionParent[splitKey[-1]] = optVal
713
685 def process_annotations(self, track): 714 def process_annotations(self, track):
686 category = track['category'].replace('__pd__date__pd__', TODAY) 715 category = track['category'].replace('__pd__date__pd__', TODAY)
687 outputTrackConfig = { 716 outputTrackConfig = {
688 'style': { 717 'style': {
689 'label': track['style'].get('label', 'description'), 718 'label': track['style'].get('label', 'description'),
744 outputTrackConfig[key] = colourOptions[key] 773 outputTrackConfig[key] = colourOptions[key]
745 774
746 if 'menus' in track['conf']['options']: 775 if 'menus' in track['conf']['options']:
747 menus = self.cs.parse_menus(track['conf']['options']) 776 menus = self.cs.parse_menus(track['conf']['options'])
748 outputTrackConfig.update(menus) 777 outputTrackConfig.update(menus)
778
779 customTrackConfig = track['conf']['options'].get('custom_config', {})
780 if customTrackConfig:
781 self.set_custom_track_options(customTrackConfig, outputTrackConfig, mapped_chars)
749 782
750 # import pprint; pprint.pprint(track) 783 # import pprint; pprint.pprint(track)
751 # import sys; sys.exit() 784 # import sys; sys.exit()
752 if dataset_ext in ('gff', 'gff3', 'bed'): 785 if dataset_ext in ('gff', 'gff3', 'bed'):
753 self.add_features(dataset_path, dataset_ext, outputTrackConfig, 786 self.add_features(dataset_path, dataset_ext, outputTrackConfig,