@@ -326,7 +326,11 @@ def sbml_readSBML2FBA(
326326 F = csio .StringIO ()
327327 model_id = M .getId ()
328328 model_name = M .getName ()
329- model_description = libsbml .XMLNode_convertXMLNodeToString (M .getNotes ())
329+ if libsbml .getLibSBMLVersion () >= 51903 :
330+ node_txt = libsbml .XMLNode .convertXMLNodeToString (M .getNotes ())
331+ else :
332+ node_txt = libsbml .XMLNode_convertXMLNodeToString (M .getNotes ())
333+ model_description = node_txt
330334 model_description = xml_stripTags (model_description ).strip ()
331335
332336 # print(model_description)
@@ -384,7 +388,10 @@ def sbml_readSBML2FBA(
384388 chemFormula = CF ,
385389 )
386390 # process notes field, get rid of <head>, <body> elements
387- specNotes = libsbml .XMLNode_convertXMLNodeToString (SBSp .getNotes ())
391+ if libsbml .getLibSBMLVersion () >= 51903 :
392+ specNotes = libsbml .XMLNode .convertXMLNodeToString (SBSp .getNotes ())
393+ else :
394+ specNotes = libsbml .XMLNode_convertXMLNodeToString (SBSp .getNotes ())
388395 S .annotation = sbml_readCOBRANote (specNotes )
389396
390397 # Note: chemFormula works will have to see about charge GETFROMNAME!!!
@@ -456,8 +463,11 @@ def sbml_readSBML2FBA(
456463 del reagents
457464 if EXREAC :
458465 R .is_exchange = True
459- # R.setAnnotation('note', libsbml.XMLNode_convertXMLNodeToString(SBRe.getNotes()))
460- reacNotes = libsbml .XMLNode_convertXMLNodeToString (SBRe .getNotes ())
466+
467+ if libsbml .getLibSBMLVersion () >= 51903 :
468+ reacNotes = libsbml .XMLNode .convertXMLNodeToString (SBRe .getNotes ())
469+ else :
470+ reacNotes = libsbml .XMLNode_convertXMLNodeToString (SBRe .getNotes ())
461471 R .annotation = sbml_readCOBRANote (reacNotes )
462472 manot = sbml_getCVterms (SBRe , model = False )
463473 if manot != None :
@@ -472,7 +482,7 @@ def sbml_readSBML2FBA(
472482 if __HAVE_FBA_ANOT__ :
473483 # root = ELTree.ElementTree(file=os.path.join(work_dir, _TEMP_XML_FILE_))
474484 root = ELTree .ElementTree (file = F )
475- root_i = root .getiterator ()
485+ root_i = root .iter ()
476486 for ri in root_i :
477487 if (
478488 ri .tag
@@ -481,7 +491,7 @@ def sbml_readSBML2FBA(
481491 if __DEBUG__ :
482492 print (ri .tag )
483493 rootfba = ELTree .ElementTree (ri )
484- root_fba_i = rootfba .getiterator ()
494+ root_fba_i = rootfba .iter ()
485495 constraints = []
486496 for ret in root_fba_i :
487497 if (
@@ -491,8 +501,7 @@ def sbml_readSBML2FBA(
491501 ):
492502 if __DEBUG__ :
493503 print (ret .tag )
494- chld = ret .getchildren ()
495- for c in chld :
504+ for c in list (ret ):
496505 if __DEBUG__ :
497506 print ('\t {}' .format (c .tag ))
498507 attrib = c .attrib
@@ -524,7 +533,7 @@ def sbml_readSBML2FBA(
524533 activeId = ret .attrib [
525534 '{http://www.sbml.org/sbml/level3/version1/fba/version1}activeObjective'
526535 ]
527- for obj in ret . getchildren ( ):
536+ for obj in list ( ret ):
528537 ## print obj.attrib
529538 if (
530539 '{http://www.sbml.org/sbml/level3/version1/fba/version1}type'
@@ -538,17 +547,17 @@ def sbml_readSBML2FBA(
538547 ## raw_input(ftype)
539548 sid = obj .attrib ['id' ]
540549 # multiobj = []
541- for c_ in obj . getchildren ( ):
550+ for c_ in list ( obj ):
542551 fo = []
543- for cc_ in c_ . getchildren ( ):
552+ for cc_ in list ( c_ ):
544553 fo .append (cc_ .attrib )
545554 multiobj .append (fo )
546555
547556 if __DEBUG__ :
548557 print (objfunc_data )
549558 obj_ = multiobj [- 1 ]
550559 for flobj_ in obj_ :
551- for a in flobj_ :
560+ for a in tuple ( flobj_ ) :
552561 flobj_ .update (
553562 {
554563 a .replace (
@@ -1186,7 +1195,10 @@ def sbml_getNotes(obj):
11861195 """
11871196 notes = ''
11881197 try :
1189- notes = libsbml .XMLNode_convertXMLNodeToString (obj .getNotes ())
1198+ if libsbml .getLibSBMLVersion () >= 51903 :
1199+ notes = libsbml .XMLNode .convertXMLNodeToString (obj .getNotes ())
1200+ else :
1201+ notes = libsbml .XMLNode_convertXMLNodeToString (obj .getNotes ())
11901202 if notes != '' and notes is not None :
11911203 # too aggressive but efficient behaviour removed
11921204 # notes = xml_stripTags(notes).strip()
@@ -3763,9 +3775,11 @@ def __init__(self, pid):
37633775 if LOADANNOT :
37643776 S .annotation = sbml_readKeyValueDataAnnotation (SBSp .getAnnotationString ())
37653777 if S .annotation == {}:
3766- S .annotation = sbml_readCOBRANote (
3767- libsbml .XMLNode_convertXMLNodeToString (SBSp .getNotes ())
3768- )
3778+ if libsbml .getLibSBMLVersion () >= 51903 :
3779+ node_txt = libsbml .XMLNode .convertXMLNodeToString (SBSp .getNotes ())
3780+ else :
3781+ node_txt = libsbml .XMLNode_convertXMLNodeToString (SBSp .getNotes ())
3782+ S .annotation = sbml_readCOBRANote (node_txt )
37693783 # SBSp.unsetNotes()
37703784 manot = sbml_getCVterms (SBSp , model = False )
37713785 if manot != None :
@@ -4016,10 +4030,12 @@ def __init__(self, pid):
40164030 if LOADANNOT :
40174031 R .annotation = sbml_readKeyValueDataAnnotation (SBRe .getAnnotationString ())
40184032 # only dig for ancient annotation if not using V2
4033+ if libsbml .getLibSBMLVersion () >= 51903 :
4034+ node_txt = libsbml .XMLNode .convertXMLNodeToString (SBRe .getNotes ())
4035+ else :
4036+ node_txt = libsbml .XMLNode_convertXMLNodeToString (SBRe .getNotes ())
40194037 if FBCver < 2 and R .annotation == {}:
4020- R .annotation = sbml_readCOBRANote (
4021- libsbml .XMLNode_convertXMLNodeToString (SBRe .getNotes ())
4022- )
4038+ R .annotation = sbml_readCOBRANote (node_txt )
40234039 manot = sbml_getCVterms (SBRe , model = False )
40244040 if manot != None :
40254041 R .miriam = manot
0 commit comments