Skip to content

Commit

Permalink
RAVEN 2.8.3 (#499)
Browse files Browse the repository at this point in the history
* fix: checkFunctionUniqueness on mac/unix

* fix: checkInstallation printOrange function

* fix: readYAMLmodel allows non-used genes

Allow for not all model.genes entries being in model.grRules.

* fix: writeYAMLmodel avoid escape character parsing

* fix: importModel with empty LB and UB (#495)

* feat: getMetaCycModelForOrganism I/O BLAST structure (#496)

* feat: getMetaCycModelForOrganism I/O blast results

* chore: updateDocumentation

* fix: ravenCobraWrapper with empty model.c (#497)

* feat: keggPhylDist.mat includes species names (#498)

for use in GECKO
  • Loading branch information
edkerk authored Jul 1, 2023
1 parent d007f3c commit 428da90
Show file tree
Hide file tree
Showing 19 changed files with 1,725 additions and 1,636 deletions.
182 changes: 92 additions & 90 deletions doc/external/kegg/getPhylDist.html
Original file line number Diff line number Diff line change
Expand Up @@ -111,96 +111,98 @@ <h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" sr
0048 fid = fopen(fullfile(keggPath,<span class="string">'taxonomy'</span>), <span class="string">'r'</span>);
0049
0050 phylDistStruct.ids={};
0051
0052 <span class="comment">%Keeps the categories for each organism</span>
0053 orgCat={};
0054
0055 currentCat={};
0056 <span class="comment">%Keeps track of the current category</span>
0057
0058 depth=0;
0059 <span class="comment">%Keeps track of the current tree depth</span>
0060
0061 <span class="comment">%Loop through the file</span>
0062 orgCounter=0;
0063 <span class="keyword">while</span> 1
0064 <span class="comment">%Get the next line</span>
0065 tline = fgetl(fid);
0066
0067 <span class="comment">%Abort at end of file</span>
0068 <span class="keyword">if</span> ~ischar(tline)
0069 <span class="keyword">break</span>;
0070 <span class="keyword">end</span>
0071
0072 <span class="keyword">if</span> any(tline)
0073 <span class="comment">%Check if it's a new category</span>
0074 <span class="keyword">if</span> tline(1)==<span class="string">'#'</span>
0075 <span class="comment">%Find the first space (=depth +1)</span>
0076 sPos=strfind(tline,<span class="string">' '</span>)-1;
0077 <span class="comment">%Should always exist</span>
0078
0079 sPos=sPos(1);
0080
0081 <span class="comment">%If we have stepped back one step in the tree</span>
0082 <span class="keyword">if</span> sPos&lt;depth
0083 currentCat=currentCat(1:sPos);
0084 <span class="keyword">end</span>
0085 depth=sPos;
0086
0087 currentCat{depth}=tline(sPos+2:end);
0088 <span class="keyword">else</span>
0089 orgCounter=orgCounter+1;
0090 <span class="comment">%It is an organism Get the id between first and second</span>
0091 <span class="comment">%white space</span>
0092 sPos=find(isstrprop(tline, <span class="string">'wspace'</span>));
0093 <span class="comment">%Should always exist</span>
0094
0095 phylDistStruct.ids{orgCounter}=tline(sPos(1)+1:sPos(2)-1);
0096 orgCat{orgCounter}=currentCat;
0097 <span class="keyword">end</span>
0098 <span class="keyword">end</span>
0099 <span class="keyword">end</span>
0100 <span class="comment">%Generate a distance matrix (very straight forward here, not neat)</span>
0101 phylDistStruct.distMat=zeros(numel(phylDistStruct.ids));
0102 phylDistStructOnlyInKingdom.distMat=zeros(numel(phylDistStruct.ids));
0103 phylDistStructOnlyInKingdom.ids=phylDistStruct.ids;
0104 <span class="keyword">for</span> i=1:numel(phylDistStruct.ids)
0105 <span class="keyword">for</span> j=1:numel(phylDistStruct.ids)
0106 <span class="keyword">if</span> ~strcmp(orgCat{i}(1),orgCat{j}(1))
0107 phylDistStructOnlyInKingdom.distMat(i,j)=Inf;
0108 <span class="keyword">end</span>
0109 <span class="comment">%Calculate the distance between then</span>
0110 dist=numel(orgCat{i})-numel(orgCat{j});
0111 <span class="keyword">if</span> dist&gt;0
0112 aCat=orgCat{i}(1:end-dist);
0113 <span class="keyword">else</span>
0114 aCat=orgCat{i};
0115 <span class="keyword">end</span>
0116 <span class="keyword">if</span> dist&lt;0
0117 bCat=orgCat{j}(1:end+dist);
0118 <span class="keyword">else</span>
0119 bCat=orgCat{j};
0120 <span class="keyword">end</span>
0121
0122 <span class="comment">%Loop through the categories and stop when they are the</span>
0123 <span class="comment">%same</span>
0124 <span class="keyword">for</span> k=numel(aCat):-1:1
0125 <span class="keyword">if</span> strcmp(aCat{k},bCat{k})
0126 <span class="keyword">break</span>;
0127 <span class="keyword">end</span>
0128 <span class="keyword">end</span>
0129 phylDistStruct.distMat(i,j)=dist+numel(aCat)-k;
0130 <span class="keyword">end</span>
0131 <span class="keyword">end</span>
0132 <span class="comment">%Save the structure</span>
0133 save(distFile,<span class="string">'phylDistStruct'</span>,<span class="string">'phylDistStructOnlyInKingdom'</span>);
0134 fprintf(<span class="string">'COMPLETE\n'</span>);
0135 <span class="keyword">end</span>
0136 <span class="keyword">end</span>
0137 <span class="keyword">if</span> onlyInKingdom==true
0138 phylDistStruct=phylDistStructOnlyInKingdom;
0139 <span class="keyword">end</span>
0140 <span class="keyword">end</span></pre></div>
0051 phylDistStruct.names={};
0052
0053 <span class="comment">%Keeps the categories for each organism</span>
0054 orgCat={};
0055
0056 currentCat={};
0057 <span class="comment">%Keeps track of the current category</span>
0058
0059 depth=0;
0060 <span class="comment">%Keeps track of the current tree depth</span>
0061
0062 <span class="comment">%Loop through the file</span>
0063 orgCounter=0;
0064 <span class="keyword">while</span> 1
0065 <span class="comment">%Get the next line</span>
0066 tline = fgetl(fid);
0067
0068 <span class="comment">%Abort at end of file</span>
0069 <span class="keyword">if</span> ~ischar(tline)
0070 <span class="keyword">break</span>;
0071 <span class="keyword">end</span>
0072
0073 <span class="keyword">if</span> any(tline)
0074 <span class="comment">%Check if it's a new category</span>
0075 <span class="keyword">if</span> tline(1)==<span class="string">'#'</span>
0076 <span class="comment">%Find the first space (=depth +1)</span>
0077 sPos=strfind(tline,<span class="string">' '</span>)-1;
0078 <span class="comment">%Should always exist</span>
0079
0080 sPos=sPos(1);
0081
0082 <span class="comment">%If we have stepped back one step in the tree</span>
0083 <span class="keyword">if</span> sPos&lt;depth
0084 currentCat=currentCat(1:sPos);
0085 <span class="keyword">end</span>
0086 depth=sPos;
0087
0088 currentCat{depth}=tline(sPos+2:end);
0089 <span class="keyword">else</span>
0090 orgCounter=orgCounter+1;
0091 <span class="comment">%It is an organism Get the id between first and second</span>
0092 <span class="comment">%white space</span>
0093 sPos=find(isstrprop(tline, <span class="string">'wspace'</span>));
0094 <span class="comment">%Should always exist</span>
0095
0096 phylDistStruct.ids{orgCounter}=tline(sPos(1)+1:sPos(2)-1);
0097 phylDistStruct.names{orgCounter}=tline(sPos(3)+1:end);
0098 orgCat{orgCounter}=currentCat;
0099 <span class="keyword">end</span>
0100 <span class="keyword">end</span>
0101 <span class="keyword">end</span>
0102 <span class="comment">%Generate a distance matrix (very straight forward here, not neat)</span>
0103 phylDistStruct.distMat=zeros(numel(phylDistStruct.ids));
0104 phylDistStructOnlyInKingdom.distMat=zeros(numel(phylDistStruct.ids));
0105 phylDistStructOnlyInKingdom.ids=phylDistStruct.ids;
0106 <span class="keyword">for</span> i=1:numel(phylDistStruct.ids)
0107 <span class="keyword">for</span> j=1:numel(phylDistStruct.ids)
0108 <span class="keyword">if</span> ~strcmp(orgCat{i}(1),orgCat{j}(1))
0109 phylDistStructOnlyInKingdom.distMat(i,j)=Inf;
0110 <span class="keyword">end</span>
0111 <span class="comment">%Calculate the distance between then</span>
0112 dist=numel(orgCat{i})-numel(orgCat{j});
0113 <span class="keyword">if</span> dist&gt;0
0114 aCat=orgCat{i}(1:end-dist);
0115 <span class="keyword">else</span>
0116 aCat=orgCat{i};
0117 <span class="keyword">end</span>
0118 <span class="keyword">if</span> dist&lt;0
0119 bCat=orgCat{j}(1:end+dist);
0120 <span class="keyword">else</span>
0121 bCat=orgCat{j};
0122 <span class="keyword">end</span>
0123
0124 <span class="comment">%Loop through the categories and stop when they are the</span>
0125 <span class="comment">%same</span>
0126 <span class="keyword">for</span> k=numel(aCat):-1:1
0127 <span class="keyword">if</span> strcmp(aCat{k},bCat{k})
0128 <span class="keyword">break</span>;
0129 <span class="keyword">end</span>
0130 <span class="keyword">end</span>
0131 phylDistStruct.distMat(i,j)=dist+numel(aCat)-k;
0132 <span class="keyword">end</span>
0133 <span class="keyword">end</span>
0134 <span class="comment">%Save the structure</span>
0135 save(distFile,<span class="string">'phylDistStruct'</span>,<span class="string">'phylDistStructOnlyInKingdom'</span>);
0136 fprintf(<span class="string">'COMPLETE\n'</span>);
0137 <span class="keyword">end</span>
0138 <span class="keyword">end</span>
0139 <span class="keyword">if</span> onlyInKingdom==true
0140 phylDistStruct=phylDistStructOnlyInKingdom;
0141 <span class="keyword">end</span>
0142 <span class="keyword">end</span></pre></div>
<hr><address>Generated by <strong><a href="http://www.artefact.tk/software/matlab/m2html/" title="Matlab Documentation in HTML">m2html</a></strong> &copy; 2005</address>
</body>
</html>
Loading

0 comments on commit 428da90

Please sign in to comment.