Writing plugins
The parsomics
plugin system enables users to easily add support for
processing the output files of new protein annotation tools.
Conventions
Versioning and formatting
The parsomics plugins must follow the versioning and formatting conventions of the parsomics project. Read them here.
Only add data to certain tables
As you may have already read in the user documentation, parsomics
plugins can
only populate existing database tables. Plugins should only add data to the
following tables:
tool
run
source
proteinannotationfile
proteinannotationentry
Plugins should never remove data from any table.
Use utils from parsomics-core
The parsomics-core
library exposes many utils (i.e. utilities) for plugin
development. The purpose of these utils is to avoid duplicate work by
centralizing a functions that are needed by many plugins. For example, plugins
commonly need to search proteins by their names, so parsomics-core
exposes
search_protein_by_name
.
These utils also help in standardizing the codebase across different plugins,
improving maintainability, and allows distributing features and fixes to many
plugins at once (as long as they update their parsomics-core
dependency).
These utils can be imported from parsomics-core.plugin_utils
. For example:
from parsomics_core.plugin_utils import search_protein_by_name
Tutorial
The parsomics
team has put together a tutorial for developing protein
annotation plugins. Throughout the tutorial, you will recreate the
parsomics-plugin-interpro
plugin, which adds support for
InterproScan protein
annotations. You can check out the complete source code of the plugin on
GitLab.
Each step of the tutorial contains "Explanation" and "Hands on" sections. The
"Hands on" section puts the explanation into practice, implementing part of the
parsomics-plugin-interpro
plugin. By the end of the tutorial, you should have a working copy of that
plugin, as well as all the knowledge you need to create your own!
📄️ Step 1: Get the template
The parsomics project has a template for protein annotation plugins, with all
📄️ Step 2: Initialize a package
Packaging is a crucial first step in plugin development. It's what makes your
📄️ Step 3: Edit validated_file.py
This file implements a class whose purpose is to distinguish files that should
📄️ Step 4: Edit file_factory.py
This file implements a class whose purpose is to create a list of all files
📄️ Step 5: Edit parser.py
This file implements a class whose purpose is parsing the data of a single
📄️ Step 6: Edit processor.py
This file implements a class that brings the file factory and parser together.
📄️ Step 7: Edit populate.py
This file implements the function that serves as the "entry point" to the
📄️ Step 8: Edit plugin_initializer.py
This file creates the object that wraps all of the plugin's functionality.
📄️ Step 9: Edit __init__.py
This file initializes the plugin's package.
📄️ Step 10: Format the codebase
Run formatters to make sure your codebase complies with the code styling rules
📄️ Step 11: Publish to PyPI
Publishing your plugin to PyPI makes it is easily installable for other people.
📄️ Step 12: Submit for review
Make your plugin more discoverable by submitting it to the parsomics plugin