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


Python Table.add_column方法代码示例

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


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

示例1: test_to_dict

# 需要导入模块: from pbcommand.models.report import Table [as 别名]
# 或者: from pbcommand.models.report.Table import add_column [as 别名]
    def test_to_dict(self):
        """
        The id of report sub elements is prepended with the id of the parent
        element when to_dict is called.
        """
        r = Report('redfang')
        a = Attribute('a', 'b')
        a2 = Attribute('a2', 'b2')
        r.add_attribute(a)
        r.add_attribute(a2)

        pg = PlotGroup('pgid')
        pg.add_plot(Plot('pid', 'anImg'))
        pg.add_plot(Plot('pid2', 'anImg2'))
        r.add_plotgroup(pg)

        t = Table('tabid')
        t.add_column(Column('c1'))
        r.add_table(t)

        d = r.to_dict()

        log.debug("\n" + pformat(d))

        self.assertEqual('redfang', d['id'])
        self.assertEqual('redfang.a', d['attributes'][0]['id'])
        self.assertEqual('redfang.a2', d['attributes'][1]['id'])
        self.assertEqual('redfang.pgid', d['plotGroups'][0]['id'])
        self.assertEqual('redfang.pgid.pid', d['plotGroups'][0]['plots'][0]['id'])
        self.assertEqual('redfang.pgid.pid2', d['plotGroups'][0]['plots'][1]['id'])

        self.assertEqual('redfang.tabid', d['tables'][0]['id'])
        self.assertEqual('redfang.tabid.c1', d['tables'][0]['columns'][0]['id'])
开发者ID:mpkocher,项目名称:pbcommand,代码行数:35,代码来源:test_models_report.py

示例2: test_to_dict_multi

# 需要导入模块: from pbcommand.models.report import Table [as 别名]
# 或者: from pbcommand.models.report.Table import add_column [as 别名]
    def test_to_dict_multi(self):
        """
        Multiple complex elements.
        The id of report sub elements is prepended with the id of the parent
        element when to_dict is called.
        """
        r = Report('redfang')
        a = Attribute('a', 'b')
        a2 = Attribute('a2', 'b2')
        r.add_attribute(a)
        r.add_attribute(a2)

        pg = PlotGroup('pgid')
        pg.add_plot(Plot('pid', 'anImg'))
        pg.add_plot(Plot('pid2', 'anImg2'))
        r.add_plotgroup(pg)

        pg = PlotGroup('pgid2')
        pg.add_plot(Plot('pid2', 'anImg2'))
        pg.add_plot(Plot('pid22', 'anImg22'))
        r.add_plotgroup(pg)

        t = Table('tabid')
        t.add_column(Column('c1'))
        r.add_table(t)

        t = Table('tabid2')
        t.add_column(Column('c2'))
        r.add_table(t)

        d = r.to_dict()

        log.debug(str(d))

        self.assertEqual('redfang', d['id'])
        self.assertEqual('redfang.a', d['attributes'][0]['id'])
        self.assertEqual('redfang.a2', d['attributes'][1]['id'])

        self.assertEqual('redfang.pgid', d['plotGroups'][0]['id'])
        self.assertEqual('redfang.pgid.pid', d[
                         'plotGroups'][0]['plots'][0]['id'])
        self.assertEqual('redfang.pgid.pid2', d[
                         'plotGroups'][0]['plots'][1]['id'])

        self.assertEqual('redfang.pgid2', d['plotGroups'][1]['id'])
        self.assertEqual('redfang.pgid2.pid2', d[
                         'plotGroups'][1]['plots'][0]['id'])
        self.assertEqual('redfang.pgid2.pid22', d[
                         'plotGroups'][1]['plots'][1]['id'])

        self.assertEqual('redfang.tabid', d['tables'][0]['id'])
        self.assertEqual('redfang.tabid.c1', d['tables'][
                         0]['columns'][0]['id'])

        self.assertEqual('redfang.tabid2', d['tables'][1]['id'])
        self.assertEqual('redfang.tabid2.c2', d[
                         'tables'][1]['columns'][0]['id'])

        log.info(repr(r))
        self.assertIsNotNone(repr(r))
开发者ID:natechols,项目名称:pbcommand,代码行数:62,代码来源:test_models_report.py

示例3: test_get_table_by_id_with_bad_id

# 需要导入模块: from pbcommand.models.report import Table [as 别名]
# 或者: from pbcommand.models.report.Table import add_column [as 别名]
    def test_get_table_by_id_with_bad_id(self):
        r = Report('redfang')
        t1 = Table('tabid1')
        t1.add_column(Column('c1'))
        r.add_table(t1)

        bad_t = r.get_table_by_id('id_that_does_not_exist')
        self.assertIsNone(bad_t)
开发者ID:natechols,项目名称:pbcommand,代码行数:10,代码来源:test_models_report.py

示例4: test_get_table_by_id

# 需要导入模块: from pbcommand.models.report import Table [as 别名]
# 或者: from pbcommand.models.report.Table import add_column [as 别名]
    def test_get_table_by_id(self):
        r = Report('redfang')
        t1 = Table('tabid1')
        t1.add_column(Column('c1'))
        r.add_table(t1)

        t = r.get_table_by_id('tabid1')
        self.assertEqual(t, t1)
开发者ID:natechols,项目名称:pbcommand,代码行数:10,代码来源:test_models_report.py

示例5: test_get_column_by_id

# 需要导入模块: from pbcommand.models.report import Table [as 别名]
# 或者: from pbcommand.models.report.Table import add_column [as 别名]
    def test_get_column_by_id(self):
        r = Report('redfang')
        t1 = Table('tabid1')
        c1 = Column('c1')
        t1.add_column(c1)
        r.add_table(t1)

        c = r.get_table_by_id('tabid1').get_column_by_id('c1')
        self.assertEqual(c, c1)
开发者ID:natechols,项目名称:pbcommand,代码行数:11,代码来源:test_models_report.py

示例6: test_to_dict_multi

# 需要导入模块: from pbcommand.models.report import Table [as 别名]
# 或者: from pbcommand.models.report.Table import add_column [as 别名]
    def test_to_dict_multi(self):
        """
        Multiple complex elements.
        The id of report sub elements is prepended with the id of the parent
        element when to_dict is called.
        """
        r = Report("redfang")
        a = Attribute("a", "b")
        a2 = Attribute("a2", "b2")
        r.add_attribute(a)
        r.add_attribute(a2)

        pg = PlotGroup("pgid")
        pg.add_plot(Plot("pid", "anImg"))
        pg.add_plot(Plot("pid2", "anImg2"))
        r.add_plotgroup(pg)

        pg = PlotGroup("pgid2")
        pg.add_plot(Plot("pid2", "anImg2"))
        pg.add_plot(Plot("pid22", "anImg22"))
        r.add_plotgroup(pg)

        t = Table("tabid")
        t.add_column(Column("c1"))
        r.add_table(t)

        t = Table("tabid2")
        t.add_column(Column("c2"))
        r.add_table(t)

        d = r.to_dict()

        log.debug(str(d))

        self.assertEqual("redfang", d["id"])
        self.assertEqual("redfang.a", d["attributes"][0]["id"])
        self.assertEqual("redfang.a2", d["attributes"][1]["id"])

        self.assertEqual("redfang.pgid", d["plotGroups"][0]["id"])
        self.assertEqual("redfang.pgid.pid", d["plotGroups"][0]["plots"][0]["id"])
        self.assertEqual("redfang.pgid.pid2", d["plotGroups"][0]["plots"][1]["id"])

        self.assertEqual("redfang.pgid2", d["plotGroups"][1]["id"])
        self.assertEqual("redfang.pgid2.pid2", d["plotGroups"][1]["plots"][0]["id"])
        self.assertEqual("redfang.pgid2.pid22", d["plotGroups"][1]["plots"][1]["id"])

        self.assertEqual("redfang.tabid", d["tables"][0]["id"])
        self.assertEqual("redfang.tabid.c1", d["tables"][0]["columns"][0]["id"])

        self.assertEqual("redfang.tabid2", d["tables"][1]["id"])
        self.assertEqual("redfang.tabid2.c2", d["tables"][1]["columns"][0]["id"])

        log.info(repr(r))
        self.assertIsNotNone(repr(r))
开发者ID:tperelmuter,项目名称:pbcommand,代码行数:56,代码来源:test_models_report.py

示例7: _get_consensus_table_and_attributes

# 需要导入模块: from pbcommand.models.report import Table [as 别名]
# 或者: from pbcommand.models.report.Table import add_column [as 别名]
def _get_consensus_table_and_attributes(ref_data, reference_entry):
    """
    Get a tuple: Table and list of Attributes
    :param ref_data: (dict) dict of data pulled from alignment_summary.gff
    :param reference_entry: (pbsystem.io.reference_entry) reference entry
    :return: tuple (pbreports.io.model.Table, [pbreports.io.model.Attributes])
    """
    table = Table('consensus_table', 'Consensus Calling Results')
    table.add_column(Column('contig_name', 'Reference'))
    table.add_column(Column('contig_len', 'Reference Length'))
    table.add_column(Column('bases_called', 'Bases Called'))
    table.add_column(Column('concordance', 'Consensus Accuracy'))
    table.add_column(Column('coverage', 'Base Coverage'))

    ordered_ids = _ref_ids_ordered_by_len(ref_data)

    sum_lengths = 0.0
    mean_bases_called = 0
    mean_concord = 'NA'
    mean_coverage = 0

    for seqid in ordered_ids:
        contig = reference_entry.get_contig(seqid)

        length = float(ref_data[seqid][LENGTH])
        gaps = float(ref_data[seqid][GAPS])
        errors = float(ref_data[seqid][ERR])
        cov = float(ref_data[seqid][COV])

        sum_lengths += length
        bases_called = 1.0 - gaps / length
        mean_bases_called += bases_called * length

        concord = 'NA'
        if length != gaps:

            log.info('length {f}'.format(f=length))
            log.info('gaps {f}'.format(f=gaps))
            log.info('errors {f}'.format(f=errors))

            concord = 1.0 - errors / (length - gaps)
            if mean_concord is 'NA':
                mean_concord = concord * length
            else:
                mean_concord += concord * length

        coverage = cov / length
        mean_coverage += coverage * length

        # table shows values for each contig
        table.add_data_by_column_id('contig_name', contig.name)
        table.add_data_by_column_id('contig_len', length)
        table.add_data_by_column_id('bases_called', bases_called)
        table.add_data_by_column_id('concordance', concord)
        table.add_data_by_column_id('coverage', coverage)

    mean_contig_length = sum_lengths / len(ordered_ids)
    mean_bases_called = mean_bases_called / sum_lengths
    if mean_concord is not 'NA':
        mean_concord = mean_concord / sum_lengths
    mean_coverage = mean_coverage / sum_lengths

    attributes = [Attribute(id_, val, Constants.ATTR_LABELS[id_])
        for id_, val in [
            (Constants.MEAN_CONTIG_LENGTH, mean_contig_length),
            (Constants.MEAN_BASES_CALLED, mean_bases_called),
            (Constants.MEAN_CONCORDANCE, mean_concord),
            (Constants.MEAN_COVERAGE, mean_coverage),
            (Constants.LONGEST_CONTIG, ordered_ids[0])]]

    return table, attributes
开发者ID:skinner,项目名称:pbreports,代码行数:73,代码来源:variants.py


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