The package HDMD
has a MolecularEntropy
function that also works on DNA in a very simple manner. It ignores non-ACGT characters or gaps and seems to use the formula H = − ∑ p*log(p) p= frequence of the base to calculate entropy. So I am not sure this is what you are after.
Your simple example would yield something like this (frequencies are always 1, so entropies are all 0):
library(HDMD)
#> Loading required package: psych
#> Loading required package: MASS
fa <- c(">sequence_1", "ACCTGC--A", ">sequence_2", "ACC-GCTTA", ">sequence_3",
"ACCTGCTTA")
fa <- grep(">",fa, invert = TRUE, value = TRUE)
MolecularEntropy(fa, type="DNA")
#> [1] "Warning: Data set contains non-nucleotide elements"
#> $counts
#> [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9]
#> A 3 0 0 0 0 0 0 0 3
#> C 0 3 3 0 0 3 0 0 0
#> G 0 0 0 0 3 0 0 0 0
#> T 0 0 0 2 0 0 2 2 0
#>
#> $freq
#> [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9]
#> A 1 0 0 0 0 0 0 0 1
#> C 0 1 1 0 0 1 0 0 0
#> G 0 0 0 0 1 0 0 0 0
#> T 0 0 0 1 0 0 1 1 0
#>
#> $H
#> [1] 0 0 0 0 0 0 0 0 0
Created on 2020-06-26 by the reprex package (v0.3.0)