This class implements an identifier transformer, that means it can be used to rename all sbase elements.
Наследование: libsbmlcs.IdentifierTransformer
Пример #1
0
    /// <summary>
    /// The program is to be invoked with two arguments, the input and output file.
    /// </summary>
    /// <param name="args">command line arguments</param>
    /// <returns>0 in case of no errors</returns>
    public static int Main(string[] args)
    {
        if (args.Length != 2)
        {
            Console.WriteLine("{0}Usage: setIdFromNames filename output{0}{0}", Environment.NewLine);
            return(1);
        }

        string filename = args[0];
        string output   = args[1];

        // read the document
        long         start    = DateTime.Now.Ticks;
        SBMLDocument document = libsbml.readSBMLFromFile(filename);
        long         stop     = DateTime.Now.Ticks;


        Console.WriteLine();
        Console.WriteLine("            filename: {0}", filename);
        Console.WriteLine("      read time (ms): {0}", TimeSpan.FromTicks(stop - start).TotalMilliseconds);

        // stop in case of serious errors
        long errors = document.getNumErrors(libsbml.LIBSBML_SEV_ERROR);

        if (errors > 0)
        {
            Console.WriteLine("            error(s): {0}", errors);
            document.printErrors();
            return((int)errors);
        }


        // get a list of all elements, as we will need to know all identifiers
        // so that we don't create duplicates.
        SBaseList allElements = document.getListOfAllElements();

        // get a list of all ids
        var allIds = getAllIds(allElements);

        // create the transformer with the ids
        var trans = new SetIdFromNames(allIds);

        // rename the identifiers (using the elements we already gathered before)
        start = DateTime.Now.Ticks;
        document.getModel().renameIDs(allElements, trans);
        stop = DateTime.Now.Ticks;
        Console.WriteLine("    rename time (ms): {0}", TimeSpan.FromTicks(stop - start).TotalMilliseconds);

        // write to file
        start = DateTime.Now.Ticks;
        libsbml.writeSBMLToFile(document, output);
        stop = DateTime.Now.Ticks;
        Console.WriteLine("     write time (ms): {0}", TimeSpan.FromTicks(stop - start).TotalMilliseconds);
        Console.WriteLine();

        // if we got here all went well ...
        return(0);
    }
Пример #2
0
    /// <summary>
    /// The program is to be invoked with two arguments, the input and output file. 
    /// </summary>
    /// <param name="args">command line arguments</param>
    /// <returns>0 in case of no errors</returns>
    public static int Main(string[] args)
    {
        if (args.Length != 2)
        {
            Console.WriteLine("{0}Usage: setIdFromNames filename output{0}{0}", Environment.NewLine);
            return 1;
        }

        string filename = args[0];
        string output = args[1];

        // read the document
        long start = DateTime.Now.Ticks;
        SBMLDocument document = libsbml.readSBMLFromFile(filename);
        long stop = DateTime.Now.Ticks;

        Console.WriteLine();
        Console.WriteLine("            filename: {0}", filename);
        Console.WriteLine("      read time (ms): {0}", TimeSpan.FromTicks(stop - start).TotalMilliseconds);

        // stop in case of serious errors
        long errors = document.getNumErrors(libsbml.LIBSBML_SEV_ERROR);
        if (errors > 0)
        {
            Console.WriteLine("            error(s): {0}", errors);
            document.printErrors();
            return (int)errors;
        }

        // get a list of all elements, as we will need to know all identifiers
        // so that we don't create duplicates.
        SBaseList allElements = document.getListOfAllElements();

        // get a list of all ids
        var allIds = getAllIds(allElements);

        // create the transformer with the ids
        var trans = new SetIdFromNames(allIds);

        // rename the identifiers (using the elements we already gathered before)
        start = DateTime.Now.Ticks;
        document.getModel().renameIDs(allElements, trans);
        stop = DateTime.Now.Ticks;
        Console.WriteLine("    rename time (ms): {0}", TimeSpan.FromTicks(stop - start).TotalMilliseconds);

        // write to file
        start = DateTime.Now.Ticks;
        libsbml.writeSBMLToFile(document, output);
        stop = DateTime.Now.Ticks;
        Console.WriteLine("     write time (ms): {0}", TimeSpan.FromTicks(stop - start).TotalMilliseconds);
        Console.WriteLine();

        // if we got here all went well ...
        return 0;
    }