Exemple #1
0
        public void test_SBMLConvert_convertToL3_localParameters()
        {
            SBMLDocument d = new  SBMLDocument(1, 2);
            Model        m = d.createModel();
            Compartment  c = m.createCompartment();

            c.setId("c");
            Species s = m.createSpecies();

            s.setId("s");
            s.setCompartment("c");
            Reaction         r  = m.createReaction();
            SpeciesReference sr = r.createReactant();

            sr.setSpecies("s");
            KineticLaw kl = r.createKineticLaw();

            kl.setFormula("s*k");
            Parameter p = kl.createParameter();

            p.setId("k");
            assertTrue(kl.getNumLocalParameters() == 0);
            assertTrue(d.setLevelAndVersion(3, 1, false) == true);
            m  = d.getModel();
            r  = m.getReaction(0);
            kl = r.getKineticLaw();
            assertTrue(kl.getNumLocalParameters() == 1);
            LocalParameter lp = kl.getLocalParameter(0);

            d = null;
        }
Exemple #2
0
        public void LocalParameter001()
        {
            // Arrange
            var expected          = JObject.Parse(@"
            {
              ""params"": {
                ""myLocalParameter"": ""id:\""ITEM01\""""
              }
            }");
            var container         = new JObject();
            var parameter         = new LocalParameter <TestDocument>();
            var solrOptions       = new SolrExpressOptions();
            var solrConnection    = new FakeSolrConnection <TestDocument>();
            var expressionBuilder = new ExpressionBuilder <TestDocument>(solrOptions, solrConnection);

            expressionBuilder.LoadDocument();
            var searchQuery = new SearchQuery <TestDocument>(expressionBuilder);

            parameter.Name  = "myLocalParameter";
            parameter.Query = searchQuery.Field(q => q.Id).EqualsTo("ITEM01");

            // Act
            ((ISearchItemExecution <JObject>)parameter).Execute();
            ((ISearchItemExecution <JObject>)parameter).AddResultInContainer(container);

            // Assert
            Assert.Equal(expected.ToString(), container.ToString());
        }
Exemple #3
0
        public void test_L3_LocalParameter_createWithNS()
        {
            XMLNamespaces xmlns = new  XMLNamespaces();

            xmlns.add("http://www.sbml.org", "testsbml");
            SBMLNamespaces sbmlns = new  SBMLNamespaces(3, 1);

            sbmlns.addNamespaces(xmlns);
            LocalParameter p = new  LocalParameter(sbmlns);

            assertTrue(p.getTypeCode() == libsbml.SBML_LOCAL_PARAMETER);
            assertTrue(p.getMetaId() == "");
            assertTrue(p.getNotes() == null);
            assertTrue(p.getAnnotation() == null);
            assertTrue(p.getLevel() == 3);
            assertTrue(p.getVersion() == 1);
            assertTrue(p.getNamespaces() != null);
            assertTrue(p.getNamespaces().getLength() == 2);
            assertTrue(p.getId() == "");
            assertTrue(p.getName() == "");
            assertTrue(p.getUnits() == "");
            assertEquals(true, double.IsNaN(p.getValue()));
            assertEquals(false, p.isSetId());
            assertEquals(false, p.isSetName());
            assertEquals(false, p.isSetValue());
            assertEquals(false, p.isSetUnits());
            p = null;
        }
Exemple #4
0
        public void test_L3_LocalParameter_hasRequiredAttributes()
        {
            LocalParameter p = new  LocalParameter(3, 1);

            assertEquals(false, p.hasRequiredAttributes());
            p.setId("id");
            assertEquals(true, p.hasRequiredAttributes());
            p = null;
        }
Exemple #5
0
 public void setUp()
 {
     P = new  LocalParameter(3, 1);
     if (P == null)
     {
         ;
     }
     {
     }
 }
Exemple #6
0
 /// <summary>
 ///     Gets the MoBi Dimension of a SBML Local Parameter.
 /// </summary>
 /// <returns> The Dimension, if it was found, or null. </returns>
 private IDimension GetDimension(LocalParameter localParameter)
 {
     if (!localParameter.isSetUnits())
     {
         return(_dimensionFactory.Dimension(Constants.Dimension.DIMENSIONLESS));
     }
     if (_sbmlInformation.MobiDimension.ContainsKey(localParameter.getUnits()))
     {
         return(_sbmlInformation.MobiDimension[localParameter.getUnits()]);
     }
     return(null);
 }
        public void test_WriteL3SBML_KineticLaw_ListOfParameters()
        {
            string expected = "<kineticLaw>\n" +
                              "  <listOfLocalParameters>\n" +
                              "    <localParameter id=\"n\" value=\"1.2\"/>\n" +
                              "  </listOfLocalParameters>\n" +
                              "</kineticLaw>";
            KineticLaw     kl = D.createModel().createReaction().createKineticLaw();
            LocalParameter p  = kl.createLocalParameter();

            p.setId("n");
            p.setValue(1.2);
            assertEquals(true, equals(expected, kl.toSBML()));
        }
        public void LocalParameter002()
        {
            // Arrange
            var container = new List <string>();
            var parameter = new LocalParameter <TestDocument>();

            parameter.Name  = "myLocalParameter";
            parameter.Value = "some value";

            // Act
            ((ISearchItemExecution <List <string> >)parameter).Execute();
            ((ISearchItemExecution <List <string> >)parameter).AddResultInContainer(container);

            // Assert
            Assert.Single(container);
            Assert.Equal("myLocalParameter=some value", container[0]);
        }
        private LocalParameter[] ParseText(OracleCommand command, string commandText, out bool isQuery)
        {
            OracleParameterCollection parameters = command.Parameters;
            ArrayList list           = new ArrayList();
            Regex     sqlTokenParser = GetSqlTokenParser();

            isQuery = false;
            bool flag = false;

            for (Match match = sqlTokenParser.Match(commandText); Match.Empty != match; match = match.NextMatch())
            {
                if (!match.Groups[_commentGroup].Success)
                {
                    if ((match.Groups[_identifierGroup].Success || match.Groups[_stringGroup].Success) || match.Groups[_otherGroup].Success)
                    {
                        flag = true;
                    }
                    else if (match.Groups[_queryGroup].Success)
                    {
                        if (!flag)
                        {
                            isQuery = true;
                        }
                    }
                    else if (match.Groups[_parameterMarkerGroup].Success)
                    {
                        string parameterName = match.Groups[_parameterMarkerGroup].Value.Substring(1);
                        this._usedParameterNames[parameterName] = null;
                        int index = parameters.IndexOf(parameterName);
                        if (0 > index)
                        {
                            string str2 = ":" + parameterName;
                            index = parameters.IndexOf(str2);
                        }
                        if (0 <= index)
                        {
                            list.Add(new LocalParameter(index, match.Index, match.Length));
                        }
                    }
                }
            }
            LocalParameter[] array = new LocalParameter[list.Count];
            list.CopyTo(array, 0);
            return(array);
        }
Exemple #10
0
        public void test_L3_KineticLaw_addParameter2()
        {
            KineticLaw     kl  = new  KineticLaw(3, 1);
            LocalParameter lp  = new  LocalParameter(3, 1);
            LocalParameter lp1 = new  LocalParameter(3, 1);
            int            i   = kl.addLocalParameter(lp);

            assertTrue(i == libsbml.LIBSBML_INVALID_OBJECT);
            lp.setId("p");
            lp1.setId("p1");
            i = kl.addLocalParameter(lp);
            assertTrue(i == libsbml.LIBSBML_OPERATION_SUCCESS);
            assertTrue(kl.getNumParameters() == 1);
            assertTrue(kl.getNumLocalParameters() == 1);
            i = kl.addParameter(lp1);
            assertTrue(i == libsbml.LIBSBML_OPERATION_SUCCESS);
            assertTrue(kl.getNumParameters() == 2);
            assertTrue(kl.getNumLocalParameters() == 2);
            lp = null;
            kl = null;
        }
Exemple #11
0
        public void LocalParameter002()
        {
            // Arrange
            var expected  = JObject.Parse(@"
            {
                ""params"":{
                    ""myLocalParameter"": ""some value""
                }
            }");
            var container = new JObject();
            var parameter = new LocalParameter <TestDocument>();

            parameter.Name  = "myLocalParameter";
            parameter.Value = "some value";

            // Act
            ((ISearchItemExecution <JObject>)parameter).Execute();
            ((ISearchItemExecution <JObject>)parameter).AddResultInContainer(container);

            // Assert
            Assert.Equal(expected.ToString(), container.ToString());
        }
        public void LocalParameter001()
        {
            // Arrange
            var container         = new List <string>();
            var parameter         = new LocalParameter <TestDocument>();
            var solrOptions       = new SolrExpressOptions();
            var solrConnection    = new FakeSolrConnection <TestDocument>();
            var expressionBuilder = new ExpressionBuilder <TestDocument>(solrOptions, solrConnection);

            expressionBuilder.LoadDocument();
            var searchQuery = new SearchQuery <TestDocument>(expressionBuilder);

            parameter.Name  = "myLocalParameter";
            parameter.Query = searchQuery.Field(q => q.Id).EqualsTo("ITEM01");

            // Act
            ((ISearchItemExecution <List <string> >)parameter).Execute();
            ((ISearchItemExecution <List <string> >)parameter).AddResultInContainer(container);

            // Assert
            Assert.Single(container);
            Assert.Equal("myLocalParameter=id:\"ITEM01\"", container[0]);
        }
 private LocalParameter[] ParseText(OracleCommand command, string commandText, out bool isQuery)
 {
     OracleParameterCollection parameters = command.Parameters;
     ArrayList list = new ArrayList();
     Regex sqlTokenParser = GetSqlTokenParser();
     isQuery = false;
     bool flag = false;
     for (Match match = sqlTokenParser.Match(commandText); Match.Empty != match; match = match.NextMatch())
     {
         if (!match.Groups[_commentGroup].Success)
         {
             if ((match.Groups[_identifierGroup].Success || match.Groups[_stringGroup].Success) || match.Groups[_otherGroup].Success)
             {
                 flag = true;
             }
             else if (match.Groups[_queryGroup].Success)
             {
                 if (!flag)
                 {
                     isQuery = true;
                 }
             }
             else if (match.Groups[_parameterMarkerGroup].Success)
             {
                 string parameterName = match.Groups[_parameterMarkerGroup].Value.Substring(1);
                 this._usedParameterNames[parameterName] = null;
                 int index = parameters.IndexOf(parameterName);
                 if (0 > index)
                 {
                     string str2 = ":" + parameterName;
                     index = parameters.IndexOf(str2);
                 }
                 if (0 <= index)
                 {
                     list.Add(new LocalParameter(index, match.Index, match.Length));
                 }
             }
         }
     }
     LocalParameter[] array = new LocalParameter[list.Count];
     list.CopyTo(array, 0);
     return array;
 }
Exemple #14
0
 public void tearDown()
 {
     P = null;
 }