Home > legacy > external > constructPathwayFromCelldesigner.m

constructPathwayFromCelldesigner

PURPOSE ^

constructPathwayFromCelldesigner

SYNOPSIS ^

function pathway = constructPathwayFromCelldesigner(inputFile)

DESCRIPTION ^

 constructPathwayFromCelldesigner
    Constructs a pathway structure from a CellDesigner XML file.

    inputFile   string representing the pathway of the Celldesigner XML 
               file

    pathway
       listOfCompartments      structure with information on the compartments
                               in the Celldesigner file
           x                   the x position
           y                   the y position
           h                   the height
           w                   the width
           compartment         string representing the compartment
           id                  alias of the compartment. Used if there are
                               several instances of the same compartment
           name                the name of the compartment
       listOfSpecies           structure with information on each species in
                               the Celldesigner file. Both metabolites and
                               enzymes are species
           x                   the x position
           y                   the y position
           h                   the height
           w                   the width
           species             string representing the species
           alias               alias of the species. Used if the species is
                               present in several places in the map
           name                the name of the species
           type                the type of the species. At the moment only
                               'SIMPLE_MOLECULE' (for metabolites) and
                               'PROTEIN' (for enzymes) are supported
           note                string that can be used on enzymes to link them
                               to the corresponding reaction in a model
       listOfReactions         structure with information on each of the
                               reactions in the Celldesigner file
           reversible          true if the reaction is reversible
           middlePoint         vector with the x and y points of the middle
                               point of the reaction. All reactions are
                               defines as having one reactant and one product.
                               They may also have a number of modifiers (such
                               as cofactors or enzymes). Each of these
                               modifiers are drawn as being connected to the
                               middle point. The middle point is calculated
                               from the positions of the reactant and the
                               product
           componentList       structure with information on the reactant,
                               product, and modifiers of the reaction
               alias           string representing the alias of the
                               species. Corresponds to the alias in
                               listOfSpecies
               species         string representing the species.
                               Corresponds to the species in listOfSpecies
               anchor          vector with the x and y points of the
                               connecting point of the species
               baseReaction    true if the species is the base reactant
               baseProduct     true if the species is the base product
               toArrow         true if the line connecting the species
                               to the middle point should start with an
                               arrow
               fromArrow       true if the line connecting the species
                               to the middle point should end with an
                               arrow
               type            'METABOLITE' or 'ENZYME'

    Usage: pathway = constructPathwayFromCelldesigner(inputFile)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function pathway = constructPathwayFromCelldesigner(inputFile)
0002 % constructPathwayFromCelldesigner
0003 %    Constructs a pathway structure from a CellDesigner XML file.
0004 %
0005 %    inputFile   string representing the pathway of the Celldesigner XML
0006 %               file
0007 %
0008 %    pathway
0009 %       listOfCompartments      structure with information on the compartments
0010 %                               in the Celldesigner file
0011 %           x                   the x position
0012 %           y                   the y position
0013 %           h                   the height
0014 %           w                   the width
0015 %           compartment         string representing the compartment
0016 %           id                  alias of the compartment. Used if there are
0017 %                               several instances of the same compartment
0018 %           name                the name of the compartment
0019 %       listOfSpecies           structure with information on each species in
0020 %                               the Celldesigner file. Both metabolites and
0021 %                               enzymes are species
0022 %           x                   the x position
0023 %           y                   the y position
0024 %           h                   the height
0025 %           w                   the width
0026 %           species             string representing the species
0027 %           alias               alias of the species. Used if the species is
0028 %                               present in several places in the map
0029 %           name                the name of the species
0030 %           type                the type of the species. At the moment only
0031 %                               'SIMPLE_MOLECULE' (for metabolites) and
0032 %                               'PROTEIN' (for enzymes) are supported
0033 %           note                string that can be used on enzymes to link them
0034 %                               to the corresponding reaction in a model
0035 %       listOfReactions         structure with information on each of the
0036 %                               reactions in the Celldesigner file
0037 %           reversible          true if the reaction is reversible
0038 %           middlePoint         vector with the x and y points of the middle
0039 %                               point of the reaction. All reactions are
0040 %                               defines as having one reactant and one product.
0041 %                               They may also have a number of modifiers (such
0042 %                               as cofactors or enzymes). Each of these
0043 %                               modifiers are drawn as being connected to the
0044 %                               middle point. The middle point is calculated
0045 %                               from the positions of the reactant and the
0046 %                               product
0047 %           componentList       structure with information on the reactant,
0048 %                               product, and modifiers of the reaction
0049 %               alias           string representing the alias of the
0050 %                               species. Corresponds to the alias in
0051 %                               listOfSpecies
0052 %               species         string representing the species.
0053 %                               Corresponds to the species in listOfSpecies
0054 %               anchor          vector with the x and y points of the
0055 %                               connecting point of the species
0056 %               baseReaction    true if the species is the base reactant
0057 %               baseProduct     true if the species is the base product
0058 %               toArrow         true if the line connecting the species
0059 %                               to the middle point should start with an
0060 %                               arrow
0061 %               fromArrow       true if the line connecting the species
0062 %                               to the middle point should end with an
0063 %                               arrow
0064 %               type            'METABOLITE' or 'ENZYME'
0065 %
0066 %    Usage: pathway = constructPathwayFromCelldesigner(inputFile)
0067 
0068 %Loads the specified xml file using XML Toolbox
0069 ravenPath=findRAVENroot();
0070 
0071 %Current path and xml toolbox path
0072 cp=pwd;
0073 xt=fullfile(ravenPath,'software','xml_toolbox');
0074 
0075 %Change path, run the script and change back
0076 cd(xt);
0077 v = xml_parseany(fileread(inputFile));
0078 cd(cp);
0079 
0080 %Saves information on each compartment
0081 for i=1:length(v.model{1,1}.annotation{1,1}.listOfCompartmentAliases{1,1}.compartmentAlias)
0082     pathway.listOfCompartments(i).x=str2double(v.model{1,1}.annotation{1,1}.listOfCompartmentAliases{1,1}...
0083         .compartmentAlias{1,i}.bounds{1,1}.ATTRIBUTE.x);
0084     pathway.listOfCompartments(i).y=str2double(v.model{1,1}.annotation{1,1}.listOfCompartmentAliases{1,1}...
0085         .compartmentAlias{1,i}.bounds{1,1}.ATTRIBUTE.y);
0086     pathway.listOfCompartments(i).h=str2double(v.model{1,1}.annotation{1,1}.listOfCompartmentAliases{1,1}...
0087         .compartmentAlias{1,i}.bounds{1,1}.ATTRIBUTE.h);
0088     pathway.listOfCompartments(i).w=str2double(v.model{1,1}.annotation{1,1}.listOfCompartmentAliases{1,1}...
0089         .compartmentAlias{1,i}.bounds{1,1}.ATTRIBUTE.w);
0090     pathway.listOfCompartments(i).compartment=v.model{1,1}.annotation{1,1}.listOfCompartmentAliases{1,1}...
0091         .compartmentAlias{1,i}.ATTRIBUTE.compartment;
0092     pathway.listOfCompartments(i).id=v.model{1,1}.annotation{1,1}.listOfCompartmentAliases{1,1}...
0093         .compartmentAlias{1,i}.ATTRIBUTE.id;
0094     
0095     %Finds the name of the compartment
0096     for j=1:length(v.model{1,1}.listOfCompartments{1,1}.compartment)
0097         if strcmpi(v.model{1,1}.listOfCompartments{1,1}.compartment{1,j}.ATTRIBUTE.id,...
0098                 pathway.listOfCompartments(i).compartment)
0099             pathway.listOfCompartments(i).name=v.model{1,1}.listOfCompartments{1,1}.compartment{1,j}.ATTRIBUTE.name;
0100             break;
0101         end
0102     end
0103 end
0104 
0105 %Saves information on each species and enzyme
0106 for i=1:length(v.model{1,1}.annotation{1,1}.listOfSpeciesAliases{1,1}.speciesAlias)
0107     pathway.listOfSpecies(i).x=str2double(v.model{1,1}.annotation{1,1}.listOfSpeciesAliases{1,1}...
0108         .speciesAlias{1,i}.bounds{1,1}.ATTRIBUTE.x);
0109     pathway.listOfSpecies(i).y=str2double(v.model{1,1}.annotation{1,1}.listOfSpeciesAliases{1,1}...
0110         .speciesAlias{1,i}.bounds{1,1}.ATTRIBUTE.y);
0111     pathway.listOfSpecies(i).h=str2double(v.model{1,1}.annotation{1,1}.listOfSpeciesAliases{1,1}...
0112         .speciesAlias{1,i}.bounds{1,1}.ATTRIBUTE.h);
0113     pathway.listOfSpecies(i).w=str2double(v.model{1,1}.annotation{1,1}.listOfSpeciesAliases{1,1}...
0114         .speciesAlias{1,i}.bounds{1,1}.ATTRIBUTE.w);
0115     pathway.listOfSpecies(i).alias=v.model{1,1}.annotation{1,1}.listOfSpeciesAliases{1,1}...
0116         .speciesAlias{1,i}.ATTRIBUTE.id;
0117     pathway.listOfSpecies(i).species=v.model{1,1}.annotation{1,1}.listOfSpeciesAliases{1,1}...
0118         .speciesAlias{1,i}.ATTRIBUTE.species;
0119     %Find the name and type of the species/enzyme
0120     for j=1:length(v.model{1,1}.listOfSpecies{1,1}.species)
0121         if strcmpi(v.model{1,1}.listOfSpecies{1,1}.species{1,j}.ATTRIBUTE.id,...
0122                 pathway.listOfSpecies(i).species)
0123             pathway.listOfSpecies(i).name=v.model{1,1}.listOfSpecies{1,1}.species{1,j}.ATTRIBUTE.name;
0124             pathway.listOfSpecies(i).type=v.model{1,1}.listOfSpecies{1,1}.species{1,j}.annotation{1,1}...
0125                 .speciesIdentity{1,1}.class{1,1}.CONTENT;
0126             
0127             %The Celldesigner chart can be linked to a model (e.g. for
0128             %visualization of fluxes) by making a note in Celldesigner for
0129             %the protein in interest (this can only be done for proteins at
0130             %the moment). The note (not protein note!) should only contain
0131             %the reaction id in the model which corresponds to the protein
0132             %in Celldesigner.
0133             if strcmpi(pathway.listOfSpecies(i).type,'PROTEIN')
0134                 if isfield(v.model{1,1}.listOfSpecies{1,1}.species{1,j},'notes')
0135                     pathway.listOfSpecies(i).note=cellstr(strtrim(v.model{1,1}.listOfSpecies{1,1}.species{1,j}...
0136                         .notes{1,1}.html{1,1}.body{1,1}.CONTENT));
0137                 end
0138             end
0139             break;
0140         end
0141     end
0142 end
0143 
0144 %Saves information on each reaction
0145 for i=1:length(v.model{1,1}.listOfReactions{1,1}.reaction)
0146     %This is because it is standard for a reaction to be defined as
0147     %reversible
0148     if isfield(v.model{1,1}.listOfReactions{1,1}.reaction{1,i}.ATTRIBUTE,'reversible')
0149         pathway.listOfReactions(i).reversible=v.model{1,1}.listOfReactions{1,1}...
0150             .reaction{1,i}.ATTRIBUTE.reversible;
0151     else
0152         pathway.listOfReactions(i).reversible='true';
0153     end
0154     
0155     %NOTE: As far as I know there can only be one base reactant/product per
0156     %reaction. This method is written with that assumption.
0157     
0158     %Finds the alias of the base reactant
0159     baseReactant=v.model{1,1}.listOfReactions{1,1}...
0160         .reaction{1,i}.annotation{1,1}.baseReactants{1,1}.baseReactant{1,1}...
0161         .ATTRIBUTE.alias;
0162     
0163     %Finds the alias of the base product
0164     baseProduct=v.model{1,1}.listOfReactions{1,1}...
0165         .reaction{1,i}.annotation{1,1}.baseProducts{1,1}.baseProduct{1,1}...
0166         .ATTRIBUTE.alias;
0167     
0168     %Saves the middle point
0169     [x1,y1]=getBindingPos(pathway,baseReactant,...
0170         v.model{1,1}.listOfReactions{1,1}.reaction{1,i}.annotation{1,1}...
0171         .baseReactants{1,1}.baseReactant{1,1}.linkAnchor{1,1}.ATTRIBUTE.position);
0172     [x2,y2]=getBindingPos(pathway,baseProduct,...
0173         v.model{1,1}.listOfReactions{1,1}.reaction{1,i}.annotation{1,1}...
0174         .baseProducts{1,1}.baseProduct{1,1}.linkAnchor{1,1}.ATTRIBUTE.position);
0175     pathway.listOfReactions(i).middlePoint(1)=x1+(x2-x1)/2;
0176     pathway.listOfReactions(i).middlePoint(2)=y1+(y2-y1)/2;
0177     
0178     %Saves information on each of the components
0179     counter=1; %Keeps track of where in componentList to add a component
0180     
0181     %Adds the base reactant
0182     pathway.listOfReactions(i).componentList(counter).alias=v.model{1,1}...
0183         .listOfReactions{1,1}.reaction{1,i}.annotation{1,1}.baseReactants{1,1}...
0184         .baseReactant{1,1}.ATTRIBUTE.alias;
0185     pathway.listOfReactions(i).componentList(counter).species=v.model{1,1}...
0186         .listOfReactions{1,1}.reaction{1,i}.annotation{1,1}.baseReactants{1,1}...
0187         .baseReactant{1,1}.ATTRIBUTE.species;
0188     [x,y]=getBindingPos(pathway,baseReactant,v.model{1,1}.listOfReactions{1,1}...
0189         .reaction{1,i}.annotation{1,1}.baseReactants{1,1}.baseReactant{1,1}...
0190         .linkAnchor{1,1}.ATTRIBUTE.position);
0191     pathway.listOfReactions(i).componentList(counter).anchor(1)=x;
0192     pathway.listOfReactions(i).componentList(counter).anchor(2)=y;
0193     pathway.listOfReactions(i).componentList(counter).baseReactant='true';
0194     pathway.listOfReactions(i).componentList(counter).baseProduct='false';
0195     
0196     %toArrow should be true if the reaction is reversible
0197     pathway.listOfReactions(i).componentList(counter).toArrow=...
0198         pathway.listOfReactions(i).reversible;
0199     pathway.listOfReactions(i).componentList(counter).fromArrow='false';
0200     pathway.listOfReactions(i).componentList(counter).type='METABOLITE';
0201     counter=counter+1;
0202     
0203     %Adds the base product
0204     pathway.listOfReactions(i).componentList(counter).alias=v.model{1,1}...
0205         .listOfReactions{1,1}.reaction{1,i}.annotation{1,1}.baseProducts{1,1}...
0206         .baseProduct{1,1}.ATTRIBUTE.alias;
0207     pathway.listOfReactions(i).componentList(counter).species=v.model{1,1}...
0208         .listOfReactions{1,1}.reaction{1,i}.annotation{1,1}.baseProducts{1,1}...
0209         .baseProduct{1,1}.ATTRIBUTE.species;
0210     [x,y]=getBindingPos(pathway,baseProduct,v.model{1,1}.listOfReactions{1,1}...
0211         .reaction{1,i}.annotation{1,1}.baseProducts{1,1}.baseProduct{1,1}...
0212         .linkAnchor{1,1}.ATTRIBUTE.position);
0213     pathway.listOfReactions(i).componentList(counter).anchor(1)=x;
0214     pathway.listOfReactions(i).componentList(counter).anchor(2)=y;
0215     pathway.listOfReactions(i).componentList(counter).baseReactant='false';
0216     pathway.listOfReactions(i).componentList(counter).baseProduct='true';
0217     pathway.listOfReactions(i).componentList(counter).toArrow='true';
0218     pathway.listOfReactions(i).componentList(counter).fromArrow='false';
0219     pathway.listOfReactions(i).componentList(counter).type='METABOLITE';
0220     counter=counter+1;
0221     
0222     %Adds the non-base reactants Not all reactions have any non-base
0223     %reactants
0224     if isfield(v.model{1,1}.listOfReactions{1,1}.reaction{1,i}.annotation{1,1}...
0225             ,'listOfReactantLinks')
0226         for j=1:length(v.model{1,1}.listOfReactions{1,1}.reaction{1,i}.annotation{1,1}...
0227                 .listOfReactantLinks{1,1}.reactantLink)
0228             pathway.listOfReactions(i).componentList(counter).alias=v.model{1,1}...
0229                 .listOfReactions{1,1}.reaction{1,i}.annotation{1,1}...
0230                 .listOfReactantLinks{1,1}.reactantLink{1,j}.ATTRIBUTE.alias;
0231             pathway.listOfReactions(i).componentList(counter).species=v.model{1,1}...
0232                 .listOfReactions{1,1}.reaction{1,i}.annotation{1,1}...
0233                 .listOfReactantLinks{1,1}.reactantLink{1,j}.ATTRIBUTE.reactant;
0234             [x,y]=getBindingPos(pathway,pathway.listOfReactions(i).componentList(counter).alias...
0235                 ,v.model{1,1}.listOfReactions{1,1}.reaction{1,i}.annotation{1,1}...
0236                 .listOfReactantLinks{1,1}.reactantLink{1,j}.linkAnchor{1,1}...
0237                 .ATTRIBUTE.position);
0238             pathway.listOfReactions(i).componentList(counter).anchor(1)=x;
0239             pathway.listOfReactions(i).componentList(counter).anchor(2)=y;
0240             pathway.listOfReactions(i).componentList(counter).baseReactant='false';
0241             pathway.listOfReactions(i).componentList(counter).baseProduct='false';
0242             pathway.listOfReactions(i).componentList(counter).toArrow='false';
0243             pathway.listOfReactions(i).componentList(counter).fromArrow='false';
0244             pathway.listOfReactions(i).componentList(counter).type='METABOLITE';
0245             counter=counter+1;
0246         end
0247     end
0248     
0249     %Adds the non-base products Not all reactions have any non-base
0250     %products
0251     if isfield(v.model{1,1}.listOfReactions{1,1}.reaction{1,i}.annotation{1,1}...
0252             ,'listOfProductLinks')
0253         for j=1:length(v.model{1,1}.listOfReactions{1,1}.reaction{1,i}.annotation{1,1}...
0254                 .listOfProductLinks{1,1}.productLink)
0255             pathway.listOfReactions(i).componentList(counter).alias=v.model{1,1}...
0256                 .listOfReactions{1,1}.reaction{1,i}.annotation{1,1}...
0257                 .listOfProductLinks{1,1}.productLink{1,j}.ATTRIBUTE.alias;
0258             pathway.listOfReactions(i).componentList(counter).species=v.model{1,1}...
0259                 .listOfReactions{1,1}.reaction{1,i}.annotation{1,1}...
0260                 .listOfProductLinks{1,1}.productLink{1,j}.ATTRIBUTE.product;
0261             [x,y]=getBindingPos(pathway,pathway.listOfReactions(i).componentList(counter).alias...
0262                 ,v.model{1,1}.listOfReactions{1,1}.reaction{1,i}.annotation{1,1}...
0263                 .listOfProductLinks{1,1}.productLink{1,j}.linkAnchor{1,1}...
0264                 .ATTRIBUTE.position);
0265             pathway.listOfReactions(i).componentList(counter).anchor(1)=x;
0266             pathway.listOfReactions(i).componentList(counter).anchor(2)=y;
0267             pathway.listOfReactions(i).componentList(counter).baseReactant='false';
0268             pathway.listOfReactions(i).componentList(counter).baseProduct='false';
0269             pathway.listOfReactions(i).componentList(counter).toArrow='true';
0270             pathway.listOfReactions(i).componentList(counter).fromArrow='false';
0271             pathway.listOfReactions(i).componentList(counter).type='METABOLITE';
0272             counter=counter+1;
0273         end
0274     end
0275     
0276     %Adds the modifiers (enzymes) Not all reactions have any modifiers
0277     if isfield(v.model{1,1}.listOfReactions{1,1}.reaction{1,i}.annotation{1,1}...
0278             ,'listOfModification')
0279         for j=1:length(v.model{1,1}.listOfReactions{1,1}.reaction{1,i}.annotation{1,1}...
0280                 .listOfModification{1,1}.modification)
0281             pathway.listOfReactions(i).componentList(counter).alias=v.model{1,1}...
0282                 .listOfReactions{1,1}.reaction{1,i}.annotation{1,1}.listOfModification{1,1}...
0283                 .modification{1,j}.linkTarget{1,1}.ATTRIBUTE.alias;
0284             pathway.listOfReactions(i).componentList(counter).species=v.model{1,1}...
0285                 .listOfReactions{1,1}.reaction{1,i}.annotation{1,1}.listOfModification{1,1}...
0286                 .modification{1,j}.linkTarget{1,1}.ATTRIBUTE.species;
0287             [x,y]=getBindingPos(pathway,pathway.listOfReactions(i).componentList(counter).alias...
0288                 ,v.model{1,1}.listOfReactions{1,1}.reaction{1,i}.annotation{1,1}...
0289                 .listOfModification{1,1}.modification{1,j}.linkTarget{1,1}...
0290                 .linkAnchor{1,1}.ATTRIBUTE.position);
0291             pathway.listOfReactions(i).componentList(counter).anchor(1)=x;
0292             pathway.listOfReactions(i).componentList(counter).anchor(2)=y;
0293             pathway.listOfReactions(i).componentList(counter).baseReactant='false';
0294             pathway.listOfReactions(i).componentList(counter).baseProduct='false';
0295             pathway.listOfReactions(i).componentList(counter).toArrow='false';
0296             pathway.listOfReactions(i).componentList(counter).fromArrow='false';
0297             pathway.listOfReactions(i).componentList(counter).type='ENZYME';
0298             counter=counter+1;
0299         end
0300     end
0301 end
0302 end
0303 
0304 function [x,y]=getBindingPos(pathway,speciesAlias,bindingSite)
0305 % getBindingPos
0306 %   Calculates the position of a given binding site for a specified species
0307 %
0308 %   pathway         the pathway structure which should be modified
0309 %   speciesAlias    the alias of the species bindingSite     The binding
0310 %   site in Celldesigner is a string of up to
0311 %                   three letters that defines which of the 16 bindings
0312 %                   sites on each species to use. They are written as N
0313 %                   (north), NNW (north north west) and so on
0314 %
0315 %   [x, y]          The position of the binding site for the species
0316 %
0317 %   Usage: [x,y]=getBindingPos(pathway,speciesAlias,bindingSite)
0318 
0319 %Find the species
0320 for i=1:length(pathway.listOfSpecies)
0321     if strcmpi(pathway.listOfSpecies(i).alias,speciesAlias)
0322         xpos=pathway.listOfSpecies(i).x;
0323         ypos=pathway.listOfSpecies(i).y;
0324         h=pathway.listOfSpecies(i).h;
0325         w=pathway.listOfSpecies(i).w;
0326         
0327         %Species marked as "PROTEIN" should be drawn as rectangles. There
0328         %is one binding site in each corner and three in between on each
0329         %side.
0330         if strcmpi(pathway.listOfSpecies(i).type,'PROTEIN')
0331             %The binding sites clockwise from the top position
0332             if strcmpi(bindingSite,'N')
0333                 x=xpos+0.5*w;
0334                 y=ypos;
0335                 break;
0336             end
0337             if strcmpi(bindingSite,'NNE')
0338                 x=xpos+0.75*w;
0339                 y=ypos;
0340                 break;
0341             end
0342             if strcmpi(bindingSite,'NE')
0343                 x=xpos+w;
0344                 y=ypos;
0345                 break;
0346             end
0347             if strcmpi(bindingSite,'ENE')
0348                 x=xpos+w;
0349                 y=ypos+0.25*h;
0350                 break;
0351             end
0352             if strcmpi(bindingSite,'E')
0353                 x=xpos+w;
0354                 y=ypos+0.5*h;
0355                 break;
0356             end
0357             if strcmpi(bindingSite,'ESE')
0358                 x=xpos+w;
0359                 y=ypos+0.75*h;
0360                 break;
0361             end
0362             if strcmpi(bindingSite,'SE')
0363                 x=xpos+w;
0364                 y=ypos+h;
0365                 break;
0366             end
0367             if strcmpi(bindingSite,'SSE')
0368                 x=xpos+0.75*w;
0369                 y=ypos+h;
0370                 break;
0371             end
0372             if strcmpi(bindingSite,'S')
0373                 x=xpos+0.5*w;
0374                 y=ypos+h;
0375                 break;
0376             end
0377             if strcmpi(bindingSite,'SSW')
0378                 x=xpos+0.25*w;
0379                 y=ypos+h;
0380                 break;
0381             end
0382             if strcmpi(bindingSite,'SW')
0383                 x=xpos;
0384                 y=ypos+h;
0385                 break;
0386             end
0387             if strcmpi(bindingSite,'WSW')
0388                 x=xpos;
0389                 y=ypos+0.75*h;
0390                 break;
0391             end
0392             if strcmpi(bindingSite,'W')
0393                 x=xpos;
0394                 y=ypos+0.5*h;
0395                 break;
0396             end
0397             if strcmpi(bindingSite,'WNW')
0398                 x=xpos;
0399                 y=ypos+0.25*h;
0400                 break;
0401             end
0402             if strcmpi(bindingSite,'NW')
0403                 x=xpos;
0404                 y=ypos;
0405                 break;
0406             end
0407             if strcmpi(bindingSite,'NNW')
0408                 x=xpos+0.25*w;
0409                 y=ypos;
0410                 break;
0411             end
0412         end
0413         
0414         %Species marked as "SIMPLE_MOLECULE" should be drawn as ellipses.
0415         %There is one binding site in each extreme point and three in
0416         %between on each side
0417         if strcmpi(pathway.listOfSpecies(i).type,'SIMPLE_MOLECULE')
0418             %Find the center of the ellipse
0419             centerX=xpos+0.5*w;
0420             centerY=ypos+0.5*h;
0421             
0422             %The binding sites clockwise from the top position
0423             if strcmpi(bindingSite,'N')
0424                 angle=(4/8)*pi;
0425             end
0426             if strcmpi(bindingSite,'NNE')
0427                 angle=(5/8)*pi;
0428             end
0429             if strcmpi(bindingSite,'NE')
0430                 angle=(6/8)*pi;
0431             end
0432             if strcmpi(bindingSite,'ENE')
0433                 angle=(7/8)*pi;
0434             end
0435             if strcmpi(bindingSite,'E')
0436                 angle=(8/8)*pi;
0437             end
0438             if strcmpi(bindingSite,'ESE')
0439                 angle=(9/8)*pi;
0440             end
0441             if strcmpi(bindingSite,'SE')
0442                 angle=(10/8)*pi;
0443             end
0444             if strcmpi(bindingSite,'SSE')
0445                 angle=(11/8)*pi;
0446             end
0447             if strcmpi(bindingSite,'S')
0448                 angle=(12/8)*pi;
0449             end
0450             if strcmpi(bindingSite,'SSW')
0451                 angle=(13/8)*pi;
0452             end
0453             if strcmpi(bindingSite,'SW')
0454                 angle=(14/8)*pi;
0455             end
0456             if strcmpi(bindingSite,'WSW')
0457                 angle=(15/8)*pi;
0458             end
0459             if strcmpi(bindingSite,'W')
0460                 angle=(16/8)*pi;
0461             end
0462             if strcmpi(bindingSite,'WNW')
0463                 angle=(1/8)*pi;
0464             end
0465             if strcmpi(bindingSite,'NW')
0466                 angle=(2/8)*pi;
0467             end
0468             if strcmpi(bindingSite,'NNW')
0469                 angle=(3/8)*pi;
0470             end
0471             x=centerX-(0.5*w)*cos(angle);
0472             y=centerY-(0.5*h)*sin(angle);
0473             break;
0474         end
0475     end
0476 end
0477 end

Generated by m2html © 2005