-
Notifications
You must be signed in to change notification settings - Fork 0
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to build a plugin starting from the template repo. #1
base: main
Are you sure you want to change the base?
Conversation
readme = "README.md" | ||
requires-python = ">=3.8" | ||
version = "0.1" | ||
|
||
dependencies = ["sourmash>=4.8.0,<5"] | ||
dependencies = ["sourmash>=4.6.1,<5"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is needed because sourmash v4.8 isn't yet released.
|
||
[metadata] | ||
license = { text = "BSD 3-Clause License" } | ||
|
||
# CTB note: do not need both reader and writer. | ||
|
||
[project.entry-points."sourmash.load_from"] | ||
xyz_reader = "sourmash_plugin_xyz:load_sketches" | ||
test1_reader = "sourmash_plugin_test1:load_sketches" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the sourmash_plugin_test1
needs to match the project name, above.
@@ -15,10 +15,12 @@ | |||
# | |||
|
|||
def load_sketches(location, *args, **kwargs): | |||
if location and location.endswith('.xyz'): | |||
if location and location.endswith('.test1.sig'): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this plugin handles loading for all files with extension .test1.sig
.
@@ -37,17 +39,20 @@ def __init__(self, location): | |||
def matches(self, location): | |||
# match anything that is not None or "" | |||
if location: | |||
return location.endswith('.xyz') | |||
notify(f"*** test1 plugin matches {location}! using!") | |||
return location.endswith('.test1.sig') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and this plugin handles saving for all files with extension .test1.sig
.
src/sourmash_plugin_test1.py
Outdated
class ScriptsCommand_XYZ: | ||
command = "xyz" | ||
description = "do something xyz" | ||
class ScriptsCommand_Test1: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This adds a command-line command sourmash scripts test1 <filename_test> -x/--xyz
.
This is an example of writing a sourmash plugin, starting from sourmash-bio/sourmash_plugin_template.
Look under "Files changed" to see the aggregate changes.
How to install and run
I install this branch with:
and then:
outputs
and
shows:
demonstrating that the plugin is loading and running properly! 馃帀