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 in comets.py: self.total_biomass = self.total_biomass.astype('float') #10

Closed beacamara closed 3 years ago

beacamara commented 3 years ago

Hi again!

I am trying to run a script which is using the module of cometspy. Enclosed you will find the screenshot of the error. The script starts running comets, but in the line 411 of the script comets.py produces an error as it can not convert string to floats. Am I doing somethig wrong? Thank you so much

Beatriz

This is the line 411: self.total_biomass = self.total_biomass.astype('float')

This is the error: ValueError: could not convert string to float: '1,0890912788E-2' '1,0890912788E-2' is the first value of self.total_biomass

cycle ecoli_1_tmp ecoli_2_tmp 0 0 1E-2 1E-2 1 1 1,0890912788E-2 1,0890912788E-2 2 2 1,1861198135E-2 1,1861198135E-2 3 3 1,2917927444E-2 1,2917927444E-2 4 4 1,4068802119E-2 1,4068802119E-2 .. ... ... ... 236 236 4,0924751615E-1 4,0924751615E-1 237 237 4,0883826864E-1 4,0883826864E-1 238 238 4,0842943037E-1 4,0842943037E-1 239 239 4,0802100094E-1 4,0802100094E-1 240 240 4,0761297994E-1 4,0761297994E-1

Captura de pantalla de 2021-05-27 14-05-05

jeremymchacon commented 3 years ago

You are not doing anything wrong--this is due to certain operating systems and locations causing decimals to be separated using a comma instead of a decimal.

We have made a change that hopefully works, which is available on pypi. Let us know if upgrading the package doesn't work.

Thanks again for helping us find these bugs!

beacamara commented 3 years ago

Thank you so much for your quick answer.

I think something similar may be hapenning to comets.media. I am still having problems with my script when I try to plot data obtained from comets.media and comets.total_biomass.

This is comets.total_biomass after doing some modifications in column names and adding two columns of the comets.media related to glc__D_e and ac_e

comets.total_biomass time(h) Ecoli1 Ecoli2 glc__D_e ac_e 0 0 0.010000 0.010000 1E1 6,321686072E-3 1 1 0.010891 0.010891 9,98E0 0 2 2 0.011861 0.011861 9,9582181744E0 1,320657924E-2 3 3 0.012918 0.012918 9,9344957782E0 2,0704856344E-2 4 4 0.014069 0.014069 9,9086599233E0 2,8871164545E-2 .. ... ... ... ... ... 236 236 0.409248 0.409248 0 0 237 237 0.408838 0.408838 0 0 238 238 0.408429 0.408429 0 0 239 239 0.408021 0.408021 0 0 240 240 0.407613 0.407613 0 0

When I want to plot the evolution of [glc__D_e] in time with this function:

l3,=ax2.plot(df2['time(h)']*0.1, df2[str(met)], label=str(met), color='b')

met = glc__D_e

This error is appears: TypeError: 'value' must be an instance of str or bytes, not a int. But I do not where it comes from. The only strange thing is that df2[str(met)] is a dtype: object, and is using also comas (',') instead of points ('.').

This is df2['time(h)']*0.1: 1 0.1 2 0.2 3 0.3 4 0.4 ... 236 23.6 237 23.7 238 23.8 239 23.9 240 24.0 Name: time(h), Length: 241, dtype: float64

and this is df2[str(met)]: 0 1E1 1 9,98E0 2 9,9582181744E0 3 9,9344957782E0 4 9,9086599233E0 ...
236 0 237 0 238 0 239 0 240 0 Name: glc__D_e, Length: 241, dtype: object

jeremymchacon commented 3 years ago

I think you are correct. We used a different file reading format for media and didn't expect it to be similarly affected, my apologies! Please let us know if the new version still gives you trouble. And again we appreciate you raising the issues!

beacamara commented 3 years ago

Thank you so much. The new version is working perfectly. I have not found other errors.

jeremymchacon commented 3 years ago

Great, thanks again @beacamara !

wupeng1998 commented 2 years ago

Hello, please ask the simulation to run case Growth in a test tube error--keyerror image

wupeng1998 commented 2 years ago

i think the method of cometspy.comets() have something wrong ?

jeremymchacon commented 1 year ago

Hi wupeng, this is an issue we've struggled with--sometimes users' environments don't access environmental variables "outside" of their local environment.

An easy fix, however, is to set the environmental variable COMETS_HOME in python, using the os package:

import os os.environ['COMETS_HOME'] = 'home/username/comets'

The path on the right side of that assignment will be specific to your machine, and specifies where COMETS is.

Hope this helps,

Jeremy

On Wed, Apr 20, 2022 at 9:36 PM wupeng1998 @.***> wrote:

i think the method of cometspy.comets() have something wrong ?

— Reply to this email directly, view it on GitHub https://github.com/segrelab/cometspy/issues/10#issuecomment-1104645946, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABLGCRJXTVATO7RK4V626PDVGC5JZANCNFSM45UEMFHQ . You are receiving this because you modified the open/close state.Message ID: @.***>

--

Jeremy M. Chacón, Ph.D.

he / him / his

Research Associate, Harcombe Lab University of Minnesota Ecology, Evolution and Behavior