Skip to main content

A report generating system for PyPPL

Project description

pyppl_report

Pypi Github PyPPL PythonVers Travis building Codacy Codacy coverage

A report generating system for PyPPL

Installation

Requires pandoc 2.7+ (and wkhtmltopdf 0.12.4+ when creating PDF reports)

pyppl_report requires pandoc/wkhtmltopdf to be installed in $PATH

pip install pyppl_report

Usage

Specifiation of template

pPyClone.config.report_template = """
# {{report.title}}

PyClone[1] is a tool using Probabilistic model for inferring clonal population
structure from deep NGS sequencing.

![Similarity matrix]({{path.join(job.o.outdir, "plots/loci/similarity_matrix.svg")}})

```table
caption: Clusters
file: "{{path.join(job.o.outdir, "tables/cluster.tsv")}}"
rows: 10
```

[1]: Roth, Andrew, et al. "PyClone: statistical inference of clonal population structure in cancer."
Nature methods 11.4 (2014): 396.
"""

# or use a template file

pPyClone.config.report_template = "file:/path/to/template.md"

Generating report

PyPPL().start(pPyClone).run().report(
	'/path/to/report',
	title='Clonality analysis using PyClone',
	template='bootstrap'
)

# or save report in a directory
PyPPL(name='Awesome-pipeline').start(pPyClone).run().report('/path/to/')
# report generated at ./Awesome-pipeline.report.html

Command line tool:

> pyppl report
Description:
  Convert a Markdown file to report.

Usage:
  pyppl report --in <LIST> [OPTIONS]

Required options:
  -i, --in <LIST>           - The input file.

Optional options:
  -o, --out <AUTO>          - The output file. Default: <in>.html
  -n, --nonstand [BOOL]     - Non-standalone mode. Save static files in  <filename of --out>.files  separately. \
                              Default: False
      --filter <LIST>       - The filters for pandoc Default: []
      --toc <INT>           - The depth of heading levels to put in TOC. 0 to disable. Default: 3
      --title <STR>         - The title of the document.
                              If the first element of the document is H1 (#), this will be ignored \
                              and the text of H1 will be used as title.
                              If the title is specified as "# Title", then a title will be added \
                              anyway. Default: Untitled document
      --template <STR>      - The template to use. Either standard template name or full path to \
                              template file. Default: bootstrap
  -h, -H, --help            - Show help message and exit.

Extra data for rendering

You can generate a toml file named job.report.data.toml under <job.outdir> with extra data to render the report template. Beyond that, proc attributes and args can also be used.

For example: job.report.data.toml:

description = 'A awesome report for job 1'

Then in your template, you can use it:

## {{jobs[0].description}}

Built-in templates

Check them to see features those templates support:

How does it work?

Following figure demonstrates how the plugin works:

How it works

Each process that you want to report, will need to have a template assigned with pXXX.config.report_template. Like scripts, you may prefice it with file:, and then followed by an absolute path to the template or a relative one to where it's assigned. You may even assign a template using a direct string. A process with no template assign will be hidden from the report.

You can use the data from the jobs or the process to render the template.

The report for each process will then be assembled by the plugin, and converted using pandoc with a default template and some built-in filters. Finally, your report will be a standalone html file.

For larget reports, non-standaone reports are recommended: .report(standalone=False, ...)

Environments

You may pass values to process envs to control report content:

pXXX.config.report_envs.foo = "bar"

Then in you can use it in the report template:

pXXX.config.report_template = """
The value of foo is "{{foo}}".
"""

Preserved envs variables

We have 4 preserved variables under pXXX.envs:

# Control the level of headings in the
pXXX.config.report_envs.level = 1
# Content to add before the template
pXXX.config.report_envs.pre = ''
# Content to add after the template
pXXX.config.report_envs.post = ''
# The title of the process report
pXXX.config.report_envs.title = None

Process report levels

No matter at which level you want to put this process report in the entire report, you need to each heading from level 1, then according to pXXX.config.report_envs.level, the headings will be shifted to corresponding level. For example, with pXXX.config.report_envs.level = 2, following template

# Section
## Subsection
content

will be rendered into:

## Section
### Subsection
content

It will not affect comments in code blocks such as:

```
## some comments
```

Adding extra contents to process report

You may add extra contents to the process report. For example, if you put the process report at level 2, then you probably need a level-1 heading. For previous example, if you have pXXX.config.report_envs.level = 2, without a level-2 heading, the entire report will look like:

## Section
### Subsection
content

Then you missed a level-1 heading, which will make your report look wired. Here you can specify a level-1 heading with pXXX.config.report_envs.pre = '# I am H1':

# I am H2
## Section
### Subsection
content

You may also append something to the process report with pXXX.config.report_envs.post

Headings added by pre and post will NOT be adjusted by pXXX.config.report_envs.level

Title of the process report

By default, if not assigned or assigned with None, the process description will be used as the title of the process report. Of course you can overwrite it with pXXX.config.report_envs.title.

# by default
pXXX = Proc(desc = 'Some analysis')
# ... other necessary settings
pXXX.report = '# {{report.title}}'

will be rendered as:

# Some analysis

with pXXX.config.report_envs.title = 'An amazing analysis', we will have:

# An amazing analysis

Making your report flexiable

You can interpolate some variables in the templates to make your report flexiable. For example, you may want to hide an image in some cases:

# {{report title}}

I have enough details.

{% if report.get('showimage') %}
![Image](./path/to/image)
{% endif %}

Then you can show that image in the report only when you have pXXX.config.report_envs.showimage = True.

Change log

Change log

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyppl_report-0.6.1.tar.gz (2.1 MB view details)

Uploaded Source

Built Distribution

pyppl_report-0.6.1-py3-none-any.whl (2.2 MB view details)

Uploaded Python 3

File details

Details for the file pyppl_report-0.6.1.tar.gz.

File metadata

  • Download URL: pyppl_report-0.6.1.tar.gz
  • Upload date:
  • Size: 2.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.5 CPython/3.7.1 Linux/4.15.0-1028-gcp

File hashes

Hashes for pyppl_report-0.6.1.tar.gz
Algorithm Hash digest
SHA256 617de6c9ec02d7864df93f9d4def9c924a834cf30b9abf1952c9808b142bdb1c
MD5 c7d15746154f35b28a98c807b3f18dcd
BLAKE2b-256 6e42c6993725e38b784d0f311276ee81890efca6ffedc2bb7d9d8de8b2de8be8

See more details on using hashes here.

File details

Details for the file pyppl_report-0.6.1-py3-none-any.whl.

File metadata

  • Download URL: pyppl_report-0.6.1-py3-none-any.whl
  • Upload date:
  • Size: 2.2 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.5 CPython/3.7.1 Linux/4.15.0-1028-gcp

File hashes

Hashes for pyppl_report-0.6.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d305186e92bda016b90f4a88fa30b6d58c23990f4a7c08c0bd70e13fec8c8d56
MD5 e3e47cb2634cfd9907cfbf97ee6113a0
BLAKE2b-256 a0dae3113c2c17d63bb98fe3a01847724beb63523e7fd13bb1fde3e1d8375caa

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page