diff --git a/cgat/Blat.py b/cgat/Blat.py index 9953888a..58414d2b 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/IndexedFasta.py b/cgat/IndexedFasta.py index 184a94f1..04ece3f0 100644 --- a/cgat/IndexedFasta.py +++ b/cgat/IndexedFasta.py @@ -36,7 +36,6 @@ ''' -from __future__ import generator_stop import os import sys import array diff --git a/cgat/SequenceProperties.py b/cgat/SequenceProperties.py index 52ff675e..dea84e3f 100644 --- a/cgat/SequenceProperties.py +++ b/cgat/SequenceProperties.py @@ -42,7 +42,6 @@ import hashlib import base64 import itertools -import six from cgat import Genomics as Genomics @@ -137,7 +136,7 @@ def loadSequence(self, sequence, seqtype="na"): SequenceProperties.loadSequence(self, sequence, seqtype) # do the encryption - h = hashlib.md5(six.b(sequence)).digest() + h = hashlib.md5(sequence.encode()).digest() # map to printable letters: hid has length 22, so the padded '=' are # truncated. You have to add them, if you ever want to decode, # but who would do such a thing :=) diff --git a/cgat/tools/gff2psl.py b/cgat/tools/gff2psl.py index 4ede2832..1978b521 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 ------- @@ -47,12 +49,19 @@ 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 diff --git a/conda/environments/cgat-apps.yml b/conda/environments/cgat-apps.yml index d059f719..d6e93af1 100644 --- a/conda/environments/cgat-apps.yml +++ b/conda/environments/cgat-apps.yml @@ -15,7 +15,6 @@ dependencies: - alignlib-lite - biopython - cython -- jinja2 - cgatcore - matplotlib - nose @@ -31,7 +30,6 @@ dependencies: - scikit-learn - scipy - setuptools -- six - sortedcontainers - bedtools - grep diff --git a/tests/test_scripts.py b/tests/test_scripts.py index 4cb79a69..3a578fb0 100644 --- a/tests/test_scripts.py +++ b/tests/test_scripts.py @@ -19,8 +19,6 @@ """ -from __future__ import print_function - import subprocess import tempfile import os