diff --git a/src/pydna/dseq.py b/src/pydna/dseq.py index 01c1d598..219a9bc9 100644 --- a/src/pydna/dseq.py +++ b/src/pydna/dseq.py @@ -15,7 +15,6 @@ """ import math as _math import copy as _copy -import itertools as _itertools import re as _re import inspect as _inspect @@ -48,6 +47,18 @@ from Bio.Restriction import RestrictionBatch as _RestrictionBatch from Bio.Restriction import CommOnly +try: + from itertools import pairwise as _pairwise +except ImportError: + + def _pairwise(iterable): + # pairwise('ABCDEFG') → AB BC CD DE EF FG + iterator = iter(iterable) + a = next(iterator, None) + for b in iterator: + yield a, b + a = b + pos_w_enz = _namedtuple("enzpos", "position enzyme recsite") from typing import ( @@ -1421,7 +1432,7 @@ def __repr__(self): cutpairs = [] - for (w1, e1, s1), (w2, e2, s2) in _itertools.pairwise(cutsites): + for (w1, e1, s1), (w2, e2, s2) in _pairwise(cutsites): table1 = {True: to_5tail_table, False: to_3tail_table}[e1.is_3overhang()] table2 = {True: to_5tail_table, False: to_3tail_table}[e2.is_5overhang()]