SystemsBioinformatics / cbmpy

CBMPy is a Python based platform for constraint based modelling and analysis.
https://systemsbioinformatics.github.io/cbmpy/
GNU General Public License v3.0
19 stars 6 forks source link

When reactions are deleted they are still part of groups and their IDs are still associated with genes. #22

Open willigott opened 4 years ago

willigott commented 4 years ago

When I do

import cbmpy as cbm

mod = cbm.CBRead.readSBML3FBC('e_coli_core.xml.gz')

print(mod.getAllProteinGeneAssociations()['G_b4395'])

mod.deleteReactionAndBounds('R_PGM')

print(mod.getAllProteinGeneAssociations()['G_b4395'])

cbm.CBWrite.writeSBML3FBCV2(mod, 'ecoli_mod.xml')

mod2 = cbm.CBRead.readSBML3FBC('ecoli_mod.xml')

the following will be printed:

['R_PGM']
Deleting reaction R_PGM and 2 associated bounds
['R_PGM']
...
Skipping group "g6" member "R_PGM", it is an incompatible type.

There are two issues with it, I think:

When a reaction is deleted, I would expect it to be also removed from all groups it is member of (now the ID will still be exported causing the "Skipping group..." part) and getAllProteinGeneAssociations() should then return an empty list for the associated gene (now it still returns the ID of the deleted reaction).

I guess both things are unintended behavior?!

bgoli commented 4 years ago

Thanks, this is a know issue (see #21 ) I'm currently working on replacing them with lists of weak_refs which avoid circular references and at least throw exceptions when they dangle ... but also have their own issues.