diff --git a/poetry.lock b/poetry.lock index 4383bb83..b279ca00 100644 --- a/poetry.lock +++ b/poetry.lock @@ -380,6 +380,7 @@ files = [ {file = "contourpy-1.1.0-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:18a64814ae7bce73925131381603fff0116e2df25230dfc80d6d690aa6e20b37"}, {file = "contourpy-1.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:90c81f22b4f572f8a2110b0b741bb64e5a6427e0a198b2cdc1fbaf85f352a3aa"}, {file = "contourpy-1.1.0-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:53cc3a40635abedbec7f1bde60f8c189c49e84ac180c665f2cd7c162cc454baa"}, + {file = "contourpy-1.1.0-cp310-cp310-win32.whl", hash = "sha256:9b2dd2ca3ac561aceef4c7c13ba654aaa404cf885b187427760d7f7d4c57cff8"}, {file = "contourpy-1.1.0-cp310-cp310-win_amd64.whl", hash = "sha256:1f795597073b09d631782e7245016a4323cf1cf0b4e06eef7ea6627e06a37ff2"}, {file = "contourpy-1.1.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:0b7b04ed0961647691cfe5d82115dd072af7ce8846d31a5fac6c142dcce8b882"}, {file = "contourpy-1.1.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:27bc79200c742f9746d7dd51a734ee326a292d77e7d94c8af6e08d1e6c15d545"}, @@ -388,6 +389,7 @@ files = [ {file = "contourpy-1.1.0-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:e5cec36c5090e75a9ac9dbd0ff4a8cf7cecd60f1b6dc23a374c7d980a1cd710e"}, {file = "contourpy-1.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:1f0cbd657e9bde94cd0e33aa7df94fb73c1ab7799378d3b3f902eb8eb2e04a3a"}, {file = "contourpy-1.1.0-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:181cbace49874f4358e2929aaf7ba84006acb76694102e88dd15af861996c16e"}, + {file = "contourpy-1.1.0-cp311-cp311-win32.whl", hash = "sha256:edb989d31065b1acef3828a3688f88b2abb799a7db891c9e282df5ec7e46221b"}, {file = "contourpy-1.1.0-cp311-cp311-win_amd64.whl", hash = "sha256:fb3b7d9e6243bfa1efb93ccfe64ec610d85cfe5aec2c25f97fbbd2e58b531256"}, {file = "contourpy-1.1.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:bcb41692aa09aeb19c7c213411854402f29f6613845ad2453d30bf421fe68fed"}, {file = "contourpy-1.1.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:5d123a5bc63cd34c27ff9c7ac1cd978909e9c71da12e05be0231c608048bb2ae"}, @@ -396,6 +398,7 @@ files = [ {file = "contourpy-1.1.0-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:317267d915490d1e84577924bd61ba71bf8681a30e0d6c545f577363157e5e94"}, {file = "contourpy-1.1.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d551f3a442655f3dcc1285723f9acd646ca5858834efeab4598d706206b09c9f"}, {file = "contourpy-1.1.0-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:e7a117ce7df5a938fe035cad481b0189049e8d92433b4b33aa7fc609344aafa1"}, + {file = "contourpy-1.1.0-cp38-cp38-win32.whl", hash = "sha256:108dfb5b3e731046a96c60bdc46a1a0ebee0760418951abecbe0fc07b5b93b27"}, {file = "contourpy-1.1.0-cp38-cp38-win_amd64.whl", hash = "sha256:d4f26b25b4f86087e7d75e63212756c38546e70f2a92d2be44f80114826e1cd4"}, {file = "contourpy-1.1.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:bc00bb4225d57bff7ebb634646c0ee2a1298402ec10a5fe7af79df9a51c1bfd9"}, {file = "contourpy-1.1.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:189ceb1525eb0655ab8487a9a9c41f42a73ba52d6789754788d1883fb06b2d8a"}, @@ -404,6 +407,7 @@ files = [ {file = "contourpy-1.1.0-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:143dde50520a9f90e4a2703f367cf8ec96a73042b72e68fcd184e1279962eb6f"}, {file = "contourpy-1.1.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e94bef2580e25b5fdb183bf98a2faa2adc5b638736b2c0a4da98691da641316a"}, {file = "contourpy-1.1.0-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:ed614aea8462735e7d70141374bd7650afd1c3f3cb0c2dbbcbe44e14331bf002"}, + {file = "contourpy-1.1.0-cp39-cp39-win32.whl", hash = "sha256:71551f9520f008b2950bef5f16b0e3587506ef4f23c734b71ffb7b89f8721999"}, {file = "contourpy-1.1.0-cp39-cp39-win_amd64.whl", hash = "sha256:438ba416d02f82b692e371858143970ed2eb6337d9cdbbede0d8ad9f3d7dd17d"}, {file = "contourpy-1.1.0-pp38-pypy38_pp73-macosx_10_9_x86_64.whl", hash = "sha256:a698c6a7a432789e587168573a864a7ea374c6be8d4f31f9d87c001d5a843493"}, {file = "contourpy-1.1.0-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:397b0ac8a12880412da3551a8cb5a187d3298a72802b45a3bd1805e204ad8439"}, @@ -1283,6 +1287,17 @@ files = [ [package.dependencies] traitlets = "*" +[[package]] +name = "more-itertools" +version = "10.1.0" +description = "More routines for operating on iterables, beyond itertools" +optional = false +python-versions = ">=3.8" +files = [ + {file = "more-itertools-10.1.0.tar.gz", hash = "sha256:626c369fa0eb37bac0291bce8259b332fd59ac792fa5497b59837309cd5b114a"}, + {file = "more_itertools-10.1.0-py3-none-any.whl", hash = "sha256:64e0735fcfdc6f3464ea133afe8ea4483b1c5fe3a3d69852e6503b43a0b222e6"}, +] + [[package]] name = "nbformat" version = "5.9.2" @@ -2584,4 +2599,4 @@ gel = ["matplotlib", "pillow", "scipy"] [metadata] lock-version = "2.0" python-versions = ">=3.8" -content-hash = "f9116f198349f8f2ea56eed13d222b048cbb2eeeb24363c01ae8a5e469341e14" +content-hash = "bbe87d96b3360fc1aca076e1d1c33c9a31b5313b2602a4be5ba4fc597e228aea" diff --git a/pyproject.toml b/pyproject.toml index 4bd81c66..267e240c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -45,6 +45,7 @@ pillow = { version = ">=8.4.0", optional = true } pyparsing = { version = ">=2.4.7", optional = true } requests = { version = ">=2.26.0", optional = true } cai2 = { version = ">=1.0.5", optional = true } +more-itertools = "^10.1.0" [tool.poetry.extras] clipboard = ["pyperclip"] gel = ["scipy", "matplotlib", "pillow"] diff --git a/src/pydna/dseq.py b/src/pydna/dseq.py index 703d436e..2100ef9e 100644 --- a/src/pydna/dseq.py +++ b/src/pydna/dseq.py @@ -22,7 +22,6 @@ import math as _math from pydna.seq import Seq as _Seq -from Bio.Restriction import FormattedSeq as _FormattedSeq from Bio.Seq import _translate_str from pydna._pretty import pretty_str as _pretty_str @@ -32,9 +31,10 @@ from pydna.utils import flatten as _flatten from pydna.common_sub_strings import common_sub_strings as _common_sub_strings -from operator import itemgetter as _itemgetter from Bio.Restriction import RestrictionBatch as _RestrictionBatch from Bio.Restriction import CommOnly +# Pairwise only exists in normal itertools after python 3.10 +from more_itertools import pairwise as _pairwise class Dseq(_Seq): @@ -1506,7 +1506,7 @@ def get_cutsite_pairs(self, cutsites): # Add the first cutsite at the end, for circular cuts cutsites.append(cutsites[0]) - return list(_itertools.pairwise(cutsites)) + return list(_pairwise(cutsites)) if __name__ == "__main__": diff --git a/tests/test_module_dseq.py b/tests/test_module_dseq.py index 34346458..459fbb81 100644 --- a/tests/test_module_dseq.py +++ b/tests/test_module_dseq.py @@ -551,12 +551,12 @@ def test_dseq(): assert obj.cut(rb) == obj.cut(BamHI, BglII) == obj.cut(BglII, BamHI) obj = Dseq("ggatccAGATCT", circular=True) - - assert obj.cut(rb) == obj.cut(BamHI, BglII) != obj.cut(BglII, BamHI) + # TODO: address this test change Related to https://github.com/BjornFJohansson/pydna/issues/78 + assert obj.cut(rb) == obj.cut(BamHI, BglII) == obj.cut(BglII, BamHI) obj = Dseq("AGATCTggatcc", circular=True) - assert obj.cut(rb) == obj.cut(BglII, BamHI) != obj.cut(BamHI, BglII) + assert obj.cut(rb) == obj.cut(BglII, BamHI) == obj.cut(BamHI, BglII) def test_Dseq_slicing(): @@ -585,7 +585,7 @@ def test_Dseq_slicing2(): from Bio.Restriction import BamHI, EcoRI, KpnI a = Dseq("aaGGATCCnnnnnnnnnGAATTCccc", circular=True) - + # TODO: address this test change Related to https://github.com/BjornFJohansson/pydna/issues/78 assert ( a.cut( EcoRI, @@ -596,7 +596,7 @@ def test_Dseq_slicing2(): BamHI, EcoRI, KpnI, - )[::-1] + ) )