Closed hebamuh68 closed 1 year ago
Hi, thank you for reporting the error. There was indeed a bug in the code. It is fixed now and a new version of mergem was pushed to pypi (0.21.5).
I tried your test with those two models from the CarveMe repo and it worked.
I had another question, my device crashed when I worked on 200 models at once, so I though to merge each 50 together then the 4 result files i'll merge to one..
I tested on smaller file 1_merge => 3 models 2_merge => 3 models and this was the result of merging (1_merge + 2_merge)
but when i merged the 6 models at once, I git this result, which the number of reactions is more than above
so I was wondering if there's any mistake in this techniqe about merging the outcome of the merge
Yes, the results can be different depending on the order of the merge. Notice that the output model always contains all the metabolites and reactions of the first model, and the rest are merged into this one as much as possible. This is important in the case of a model containing synonymous metabolites (such as NH2 and NH3). In this case, both metabolites will be preserved if that model is the first, but one of those metabolites will be lost if the first model does not contain both metabolites. These differences can result in different number of reactions.
If your computer cannot handle 200 models at once, you could try merging them one at a time in a for loop, starting with your best base model:
# A list with your 200 models
models = ["test/Abiotrophia_defectiva_ATCC_49176.xml", "test/Acidaminococcus_fermentans_DSM_20731.xml", ...]
merged_model = mergem.load_model(models[0])
for model_index in range(1, len(models)):
merged_model = mergem.merge([merged_model, models[model_index]], 1)
but isn't this in case i put the -obj as 1? am using => -obj merge,, which means will merge all which i want to get ?
That parameter only affects the objective function. What I wrote is true for all the metabolites, and hence reactions in the model. Either parameter would work, depending on what you want.
Hi, I'm trying to merge about 200 models into one
First I tried with only 2 and it raised this error:
merge_results = mergem.merge(["test/Abiotrophia_defectiva_ATCC_49176.xml","test/Acidaminococcus_fermentans_DSM_20731.xml"], 1)
IndexError Traceback (most recent call last) /tmp/ipykernel_20689/2630019269.py in
----> 1 merge_results = mergem.merge(["test/Abiotrophia_defectiva_ATCC_49176.xml", "test/Acidaminococcus_fermentans_DSM_20731.xml"], 1)
~/anaconda3/lib/python3.9/site-packages/mergem/__mergeModels.py in merge(input_models, set_objective) 54 merged_model_metabolites.append(metabolite) 55 old_met_id = metabolite.id ---> 56 new_met_id = map_metabolite_to_mergem_id(metabolite) 57 58 if (new_met_id is None) or (new_met_id in met_sources_dict):
~/anaconda3/lib/python3.9/site-packages/mergem/__mergeModels.py in map_metabolite_to_mergem_id(metabolite) 234 else: 235 split = metid.rsplit("", 1) --> 236 met_compartment = __modelHandling.map_localization(split[1]) 237 if met_compartment == '': 238 met_compartment = split[1]
IndexError: list index out of range
========================================== Some search said this error with the models itself, is there anway to fix this with all models?