is there a way to convert a sequence (in my case a fastA character vector) into a IRanges object based on a numeric vector? the vector contains the positions of a specific pattern in the fastA sequence.
> myseq "MKLSVNEAQLGFPESLKTGQMMDESDEDFKELCASFFQRVKKHGIKEVSGE" > Positions <- words.pos("K", myseq)  2 17 30 41 42 46
I would like to convert the sequence into a IRanges object were the positions of the pattern give me the end positions of each range in the list. the start position should be one bigger than the last end position
it should be something like that:
IRanges object with 90 ranges and 0 metadata columns: start end width <integer> <integer> <integer>  1 2 2  3 17 15  18 30 13 ...
What I have until now is this:
> Start <- c(1, Positions+1) > End <- c(Positions, nchar(myseq)) > myRanges <- IRanges(start = Start, end = End)
Is there a more efficient method to do it?
I also have the constrain here, that I take the positions as the end position, But what if i want to have it at the beginning pf my pattern and not the end?
thanks for any advices