Skip to content
This repository has been archived by the owner on Sep 12, 2022. It is now read-only.

Commit

Permalink
Merge pull request #1 from AxelGiottonini/plugin_version
Browse files Browse the repository at this point in the history
plugin version
  • Loading branch information
AxelGiottonini authored May 20, 2021
2 parents 108415e + d829335 commit cf079b3
Show file tree
Hide file tree
Showing 28 changed files with 1,175 additions and 304 deletions.
15 changes: 0 additions & 15 deletions Pipfile

This file was deleted.

134 changes: 0 additions & 134 deletions Pipfile.lock

This file was deleted.

62 changes: 62 additions & 0 deletions Plugins/__caller__.py
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"
28 changes: 28 additions & 0 deletions Plugins/__init__.py
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
38 changes: 38 additions & 0 deletions Plugins/__plugin__.py
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"
60 changes: 60 additions & 0 deletions Plugins/__read__.py
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
21 changes: 21 additions & 0 deletions Plugins/__read_gff_maker__.py
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.")

10 changes: 10 additions & 0 deletions Plugins/__read_tab_pannzer__.py
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)
Loading

0 comments on commit cf079b3

Please sign in to comment.