Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Blog
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
Please
log in
to post a comment.
14-09-2020GRam
Tablet-Sprite-image-Interval
26-08-2020AjusteCurvab
test
Dbinom
print next number using linear
Sampling Distribution for the Wald-Wolfowitz 2-Sample Runs Test
Sierpinski curve
iron-anova-dbc
First wall
Please log in to post a comment.