public static void Main(String[] args) { if (!SBMLExtensionRegistry.isPackageEnabled("comp")) { Console.WriteLine("This copy of libSBML does not contain the 'comp' extension"); Console.WriteLine("Unable to proceed with the resolver example the model."); Environment.Exit(2); } // create custom resolver CustomResolver resolver = new CustomResolver(); // add the resolver and store its index, so we can free it later. int index = SBMLResolverRegistry.getInstance().addResolver(resolver); // create a new document with comp enabled SBMLDocument doc = new SBMLDocument(new CompPkgNamespaces()); // get a hold of a plugin object CompSBMLDocumentPlugin plugin = (CompSBMLDocumentPlugin)doc.getPlugin("comp"); // create an external model definition ExternalModelDefinition external = plugin.createExternalModelDefinition(); // set the source to the URI external.setSource("http://www.ebi.ac.uk/biomodels-main/download?mid=BMID000000063853"); // resolve the model Model model = external.getReferencedModel(); if (model == null) { Console.Error.WriteLine("couldn't resolve"); Environment.Exit(2); } // model is ready to be used now, however, only as long and the document // holding the external model definition is still alive and referenced Console.WriteLine("Model id: " + model.getId()); Console.WriteLine("# species: " + model.getNumSpecies()); Console.WriteLine("# reactions: " + model.getNumReactions()); // now that we are done get rid of the resolver SBMLResolverRegistry.getInstance().removeResolver(index); // also clear the resolver instance, just to be sure that it has // no more references to the C# resolver SBMLResolverRegistry.deleteResolerRegistryInstance(); // finally we can get rid of the C# resolver resolver = null; }
public static int Main(string[] args) { Console.Write("This version of LibSBML: " + libsbml.getLibSBMLDottedVersion() + " includes: " + Environment.NewLine); for (int i = 0; i < SBMLExtensionRegistry.getNumRegisteredPackages(); i++) { Console.Write("\t" + SBMLExtensionRegistry.getRegisteredPackageName(i) + Environment.NewLine); } Console.Write(Environment.NewLine); return(0); }
public static int Main(string[] args) { if (args.Length != 1) { Console.WriteLine(" Usage: printRenderInformation <input file> \n" + " prints a summary of the render information object."); return(1); } string inputFile = args[0]; SBMLDocument doc = libsbml.readSBMLFromFile(inputFile); Console.WriteLine("Using libSBML: {0} supporting packages for:", libsbml.getLibSBMLDottedVersion()); for (int i = 0; i < SBMLExtensionRegistry.getNumRegisteredPackages(); ++i) { Console.WriteLine("\t {0}", SBMLExtensionRegistry.getRegisteredPackageName(i)); } Console.WriteLine("\nThe document is: level {0}, version {1}", doc.getLevel(), doc.getVersion()); for (int i = 0; i < doc.getNumPlugins(); ++i) { Console.WriteLine(" doc uses package: {0}", doc.getPlugin(i).getElementNamespace()); } Console.WriteLine("\n"); long numErrors = doc.getNumErrors(libsbml.LIBSBML_SEV_ERROR); if (numErrors > 0) { Console.WriteLine("Encountered errors while reading the file. "); Console.WriteLine("Please correct the following errors and try again."); doc.printErrors(); return(2); } Model model = doc.getModel(); LayoutModelPlugin plugin = (LayoutModelPlugin)model.getPlugin("layout"); if (plugin == null || plugin.getNumLayouts() == 0) { Console.WriteLine("The loaded model contains no layout information, please add these first."); return(3); } RenderListOfLayoutsPlugin lolPlugin = (RenderListOfLayoutsPlugin)plugin.getListOfLayouts().getPlugin("render"); if (lolPlugin != null && lolPlugin.getNumGlobalRenderInformationObjects() > 0) { Console.WriteLine("The loaded model contains global Render information: "); for (int i = 0; i < lolPlugin.getNumGlobalRenderInformationObjects(); ++i) { GlobalRenderInformation info = lolPlugin.getRenderInformation(i); print_render_info(info); } } Layout layout = plugin.getLayout(0); RenderLayoutPlugin rPlugin = (RenderLayoutPlugin)layout.getPlugin("render"); if (rPlugin != null && rPlugin.getNumLocalRenderInformationObjects() > 0) { Console.WriteLine("The loaded model contains local Render information. "); // here we would do the same as above for the local render information ... for (int i = 0; i < rPlugin.getNumLocalRenderInformationObjects(); ++i) { LocalRenderInformation info = rPlugin.getRenderInformation(i); print_render_info(info); } } return(0); }