%mBuildBPButtons.m
% if isfield(handles, 'h')
%     delete(handles.h) %Delete the handles for these buttons if they were built before
% end

set(handles.ScoreValue_Title,'Visible','off'), set(handles.ScoreValue,'Visible','off')

if isempty(findall(0,'Tag','AA')) %%%So buttons will be created only once
    for i=1:6
        for j=1:6
            if i==1,
                try %some of the 6 may not exist, depending on ShowNs and ShowGaps
                    handles.h(i+6,j) = uicontrol('Tag',strcat(BPs{i,j},'titlebar'),'Style','text','Units','normalized','Position',[(0.109+0.082*j) (0.802) .078 .04],'String',Bases{j},'Background',[.502 .502 1],'FontName','Courier New','FontUnits','points','FontSize',15.0);
                end
            end
            if j==1,
                try %some of the 6 may not exist, depending on ShowNs and ShowGaps
                    handles.h(i,j+6) = uicontrol('Tag',strcat(BPs{i,j},'titlebar'),'Style','text','Units','normalized','Position',[(0.109) (0.802-0.045*i) .078 .04],'String',Bases{i},'Background',[.502 .502 1],'FontName','Courier New','FontUnits','points','FontSize',15.0);
                end
            end
            try %some of the 6 may not exist, depending on ShowNs and ShowGaps
                if ~isnan(VALUE(i,j,1,P))
                    handles.h(i,j) = uicontrol('Tag',BPs{i,j},'Units','normalized','Position',[(0.109+0.082*j) (0.802-0.045*i) .078 .04],'String',num2str(VALUE(i,j,1,P)),'FontUnits','points','FontSize',10);
                else
                    handles.h(i,j) = uicontrol('Tag',BPs{i,j},'Units','normalized','Position',[(0.109+0.082*j) (0.802-0.045*i) .078 .04],'String','','FontUnits','points','FontSize',10);
                end
                set(handles.h(i,j),'Callback',{@Pushbutton_Callback,handles}); %THIS IS VERY IMPORTANT, TO MAKE THIS OBJECT INTERACT WITH OTHER GUI OBJECTS CREATED BY GUIDE
                if strcmp(Sequences(OrgInd(1),UnivBas(1,:)),BPs{i,j}) && isempty(regexpi(OrganismName{1},'univ'))
                    set(handles.h(i,j),'FontUnits','points','FontSize',14);
                end
            end
        end
    end
    set(handles.ImposeColor,'Visible','on');
    
else
    for i=1:6
        for j=1:6
            try
                if ~isnan(VALUE(i,j,1,P))
                    set(handles.h(i,j),'String',num2str(VALUE(i,j,1,P)));
                else
                    set(handles.h(i,j),'String','');
                end
            end
        end
    end
end
ShowBPButtons
% guidata(hObject, handles); Done in the one-by-one GUI

