Skip to content

Commit

Permalink
remove old cut2
Browse files Browse the repository at this point in the history
  • Loading branch information
manulera committed Nov 24, 2023
1 parent c3863c7 commit 1bd4e18
Showing 1 changed file with 4 additions and 45 deletions.
49 changes: 4 additions & 45 deletions src/pydna/dseqrecord.py
Original file line number Diff line number Diff line change
Expand Up @@ -1293,7 +1293,7 @@ def shifted(self, shift):
answer.seq = newseq
return answer

def cut2(self, *enzymes):
def cut(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 @@ -1330,46 +1330,10 @@ def cut2(self, *enzymes):
"""
from pydna.utils import shift_location

features = _copy.deepcopy(self.features)

if self.circular:
try:
x, y, oh = self.seq._firstcut(*enzymes)
except ValueError:
return ()
dsr = _Dseq(
self.seq.watson[x:] + self.seq.watson[:x],
self.seq.crick[y:] + self.seq.crick[:y],
oh,
)
newstart = min(x, (self.seq.length - y))
for f in features:
f.location = shift_location(f.location, -newstart, self.seq.length)
f.location, *rest = f.location.parts
for part in rest:
if 0 in part:
f.location._end = part.end + self.seq.length
else:
f.location += part
frags = dsr.cut(enzymes) or [dsr]
else:
frags = self.seq.cut(enzymes)
if not frags:
return ()
dsfs = []
for fr in frags:
dsf = Dseqrecord(fr, n=self.n)
start = fr.pos
end = fr.pos + fr.length
dsf.features = [
_copy.deepcopy(fe) for fe in features if start <= fe.location.start and end >= fe.location.end
]
for feature in dsf.features:
feature.location += -start
dsfs.append(dsf)
return tuple(dsfs)
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)

def apply_cut(self, left_cut, right_cut):
dseq = self.seq.apply_cut(left_cut, right_cut)
Expand All @@ -1387,11 +1351,6 @@ def apply_cut(self, left_cut, right_cut):

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")
_os.environ["pydna_cache"] = "nocache"
Expand Down

0 comments on commit 1bd4e18

Please sign in to comment.