
R version 4.5.0 (2025-04-11 ucrt) -- "How About a Twenty-Six"
Copyright (C) 2025 The R Foundation for Statistical Computing
Platform: x86_64-w64-mingw32/x64

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(SVAlignR)
> 
> ## single byte
> data(longreads)
> raw <- longreads$connection
> alfa <- Cipher(raw)
> coded <- encode(alfa, raw)
> makeWords(coded, 3)

AAA AAD AAE AAb ADA ADY AEA AFK AKH AKN ALN APR AbB AbU Abd Abg Abm Abo Abq Afq 
 55  14   1  26  18   1   1   4   1  13   4   6   3  11   1   1   1   1  95   1 
Ahq Ajq Alq Anq Ass BrA Bss DAA DAD DAb EAA FKN GAb IAb KNM KNq LNq MNq NMN NqA 
  1   2   1   2   1   1   1   9   2   5   1   3   1   2   6  11   3   4   6  11 
Nqk Nss OqP PRA PRc QqP RAA RAC RAP RAb RAf RAn Rcq STA TAb Tsb UVA UaA VAD WAA 
 20   1   3  54   6   1   2   2   1  38   2   2   6   4   4   1   1   1   1   1 
aAA aAZ bBr bBs bUV bUa bdq bgA bmA bpb bqA bqG bqP bqS bqb bqe bqk cqP dqP eqP 
 12   1   1   1   1   1   2   1   1   1  71   1  15   8   5   8   4   6   3  10 
fqP gAb hqA iQq jqA jqk kqA kqk lqA mAb nqP pbq qAA qAF qAK qAL qAP qAb qAj qAl 
  1   1   1   1   1   1  21   6   1   1   2   1  19   3  23   3   3  44   6   1 
qAs qGA qPR qST qbq qeq qkq qks rAA sAb sAs sFK sNq sNs sTs sbq ssA ssF ssN sss 
  1   1  51   6   8   9  29   1   1   1   1   1   1   1   1   1   1   1   2   1 
> countWords(coded, 3)

AAA AAD AAE AAb ADA ADY AEA AFK AKH AKN ALN APR AbB AbU Abd Abg Abm Abo Abq Afq 
 55  14   1  26  18   1   1   4   1  13   4   6   3  11   1   1   1   1  95   1 
Ahq Ajq Alq Anq Ass BrA Bss DAA DAD DAb EAA FKN GAb IAb KNM KNq LNq MNq NMN NqA 
  1   2   1   2   1   1   1   9   2   5   1   3   1   2   6  11   3   4   6  11 
Nqk Nss OqP PRA PRc QqP RAA RAC RAP RAb RAf RAn Rcq STA TAb Tsb UVA UaA VAD WAA 
 20   1   3  54   6   1   2   2   1  38   2   2   6   4   4   1   1   1   1   1 
aAA aAZ bBr bBs bUV bUa bdq bgA bmA bpb bqA bqG bqP bqS bqb bqe bqk cqP dqP eqP 
 12   1   1   1   1   1   2   1   1   1  71   1  15   8   5   8   4   6   3  10 
fqP gAb hqA iQq jqA jqk kqA kqk lqA mAb nqP pbq qAA qAF qAK qAL qAP qAb qAj qAl 
  1   1   1   1   1   1  21   6   1   1   2   1  19   3  23   3   3  44   6   1 
qAs qGA qPR qST qbq qeq qkq qks rAA sAb sAs sFK sNq sNs sTs sbq ssA ssF ssN sss 
  1   1  51   6   8   9  29   1   1   1   1   1   1   1   1   1   1   1   2   1 
> countWords(coded, 3, alfa)
   0-0-0   0-0-14   0-0-15   0-0-50   0-14-0  0-14-45   0-15-0  0-17-25 
      55       14        1       26       18        1        1        4 
 0-25-23  0-25-28  0-26-28  0-32-34  0-50-12  0-50-37  0-50-52  0-50-57 
       1       13        4        6        3       11        1        1 
 0-50-65  0-50-70  0-50-74  0-56-74  0-58-74  0-60-74  0-63-74  0-66-74 
       1        1       95        1        1        2        1        2 
   0-x-x  12-75-0   12-x-x   14-0-0  14-0-14  14-0-50   15-0-0 17-25-28 
       1        1        1        9        2        5        1        3 
 19-0-50  24-0-50 25-28-27 25-28-74 26-28-74 27-28-74 28-27-28  28-74-0 
       1        2        6       11        3        4        6       11 
28-74-61   28-x-x 31-74-32  32-34-0 32-34-51 33-74-32   34-0-0  34-0-13 
      20        1        3       54        6        1        2        2 
 34-0-32  34-0-50  34-0-56  34-0-66 34-51-74  35-36-0  36-0-50  36-x-50 
       1       38        2        2        6        4        4        1 
 37-38-0  37-48-0  38-0-14   40-0-0   48-0-0  48-0-46 50-12-75  50-12-x 
       1        1        1        1       12        1        1        1 
50-37-38 50-37-48 50-52-74  50-57-0  50-65-0 50-71-50  50-74-0 50-74-19 
       1        1        2        1        1        1       71        1 
50-74-32 50-74-35 50-74-50 50-74-54 50-74-61 51-74-32 52-74-32 54-74-32 
      15        8        5        8        4        6        3       10 
56-74-32  57-0-50  58-74-0  6-33-74  60-74-0 60-74-61  61-74-0 61-74-61 
       1        1        1        1        1        1       21        6 
 63-74-0  65-0-50 66-74-32 71-50-74   74-0-0  74-0-17  74-0-25  74-0-26 
       1        1        2        1       19        3       23        3 
 74-0-32  74-0-50  74-0-60  74-0-63   74-0-x  74-19-0 74-32-34 74-35-36 
       3       44        6        1        1        1       51        6 
74-50-74 74-54-74 74-61-74  74-61-x   75-0-0   x-0-50    x-0-x  x-17-25 
       8        9       29        1        1        1        1        1 
 x-28-74   x-28-x   x-36-x  x-50-74    x-x-0   x-x-17   x-x-28    x-x-x 
       1        1        1        1        1        1        2        1 
> 
> IT <- intToUtf8(L <- c(38:44, 46:57, 59:62, 64:126)) ## omit hyphen, colon, and question
> JT <- paste(strsplit(IT, "|")[[1]], collapse = "-")
> beta <- Cipher(JT)
Warning message:
In Cipher(JT) : Input has more than 72 letters. Using two-byte codes.

> 
> twob <- encode(beta, JT)
> double <- c(twob, twob)
> countWords(double, 3)       # don't do this

!A@ #A$ $A% %A^ &A| ,BA /A, 0A! 1A2 2A3 3A4 4A5 5A6 6A7 7A8 8A9 9A0 ;A/ @A# A!A 
  2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2 
A#A A$A A%A A&A A,B A/A A0A A1A A2A A3A A4A A5A A6A A7A A8A A9A A;A A@A AAA AAB 
  2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2 
ABA ABB ACA ADA AEA AFA AGA AHA AIA AKA ALA AMA ANA AOA APA AQA ARA ASA ATA AUA 
  2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2 
AVA AWA AYA AZA A^A A_A AaA AbA AcA AdA AeA AfA AgA AhA AiA AjA AkA AlA AmA AnA 
  2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2 
AoA ApA AqA ArA AsA AtA AuA AvA AwA AxA AyA AzA A|A BAB BAC BBB BBC BCB BDB BEB 
  2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2 
BFB BGB BHB BIB BKB BLB BMB BNB CAD CBD DAE DBE EAF EBF FAG FBG GAH GBH HAI HBI 
  2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2 
IAK IBK KAL KBL LAM LBM MAN MBN NAO NBO OAP PAQ QAR RAS SAT TAU UAV VAW WAY YAZ 
  2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2 
ZAa ^A& _A; aAb bAc cAd dAe eAf fAg gAh hAi iAj jAk kAl lAm mAn nAo oAp pAq qAr 
  2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2 
rAs sAt tAu uAv vAw wAx xAy yAz zA1 |A_ 
  2   2   2   2   2   2   2   2   2   2 
> countWords(double, 3, beta) # this is right
 e-f-g  g-h-i  h-i-j  i-j-k  k-l-m  p-q-r  o-p-q  d-e-f [-\\-] \\-]-^  ]-^-_ 
     2      2      2      2      2      2      2      2      2      2      2 
 ^-_-`  _-`-a  `-a-b  a-b-c  b-c-d  c-d-e  n-o-p  f-g-h  &-'-(  '-(-)  (-)-* 
     2      2      2      2      2      2      2      2      2      2      2 
 )-*-+  *-+-,  +-,-.  ,-.-/  .-/-0  /-0-1  0-1-2  1-2-3  2-3-4  3-4-5  4-5-6 
     2      2      2      2      2      2      2      2      2      2      2 
 5-6-7  6-7-8  7-8-9  8-9-;  9-;-<  ;-<-=  <-=->  =->-@  >-@-A  @-A-B  j-k-l 
     2      2      2      2      2      2      2      2      2      2      2 
 m-n-o  A-B-C  B-C-D  C-D-E  D-E-F  E-F-G  F-G-H  G-H-I  H-I-J  I-J-K  J-K-L 
     2      2      2      2      2      2      2      2      2      2      2 
 K-L-M  L-M-N  M-N-O  N-O-P  O-P-Q  P-Q-R  Q-R-S  R-S-T  S-T-U  T-U-V  U-V-W 
     2      2      2      2      2      2      2      2      2      2      2 
 V-W-X  W-X-Y  X-Y-Z  Y-Z-[ Z-[-\\  l-m-n  q-r-s  r-s-t  s-t-u  t-u-v  u-v-w 
     2      2      2      2      2      2      2      2      2      2      2 
 v-w-x  w-x-y  x-y-z  y-z-{  z-{-|  {-|-}  |-}-~ 
     2      2      2      2      2      2      2 
> 
> makeWords(double, 3)    # don't do this

!A@ #A$ $A% %A^ &A| ,BA /A, 0A! 1A2 2A3 3A4 4A5 5A6 6A7 7A8 8A9 9A0 ;A/ @A# A!A 
  2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2 
A#A A$A A%A A&A A,B A/A A0A A1A A2A A3A A4A A5A A6A A7A A8A A9A A;A A@A AAA AAB 
  2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2 
ABA ABB ACA ADA AEA AFA AGA AHA AIA AKA ALA AMA ANA AOA APA AQA ARA ASA ATA AUA 
  2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2 
AVA AWA AYA AZA A^A A_A AaA AbA AcA AdA AeA AfA AgA AhA AiA AjA AkA AlA AmA AnA 
  2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2 
AoA ApA AqA ArA AsA AtA AuA AvA AwA AxA AyA AzA A|A BAB BAC BBB BBC BCB BDB BEB 
  2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2 
BFB BGB BHB BIB BKB BLB BMB BNB CAD CBD DAE DBE EAF EBF FAG FBG GAH GBH HAI HBI 
  2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2 
IAK IBK KAL KBL LAM LBM MAN MBN NAO NBO OAP PAQ QAR RAS SAT TAU UAV VAW WAY YAZ 
  2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2 
ZAa ^A& _A; aAb bAc cAd dAe eAf fAg gAh hAi iAj jAk kAl lAm mAn nAo oAp pAq qAr 
  2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2 
rAs sAt tAu uAv vAw wAx xAy yAz zA1 |A_ 
  2   2   2   2   2   2   2   2   2   2 
> makeWords(double, 3, 2) # this is right

A!A@A# A#A$A% A$A%A^ A%A^A& A&A|A_ A,BABB A/A,BA A0A!A@ A1A2A3 A2A3A4 A3A4A5 
     2      2      2      2      2      2      2      2      2      2      2 
A4A5A6 A5A6A7 A6A7A8 A7A8A9 A8A9A0 A9A0A! A;A/A, A@A#A$ AAABAC ABACAD ACADAE 
     2      2      2      2      2      2      2      2      2      2      2 
ADAEAF AEAFAG AFAGAH AGAHAI AHAIAK AIAKAL AKALAM ALAMAN AMANAO ANAOAP AOAPAQ 
     2      2      2      2      2      2      2      2      2      2      2 
APAQAR AQARAS ARASAT ASATAU ATAUAV AUAVAW AVAWAY AWAYAZ AYAZAa AZAaAb A^A&A| 
     2      2      2      2      2      2      2      2      2      2      2 
A_A;A/ AaAbAc AbAcAd AcAdAe AdAeAf AeAfAg AfAgAh AgAhAi AhAiAj AiAjAk AjAkAl 
     2      2      2      2      2      2      2      2      2      2      2 
AkAlAm AlAmAn AmAnAo AnAoAp AoApAq ApAqAr AqArAs ArAsAt AsAtAu AtAuAv AuAvAw 
     2      2      2      2      2      2      2      2      2      2      2 
AvAwAx AwAxAy AxAyAz AyAzA1 AzA1A2 A|A_A; BABBBC BBBCBD BCBDBE BDBEBF BEBFBG 
     2      2      2      2      2      2      2      2      2      2      2 
BFBGBH BGBHBI BHBIBK BIBKBL BKBLBM BLBMBN BMBNBO 
     2      2      2      2      2      2      2 
> 
> m <- lapply(1:8, function(J) countWords(coded, J, alfa))
> plotWords(3, m)
> 
> M <- lapply(1:8, function(J) countWords(double, J, beta))
> plotWords(2, M)
> 
> proc.time()
   user  system elapsed 
   2.04    0.10    2.15 
