Example that shows how to call an external program for validation.
using System.Collections.Generic;
internal class CallExternalValidator
{
public static int Main(string[] args)
{
if (args.Length < 3)
{
Console.WriteLine("Usage: callExternalValidator filename externalValidator [ tempSBMLFile outputFile [ ADDITIONAL-ARGS] ]");
return 1;
}
string filename = args[0];
string externalValidator = args[1];
string tempSBMLFileName = filename + "_temp.xml";
if (args.Length > 2)
tempSBMLFileName = args[2];
string outputFile = filename + "_out.xml";
if (args.Length > 3)
outputFile = args[3];
List<string> additionalArgs = new List<string>();
for (int i = 4; i < args.Length; i++)
additionalArgs.Add(args[i]);
additionalArgs.Add(outputFile);
SBMLDocument document = libsbml.readSBML(filename);
SBMLExternalValidator validator = new SBMLExternalValidator();
validator.setProgram(externalValidator);
validator.setSBMLFileName(tempSBMLFileName);
validator.setOutputFileName(outputFile);
foreach (string item in additionalArgs)
{
validator.addArgument(item);
}
document.setApplicableValidators(0);
document.addValidator(validator);
int numErrors = (int)document.checkConsistency();
document.printErrors();
return numErrors;
}
}