public static void Main(String[] args)
    {
        if (args.Length == 0)
        {
            Console.WriteLine("Need one argument, copasi file");
            Environment.Exit(1);
        }

        CDataModel dataModel = CRootContainer.addDatamodel();

        if (!dataModel.loadModel(args[0]))
        {
            Console.WriteLine("Could not open file");
            Console.WriteLine(CCopasiMessage.getAllMessageText());
            Environment.Exit(1);
        }

        CModel model = dataModel.getModel();
        ModelParameterSetVectorN sets = model.getModelParameterSets();

        // if we don't have one, create one
        if (sets.size() == 0)
        {
            CModelParameterSet newSet = new CModelParameterSet("Current State", model);
            newSet.createFromModel();
            printParameterSet(newSet);
            sets.add(newSet);
        }

        // interrogate the exiting parameter sets
        printExistingParametersets(model.getModelParameterSets());
    }
    public static void Main(String[] args)
    {
        // create a new datamodel
        CDataModel dataModel = CRootContainer.addDatamodel();

        if (args.Length != 1)
        {
            Console.WriteLine("Need one argument: SBML | CPS filename.");
            Environment.Exit(1);
        }

        String filename = args[0];

        try
        {
            String ext = System.IO.Path.GetExtension(filename);
            if (ext.Trim().ToLowerInvariant().EndsWith("xml"))
            {
                // load the model without progress report
                dataModel.importSBML(filename);
            }
            else
            {
                // load the model without progress report
                dataModel.loadModel(filename);
            }
        }
        catch
        {
            Console.WriteLine("Error while loading the model from file named \"" + filename + "\".");
            Environment.Exit(1);
        }
        try
        {
            CModel model          = dataModel.getModel();
            int    numAnnotations = model.getNumUnsupportedAnnotations();
            Console.WriteLine("The model has: " + numAnnotations + " unsupported annotations.");

            if (numAnnotations == 0)
            {
                Console.WriteLine("adding custom annotation");
                // we don't have an annotation, so lets add one
                if (!model.addUnsupportedAnnotation("http://myannotation.org", "<test xmlns='http://myannotation.org' value='blaaaahaaa'/>"))
                {
                    Console.WriteLine("couldn't set annotation: ");
                    Console.WriteLine(CCopasiMessage.getAllMessageText());
                }
            }
            Console.WriteLine("The name of the first is: " + model.getUnsupportedAnnotationName(0));
            Console.WriteLine("The raw xml of the first is: " + model.getUnsupportedAnnotation(0));
        }
        catch (Exception ex)
        {
            Console.WriteLine("Error: " + ex.Message);
        }
    }
Exemplo n.º 3
0
    public static void Main(String[] args)
    {
        // create a new datamodel
        CDataModel dataModel = CRootContainer.addDatamodel();

        if (args.Length != 2)
        {
            Console.WriteLine("Need two arguments: filename and filter.");
            Environment.Exit(1);
        }

        String filename = args[0];

        try
        {
            String ext = System.IO.Path.GetExtension(filename);
            if (ext.Trim().ToLowerInvariant() == "xml")
            {
                // load the model without progress report
                dataModel.importSBML(filename);
            }
            else
            {
                // load the model without progress report
                dataModel.loadModel(filename);
            }
        }
        catch
        {
            Console.WriteLine("Error while loading the model from file named \"" + filename + "\".");
            Environment.Exit(1);
        }
        try
        {
            // clear warnings / error messages
            CCopasiMessage.clearDeque();

            // convert
            String translation = dataModel.exportMathModelToString(args[1]);

            // if conversion failed print message
            if (string.IsNullOrEmpty(translation))
            {
                Console.WriteLine("Translation failed: ");
                Console.WriteLine(CCopasiMessage.getAllMessageText());
            }

            // print translation
            Console.WriteLine(translation);
        }
        catch
        {
            Console.WriteLine("Error. Exporting the model to math failed.");
        }
    }
Exemplo n.º 4
0
    static void Main(string[] args)
    {
        Debug.Assert(CRootContainer.getRoot() != null);
        // create a new datamodel
        CDataModel dataModel = CRootContainer.addDatamodel();

        Debug.Assert(CRootContainer.getDatamodelList().size() == 1);
        // the only argument to the main routine should be the name of a CPS file
        if (args.Length == 1)
        {
            string filename = args[0];
            try
            {
                // load the model without progress report
                dataModel.loadModel(filename);
            }
            catch
            {
                System.Console.Error.WriteLine("Error while loading the model from file named \"" + filename + "\".");
                System.Environment.Exit(1);
            }
            CModel model = dataModel.getModel();
            Debug.Assert(model != null);
            System.Console.WriteLine("Model statistics for model \"" + model.getObjectName() + "\".");

            // output number and names of all compartments
            uint i, iMax = (uint)model.getCompartments().size();
            System.Console.WriteLine("Number of Compartments: " + System.Convert.ToString(iMax));
            System.Console.WriteLine("Compartments: ");
            for (i = 0; i < iMax; ++i)
            {
                CCompartment compartment = model.getCompartment(i);
                Debug.Assert(compartment != null);
                System.Console.WriteLine("\t" + compartment.getObjectName());
            }

            // output number and names of all metabolites
            iMax = (uint)model.getMetabolites().size();
            System.Console.WriteLine("Number of Metabolites: " + System.Convert.ToString(iMax));
            System.Console.WriteLine("Metabolites: ");
            for (i = 0; i < iMax; ++i)
            {
                CMetab metab = model.getMetabolite(i);
                Debug.Assert(metab != null);
                System.Console.WriteLine("\t" + metab.getObjectName());
            }

            // output number and names of all reactions
            iMax = (uint)model.getReactions().size();
            System.Console.WriteLine("Number of Reactions: " + System.Convert.ToString(iMax));
            System.Console.WriteLine("Reactions: ");
            for (i = 0; i < iMax; ++i)
            {
                CReaction reaction = model.getReaction(i);
                Debug.Assert(reaction != null);
                System.Console.WriteLine("\t" + reaction.getObjectName());
            }
        }
        else
        {
            System.Console.Error.WriteLine("Usage: example2 CPSFILE");
            System.Environment.Exit(1);
        }
    }