Наследование: IDisposable
Пример #1
0
        public static void Main(string[] args)
        {
            if (args.Length != 2)
              {
            string myname = Path.GetFileName(Environment.GetCommandLineArgs()[0]);
            Console.WriteLine("Usage: {0} input-filename output-filename", myname);
            Environment.Exit(1);
              }

              string inputFile  = args[0];
              string outputFile = args[1];

              if ( ! File.Exists(inputFile) )
              {
            Console.WriteLine("[Error] {0} : No such file.", inputFile);
            Environment.Exit(1);
              }

              SBMLReader   reader  = new SBMLReader();
              SBMLWriter   writer  = new SBMLWriter();
              SBMLDocument sbmlDoc = reader.readSBML(inputFile);

              if ( sbmlDoc.getNumErrors() > 0)
              {
            sbmlDoc.printErrors();
            Console.WriteLine("[Error] Cannot read {0}", inputFile);
            Environment.Exit(1);
              }

              writer.writeSBML(sbmlDoc, outputFile);

              Console.WriteLine("[OK] Echoed {0} to {1}", inputFile, outputFile);
        }
Пример #2
0
        public static void Main(String[] args)
        {
            if (args.Length < 2 || args.Length > 3)
            {
                Console.WriteLine("Usage: FlattenModel [-p] input-filename output-filename");
                Console.WriteLine(" -p : list unused ports");
                Environment.Exit(2);
            }

            SBMLReader reader = new SBMLReader();
            SBMLWriter writer = new SBMLWriter();
            bool leavePorts = false;

            SBMLDocument doc;
            if (args.Length == 2)
            {
                doc = reader.readSBML(args[0]);
            }
            else
            {
                doc = reader.readSBML(args[1]);
                leavePorts = true;
            }

            if (doc.getErrorLog().getNumFailsWithSeverity(libsbml.LIBSBML_SEV_ERROR) > 0)
            {
                doc.printErrors();
            }
            else
            {
                /* create a new conversion properties structure */
                ConversionProperties props = new ConversionProperties();

                /* add an option that we want to flatten */
                props.addOption("flatten comp", true, "flatten comp");

                /* add an option to leave ports if the user has requested this */
                props.addOption("leavePorts", leavePorts, "unused ports should be listed in the flattened model");

                /* perform the conversion */
                int result = doc.convert(props);
                if (result != libsbml.LIBSBML_OPERATION_SUCCESS)
                {
                    Console.WriteLine("conversion failed ... ({0})", result);
                    doc.printErrors();
                    Environment.Exit(3);
                }

                if (args.Length == 2)
                {
                    writer.writeSBML(doc, args[1]);
                }
                else
                {
                    writer.writeSBML(doc, args[2]);
                }
            }
        }
Пример #3
0
        public static void Main(string[] args)
        {
            if (args.Length != 2)
              {
            string myname = Path.GetFileName(Environment.GetCommandLineArgs()[0]);
            Console.WriteLine("Usage: {0} input-filename output-filename", myname);
            Environment.Exit(1);
              }

              string inputFile      = args[0];
              string outputFile     = args[1];

              if ( ! File.Exists(inputFile) )
              {
            Console.WriteLine("[Error] {0} : No such file.", inputFile);
            Environment.Exit(1);
              }

              var now = DateTime.Now.Ticks;

              SBMLReader   reader  = new SBMLReader();
              SBMLWriter   writer  = new SBMLWriter();
              SBMLDocument sbmlDoc = reader.readSBML(inputFile);

              if ( sbmlDoc.getErrorLog().getNumFailsWithSeverity(libsbml.LIBSBML_SEV_ERROR) > 0)
              {
            sbmlDoc.printErrors();
            Console.WriteLine("[Error] Cannot read {0}", inputFile);
            Environment.Exit(1);
              }

              Console.WriteLine("Read {0} in {1}", inputFile, new TimeSpan(DateTime.Now.Ticks - now).TotalMilliseconds);

              /* create a new conversion properties structure */
              ConversionProperties props = new ConversionProperties();

              /* add an option that we want to convert a model  with
             L3 FBC to L2 with COBRA annotation */
              props.addOption("convert fbc to cobra", true, "Convert FBC model to Cobra model");

              now = DateTime.Now.Ticks;

              /* perform the conversion */
              int result = sbmlDoc.convert(props);
              if (result != libsbml.LIBSBML_OPERATION_SUCCESS)
              {
              	Console.WriteLine ("conversion failed ... ");
              	Environment.Exit(3);
              }

              writer.writeSBML(sbmlDoc, outputFile);

              Console.WriteLine("[OK] converted to FBC from {0} and wrote to {1}  (in {2} msec)", inputFile, outputFile, new TimeSpan(DateTime.Now.Ticks - now).TotalMilliseconds);
        }
        internal static HandleRef getCPtrAndDisown(SBMLWriter obj)
        {
            HandleRef ptr = new HandleRef(null, IntPtr.Zero);

            if (obj != null)
            {
                ptr             = obj.swigCPtr;
                obj.swigCMemOwn = false;
            }

            return(ptr);
        }
Пример #5
0
        public static void Main(string[] args)
        {
            if (args.Length != 3)
              {
            string myname = Path.GetFileName(Environment.GetCommandLineArgs()[0]);
            Console.WriteLine("Usage: {0} input-filename package-to-strip output-filename", myname);
            Environment.Exit(1);
              }

              string inputFile      = args[0];
              string packageToStrip = args[1];
              string outputFile     = args[2];

              if ( ! File.Exists(inputFile) )
              {
            Console.WriteLine("[Error] {0} : No such file.", inputFile);
            Environment.Exit(1);
              }

              SBMLReader   reader  = new SBMLReader();
              SBMLWriter   writer  = new SBMLWriter();
              SBMLDocument sbmlDoc = reader.readSBML(inputFile);

              if ( sbmlDoc.getErrorLog().getNumFailsWithSeverity(libsbml.LIBSBML_SEV_ERROR) > 0)
              {
            sbmlDoc.printErrors();
            Console.WriteLine("[Error] Cannot read {0}", inputFile);
            Environment.Exit(1);
              }

              /* create a new conversion properties structure */
              ConversionProperties props = new ConversionProperties();

              /* add an option that we want to strip a given package */
              props.addOption("stripPackage", true, "Strip SBML Level 3 package constructs from the model");

              /* add an option with the package we want to remove */
              props.addOption("package", packageToStrip, "Name of the SBML Level 3 package to be stripped");

              /* perform the conversion */
              if (sbmlDoc.convert(props) != libsbml.LIBSBML_OPERATION_SUCCESS)
              {
              	Console.WriteLine ("conversion failed ... ");
              	Environment.Exit(3);
              }

              writer.writeSBML(sbmlDoc, outputFile);

              Console.WriteLine("[OK] Stripped package '{0}' from {1} and wrote to {2}", packageToStrip, inputFile, outputFile);
        }
Пример #6
0
        public static void Main(string[] args)
        {
            if (args.Length != 2)
              {
            string myname = Path.GetFileName(Environment.GetCommandLineArgs()[0]);
            Console.WriteLine("Usage: {0} input-filenameoutput-filename", myname);
            Environment.Exit(1);
              }

              string inputFile      = args[0];
              string outputFile     = args[1];

              if ( ! File.Exists(inputFile) )
              {
            Console.WriteLine("[Error] {0} : No such file.", inputFile);
            Environment.Exit(1);
              }

              SBMLReader   reader  = new SBMLReader();
              SBMLWriter   writer  = new SBMLWriter();
              SBMLDocument sbmlDoc = reader.readSBML(inputFile);

              if ( sbmlDoc.getErrorLog().getNumFailsWithSeverity(libsbml.LIBSBML_SEV_ERROR) > 0)
              {
            sbmlDoc.printErrors();
            Console.WriteLine("[Error] Cannot read {0}", inputFile);
            Environment.Exit(1);
              }

              /* create a new conversion properties structure */
              ConversionProperties props = new ConversionProperties();

              /* add an option that we want to promote parameters */
              props.addOption("promoteLocalParameters", true, "Promotes all Local Parameters to Global ones");

              /* perform the conversion */
              if (sbmlDoc.convert(props) != libsbml.LIBSBML_OPERATION_SUCCESS)
              {
              	Console.WriteLine ("conversion failed ... ");
              	Environment.Exit(3);
              }

              writer.writeSBML(sbmlDoc, outputFile);

              Console.WriteLine("[OK] promoted paramters from {0} and wrote to {1}", inputFile, outputFile);
        }
Пример #7
0
        internal static HandleRef getCPtrAndDisown(SBMLWriter obj)
        {
            HandleRef ptr = new HandleRef(null, IntPtr.Zero);

            if (obj != null)
            {
            ptr             = obj.swigCPtr;
            obj.swigCMemOwn = false;
            }

            return ptr;
        }
Пример #8
0
 internal static HandleRef getCPtr(SBMLWriter obj)
 {
     return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
 }
 internal static HandleRef getCPtr(SBMLWriter obj)
 {
     return((obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr);
 }
Пример #10
0
 public void test_SBMLWriter_L3_setProgramName()
 {
     SBMLWriter w = new  SBMLWriter();
       assertTrue( w != null );
       int i = w.setProgramName( "sss");
       assertTrue( i == libsbml.LIBSBML_OPERATION_SUCCESS );
       i = w.setProgramName("");
       assertTrue( i == libsbml.LIBSBML_OPERATION_SUCCESS );
       w = null;
 }
Пример #11
0
 public void test_SBMLWriter_L3_create()
 {
     SBMLWriter w = new  SBMLWriter();
       assertTrue( w != null );
       w = null;
 }
Пример #12
0
 public void test_WriteL3SBML_error()
 {
     SBMLDocument d = new SBMLDocument();
       SBMLWriter w = new SBMLWriter();
       assertEquals( false, w.writeSBML(d, "/tmp/impossible/path/should/fail") );
       assertTrue( d.getNumErrors() == 1 );
       assertTrue( d.getError(0).getErrorId() == libsbml.XMLFileUnwritable );
       d = null;
       w = null;
 }
Пример #13
0
        public void test_SBase_appendNotesWithGlobalNamespace()
        {
            string notes = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<sbml xmlns=\"http://www.sbml.org/sbml/level2/version4\" xmlns:html=\"http://www.w3.org/1999/xhtml\" level=\"2\" version=\"4\">\n" + "  <model id=\"test\" name=\"name\">\n" + "    <notes>\n" + "      <html:p>DATE: 2010/12/08 13:00:00</html:p>\n" + "      <html:p>VERSION: 0.99</html:p>\n" + "      <html:p>TAXONOMY: 9606</html:p>\n" + "    </notes>\n" + "  </model>\n" + "</sbml>\n";
            SBMLDocument sbmlDoc = new SBMLDocument (2, 4);
            sbmlDoc.getNamespaces ().@add ("http://www.w3.org/1999/xhtml", "html");
            Model sbmlModel = sbmlDoc.createModel ();
            sbmlModel.setId ("test");
            sbmlModel.setName ("name");
            setOrAppendNotes (sbmlModel, "<html:p>DATE: 2010/12/08 13:00:00</html:p>");
            setOrAppendNotes (sbmlModel, "<html:p>VERSION: 0.99</html:p>");
            setOrAppendNotes (sbmlModel, "<html:p>TAXONOMY: 9606</html:p>");

            SBMLWriter ttt = new SBMLWriter ();
            string documentString = ttt.writeToString (sbmlDoc);
            assertTrue ((notes == documentString));
        }