Description of KeggDrawTable

Home > BiKEGG > KeggDrawTable.m

# KeggDrawTable

## PURPOSE

KeggDrawTable(GUI)

## SYNOPSIS

function varargout = KeggDrawTable(varargin)

## DESCRIPTION

     KeggDrawTable(GUI)

     O. Jamialahmadi
     TMU, Chem. Eng. Dept., Biotech. Group
     Nov. 2015

## CROSS-REFERENCE INFORMATION

This function calls:

This function is called by:

- KeggDraw KeggDraw
- NetDraw NetDraw

## SUBFUNCTIONS

- function KeggDrawTable_OpeningFcn(hObject, eventdata, handles, varargin)
- function varargout = KeggDrawTable_OutputFcn(hObject, eventdata, handles)
- function pushbutton1_Callback(hObject, eventdata, handles)
- function KeggListbox_Callback(hObject, eventdata, handles)
- function KeggListbox_CreateFcn(hObject, eventdata, handles)
- function Rxnuitable_CellEditCallback(hObject, eventdata, handles)
- function ResultListbox_Callback(hObject, eventdata, handles)
- function ResultListbox_CreateFcn(hObject, eventdata, handles)

## SOURCE CODE

    0001 function varargout = KeggDrawTable(varargin)
    0002 % KeggDrawTable(GUI)
    0003 %
    0004 % O. Jamialahmadi
    0005 % TMU, Chem. Eng. Dept., Biotech. Group
    0006 % Nov. 2015
    0007
    0008 % Begin initialization code - DO NOT EDIT
    0009 gui_Singleton = 1;
    0010 gui_State = struct('gui_Name',       mfilename, ...
    0011                    'gui_Singleton',  gui_Singleton, ...
    0012                    'gui_OpeningFcn', @KeggDrawTable_OpeningFcn, ...
    0013                    'gui_OutputFcn',  @KeggDrawTable_OutputFcn, ...
    0014                    'gui_LayoutFcn',  [] , ...
    0015                    'gui_Callback',   []);
    0016 if nargin && ischar(varargin{1})
    0017     gui_State.gui_Callback = str2func(varargin{1});
    0018 end
    0019
    0020 if nargout
    0021     [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
    0022 else
    0023     gui_mainfcn(gui_State, varargin{:});
    0024 end
    0025 % End initialization code - DO NOT EDIT
    0026
    0027
    0028 % --- Executes just before KeggDrawTable is made visible.
    0029 function KeggDrawTable_OpeningFcn(hObject, eventdata, handles, varargin)
    0030 % This function has no output args, see OutputFcn.
    0031 % hObject    handle to figure
    0032 % eventdata  reserved - to be defined in a future version of MATLAB
    0033 % handles    structure with handles and user data (see GUIDATA)
    0034 % varargin   command line arguments to KeggDrawTable (see VARARGIN)
    0035 CurrentMap = getappdata(0,'CurrentMap');
    0036 CurrentMap1 = ['Map: ',CurrentMap];
    0037 set(handles.text2,'String',CurrentMap1)
    0038 RptRxns = getappdata(0,'RptRxns');
    0039 ListData = {0};
    0040 for ct = 1:numel(RptRxns)
    0041     ListData{ct} = RptRxns{ct}{1};
    0042     data1{ct} = 'Not slected';
    0043 end
    0044 set(handles.KeggListbox,'String',ListData);
    0045 set(handles.ResultListbox,'String',data1);
    0046 % Choose default command line output for KeggDrawTable
    0047 handles.output = hObject;
    0048
    0049 % Update handles structure
    0050 guidata(hObject, handles);
    0051
    0052 % UIWAIT makes KeggDrawTable wait for user response (see UIRESUME)
    0053 % uiwait(handles.figure1);
    0054
    0055
    0056 % --- Outputs from this function are returned to the command line.
    0057 function varargout = KeggDrawTable_OutputFcn(hObject, eventdata, handles)
    0058 % varargout  cell array for returning output args (see VARARGOUT);
    0059 % hObject    handle to figure
    0060 % eventdata  reserved - to be defined in a future version of MATLAB
    0061 % handles    structure with handles and user data (see GUIDATA)
    0062
    0063 % Get default command line output from handles structure
    0064 varargout{1} = handles.output;
    0065
    0066
    0067 % --- Executes on button press in pushbutton1.
    0068 function pushbutton1_Callback(hObject, eventdata, handles)
    0069 % hObject    handle to pushbutton1 (see GCBO)
    0070 % eventdata  reserved - to be defined in a future version of MATLAB
    0071 % handles    structure with handles and user data (see GUIDATA)
    0072 data1 = getappdata(0,'data1');
    0073 setappdata(0,'data1',data1);
    0074 close(gcf)
    0075
    0076 % --- Executes on selection change in KeggListbox.
    0077 function KeggListbox_Callback(hObject, eventdata, handles)
    0078 % hObject    handle to KeggListbox (see GCBO)
    0079 % eventdata  reserved - to be defined in a future version of MATLAB
    0080 % handles    structure with handles and user data (see GUIDATA)
    0081 RptFlx = getappdata(0,'RptFlx');
    0082 RptBiggs = getappdata(0,'RptBiggs');
    0083 ListChoice = get(handles.KeggListbox, 'Value');
    0084 ColNm = size(RptFlx{ListChoice},2);
    0085 for ct=1:ColNm
    0086     ColNm1{ct} = num2str(ct);
    0087 end
    0088 columnname = {'check' , ColNm1{:}};
    0089 CurrentSize = size(RptFlx{ListChoice},1);
    0090 checkBox = num2cell(false(CurrentSize,1));
    0091 columnformat = {'logical','numeric'};
    0092 columneditable = true;
    0093 Y = num2cell(RptFlx{ListChoice});
    0094 MixedData = [checkBox Y];
    0095 set(handles.Rxnuitable,'Data',MixedData)
    0096 set(handles.Rxnuitable,'ColumnFormat',columnformat)
    0097 set(handles.Rxnuitable,'ColumnName',columnname)
    0098 set(handles.Rxnuitable,'ColumnEditable',columneditable)
    0099 set(handles.Rxnuitable, 'RowName', RptBiggs{ListChoice})
    0100
    0101 % URptRxns = unique(RptRxns
    0102
    0103 % Hints: contents = cellstr(get(hObject,'String')) returns KeggListbox contents as cell array
    0104 %        contents{get(hObject,'Value')} returns selected item from KeggListbox
    0105
    0106
    0107 % --- Executes during object creation, after setting all properties.
    0108 function KeggListbox_CreateFcn(hObject, eventdata, handles)
    0109 % hObject    handle to KeggListbox (see GCBO)
    0110 % eventdata  reserved - to be defined in a future version of MATLAB
    0111 % handles    empty - handles not created until after all CreateFcns called
    0112
    0113 % Hint: listbox controls usually have a white background on Windows.
    0114 %       See ISPC and COMPUTER.
    0115 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    0116     set(hObject,'BackgroundColor','white');
    0117 end
    0118
    0119
    0120 % --- Executes when entered data in editable cell(s) in Rxnuitable.
    0121 function Rxnuitable_CellEditCallback(hObject, eventdata, handles)
    0122 % hObject    handle to Rxnuitable (see GCBO)
    0123 % eventdata  structure with the following fields (see UITABLE)
    0124 %    Indices: row and column indices of the cell(s) edited
    0125 %    PreviousData: previous data for the cell(s) edited
    0126 %    EditData: string(s) entered by the user
    0127 %    NewData: EditData or its converted form set on the Data property. Empty if Data was not changed
    0128 %    Error: error string when failed to convert EditData to appropriate value for Data
    0129 % handles    structure with handles and user data (see GUIDATA)
    0130 data=get(hObject,'Data'); % get the data cell array of the table
    0131 cols=get(hObject,'ColumnFormat'); % get the column formats
    0132 if strcmp(cols(eventdata.Indices(2)),'logical') % if the column of the edited cell is logical
    0133     if eventdata.EditData % if the checkbox was set to true
    0134         data{eventdata.Indices(1),eventdata.Indices(2)}=true; % set the data value to true
    0135     else % if the checkbox was set to false
    0136         data{eventdata.Indices(1),eventdata.Indices(2)}=false; % set the data value to false
    0137     end
    0138 end
    0139 set(hObject,'Data',data); % now set the table's data to the updated data cell array
    0140
    0141 RptBiggs = getappdata(0,'RptBiggs');
    0142 KeggChoice = get(handles.KeggListbox, 'Value');
    0143 BiggSelect = data(:,1); BiggSelect = [BiggSelect{:}];
    0144 BiggInd = find(BiggSelect);
    0145 data1 = get(handles.ResultListbox,'String');
    0146 if numel(BiggInd) ==1
    0147     data1{KeggChoice} = RptBiggs{KeggChoice}{BiggInd};
    0148     set(handles.ResultListbox,'String',data1)
    0149     NoteStr = ['BiGG ID: ',data1{KeggChoice},' is selected'];
    0150     set(handles.text1,'String',NoteStr)
    0151     setappdata(0,'data1',data1)
    0152 elseif numel(BiggInd)>1
    0153     NoteStr = 'Warning: More than one BiGG ID is selected!';
    0154     set(handles.text1,'String',NoteStr)
    0155 else
    0156     data1{KeggChoice} = 'Not slected';
    0157     set(handles.ResultListbox,'String',data1)
    0158     NoteStr = 'Warning: No BiGG ID is selected!';
    0159     set(handles.text1,'String',NoteStr)
    0160     setappdata(0,'data1',data1)
    0161 end
    0162
    0163
    0164 % --- Executes on selection change in ResultListbox.
    0165 function ResultListbox_Callback(hObject, eventdata, handles)
    0166 % hObject    handle to ResultListbox (see GCBO)
    0167 % eventdata  reserved - to be defined in a future version of MATLAB
    0168 % handles    structure with handles and user data (see GUIDATA)
    0169
    0170 % Hints: contents = cellstr(get(hObject,'String')) returns ResultListbox contents as cell array
    0171 %        contents{get(hObject,'Value')} returns selected item from ResultListbox
    0172
    0173
    0174 % --- Executes during object creation, after setting all properties.
    0175 function ResultListbox_CreateFcn(hObject, eventdata, handles)
    0176 % hObject    handle to ResultListbox (see GCBO)
    0177 % eventdata  reserved - to be defined in a future version of MATLAB
    0178 % handles    empty - handles not created until after all CreateFcns called
    0179
    0180 % Hint: listbox controls usually have a white background on Windows.
    0181 %       See ISPC and COMPUTER.
    0182 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    0183     set(hObject,'BackgroundColor','white');
    0184 end