diff --git a/cgat/Blat.py b/cgat/Blat.py index 9953888a..0f471fc2 100644 --- a/cgat/Blat.py +++ b/cgat/Blat.py @@ -1,11 +1,18 @@ '''Blat.py - tools for working with PSL formatted files and data ============================================================= +IMPORTANT NOTICE: +Several functions within this module are scheduled for +deprecation in May 2024. +Details regarding the specific functions to be deprecated +can be found in the documentation of each function. + + This module provides a class to parse :term:`PSL` formatted files such as those output by the BLAT tool. This module defines the :class:`Blat.Match` class representing a -single entry and a series of iterators to iterate of :term:`PSL` +single entry and a series of iterators to iterate of :term:`SL` formatted files (:func:`iterator`, :func:`iterator_target_overlap`, ...). @@ -16,6 +23,8 @@ import copy import string import collections +import warnings +import functools try: import alignlib_lite @@ -26,6 +35,19 @@ from cgatcore import experiment as E +def deprecated_class(cls): + orig_init = cls.__init__ + + @functools.wraps(orig_init) + def new_init(self, *args, **kwargs): + warnings.warn(f"{cls.__name__} is deprecated and will be removed in May 2024.", DeprecationWarning) + orig_init(self, *args, **kwargs) + + cls.__init__ = new_init + return cls + + +@deprecated_class class Error(Exception): """Base class for exceptions in this module.""" @@ -40,6 +62,7 @@ def _set_message(self, message): message = property(_get_message, _set_message) +@deprecated_class class ParsingError(Error): """Exception raised for errors while parsing @@ -61,6 +84,7 @@ def __init__(self, message, line=None): ---------------------------------------------------------------------------------------------------------------------------------------------------------------""" +@deprecated_class class Match: """a :term:`psl` formatted alignment. @@ -479,6 +503,7 @@ def getHeaders(self): "qStarts", "tStarts") +@deprecated_class class MatchPSLX(Match): def __init__(self): @@ -601,6 +626,7 @@ def _iterate(infile): yield match +@deprecated_class class BlatIterator: def __init__(self, f, *args, **kwargs): diff --git a/cgat/tools/gff2psl.py b/cgat/tools/gff2psl.py index 4ede2832..8f2b8d6b 100644 --- a/cgat/tools/gff2psl.py +++ b/cgat/tools/gff2psl.py @@ -4,6 +4,8 @@ :Tags: Genomics Intervals GFF PSL Conversion +Note: This script is scheduled for deprecation in May 2024. + Purpose ------- @@ -46,12 +48,17 @@ import alignlib_lite import cgat.Intervals as Intervals +def print_deprecation_warning(): + warning_message = ("""WARNING: 'gff2psl.py' is deprecated and will be removed in May 2024.""") + print(warning_message, file=sys.stderr) + def main(argv=None): """script main. parses command line options in sys.argv, unless *argv* is given. """ + print_deprecation_warning() if argv is None: argv = sys.argv