%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  atomGrps2  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%   Scripts that use the grpNum and atoms:
%   NOEfitFun.m 
%   stereoAndQ2H.m, pdbNumCodeFilter
%   process_spindiffAll.m, stereo.m
%   3spin: simulations.m, rhosim


% spinDiff deut level relevant
conditions.all.exSolAtoms          = [1 51 52 53 56 57 58 61 62 63 64 65 66 67 68 70]; %> 50 && ATOMj < 70
conditions.all.methylAtoms;

if ~isfield(user, 'labelingScheme')
    user.labelingScheme           = 'n';
end


words       = regexp(user.labelingScheme, ' ', 'split');
uniqueWords = unique(words);
n           = length(uniqueWords);

words2      = regexp(words, '%', 'split');
    
vocab{1}    = 'ALA_B';
vocab{2}    = 'ILE_D1';
vocab{3}    = 'ILE_G2';
vocab{4}    = 'LEU_D1';
vocab{5}    = 'LEU_D2';
vocab{6}    = 'LEU_D1_D2';
vocab{7}    = 'MET_E';
vocab{8}    = 'THR_G2';
vocab{9}    = 'VAL_G1';
vocab{10}   = 'VAL_G2';
vocab{11}   = 'VAL_G1_G2';

count = 0;

for i=1:length(vocab)
    for j=1:length(uniqueWords)
        if strcmpi(vocab{i}, words2{j}{1,1});
            count = count + 1;
        end
    end
end


conditions.labelingScheme = struct('resLabel','DUMMY','resName','NNN','grpNum',[0],'atoms',[0],'deutLevel','0');


c = 1;

for j=1:length(uniqueWords)
if strmatch('ALA_B', words2{j}{1,1}, 'exact')
    
    conditions.labelingScheme(c).resLabel    = 'ALA_B';
    conditions.labelingScheme(c).resName     = 'ALA';
    conditions.labelingScheme(c).grpNum      = [100];
    conditions.labelingScheme(c).atoms       = [305 315 325];
    conditions.labelingScheme(c).deutLevel   = str2num(words2{j}{1,2});
    c = c + 1;
    
end

if strmatch('ILE_D1', words2{j}{1,1}, 'exact')
    
    conditions.labelingScheme(c).resLabel    = 'ILE_D1';
    conditions.labelingScheme(c).resName     = 'ILE';
    conditions.labelingScheme(c).grpNum      = [107];
    conditions.labelingScheme(c).atoms       = [250 255 260];
    conditions.labelingScheme(c).deutLevel   = str2num(words2{j}{1,2});
    c = c + 1;
    
end

if strmatch('ILE_G2', words2{j}{1,1}, 'exact')
    
    conditions.labelingScheme(c).resLabel    = 'ILE_G2';
    conditions.labelingScheme(c).resName     = 'ILE';
    conditions.labelingScheme(c).grpNum      = [103];
    conditions.labelingScheme(c).atoms       = [335 345 355];
    conditions.labelingScheme(c).deutLevel   = str2num(words2{j}{1,2});
    c = c + 1;
    
end


if strmatch('LEU_D1', words2{j}{1,1}, 'exact')
    
    conditions.labelingScheme(c).resLabel    = 'LEU_D1';
    conditions.labelingScheme(c).resName     = 'LEU';
    conditions.labelingScheme(c).grpNum      = [104];
    conditions.labelingScheme(c).atoms       = [220 230 240];
    conditions.labelingScheme(c).deutLevel   = str2num(words2{j}{1,2});
    c = c + 1;
    
end

if strmatch('LEU_D2', words2{j}{1,1}, 'exact')
    
    conditions.labelingScheme(c).resLabel    = 'LEU_D2';
    conditions.labelingScheme(c).resName     = 'LEU';
    conditions.labelingScheme(c).grpNum      = [105];
    conditions.labelingScheme(c).atoms       = [270 280 290];
    conditions.labelingScheme(c).deutLevel   = str2num(words2{j}{1,2});
    c = c + 1;
    
end


if strmatch('LEU_D1_D2', words2{j}{1,1}, 'exact')
    
    conditions.labelingScheme(c).resLabel    = 'LEU_D1_D2';
    conditions.labelingScheme(c).resName     = 'LEU';
    conditions.labelingScheme(c).grpNum      = [104 105];
    conditions.labelingScheme(c).atoms       = [220 230 240 270 280 290];
    conditions.labelingScheme(c).deutLevel   = str2num(words2{j}{1,2});
    c = c + 1;
    
end


if strmatch('MET_E', words2{j}{1,1}, 'exact')
    
    conditions.labelingScheme(c).resLabel    = 'MET_E';
    conditions.labelingScheme(c).resName     = 'MET';
    conditions.labelingScheme(c).grpNum      = [106];
    conditions.labelingScheme(c).atoms       = [365 375 385];
    conditions.labelingScheme(c).deutLevel   = str2num(words2{j}{1,2});
    c = c + 1;
    
end

if strmatch('THR_G2', words2{j}{1,1}, 'exact')
    
    conditions.labelingScheme(c).resLabel    = 'THR_G2';
    conditions.labelingScheme(c).resName     = 'THR';
    conditions.labelingScheme(c).grpNum      = [103];
    conditions.labelingScheme(c).atoms       = [335 345 355];
    conditions.labelingScheme(c).deutLevel   = str2num(words2{j}{1,2});
    c = c + 1;
    
end


if strmatch('VAL_G1', words2{j}{1,1}, 'exact')
    
    conditions.labelingScheme(c).resLabel    = 'VAL_G1';
    conditions.labelingScheme(c).resName     = 'VAL';
    conditions.labelingScheme(c).grpNum      = [101];
    conditions.labelingScheme(c).atoms       = [120 130 140];
    conditions.labelingScheme(c).deutLevel   = str2num(words2{j}{1,2});
    c = c + 1;
    
end


if strmatch('VAL_G2', words2{j}{1,1}, 'exact')
    
    conditions.labelingScheme(c).resLabel    = 'VAL_G2';
    conditions.labelingScheme(c).resName     = 'VAL';
    conditions.labelingScheme(c).grpNum      = [102];
    conditions.labelingScheme(c).atoms       = [170 180 190];
    conditions.labelingScheme(c).deutLevel   = str2num(words2{j}{1,2});
    c = c + 1;
    
end


if strmatch('VAL_G1_G2', words2{j}{1,1}, 'exact')
    
    conditions.labelingScheme(c).resLabel    = 'VAL_G1_G2';
    conditions.labelingScheme(c).resName     = 'VAL';
    conditions.labelingScheme(c).grpNum      = [101 102];
    conditions.labelingScheme(c).atoms       = [120 130 140 170 180 190];
    conditions.labelingScheme(c).deutLevel   = str2num(words2{j}{1,2});
    c = c + 1;
    
end
end

%conditions.labelingScheme

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%