Description of pixHover

Home > BiKEGG > pixHover.m

# pixHover

## PURPOSE

pixHover

## SYNOPSIS

function pixHover(x,y,rad,cnames,Allx,Ally,AllHover,HoverUs,flx,h1,H1)

## DESCRIPTION

     pixHover
     a subfunction of NetDraw for showing information about
     reactions/compounds upon hovering the cursor on the customized map
     created by NetDraw

     Inputs:
     x, y: Compounds' coordinates.
     Allx, Ally: Reactions' coordinates.
     AllHover: BiGG/KEGG identifiers for all reactions.
     HoverUs: BiGG/KEGG identifiers for flux carrying reactions.
     flx: Flux rates.
     h1: Handle to map's axes.
     H1: Handle to map's figure.

## CROSS-REFERENCE INFORMATION

This function calls:

This function is called by:

- NetDraw NetDraw
- NetPoster NetPoster

## SUBFUNCTIONS

- function hoverCallback(src, evt)

## SOURCE CODE

    0001 function pixHover(x,y,rad,cnames,Allx,Ally,AllHover,HoverUs,flx,h1,H1)
    0002 % pixHover
    0003 % a subfunction of NetDraw for showing information about
    0004 % reactions/compounds upon hovering the cursor on the customized map
    0005 % created by NetDraw
    0006 %
    0007 % Inputs:
    0008 % x, y: Compounds' coordinates.
    0009 % Allx, Ally: Reactions' coordinates.
    0010 % AllHover: BiGG/KEGG identifiers for all reactions.
    0011 % HoverUs: BiGG/KEGG identifiers for flux carrying reactions.
    0012 % flx: Flux rates.
    0013 % h1: Handle to map's axes.
    0014 % H1: Handle to map's figure.
    0015
    0016 % O. Jamialahmadi
    0017 % TMU, Chem. Eng. Dept., Biotech. Group
    0018 % July 2016
    0019
    0020  Thresh = 15; % Threshold identifying the hovering area
    0021  axes(h1)
    0022  set(H1,'WindowButtonMotionFcn', @hoverCallback);
    0023  textHdl = text('Color', 'black', 'VerticalAlign',...
    0024      'Bottom','Interpreter','none','Parent',gca);
    0025  set(textHdl,'BackgroundColor',[173,255,47]./255)
    0026  set(textHdl,'EdgeColor',[34,139,34]./255)
    0027  set(textHdl,'Parent',h1)
    0028  textHdl1 = text('Color', 'black', 'VerticalAlign',...
    0029      'Bottom','Interpreter','none','Parent',gca);
    0030  set(textHdl1,'BackgroundColor',[144,238,144]./255)
    0031  set(textHdl1,'EdgeColor',[34,139,34]./255)
    0032  set(textHdl1,'Parent',h1)
    0033
    0034  function hoverCallback(src, evt)
    0035     mousePoint = get(h1, 'CurrentPoint');
    0036     mouseX = mousePoint(1,1);
    0037     mouseY = mousePoint(1,2);
    0038     distancesToMouse = hypot(x - mouseX, y - mouseY);
    0039     [~, ind] = min(abs(distancesToMouse));
    0040     if abs(mouseX - x(ind)) < Thresh && abs(mouseY - y(ind)) < Thresh
    0041         set(textHdl, 'String', ['ID = ', cnames(ind)]);
    0042         set(textHdl, 'Position', [x(ind) + Thresh, y(ind) + Thresh])
    0043         axes(h1)
    0044         viscircles(h1,[x(ind) y(ind)],rad, 'EdgeColor',[1,0.8667,0.1765]);
    0045     else
    0046         set(textHdl, 'String', '')
    0047         hg1 = findobj('type', 'line');
    0048         set(hg1, 'Visible','off');
    0049     end
    0050     inFlag = 0; cum_str = [];
    0051     for i1 =1:numel(Allx)
    0052         SX = Allx{i1};
    0053         SY = Ally{i1};
    0054         distancesToMouse1 = hypot(SX - mouseX, SY - mouseY);
    0055         [~, ind1] = min(abs(distancesToMouse1));
    0056         if abs(mouseX - SX(ind1)) < Thresh/4 && abs(mouseY - SY(ind1)) < Thresh/4
    0057             inFlag = [i1,ind1];
    0058             cum_str = [cum_str,AllHover.P(i1)];
    0059         end
    0060     end
    0061     if inFlag(1)
    0062         [N1,~] = (ismember(HoverUs.P,cum_str));
    0063         AllKEGG = AllHover.R(ismember(AllHover.P,cum_str));
    0064         [~,NA] = intersect(AllHover.K,AllKEGG);
    0065         AllBiGG = AllHover.B(NA);
    0066         ThisKEGGH = HoverUs.R(N1); ThisKEGG = HoverUs.CR(N1);
    0067         [~,NW] = intersect(HoverUs.K,ThisKEGGH);
    0068         ThisBiGG = HoverUs.B(NW);
    0069         if isempty(ThisBiGG); ThisBiGG = {'None'}; end;
    0070         if isempty(AllBiGG); AllBiGG = {'None'}; end;
    0071         if ~isempty(ThisKEGG) % Flux carrying rxns ////////////////////
    0072             if numel(ThisKEGG) > 1
    0073                 ForThisFlux = strrep(cellstr(num2str(flx(N1))),' ','');
    0074                 if size(ForThisFlux,1) > size(ForThisFlux,2)
    0075                     ForThisFlux = ForThisFlux';
    0076                 end
    0077                 if size(ThisKEGG,1) > size(ThisKEGG,2)
    0078                     ThisKEGG = ThisKEGG';
    0079                 end
    0080                 if size(ThisBiGG,1) > size(ThisBiGG,2)
    0081                     ThisBiGG = ThisBiGG';
    0082                 end
    0083                 set(textHdl1, 'String', {['KEGG: ', strjoin(ThisKEGG,',')],...
    0084                     ['BiGG: ', strjoin(ThisBiGG,',')],...
    0085                     ['Rate: ',strjoin(ForThisFlux,',')]});
    0086             elseif numel(ThisKEGG) == 1 && numel(ThisBiGG)>1
    0087                 if size(ThisBiGG,1) > size(ThisBiGG,2)
    0088                     ThisBiGG = ThisBiGG';
    0089                 end
    0090                 ForThisFlux = num2str(flx(N1));
    0091                 set(textHdl1, 'String', {strjoin(['KEGG: ', ThisKEGG]),...
    0092                     ['BiGG: ', strjoin(ThisBiGG,',')],...
    0093                     ['Rate: ',ForThisFlux]});
    0094             else
    0095                 ForThisFlux = num2str(flx(N1));
    0096                 set(textHdl1, 'String', {strjoin(['KEGG: ', ThisKEGG]),...
    0097                     ['BiGG: ', ThisBiGG{1}],...
    0098                     ['Rate: ',ForThisFlux]});
    0099             end
    0100         else % Inactive rxns //////////////////////////////////////////
    0101             if numel(AllKEGG) > 1
    0102                 if size(AllBiGG,1) > size(AllBiGG,2)
    0103                     AllBiGG = AllBiGG';
    0104                 end
    0105                 set(textHdl1, 'String', {['KEGG: ', strjoin(AllKEGG,',')],...
    0106                     ['BiGG: ', strjoin(AllBiGG,',')]});
    0107             elseif numel(AllKEGG) == 1 && numel(AllBiGG)>1
    0108                 if size(AllBiGG,1) > size(AllBiGG,2)
    0109                     AllBiGG = AllBiGG';
    0110                 end
    0111                 set(textHdl1, 'String', {['KEGG: ', AllKEGG{1}],...
    0112                     ['BiGG: ', strjoin(AllBiGG,',')]});
    0113             else
    0114                 set(textHdl1, 'String', {['KEGG: ', AllKEGG{1}],...
    0115                     ['BiGG: ', AllBiGG{1}]});
    0116             end
    0117         end
    0118         set(textHdl1, 'Position', [Allx{inFlag(1)}(inFlag(2)) + Thresh, Ally{inFlag(1)}(inFlag(2)) + Thresh])
    0119     else
    0120         set(textHdl1, 'String', '')
    0121     end
    0122
    0123 end
    0124 end