Search in sources :

Example 1 with SedMLError

use of org.jlibsedml.SedMLError in project vcell by virtualcell.

the class KisaoIDValidator method validate.

/**
 * Validates the syntax of the KiSAO identifier for uniform time course descriptions.
 * @see org.jlibsedml.validation.ISedMLValidator#validate()
 */
public List<SedMLError> validate() {
    List<SedMLError> errs = new ArrayList<SedMLError>();
    for (Simulation sim : sims) {
        String kisaoID = sim.getAlgorithm().getKisaoID();
        if (KisaoOntology.getInstance().getTermById(kisaoID) == null) {
            int line = getLineNumberOfError(SEDMLTags.SIMUL_UTC_KIND, sim);
            errs.add(new SedMLError(line, " The supplied KisaoID [" + kisaoID + "] for simulation [" + sim.getId() + "]  is not a recognized KISAO identifier.\n" + " Identifiers should be the format 'KISAO:0000001' ", SedMLError.ERROR_SEVERITY.WARNING));
        }
    }
    return errs;
}
Also used : SedMLError(org.jlibsedml.SedMLError) Simulation(org.jlibsedml.Simulation) ArrayList(java.util.ArrayList)

Example 2 with SedMLError

use of org.jlibsedml.SedMLError in project vcell by virtualcell.

the class ModelCyclesDetector method validate.

/**
 * @see ISedMLValidator
 */
public List<SedMLError> validate() throws XMLException {
    List<SedMLError> errs = new ArrayList<SedMLError>();
    List<Model> models = sedml.getModels();
    for (Model model : models) {
        String src = model.getSource();
        String id = model.getId();
        Set<String> ids = new HashSet<String>();
        ids.add(id);
        while (sedml.getModelWithId(src) != null) {
            String newID = sedml.getModelWithId(src).getId();
            if (ids.contains(newID)) {
                int line = getLineNumberOfError(SEDMLTags.MODEL_TAG, model);
                errs.add(new SedMLError(line, "Cycles detected in source references for model " + newID + " and " + sedml.getModelWithId(newID).getSource(), ERROR_SEVERITY.ERROR));
                return errs;
            } else {
                ids.add(newID);
                src = sedml.getModelWithId(src).getSource();
            }
        }
    }
    return errs;
}
Also used : SedMLError(org.jlibsedml.SedMLError) ArrayList(java.util.ArrayList) Model(org.jlibsedml.Model) HashSet(java.util.HashSet)

Example 3 with SedMLError

use of org.jlibsedml.SedMLError in project vcell by virtualcell.

the class MathMLValidator method checkMathIds.

private List<SedMLError> checkMathIds() {
    List<SedMLError> errors = new ArrayList<SedMLError>();
    List<? extends IIdentifiable> vars = mathContainer.getListOfVariables();
    List<? extends IIdentifiable> params = mathContainer.getListOfParameters();
    Set<ASTCi> identifiers = mathContainer.getMath().getIdentifiers();
    for (ASTCi var : identifiers) {
        if (!(check(var, vars) || check(var, params))) {
            errors.add(new SedMLError(0, "Math ml in  [" + mathContainer.getId() + "] refers to  a variable not defined in the model", ERROR_SEVERITY.WARNING));
        }
    }
    return errors;
}
Also used : SedMLError(org.jlibsedml.SedMLError) ASTCi(org.jmathml.ASTCi) ArrayList(java.util.ArrayList)

Example 4 with SedMLError

use of org.jlibsedml.SedMLError in project vcell by virtualcell.

the class MathMLValidator method checkFunctions.

private List<SedMLError> checkFunctions() {
    List<SedMLError> errors = new ArrayList<SedMLError>();
    ASTNode node = mathContainer.getMath();
    EvaluationContext cont = new EvaluationContext();
    for (IIdentifiable id : mathContainer.getListOfParameters()) {
        cont.setValueFor(id.getId(), 0.0);
    }
    for (IIdentifiable id : mathContainer.getListOfVariables()) {
        cont.setValueFor(id.getId(), 0.0);
    }
    if (!node.canEvaluate(cont)) {
        errors.add(new SedMLError(0, "This node [" + node.getName() + "] cannot be evaluated", ERROR_SEVERITY.WARNING));
    }
    return errors;
}
Also used : SedMLError(org.jlibsedml.SedMLError) ArrayList(java.util.ArrayList) ASTNode(org.jmathml.ASTNode) IIdentifiable(org.jlibsedml.IIdentifiable) EvaluationContext(org.jmathml.EvaluationContext)

Example 5 with SedMLError

use of org.jlibsedml.SedMLError in project vcell by virtualcell.

the class SEDMLSchemaValidator method validate.

/**
 * @throws XMLException
 * @see  ISedMLValidator
 */
public List<SedMLError> validate() throws XMLException {
    final List<SedMLError> errors = new ArrayList<SedMLError>();
    String xmlAsString = new SEDMLDocument(sedml).writeDocumentToString();
    new SchemaValidatorImpl().validateSedMLString(errors, xmlAsString);
    return errors;
}
Also used : SedMLError(org.jlibsedml.SedMLError) SEDMLDocument(org.jlibsedml.SEDMLDocument) ArrayList(java.util.ArrayList)

Aggregations

ArrayList (java.util.ArrayList)6 SedMLError (org.jlibsedml.SedMLError)6 SEDMLDocument (org.jlibsedml.SEDMLDocument)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 InputStream (java.io.InputStream)1 StringReader (java.io.StringReader)1 HashSet (java.util.HashSet)1 Transformer (javax.xml.transform.Transformer)1 TransformerConfigurationException (javax.xml.transform.TransformerConfigurationException)1 TransformerException (javax.xml.transform.TransformerException)1 TransformerFactory (javax.xml.transform.TransformerFactory)1 StreamResult (javax.xml.transform.stream.StreamResult)1 StreamSource (javax.xml.transform.stream.StreamSource)1 IIdentifiable (org.jlibsedml.IIdentifiable)1 Model (org.jlibsedml.Model)1 Simulation (org.jlibsedml.Simulation)1 ASTCi (org.jmathml.ASTCi)1 ASTNode (org.jmathml.ASTNode)1 EvaluationContext (org.jmathml.EvaluationContext)1