parameter units FBA model for valid SBML

10 views
Skip to first unread message

Michiel Karrenbelt

unread,
Nov 8, 2018, 11:37:01 AM11/8/18
to sbml-interoperability
when I read in the E. coli genome scale (iJO1366) or core model, parse the parameters, and then try to write it back, I obtain the following error when checking sbml validity: 

 The units 'mmol_per_gDW_per_hr' of the <parameter> with id 'R_ATPM_lower_bound' do not refer to a valid unit kind/built-in unit or the identifier of an existing <unitDefinition>. 

whereas this was already in the model. When I check the original model that I parsed and tried to rewrite it's considered valid though. This leads me to suspect I probably need to indicate that this is either a FBC model, or a FBC parameter, but I haven't quite figured out how. Can someone shed some light on this?

Andreas Dräger

unread,
Nov 8, 2018, 2:27:57 PM11/8/18
to sbml-inter...@googlegroups.com
Dear Michiel,

Could you please provide a little more information what "read in… and then try to write it back" means? Which SBML library (libSBML/JSBML), which programing language or environment? How do you obtain this message, i.e., which function did you call to obtain the message?

With best regards

Dr. Andreas Draeger
Assistant Professor
---
University of Tübingen
Center for Bioinformatics Tübingen (ZBIT)
Computational Systems Biology of Infection and Antimicrobial-Resistant Pathogens
Sand 14 · Office #C320 · 72076 Tübingen · Germany
Phone: +49-7071-29-70459 · Fax: +49-7071-29-5152
Web: http://draeger-lab.org · Twitter: @dr_drae
YouTube: https://www.youtube.com/c/systemsbiology

Michiel Karrenbelt

unread,
Nov 8, 2018, 5:32:50 PM11/8/18
to sbml-interoperability
Certainly, excuse moi

I am using libSBML. I read it in as such:

SBML_PARAMETER_ATTR = ['getId','getName','getConstant','getAnnotationString',
                       'getSBOTermID','getValue','getUnits']

def get_parameters(model):
    
    parameter_ids = [p.getId() for p in model.getListOfParameters()]
    parameters = dict.fromkeys(parameter_ids)
    
    for p in model.getListOfParameters():
        d = dict.fromkeys(settings.SBML_PARAMETER_ATTR)
        for attr in settings.SBML_PARAMETER_ATTR:
            d[attr] = getattr(p, attr, lambda: None)()
        parameters[p.getId()] = d
    
    return parameters


and read back as:

def write_sbml(d, outfile=None):
    
    inv_map = {v:k for k,v in settings.SBML_MAPPING.items()}
    for k, v in d.items():
        df = pd.DataFrame(v)
        df.rename(index=inv_map, inplace=True)
        d[k] = df

    for _, p in d.parameters.items():
        k = model.createParameter()
        k.setId(p.getId)
        k.setName(p.getName)
        k.setConstant(p.getConstant)        
        k.setValue(p.getValue) 
        k.setUnits(p.getUnits)  

there's more code to it, but that does not yield any error when writing the SBML. I have a script that validates the file, but using the online validator (http://sbml.org/Facilities/Validator/) yields the same error. I'm using python 3.6.6, libsbml 5.17.0


On Thursday, 8 November 2018 20:27:57 UTC+1, Andreas Dräger wrote:
> Am 08.11.2018 um 17:30 schrieb Michiel Karrenbelt <m.a.p.ka...@gmail.com>:
>
> when I read in the E. coli genome scale (iJO1366) or core model, parse the parameters, and then try to write it back, I obtain the following error when checking sbml validity:
>
>  The units 'mmol_per_gDW_per_hr' of the <parameter> with id 'R_ATPM_lower_bound' do not refer to a valid unit kind/built-in unit or the identifier of an existing <unitDefinition>.
>
> whereas this was already in the model. When I check the original model that I parsed and tried to rewrite it's considered valid though. This leads me to suspect I probably need to indicate that this is either a FBC model, or a FBC parameter, but I haven't quite figured out how. Can someone shed some light on this?


Dear Michiel,

Could you please provide a little more information what "read in… and then try to write it back" means? Which SBML library (libSBML/JSBML), which programming language or environment? How do you obtain this message, i.e., which function did you call to obtain the message?

Frank T. Bergmann

unread,
Nov 9, 2018, 1:41:18 AM11/9/18
to sbml-interoperability
Hello Michiel, 

The error indicates, that while you have correctly copied the parameters, the new model is missing a unit definition for 'mmol_per_gDW_per_hr'. you simply need to create that unit definition  and that error will go away. 

best
Frank

Reply all
Reply to author
Forward
0 new messages