Mercurial > repos > yating-l > jbrowsearchivecreator
annotate tracks/IntervalFeatures.py @ 38:d17f629f5486 draft
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
author | yating-l |
---|---|
date | Fri, 06 Apr 2018 13:44:56 -0400 |
parents | |
children |
rev | line source |
---|---|
38
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
yating-l
parents:
diff
changeset
|
1 #!/usr/bin/env python |
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
yating-l
parents:
diff
changeset
|
2 import json |
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
yating-l
parents:
diff
changeset
|
3 import logging |
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
yating-l
parents:
diff
changeset
|
4 import collections |
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
yating-l
parents:
diff
changeset
|
5 |
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
yating-l
parents:
diff
changeset
|
6 from TrackDb import TrackDb |
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
yating-l
parents:
diff
changeset
|
7 from util import subtools |
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
yating-l
parents:
diff
changeset
|
8 from util import santitizer |
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
yating-l
parents:
diff
changeset
|
9 |
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
yating-l
parents:
diff
changeset
|
10 class Features(TrackDb): |
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
yating-l
parents:
diff
changeset
|
11 def __init__(self, trackName, trackLabel, trackDataURL, trackType, dataType, extraSettings=None): |
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
yating-l
parents:
diff
changeset
|
12 super(Features, self).__init__(trackName, trackLabel, trackDataURL, trackType, dataType, extraSettings) |
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
yating-l
parents:
diff
changeset
|
13 |
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
yating-l
parents:
diff
changeset
|
14 def prepareExtraSetting(self): |
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
yating-l
parents:
diff
changeset
|
15 if self.trackType == 'HTMLFeatures': |
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
yating-l
parents:
diff
changeset
|
16 self.prepareHTMLExtraSetting() |
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
yating-l
parents:
diff
changeset
|
17 else: |
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
yating-l
parents:
diff
changeset
|
18 self.prepareCanvasExtraSetting() |
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
yating-l
parents:
diff
changeset
|
19 |
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
yating-l
parents:
diff
changeset
|
20 def prepareHTMLExtraSetting(self): |
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
yating-l
parents:
diff
changeset
|
21 """ set HTMLFeatures configuration options """ |
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
yating-l
parents:
diff
changeset
|
22 extraConfigs = dict() |
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
yating-l
parents:
diff
changeset
|
23 self.extraSettings["clientConfig"] = dict() |
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
yating-l
parents:
diff
changeset
|
24 self.extraSettings["config"] = dict() |
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
yating-l
parents:
diff
changeset
|
25 if 'type' in self.extraSettings: |
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
yating-l
parents:
diff
changeset
|
26 extraConfigs["type"] = self.extraSettings['type'] |
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
yating-l
parents:
diff
changeset
|
27 if 'color' in self.extraSettings and self.extraSettings['color']: |
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
yating-l
parents:
diff
changeset
|
28 extraConfigs['feature_color'] = self.extraSettings['color'] |
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
yating-l
parents:
diff
changeset
|
29 else: |
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
yating-l
parents:
diff
changeset
|
30 extraConfigs['feature_color'] = "#000000" |
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
yating-l
parents:
diff
changeset
|
31 #self.extraSettings['clientConfig']['color'] = self.extraSettings['color'] |
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
yating-l
parents:
diff
changeset
|
32 if 'subfeatureClasses' in self.extraSettings: |
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
yating-l
parents:
diff
changeset
|
33 subfeature_css_class = santitizer.sanitize_name(self.trackLabel + "_" + self.extraSettings['subfeatureClasses']) |
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
yating-l
parents:
diff
changeset
|
34 extraConfigs['subfeatureClasses'] = {self.extraSettings['subfeatureClasses']: subfeature_css_class} |
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
yating-l
parents:
diff
changeset
|
35 |
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
yating-l
parents:
diff
changeset
|
36 if 'category' not in self.extraSettings or not self.extraSettings['category']: |
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
yating-l
parents:
diff
changeset
|
37 self.extraSettings['config']['category'] = "Default group" |
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
yating-l
parents:
diff
changeset
|
38 else: |
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
yating-l
parents:
diff
changeset
|
39 self.extraSettings['config']['category'] = self.extraSettings['category'] |
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
yating-l
parents:
diff
changeset
|
40 |
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
yating-l
parents:
diff
changeset
|
41 extraConfigs['config'] = json.dumps(self.extraSettings["config"]) |
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
yating-l
parents:
diff
changeset
|
42 extraConfigs['clientConfig'] = json.dumps(self.extraSettings["clientConfig"]) |
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
yating-l
parents:
diff
changeset
|
43 return extraConfigs |
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
yating-l
parents:
diff
changeset
|
44 |
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
yating-l
parents:
diff
changeset
|
45 def prepareCanvasExtraSetting(self): |
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
yating-l
parents:
diff
changeset
|
46 """ set CanvasFeatures configuration options """ |
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
yating-l
parents:
diff
changeset
|
47 extraConfigs = dict() |
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
yating-l
parents:
diff
changeset
|
48 self.extraSettings["clientConfig"] = dict() |
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
yating-l
parents:
diff
changeset
|
49 self.extraSettings["config"] = dict() |
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
yating-l
parents:
diff
changeset
|
50 if 'color' not in self.extraSettings or not self.extraSettings['color']: |
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
yating-l
parents:
diff
changeset
|
51 self.extraSettings["clientConfig"]['color'] = "#daa520" |
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
yating-l
parents:
diff
changeset
|
52 else: |
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
yating-l
parents:
diff
changeset
|
53 self.extraSettings["clientConfig"]['color'] = self.extraSettings['color'] |
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
yating-l
parents:
diff
changeset
|
54 if 'category' not in self.extraSettings or not self.extraSettings['category']: |
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
yating-l
parents:
diff
changeset
|
55 self.extraSettings["config"]['category'] = "Default group" |
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
yating-l
parents:
diff
changeset
|
56 else: |
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
yating-l
parents:
diff
changeset
|
57 self.extraSettings["config"]['category'] = self.extraSettings['category'] |
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
yating-l
parents:
diff
changeset
|
58 if 'glyph' in self.extraSettings: |
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
yating-l
parents:
diff
changeset
|
59 self.extraSettings["config"]['glyph'] = self.extraSettings['glyph'] |
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
yating-l
parents:
diff
changeset
|
60 if 'transcriptType' in self.extraSettings: |
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
yating-l
parents:
diff
changeset
|
61 self.extraSettings['config']['transcriptType'] = self.extraSettings['transcriptType'] |
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
yating-l
parents:
diff
changeset
|
62 extraConfigs["config"] = json.dumps(self.extraSettings["config"]) |
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
yating-l
parents:
diff
changeset
|
63 extraConfigs["clientConfig"] = json.dumps(self.extraSettings["clientConfig"]) |
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
yating-l
parents:
diff
changeset
|
64 return extraConfigs |
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
yating-l
parents:
diff
changeset
|
65 |
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
yating-l
parents:
diff
changeset
|
66 def createTrackDb(self): |
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
yating-l
parents:
diff
changeset
|
67 self.track_db = collections.OrderedDict([("track",self.trackName), |
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
yating-l
parents:
diff
changeset
|
68 ("trackLabel",self.trackLabel), |
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
yating-l
parents:
diff
changeset
|
69 ("trackDataURL",self.trackDataURL), |
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
yating-l
parents:
diff
changeset
|
70 ("dataType", self.dataType), |
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
yating-l
parents:
diff
changeset
|
71 ("trackType", self.trackType)] |
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
yating-l
parents:
diff
changeset
|
72 ) |
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
yating-l
parents:
diff
changeset
|
73 |
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
yating-l
parents:
diff
changeset
|
74 |
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
yating-l
parents:
diff
changeset
|
75 htmlExtraConfigs = self.prepareHTMLExtraSetting() |
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
yating-l
parents:
diff
changeset
|
76 self.logger.debug("Generate extraConfigs for htmlFeatures = %s", json.dumps(htmlExtraConfigs)) |
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
yating-l
parents:
diff
changeset
|
77 self.track_db["html"]["options"] = htmlExtraConfigs |
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
yating-l
parents:
diff
changeset
|
78 canvasExtraConfigs = self.prepareCanvasExtraSetting() |
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
yating-l
parents:
diff
changeset
|
79 self.logger.debug("Generate extraConfigs for canvasFeatures = %s", json.dumps(canvasExtraConfigs)) |
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
yating-l
parents:
diff
changeset
|
80 self.track_db["canvas"]["options"] = canvasExtraConfigs |
d17f629f5486
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit e4c1d387db160a3bf4a1e8abc288bdffbbbe2818-dirty
yating-l
parents:
diff
changeset
|
81 self.logger.debug("TrackDb object is created track_db = %s ", json.dumps(self.track_db)) |