Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. input <- "g.chr17:7577121G>A"
  2. input <- sub("^([^.]+\.)([^:]+:)", "\2\1", input)
  3. input
  4.  
  5. [1] "chr17:g.7577121G>A"
  6.  
  7. ^ from the beginning of the input
  8. ([^.]+\.) match and capture any non dot characters up to and including
  9. the first dot
  10. ([^:]+:) then match and capture any non colon characters up to and
  11. including the first colon
  12.  
  13. sub("(^.{2})(.*:)(.*)", "\2\1\3", x)
  14. #[1] "chr17:g.7577121G>A" "chr3:g.52712586T>C"
  15.  
  16. x <- c("g.chr17:7577121G>A", "g.chr3:52712586T>C")
  17.  
  18. v1 <- strsplit(input, "[.:]")[[1]]
  19. paste0(v1[2], ":", v1[1], ".", v1[3])
  20. #[1] "chr17:g.7577121G>A"
  21.  
  22. input <- "g.chr17:7577121G>A"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement