Skip to content

Commit

Permalink
Merge pull request #124 from cgat-developers/AC-codeclean
Browse files Browse the repository at this point in the history
deprication of Blat and gff2psl
  • Loading branch information
Acribbs authored Apr 4, 2024
2 parents c931a5d + a2aab04 commit c0aef8b
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 8 deletions.
28 changes: 27 additions & 1 deletion cgat/Blat.py
Original file line number Diff line number Diff line change
@@ -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`,
...).
Expand All @@ -16,6 +23,8 @@
import copy
import string
import collections
import warnings
import functools

try:
import alignlib_lite
Expand All @@ -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."""

Expand All @@ -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
Expand All @@ -61,6 +84,7 @@ def __init__(self, message, line=None):
---------------------------------------------------------------------------------------------------------------------------------------------------------------"""


@deprecated_class
class Match:

"""a :term:`psl` formatted alignment.
Expand Down Expand Up @@ -479,6 +503,7 @@ def getHeaders(self):
"qStarts", "tStarts")


@deprecated_class
class MatchPSLX(Match):

def __init__(self):
Expand Down Expand Up @@ -601,6 +626,7 @@ def _iterate(infile):
yield match


@deprecated_class
class BlatIterator:

def __init__(self, f, *args, **kwargs):
Expand Down
1 change: 0 additions & 1 deletion cgat/IndexedFasta.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
'''

from __future__ import generator_stop
import os
import sys
import array
Expand Down
3 changes: 1 addition & 2 deletions cgat/SequenceProperties.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
import hashlib
import base64
import itertools
import six

from cgat import Genomics as Genomics

Expand Down Expand Up @@ -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 :=)
Expand Down
9 changes: 9 additions & 0 deletions cgat/tools/gff2psl.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
:Tags: Genomics Intervals GFF PSL Conversion
Note: This script is scheduled for deprecation in May 2024.
Purpose
-------
Expand Down Expand Up @@ -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

Expand Down
2 changes: 0 additions & 2 deletions conda/environments/cgat-apps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ dependencies:
- alignlib-lite
- biopython
- cython
- jinja2
- cgatcore
- matplotlib
- nose
Expand All @@ -31,7 +30,6 @@ dependencies:
- scikit-learn
- scipy
- setuptools
- six
- sortedcontainers
- bedtools
- grep
Expand Down
2 changes: 0 additions & 2 deletions tests/test_scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
"""

from __future__ import print_function

import subprocess
import tempfile
import os
Expand Down

0 comments on commit c0aef8b

Please sign in to comment.