Skip to content

Commit

Permalink
Merge pull request #417 from SysBioChalmers/devel
Browse files Browse the repository at this point in the history
RAVEN 2.7.0
  • Loading branch information
edkerk authored May 13, 2022
2 parents 16298dc + 940aca0 commit fbbdba1
Show file tree
Hide file tree
Showing 292 changed files with 38,024 additions and 17,414 deletions.
3 changes: 2 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
# Use MATLAB style diff
*.m text diff=matlab
# Mark as binary to prevent EOL changes. Also no need to track
mafft-linux*/* binary
mafft.bat binary
mafft/ binary
# Files/folders that should not be included when downloading repo as ZIP
.gitattributes export-ignore
.gitignore export-ignore
Expand Down
36 changes: 19 additions & 17 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,24 @@ jobs:
runs-on: self-hosted

steps:
- name: Checkout
uses: actions/checkout@v2

- 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] } }')
PARSED_RESULTS="${PARSED_RESULTS//'%'/'%25'}"
PARSED_RESULTS="${PARSED_RESULTS//$'\n'/'%0A'}"
PARSED_RESULTS="${PARSED_RESULTS//$'\r'/'%0D'}"
echo ::set-output name=results::$PARSED_RESULTS
- 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}}
- 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}}
4 changes: 4 additions & 0 deletions INIT/getINITModel.m
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@

if nargin<3
celltype=[];
else
celltype=char(celltype);
end
if nargin<4
hpaData=[];
Expand All @@ -121,6 +123,8 @@
end
if nargin<7
taskFile=[];
else
taskFile=char(taskFile);
end
if nargin<8 || isempty(useScoresForTasks)
useScoresForTasks=true;
Expand Down
21 changes: 7 additions & 14 deletions INIT/runINIT.m
Original file line number Diff line number Diff line change
Expand Up @@ -67,24 +67,17 @@
if isempty(rxnScores)
rxnScores=zeros(numel(model.rxns),1);
end
if nargin<3
if nargin<3 || isempty(presentMets)
presentMets={};
else
presentMets=convertCharArray(presentMets);
end
if isempty(presentMets)
presentMets={};
end
presentMets=presentMets(:);
if nargin<4
essentialRxns={};
end
if isempty(essentialRxns)
if nargin<4 || isempty(essentialRxns)
essentialRxns={};
else
essentialRxns=convertCharArray(essentialRxns);
end
essentialRxns=essentialRxns(:);
if nargin<5
prodWeight=0.5;
end
if isempty(prodWeight)
if nargin<5 || isempty(prodWeight)
prodWeight=0.5;
end
if nargin<6
Expand Down
4 changes: 4 additions & 0 deletions core/FSEOF.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
%
% Usage: targets=FSEOF(model,biomassRxn,targetRxn,iterations,coefficient,outputFile)

biomassRxn=char(biomassRxn);
targetRxn=char(targetRxn);

if nargin<4
iterations=10;
coefficient=0.9;
Expand Down Expand Up @@ -96,6 +99,7 @@
%Generating output
formatSpec='%s\t%s\t%s\t%s\t%s\t%s\t%s\n';
if output == 1 %Output to a file
outputFile=char(outputFile);
fid=fopen(outputFile,'w');
fprintf(fid,formatSpec,'Slope','rowID','Enzyme ID','Enzyme Name','Subsystems','Direction','Gr Rule');
else %Output to screen
Expand Down
5 changes: 4 additions & 1 deletion core/addExchangeRxns.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,14 @@

if nargin<3
mets=model.mets;
elseif ~islogical(mets) && ~isnumeric(mets)
mets=convertCharArray(mets);
end
reactionType=upper(reactionType);
J=getIndexes(model,mets,'mets',false);
mets=model.mets(J);

reactionType=char(upper(reactionType));

%Production is positive for OUT and BOTH
if strcmp(reactionType,'IN')
I=speye(numel(model.mets));
Expand Down
12 changes: 3 additions & 9 deletions core/addGenesRaven.m
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,8 @@
if ~isfield(genesToAdd,'genes')
EM='genes is a required field in genesToAdd';
dispEM(EM);
end

if ~iscellstr(genesToAdd.genes)
EM='genesToAdd.genes must be a cell array of strings';
dispEM(EM);
else
genesToAdd.genes=convertCharArray(genesToAdd.genes);
end

%Number of genes
Expand Down Expand Up @@ -68,14 +65,11 @@

%Some more checks and if they pass then add each field to the structure
if isfield(genesToAdd,'geneShortNames')
genesToAdd.geneShortNames=convertCharArray(genesToAdd.geneShortNames);
if numel(genesToAdd.geneShortNames)~=nGenes
EM='genesToAdd.geneShortNames must have the same number of elements as genesToAdd.genes';
dispEM(EM);
end
if ~iscellstr(genesToAdd.geneShortNames)
EM='genesToAdd.geneShortNames must be a cell array of strings';
dispEM(EM);
end
%Add empty field if it doesn't exist
if ~isfield(newModel,'geneShortNames')
newModel.geneShortNames=largeFiller;
Expand Down
63 changes: 15 additions & 48 deletions core/addMets.m
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@
end
if nargin<4
prefix='m_';
else
prefix=char(prefix);
end

newModel=model;
Expand All @@ -69,35 +71,19 @@
%Check some stuff regarding the required fields
if ~isfield(metsToAdd,'mets')
metsToAdd.mets=generateNewIds(newModel,'mets',prefix,numel(metsToAdd.metNames));
else
metsToAdd.mets=convertCharArray(metsToAdd.mets);
end
if ~isfield(metsToAdd,'metNames')
metsToAdd.metNames=metsToAdd.mets;
else
metsToAdd.metNames=convertCharArray(metsToAdd.metNames);
end
if ~isfield(metsToAdd,'compartments')
EM='compartments is a required field in metsToAdd';
dispEM(EM);
end
if ischar(metsToAdd.mets)
metsToAdd.mets={metsToAdd.mets};
elseif ~iscellstr(metsToAdd.mets)
EM='metsToAdd.mets must be a cell array of strings';
dispEM(EM);
end
if ischar(metsToAdd.metNames)
metsToAdd.metNames={metsToAdd.metNames};
elseif ~iscellstr(metsToAdd.metNames)
EM='metsToAdd.metNames must be a cell array of strings';
dispEM(EM);
end
if ~iscellstr(metsToAdd.compartments)
if ischar(metsToAdd.compartments)
temp=cell(numel(metsToAdd.mets),1);
temp(:)={metsToAdd.compartments};
metsToAdd.compartments=temp;
else
EM='metsToAdd.compartments must be a cell array of strings';
dispEM(EM);
end
else
metsToAdd.compartments=convertCharArray(metsToAdd.compartments);
end

%Number of metabolites
Expand Down Expand Up @@ -193,14 +179,11 @@
end

if isfield(metsToAdd,'inchis')
metsToAdd.inchis=convertCharArray(metsToAdd.inchis);
if numel(metsToAdd.inchis)~=nMets
EM='metsToAdd.inchis must have the same number of elements as metsToAdd.mets';
dispEM(EM);
end
if ~iscellstr(metsToAdd.inchis)
EM='metsToAdd.inchis must be a cell array of strings';
dispEM(EM);
end
%Add empty field if it doesn't exist
if ~isfield(newModel,'inchis')
newModel.inchis=largeFiller;
Expand All @@ -214,14 +197,11 @@
end

if isfield(metsToAdd,'metFormulas')
metsToAdd.metFormulas=convertCharArray(metsToAdd.metFormulas);
if numel(metsToAdd.metFormulas)~=nMets
EM='metsToAdd.metFormulas must have the same number of elements as metsToAdd.mets';
dispEM(EM);
end
if ~iscellstr(metsToAdd.metFormulas)
EM='metsToAdd.metFormulas must be a cell array of strings';
dispEM(EM);
end
%Add empty field if it doesn't exist
if ~isfield(newModel,'metFormulas')
newModel.metFormulas=largeFiller;
Expand All @@ -243,6 +223,9 @@
EM='metsToAdd.metCharges must be of type "double"';
dispEM(EM);
end
if ~isfield(newModel,'metCharges')
newModel.metCharges=NaN(numel(largeFiller),1);
end
newModel.metCharges=[newModel.metCharges;metsToAdd.metCharges(:)];
else
%Add default
Expand All @@ -252,19 +235,16 @@
end

if isfield(metsToAdd,'metNotes')
metsToAdd.metNotes=convertCharArray(metsToAdd.metNotes);
if numel(metsToAdd.metNotes)~=nMets
EM='metsToAdd.metNotes must have the same number of elements as metsToAdd.mets';
dispEM(EM);
end
if ~iscellstr(metsToAdd.metNotes)
EM='metsToAdd.metNotes must be a cell array of strings';
dispEM(EM);
end
%Add empty field if it doesn't exist
if ~isfield(newModel,'metNotes')
newModel.metNotes=largeFiller;
end
newModel.metNotes=[newModel.inchis;metsToAdd.metNotes(:)];
newModel.metNotes=[newModel.metNotes;metsToAdd.metNotes(:)];
else
%Add empty strings if structure is in model
if isfield(newModel,'metNotes')
Expand Down Expand Up @@ -326,16 +306,3 @@
end
end
end

%For getting the numerical form of metabolite ids on the form "m1".
function I=getInteger(s)
%Checks if a string is on the form "m1" and if so returns the value of the
%integer
I=0;
if strcmpi(s(1),'m')
t=str2double(s(2:end));
if ~isnan(t) && ~isempty(t)
I=t;
end
end
end
Loading

0 comments on commit fbbdba1

Please sign in to comment.