Ejemplo n.º 1
0
 public void response_SBSKnownDerivedAsSBase(SBase sb)
 {
     AllTests.test(sb.sb.Equals("SBSKnownDerived.sb"));
     SBSKnownDerived sbskd = (SBSKnownDerived) sb;
     AllTests.test(sbskd != null);
     AllTests.test(sbskd.sbskd.Equals("SBSKnownDerived.sbskd"));
     callback.called();
 }
Ejemplo n.º 2
0
        SBase getElementBySId(string id)
        {
            SBase ret = (SBase)libsbml.DowncastSBase(libsbmlPINVOKE.ListOfLocalParameters_getElementBySId(swigCPtr, id), false);

            if (libsbmlPINVOKE.SWIGPendingException.Pending)
            {
                throw libsbmlPINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Ejemplo n.º 3
0
        SBase getElementByMetaId(string metaid)
        {
            SBase ret = (SBase)libsbml.DowncastSBase(libsbmlPINVOKE.SBasePlugin_getElementByMetaId(swigCPtr, metaid), false);

            if (libsbmlPINVOKE.SWIGPendingException.Pending)
            {
                throw libsbmlPINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Ejemplo n.º 4
0
        SBase getElementBySId(string id)
        {
            SBase ret = (SBase)libsbml.DowncastSBase(libsbmlPINVOKE.UnitDefinition_getElementBySId(swigCPtr, id), false);

            if (libsbmlPINVOKE.SWIGPendingException.Pending)
            {
                throw libsbmlPINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
    private static void printNotes(SBase sb)
    {
        string id = "";

        if (sb.isSetId())
        {
            id = sb.getId();
        }
        printNotes(sb, id);
    }
Ejemplo n.º 6
0
        public void test_RDFAnnotation_C_parseCVTerms()
        {
            SBase   obj  = m.getCompartment(0);
            XMLNode node = RDFAnnotationParser.parseCVTerms(obj);

            assertTrue(node.getNumChildren() == 1);
            XMLNode rdf = node.getChild(0);

            assertTrue(("RDF" == rdf.getName()));
            assertTrue(("rdf" == rdf.getPrefix()));
            assertTrue(("http://www.w3.org/1999/02/22-rdf-syntax-ns#" == rdf.getURI()));
            assertTrue(rdf.getNumChildren() == 1);
            XMLNode desc = rdf.getChild(0);

            assertTrue(("Description" == desc.getName()));
            assertTrue(("rdf" == desc.getPrefix()));
            assertTrue(("http://www.w3.org/1999/02/22-rdf-syntax-ns#" == desc.getURI()));
            assertTrue(desc.getNumChildren() == 1);
            XMLNode is1 = desc.getChild(0);

            assertTrue(("is" == is1.getName()));
            assertTrue(("bqbiol" == is1.getPrefix()));
            assertTrue(is1.getNumChildren() == 1);
            XMLNode Bag = is1.getChild(0);

            assertTrue(("Bag" == Bag.getName()));
            assertTrue(("rdf" == Bag.getPrefix()));
            assertTrue(("http://www.w3.org/1999/02/22-rdf-syntax-ns#" == Bag.getURI()));
            assertTrue(Bag.getNumChildren() == 4);
            XMLNode li = Bag.getChild(0);

            assertTrue(("li" == li.getName()));
            assertTrue(("rdf" == li.getPrefix()));
            assertTrue(("http://www.w3.org/1999/02/22-rdf-syntax-ns#" == li.getURI()));
            assertTrue(li.getNumChildren() == 0);
            XMLNode li1 = Bag.getChild(1);

            assertTrue(("li" == li1.getName()));
            assertTrue(("rdf" == li1.getPrefix()));
            assertTrue(("http://www.w3.org/1999/02/22-rdf-syntax-ns#" == li1.getURI()));
            assertTrue(li1.getNumChildren() == 0);
            XMLNode li2 = Bag.getChild(2);

            assertTrue(("li" == li2.getName()));
            assertTrue(("rdf" == li2.getPrefix()));
            assertTrue(("http://www.w3.org/1999/02/22-rdf-syntax-ns#" == li2.getURI()));
            assertTrue(li2.getNumChildren() == 0);
            XMLNode li3 = Bag.getChild(3);

            assertTrue(("li" == li3.getName()));
            assertTrue(("rdf" == li3.getPrefix()));
            assertTrue(("http://www.w3.org/1999/02/22-rdf-syntax-ns#" == li3.getURI()));
            assertTrue(li3.getNumChildren() == 0);
            node = null;
        }
    private static void printAnnotation(SBase sb, string id)
    {
        if (!sb.isSetAnnotation())
        {
            return;
        }

        Console.Write("----- " + sb.getElementName() + " (" + id
                      + ") annotation -----" + Environment.NewLine);
        Console.Write(sb.getAnnotationString() + Environment.NewLine);
        Console.Write(Environment.NewLine);
    }
Ejemplo n.º 8
0
    private static void printNotes(SBase sb, string id)
    {
        if (!sb.isSetNotes())
        {
            return;
        }


        Console.WriteLine("----- " + sb.getElementName() + " (" + id
                          + ") notes -----");
        Console.WriteLine(sb.getNotesString());
        Console.WriteLine();
    }
Ejemplo n.º 9
0
    protected override void Read()
    {
        Type t = this.GetType();

        FieldInfo[] infos = t.GetFields();
        SBase       tmp   = null;

        for (int i = 0; i < infos.Length; i++)
        {
            FieldInfo fi = infos[i];

            if (fi.FieldType == typeof(SInt))
            {
                tmp = new SInt();
                SDefAttribute ca = GetAttr(fi);
                if (ca != null)
                {
                    (tmp as SInt).Def = ca.intv;
                }
            }
            else if (fi.FieldType == typeof(SFloat))
            {
                tmp = new SFloat();
                SDefAttribute ca = GetAttr(fi);
                if (ca != null)
                {
                    (tmp as SFloat).Def = ca.floatv;
                }
            }
            else if (fi.FieldType == typeof(SString))
            {
                tmp = new SString();
                SDefAttribute ca = GetAttr(fi);
                if (ca != null)
                {
                    (tmp as SString).Def = ca.stringv;
                }
            }
            else if (IsBaseType(fi.FieldType, typeof(SBase)))
            {
                tmp = Activator.CreateInstance(fi.FieldType) as SBase;
            }
            else
            {
                Debug.LogError(string.Format("{0} no suppot!", fi.Name));
                continue;
            }
            tmp.Init(sb, string.Format(ConnctFormat, key, fi.Name));
            fi.SetValue(this, tmp);
        }
    }
Ejemplo n.º 10
0
    public override void Delete()
    {
        Type t = this.GetType();

        FieldInfo[] infos = t.GetFields();
        for (int i = 0; i < infos.Length; i++)
        {
            FieldInfo fi = infos[i];
            if (IsBaseType(fi.FieldType, typeof(SBase)))
            {
                SBase v = fi.GetValue(this) as SBase;
                v.Delete();
            }
        }
    }
Ejemplo n.º 11
0
        public void test_GetMultipleObjects_getId()
        {
            SBMLReader   reader = new SBMLReader();
            SBMLDocument d;
            string       filename = "../../sbml/test/test-data/";

            filename += "multiple-ids.xml";
            d         = reader.readSBML(filename);
            if (d == null)
            {
                ;
            }
            {
            }
            SBase obj = d.getElementBySId("no_id");

            assertTrue(obj == null);
            obj = d.getElementBySId("");
            assertTrue(obj == null);
            obj = d.getElementBySId("find_id");
            assertTrue(obj != null);
            assertTrue(obj.getTypeCode() == libsbml.SBML_MODEL);
            obj = d.getElementBySId("func1");
            assertTrue(obj != null);
            assertTrue(obj.getTypeCode() == libsbml.SBML_FUNCTION_DEFINITION);
            obj = d.getElementBySId("comp");
            assertTrue(obj != null);
            assertTrue(obj.getTypeCode() == libsbml.SBML_COMPARTMENT);
            obj = d.getElementBySId("b");
            assertTrue(obj != null);
            assertTrue(obj.getTypeCode() == libsbml.SBML_SPECIES);
            obj = d.getElementBySId("x");
            assertTrue(obj != null);
            assertTrue(obj.getTypeCode() == libsbml.SBML_PARAMETER);
            obj = d.getElementBySId("J0");
            assertTrue(obj != null);
            assertTrue(obj.getTypeCode() == libsbml.SBML_REACTION);
            obj = d.getElementBySId("E0");
            assertTrue(obj != null);
            assertTrue(obj.getTypeCode() == libsbml.SBML_EVENT);
            d = null;
        }
Ejemplo n.º 12
0
    /**
     * Returns a list of all ids from the given list of elements
     */
    public static List <string> getAllIds(SBaseList allElements)
    {
        var result = new List <string>();

        if (allElements == null || allElements.getSize() == 0)
        {
            return(result);
        }

        for (uint i = 0; i < allElements.getSize(); ++i)
        {
            SBase current = allElements.get(i);
            if (current.isSetId() && current.getTypeCode() != libsbml.SBML_LOCAL_PARAMETER)
            {
                result.Add(current.getId());
            }
        }

        return(result);
    }
Ejemplo n.º 13
0
    /// <summary>
    /// The function performing the filtering, here we just check
    /// that we have a valid element, and that it has notes.
    /// </summary>
    /// <param name="element">the current element</param>
    /// <returns><b>true</b> if element is to be included, <b>false</b> otherwise</returns>
    public override bool filter(SBase element)
    {
        // return in case we don't have a valid element
        if (element == null || !element.isSetNotes())
        {
            return(false);
        }

        // otherwise we have notes set and want to keep the element
        if (!element.isSetId())
        {
            Console.WriteLine("                     found : {0}", element.getId());
        }
        else
        {
            Console.WriteLine("                     found element without id");
        }

        return(true);
    }
Ejemplo n.º 14
0
        static void Main()
        {
            #region Definations
            IBase     _SBase     = new SBase();
            ICommand  _SCommand  = new SCommand(_SBase);
            ILocation _SLocation = new SLocation(_SCommand);
            IRover    _SRover    = new SRover(_SCommand, _SBase, _SLocation);
            IPlateau  _SPlateau  = new SPlateau();
            #endregion

            #region Test Input One
            Plateau plateau = _SPlateau.createPlateau(5, 5);
            Dictionary <Rover, bool> firstRover = _SRover.setRoverLocation(plateau, 1, 2, enumMainDirections.N);

            if (firstRover.FirstOrDefault().Value)
            {
                Dictionary <Rover, bool> firstRoverResponse = _SRover.updateRoverLocation(plateau, firstRover.FirstOrDefault().Key, "LMLMLMLMM");
                _SLocation.roverResultLocation(firstRoverResponse);
            }
            else
            {
                _SCommand.printInvalidLocationOrDirection();
            }
            #endregion

            #region Test Input Two
            Dictionary <Rover, bool> secondRover = _SRover.setRoverLocation(plateau, 3, 3, enumMainDirections.E);
            if (firstRover.FirstOrDefault().Value)
            {
                Dictionary <Rover, bool> secondRoverResponse = _SRover.updateRoverLocation(plateau, secondRover.FirstOrDefault().Key, "MMRMMRMRRM");
                _SLocation.roverResultLocation(secondRoverResponse);
            }
            else
            {
                _SCommand.printInvalidLocationOrDirection();
            }
            #endregion

            Console.ReadLine();
        }
Ejemplo n.º 15
0
        public void test_GetMultipleObjects_noUnits()
        {
            SBMLReader   reader = new SBMLReader();
            SBMLDocument d;
            string       filename = "../../sbml/test/test-data/";

            filename += "multiple-ids.xml";
            d         = reader.readSBML(filename);
            if (d == null)
            {
                ;
            }
            {
            }
            SBase obj = d.getElementBySId("volume");

            assertTrue(obj == null);
            obj = d.getElementByMetaId("meta30");
            assertTrue(obj != null);
            assertTrue(obj.getTypeCode() == libsbml.SBML_UNIT_DEFINITION);
            d = null;
        }
Ejemplo n.º 16
0
        public void test_GetMultipleObjects_noAssignments()
        {
            SBMLReader   reader = new SBMLReader();
            SBMLDocument d;
            string       filename = "../../sbml/test/test-data/";

            filename += "assignments-invalid.xml";
            d         = reader.readSBML(filename);
            if (d.getModel() == null)
            {
                ;
            }
            {
            }
            SBase obj = d.getElementBySId("ia");

            assertTrue(obj == null);
            obj = d.getElementByMetaId("ia_meta");
            assertTrue(obj != null);
            assertTrue(obj.getTypeCode() == libsbml.SBML_INITIAL_ASSIGNMENT);
            obj = d.getElementBySId("ar");
            assertTrue(obj == null);
            obj = d.getElementByMetaId("ar_meta");
            assertTrue(obj != null);
            assertTrue(obj.getTypeCode() == libsbml.SBML_ASSIGNMENT_RULE);
            obj = d.getElementBySId("rr");
            assertTrue(obj == null);
            obj = d.getElementByMetaId("rr_meta");
            assertTrue(obj != null);
            assertTrue(obj.getTypeCode() == libsbml.SBML_RATE_RULE);
            obj = d.getElementBySId("ea");
            assertTrue(obj == null);
            obj = d.getElementByMetaId("ea_meta");
            assertTrue(obj != null);
            assertTrue(obj.getTypeCode() == libsbml.SBML_EVENT_ASSIGNMENT);
            d = null;
        }
Ejemplo n.º 17
0
        int append(SBase item)
        {
            int ret = libsbmlPINVOKE.ListOf_append(swigCPtr, SBase.getCPtr(item));

            return(ret);
        }
Ejemplo n.º 18
0
        int appendAndOwn(SBase disownedItem)
        {
            int ret = libsbmlPINVOKE.ListOf_appendAndOwn(swigCPtr, SBase.getCPtrAndDisown(disownedItem));

            return(ret);
        }
Ejemplo n.º 19
0
        bool isValidTypeForList(SBase item)
        {
            bool ret = libsbmlPINVOKE.SBasePlugin_isValidTypeForList(swigCPtr, SBase.getCPtrAndDisown(item));

            return(ret);
        }
Ejemplo n.º 20
0
        bool filter(SBase element)
        {
            bool ret = (SwigDerivedClassHasMethod("filter", swigMethodTypes0) ? libsbmlPINVOKE.ElementFilter_filterSwigExplicitElementFilter(swigCPtr, SBase.getCPtr(element)) : libsbmlPINVOKE.ElementFilter_filter(swigCPtr, SBase.getCPtr(element)));

            return(ret);
        }
Ejemplo n.º 21
0
 void connectToParent(SBase sbase)
 {
     libsbmlPINVOKE.SBasePlugin_connectToParent(swigCPtr, SBase.getCPtr(sbase));
 }
Ejemplo n.º 22
0
        SBase getParentSBMLObject()
        {
            SBase ret = (SBase)libsbml.DowncastSBase(libsbmlPINVOKE.SBasePlugin_getParentSBMLObject__SWIG_0(swigCPtr), false);

            return(ret);
        }
Ejemplo n.º 23
0
        SBase get(long n)
        {
            SBase ret = (SBase)libsbml.DowncastSBase(libsbmlPINVOKE.ListOf_get__SWIG_0(swigCPtr, n), false);

            return(ret);
        }
Ejemplo n.º 24
0
 public override SBase SBaseAsSBase(Ice.Current current)
 {
     SBase sb = new SBase();
     sb.sb = "SBase.sb";
     return sb;
 }
Ejemplo n.º 25
0
        int insert(int location, SBase item)
        {
            int ret = libsbmlPINVOKE.ListOf_insert(swigCPtr, location, SBase.getCPtr(item));

            return(ret);
        }
Ejemplo n.º 26
0
 public void response_SBSUnknownDerivedAsSBase(SBase sb)
 {
     AllTests.test(sb.sb.Equals("SBSUnknownDerived.sb"));
     callback.called();
 }
Ejemplo n.º 27
0
 public override void SBaseAsSBase_async(AMD_TestIntf_SBaseAsSBase cb, Ice.Current current)
 {
     SBase sb = new SBase();
     sb.sb = "SBase.sb";
     cb.ice_response(sb);
 }
Ejemplo n.º 28
0
        SBase getElementBySId(string id)
        {
            SBase ret = (SBase)libsbml.DowncastSBase(libsbmlPINVOKE.ListOfRules_getElementBySId(swigCPtr, id), false);

            return(ret);
        }
Ejemplo n.º 29
0
 public void response_SBSUnknownDerivedAsSBaseCompact(SBase sb)
 {
     AllTests.test(false);
 }
Ejemplo n.º 30
0
        int insertAndOwn(int location, SBase disownedItem)
        {
            int ret = libsbmlPINVOKE.ListOf_insertAndOwn(swigCPtr, location, SBase.getCPtrAndDisown(disownedItem));

            return(ret);
        }
Ejemplo n.º 31
0
        SBase getParentSBMLObject()
        {
            SBase ret = (SBase)libsbml.DowncastSBase(libsbmlPINVOKE.ASTBase_getParentSBMLObject(swigCPtr), false);

            return(ret);
        }
Ejemplo n.º 32
0
        SBase remove(long n)
        {
            SBase ret = (SBase)libsbml.DowncastSBase(libsbmlPINVOKE.ListOf_remove(swigCPtr, n), true);

            return(ret);
        }
Ejemplo n.º 33
0
 public override Ice.Object SBaseAsObject(Ice.Current current)
 {
     SBase sb = new SBase();
     sb.sb = "SBase.sb";
     return sb;
 }
Ejemplo n.º 34
0
        SBase getElementByMetaId(string metaid)
        {
            SBase ret = (SBase)libsbml.DowncastSBase(libsbmlPINVOKE.KineticLaw_getElementByMetaId(swigCPtr, metaid), false);

            return(ret);
        }
Ejemplo n.º 35
0
        static void testListOfRemove(ListOf lof, SBase s)
        {
            string ename = s.getElementName();

            lof.append(s);
            SBase c = lof.get(0);

            if (c is CompartmentType)
            {
                CompartmentType x = (lof as ListOfCompartmentTypes).remove(0); c = x;
            }
            else if (c is Compartment)
            {
                Compartment x = (lof as ListOfCompartments).remove(0); c = x;
            }
            else if (c is Constraint)
            {
                Constraint x = (lof as ListOfConstraints).remove(0); c = x;
            }
            else if (c is EventAssignment)
            {
                EventAssignment x = (lof as ListOfEventAssignments).remove(0); c = x;
            }
            else if (c is Event)
            {
                Event x = (lof as ListOfEvents).remove(0); c = x;
            }
            else if (c is FunctionDefinition)
            {
                FunctionDefinition x = (lof as ListOfFunctionDefinitions).remove(0); c = x;
            }
            else if (c is InitialAssignment)
            {
                InitialAssignment x = (lof as ListOfInitialAssignments).remove(0); c = x;
            }
            else if (c is Parameter)
            {
                Parameter x = (lof as ListOfParameters).remove(0); c = x;
            }
            else if (c is Reaction)
            {
                Reaction x = (lof as ListOfReactions).remove(0); c = x;
            }
            else if (c is Rule)
            {
                Rule x = (lof as ListOfRules).remove(0); c = x;
            }
            else if (c is Species)
            {
                Species x = (lof as ListOfSpecies).remove(0); c = x;
            }
            else if (c is SpeciesReference)
            {
                SimpleSpeciesReference x = (lof as ListOfSpeciesReferences).remove(0); c = x;
            }
            else if (c is SpeciesType)
            {
                SpeciesType x = (lof as ListOfSpeciesTypes).remove(0); c = x;
            }
            else if (c is UnitDefinition)
            {
                UnitDefinition x = (lof as ListOfUnitDefinitions).remove(0); c = x;
            }
            else if (c is Unit)
            {
                Unit x = (lof as ListOfUnits).remove(0); c = x;
            }
            else
            {
                ERR("[testListOfRemove] Error: (" + ename + ") : ListOfXXX::remove() failed.");
                return;
            }

            if (c == null)
            {
                ERR("[testListOfRemove] Error: (" + ename + ") : ListOfXXX::remove() failed.");
                return;
            }

            string enameGet = c.getElementName();

            if (ename == enameGet)
            {
                //Console.Out.WriteLine("[testListOfRemove] OK: (" + ename + ") remove(" + enameGet + ") : type match.");
                OK();
            }
            else
            {
                ERR("[testListOfRemove] Error: (" + ename + ") remove(" + enameGet + ") : type mismatch.");
            }
        }
Ejemplo n.º 36
0
 public void prepend(SBase item)
 {
     libsbmlPINVOKE.SBaseList_prepend(swigCPtr, SBase.getCPtr(item));
 }
Ejemplo n.º 37
0
 public void response_SBaseAsSBase(SBase sb)
 {
     AllTests.test(sb.sb.Equals("SBase.sb"));
     callback.called();
 }