[med-svn] [Git][med-team/python-pybedtools][upstream] New upstream version 0.10.0

Michael R. Crusoe (@crusoe) gitlab at salsa.debian.org
Fri May 3 17:42:05 BST 2024



Michael R. Crusoe pushed to branch upstream at Debian Med / python-pybedtools


Commits:
462ee1df by Michael R. Crusoe at 2024-05-03T17:42:51+02:00
New upstream version 0.10.0
- - - - -


27 changed files:

- .github/workflows/main.yml
- docs/source/changes.rst
- docs/source/topical-bam.rst
- pybedtools/__init__.py
- pybedtools/bedtool.py
- pybedtools/cbedtools.pyx
- pybedtools/contrib/bigbed.py
- pybedtools/contrib/long_range_interaction.py
- pybedtools/contrib/plotting.py
- pybedtools/contrib/venn_maker.py
- pybedtools/filenames.py
- pybedtools/helpers.py
- pybedtools/include/bedFile.h
- pybedtools/paths.py
- pybedtools/scripts/peak_pie.py
- pybedtools/scripts/venn_gchart.py
- pybedtools/test/genomepy_integration.py
- pybedtools/test/test_1.py
- pybedtools/test/test_cbedtools.py
- pybedtools/test/test_gzip_support.py
- pybedtools/test/test_helpers.py
- pybedtools/test/test_issues.py
- pybedtools/test/test_iter.py
- pybedtools/test/test_pathlib.py
- pybedtools/version.py
- requirements.txt
- setup.py


Changes:

=====================================
.github/workflows/main.yml
=====================================
@@ -13,10 +13,10 @@ jobs:
   build-and-test:
     strategy:
       matrix:
-        python-version: ["3.8", "3.9", "3.10", "3.11"]
+        python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
     runs-on: ubuntu-latest
     steps:
-    - uses: actions/checkout at v2
+    - uses: actions/checkout at v3
 
 
     - name: git setup
@@ -63,33 +63,19 @@ jobs:
         eval "$(conda shell.bash hook)"
         conda install mamba python=${{ matrix.python-version }} -y --channel conda-forge
 
-        if [ ${{ matrix.python-version }} != "3.11" ]; then
-          mamba create -y -p ./test-env \
-            --channel conda-forge \
-            --channel bioconda python=${{ matrix.python-version }} \
-            --file requirements.txt \
-            --file test-requirements.txt \
-            --file optional-requirements.txt
-          conda activate ./test-env
-        else
-          # Only install bedtools; let pip take care of the rest for 3.11 until
-          # bioconda catches up.
-          #
-          # We still install the test requirements though, and the optional
-          # requirements except for genomepy which is in bioconda.
-          grep -v "genomepy" optional-requirements.txt > optional-requirements-3.11.txt
-          mamba create -y -p ./test-env \
-            --channel conda-forge \
-            --channel bioconda \
-            bedtools \
-            python=${{ matrix.python-version }} \
-            --file test-requirements.txt \
-            --file optional-requirements-3.11.txt
-          conda activate ./test-env
-          pip install genomepy
+        # Only install non-python dependencies (like bedtools & ucsc tools);
+        # let pip take care of the rest.
+        grep -Ev "genomepy|matplotlib" optional-requirements.txt > optional-requirements-conda.txt
+        grep -E "genomepy|matplotlib" optional-requirements.txt > optional-requirements-python.txt
+        mamba create -y -p ./test-env \
+          --channel conda-forge \
+          --channel bioconda \
+          bedtools \
+          python=${{ matrix.python-version }} \
+          --file optional-requirements-conda.txt
 
-        fi
         conda activate ./test-env
+        pip install -r test-requirements.txt -r optional-requirements-python.txt
 
         mkdir -p /tmp/pybedtools-uncompressed
         cd /tmp/pybedtools-uncompressed
@@ -116,6 +102,7 @@ jobs:
 
 
     - name: build-docs
+      if: ${{ (matrix.python-version == 3.10) }}
       # Build docs and commit to gh-pages branch. Note that no push happens
       # unless we're on the master branch
       run: |
@@ -148,7 +135,7 @@ jobs:
 
     - name: docs artifact
       # Upload built docs as an artifact for inspection, even on PRs
-      uses: actions/upload-artifact at v2
+      uses: actions/upload-artifact at v3
       with:
         name: docs
         path: /tmp/docs


=====================================
docs/source/changes.rst
=====================================
@@ -3,6 +3,17 @@
 Changelog
 =========
 
+Changes in v0.10.1
+------------------
+
+2024-04-09
+
+* Remove last traces of Python 2.7 support by removing ``six`` dependency (thanks Valentyn Bezshapkin)
+* Support building on later C++ toolchains (thanks Cameron Smith)
+* Support ``pathlib.Path`` in ``BedTool.cat()`` (fixes #405)
+* Improvements to testing: add tests for Python 3.12, more explicity setup/teardown
+
+
 Changes in v0.9.1
 -----------------
 


=====================================
docs/source/topical-bam.rst
=====================================
@@ -86,8 +86,7 @@ there is some additional complexity here due to supporting Python 2 and
     >>> bam_results[0].start
     9329
 
-    >>> import six
-    >>> isinstance(bam_results[0][3], six.string_types)
+    >>> isinstance(bam_results[0][3], str)
     True
 
     >>> print(bam_results[0][3])


=====================================
pybedtools/__init__.py
=====================================
@@ -3,8 +3,8 @@ import sys
 import subprocess
 import tempfile
 import logging
-from six.moves import urllib
-from six.moves import copyreg
+import copyreg
+
 from .cbedtools import (
     Interval,
     IntervalFile,
@@ -128,7 +128,7 @@ def load_path_config(fn):
                 pass
 
     if isinstance(fn, str):
-        from six.moves import configparser
+        import configparser
 
         c = configparser.SafeConfigParser()
         c.read(fn)


=====================================
pybedtools/bedtool.py
=====================================
@@ -10,10 +10,10 @@ import string
 import pprint
 from itertools import islice
 import multiprocessing
-import six
 import gzip
 import pysam
 from warnings import warn
+from pathlib import Path
 
 from .helpers import (
     get_tempdir,
@@ -53,7 +53,7 @@ def _jaccard_output_to_dict(s, **kwargs):
     jaccard method doesn't return an interval file, rather, it returns a short
     summary of results.  Here, we simply parse it into a dict for convenience.
     """
-    if isinstance(s, six.string_types):
+    if isinstance(s, str):
         _s = open(s).read()
     elif hasattr(s, "next") or hasattr(s, "__next__"):
         _s = "".join([i for i in s])
@@ -78,11 +78,11 @@ def _reldist_output_handler(s, **kwargs):
     """
     if "detail" in kwargs:
         return BedTool(s)
-    if isinstance(s, six.string_types):
+    if isinstance(s, str):
         iterable = open(s)
     if hasattr(s, "next"):
         iterable = s
-    header = six.advance_iterator(iterable).split()
+    header = next(iterable).split()
     results = {}
     for h in header:
         results[h] = []
@@ -370,7 +370,7 @@ def _wraps(
             # keep the nonbam arg passed into the original _wraps() decorator
             # in scope.
             if nonbam is not None and nonbam != "ALL":
-                if isinstance(nonbam, six.string_types):
+                if isinstance(nonbam, str):
                     _nonbam = [nonbam]
                 else:
                     _nonbam = nonbam
@@ -503,14 +503,12 @@ class BedTool(object):
                 fn = fn.fn
 
             # from_string=False, so assume it's a filename
-            elif isinstance(fn, six.string_types):
+            elif isinstance(fn, str):
                 if remote:
                     self._isbam = True
                 else:
                     if not os.path.exists(fn):
                         msg = 'File "%s" does not exist' % fn
-                        if six.PY2:
-                            raise ValueError(msg)
                         raise FileNotFoundError(msg)
                     self._isbam = isBAM(fn)
 
@@ -618,7 +616,7 @@ class BedTool(object):
         default_kwargs.update(kwargs)
         df.to_csv(outfile, **default_kwargs)
 
-        if isinstance(outfile, six.string_types):
+        if isinstance(outfile, str):
             fn = outfile
         else:
             try:
@@ -670,7 +668,7 @@ class BedTool(object):
         if isinstance(genome, dict):
             chromdict = genome
         else:
-            assert isinstance(genome, six.string_types)
+            assert isinstance(genome, str)
             chromdict = helpers.chromsizes(genome)
 
         tmp = self._tmp()
@@ -792,7 +790,7 @@ class BedTool(object):
         pointing to a BGZIPed file with a .tbi file in the same dir.
         """
         if (
-            isinstance(self.fn, six.string_types)
+            isinstance(self.fn, str)
             and isBGZIP(self.fn)
             and os.path.exists(self.fn + ".tbi")
         ):
@@ -820,7 +818,7 @@ class BedTool(object):
             force_arg = ""
 
         # It may already be BGZIPed...
-        if isinstance(self.fn, six.string_types) and not force:
+        if isinstance(self.fn, str) and not force:
             if isBGZIP(self.fn):
                 return self.fn
 
@@ -1104,7 +1102,7 @@ class BedTool(object):
         >>> print(a.file_type)
         bed
         """
-        if not isinstance(self.fn, six.string_types):
+        if not isinstance(self.fn, str):
             raise ValueError(
                 "Checking file_type not supported for "
                 "non-file BedTools. Use .saveas() to "
@@ -1114,7 +1112,7 @@ class BedTool(object):
             self._file_type = "bam"
         else:
             try:
-                self._file_type = six.advance_iterator(iter(self)).file_type
+                self._file_type = next(iter(self)).file_type
             except StopIteration:
                 self._file_type = "empty"
 
@@ -1177,7 +1175,7 @@ class BedTool(object):
             return BAM(self.fn)
 
         # Plain ol' filename
-        if isinstance(self.fn, six.string_types):
+        if isinstance(self.fn, str):
             if not os.path.exists(self.fn):
                 raise BedToolsFileError("{0} does not exist".format(self.fn))
             if isGZIP(self.fn):
@@ -1192,13 +1190,13 @@ class BedTool(object):
 
     @property
     def intervals(self):
-        if isinstance(self.fn, six.string_types):
+        if isinstance(self.fn, str):
             return IntervalFile(self.fn)
         else:
             raise ValueError("Please convert to a file-based BedTool using saveas")
 
     def __repr__(self):
-        if isinstance(self.fn, six.string_types):
+        if isinstance(self.fn, str):
             if os.path.exists(self.fn) or self.remote:
                 return "<BedTool(%s)>" % self.fn
             else:
@@ -1224,11 +1222,11 @@ class BedTool(object):
         return self.count()
 
     def __eq__(self, other):
-        if isinstance(other, six.string_types):
+        if isinstance(other, str):
             other_str = other
         elif isinstance(other, BedTool):
-            if not isinstance(self.fn, six.string_types) or not isinstance(
-                other.fn, six.string_types
+            if not isinstance(self.fn, str) or not isinstance(
+                other.fn, str
             ):
                 raise NotImplementedError(
                     "Testing equality only supported for"
@@ -1290,7 +1288,7 @@ class BedTool(object):
         <BLANKLINE>
 
         """
-        if not isinstance(self.fn, six.string_types):
+        if not isinstance(self.fn, str):
             raise NotImplementedError(
                 "head() not supported for non file-based BedTools"
             )
@@ -1329,7 +1327,7 @@ class BedTool(object):
             (0, 249250621)
 
         """
-        if isinstance(chromsizes, six.string_types):
+        if isinstance(chromsizes, str):
             self.chromsizes = pybedtools.chromsizes(chromsizes)
         elif isinstance(chromsizes, dict):
             self.chromsizes = chromsizes
@@ -1393,7 +1391,7 @@ class BedTool(object):
 
         # If we're just working with filename-based BedTool objects, just copy
         # the files directly
-        if isinstance(iterable, BedTool) and isinstance(iterable.fn, six.string_types):
+        if isinstance(iterable, BedTool) and isinstance(iterable.fn, str):
             with out_open_func(fn, "wt") as out_:
                 if sys.version_info > (3,0):
                     in_ = in_open_func(iterable.fn, "rt", errors="ignore")
@@ -1464,7 +1462,7 @@ class BedTool(object):
                 instream1 = instream1.fn
 
             # Filename? No pipe, just provide the file
-            if isinstance(instream1, six.string_types):
+            if isinstance(instream1, str):
                 kwargs[inarg1] = instream1
                 stdin = None
 
@@ -1494,7 +1492,7 @@ class BedTool(object):
                 instream2 = instream2.fn
 
             # Filename
-            if isinstance(instream2, six.string_types):
+            if isinstance(instream2, str):
                 kwargs[inarg2] = instream2
 
             # If it's a list of strings, then we need to figure out if it's
@@ -1511,7 +1509,7 @@ class BedTool(object):
             # left to the user.
             #
             elif isinstance(instream2, (list, tuple)) and isinstance(
-                instream2[0], six.string_types
+                instream2[0], str
             ):
                 try:
                     _ = create_interval_from_list(instream2[0].split("\t"))
@@ -1627,8 +1625,6 @@ class BedTool(object):
 
         if not os.path.exists(kwargs["g"]):
             msg = 'Genome file "%s" does not exist' % (kwargs["g"])
-            if six.PY2:
-                raise ValueError(msg)
             raise FileNotFoundError(msg)
 
         return kwargs
@@ -1650,7 +1646,7 @@ class BedTool(object):
 
         # If it's a file-based BedTool -- which is likely, if we're trying to
         # remove invalid features -- then we need to parse it line by line.
-        if isinstance(self.fn, six.string_types):
+        if isinstance(self.fn, str):
             i = IntervalIterator(open(self.fn, "r"))
         else:
             tmp = self.saveas()
@@ -1697,7 +1693,7 @@ class BedTool(object):
         if not isinstance(interval, Interval):
             raise ValueError("Need an Interval instance")
         fn = self.fn
-        if not isinstance(fn, six.string_types):
+        if not isinstance(fn, str):
             fn = self.saveas().fn
         if self._isbam:
             fn = self.bam_to_bed().fn
@@ -1725,7 +1721,7 @@ class BedTool(object):
         if not isinstance(interval, Interval):
             raise ValueError("Need an Interval instance")
         fn = self.fn
-        if not isinstance(fn, six.string_types):
+        if not isinstance(fn, str):
             fn = self.saveas().fn
         if self._isbam:
             fn = self.bam_to_bed().fn
@@ -1753,7 +1749,7 @@ class BedTool(object):
         if not isinstance(interval, Interval):
             raise ValueError("Need an Interval instance")
         fn = self.fn
-        if not isinstance(fn, six.string_types):
+        if not isinstance(fn, str):
             fn = self.saveas().fn
         if self._isbam:
             fn = self.bam_to_bed().fn
@@ -1913,7 +1909,7 @@ class BedTool(object):
         >>> BedTool.seq(('chr1', 1, 10), fn)
         'GATGAGTCT'
         """
-        if isinstance(loc, six.string_types):
+        if isinstance(loc, str):
             chrom, start_end = loc.split(":")
             start, end = list(map(int, start_end.split("-")))
             start -= 1
@@ -2807,7 +2803,7 @@ class BedTool(object):
             pct = (np.mean(a_len[idx]) / n) * 100.0
             return pct
 
-        if isinstance(other, six.string_types):
+        if isinstance(other, str):
             other = BedTool(other)
         else:
             assert isinstance(
@@ -3218,7 +3214,7 @@ class BedTool(object):
         assert len(others) > 0, "You must specify at least one other bedfile!"
         other_beds = []
         for other in others:
-            if isinstance(other, six.string_types):
+            if isinstance(other, (str, Path)):
                 other = BedTool(other)
             else:
                 assert isinstance(
@@ -3345,7 +3341,7 @@ class BedTool(object):
             else:
                 compressed = False
 
-        in_compressed = isinstance(self.fn, six.string_types) and isGZIP(self.fn)
+        in_compressed = isinstance(self.fn, str) and isGZIP(self.fn)
 
         fn = self._collapse(
             self,
@@ -3376,7 +3372,7 @@ class BedTool(object):
         >>> b == a_contents
         True
         """
-        if not isinstance(self.fn, six.string_types):
+        if not isinstance(self.fn, str):
             fn = self._collapse(self, fn=fn)
         else:
             shutil.move(self.fn, fn)
@@ -3393,7 +3389,7 @@ class BedTool(object):
         ----------
 
         n : int
-            Number of features to return. Only one of `n` or `f` can be provided. 
+            Number of features to return. Only one of `n` or `f` can be provided.
 
         f : float, 0 <= f <= 1
             Fraction of features to return. Cannot be provided with `n`.
@@ -3510,7 +3506,7 @@ class BedTool(object):
         """
         Returns an IntervalFile of this BedTool for low-level interface.
         """
-        if not isinstance(self.fn, six.string_types):
+        if not isinstance(self.fn, str):
             fn = self._collapse(self.fn)
         else:
             fn = self.fn
@@ -3675,7 +3671,7 @@ class BedTool(object):
         # Complain if BAM or if not a file
         if self._isbam:
             raise ValueError("BAM not supported for converting to DataFrame")
-        if not isinstance(self.fn, six.string_types):
+        if not isinstance(self.fn, str):
             raise ValueError("use .saveas() to make sure self.fn is a file")
 
         try:
@@ -3702,7 +3698,7 @@ class BedTool(object):
             return pandas.read_csv(self.fn, *args, sep="\t", **kwargs)
         else:
             return pandas.DataFrame()
-        
+
     def tail(self, lines=10, as_string=False):
         """
         Like `head`, but prints last 10 lines of the file by default.
@@ -3714,7 +3710,7 @@ class BedTool(object):
         """
         if self._isbam:
             raise ValueError("tail() not yet implemented for BAM files")
-        if not isinstance(self.fn, six.string_types):
+        if not isinstance(self.fn, str):
             raise ValueError(
                 "tail() not implemented for non-file-based "
                 "BedTool objects.  Please use saveas() first."
@@ -3753,7 +3749,7 @@ class BAM(object):
         The pysam.Samfile can be accessed via the .pysam_bamfile attribute.
         """
         self.stream = stream
-        if not isinstance(self.stream, six.string_types):
+        if not isinstance(self.stream, str):
             raise ValueError("Only files are supported, not streams")
         self.pysam_bamfile = pysam.Samfile(self.stream)
 
@@ -3864,10 +3860,8 @@ class HistoryStep(object):
         try:
             self.method = method._name
         except AttributeError:
-            if six.PY3:
                 self.method = method.__name__
-            else:
-                self.method = method.func_name
+
         self.args = args
         self.kwargs = kwargs
         self.fn = bedtool_instance.fn
@@ -3881,7 +3875,7 @@ class HistoryStep(object):
         """
         if isinstance(arg, pybedtools.BedTool):
             arg = arg.fn
-        if isinstance(arg, six.string_types):
+        if isinstance(arg, str):
             arg = '"%s"' % arg
         return arg
 
@@ -3918,8 +3912,6 @@ def example_bedtool(fn):
     fn = os.path.join(filenames.data_dir(), fn)
     if not os.path.exists(fn):
         msg = "%s does not exist" % fn
-        if six.PY2:
-            raise ValueError(msg)
         raise FileNotFoundError(msg)
     return BedTool(fn)
 


=====================================
pybedtools/cbedtools.pyx
=====================================
@@ -13,8 +13,6 @@
 #   Cython uses the `str` type as whatever the native Python version uses as
 #   str.
 
-
-from cpython.version cimport PY_MAJOR_VERSION
 from libcpp.string cimport string
 import numpy as np
 
@@ -37,10 +35,8 @@ cdef _pystr(string s):
     # Always returns unicode.
     return s.decode('UTF-8', 'strict')
 
-if PY_MAJOR_VERSION < 3:
-    integer_types = (int, long, np.int64)
-else:
-    integer_types = (int, np.int64)
+integer_types = (int, long, np.int64)
+
 
 """
     bedtools.pyx: A Cython wrapper for the BEDTools BedFile class
@@ -52,7 +48,6 @@ else:
 """
 from cython.operator cimport dereference as deref
 import sys
-import six
 import subprocess
 from collections import defaultdict
 
@@ -846,7 +841,7 @@ cdef class IntervalFile:
     def file_type(self):
         if not self.intervalFile_ptr._typeIsKnown:
             try:
-                a = six.advance_iterator(iter(self))
+                a = next(iter(self))
                 file_type = _pystr(self.intervalFile_ptr.file_type)
                 self.intervalFile_ptr.Close()
                 return file_type


=====================================
pybedtools/contrib/bigbed.py
=====================================
@@ -1,6 +1,4 @@
-import os
 import subprocess
-import six
 import pybedtools
 
 
@@ -30,9 +28,9 @@ def bigbed(
 
     Assumes that a recent version of bedToBigBed from UCSC is on the path.
     """
-    if isinstance(x, six.string_types):
+    if isinstance(x, str):
         x = pybedtools.BedTool(x)
-    if not isinstance(x.fn, six.string_types):
+    if not isinstance(x.fn, str):
         x = x.saveas()
     chromsizes = pybedtools.chromsizes_to_file(pybedtools.chromsizes(genome))
     if bedtype is None:


=====================================
pybedtools/contrib/long_range_interaction.py
=====================================
@@ -1,9 +1,5 @@
-import os
 import sys
 import itertools
-import six
-import time
-import pysam
 import pybedtools
 
 
@@ -232,9 +228,7 @@ def tag_bedpe(bedpe, queries, verbose=False):
     grouped_end2 = itertools.groupby(end2_hits, lambda f: f[3])
 
     def gen():
-        for (label1, group1), (label2, group2) in six.moves.zip(
-            grouped_end1, grouped_end2
-        ):
+        for (label1, group1), (label2, group2) in zip(grouped_end1, grouped_end2):
             assert label1 == label2
             yield label1, group1, group2
 
@@ -372,8 +366,8 @@ def cis_trans_interactions(iterator, n, extra, verbose=True):
             interval = pybedtools.create_interval_from_list(f[7 + extra :])
             return [f[6 + extra], interval.name]
 
-        names1 = set(six.moves.map(tuple, six.moves.map(get_name_hits, end1_hits)))
-        names2 = set(six.moves.map(tuple, six.moves.map(get_name_hits, end2_hits)))
+        names1 = set(map(tuple, map(get_name_hits, end1_hits)))
+        names2 = set(map(tuple, map(get_name_hits, end2_hits)))
 
         for cis, others in [(names1, names2), (names2, names1)]:
             for target in cis:


=====================================
pybedtools/contrib/plotting.py
=====================================
@@ -5,7 +5,6 @@ from matplotlib import collections
 from matplotlib import pyplot as plt
 import numpy as np
 import pybedtools
-import six
 
 
 class Track(collections.PolyCollection):
@@ -85,7 +84,7 @@ class Track(collections.PolyCollection):
         >>> limits = ax.axis('tight')
         """
         if isinstance(features, pybedtools.BedTool) and isinstance(
-            features.fn, six.string_types
+            features.fn, str
         ):
             self.features = features
         else:
@@ -211,10 +210,10 @@ class BinaryHeatmap(object):
         _bts = []
         for bt in bts:
             if isinstance(bt, pybedtools.BedTool):
-                if not isinstance(bt.fn, six.string_types):
+                if not isinstance(bt.fn, str):
                     bt = bt.saveas()
                 _bts.append(bt.fn)
-            elif isinstance(bt, six.string_types):
+            elif isinstance(bt, str):
                 _bts.append(bt)
 
         # Do the multi-intersection.
@@ -476,7 +475,7 @@ class BedToolsDemo(TrackCollection):
         config = [list(i) for i in config]
         if data_path:
             for conf in config:
-                if not isinstance(conf[0], six.string_types):
+                if not isinstance(conf[0], str):
                     raise ValueError(
                         "data_path was specified, so you need "
                         "filenames in the config"


=====================================
pybedtools/contrib/venn_maker.py
=====================================
@@ -7,7 +7,6 @@ R script that can be edited and tweaked by the user before being run in R.
 import os
 import string
 import pybedtools
-import six
 from pybedtools import helpers
 import subprocess
 from collections import OrderedDict


=====================================
pybedtools/filenames.py
=====================================
@@ -3,7 +3,6 @@ Provides access to example files and keeps track of all temp files created
 during a Python session.
 """
 import os
-import six
 
 TEMPFILES = []
 
@@ -24,8 +23,6 @@ def example_filename(fn):
     fn = os.path.join(data_dir(), fn)
     if not os.path.exists(fn):
         msg = "%s does not exist" % fn
-        if six.PY2:
-            raise ValueError(msg)
         raise FileNotFoundError(msg)
     return fn
 


=====================================
pybedtools/helpers.py
=====================================
@@ -3,21 +3,19 @@ import os
 import gzip
 import tempfile
 import subprocess
-import random
-import string
 import glob
 import struct
 import atexit
-import six
-import pysam
 import re
-from six.moves import urllib
+import urllib
+import urllib.error
+import urllib.request
 
 try:  # Use genomepy to determine chrom sizes if it is installed
     import genomepy
 except ImportError:
     pass
-from . import cbedtools
+
 from . import settings
 from . import filenames
 from . import genome_registry
@@ -266,8 +264,6 @@ def set_tempdir(tempdir):
     """
     if not os.path.exists(tempdir):
         errstr = "The tempdir you specified, %s, does not exist" % tempdir
-        if six.PY2:
-            raise ValueError(errstr)
         raise FileNotFoundError(errstr)
     tempfile.tempdir = tempdir
 
@@ -540,7 +536,7 @@ def close_or_delete(*args):
     streaming or file-based version.
     """
     for x in args:
-        if isinstance(x.fn, six.string_types):
+        if isinstance(x.fn, str):
             os.unlink(x.fn)
         elif hasattr(x.fn, "close"):
             x.fn.close()
@@ -579,7 +575,7 @@ def string_to_interval(s):
 
     If it's already an interval, then return it as-is.
     """
-    if isinstance(s, six.string_types):
+    if isinstance(s, str):
         m = coord_re.search(s)
         if m.group("strand"):
             return create_interval_from_list(
@@ -862,7 +858,7 @@ def chromsizes(genome):
     """
     Looks for a *genome* already included in the genome registry; if not found
     it first tries to look it up via genomepy. If genomepy is not installed, or
-    if this lookup fails then it looks it up on UCSC.  Returns the dictionary of 
+    if this lookup fails then it looks it up on UCSC.  Returns the dictionary of
     chromsize tuples where each tuple has (start,stop).
 
     Chromsizes are described as (start, stop) tuples to allow randomization


=====================================
pybedtools/include/bedFile.h
=====================================
@@ -89,7 +89,7 @@ BIN getBin(CHRPOS start, CHRPOS end) {
     start >>= _binFirstShift;
     end   >>= _binFirstShift;
     
-    for (register short i = 0; i < _binLevels; ++i) {
+    for (short i = 0; i < _binLevels; ++i) {
         if (start == end) return _binOffsetsExtended[i] + start;
         start >>= _binNextShift;
         end   >>= _binNextShift;


=====================================
pybedtools/paths.py
=====================================
@@ -8,15 +8,15 @@ setting the bedtools path.
 import pybedtools
 from pybedtools import bedtool
 from . import settings
-from six.moves import reload_module
+from importlib import reload
 
 
 def _set_bedtools_path(path=""):
     old_path = settings._bedtools_path
     settings._bedtools_path = path
     if old_path != path:
-        reload_module(bedtool)
-        reload_module(pybedtools)
+        reload(bedtool)
+        reload(pybedtools)
         return True
 
 


=====================================
pybedtools/scripts/peak_pie.py
=====================================
@@ -11,7 +11,7 @@ intron".
 """
 
 import sys
-from six.moves import urllib
+import urllib
 import argparse
 import pybedtools
 from collections import defaultdict


=====================================
pybedtools/scripts/venn_gchart.py
=====================================
@@ -12,7 +12,8 @@ The values in the diagram assume:
 import argparse
 import sys
 import pybedtools
-from six.moves import urllib
+import urllib
+
 
 
 def venn_gchart(a, b, c=None, colors=None, labels=None, size="300x300"):


=====================================
pybedtools/test/genomepy_integration.py
=====================================
@@ -1,4 +1,3 @@
-from six.moves import builtins
 import os
 import sys
 import pytest


=====================================
pybedtools/test/test_1.py
=====================================
@@ -1,32 +1,24 @@
 import pybedtools
-import gzip
 import os, difflib, sys
-from textwrap import dedent
-from pybedtools.helpers import BEDToolsError
 from pybedtools import featurefuncs
-import six
-import pysam
-from six.moves import socketserver
-from six.moves import BaseHTTPServer
 import pytest
 
 import threading
 import warnings
+from .tfuncs import test_tempdir
 
-testdir = os.path.dirname(__file__)
-tempdir = os.path.join(os.path.abspath(testdir), "tmp")
 unwriteable = "unwriteable"
 
 
 def setup_module():
-    if not os.path.exists(tempdir):
-        os.system("mkdir -p %s" % tempdir)
-    pybedtools.set_tempdir(tempdir)
+    if not os.path.exists(test_tempdir):
+        os.system("mkdir -p %s" % test_tempdir)
+    pybedtools.set_tempdir(test_tempdir)
 
 
 def teardown_module():
-    if os.path.exists(tempdir):
-        os.system("rm -r %s" % tempdir)
+    if os.path.exists(test_tempdir):
+        os.system("rm -r %s" % test_tempdir)
     pybedtools.cleanup()
 
 
@@ -75,7 +67,7 @@ def cleanup_unwriteable():
     """
     if os.path.exists(unwriteable):
         os.system("rm -rf %s" % unwriteable)
-    pybedtools.set_tempdir(tempdir)
+    pybedtools.set_tempdir(test_tempdir)
 
 
 def test_interval_index():
@@ -325,7 +317,7 @@ def test_malformed():
     a_i = iter(a)
 
     # first feature is OK
-    print(six.advance_iterator(a_i))
+    print(next(a_i))
 
     # but next one is not and should raise exception
     with pytest.raises(pybedtools.MalformedBedLineError):
@@ -511,7 +503,7 @@ def test_sequence():
     For example, the first 100 bases of a chromosome are defined as
     chromStart=0, chromEnd=100, and span the bases numbered 0-99. """
 
-    fi = os.path.join(testdir, "test.fasta")
+    fi = os.path.join(test_tempdir, "test.fasta")
 
     s = """
     chrX 9  16 . . +
@@ -709,8 +701,8 @@ def test_bedtool_creation():
     a = pybedtools.example_bedtool("a.bed")
     b = pybedtools.BedTool(a)
     assert b.fn == a.fn
-    e = FileNotFoundError if six.PY3 else ValueError
-    with pytest.raises(e):
+
+    with pytest.raises(FileNotFoundError):
         pybedtools.BedTool("nonexistend.bed")
 
     # note that *s* has both tabs and spaces....


=====================================
pybedtools/test/test_cbedtools.py
=====================================
@@ -4,9 +4,19 @@ import unittest
 import os
 from pybedtools import Interval, IntervalFile
 import pybedtools
-from .tfuncs import setup_module, teardown_module
 import pytest
+from .tfuncs import test_tempdir
 
+def setup_module():
+    if not os.path.exists(test_tempdir):
+        os.system("mkdir -p %s" % test_tempdir)
+    pybedtools.set_tempdir(test_tempdir)
+
+
+def teardown_module():
+    if os.path.exists(test_tempdir):
+        os.system("rm -r %s" % test_tempdir)
+    pybedtools.cleanup()
 
 PATH = os.path.dirname(__file__)
 


=====================================
pybedtools/test/test_gzip_support.py
=====================================
@@ -4,10 +4,18 @@ import pybedtools.test.tfuncs as tfuncs
 
 import pybedtools
 import gzip
+from .tfuncs import test_tempdir
 
-setup = tfuncs.setup_module
-teardown = tfuncs.teardown_module
 
+def setup_module():
+    if not os.path.exists(test_tempdir):
+        os.system("mkdir -p %s" % test_tempdir)
+    pybedtools.set_tempdir(test_tempdir)
+
+def teardown_module():
+    if os.path.exists(test_tempdir):
+        os.system("rm -r %s" % test_tempdir)
+    pybedtools.cleanup()
 
 def _make_temporary_gzip(bed_filename):
     """


=====================================
pybedtools/test/test_helpers.py
=====================================
@@ -1,9 +1,9 @@
 import pybedtools
-import six
 import sys
-import os, difflib
-from .tfuncs import setup_module, teardown_module, testdir, test_tempdir, unwriteable
+import os
+from .tfuncs import testdir, test_tempdir
 import pytest
+from pathlib import Path
 
 
 def fix(x):
@@ -41,10 +41,11 @@ def test_cleanup():
 
     # make a fake tempfile, not created during this pybedtools session
     pybedtools.cleanup()
-
-    testfn = os.path.join(test_tempdir, "pybedtools.TESTING.tmp")
-    os.system("touch %s" % testfn)
+    testfn = Path(test_tempdir) / "pybedtools.TESTING.tmp"
+    testfn.parent.mkdir(parents=True, exist_ok=True)
+    testfn.touch()
     assert os.path.exists(testfn)
+    pybedtools.set_tempdir(test_tempdir)
 
     # make some temp files
     a = pybedtools.BedTool(os.path.join(testdir, "data", "a.bed"))
@@ -180,7 +181,7 @@ def test_getting_example_beds():
     assert a.fn == os.path.join(testdir, "data", "a.bed")
 
     # complain appropriately if nonexistent paths are asked for
-    e = FileNotFoundError if six.PY3 else ValueError
+    e = FileNotFoundError
     with pytest.raises(e):
         pybedtools.example_filename("nonexistent")
     with pytest.raises(e):


=====================================
pybedtools/test/test_issues.py
=====================================
@@ -4,7 +4,7 @@ import os
 import subprocess
 import sys
 from textwrap import dedent
-import six
+from pathlib import Path
 import pytest
 import psutil
 
@@ -256,12 +256,6 @@ def test_issue_154():
     regions = [("chr2", int(1), int(2), "tag")]
     pybedtools.BedTool(regions)
 
-    # ensure longs are OK as start/stop. In Python3 everything is long, so only
-    # try the following on PY2
-    if six.PY2:
-        regions = [("chr2", long(1), long(2), "tag")]
-        pybedtools.BedTool(regions)
-
 
 def test_issue_151():
     # this used to be incorrectly inferred to be SAM because of the name field
@@ -875,7 +869,7 @@ def test_issue_355():
     assert line.split('\t')[1] == '14'
     assert vcf[0].start == 13
 
-    
+
 def test_genome_dict_sort():
     genome = {
         "chr1": (0, 5000),
@@ -919,3 +913,10 @@ def test_issue_390():
     # Fix was to include np.int64 as an integer type in cbedtools.pyx.
     import numpy as np
     pybedtools.BedTool([['chr1', np.int64(1), np.int64(2)]])
+
+def test_issue_405():
+    a = Path(pybedtools.example_filename('a.bed'))
+    b = Path(pybedtools.example_filename('b.bed'))
+    a = pybedtools.BedTool(a)
+    a.cat(b)
+


=====================================
pybedtools/test/test_iter.py
=====================================
@@ -5,7 +5,18 @@ import yaml
 import os
 import gzip
 import pybedtools
-from .tfuncs import setup_module, teardown_module
+from .tfuncs import test_tempdir
+
+def setup_module():
+    if not os.path.exists(test_tempdir):
+        os.system("mkdir -p %s" % test_tempdir)
+    pybedtools.set_tempdir(test_tempdir)
+
+
+def teardown_module():
+    if os.path.exists(test_tempdir):
+        os.system("rm -r %s" % test_tempdir)
+    pybedtools.cleanup()
 
 yamltestdesc = ["test_cases.yaml"]
 


=====================================
pybedtools/test/test_pathlib.py
=====================================
@@ -1,8 +1,6 @@
 import os
 import pathlib
 
-import six
-
 import pybedtools
 import pytest
 
@@ -25,9 +23,5 @@ def test_pathlib_derived():
 def test_pathlib_nonexistent_file():
     fn = os.path.join(pybedtools.filenames.data_dir(), "this_file_is_missing")
     path = pathlib.Path(fn)
-    if six.PY2:
-        with pytest.raises(ValueError):
-            pybedtools.BedTool(path)
-    else:
-        with pytest.raises(FileNotFoundError):
-            pybedtools.BedTool(path)
+    with pytest.raises(FileNotFoundError):
+        pybedtools.BedTool(path)


=====================================
pybedtools/version.py
=====================================
@@ -1,4 +1,4 @@
 
 # THIS FILE IS GENERATED FROM SETUP.PY
-version = '0.9.1'
+version = '0.10.0'
 __version__ = version
\ No newline at end of file


=====================================
requirements.txt
=====================================
@@ -1,4 +1,3 @@
 numpy
 pandas
 pysam
-six


=====================================
setup.py
=====================================
@@ -76,8 +76,8 @@ import distutils.log
 
 
 MAJ = 0
-MIN = 9
-REV = 1
+MIN = 10
+REV = 0
 VERSION = '%d.%d.%d' % (MAJ, MIN, REV)
 
 
@@ -296,7 +296,7 @@ if __name__ == "__main__":
         long_description=README,
         zip_safe=False,
         setup_requires=[],
-        install_requires=['six', 'pysam', 'numpy'],
+        install_requires=['pysam', 'numpy'],
         classifiers=[
             'Development Status :: 5 - Production/Stable',
             'Intended Audience :: Science/Research',



View it on GitLab: https://salsa.debian.org/med-team/python-pybedtools/-/commit/462ee1df9467511a60d0a1803bfdfe5948e10f0e

-- 
View it on GitLab: https://salsa.debian.org/med-team/python-pybedtools/-/commit/462ee1df9467511a60d0a1803bfdfe5948e10f0e
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/20240503/d10e2f10/attachment-0001.htm>


More information about the debian-med-commit mailing list