 function [N_offtargets,OFF_TARGETS_TS] = Nboffsearch (target)
load GENOTEK_BENTHAMIANA;

%% Searches for the 3N-PAM 5'-> 3' region of the gRNA among the potential off-target sequences in GENOTEK
positions_PAM = {};
loc=[];
for i=1:size(GENOTEK,2)
    positions_half{i} = strfind(GENOTEK{1,i},target(end-5:end)); 
    if positions_half{i}>0
        loc = [loc,{i}];
    end
end
for j=1:size(loc,2)
    loc{2,j} = positions_half{1,loc{1,j}};
end
off={};
score_off=[];
for j=1:size(loc,2)
    for k=1:size(loc{2,j},2)
        base=loc{2,j}(k);
        off{j,k}={GENOTEK{1,loc{1,j}}(base-14:base+5)};
        scoor(j,k)=swalign(target,off{j,k}{1},'GapOpen',20);
        score_off(loc{1,j},k)=swalign(target,off{j,k}{1},'GapOpen',20);
    end
end
score_target=swalign(target,target,'GapOpen',20);
[coor1,coor2]=find(scoor>=(0.5*score_target));
for l=1:length(coor1)
    off_target{l}=off{coor1(l),coor2(l)};
end
N_offtargets = length(off_target);
OFF_TARGETS_TS = off_target;
end
 
