Skip to content

OpenVariant | New feature Multiple fields for a single plugin #51

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 14 commits into
base: develop
Choose a base branch
from

Conversation

dmartmillan
Copy link
Collaborator

Be able to create plugins that modify multiple fields, added along with a small example and documentation explaining the use case.

The main change is how Annotation (annotation._annotation) is stored:

Previous version (each plugin has its individual field):

{
'TYPE': ('PLUGIN', ....), 
'POSITION': ('PLUGIN', ....), 
'VARIANT': ('PLUGIN', ....), 
'HGVS': ('INTERNAL',, ....)
}

Now (a tuple is created as a key, it encompass multiple fields to a unique plugin function):

{
('TYPE', 'POSITION', 'VARIANT'): ('PLUGIN', ....), 
'HGVS': ('INTERNAL', ....)
}

With this simple change, we can distinguish which fields are grouped under each plugin. This makes parsing straightforward, as we know which plugin function to execute and which fields it should apply to.
In the first example, the plugin is executed three times in separate processes; now, it runs just once for multiple fields.

The filedSource was discarted because the field from inputs can be used as follow (and being access by the plugin):

annotation:
- type: plugin
  plugin: HGVS_decoder
  field: 
  - TYPE
  - POSITION
  - VARIANT
- type: internal
  field: HGVS
  fieldSource:
  - 'HGVS Consequence'
  - HGVSp

@dmartmillan dmartmillan self-assigned this May 18, 2025
@dmartmillan dmartmillan added documentation Improvements or additions to documentation enhancement New feature or request labels May 18, 2025
@dmartmillan dmartmillan linked an issue May 18, 2025 that may be closed by this pull request
@dmartmillan
Copy link
Collaborator Author

Not merge yet!
Need to add more docs info and fix a bug on the plugin example.

@dmartmillan
Copy link
Collaborator Author

Ready!

@FedericaBrando FedericaBrando requested a review from Copilot May 21, 2025 15:32
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces support for plugins that target multiple output fields in a single invocation by keying plugins on tuples of field names and updating parsing, annotation loading, and documentation accordingly.

  • Key changes:
    • Annotation storage now uses tuple keys for multi‐field plugins and updates header extraction and parsing in variant.py.
    • Annotation loader in annotation.py now accepts list‐style field declarations and normalizes into tuple keys.
    • Examples and documentation expanded to show multi‐field plugin usage and fixed sample notebooks/READMEs.

Reviewed Changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
openvariant/variant/variant.py Updated header and parser logic to unpack tuple‐keyed plugins.
openvariant/annotation/annotation.py Accept list fields, normalize keys, and verify columns.
examples/plugin_system/HGVS_decoder/init.py Added example init for multi‐field plugin (syntax needs fix).
examples/plugin_system/README.md Updated README with new plugins section (spelling error).
docs/user_guide/annotation_structure.rst Expanded docs for multi‐field plugin (duplicate word issue).
Comments suppressed due to low confidence (2)

examples/plugin_system/HGVS_decoder/init.py:1

  • This import syntax is invalid; change to from .multi_test import Multi_testPlugin to correctly import the plugin class.
import .multi_test from Multi_testPlugin

docs/examples/plugin_system/HGVS_decoder/init.py:1

  • Invalid import syntax in docs example; update to from .multi_test import Multi_testPlugin to match real code.
import .multi_test from Multi_testPlugin

dmartmillan and others added 5 commits May 22, 2025 13:53
Co-authored-by: Copilot <[email protected]>
…-plugin' of github.com:bbglab/openvariant into 50-openvariant-new-feature-multiple-fields-for-a-single-plugin
@dmartmillan
Copy link
Collaborator Author

Can we merge it? or it needs revision?

@FedericaBrando
Copy link
Member

Hi David, it still needs revision and testing. We've been quite busy lately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

OpenVariant New Feature | Multiple fields for a single plugin
2 participants