Loop help

anyone know how I can loop looking at a sequence? like if i have
acgtacgt
how can i first look at acgt and then cgta etc?

For your example there you can use RegEx to do it.

A pattern like this:code(\w{4})[/code] will find “acgt” and “cgta” as two separate matches.

http://documentation.xojo.com/index.php/RegEx

If you’re having a lot of variation you may have to process the characters one by one. Good luck

or something like

dim segmentLength as integer dim mySequence as string = "acgtacgt" segmentlength = 4 // change this to change the number of bases you look at for i as integer = 1 to len(mySequence)-segmentLength // do something with mid(mySequence, i, segmentLength) next

(I haven’t checked this code, but you get the idea.)
Not sure which is faster, this or the RegEx - probably the regex, but I include this as another way of looking at it.

@Hamish,

that makes sense thank you! do you know how i could incorporate two strings so it finds matches between the two?

Can you give an example?

Boyer moore or one of the other search algorithms using a memory block might be very useful

You might also read https://forum.xojo.com/6646-finding-string-matches/34#p46963 as this fellow is doing the same thing
There are several decent algorithms that might work
Knuth-Morris-Pratt
Boyer–Moore
Rabin–Karp
Aho–Corasick

And then there were plugins from Theodore Smith called “Elf data” that someone was using to do something similar
I’ve not seen or heard from Theo in a long while though