Skip to content

Commit

Permalink
Updating specs to include expression inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
cshenry committed Mar 28, 2024
1 parent 6571b80 commit 1edadfe
Show file tree
Hide file tree
Showing 5 changed files with 122 additions and 7 deletions.
37 changes: 32 additions & 5 deletions lib/ModelSEEDReconstruction/modelseedrecon.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,10 @@ def build_metabolic_models(self,params):
"base_media":None,
"compound_list":None,
"base_media_target_element":"C",
"expression_refs":None
"expression_refs":None,
"extend_model_with_ontology":False,
"ontology_events":None,
"save_models_to_kbase":True,
})
if params["change_to_complete"]:
default_media = "KBaseMedia/Complete"
Expand Down Expand Up @@ -138,14 +141,16 @@ def build_metabolic_models(self,params):
#Building model
base_model = FBAModel({'id':gid+params["suffix"], 'name':genome.scientific_name})
builder = MSBuilder(genome, self.gs_template)
mdl = builder.build(base_model, '0', False, False)
mdl = builder.build(base_model, '0', False, False)
mdl.genome = genome
mdl.template = self.gs_template
mdl.core_template_ref = str(self.core_template.info)
mdl.genome_ref = self.wsinfo_to_ref(genome.annoont.info)
mdl.template_ref = str(self.gs_template.info)
current_output["Core GF"] = "NA"
mdlutl = MSModelUtil.get(mdl)
if params["extend_model_with_ontology"]:
self.extend_model_with_other_ontologies(mdlutl,genome.anno_ont,builder,prioritized_event_list=params["ontology_events"])
genome_objs = {mdlutl:genome}
expression_objs = None
if params["expression_refs"]:
Expand Down Expand Up @@ -176,10 +181,12 @@ def build_metabolic_models(self,params):
"gapfilling_mode":params["gapfilling_mode"],
"base_media":params["base_media"],
"compound_list":params["compound_list"],
"base_media_target_element":params["base_media_target_element"]
"base_media_target_element":params["base_media_target_element"],
"save_models_to_kbase":params["save_models_to_kbase"]
})
else:
self.save_model(mdlutl,params["workspace"],None)
if params["save_models_to_kbase"]:
self.save_model(mdlutl,params["workspace"],None)
mdlutl.model.objective = "bio1"
mdlutl.pkgmgr.getpkg("KBaseMediaPkg").build_package(None)
current_output["Growth"] = "Complete:"+str(mdlutl.model.slim_optimize())
Expand Down Expand Up @@ -240,6 +247,8 @@ def gapfill_metabolic_models(self,params):
"base_media":None,
"compound_list":None,
"base_media_target_element":"C",
"save_models_to_kbase":True,
"save_gapfilling_fba_to_kbase":True
})
base_comments = []
if params["change_to_complete"]:
Expand Down Expand Up @@ -338,15 +347,33 @@ def gapfill_metabolic_models(self,params):
run_sensitivity_analysis=True,
integrate_solutions=True
)
output_solution = None
output_solution_media = None
for media in params["media_objs"]:
if media.id in solutions and "growth" in solutions[media]:
growth_array.append(media.id+":"+str(solutions[media]["growth"]))
if solutions[media]["growth"] > 0 and output_solution == None:
mdlutl.pkgmgr.getpkg("KBaseMediaPkg").build_package(media)
output_solution = mdlutl.model.optimize()
output_solution_media = media
solution_rxn_types = ["new","reversed"]
if output_solution and output_solution_media in solutions:
gfsolution = solutions[output_solution_media]
for rxn_type in solution_rxn_types:
for rxn_id in gfsolution[rxn_type]:
if gfsolution[rxn_type] == ">":
output_solution.fluxes[rxn_id] = 1000
else:
output_solution.fluxes[rxn_id] = -1000
current_output["Growth"] = "<br>".join(growth_array)
current_output["GS GF"] = len(mdlutl.gfutl.cumulative_gapfilling)
current_output["Reactions"] = mdlutl.nonexchange_reaction_count()
current_output["Model genes"] = len(mdlutl.model.genes)
#Saving completely gapfilled model
self.save_model(mdlutl,params["workspace"],None,params["suffix"])
if params["save_models_to_kbase"]:
self.save_model(mdlutl,params["workspace"],None,params["suffix"])
if params["save_gapfilling_fba_to_kbase"] and output_solution:
self.save_solution_as_fba(output_solution,mdlutl,output_solution_media,workspace=params["workspace"],suffix=".gffba")
if not params["internal_call"]:
result_table = result_table.append(current_output, ignore_index = True)
output = {}
Expand Down
12 changes: 12 additions & 0 deletions ui/narrative/methods/build_metabolic_models/display.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,18 @@ parameters :
short-hint : |
Specifies the gapfilling approach: cumulative means building up a solution as each new condition is gapfilled; independent means keeping every solution independent; global means gapfilling all conditions at once.
expression_refs :
ui-name : |
Expression datasets
short-hint : |
Feature value matrices to be used in OMEGGA method to aid in selecting gene candidates for gapfilled reactions
expression_conditions :
ui-name : |
Expression conditions
short-hint : |
Optional list of columns within the expression dataset to use with OMEGGA method. If no conditions are specified within an expression dataset, all the columnns will be used.
icon: modelseed-teal.png

description : |
Expand Down
34 changes: 33 additions & 1 deletion ui/narrative/methods/build_metabolic_models/spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,33 @@
"allow_multiple": false,
"optional": false,
"advanced": true
}
},{
"text_options" : {
"valid_ws_types" : [
"KBaseFeatureValues.ExpressionMatrix"
]
},
"default_values" : [
""
],
"id" : "expression_refs",
"advanced" : true,
"allow_multiple" : true,
"optional" : true,
"field_type" : "text"
},{
"default_values" : [
""
],
"advanced" : true,
"id" : "expression_conditions",
"field_type" : "text",
"allow_multiple" : true,
"optional" : true,
"text_options" : {
"valid_ws_types" : []
}
}
],
"behavior": {
"service-mapping": {
Expand Down Expand Up @@ -470,6 +496,12 @@
},{
"target_property": "forced_atp_list",
"input_parameter": "forced_atp_list"
},{
"target_property": "expression_refs",
"input_parameter": "expression_refs"
},{
"target_property": "expression_conditions",
"input_parameter": "expression_conditions"
},{
"target_property": "gs_template",
"input_parameter": "gs_template"
Expand Down
12 changes: 12 additions & 0 deletions ui/narrative/methods/gapfill_metabolic_models/display.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,18 @@ parameters :
short-hint : |
Specifies the gapfilling approach: cumulative means building up a solution as each new condition is gapfilled; independent means keeping every solution independent; global means gapfilling all conditions at once.
expression_refs :
ui-name : |
Expression datasets
short-hint : |
Feature value matrices to be used in OMEGGA method to aid in selecting gene candidates for gapfilled reactions
expression_conditions :
ui-name : |
Expression conditions
short-hint : |
Optional list of columns within the expression dataset to use with OMEGGA method. If no conditions are specified within an expression dataset, all the columnns will be used.
icon: modelseed-teal.png

description : |
Expand Down
34 changes: 33 additions & 1 deletion ui/narrative/methods/gapfill_metabolic_models/spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,33 @@
"allow_multiple": false,
"optional": false,
"advanced": true
}
},{
"text_options" : {
"valid_ws_types" : [
"KBaseFeatureValues.ExpressionMatrix"
]
},
"default_values" : [
""
],
"id" : "expression_refs",
"advanced" : true,
"allow_multiple" : true,
"optional" : true,
"field_type" : "text"
},{
"default_values" : [
""
],
"advanced" : true,
"id" : "expression_conditions",
"field_type" : "text",
"allow_multiple" : true,
"optional" : true,
"text_options" : {
"valid_ws_types" : []
}
}
],
"behavior": {
"service-mapping": {
Expand Down Expand Up @@ -426,6 +452,12 @@
},{
"target_property": "minimum_objective",
"input_parameter": "minimum_objective"
},{
"target_property": "expression_refs",
"input_parameter": "expression_refs"
},{
"target_property": "expression_conditions",
"input_parameter": "expression_conditions"
},{
"target_property": "default_objective",
"input_parameter": "default_objective"
Expand Down

0 comments on commit 1edadfe

Please sign in to comment.