From 7d22e5fd7585192998f79d00f23b20c648e05172 Mon Sep 17 00:00:00 2001 From: Manuel Lera-Ramirez Date: Wed, 22 Nov 2023 19:02:02 +0000 Subject: [PATCH] WIP --- src/pydna/dseq.py | 9 +++++++-- tests/test_module_dseq.py | 6 ++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/pydna/dseq.py b/src/pydna/dseq.py index 764c0265..703d436e 100644 --- a/src/pydna/dseq.py +++ b/src/pydna/dseq.py @@ -1482,9 +1482,12 @@ def apply_cut(self, left_cut, right_cut): left_watson, left_crick = left_cut[0] ovhg = 0 if left_cut[1] is None else left_cut[1].ovhg right_watson, right_crick = right_cut[0] + # TODO: this fills up nucleotides when it should not. It should either use the watson and crick + # sequences as they are, or use the ovhg to shift the start or finish. return Dseq( str(self[left_watson:right_watson]), - _rc(str(self[left_crick:right_crick])), + # The line below could be easier to understand as _rc(str(self[left_crick:right_crick])), but it does not preserve the case + str(self.reverse_complement()[len(self) - right_crick:len(self) - left_crick]), ovhg=ovhg, ) @@ -1494,7 +1497,9 @@ def get_cutsite_pairs(self, cutsites): if len(cutsites) == 1 and self.circular: return [(cutsites[0], cutsites[0])] if not self.circular: - cutsites = [((0, 0), None), *cutsites, ((len(self), len(self)), None)] + left_edge = ((0 if self.ovhg < 0 else self.ovhg, 0 if self.ovhg < 0 else -self.ovhg), None) + right_edge = ((left_edge[0][0] + len(self.watson), left_edge[0][1] + len(self.crick)), None) + cutsites = [left_edge, *cutsites, right_edge] else: # Return in the same order as previous pydna versions cutsites = [cutsites[-1]] + cutsites[:-1] diff --git a/tests/test_module_dseq.py b/tests/test_module_dseq.py index 4851c3a0..34346458 100644 --- a/tests/test_module_dseq.py +++ b/tests/test_module_dseq.py @@ -442,6 +442,12 @@ def test_dseq(): frag1 = Dseq("G", "gatcc", 0) frag2 = Dseq("GATCCaaa", "g", -4) + print(obj.__repr__()) + print(obj.cut(BamHI)[0].__repr__()) + print(frag1.__repr__()) + print(obj.cut(BamHI)[1].__repr__()) + print(frag2.__repr__()) + assert obj.cut(BamHI) == (frag1, frag2) assert frag1 + frag2 == obj