isNumber() public method

public isNumber ( ) : bool
return bool
Ejemplo n.º 1
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="anASTNode"></param>
        /// <returns></returns>
        private ASTNode convertVariableName(ASTNode anASTNode)
        {
            long aNumChildren = anASTNode.getNumChildren();

            if ( aNumChildren == 2 )
            {
                this.convertVariableName( anASTNode.getLeftChild() );
                this.convertVariableName( anASTNode.getRightChild() );

                return anASTNode;
            }
            else if ( aNumChildren == 1 )
            {
                this.convertVariableName( anASTNode.getLeftChild() );
                return anASTNode;
            }
            else if ( aNumChildren == 0 )
            {
                if ( anASTNode.isNumber() )
                {
                }
                else
                {
                    string aName = anASTNode.getName();
                    string variableName = "";

                    // Check Species
                    foreach(SpeciesStruct aSpecies in this.Model.SpeciesList)
                    {
                        if ( aSpecies.ID != aName && aSpecies.Name != aName)
                            continue;

                        // Check VariableReference
                        foreach(VariableReferenceStruct aVariableReference in this.VariableReferenceList)
                            if (aVariableReference.Variable.Split(':')[2] == aName)
                                variableName =  aVariableReference.Name;
                        if (variableName == "")
                        {
                            string aModifierID = this.Model.getSpeciesReferenceID(aName);

                            VariableReferenceStruct varRef = new VariableReferenceStruct(
                                "C" + this.ModifierNumber.ToString(),
                                "Variable:" + aModifierID,
                                0);
                            this.VariableReferenceList.Add(varRef);

                            variableName = varRef.Name;
                            this.ModifierNumber++;
                        }
                        //string compartmentName = this.setCompartmentToVariableReference( aSpecies.Compartment );
                        //anASTNode.setType( libsbml.libsbml.AST_DIVIDE );
                        //anASTNode.addChild( new ASTNode( libsbml.libsbml.AST_NAME ) );
                        //anASTNode.addChild( new ASTNode( libsbml.libsbml.AST_NAME ) );
                        //anASTNode.getLeftChild().setName( variableName + ".Value" );
                        //anASTNode.getRightChild().setName( compartmentName + ".Value" ) ;
                        anASTNode.setName(variableName + ".Value");
                        return anASTNode;
                    }

                    // Check Parameters.
                    foreach(ParameterStruct aParameter in this.Model.ParameterList)
                    {
                        if (aParameter.ID != aName && aParameter.Name != aName)
                            continue;
                        foreach(VariableReferenceStruct aVariableReference in this.VariableReferenceList)
                            if (aVariableReference.Variable.Split(':')[2] == aName)
                                variableName = aVariableReference.Name;

                        if( variableName == "" )
                        {
                            VariableReferenceStruct varRef = new VariableReferenceStruct(
                                aName,
                                "Variable:/:" + aName,
                                0 );
                            this.VariableReferenceList.Add( varRef );

                            this.ParameterNumber++;
                            variableName = varRef.Name;
                        }

                        anASTNode.setName( variableName + ".Value" );

                        return anASTNode;
                    }
            //                if variableName == '':
                    variableName = this.setCompartmentToVariableReference( aName );
                    if (variableName != "")
                        anASTNode.setName( variableName + ".Value" );
                }
            }
            return anASTNode;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="anASTNode"></param>
        /// <returns></returns>
        private ASTNode convertVariableName(ASTNode anASTNode)
        {
            long aNumChildren = anASTNode.getNumChildren();

            if ( aNumChildren == 2 )
            {
                this.convertVariableName( anASTNode.getLeftChild() );
                this.convertVariableName( anASTNode.getRightChild() );
            }
            else if ( aNumChildren == 1 )
            {
                this.convertVariableName( anASTNode.getLeftChild() );
            }
            else if ( aNumChildren == 0 )
            {
                if ( anASTNode.isNumber() )
                {
                }
                else
                {
                    string aName = anASTNode.getName();
                    int aType = this.getVariableType( aName );

                    //# Species
                    if ( aType == libsbml.libsbml.SBML_SPECIES )
                    {
                        string variableName = this.setSpeciesToVariableReference( aName , 0);
                        if( variableName != "" )
                        {
                            anASTNode.setName( variableName + ".Value" );
                            return anASTNode;
                        }
                    }
                    //# Parameter
                    else if ( aType == libsbml.libsbml.SBML_PARAMETER )
                    {
                        string variableName = this.setParameterToVariableReference( aName , 0);
                        if( variableName != "" )
                        {
                            anASTNode.setName( variableName + ".Value" );
                            return anASTNode;
                        }
                    }
                    //# Compartment
                    else if (aType == libsbml.libsbml.SBML_COMPARTMENT)
                    {
                        string variableName = this.setCompartmentToVariableReference(aName, 0);
                        if( variableName != "" )
                        {
                            anASTNode.setName( variableName + ".Value" );
                            return anASTNode;
                        }
                    }
                }
            }
            return anASTNode;
        }