function varargout = MT_GUI(varargin) % MT_GUI M-file for MT_GUI.fig % MT_GUI, by itself, creates a new MT_GUI or raises the existing % singleton*. % % H = MT_GUI returns the handle to a new MT_GUI or the handle to % the existing singleton*. % % MT_GUI('CALLBACK',hObject,eventData,handles,...) calls the local % function named CALLBACK in MT_GUI.M with the given input arguments. % % MT_GUI('Property','Value',...) creates a new MT_GUI or raises the % existing singleton*. Starting from the left, property value pairs are % applied to the GUI before MT_GUI_OpeningFunction gets called. An % unrecognized property name or invalid value makes property application % stop. All inputs are passed to MT_GUI_OpeningFcn via varargin. % % *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one % instance to run (singleton)". % % See also: GUIDE, GUIDATA, GUIHANDLES % Edit the above text to modify the response to help MT_GUI % Last Modified by GUIDE v2.5 07-Aug-2006 12:23:47 % Begin initialization code - DO NOT EDIT gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @MT_GUI_OpeningFcn, ... 'gui_OutputFcn', @MT_GUI_OutputFcn, ... 'gui_LayoutFcn', [] , ... 'gui_Callback', []); if nargin && ischar(varargin{1}) gui_State.gui_Callback = str2func(varargin{1}); end if nargout [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); else gui_mainfcn(gui_State, varargin{:}); end % End initialization code - DO NOT EDIT % --- Executes just before MT_GUI is made visible. function MT_GUI_OpeningFcn(hObject, eventdata, handles, varargin) % This function has no output args, see OutputFcn. % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % varargin command line arguments to MT_GUI (see VARARGIN) clc; global a c c_tot cpu L N_MT_max MT_length MT_state step bad_input_warning; L = 10; % microns Lz = 1; % microns % The length of a heterodimer is 8nm; there are usually 13 protofilaments % in the MT. Hence to grow by 1 micron the MT needs 13*10^-6/8*10^-9 = 1625 % dimers. Then the concentration of free Tu, c, will drop by 1625/V % heterodimers per micron^3 (V is measured in micron^3). % 1 microM = 10^-21*N_A heterodimers/micron^3, where N_A = 6.022*10^23. % Therefore, change in c, expressed in microM, is 1625/(10^-21*N_A*V(in % micron^3)). We denote this quantity by cpu. We also assume that the cell % has a cylindrical shape, with radius L and height Lz. % polymerization of unit length (micron) reduces the free Tu concentration c by: cpu = 1625/(602*pi*L^2*Lz); % microM per micron % initialization: % make of maximal size in order to be able to change N_MT after hitting % "Stop", and then to run again (to continue). MT_length = zeros(N_MT_max,1); % in microns MT_state = ones(N_MT_max,1); % 1 - growth state, 2 - shortening state c_tot = c; % because initially have no MTs step = 0; bad_input_warning = 0; a = linspace(0,2*pi); clr = ['b','r']; % colors of growing and shortening MTs plot(L*cos(a),L*sin(a),'k','LineWidth',3); axis off; axis square; % Choose default command line output for MT_GUI handles.output = hObject; % Update handles structure guidata(hObject, handles); % UIWAIT makes MT_GUI wait for user response (see UIRESUME) % uiwait(handles.figure1); % --- Outputs from this function are returned to the command line. function varargout = MT_GUI_OutputFcn(hObject, eventdata, handles) % varargout cell array for returning output args (see VARARGOUT); % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Get default command line output from handles structure varargout{1} = handles.output; disp('Hello! You have started the simple simulation GUI for MTs.'); function c_Callback(hObject, eventdata, handles) % hObject handle to c (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of c as text % str2double(get(hObject,'String')) returns contents of c as a double global c c_tot N_MT MT_length cpu bad_input_warning L; c_new = str2num(get(hObject,'String')); if isempty(c_new) || c_new < 0 || ~isreal(c_new) % the input is invalid bad_input_warning = 1; text(-L*1.1,-L*1.05,'The input value discarded. The input should be a non-negative number.','Color','r'); set(hObject,'string',num2str(c)); % to restore the previous value in the box. else % have a valid input c = c_new; % when I change c I have to recalculate c_tot: c_tot = c + sum(MT_length(1:N_MT))*cpu; end % --- Executes during object creation, after setting all properties. function c_CreateFcn(hObject, eventdata, handles) % hObject handle to c (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end global c hObject_c; % set the initial value of c: c = 10; set(hObject,'string',num2str(c)); hObject_c = hObject; % need this in order to update the value of c in the box from another function. function k_g_Callback(hObject, eventdata, handles) % hObject handle to k_g (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of k_g as text % str2double(get(hObject,'String')) returns contents of k_g as a double global k_g bad_input_warning L; k_g_new = str2num(get(hObject,'String')); if isempty(k_g_new) || k_g_new < 0 || ~isreal(k_g_new) % the input is invalid bad_input_warning = 1; text(-L*1.1,-L*1.05,'The input value discarded. The input should be a non-negative number.','Color','r'); set(hObject,'string',num2str(k_g)); else % have a valid input k_g = k_g_new; end % --- Executes during object creation, after setting all properties. function k_g_CreateFcn(hObject, eventdata, handles) % hObject handle to k_g (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end global k_g; k_g = .005; set(hObject,'string',num2str(k_g)); function v_s_Callback(hObject, eventdata, handles) % hObject handle to v_s (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of v_s as text % str2double(get(hObject,'String')) returns contents of v_s as a double global v_s bad_input_warning L; v_s_new = str2num(get(hObject,'String')); if isempty(v_s_new) || v_s_new < 0 || ~isreal(v_s_new) % the input is invalid bad_input_warning = 1; text(-L*1.1,-L*1.05,'The input value discarded. The input should be a non-negative number.','Color','r'); set(hObject,'string',num2str(v_s)); else % have a valid input v_s = v_s_new; end % --- Executes during object creation, after setting all properties. function v_s_CreateFcn(hObject, eventdata, handles) % hObject handle to v_s (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end global v_s; v_s = .7; set(hObject,'string',num2str(v_s)); function k_cat_Callback(hObject, eventdata, handles) % hObject handle to k_cat (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of k_cat as text % str2double(get(hObject,'String')) returns contents of k_cat as a double global k_cat bad_input_warning L; k_cat_new = str2num(get(hObject,'String')); if isempty(k_cat_new) || k_cat_new < 0 || ~isreal(k_cat_new) % the input is invalid bad_input_warning = 1; text(-L*1.1,-L*1.05,'The input value discarded. The input should be a non-negative number.','Color','r'); set(hObject,'string',num2str(k_cat)); else % have a valid input k_cat = k_cat_new; end % --- Executes during object creation, after setting all properties. function k_cat_CreateFcn(hObject, eventdata, handles) % hObject handle to k_cat (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end global k_cat; k_cat = 3; set(hObject,'string',num2str(k_cat)); function k_res_Callback(hObject, eventdata, handles) % hObject handle to k_res (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of k_res as text % str2double(get(hObject,'String')) returns contents of k_res as a double global k_res bad_input_warning L; k_res_new = str2num(get(hObject,'String')); if isempty(k_res_new) || k_res_new < 0 || ~isreal(k_res_new) % the input is invalid bad_input_warning = 1; text(-L*1.1,-L*1.05,'The input value discarded. The input should be a non-negative number.','Color','r'); set(hObject,'string',num2str(k_res)); else % have a valid input k_res = k_res_new; end % --- Executes during object creation, after setting all properties. function k_res_CreateFcn(hObject, eventdata, handles) % hObject handle to k_res (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end global k_res; k_res = .007; set(hObject,'string',num2str(k_res)); % --- Executes on slider movement. function N_MT_Callback(hObject, eventdata, handles) % hObject handle to N_MT (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'Value') returns position of slider % get(hObject,'Min') and get(hObject,'Max') to determine range of slider global N_MT N_MT_max MT_length c c_tot cpu; N_MT = round(get(hObject,'Value')); set(hObject,'Value',N_MT); % correct slider position, because rounded the value. % If reduce the number of MTs - assume all the extra MTs get % depolymerized, i.e., all the extra MTs become zero length: MT_length(N_MT+1:N_MT_max) = 0; % If change N_MT also have to ensure the conservation of tubulin: c = c_tot - sum(MT_length(1:N_MT))*cpu; % --- Executes during object creation, after setting all properties. function N_MT_CreateFcn(hObject, eventdata, handles) % hObject handle to N_MT (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: slider controls usually have a light gray background. if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor',[.9 .9 .9]); end global N_MT N_MT_min N_MT_max; N_MT_min = 1; N_MT_max = 200; N_MT = 60; set(hObject,'Min',N_MT_min); set(hObject,'Max',N_MT_max); set(hObject,'Value',N_MT); % --- Executes on button press in Run. function Run_Callback(hObject, eventdata, handles) % hObject handle to Run (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) global a c c_tot cpu k_g v_s k_cat k_res L N_MT MT_length MT_state stop step hObject_c bad_input_warning; %disp(['k_g = ',num2str(k_g),', v_s = ',num2str(v_s),', k_cat = ',num2str(k_cat),', k_res = ',num2str(k_res)]); stop = 0; v_g = inline('k_g*c','k_g','c'); f_cat = inline('k_cat/c^2','k_cat','c'); f_res = inline('k_res*c','k_res','c'); STEPS = 10000; % each step runs through all the MTs while step < STEPS && ~stop step = step + 1; if bad_input_warning disp('Input value discarded. The input should be a non-negative number.'); text(-L*1.1,-L*1.05,'The input value discarded. The input should be a non-negative number.','Color','r'); pause(3); bad_input_warning = 0; end dt = .3/(k_res*c_tot); % time step; this is inside the loop in case I change % c_tot (through changing c) or k_res while running. for n = 1:N_MT if MT_state(n) == 1 % if in the growth state % disp(['c = ',num2str(c),', k_cat = ',num2str(k_cat)]); if c == 0 || rand > exp(-dt*f_cat(k_cat,c)) % if have catastrophe MT_state(n) = 2; else % continue growth % dl is the length increment; MT length cannot be > L; % also, because growth reduces free Tu concentration c, % it cannot become negative. The factor of (.5+rand) in % front of the velocity is not necessary, but is used here % to introduce some randomness. dl = min([(.5+rand)*v_g(k_g,c)*dt,L-MT_length(n),c/cpu]); MT_length(n) = MT_length(n) + dl; c = c - dl*cpu; end else % if in the shortening state, i.e., MT_state(n) = 2 if rand > exp(-dt*f_res(k_res,c)) % if have rescue MT_state(n) = 1; else % continue shortening dl = min([(.5+rand)*v_s*dt,MT_length(n)]); MT_length(n) = MT_length(n) - dl; c = c + dl*cpu; end end end % for n = 1:N_MT % make a check: if c > (1.00000000001)*c_tot || c < 0 disp(['ERROR: wrong concentration of free Tu: ',num2str(c)]); return; elseif c > c_tot c = c_tot; end err = c_tot - c - sum(MT_length(1:N_MT))*cpu; if abs(err/c_tot) > 1e-10 disp('ERROR: There is no concervation of tubulin!'); disp(['step ',num2str(step),': c_tot - c - sum(MT_length(1:N_MT))*cpu = ',num2str(err)]); return; else % make a correction: c = c + err; end % updating the value of c in the GUI box: set(hObject_c,'string',num2str(c)); % drawing: clr = ['b','r']; % colors of growing and shortening MTs hold off; plot(L*cos(a),L*sin(a),'k','LineWidth',3); axis off; axis square; hold on; for n = 1:N_MT plot([0 MT_length(n)*cos(2*pi*n/N_MT)],[0 MT_length(n)*sin(2*pi*n/N_MT)],clr(MT_state(n))); end title([num2str(N_MT),' MTs; step ',num2str(step),': \Deltat = ',num2str(dt,3),'s, c_{tot} = ',num2str(c_tot,3),', c = ',num2str(c,3)]); pause(.01); end if step == STEPS disp('Reached the maximal allowed number of steps. Click ''Reset'' to proceed.'); text(-L*1.1,-L*1.05,'Reached the maximal allowed number of steps. Click ''Reset'' to proceed.','Color','r'); end % --- Executes on button press in Stop. function Stop_Callback(hObject, eventdata, handles) % hObject handle to Stop (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) global stop; stop = 1; % --- Executes on button press in Reset. function Reset_Callback(hObject, eventdata, handles) % hObject handle to Reset (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) global a L N_MT N_MT_max MT_length MT_state c c_tot step; % initialization: MT_length = zeros(N_MT_max,1); MT_state = ones(N_MT_max,1); % 1 - growth state, 2 - shortening state c = c_tot; step = 0; hold off; plot(L*cos(a),L*sin(a),'k','LineWidth',3); axis off; axis square; % --- Executes on button press in Quit. function Quit_Callback(hObject, eventdata, handles) % hObject handle to Quit (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) disp('Good bye!'); % first need to stop, then quit; if don't stop then quit with errors. global stop stop = 1; close(handles.output);