GithubHelp home page GithubHelp logo

lars20070 / example-plugin Goto Github PK

View Code? Open in Web Editor NEW

This project forked from multiqc/example-plugin

0.0 0.0 0.0 421 KB

A miniature example of a MultiQC plugin.

Home Page: http://multiqc.info

License: MIT License

Python 100.00%

example-plugin's Introduction

Example MultiQC Plugin

A miniature example of a MultiQC plugin

This example repository contains the following code to help you get started with writing your own MultiQC plugin.

It should be used in addition to the main MultiQC documentation: http://multiqc.info/docs/#coding-with-multiqc

If you have any questions, please get in touch on Gitter: https://gitter.im/ewels/MultiQC


MultiQC


When to write a plugin

This example plugin contains both custom code and a MultiQC module for parsing content into reports.

MultiQC modules can either be written as part of the core MultiQC program, or in a stand-alone plugin. If your module is for a publicly available tool, please add it to the main program and contribute your code via a pull request (see the contributing instructions).

If your module is for something very niche, which no-one else can use, then it's best to write it as part of a custom plugin. The process is almost identical, though it keeps the code bases separate.

Overview of files

  • setup.py
    • Where the setuptools plugin hooks are defined. This is where you tell MultiQC where to find your code.
    • This file also defines how your plugin should be installed, including required python packages.
  • example_plugin/
    • Installable Python packages are typically put into a directory with the same name.
  • example_plugin/__init__.py
    • Python packages need an __init__.py file in every directory. Here, these are mostly empty (except the one in the my_example folder, which contains a shortcut to make the import statement shorter).
    • If you prefer, you can put all code in these files and just reference the directory name only.
  • example_plugin/cli.py
    • Additional command line parameters to add to MultiQC
  • example_plugin/custom_code.py
    • File to hold custom functions that can tie into the main MultiQC execution flow.
    • In this file, we define some new config defaults, including the search patterns used by the example module
  • example_plugin/modules/my_example/
    • This folder contains a minimal MultiQC module which will execute along with all other MultiQC modules (as defined by the setup.py hook).

Usage

To use this code, you need to install MultiQC and then your code. For example:

pip install MultiQC
python setup.py install

Use python setup.py develop if you're actively working on the code - then you don't need to rerun the installation every time you make an edit (though you still do if you change anything in setup.py).

Disabling the plugin

In this example plugin, I have defined a single additional command line flag - --disable-example-plugin. When specified, it sets a new MultiQC config value to True. This is checked in every plugin function; the function then returns early if it's True.

In this way, we can effectively disable the plugin code and allow native MultiQC execution. Note that a similar approach could be used to enable a custom plugin or feature.

example-plugin's People

Contributors

ewels avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.