From 77ab03c6d2f8ba401f3be0172e3c7ad4fb117f70 Mon Sep 17 00:00:00 2001 From: Acribbs Date: Thu, 4 Apr 2024 09:28:17 +0100 Subject: [PATCH 1/5] deprication of Blat and gff2psl --- cgat/Blat.py | 28 +++++++++++++++++++++++++++- cgat/tools/gff2psl.py | 7 +++++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/cgat/Blat.py b/cgat/Blat.py index 9953888ad..0f471fc2c 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 4ede2832c..8f2b8d6b3 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 From 15d0442b4cae87f36c91558a9efd0a06272169f6 Mon Sep 17 00:00:00 2001 From: Acribbs Date: Thu, 4 Apr 2024 09:38:25 +0100 Subject: [PATCH 2/5] pep8 changes --- cgat/Blat.py | 4 ++-- cgat/tools/gff2psl.py | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/cgat/Blat.py b/cgat/Blat.py index 0f471fc2c..58414d2bc 100644 --- a/cgat/Blat.py +++ b/cgat/Blat.py @@ -37,12 +37,12 @@ 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 diff --git a/cgat/tools/gff2psl.py b/cgat/tools/gff2psl.py index 8f2b8d6b3..1978b5216 100644 --- a/cgat/tools/gff2psl.py +++ b/cgat/tools/gff2psl.py @@ -4,7 +4,7 @@ :Tags: Genomics Intervals GFF PSL Conversion -Note: This script is scheduled for deprecation in May 2024. +Note: This script is scheduled for deprecation in May 2024. Purpose ------- @@ -48,6 +48,7 @@ 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) @@ -58,6 +59,7 @@ def main(argv=None): parses command line options in sys.argv, unless *argv* is given. """ + print_deprecation_warning() if argv is None: From eeb845916a003bf084fdde5c666d6d21bab76cb0 Mon Sep 17 00:00:00 2001 From: Acribbs Date: Thu, 4 Apr 2024 09:45:02 +0100 Subject: [PATCH 3/5] remove six dependancy since we dont support py2 --- cgat/SequenceProperties.py | 3 +-- conda/environments/cgat-apps.yml | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/cgat/SequenceProperties.py b/cgat/SequenceProperties.py index 52ff675e8..dea84e3fb 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/conda/environments/cgat-apps.yml b/conda/environments/cgat-apps.yml index d059f719d..b0f5db44c 100644 --- a/conda/environments/cgat-apps.yml +++ b/conda/environments/cgat-apps.yml @@ -31,7 +31,6 @@ dependencies: - scikit-learn - scipy - setuptools -- six - sortedcontainers - bedtools - grep From e9d74d877c6cac570cada09fd2b8ca44f4eea6a3 Mon Sep 17 00:00:00 2001 From: Acribbs Date: Thu, 4 Apr 2024 09:54:57 +0100 Subject: [PATCH 4/5] have removed jinja2 as it doesnt seem to be used in the code --- conda/environments/cgat-apps.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/conda/environments/cgat-apps.yml b/conda/environments/cgat-apps.yml index b0f5db44c..d6e93af13 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 From a2aab04d00398650c38cc44fd21745fdb5a0888e Mon Sep 17 00:00:00 2001 From: Acribbs Date: Thu, 4 Apr 2024 09:57:35 +0100 Subject: [PATCH 5/5] removed future dep as we only support py3 now --- cgat/IndexedFasta.py | 1 - tests/test_scripts.py | 2 -- 2 files changed, 3 deletions(-) diff --git a/cgat/IndexedFasta.py b/cgat/IndexedFasta.py index 184a94f16..04ece3f05 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/tests/test_scripts.py b/tests/test_scripts.py index 4cb79a693..3a578fb09 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