0001 function varargout = MapAdjuster(varargin)
0002
0003
0004
0005
0006
0007
0008
0009
0010 gui_Singleton = 1;
0011 gui_State = struct('gui_Name', mfilename, ...
0012 'gui_Singleton', gui_Singleton, ...
0013 'gui_OpeningFcn', @MapAdjuster_OpeningFcn, ...
0014 'gui_OutputFcn', @MapAdjuster_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
0027
0028
0029
0030 function MapAdjuster_OpeningFcn(hObject, eventdata, handles, varargin)
0031
0032
0033
0034
0035
0036
0037
0038 handles.output = hObject;
0039
0040
0041 guidata(hObject, handles);
0042
0043
0044
0045
0046
0047
0048 function varargout = MapAdjuster_OutputFcn(hObject, eventdata, handles)
0049
0050
0051
0052
0053
0054
0055 varargout{1} = handles.output;
0056
0057
0058
0059 function DonePush_Callback(hObject, eventdata, handles)
0060 PostData = getappdata(0,'PostData');
0061
0062 Title = get(handles.TitleEdit,'String');
0063 FHndl = getappdata(0,'ParentFig');
0064 AxHndl = getappdata(0,'ParentAx');
0065
0066
0067 text('position',[50,50],'String',Title,'Unit','data','FontSize',22,...
0068 'Parent',AxHndl);
0069
0070 set(FHndl,'name',Title,'numbertitle','off')
0071
0072 ShowRate = get(handles.ShowRatesCheck,'Value');
0073 if ShowRate
0074 FlxStrHndls = getappdata(hObject,'FlxStrHndls');
0075 set(FlxStrHndls,'Visible','off');
0076 AxHndl = getappdata(0,'ParentAx');
0077 flx = PostData.flx(:,PostData.k);
0078 ArX = PostData.ArX;
0079 ArY = PostData.ArY;
0080 for i1=1:numel(ArX)
0081 FlxStrHndls(i1) = text('position',[mean(ArX{i1}),mean(ArY{i1})],...
0082 'String',num2str(abs(flx(i1)),'%.2f'),'FontSize',7,'Parent',AxHndl);
0083 end
0084 setappdata(hObject,'FlxStrHndls',FlxStrHndls);
0085 else
0086 FlxStrHndls = getappdata(hObject,'FlxStrHndls');
0087 set(FlxStrHndls,'Visible','off');
0088 end
0089
0090 CpdPanelTags = {'KeggCpdIdRadio','KeggCpdNRadio','BiGGCpdRadio','RmvCpdRadio'};
0091 hCpdpanel = get(handles.CpdPanel,'SelectedObject');
0092 Cpdpanel = find(strcmp(CpdPanelTags,get(hCpdpanel,'Tag')));
0093 AxHndl = getappdata(0,'ParentAx');
0094 KEGGCpdH = getappdata(hObject,'KEGGCpdH');
0095 KEGGCpdNH = getappdata(hObject,'KEGGCpdNH');
0096 BiGGCpdH = getappdata(hObject,'BiGGCpdH');
0097 if any(ishandle(KEGGCpdH))
0098 set(KEGGCpdH,'Visible','off');
0099 end
0100 if any(ishandle(KEGGCpdNH))
0101 set(KEGGCpdNH,'Visible','off');
0102 end
0103 if any(ishandle(BiGGCpdH))
0104 set(BiGGCpdH,'Visible','off');
0105 end
0106 switch Cpdpanel
0107 case 1
0108 cpdnames = PostData.cpdnames;
0109 x_cpd = PostData.x_cpd;
0110 y_cpd = PostData.y_cpd;
0111 cpdxy = PostData.cpdxy;
0112 for i1=1:numel(cpdnames)
0113 KEGGCpdH(i1) = text('position',[x_cpd(i1)+cpdxy(1,4)/2,y_cpd(i1)-cpdxy(1,4)/2],...
0114 'String',cpdnames{i1},'FontSize',7,'Parent',AxHndl);
0115 end
0116 setappdata(hObject,'KEGGCpdH',KEGGCpdH);
0117 case 2
0118 cpdnames = PostData.cpdnames;
0119 x_cpd = PostData.x_cpd;
0120 y_cpd = PostData.y_cpd;
0121 cpdxy = PostData.cpdxy;
0122 Fileid = fopen('KEGGcpd.txt','r');
0123 TempCpds = textscan(Fileid,'%s %s %[^\n]');
0124 fclose(Fileid);
0125 CpdIds = TempCpds{1}; CpdIds = strrep(CpdIds,'cpd:','');
0126 CpdNms = TempCpds{2}; CpdNms = strrep(CpdNms,';','');
0127 clear TempCpds
0128 [~,N1] = ismember(cpdnames,CpdIds);
0129 KEGGCpdNms = CpdNms(N1);
0130 for i1=1:numel(KEGGCpdNms)
0131 KEGGCpdNH(i1) = text('position',[x_cpd(i1)+cpdxy(1,4)/2,y_cpd(i1)-cpdxy(1,4)/2],...
0132 'String',KEGGCpdNms{i1},'FontSize',5.5,'Parent',AxHndl);
0133 end
0134 setappdata(hObject,'KEGGCpdNH',KEGGCpdNH);
0135 case 3
0136 BiGGModel = getappdata(0,'BiGGModel');
0137 if isempty(BiGGModel)
0138 [pname,fname1]=uigetfile({'*.*'},'Select the model file (SBML)');
0139 Testname=pname(strfind(pname,'.')+1:end);
0140 if ~strcmp(Testname,'xml')
0141 msgbox('Only xml file format!','Error','error');
0142 return
0143 else
0144 Idf = fopen([fname1,pname]);
0145 D = textscan(Idf,'%s');
0146 fclose(Idf);
0147 CbModel = readCbModel([fname1,pname]);
0148 [Metkegg,Metbigg] = KEGG2BiGGMets(D,CbModel);
0149 BiGGModel.Metkegg = Metkegg;
0150 BiGGModel.CbModel = CbModel;
0151 BiGGModel.Metbigg = Metbigg;
0152 setappdata(0,'BiGGModel',BiGGModel);
0153 end
0154 end
0155 Metbigg = BiGGModel.Metbigg;
0156 Metkegg = BiGGModel.Metkegg;
0157 cpdnames = PostData.cpdnames;
0158 x_cpd = PostData.x_cpd;
0159 y_cpd = PostData.y_cpd;
0160 cpdxy = PostData.cpdxy;
0161 for m1 = 1:numel(cpdnames)
0162 if any(ismember(cpdnames{m1},Metkegg))
0163 whrc = find(ismember(Metkegg,cpdnames{m1}));
0164 cpdnames(m1) = Metbigg(whrc(1));
0165 end
0166 end
0167
0168 for i1=1:numel(cpdnames)
0169 BiGGCpdH(i1) = text('position',[x_cpd(i1)+cpdxy(1,4)/2,y_cpd(i1)-cpdxy(1,4)/2],...
0170 'Interpreter','none','String',cpdnames{i1},'FontSize',5.5,'Parent',AxHndl);
0171 end
0172 setappdata(hObject,'BiGGCpdH',BiGGCpdH);
0173 end
0174
0175 RxnPanelTags = {'KeggRxnIdRadio','BiGGRxnRadio','RmvRxnRadio'};
0176 hrxnpanel = get(handles.RxnPanel,'SelectedObject');
0177 rxnpanel = find(strcmp(RxnPanelTags,get(hrxnpanel,'Tag')));
0178 AxHndl = getappdata(0,'ParentAx');
0179 KEGGRxnHndls = getappdata(hObject,'KEGGRxnHndls');
0180 BiGGRxnHndls = getappdata(hObject,'BiGGRxnHndls');
0181 if any(ishandle(KEGGRxnHndls))
0182 set(KEGGRxnHndls,'Visible','off');
0183 end
0184 if any(ishandle(BiGGRxnHndls))
0185 set(BiGGRxnHndls,'Visible','off');
0186 end
0187
0188 switch rxnpanel
0189 case 1
0190 [OverlayMe,Allx4Arrow,Ally4Arrow] = RxnAdjuster(PostData,[],'kegg');
0191 for i1=1:numel(Allx4Arrow)
0192 if std(Allx4Arrow{i1})<1e-1
0193 KEGGRxnHndls(i1) = text('position',...
0194 [mean(Allx4Arrow{i1})-10,mean(Ally4Arrow{i1})+15],...
0195 'String',OverlayMe{i1},'FontSize',6.5,'rotation',90,'Parent',AxHndl);
0196 else
0197 KEGGRxnHndls(i1) = text('position',...
0198 [mean(Allx4Arrow{i1})-15,mean(Ally4Arrow{i1})-10],...
0199 'String',OverlayMe{i1},'FontSize',6.5,'Parent',AxHndl);
0200 end
0201 end
0202 setappdata(hObject,'KEGGRxnHndls',KEGGRxnHndls)
0203 case 2
0204 Mdl = getappdata(0,'Mdl');
0205 if isempty(Mdl)
0206 [pname,~]=uigetfile({'*.*'},'Select the model file (SBML)');
0207 Testname=pname(strfind(pname,'.')+1:end);
0208 if ~strcmp(Testname,'xml')
0209 msgbox('Only xml file format!','Error','error');
0210 return
0211 end
0212 Chk = which([pname(1:strfind(pname,'.')-1),'KEGG.mat']);
0213 if isempty(Chk)
0214 msgbox({[pname(1:strfind(pname,'.')-1),'KEGG.mat',' cannot be found!'];...
0215 'Make sure the file is present in BiGG2KEGG folder'},'Error','error');
0216 return
0217 end
0218 Mdl = load(which([pname(1:strfind(pname,'.')-1),'KEGG.mat']));
0219 setappdata(0,'Mdl',Mdl);
0220 end
0221 [OverlayMe,Allx4Arrow,Ally4Arrow] = RxnAdjuster(PostData,Mdl,'bigg');
0222
0223 Chkempty = find(cellfun('isempty',regexp(OverlayMe,'\w','match')));
0224 OverlayMe(Chkempty) = {''};
0225
0226 for i1=1:numel(Allx4Arrow)
0227 if std(Allx4Arrow{i1})<1e-1
0228 BiGGRxnHndls(i1) = text('position',...
0229 [mean(Allx4Arrow{i1})-10,mean(Ally4Arrow{i1})+15],...
0230 'String',OverlayMe{i1},'FontSize',6,'rotation',90,...
0231 'Interpreter','none','Parent',AxHndl);
0232 else
0233 BiGGRxnHndls(i1) = text('position',...
0234 [mean(Allx4Arrow{i1})-15,mean(Ally4Arrow{i1})-10],...
0235 'String',OverlayMe{i1},'FontSize',6,'Parent',AxHndl,...
0236 'Interpreter','none');
0237 end
0238 end
0239 setappdata(hObject,'BiGGRxnHndls',BiGGRxnHndls)
0240 end
0241
0242 function TitleEdit_Callback(hObject, eventdata, handles)
0243
0244
0245
0246
0247 function TitleEdit_CreateFcn(hObject, eventdata, handles)
0248
0249
0250
0251
0252
0253
0254 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0255 set(hObject,'BackgroundColor','white');
0256 end
0257
0258
0259
0260 function TitlePush_Callback(hObject, eventdata, handles)
0261
0262
0263
0264 function LineWEdit_Callback(hObject, eventdata, handles)
0265
0266
0267
0268
0269
0270
0271
0272
0273
0274 function LineWEdit_CreateFcn(hObject, eventdata, handles)
0275
0276
0277
0278
0279
0280
0281 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
0282 set(hObject,'BackgroundColor','white');
0283 end
0284
0285
0286
0287 function ShowRatesCheck_Callback(hObject, eventdata, handles)
0288
0289
0290
0291
0292
0293
0294
0295
0296 function OverlapCheck_Callback(hObject, eventdata, handles)
0297
0298
0299
0300
0301
0302
0303
0304
0305 function ColormapCheck_Callback(hObject, eventdata, handles)
0306
0307
0308
0309
0310
0311
0312
0313
0314 function RedrawPush_Callback(hObject, eventdata, handles)
0315 OverlapC = get(handles.OverlapCheck,'Value');
0316 ColormapC = get(handles.ColormapCheck,'Value');
0317 LineStr = str2double(get(handles.LineWEdit,'String'));
0318 BackCol = getappdata(handles.Backgroundpush,'BackCol');
0319 CpdCol = getappdata(handles.Cpdpush,'CpdCol');
0320 inactiveCol = getappdata(handles.inactivespush,'inactiveCol');
0321 NetPoster(LineStr,OverlapC,ColormapC,BackCol,CpdCol,inactiveCol)
0322
0323
0324
0325 function Backgroundpush_Callback(hObject, eventdata, handles)
0326 BackCol=uisetcolor;
0327 setappdata(hObject,'BackCol',BackCol);
0328
0329
0330
0331 function Cpdpush_Callback(hObject, eventdata, handles)
0332 CpdCol=uisetcolor;
0333 setappdata(hObject,'CpdCol',CpdCol);
0334
0335
0336
0337 function inactivespush_Callback(hObject, eventdata, handles)
0338 inactiveCol=uisetcolor;
0339 setappdata(hObject,'inactiveCol',inactiveCol);
0340
0341
0342
0343 function ClosePush_Callback(hObject, eventdata, handles)
0344
0345
0346
0347 close(gcf)