function [pdbHQnumCode, lib] = pdb2numCode(pdb, lib, user)

count = 1;

if strcmp(user.noesyType,'1H')

    for i = 1:length(pdb.Model.Atom)
    
        if ~isempty(findstr('H', pdb.Model.Atom(i).AtomName)) 
        
                pdbHQnumCodeTemp.Model.Atom(count) = pdb.Model.Atom(i);
        
                count = count + 1;
        end
        
        if ~isempty(findstr('Q', pdb.Model.Atom(i).AtomName))
            
                pdbHQnumCodeTemp.Model.Atom(count) = pdb.Model.Atom(i);
        
                count = count + 1;
        
        end
    
        if ~isempty(findstr('M', pdb.Model.Atom(i).AtomName))
            
                pdbHQnumCodeTemp.Model.Atom(count) = pdb.Model.Atom(i);
        
                count = count + 1;
        
        end
    
    end
end

count = 1;

for j = 1:length(pdbHQnumCodeTemp.Model.Atom)
    
    pdbHQnumCodeTemp.Model.Atom(j).NumCode = [];
    
    for i = 1:length(lib)
    
        if strfind(pdbHQnumCodeTemp.Model.Atom(j).resName, lib(i).RESIDUE)
            
% % %             numcodeIndx = find(~cellfun('isempty', strfind(lib(i).ATOMS, pdbHQnumCodeTemp.Model.Atom(j).AtomName)),1);
            numcodeIndx = 0;
            for k = 1:length(lib(i).ATOMS)
                if strcmp(lib(i).ATOMS(k), pdbHQnumCodeTemp.Model.Atom(j).AtomName)
                    numcodeIndx = k;
                end
            end

            pdbHQnumCode.Model.Atom(count)          = pdbHQnumCodeTemp.Model.Atom(j);
            pdbHQnumCode.Model.Atom(count).NumCode  = lib(i).ATOMNUMCODES(numcodeIndx);
            
        end
    end
    
    count = count+1;
end
