예제 #1
0
 def layout(self, view):
     BaseScene.layout(self, view)
     cur = view.frame.centeredSubrect(w=800, h=view.frame.size.h - 100)
     left = cur.leftSubrect(w=400)
     self.scroller = layoutInScroller(self.tagViews, cur.leftover,
                                      Size(300, 40), 20, self.scroller)
     top = left.topSubrect(40)
     left = left.leftover
     self.query_label.frame = top.leftSubrect(200).centeredSubrect(w=200,
                                                                   h=16)
     self.buttonWithKey(
         'showMatches').frame = top.leftover.leftCenteredSubrect(
             size=buttonSize, margin=20)
     self.query_scroller = layoutInScroller(self.queryTagViews, left,
                                            Size(300, 40), 20,
                                            self.query_scroller)
     for tv in self.tagViews + self.queryTagViews:
         f = tv.frame.bounds()
         tv.name_label.frame = f.leftCenteredSubrect(w=212, h=16, margin=8)
         if tv.incl:
             tv.incl.frame = f.leftover.leftCenteredSubrect(w=36,
                                                            h=20,
                                                            margin=2)
         if tv.excl:
             tv.excl.frame = f.leftover.rightCenteredSubrect(w=36,
                                                             h=20,
                                                             margin=2)
     return view
예제 #2
0
 def build(self):
     BaseScene.build(self)
     self.ui.spats.run.allow_negative_values = True
     self.profiles = self.ui.spats.compute_profiles()
     self.maxes = {
         dt: (4 if dt == "rho" else self.profiles.data_range(dt)[1])
         for dt in self.data_types
     }
     self.data_type_views = [
         self.makeDataTypeView(data_type) for data_type in self.data_types
     ]
     self.targetButtons([
         self.togglePlotType, self.toggleCounts, self.toggleNull,
         self.totalCounts
     ])
     self.buttonWithKey('togglePlotType').text = "Plot Type: Row"
     self.buttonWithKey('toggleCounts').text = "Show f+/f-: On"
     self.buttonWithKey('toggleNull').text = "Flags: Off"
     self.type_label = self.addView(
         cjb.uif.views.Label("Query: {}".format(self.data_type),
                             fontSize=16))
     if self.ui.has_tags:
         sitemap = {
             "{}:{}:{}:{}".format(self.target_id, s[0], s[2], s[1]): s[3]
             for s in self.ui.db.result_sites(self.ui.result_set_id,
                                              self.target_id)
         }
     else:
         sitemap = self.ui.spats.counters.registered_dict()
     self.matrix = cjb.uif.views.CustomView('SpatsMatrix')
     self.matrix.properties["d"] = self.profiles.cotrans_data()
     self.matrix.properties["plot"] = self.data_type
     self.matrix.properties["max"] = self.profiles.data_range(
         self.data_type)[1]
     self.addView(self.matrix)
예제 #3
0
 def layout(self, view):
     BaseScene.layout(self, view)
     cur = view.frame.centeredSubrect(w=800, h=600)
     self.matrix.frame = cur
     self.type_label.frame = view.frame.topLeftSubrect(w=240,
                                                       h=24,
                                                       margins=Size(
                                                           40, 100))
     grid = Grid(frame=view.frame.bottomCenteredSubrect(w=600,
                                                        h=40,
                                                        margin=20),
                 itemSize=Size(120, 40),
                 columns=4,
                 rows=1,
                 spacing=Size(20, 0))
     grid.applyToViews(
         map(self.buttonWithKey, [
             'togglePlotType', 'toggleCounts', 'toggleNull', 'totalCounts'
         ]))
     grid = Grid(frame=view.frame.leftCenteredSubrect(w=120,
                                                      h=400,
                                                      margin=40),
                 itemSize=Size(120, 70),
                 columns=1,
                 rows=5,
                 spacing=Size(0, 10))
     grid.applyToViews(self.data_type_views)
     for dtv in self.data_type_views:
         self.layoutDataTypeView(dtv)
     return view
예제 #4
0
 def handleKeyEvent(self, keyInfo):
     handler = None
     if "t" in keyInfo and keyInfo.get('cmd'):
         handler = {
             "b": self.beta,
             "h": self.theta,
             "r": self.rho,
             "t": self.treated,
             "u": self.untreated
         }.get(keyInfo["t"])
     elif "t" in keyInfo and keyInfo.get('ctrl'):
         handler = {
             "b": self.show_beta,
             "h": self.show_theta,
             "r": self.show_rho,
             "t": self.show_treated,
             "u": self.show_untreated
         }.get(keyInfo["t"])
     elif "t" in keyInfo:
         handler = {
             "p": self.togglePlotType,
             "c": self.toggleCounts,
             "f": self.toggleNull,
             "t": self.totalCounts
         }.get(keyInfo["t"])
     if handler:
         handler()
     else:
         BaseScene.handleKeyEvent(self, keyInfo)
예제 #5
0
 def build(self):
     BaseScene.build(self)
     counts = self.ui.db.tag_counts(self.ui.result_set_id,
                                    self.incl_excl_tags[0],
                                    self.incl_excl_tags[1])
     counts = sorted([(key, counts[key]) for key in counts.keys()],
                     key=lambda x: x[1],
                     reverse=True)
     total = float(
         self.ui.db.count_matches(self.ui.result_set_id,
                                  self.incl_excl_tags[0],
                                  self.incl_excl_tags[1]))
     tags = [
         Tag(tc[0], "{:.1f}%".format(float(tc[1]) * 100.0 / total))
         for tc in counts
     ]
     query_tags = self.incl_excl_tags[0] + self.incl_excl_tags[1]
     self.tagViews = [
         self.addTagView(t, COLOR_BG) for t in tags
         if t.tag not in query_tags
     ]
     self.targetButtons([self.showMatches])
     self.query_label = self.addView(
         cjb.uif.views.Label("Query: {} matches.".format(int(total)),
                             fontSize=14))
     self.queryTagViews = [self.addQueryTag(t) for t in query_tags]
예제 #6
0
파일: pair.py 프로젝트: LucksLab/spats
 def __init__(self, ui, pair, expanded = True):
     self.pair = pair
     self.expanded = expanded
     self.parts = {}
     self.labels = {}
     self.nucSize = Size(10, 16)
     BaseScene.__init__(self, ui, self.__class__.__name__)
예제 #7
0
 def layout(self, view):
     BaseScene.layout(self, view)
     cur = view.frame.centeredSubrect(w = 1000, h = view.frame.size.h - 100)
     self.scroller = layoutInScroller(self.matchViews, cur, Size(1000, 14), 2, self.scroller)
     for v in self.matchViews:
         self.layoutMatch(v)
     self.filter_label.frame = view.frame.topLeftSubrect(w = 200, h = 20, margin = 20)
     return view
예제 #8
0
 def handleViewMessage(self, scene, obj, message):
     if obj and (isinstance(obj, MatchedPair) or isinstance(obj, Nuc)):
         mp = obj if isinstance(obj, MatchedPair) else obj.context
         pair = self.processed_pair(mp)
         if pair.has_site:
             self.ui.pushScene(PairScene(self.ui, pair, expanded = True))
         else:
             self.ui.pushScene(RawPairScene(self.ui, pair, expanded = True))
     else:
         BaseScene.handleViewMessage(self, scene, obj, message)
예제 #9
0
파일: tagset.py 프로젝트: LucksLab/spats
 def build(self):
     BaseScene.build(self)
     counts = self.ui.db.tag_counts(self.ui.result_set_id, self.incl_excl_tags[0], self.incl_excl_tags[1])
     counts = sorted([ (key, counts[key]) for key in counts.keys() ], key = lambda x : x[1], reverse = True)
     total = float(self.ui.db.count_matches(self.ui.result_set_id, self.incl_excl_tags[0], self.incl_excl_tags[1]))
     tags = [ Tag(tc[0], "{:.1f}%".format(float(tc[1]) * 100.0 / total)) for tc in counts ]
     query_tags = self.incl_excl_tags[0] + self.incl_excl_tags[1]
     self.tagViews = [ self.addTagView(t, COLOR_BG) for t in tags if t.tag not in query_tags ]
     self.targetButtons([self.showMatches])
     self.query_label = self.addView(cjb.uif.views.Label("Query: {} matches.".format(int(total)), fontSize = 14))
     self.queryTagViews = [ self.addQueryTag(t) for t in query_tags ]
예제 #10
0
파일: targets.py 프로젝트: LucksLab/spats
 def handleViewMessage(self, scene, obj, message):
     if "site" == message.get("event"):
         self.show_plot(message["L"], message["site"])
     elif "sel" == message.get("event"):
         self.selected_values = sorted(message["data"])
     elif "show_sel" == message.get("event"):
         self.show_selected_plot()
     elif obj and isinstance(obj, Site):
         self.show_plot_site(obj)
     else:
         BaseScene.handleViewMessage(self, scene, obj, message)
예제 #11
0
 def build(self):
     BaseScene.build(self)
     if self.site:
         pairs = self.ui.db.results_matching_site(self.ui.result_set_id, self.site.target_id, self.site.end, self.site.site, limit = 50)
         self.total_matches = self.site.total
     else:
         pairs = self.ui.db.results_matching(self.ui.result_set_id, self.include_tags, self.exclude_tags, limit = 50)
         self.total_matches = self.ui.db.count_matches(self.ui.result_set_id, self.include_tags, self.exclude_tags)
     matches = [ MatchedPair(p[2], p[3], p[4], p[0], p[1]) for p in pairs ]
     self.matchViews = [ self.addMatchView(m) for m in matches ]
     self.filter_label = self.addView(cjb.uif.views.Label("Filter: <None>", fontSize = 11))
예제 #12
0
 def handleViewMessage(self, scene, obj, message):
     if "site" == message.get("event"):
         self.show_plot(message["L"], message["site"])
     elif "sel" == message.get("event"):
         self.selected_values = sorted(message["data"])
     elif "show_sel" == message.get("event"):
         self.show_selected_plot()
     elif obj and isinstance(obj, Site):
         self.show_plot_site(obj)
     else:
         BaseScene.handleViewMessage(self, scene, obj, message)
예제 #13
0
파일: targets.py 프로젝트: LucksLab/spats
 def layout(self, view):
     BaseScene.layout(self, view)
     cur = view.frame.centeredSubrect(w = 800, h = 600)
     self.matrix.frame = cur
     self.type_label.frame = view.frame.topLeftSubrect(w = 240, h = 24, margins = Size(40, 100))
     grid = Grid(frame = view.frame.bottomCenteredSubrect(w = 600, h = 40, margin = 20), itemSize = Size(120, 40), columns = 4, rows = 1, spacing = Size(20, 0))
     grid.applyToViews(map(self.buttonWithKey, [ 'togglePlotType', 'toggleCounts', 'toggleNull', 'totalCounts' ]))
     grid = Grid(frame = view.frame.leftCenteredSubrect(w = 120, h = 400, margin = 40), itemSize = Size(120, 70), columns = 1, rows = 5, spacing = Size(0, 10))
     grid.applyToViews(self.data_type_views)
     for dtv in self.data_type_views:
         self.layoutDataTypeView(dtv)
     return view
예제 #14
0
 def handleKeyEvent(self, keyInfo):
     if keyInfo.get("s") == "DEL":
         self.match_filter = self.match_filter[:-1]
         self.update_filter()
     elif keyInfo.get("t") in [ "a","c","g","t" ] and 1 == len(keyInfo):
         self.match_filter += keyInfo["t"].upper()
         self.update_filter()
     elif keyInfo.get("t") == "x" and 1 == len(keyInfo):
         self.match_filter = ""
         self.update_filter()
     else:
         BaseScene.handleKeyEvent(self, keyInfo)
예제 #15
0
파일: targets.py 프로젝트: LucksLab/spats
 def __init__(self, ui, target, data_type = "treated"):
     self.cotrans = ui.spats.run.cotrans
     self.name = target[0]
     self.seq = target[1]
     self.target_id = target[2]
     self.data_type = data_type
     self.plot_type = "row"
     self.selected_values = None
     self.show_counts = True
     self.show_null = False
     self.data_types = [ "treated", "untreated", "beta", "theta", "rho" ]
     for data_type in self.data_types:
         setattr(self, data_type, self.changer(data_type))
         setattr(self, "show_" + data_type, self.shower(data_type))
         setattr(self, "update_" + data_type, self.updater(data_type))
     BaseScene.__init__(self, ui, self.__class__.__name__)
예제 #16
0
 def __init__(self, ui, target, data_type="treated"):
     self.cotrans = ui.spats.run.cotrans
     self.name = target[0]
     self.seq = target[1]
     self.target_id = target[2]
     self.data_type = data_type
     self.plot_type = "row"
     self.selected_values = None
     self.show_counts = True
     self.show_null = False
     self.data_types = ["treated", "untreated", "beta", "theta", "rho"]
     for data_type in self.data_types:
         setattr(self, data_type, self.changer(data_type))
         setattr(self, "show_" + data_type, self.shower(data_type))
         setattr(self, "update_" + data_type, self.updater(data_type))
     BaseScene.__init__(self, ui, self.__class__.__name__)
예제 #17
0
파일: tagset.py 프로젝트: LucksLab/spats
 def layout(self, view):
     BaseScene.layout(self, view)
     cur = view.frame.centeredSubrect(w = 800, h = view.frame.size.h - 100)
     left = cur.leftSubrect(w = 400)
     self.scroller = layoutInScroller(self.tagViews, cur.leftover, Size(300, 40), 20, self.scroller)
     top = left.topSubrect(40)
     left = left.leftover
     self.query_label.frame = top.leftSubrect(200).centeredSubrect(w = 200, h = 16)
     self.buttonWithKey('showMatches').frame = top.leftover.leftCenteredSubrect(size = buttonSize, margin = 20)
     self.query_scroller = layoutInScroller(self.queryTagViews, left, Size(300, 40), 20, self.query_scroller)
     for tv in self.tagViews + self.queryTagViews:
         f = tv.frame.bounds()
         tv.name_label.frame = f.leftCenteredSubrect(w = 212, h = 16, margin = 8)
         if tv.incl:
             tv.incl.frame = f.leftover.leftCenteredSubrect(w = 36, h = 20, margin = 2)
         if tv.excl:
             tv.excl.frame = f.leftover.rightCenteredSubrect(w = 36, h = 20, margin = 2)
     return view
예제 #18
0
파일: targets.py 프로젝트: LucksLab/spats
 def build(self):
     BaseScene.build(self)
     self.ui.spats.run.allow_negative_values = True
     self.profiles = self.ui.spats.compute_profiles()
     self.maxes = { dt : (4 if dt == "rho" else self.profiles.data_range(dt)[1]) for dt in self.data_types }
     self.data_type_views = [ self.makeDataTypeView(data_type) for data_type in self.data_types ]
     self.targetButtons([self.togglePlotType, self.toggleCounts, self.toggleNull, self.totalCounts])
     self.buttonWithKey('togglePlotType').text = "Plot Type: Row"
     self.buttonWithKey('toggleCounts').text = "Show f+/f-: On"
     self.buttonWithKey('toggleNull').text = "Flags: Off"
     self.type_label = self.addView(cjb.uif.views.Label("Query: {}".format(self.data_type), fontSize = 16))
     if self.ui.has_tags:
         sitemap = { "{}:{}:{}:{}".format(self.target_id, s[0], s[2], s[1]) : s[3] for s in self.ui.db.result_sites(self.ui.result_set_id, self.target_id) }
     else:
         sitemap = self.ui.spats.counters.registered_dict()
     self.matrix = cjb.uif.views.CustomView('SpatsMatrix')
     self.matrix.properties["d"] = self.profiles.cotrans_data()
     self.matrix.properties["plot"] = self.data_type
     self.matrix.properties["max"] = self.profiles.data_range(self.data_type)[1]
     self.addView(self.matrix)
예제 #19
0
파일: pair.py 프로젝트: LucksLab/spats
    def layout(self, view):
        BaseScene.layout(self, view)
        self.buttonWithKey('dump').frame = view.frame.topLeftSubrect(size = buttonSize, margin = 20)
        cols = 100
        rows = 40
        frame = view.frame.centeredSubrect(self.nucSize.w * cols, self.nucSize.h * rows)
        grid = Grid(frame = frame, itemSize = self.nucSize, columns = cols, rows = rows)
        row_idx = 4

        def labelFrame(owner_parts, tag_parts):
            base_frame = tag_parts[0].frame.copy()
            base_frame.origin.x = owner_parts[0].frame.origin.x - 130
            base_frame.size = Size(80, base_frame.size.height)
            return base_frame

        for part_name in ( "r1", "r2" ):
            part_start = 32
            part = getattr(self.pair, part_name)
            if part_name == "r2":
                row_idx = 20
            grid.setLocation(part_start, row_idx)
            grid.applyToViews(self.parts[part_name])
            self.labels[part_name].frame = labelFrame(self.parts[part_name], self.parts[part_name])

            for tindex in range(len(part.tags)):
                tag = part.tags[tindex]
                tseq = self.tag_seqs[tag[0]]
                match_index = tag[3]
                tstart = max(0, match_index - 4)
                col = part_start + tag[1] - (match_index - tstart)
                row_idx += 1
                #print(part_name + tag[0] + ": {} , {}".format(col, row_idx))
                grid.setLocation(col, row_idx)
                grid.applyToViews(self.parts[part_name + str(tindex)])

                self.labels[part_name + str(tindex)].frame = labelFrame(self.parts[part_name], self.parts[part_name + str(tindex)])

        return view
예제 #20
0
파일: pair.py 프로젝트: LucksLab/spats
    def build(self):

        BaseScene.build(self)
        self.targetButton(self.dump)

        processor = self.ui.processor
        seqs = {
            "RRRY" : "RRRY",
            "YYYR" : "YYYR",
        }
        for target in processor._tag_targets.targets:
            seqs[target.name] = target.seq
        self.tag_seqs = seqs

        colors = self.ui.colors
        color_idx = 1
        for part_name in ( "r1", "r2" ):
            part = getattr(self.pair, part_name)
            seq = part.original_seq
            self.parts[part_name] = map(lambda x: self.addNucView(x, TAG_COLORS[0]), [ Nuc(seq[idx], (part_name, idx, None)) for idx in range(len(seq)) ])
            self.labels[part_name] = self.addView(Label(part_name.upper()))
            for tindex in range(len(part.tags)):
                tag = part.tags[tindex]
                tkey = tag[0].rstrip("_rc_")
                tcol = colors.color(tkey)
                tseq = self.tag_seqs[tag[0]]
                match_index = tag[3]
                views = []
                for idx in range(max(0,match_index - 4), min(len(tseq), match_index + tag[2] + 4)):
                    v = self.addNucView(Nuc(tseq[idx], (part_name, idx, tag)), tcol)
                    if idx < match_index or idx >= match_index + tag[2]:
                        v.alpha = 0.5
                        #print(" set a=0.5, bg: {}".format(v.bg))
                    views.append(v)
                self.parts[part_name + str(tindex)] = views
                label = Label(tag[0])
                label.bg = tcol
                self.labels[part_name + str(tindex)] = self.addView(label)
예제 #21
0
파일: targets.py 프로젝트: LucksLab/spats
 def handleKeyEvent(self, keyInfo):
     handler = None
     if "t" in keyInfo and keyInfo.get('cmd'):
         handler = { "b" : self.beta,
                     "h" : self.theta,
                     "r" : self.rho,
                     "t" : self.treated,
                     "u" : self.untreated }.get(keyInfo["t"])
     elif "t" in keyInfo and keyInfo.get('ctrl'):
         handler = { "b" : self.show_beta,
                     "h" : self.show_theta,
                     "r" : self.show_rho,
                     "t" : self.show_treated,
                     "u" : self.show_untreated }.get(keyInfo["t"])
     elif "t" in keyInfo:
         handler = { "p" : self.togglePlotType,
                     "c" : self.toggleCounts,
                     "f" : self.toggleNull,
                     "t" : self.totalCounts }.get(keyInfo["t"])
     if handler:
         handler()
     else:
         BaseScene.handleKeyEvent(self, keyInfo)
예제 #22
0
파일: targets.py 프로젝트: LucksLab/spats
 def build(self):
     BaseScene.build(self)
     targets = sorted(self.ui.db.targets(), key = lambda x : x[0])
     self.targetViews = [ self.addTargetView(t, [ 1.0, 0.85, 0.7 ]) for t in targets ]
예제 #23
0
파일: pair.py 프로젝트: LucksLab/spats
 def handleKeyEvent(self, keyInfo):
     handler = { "x" : self.expand }.get(keyInfo["t"])
     if handler:
         handler()
     else:
         BaseScene.handleKeyEvent(self, keyInfo)
예제 #24
0
파일: targets.py 프로젝트: LucksLab/spats
 def handleKeyEvent(self, keyInfo):
     handler = { "0" : self.firstTarget }.get(keyInfo["t"])
     if handler:
         handler()
     else:
         BaseScene.handleKeyEvent(self, keyInfo)
예제 #25
0
파일: tagset.py 프로젝트: LucksLab/spats
 def __init__(self, ui, incl_excl_tags = [ [], [] ]):
     self.incl_excl_tags = incl_excl_tags
     self.query_scroller = None
     BaseScene.__init__(self, ui, self.__class__.__name__)
예제 #26
0
파일: pair.py 프로젝트: LucksLab/spats
    def layout(self, view):
        BaseScene.layout(self, view)
        cols = 100
        rows = 40
        frame = view.frame.centeredSubrect(self.nucSize.w * cols, self.nucSize.h * rows)
        grid = Grid(frame = frame, itemSize = self.nucSize, columns = cols, rows = rows)

        skips = self._skips()
        def skipped(idx):
            ret_idx = idx
            for skip in skips:
                if idx > skip[0]:
                    ret_idx = ret_idx - skip[1] + 1 # +1 for spaces representing skips
            return ret_idx

        target = self.pair.target
        row_idx = 4
        skipped_len = skipped(target.n)
        start_col = int((cols - skipped_len) / 2)

        def labelFrame(tag_parts):
            return Rect(grid.frame(start_col).origin.x - 140, tag_parts[0].frame.origin.y, 80, tag_parts[0].frame.size.height)

        grid.setLocation(start_col, row_idx)
        curskip_idx = 0
        nucs = self.parts[target.name]
        for idx in range(len(nucs)):
            nv = nucs[idx]
            if nv:
                nv.frame = grid.nextFrame()
            elif curskip_idx < len(skips) and idx == skips[curskip_idx][0]:
                nv = self.addNucView(Nuc("/", None), [1.0, 1.0, 1.0, 0.0 ])
                nv.frame = grid.nextFrame() # skip a frame
                curskip_idx += 1
        self.labels[target.name].frame = labelFrame(self.parts[target.name])

        row_idx += (2 if self.expanded else 1)
        r2tagmap = { tag[0] : tag for tag in self.pair.r2.tags }
        r2match = r2tagmap.get(target.name, ("", 0, 0, 0))
        grid.setLocation(start_col + skipped(r2match[3] - r2match[1]), row_idx)
        grid.applyToViews(self.parts["r2"])
        self.labels["r2"].frame = labelFrame(self.parts["r2"])

        nucs = self.parts.get("r2" + "adapter_t_rc")
        if nucs:
            row_idx += 1
            atag = r2tagmap["adapter_t_rc"]
            grid.setLocation(start_col + skipped(r2match[3] - r2match[1] + atag[1] - atag[3]), row_idx)
            grid.applyToViews(nucs)
            self.labels["r2" + "adapter_t_rc"].frame = labelFrame(nucs)

        r1tagmap = { tag[0] : tag for tag in self.pair.r1.tags }
        r1match = r1tagmap.get(target.name + "_rc", ("", 0, 0, 0))
        r1start = target.n - r1match[3] - r1match[2]
        nucs = self.parts.get("r1" + target.name + "_rc")
        if nucs:
            row_idx += 1
            grid.setLocation(start_col + skipped(r1start), row_idx)
            grid.applyToViews(nucs)
            self.labels["r1" + target.name + "_rc"].frame = labelFrame(nucs)

        same_row = (not self.expanded) and (r1start >= r2match[3] + r2match[2])
        row_idx += (0 if same_row else 1)
        grid.setLocation(start_col + skipped(r1start - r1match[1]), row_idx)
        grid.applyToViews(self.parts["r1"])
        if same_row:
            self.labels["r2"].text = "R2 / R1"
            self.labels["r1"].alpha = 0
        else:
            self.labels["r1"].frame = labelFrame(self.parts["r1"])

        nucs = self.parts.get("r1" + "adapter_b")
        if nucs:
            row_idx += 1
            atag = r1tagmap["adapter_b"]
            grid.setLocation(start_col + skipped(r1start - r1match[1] + atag[1] - atag[3]), row_idx)
            grid.applyToViews(nucs)
            self.labels["r1" + "adapter_b"].frame = labelFrame(nucs)

        for handle in [ "YYYR", "RRRY" ]:
            nucs = self.parts.get("r1" + handle)
            if nucs:
                row_idx += 1
                grid.setLocation(start_col + skipped(r1start - r1match[1]), row_idx)
                grid.applyToViews(nucs)
                self.labels["r1" + handle].frame = labelFrame(nucs)
            
        return view
예제 #27
0
파일: pair.py 프로젝트: LucksLab/spats
    def build(self):

        BaseScene.build(self)

        processor = self.ui.processor
        seqs = {
            "adapter_t_rc" : reverse_complement(processor._run.adapter_t),
            "adapter_b" : processor._run.adapter_b,
            "RRRY" : "RRRY",
            "YYYR" : "YYYR",
        }
        for target in processor._tag_targets.targets:
            seqs[target.name] = target.seq
            seqs[target.name + "_rc"] = reverse_complement(target.seq)
        self.tag_seqs = seqs

        colors = self.ui.colors
        target = self.pair.target
        colors._colors[target.name] = colors.color("target")
        tcol = colors.color("target")
        nomatch_col = colors.color("grey")
        error_col = colors.color("error")

        skips = self._skips()

        tseq = target.seq
        tlen = target.n
        def should_skip(idx):
            for skip in skips:
                if idx >= skip[0] and idx < skip[0] + skip[1]:
                    return True
            return False
        self.parts[target.name] = [ None if should_skip(i) else self.addNucView(Nuc(tseq[i], (target.name, i, None)), tcol) for i in range(tlen)  ]
        self.labels[target.name] = self.addLabel(target.name, bg = tcol)

        for part_name in ( "r1", "r2" ):
            parts = []
            part = getattr(self.pair, part_name)
            seq = part.original_seq
            idx = 0

            for tag in sorted(part.tags, key = lambda t : t[1]):
                tkey = tag[0].rstrip("_rc_")
                while idx < tag[1] + tag[2]:
                    ntcol = nomatch_col if idx < tag[1] else colors.color(tkey)
                    if idx in part.match_errors or idx in part.adapter_errors:
                        ntcol = error_col
                    parts.append(self.addNucView(Nuc(seq[idx], (part_name, idx, None if idx < tag[1] else tag[0])), ntcol))
                    idx += 1

                if self.expanded:
                    if tag[0] == target.name + "_rc":
                        rc = reverse_complement(seq[tag[1]:tag[1] + tag[2]])
                        self.parts[part_name + tag[0]] = [ self.addNucView(Nuc(rc[j], (tag[0], j, None)), tcol) for j in range(0, tag[2]) ]
                        self.labels[part_name + tag[0]] = self.addLabel("R1_rc")
                    elif tkey.startswith("adapter"):
                        tagseq = self.tag_seqs[tag[0]]
                        aparts = []
                        for j in range(max(tag[3] - 4, 0), min(tag[2] + 4, len(tagseq))):
                            v = self.addNucView(Nuc(tagseq[j], (tag[0], j, None)), colors.color(tkey))
                            if j < tag[3] or j >= tag[3] + tag[2]:
                                v.alpha = 0.5
                            aparts.append(v)
                        self.parts[part_name + tag[0]] = aparts
                        self.labels[part_name + tag[0]] = self.addLabel(tag[0], bg = colors.color(tkey))
                    elif part_name == "r1" and (tag[0] == 'YYYR' or tag[0] == 'RRRY'):
                        hcol = colors.color(tag[0])
                        self.parts[part_name + tag[0]] = [ self.addNucView(Nuc(tag[0][j], (tag[0], j, None)), hcol) for j in range(len(tag[0])) ]
                        self.labels[part_name + tag[0]] = self.addLabel(tag[0], bg = hcol)

            while idx < len(seq):
                parts.append(self.addNucView(Nuc(seq[idx], (part_name, idx, None)), nomatch_col))
                idx += 1

            self.parts[part_name] = parts
            self.labels[part_name] = self.addLabel(part_name.upper())
예제 #28
0
 def build(self):
     BaseScene.build(self)
     targets = sorted(self.ui.db.targets(), key=lambda x: x[0])
     self.targetViews = [
         self.addTargetView(t, [1.0, 0.85, 0.7]) for t in targets
     ]
예제 #29
0
파일: pair.py 프로젝트: LucksLab/spats
 def __init__(self, ui, pair, expanded = False):
     self.pair = pair
     self.parts = {}
     self.labels = {}
     self.nucSize = Size(12, 18)
     BaseScene.__init__(self, ui, self.__class__.__name__)
예제 #30
0
파일: targets.py 프로젝트: LucksLab/spats
 def layout(self, view):
     BaseScene.layout(self, view)
     cur = view.frame.centeredSubrect(w = 300, h = view.frame.size.h - 100)
     self.scroller = layoutInScroller(self.targetViews, cur, Size(200, 40), 20, self.scroller)
     return view
예제 #31
0
파일: targets.py 프로젝트: LucksLab/spats
 def handleViewMessage(self, scene, obj, message):
     if obj and 3 == len(obj):
         self.ui.pushScene(CotransTarget(self.ui, obj))
     else:
         BaseScene.handleViewMessage(self, scene, obj, message)
예제 #32
0
 def handleViewMessage(self, scene, obj, message):
     if obj and isinstance(obj, TagAction):
         self.ui.pushScene(
             Tagset(self.ui, obj.new_tags(self.incl_excl_tags)))
     else:
         BaseScene.handleViewMessage(self, scene, obj, message)
예제 #33
0
 def layout(self, view):
     BaseScene.layout(self, view)
     cur = view.frame.centeredSubrect(w=300, h=view.frame.size.h - 100)
     self.scroller = layoutInScroller(self.targetViews, cur, Size(200, 40),
                                      20, self.scroller)
     return view
예제 #34
0
 def __init__(self, ui, include_tags = None, exclude_tags = None, site = None):
     self.include_tags = include_tags
     self.exclude_tags = exclude_tags
     self.site = site
     self.match_filter = ""
     BaseScene.__init__(self, ui, self.__class__.__name__)
예제 #35
0
파일: tagset.py 프로젝트: LucksLab/spats
 def handleViewMessage(self, scene, obj, message):
     if obj and isinstance(obj, TagAction):
         self.ui.pushScene(Tagset(self.ui, obj.new_tags(self.incl_excl_tags)))
     else:
         BaseScene.handleViewMessage(self, scene, obj, message)
예제 #36
0
 def handleViewMessage(self, scene, obj, message):
     if obj and 3 == len(obj):
         self.ui.pushScene(CotransTarget(self.ui, obj))
     else:
         BaseScene.handleViewMessage(self, scene, obj, message)
예제 #37
0
 def handleKeyEvent(self, keyInfo):
     handler = {"0": self.firstTarget}.get(keyInfo["t"])
     if handler:
         handler()
     else:
         BaseScene.handleKeyEvent(self, keyInfo)
예제 #38
0
 def __init__(self, ui, incl_excl_tags=[[], []]):
     self.incl_excl_tags = incl_excl_tags
     self.query_scroller = None
     BaseScene.__init__(self, ui, self.__class__.__name__)