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


Python report.Report类代码示例

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


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

示例1: make_variants_report

def make_variants_report(aln_summ_gff, variants_gff, reference, max_contigs_to_plot, report, output_dir, dpi=72, dumpdata=True):
    """
    Entry to report.
    :param aln_summ_gff: (str) path to alignment_summary.gff
    :param variants_gff: (str) path to variants_gff
    :param reference: (str) path to reference_dir
    :param max_contigs_to_plot: (int) max number of contigs to plot
    """
    _validate_inputs([('aln_summ_gff', aln_summ_gff),
                      ('variants_gff', variants_gff),
                      ('reference', reference)])

    # reference entry & top contings
    ref = openReference(reference)
    top_contigs = get_top_contigs_from_ref_entry(ref, max_contigs_to_plot)

    # extract gff data from files
    ref_data, contig_variants = _extract_alignment_summ_data(
        aln_summ_gff, top_contigs)
    _append_variants_gff_data(ref_data, variants_gff)

    # make report objects
    table, atts = _get_consensus_table_and_attributes(ref_data, ref)
    plotgroup = _create_variants_plot_grp(
        top_contigs, contig_variants, output_dir)

    rpt = Report(Constants.R_ID,
                 plotgroups=[plotgroup],
                 attributes=atts,
                 tables=[table],
                 dataset_uuids=(ReferenceSet(reference).uuid,))

    rpt = spec.apply_view(rpt)
    rpt.write_json(os.path.join(output_dir, report))
    return rpt
开发者ID:lpp1985,项目名称:lpp_Script,代码行数:35,代码来源:variants.py

示例2: test_to_dict

    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:tperelmuter,项目名称:pbcommand,代码行数:33,代码来源:test_models_report.py

示例3: make_report

def make_report(in_fn, out_dir='.', bounds=None, nolegend=False,
                reference=None, dpi=60, name=None):
    """AlignmentToPng Report

    Convert an input bam or DataSet XML file to a figure of Concordance vs.
    Subread Length.

    Args:
        in_fn: the bam, DataSet XML or cmp.h5 file to turn into a length vs
               concordance plot
        out_dir: the output directory to be used with the file name or default
        name: the file name to be used with the outdir or default (no full
              path filenames!)
        bounds: the figure limits (in xmin:xmax:ymin:ymax)
        nolegend: exclude the figure legend
        reference: the reference to use in the figure. Default of all
                   references
        dpi: the dots per inch (resolution) of the figure
    """

    data = _read_in_file(in_fn, reference)
    report = Report('alignment_to_png_report')

    if not name:
        name = '%s.png' % os.path.splitext(os.path.basename(in_fn))[0]
    png_fn = os.path.join(out_dir, name)
    _make_plot(data, png_fn, bounds, dpi, nolegend)
    plot_group = PlotGroup(Constants.PLOT_GROUP_ID,
                           plots=[Plot('alignment_to_png_plot',
                                       os.path.basename(png_fn))])
    report.add_plotgroup(plot_group)
    return report
开发者ID:lpp1985,项目名称:lpp_Script,代码行数:32,代码来源:rainbow.py

示例4: make_control_report

def make_control_report(control_cmph5, filtered_subreads_csv, report,
                        output_dir, dpi, dumpdata):
    """
    Entry to report.
    :param control_cmph5: (str) path to control_reads.cmp.h5
    :param filtered_subreads_csv: (str) path to filtered_subread_summary.csv
    """
    _validate_inputs(control_cmph5, filtered_subreads_csv)
    name, control_reads = _get_control_reads(control_cmph5)
    filtered_reads = _get_filtered_reads(filtered_subreads_csv)
    control_data, sample_data = _process_reads(control_reads, filtered_reads)
    nr = _get_num_control_reads(control_data)
    if nr == 0:
        # Not sure this ever happens, but logic exists in makeControlReport.py
        r = _get_error_report()
        r.write_json(os.path.join(output_dir, report))
        return
    atts = _get_attributes(name, control_data, sample_data)
    pgs = [_get_plot_group_score(control_data,
                                 sample_data, output_dir),
           _get_plot_group_length(control_data,
                                  sample_data, output_dir)]
    r = Report(meta_rpt.id, attributes=atts, plotgroups=pgs)
    r = meta_rpt.apply_view(r)
    r.write_json(os.path.join(output_dir, report))
开发者ID:mdsmith,项目名称:pbreports,代码行数:25,代码来源:control.py

示例5: make_topvariants_report

def make_topvariants_report(gff, reference, how_many, batch_sort_size, report,
                            output_dir, is_minor_variants_rpt=False):
    """
    Entry to report.
    :param gff: (str) path to variants.gff (or rare_variants.gff). Note, could also be *.gz
    :param reference: (str) path to reference dir
    :param how_many: (int)
    :param batch_sort_size: (int)
    :param report: (str) report name
    :param batch_sort_size: (str) output dir
    :param is_minor_variants_rpt: (bool) True to create a minor top variant report. False to
    create a variant report.
    """
    _validate_inputs(gff, reference, how_many, batch_sort_size)

    table_builder = None
    if is_minor_variants_rpt:
        table_builder = MinorVariantTableBuilder()
    else:
        table_builder = VariantTableBuilder()
    vf = VariantFinder(gff, reference, how_many, batch_sort_size)
    top = vf.find_top()
    for v in top:
        table_builder.add_variant(v)

    r = Report(Constants.R_ID, tables=[table_builder.table],
               dataset_uuids=(ReferenceSet(reference).uuid,))
    r = spec.apply_view(r)
    r.write_json(os.path.join(output_dir, report))
    return 0
开发者ID:natechols,项目名称:pbreports,代码行数:30,代码来源:top_variants.py

示例6: run_reference_dataset_report

def run_reference_dataset_report(reference_ds, output_json):
    """

    :param reference_ds:
    :type reference_ds: ReferenceSet

    :param output_json:
    :return:
    """
    output_dir = os.path.dirname(output_json)
    host = socket.getfqdn()

    attributes = _dataset_to_attribute_reports(reference_ds)
    _add = attributes.append

    _add(Attribute("host", host, name="Host"))
    _add(Attribute("task_dir", output_dir, name="Task Directory"))

    fasta_file = reference_ds.toExternalFiles()[0]

    plot_groups = try_fasta_to_plot_group(fasta_file, output_dir)
    report = Report("dev_diagnostic_report",
                    attributes=attributes,
                    plotgroups=plot_groups,
                    dataset_uuids=[reference_ds.uuid])

    report.write_json(output_json)
    return 0
开发者ID:knyquist,项目名称:pbsmrtpipe,代码行数:28,代码来源:dev.py

示例7: _example_main

def _example_main(input_file, output_file, **kwargs):
    """
    This func should be imported from your python package.

    This should have *no* dependency on the pbcommand IO, such as the RTC/TC models.
    """

    # This is just for test purposes
    log.info("Running example main with {i} {o} kw:{k}".format(i=input_file,
                                                               o=output_file,
                                                               k=kwargs))

    # Open dset CSV. Store absolute path of each alignment set.
    dset_paths = _get_dset_paths(input_file[0])

    # Open plots CSV. Store names of plots to produce.
    plots_to_generate = _get_plots_to_generate(input_file[1])

    dsets_kpis = {}
    for f in dset_paths:
        dset = openDataSet(dset_paths[f]['aset'])
        subsampled_dset = _subsample_alignments(dset)
        dsets_kpis[f] = _getKPIs(dset, subsampled_dset)

    figures = []
    # figure tuple has form (plot_group_id, plot_id, figure)
    if 'accuracy_vs_readlength' in plots_to_generate:
        figures.append(('accuracy', 'accuracy_vs_readlength', accuracy_plots._plot_accuracy_vs_readlength(dsets_kpis)))
    if 'accuracy' in plots_to_generate:
        figures.append(('accuracy', 'accuracy', accuracy_plots._plot_accuracy_distribution(dsets_kpis)))
    if 'accuracy_boxplot' in plots_to_generate:
        figures.append(('accuracy', 'accuracy_boxplot', accuracy_plots._plot_accuracy_boxplots(dsets_kpis)))

    all_plots = {} # dictionary of plots. keys are groups
    for plot_group, plot_id, fig in figures:
        if plot_group not in all_plots.keys():
            all_plots[plot_group] = []
        plot(fig, filename='{i}.html'.format(i=plot_id), show_link=False, auto_open=False)
        phantomjs_driver.set_window_size(1920, 1080)
        phantomjs_driver.get('{i}.html'.format(i=plot_id))
        phantomjs_driver.save_screenshot('{i}.png'.format(i=plot_id))
        phantomjs_driver.get('{i}.html'.format(i=plot_id))
        phantomjs_driver.save_screenshot('{i}_thumb.png'.format(i=plot_id))
        os.remove('{i}.html'.format(i=plot_id))
        plot_path = '{i}.png'.format(i=plot_id)
        thumb_path = '{i}_thumb.png'.format(i=plot_id)
        all_plots[plot_group].append(Plot(plot_id, plot_path, thumbnail=thumb_path))

    plot_groups = []
    for plot_group_title in all_plots.keys():
        plot_group = PlotGroup( plot_group_title, plots=all_plots[plot_group_title])
        plot_groups.append(plot_group) 

    report = Report('mh_toy', tables=(), plotgroups=plot_groups, attributes=())
    report.write_json( output_file )

    phantomjs_driver.quit()

    return 0
开发者ID:knyquist,项目名称:pbsmrtpipe-examples,代码行数:59,代码来源:mh_toy.py

示例8: test_get_plotgroup_by_id

    def test_get_plotgroup_by_id(self):
        r = Report('redfang')
        pg1 = PlotGroup('pgid1')
        pg1.add_plot(Plot('pid1', 'anImg'))
        r.add_plotgroup(pg1)

        pg = r.get_plotgroup_by_id('pgid1')
        self.assertEqual(pg, pg1)
开发者ID:natechols,项目名称:pbcommand,代码行数:8,代码来源:test_models_report.py

示例9: test_get_plotgroup_by_id_with_bad_id

    def test_get_plotgroup_by_id_with_bad_id(self):
        r = Report('redfang')
        pg1 = PlotGroup('pgid1')
        pg1.add_plot(Plot('pid1', 'anImg'))
        r.add_plotgroup(pg1)

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

示例10: test_get_table_by_id_with_bad_id

    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,代码行数:8,代码来源:test_models_report.py

示例11: test_get_table_by_id

    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,代码行数:8,代码来源:test_models_report.py

示例12: test_version_and_changelist

    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)
开发者ID:natechols,项目名称:pbcommand,代码行数:8,代码来源:test_models_report.py

示例13: test_get_attribute_by_id

    def test_get_attribute_by_id(self):
        a = Attribute("a", "b")
        a2 = Attribute("b", "b2")
        attributes = [a, a2]
        r = Report("redfang", attributes=attributes)

        a1 = r.get_attribute_by_id("a")

        self.assertEqual(a, a1)
开发者ID:tperelmuter,项目名称:pbcommand,代码行数:9,代码来源:test_models_report.py

示例14: test_get_column_by_id

    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,代码行数:9,代码来源:test_models_report.py

示例15: test_bad_01

    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)
开发者ID:natechols,项目名称:pbcommand,代码行数:10,代码来源:test_models_report.py


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