@@ -2440,7 +2440,6 @@ def get_ds_meltsites(self: DseqType, length: int) -> List[CutSiteType]:
24402440 if self .circular :
24412441 spacer = length
24422442 cutfrom = self ._data [- length :] + self ._data + self ._data [:length ]
2443- print (cutfrom )
24442443 else :
24452444 spacer = 0
24462445 cutfrom = self ._data
@@ -2561,8 +2560,13 @@ def melt(self, length):
25612560 cutsites = new .get_ds_meltsites (length )
25622561
25632562 cutsite_pairs = self .get_cutsite_pairs (cutsites )
2563+ cutsite_pairs = self .shift_melt_cutsite_pairs (cutsite_pairs )
25642564
2565- result = tuple (new .apply_cut (* cutsite_pair ) for cutsite_pair in cutsite_pairs )
2565+ result = tuple (
2566+ new .apply_cut (* cutsite_pair , allow_overlap = True )
2567+ for cutsite_pair in cutsite_pairs
2568+ )
2569+ print (result )
25662570
25672571 result = tuple ([new ]) if strands and not result else result
25682572
@@ -2763,9 +2767,6 @@ def apply_cut(
27632767 left_watson , left_crick , ovhg_left = self .get_cut_parameters (left_cut , True )
27642768 right_watson , right_crick , _ = self .get_cut_parameters (right_cut , False )
27652769
2766- print ("%%" )
2767- print (self [left_watson :right_watson ])
2768- print (self [left_crick :right_crick ])
27692770 return Dseq (
27702771 self [left_watson :right_watson ]._data .translate (dscode_to_watson_table ),
27712772 self [left_crick :right_crick ]
@@ -2836,45 +2837,58 @@ def shift_melt_cutsite_pairs(
28362837 ss_crick_bytes = set (ss_letters_crick .encode ("ascii" ))
28372838 ss_watson_bytes = set (ss_letters_watson .encode ("ascii" ))
28382839 n = len (self ._data )
2839- data = self ._data * 2 if self . circular else self . _data
2840+ is_circular = self .circular
28402841
28412842 new_cutsite_pairs = []
28422843 for left_cut , right_cut in cutsite_pairs :
28432844 if left_cut is not None :
28442845 (watson , ovhg ), enz = left_cut
2845- crick = watson - ovhg
28462846 if ovhg > 0 :
2847- while watson < len (data ) and data [watson ] in ss_crick_bytes :
2847+ for _ in range (n ):
2848+ if (not is_circular and watson >= n ) or self ._data [
2849+ watson % n
2850+ ] not in ss_crick_bytes :
2851+ break
28482852 watson += 1
2853+ ovhg += 1
28492854 elif ovhg < 0 :
2850- while crick < len (data ) and data [crick ] in ss_watson_bytes :
2851- crick += 1
2852- if self .circular :
2853- left_cut = ((watson % n , (watson % n ) - (crick % n )), enz )
2855+ for _ in range (n ):
2856+ if (not is_circular and watson - ovhg >= n ) or self ._data [
2857+ (watson - ovhg ) % n
2858+ ] not in ss_watson_bytes :
2859+ break
2860+ ovhg -= 1
2861+ if is_circular :
2862+ left_cut = ((watson % n , ovhg % n ), enz )
28542863 else :
2855- left_cut = ((watson , watson - crick ), enz )
2864+ left_cut = ((watson , ovhg ), enz )
28562865
28572866 if right_cut is not None :
28582867 (watson , ovhg ), enz = right_cut
2859- crick = watson - ovhg
28602868 if ovhg > 0 :
2861- while crick > 0 and data [crick - 1 ] in ss_watson_bytes :
2862- crick -= 1
2869+ for _ in range (n ):
2870+ if (not is_circular and watson - ovhg <= 0 ) or self ._data [
2871+ (watson - ovhg - 1 ) % n
2872+ ] not in ss_watson_bytes :
2873+ break
2874+ ovhg += 1
28632875 elif ovhg < 0 :
2864- while watson > 0 and data [watson - 1 ] in ss_crick_bytes :
2876+ for _ in range (n ):
2877+ if (not is_circular and watson <= 0 ) or self ._data [
2878+ (watson - 1 ) % n
2879+ ] not in ss_crick_bytes :
2880+ break
28652881 watson -= 1
2866- if self .circular :
2867- right_cut = ((watson % n , (watson % n ) - (crick % n )), enz )
2882+ ovhg -= 1
2883+ if is_circular :
2884+ right_cut = ((watson % n , ovhg % n ), enz )
28682885 else :
2869- right_cut = ((watson , watson - crick ), enz )
2886+ right_cut = ((watson , ovhg ), enz )
28702887
28712888 new_cutsite_pairs .append ((left_cut , right_cut ))
28722889
28732890 if self .circular :
2874- new_cutsite_pairs = [
2875- cut for pair in deduplicate (new_cutsite_pairs ) for cut in pair
2876- ]
2877-
2891+ new_cutsite_pairs = deduplicate (new_cutsite_pairs )
28782892 return new_cutsite_pairs
28792893
28802894 def get_parts (self ):
0 commit comments