当前位置: 首页>>代码示例>>C#>>正文


C# ConversionProperties.addOption方法代码示例

本文整理汇总了C#中libsbmlcs.ConversionProperties.addOption方法的典型用法代码示例。如果您正苦于以下问题:C# ConversionProperties.addOption方法的具体用法?C# ConversionProperties.addOption怎么用?C# ConversionProperties.addOption使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在libsbmlcs.ConversionProperties的用法示例。


在下文中一共展示了ConversionProperties.addOption方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

        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]);
                }
            }
        }
开发者ID:TotteKarlsson,项目名称:roadrunner,代码行数:58,代码来源:FlattenModel.cs

示例2: Main

        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);
        }
开发者ID:TotteKarlsson,项目名称:roadrunner,代码行数:50,代码来源:stripPackage.cs

示例3: Main

        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);
        }
开发者ID:TotteKarlsson,项目名称:roadrunner,代码行数:54,代码来源:convertFbcToCobra.cs

示例4: Main

        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);
        }
开发者ID:TotteKarlsson,项目名称:roadrunner,代码行数:46,代码来源:promoteParameters.cs

示例5: WriteUsingFBC

        private string WriteUsingFBC(int version = 1)
        {
            var doc = libsbml.readSBMLFromString(SBML);
              var model = doc.getModel();
              if (doc.getLevel() < 3)
              {
            var properties = new ConversionProperties(new SBMLNamespaces(3, 1));
            properties.addOption("strict", false);
            properties.addOption("setLevelAndVersion", true);
            properties.addOption("ignorePackages", true);
            doc.convert(properties);
              }

              if (version == 1)
              {
            doc.enablePackage(FbcExtension.getXmlnsL3V1V2(), "fbc", false);
            doc.enablePackage(FbcExtension.getXmlnsL3V1V1(), "fbc", true);
              }
              else if (version == 2)
              {
            doc.enablePackage(FbcExtension.getXmlnsL3V1V1(), "fbc", false);
            doc.enablePackage(FbcExtension.getXmlnsL3V1V2(), "fbc", true);
              }

              doc.setPackageRequired("fbc", false);

              var plugin = (FbcModelPlugin)model.getPlugin("fbc");
              if (plugin == null)
              {

            throw new Exception("Could not save using Fbc. Please check that your model contains no errors!");
              }
              plugin.getListOfFluxBounds().clear();
              plugin.getListOfGeneAssociations().clear();
              plugin.getListOfObjectives().clear();
              plugin.getListOfGeneProducts().clear();

              if (version == 1)
              {
            plugin.unsetStrict();
            foreach (var constraint in Constraints)
            {
              var bound = plugin.createFluxBound();
              bound.setReaction(constraint.Id);
              bound.setOperation(ToFbcString(constraint.Operator));
              bound.setValue(constraint.Value);
            }
              }
              else
              {

            plugin.setStrict(false);

            foreach (var constraint in Constraints)
            {
              var reaction = model.getReaction(constraint.Id);
              if (reaction == null) continue;
              var rplug = (FbcReactionPlugin)reaction.getPlugin("fbc");
              if (rplug == null) continue;

              switch (constraint.Operator)
              {
            case lpsolve_constr_types.LE:
              {
                var param = model.createParameter();
                param.setId(string.Format("fb_{0}_ub", reaction.getId()));
                param.setConstant(true);
                param.setValue(constraint.Value);
                rplug.setUpperFluxBound(param.getId());
              }
              break;
            case lpsolve_constr_types.EQ:
              {
                var param = model.createParameter();
                param.setId(string.Format("fb_{0}_ub", reaction.getId()));
                param.setConstant(true);
                param.setValue(constraint.Value);
                rplug.setUpperFluxBound(param.getId());

                param = model.createParameter();
                param.setId(string.Format("fb_{0}_lb", reaction.getId()));
                param.setConstant(true);
                param.setValue(constraint.Value);
                rplug.setLowerFluxBound(param.getId());
              }
              break;
            case lpsolve_constr_types.GE:
              {
                var param = model.createParameter();
                param.setId(string.Format("fb_{0}_lb", reaction.getId()));
                param.setConstant(true);
                param.setValue(constraint.Value);
                rplug.setLowerFluxBound(param.getId());
              }
              break;
            default:
              break;
              }

            }
//.........这里部分代码省略.........
开发者ID:fbergmann,项目名称:FluxBalance,代码行数:101,代码来源:FluxBalance.cs

示例6: InitializeFromCobraAnnotation

        private void InitializeFromCobraAnnotation(string sbmlContent)
        {
            try
              {
            var doc = libsbml.readSBMLFromString(sbmlContent);
            var props = new ConversionProperties();
            props.addOption("convert cobra", true, "");
            if (doc.convert(props) != libsbml.LIBSBML_OPERATION_SUCCESS)
              return;
            InitializeFromSBMLDocument(doc);
              }
              catch
              {

              }
        }
开发者ID:fbergmann,项目名称:FluxBalance,代码行数:16,代码来源:FluxBalance.cs

示例7: WriteAsCobraAnnotation

        public string WriteAsCobraAnnotation()
        {
            var doc = libsbml.readSBMLFromString(SBML);
              var model = doc.getModel();
              if (doc.getLevel() < 3)
              {
            var properties = new ConversionProperties(new SBMLNamespaces(3, 1));
            properties.addOption("strict", false);
            properties.addOption("setLevelAndVersion", true);
            properties.addOption("ignorePackages", true);
            doc.convert(properties);
              }
              doc.enablePackage(FbcExtension.getXmlnsL3V1V1(), "fbc", true);
              var plugin = (FbcModelPlugin)model.getPlugin("fbc");
              if (plugin == null)
              {

            throw new Exception("Could not save using Fbc. Please check that your model contains no errors!");
              }
              plugin.getListOfFluxBounds().clear();
              plugin.getListOfGeneAssociations().clear();
              plugin.getListOfObjectives().clear();

              foreach (var constraint in Constraints)
              {
            var bound = plugin.createFluxBound();
            bound.setReaction(constraint.Id);
            bound.setOperation(ToFbcString(constraint.Operator));
            bound.setValue(constraint.Value);
              }

              var active = plugin.createObjective();
              active.setId("objective1");
              active.setType(Mode == FBA_Mode.maximize ? "maximize" : "minimize");

              foreach (var objective in Objectives)
              {
            var current = active.createFluxObjective();
            current.setReaction(objective.Id);
            current.setCoefficient(objective.Value);
              }

              plugin.setActiveObjectiveId("objective1");

              // convert to COBRA
              var props = new ConversionProperties();
              props.addOption("convert fbc to cobra", true, "Convert FBC model to Cobra model");
              if (doc.convert(props) != libsbml.LIBSBML_OPERATION_SUCCESS)
              {
            throw new Exception(doc.getErrorLog().toString());
              }

              model = doc.getModel();
              plugin = (FbcModelPlugin)model.getPlugin("fbc");
              if (plugin != null)
              {
            plugin.getListOfGeneProducts().clear();
            plugin.getListOfGeneAssociations().clear();
            plugin.getListOfFluxBounds().clear();
            plugin.getListOfObjectives().clear();
              }
              return libsbml.writeSBMLToString(doc);
        }
开发者ID:fbergmann,项目名称:FluxBalance,代码行数:63,代码来源:FluxBalance.cs

示例8: ConvertToL2

        public static string ConvertToL2(string model)
        {
            try
              {

            var doc = libsbml.readSBMLFromString(model);
            if (doc.isPackageEnabled("fbc"))
              doc.enablePackageInternal(doc.getNamespaces().getURI("fbc"), "fbc", false);
            var properties = new ConversionProperties(new SBMLNamespaces(2, 4));
            properties.addOption("strict", false);
            properties.addOption("setLevelAndVersion", true);
            properties.addOption("ignorePackages", true);
            doc.convert(properties);
            return libsbml.writeSBMLToString(doc);
              }
              catch// (Exception)
              {
            return model;
              }
        }
开发者ID:fbergmann,项目名称:FluxBalance,代码行数:20,代码来源:FluxBalance.cs


注:本文中的libsbmlcs.ConversionProperties.addOption方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。