Skip to content

Commit

Permalink
Fixing error with bio reaction, fixing check for compounds in templat…
Browse files Browse the repository at this point in the history
…e, setting failure testing to false, and fixing report
  • Loading branch information
Christopher Henry committed Nov 5, 2024
1 parent 0e84a2b commit 78fda49
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
4 changes: 3 additions & 1 deletion modelseedpy/core/msbuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
)
from cobra.core import Gene, Metabolite, Model, Reaction, Group
from modelseedpy.core import FBAHelper
from modelseedpy.core.msmodel import MSModel
from modelseedpy.fbapkg.mspackagemanager import MSPackageManager
from modelseedpy.biochem.modelseed_biochem import ModelSEEDBiochem
from modelseedpy.biochem.modelseed_to_cobra import modelseed_to_cobra_reaction
Expand Down Expand Up @@ -1078,7 +1079,8 @@ def build_full_template_model(template, model_id=None, index="0"):
bio.build_biomass(
model, index, classic=False, GC=0.5, add_to_model=True
)
model.objective = "bio1"
if "bio1" in model.reactions:
model.objective = "bio1"

reactions_sinks = []
for cpd_id in ["cpd02701_c0", "cpd11416_c0", "cpd15302_c0", "cpd03091_c0"]:
Expand Down
6 changes: 3 additions & 3 deletions modelseedpy/core/msmodelreport.py
Original file line number Diff line number Diff line change
Expand Up @@ -610,13 +610,13 @@ def build_report(self, output_path):
with open(output_path, "w", encoding="utf-8") as f:
f.write('<meta charset="UTF-8">')
f.write("<h1>Model Summary</h1>")
f.write(model_summary_df_styled.render(escape=False))
f.write(model_summary_df_styled.to_html(escape=False))
f.write("<br><br>")
f.write("<h1>Gapfillings Analysis</h1>")

# Check for Gapfillings Analysis data
if not gapfillings_analysis_df.empty:
f.write(gapfillings_analysis_df_styled.render(escape=False))
f.write(gapfillings_analysis_df_styled.to_html(escape=False))
f.write(f"<br><br><h3>Legend:</h3>{annotations_text_gapfillings}")
else:
f.write(
Expand All @@ -627,7 +627,7 @@ def build_report(self, output_path):

# Check for ATP Analysis data
if not atp_analysis_df.empty:
f.write(atp_analysis_df_styled.render(escape=False))
f.write(atp_analysis_df_styled.to_html(escape=False))
f.write(f"<br><br><h3>Legend:</h3>{annotations_text_atp_analysis}")
f.write(explanation_text_atp_analysis)
else:
Expand Down
2 changes: 1 addition & 1 deletion modelseedpy/core/msmodelutl.py
Original file line number Diff line number Diff line change
Expand Up @@ -1375,7 +1375,7 @@ def apply_test_condition(self, condition, model=None):
# model.objective.direction = "min"
pkgmgr.getpkg("KBaseMediaPkg").build_package(condition["media"])

def test_single_condition(self, condition, apply_condition=True, model=None,report_atp_loop_reactions=False,analyze_failures=True,rxn_list=[]):
def test_single_condition(self, condition, apply_condition=True, model=None,report_atp_loop_reactions=False,analyze_failures=False,rxn_list=[]):
"""Runs a single test condition to determine if objective value on set media exceeds threshold
Parameters
Expand Down
4 changes: 4 additions & 0 deletions modelseedpy/core/mstemplate.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,10 @@ def to_metabolite(self, index="0", force=False):

cpd_id = f"{self.id}{index}"
compartment = f"{self.compartment}{index}"
if self.compound == None:
logger.critical(
f"Compound objective associated with [{cpd_id}] is missing from template"
)
name = f"{self.compound.name} [{compartment}]"
metabolite = Metabolite(cpd_id, self.formula, name, self.charge, compartment)
metabolite.notes["modelseed_template_id"] = self.id
Expand Down

0 comments on commit 78fda49

Please sign in to comment.