function [match_hamming, match_pos ] = align_no_internal_gaps(target, query, max_start)
%#codegen

ltarget = length(target);
lquery = length(query);

min_start = 1;
max_start = min(max_start, ltarget - lquery + 1);
match_hamming = 100;
match_pos = 0;

for i_start = min_start:max_start
   new_match_hamming = sum(target(i_start: i_start + lquery-1)~=query);
   if new_match_hamming < match_hamming
       match_hamming = new_match_hamming;
       match_pos = i_start;
   end
end

end