|
75 | 75 | % * .Nodes.MoietyIndex - numeric id of the corresponding moiety (arm.MTG.Nodes.MoietyIndex)
|
76 | 76 | % * .Nodes.Component - numeric id of the corresponding connected component (rows of C2A)
|
77 | 77 | % * .Nodes.IsomorphismClass - numeric id of the corresponding isomprphism class (rows of I2C)
|
78 |
| -% * .Nodes.IsFirst - boolean, true if atom is within first component of an isomorphism class |
| 78 | +% * .Nodes.IsCanonical - boolean, true if atom is within first component of an isomorphism class |
79 | 79 | %
|
80 | 80 | % * .Edges — Table of edge information, with `u` rows, one for each atom transition instance.
|
81 | 81 | % * .Edges.EndNodes - numeric id of head and tail atoms that defines the graph edges
|
|
87 | 87 | % * .Edges.TransIndex - unique numeric id for each atom transition
|
88 | 88 | % * .Edges.Component - numeric id of the corresponding connected component (columns of T2C)
|
89 | 89 | % * .Edges.IsomorphismClass - numeric id of the corresponding isomprphism class (columns of T2I)
|
90 |
| -% * .Edges.IsFirst - boolean, true if atom transition is within first component of an isomorphism class |
| 90 | +% * .Edges.IsCanonical - boolean, true if atom transition is within first component of an isomorphism class |
91 | 91 | %
|
92 | 92 | % arm.M2A: `m x a` matrix mapping each metabolite to one or more atoms in the (undirected) atom transition graph
|
93 | 93 | % arm.A2R: `u x n` matrix that maps atom transitions to reactions. An atom transition can map to multiple reactions and a reaction can map to multiple atom transitions
|
|
105 | 105 | % arm.MTG: (undirected) moitey transition graph, as a MATLAB graph structure with the following tables and variables:
|
106 | 106 | %
|
107 | 107 | % * .Nodes — Table of node information, with `p` rows, one for each moiety instance.
|
108 |
| -% * .Nodes.MoietyIndex - unique numeric id of the moiety |
| 108 | +% * .Nodes.MoietyIndex - unique numeric id of the moiety instance |
109 | 109 | % * .Nodes.Formula - chemical formula of the moiety (Hill notation)
|
110 |
| -% * .Nodes.Met - representative metabolite containing the moiety |
| 110 | +% * .Nodes.Met - metabolite containing the moiety instance |
111 | 111 | % * .Nodes.Component - numeric id of the corresponding connected component (rows of C2M)
|
112 | 112 | % * .Nodes.IsomorphismClass - numeric id of the corresponding isomprphism class (rows of I2M)
|
113 | 113 |
|
|
117 | 117 | % * .Edges.Rxn - the reaction from which this moiety transition was derived
|
118 | 118 | % * .Edges.Component - numeric id of the corresponding connected component (columns of M2C)
|
119 | 119 | % * .Edges.IsomorphismClass - numeric id of the corresponding isomprphism class (columns of M2I)
|
120 |
| -% * .Edges.IsFirst - boolean, true if moiety transition is within first component of an isomorphism class |
| 120 | +% * .Edges.IsCanonical - boolean, true if moiety transition is within first component of an isomorphism class |
121 | 121 | % Note that M = incidence(arm.MTG); gives the p x q incidence matrix of the moitey transition graph
|
122 | 122 | %
|
123 | 123 | % arm.I2M Matrix to map each isomorphism class to one or more moiety instances
|
|
134 | 134 | % arm.ATG.Edges.orientationATM2dATM - orientation of edge with respect to the reaction from which this atom transition was derived
|
135 | 135 | % arm.ATG.Edges.Rxn - the reaction from which this atom transition was derived
|
136 | 136 | %
|
137 |
| -% arm.MTG.Nodes.IsFirst - boolean, true if moiety corresponds to the first component of an isomorphism class (should be all true) |
| 137 | +% arm.MTG.Nodes.IsCanonical - boolean, true if moiety corresponds to the first component of an isomorphism class (should be all true) |
138 | 138 | % arm.MTG.Nodes.Atom - alphanumeric id of the corresponding atom in the first component of an isomorphism class
|
139 | 139 | % arm.MTG.Nodes.AtomIndex - numeric id of the corresponding atom in the first component of an isomorphism class
|
140 | 140 | % arm.MTG.Edges.orientationATM2dATM - orientation of moiety transition with respect to the reaction from which this moiety transition was derived
|
|
713 | 713 | %% Moiety transition graph
|
714 | 714 | %create the moiety transition graph explicitly as a
|
715 | 715 | %subgraph of the atom transition graph
|
716 |
| -[isFirst, moiety2isomorphismClass] = ismember(atoms2component,firstSubgraphIndices); |
717 |
| -moiety2isomorphismClass = moiety2isomorphismClass(isFirst); |
| 716 | +[isCanonical, moiety2isomorphismClass] = ismember(atoms2component,firstSubgraphIndices); |
| 717 | +moiety2isomorphismClass = moiety2isomorphismClass(isCanonical); |
718 | 718 |
|
719 | 719 | if sanityChecks
|
720 |
| - moiety2isomorphismClass2 = atoms2isomorphismClass(isFirst); |
| 720 | + moiety2isomorphismClass2 = atoms2isomorphismClass(isCanonical); |
721 | 721 | if any(moiety2isomorphismClass~=moiety2isomorphismClass2)
|
722 | 722 | error('Inconsistent moiety2isomorphismClass vector')
|
723 | 723 | end
|
724 | 724 | end
|
725 | 725 |
|
726 |
| -ATG.Nodes = addvars(ATG.Nodes,isFirst,'NewVariableNames','IsFirst'); |
| 726 | +ATG.Nodes = addvars(ATG.Nodes,isCanonical,'NewVariableNames','IsCanonical'); |
727 | 727 | %size of the moiety instance transition graph
|
728 |
| -nMoieties=nnz(isFirst); |
729 |
| -isFirstTransition = any(A(isFirst, :), 1)'; |
730 |
| -nMoietyTransitions = nnz(isFirstTransition); |
| 728 | +nMoieties=nnz(isCanonical); |
| 729 | +isCanonicalTransition = any(A(isCanonical, :), 1)'; |
| 730 | +nMoietyTransitions = nnz(isCanonicalTransition); |
731 | 731 |
|
732 | 732 | if 0
|
733 |
| - ATG.Edges = addvars(ATG.Edges,isFirstTransition,'NewVariableNames','IsFirst'); |
| 733 | + ATG.Edges = addvars(ATG.Edges,isCanonicalTransition,'NewVariableNames','IsCanonical'); |
734 | 734 | else
|
735 |
| - ATG.Edges.IsFirst = isFirstTransition; |
| 735 | + ATG.Edges.IsCanonical = isCanonicalTransition; |
736 | 736 | end
|
737 | 737 |
|
738 | 738 | %draft moiety transition graph, before editing node and
|
739 | 739 | %edge information
|
740 |
| -MTG = subgraph(ATG,isFirst); |
| 740 | +MTG = subgraph(ATG,isCanonical); |
741 | 741 | M = incidence(MTG);
|
742 | 742 |
|
743 | 743 | MTG.Nodes.MoietyIndex = (1:nMoieties)';
|
|
752 | 752 | end
|
753 | 753 |
|
754 | 754 | %add moiety specific information
|
755 |
| -MTG.Nodes = removevars(MTG.Nodes,{'AtomNumber','Element','IsFirst','Atom','AtomIndex'}); |
| 755 | +MTG.Nodes = removevars(MTG.Nodes,{'AtomNumber','Element','IsCanonical','Atom','AtomIndex'}); |
756 | 756 | MTG.Nodes = addvars(MTG.Nodes,moietyFormulae(moiety2isomorphismClass),'NewVariableNames','Formula','After','MoietyIndex');
|
757 | 757 |
|
758 | 758 | % * .Edges.HeadAtom - head Nodes.Atom
|
|
767 | 767 | if 1
|
768 | 768 | %graph.Edges cannot be directly edited in a graph object, so extract,
|
769 | 769 | %edit and regenerate the graph
|
770 |
| - Edges = removevars(MTG.Edges,{'Trans','TransIndex','TransInstIndex','OrigTransInstIndex','HeadAtomIndex','TailAtomIndex','HeadAtom','TailAtom','orientationATM2dATM','IsFirst','Rxn'}); |
| 770 | + Edges = removevars(MTG.Edges,{'Trans','TransIndex','TransInstIndex','OrigTransInstIndex','HeadAtomIndex','TailAtomIndex','HeadAtom','TailAtom','orientationATM2dATM','IsCanonical','Rxn'}); |
771 | 771 | %add variables
|
772 | 772 | Edges = addvars(Edges,MTG.Nodes.Formula(Edges.EndNodes(:,1)),'NewVariableNames','Formula');
|
773 | 773 | %reorder the variables
|
|
796 | 796 | % Extract moiety graph directly from atom transition
|
797 | 797 | % graph incidence matrix
|
798 | 798 | [isFirstAlso, ~] = ismember(atoms2component,firstSubgraphIndices);
|
799 |
| - if ~all(isFirst == isFirstAlso) |
| 799 | + if ~all(isCanonical == isFirstAlso) |
800 | 800 | error('moiety incidence matrix does not match first component')
|
801 | 801 | end
|
802 | 802 | A = incidence(ATG);
|
|
824 | 824 | %add the moiety indices for the first atoms in each moiety
|
825 | 825 | moietyInd=1;
|
826 | 826 | for i=1:nAtoms
|
827 |
| - if ATG.Nodes.IsFirst(i) |
| 827 | + if ATG.Nodes.IsCanonical(i) |
828 | 828 | ATG.Nodes.MoietyIndex(i)=moietyInd;
|
829 | 829 | moietyInd = moietyInd + 1;
|
830 | 830 | end
|
|
880 | 880 |
|
881 | 881 | %% Map between moiety graph and metabolic network
|
882 | 882 | %map metabolite to moieties
|
883 |
| -moieties2mets = atoms2mets(isFirst); |
| 883 | +moieties2mets = atoms2mets(isCanonical); |
884 | 884 |
|
885 | 885 | %matrix to map each metabolite to one or more moieties
|
886 | 886 | M2M = sparse(moieties2mets,(1:nMoieties)', 1,nMappedMets,nMoieties);
|
|
919 | 919 | %matrix to map moiety transitions to reactions. Multiple moiety
|
920 | 920 | %transitions can map to multiple reactions.
|
921 | 921 | %A2R = A2Ti*Ti2R;
|
922 |
| -M2R = A2R(isFirstTransition,:); |
| 922 | +M2R = A2R(isCanonicalTransition,:); |
923 | 923 |
|
924 | 924 | if 0
|
925 | 925 | %in general it is not possible to specify the mapping from moiety
|
|
0 commit comments