Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- pdf("fig_11.pdf", width = 5, height = 5)
- par(bty = "n", las = 1, mar = c(5, 5, 1, 1) + 0.2)
- # función suma armónicos
- sum_arm <- function(n) {
- a <- numeric(n)
- for (i in 1:n) {
- for (j in 1:i) {
- a[j] <- a[j] + 1/i
- }
- }
- a/n
- }
- # la secuencia de un archivo txt
- sec <- readChar("secuencia.txt", file.info("secuencia.txt")$size)
- # posiciones de las metioninas
- mets <- unlist(gregexpr("M", sec))
- # distancias entre ellas
- n <- length(mets) - 1
- distancias <- numeric(n)
- for (i in 1:n) {
- distancias[i] <- mets[i + 1] - mets[i]
- }
- # ordenar de mayor a menor distancia
- distancias <- sort(distancias, decreasing = TRUE)
- # gráfico
- plot(distancias, type = "h", lwd = 2, bty = "n", xaxt = "n", xlab = "Rango",
- ylab = "Distancia (residuos)", xlim = c(1, 17))
- axis(1, at = 1:n, labels = 1:n)
- longitud <- sum(distancias)
- lines(longitud * sum_arm(n), col = "red", lwd = 2)
- legend("topright", bty = "n", cex = 0.8, c("observado", "teórico"), lty = 1, lwd = 2, col = c("black", "red"))
- dev.off()
Advertisement
Add Comment
Please, Sign In to add comment