Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
manulera committed Nov 22, 2023
1 parent 77eaedf commit 7d22e5f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/pydna/dseq.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)

Expand All @@ -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]
Expand Down
6 changes: 6 additions & 0 deletions tests/test_module_dseq.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7d22e5f

Please sign in to comment.