Home > BiKEGG > OverlapChecker.m

OverlapChecker

PURPOSE ^

OverlapChecker

SYNOPSIS ^

function [I,ArX,ArY,ArrowChek,DoubleData] = OverlapChecker(I,ArX,ArY,OverlapData,flx,McmCollect,field_intsect_overlay,LineStrength)

DESCRIPTION ^

 OverlapChecker
 is a subfunction of NetDraw and identifies overlapping reactions.
 
 Inputs:
 I: An array containing the customized metabolic map.
 ArX,ArY: Coordinates for flux carrying reactions.
 OverlapData: Data for identifying overlapping reactions.
 flx: Flux rates.
 McmCollect: Color codes corresponding to flux rates.
 field_intsect_overlay: Reaction identifiers for flux carrying reactions.
 LineStrength: Reaction's line width.
 
 Outputs:
 I: Customized metabolic map after modification for overlapping reactions.
 ArX,ArY: Coordinates for flux carrying reactions after modification for
 overlapping reactions.
 ArrowChek: Data for arrowhead function.
 DoubleData: Data for ArrowheadProcess function.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [I,ArX,ArY,ArrowChek,DoubleData] = OverlapChecker(I,ArX,ArY,OverlapData,...
0002     flx,McmCollect,field_intsect_overlay,LineStrength)
0003 % OverlapChecker
0004 % is a subfunction of NetDraw and identifies overlapping reactions.
0005 %
0006 % Inputs:
0007 % I: An array containing the customized metabolic map.
0008 % ArX,ArY: Coordinates for flux carrying reactions.
0009 % OverlapData: Data for identifying overlapping reactions.
0010 % flx: Flux rates.
0011 % McmCollect: Color codes corresponding to flux rates.
0012 % field_intsect_overlay: Reaction identifiers for flux carrying reactions.
0013 % LineStrength: Reaction's line width.
0014 %
0015 % Outputs:
0016 % I: Customized metabolic map after modification for overlapping reactions.
0017 % ArX,ArY: Coordinates for flux carrying reactions after modification for
0018 % overlapping reactions.
0019 % ArrowChek: Data for arrowhead function.
0020 % DoubleData: Data for ArrowheadProcess function.
0021 
0022 % O. Jamialahmadi
0023 % TMU, Chem. Eng. Dept., Biotech. Group
0024 % July 2016
0025 
0026 [~,Idx1,~] = unique(OverlapData);
0027 Chck1 = setdiff(1:size(OverlapData,1),Idx1);
0028 ArrowChek = []; ct = 1; RxnId = ({}); RxnX = ({}); RxnY = ({});
0029 RxnX1 = RxnX; RxnY1 = RxnY;
0030 for m1 = 1:numel(Chck1)
0031     WhrC = find(ismember(OverlapData,OverlapData{Chck1(m1)}));
0032     if std(flx(WhrC))<1e-4 % Same flux rates
0033         continue
0034     end
0035     pixx = ArX{WhrC(1)}; pixy = ArY{WhrC(1)};
0036     ColSpec = McmCollect(WhrC,:);
0037     % set start from the most top/left part of line
0038     if ~std(pixx)
0039             pixx = pixx - LineStrength*numel(WhrC)/2;
0040     elseif ~std(pixy)
0041             pixy = pixy - LineStrength*numel(WhrC)/2;
0042     else
0043             pixx = pixx - LineStrength*numel(WhrC)/2;
0044             pixy = pixy - LineStrength*numel(WhrC)/2;
0045     end
0046 %     LineSegments = linspace(0,LineStrength,numel(WhrC)+1);
0047 %     LineSegments = sort(LineSegments,'descend');
0048     LineSegments = [];
0049     LineSegments(1) = 0; LineSegments(2) = LineStrength;
0050     for i1 = 3:numel(WhrC)*2
0051         if mod(i1,2)
0052             LineSegments(i1) = LineSegments(i1-1) + 1;
0053         else
0054             LineSegments(i1) = LineSegments(i1-1) + LineStrength;
0055         end
0056     end
0057     
0058     for m2 = 1:numel(WhrC)
0059         if ~std(pixx)
0060             pixx1 = pixx + LineSegments(2*m2-1);
0061             pixx1A = pixx1 + LineStrength/2;
0062             pixx2 = pixx + LineSegments(2*m2);
0063             pixy1 = pixy;
0064             pixy1A = pixy;
0065             pixy2 = pixy;
0066         elseif ~std(pixy)
0067             pixy1 = pixy + LineSegments(2*m2-1);
0068             pixy1A = pixy1 + LineStrength/2;
0069             pixy2 = pixy + LineSegments(2*m2);
0070             pixx1 = pixx;
0071             pixx1A = pixx;
0072             pixx2 = pixx;
0073         else
0074             pixx1 = pixx + LineSegments(2*m2-1);
0075             pixx1A = pixx1 + LineStrength/2;
0076             pixx2 = pixx + LineSegments(2*m2);
0077             pixy1 = pixy + LineSegments(2*m2-1);
0078             pixy1A = pixy1 + LineStrength/2;
0079             pixy2 = pixy + LineSegments(2*m2);
0080         end
0081         pixx1 = round(pixx1); pixx2 = round(pixx2);
0082         pixy1 = round(pixy1); pixy2 = round(pixy2);
0083         ArX{WhrC(m2)} = []; ArX{WhrC(m2)} = pixx1A; RxnId{ct} = field_intsect_overlay{WhrC(m2)};
0084         ArY{WhrC(m2)} = []; ArY{WhrC(m2)} = pixy1A; 
0085         RxnX{ct} =  pixx1; RxnY{ct} = pixy1; RxnX1{ct} = pixx2;RxnY1{ct} = pixy2;
0086         ArrowChek(ct,1) = WhrC(m2); ArrowChek(ct,2) = numel(WhrC);
0087         ct = ct + 1;
0088         for i5 = 1:numel(pixx)
0089             I(pixy1(i5):pixy2(i5),pixx1(i5),1) = ColSpec(m2,1);
0090             I(pixy1(i5),pixx1(i5):pixx2(i5),1) = ColSpec(m2,1); 
0091             I(pixy1(i5):pixy2(i5),pixx1(i5),2) = ColSpec(m2,2);
0092             I(pixy1(i5),pixx1(i5):pixx2(i5),2) = ColSpec(m2,2); 
0093             I(pixy1(i5):pixy2(i5),pixx1(i5),3) = ColSpec(m2,3);
0094             I(pixy1(i5),pixx1(i5):pixx2(i5),3) = ColSpec(m2,3); 
0095         end
0096     end
0097 end
0098 DoubleData.X = RxnX; DoubleData.Y = RxnY; DoubleData.Id = RxnId;
0099 DoubleData.X1 = RxnX1; DoubleData.Y1 = RxnY1;

Generated on Sat 16-Jul-2016 20:21:30 by m2html © 2005