示例#1
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)
示例#2
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]
示例#3
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 ]
示例#4
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))
示例#5
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)
示例#6
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)
示例#7
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 ]
示例#8
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
     ]
示例#9
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())