Skip to content
Open

Develop #2606

Show file tree
Hide file tree
Changes from all commits
Commits
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
28 changes: 14 additions & 14 deletions documentation/source/guides/howToContribute.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ This guide explains, step by step, how to contribute code to the COBRA Toolbox:
how to fork the repository, work on your changes locally, place your code in the
correct folder inside ``src``, add tests, and open a pull request (PR).

1. Overview of the contribution workflow
Overview of the contribution workflow
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The typical workflow for contributing is:
Expand All @@ -21,7 +21,7 @@ The typical workflow for contributing is:

The following sections describe each step in more detail.

2. Fork the COBRA Toolbox repository
1. Fork the COBRA Toolbox repository
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

1. Go to the main COBRA Toolbox repository on GitHub:
Expand All @@ -36,7 +36,7 @@ The following sections describe each step in more detail.

All your changes will be pushed to this fork.

3. Clone your fork locally
2. Clone your fork locally
~~~~~~~~~~~~~~~~~~~~~~~~~~

To work on the code, clone your fork to your local machine.
Expand All @@ -56,7 +56,7 @@ To work on the code, clone your fork to your local machine.
git remote add upstream https://github.com/opencobra/cobratoolbox.git
git fetch upstream

4. Add your code to the correct folder in ``src``
3. Add your code to the correct folder in ``src``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

All new COBRA Toolbox code should be added under the ``src`` folder. The main
Expand All @@ -75,7 +75,7 @@ easier for others to navigate the code.

Below is guidance on when to use each folder.

**4.1. src/analysis**
**3.1. src/analysis**

Use ``analysis`` for methods that analyse existing metabolic models. Examples:

Expand All @@ -86,7 +86,7 @@ Use ``analysis`` for methods that analyse existing metabolic models. Examples:
Suggested structure:
``src/analysis/myNewAnalysisTool/``

**4.2. src/base**
**3.2. src/base**

Use ``base`` for shared utilities and core methods needed across the toolbox.
Examples include:
Expand All @@ -98,7 +98,7 @@ Examples include:
Suggested structure:
``src/base/myUtilityFunctions/``

**4.3. src/dataIntegration**
**3.3. src/dataIntegration**

Use ``dataIntegration`` for code that integrates omics or experimental data with
a model. Examples:
Expand All @@ -110,7 +110,7 @@ a model. Examples:
Suggested structure:
``src/dataIntegration/myIntegrationPipeline/``

**4.4. src/design**
**3.4. src/design**

Use ``design`` for algorithms that propose modifications or interventions.
Examples:
Expand All @@ -122,7 +122,7 @@ Examples:
Suggested structure:
``src/design/myDesignAlgorithm/``

**4.5. src/reconstruction**
**3.5. src/reconstruction**

Use ``reconstruction`` for tools that construct, curate or update metabolic
models. Examples:
Expand All @@ -134,7 +134,7 @@ models. Examples:
Suggested structure:
``src/reconstruction/myReconstructionPipeline/``

**4.6. src/visualization**
**3.6. src/visualization**

Use ``visualization`` for tools that generate plots, diagrams or graphical
summaries. Examples:
Expand All @@ -146,7 +146,7 @@ summaries. Examples:
Suggested structure:
``src/visualization/myVisualisationTools/``

5. Add a test for every new code module
4. Add a test for every new code module
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Every contribution must include a corresponding **test**. This ensures that new
Expand All @@ -162,7 +162,7 @@ For more information on writing tests, refer to:

* :ref:`testGuide`

6. Commit and push your changes
5. Commit and push your changes
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Once your code and tests are ready, commit your work.
Expand Down Expand Up @@ -192,7 +192,7 @@ Once your code and tests are ready, commit your work.

git push origin develop

7. Open a pull request
6. Open a pull request
~~~~~~~~~~~~~~~~~~~~~~

Once your changes are pushed, open a pull request on GitHub.
Expand All @@ -218,7 +218,7 @@ Once your changes are pushed, open a pull request on GitHub.

5. Submit the pull request.

8. Address review comments
7. Address review comments
~~~~~~~~~~~~~~~~~~~~~~~~~~

Maintainers may request revisions. This is normal.
Expand Down
103 changes: 0 additions & 103 deletions documentation/source/notes/COBRAModelFields.md

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,7 @@
matStart=0;
cnt=1;
for i = 1:length(presBac)
% find the indices of where there merged matrices are on the C
% matrix
% find the indices of where there merged matrices are on the C matrix
matInd1=[];
for j=1:size(couplingMatrixRed{i,1},1)
matInd1(size(matInd1,1)+1,1)=j+matStart;
Expand All @@ -99,7 +98,27 @@
pruned_model.ctrs{cnt,1}=couplingMatrixRed{i,4}{j,1};
cnt=cnt+1;
end
matInd2=find(strncmp(pruned_model.rxns,[presBac{i,1} '_'],length(presBac{i,1})+1));%finding indixes of specific reactions
thisBac = presBac{i,1};
rxns = pruned_model.rxns;

% start with all reactions for this bacterium prefix
mask = strncmp(rxns, [thisBac '_'], length(thisBac)+1);

% Find "child" bacteria whose names extend this one
allBacs = presBac(:,1);
childMask = strncmp(allBacs, [thisBac '_'], length(thisBac)+1);
childNames = allBacs(childMask);

% exclude reactions belonging to any child bacterium
for c = 1:numel(childNames)
child = childNames{c};
maskChild = strncmp(rxns, [child '_'], length(child)+1);
mask = mask & ~maskChild;
end

% final indices
matInd2 = find(mask);
pruned_model.rxns(matInd2)
% merge the C matrix
pruned_model.C(matInd1,matInd2) = couplingMatrixRed{i,1};

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
function interrogateWBmodelsQP(directory,resPath, solver, param)
% Performs FBA on a all whole-body models in a folder with the quadratic flux minimisation
% algorithm (QP) and saves the QP FBA results in a separate results folder.
%
% USAGE:
% interrogateWBmodelsQP(directory,resPath,solver)
%
%
% INPUTS
% directory [char] Path to folder with WBMs
% resPath [char] Path to location of FBA results
% solver [char] Solver name, e.g., gurobi.
%
% OPTIONAL INPUTS:
% param [struct] FBA parameters. See OptimizeWBModel.m or
% OptimizeCbModel.m for more information. All FBA parameters are set to
% their defaults except for param.minNorm (1e-6) and secondsTimeLimit (500
% seconds instead of 100 seconds)
%
% AUTHOR:
% - Tim Hensen, January 2026.


if nargin<4
% Set FBA parameters
param.minNorm = 1e-6;
param.secondsTimeLimit = 500;
end

% Set QP solver
changeCobraSolver(solver,'QP',-1)

% Get model names
modelNames = what(directory).mat;
modelPaths = fullfile(directory,modelNames);

% Create output folder if not present already
if ~isfolder(resPath)
mkdir(resPath)
end

% Remove already analysed models
prevSol = what(resPath);
if ~isempty(prevSol)
prevSol = prevSol.mat;
[~,idx] = setdiff(modelNames,prevSol);
modelPaths = modelPaths(idx);
end

for i=1:numel(modelPaths)

% load model
disp(append('load and interrogate model : ', modelNames{i}))
model = loadPSCMfile(modelPaths{i});

% Set objective at Whole_body_objective_rxn
model = changeObjective(model, 'Whole_body_objective_rxn');

% Fix objective flux bounds at one
model = changeRxnBounds(model,'Whole_body_objective_rxn',1,'b');

% Minimise the Euclidean norm of all reactions for a fixed objective
model.osenseStr = 'min';

tic
% Perform FBA
FBA = optimizeWBModel(model, param);
toc

% Append metabolites and reactions
FBA.rxns = model.rxns;
FBA.mets = model.mets;

% Save results
filePath=fullfile(resPath, append('qpFBA_',modelNames{i}));
solution = FBA;
save(filePath,'-struct', 'solution')
end

end
Loading