Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RAVEN 2.6.0 #393

Merged
merged 174 commits into from
Feb 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
174 commits
Select commit Hold shift + click to select a range
7a085c0
feat: permuteModel can order genes
edkerk Aug 27, 2021
44baaf5
feat: exportForGit sorts model before export
edkerk Aug 27, 2021
c430c54
fix: exportModel correct prefix compartment IDs
edkerk Sep 3, 2021
7e5e16e
chore: update documentation
edkerk Sep 3, 2021
c00c9c2
fix: allow _ as first character
edkerk Sep 5, 2021
64ca217
chore: update documentation
edkerk Sep 5, 2021
7ab0f9d
Merge pull request #367 from SysBioChalmers/fix/exportModelComp
edkerk Sep 5, 2021
a80c3f2
fix: getBlast allow spaces in path to fasta file
edkerk Sep 12, 2021
1da822c
fix: getBlast allow spaces in path to fasta file
edkerk Sep 12, 2021
8c2e75f
fix: speed up gene renaming getKEGGModelForOrg
edkerk Sep 12, 2021
8282d96
feat: global KEGG model preloaded for getKEGGModelForOrganism
edkerk Sep 12, 2021
7363574
feat: checkFileExistence can copy files to tmp dir
edkerk Sep 21, 2021
5d316ed
refactor: copy fasta files to tempdir
edkerk Sep 21, 2021
5302bbc
Merge pull request #369 from SysBioChalmers/feat/speedgetKEGGmodel
edkerk Sep 21, 2021
ed6d8f4
fix: delete fasta file in temp dir
edkerk Sep 21, 2021
4083b38
chore: updateDocumentation
edkerk Sep 21, 2021
5df8248
Merge remote-tracking branch 'origin/devel' into fix/getBlast-spaces
edkerk Sep 21, 2021
17cfd43
Merge pull request #368 from SysBioChalmers/fix/getBlast-spaces
edkerk Sep 25, 2021
2016449
Merge remote-tracking branch 'origin/devel' into feat/sortIteams
edkerk Oct 18, 2021
03186b3
doc: remove reference to mosek and output MATLAB release
simas232 Oct 23, 2021
8a40994
Merge pull request #373 from SysBioChalmers/doc/updateCheckInstallation
simas232 Oct 23, 2021
f9f3c01
fix: correct formatting in getKEGGModelForOrganism
simas232 Oct 23, 2021
3be8314
Merge pull request #374 from SysBioChalmers/fix/getKEGGModelForOrganism
simas232 Oct 24, 2021
75c1939
fix: testBlast(false) allow to test makeblastdb before blastp
simas232 Oct 24, 2021
9e18822
fix: testBlast add exe extension for Windows binaries
simas232 Oct 24, 2021
b8da26a
refactor: integrate testBlast into checkInstallation
simas232 Oct 24, 2021
63abc85
fix: testDiamond add exe extension for Windows binary
simas232 Oct 24, 2021
6f5f4d8
refactor: integrate testDiamond into checkInstallation
simas232 Oct 24, 2021
f830e31
doc: testDiamond minor text fixes
simas232 Oct 24, 2021
1c10175
feat: permuteModel handles comps
edkerk Oct 25, 2021
35ea1b7
feat: sortIdentifiers function
edkerk Oct 25, 2021
4a250ac
refactor: use sortIdentifiers for model export
edkerk Oct 25, 2021
8dd899d
feat: test sortIdentifiers and permuteModel
edkerk Oct 25, 2021
274eb29
doc: updateDocumentation
edkerk Oct 25, 2021
b18c3c7
fix: checkInstallation MAFFT Windows check
simas232 Oct 29, 2021
10e445a
refactor: move testBlast and testDiamond to function_tests directory
simas232 Nov 1, 2021
23ec883
feat: add a small multi-fasta file for testing
simas232 Nov 1, 2021
9cb1178
feat: use yeast_galactosidases.fa instead of sce.fa in testBlast and …
simas232 Nov 1, 2021
736b591
feat: add blast db files
simas232 Nov 1, 2021
1245b3d
refactor: simplify testBlast and reintegrate to checkInstallation
simas232 Nov 1, 2021
0b54d53
refactor: simplify testDiamond and reintegrate to checkInstallation
simas232 Nov 1, 2021
29614ed
fix: testBlast, testDiamond rename tmpDB to tmpDIR
simas232 Nov 2, 2021
a0d7efe
feat: add testHmmer function and integrate to checkInstallation
simas232 Nov 2, 2021
b4938e6
fix: testHmmer remove unnecessary lines
simas232 Nov 2, 2021
c8f9318
feat: add testCdhit function and integrate to checkInstallation
simas232 Nov 2, 2021
48c5702
doc: minor text fixes for testing functions
simas232 Nov 2, 2021
3f73b78
feat: add testMafft function and integrate to checkInstallation
simas232 Nov 2, 2021
1048563
fix: several improvements for testing functions
simas232 Nov 2, 2021
1daf226
feat: ensure that testing functions work when external binaries are n…
simas232 Nov 2, 2021
4a7ae5a
doc: rename function_tests directory to software_tests
simas232 Nov 2, 2021
e329244
feat: checkModelStruct checks model.c
edkerk Nov 4, 2021
e715abf
fix: exportModel model.comps check
edkerk Nov 4, 2021
050af30
chore: updateDocumentation
edkerk Nov 4, 2021
116bb31
fix: checkModelStruct
edkerk Nov 4, 2021
a991dc1
chore: more detailed warning
edkerk Nov 4, 2021
8e5eb7f
doc: correct warning message
edkerk Nov 4, 2021
739ea86
doc: clarify warning message
edkerk Nov 4, 2021
519d6af
Merge pull request #379 from SysBioChalmers/fix/modelCheck
edkerk Nov 4, 2021
c63228c
feat: create a unit test for BLAST+
simas232 Nov 4, 2021
55f606e
feat: integrate BLAST+ unit test in checkInstallation
simas232 Nov 4, 2021
f867410
fix: checkInstallation small printed message fix
simas232 Nov 4, 2021
466ea8f
feat: create a unit test for DIAMOND
simas232 Nov 5, 2021
c0d0fb9
feat: integrate DIAMOND unit test in checkInstallation
simas232 Nov 5, 2021
e8d0eb9
feat: create a unit test for HMMER
simas232 Nov 8, 2021
61771d0
feat: integrate HMMER unit test in checkInstallation
simas232 Nov 8, 2021
988c110
doc: minor comment corrections in blastPlusTests and diamondTests
simas232 Nov 8, 2021
f2eef0e
fix: remove unnecessary line from diamondTests and hmmerTests
simas232 Nov 8, 2021
31b82d4
feat: create a unit test for CD-HIT
simas232 Nov 8, 2021
c1c347e
feat: integrate CD-HIT unit test in checkInstallation
simas232 Nov 8, 2021
4837b8c
feat: remove expHmmerResults.mat
simas232 Nov 8, 2021
550f192
feat: create a unit test for MAFFT
simas232 Nov 12, 2021
0544a7a
feat: integrate MAFFT unit test in checkInstallation
simas232 Nov 12, 2021
67b3c75
fix: remove -s flag in unit tests for MD5 calculations in macOS
simas232 Nov 12, 2021
6d646da
fix: blastPlusTests no longer checks for machine-specific files
simas232 Nov 14, 2021
c119c24
fix: blastPlusTests restore MD5 hash for BLAST results
simas232 Nov 14, 2021
e92579d
fix: blastPlus tests modify BLAST results check
simas232 Nov 14, 2021
f045ad5
doc: update comments to blastPlusTests
simas232 Nov 14, 2021
8c589ef
doc: update comments and restructure code in blastPlusTests
simas232 Nov 14, 2021
124d4cf
feat: add new function getMD5Hash for MD5 checksum calculation
simas232 Nov 21, 2021
ffa1ea2
refactor+feat: blastPlusTests
simas232 Nov 21, 2021
072da8f
doc: getBlast minor comment corrections
simas232 Nov 22, 2021
7de0918
refactor+feat: diamondTests
simas232 Nov 24, 2021
c4b581e
doc: add subsections in blastPlusTests and diamondTests
simas232 Nov 25, 2021
c489d6d
fix: minor fixes in hmmerTests
simas232 Nov 25, 2021
70b4a58
fix: update cdhitTests
simas232 Nov 25, 2021
e2684a4
fix: update mafftTests
simas232 Nov 25, 2021
74a8a25
fix: mafftTests now checks the result file, not md5 their MD5 hashes
simas232 Nov 26, 2021
93ea0d0
fix: cdhitTests now checks the result file, not md5 their MD5 hashes
simas232 Nov 26, 2021
56d5ba3
fix: remove unnecessary code from mafftTests
simas232 Nov 26, 2021
3b25eef
doc: minor comment fix in cdhitTests
simas232 Nov 26, 2021
cf9e16d
feat: add exec permission in Unix for newly added functions
simas232 Nov 26, 2021
1ced906
fix: checkInstallation remove duplicate code
simas232 Dec 3, 2021
9722579
fix: getDiamond simplify tmpDB removal
simas232 Dec 3, 2021
82eda24
fix: getDiamond simplify tmpDB removal
simas232 Dec 3, 2021
f54174d
fix: getBlast simplify tmpDB removal
simas232 Dec 3, 2021
aa9ec3f
fix: getBlast simplify tmpDB removal
simas232 Dec 3, 2021
2187f7b
Merge pull request #377 from SysBioChalmers/feat/addTests
simas232 Dec 3, 2021
a54857c
Merge branch 'devel' into feat/sortIteams
edkerk Dec 3, 2021
34f8816
fix+style: sortIdentifiers_and_permuteModelTests
simas232 Dec 4, 2021
771c571
doc: update HTML documentation
simas232 Dec 4, 2021
96c0c33
Merge pull request #364 from SysBioChalmers/feat/sortIteams
edkerk Dec 5, 2021
85971ca
Merge remote-tracking branch 'origin/devel' into doc/updateDocumentation
edkerk Dec 5, 2021
a8c9691
doc: update HTML documentation
edkerk Dec 5, 2021
77c5dc8
Merge pull request #381 from SysBioChalmers/doc/updateDocumentation
simas232 Dec 5, 2021
d8e74f8
feat: handle both main and master
mihai-sysbio Dec 6, 2021
a6be4cb
docs: update according to main branch rename
mihai-sysbio Dec 13, 2021
7a31ae2
chore: copy .github from master branch
mihai-sysbio Dec 13, 2021
99f40ba
feat: add automated tests with gh actions
mihai-sysbio Dec 6, 2021
8397579
refactor: gh templates styling
mihai-sysbio Dec 13, 2021
20cfb21
Merge pull request #383 from SysBioChalmers/chore/rename-master-to-main
mihai-sysbio Dec 13, 2021
8f19eb5
chore: remove all existing MAFFT files
simas232 Dec 18, 2021
1e983fa
chore: MAFFT (macOS) update to 7.490
simas232 Dec 18, 2021
dceeabc
chore: MAFFT (Unix) update to 7.490
simas232 Dec 18, 2021
7b71d02
chore: MAFFT (Windows) update to 7.490
simas232 Dec 18, 2021
b8ba05d
doc: add MAFFT license
simas232 Dec 18, 2021
a6a0ba3
doc: update MAFFT version in software/versions.txt
simas232 Dec 18, 2021
ffc6364
feat: enable exec permissions in macOS for MAFFT binaries
simas232 Dec 18, 2021
3504156
feat: enable exec permissions in Unix for MAFFT binaries
simas232 Dec 18, 2021
dcb2859
chore: fix broken CD-HIT executable for macOS
simas232 Dec 18, 2021
059ef47
chore: fix broken CD-HIT executable for Unix
simas232 Dec 18, 2021
2340b82
chore: recompile CD-HIT executable for Windows
simas232 Dec 18, 2021
a4484ad
chore: remove all existing HMMER files
simas232 Dec 18, 2021
337111a
chore: HMMER (macOS) update to 3.3.2
simas232 Dec 18, 2021
b232025
chore: HMMER (Unix) update to 3.3.2
simas232 Dec 18, 2021
8cf7a74
chore: HMMER (Windows) update to 3.3.2
simas232 Dec 18, 2021
c9fd3ca
doc: add HMMER license
simas232 Dec 18, 2021
2020ec1
doc: update HMMER version in software/versions.txt
simas232 Dec 18, 2021
1b6f653
chore: remove all existing DIAMOND files
simas232 Dec 18, 2021
01f3719
chore: DIAMOND (macOS) update to 2.0.13
simas232 Dec 18, 2021
917aa66
chore: DIAMOND (Unix) update to 2.0.13
simas232 Dec 18, 2021
71c009e
chore: DIAMOND (Windows) update to 2.0.13
simas232 Dec 19, 2021
4eec284
doc: add DIAMOND license
simas232 Dec 19, 2021
d5718f3
doc: update DIAMOND version in software/versions.txt
simas232 Dec 19, 2021
4b2e626
chore: remove all existing BLAST+ files
simas232 Dec 19, 2021
154e9fb
chore: BLAST+ (macOS) update to 2.12.0
simas232 Dec 19, 2021
c2d2b9f
chore: BLAST+ (Unix) update to 2.12.0
simas232 Dec 19, 2021
8ce8aa1
chore: BLAST+ (Windows) update to 2.12.0
simas232 Dec 19, 2021
6b3fcbb
doc: add BLAST+ license
simas232 Dec 19, 2021
008a2b4
doc: update BLAST+ version in software/versions.txt
simas232 Dec 19, 2021
52b3523
fix: rename compareModels to compareRxnsGenesMetsComps
simas232 Dec 19, 2021
223ec34
doc: update documentation
simas232 Dec 19, 2021
7c8f7c5
fix: updateDocumentation now removes keggModel.mat file
simas232 Dec 19, 2021
70aad10
Merge pull request #387 from SysBioChalmers/chore/updateExtSoftware
simas232 Dec 19, 2021
421bc53
Merge pull request #388 from SysBioChalmers/fix/renameCompareModels
simas232 Dec 19, 2021
da386dc
Merge pull request #389 from SysBioChalmers/fix/updateDocumentation
simas232 Dec 19, 2021
a624ac0
feat: change download links for KEGG HMMs
simas232 Dec 19, 2021
6c489af
doc: updated HTML documentation
simas232 Dec 19, 2021
19e8e84
Merge pull request #390 from SysBioChalmers/feat/changeKEGGHmmDownloa…
simas232 Dec 19, 2021
66d55f2
refactor: convertToIrrev speedup
edkerk Dec 20, 2021
081dcb1
feat: post test results as pr comment
mihai-sysbio Dec 18, 2021
18fc138
fix: show all test results
mihai-sysbio Dec 20, 2021
42f758d
Merge pull request #384 from SysBioChalmers/feat/testing-w-actions
mihai-sysbio Dec 20, 2021
9a9553f
fix: getKEGGModelForOrganism now checks organismID
simas232 Dec 31, 2021
f754e09
doc: updated documentation
simas232 Dec 31, 2021
2ab6124
Merge pull request #391 from SysBioChalmers/refactor/solveLP
edkerk Jan 1, 2022
f74cb0d
refactor: run MAFFT and CD-HIT via WSL on Windows
edkerk Jan 6, 2022
074ccdb
refactor: avoid unnecessary warnings about existing files
edkerk Jan 6, 2022
43de3e8
chore: update KEGG MAT-files to version 100
edkerk Jan 6, 2022
d946302
feat: remove MAFFT and CD-HIT Windows binaries
edkerk Jan 6, 2022
63ac1c2
Update external/kegg/getKEGGModelForOrganism.m
edkerk Jan 6, 2022
1113c0d
Merge pull request #392 from SysBioChalmers/fix/getKEGGModelForOrganism
simas232 Jan 8, 2022
8f45375
refactor: reporting of progress
edkerk Jan 6, 2022
3524d52
feat: checkInstallation develMode
edkerk Jan 12, 2022
24c3021
refactor: mafftTests and cdhitTests use WSL on PC
edkerk Jan 12, 2022
a8dc1d8
refactor: more accurate progress reporting
edkerk Jan 13, 2022
6c27c20
chore: pretrained HMMs only have 90% seqIdentity
edkerk Feb 3, 2022
736b85f
Merge remote-tracking branch 'origin/devel' into chore/updateKEGG
edkerk Feb 3, 2022
3ddeb6e
doc: updated HTML documentation
edkerk Feb 3, 2022
6e99ef5
refactor: getWSLpath to get Unix path in Windows
edkerk Feb 4, 2022
7e183b3
chore: update tutorial5
edkerk Feb 6, 2022
ce329ba
fix: getKEGGModelForOrgansim getWSLpath calls
edkerk Feb 6, 2022
fe3daa4
doc: update HTML-documentation
edkerk Feb 6, 2022
558d148
Merge pull request #395 from SysBioChalmers/chore/updateKEGG
edkerk Feb 7, 2022
dcc7af1
Merge branch 'main' into devel
edkerk Feb 7, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions .github/issue_template.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
### Description of the issue:
*Try to be as clear as possible, e.g.:
<!-- Try to be as clear as possible, e.g.
- Is there a functionality missing?
- Did an existing function fail?
- What is the exact error message, and other output that you got?
- What have you tried yourself to fix it?
- What have you tried yourself to fix it? -->

#### Reproducing this issue:
*If applicable, please attach the problematic code. PLEASE DELETE THIS LINE.*
<!-- If applicable, please attach the problematic code. -->
```matlab
INSERT CODE HERE
```
Expand All @@ -17,8 +17,7 @@ INSERT CODE HERE
2. Operating system (Windows/Mac/Linux; include version)

**I hereby confirm that I have:**
<!-- Note: replace [ ] with [X] to check the box -->
- [ ] Followed the [guidelines](https://github.com/SysBioChalmers/RAVEN/wiki/Installation) to install RAVEN.
- [ ] Checked that a similar issue does not [already exist](https://github.com/SysBioChalmers/RAVEN/issues?utf8=%E2%9C%93&q=is%3Aissue)
- [ ] If suitable, needed, asked first in the [Gitter chat room](https://gitter.im/SysBioChalmers/RAVEN) about the issue

*Note: replace [ ] with [X] to check the box. PLEASE DELETE THIS LINE*
8 changes: 3 additions & 5 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
### Main improvements in this PR:
*Pointwise mention what changes were made in what function. Examples:
<!-- Pointwise mention what changes were made in what function. Examples:
- fix bug where `functionName` failed to do function X
- updated all documentation
PLEASE DELETE THESE LINES*
- updated all documentation -->

**I hereby confirm that I have:**
<!-- Note: replace [ ] with [X] to check the box -->

- [ ] Tested my code on my own machine
- [ ] Followed the [development guidelines](https://github.com/SysBioChalmers/RAVEN/wiki/DevGuidelines).
- [ ] Selected `devel` as a target branch
- [ ] If needed, asked first in the [Gitter chat room](https://gitter.im/SysBioChalmers/RAVEN) about this PR

*Note: replace [ ] with [X] to check the box. PLEASE DELETE THIS LINE*
7 changes: 7 additions & 0 deletions .github/workflows/testing-comment.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
This PR has been [automatically tested with GH Actions](https://github.com/SysBioChalmers/RAVEN/actions/runs/{GH_ACTION_RUN}). Here is the output of the tests:

```
{TEST_RESULTS}
```

> _Note: In the case of multiple test runs, this post will be edited._
28 changes: 28 additions & 0 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Testing

on: [pull_request]

jobs:
matlab-tests:
runs-on: self-hosted

steps:

- name: Checkout
uses: actions/checkout@v2

- name: Run tests
id: matlab-test
run: |
TEST_RESULTS=$(/usr/local/bin/matlab -nodisplay -nosplash -nodesktop -r "addpath(genpath('.')); cd('testing/unit_tests'); runtests(struct2table(dir('*.m')).name); exit;")
PARSED_RESULTS=$(echo $TEST_RESULTS | awk -F'.com.' '{ n = split($2, v, "__________"); for (i = 0; ++i <= n;) { print v[i] } }')
echo ::set-output name=results::$PARSED_RESULTS

- name: Post comment
uses: NejcZdovc/comment-pr@v1
with:
file: "testing-comment.md"
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
TEST_RESULTS: ${{steps.matlab-test.outputs.results}}
GH_ACTION_RUN: ${{github.run_id}}
12 changes: 12 additions & 0 deletions core/checkModelStruct.m
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,18 @@ function checkModelStruct(model,throwErrors,trimWarnings)
EM='The following reactions have bounds contradicting their reversibility:';
dispEM(EM,throwErrors,model.rxns(model.lb<0 & model.rev==0),trimWarnings);

%Multiple or no objective functions not allowed in SBML L3V1 FBCv2
if numel(find(model.c))>1
EM='Multiple objective functions found. This might be intended, but exportModel will fail due to SBML FBCv2 non-compliance:';
dispEM(EM,false,model.rxns(find(model.c)),trimWarnings);
elseif ~any(model.c)
EM='No objective function found. This might be intended, but exportModel will fail due to SBML FBCv2 non-compliance';
dispEM(EM,false);
end

EM='The following reactions have contradicting bounds:';
dispEM(EM,throwErrors,model.rxns(model.lb>model.ub),trimWarnings);

%Mapping of compartments
if isfield(model,'compOutside')
EM='The following compartments are in "compOutside" but not in "comps":';
Expand Down
6 changes: 3 additions & 3 deletions core/compareModels.m → core/compareRxnsGenesMetsComps.m
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
function compStruct=compareModels(models,printResults)
% compareModels
function compStruct=compareRxnsGenesMetsComps(models,printResults)
% compareRxnsGenesMetsComps
% Compares two or more models with respect to overlap in terms of genes,
% reactions, metabolites and compartments.
%
Expand All @@ -23,7 +23,7 @@
% nElements vector with the number of elements for each
% comparison
%
% Usage: compStruct=compareModels(models,printResults)
% Usage: compStruct=compareRxnsGenesMetsComps(models,printResults)

if nargin<2
printResults=true;
Expand Down
6 changes: 3 additions & 3 deletions core/convertToIrrev.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
% Usage: irrevModel=convertToIrrev(model,rxns)

if nargin<2
rxns=model.rxns;
I=true(numel(model.rxns),1);
else
I=getIndexes(model,rxns,'rxns',true);
end

irrevModel=model;

I=getIndexes(model,rxns,'rxns',true);

revIndexesBool=model.rev~=0 & I;
revIndexes=find(revIndexesBool);
if any(revIndexesBool)
Expand Down
2 changes: 2 additions & 0 deletions core/dispEM.m
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ function dispEM(string,throwErrors,toList,trimWarnings)
end
end
if throwErrors==false
%Escape special characters, required for fprintf
errorText=regexprep(errorText,'(\\|\%|'')','\\$0');
fprintf([errorText '\n']);
else
throw(MException('',errorText));
Expand Down
240 changes: 142 additions & 98 deletions core/permuteModel.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,111 +2,155 @@
% permuteModel
% Changes the order of the reactions or metabolites in a model
%
% Input:
% model a model structure
% indexes a vector with the same length as the number of reactions in the
% model which gives the new order of reactions
% type 'rxns' for reactions and 'mets' for metabolites
% indexes a vector with the same length as the number of items in the
% model, which gives the new order of items
% type 'rxns' for reactions, 'mets' for metabolites, 'genes' for
% genes, 'comps' for compartments
%
% newModel an updated model structure
% Output:
% newModel an updated model structure
%
% Usage: newModel=permuteModel(model, indexes, type)

newModel=model;
indexes=indexes(:);

if strcmp(type,'rxns')
if isfield(newModel,'rxns')
newModel.rxns=newModel.rxns(indexes);
end
if isfield(newModel,'lb')
newModel.lb=newModel.lb(indexes);
end
if isfield(newModel,'ub')
newModel.ub=newModel.ub(indexes);
end
if isfield(newModel,'rev')
newModel.rev=newModel.rev(indexes);
end
if isfield(newModel,'c')
newModel.c=newModel.c(indexes);
end
if isfield(newModel,'S')
newModel.S=newModel.S(:,indexes);
end
if isfield(newModel,'rxnNames')
newModel.rxnNames=newModel.rxnNames(indexes);
end
if isfield(newModel,'rxnGeneMat')
newModel.rxnGeneMat=newModel.rxnGeneMat(indexes,:);
end
if isfield(newModel,'grRules')
newModel.grRules=newModel.grRules(indexes);
end
if isfield(newModel,'subSystems')
newModel.subSystems=newModel.subSystems(indexes);
end
if isfield(newModel,'eccodes')
newModel.eccodes=newModel.eccodes(indexes);
end
if isfield(newModel,'equations')
newModel.equations=newModel.equations(indexes);
end
if isfield(newModel,'rxnMiriams')
newModel.rxnMiriams=newModel.rxnMiriams(indexes);
end
if isfield(newModel,'rxnComps')
newModel.rxnComps=newModel.rxnComps(indexes);
end
if isfield(newModel,'rxnFrom')
newModel.rxnFrom=newModel.rxnFrom(indexes);
end
if isfield(newModel,'rxnScores')
newModel.rxnScores=newModel.rxnScores(indexes);
end
if isfield(newModel,'rxnNotes')
newModel.rxnNotes=newModel.rxnNotes(indexes);
end
if isfield(newModel,'rxnReferences')
newModel.rxnReferences=newModel.rxnReferences(indexes);
end
if isfield(newModel,'rxnConfidenceScores')
newModel.rxnConfidenceScores=newModel.rxnConfidenceScores(indexes);
end
end

if strcmp(type,'mets')
if isfield(newModel,'mets')
newModel.mets=newModel.mets(indexes);
end
if isfield(newModel,'metNames')
newModel.metNames=newModel.metNames(indexes);
end
if isfield(newModel,'b')
newModel.b=newModel.b(indexes,:);
end
if isfield(newModel,'metComps')
newModel.metComps=newModel.metComps(indexes);
end
if isfield(newModel,'S')
newModel.S=newModel.S(indexes,:);
end
if isfield(newModel,'unconstrained')
newModel.unconstrained=newModel.unconstrained(indexes);
end
if isfield(newModel,'metMiriams')
newModel.metMiriams=newModel.metMiriams(indexes,:);
end
if isfield(newModel,'inchis')
newModel.inchis=newModel.inchis(indexes);
end
if isfield(newModel,'metFormulas')
newModel.metFormulas=newModel.metFormulas(indexes);
end
if isfield(newModel,'metFrom')
newModel.metFrom=newModel.metFrom(indexes);
end
if isfield(newModel,'metCharges')
newModel.metCharges=newModel.metCharges(indexes);
end
switch type
case 'rxns'
if isfield(newModel,'rxns')
newModel.rxns=newModel.rxns(indexes);
end
if isfield(newModel,'lb')
newModel.lb=newModel.lb(indexes);
end
if isfield(newModel,'ub')
newModel.ub=newModel.ub(indexes);
end
if isfield(newModel,'rev')
newModel.rev=newModel.rev(indexes);
end
if isfield(newModel,'c')
newModel.c=newModel.c(indexes);
end
if isfield(newModel,'S')
newModel.S=newModel.S(:,indexes);
end
if isfield(newModel,'rxnNames')
newModel.rxnNames=newModel.rxnNames(indexes);
end
if isfield(newModel,'rxnGeneMat')
newModel.rxnGeneMat=newModel.rxnGeneMat(indexes,:);
end
if isfield(newModel,'grRules')
newModel.grRules=newModel.grRules(indexes);
end
if isfield(newModel,'subSystems')
newModel.subSystems=newModel.subSystems(indexes);
end
if isfield(newModel,'eccodes')
newModel.eccodes=newModel.eccodes(indexes);
end
if isfield(newModel,'equations')
newModel.equations=newModel.equations(indexes);
end
if isfield(newModel,'rxnMiriams')
newModel.rxnMiriams=newModel.rxnMiriams(indexes);
end
if isfield(newModel,'rxnComps')
newModel.rxnComps=newModel.rxnComps(indexes);
end
if isfield(newModel,'rxnFrom')
newModel.rxnFrom=newModel.rxnFrom(indexes);
end
if isfield(newModel,'rxnScores')
newModel.rxnScores=newModel.rxnScores(indexes);
end
if isfield(newModel,'rxnNotes')
newModel.rxnNotes=newModel.rxnNotes(indexes);
end
if isfield(newModel,'rxnReferences')
newModel.rxnReferences=newModel.rxnReferences(indexes);
end
if isfield(newModel,'rxnConfidenceScores')
newModel.rxnConfidenceScores=newModel.rxnConfidenceScores(indexes);
end
case 'mets'
if isfield(newModel,'mets')
newModel.mets=newModel.mets(indexes);
end
if isfield(newModel,'metNames')
newModel.metNames=newModel.metNames(indexes);
end
if isfield(newModel,'b')
newModel.b=newModel.b(indexes,:);
end
if isfield(newModel,'metComps')
newModel.metComps=newModel.metComps(indexes);
end
if isfield(newModel,'S')
newModel.S=newModel.S(indexes,:);
end
if isfield(newModel,'unconstrained')
newModel.unconstrained=newModel.unconstrained(indexes);
end
if isfield(newModel,'metMiriams')
newModel.metMiriams=newModel.metMiriams(indexes,:);
end
if isfield(newModel,'inchis')
newModel.inchis=newModel.inchis(indexes);
end
if isfield(newModel,'metFormulas')
newModel.metFormulas=newModel.metFormulas(indexes);
end
if isfield(newModel,'metFrom')
newModel.metFrom=newModel.metFrom(indexes);
end
if isfield(newModel,'metCharges')
newModel.metCharges=newModel.metCharges(indexes);
end
case 'genes'
if isfield(newModel,'genes')
newModel.genes=newModel.genes(indexes);
end
if isfield(newModel,'geneComps')
newModel.geneComps=newModel.geneComps(indexes);
end
if isfield(newModel,'geneMiriams')
newModel.geneMiriams=newModel.geneMiriams(indexes);
end
if isfield(newModel,'geneShortNames')
newModel.geneShortNames=newModel.geneShortNames(indexes);
end
if isfield(newModel,'rxnGeneMat')
newModel.rxnGeneMat=newModel.rxnGeneMat(:,indexes);
end
case 'comps'
if isfield(newModel,'comps')
newModel.comps=newModel.comps(indexes);
end
if isfield(newModel,'compNames')
newModel.compNames=newModel.compNames(indexes);
end
if isfield(newModel,'compOutside')
newModel.compOutside=newModel.compOutside(indexes);
end
if isfield(newModel,'compMiriams')
newModel.compMiriams=newModel.compMiriams(indexes);
end
[~,J]=sort(indexes); % The *index* of compartment is used in next fields
if isfield(newModel,'metComps')
[toreplace, bywhat] = ismember(newModel.metComps,1:length(J));
newModel.metComps(toreplace) = J(bywhat(toreplace));
end
if isfield(model,'rxnComps')
[toreplace, bywhat] = ismember(model.rxnComps,1:length(J));
model.rxnComps(toreplace) = J(bywhat(toreplace));
end
if isfield(model,'geneComps')
[toreplace, bywhat] = ismember(model.geneComps,1:length(J));
model.geneComps(toreplace) = J(bywhat(toreplace));
end
end
end
Loading