Location: cellLib @ 0f94d0bdf02a / Scripts / modelValidation.py

Author:
WeiweiAi <wai484@aucklanduni.ac.nz>
Date:
2022-05-16 13:04:54+12:00
Desc:
Add a merge script and update accordingly
Permanent Source URI:
https://models.physiomeproject.org/workspace/6bc/rawfile/0f94d0bdf02afd16ebe8651a92628c98334ddb1f/Scripts/modelValidation.py

import libcellml

def modelValidation(cellmlfile,mPath):
   #Parse a CellML file into a model m
   p=libcellml.Parser()
   with open(cellmlfile) as f:
       contents=f.read()
       m=p.parseModel(contents)
   
   print('The component count is: ', m.componentCount())
   print('The model has imports? ',m.hasImports())  
   # Create an Importer to resolve and flatten the model
   i=libcellml.Importer()
   result=i.resolveImports(m,mPath)
   print('Resolving result:',result)   
   print('The issue count: ',i.issueCount())
   for index in range(i.issueCount()):
       print(i.issue(index).description())
   
   # Create a validator instance v and pass the model to it
   v=libcellml.Validator()
   # Validate the model m
   v.validateModel(m)
   # Retrieve the error information
   print('The error count is: ',v.errorCount())
   for index in range(v.errorCount()):
       print(v.error(index).description())
   
   print('The issue count is: ',v.issueCount())
   for index in range(v.issueCount()):
       print(v.issue(index).description())
   
   print('The warning count is: ',v.warningCount())
   for index in range(v.warningCount()):
       print(v.warning(index).description())
   
   print('The hint count is: ',v.hintCount())
   for index in range(v.warningCount()):
       print(v.hint(index).description())
   
   print('The message count is: ',v.messageCount())
   for index in range(v.warningCount()):
       print(v.message(index).description())
   
   f.close()
   return