Пример #1
0
    def get_pairing_contents(self, index: int, width: int, height: int) -> str:
        """ Generate an SVG comparing the query to a single hit cluster

            Arguments:
                index: the index of the hit
                width: the width of the SVG
                height: the height of the SVG

            Returns:
                a string containing the SVG XML
        """
        svg = Svg(x=0, y=0, width=width, height=height)
        viewbox = "0 0 %d %d" % (width, height)
        svg.set_viewBox(viewbox)
        svg.set_preserveAspectRatio("none")
        max_length = max([len(self.query_cluster), len(self.hits[index])])
        scaling = (width - 20) / max_length
        for i, cluster in enumerate([self.query_cluster, self.hits[index]]):
            for group in cluster.get_svg_groups(
                    v_offset=50 * i,
                    h_offset=(max_length - len(cluster)) // 2,
                    scaling=scaling,
                    colours=self.colour_lookup):
                svg.addElement(group)
        return svg.getXML()
Пример #2
0
    def makePathSvg(self) -> Svg:
        """
        Returns the main `Svg` object for Path view.

        """
        viewbox = "0 0 %s %s" % (self.w, self.h)
        path_svg = Svg(width=self.w, height=self.h)
        path_svg.set_viewBox(viewbox)
        path_svg.set_preserveAspectRatio("xMinYMid meet")
        path_svg.setAttribute('id', "Cadnano_Path")  # Main layer name
        path_svg.addElement(self.defs)
        path_svg.addElement(self.g_pathgridlines)  # bottom layer
        path_svg.addElement(self.g_patholigos)
        path_svg.addElement(self.g_pathendpoints)
        path_svg.addElement(self.g_pathvirtualhelices)
        path_svg.addElement(self.g_pathvirtualhelixlabels)  # top layer
        path_svg.addElement(self.g_pathinsertions)
        path_svg.addElement(self.g_pathskips)
        if self.cn_doc.sequence_applied:
            path_svg.addElement(self.g_pathsequences)
        else:
            print('No sequences were applied. Max oligo length: %s' % self.cn_doc.max_oligo_length, file=sys.stderr)

        path_svg.save(self.output_path)

        return path_svg
Пример #3
0
    def get_overview_contents(self, width: int, height: int) -> str:
        """ Generate an SVG comparing the query to all hit cluster

            Arguments:
                width: the width of the SVG
                height: the height of the SVG

            Returns:
                a string containing the SVG XML
        """
        svg = Svg(x=0, y=0, width=width, height=height)
        viewbox = "0 0 %d %d" % (width, height)
        svg.set_viewBox(viewbox)
        svg.set_preserveAspectRatio("none")
        scaling = (width - 20) / self.max_length  # -20 for margins
        offset = (self.max_length - len(self.query_cluster)) // 2
        for group in self.query_cluster.get_svg_groups(
                h_offset=offset,
                scaling=scaling,
                colours=self.colour_lookup,
                overview=True,
                prefix=self.prefix):
            svg.addElement(group)
        for index, cluster in enumerate(self.hits):
            for group in cluster.get_svg_groups(
                    v_offset=50 * (index + 1),
                    h_offset=(self.max_length - len(cluster)) // 2,
                    scaling=scaling,
                    colours=self.colour_lookup,
                    overview=True,
                    prefix=self.prefix):
                svg.addElement(group)
        return svg.getXML()
Пример #4
0
 def makeSliceSvg(self) -> Svg:
     slice_svg = Svg(width=self.w, height=self.h)
     viewbox = "0 0 %s %s" % (self.w, self.h)
     slice_svg.set_viewBox(viewbox)
     slice_svg.set_preserveAspectRatio("xMidYMid meet")
     slice_svg.setAttribute('id', "Cadnano_Slice")  # Main layer name
     slice_svg.addElement(self.g_slicevirtualhelices)  # bottom layer
     slice_svg.addElement(self.g_slicevirtualhelixlabels)  # top layer
     slice_svg.save(self.output_path)