Bioinformatics/Subsequence: Difference between revisions

Line 74:
 
=={{header|Phix}}==
Note: match_all() is due to become a builtin in the next release, so the version below may or may not need renaming/deleting before it will run.<br>
Currently only searches for non-overlapped sequences, but it should be pretty obviuous how to change that, in which case the next underline will simply partially overwrite the previous, so you'll get eg "<=<==>".
<lang Phix>constant cheat = false
 
Line 119 ⟶ 120:
end procedure
 
function match_all(object needle, sequence haystack, bool bOverlap = false)
if atom(needle) then return find_all(needle,haystack) end if
integer start = 1
sequence res = {}
Line 126 ⟶ 128:
if start=0 then exit end if
res = append(res,start)
start += iff(bOverlap?1:length(needle))
end while
return res
7,818

edits