예제 #1
0
    def addGroupStart(self, x, y, contig, start):
        """plot start of contig."""

        t = "%s:%i" % (contig, start)
        max_x = x + len(t) * self.contigFontSize * self.mFontFactor

        ## plot line
        e = SVGdraw.line(
            x,
            y,
            max_x,
            y,
            stroke="rgb(%i,%i,%i)" % BLACK,
        )

        self.addElement(e)
        e = SVGdraw.text(x,
                         y,
                         t,
                         self.contigFontSize,
                         self.contigFont,
                         stroke="rgb(%i,%i,%i)" % BLACK,
                         text_anchor="left")

        self.addElement(e)

        return max_x
예제 #2
0
    def writeToFile(self, outfile):
        """write svg image to file.
        """
        self.finalizePlot()

        self.mRoot = SVGdraw.drawing()
        self.mDraw = SVGdraw.svg(
            (0, 0, self.mPageWidth, self.mPageHeight), "100%", "100%")

        kk = self.mElements.keys()
        kk.sort()
        kk.reverse()
        for k in kk:
            for e in self.mElements[k]:
                self.mDraw.addElement(e)

        self.mRoot.setSVG(self.mDraw)

        tfile = tempfile.mktemp()

        self.mRoot.toXml(tfile)

        lines = open(tfile, "r").readlines()

        outfile.write(string.join(lines, ""))
        outfile.write("\n")

        os.remove(tfile)
예제 #3
0
    def writeToFile(self, outfile):
        """write svg image to file.
        """
        self.finalizePlot()

        self.mRoot = SVGdraw.drawing()
        self.mDraw = SVGdraw.svg((0, 0, self.mPageWidth, self.mPageHeight),
                                 "100%", "100%")

        kk = self.mElements.keys()
        kk.sort()
        kk.reverse()
        for k in kk:
            for e in self.mElements[k]:
                self.mDraw.addElement(e)

        self.mRoot.setSVG(self.mDraw)

        tfile = tempfile.mktemp()

        self.mRoot.toXml(tfile)

        lines = open(tfile, "r").readlines()

        outfile.write(string.join(lines, ""))
        outfile.write("\n")

        os.remove(tfile)
예제 #4
0
    def writeGrid(self):
        """add grid lines."""

        min_x = self.mHeaderWidth
        max_x = min_x + self.mDataWidth
        min_y = self.mHeaderHeight
        max_y = min_y + self.mDataHeight

        for contig in self.mSortedContigs1:
            if contig not in self.mMapContig2Start1:
                continue
            x = self.mMapContig2Start1[contig]

            e = SVGdraw.line(min_x + x, min_y, min_x + x, max_y,
                             stroke="rgb(%i,%i,%i)" % GREEN,
                             )
            self.addElement(e)

        self.addElement(SVGdraw.line(max_x, min_y, max_x, max_y,
                                     stroke="rgb(%i,%i,%i)" % GREEN))

        for contig in self.mSortedContigs2:
            if contig not in self.mMapContig2Start2:
                continue
            y = self.mMapContig2Start2[contig]
            e = SVGdraw.line(min_x, min_y + y, max_x, min_y + y,
                             stroke="rgb(%i,%i,%i)" % GREEN,
                             )
            self.addElement(e)

        self.addElement(SVGdraw.line(min_x, max_y, max_x, max_y,
                                     stroke="rgb(%i,%i,%i)" % GREEN))
예제 #5
0
파일: SVGTree.py 프로젝트: santayana/cgat
    def writeToFile(self, outfile):
        """write svg image to file.
        """
        self.finalizePlot()

        kk = self.mElements.keys()
        kk.sort()
        kk.reverse()

        # make sure the image size is ok
        min_x, min_y, max_x, max_y = 0, 0, 0, 0

        for k in kk:
            for e in self.mElements[k]:
                for x in ('x', 'x2', 'x1'):
                    if x in e.attributes:
                        v = e.attributes[x]
                        min_x = min(min_x, v)
                        max_x = max(max_x, v)
                for y in ('y', 'y2', 'y1'):
                    if y in e.attributes:
                        v = e.attributes[y]
                        min_y = min(min_y, v)
                        max_y = max(max_y, v)

        min_x, min_y = int(math.floor(min_x)), int(math.floor(min_y))
        max_x, max_y = int(math.floor(max_x)), int(math.floor(max_y))

        for k in kk:
            for e in self.mElements[k]:
                for x in ('x', 'x2', 'x1'):
                    if x in e.attributes:
                        e.attributes[x] -= min_x
                for x in ('y', 'y2', 'y1'):
                    if y in e.attributes:
                        e.attributes[y] -= min_y

        # now add all the elements
        self.mRoot = SVGdraw.drawing()
        self.mDraw = SVGdraw.svg(
            (0, 0, self.mPageWidth - min_x, self.mPageHeight - min_y), "100%",
            "100%")

        for k in kk:
            for e in self.mElements[k]:
                self.mDraw.addElement(e)

        self.mRoot.setSVG(self.mDraw)

        tfile = tempfile.mktemp()

        self.mRoot.toXml(tfile)

        lines = open(tfile, "r").readlines()

        outfile.write(string.join(lines, ""))
        outfile.write("\n")

        os.remove(tfile)
예제 #6
0
    def writeFooter(self):
        """write footer.

        The footer contains the legend.
        """
        current_x = self.mFooterFrom
        current_y = self.mHeaderHeight + self.mDataHeight + 2 * self.mSeparator

        self.mFooterBoxSize = 30
        self.mNumTicks = 20
        for x in range(len(self.mColourThresholds)):

            e = SVGdraw.rect(current_x,
                             current_y,
                             self.mFooterBoxSize,
                             self.mFooterBoxSize,
                             fill="rgb(%i,%i,%i)" % self.mColours[x],
                             stroke="rgb(%i,%i,%i)" % self.mColours[x])

            self.addElement(e)

            if x % self.mNumTicks == 0:

                e = SVGdraw.line(current_x,
                                 current_y,
                                 current_x,
                                 current_y + self.mFooterBoxSize,
                                 stroke="rgb(%i,%i,%i)" % BLACK,
                                 stroke_width=5)
                self.addElement(e)

                e = SVGdraw.text(current_x,
                                 current_y - self.mFooterBoxSize,
                                 self.mFormatNumberLegend % self.mColourThresholds[
                                     x],
                                 self.mFooterFontSize,
                                 self.mFooterFont,
                                 stroke="rgb(%i,%i,%i)" % BLACK,
                                 text_anchor="start")
                self.addElement(e)

            current_x += self.mFooterBoxSize

        ###########################################################
        if self.mFooter:

            current_y += max(self.mFooterFontSize,
                             self.mMaxBoxSize) + self.mSeparator

            e = SVGdraw.text(self.mPageWidth / 2,
                             current_y + self.mFooterFontSize,
                             self.mFooter,
                             self.mFooterFontSize,
                             self.mFooterFont,
                             stroke="rgb(%i,%i,%i)" % BLACK,
                             text_anchor="middle")

            self.addElement(e)
예제 #7
0
    def writeFooter(self):
        """write footer.

        The footer contains the legend.
        """
        current_x = self.mFooterFrom
        current_y = self.mHeaderHeight + self.mDataHeight + 2 * self.mSeparator

        self.mFooterBoxSize = 30
        self.mNumTicks = 20
        for x in range(len(self.mColourThresholds)):

            e = SVGdraw.rect(current_x,
                             current_y,
                             self.mFooterBoxSize,
                             self.mFooterBoxSize,
                             fill="rgb(%i,%i,%i)" % self.mColours[x],
                             stroke="rgb(%i,%i,%i)" % self.mColours[x])

            self.addElement(e)

            if x % self.mNumTicks == 0:

                e = SVGdraw.line(current_x,
                                 current_y,
                                 current_x,
                                 current_y + self.mFooterBoxSize,
                                 stroke="rgb(%i,%i,%i)" % BLACK,
                                 stroke_width=5)
                self.addElement(e)

                e = SVGdraw.text(current_x,
                                 current_y - self.mFooterBoxSize,
                                 self.mFormatNumberLegend %
                                 self.mColourThresholds[x],
                                 self.mFooterFontSize,
                                 self.mFooterFont,
                                 stroke="rgb(%i,%i,%i)" % BLACK,
                                 text_anchor="start")
                self.addElement(e)

            current_x += self.mFooterBoxSize

        ###########################################################
        if self.mFooter:

            current_y += max(self.mFooterFontSize,
                             self.mMaxBoxSize) + self.mSeparator

            e = SVGdraw.text(self.mPageWidth / 2,
                             current_y + self.mFooterFontSize,
                             self.mFooter,
                             self.mFooterFontSize,
                             self.mFooterFont,
                             stroke="rgb(%i,%i,%i)" % BLACK,
                             text_anchor="middle")

            self.addElement(e)
예제 #8
0
    def writeToFile(self, outfile):
        """write svg image to file.
        """
        self.finalizePlot()

        kk = self.mElements.keys()
        kk.sort()
        kk.reverse()

        # make sure the image size is ok
        min_x, min_y, max_x, max_y = 0, 0, 0, 0

        for k in kk:
            for e in self.mElements[k]:
                for x in ('x', 'x2', 'x1'):
                    if x in e.attributes:
                        v = e.attributes[x]
                        min_x = min(min_x, v)
                        max_x = max(max_x, v)
                for y in ('y', 'y2', 'y1'):
                    if y in e.attributes:
                        v = e.attributes[y]
                        min_y = min(min_y, v)
                        max_y = max(max_y, v)

        min_x, min_y = int(math.floor(min_x)), int(math.floor(min_y))
        max_x, max_y = int(math.floor(max_x)), int(math.floor(max_y))

        for k in kk:
            for e in self.mElements[k]:
                for x in ('x', 'x2', 'x1'):
                    if x in e.attributes:
                        e.attributes[x] -= min_x
                for x in ('y', 'y2', 'y1'):
                    if y in e.attributes:
                        e.attributes[y] -= min_y

        # now add all the elements
        self.mRoot = SVGdraw.drawing()
        self.mDraw = SVGdraw.svg(
            (0, 0, self.mPageWidth - min_x, self.mPageHeight - min_y), "100%", "100%")

        for k in kk:
            for e in self.mElements[k]:
                self.mDraw.addElement(e)

        self.mRoot.setSVG(self.mDraw)

        tfile = tempfile.mktemp()

        self.mRoot.toXml(tfile)

        lines = open(tfile, "r").readlines()

        outfile.write(string.join(lines, ""))
        outfile.write("\n")

        os.remove(tfile)
예제 #9
0
    def writeScale(self):
        """write scales."""

        current_x = self.mScaleX
        current_y = self.mScaleY + self.mScaleHeight

        nboxes = len(self.mColourThresholds)
        # box size for legend in x-direction
        # subtract size of right-most axis label so that it takes the
        # same width as self.mDataWidth.
        box_size_x = math.ceil(
            (self.mDataWidth -
             (self.mScaleFontSize *
              len(self.mFormatNumberLegend % self.mColourThresholds[-1]))) /
            nboxes)

        # change font size such that it labels will fit between tick-marks
        self.mScaleFontSize = min(
            self.mScaleFontSize, (box_size_x * self.mScaleNumTicks * 1.5) /
            len(self.mFormatNumberLegend % self.mColourThresholds[-1]))

        for x in range(nboxes):

            e = SVGdraw.rect(current_x,
                             current_y,
                             box_size_x,
                             self.mScaleBoxSizeY,
                             fill="rgb(%i,%i,%i)" % self.mColours[x],
                             stroke="rgb(%i,%i,%i)" % self.mColours[x])

            self.addElement(e)

            if x % self.mScaleNumTicks == 0:

                e = SVGdraw.line(current_x,
                                 current_y,
                                 current_x,
                                 current_y + self.mScaleBoxSizeY,
                                 stroke="rgb(%i,%i,%i)" % BLACK,
                                 stroke_width=5)
                self.addElement(e)

                e = SVGdraw.text(current_x,
                                 current_y - self.mScaleBoxSizeY,
                                 self.mFormatNumberLegend %
                                 self.mColourThresholds[x],
                                 self.mScaleFontSize,
                                 self.mScaleFont,
                                 stroke="rgb(%i,%i,%i)" % BLACK,
                                 text_anchor="start")
                self.addElement(e)

            current_x += box_size_x
예제 #10
0
    def writeScale(self):
        """write scales."""

        current_x = self.mScaleX
        current_y = self.mScaleY + self.mScaleHeight

        nboxes = len(self.mColourThresholds)
        # box size for legend in x-direction
        # subtract size of right-most axis label so that it takes the
        # same width as self.mDataWidth.
        box_size_x = math.ceil((self.mDataWidth -
                                (self.mScaleFontSize * len(
                                    self.mFormatNumberLegend %
                                    self.mColourThresholds[-1]))) / nboxes)

        # change font size such that it labels will fit between tick-marks
        self.mScaleFontSize = min(self.mScaleFontSize,
                                  (box_size_x * self.mScaleNumTicks * 1.5) /
                                  len(self.mFormatNumberLegend %
                                      self.mColourThresholds[-1]))

        for x in range(nboxes):

            e = SVGdraw.rect(current_x,
                             current_y,
                             box_size_x,
                             self.mScaleBoxSizeY,
                             fill="rgb(%i,%i,%i)" % self.mColours[x],
                             stroke="rgb(%i,%i,%i)" % self.mColours[x])

            self.addElement(e)

            if x % self.mScaleNumTicks == 0:

                e = SVGdraw.line(current_x,
                                 current_y,
                                 current_x,
                                 current_y + self.mScaleBoxSizeY,
                                 stroke="rgb(%i,%i,%i)" % BLACK,
                                 stroke_width=5)
                self.addElement(e)

                e = SVGdraw.text(current_x,
                                 current_y - self.mScaleBoxSizeY,
                                 self.mFormatNumberLegend % self.mColourThresholds[
                                     x],
                                 self.mScaleFontSize,
                                 self.mScaleFont,
                                 stroke="rgb(%i,%i,%i)" % BLACK,
                                 text_anchor="start")
                self.addElement(e)

            current_x += box_size_x
예제 #11
0
    def writeGrid(self):
        """add grid lines."""

        min_x = self.mHeaderWidth
        max_x = min_x + self.mDataWidth
        min_y = self.mHeaderHeight
        max_y = min_y + self.mDataHeight

        for contig in self.mSortedContigs1:
            if contig not in self.mMapContig2Start1:
                continue
            x = self.mMapContig2Start1[contig]

            e = SVGdraw.line(
                min_x + x,
                min_y,
                min_x + x,
                max_y,
                stroke="rgb(%i,%i,%i)" % GREEN,
            )
            self.addElement(e)

        self.addElement(
            SVGdraw.line(max_x,
                         min_y,
                         max_x,
                         max_y,
                         stroke="rgb(%i,%i,%i)" % GREEN))

        for contig in self.mSortedContigs2:
            if contig not in self.mMapContig2Start2:
                continue
            y = self.mMapContig2Start2[contig]
            e = SVGdraw.line(
                min_x,
                min_y + y,
                max_x,
                min_y + y,
                stroke="rgb(%i,%i,%i)" % GREEN,
            )
            self.addElement(e)

        self.addElement(
            SVGdraw.line(min_x,
                         max_y,
                         max_x,
                         max_y,
                         stroke="rgb(%i,%i,%i)" % GREEN))
예제 #12
0
파일: go2svg.py 프로젝트: CGATOxford/cgat
    def addValue(self, row, col, size, colour_value):
        """add a dot in row/col.
        """

        # decide the size of the box
        pos = bisect.bisect(self.mThresholdsSize, size)

        if self.mRevertSize:
            size = self.mMaxBoxSize * \
                (1.0 - float(pos) / len(self.mThresholdsSize))
        else:
            size = self.mMaxBoxSize * float(pos) / len(self.mThresholdsSize)

        d = (self.mMaxBoxSize - size) / 2

        x = self.mMapCol2Position[col] + d
        try:
            y = self.mMapRow2Position[row] + d
        except KeyError:
            return

        # determine the colour of the box
        pos = bisect.bisect(self.mThresholdsColour, colour_value)
        colour = self.mColours[pos]

        e = SVGdraw.rect(x, y,
                         size, size,
                         stroke="black",
                         fill="rgb(%i,%i,%i)" % colour)

        self.mElements.append(e)
예제 #13
0
    def writeRowHeader(self):
        """write row header

        The row header contains the species names
        """
        x = 0
        y = self.mHeaderHeight

        max_l = 0

        for species in self.mSpeciesList:
            max_l = max(max_l,
                        len(species) * self.mHeaderFontSize) * self.mFontFactor
            e = SVGdraw.text(x,
                             y,
                             species,
                             self.mHeaderFontSize,
                             self.mHeaderFont,
                             stroke="rgb(%i,%i,%i)" % BLACK,
                             text_anchor="left")

            self.addElement(e)

            y += self.mBlockSize + self.mHorizontalSeparator

        self.mHeaderWidth = max_l
예제 #14
0
    def writeRowHeader(self):
        """write row header

        The row header contains the species names
        """
        x = 0
        y = self.mHeaderHeight

        max_l = 0

        for species in self.mSpeciesList:
            max_l = max(max_l, len(species) * self.mHeaderFontSize) * self.mFontFactor
            e = SVGdraw.text(
                x,
                y,
                species,
                self.mHeaderFontSize,
                self.mHeaderFont,
                stroke="rgb(%i,%i,%i)" % BLACK,
                text_anchor="left",
            )

            self.addElement(e)

            y += self.mBlockSize + self.mHorizontalSeparator

        self.mHeaderWidth = max_l
예제 #15
0
파일: png2svg.py 프로젝트: yangjl/cgat
 def getSVG(self, xoffset, yoffset):
     return SVGdraw.image(self.mFilename,
                          self.mX + xoffset,
                          self.mY + yoffset,
                          self.mWidth,
                          self.mHeight,
                          opacity=self.mOpacity)
예제 #16
0
    def plotOrthologs(self):
        """plot orthologs orthologwise."""

        # Do the plot
        for ortholog_id in self.mOrthologs1.keys():

            for o1 in self.mOrthologs1[ortholog_id]:

                try:
                    x = self.getCoords1(o1)
                except KeyError:
                    continue

                for o2 in self.mOrthologs2[ortholog_id]:

                    try:
                        y = self.getCoords2(o2)
                    except KeyError:
                        continue

                    e = SVGdraw.circle(x, y,
                                       self.mDotRadius,
                                       fill="rgb(%i,%i,%i)" % BLACK,
                                       stroke="rgb(%i,%i,%i)" % BLACK,
                                       stroke_width=1)

                    self.addElement(e)
예제 #17
0
    def getElements(self, node_id, x, y1, y2):

        e = []
        e.append(SVGdraw.line(x, y1, x, y2,
                              stroke="rgb(%i,%i,%i)" % BLACK,
                              stroke_width=1))
        return e
예제 #18
0
    def plotOrthologs(self):
        """plot orthologs orthologwise."""

        # Do the plot
        for ortholog_id in self.mOrthologs1.keys():

            for o1 in self.mOrthologs1[ortholog_id]:

                try:
                    x = self.getCoords1(o1)
                except KeyError:
                    continue

                for o2 in self.mOrthologs2[ortholog_id]:

                    try:
                        y = self.getCoords2(o2)
                    except KeyError:
                        continue

                    e = SVGdraw.circle(x,
                                       y,
                                       self.mDotRadius,
                                       fill="rgb(%i,%i,%i)" % BLACK,
                                       stroke="rgb(%i,%i,%i)" % BLACK,
                                       stroke_width=1)

                    self.addElement(e)
예제 #19
0
파일: go2svg.py 프로젝트: gsc0107/cgat
    def addValue(self, row, col, size, colour_value):
        """add a dot in row/col.
        """

        # decide the size of the box
        pos = bisect.bisect(self.mThresholdsSize, size)

        if self.mRevertSize:
            size = self.mMaxBoxSize * \
                (1.0 - float(pos) / len(self.mThresholdsSize))
        else:
            size = self.mMaxBoxSize * float(pos) / len(self.mThresholdsSize)

        d = (self.mMaxBoxSize - size) / 2

        x = self.mMapCol2Position[col] + d
        try:
            y = self.mMapRow2Position[row] + d
        except KeyError:
            return

        # determine the colour of the box
        pos = bisect.bisect(self.mThresholdsColour, colour_value)
        colour = self.mColours[pos]

        e = SVGdraw.rect(x,
                         y,
                         size,
                         size,
                         stroke="black",
                         fill="rgb(%i,%i,%i)" % colour)

        self.mElements.append(e)
예제 #20
0
파일: go2svg.py 프로젝트: gsc0107/cgat
    def writeColHeaders(self):
        """write row headers."""

        current_x = self.mColWidth / 2
        current_y = self.mHeaderHeight
        for i in range(len(self.mColNames)):
            if self.mMarkColumns and self.mMarkColumns[i]:
                color = BLUE
                name = self.mColNames[i] + "*"
            else:
                color = BLACK
                name = self.mColNames[i]

            e = SVGdraw.text(current_x,
                             current_y,
                             name,
                             self.mHeaderFontSize,
                             self.mHeaderFont,
                             stroke="rgb(%i,%i,%i)" % color,
                             text_anchor="start",
                             transform="rotate(-45,%i,%i)" %
                             (current_x, current_y))

            self.mElements.append(e)

            current_x += self.mColWidth
예제 #21
0
파일: png2svg.py 프로젝트: CGATOxford/cgat
 def getSVG(self, xoffset, yoffset):
     return SVGdraw.image(self.mFilename,
                          self.mX + xoffset,
                          self.mY + yoffset,
                          self.mWidth,
                          self.mHeight,
                          opacity=self.mOpacity)
예제 #22
0
    def getElements(self, node_id, x1, x2, y):

        e = SVGTree.BranchDecoratorHorizontal.getElements(
            self, node_id, x1, x2, y)

        table_id = str(int(self.mTree.node(node_id).data.branchlength))

        if table_id not in self.mTables:
            return e

        startx = x1 + self.mFontSize
        y = y + self.mFontSize

        table, column_widths = self.mTables[
            table_id], self.mColumnWidths[table_id]

        font_weight = "bold"

        for r, row in enumerate(table):
            x = startx

            for c, col in enumerate(row):
                e.append(SVGdraw.text(x, y,
                                      col,
                                      20,
                                      self.mFont,
                                      stroke="rgb(%i,%i,%i)" % self.mFontColour,
                                      font_weight=font_weight,
                                      text_anchor="left"))
                x += column_widths[c] * self.mFontSize // 2

            y += self.mFontSize
            font_weight = "normal"

        return e
예제 #23
0
파일: go2svg.py 프로젝트: CGATOxford/cgat
    def writeColHeaders(self):
        """write row headers."""

        current_x = self.mColWidth / 2
        current_y = self.mHeaderHeight
        for i in range(len(self.mColNames)):
            if self.mMarkColumns and self.mMarkColumns[i]:
                color = BLUE
                name = self.mColNames[i] + "*"
            else:
                color = BLACK
                name = self.mColNames[i]

            e = SVGdraw.text(
                current_x,
                current_y,
                name,
                self.mHeaderFontSize,
                self.mHeaderFont,
                stroke="rgb(%i,%i,%i)" % color,
                text_anchor="start",
                transform="rotate(-45,%i,%i)" % (current_x, current_y))

            self.mElements.append(e)

            current_x += self.mColWidth
예제 #24
0
 def addSeparator(self):
     """add separator on circles."""
     if self.mRadius not in self.mSeparators:
         e = SVGdraw.circle(self.mDataMiddleX, self.mDataMiddleY, self.mRadius, fill="none",
                            stroke="rgb(%i,%i,%i)" % self.mGridColour,
                            stroke_width=self.mGridStrokeWidth)
         self.addWheelElement(e, self.mPlaneGrid)
     self.mSeparators[self.mRadius] = 1
예제 #25
0
    def addGroupStart(self, x, y, contig, start):
        """plot start of contig."""

        t = "%s:%i" % (contig, start)
        max_x = x + len(t) * self.contigFontSize * self.mFontFactor

        # plot line
        e = SVGdraw.line(x, y, max_x, y, stroke="rgb(%i,%i,%i)" % BLACK)

        self.addElement(e)
        e = SVGdraw.text(
            x, y, t, self.contigFontSize, self.contigFont, stroke="rgb(%i,%i,%i)" % BLACK, text_anchor="left"
        )

        self.addElement(e)

        return max_x
예제 #26
0
 def addSeparator(self):
     """add separator on circles."""
     if self.mRadius not in self.mSeparators:
         e = SVGdraw.circle(self.mDataMiddleX, self.mDataMiddleY, self.mRadius, fill="none",
                            stroke="rgb(%i,%i,%i)" % self.mGridColour,
                            stroke_width=self.mGridStrokeWidth)
         self.addWheelElement(e, self.mPlaneGrid)
     self.mSeparators[self.mRadius] = 1
예제 #27
0
    def getElements(self, node_id, x1, x2, y):

        e = []
        if not self.mNoBranch:
            e.append(SVGdraw.line(x1, y, x2, y,
                                  stroke="rgb(%i,%i,%i)" % BLACK,
                                  stroke_width=1))
        return e
예제 #28
0
    def writeGrid(self):
        """add grid lines."""

        middlex = self.mDataMiddleX
        middley = self.mDataMiddleY

        # print separators
        for c in range(len(self.contigs)):

            contig = self.contigs[c]

            pos = self.getPosition(contig, "+", 0)
            angle = self.getAngle(pos)

            x, y = self.getPosOnArc(angle, self.mRadius)

            e = SVGdraw.line(middlex,
                             middley,
                             x,
                             y,
                             stroke="rgb(%i,%i,%i)" % BLACK,
                             stroke_width=self.mGridStrokeWidth)

            self.addElement(e, self.mPlaneGrid)

            if c < len(self.contigs) - 1:
                next_angle = self.getAngle(
                    self.getPosition(self.contigs[c + 1], "+", 0))
            else:
                next_angle = 360

            x, y = self.getPosOnArc(
                angle + float(next_angle - angle) / 2, self.mRadiusStart / 2)

            e = SVGdraw.text(x,
                             y,
                             contig,
                             self.mGridFontSize,
                             self.mGridFont,
                             stroke="rgb(%i,%i,%i)" % BLACK,
                             text_anchor="start")
            # do not rotate text:
            # transform="rotate(%i,%i,%i)" % ( angle, x, y ))

            self.addElement(e)
예제 #29
0
파일: tree2svg.py 프로젝트: yangjl/cgat
    def getElements(self, node_id, x, y):

        node = self.mTree.node(node_id)
        e = []

        p = node.data.support

        if p == 1.0:
            e.append(
                SVGdraw.circle(x,
                               y,
                               self.mRadius,
                               stroke="rgb(%i,%i,%i)" % SVGTree.BLACK,
                               fill="rgb(%i,%i,%i)" % SVGTree.RED))
        elif p > 0.0:
            e.append(
                SVGdraw.circle(x,
                               y,
                               self.mRadius,
                               stroke="rgb(%i,%i,%i)" % SVGTree.BLACK,
                               fill="rgb(%i,%i,%i)" % SVGTree.WHITE))

            d = SVGdraw.pathdata(x, y)

            d.line(x + self.mRadius, y)

            angle = 360.0 * p
            dx = self.mRadius * math.cos(math.radians(angle)) + x
            dy = self.mRadius * math.sin(math.radians(angle)) + y

            if p <= 0.5:
                d.ellarc(self.mRadius, self.mRadius, 0, 0, 1, dx, dy)
            else:
                d.ellarc(self.mRadius, self.mRadius, 0, 1, 1, dx, dy)

            e.append(
                SVGdraw.path(d,
                             stroke="rgb(%i,%i,%i)" % SVGTree.RED,
                             fill="rgb(%i,%i,%i)" % SVGTree.RED,
                             stroke_width=self.mStrokeWidth))

        else:
            pass

        return e
예제 #30
0
    def writeGrid(self):
        """add grid lines."""

        middlex = self.mDataMiddleX
        middley = self.mDataMiddleY

        # print separators
        for c in range(len(self.contigs)):

            contig = self.contigs[c]

            pos = self.getPosition(contig, "+", 0)
            angle = self.getAngle(pos)

            x, y = self.getPosOnArc(angle, self.mRadius)

            e = SVGdraw.line(middlex,
                             middley,
                             x,
                             y,
                             stroke="rgb(%i,%i,%i)" % BLACK,
                             stroke_width=self.mGridStrokeWidth)

            self.addElement(e, self.mPlaneGrid)

            if c < len(self.contigs) - 1:
                next_angle = self.getAngle(
                    self.getPosition(self.contigs[c + 1], "+", 0))
            else:
                next_angle = 360

            x, y = self.getPosOnArc(
                angle + float(next_angle - angle) / 2, self.mRadiusStart / 2)

            e = SVGdraw.text(x,
                             y,
                             contig,
                             self.mGridFontSize,
                             self.mGridFont,
                             stroke="rgb(%i,%i,%i)" % BLACK,
                             text_anchor="start")
            # do not rotate text:
            # transform="rotate(%i,%i,%i)" % ( angle, x, y ))

            self.addElement(e)
예제 #31
0
파일: SVGTree.py 프로젝트: santayana/cgat
    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
예제 #32
0
    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
예제 #33
0
파일: go2svg.py 프로젝트: gsc0107/cgat
    def writeGrid(self):
        """add grid lines."""

        if self.mRowTicks:

            start_x = 0,
            end_x = self.mDataWidth + self.mSeparator + self.mHeaderWidth
            current_y = self.mHeaderHeight + self.mSeparator / \
                2 + self.mRowTicks * self.mRowHeight

            for x in range(self.mRowTicks, len(self.mRowNames),
                           self.mRowTicks):

                e = SVGdraw.line(start_x,
                                 current_y,
                                 end_x,
                                 current_y,
                                 stroke="rgb(%i,%i,%i)" % BLACK)

                self.mElements.append(e)

                current_y += self.mRowTicks * self.mRowHeight

        if self.mColTicks:

            start_y = self.mHeaderHeight + self.mSeparator / 2
            end_y = start_y + self.mDataHeight

            current_x = self.mColTicks * self.mColWidth - self.mColWidth / 2

            for x in range(self.mColTicks, len(self.mColNames),
                           self.mColTicks):

                e = SVGdraw.line(current_x,
                                 start_y,
                                 current_x,
                                 end_y,
                                 stroke="rgb(%i,%i,%i)" % BLACK)

                self.mElements.append(e)

                current_x += self.mColTicks * self.mColWidth
예제 #34
0
파일: go2svg.py 프로젝트: CGATOxford/cgat
    def writeGrid(self):
        """add grid lines."""

        if self.mRowTicks:

            start_x = 0,
            end_x = self.mDataWidth + self.mSeparator + self.mHeaderWidth
            current_y = self.mHeaderHeight + self.mSeparator / \
                2 + self.mRowTicks * self.mRowHeight

            for x in range(self.mRowTicks, len(self.mRowNames),
                           self.mRowTicks):

                e = SVGdraw.line(start_x,
                                 current_y,
                                 end_x,
                                 current_y,
                                 stroke="rgb(%i,%i,%i)" % BLACK)

                self.mElements.append(e)

                current_y += self.mRowTicks * self.mRowHeight

        if self.mColTicks:

            start_y = self.mHeaderHeight + self.mSeparator / 2
            end_y = start_y + self.mDataHeight

            current_x = self.mColTicks * self.mColWidth - self.mColWidth / 2

            for x in range(self.mColTicks, len(self.mColNames),
                           self.mColTicks):

                e = SVGdraw.line(current_x,
                                 start_y,
                                 current_x,
                                 end_y,
                                 stroke="rgb(%i,%i,%i)" % BLACK)

                self.mElements.append(e)

                current_x += self.mColTicks * self.mColWidth
예제 #35
0
    def getElements(self, node_id, x1, x2, y):

        e = []
        e.append(SVGdraw.line(x1, y, x2, y,
                              stroke="rgb(%i,%i,%i)" % BLACK,
                              stroke_width=1))

        e += self.mDecorator1.getElements(node_id, x1, x2, y)
        e += self.mDecorator2.getElements(node_id, x1, x2, y + self.mFontSize)

        return e
예제 #36
0
    def getElements(self, node_id, x, y):

        e = []
        colour = self.getColour(node_id, x, y)

        if self.mPlotSymbol == "circle":
            e.append(SVGdraw.circle(x + self.mFontSize / 2,
                                    y,
                                    self.mFontSize / 2,
                                    stroke="rgb(%i,%i,%i)" % BLACK,
                                    fill="rgb(%i,%i,%i)" % colour))

        elif self.mPlotSymbol == "square":
            e.append(SVGdraw.rect(x, y - self.mFontSize / 2,
                                  self.mFontSize,
                                  self.mFontSize,
                                  stroke="rgb(%i,%i,%i)" % BLACK,
                                  fill="rgb(%i,%i,%i)" % colour))

        return e
예제 #37
0
파일: SVGTree.py 프로젝트: santayana/cgat
    def getElements(self, node_id, x, y1, y2):

        e = []
        e.append(
            SVGdraw.line(x,
                         y1,
                         x,
                         y2,
                         stroke="rgb(%i,%i,%i)" % BLACK,
                         stroke_width=1))
        return e
예제 #38
0
파일: SVGTree.py 프로젝트: santayana/cgat
    def getElements(self, node_id, x1, x2, y):

        e = []
        if not self.mNoBranch:
            e.append(
                SVGdraw.line(x1,
                             y,
                             x2,
                             y,
                             stroke="rgb(%i,%i,%i)" % BLACK,
                             stroke_width=1))
        return e
예제 #39
0
    def writeTitle(self):
        """write title into plot."""

        if self.mTitle:
            e = SVGdraw.text(self.mPageWidth / 2,
                             self.mTitleFontSize,
                             self.mTitle,
                             self.mTitleFontSize,
                             self.mTitleFont,
                             stroke="rgb(%i,%i,%i)" % BLACK,
                             text_anchor="middle")

            self.addElement(e)
예제 #40
0
파일: SVGTree.py 프로젝트: santayana/cgat
    def writeTitle(self):
        """write title into plot."""

        if self.mTitle:
            e = SVGdraw.text(self.mPageWidth / 2,
                             self.mTitleFontSize,
                             self.mTitle,
                             self.mTitleFontSize,
                             self.mTitleFont,
                             stroke="rgb(%i,%i,%i)" % BLACK,
                             text_anchor="middle")

            self.addElement(e)
예제 #41
0
    def getElements(self, node_id, x, y):

        node = self.mTree.node(node_id)
        e = []

        p = node.data.support

        if p == 1.0:
            e.append(SVGdraw.circle(x, y, self.mRadius,
                                    stroke="rgb(%i,%i,%i)" % SVGTree.BLACK,
                                    fill="rgb(%i,%i,%i)" % SVGTree.RED))
        elif p > 0.0:
            e.append(SVGdraw.circle(x, y, self.mRadius,
                                    stroke="rgb(%i,%i,%i)" % SVGTree.BLACK,
                                    fill="rgb(%i,%i,%i)" % SVGTree.WHITE))

            d = SVGdraw.pathdata(x, y)

            d.line(x + self.mRadius, y)

            angle = 360.0 * p
            dx = self.mRadius * math.cos(math.radians(angle)) + x
            dy = self.mRadius * math.sin(math.radians(angle)) + y

            if p <= 0.5:
                d.ellarc(self.mRadius, self.mRadius, 0, 0, 1, dx, dy)
            else:
                d.ellarc(self.mRadius, self.mRadius, 0, 1, 1, dx, dy)

            e.append(SVGdraw.path(d,
                                  stroke="rgb(%i,%i,%i)" % SVGTree.RED,
                                  fill="rgb(%i,%i,%i)" % SVGTree.RED,
                                  stroke_width=self.mStrokeWidth))

        else:
            pass

        return e
예제 #42
0
파일: SVGTree.py 프로젝트: santayana/cgat
    def getElements(self, node_id, x, y):

        e = []
        colour = self.getColour(node_id, x, y)

        if self.mPlotSymbol == "circle":
            e.append(
                SVGdraw.circle(x + self.mFontSize / 2,
                               y,
                               self.mFontSize / 2,
                               stroke="rgb(%i,%i,%i)" % BLACK,
                               fill="rgb(%i,%i,%i)" % colour))

        elif self.mPlotSymbol == "square":
            e.append(
                SVGdraw.rect(x,
                             y - self.mFontSize / 2,
                             self.mFontSize,
                             self.mFontSize,
                             stroke="rgb(%i,%i,%i)" % BLACK,
                             fill="rgb(%i,%i,%i)" % colour))

        return e
예제 #43
0
    def writeGrid(self):
        """add grid lines."""

        # print last circle
        self.mRadius = self.mRadiusMax + self.mRadiusIncrement
        self.addSeparator()

        # print separators
        for contig, pos in self.contig2Position.items():

            pos = self.getPosition(contig, "+", 0)

            angle = self.getAngle(pos)

            x, y = self.getPosOnArc(angle, self.mRadius)

            e = SVGdraw.line(self.mDataMiddleX,
                             self.mDataMiddleY,
                             x,
                             y,
                             stroke="rgb(%i,%i,%i)" % BLACK)

            self.addElement(e, self.mPlaneGrid)

            x, y = self.getPosOnArc(
                angle, (self.mRadius + self.mRadiusStart) / 2)

            e = SVGdraw.text(x,
                             y,
                             contig,
                             self.mHeaderFontSize,
                             self.mHeaderFont,
                             stroke="rgb(%i,%i,%i)" % BLACK,
                             text_anchor="start",
                             transform="rotate(%i,%i,%i)" % (angle, x, y))

            self.addElement(e)
예제 #44
0
    def writeGrid(self):
        """add grid lines."""

        # print last circle
        self.mRadius = self.mRadiusMax + self.mRadiusIncrement
        self.addSeparator()

        # print separators
        for contig, pos in self.contig2Position.items():

            pos = self.getPosition(contig, "+", 0)

            angle = self.getAngle(pos)

            x, y = self.getPosOnArc(angle, self.mRadius)

            e = SVGdraw.line(self.mDataMiddleX,
                             self.mDataMiddleY,
                             x,
                             y,
                             stroke="rgb(%i,%i,%i)" % BLACK)

            self.addElement(e, self.mPlaneGrid)

            x, y = self.getPosOnArc(angle,
                                    (self.mRadius + self.mRadiusStart) / 2)

            e = SVGdraw.text(x,
                             y,
                             contig,
                             self.mHeaderFontSize,
                             self.mHeaderFont,
                             stroke="rgb(%i,%i,%i)" % BLACK,
                             text_anchor="start",
                             transform="rotate(%i,%i,%i)" % (angle, x, y))

            self.addElement(e)
예제 #45
0
파일: png2svg.py 프로젝트: CGATOxford/cgat
    def writeFooter(self):
        """write footer.

        The footer contains the legend.
        """
        if self.mTitle:
            e = SVGdraw.text(self.mPageWidth / 2,
                             self.mTitleFontSize,
                             self.mTitle,
                             self.mTitleFontSize,
                             self.mTitleFont,
                             stroke="rgb(%i,%i,%i)" % BLACK,
                             text_anchor="middle")

            self.addElement(e)
예제 #46
0
파일: png2svg.py 프로젝트: yangjl/cgat
    def writeFooter(self):
        """write footer.

        The footer contains the legend.
        """
        if self.mTitle:
            e = SVGdraw.text(self.mPageWidth / 2,
                             self.mTitleFontSize,
                             self.mTitle,
                             self.mTitleFontSize,
                             self.mTitleFont,
                             stroke="rgb(%i,%i,%i)" % BLACK,
                             text_anchor="middle")

            self.addElement(e)
예제 #47
0
파일: SVGTree.py 프로젝트: santayana/cgat
    def getElements(self, node_id, x1, x2, y):

        e = []
        e.append(
            SVGdraw.line(x1,
                         y,
                         x2,
                         y,
                         stroke="rgb(%i,%i,%i)" % BLACK,
                         stroke_width=1))

        e += self.mDecorator1.getElements(node_id, x1, x2, y)
        e += self.mDecorator2.getElements(node_id, x1, x2, y + self.mFontSize)

        return e
예제 #48
0
    def plotLinksForPair(self, species1, species2, colour=BLACK, plane=0):
        """plot links."""

        if species1 not in self.mOrthologs or species2 not in self.mOrthologs:
            return

        for group1 in self.mOrthologs[species1]:
            if group1 in self.mOrthologs[species2]:
                for g1 in self.mOrthologs[species1][group1]:
                    for g2 in self.mOrthologs[species2][group1]:
                        x1, y1 = self.mMapGene2Coord[g1]
                        x2, y2 = self.mMapGene2Coord[g2]

                        e = SVGdraw.line(x1, y1, x2, y2, stroke="rgb(%i,%i,%i)" % colour)

                        self.addElement(e, plane=plane)
예제 #49
0
    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
        e.append(SVGdraw.text(x_label, y_label,
                              self.mTree.node(node_id).data.taxon,
                              self.mFontSize,
                              self.mFont,
                              stroke="rgb(%i,%i,%i)" % BLACK,
                              font_style=self.mFontStyle,
                              text_anchor="left"))
        return e
예제 #50
0
    def writeFooter(self):
        """write footer.

        The footer contains the legend.
        """

        x = self.mHeaderWidth + self.mBlockSize

        group_ids = self.mMapGroup2Colour.keys()
        group_ids.sort()
        ncolumns = 10
        l = int(math.ceil(len(group_ids) / float(ncolumns)))

        max_d = 0

        for a in range(0, ncolumns):

            y = self.mHeaderHeight + self.mDataHeight
            for b in range(a * l, min(len(group_ids), (a + 1) * l)):

                group_id = group_ids[b]

                e = self.plotGene(x, y, group_id=group_id)
                self.addElement(e)

                t = str(group_id)

                max_d = max(
                    len(t) * self.mLegendFontSize * self.mFontFactor, max_d)

                e = SVGdraw.text(x + self.mBlockSize +
                                 self.mLegendVerticalSeparator,
                                 y,
                                 str(group_id),
                                 self.mLegendFontSize,
                                 self.mLegendFont,
                                 stroke="rgb(%i,%i,%i)" % BLACK,
                                 text_anchor="left")

                self.addElement(e)

                y += self.mLegendFontSize + self.mLegendHorizontalSeparator

            x += max_d + 2 * self.mBlockSize + \
                2 * self.mLegendVerticalSeparator
예제 #51
0
파일: SVGTree.py 프로젝트: santayana/cgat
    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
        e.append(
            SVGdraw.text(x_label,
                         y_label,
                         self.mTree.node(node_id).data.taxon,
                         self.mFontSize,
                         self.mFont,
                         stroke="rgb(%i,%i,%i)" % BLACK,
                         font_style=self.mFontStyle,
                         text_anchor="left"))
        return e
예제 #52
0
    def writeFooter(self):
        """write footer.

        The footer contains the legend.
        """

        x = self.mHeaderWidth + self.mBlockSize

        group_ids = self.mMapGroup2Colour.keys()
        group_ids.sort()
        ncolumns = 10
        l = int(math.ceil(len(group_ids) / float(ncolumns)))

        max_d = 0

        for a in range(0, ncolumns):

            y = self.mHeaderHeight + self.mDataHeight
            for b in range(a * l, min(len(group_ids), (a + 1) * l)):

                group_id = group_ids[b]

                e = self.plotGene(x, y, group_id=group_id)
                self.addElement(e)

                t = str(group_id)

                max_d = max(len(t) * self.mLegendFontSize * self.mFontFactor, max_d)

                e = SVGdraw.text(
                    x + self.mBlockSize + self.mLegendVerticalSeparator,
                    y,
                    str(group_id),
                    self.mLegendFontSize,
                    self.mLegendFont,
                    stroke="rgb(%i,%i,%i)" % BLACK,
                    text_anchor="left",
                )

                self.addElement(e)

                y += self.mLegendFontSize + self.mLegendHorizontalSeparator

            x += max_d + 2 * self.mBlockSize + 2 * self.mLegendVerticalSeparator
예제 #53
0
파일: plot_synteny.py 프로젝트: yangjl/cgat
    def writeColLabels(self):
        """write column headers."""

        y = self.mHeaderHeight

        for contig in self.mSortedContigs1:

            if contig not in self.mMapContig2Start1: continue

            x = self.mHeaderWidth + self.mMapContig2Start1[contig]
            e = SVGdraw.text(x,
                             y,
                             contig,
                             self.mLabelFontSize * self.mFontSizeFactor,
                             self.mLabelFont,
                             stroke="rgb(%i,%i,%i)" % BLACK,
                             text_anchor="start")

            self.addElement(e)
예제 #54
0
파일: plot_synteny.py 프로젝트: siping/cgat
    def writeColLabels( self ):
        """write column headers."""

        y = self.mHeaderHeight

        for contig in self.mSortedContigs1:

            if contig not in self.mMapContig2Start1: continue
            
            x = self.mHeaderWidth + self.mMapContig2Start1[contig] 
            e = SVGdraw.text( x,
                              y,
                              contig,
                              self.mLabelFontSize * self.mFontSizeFactor,
                              self.mLabelFont,
                              stroke = "rgb(%i,%i,%i)" % BLACK,
                              text_anchor = "start" )

            self.addElement( e )
예제 #55
0
    def writeColHeaders(self):
        """write row headers."""

        current_x = self.mColWidth / 2
        current_y = self.mHeaderHeight
        i = 0
        for name in self.mColNames:
            e = SVGdraw.text(current_x,
                             current_y,
                             name,
                             self.mHeaderFontSize,
                             self.mHeaderFont,
                             stroke="rgb(%i,%i,%i)" % BLACK,
                             text_anchor="start",
                             transform="rotate(-45,%i,%i)" % (current_x, current_y))

            self.addElement(e)

            current_x += self.mColWidth
예제 #56
0
    def writeColHeaders( self ):
        """write row headers."""

        current_x = self.mColWidth / 2
        current_y = self.mHeaderHeight
        i = 0
        for name in self.mColNames:
            e = SVGdraw.text( current_x,
                              current_y,
                              name,
                              self.mHeaderFontSize,
                              self.mHeaderFont,
                              stroke = "rgb(%i,%i,%i)" % BLACK,
                              text_anchor = "start",
                              transform="rotate(-45,%i,%i)" %( current_x, current_y ))

            self.addElement(e)
            
            current_x += self.mColWidth
예제 #57
0
    def writeFooter(self):
        """write footer."""

        current_x = self.mFooterX
        current_y = self.mFooterY

        if self.mFooter:

            current_y += max(self.mFooterFontSize,
                             self.mMaxBoxSize) + self.mSeparator

            e = SVGdraw.text(self.mPageWidth / 2,
                             current_y + self.mFooterFontSize,
                             self.mFooter,
                             self.mFooterFontSize,
                             self.mFooterFont,
                             stroke="rgb(%i,%i,%i)" % BLACK,
                             text_anchor="middle")

            self.addElement(e)
예제 #58
0
    def writeFooter(self):
        """write footer."""

        current_x = self.mFooterX
        current_y = self.mFooterY

        if self.mFooter:

            current_y += max(self.mFooterFontSize,
                             self.mMaxBoxSize) + self.mSeparator

            e = SVGdraw.text(self.mPageWidth / 2,
                             current_y + self.mFooterFontSize,
                             self.mFooter,
                             self.mFooterFontSize,
                             self.mFooterFont,
                             stroke="rgb(%i,%i,%i)" % BLACK,
                             text_anchor="middle")

            self.addElement(e)
예제 #59
0
파일: plot_synteny.py 프로젝트: yangjl/cgat
    def writeRowLabels(self):
        """write column headers."""

        x = self.mHeaderWidth

        for contig in self.mSortedContigs2:

            if contig not in self.mMapContig2Start2: continue

            y = self.mHeaderHeight + self.mMapContig2Start2[
                contig] + self.mMapContig2Size2[contig]
            e = SVGdraw.text(x,
                             y,
                             contig,
                             self.mLabelFontSize * self.mFontSizeFactor,
                             self.mLabelFont,
                             stroke="rgb(%i,%i,%i)" % BLACK,
                             text_anchor="start",
                             transform="rotate(-90,%i,%i)" % (x, y))

            self.addElement(e)
예제 #60
0
    def writeRowHeaders(self):
        """write row headers."""

        current_x = self.mDataWidth + self.mSeparator

        current_y = self.mHeaderHeight + self.mSeparator + self.mHeaderFontSize

        for name in self.mRowNames:
            e = SVGdraw.text(current_x,
                             current_y,
                             name,
                             self.mHeaderFontSize,
                             self.mHeaderFont,
                             stroke="rgb(%i,%i,%i)" % BLACK,
                             text_anchor="start")

            self.addElement(e)

            current_y += self.mRowHeight

        self.mHeaderWidth = max(map(len,
                                    self.mRowNames)) * self.mHeaderFontSize / 2