Skip to content

Commit

Permalink
commscores community updates
Browse files Browse the repository at this point in the history
  • Loading branch information
freiburgermsu committed Dec 7, 2023
1 parent 249af79 commit 2d81a53
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
7 changes: 4 additions & 3 deletions modelseedpy/community/commhelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,10 @@ def build_from_species_models(org_models, model_id=None, name=None, abundances=N
if index == "": rxn.id += str(model_index)
else: rxn.id = rxn_id + str(model_index)
finalID = str(rxn.id)
string_diff = set(initialID).symmetric_difference(set(finalID))
if string_diff and not all(FBAHelper.isnumber(x) for x in string_diff):
print(f"The ID {initialID} is changed with {string_diff} to create the final ID {finalID}")
string_diff = ""
for index, let in enumerate(finalID):
if index >= len(initialID) or index < len(initialID) and let != initialID[index]: string_diff += let
if string_diff != f"_{compartment}{model_index}": print(f"The ID {initialID} is changed with {string_diff} to create the final ID {finalID}")
new_reactions.add(rxn)
# else:
# # TODO develop a method for compartmentalizing models without editing all reaction IDs or assuming their syntax
Expand Down
9 changes: 5 additions & 4 deletions modelseedpy/community/mscommunity.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
from modelseedpy.core.fbahelper import FBAHelper
#from modelseedpy.fbapkg.gapfillingpkg import default_blacklist
from modelseedpy.core.msatpcorrection import MSATPCorrection
from cobra import Reaction
from cobra.io import save_matlab_model, write_sbml_model
from cobra.core.dictlist import DictList
from cobra.io import save_matlab_model
from optlang.symbolics import Zero
from optlang import Constraint
from pandas import DataFrame
from pprint import pprint
from cobra import Reaction
import logging

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -97,13 +97,14 @@ def __init__(self, model=None, member_models: list = None, ids=None, abundances=
self.pkgmgr = MSPackageManager.get_pkg_mgr(self.util.model)
msid_cobraid_hash = self.util.msid_hash()
# print(msid_cobraid_hash)
write_sbml_model(model, "test_comm.xml")

# TODO this logic needs to be updated to accommodate non-MS models

if "cpd11416" not in msid_cobraid_hash: raise KeyError("Could not find biomass compound for the model.")
other_biomass_cpds = []
for self.biomass_cpd in msid_cobraid_hash["cpd11416"]:
if "c" in self.biomass_cpd.compartment:
if "c0" in self.biomass_cpd.id:
for rxn in self.util.model.reactions:
if self.biomass_cpd not in rxn.metabolites: continue
print(self.biomass_cpd, rxn, end=";\t")
Expand All @@ -114,7 +115,7 @@ def __init__(self, model=None, member_models: list = None, ids=None, abundances=
if printing: print('primary biomass defined', rxn.id)
self.primary_biomass = rxn
elif rxn.metabolites[self.biomass_cpd] < 0 and len(rxn.metabolites) == 1: self.biomass_drain = rxn
elif 'c' in self.biomass_cpd.compartment: # TODO expand to capture nonMS models
elif 'c' in self.biomass_cpd.compartment:
other_biomass_cpds.append(self.biomass_cpd)
# assign community members and their abundances
abundances = abundances or [1/len(other_biomass_cpds)]*len(other_biomass_cpds)
Expand Down

0 comments on commit 2d81a53

Please sign in to comment.