Skip to content

Commit

Permalink
Merge pull request #4 from z-haiman/develop
Browse files Browse the repository at this point in the history
Develop 0.3.0
  • Loading branch information
z-haiman authored Jan 19, 2024
2 parents fb38c0d + 9d223e6 commit 3e3261a
Show file tree
Hide file tree
Showing 40 changed files with 45,615 additions and 35,239 deletions.
1,137 changes: 1,137 additions & 0 deletions .deprecated/code/curation/RBC-GEM_v0.2.0_v0.3.0.ipynb

Large diffs are not rendered by default.

472 changes: 226 additions & 246 deletions code/notebooks/annotation/AnnotateModel_RBC-GEM.ipynb

Large diffs are not rendered by default.

332 changes: 250 additions & 82 deletions code/notebooks/annotation/ExtractAnnotations_MIM.ipynb

Large diffs are not rendered by default.

311 changes: 169 additions & 142 deletions code/notebooks/annotation/ExtractAnnotations_MetAtlas.ipynb

Large diffs are not rendered by default.

569 changes: 294 additions & 275 deletions code/notebooks/annotation/ExtractAnnotations_RBC-GEM.ipynb

Large diffs are not rendered by default.

3,952 changes: 3,952 additions & 0 deletions code/notebooks/annotation/ExtractAnnotations_UniProt.ipynb

Large diffs are not rendered by default.

4,171 changes: 4,171 additions & 0 deletions code/notebooks/annotation/ReconcileAnnotations_RBC-GEM.ipynb

Large diffs are not rendered by default.

2,294 changes: 2,294 additions & 0 deletions code/notebooks/data/AggregateData_Proteomics.ipynb

Large diffs are not rendered by default.

2,033 changes: 2,033 additions & 0 deletions code/notebooks/data/EvidenceGenes_RBC-GEM.ipynb

Large diffs are not rendered by default.

1,604 changes: 1,604 additions & 0 deletions code/notebooks/data/IdentifierUpdates_Proteomics.ipynb

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions code/src/rbc_gem_utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
ANNOTATION_PATH,
INTERIM_PATH,
EXTERNAL_PATH,
CURATION_PATH,
GEM_NAME,
GEM_URL,
COBRA_CONFIGURATION,
build_string,
split_string,
Expand Down
46 changes: 45 additions & 1 deletion code/src/rbc_gem_utils/annotation.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,51 @@
import pandas as pd
from cobra import DictList
import logging
from rbc_gem_utils.util import ensure_iterable, build_string, check_if_valid

LOGGER = logging.getLogger(__name__)

def set_sbo_default_annotations(model, annotation_type, verbose=False):
"""Set default SBO annotations on the model."""
annotation_type = check_if_valid(annotation_type, ["reactions", "metabolites", "genes"], "Unrecognized annotations for Human-GEM")
for attr in annotation_type:
for model_object in getattr(model, attr):
if attr == "reactions":
if model_object.boundary and model_object in model.exchanges:
sbo_term = "SBO:0000627" # Exchange reaction
elif model_object.boundary and model_object in model.demands:
sbo_term = "SBO:0000628" # Demand reaction
elif model_object.boundary and model_object in model.sinks:
sbo_term = "SBO:0000632" # Sink reaction
elif len(model_object.compartments) > 1:
sbo_term = "SBO:0000185" # Transport reaction
else:
sbo_term = "SBO:0000176" # Biochemical reaction
elif attr == "metabolites":
sbo_term = "SBO:0000247" # Metabolite
elif attr == "genes":
sbo_term = "SBO:0000243" # Gene
else:
continue

try:
assert model_object.annotation["sbo"] == sbo_term
except KeyError:
msg = f"SBO term set for {model_object.id}"
LOGGER.info(msg)
if verbose:
print(msg)
model_object.annotation["sbo"] = sbo_term
except AssertionError:
msg = f"SBO term changed for {model_object.id}: {model_object.annotation['sbo']} --> {sbo_term}"
LOGGER.info(msg)
if verbose:
print(msg)
model_object.annotation["sbo"] = sbo_term

return model


from rbc_gem_utils.util import ensure_iterable, build_string

def get_id_annotation_mapping(objects, annotation_key, default=None):
"""Return a dictionary containing model identifiers mapped to annotation values.
Expand Down
7 changes: 2 additions & 5 deletions code/src/rbc_gem_utils/database/metatlas.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def get_annotations_HumanGEM(
return df_annotations


def download_database_HumanGEM(annotation_type=None, database_dirpath=None, model_filetype=None, model_version=None):
def download_database_HumanGEM(annotation_type=None, database_dirpath=None, model_filetype=None, model_version="xml"):
"""Download the HumanGEM database files. Requires internet connection.
Default values are used based on the RBC-GEM repository format.
Expand Down Expand Up @@ -140,10 +140,7 @@ def download_database_HumanGEM(annotation_type=None, database_dirpath=None, mode
else:
annotation_type = check_if_valid(annotation_type, valid, "Unrecognized annotations for Human-GEM")

if model_filetype is None:
model_filetype = ["xml"]
else:
model_filetype = check_if_valid(model_filetype, HUMANGEM_MODEL_FILETYPES, "Unrecognized filetypes for Human-GEM")
model_filetype = check_if_valid(model_filetype, HUMANGEM_MODEL_FILETYPES, "Unrecognized filetypes for Human-GEM")

if database_dirpath is not None:
# Ensure the path exists
Expand Down
3 changes: 3 additions & 0 deletions code/src/rbc_gem_utils/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,13 @@
PROCESSED_PATH = "/data/processed"
EXTERNAL_PATH = "/data/external"
ANNOTATION_PATH = "/data/annotation"
CURATION_PATH = "/data/curation"
DATABASE_PATH = f"{EXTERNAL_PATH}/database"


GEM_NAME = "RBC-GEM"
GEM_URL = f"{RAW_GH_URL}/z-haiman/{GEM_NAME}"
GEM_MODEL_FILETYPES = {'mat', 'json', 'xml', 'yml'}


def show_versions():
Expand Down
632 changes: 283 additions & 349 deletions data/annotation/genes_MIM.tsv

Large diffs are not rendered by default.

Loading

0 comments on commit 3e3261a

Please sign in to comment.