SHARE
TWEET

Untitled

a guest Jun 25th, 2019 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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"
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top