
R version 4.1.0 (2021-05-18) -- "Camp Pontanezen"
Copyright (C) 2021 The R Foundation for Statistical Computing
Platform: x86_64-w64-mingw32/x64 (64-bit)

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)
> data(longreads)
> N <- 32
> sequences <- longreads$connection[1:N]
> 
> # specify Levenshtein (should get two warnings)
> sc1 <- SequenceCluster(sequences, method = "levenshtein", NC = 4)
Warning messages:
1: In SequenceCluster(sequences, method = "levenshtein", NC = 4) :
  Adding names to input sequences.
2: In SequenceCluster(sequences, method = "levenshtein", NC = 4) :
  Removing 6 duplicated sequences.

> plot(sc1@hc)
> 
> # after assigning names, should get one warning
> names(sequences) <- rownames(longreads)[1:N]
> sc1 <- SequenceCluster(sequences, method = "levenshtein", NC = 4)
Warning message:
In SequenceCluster(sequences, method = "levenshtein", NC = 4) :
  Removing 6 duplicated sequences.

> 
> # after removing duplicates, should get no warnings
> sequences <- sequences[!duplicated(sequences)]
> sc1 <- SequenceCluster(sequences, method = "levenshtein", NC = 4)
> 
> # default Needelman-Wunsch
> sc <- SequenceCluster(sequences, NC = 4)
> plot(sc)
> # Other plot forms
> plot(sc, type = "clipped")
> plot(sc, type = "unrooted")
> 
> 
> # make sure unknown methods fail.
> try( sc <- SequenceCluster(sequences, method = "clustal") )
Error in match.arg(method) : 
  'arg' should be one of "needelman", "levenshtein"
> try( sc3 <- SequenceCluster(sequences, method = "leven") ) # Now OK
> 
> # same with unknown plot types
> try( plot(sc, type = "doodle") )
Error in match.arg(type, types) : 
  'arg' should be one of "rooted", "clipped", "unrooted"
> 
> #### update cluster number
> sc <- updateClusters(sc, NC = 3)
> plot(sc, type = "unrooted")
> 
> proc.time()
   user  system elapsed 
   1.92    0.28    2.21 
