Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions src/sbml/SBMLDocument.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2405,11 +2405,11 @@ SBMLDocument_checkConsistency (SBMLDocument_t *d)


LIBSBML_EXTERN
unsigned int SBMLDocument_validateSBML(SBMLDocument_t * d)
{
unsigned int SBMLDocument_validateSBML(SBMLDocument_t * d)
{
return (d != NULL) ? d->validateSBML() : SBML_INT_MAX;
}
}

unsigned int
SBMLDocument_checkInternalConsistency (SBMLDocument_t *d)
{
Expand Down Expand Up @@ -2490,11 +2490,11 @@ SBMLDocument_getError (SBMLDocument_t *d, unsigned int n)
return (d != NULL) ? d->getError(n) : NULL;
}

LIBSBML_EXTERN
const SBMLErrorLog_t *
SBMLDocument_getErrorLog(SBMLDocument_t *d)
{
return (d != NULL) ? d->getErrorLog() : NULL;
LIBSBML_EXTERN
const SBMLErrorLog_t *
SBMLDocument_getErrorLog(SBMLDocument_t *d)
{
return (d != NULL) ? d->getErrorLog() : NULL;
}

LIBSBML_EXTERN
Expand Down
27 changes: 25 additions & 2 deletions src/sbml/packages/distrib/extension/DistribASTPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
#include <sbml/xml/XMLNamespaces.h>
#include <sbml/math/L3ParserSettings.h>
#include <sbml/packages/distrib/extension/DistribExtension.h>
#include <sbml/units/UnitFormulaFormatter.h>

/** @cond doxygenIgnored */

Expand Down Expand Up @@ -265,8 +266,30 @@ double DistribASTPlugin::evaluateASTNode(const ASTNode * node, const Model * m)

UnitDefinition * DistribASTPlugin::getUnitDefinitionFromPackage(UnitFormulaFormatter* uff, const ASTNode * node, bool inKL, int reactNo) const
{
//OK, this *definitely* could be actually coded, so we could do unit checking on draws from distributions. But it will be a fair amount of work to get right.
return NULL;
UnitDefinition* ud = NULL;
switch (node->getType())
{
case AST_DISTRIB_FUNCTION_UNIFORM:
case AST_DISTRIB_FUNCTION_NORMAL:
case AST_DISTRIB_FUNCTION_BINOMIAL:
case AST_DISTRIB_FUNCTION_CAUCHY:
case AST_DISTRIB_FUNCTION_CHISQUARE:
case AST_DISTRIB_FUNCTION_EXPONENTIAL:
case AST_DISTRIB_FUNCTION_GAMMA:
case AST_DISTRIB_FUNCTION_LAPLACE:
case AST_DISTRIB_FUNCTION_LOGNORMAL:
case AST_DISTRIB_FUNCTION_POISSON:
case AST_DISTRIB_FUNCTION_RAYLEIGH:
case AST_DISTRIB_FUNCTION_BERNOULLI:

ud = uff->getUnitDefinitionFromArgUnitsReturnFunction(node, inKL, reactNo);
break;

default:
break;
}
return ud;

}

#endif /* __cplusplus */
Expand Down
31 changes: 31 additions & 0 deletions src/sbml/packages/distrib/extension/DistribSBMLDocumentPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
#include <sbml/packages/distrib/validator/DistribSBMLError.h>
#include <sbml/packages/distrib/validator/DistribConsistencyValidator.h>
#include <sbml/packages/distrib/validator/DistribIdentifierConsistencyValidator.h>
#include <sbml/packages/distrib/validator/DistribMathMLConsistencyValidator.h>
#include <sbml/packages/distrib/validator/DistribUnitConsistencyValidator.h>


using namespace std;
Expand Down Expand Up @@ -167,7 +169,11 @@ DistribSBMLDocumentPlugin::checkConsistency()
unsigned char applicableValidators = doc->getApplicableValidators();
bool id = ((applicableValidators & 0x01) ==0x01);
bool core = ((applicableValidators & 0x02) ==0x02);
bool math = ((applicableValidators & 0x08) == 0x08);
bool units = ((applicableValidators & 0x10) == 0x10);

DistribMathMLConsistencyValidator math_validator;
DistribUnitConsistencyValidator unit_validator;
DistribIdentifierConsistencyValidator id_validator;
DistribConsistencyValidator core_validator;

Expand Down Expand Up @@ -200,7 +206,32 @@ DistribSBMLDocumentPlugin::checkConsistency()
}
}
}
if (math)
{
math_validator.init();
nerrors = math_validator.validate(*doc);
total_errors += nerrors;
if (nerrors > 0)
{
log->add(math_validator.getFailures());
/* only want to bail if errors not warnings */
if (log->getNumFailsWithSeverity(LIBSBML_SEV_ERROR) > 0)
{
return total_errors;
}
}
}

if (units)
{
unit_validator.init();
nerrors = unit_validator.validate(*doc);
total_errors += nerrors;
if (nerrors > 0)
{
log->add(unit_validator.getFailures());
}
}
return total_errors;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@

/** @cond doxygenLibsbmlInternal */

/**
* @file DistribMathMLConsistencyValidator.cpp
* @brief Definition of DistribMathMLConsistencyValidator.
* @author SBMLTeam
*
* <!--------------------------------------------------------------------------
* This file is part of libSBML. Please visit http://sbml.org for more
* information about SBML, and the latest version of libSBML.
*
* Copyright (C) 2020 jointly by the following organizations:
* 1. California Institute of Technology, Pasadena, CA, USA
* 2. University of Heidelberg, Heidelberg, Germany
* 3. University College London, London, UK
*
* Copyright (C) 2019 jointly by the following organizations:
* 1. California Institute of Technology, Pasadena, CA, USA
* 2. University of Heidelberg, Heidelberg, Germany
*
* Copyright (C) 2013-2018 jointly by the following organizations:
* 1. California Institute of Technology, Pasadena, CA, USA
* 2. EMBL European Bioinformatics Institute (EMBL-EBI), Hinxton, UK
* 3. University of Heidelberg, Heidelberg, Germany
*
* Copyright (C) 2009-2013 jointly by the following organizations:
* 1. California Institute of Technology, Pasadena, CA, USA
* 2. EMBL European Bioinformatics Institute (EMBL-EBI), Hinxton, UK
*
* Copyright (C) 2006-2008 by the California Institute of Technology,
* Pasadena, CA, USA
*
* Copyright (C) 2002-2005 jointly by the following organizations:
* 1. California Institute of Technology, Pasadena, CA, USA
* 2. Japan Science and Technology Agency, Japan
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation. A copy of the license agreement is provided in the
* file named "LICENSE.txt" included with this software distribution and also
* available online as http://sbml.org/software/libsbml/license.html
* ------------------------------------------------------------------------ -->
*/

#ifndef doxygen_ignore

#include <sbml/packages/distrib/validator/DistribMathMLConsistencyValidator.h>

/**
* Compile ConsistencyConstraints
*/
#include "constraints/DistribMathMLConsistencyConstraints.cpp"


LIBSBML_CPP_NAMESPACE_BEGIN


/**
* Initializes this Validator with a set of Constraints
*/
void
DistribMathMLConsistencyValidator::init()
{
#define AddingConstraintsToValidator 1
#include "constraints/DistribMathMLConsistencyConstraintsDeclared.cxx"
}




LIBSBML_CPP_NAMESPACE_END



#endif /* doxygen_ignore */


/** @endcond */

Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@

/** @cond doxygenLibsbmlInternal */

/**
* @file DistribMathMLConsistencyValidator.h
* @brief Definition of DistribMathMLConsistencyValidator.
* @author SBMLTeam
*
* <!--------------------------------------------------------------------------
* This file is part of libSBML. Please visit http://sbml.org for more
* information about SBML, and the latest version of libSBML.
*
* Copyright (C) 2020 jointly by the following organizations:
* 1. California Institute of Technology, Pasadena, CA, USA
* 2. University of Heidelberg, Heidelberg, Germany
* 3. University College London, London, UK
*
* Copyright (C) 2019 jointly by the following organizations:
* 1. California Institute of Technology, Pasadena, CA, USA
* 2. University of Heidelberg, Heidelberg, Germany
*
* Copyright (C) 2013-2018 jointly by the following organizations:
* 1. California Institute of Technology, Pasadena, CA, USA
* 2. EMBL European Bioinformatics Institute (EMBL-EBI), Hinxton, UK
* 3. University of Heidelberg, Heidelberg, Germany
*
* Copyright (C) 2009-2013 jointly by the following organizations:
* 1. California Institute of Technology, Pasadena, CA, USA
* 2. EMBL European Bioinformatics Institute (EMBL-EBI), Hinxton, UK
*
* Copyright (C) 2006-2008 by the California Institute of Technology,
* Pasadena, CA, USA
*
* Copyright (C) 2002-2005 jointly by the following organizations:
* 1. California Institute of Technology, Pasadena, CA, USA
* 2. Japan Science and Technology Agency, Japan
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation. A copy of the license agreement is provided in the
* file named "LICENSE.txt" included with this software distribution and also
* available online as http://sbml.org/software/libsbml/license.html
* ------------------------------------------------------------------------ -->
*/


#ifndef DistribMathMLConsistencyValidator_H__
#define DistribMathMLConsistencyValidator_H__




#ifdef __cplusplus


#include <sbml/packages/distrib/validator/DistribValidator.h>


LIBSBML_CPP_NAMESPACE_BEGIN


class DistribMathMLConsistencyValidator : public DistribValidator
{
public:

DistribMathMLConsistencyValidator()
: DistribValidator( LIBSBML_CAT_MATHML_CONSISTENCY)
{
}


virtual ~DistribMathMLConsistencyValidator()
{
}


/**
* Initializes this Validator with a set of Constraints
*/
virtual void init();


};



LIBSBML_CPP_NAMESPACE_END




#endif /* __cplusplus */




#endif /* !DistribMathMLConsistencyValidator_H__ */



/** @endcond */

2 changes: 2 additions & 0 deletions src/sbml/packages/distrib/validator/DistribSBMLError.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,10 @@ typedef enum
DistribUnknown = 1510100
, DistribNSUndeclared = 1510101
, DistribElementNotInNs = 1510102
, DistribMathnumber = 1510201
, DistribDuplicateComponentId = 1510301
, DistribIdSyntaxRule = 1510302
, DistribUnitsRule = 1510501
, DistribAttributeRequiredMissing = 1520101
, DistribAttributeRequiredMustBeBoolean = 1520102
, DistribAttributeRequiredMustHaveValue = 1520103
Expand Down
23 changes: 23 additions & 0 deletions src/sbml/packages/distrib/validator/DistribSBMLErrorTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,19 @@ static const packageErrorTableEntry distribErrorTable[] =
}
},

// 1510201
{ DistribMathnumber,
"Element not in Distrib namespace",
LIBSBML_CAT_GENERAL_CONSISTENCY,
LIBSBML_SEV_ERROR,
"Wherever they appear in an SBML document, elements and attributes from the "
"Distributions Package must use the "
"'http://www.sbml.org/sbml/level3/version1/distrib/version1' namespace, "
"declaring so either explicitly or implicitly.",
{ "L3V1 Distrib V1 Section 3.1"
}
},

// 1510301
{ DistribDuplicateComponentId,
"Duplicate 'id' attribute value",
Expand All @@ -114,6 +127,16 @@ static const packageErrorTableEntry distribErrorTable[] =
}
},

// 1510501
{ DistribUnitsRule,
"Invalid units",
LIBSBML_CAT_GENERAL_CONSISTENCY,
LIBSBML_SEV_ERROR,
"The unit supplied to an argument must be correct.",
{ "L3V1 Distrib V1 Section"
}
},

// 1520101
{ DistribAttributeRequiredMissing,
"Required distrib:required attribute on <sbml>",
Expand Down
Loading