本文整理汇总了Python中pbcommand.models.report.Report.to_dict方法的典型用法代码示例。如果您正苦于以下问题:Python Report.to_dict方法的具体用法?Python Report.to_dict怎么用?Python Report.to_dict使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pbcommand.models.report.Report
的用法示例。
在下文中一共展示了Report.to_dict方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_to_dict_multi
# 需要导入模块: from pbcommand.models.report import Report [as 别名]
# 或者: from pbcommand.models.report.Report import to_dict [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))
示例2: test_to_dict
# 需要导入模块: from pbcommand.models.report import Report [as 别名]
# 或者: from pbcommand.models.report.Report import to_dict [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'])
示例3: test_version_and_changelist
# 需要导入模块: from pbcommand.models.report import Report [as 别名]
# 或者: from pbcommand.models.report.Report import to_dict [as 别名]
def test_version_and_changelist(self):
r = Report('example')
d = r.to_dict()
log.info("\n" + pformat(d))
fields = ('version', 'uuid', 'plotGroups', 'tables', 'dataset_uuids')
for field in fields:
self.assertTrue(field in d)
示例4: test_bad_01
# 需要导入模块: from pbcommand.models.report import Report [as 别名]
# 或者: from pbcommand.models.report.Report import to_dict [as 别名]
def test_bad_01(self):
r = Report("stuff", uuid=1234)
d = r.to_dict()
def fx():
# when the Report validation is enabled, use to_json
# r.to_json()
return validate_report(d)
self.assertRaises(IOError, fx)
示例5: test_to_dict_multi
# 需要导入模块: from pbcommand.models.report import Report [as 别名]
# 或者: from pbcommand.models.report.Report import to_dict [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))
示例6: test_version_and_changelist
# 需要导入模块: from pbcommand.models.report import Report [as 别名]
# 或者: from pbcommand.models.report.Report import to_dict [as 别名]
def test_version_and_changelist(self):
r = Report('example')
d = r.to_dict()
log.info("\n" + pformat(d))
self.assertTrue('_version' in d)
self.assertTrue('_changelist' in d)
# Not used anymore. The all version information is encoded in _version.
# that should be sufficient.
# self.assertTrue(isinstance(d['_changelist'], int))
rx = re.compile(r'[0-9]*\.[0-9]*')
self.assertIsNotNone(rx.search(d['_version']))
示例7: to_motifs_report
# 需要导入模块: from pbcommand.models.report import Report [as 别名]
# 或者: from pbcommand.models.report.Report import to_dict [as 别名]
def to_motifs_report(gff_file, motif_summary_csv, output_dir):
_d = dict(g=gff_file, c=motif_summary_csv, o=output_dir)
log.info(
"starting Motif report generations with: \nGFF:{g}\nCSV:{c}\ndir:{o}".format(**_d))
# Generate a histogram with lines corresponding to motifs
kinData = readMotifFiles(gff_file)
plot_group = addQmodMotifHist(motif_summary_csv, kinData, output_dir)
plot_groups = [plot_group]
motif_records = _motif_csv_to_records(motif_summary_csv)
table = to_table(motif_records)
r = Report(Constants.R_ID, plotgroups=plot_groups, tables=[table])
log.debug(pformat(r.to_dict(), indent=4))
return r