micom icon indicating copy to clipboard operation
micom copied to clipboard

Error while copying model using model.copy()

Open cdiener opened this issue 2 years ago • 2 comments

Discussed in https://github.com/micom-dev/micom/discussions/69

Originally posted by anubhavdas0907 March 8, 2022 Hello Christian,

I was trying to copy a community model to a different variable, but I get an error. I want to manipulate a model, without changing the original one.

Following are the details.

from micom import load_pickle
model = load_pickle("ERR1883210.pickle")
model_1 = model.copy()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/data/Conda_base/envs/MyConda/lib/python3.7/site-packages/cobra/core/model.py", line 321, in copy
    new = self.__class__()
TypeError: __init__() missing 1 required positional argument: 'taxonomy'

Can you please suggest, what's wrong in this code, and what can be the solution?

Regards Anubhav

cdiener avatar Mar 16 '22 18:03 cdiener

Sorry about that I haven't overwritten the copy function yet. For now you can just read the model again and that should have the same effect, like:

from micom import load_pickle
model = load_pickle("ERR1883210.pickle")
model_1 = load_pickle("ERR1883210.pickle")  # that's basically a copy

cdiener avatar Mar 16 '22 18:03 cdiener

Hello Christian,

Thanks for suggesting that solution. I will try that.

Regards Anubhav

anubhavdas0907 avatar Mar 21 '22 12:03 anubhavdas0907