[med-svn] [Git][med-team/python-pyfaidx][upstream] New upstream version 0.8.0

Étienne Mollier (@emollier) gitlab at salsa.debian.org
Sat Jan 13 16:44:45 GMT 2024



Étienne Mollier pushed to branch upstream at Debian Med / python-pyfaidx


Commits:
3eadce6c by Étienne Mollier at 2024-01-13T17:33:26+01:00
New upstream version 0.8.0
- - - - -


6 changed files:

- .coveragerc
- dev-requirements.txt
- pyfaidx/__init__.py
- pyproject.toml
- tests/test_Fasta_synchronization.py
- tests/test_feature_indexing.py


Changes:

=====================================
.coveragerc
=====================================
@@ -5,8 +5,6 @@ omit =
     */lib_pypy/_*.py
     */site-packages/ordereddict.py
     */site-packages/nose/*
-    */site-packages/six/*
-    */unittest2/*
 
 [paths]
 source =


=====================================
dev-requirements.txt
=====================================
@@ -1,8 +1,6 @@
-six
 pytest
 pytest-cov
 setuptools
-mock
 cython 
 # pysam
 requests 


=====================================
pyfaidx/__init__.py
=====================================
@@ -3,8 +3,6 @@
 Fasta file -> Faidx -> Fasta -> FastaRecord -> Sequence
 """
 
-from __future__ import division
-
 import datetime
 import os
 import re
@@ -13,7 +11,7 @@ import sys
 import shutil
 import warnings
 from collections import namedtuple
-from itertools import islice
+from itertools import islice, zip_longest
 from math import ceil
 from os.path import getmtime
 from tempfile import TemporaryFile
@@ -24,13 +22,7 @@ try:
 except ImportError: #python < 3.8
     from importlib_metadata import version
 
-from six import PY2, PY3, integer_types, string_types
-from six.moves import zip_longest
-
-try:
-    from collections import OrderedDict
-except ImportError:  #python 2.6
-    from ordereddict import OrderedDict
+from collections import OrderedDict
 
 try:
     import fsspec
@@ -39,9 +31,6 @@ except ImportError:
 
 __version__ = version("pyfaidx")
 
-if sys.version_info > (3, ):
-    buffer = memoryview
-
 dna_bases = re.compile(r'([ACTGNactgnYRWSKMDVHBXyrwskmdvhbx]+)')
 
 class KeyFunctionError(ValueError):
@@ -99,8 +88,8 @@ class Sequence(object):
         self.start = start
         self.end = end
         self.comp = comp
-        assert isinstance(name, string_types)
-        assert isinstance(seq, string_types)
+        assert isinstance(name, str)
+        assert isinstance(seq, str)
 
     def __getitem__(self, n):
         """ Returns a sliced version of Sequence
@@ -180,7 +169,7 @@ class Sequence(object):
                 end = self_start + slice_stop + correction_factor
             return self.__class__(self.name, self.seq[n], start, end,
                                   self.comp)
-        elif isinstance(n, integer_types):
+        elif isinstance(n, int):
             if n < 0:
                 n = len(self) + n
             if self.start:
@@ -455,7 +444,7 @@ class Faidx(object):
         try:
             key_fn_test = self.key_function(
                 "TestingReturnType of_key_function")
-            if not isinstance(key_fn_test, string_types):
+            if not isinstance(key_fn_test, str):
                 raise KeyFunctionError(
                     "key_function argument should return a string, not {0}".
                     format(type(key_fn_test)))
@@ -482,9 +471,9 @@ class Faidx(object):
         self.lock = Lock()
         self.buffer = dict((('seq', None), ('name', None), ('start', None),
                             ('end', None)))
-        if not read_ahead or isinstance(read_ahead, integer_types):
+        if not read_ahead or isinstance(read_ahead, int):
             self.read_ahead = read_ahead
-        elif not isinstance(read_ahead, integer_types):
+        elif not isinstance(read_ahead, int):
             raise ValueError("read_ahead value must be int, not {0}".format(
                 type(read_ahead)))
 
@@ -923,7 +912,7 @@ class FastaRecord(object):
                     start = len(self) + start
                 return self._fa.get_seq(self.name, start + 1, stop)[::step]
 
-            elif isinstance(n, integer_types):
+            elif isinstance(n, int):
                 if n < 0:
                     n = len(self) + n
                 return self._fa.get_seq(self.name, n + 1, n + 1)
@@ -1034,7 +1023,7 @@ class FastaRecord(object):
             'shape': (len(self), ),
             'typestr': '|S1',
             'version': 3,
-            'data': buffer(str(self).encode('ascii'))
+            'data': memoryview(str(self).encode('ascii'))
         }
 
 
@@ -1065,7 +1054,7 @@ class MutableFastaRecord(FastaRecord):
                     start = len(self) + start
                 self._fa.faidx.to_file(self.name, start + 1, stop, value)
 
-            elif isinstance(n, integer_types):
+            elif isinstance(n, int):
                 if n < 0:
                     n = len(self) + n
                 return self._fa.faidx.to_file(self.name, n + 1, n + 1, value)
@@ -1126,7 +1115,7 @@ class Fasta(object):
 
     def __getitem__(self, rname):
         """Return a chromosome by its name, or its numerical index."""
-        if isinstance(rname, integer_types):
+        if isinstance(rname, int):
             rname = next(islice(self.records.keys(), rname, None))
         try:
             return self.records[rname]
@@ -1353,13 +1342,9 @@ invalid_characters_set = set(
     chr(x) for x in range(256) if chr(x) not in complement_map[0])
 invalid_characters_string = ''.join(invalid_characters_set)
 
-if PY3:
-    complement_table = str.maketrans(complement_map[0], complement_map[1],
-                                     invalid_characters_string)
-    translate_arguments = (complement_table, )
-elif PY2:
-    complement_table = string.maketrans(complement_map[0], complement_map[1])
-    translate_arguments = (complement_table, invalid_characters_string)
+complement_table = str.maketrans(complement_map[0], complement_map[1],
+                                 invalid_characters_string)
+translate_arguments = (complement_table, )
 
 
 def complement(seq):


=====================================
pyproject.toml
=====================================
@@ -27,7 +27,6 @@ classifiers = [
     "Topic :: Scientific/Engineering :: Bio-Informatics"
 ]
 dependencies = [
-    "six",
     "setuptools",
     "importlib_metadata"
 ]


=====================================
tests/test_Fasta_synchronization.py
=====================================
@@ -1,9 +1,6 @@
 import os
 import pytest
-try:
-    from collections import OrderedDict
-except ImportError: #python 2.6
-    from ordereddict import OrderedDict
+from collections import OrderedDict
 import threading
 from pyfaidx import Fasta
 import random


=====================================
tests/test_feature_indexing.py
=====================================
@@ -1,3 +1,4 @@
+import builtins
 import os
 import pytest
 from os.path import getmtime
@@ -7,12 +8,7 @@ import time
 import platform
 import shutil
 
-try:
-    from unittest import mock
-except ImportError:
-    import mock
-
-import six.moves.builtins as builtins
+from unittest import mock
 
 path = os.path.dirname(__file__)
 os.chdir(path)
@@ -268,7 +264,7 @@ def test_build_issue_96_fail_build_faidx(remove_index):
             opened_files.append(f)
             return f
 
-        with mock.patch('six.moves.builtins.open', side_effect=test_open):
+        with mock.patch('builtins.open', side_effect=test_open):
             try:
                 Faidx(fasta_path)
                 remove_index.assertFail(
@@ -305,7 +301,7 @@ def test_build_issue_96_fail_read_malformed_index_duplicate_key(remove_index):
             opened_files.append(f)
             return f
 
-        with mock.patch('six.moves.builtins.open', side_effect=test_open):
+        with mock.patch('builtins.open', side_effect=test_open):
             try:
                 Faidx(fasta_path)
                 remove_index.assertFail(



View it on GitLab: https://salsa.debian.org/med-team/python-pyfaidx/-/commit/3eadce6c2fa66ccd54e2ed7e371e065b639f143d

-- 
View it on GitLab: https://salsa.debian.org/med-team/python-pyfaidx/-/commit/3eadce6c2fa66ccd54e2ed7e371e065b639f143d
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/debian-med-commit/attachments/20240113/bf39db42/attachment-0001.htm>


More information about the debian-med-commit mailing list