Location: cellLib @ 4ff19c3f257b / Scripts / modelValidation.py

Author:
WeiweiAi <wai484@aucklanduni.ac.nz>
Date:
2022-04-20 20:26:31+12:00
Desc:
Add concentration clamp; Check interface IO when mapping; Add init in the csv to allow building a model with init:
Permanent Source URI:
https://models.fieldml.org/workspace/6bc/rawfile/4ff19c3f257b33704e3c001e62550111f4ed828a/Scripts/modelValidation.py

import os
import libcellml
#Parse a CellML file into a model m
filename = 'path2thefile/Single_stim_experiment.cellml'
p=libcellml.Parser()
with open(filename) as f:
    contents=f.read()
    m=p.parseModel(contents)

print('The component count is:', m.componentCount())
print('The model has imports?',m.hasImports())
#print(m.componentCount())
# Create an Importer to resolve and flatten the model
i=libcellml.Importer()
result=i.resolveImports(m,'path2saveTheResult/')
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',v.issueCount())
for index in range(v.issueCount()):
    print(v.issue(index).description())

print('The warning count',v.warningCount())
for index in range(v.warningCount()):
    print(v.warning(index).description())

print('The hint count',v.hintCount())
for index in range(v.warningCount()):
    print(v.hint(index).description())

print('The message count',v.messageCount())
for index in range(v.warningCount()):
    print(v.message(index).description())

f.close()