view tracks/CanvasFeatures.py @ 19:62dee5369e80 draft

planemo upload for repository https://github.com/goeckslab/jbrowse-archive-creator.git commit afd782e8741a859506794bea92475f620265c50e
author sargentl
date Thu, 13 Sep 2018 17:43:23 -0400
parents 315a40b0b694
children 85971ec2a527
line wrap: on
line source

#!/usr/bin/env python2
import os
import json
import logging

from TrackDb import TrackDb
from util import subtools


class CanvasFeatures(TrackDb):
    def __init__(self, trackName, trackLabel, trackDataURL, trackType, dataType, extraSettings=None):
        super(CanvasFeatures, self).__init__(trackName, trackLabel, trackDataURL, trackType, dataType, extraSettings)

    def prepareExtraSetting(self):
        if 'category' not in self.extraSettings or not self.extraSettings['category']:
            self.extraSettings['category'] = "Default group"
        self.extraSettings['style'] = {}
        self.extraSettings['style']['className'] = 'feature'
        if 'color' not in self.extraSettings or not self.extraSettings['color']:
            self.extraSettings['style']['color'] = "#FFA600"
        else:
            self.extraSettings['style']['color'] = self.extraSettings['color']
        track = dict()
        track['type'] = 'JBrowse/View/Track/' + self.trackType
        track['storeClass'] = 'JBrowse/Store/SeqFeature/GFF3Tabix'
        if self.dataType == 'gff':
            # need .gff3.gz extension to index the name of the track with generate-name.pl
            track['urlTemplate'] = os.path.join('tracks', self.trackName + '.gff3.gz')
        else:
            track['urlTemplate'] = os.path.join('tracks', self.trackName)
        if 'glyph' in self.extraSettings:
            track['glyph'] = self.extraSettings['glyph']
        if 'subfeatureClasses' in self.extraSettings:
            track['subfeatureClasses'] = self.extraSettings['subfeatureClasses']
        track['label'] = self.trackLabel
        track['category'] = self.extraSettings['category']
        track['style'] = self.extraSettings['style']
        if "menuTemplate" in self.extraSettings:
            track["menuTemplate"] = [{}, self.extraSettings["menuTemplate"]]
            #self.track["menuTemplate"] += [{"label" : "View details"}, {"label" : "Highlight this gene"}, self.extraSettings["menuTemplate"]]
        extraConfigs = track
        return extraConfigs