Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Sequence position finder2
#R version 3.4.4 ################ # Short version # seq <- "--ABC-----DA--" # allchars <- strsplit(seq, "")[[1]] # names(allchars) <- c(1:length(allchars)) # letters <- allchars[allchars!="-"] ###################################################### # Long version with comments and console visualization seq <- "--ABC-----DA--" print("Original sequence") print(seq) # split sequence to a vector char by char allchars <- strsplit(seq, "")[[1]] # create numeric names for each char (to have their position) names(allchars) <- c(1:length(allchars)) # print named vector just to see it, but it's not needed for our final purpose print("Full sequence (indexed)") for(key in names(allchars)){ value <- allchars[key] print(paste(key,'=',value)) } # create another vector without dash characters # this will also remove the non-interesting numeric names while # keeping their original position letters <- allchars[allchars!="-"] # letters is a named vector with the values that we want print("Letters positions in original sequence") for(key in names(letters)){ value <- letters[key] print(paste('The letter',value,'is in position',as.integer(key))) }
run
|
edit
|
history
|
help
0
16-09-2020ExVitorb
Practice series1(37)
Hello, world!
Gab1A(resumido)
At matrix division
Roll of a two dice
test
BoxPlot_Anomaly
Ass2 q2
YD