close all
clc

% the path of the toolbox
addpath('MATLAB/BNPBN/');
addpath('MATLAB/BNPBN/BNPBN');
% add path to the directory that contains TruthTable.m, 
% TruthTable_del_a_temp.m, and TruthTable_del_n_temp.m

% Boolean model of T-LGL_Survival_Network_2011 from paper:
% "Dynamical and Structural Analysis
% of a T Cell Survival Network Identifies Novel Candidate Therapeutic 
% Targets for Large Granular Lymphocyte Leukemia (2011).
% Saadatpour A et al. PLoS Comput Biol. 2011 Nov;7(11):e1002267.

%Number of inputs
n = 16;
p = 2;

% Variables for 16 nodes:x1=CREB,x2=IFNG,x3=P2,x4=GPCR,x5=SMAD,x6=Fas,
% x7=sFAs,x8=Ceramide,x9=DISC,x10=Caspase,x11=FLIP,x12=BID,x13=IAP,
% x14=MCL1,x15=S1P,x16=Apoptosis.

varF=load('T_LGL_varF16.txt');

nv=load('T_LGL_nv16.txt');

F = load('T_LGL_tt16.txt');

% delete nodes temporarily
% Cnodes = ( 8 );% Ceramide
% Cnodes = ( 9 );% DISC
% Cnodes = ( 10 );% Caspase
% Cnodes = ( 12 );% BID
% Cnodes = ( 14 );% MCL1, OFF
% Cnodes = ( 15 );% S1P, OFF
% Cnodes = ( 6 );% Fas, ON and
Cnodes = ( 7 );% sFas, OFF and
% F1_temp = TruthTable_del_n_temp(F,nv,varF,p,Cnodes,1);
F1_temp = TruthTable_del_n_temp(F,nv,varF,p,Cnodes,0);

Cnodes1 = ( 11 );% FLIP OFF
F2_temp = TruthTable_del_n_temp(F1_temp,nv,varF,p,Cnodes1,0);

% [~,Avec] = bnAsparse(F,varF,nv);
% [~,Avec] = bnAsparse(F1_temp,varF,nv);
[~,Avec] = bnAsparse(F2_temp,varF,nv);

% show te atractos and their respective basins
[ab,dd] = bnAttractor(Avec);

attrs =  unique(ab(ab<0));
disp(attrs)
% find(ab==-1)
% x = dec2multistate(49-1,p,n)
% length(find(ab==2))
