Fxe / cobrakbase

KBase Interface for COBRApy
MIT License
2 stars 4 forks source link

original Media object wont load without object_type string #16

Closed samseaver closed 11 months ago

samseaver commented 11 months ago

This simple script wouldn't work for me:

#!/usr/bin/env python
import cobrakbase
kbase = cobrakbase.KBaseAPI()
ws = "KBaseMedia"
media = kbase.get_from_ws('Carbon-D-Glucose', ws)

I figured out somehow that the Media object in cobrakbase/core/kbasebiochem/media.py is not passing the object_type field, while the one in cobrakbase/core/kbasebiochemmedia.py does, and if I use the latter, it doesn't fail, but I'm unsure if this is the right object to use for ModelSEEDPy

samseaver commented 11 months ago

I was testing in ModelSEEDPy and so by implementing these changes it seems to work with model.medium=<media object> but it's not fully tested...

Fxe commented 11 months ago

The example code snippet you gave works just fine for me. Also tested on another model and medium assignment works:

import cobrakbase
kbase = cobrakbase.KBaseAPI()
model = kbase.get_from_ws('GCF_000005845.2.RAST.mdl', 151186)
media = kbase.get_from_ws('Carbon-D-Glucose', 151186)
model.medium = media

The corrected type for KBase media should be cobrakbase.core.kbasebiochem.media.Media I have old types when I wasn't following the KBase datatype "path"

Fxe commented 11 months ago

Oh, I think you are using the wrong branch... https://github.com/Fxe/cobrakbase/tree/cobra-model ! this is the corrected branch, sorry for the confusion. Will fix this mess since it is not obvious for other folks.

samseaver commented 11 months ago

I was using the cobra-model branch, but I see you've updated it so I'll do a pull and test