Skip to content

Commit

Permalink
more WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
manulera committed Nov 23, 2023
1 parent 73ea44f commit 3385265
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 9 deletions.
4 changes: 1 addition & 3 deletions src/pydna/dseq.py
Original file line number Diff line number Diff line change
Expand Up @@ -1482,8 +1482,6 @@ 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]),
# The line below could be easier to understand as _rc(str(self[left_crick:right_crick])), but it does not preserve the case
Expand All @@ -1502,7 +1500,7 @@ def get_cutsite_pairs(self, cutsites):
cutsites = [left_edge, *cutsites, right_edge]
else:
# Return in the same order as previous pydna versions
cutsites = [cutsites[-1]] + cutsites[:-1]
# cutsites = [cutsites[-1]] + cutsites[:-1]
# Add the first cutsite at the end, for circular cuts
cutsites.append(cutsites[0])

Expand Down
11 changes: 10 additions & 1 deletion src/pydna/dseqrecord.py
Original file line number Diff line number Diff line change
Expand Up @@ -1284,7 +1284,7 @@ def shifted(self, shift):
answer.seq = newseq
return answer

def cut(self, *enzymes):
def cut2(self, *enzymes):
"""Digest a Dseqrecord object with one or more restriction enzymes.
returns a list of linear Dseqrecords. If there are no cuts, an empty
Expand Down Expand Up @@ -1362,6 +1362,15 @@ def cut(self, *enzymes):
dsfs.append(dsf)
return tuple(dsfs)

def apply_cut(self, left_cut, right_cut):
dseq = self.seq.apply_cut(left_cut, right_cut)
features = self[min(left_cut[0]):max(right_cut[0])].features
return Dseqrecord(dseq, features=features)

def cut(self, *enzymes):
cutsites = self.seq.get_cutsites(*enzymes)
cutsite_pairs = self.seq.get_cutsite_pairs(cutsites)
return tuple(self.apply_cut(*cs) for cs in cutsite_pairs)

if __name__ == "__main__":
cache = _os.getenv("pydna_cache")
Expand Down
4 changes: 2 additions & 2 deletions tests/test_module_dseq.py
Original file line number Diff line number Diff line change
Expand Up @@ -728,8 +728,8 @@ def test_misc():
a, b = x.cut(NotI)

z = (a + b).looped()

assert z.shifted(5) == x
# TODO: address this test change Related to https://github.com/BjornFJohansson/pydna/issues/78
assert z.shifted(-6) == x


def test_cut_missing_enzyme():
Expand Down
9 changes: 6 additions & 3 deletions tests/test_module_dseqrecord.py
Original file line number Diff line number Diff line change
Expand Up @@ -1259,11 +1259,14 @@ def test_features_change_ori():
"""

bb, ins = sorted(b.cut(Acc65I, BamHI), key=len, reverse=True)

# pytest -s -k test_features_change_ori tests/test_module_dseqrecord.py
print('>>>>>>', str(bb))
print()
print(ins)
assert eq(bb1, bb)
assert eq(ins1, ins)

assert bb.features[0].extract(bb).seq == bbfeat
assert bb.features[1].extract(bb).seq == bbfeat
assert str(ins.features[0].extract(ins).seq) == str(insfeat)


Expand Down Expand Up @@ -1630,7 +1633,7 @@ def test_figure():
)
assert b25.extract_feature(0).seq == feat


@pytest.mark.xfail(reason="issue #78")
def test_jan_glx():
# Thanks to https://github.com/jan-glx
from Bio.Restriction import NdeI, BamHI
Expand Down

0 comments on commit 3385265

Please sign in to comment.