def makeCalculator(self, *args, **kw):
     if args:
         discontinued('method', "makeCalculator(aligns)", '1.6')
         # and shadowing a quite different superclass method.
         self.setAlignment(*args)
         if getattr(self, 'used_as_calculator', False):
             warnings.warn('PC used as two different calculators', stacklevel=2)
         self.used_as_calculator = True
         return self
     else:
         return super(_LF, self).makeCalculator(**kw)
示例#2
0
 def drawToPDF(self, filename, total_width=None, height=None, **kw):
     # Matches, as far as possible, old ReportLab version
     
     if total_width is not None:
         kw['width'] = total_width / 72
     kw2 = {}
     for (k,v) in kw.items():
         if k in ['wraps', 'border', 'withTrackLabelColumn']:
             discontinued('argument', "%s" % k, '1.6')
         else:
             kw2[k] = v
     kw2['format'] = 'pdf'
     if height:
         kw2['height'] = height / 72
     return self.drawToFile(filename, **kw2)
示例#3
0
    def drawToPDF(self, filename, total_width=None, height=None, **kw):
        # Matches, as far as possible, old ReportLab version

        if total_width is not None:
            kw['width'] = total_width / 72
        kw2 = {}
        for (k, v) in kw.items():
            if k in ['wraps', 'border', 'withTrackLabelColumn']:
                discontinued('argument', "%s" % k, '1.6')
            else:
                kw2[k] = v
        kw2['format'] = 'pdf'
        if height:
            kw2['height'] = height / 72
        return self.drawToFile(filename, **kw2)
示例#4
0
 def makeFigure(self, window=20, join_gaps=None, min_gap=0, **kw):
     """Drawing of a line segment based dotplot with annotated axes"""
     # hard to pick min_gap without knowing pixels per base, and
     # matplotlib is reasonably fast anyway, so:
     if join_gaps is not None:
         discontinued('argument', 'join_gaps', '1.6')
     ax = comparison_display(self.seq1d, self.seq2d, **kw)
     (fwd, rev) = self._calc_lines(window, None, min_gap)
     for (lines, colour) in [(fwd, 'blue'), (rev, 'red')]:
         vertices = []
         for segment in lines:
             vertices.extend(segment)
         if vertices:
             ops = [Path.MOVETO, Path.LINETO] * (len(vertices) // 2)
             path = Path(vertices, ops)
             patch = PathPatch(path, edgecolor=colour, fill=False)
             ax.add_patch(patch)
     return ax.get_figure()
示例#5
0
 def makeFigure(self, window=20, join_gaps=None, min_gap=0, **kw):
     """Drawing of a line segment based dotplot with annotated axes"""
     # hard to pick min_gap without knowing pixels per base, and
     # matplotlib is reasonably fast anyway, so:
     if join_gaps is not None:
         discontinued('argument', 'join_gaps', '1.6')
     ax = comparison_display(self.seq1d, self.seq2d, **kw)
     (fwd, rev) = self._calc_lines(window, None, min_gap)
     for (lines, colour) in [(fwd, 'blue'), (rev, 'red')]:
         vertices = []
         for segment in lines:
             vertices.extend(segment)
         if vertices:
             ops = [Path.MOVETO, Path.LINETO] * (len(vertices)//2)
             path = Path(vertices, ops)
             patch = PathPatch(path, edgecolor=colour, fill=False)
             ax.add_patch(patch)
     return ax.get_figure()
    def getStatisticsAsDict(self,
                            with_parent_names=True,
                            with_edge_names=False):
        """Returns a dictionary containing the statistics for each edge of the
        tree, and any other information provided by the substitution model. The
        dictionary is keyed at the top-level by parameter name, and then by
        edge.name.
        
        Arguments:
            - with_edge_names: if True, an ordered list of edge names is
              included under the top-level key 'edge.names'. Default is
              False.
        """

        discontinued(
            'method', "'getStatisticsAsDict' "
            "use 'getParamValueDict(['edge'])' is nearly equivalent", '1.6')

        stats_dict = self.getParamValueDict(['edge'])

        if hasattr(self.model, 'scale_masks'):
            for predicate in self.model.scale_masks:
                stats_dict[predicate] = self.getScaledLengths(predicate)

        edge_vector = [e for e in self._tree.getEdgeVector() if not e.isroot()]

        # do the edge names
        if with_parent_names:
            parents = {}
            for edge in edge_vector:
                if edge.Parent.isroot():
                    parents[edge.Name] = "root"
                else:
                    parents[edge.Name] = str(edge.Parent.Name)
            stats_dict["edge.parent"] = parents

        if with_edge_names:
            stats_dict['edge.name'] = (
                [e.Name for e in edge_vector if e.istip()] +
                [e.Name for e in edge_vector if not e.istip()])

        return stats_dict
 def getStatisticsAsDict(self, with_parent_names=True,
             with_edge_names=False):
     """Returns a dictionary containing the statistics for each edge of the
     tree, and any other information provided by the substitution model. The
     dictionary is keyed at the top-level by parameter name, and then by
     edge.name.
     
     Arguments:
         - with_edge_names: if True, an ordered list of edge names is
           included under the top-level key 'edge.names'. Default is
           False.
     """
     
     discontinued('method', "'getStatisticsAsDict' "
             "use 'getParamValueDict(['edge'])' is nearly equivalent", 
             '1.6')
     
     stats_dict = self.getParamValueDict(['edge'])
     
     if hasattr(self.model, 'scale_masks'):
         for predicate in self.model.scale_masks:
             stats_dict[predicate] = self.getScaledLengths(predicate)
     
     edge_vector = [e for e in self._tree.getEdgeVector() if not e.isroot()]
     
     # do the edge names
     if with_parent_names:
         parents = {}
         for edge in edge_vector:
             if edge.Parent.isroot():
                 parents[edge.Name] = "root"
             else:
                 parents[edge.Name] = str(edge.Parent.Name)
         stats_dict["edge.parent"] = parents
     
     if with_edge_names:
         stats_dict['edge.name'] = (
                 [e.Name for e in edge_vector if e.istip()] +
                 [e.Name for e in edge_vector if not e.istip()])
     
     return stats_dict
示例#8
0
def asReportlabTable(header, formatted_table, total_width=476, table_style = None):
    """Returns a reportlab table instance.
    
    Arguments:
        - header: series with column headings
        - formatted_table: a two dimensional structure (list/tuple) of strings
          previously formatted to the same width within a column.
        - total_width: table width
        - table_style: reportlab compliant table style settings.
    """
    discontinued('function', 'asReportlabTable', 1.5)
    from reportlab.platypus import Table as reportlabTable
    from reportlab.lib import colors
    if not table_style:
        table_style = [('GRID', (0,0), (-1,-1), 0.5, colors.grey),
                       ('BOX', (0,0), (-1,-1), 0.5, colors.black),
                       ('BACKGROUND', (0,0), (-1,0), colors.lightgrey),
                       ('VALIGN', (0,0), (-1,-1), 'MIDDLE'),]
    formatted_table = formatted_table[:]
    header = header[:]
    formatted_table.insert(0, header)
    return reportlabTable(formatted_table, total_width/len(formatted_table[0]),
                            style = table_style)