BjornFJohansson / pydna

Clone with Python! Data structures for double stranded DNA & simulation of homologous recombination, Gibson assembly, cut & paste cloning.
Other
160 stars 39 forks source link

Error when extracting composed features from overhangs #181

Open manulera opened 5 months ago

manulera commented 5 months ago

Not a priority to fix, but still a bug.

seq = Dseq.from_full_sequence_and_overhangs('AATTAA', 2, 2)
print(seq.__repr__())

# Extract simple features
loc = SimpleLocation(0, 2, strand=1)
print(loc, loc.extract(seq))
loc = SimpleLocation(0, 2, strand=-1)
print(loc, loc.extract(seq))

# Extract composed feature where there is no overhang
loc = SimpleLocation(2, 3, strand=1) + SimpleLocation(3, 4, strand=1)
print(loc, loc.extract(seq))
# Raises error on overhang
loc = SimpleLocation(0, 1, strand=1) + SimpleLocation(1, 2, strand=1)
print(loc, loc.extract(seq))

returns

Dseq(-6)
  TTAA
TTAA
[0:2](+) AA
[0:2](-) TT
join{[2:3](+), [3:4](+)} TT
Traceback (most recent call last):
  File "/Users/Manu/Documents/OpenSource/pydna/dummy.py", line 78, in <module>
    print(loc, loc.extract(seq))
               ^^^^^^^^^^^^^^^^
  File "/Users/Manu/Documents/OpenSource/pydna/.venv/lib/python3.11/site-packages/Bio/SeqFeature.py", line 1774, in extract
    f_seq = functools.reduce(lambda x, y: x + y, parts)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/Manu/Documents/OpenSource/pydna/.venv/lib/python3.11/site-packages/Bio/SeqFeature.py", line 1774, in <lambda>
    f_seq = functools.reduce(lambda x, y: x + y, parts)
                                          ~~^~~
  File "/Users/Manu/Documents/OpenSource/pydna/src/pydna/dseq.py", line 1049, in __add__
    raise TypeError("sticky ends not compatible!")
TypeError: sticky ends not compatible!