Beispiel #1
0
    def __init__(self, all_transcripts, region, options):
        # call superclass constructor
        super(GenesTrack, self).__init__(region, options)

        self.transcripts = all_transcripts

        self.n_fwd_rows = None
        self.n_rev_rows = None
        self.row_assignment = None
        self.color = options['color']
        self.utr_color = options['utr_color']
        
        # get all transcripts that overlap region
        self.overlap_trs = coord.get_coord_overlaps(self.region,
                                                    self.transcripts,
                                                    use_strand=False)

        # assign rows to the transcripts
        padding = region.length() * 0.2
        self.assign_feature_rows(self.overlap_trs, padding=padding)

        if self.height <= 0.0:
            # assign height based on how many rows of transcripts
            # there are
            self.height = float(self.n_row) * 0.5
Beispiel #2
0
    def __init__(self, all_transcripts, region, options):
        # call superclass constructor
        super(GenesTrack, self).__init__(region, options)

        self.transcripts = all_transcripts

        self.n_fwd_rows = None
        self.n_rev_rows = None
        self.row_assignment = None
        self.color = options['color']
        self.utr_color = options['utr_color']

        if 'draw_label' in options:
            self.draw_label = self.parse_bool_str(options['draw_label'])
        else:
            self.draw_label = True

        # get all transcripts that overlap region
        self.overlap_trs = coord.get_coord_overlaps(self.region,
                                                    self.transcripts,
                                                    use_strand=False)

        if 'longest_isoform_only' in options:
            longest_only = self.parse_bool_str(options['longest_isoform_only'])
        else:
            longest_only = False

        if longest_only:
            sys.stderr.write("  only drawing longest isoform of each gene\n")

            gene_groups = genome.gene.group_transcripts(self.overlap_trs)

            sys.stderr.write("  grouped %d transcripts into %d genes\n" % (len(self.overlap_trs), len(gene_groups)))
            
            longest_trs = []
            for gene in gene_groups:
                longest_trs.append(gene.get_longest_transcript())

            self.overlap_trs = longest_trs
            
        # assign rows to the transcripts
        if self.draw_label:
            padding = region.length() * 0.2
        else:
            padding = region.length() * 0.01
        self.assign_feature_rows(self.overlap_trs, padding=padding)

        if self.height <= 0.0:
            # assign height based on how many rows of transcripts
            # there are
            self.height = float(self.n_row) * 0.5
Beispiel #3
0
    def __init__(self, all_genes, region, options):
        # call superclass constructor
        super(GenesTrack, self).__init__(region, options)

        self.genes = all_genes
        self.n_fwd_rows = None
        self.n_rev_rows = None
        self.row_assignment = None
        self.color = options['color']
        self.utr_color = options['utr_color']
        self.longest_isoform_only = self.parse_bool_str(
            options['longest_isoform_only'])

        if 'draw_label' in options:
            self.draw_label = self.parse_bool_str(options['draw_label'])
        else:
            self.draw_label = True

        sys.stderr.write("%d genes total\n" % len(all_genes))

        # get all genes that overlap region
        self.overlap_genes = coord.get_coord_overlaps(self.region,
                                                      self.genes,
                                                      use_strand=False)

        sys.stderr.write("%d genes overlap region\n" % len(self.overlap_genes))

        self.overlap_trs = []
        for g in self.overlap_genes:
            if self.longest_isoform_only:
                # only longest transcript for each gene
                self.overlap_trs.append(g.get_longest_transcript())
            else:
                # use all transcripts
                self.overlap_trs.extend(gene.transcripts)
        sys.stderr.write("%d transcripts overlap region" %
                         len(self.overlap_trs))

        # assign rows to the transcripts
        if self.draw_label:
            padding = region.length() * 0.2
        else:
            padding = region.length() * 0.01
        self.assign_feature_rows(self.overlap_trs, padding=padding)

        if self.height <= 0.0:
            # assign height based on how many rows of transcripts
            # there are
            self.height = float(self.n_row) * 0.5
Beispiel #4
0
    def __init__(self, all_genes, region, options):
        # call superclass constructor
        super(GenesTrack, self).__init__(region, options)

        self.genes = all_genes
        self.n_fwd_rows = None
        self.n_rev_rows = None
        self.row_assignment = None
        self.color = options['color']
        self.utr_color = options['utr_color']
        self.longest_isoform_only = self.parse_bool_str(options['longest_isoform_only'])

        if 'draw_label' in options:
            self.draw_label = self.parse_bool_str(options['draw_label'])
        else:
            self.draw_label = True

        sys.stderr.write("%d genes total\n" % len(all_genes))
            
        # get all genes that overlap region
        self.overlap_genes = coord.get_coord_overlaps(self.region,
                                                      self.genes,
                                                      use_strand=False)

        sys.stderr.write("%d genes overlap region\n" % len(self.overlap_genes))

        self.overlap_trs = []
        for g in self.overlap_genes:
            if self.longest_isoform_only:
                # only longest transcript for each gene
                self.overlap_trs.append(g.get_longest_transcript())
            else:
                # use all transcripts
                self.overlap_trs.extend(gene.transcripts)
        sys.stderr.write("%d transcripts overlap region" % len(self.overlap_trs))
        
        # assign rows to the transcripts
        if self.draw_label:
            padding = region.length() * 0.2
        else:
            padding = region.length() * 0.01
        self.assign_feature_rows(self.overlap_trs, padding=padding)

        if self.height <= 0.0:
            # assign height based on how many rows of transcripts
            # there are
            self.height = float(self.n_row) * 0.5