本文整理汇总了Python中pbcommand.models.report.Report.add_attribute方法的典型用法代码示例。如果您正苦于以下问题:Python Report.add_attribute方法的具体用法?Python Report.add_attribute怎么用?Python Report.add_attribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pbcommand.models.report.Report
的用法示例。
在下文中一共展示了Report.add_attribute方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_to_dict
# 需要导入模块: from pbcommand.models.report import Report [as 别名]
# 或者: from pbcommand.models.report.Report import add_attribute [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'])
示例2: make_sat_report
# 需要导入模块: from pbcommand.models.report import Report [as 别名]
# 或者: from pbcommand.models.report.Report import add_attribute [as 别名]
def make_sat_report(aligned_reads_file, mapping_stats_report, variants_report, report, output_dir):
"""
Entry to report.
:param aligned_reads_file: (str) path to aligned_reads.xml
:param mapping_stats_report: (str) path to mapping stats json report
:param variants_report: (str) path to variants report
"""
_validate_inputs([('aligned_reads_file', aligned_reads_file),
('mapping_stats_report', mapping_stats_report),
('variants_report', variants_report)])
d_map = _get_mapping_stats_data(mapping_stats_report)
reads, inst = _get_reads_info(aligned_reads_file)
d_bam = _get_read_hole_data(reads, inst)
d_var = _get_variants_data(variants_report)
ds = AlignmentSet(aligned_reads_file)
rpt = Report(Constants.R_ID, dataset_uuids=(ds.uuid,))
rpt.add_attribute(Attribute(Constants.A_INSTRUMENT,
d_bam[Constants.A_INSTRUMENT]))
rpt.add_attribute(Attribute(Constants.A_COVERAGE,
d_var[Constants.A_COVERAGE]))
rpt.add_attribute(Attribute(Constants.A_CONCORDANCE,
d_var[Constants.A_CONCORDANCE]))
rpt.add_attribute(Attribute(Constants.A_READLENGTH,
d_map[Constants.A_READLENGTH]))
rpt.add_attribute(Attribute(Constants.A_READS, d_bam[Constants.A_READS]))
rpt = spec.apply_view(rpt)
rpt.write_json(os.path.join(output_dir, report))
示例3: test_to_dict_multi
# 需要导入模块: from pbcommand.models.report import Report [as 别名]
# 或者: from pbcommand.models.report.Report import add_attribute [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))
示例4: make_sat_report
# 需要导入模块: from pbcommand.models.report import Report [as 别名]
# 或者: from pbcommand.models.report.Report import add_attribute [as 别名]
def make_sat_report(aligned_reads_file, mapping_stats_report, variants_report, report, output_dir):
"""
Entry to report.
:param aligned_reads_file: (str) path to aligned_reads.xml
:param mapping_stats_report: (str) path to mapping stats json report
:param variants_report: (str) path to variants report
"""
_validate_inputs([('aligned_reads_file', aligned_reads_file),
('mapping_stats_report', mapping_stats_report),
('variants_report', variants_report)])
d_map = _get_mapping_stats_data(mapping_stats_report)
reads, inst = _get_reads_info(aligned_reads_file)
d_bam = _get_read_hole_data(reads, inst)
d_var = _get_variants_data(variants_report)
rpt = Report('sat')
rpt.add_attribute(Attribute('instrument', d_bam['instrument'],
Constants.ATTR_LABELS["instrument"]))
rpt.add_attribute(Attribute('coverage', d_var['coverage'],
Constants.ATTR_LABELS["coverage"]))
rpt.add_attribute(Attribute('accuracy', d_var['accuracy'],
Constants.ATTR_LABELS["accuracy"]))
rpt.add_attribute(Attribute('mapped_readlength_mean', d_map[
'mapped_readlength_mean'], Constants.ATTR_LABELS["mapped_readlength_mean"]))
rpt.add_attribute(Attribute('reads_in_cell', d_bam[
'reads_in_cell'], Constants.ATTR_LABELS["reads_in_cell"]))
rpt.write_json(os.path.join(output_dir, report))
示例5: test_to_dict_multi
# 需要导入模块: from pbcommand.models.report import Report [as 别名]
# 或者: from pbcommand.models.report.Report import add_attribute [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: make_polished_assembly_report
# 需要导入模块: from pbcommand.models.report import Report [as 别名]
# 或者: from pbcommand.models.report.Report import add_attribute [as 别名]
def make_polished_assembly_report(report, gff, fastq, output_dir):
"""
Entry to report.
:param gff: (str) path to alignment_summary.gff
:param fastq: (str) path to polished fastq file
:param report: (str) report name
create a polished assembly report.
"""
log.info("Starting version {f} v{x}".format(
x=__version__, f=os.path.basename(__file__)))
log.debug("Loading {f}".format(f=fastq))
contigs = _get_contigs(fastq)
log.debug("Loading {f}".format(f=gff))
_get_contig_coverage(gff, contigs)
log.debug("Computing and creating plots")
cvqp = _coverage_vs_quality_plot(contigs, output_dir)
pgrp = PlotGroup('coverage_based',
title='Contig Coverage vs Confidence',
thumbnail=cvqp.thumbnail,
plots=[cvqp])
rep = Report('polished_assembly')
rep.add_attribute(
Attribute(Constants.A_N_CONTIGS, len(contigs),
Constants.ATTR_LABELS[Constants.A_N_CONTIGS]))
read_lengths = [c.length for c in contigs.values()]
read_lengths.sort()
rep.add_attribute(_get_att_max_contig_length(read_lengths))
rep.add_attribute(_get_att_n_50_contig_length(read_lengths))
rep.add_attribute(_get_att_sum_contig_lengths(read_lengths))
rep.add_plotgroup(pgrp)
rep.write_json(os.path.join(output_dir, report))
_write_coverage_vs_quality_csv(contigs, output_dir)
return 0
示例7: test_illegal_id
# 需要导入模块: from pbcommand.models.report import Report [as 别名]
# 或者: from pbcommand.models.report.Report import add_attribute [as 别名]
def test_illegal_id(self):
"""Ids must be alphanumberic with underscores"""
with self.assertRaises(PbReportError):
r = Report('redfang')
r.add_attribute(Attribute('a b', 'b'))
r.add_attribute(Attribute('a', 'c'))
示例8: test_duplicate_ids
# 需要导入模块: from pbcommand.models.report import Report [as 别名]
# 或者: from pbcommand.models.report.Report import add_attribute [as 别名]
def test_duplicate_ids(self):
"""Can't add elements with the same id."""
with self.assertRaises(PbReportError):
r = Report('redfang')
r.add_attribute(Attribute('a', 'b'))
r.add_attribute(Attribute('a', 'c'))