segrelab / cometspy

Python interface for running COMETS simulations and analyzing the results
GNU General Public License v3.0
11 stars 9 forks source link

error when following case study: Studying the evolution citrate utilization in the Long Term Evolution Experiment. #11

Closed beacamara closed 3 years ago

beacamara commented 3 years ago

Hello again! I am following the examples in the documentation in order to get used of comets. In the case study of "Studying the evolution citrate utilization in the Long Term Evolution Experiment", an error came up when running comets in the second phase of the experiment (marked in bold in the code below)

At roughly Generation 31,000 we introduce the CitT genotype and run for around 2000 Generations

batch_test.layout.models[0].initial_pop = [0, 0, float(batch_test.total_biomass.Ancestor.tail(1))] batch_test.layout.models[1].initial_pop = [0, 0, 3.9e-11] _batch_test.layout.build_initial_pop() # not present in the current version of comets batch_test.parameters.set_param('maxCycles', int(300*cycles_per_day)) batch_test.run()

Here is the error that I obtain. I do not understand from where it comes from, as when I run the code manually I can not see an error. The build_initial_pop() is not present in the current version of comets. I do not know if this can be the reason of the error. Or something related to the local configuration of my computer as it occurred in past issues or maybe something I did wrong or I didn't do. Could you help me to figure out what is happening?

Thank you so much

Beatriz Traceback (most recent call last): File "", line 1, in File "/usr/local/lib/python3.8/dist-packages/cometspy/comets.py", line 361, in run self.layout.write_necessary_files(self.working_dir, to_append) File "/usr/local/lib/python3.8/dist-packages/cometspy/layout.py", line 633, in write_necessary_files self.__check_if_initial_pops_in_range() File "/usr/local/lib/python3.8/dist-packages/cometspy/layout.py", line 1418, in __check_if_initial_pops_in_range for founder in m.initial_pop: TypeError: 'int' object is not subscriptable

djbajic commented 3 years ago

Hola Bea,

I apologize for this. We have made some changes to cometspy lately to fix some bugs that we were catching and make some improvements. I think you have an outdated version. You should just upgrade your cometspy, using pip install cometspy --upgrade. Please let me know if it still doesn't work.

Oh, and also, the function build_initial_pop is outdated, just use update_models() instead.

Thanks for your testing and input and please don't hesitate to post any issue also in the future.

beacamara commented 3 years ago

Hello again, I have update cometspy, and now my script is not working anymore. I think the new version has something that modify the c.model function. Below you will find the error message related to line 115 of model.py

model_modifications(glu1, ac1, o21, glu2, ac2, o22) File "/media/Backup/disk1/bcamara/portatil_acer/CNB_globachem/software/FLYCOP/FLYCOP-master/Scripts/ecoliLongTermFLYCOP.py", line 29, in model_modifications model1=c.model('/media/Backup/disk1/bcamara/portatil_acer/CNB_globachem/software/FLYCOP/FLYCOP-master/test/iJO1366.cmd') File "/home/bcamara/.local/lib/python3.8/site-packages/cometspy/model.py", line 115, in init self.read_comets_model(model, randomtag) TypeError: read_comets_model() takes 2 positional arguments but 3 were given

beacamara commented 3 years ago

Hello, I have modified the code of my script in order to read the model using cobrapy and then cometspy. However, another error came up, related to the function of c.layout(file)

layout=c.layout(file) File "/home/bcamara/.local/lib/python3.8/site-packages/cometspy/layout.py", line 132, in init self.read_comets_layout(input_obj) File "/home/bcamara/.local/lib/python3.8/site-packages/cometspy/layout.py", line 408, in read_comets_layout curr_model = model(model_path) File "/home/bcamara/.local/lib/python3.8/site-packages/cometspy/model.py", line 115, in init self.read_comets_model(model, randomtag) TypeError: read_comets_model() takes 2 positional arguments but 3 were given

Enclosed you will finde a screenshot of the layout file. As you can see the models are in .cmd format. And when cometspy internally try to read this models with the c.model() function, an error comes up, but this error does not appear when the model is first read using cobrapy.

Captura de pantalla de 2021-07-01 11-37-21

Here you will find the different examples I have tried to come to this conclusion

test_model = cobra.test.create_test_model('textbook') test_model = c.model(test_model)

model_ecoli_cometspy_read = c.model('/home/bcamara/iJO1366.cmd') Traceback (most recent call last): File "", line 1, in File "/home/bcamara/.local/lib/python3.8/site-packages/cometspy/model.py", line 115, in init self.read_comets_model(model, randomtag) TypeError: read_comets_model() takes 2 positional arguments but 3 were given model_ecoli = cobra.io.read_sbml_model('/media/Backup/disk1/bcamara/portatil_acer/CNB_globachem/software/FLYCOP/FLYCOP-master/test/iJO1366.xml') model_ecoli_cometspy = c.model(model_ecoli) model1=c.model('/media/Backup/disk1/bcamara/portatil_acer/CNB_globachem/software/FLYCOP/FLYCOP-master/test/iJO1366.cmd') Traceback (most recent call last): File "", line 1, in File "/home/bcamara/.local/lib/python3.8/site-packages/cometspy/model.py", line 115, in init self.read_comets_model(model, randomtag) TypeError: read_comets_model() takes 2 positional arguments but 3 were given

djbajic commented 3 years ago

That is a bug arising from the last update. I fixed it now, please upgrade your package again and you should be ready to go.

beacamara commented 3 years ago

Thank you djbajic for you quick answer. However, the error still arises when I execute my script. It is also related to line 115 of layout.py. Enclosed you will find a screenshot of the error.

It seems that the function self.read_comets_model(model, randomtag) of layout.py has only two arguments but it is receiving three.

/home/bcamara/.local/lib/python3.8/site-packages/cometspy/model.py Captura de pantalla de 2021-07-02 09-28-16

djbajic commented 3 years ago

I don't understand at this point what is going on. That should be fixed, and indeed it works on my side when I test it, e.g. ltrying to load a comets layout file.

The function read_comets_model currently takes two arguments, model and randomtag. You shouldn't care about the latter at this point, it is passed by default with a False value.

Actually, the function does admit three arguments, because the python statement :

self.read_comets_model(model)

is python's "syntactic sugar", and is interpreted behind the scenes as:

model.read_comets_model(self, model, randomtag=False)

So the message is puzzling. Did you correctly update and reload the cometspy library in your script? If the answer is yes, could you provide me with a minimal example code reproducing the error?

beacamara commented 3 years ago

I do not understand also what is happening. Because before the last update, the script was working perfectly, and then after the update the script crashes. Following your suggestions, I have uninstall and reinstall cometspy. And then I have tryied to read a model in .cmd format using the c.model function. Also, I have tried to read a simple layout file and it does not work.

Captura de pantalla de 2021-07-05 08-54-16 Captura de pantalla de 2021-07-05 08-31-55

djbajic commented 3 years ago

I am really puzzled, because with cometspy 0.4.13, I am able to run your code without errors.

Could you please show me the output of c.model.read_comets_model

beacamara commented 3 years ago

Me too. I also do not understand what is going on. Here is the output of the c.model.read_comets_model. I hope it helps. I have tried to read one of your models from the comets_protocol folder but it also fails. I am going to test the code in other computers to discard that it is something from my computer. I will let you know.

Captura de pantalla de 2021-07-06 09-17-23

beacamara commented 3 years ago

Hello djbajic, I have finally found out what was going on. The problem was related to the cometspy version that my system was executing. I updated the last version of cometspy in the system, but python was using a local version of python which had a version of cometspy 0.4.12 and for that reason the error was still there. My apologies for any inconvenience caused. Thank you for you time and patience

djbajic commented 3 years ago

Great, glad we managed to solve it!