% Jim Dickson 
% June 2007
% For our current problem the first terminator can reside in the 8th..12th
% position of Amber's model and create a false positive. This program tells
% how to weight the false positives of each of these lengths that Amber's
% program finds. This program takes into account the orientation of edges.
% Edges refers to the number of edges in the graph. Therefore we often
% consider edges+1 as in her model Amber includes the promoter. 
edges=14
nodes=7
falsepositives=[];
for T=8
B=T-nodes+1
E=edges+1-T
d = [0:E-1]
[b1,b2] = ndgrid(d,d)
X = [b1(:),b2(:)]   
X_good = [];
for i = 1:length(X)
if sum(X(i,:))==E-1
    X_good=[X_good;X(i,:)];
end
end
X_good(:,B)=X_good(:,B)+1
X_good
A=factorial(X_good)
falses=sum(prod(A'))
falsepositives(T)=falses*2^E
end
for T=9
B=T-nodes+1
E=edges+1-T
d = [0:E-1]
[b1,b2,b3] = ndgrid(d,d,d)
X = [b1(:),b2(:),b3(:)]   
X_good = [];
for i = 1:length(X)
if sum(X(i,:))==E-1
    X_good=[X_good;X(i,:)];
end
end
X_good(:,B)=X_good(:,B)+1
X_good
A=factorial(X_good)
falses=sum(prod(A'))
falsepositives(T)=falses*2^E
end
for T=10
B=T-nodes+1
E=edges+1-T
d = [0:E-1]
[b1,b2,b3,b4] = ndgrid(d,d,d,d)
X = [b1(:),b2(:),b3(:),b4(:)]   
X_good = [];
for i = 1:length(X)
if sum(X(i,:))==E-1
    X_good=[X_good;X(i,:)];
end
end
X_good(:,B)=X_good(:,B)+1
X_good
A=factorial(X_good)
falses=sum(prod(A'))
falsepositives(T)=falses*2^E
end
for T=11
B=T-nodes+1
E=edges+1-T
d = [0:E-1]
[b1,b2,b3,b4,b5] = ndgrid(d,d,d,d,d)
X = [b1(:),b2(:),b3(:),b4(:),b5(:)]   
X_good = [];
for i = 1:length(X)
if sum(X(i,:))==E-1
    X_good=[X_good;X(i,:)];
end
end
X_good(:,B)=X_good(:,B)+1
X_good
A=factorial(X_good)
falses=sum(prod(A'))
falsepositives(T)=falses*2^E
end
for T=12
B=T-nodes+1
E=edges+1-T
d = [0:E-1]
[b1,b2,b3,b4,b5,b6] = ndgrid(d,d,d,d,d,d)
X = [b1(:),b2(:),b3(:),b4(:),b5(:),b6(:)]   
X_good = [];
for i = 1:size(X)
if sum(X(i,:))==E-1
    X_good=[X_good;X(i,:)];
end
end
X_good(:,B)=X_good(:,B)+1
X_good
A=factorial(X_good)
falses=sum(prod(A'))
falsepositives(T)=falses*2^E
end
