Beispiel #1
0
    public static int Main(string[] args)
    {
        if (args.Length != 2)
        {
            Console.WriteLine("Usage: inlineInitialAssignments filename outFile");
            return(1);
        }

        string       filename = args[0];
        string       outFile  = args[1];
        long         current  = DateTime.Now.Ticks;
        SBMLDocument document = libsbml.readSBML(filename);


        if (document.getNumErrors(libsbml.LIBSBML_SEV_ERROR) > 0)
        {
            Console.WriteLine("The models contains errors, please correct them before continuing.");
            document.printErrors();
            return(1);
        }

        var model = document.getModel();

        SBMLTransforms.expandInitialAssignments(model);

        libsbml.writeSBML(document, outFile);

        return(0);
    }
    public static int Main(string[] args)
    {
        if (args.Length != 4)
        {
            Console.WriteLine("Usage: replaceOneFD filename functionDefinitionId reactionId outfile");
            return(1);
        }

        string       filename             = args[0];
        string       outFile              = args[3];
        string       functionDefinitionId = args[1];
        string       reactionId           = args[2];
        long         current              = DateTime.Now.Ticks;
        SBMLDocument document             = libsbml.readSBML(filename);

        if (document.getNumErrors(libsbml.LIBSBML_SEV_ERROR) > 0)
        {
            Console.WriteLine("The models contains errors, please correct them before continuing.");
            document.printErrors();
            return(1);
        }

        var model = document.getModel();
        var functionDefinition = model.getFunctionDefinition(functionDefinitionId);

        if (functionDefinition == null)
        {
            Console.WriteLine();
            Console.WriteLine("No functiondefinition with the given id can be found.");
            return(1);
        }

        var reaction = model.getReaction(reactionId);

        if (reaction == null)
        {
            Console.WriteLine();
            Console.WriteLine("No reaction with the given id can be found.");
            return(1);
        }

        if (!reaction.isSetKineticLaw() || !reaction.getKineticLaw().isSetMath())
        {
            Console.WriteLine();
            Console.WriteLine("The reaction has no math set. ");
            return(1);
        }

        // Until here it was all setup, all we needed was an ASTNode, in which we wanted to
        // replace calls to a function definition, with the function definitions content.
        //
        SBMLTransforms.replaceFD(reaction.getKineticLaw().getMath(), functionDefinition);

        // finally write to file
        libsbml.writeSBML(document, outFile);

        return(0);
    }
    public static int Main(string[] args)
    {
        if (args.Length < 1)
        {
            Console.WriteLine("Usage: evaluateCustomMath formula [model containing values]");
            return(1);
        }

        string formula  = args[0];
        string filename = args.Length == 2 ?  args[1] : null;

        var math = libsbml.parseFormula(formula);

        if (math == null)
        {
            Console.WriteLine("Invalid formula, aborting.");
            return(1);
        }

        SBMLDocument doc = null;

        if (filename != null)
        {
            doc = libsbml.readSBML(filename);
            if (doc.getNumErrors(libsbml.LIBSBML_SEV_ERROR) > 0)
            {
                Console.WriteLine("The models contains errors, please correct them before continuing.");
                doc.printErrors();
                return(1);
            }
            // the following maps a list of ids to their corresponding model values
            // this makes it possible to evaluate expressions involving SIds.
            SBMLTransforms.mapComponentValues(doc.getModel());
        }
        else
        {
            // create dummy document
            doc = new SBMLDocument(3, 1);
        }

        var result = SBMLTransforms.evaluateASTNode(math, doc.getModel());

        Console.WriteLine("{0} = {1}", formula, result);

        return(0);
    }