⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 netgraph_move.m

📁 %The Metabolic Networks Toolbox contains functions to create, %modify, display, and simulate bioche
💻 M
字号:
function network = netgraph_move(network,flag_draw_details)%network = netgraph_move(network,flag_draw_details)%%move nodes of metabolic network graph with the mouse%% left button:     first click: choose node%                 second click: choose new position% center button:   relax positions% right button:    quit%% flag_draw_details (optional): 0: only reaction lines% 1: also regulation lines% 2: also node namesfprintf('Left button  : choose node to move. Place it with the left button (free position) or center button (fixed position)\nCenter button: Relax the network\nRight button : Quit\n');if ~isfield(network,'graphics_par'),  network=netgraph_make_graph(network);endgridsize = 0.01; % distance between discrete x valuesk1 = 0.01;  % overall repulsion strengthk2 = 0.5*sqrt(1/length(network.graphics_par.metnames));  % overall repulsion scalek3 = 0.2;  % neighbour attraction strengthif ~exist('flag_draw_details','var'), flag_draw_details = 0;  end;if ~isfield(network.graphics_par,'fixed'), network.graphics_par.fixed = zeros(size(network.graphics_par.x,2),1); endp   = network.graphics_par;db  = network.graphics_par.db;m   = network.graphics_par.m;x   = network.graphics_par.x;p.x = x;names=[network.graphics_par.metnames; network.graphics_par.actnames];p.arrowstyle='none';switch flag_draw_details, case 0, netgraph_draw_simple(network); noticks; case 1, netgraph_draw_simple(network,1); noticks; case 2, netgraph_draw(network,p); noticks;end% noticks;cont = 1;[Ni,Nj]=ind2sub(size(p.N),find((p.N~=0)));Nj = Nj+length(p.metnames);  edgecenters = 0.5*(x(:,Ni)+x(:,Nj));   hold on;      %     plot(edgecenters(1,:),edgecenters(2,:),'g.');     fixed = find(network.graphics_par.fixed);     plot(network.graphics_par.x(1,fixed),network.graphics_par.x(2,fixed),'k.');     hold off;while cont==1,     [x_old,y_old,button] = ginput(1);     dist= sum( (repmat([x_old;y_old],1,size(x,2))-x).^2);     [dum,i]=min(dist);     index=i(1);     loose=find(1-network.graphics_par.fixed);     switch button       case 1,	 loose=find(1-network.graphics_par.fixed);	 [x_new,y_new,button] = ginput(1);	 factors = exp(-network.graphics_par.db(index,:)/network.graphics_par.lambda);	 x(:,loose) = x(:,loose) + [x_new-x_old; y_new-y_old] * factors(:,loose);         network.graphics_par.fixed(index) = button-1;       case 2,	 x = x + 0.001*randn(size(x));	 for it=1:3	   edgecenters = 0.5*(x(:,Ni)+x(:,Nj));	   for i=1:size(x,2);	     distances = repmat(x(:,i),1,size(x,2)+length(Ni)) - [x, edgecenters]; %             f1 = sum(distances.^2)+10^-10;	     f1 = exp(-f1/(2*k2^2))./sqrt(f1);             dummy = x(:,find(db(i,:)==1));	     if length(dummy),	       xdum = mean(dummy,2);	     else,                     xdum = x(:,i);	       end	       xnew(:,i)= x(:,i) + k1 * sum(distances.*repmat(f1,2,1),2) ...		   + k3 * ( xdum - x(:,i) );	   end	   loose=find(1-network.graphics_par.fixed);	   if length(loose),	     x(:,loose) = xnew(:,loose);	     x(:,loose) = x(:,loose)-repmat(min(x(:,loose)')',1,size(x(:,loose),2));	     x(:,loose) = diag(1./(max(x(:,loose)')'))*x(:,loose);	     x(:,loose) = gridsize * round(x(:,loose)/gridsize);	   end	 end       case 3,	 cont = 0;      end          loose = find(1-network.graphics_par.fixed);     if length(loose),       x(:,loose) = x(:,loose)-repmat(min(x(:,loose)')',1,size(x(:,loose),2));       x(:,loose) = diag(min(1,1./(max(x(:,loose)')')))*x(:,loose);       x(:,loose) = gridsize * round(x(:,loose)/gridsize);     end     network.graphics_par.x = x;     edgecenters = 0.5*(network.graphics_par.x(:,Ni)+network.graphics_par.x(:,Nj));          switch flag_draw_details,     case 0,      netgraph_draw_simple(network);   noticks;     case 1,      netgraph_draw_simple(network,1);   noticks;     case 2,                netgraph_draw(network,network.graphics_par);  noticks;  end      hold on; %           plot(edgecenters(1,:),edgecenters(2,:),'g.');       fixed = find(network.graphics_par.fixed);      plot(network.graphics_par.x(1,fixed),network.graphics_par.x(2,fixed),'k.'); hold off      hold off;% noticks;end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -