This repository has been archived by the owner on Sep 12, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from AxelGiottonini/plugin_version
plugin version
- Loading branch information
Showing
28 changed files
with
1,175 additions
and
304 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#__caller__.py | ||
|
||
""" | ||
""" | ||
from Plugins.__verify__ import FailedVerification | ||
|
||
|
||
class Caller: | ||
""" | ||
""" | ||
def __init__(self, app): | ||
self.app = app | ||
self.status = True | ||
self.last_result = None | ||
|
||
""" | ||
""" | ||
def run(self, callback_function, *args): | ||
if args[1] not in ["default", "verify", "bypass"]: | ||
raise UnknownCallerModeError(f"{args[1]} mode is not defined.") | ||
|
||
if self.status and args[1] in ["default"]: | ||
self.last_result = callback_function(*args) | ||
return self.last_result | ||
|
||
elif self.status and args[1] in ["verify"]: | ||
try: | ||
callback_function(self.app, self.last_result) | ||
except FailedVerification: | ||
self.status = False | ||
raise CallerFailedVerification() | ||
return None | ||
|
||
elif not self.status and args[1] in ["bypass"]: | ||
self.last_result = callback_function(*args) | ||
return self.last_result | ||
|
||
class UnknownCallerModeError(Exception): | ||
def __init__(self, *args): | ||
if args: | ||
self.message = args[0] | ||
else: | ||
self.message = None | ||
|
||
def __str__(self): | ||
if self.message: | ||
return f"UnknownCallerModeError: {self.message}" | ||
else: | ||
return "UnknownCallerModeError has been raised" | ||
|
||
class CallerFailedVerification(Exception): | ||
def __init__(self, *args): | ||
if args: | ||
self.message = args[0] | ||
else: | ||
self.message = None | ||
|
||
def __str__(self): | ||
if self.message: | ||
return f"CallerFailedVerification: {self.message}" | ||
else: | ||
return "CallerFailedVerification has been raised" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#__init.py__ | ||
|
||
from Plugins.__caller__ import Caller, UnknownCallerModeError, CallerFailedVerification | ||
|
||
from Plugins.__plugin__ import __Plugin__, RequiredMetadataError, UndefinedMethodError | ||
from Plugins.__read__ import __Read__ | ||
from Plugins.__read_gff_maker__ import __ReadGFFMaker__ | ||
from Plugins.__read_tab_pannzer__ import __ReadTabPannzer__ | ||
from Plugins.__verify__ import __Verify__, FailedVerification | ||
|
||
from Plugins.read_fasta import Plugin | ||
|
||
from Plugins.read_gff_maker_3UTR import Plugin | ||
from Plugins.read_gff_maker_5UTR import Plugin | ||
from Plugins.read_gff_maker_CDS import Plugin | ||
from Plugins.read_gff_maker_exon import Plugin | ||
from Plugins.read_gff_maker_gene import Plugin | ||
from Plugins.read_gff_maker_mRNA import Plugin | ||
from Plugins.read_gff_maker_source import Plugin | ||
|
||
from Plugins.read_tab_pannzer_CDS import Plugin | ||
from Plugins.read_tab_pannzer_gene import Plugin | ||
|
||
from Plugins.to_handle_fasta import Plugin | ||
from Plugins.to_handle_gff_maker import Plugin | ||
from Plugins.to_handle_tab_pannzer import Plugin | ||
|
||
from Plugins.verify_gff_maker_CDS import Plugin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#__plugin__.py | ||
|
||
class __Plugin__: | ||
def process(*args): | ||
raise UndefinedMethodError("process has not been defined") | ||
|
||
def required_metadata_check(*args): | ||
return True | ||
|
||
""" | ||
""" | ||
class RequiredMetadataError(Exception): | ||
def __init__(self, *args): | ||
if args: | ||
self.message = args[0] | ||
else: | ||
self.message = None | ||
|
||
def __str__(self): | ||
if self.message: | ||
return f"RequiredMetadataError: {self.message}" | ||
else: | ||
return "RequiredMetadataError has been raised" | ||
|
||
""" | ||
""" | ||
class UndefinedMethodError(Exception): | ||
def __init__(self, *args): | ||
if args: | ||
self.message = args[0] | ||
else: | ||
self.message = None | ||
|
||
def __str__(self): | ||
if self.message: | ||
return f"UndefinedMethodError: {self.message}" | ||
else: | ||
return "UndefinedMethodError has been raised" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# __read__.py | ||
|
||
from Plugins.__plugin__ import __Plugin__, RequiredMetadataError, UndefinedMethodError | ||
from Plugins.__caller__ import Caller, CallerFailedVerification | ||
|
||
class __Read__(__Plugin__): | ||
|
||
""" | ||
""" | ||
def feature_initialize(self, pre_feature, metadata): | ||
raise UndefinedMethodError("feature_initialize has not been defined.") | ||
|
||
""" | ||
""" | ||
def callbacks(self, app, calls, target): | ||
raise UndefinedMethodError("callbacks has not been defined.") | ||
|
||
""" | ||
""" | ||
def callbacks_extend(self, app, calls, target): | ||
caller = Caller(app) | ||
sender = [] | ||
for app, key_plugin, *args in calls: | ||
temp = None | ||
try: | ||
temp = caller.run(app.plugins[key_plugin].process, app, *args, target) | ||
except CallerFailedVerification: | ||
sender = [] | ||
if temp: | ||
sender.extend(temp) | ||
return sender | ||
|
||
""" | ||
""" | ||
def callbacks_append(self, app, calls, target): | ||
caller = Caller(app) | ||
sender = [] | ||
for app, key_plugin, *args in calls: | ||
temp = None | ||
try: | ||
temp = caller.run(app.plugins[key_plugin].process, app, *args, target) | ||
except CallerFailedVerification: | ||
sender = [] | ||
if temp: | ||
sender.append(temp) | ||
return sender | ||
|
||
""" | ||
""" | ||
def merge(self, feature, receiver): | ||
return feature | ||
|
||
""" | ||
""" | ||
def required_metadata_check(self, app, keys:list=[]): | ||
if keys: | ||
for key in keys: | ||
if not key in app.metadata: | ||
raise RequiredMetadataError(f"Required metadata attribute, {key}, not found.") | ||
return True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#__read_gff_maker__.py | ||
|
||
from Plugins.__read__ import __Read__ | ||
|
||
class __ReadGFFMaker__(__Read__): | ||
|
||
""" | ||
""" | ||
def multi_feature_initialize(self, pre_multi_feature, metadata): | ||
raise UndefinedMethodError("multi_feature_initialize has not been defined.") | ||
|
||
""" | ||
""" | ||
def callbacks(self, app, calls, target): | ||
return super().callbacks_append(app, calls, target) | ||
|
||
""" | ||
""" | ||
def callbacks_with_iterator(self, app, calls, target, iterator): | ||
raise UndefinedMethodError("callbacks_with_iterator has not been defined.") | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#__read_tab_pannzer__.py | ||
|
||
from Plugins.__read__ import __Read__ | ||
|
||
class __ReadTabPannzer__(__Read__): | ||
|
||
""" | ||
""" | ||
def callbacks(self, app, calls, target): | ||
return self.callbacks_extend(app, calls, target) |
Oops, something went wrong.