base
Base classes for tool-specific progress parsing plugins.
Classes¶
PluginMetadata
dataclass
¶
Validated metadata for a tool progress plugin.
This dataclass provides structured access to plugin metadata with
validation. Use from_plugin() to create an instance from a plugin.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
The tool name (e.g., 'bwa', 'samtools', 'star'). |
api_version |
int
|
The plugin API version this plugin supports. |
patterns |
tuple[str, ...]
|
Command patterns that indicate this tool is being used. |
description |
str
|
Optional description of what this plugin parses. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If validation fails during construction. |
Example
metadata = PluginMetadata.from_plugin(my_plugin) print(f"Plugin: {metadata.name} (API v{metadata.api_version})")
Source code in snakesee/plugins/base.py
Functions¶
__post_init__ ¶
Validate metadata fields.
Source code in snakesee/plugins/base.py
from_plugin
classmethod
¶
from_plugin(plugin: ToolProgressPlugin) -> PluginMetadata
Create metadata from a plugin instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
plugin
|
ToolProgressPlugin
|
The plugin to extract metadata from. |
required |
Returns:
| Type | Description |
|---|---|
PluginMetadata
|
Validated PluginMetadata instance. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If plugin metadata is invalid. |
AttributeError
|
If plugin is missing required attributes. |
Source code in snakesee/plugins/base.py
is_compatible ¶
Check if the plugin is compatible with the current API version.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
current_api_version
|
int | None
|
The API version to check against. Defaults to PLUGIN_API_VERSION. |
None
|
Returns:
| Type | Description |
|---|---|
bool
|
True if the plugin is compatible, False otherwise. |
Source code in snakesee/plugins/base.py
ToolProgress
dataclass
¶
Progress information extracted from a tool's log output.
Attributes:
| Name | Type | Description |
|---|---|---|
items_processed |
int
|
Number of items processed so far. |
items_total |
int | None
|
Total number of items to process (None if unknown). |
unit |
str
|
Unit of items (e.g., "reads", "alignments", "variants"). |
percent_complete |
float | None
|
Percentage complete (0-100), None if unknown. |
estimated_remaining_seconds |
float | None
|
Estimated seconds remaining, None if unknown. |
Source code in snakesee/plugins/base.py
ToolProgressPlugin ¶
Bases: ABC
Abstract base class for tool-specific progress parsers.
Subclasses implement parsing logic for specific bioinformatics tools (e.g., BWA, STAR, samtools) to extract progress information from logs.
Plugin Versioning
Plugins can declare which API version they support via the
plugin_api_version property. If not specified, version 1 is assumed.
Plugins requiring a newer API than the current version will be skipped.
Example implementation::
class BWAPlugin(ToolProgressPlugin):
@property
def tool_name(self) -> str:
return "bwa"
@property
def tool_patterns(self) -> list[str]:
return ["bwa mem", "bwa-mem2"]
def can_parse(self, rule_name: str, log_content: str) -> bool:
return "bwa" in rule_name.lower() or "[M::mem_" in log_content
def parse_progress(self, log_content: str) -> ToolProgress | None:
# Parse BWA-specific progress patterns
...
Source code in snakesee/plugins/base.py
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 | |
Attributes¶
plugin_api_version
property
¶
The plugin API version this plugin was written for.
Override to declare compatibility with a specific API version. If not overridden, version 1 is assumed.
tool_name
abstractmethod
property
¶
Identifier for this tool (e.g., 'bwa', 'samtools', 'star').
Should be lowercase and match common tool naming conventions.
tool_patterns
property
¶
Common command patterns that indicate this tool is being used.
Used for initial filtering before detailed log parsing. Override in subclasses for tool-specific patterns.
Functions¶
can_parse
abstractmethod
¶
Determine if this plugin can parse the given log content.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rule_name
|
str
|
Name of the Snakemake rule. |
required |
log_content
|
str
|
Content of the rule's log file. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if this plugin can extract progress from this log. |
Source code in snakesee/plugins/base.py
parse_progress
abstractmethod
¶
parse_progress(log_content: str) -> ToolProgress | None
Extract progress information from log content.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
log_content
|
str
|
Content of the rule's log file. |
required |
Returns:
| Type | Description |
|---|---|
ToolProgress | None
|
ToolProgress if progress could be extracted, None otherwise. |
Source code in snakesee/plugins/base.py
parse_progress_from_file ¶
parse_progress_from_file(log_path: Path) -> ToolProgress | None
Extract progress from a log file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
log_path
|
Path
|
Path to the log file. |
required |
Returns:
| Type | Description |
|---|---|
ToolProgress | None
|
ToolProgress if progress could be extracted, None otherwise. |