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.0.tar.gz (2.1 MB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for pyppl_report-0.6.0.tar.gz
Algorithm Hash digest
SHA256 4951ea47e567ec41d12f417cd732d6388e29af89a991cd03b8d2f60726808214
MD5 e48fa59e086c8718a8d0fe57c2178d20
BLAKE2b-256 64b93fc1b86b05dc5e2792bb5c8046f0ba1b2b5d0714a0434a437862398a597a

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for pyppl_report-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cac617870881ec0d572f4d16775833a4a987e8e7be842fc907a19207a5f44e1f
MD5 fc7dfd164c948fc5429293e905ebc2a8
BLAKE2b-256 c13d1fee10950f3f2b8524da156052ab6e6bf30af06118c99b7d5784f54439ba

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