diff --git a/.github/workflows/qiita-plugin-ci.yml b/.github/workflows/qiita-plugin-ci.yml index b88f397..952def6 100644 --- a/.github/workflows/qiita-plugin-ci.yml +++ b/.github/workflows/qiita-plugin-ci.yml @@ -11,7 +11,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ["3.5", "3.6", "3.9", "3.10", "3.11", "3.12"] + python-version: ["2.7", "3.5", "3.6", "3.9", "3.10", "3.11", "3.12"] steps: # Downloads a copy of the code in your repository before running CI tests - name: Check out repository code @@ -35,7 +35,7 @@ jobs: shell: bash -l {0} run: | conda activate qiita-files - pytest --doctest-modules --cov=qiita_files `if (( $(echo "${{ matrix.python-version }} > 3.6" | bc -l) )); then echo "--cov-report=lcov"; else echo ""; fi` + pytest --doctest-modules `if (( $(echo "${{ matrix.python-version }} > 3.6" | bc -l) )); then echo "--cov-report=lcov --cov=qiita_files"; else echo ""; fi` lint: runs-on: ubuntu-latest diff --git a/qiita_files/parse/fastq.py b/qiita_files/parse/fastq.py index 3626da4..1b4d2a9 100644 --- a/qiita_files/parse/fastq.py +++ b/qiita_files/parse/fastq.py @@ -8,7 +8,10 @@ import numpy as np from qiita_files.util import open_file -from itertools import zip_longest +try: + from itertools import zip_longest +except ImportError: + from itertools import izip_longest as zip_longest def _ascii_to_phred(s, offset): diff --git a/qiita_files/parse/tests/test_fastq.py b/qiita_files/parse/tests/test_fastq.py index a331260..57c1849 100644 --- a/qiita_files/parse/tests/test_fastq.py +++ b/qiita_files/parse/tests/test_fastq.py @@ -155,7 +155,7 @@ class ParseFastqTestsInputIsFileNames(FileData, ParseFastqTests, TestCase): } -FASTQ_EXAMPLE = rb"""@GAPC_0015:6:1:1259:10413#0/1 +FASTQ_EXAMPLE = r"""@GAPC_0015:6:1:1259:10413#0/1 AACACCAAACTTCTCCACCACGTGAGCTACAAAAG +GAPC_0015:6:1:1259:10413#0/1 ````Y^T]`]c^cabcacc`^Lb^ccYT\T\Y\WF @@ -194,10 +194,10 @@ class ParseFastqTestsInputIsFileNames(FileData, ParseFastqTests, TestCase): @GAPC_0015:6:1:1317:3403#0/1 TTGTTTCCACTTGGTTGATTTCACCCCTGAGTTTG +GAPC_0015:6:1:1317:3403#0/1 -\\\ZTYTSaLbb``\_UZ_bbcc`cc^[ac\a\Tc""" +\\\ZTYTSaLbb``\_UZ_bbcc`cc^[ac\a\Tc""".encode("utf-8") -FASTQ_EXAMPLE_2 = rb"""@GAPC_0017:6:1:1259:10413#0/1 +FASTQ_EXAMPLE_2 = r"""@GAPC_0017:6:1:1259:10413#0/1 AACACCAAACTTCTCCACCACGTGAGCTACAAAAG +GAPC_0015:6:1:1259:10413#0/1 ````Y^T]`]c^cabcacc`^Lb^ccYT\T\Y\WF @@ -205,15 +205,15 @@ class ParseFastqTestsInputIsFileNames(FileData, ParseFastqTests, TestCase): TATGTATATATAACATATACATATATACATACATA +GAPC_0015:6:1:1283:11957#0/1 ]KZ[PY]_[YY^```ac^\\`bT``c`\aT``bbb -""" +""".encode("utf-8") -FASTQ_EXAMPLE_3 = rb"""@GAPC_0017:6:1:1259:10413#0/1 +FASTQ_EXAMPLE_3 = r"""@GAPC_0017:6:1:1259:10413#0/1 AACACCAAACTTCTCCACCACGTGAGCTACAAAAG +GAPC_0015:6:1:1259:10413#0/1 ````Y^T]`]c^cabcacc`^Lb^ccYT\T\Y\WF @GAPC_0015:6:1:1283:11957#0/1 -""" +""".encode("utf-8") if __name__ == "__main__": diff --git a/qiita_files/parse/tests/test_iterator.py b/qiita_files/parse/tests/test_iterator.py index 6795fe8..3dda430 100644 --- a/qiita_files/parse/tests/test_iterator.py +++ b/qiita_files/parse/tests/test_iterator.py @@ -276,47 +276,47 @@ def test_fastq_gen(self): self.assertEqual(obs3, exp3) -fasta1 = rb""">1 +fasta1 = r""">1 aattggcc >2 aattaatt -""" +""".encode("utf-8") -fasta2 = rb""">3 +fasta2 = r""">3 atat -""" +""".encode("utf-8") -fasta3 = rb""">4 +fasta3 = r""">4 attatt >5 ggccc -""" +""".encode("utf-8") -qual1 = rb""">1 +qual1 = r""">1 1 2 3 4 5 6 7 8 >2 8 7 6 5 4 3 2 1 -""" +""".encode("utf-8") -qual2 = rb""">3 +qual2 = r""">3 1 2 3 4 -""" +""".encode("utf-8") -qual3 = rb""">4 +qual3 = r""">4 1 2 3 4 5 6 >5 1 2 3 4 5 -""" +""".encode("utf-8") -qual_bad_val = rb""">3 +qual_bad_val = r""">3 1 2 -""" +""".encode("utf-8") -qual_bad_id = rb""">asdasd +qual_bad_id = r""">asdasd 1 2 3 4 -""" +""".encode("utf-8") -fastq1 = rb"""@1 +fastq1 = r"""@1 atat + ABCD @@ -324,13 +324,13 @@ def test_fastq_gen(self): atgc + BCDE -""" +""".encode("utf-8") -fastq2 = rb"""@3 +fastq2 = r"""@3 taa + EFG -""" +""".encode("utf-8") if __name__ == '__main__': diff --git a/qiita_files/tests/test_util.py b/qiita_files/tests/test_util.py index daf256f..4a600f2 100644 --- a/qiita_files/tests/test_util.py +++ b/qiita_files/tests/test_util.py @@ -8,11 +8,16 @@ # ----------------------------------------------------------------------------- import os +import sys from unittest import TestCase, main import tempfile import h5py -from io import StringIO, BytesIO +if sys.version_info[0] == 2: + from StringIO import StringIO +else: + from io import StringIO +from io import BytesIO from qiita_files.util import (open_file, _is_string_or_bytes) @@ -25,7 +30,7 @@ class TestFilePathOpening(TestCase): """Tests adapted from scikit-bio's skbio.io.util tests""" def test_is_string_or_bytes(self): self.assertTrue(_is_string_or_bytes('foo')) - self.assertTrue(_is_string_or_bytes(u'foo')) + self.assertTrue(_is_string_or_bytes(u'foo'.encode("utf-8"))) self.assertTrue(_is_string_or_bytes(b'foo')) self.assertFalse(_is_string_or_bytes(StringIO('bar'))) self.assertFalse(_is_string_or_bytes([1])) diff --git a/setup.py b/setup.py index 2580547..cd49f1b 100644 --- a/setup.py +++ b/setup.py @@ -18,6 +18,7 @@ Topic :: Software Development :: Libraries :: Application Frameworks Topic :: Software Development :: Libraries :: Python Modules Programming Language :: Python + Programming Language :: Python :: 2.7 Programming Language :: Python :: 3.5 Programming Language :: Python :: 3.6 Programming Language :: Python :: 3.9