Description of UpdateDBase

Home > BiKEGG > UpdateDBase.m

# UpdateDBase

## PURPOSE

UpdateDBase(GUI)

## SYNOPSIS

function varargout = UpdateDBase(varargin)

## DESCRIPTION

     UpdateDBase(GUI)
     Updating the local database of BiKEGG for offline use.

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

## CROSS-REFERENCE INFORMATION

This function calls:

- GetData4MultiRxns GetData4MultiRxns
- Weight4TransRxns Weight4TransRxns
- getKGML getKGML

This function is called by:

## SUBFUNCTIONS

- function UpdateDBase_OpeningFcn(hObject, eventdata, handles, varargin)
- function varargout = UpdateDBase_OutputFcn(hObject, eventdata, handles)
- function rxn2mappushbutton1_Callback(hObject, eventdata, handles)
- function map2cpdpushbutton_Callback(hObject, eventdata, handles)
- function KEGGmapspushbutton_Callback(hObject, eventdata, handles)
- function KEGGcpdpushbutton_Callback(hObject, eventdata, handles)
- function ec2rxnpushbutton_Callback(hObject, eventdata, handles)
- function cpd2weightpushbutton_Callback(hObject, eventdata, handles)
- function cpd2rxnpushbutton_Callback(hObject, eventdata, handles)
- function Donepushbutton8_Callback(hObject, eventdata, handles)
- function Weight4TransRxnspushbutton_Callback(hObject, eventdata, handles)
- function getKGMLpushbutton_Callback(hObject, eventdata, handles)
- function MultiRxnpushbutton_Callback(hObject, eventdata, handles)
- function Orgspushbutton_Callback(hObject, eventdata, handles)

## SOURCE CODE

    0001 function varargout = UpdateDBase(varargin)
    0002 % UpdateDBase(GUI)
    0003 % Updating the local database of BiKEGG for offline use.
    0004 %
    0005 % O. Jamialahmadi
    0006 % TMU, Chem. Eng. Dept., Biotech. Group
    0007 % Mar. 2015
    0008
    0009 % Begin initialization code - DO NOT EDIT
    0010 gui_Singleton = 1;
    0011 gui_State = struct('gui_Name',       mfilename, ...
    0012                    'gui_Singleton',  gui_Singleton, ...
    0013                    'gui_OpeningFcn', @UpdateDBase_OpeningFcn, ...
    0014                    'gui_OutputFcn',  @UpdateDBase_OutputFcn, ...
    0015                    'gui_LayoutFcn',  [] , ...
    0016                    'gui_Callback',   []);
    0017 if nargin && ischar(varargin{1})
    0018     gui_State.gui_Callback = str2func(varargin{1});
    0019 end
    0020
    0021 if nargout
    0022     [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
    0023 else
    0024     gui_mainfcn(gui_State, varargin{:});
    0025 end
    0026 % End initialization code - DO NOT EDIT
    0027
    0028
    0029 % --- Executes just before UpdateDBase is made visible.
    0030 function UpdateDBase_OpeningFcn(hObject, eventdata, handles, varargin)
    0031 % This function has no output args, see OutputFcn.
    0032 % hObject    handle to figure
    0033 % eventdata  reserved - to be defined in a future version of MATLAB
    0034 % handles    structure with handles and user data (see GUIDATA)
    0035 % varargin   command line arguments to UpdateDBase (see VARARGIN)
    0036
    0037 % Choose default command line output for UpdateDBase
    0038 handles.output = hObject;
    0039
    0040 % Update handles structure
    0041 guidata(hObject, handles);
    0042
    0043 % UIWAIT makes UpdateDBase wait for user response (see UIRESUME)
    0044 % uiwait(handles.figure1);
    0045
    0046
    0047 % --- Outputs from this function are returned to the command line.
    0048 function varargout = UpdateDBase_OutputFcn(hObject, eventdata, handles)
    0049 % varargout  cell array for returning output args (see VARARGOUT);
    0050 % hObject    handle to figure
    0051 % eventdata  reserved - to be defined in a future version of MATLAB
    0052 % handles    structure with handles and user data (see GUIDATA)
    0053
    0054 % Get default command line output from handles structure
    0055 varargout{1} = handles.output;
    0056
    0057
    0058 % --- Executes on button press in rxn2mappushbutton1.
    0059 function rxn2mappushbutton1_Callback(hObject, eventdata, handles)
    0060 % hObject    handle to rxn2mappushbutton1 (see GCBO)
    0061 % eventdata  reserved - to be defined in a future version of MATLAB
    0062 % handles    structure with handles and user data (see GUIDATA)
    0063 TestLink='http://rest.kegg.jp';
    0064 [~,Stat1]=urlread(TestLink);
    0065 if ~Stat1
    0066     msgbox({'This step requires a stable internet connection';...
    0067         'Seemingly you are offline!'});
    0068     return
    0069 end
    0070
    0071 Text1 = 'Updating rxn2map.txt...';
    0072 fprintf(Text1)
    0073 Data=urlread('http://rest.kegg.jp/link/path/rn');
    0074 Pth1 = which ('Bigg2Kegg.m');
    0075 tind = find(Pth1=='\',1,'last');
    0076 Pth = Pth1(1:tind-1);
    0077 Pth1 = [Pth,'\','rxn2map.txt'];
    0078 Idf = fopen(Pth1,'w');
    0079 fprintf(Idf,Data);
    0080 fclose(Idf);
    0081 waitfor(msgbox('rxn2map.txt was successfully updated!','Update'))
    0082 for i =1:numel(Text1)
    0083     fprintf('\b')
    0084 end
    0085 % --- Executes on button press in map2cpdpushbutton.
    0086 function map2cpdpushbutton_Callback(hObject, eventdata, handles)
    0087 % hObject    handle to map2cpdpushbutton (see GCBO)
    0088 % eventdata  reserved - to be defined in a future version of MATLAB
    0089 % handles    structure with handles and user data (see GUIDATA)
    0090 TestLink='http://rest.kegg.jp';
    0091 [~,Stat1]=urlread(TestLink);
    0092 if ~Stat1
    0093     msgbox({'This step requires a stable internet connection';...
    0094         'Seemingly you are offline!'});
    0095     return
    0096 end
    0097 Text1 = 'Updating map2cpd.txt...';
    0098 fprintf(Text1)
    0099 Data=urlread('http://rest.kegg.jp/link/cpd/path');
    0100 Pth1 = which ('Bigg2Kegg.m');
    0101 tind = find(Pth1=='\',1,'last');
    0102 Pth = Pth1(1:tind-1);
    0103 Pth1 = [Pth,'\','map2cpd.txt'];
    0104 Idf = fopen(Pth1,'w');
    0105 fprintf(Idf,Data);
    0106 fclose(Idf);
    0107 waitfor(msgbox('map2cpd.txt was successfully updated!','Update'))
    0108 for i =1:numel(Text1)
    0109     fprintf('\b')
    0110 end
    0111
    0112 % --- Executes on button press in KEGGmapspushbutton.
    0113 function KEGGmapspushbutton_Callback(hObject, eventdata, handles)
    0114 % hObject    handle to KEGGmapspushbutton (see GCBO)
    0115 % eventdata  reserved - to be defined in a future version of MATLAB
    0116 % handles    structure with handles and user data (see GUIDATA)
    0117 TestLink='http://rest.kegg.jp';
    0118 [~,Stat1]=urlread(TestLink);
    0119 if ~Stat1
    0120     msgbox({'This step requires a stable internet connection';...
    0121         'Seemingly you are offline!'});
    0122     return
    0123 end
    0124 Text1 = 'Updating KEGGmaps.txt...';
    0125 fprintf(Text1)
    0126 Data=urlread('http://rest.kegg.jp/list/pathway');
    0127 Pth1 = which ('Bigg2Kegg.m');
    0128 tind = find(Pth1=='\',1,'last');
    0129 Pth = Pth1(1:tind-1);
    0130 Pth1 = [Pth,'\','KEGGmaps.txt'];
    0131 Idf = fopen(Pth1,'w');
    0132 fprintf(Idf,Data);
    0133 fclose(Idf);
    0134 waitfor(msgbox('KEGGmaps.txt was successfully updated!','Update'))
    0135 for i =1:numel(Text1)
    0136     fprintf('\b')
    0137 end
    0138
    0139 % --- Executes on button press in KEGGcpdpushbutton.
    0140 function KEGGcpdpushbutton_Callback(hObject, eventdata, handles)
    0141 % hObject    handle to KEGGcpdpushbutton (see GCBO)
    0142 % eventdata  reserved - to be defined in a future version of MATLAB
    0143 % handles    structure with handles and user data (see GUIDATA)
    0144 TestLink='http://rest.kegg.jp';
    0145 [~,Stat1]=urlread(TestLink);
    0146 if ~Stat1
    0147     msgbox({'This step requires a stable internet connection';...
    0148         'Seemingly you are offline!'});
    0149     return
    0150 end
    0151 Text1 = 'Updating KEGGcpd.txt...';
    0152 fprintf(Text1)
    0153 Data=urlread('http://rest.kegg.jp/list/cpd');
    0154 Pth1 = which ('Bigg2Kegg.m');
    0155 tind = find(Pth1=='\',1,'last');
    0156 Pth = Pth1(1:tind-1);
    0157 Pth1 = [Pth,'\','KEGGcpd.txt'];
    0158 Idf = fopen(Pth1,'w');
    0159 fprintf(Idf,Data);
    0160 fclose(Idf);
    0161 waitfor(msgbox('KEGGcpd.txt was successfully updated!','Update'))
    0162 for i =1:numel(Text1)
    0163     fprintf('\b')
    0164 end
    0165
    0166 % --- Executes on button press in ec2rxnpushbutton.
    0167 function ec2rxnpushbutton_Callback(hObject, eventdata, handles)
    0168 % hObject    handle to ec2rxnpushbutton (see GCBO)
    0169 % eventdata  reserved - to be defined in a future version of MATLAB
    0170 % handles    structure with handles and user data (see GUIDATA)
    0171 TestLink='http://rest.kegg.jp';
    0172 [~,Stat1]=urlread(TestLink);
    0173 if ~Stat1
    0174     msgbox({'This step requires a stable internet connection';...
    0175         'Seemingly you are offline!'});
    0176     return
    0177 end
    0178 Text1 = 'Updating ec2rxn.txt...';
    0179 fprintf(Text1)
    0180 Data=urlread('http://rest.kegg.jp/link/rn/ec');
    0181 Pth1 = which ('Bigg2Kegg.m');
    0182 tind = find(Pth1=='\',1,'last');
    0183 Pth = Pth1(1:tind-1);
    0184 Pth1 = [Pth,'\','ec2rxn.txt'];
    0185 Idf = fopen(Pth1,'w');
    0186 fprintf(Idf,Data);
    0187 fclose(Idf);
    0188 waitfor(msgbox('ec2rxn.txt was successfully updated!','Update'))
    0189 for i =1:numel(Text1)
    0190     fprintf('\b')
    0191 end
    0192
    0193 % --- Executes on button press in cpd2weightpushbutton.
    0194 function cpd2weightpushbutton_Callback(hObject, eventdata, handles)
    0195 % hObject    handle to cpd2weightpushbutton (see GCBO)
    0196 % eventdata  reserved - to be defined in a future version of MATLAB
    0197 % handles    structure with handles and user data (see GUIDATA)
    0198 TestLink='http://rest.kegg.jp';
    0199 [~,Stat1]=urlread(TestLink);
    0200 if ~Stat1
    0201     msgbox({'This step requires a stable internet connection';...
    0202         'Seemingly you are offline!'});
    0203     return
    0204 end
    0205 Text1 = 'Updating cpd2weight.txt...';
    0206 fprintf(Text1)
    0207 Data=urlread('http://rest.kegg.jp/find/compound/1-9000/mol_weight');
    0208 Pth1 = which ('Bigg2Kegg.m');
    0209 tind = find(Pth1=='\',1,'last');
    0210 Pth = Pth1(1:tind-1);
    0211 Pth1 = [Pth,'\','cpd2weight.txt'];
    0212 Idf = fopen(Pth1,'w');
    0213 fprintf(Idf,Data);
    0214 fclose(Idf);
    0215 waitfor(msgbox('cpd2weight.txt was successfully updated!','Update'))
    0216 for i =1:numel(Text1)
    0217     fprintf('\b')
    0218 end
    0219
    0220 % --- Executes on button press in cpd2rxnpushbutton.
    0221 function cpd2rxnpushbutton_Callback(hObject, eventdata, handles)
    0222 % hObject    handle to cpd2rxnpushbutton (see GCBO)
    0223 % eventdata  reserved - to be defined in a future version of MATLAB
    0224 % handles    structure with handles and user data (see GUIDATA)
    0225 TestLink='http://rest.kegg.jp';
    0226 [~,Stat1]=urlread(TestLink);
    0227 if ~Stat1
    0228     msgbox({'This step requires a stable internet connection';...
    0229         'Seemingly you are offline!'});
    0230     return
    0231 end
    0232 Text1 = 'Updating cpd2rxn.txt...';
    0233 fprintf(Text1)
    0234 Data=urlread('http://rest.kegg.jp/link/rn/cpd');
    0235 Pth1 = which ('Bigg2Kegg.m');
    0236 tind = find(Pth1=='\',1,'last');
    0237 Pth = Pth1(1:tind-1);
    0238 Pth1 = [Pth,'\','cpd2rxn.txt'];
    0239 Idf = fopen(Pth1,'w');
    0240 fprintf(Idf,Data);
    0241 fclose(Idf);
    0242 waitfor(msgbox('cpd2rxn.txt was successfully updated!','Update'))
    0243 for i =1:numel(Text1)
    0244     fprintf('\b')
    0245 end
    0246
    0247
    0248 % --- Executes on button press in Donepushbutton8.
    0249 function Donepushbutton8_Callback(hObject, eventdata, handles)
    0250 % hObject    handle to Donepushbutton8 (see GCBO)
    0251 % eventdata  reserved - to be defined in a future version of MATLAB
    0252 % handles    structure with handles and user data (see GUIDATA)
    0253 close(gcf)
    0254
    0255
    0256 % --- Executes on button press in Weight4TransRxnspushbutton.
    0257 function Weight4TransRxnspushbutton_Callback(hObject, eventdata, handles)
    0258 % hObject    handle to Weight4TransRxnspushbutton (see GCBO)
    0259 % eventdata  reserved - to be defined in a future version of MATLAB
    0260 % handles    structure with handles and user data (see GUIDATA)
    0261 TestLink='http://rest.kegg.jp';
    0262 [~,Stat1]=urlread(TestLink);
    0263 if ~Stat1
    0264     msgbox({'This step requires a stable internet connection';...
    0265         'Seemingly you are offline!'});
    0266     return
    0267 end
    0268 Text1 = 'Updating W4TranRxns2.txt and W4TranRxns4.txt...';
    0269 fprintf(Text1)
    0270 fprintf('\n')
    0271 Weight4TransRxns(2)
    0272 fprintf('\n')
    0273 Weight4TransRxns(4)
    0274 fprintf('\n')
    0275 waitfor(msgbox('W4TranRxns2.txt and W4TranRxns4.txt was successfully updated!','Update'))
    0276 for i =1:numel(Text1)
    0277     fprintf('\b')
    0278 end
    0279 clc
    0280
    0281 % --- Executes on button press in getKGMLpushbutton.
    0282 function getKGMLpushbutton_Callback(hObject, eventdata, handles)
    0283 % hObject    handle to getKGMLpushbutton (see GCBO)
    0284 % eventdata  reserved - to be defined in a future version of MATLAB
    0285 % handles    structure with handles and user data (see GUIDATA)
    0286 TestLink='http://rest.kegg.jp';
    0287 [~,Stat1]=urlread(TestLink);
    0288 if ~Stat1
    0289     msgbox({'This step requires a stable internet connection';...
    0290         'Seemingly you are offline!'});
    0291     return
    0292 end
    0293 Text1 = 'Updating KEGGmaps folder...';
    0294 fprintf([Text1,'\n'])
    0295 getKGML
    0296 waitfor(msgbox('KEGGmaps folder was successfully updated!','Update'))
    0297 for i =1:numel(Text1)
    0298     fprintf('\b')
    0299 end
    0300
    0301 % --- Executes on button press in MultiRxnpushbutton.
    0302 function MultiRxnpushbutton_Callback(hObject, eventdata, handles)
    0303 % hObject    handle to MultiRxnpushbutton (see GCBO)
    0304 % eventdata  reserved - to be defined in a future version of MATLAB
    0305 % handles    structure with handles and user data (see GUIDATA)
    0306 TestLink='http://rest.kegg.jp';
    0307 [~,Stat1]=urlread(TestLink);
    0308 if ~Stat1
    0309     msgbox({'This step requires a stable internet connection';...
    0310         'Seemingly you are offline!'});
    0311     return
    0312 end
    0313 Text1 = 'Updating OfflineRxnData folder...';
    0314 fprintf(Text1)
    0315 GetData4MultiRxns
    0316 waitfor(msgbox('OfflineRxnData folder was successfully updated!','Update'))
    0317 for i =1:numel(Text1)
    0318     fprintf('\b')
    0319 end
    0320 clc
    0321
    0322 % --- Executes on button press in Orgspushbutton.
    0323 function Orgspushbutton_Callback(hObject, eventdata, handles)
    0324 % hObject    handle to Orgspushbutton (see GCBO)
    0325 % eventdata  reserved - to be defined in a future version of MATLAB
    0326 % handles    structure with handles and user data (see GUIDATA)
    0327 TestLink='http://rest.kegg.jp';
    0328 [~,Stat1]=urlread(TestLink);
    0329 if ~Stat1
    0330     msgbox({'This step requires a stable internet connection';...
    0331         'Seemingly you are offline!'});
    0332     return
    0333 end
    0334 Text1 = 'Updating orgs.txt...';
    0335 fprintf(Text1)
    0336 Data=urlread('http://rest.kegg.jp/list/organism');
    0337 Pth1 = which ('Precons.m');
    0338 tind = find(Pth1=='\',1,'last');
    0339 Pth = Pth1(1:tind-1);
    0340 Pth1 = [Pth,'\','orgs.txt'];
    0341 Idf = fopen(Pth1,'w');
    0342 fprintf(Idf,Data);
    0343 fclose(Idf);
    0344 waitfor(msgbox('orgs.txt was successfully updated!','Update'))
    0345 for i =1:numel(Text1)
    0346     fprintf('\b')
    0347 end