当前位置: 首页>>代码示例>>Python>>正文


Python SVGdraw.link方法代码示例

本文整理汇总了Python中CGAT.SVGdraw.link方法的典型用法代码示例。如果您正苦于以下问题:Python SVGdraw.link方法的具体用法?Python SVGdraw.link怎么用?Python SVGdraw.link使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CGAT.SVGdraw的用法示例。


在下文中一共展示了SVGdraw.link方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: getElements

# 需要导入模块: from CGAT import SVGdraw [as 别名]
# 或者: from CGAT.SVGdraw import link [as 别名]
    def getElements(self, node_id, x, y, x_label=None, y_label=None):

        e = NodeDecorator.getElements(self, node_id, x, y)

        if x_label is None:
            x_label = x
        if y_label is None:
            y_label = y

        t = self.mTree.node(node_id).data.taxon
        species = self.mExtractSpecies(t)

        if species not in self.mMapSpecies2Colour:
            self.mMapSpecies2Colour[species] = COLOURS[
                len(self.mMapSpecies2Colour) % len(COLOURS)]

        if species in self.mMapSpecies2Name:
            tx = re.sub(species, "%s" % self.mMapSpecies2Name[species], t)
        else:
            tx = t

        colour = self.getColour(node_id, x, y)

        if self.mPlotLabel:
            ee = SVGdraw.text(x_label, y_label,
                              tx,
                              self.mFontSize,
                              self.mFont,
                              stroke="rgb(%i,%i,%i)" % colour,
                              text_anchor="left")

            if self.mMapTaxon2URL is not None:
                url = self.mMapTaxon2URL(t)
                if url:
                    l = SVGdraw.link(url)
                    l.addElement(ee)
                    e.append(l)
                else:
                    e.append(ee)
            else:
                e.append(ee)
        return e
开发者ID:Charlie-George,项目名称:cgat,代码行数:44,代码来源:SVGTree.py

示例2: addDuplication

# 需要导入模块: from CGAT import SVGdraw [as 别名]
# 或者: from CGAT.SVGdraw import link [as 别名]
    def addDuplication(self, entries, map_gene2pos, height,
                       url=None,
                       with_separator=True,
                       link_to_previous=False,
                       quality2symbol={},
                       quality2mask={}):
        """add a dot in row/col."""

        mi, ma = None, 0

        pos = bisect.bisect(self.mColourThresholds, height)
        master_colour = self.mColours[pos]

        chrs = {}
        points = []

        if not link_to_previous:
            self.mPreviousPoints = {}

        ########################################################
        ########################################################
        ########################################################
        # convert gene list to a set of points
        ########################################################
        for species, transcript, gene, quality in entries:

            chr, strand, first_res, last_res = map_gene2pos[gene]
            chrs[chr] = 1
            pos1 = self.getPosition(chr, strand, first_res)
            pos2 = self.getPosition(chr, strand, last_res)

            a = min(pos1, pos2)
            b = max(pos1, pos2)

            if mi is None:
                mi = a
            else:
                mi = min(a, mi)
            ma = max(b, ma)

            points.append((pos1, pos2, gene, quality, chr))

        ########################################################
        ########################################################
        ########################################################
        # decide whether we need to increment the radius
        ########################################################
        cis = len(chrs) == 1

        old_radius = self.mRadius
        is_overlap = False
        if cis:
            if not self.mLastChr:
                self.mLastChr = chr

            if chr != self.mLastChr:
                self.mRadius = self.mRadiusFallBack
                self.mLastMax = ma
                self.mPreviousMax = ma
                self.mLastChr = chr
            else:
                if self.mPreviousMax + self.mMinDistance > mi:
                    # overlap due to close proximitiy
                    self.mRadius += self.mRadiusIncrement
                    if with_separator:
                        self.addSeparator()

                    # true overlap
                    if self.mPreviousMax > mi:
                        is_overlap = True

                elif self.mLastMax + self.mMinDistance > mi:
                    pass
                else:
                    self.mRadius = self.mRadiusFallBack

                self.mLastMax = max(self.mLastMax, ma)
        else:
            if self.mLastMax > mi:
                self.mRadius += self.mRadiusIncrement
                if with_separator:
                    self.addSeparator()

        self.mPreviousMin = mi
        self.mPreviousMax = ma
        self.mPreviousCis = cis

        self.mRadiusMax = max(self.mRadius, self.mRadiusMax)

        ########################################################
        ########################################################
        ########################################################
        # draw points
        ########################################################
        link_colour = master_colour
        link_rad_width = self.mLinkRadStrokeWidth
        link_arc_width = self.mLinkArcStrokeWidth
        new_points = {}
        for pos1, pos2, gene, quality, chr in points:

#.........这里部分代码省略.........
开发者ID:Charlie-George,项目名称:cgat,代码行数:103,代码来源:SVGDuplicationsWheel.py

示例3: plotGenes

# 需要导入模块: from CGAT import SVGdraw [as 别名]
# 或者: from CGAT.SVGdraw import link [as 别名]
    def plotGenes(self):
        """plot orthologs orthologwise."""

        # sort all entries by coordinates
        # and build coordinates
        map_gene2coord = {}

        y = self.mHeaderHeight

        self.mMapGene2Coord = {}

        reference_genes = None

        for species in self.mSpeciesList:
            genes = self.getGenes(species)
            genes.sort(lambda x, y: cmp((x.contig, x.mFrom), (y.contig, y.mFrom)))

            if reference_genes:
                genes = self.getSortedGenes(genes, reference_genes)
            else:
                genes = self.getSortedGenesByBlockSize(genes)

            x = self.getRowWidth(genes)

            x = self.mHeaderWidth + (self.mDataWidth - x) / 2

            last_contig, last_end = None, 0

            # build list of genes to skip (note: this can be improved
            # by working in blocks from the start.)
            blocks = self.getBlocks(genes)

            for block in blocks:

                nlinks = 0
                for gene in block:
                    nlinks += len(self.mMapGroup2Genes[gene.mOrthologId])
                if nlinks == len(block):
                    continue

                x = self.addGroupStart(x, y, gene.contig, gene.mFrom)

                # count number of links to be made
                for gene in block:

                    self.mMapGene2Coord[gene] = (x, y)

                    ee = self.plotGene(x, y, gene)

                    if self.mGeneUrl:
                        e = SVGdraw.link(self.mGeneUrl % gene)
                        e.addElement(ee)
                    else:
                        e = ee

                    self.addElement(e)
                    x += self.mBlockSize + self.mVerticalSeparator

                    last_contig, last_end = gene.contig, gene.mTo

            y += self.mBlockSize + self.mHorizontalSeparator

            # set orientation
            if self.mOrientation == "local":
                reference_genes = genes
            elif self.mOrientation == "first":
                if not reference_genes:
                    reference_genes = genes
开发者ID:CGATOxford,项目名称:Optic,代码行数:70,代码来源:plot_multiple_synteny.py

示例4: addDuplication

# 需要导入模块: from CGAT import SVGdraw [as 别名]
# 或者: from CGAT.SVGdraw import link [as 别名]
    def addDuplication( self, entries, map_gene2pos, height,
                        url = None,
                        with_separator=True,
                        link_to_previous = False,
                        quality2symbol = {},
                        quality2mask = {}):
        """add a dot in row/col."""
        
        mi, ma = None, 0

        pos = bisect.bisect( self.mColourThresholds, height )
        master_colour = self.mColours[pos]
        
        chrs = {}
        points = []
        for species, transcript, gene, quality in entries:

            chr, strand, first_res, last_res = map_gene2pos[gene]
            chrs[chr] = 1
            pos1 = self.getPosition( chr, strand, first_res )
            pos2 = self.getPosition( chr, strand, last_res )

            a = min( pos1, pos2 )
            b = max( pos1, pos2 )

            if mi == None:
                mi = a
            else:
                mi = min(a, mi)
            ma = max(b, ma)
            
            points.append( (pos1, pos2, gene, quality) )

        ## decide whether we need to increment the radius
        cis = len(chrs) == 1

        old_radius = self.mRadius
        is_overlap = False
        if cis:
            if not self.mLastChr:
                self.mLastChr = chr

            if chr != self.mLastChr:
                self.mRadius = self.mRadiusFallBack
                self.mLastMax = ma
                self.mPreviousMax = ma
                self.mLastChr = chr
            else:
                if self.mPreviousMax + self.mMinDistance > mi:
                    ## overlap due to close proximitiy
                    self.mRadius += self.mRadiusIncrement
                    if with_separator: self.addSeparator()

                    ## true overlap
                    if self.mPreviousMax > mi:
                        is_overlap = True
                    
                elif self.mLastMax + self.mMinDistance > mi:
                    pass
                else:
                    self.mRadius = self.mRadiusFallBack
                    
                self.mLastMax = max(self.mLastMax, ma)
        else:
            if self.mLastMax > mi:
                self.mRadius += self.mRadiusIncrement
                if with_separator: self.addSeparator()
                
        if cis and self.mPreviousCis and (link_to_previous or is_overlap):

            # print old_x1, old_y1, old_x2, old_y2, new_x1, new_y2, new_x2, new_y2
            r1 = old_radius
            r2 = self.mRadius
            old_x1, old_y1 = self.getPosOnArcForRadius( self.mPreviousMin, r1 )
            old_x2, old_y2 = self.getPosOnArcForRadius( self.mPreviousMax, r1 )
            new_x1, new_y1 = self.getPosOnArcForRadius( mi, r2 )
            new_x2, new_y2 = self.getPosOnArcForRadius( ma, r2 )

            if link_to_previous:
                
                # print cis, entries, chrs
                
                d = SVGdraw.pathdata( old_x1, old_y1 )
                d.ellarc( r1, r1, 0, 0, 1, old_x2, old_y2 )            
                d.line( new_x2, new_y2 )
                d.ellarc( r2, r2, 0, 0, 1, new_x1, new_y1 )
                d.line( old_x1, old_y1 )
                
                e = SVGdraw.path( d,
                                  fill = "rgb(%i,%i,%i)" % GREY,
                                  stroke = "rgb(%i,%i,%i)" % GREY,
                                  stroke_width = 1 )
                
            else:

                # get points of center
                old_x1, old_y1 = self.getPosOnArcForRadius( (self.mPreviousMax + self.mPreviousMin) / 2, r1 )
                new_x1, new_y1 = self.getPosOnArcForRadius( (ma + mi) / 2, r2 )

                # lines for interleaved spans: skip
#.........这里部分代码省略.........
开发者ID:siping,项目名称:cgat,代码行数:103,代码来源:plot_duplications.py


注:本文中的CGAT.SVGdraw.link方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。