Home > BiKEGG > pixFit.m

pixFit

PURPOSE ^

pixFit

SYNOPSIS ^

function pixFit(x,y,rxn)

DESCRIPTION ^

 pixFit 
 uses discrete position coordinates from BaseMapReader and interpolates
 them to generate spatially continuous points for each reaction. This
 function uses the already existing Pixdata.mat file.
 
 Inputs:
 x,y: Original discrete coordinates from BaseMapReader.
 rxn: Reaction identifier in the form of [KEGG reaction ID,Entry ID provided
 in the global map's KGML file], e.g.: 'R000933116' is a unique reaction
 identifier for reaction ID R00093 and entry ID 3116.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function pixFit(x,y,rxn)
0002 % pixFit
0003 % uses discrete position coordinates from BaseMapReader and interpolates
0004 % them to generate spatially continuous points for each reaction. This
0005 % function uses the already existing Pixdata.mat file.
0006 %
0007 % Inputs:
0008 % x,y: Original discrete coordinates from BaseMapReader.
0009 % rxn: Reaction identifier in the form of [KEGG reaction ID,Entry ID provided
0010 % in the global map's KGML file], e.g.: 'R000933116' is a unique reaction
0011 % identifier for reaction ID R00093 and entry ID 3116.
0012 
0013 % O. Jamialahmadi
0014 % TMU, Chem. Eng. Dept., Biotech. Group
0015 % July 2016
0016 
0017 if size(x,2) > size(x,1)
0018     x = x';
0019 end
0020 if size(y,2) > size(y,1)
0021     y = y';
0022 end
0023 xy = [x,y];
0024 xy = unique(xy,'rows');
0025 x = xy(:,1); y = xy(:,2);
0026 
0027 if ~all(diff(x)==0) % Not a vertical line
0028     pixxy = interparc(2000,x,y,'pchip'); % Copyright (c) 2012, John D'Errico
0029     pixx = pixxy(:,1);
0030     pixy = pixxy(:,2);
0031     pixy = round(pixy);
0032     pixx = round(pixx);
0033     if size(pixx,2) > size(pixx,1)
0034         pixx = pixx';
0035     end
0036     if size(pixy,2) > size(pixy,1)
0037         pixy = pixy';
0038     end
0039     pixxy = [pixx,pixy];
0040     pixxy = unique(pixxy,'rows');
0041     pixx = pixxy(:,1); pixy = pixxy(:,2);   
0042 else
0043     pixy = min(y):max(y);
0044     pixx = ones(1,numel(pixy)).*x(1);
0045     if size(pixx,2) > size(pixx,1)
0046         pixx = pixx';
0047     end
0048     if size(pixy,2) > size(pixy,1)
0049         pixy = pixy';
0050     end
0051     pixxy = [pixx,pixy];
0052     pixxy = unique(pixxy,'rows');
0053     pixx = pixxy(:,1); pixy = pixxy(:,2);
0054 end
0055 
0056 path_name = which('Pixdata.mat');
0057 if isempty(path_name)
0058     msgbox({'Pixdata.mat cannot be found!';...
0059                 'Make sure the file is present in BiKEGG folder'},'Error','error');
0060     return
0061 end
0062 load(path_name)
0063 
0064 if isfield(pix_x,rxn)
0065     fprintf('%s has been replaced with new pixels!\n',rxn)
0066     temp_pixx = pix_x.(rxn);
0067     temp_pixy = pix_y.(rxn);
0068     if size(pixx,2) > size(pixx,1)
0069         pixx = pixx';
0070     end
0071     if size(pixy,2) > size(pixy,1)
0072         pixy = pixy';
0073     end
0074     if size(temp_pixx,2) > size(temp_pixx,1)
0075         temp_pixx = temp_pixx';
0076     end
0077     if size(temp_pixy,2) > size(temp_pixy,1)
0078         temp_pixy = temp_pixy';
0079     end
0080     pixx = [pixx;temp_pixx];
0081     pixy = [pixy;temp_pixy];
0082     pixxy = [pixx,pixy];
0083     pixxy = unique(pixxy,'rows');
0084     pixx = pixxy(:,1); pixy = pixxy(:,2);
0085     pix_x.(rxn) = pixx;
0086     pix_y.(rxn) = pixy;
0087 else
0088     pix_x.(rxn) = pixx;
0089     pix_y.(rxn) = pixy;
0090 end
0091 delete(path_name)
0092 save(path_name,'pix_x','pix_y')
0093

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