function rawData = prepData(libAss, pdb, user)

if isempty(user.nmrDrawTabFileName)
    
    if strcmp(user.intensityFileNumLetter, 'num')
        
        fprintf('\n\nReading and processing the intensity file\n\n')
        
        intensityFile = load(user.intensityFileName);
                        
        for j = 1:size(intensityFile,1)
        
            if user.magOriginSpin == 1
            
                rawData(j).procAss.ASSi                  = intensityFile(j,1);
                rawData(j).procAss.ASSi_resName          = [];
                rawData(j).procAss.ATOMi                 = [];
                rawData(j).procAss.ATOMi_NUMCODE         = intensityFile(j,2);
                rawData(j).procAss.ATOMi_MARKLEY         = [];
                
                rawData(j).procAss.ASSj                  = intensityFile(j,3);
                rawData(j).procAss.ASSj_resName          = [];
                rawData(j).procAss.ATOMj                 = [];
                rawData(j).procAss.ATOMj_NUMCODE         = intensityFile(j,4);
                rawData(j).procAss.ATOMj_MARKLEY         = [];
            
            elseif user.magOriginSpin == 2
            
                rawData(j).procAss.ASSi                  = intensityFile(j,3);
                rawData(j).procAss.ASSi_resName          = [];
                rawData(j).procAss.ATOMi                 = [];
                rawData(j).procAss.ATOMi_NUMCODE         = intensityFile(j,4);
                rawData(j).procAss.ATOMi_MARKLEY         = [];
                
                rawData(j).procAss.ASSj                  = intensityFile(j,1);
                rawData(j).procAss.ASSj_resName          = [];
                rawData(j).procAss.ATOMj                 = [];
                rawData(j).procAss.ATOMj_NUMCODE         = intensityFile(j,2);
                rawData(j).procAss.ATOMj_MARKLEY         = [];
        
            end
        
                
                k = length(user.mixing_times);
                for i = 1:length(user.mixing_times)                    
                    rawData(j).procAss.INVintensities(i) = intensityFile(j,k + 4)  * 1/user.scaleFactor(i);
                    k = k - 1;
                end
                
        end
                
                seq                                     = pdbreadSeqFun(pdb);
                [rawData, stopFlag]                    	= matchSeqFun(rawData, seq);
    
                if stopFlag == 1
                    beep off
                    error('Check your assignment and pdb file!')
                end
                
                rawData                                 = numCode2markleyFun(rawData);
        
    else
        
        fprintf('\n\nReading and processing the intensity file\n\n')
        FID             = fopen(user.intensityFileName);
        if FID          == -1, error('Cannot open file'), end;
        Data         = textscan(FID, '%s', 'delimiter', '\n', 'whitespace', '');
        fclose(FID);
    
        count.peaks = 1;
        for j=1:length(Data{1,1})
            Data2{count.peaks,1} = textscan(Data{1,1}{j},'%s');
            count.peaks = count.peaks + 1;
        end
    
        for j=1:length(Data2)
            for i = 1:length(Data2{1,1}{1,1})
                intensityFile{j,i} = Data2{j,1}{1,1}{i};
            
            end
        
        end
                
        for j = 1:size(intensityFile,1)
        
            if user.magOriginSpin == 1
                
                rawData(j).line                          = intensityFile(j,:);
                rawData(j).procAss.ASSi                  = str2num(intensityFile{j,1});
                rawData(j).procAss.ASSi_resName          = intensityFile{j,2};
                rawData(j).procAss.ATOMi                 = intensityFile{j,3};
                rawData(j).procAss.ATOMi_NUMCODE         = [];
                rawData(j).procAss.ATOMi_MARKLEY         = [];
            
                rawData(j).procAss.ASSj                  = str2num(intensityFile{j,4});
                rawData(j).procAss.ASSj_resName          = intensityFile{j,5};
                rawData(j).procAss.ATOMj                 = intensityFile{j,6};
                rawData(j).procAss.ATOMj_NUMCODE         = [];
                rawData(j).procAss.ATOMj_MARKLEY         = [];
            
            elseif user.magOriginSpin == 2
            
                rawData(j).line                          = intensityFile(j,:);
                rawData(j).procAss.ASSi                  = str2num(intensityFile{j,4});
                rawData(j).procAss.ASSi_resName          = intensityFile{j,5};
                rawData(j).procAss.ATOMi                 = intensityFile{j,6};
                rawData(j).procAss.ATOMi_NUMCODE         = [];
                rawData(j).procAss.ATOMi_MARKLEY         = [];
            
                rawData(j).procAss.ASSj                  = str2num(intensityFile{j,1});
                rawData(j).procAss.ASSj_resName          = intensityFile{j,2};
                rawData(j).procAss.ATOMj                 = intensityFile{j,3};
                rawData(j).procAss.ATOMj_NUMCODE         = [];
                rawData(j).procAss.ATOMj_MARKLEY         = [];
                
            end
            
                
                k = length(user.mixing_times);
                for i = 1:length(user.mixing_times)                    
                    rawData(j).procAss.INVintensities(i) = str2double(intensityFile{j,k + 6})  * 1/user.scaleFactor(i);
                    k = k - 1;
                end
            
        end

    [rawData, stopFlag]                                 = ass2numCodeFun(rawData, libAss);
    
    if stopFlag == 1
        beep off
        error('Check your assignment and setting for assignment standard!')
    end
        
    end

    
elseif ~isempty(user.nmrDrawTabFileName)
    
    [nmrDrawTabUnique, nmrDrawTabOverlap]               = nmrDrawTabFun(user);
    nmrDrawTabUnique                                    = intensitiesFun(nmrDrawTabUnique,user);
    seq                                                 = pdbreadSeqFun(pdb);
    [nmrDrawTabUnique, stopFlag]                        = matchSeqFun(nmrDrawTabUnique, seq);
    
    if stopFlag == 1
        beep off
        error('Check your assignment and pdb file!')
    end
    
    [nmrDrawTabUnique, stopFlag]                      	= ass2numCodeFun(nmrDrawTabUnique, libAss);
            
    if stopFlag == 1
        beep off
        error('Check your assignment and setting for assignment standard!')
    end
    
    
    rawData                                             = nmrDrawTabUnique;
    
    
    out.rawDataCount    = 1;
    for j = 1:length(rawData)
        
        k = length(user.mixing_times);
        for i = 1:length(user.mixing_times)
            rawData(j).procAss.INVintensities(i)     =...
            rawData(j).procAss.(sprintf('intensity_%d',k - 1))  * 1/user.scaleFactor(i);
            k = k - 1;
        end
        
        out.rawDataCount = out.rawDataCount + 1;
    end    
end

% % % % temp.mixing_times   = user.mixing_times;
% % % % temp.num_mix_t      = length(temp.mixing_times);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% take the absolute value of the intensities if requested

if user.absIntensities == 1
    
    diary on
    fprintf('\nAbsolute value of intensities used (user.absIntensities = 0 to disable)\n')
    diary off
    
    for j = 1:length(rawData)
        for i = 1:length(user.mixing_times)
            rawData(j).procAss.INVintensities(i) =...
            abs(rawData(j).procAss.INVintensities(i));
        end
    end
end




%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% assign pdb serial number

for j = 1:length(rawData)
    
    ASS                                 = rawData(j).procAss.ASSi;
    ATOM                                = rawData(j).procAss.ATOMi_NUMCODE;
    ATOM_pdbSerNo                       = pdbSerNoFun(ASS,ATOM,pdb);
    
    rawData(j).procAss.ATOMi_pdbSerNo   = ATOM_pdbSerNo;
    
    if isempty(ATOM_pdbSerNo)
        
        diary('on')
        fprintf(['\nNOT all assignments have been matched to the pdb file'...
             '\nInspect: ', num2str(rawData(j).procAss.ASSi), ' ', rawData(j).procAss.ATOMi, ' ' ...
                          , num2str(rawData(j).procAss.ASSj), ' ', rawData(j).procAss.ATOMj ...
             '\n'])
        diary('off')
        
    end
    
    ASS                                 = rawData(j).procAss.ASSj;
    ATOM                                = rawData(j).procAss.ATOMj_NUMCODE;
    ATOM_pdbSerNo                       = pdbSerNoFun(ASS,ATOM,pdb);
    
    rawData(j).procAss.ATOMj_pdbSerNo   = ATOM_pdbSerNo;
    
    if isempty(ATOM_pdbSerNo)
        
        diary('on')
        fprintf(['\nNOT all assignments have been matched to the pdb file'...
             '\nInspect: ', num2str(rawData(j).procAss.ASSi), ' ',rawData(j).procAss.ATOMi, ' ' ...
                          , num2str(rawData(j).procAss.ASSj), ' ',rawData(j).procAss.ATOMj ...
             '\n\n'])
        diary('off')
        
    end
    
end

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