Skip to content

Commit

Permalink
Fixed itertools issue and modified tests , see #78
Browse files Browse the repository at this point in the history
  • Loading branch information
manulera committed Nov 23, 2023
1 parent 2aac24e commit 73ea44f
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 9 deletions.
17 changes: 16 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
6 changes: 3 additions & 3 deletions src/pydna/dseq.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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):
Expand Down Expand Up @@ -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__":
Expand Down
10 changes: 5 additions & 5 deletions tests/test_module_dseq.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down Expand Up @@ -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,
Expand All @@ -596,7 +596,7 @@ def test_Dseq_slicing2():
BamHI,
EcoRI,
KpnI,
)[::-1]
)
)


Expand Down

0 comments on commit 73ea44f

Please sign in to comment.