Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- input <- "g.chr17:7577121G>A"
- input <- sub("^([^.]+\.)([^:]+:)", "\2\1", input)
- input
- [1] "chr17:g.7577121G>A"
- ^ from the beginning of the input
- ([^.]+\.) match and capture any non dot characters up to and including
- the first dot
- ([^:]+:) then match and capture any non colon characters up to and
- including the first colon
- sub("(^.{2})(.*:)(.*)", "\2\1\3", x)
- #[1] "chr17:g.7577121G>A" "chr3:g.52712586T>C"
- x <- c("g.chr17:7577121G>A", "g.chr3:52712586T>C")
- v1 <- strsplit(input, "[.:]")[[1]]
- paste0(v1[2], ":", v1[1], ".", v1[3])
- #[1] "chr17:g.7577121G>A"
- input <- "g.chr17:7577121G>A"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement