jmbm

Fig_11

Oct 10th, 2022 (edited)
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
R 1.02 KB | None | 0 0
  1. pdf("fig_11.pdf", width = 5, height = 5)
  2. par(bty = "n", las = 1, mar = c(5, 5, 1, 1) + 0.2)
  3.  
  4. # función suma armónicos
  5. sum_arm <- function(n) {
  6.   a <- numeric(n)
  7.   for (i in 1:n) {
  8.     for (j in 1:i) {
  9.       a[j] <- a[j] + 1/i
  10.     }
  11.   }
  12.   a/n
  13. }
  14.  
  15. # la secuencia de un archivo txt
  16. sec <- readChar("secuencia.txt", file.info("secuencia.txt")$size)
  17.  
  18. # posiciones de las metioninas
  19. mets <- unlist(gregexpr("M", sec))
  20. # distancias entre ellas
  21. n <- length(mets) - 1
  22. distancias <- numeric(n)
  23. for (i in 1:n) {
  24.   distancias[i] <- mets[i + 1] - mets[i]
  25. }
  26. # ordenar de mayor a menor distancia
  27. distancias <- sort(distancias, decreasing = TRUE)
  28. # gráfico
  29. plot(distancias, type = "h", lwd = 2, bty = "n", xaxt = "n", xlab = "Rango",
  30.      ylab = "Distancia (residuos)", xlim = c(1, 17))
  31. axis(1, at = 1:n, labels = 1:n)
  32. longitud <- sum(distancias)
  33. lines(longitud * sum_arm(n), col = "red", lwd = 2)
  34. legend("topright", bty = "n", cex = 0.8, c("observado", "teórico"), lty = 1, lwd = 2, col = c("black", "red"))
  35.  
  36. dev.off()
Advertisement
Add Comment
Please, Sign In to add comment