Skip to content

Commit

Permalink
Human 1.6
Browse files Browse the repository at this point in the history
  • Loading branch information
haowang-bioinfo committed Jan 25, 2021
2 parents 4f1e9d5 + 670c298 commit 31d5173
Show file tree
Hide file tree
Showing 19 changed files with 26,694 additions and 289,958 deletions.
42 changes: 15 additions & 27 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ If you want to contribute to the model with some additions or improvements, plea

Here's how to set up Human-GEM for local development to contribute smaller features or changes that you can implement yourself:

1. First of all, make sure that you have all [requirements](https://github.com/SysBioChalmers/Human-GEM#required-software) for contributing to Human-GEM. Note that COBRA and RAVEN should be cloned in your computer and not just downloaded.
1. Make sure that you have all [requirements](https://github.com/SysBioChalmers/Human-GEM#required-software) for contributing to Human-GEM. Note that COBRA and RAVEN should be cloned to your computer and not just downloaded.

2. Fork the Human-GEM repository on GitHub (go to https://github.com/SysBioChalmers/Human-GEM & click on the upper right corner).

Expand All @@ -41,7 +41,7 @@ Here's how to set up Human-GEM for local development to contribute smaller featu
git clone https://github.com/<your Github name>/Human-GEM.git
```
4. Check out the branch that you want to contribute to. Most likely that will be ``devel``:
4. Check out the branch that you want to contribute to. Most likely that will be `devel`:
```
git checkout devel
```
Expand All @@ -55,8 +55,7 @@ Here's how to set up Human-GEM for local development to contribute smaller featu
* If your changes are minor (e.g. a single chemical formula you wish to correct), you can do it directly from the command line.
* If your changes are not so small and require several steps, create a script that loads the model, reads data (if applicable), changes the model accordingly, and saves the model back.
* Each script should start with a commented section describing the script, explaining the parameters, and indicating your name and the date it was written. Existing functions can clarify what style should be used.
* If you add new metabolites and/or reactions to the model, please use . If you add a new gene, please use .
* Store scripts in the appropriate folder in `/ComplementaryScripts` and data (as `.tsv` files) in the appropriate folder in `/ComplementaryData`. If you think no folder is adequate for your script/data, feel free to create your own folder. Note that binary data such as `.mat` structures or `.xls` tables cannot be stored in the repo (as they cannot be version-controlled, and they increment too much the size of the repo).
* Store scripts in the appropriate folder in `/code` and data (as `.tsv` files) in the appropriate folder in `/data`. If you think no folder is adequate for your script/data, feel free to create your own folder. Note that binary data such as `.mat` structures or `.xls` tables cannot be stored in the repo (as they cannot be version-controlled, and they increment too much the size of the repo).
* When you are done making changes, review locally your changes with `git diff` or any git client, to make sure you are modifying the model as you intended.
7. Commit your changes and push your branch to GitHub.
Expand All @@ -65,29 +64,27 @@ Here's how to set up Human-GEM for local development to contribute smaller featu
git commit -m "Title of your commit"
git push origin name-of-your-branch
```
[See below](#semantic-commits) for recommendations on how to name your commits. In case of larger updates, you can of course make several commits on a single contribution. However, if you need to do too many commits, consider if your contribution could be instead split into separate branches (making it easier for reviewing later).
[See below](#semantic-commits) for recommendations on how to name your commits. In case of larger updates, you can of course make several commits on a single contribution. However, if you need to make many commits, consider if your contribution could be instead split into separate branches (making it easier for reviewing later).
8. Submit a pull request through the GitHub website (https://help.github.com/articles/creating-a-pull-request-from-a-fork/) to the `devel` branch of the original SysBioChalmers repo (not your fork). We recommend ticking the box "Allow edits from maintainers" if you wish for us to be able to contribute directly to your branch (speeding-up the reviewing process).
8. Submit a pull request through the GitHub website (https://help.github.com/articles/creating-a-pull-request-from-a-fork/) to the `devel` branch of the original SysBioChalmers repo (not to your fork). We recommend ticking the box "Allow edits from maintainers" if you wish for us to be able to contribute directly to your branch (speeding-up the reviewing process).
Finally, and for larger features that you want to work on collaboratively, you may consider to first request to join our development team to get write access to the repository so that you can create a branch directly in the main repository (or simply ask the administrator to create a branch for you). Once you have a new branch, you can push your changes directly to the main repository and when finished, submit a pull request from that branch to ``devel``. [See below](#development-team-guidelines) for more details.
Finally, and for larger features that you want to work on collaboratively, you may consider to first request to join our development team to get write access to the repository so that you can create a branch directly in the main repository (or simply ask the administrator to create a branch for you). Once you have a new branch, you can push your changes directly to the main repository and when finished, submit a pull request from that branch to `devel`. [See below](#development-team-guidelines) for more details.
Thank you very much for contributing to Human-GEM!
#### Branching model
* `devel`: Is the branch all pull-requests should be based on.
* `devel`: Is the branch to which all pull requests should be made.
* `master`: Is only touched by the administrator and is the branch with the tested & reviewed model that is released or ready for the next release.
* `master`: Is only modified by the administrator and is the branch with the tested & reviewed model that is released or ready for the next release.
* `{chore, doc, feat, fix, refactor, style}/descriptive-name`: Any other branch created in the model. If you work on a fix, start the branch name with `fix/`, if you work on a feature, start the branch name with `feat/`. Examples: `fix/format_reactions` or `feat/new_algorithms`. [See below](#semantic-commits) for more details on the possible actions you can use.
#### Semantic commits
Please use concise descriptive commit messages. Ideally, use semantic commit messages to make it easier to show what you are aiming to do:
`action-object: brief description`
* `action` = {`feat`, `fix`, `refactor`, `style`, `doc`, `chore`, `test`}
* `object` (optional field) = {`rxn`, `rxn.annot`, `rxn.prop`, `met`, `met.annot`, `met.prop`, `gene`, `gene.annot`, `comp`, `comp.annot`, `data`}
`action: brief description`
`action` refers to what exactly are you doing in the commit, following a [standard definition](http://karma-runner.github.io/2.0/dev/git-commit-msg.html) in software development:
* `chore`: updating toolbox, data files, etc.
Expand All @@ -97,25 +94,16 @@ Please use concise descriptive commit messages. Ideally, use semantic commit mes
* `refactor`: see [code refactoring](https://en.wikipedia.org/wiki/Code_refactoring).
* `style`: minor format changes of model, functions or data (spaces, semi-colons, etc., no code change).
`object` may or may not be used, and refers to the receiver of the action, i.e. what part of the model/data are you modifying:
* `object`: Used when adding/removing/modifying the whole object (`rxn`, `met`, `gene`, `comp` or `data`).
* `object.annot`: Annotation of the object (e.g. KEGG IDs, EC numbers, etc). Applies for `rxn`, `met`, `gene` or `comp`.
* `object.prop`: Any other property of the object (e.g. formulas, charge, stoich coeffs, LB, UB, etc). Applies for `rxn` or `met`.
Some examples:
|commit|commit message|
|:---:|:---:|
|Add new rxns|`feat-rxn: methanol pathway`|
|Remove a metabolite|`fix-met: duplicated citrate`|
|Add metabolite formula|`feat-met.prop: carbohydrate formulas`|
|Fix rxn stoichiometry|`fix-rxn.prop: complex V stoich coeffs`|
|Update gene IDs|`fix-gene.annot: update IDs from SWISSPROT`|
|Format name of compartment|`style-comp.annot: remove uppercases`|
|Split a rxn in 2|`refactor-rxn: split isomerase in 2 steps`|
|Add some data|`feat-data: metabolomics data`|
|Update documentation of function|`doc: addDBnewRxn.m`|
|Update toolbox|`chore: update RAVEN version`|
|Add new rxns|`feat: add methanol pathway`|
|Remove a metabolite|`fix: remove duplicated citrate`|
|Add metabolite formula|`feat: add carbohydrate formulas`|
|Format name of compartment|`style: convert to all lowercase`|
|Split a rxn in 2|`refactor: split isomerase in 2 steps`|
|Update documentation of function|`doc: addDBnewRxn.m update documentation`|
More examples [here](https://github.com/SysBioChalmers/Human-GEM/commits/master). A more detailed explanation or comments is encouraged to be left in the commit description.
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/yaml-validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ jobs:
with:
python-version: '3.x'

- name: Install GLPK, dependecy for swiglpk
run: sudo apt-get install glpk-utils libglpk-dev

- name: Test import with cobrapy and consistency with annotation files
run: |
pip install -U pip
pip install cobra
python code/test/sanityCheck.py
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Human-GEM: The generic genome-scale metabolic model of _Homo sapiens_

[![Join the chat at https://gitter.im/SysBioChalmers/Human-GEM](https://badges.gitter.im/SysBioChalmers/Human-GEM.svg)](https://gitter.im/SysBioChalmers/Human-GEM?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![GitHub version](https://badge.fury.io/gh/sysbiochalmers%2FHuman-GEM.svg)](https://badge.fury.io/gh/sysbiochalmers%2FHuman-GEM)
[![DOI](https://zenodo.org/badge/105752644.svg)](https://zenodo.org/badge/latestdoi/105752644)

### Brief Model Description

Expand Down Expand Up @@ -63,6 +64,11 @@ Detailed instructions on the installation and use of the Human-GEM model and rep
The model is available as `.xml`, `.xlsx`, `.txt`, `.yml`, and `.mat` in the `model/` directory. Note that only the `.yml` version is available on branches other than `master` (e.g., `devel`), to facilitate tracking of model changes.


## Reaction, Metabolite, and Gene Annotations

Additional annotation information and external identifiers for Human-GEM reactions, metabolites, and genes can be found in the respective `reactions.tsv`, `metabolites.tsv`, and `genes.tsv` files in the `model/` directory. To import/export this annotation data to/from MATLAB, use the `importTsvFile` and `exportTsvFile` functions, respectively.



## Usage

Expand Down
167 changes: 167 additions & 0 deletions code/addMetabolicNetwork.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
function [newModel, modelChanges] = addMetabolicNetwork(model,rxnsToAdd,metsToAdd)
%addMetabolicNetwork Integrate a new metabolic network into a model
%
% NOTE: The function is to incorporate a subnetwork that is provided by two
% arrays, rxnsToAdd and metsToAdd, which should be in defined
% structure as below,and with reactions and metabolites that are
% NOT included in the model
%
% Usage:
% [newModel, modelChanges] = addMetabolicNetwork(model,rxnsToAdd,metsToAdd)
%
%
% Inputs:
% model A model structure
%
% rxnsToAdd the reaction structure can have the following fields:
% rxns cell array with unique strings that
% identifies each reaction
% equations cell array with equation strings. Decimal
% coefficients are expressed as "1.2".
% Reversibility is indicated by "<=>" or "=>"
% The metabolites have to be written as
% "metNames[comps]". Only compartments in
% model.comps are allowed. New metabolites to
% the model should be added to metsToAdd array
% rxnNames cell array with the names of each reaction
% (opt, default '')
% lb vector with the lower bounds (opt, default
% to model.annotations.defaultLB or -inf for
% reversible reactions and 0 for irreversible
% when "equations" is used. When "mets" and
% "stoichCoeffs" are used it defaults for all
% reactions to model.annotations.defaultLB or
% -inf)
% ub vector with the upper bounds (opt, default
% to model.annotations.defaultUB or inf)
% eccodes cell array with the EC-numbers for each
% reactions. Delimit several EC-numbers with
% ";" (opt, default '')
% subSystems cell array with the subsystems for each
% reaction (opt, default '')
% grRules cell array with the gene-reaction
% relationship for each reaction. For example
% "(A and B) or (C)" means that the reaction
% could be catalyzed by a complex between
% A & B or by C on its own. All the genes
% have to be present in model.genes. Add
% genes with addGenesRaven before calling
% this function if needed (opt, default '')
% rxnReferences cell array with reaction references (opt,
% default '')
% rxnConfidenceScores vector with reaction confidence scores
% (opt, default NaN)
%
% metsToAdd the metabolite structure can have the following fields:
% mets cell array with unique strings that
% identifies each metabolite (opt, default IDs
% of new metabolites are numbered with the
% prefix defined below)
% metNames cell array with the names of each
% metabolite
% compartments cell array with the compartment of each
% metabolite. Should match model.comps.
% If this is a string rather than a cell
% array it is assumed that all mets are in
% that compartment
% inchis cell array with InChI strings for each
% metabolite (opt, default '')
% metFormulas cell array with the formulas for each of
% the metabolites (opt, default '')
% metCharges metabolite charge (opt, default NaN)
%
%
% Outputs:
% newModel a new model with the added reactons and metabolites
%
% modelChanges a cell structure containing the original and new reaction
% and/or metabolite properties. Reaction-related changes
% are reported in the modelChanges.rxns field, whereas
% metabolite-related changes are reported in the
% modelChanges.mets field
%

if nargin<2
error('Missing input!');
end

if nargin<3
metsToAdd = [];
end



%% Add new metabolites

if isempty(metsToAdd)
newModel = model;
else
% the following metabolite fields are required to be included
requiredMetFields = {'mets','metNames','metFormulas','metCharges','compartments'};
if ~all(ismember(requiredMetFields, fieldnames(metsToAdd)))
error('There is missing fields in the metabolite structure to be added.');
end

% verify that none of the metabolites exist in the current model
if any(ismember(metsToAdd.mets, model.mets))
error('One or more metabolite IDs to be added already exist in the model.');
end

% add metabolites to the model
newModel = addMets(model,metsToAdd);
end



%% Check new reactions

% the following reaction fields are required to be included
requiredRxnFields = {'rxns','equations','subSystems','grRules'};
if ~all(ismember(requiredRxnFields, fieldnames(rxnsToAdd)))
error('There is missing fields in the metabolite structure to be added.');
end

% verify that none of the reactions exist in the current model
if any(ismember(rxnsToAdd.rxns, model.rxns))
error('One or more reactions to be added already exist in the model.');
end

% make sure all equations have metabolites in a format of "metNames[comps]"
if ~all(contains(rxnsToAdd.equations, '[') & contains(rxnsToAdd.equations, ']'))
error('The metabolites in equations should be in a format of "metNames[comps]".');
end



%% Add new genes

% extract genes from grRules
newGenes = getGenesFromGrRules(rxnsToAdd.grRules);

% remove genes that are already existed in model
if any(ismember(newGenes, newModel.genes))
fprintf('One or more genes to be added already exist in the model,therefore they will be merged.\n');
newGenes = setdiff(newGenes, newModel.genes);
end

% append new genes to list of model genes
newModel.genes = [newModel.genes; newGenes];

% add new columns to rxnGeneMat will be updated after the new reactions are added below.
newModel.rxnGeneMat(:, end+1:end+numel(newGenes)) = 0;



%% Integrate new subnetwork to the model
newModel = addRxns(newModel, rxnsToAdd, 3);


% update genes and rxnGeneMat with new grRules
[newModel.genes, newModel.rxnGeneMat] = getGenesFromGrRules(newModel.grRules);



%% Document model changes
modelChanges = docModelChanges(model, newModel);


Loading

0 comments on commit 31d5173

Please sign in to comment.