diff --git a/vcell-cli/src/main/java/org/vcell/cli/run/ExecuteImpl.java b/vcell-cli/src/main/java/org/vcell/cli/run/ExecuteImpl.java index d47997553b..7a1544faa6 100644 --- a/vcell-cli/src/main/java/org/vcell/cli/run/ExecuteImpl.java +++ b/vcell-cli/src/main/java/org/vcell/cli/run/ExecuteImpl.java @@ -3,7 +3,7 @@ import cbit.vcell.parser.ExpressionException; import cbit.vcell.solver.ode.ODESolverResultSet; -import org.vcell.cli.CLIRecorder; +import org.vcell.cli.CLIRecordable; import org.vcell.cli.PythonStreamException; import org.vcell.cli.vcml.VCMLHandler; import org.vcell.util.FileUtils; @@ -22,7 +22,7 @@ public class ExecuteImpl { private final static Logger logger = LogManager.getLogger(ExecuteImpl.class); - public static void batchMode(File dirOfArchivesToProcess, File outputDir, CLIRecorder cliLogger, + public static void batchMode(File dirOfArchivesToProcess, File outputDir, CLIRecordable cliLogger, boolean bKeepTempFiles, boolean bExactMatchOnly, boolean bSmallMeshOverride) { FilenameFilter filter = (f, name) -> name.endsWith(".omex") || name.endsWith(".vcml"); File[] inputFiles = dirOfArchivesToProcess.listFiles(filter); @@ -67,7 +67,7 @@ public static void batchMode(File dirOfArchivesToProcess, File outputDir, CLIRec } } - public static void singleMode(File inputFile, File rootOutputDir, CLIRecorder cliLogger, + public static void singleMode(File inputFile, File rootOutputDir, CLIRecordable cliLogger, boolean bKeepTempFiles, boolean bExactMatchOnly, boolean bEncapsulateOutput, boolean bSmallMeshOverride) throws Exception { // Build statuses String bioModelBaseName = FileUtils.getBaseName(inputFile.getName()); // bioModelBaseName = input file without the path @@ -81,7 +81,7 @@ public static void singleMode(File inputFile, File rootOutputDir, CLIRecorder cl ExecuteImpl.singleExecOmex(inputFile, rootOutputDir, cliLogger, bKeepTempFiles, bExactMatchOnly, bEncapsulateOutput, bSmallMeshOverride); } - public static void singleMode(File inputFile, File outputDir, CLIRecorder cliLogger) throws Exception { + public static void singleMode(File inputFile, File outputDir, CLIRecordable cliLogger) throws Exception { final boolean bKeepTempFiles = false; final boolean bExactMatchOnly = false; final boolean bEncapsulateOutput = false; @@ -91,7 +91,7 @@ public static void singleMode(File inputFile, File outputDir, CLIRecorder cliLog } @Deprecated - public static void singleExecVcml(File vcmlFile, File outputDir, CLIRecorder cliLogger) { + public static void singleExecVcml(File vcmlFile, File outputDir, CLIRecordable cliLogger) { logger.warn("Using deprecated function to execute vcml"); VCMLHandler.outputDir = outputDir.getAbsolutePath(); logger.debug("Executing VCML file " + vcmlFile); @@ -143,7 +143,7 @@ public static void singleExecVcml(File vcmlFile, File outputDir, CLIRecorder cli } } - private static void singleExecOmex(File inputFile, File rootOutputDir, CLIRecorder cliRecorder, + private static void singleExecOmex(File inputFile, File rootOutputDir, CLIRecordable cliRecorder, boolean bKeepTempFiles, boolean bExactMatchOnly, boolean bEncapsulateOutput, boolean bSmallMeshOverride) throws ExecutionException, PythonStreamException, IOException, InterruptedException { ExecutionJob requestedExecution = new ExecutionJob(inputFile, rootOutputDir, cliRecorder, diff --git a/vcell-cli/src/main/java/org/vcell/cli/run/ExecutionException.java b/vcell-cli/src/main/java/org/vcell/cli/run/ExecutionException.java index ad211fba55..cd61b9a10d 100644 --- a/vcell-cli/src/main/java/org/vcell/cli/run/ExecutionException.java +++ b/vcell-cli/src/main/java/org/vcell/cli/run/ExecutionException.java @@ -1,10 +1,6 @@ package org.vcell.cli.run; public class ExecutionException extends Exception { - public ExecutionException(){ - super(); - } - public ExecutionException(String message){ super(message); } diff --git a/vcell-cli/src/main/java/org/vcell/cli/run/ExecutionJob.java b/vcell-cli/src/main/java/org/vcell/cli/run/ExecutionJob.java index 22b1b31966..0819c4a298 100644 --- a/vcell-cli/src/main/java/org/vcell/cli/run/ExecutionJob.java +++ b/vcell-cli/src/main/java/org/vcell/cli/run/ExecutionJob.java @@ -1,6 +1,6 @@ package org.vcell.cli.run; -import org.vcell.cli.CLIRecorder; +import org.vcell.cli.CLIRecordable; import org.vcell.cli.PythonStreamException; import org.vcell.util.FileUtils; @@ -32,7 +32,7 @@ public class ExecutionJob { private Path sedmlPath2d3d; private File inputFile; - private CLIRecorder cliRecorder; + private CLIRecordable cliRecorder; /** * Constructor to provide all necessary info. @@ -45,7 +45,7 @@ public class ExecutionJob { * @param bEncapsulateOutput whether to provide a sub-folder for outputs (needed for batch jobs) * @param bSmallMeshOverride whether to use small meshes or standard meshes. */ - public ExecutionJob(File inputFile, File rootOutputDir, CLIRecorder cliRecorder, + public ExecutionJob(File inputFile, File rootOutputDir, CLIRecordable cliRecorder, boolean bKeepTempFiles, boolean bExactMatchOnly, boolean bEncapsulateOutput, boolean bSmallMeshOverride){ this(); this.inputFile = inputFile; @@ -139,8 +139,9 @@ public void executeArchive() throws InterruptedException, PythonStreamException, logger.error("Python-processing encountered fatal error. Execution is unable to properly continue.", e); throw e; } catch(InterruptedException|IOException e){ - logger.error("System IO encountered a fatal error"); - throw new ExecutionException(); + String message = "System IO encountered a fatal error"; + logger.error(message, e); + throw new ExecutionException(message, e); } } diff --git a/vcell-cli/src/main/java/org/vcell/cli/run/SedmlJob.java b/vcell-cli/src/main/java/org/vcell/cli/run/SedmlJob.java index e29d4ba273..4389d5be30 100644 --- a/vcell-cli/src/main/java/org/vcell/cli/run/SedmlJob.java +++ b/vcell-cli/src/main/java/org/vcell/cli/run/SedmlJob.java @@ -1,14 +1,15 @@ package org.vcell.cli.run; +import ncsa.hdf.hdf5lib.exceptions.HDF5Exception; + import cbit.vcell.parser.ExpressionException; import cbit.vcell.resource.OperatingSystemInfo; import cbit.vcell.xml.ExternalDocInfo; -import ncsa.hdf.hdf5lib.exceptions.HDF5Exception; - -import org.jlibsedml.*; - import org.apache.commons.io.FilenameUtils; -import org.vcell.cli.CLIRecorder; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.jlibsedml.*; +import org.vcell.cli.CLIRecordable; import org.vcell.cli.PythonStreamException; import org.vcell.cli.run.hdf5.Hdf5DatasetWrapper; import org.vcell.cli.run.hdf5.Hdf5FileWrapper; @@ -17,13 +18,10 @@ import org.vcell.util.FileUtils; import org.vcell.util.GenericExtensionFilter; -import org.apache.logging.log4j.Logger; -import org.apache.logging.log4j.LogManager; - import java.io.File; -import java.io.IOException; import java.io.FileInputStream; import java.io.FileNotFoundException; +import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; @@ -33,13 +31,13 @@ public class SedmlJob { private boolean somethingFailed, hasScans, hasOverrides, bKeepTempFiles, bExactMatchOnly, bSmallMeshOverride; - private String sedmlLocation, bioModelBaseName, resultsDirPath, logDocumentMessage, logDocumentError, sedmlName; + private String sedmlLocation, bioModelBaseName, resultsDirPath, logDocumentMessage, logDocumentError, sedmlName, problemsOccured; private StringBuilder logOmexMessage; private SedmlStatistics docStatistics; private SedML sedml; private File masterOmexArchive, rootOutputDir, plotsDirectory, plotFile; private List outputs; - private CLIRecorder cliRecorder; + private CLIRecordable cliRecorder; private File outDirForCurrentSedml; private final static Logger logger = LogManager.getLogger(SedmlJob.class); @@ -60,7 +58,7 @@ public class SedmlJob { * @param logOmexMessage a string-builder to contain progress updates of omex execution */ public SedmlJob(String sedmlLocation, OmexHandler omexHandler, File masterOmexArchive, File rootOutputDir, String resultsDirPath, String sedmlPath2d3dString, - CLIRecorder cliRecorder, boolean bKeepTempFiles, boolean bExactMatchOnly, boolean bSmallMeshOverride, StringBuilder logOmexMessage){ + CLIRecordable cliRecorder, boolean bKeepTempFiles, boolean bExactMatchOnly, boolean bSmallMeshOverride, StringBuilder logOmexMessage){ this.somethingFailed = false; this.masterOmexArchive = masterOmexArchive; this.sedmlLocation = sedmlLocation; @@ -77,6 +75,7 @@ public SedmlJob(String sedmlLocation, OmexHandler omexHandler, File masterOmexAr this.cliRecorder = cliRecorder; this.logDocumentMessage = "Initializing SED-ML document... "; this.logDocumentError = ""; + this.problemsOccured = ""; } @@ -269,13 +268,13 @@ private void processOutputs(SolverHandler solverHandler) throws PythonStreamExce logDocumentError += e.getMessage(); this.reportProblem(e); org.apache.commons.io.FileUtils.deleteDirectory(this.plotsDirectory); // removing temp path generated from python - throw new ExecutionException(); + throw new ExecutionException("error while processing outputs: "+e.getMessage(), e); } } private boolean evalulateResults() throws PythonStreamException, InterruptedException, IOException { if (this.somethingFailed) { // something went wrong but no exception was fired - Exception e = new RuntimeException("Failure executing the sed document. "); + Exception e = new RuntimeException("Failure executing the sed document:\n" + this.problemsOccured); logDocumentError += e.getMessage(); this.reportProblem(e); org.apache.commons.io.FileUtils.deleteDirectory(this.plotsDirectory); // removing temp path generated from python @@ -384,10 +383,11 @@ private static Path getRelativePath(String[] tokenizedPath){ return null; } - private static boolean somethingDidFail(){ + private boolean somethingDidFail(){ StackTraceElement elem = new Exception().getStackTrace()[1]; - - logger.debug(String.format("Something failed in %s @ line %d", elem.getClassName(), elem.getLineNumber())); + String failString = String.format("Something failed in %s @ line %d", elem.getClassName(), elem.getLineNumber()); + this.problemsOccured += failString + '\n'; + logger.debug(failString); return true; } diff --git a/vcell-cli/src/main/java/org/vcell/cli/run/SolverHandler.java b/vcell-cli/src/main/java/org/vcell/cli/run/SolverHandler.java index 295cd89959..5864955ab3 100644 --- a/vcell-cli/src/main/java/org/vcell/cli/run/SolverHandler.java +++ b/vcell-cli/src/main/java/org/vcell/cli/run/SolverHandler.java @@ -37,7 +37,7 @@ import org.jlibsedml.XPathTarget; import org.jlibsedml.modelsupport.SBMLSupport; import org.jmathml.ASTNode; -import org.vcell.cli.CLIRecorder; +import org.vcell.cli.CLIRecordable; import org.vcell.sbml.vcell.SBMLImportException; import org.vcell.sbml.vcell.SBMLImporter; import org.vcell.util.ISize; @@ -281,7 +281,7 @@ public void initialize(List bioModelList, SedML sedml) throws Expressi System.out.println("topTaskToBaseTask: " + topTaskToBaseTask.size()); } - public void simulateAllTasks(ExternalDocInfo externalDocInfo, SedML sedml, CLIRecorder cliLogger, + public void simulateAllTasks(ExternalDocInfo externalDocInfo, SedML sedml, CLIRecordable cliLogger, File outputDirForSedml, String outDir, String outputBaseDir, String sedmlLocation, boolean keepTempFiles, boolean exactMatchOnly, boolean bSmallMeshOverride) throws Exception { // create the VCDocument(s) (bioModel(s) + application(s) + simulation(s)), do sanity checks diff --git a/vcell-cli/src/test/java/org/vcell/cli/run/BSTS_OmexExecTest.java b/vcell-cli/src/test/java/org/vcell/cli/run/BSTS_OmexExecTest.java new file mode 100644 index 0000000000..ec80eeeda7 --- /dev/null +++ b/vcell-cli/src/test/java/org/vcell/cli/run/BSTS_OmexExecTest.java @@ -0,0 +1,238 @@ +package org.vcell.cli.run; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.nio.file.FileAlreadyExistsException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.function.Predicate; +import java.util.stream.Collectors; + +import org.apache.commons.io.FileUtils; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.experimental.categories.Category; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import org.vcell.cli.CLIPythonManager; +import org.vcell.cli.CLIRecordable; +import org.vcell.test.SEDML_SBML_IT; +import org.vcell.util.VCellUtilityHub; + +import cbit.vcell.mongodb.VCMongoMessage; +import cbit.vcell.resource.NativeLib; +import cbit.vcell.resource.PropertyLoader; + +@RunWith(Parameterized.class) +@Category({SEDML_SBML_IT.class}) +public class BSTS_OmexExecTest { + private final String testCaseFilename; + + public BSTS_OmexExecTest(String testCase){ + this.testCaseFilename = testCase; + } + + @BeforeClass + public static void setup() throws IOException { + System.setProperty(PropertyLoader.installationRoot, new File("..").getAbsolutePath()); + NativeLib.HDF5.load(); + NativeLib.combinej.load(); + VCellUtilityHub.startup(VCellUtilityHub.MODE.CLI); + + System.setProperty(PropertyLoader.cliWorkingDir, new File("../vcell-cli-utils").getAbsolutePath()); + VCMongoMessage.enabled = false; + + CLIPythonManager.getInstance().instantiatePythonProcess(); + } + + @BeforeClass + public static void teardown() throws Exception { + CLIPythonManager.getInstance().closePythonProcess(); + VCellUtilityHub.shutdown(); + } + + public enum FAULT { + EXPRESSIONS_DIFFERENT, + EXPRESSION_BINDING, + MATH_GENERATION_FAILURE, + MATHOVERRIDES_INVALID, + MATHOVERRIDES_SurfToVol, + MATHOVERRIDES_A_FUNCTION, + UNITS_EXCEPTION, + TOO_SLOW, + GEOMETRYSPEC_DIFFERENT, + NULL_POINTER_EXCEPTION, + UNKNOWN_IDENTIFIER, + SBML_IMPORT_FAILURE, + DIVIDE_BY_ZERO, + ARRAY_INDEX_OUT_OF_BOUNDS, + UNSUPPORTED_NONSPATIAL_STOCH_HISTOGRAM, + SEDML_UNSUPPORTED_ENTITY, + SEDML_DIFF_NUMBER_OF_BIOMODELS, + SEDML_NO_MODELS_IN_OMEX, + SEDML_ERROR_CONSTRUCTING_SIMCONTEXT, + SEDML_NONSPATIAL_STOCH_HISTOGRAM, + SEDML_MATH_OVERRIDE_NOT_EQUIVALENT, + SEDML_MATH_OVERRIDE_NAMES_DIFFERENT, + SEDML_SIMCONTEXT_NOT_FOUND_BY_NAME, + SEDML_SIMULATION_NOT_FOUND_BY_NAME, + SEDML_SEQUENTIAL_REPEATED_TASKS, + + SEDML_UNSUPPORTED_MODEL_REFERENCE, // Model refers to either a non-existent model (invalid SED-ML) or to another model with changes (not supported yet) + + HDF5_FILE_ALREADY_EXISTS, // reports.h5 file already exists, so action is blocked. Fixed in branch to be merged in. + OPERATION_NOT_SUPPORTED, // VCell simply doesn't have the necessary features to run this archive. + + UNCATETORIZED_FAULT + }; + + static Set slowModels(){ + HashSet slowSet = new HashSet<>(); + slowSet.add("synths/sedml/SimulatorSupportsAddReplaceRemoveModelElementChanges/3.execute-should-fail.omex"); + slowSet.add("synths/sedml/SimulatorSupportsAddReplaceRemoveModelElementChanges/1.execute-should-fail.omex"); + slowSet.add("synths/sedml/SimulatorSupportsModelAttributeChanges/1.execute-should-fail.omex"); + slowSet.add("sbml-core/Vilar-PNAS-2002-minimal-circardian-clock-discrete-NRM.omex"); + slowSet.add("sbml-core/Vilar-PNAS-2002-minimal-circardian-clock-discrete-SSA.omex"); + slowSet.add("sbml-core/Vilar-PNAS-2002-minimal-circardian-clock.omex"); + slowSet.add("sbml-core/Vilar-PNAS-2002-minimal-circardian-clock-continuous.omex"); + slowSet.add("synths/sedml/SimulatorCanResolveModelSourcesDefinedByUriFragments/1.execution-should-succeed.omex"); + slowSet.add("synths/sedml/SimulatorCanResolveModelSourcesDefinedByUriFragmentsAndInheritChanges/1.execution-should-succeed.omex"); + return slowSet; + } + + // We have blacklisted these next two out because we do not support sequential repeated tasks, + // ...but by design we permit this kind of error to be a non-obstructive side effect. + static Set sequentialRepeatedTasks(){ + HashSet srtSet = new HashSet<>(); + srtSet.add("synths/sedml/SimulatorSupportsRepeatedTasksWithSubTasksOfMixedTypes/1.execution-should-succeed.omex"); + srtSet.add("synths/sedml/SimulatorSupportsRepeatedTasksWithSubTasksOfMixedTypes/2.execution-should-succeed.omex"); + return srtSet; + } + + static Map knownFaults() { + HashMap faults = new HashMap<>(); +// faults.put("sbml-core/Vilar-PNAS-2002-minimal-circardian-clock-discrete-NRM.omex", FAULT.SEDML_UNSUPPORTED_MODEL_REFERENCE); // Model refers to either a non-existent model (invalid SED-ML) or to another model with changes (not supported yet) +// faults.put("sbml-core/Vilar-PNAS-2002-minimal-circardian-clock-discrete-SSA.omex", FAULT.SEDML_UNSUPPORTED_MODEL_REFERENCE); // Model refers to either a non-existent model (invalid SED-ML) or to another model with changes (not supported yet) +// faults.put("sbml-core/Vilar-PNAS-2002-minimal-circardian-clock.omex", FAULT.SEDML_UNSUPPORTED_MODEL_REFERENCE); // Model refers to either a non-existent model (invalid SED-ML) or to another model with changes (not supported yet) +// faults.put("sbml-core/Vilar-PNAS-2002-minimal-circardian-clock-continuous.omex", FAULT.SEDML_UNSUPPORTED_MODEL_REFERENCE); // Model refers to either a non-existent model (invalid SED-ML) or to another model with changes (not supported yet) +// faults.put("synths/sedml/SimulatorSupportsDataSetsWithDifferentShapes/1.execution-should-succeed.omex", FAULT.UNCATETORIZED_FAULT); // java.lang.ArrayIndexOutOfBoundsException at org.vcell.cli.run.hdf5.Hdf5DataPreparer.prepareNonspacialData(Hdf5DataPreparer.java:140) +// faults.put("synths/sedml/SimulatorSupportsRepeatedTasksWithSubTasksOfMixedTypes/1.execution-should-succeed.omex", FAULT.UNCATETORIZED_FAULT); // ERROR (SEDMLImporter.java:589) - sequential RepeatedTask not yet supported, task __repeated_task_1 is being skipped []{} +// faults.put("synths/sedml/SimulatorSupportsRepeatedTasksWithSubTasksOfMixedTypes/2.execution-should-succeed.omex", FAULT.UNCATETORIZED_FAULT); // ERROR (SEDMLImporter.java:589) - sequential RepeatedTask not yet supported, task __repeated_task_1 is being skipped []{} + faults.put("synths/combine_archive/WhenACombineArchiveHasNoMasterFileSimulatorExecutesAllSedDocuments/1.execution-should-succeed.omex", FAULT.HDF5_FILE_ALREADY_EXISTS); + faults.put("synths/combine_archive/CombineArchiveHasSedDocumentsWithSameNamesInDifferentInNestedDirectories/1.execution-should-succeed.omex", FAULT.HDF5_FILE_ALREADY_EXISTS); + faults.put("synths/sedml/SimulatorSupportsDataSetsWithDifferentShapes/1.execution-should-succeed.omex", FAULT.ARRAY_INDEX_OUT_OF_BOUNDS); + faults.put("synths/sedml/SimulatorSupportsRepeatedTasksWithSubTasksOfMixedTypes/1.execution-should-succeed.omex", FAULT.SEDML_SEQUENTIAL_REPEATED_TASKS); + faults.put("synths/sedml/SimulatorSupportsRepeatedTasksWithSubTasksOfMixedTypes/2.execution-should-succeed.omex", FAULT.SEDML_SEQUENTIAL_REPEATED_TASKS); + return faults; + } + + @Parameterized.Parameters + public static Collection testCases() { + Set modelsToFilter = slowModels(); + + Predicate filter = (t) -> !modelsToFilter.contains(t); + List testCases = Arrays.stream(BSTS_TestSuiteFiles.getBSTSTestCases()).filter(filter).collect(Collectors.toList()); + return testCases; + } + + @Test + public void testSedmlExecutions() throws Exception { + FAULT knownFault = knownFaults().get(testCaseFilename); + try { + System.out.println("running test " + testCaseFilename); + final boolean[] bFailed = new boolean[1]; + final String[] errorMessage = new String[1]; + + Path outdirPath = Files.createTempDirectory("BSTS_OmexExecTest"); + CLIRecordable cliRecorder = new CLIRecordable() { + @Override + public void writeDetailedErrorList(String message) { + System.err.println("writeDetailedErrorList(): " + message); + bFailed[0] = true; + errorMessage[0] = message; + } + @Override + public void writeFullSuccessList(String message) { + System.out.println("writeFullSuccessList(): " + message); + } + @Override + public void writeErrorList(String message) { + System.err.println("writeErrorList(): " + message); + bFailed[0] = true; + errorMessage[0] = message; + } + @Override + public void writeDetailedResultList(String message) { + System.out.println("writeDetailedResultList(): " + message); + } + @Override + public void writeSpatialList(String message) { + System.out.println("writeSpatialList(): " + message); + } + @Override + public void writeImportErrorList(String message) { + System.err.println("writeImportErrorList(): " + message); + bFailed[0] = true; + errorMessage[0] = message; + } + }; + InputStream omexInputStream = BSTS_TestSuiteFiles.getBSTSTestCase(testCaseFilename); + Path omexFile = Files.createTempFile("BSTS_OmexFile_", "omex"); + FileUtils.copyInputStreamToFile(omexInputStream, omexFile.toFile()); + ExecuteImpl.singleMode(omexFile.toFile(), outdirPath.toFile(), cliRecorder); + String errMessage = (errorMessage[0] != null) ? errorMessage[0].replace("\n", " | ") : ""; + Assert.assertFalse("failure: '" + errMessage + "'", bFailed[0]); + if (knownFault != null){ + throw new RuntimeException("test case passed, but expected "+knownFault.name()+", remove "+testCaseFilename+" from known faults"); + } + Assert.assertNull("file " + testCaseFilename + " passed, but knownFault was set", knownFault); + + } catch (Exception | AssertionError e){ + FAULT fault = this.determineFault(e); + if (knownFault == fault) { + System.err.println("Expected error: " + e.getMessage()); + return; + } + + System.err.println("add FAULT." + fault.name() + " to " + testCaseFilename); + throw e; + } + } + + private FAULT determineFault(Throwable caughtException){ // Throwable because Assertion Error + FAULT determinedFault = FAULT.UNCATETORIZED_FAULT; + String errorMessage = caughtException.getMessage(); + if (errorMessage == null) errorMessage = ""; // Prevent nullptr exception + + if (errorMessage.contains("refers to either a non-existent model")) { //"refers to either a non-existent model (invalid SED-ML) or to another model with changes (not supported yet)" + determinedFault = FAULT.SEDML_UNSUPPORTED_MODEL_REFERENCE; + } else if (errorMessage.contains("System IO encountered a fatal error")){ + Throwable subException = caughtException.getCause(); + //String subMessage = (subException == null) ? "" : subException.getMessage(); + if (subException instanceof FileAlreadyExistsException){ + determinedFault = FAULT.HDF5_FILE_ALREADY_EXISTS; + } + } else if (errorMessage.contains("error while processing outputs: null")){ + Throwable subException = caughtException.getCause(); + if (subException instanceof ArrayIndexOutOfBoundsException){ + determinedFault = FAULT.ARRAY_INDEX_OUT_OF_BOUNDS; + } + } else if (errorMessage.contains("Something failed in org.vcell.cli.run.SedmlJob")){ + if (BSTS_OmexExecTest.sequentialRepeatedTasks().contains(this.testCaseFilename)){ + determinedFault = FAULT.SEDML_SEQUENTIAL_REPEATED_TASKS; + } + } + + return determinedFault; + } + +} diff --git a/vcell-cli/src/test/java/org/vcell/cli/run/BSTS_TestSuiteFiles.java b/vcell-cli/src/test/java/org/vcell/cli/run/BSTS_TestSuiteFiles.java new file mode 100644 index 0000000000..c52e4194e0 --- /dev/null +++ b/vcell-cli/src/test/java/org/vcell/cli/run/BSTS_TestSuiteFiles.java @@ -0,0 +1,115 @@ +package org.vcell.cli.run; + +import org.junit.Assert; +import org.junit.Test; +import org.junit.experimental.categories.Category; +import org.vcell.test.Fast; + +import java.io.FileNotFoundException; +import java.io.InputStream; +import java.util.Arrays; +import java.util.function.Predicate; + + +@Category(Fast.class) +public class BSTS_TestSuiteFiles { + + private final static String[] allTestFiles = new String[]{ + "sbml-core/Caravagna-J-Theor-Biol-2010-tumor-suppressive-oscillations.omex", + "sbml-core/Parmar-BMC-Syst-Biol-2017-iron-distribution.omex", + "sbml-core/Vilar-PNAS-2002-minimal-circardian-clock-discrete-NRM.omex", + "sbml-core/Ciliberto-J-Cell-Biol-2003-morphogenesis-checkpoint-Fehlberg.omex", + "sbml-core/Szymanska-J-Theor-Biol-2009-HSP-synthesis.omex", + "sbml-core/Vilar-PNAS-2002-minimal-circardian-clock-discrete-SSA.omex", + "sbml-core/Ciliberto-J-Cell-Biol-2003-morphogenesis-checkpoint-continuous.omex", + "sbml-core/Tomida-EMBO-J-2003-NFAT-translocation.omex", + "sbml-core/Vilar-PNAS-2002-minimal-circardian-clock.omex", + "sbml-core/Edelstein-Biol-Cybern-1996-Nicotinic-excitation.omex", + "sbml-core/Varusai-Sci-Rep-2018-mTOR-signaling-LSODA-LSODAR-SBML.omex", + "sbml-core/Elowitz-Nature-2000-Repressilator.omex", + "sbml-core/Vilar-PNAS-2002-minimal-circardian-clock-continuous.omex", + "synths/docker_image/SingularityImageExecutesSimulationsSuccessfully/1.execution-should-succeed.omex", + "synths/results_report/SimulatorGeneratesReportsOfSimulationResults/1.execution-should-succeed.omex", + "synths/combine_archive/WhenACombineArchiveHasAMasterFileSimulatorOnlyExecutesThisFile/1.execution-should-succeed.omex", + "synths/combine_archive/WhenACombineArchiveHasNoMasterFileSimulatorExecutesAllSedDocuments/1.execution-should-succeed.omex", + "synths/combine_archive/CombineArchiveHasSedDocumentsWithSameNamesInDifferentInNestedDirectories/1.execution-should-succeed.omex", + "synths/combine_archive/CombineArchiveHasSedDocumentsInNestedDirectories/1.execution-should-succeed.omex", + "synths/log/SimulatorReportsTheStatusOfTheExecutionOfSedDocuments/1.execution-should-succeed.omex", + "synths/log/SimulatorReportsTheStatusOfTheExecutionOfSedOutputs/1.execution-should-succeed.omex", + "synths/log/SimulatorReportsTheStatusOfTheExecutionOfCombineArchives/1.execution-should-succeed.omex", + "synths/log/SimulatorReportsTheStatusOfTheExecutionOfSedTasks/1.execution-should-succeed.omex", + "synths/sedml/SimulatorSupportsAddReplaceRemoveModelElementChanges/3.execute-should-fail.omex", + "synths/sedml/SimulatorSupportsAddReplaceRemoveModelElementChanges/1.execute-should-fail.omex", + "synths/sedml/SimulatorSupportsAddReplaceRemoveModelElementChanges/2.execution-should-succeed.omex", + "synths/sedml/SimulatorSupportsRepeatedTasksWithMultipleSubTasks/1.execution-should-succeed.omex", + "synths/sedml/SimulatorProducesMultiplePlots/1.execution-should-succeed.omex", + "synths/sedml/SimulatorProducesMultiplePlots/2.execution-should-succeed.omex", + "synths/sedml/SimulatorSupportsRepeatedTasksWithChanges/1.execute-should-fail.omex", + "synths/sedml/SimulatorSupportsRepeatedTasksWithChanges/2.execution-should-succeed.omex", + "synths/sedml/SimulatorSupportsDataGeneratorsWithDifferentShapes/1.execution-should-succeed.omex", + "synths/sedml/SimulatorSupportsRepeatedTasksWithFunctionalRanges/1.execution-should-succeed.omex", + "synths/sedml/SimulatorSupportsDataSetsWithDifferentShapes/1.execution-should-succeed.omex", + "synths/sedml/SimulatorSupportsRepeatedTasksWithVectorRanges/1.execution-should-succeed.omex", + "synths/sedml/SimulatorSupportsComputeModelChanges/1.execute-should-fail.omex", + "synths/sedml/SimulatorSupportsComputeModelChanges/2.execution-should-succeed.omex", + "synths/sedml/SimulatorSupportsMultipleReportsPerSedDocument/1.execution-should-succeed.omex", + "synths/sedml/SimulatorProducesLogarithmic2DPlots/1.execution-should-succeed.omex", + "synths/sedml/SimulatorProducesLogarithmic2DPlots/2.execution-should-succeed.omex", + "synths/sedml/SimulatorCanResolveModelSourcesDefinedByUriFragmentsAndInheritChanges/1.execution-should-succeed.omex", + "synths/sedml/SimulatorSupportsModelsSimulationsTasksDataGeneratorsAndReports/1.execution-should-succeed.omex", + "synths/sedml/SimulatorSupportsModelAttributeChanges/1.execute-should-fail.omex", + "synths/sedml/SimulatorSupportsModelAttributeChanges/2.execution-should-succeed.omex", + "synths/sedml/SimulatorSupportsRepeatedTasksWithNestedRepeatedTasks/1.execution-should-succeed.omex", + "synths/sedml/SimulatorSupportsRepeatedTasksWithLogarithmicUniformRanges/1.execution-should-succeed.omex", + "synths/sedml/SimulatorSupportsRepeatedTasksWithLinearUniformRanges/1.execution-should-succeed.omex", + "synths/sedml/SimulatorSupportsUniformTimeCoursesWithNonZeroInitialTimes/1.execution-should-succeed.omex", + "synths/sedml/SimulatorSupportsMultipleTasksPerSedDocument/1.execution-should-succeed.omex", + "synths/sedml/SimulatorSupportsAlgorithmParameters/1.execution-should-succeed.omex", + "synths/sedml/SimulatorSupportsUniformTimeCoursesWithNonZeroOutputStartTimes/1.execution-should-succeed.omex", + "synths/sedml/SimulatorSupportsRepeatedTasksWithFunctionalRangeVariables/1.execute-should-fail.omex", + "synths/sedml/SimulatorSupportsRepeatedTasksWithFunctionalRangeVariables/2.execution-should-succeed.omex", + "synths/sedml/SimulatorProducesLinear2DPlots/1.execution-should-succeed.omex", + "synths/sedml/SimulatorProducesLinear2DPlots/2.execution-should-succeed.omex", + "synths/sedml/SimulatorSupportsRepeatedTasksWithNestedFunctionalRanges/1.execution-should-succeed.omex", + "synths/sedml/SimulatorSupportsRepeatedTasksWithSubTasksOfMixedTypes/1.execution-should-succeed.omex", + "synths/sedml/SimulatorSupportsRepeatedTasksWithSubTasksOfMixedTypes/2.execution-should-succeed.omex", + "synths/sedml/SimulatorCanResolveModelSourcesDefinedByUriFragments/1.execution-should-succeed.omex", + "synths/sedml/SimulatorSupportsSubstitutingAlgorithms/3.execute-should-fail.omex", + "synths/sedml/SimulatorSupportsSubstitutingAlgorithms/4.execution-should-succeed.omex", + "synths/sedml/SimulatorSupportsSubstitutingAlgorithms/1.execute-should-fail.omex", + "synths/sedml/SimulatorSupportsSubstitutingAlgorithms/2.execution-should-succeed.omex" + }; + + public static String[] getBSTSTestCases() { + Predicate testFilter = t -> true; + + return Arrays.stream(allTestFiles).filter(testFilter).toArray(String[]::new); + } + + public static InputStream getBSTSTestCase(String testFile) { + if (!Arrays.stream(allTestFiles).anyMatch(file -> file.equals(testFile))) { + throw new RuntimeException("file not found for VCell Published Test Suite test "+testFile); + } + try { + return getFileFromResourceAsStream(testFile); + }catch (FileNotFoundException e){ + throw new RuntimeException("failed to find test case file '"+testFile+"': " + e.getMessage(), e); + } + } + + private static InputStream getFileFromResourceAsStream(String fileName) throws FileNotFoundException { + InputStream inputStream = BSTS_TestSuiteFiles.class.getResourceAsStream("/bsts-omex/"+fileName); + if (inputStream == null) { + throw new FileNotFoundException("file not found! " + fileName); + } else { + return inputStream; + } + } + + @Test + public void test_read_BSTS_omex_file() { + InputStream inputStream = getBSTSTestCase(allTestFiles[0]); + Assert.assertTrue(inputStream != null); + } + +} diff --git a/vcell-cli/src/test/resources/bsts-omex/sbml-core/Caravagna-J-Theor-Biol-2010-tumor-suppressive-oscillations.omex b/vcell-cli/src/test/resources/bsts-omex/sbml-core/Caravagna-J-Theor-Biol-2010-tumor-suppressive-oscillations.omex new file mode 100644 index 0000000000..8f807fa286 Binary files /dev/null and b/vcell-cli/src/test/resources/bsts-omex/sbml-core/Caravagna-J-Theor-Biol-2010-tumor-suppressive-oscillations.omex differ diff --git a/vcell-cli/src/test/resources/bsts-omex/sbml-core/Ciliberto-J-Cell-Biol-2003-morphogenesis-checkpoint-Fehlberg.omex b/vcell-cli/src/test/resources/bsts-omex/sbml-core/Ciliberto-J-Cell-Biol-2003-morphogenesis-checkpoint-Fehlberg.omex new file mode 100644 index 0000000000..6af08c0ba9 Binary files /dev/null and b/vcell-cli/src/test/resources/bsts-omex/sbml-core/Ciliberto-J-Cell-Biol-2003-morphogenesis-checkpoint-Fehlberg.omex differ diff --git a/vcell-cli/src/test/resources/bsts-omex/sbml-core/Ciliberto-J-Cell-Biol-2003-morphogenesis-checkpoint-continuous.omex b/vcell-cli/src/test/resources/bsts-omex/sbml-core/Ciliberto-J-Cell-Biol-2003-morphogenesis-checkpoint-continuous.omex new file mode 100644 index 0000000000..13316917c1 Binary files /dev/null and b/vcell-cli/src/test/resources/bsts-omex/sbml-core/Ciliberto-J-Cell-Biol-2003-morphogenesis-checkpoint-continuous.omex differ diff --git a/vcell-cli/src/test/resources/bsts-omex/sbml-core/Edelstein-Biol-Cybern-1996-Nicotinic-excitation.omex b/vcell-cli/src/test/resources/bsts-omex/sbml-core/Edelstein-Biol-Cybern-1996-Nicotinic-excitation.omex new file mode 100644 index 0000000000..ba103bb092 Binary files /dev/null and b/vcell-cli/src/test/resources/bsts-omex/sbml-core/Edelstein-Biol-Cybern-1996-Nicotinic-excitation.omex differ diff --git a/vcell-cli/src/test/resources/bsts-omex/sbml-core/Elowitz-Nature-2000-Repressilator.omex b/vcell-cli/src/test/resources/bsts-omex/sbml-core/Elowitz-Nature-2000-Repressilator.omex new file mode 100644 index 0000000000..ab3e3e033b Binary files /dev/null and b/vcell-cli/src/test/resources/bsts-omex/sbml-core/Elowitz-Nature-2000-Repressilator.omex differ diff --git a/vcell-cli/src/test/resources/bsts-omex/sbml-core/Parmar-BMC-Syst-Biol-2017-iron-distribution.omex b/vcell-cli/src/test/resources/bsts-omex/sbml-core/Parmar-BMC-Syst-Biol-2017-iron-distribution.omex new file mode 100644 index 0000000000..52d779df3c Binary files /dev/null and b/vcell-cli/src/test/resources/bsts-omex/sbml-core/Parmar-BMC-Syst-Biol-2017-iron-distribution.omex differ diff --git a/vcell-cli/src/test/resources/bsts-omex/sbml-core/Szymanska-J-Theor-Biol-2009-HSP-synthesis.omex b/vcell-cli/src/test/resources/bsts-omex/sbml-core/Szymanska-J-Theor-Biol-2009-HSP-synthesis.omex new file mode 100644 index 0000000000..aa3004c6df Binary files /dev/null and b/vcell-cli/src/test/resources/bsts-omex/sbml-core/Szymanska-J-Theor-Biol-2009-HSP-synthesis.omex differ diff --git a/vcell-cli/src/test/resources/bsts-omex/sbml-core/Tomida-EMBO-J-2003-NFAT-translocation.omex b/vcell-cli/src/test/resources/bsts-omex/sbml-core/Tomida-EMBO-J-2003-NFAT-translocation.omex new file mode 100644 index 0000000000..50132be47e Binary files /dev/null and b/vcell-cli/src/test/resources/bsts-omex/sbml-core/Tomida-EMBO-J-2003-NFAT-translocation.omex differ diff --git a/vcell-cli/src/test/resources/bsts-omex/sbml-core/Varusai-Sci-Rep-2018-mTOR-signaling-LSODA-LSODAR-SBML.omex b/vcell-cli/src/test/resources/bsts-omex/sbml-core/Varusai-Sci-Rep-2018-mTOR-signaling-LSODA-LSODAR-SBML.omex new file mode 100644 index 0000000000..a065f2e232 Binary files /dev/null and b/vcell-cli/src/test/resources/bsts-omex/sbml-core/Varusai-Sci-Rep-2018-mTOR-signaling-LSODA-LSODAR-SBML.omex differ diff --git a/vcell-cli/src/test/resources/bsts-omex/sbml-core/Vilar-PNAS-2002-minimal-circardian-clock-continuous.omex b/vcell-cli/src/test/resources/bsts-omex/sbml-core/Vilar-PNAS-2002-minimal-circardian-clock-continuous.omex new file mode 100644 index 0000000000..2cd423b3be Binary files /dev/null and b/vcell-cli/src/test/resources/bsts-omex/sbml-core/Vilar-PNAS-2002-minimal-circardian-clock-continuous.omex differ diff --git a/vcell-cli/src/test/resources/bsts-omex/sbml-core/Vilar-PNAS-2002-minimal-circardian-clock-discrete-NRM.omex b/vcell-cli/src/test/resources/bsts-omex/sbml-core/Vilar-PNAS-2002-minimal-circardian-clock-discrete-NRM.omex new file mode 100644 index 0000000000..9198ef305d Binary files /dev/null and b/vcell-cli/src/test/resources/bsts-omex/sbml-core/Vilar-PNAS-2002-minimal-circardian-clock-discrete-NRM.omex differ diff --git a/vcell-cli/src/test/resources/bsts-omex/sbml-core/Vilar-PNAS-2002-minimal-circardian-clock-discrete-SSA.omex b/vcell-cli/src/test/resources/bsts-omex/sbml-core/Vilar-PNAS-2002-minimal-circardian-clock-discrete-SSA.omex new file mode 100644 index 0000000000..8c7cd7d6b6 Binary files /dev/null and b/vcell-cli/src/test/resources/bsts-omex/sbml-core/Vilar-PNAS-2002-minimal-circardian-clock-discrete-SSA.omex differ diff --git a/vcell-cli/src/test/resources/bsts-omex/sbml-core/Vilar-PNAS-2002-minimal-circardian-clock.omex b/vcell-cli/src/test/resources/bsts-omex/sbml-core/Vilar-PNAS-2002-minimal-circardian-clock.omex new file mode 100644 index 0000000000..4ea49ea2a2 Binary files /dev/null and b/vcell-cli/src/test/resources/bsts-omex/sbml-core/Vilar-PNAS-2002-minimal-circardian-clock.omex differ diff --git a/vcell-cli/src/test/resources/bsts-omex/synths/combine_archive/CombineArchiveHasSedDocumentsInNestedDirectories/1.execution-should-succeed.omex b/vcell-cli/src/test/resources/bsts-omex/synths/combine_archive/CombineArchiveHasSedDocumentsInNestedDirectories/1.execution-should-succeed.omex new file mode 100644 index 0000000000..fb4823d760 Binary files /dev/null and b/vcell-cli/src/test/resources/bsts-omex/synths/combine_archive/CombineArchiveHasSedDocumentsInNestedDirectories/1.execution-should-succeed.omex differ diff --git a/vcell-cli/src/test/resources/bsts-omex/synths/combine_archive/CombineArchiveHasSedDocumentsWithSameNamesInDifferentInNestedDirectories/1.execution-should-succeed.omex b/vcell-cli/src/test/resources/bsts-omex/synths/combine_archive/CombineArchiveHasSedDocumentsWithSameNamesInDifferentInNestedDirectories/1.execution-should-succeed.omex new file mode 100644 index 0000000000..0abb80d512 Binary files /dev/null and b/vcell-cli/src/test/resources/bsts-omex/synths/combine_archive/CombineArchiveHasSedDocumentsWithSameNamesInDifferentInNestedDirectories/1.execution-should-succeed.omex differ diff --git a/vcell-cli/src/test/resources/bsts-omex/synths/combine_archive/WhenACombineArchiveHasAMasterFileSimulatorOnlyExecutesThisFile/1.execution-should-succeed.omex b/vcell-cli/src/test/resources/bsts-omex/synths/combine_archive/WhenACombineArchiveHasAMasterFileSimulatorOnlyExecutesThisFile/1.execution-should-succeed.omex new file mode 100644 index 0000000000..5db8aa6e65 Binary files /dev/null and b/vcell-cli/src/test/resources/bsts-omex/synths/combine_archive/WhenACombineArchiveHasAMasterFileSimulatorOnlyExecutesThisFile/1.execution-should-succeed.omex differ diff --git a/vcell-cli/src/test/resources/bsts-omex/synths/combine_archive/WhenACombineArchiveHasNoMasterFileSimulatorExecutesAllSedDocuments/1.execution-should-succeed.omex b/vcell-cli/src/test/resources/bsts-omex/synths/combine_archive/WhenACombineArchiveHasNoMasterFileSimulatorExecutesAllSedDocuments/1.execution-should-succeed.omex new file mode 100644 index 0000000000..8a375d5035 Binary files /dev/null and b/vcell-cli/src/test/resources/bsts-omex/synths/combine_archive/WhenACombineArchiveHasNoMasterFileSimulatorExecutesAllSedDocuments/1.execution-should-succeed.omex differ diff --git a/vcell-cli/src/test/resources/bsts-omex/synths/docker_image/SingularityImageExecutesSimulationsSuccessfully/1.execution-should-succeed.omex b/vcell-cli/src/test/resources/bsts-omex/synths/docker_image/SingularityImageExecutesSimulationsSuccessfully/1.execution-should-succeed.omex new file mode 100644 index 0000000000..cc00075519 Binary files /dev/null and b/vcell-cli/src/test/resources/bsts-omex/synths/docker_image/SingularityImageExecutesSimulationsSuccessfully/1.execution-should-succeed.omex differ diff --git a/vcell-cli/src/test/resources/bsts-omex/synths/log/SimulatorReportsTheStatusOfTheExecutionOfCombineArchives/1.execution-should-succeed.omex b/vcell-cli/src/test/resources/bsts-omex/synths/log/SimulatorReportsTheStatusOfTheExecutionOfCombineArchives/1.execution-should-succeed.omex new file mode 100644 index 0000000000..d5a6ed1ffe Binary files /dev/null and b/vcell-cli/src/test/resources/bsts-omex/synths/log/SimulatorReportsTheStatusOfTheExecutionOfCombineArchives/1.execution-should-succeed.omex differ diff --git a/vcell-cli/src/test/resources/bsts-omex/synths/log/SimulatorReportsTheStatusOfTheExecutionOfSedDocuments/1.execution-should-succeed.omex b/vcell-cli/src/test/resources/bsts-omex/synths/log/SimulatorReportsTheStatusOfTheExecutionOfSedDocuments/1.execution-should-succeed.omex new file mode 100644 index 0000000000..d5a6ed1ffe Binary files /dev/null and b/vcell-cli/src/test/resources/bsts-omex/synths/log/SimulatorReportsTheStatusOfTheExecutionOfSedDocuments/1.execution-should-succeed.omex differ diff --git a/vcell-cli/src/test/resources/bsts-omex/synths/log/SimulatorReportsTheStatusOfTheExecutionOfSedOutputs/1.execution-should-succeed.omex b/vcell-cli/src/test/resources/bsts-omex/synths/log/SimulatorReportsTheStatusOfTheExecutionOfSedOutputs/1.execution-should-succeed.omex new file mode 100644 index 0000000000..d5a6ed1ffe Binary files /dev/null and b/vcell-cli/src/test/resources/bsts-omex/synths/log/SimulatorReportsTheStatusOfTheExecutionOfSedOutputs/1.execution-should-succeed.omex differ diff --git a/vcell-cli/src/test/resources/bsts-omex/synths/log/SimulatorReportsTheStatusOfTheExecutionOfSedTasks/1.execution-should-succeed.omex b/vcell-cli/src/test/resources/bsts-omex/synths/log/SimulatorReportsTheStatusOfTheExecutionOfSedTasks/1.execution-should-succeed.omex new file mode 100644 index 0000000000..d5a6ed1ffe Binary files /dev/null and b/vcell-cli/src/test/resources/bsts-omex/synths/log/SimulatorReportsTheStatusOfTheExecutionOfSedTasks/1.execution-should-succeed.omex differ diff --git a/vcell-cli/src/test/resources/bsts-omex/synths/results_report/SimulatorGeneratesReportsOfSimulationResults/1.execution-should-succeed.omex b/vcell-cli/src/test/resources/bsts-omex/synths/results_report/SimulatorGeneratesReportsOfSimulationResults/1.execution-should-succeed.omex new file mode 100644 index 0000000000..d5a6ed1ffe Binary files /dev/null and b/vcell-cli/src/test/resources/bsts-omex/synths/results_report/SimulatorGeneratesReportsOfSimulationResults/1.execution-should-succeed.omex differ diff --git a/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorCanResolveModelSourcesDefinedByUriFragments/1.execution-should-succeed.omex b/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorCanResolveModelSourcesDefinedByUriFragments/1.execution-should-succeed.omex new file mode 100644 index 0000000000..6998494f2f Binary files /dev/null and b/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorCanResolveModelSourcesDefinedByUriFragments/1.execution-should-succeed.omex differ diff --git a/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorCanResolveModelSourcesDefinedByUriFragmentsAndInheritChanges/1.execution-should-succeed.omex b/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorCanResolveModelSourcesDefinedByUriFragmentsAndInheritChanges/1.execution-should-succeed.omex new file mode 100644 index 0000000000..a051c46002 Binary files /dev/null and b/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorCanResolveModelSourcesDefinedByUriFragmentsAndInheritChanges/1.execution-should-succeed.omex differ diff --git a/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorProducesLinear2DPlots/1.execution-should-succeed.omex b/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorProducesLinear2DPlots/1.execution-should-succeed.omex new file mode 100644 index 0000000000..3fff8a92a9 Binary files /dev/null and b/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorProducesLinear2DPlots/1.execution-should-succeed.omex differ diff --git a/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorProducesLinear2DPlots/2.execution-should-succeed.omex b/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorProducesLinear2DPlots/2.execution-should-succeed.omex new file mode 100644 index 0000000000..94a5737f0d Binary files /dev/null and b/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorProducesLinear2DPlots/2.execution-should-succeed.omex differ diff --git a/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorProducesLogarithmic2DPlots/1.execution-should-succeed.omex b/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorProducesLogarithmic2DPlots/1.execution-should-succeed.omex new file mode 100644 index 0000000000..a4922ca241 Binary files /dev/null and b/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorProducesLogarithmic2DPlots/1.execution-should-succeed.omex differ diff --git a/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorProducesLogarithmic2DPlots/2.execution-should-succeed.omex b/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorProducesLogarithmic2DPlots/2.execution-should-succeed.omex new file mode 100644 index 0000000000..48f62a90ac Binary files /dev/null and b/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorProducesLogarithmic2DPlots/2.execution-should-succeed.omex differ diff --git a/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorProducesMultiplePlots/1.execution-should-succeed.omex b/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorProducesMultiplePlots/1.execution-should-succeed.omex new file mode 100644 index 0000000000..f22d3252b9 Binary files /dev/null and b/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorProducesMultiplePlots/1.execution-should-succeed.omex differ diff --git a/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorProducesMultiplePlots/2.execution-should-succeed.omex b/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorProducesMultiplePlots/2.execution-should-succeed.omex new file mode 100644 index 0000000000..103e43453d Binary files /dev/null and b/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorProducesMultiplePlots/2.execution-should-succeed.omex differ diff --git a/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorSupportsAddReplaceRemoveModelElementChanges/1.execute-should-fail.omex b/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorSupportsAddReplaceRemoveModelElementChanges/1.execute-should-fail.omex new file mode 100644 index 0000000000..833ce8847a Binary files /dev/null and b/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorSupportsAddReplaceRemoveModelElementChanges/1.execute-should-fail.omex differ diff --git a/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorSupportsAddReplaceRemoveModelElementChanges/2.execution-should-succeed.omex b/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorSupportsAddReplaceRemoveModelElementChanges/2.execution-should-succeed.omex new file mode 100644 index 0000000000..a78850d6da Binary files /dev/null and b/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorSupportsAddReplaceRemoveModelElementChanges/2.execution-should-succeed.omex differ diff --git a/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorSupportsAddReplaceRemoveModelElementChanges/3.execute-should-fail.omex b/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorSupportsAddReplaceRemoveModelElementChanges/3.execute-should-fail.omex new file mode 100644 index 0000000000..1c36b75985 Binary files /dev/null and b/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorSupportsAddReplaceRemoveModelElementChanges/3.execute-should-fail.omex differ diff --git a/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorSupportsAlgorithmParameters/1.execution-should-succeed.omex b/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorSupportsAlgorithmParameters/1.execution-should-succeed.omex new file mode 100644 index 0000000000..0e38ab4f96 Binary files /dev/null and b/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorSupportsAlgorithmParameters/1.execution-should-succeed.omex differ diff --git a/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorSupportsComputeModelChanges/1.execute-should-fail.omex b/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorSupportsComputeModelChanges/1.execute-should-fail.omex new file mode 100644 index 0000000000..81261f0275 Binary files /dev/null and b/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorSupportsComputeModelChanges/1.execute-should-fail.omex differ diff --git a/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorSupportsComputeModelChanges/2.execution-should-succeed.omex b/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorSupportsComputeModelChanges/2.execution-should-succeed.omex new file mode 100644 index 0000000000..7632e76158 Binary files /dev/null and b/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorSupportsComputeModelChanges/2.execution-should-succeed.omex differ diff --git a/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorSupportsDataGeneratorsWithDifferentShapes/1.execution-should-succeed.omex b/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorSupportsDataGeneratorsWithDifferentShapes/1.execution-should-succeed.omex new file mode 100644 index 0000000000..17ffaa0a62 Binary files /dev/null and b/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorSupportsDataGeneratorsWithDifferentShapes/1.execution-should-succeed.omex differ diff --git a/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorSupportsDataSetsWithDifferentShapes/1.execution-should-succeed.omex b/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorSupportsDataSetsWithDifferentShapes/1.execution-should-succeed.omex new file mode 100644 index 0000000000..c45883b0fe Binary files /dev/null and b/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorSupportsDataSetsWithDifferentShapes/1.execution-should-succeed.omex differ diff --git a/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorSupportsModelAttributeChanges/1.execute-should-fail.omex b/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorSupportsModelAttributeChanges/1.execute-should-fail.omex new file mode 100644 index 0000000000..3c6f43abc2 Binary files /dev/null and b/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorSupportsModelAttributeChanges/1.execute-should-fail.omex differ diff --git a/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorSupportsModelAttributeChanges/2.execution-should-succeed.omex b/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorSupportsModelAttributeChanges/2.execution-should-succeed.omex new file mode 100644 index 0000000000..ea4471e6dd Binary files /dev/null and b/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorSupportsModelAttributeChanges/2.execution-should-succeed.omex differ diff --git a/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorSupportsModelsSimulationsTasksDataGeneratorsAndReports/1.execution-should-succeed.omex b/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorSupportsModelsSimulationsTasksDataGeneratorsAndReports/1.execution-should-succeed.omex new file mode 100644 index 0000000000..90be229e4a Binary files /dev/null and b/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorSupportsModelsSimulationsTasksDataGeneratorsAndReports/1.execution-should-succeed.omex differ diff --git a/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorSupportsMultipleReportsPerSedDocument/1.execution-should-succeed.omex b/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorSupportsMultipleReportsPerSedDocument/1.execution-should-succeed.omex new file mode 100644 index 0000000000..c040d666fe Binary files /dev/null and b/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorSupportsMultipleReportsPerSedDocument/1.execution-should-succeed.omex differ diff --git a/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorSupportsMultipleTasksPerSedDocument/1.execution-should-succeed.omex b/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorSupportsMultipleTasksPerSedDocument/1.execution-should-succeed.omex new file mode 100644 index 0000000000..350daaf4c6 Binary files /dev/null and b/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorSupportsMultipleTasksPerSedDocument/1.execution-should-succeed.omex differ diff --git a/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorSupportsRepeatedTasksWithChanges/1.execute-should-fail.omex b/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorSupportsRepeatedTasksWithChanges/1.execute-should-fail.omex new file mode 100644 index 0000000000..ede65cb296 Binary files /dev/null and b/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorSupportsRepeatedTasksWithChanges/1.execute-should-fail.omex differ diff --git a/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorSupportsRepeatedTasksWithChanges/2.execution-should-succeed.omex b/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorSupportsRepeatedTasksWithChanges/2.execution-should-succeed.omex new file mode 100644 index 0000000000..d7ce547e31 Binary files /dev/null and b/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorSupportsRepeatedTasksWithChanges/2.execution-should-succeed.omex differ diff --git a/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorSupportsRepeatedTasksWithFunctionalRangeVariables/1.execute-should-fail.omex b/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorSupportsRepeatedTasksWithFunctionalRangeVariables/1.execute-should-fail.omex new file mode 100644 index 0000000000..a41dba3d17 Binary files /dev/null and b/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorSupportsRepeatedTasksWithFunctionalRangeVariables/1.execute-should-fail.omex differ diff --git a/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorSupportsRepeatedTasksWithFunctionalRangeVariables/2.execution-should-succeed.omex b/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorSupportsRepeatedTasksWithFunctionalRangeVariables/2.execution-should-succeed.omex new file mode 100644 index 0000000000..03656c9433 Binary files /dev/null and b/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorSupportsRepeatedTasksWithFunctionalRangeVariables/2.execution-should-succeed.omex differ diff --git a/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorSupportsRepeatedTasksWithFunctionalRanges/1.execution-should-succeed.omex b/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorSupportsRepeatedTasksWithFunctionalRanges/1.execution-should-succeed.omex new file mode 100644 index 0000000000..a55b8fbd9a Binary files /dev/null and b/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorSupportsRepeatedTasksWithFunctionalRanges/1.execution-should-succeed.omex differ diff --git a/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorSupportsRepeatedTasksWithLinearUniformRanges/1.execution-should-succeed.omex b/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorSupportsRepeatedTasksWithLinearUniformRanges/1.execution-should-succeed.omex new file mode 100644 index 0000000000..8f78ae23d2 Binary files /dev/null and b/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorSupportsRepeatedTasksWithLinearUniformRanges/1.execution-should-succeed.omex differ diff --git a/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorSupportsRepeatedTasksWithLogarithmicUniformRanges/1.execution-should-succeed.omex b/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorSupportsRepeatedTasksWithLogarithmicUniformRanges/1.execution-should-succeed.omex new file mode 100644 index 0000000000..5dee258e9a Binary files /dev/null and b/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorSupportsRepeatedTasksWithLogarithmicUniformRanges/1.execution-should-succeed.omex differ diff --git a/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorSupportsRepeatedTasksWithMultipleSubTasks/1.execution-should-succeed.omex b/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorSupportsRepeatedTasksWithMultipleSubTasks/1.execution-should-succeed.omex new file mode 100644 index 0000000000..ae6e97489a Binary files /dev/null and b/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorSupportsRepeatedTasksWithMultipleSubTasks/1.execution-should-succeed.omex differ diff --git a/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorSupportsRepeatedTasksWithNestedFunctionalRanges/1.execution-should-succeed.omex b/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorSupportsRepeatedTasksWithNestedFunctionalRanges/1.execution-should-succeed.omex new file mode 100644 index 0000000000..06e53d22dc Binary files /dev/null and b/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorSupportsRepeatedTasksWithNestedFunctionalRanges/1.execution-should-succeed.omex differ diff --git a/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorSupportsRepeatedTasksWithNestedRepeatedTasks/1.execution-should-succeed.omex b/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorSupportsRepeatedTasksWithNestedRepeatedTasks/1.execution-should-succeed.omex new file mode 100644 index 0000000000..682495d951 Binary files /dev/null and b/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorSupportsRepeatedTasksWithNestedRepeatedTasks/1.execution-should-succeed.omex differ diff --git a/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorSupportsRepeatedTasksWithSubTasksOfMixedTypes/1.execution-should-succeed.omex b/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorSupportsRepeatedTasksWithSubTasksOfMixedTypes/1.execution-should-succeed.omex new file mode 100644 index 0000000000..cfb9fbb293 Binary files /dev/null and b/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorSupportsRepeatedTasksWithSubTasksOfMixedTypes/1.execution-should-succeed.omex differ diff --git a/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorSupportsRepeatedTasksWithSubTasksOfMixedTypes/2.execution-should-succeed.omex b/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorSupportsRepeatedTasksWithSubTasksOfMixedTypes/2.execution-should-succeed.omex new file mode 100644 index 0000000000..16deebea2f Binary files /dev/null and b/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorSupportsRepeatedTasksWithSubTasksOfMixedTypes/2.execution-should-succeed.omex differ diff --git a/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorSupportsRepeatedTasksWithVectorRanges/1.execution-should-succeed.omex b/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorSupportsRepeatedTasksWithVectorRanges/1.execution-should-succeed.omex new file mode 100644 index 0000000000..50f26e21f1 Binary files /dev/null and b/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorSupportsRepeatedTasksWithVectorRanges/1.execution-should-succeed.omex differ diff --git a/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorSupportsSubstitutingAlgorithms/1.execute-should-fail.omex b/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorSupportsSubstitutingAlgorithms/1.execute-should-fail.omex new file mode 100644 index 0000000000..6a29f8b096 Binary files /dev/null and b/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorSupportsSubstitutingAlgorithms/1.execute-should-fail.omex differ diff --git a/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorSupportsSubstitutingAlgorithms/2.execution-should-succeed.omex b/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorSupportsSubstitutingAlgorithms/2.execution-should-succeed.omex new file mode 100644 index 0000000000..6a29f8b096 Binary files /dev/null and b/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorSupportsSubstitutingAlgorithms/2.execution-should-succeed.omex differ diff --git a/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorSupportsSubstitutingAlgorithms/3.execute-should-fail.omex b/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorSupportsSubstitutingAlgorithms/3.execute-should-fail.omex new file mode 100644 index 0000000000..68f0245a64 Binary files /dev/null and b/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorSupportsSubstitutingAlgorithms/3.execute-should-fail.omex differ diff --git a/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorSupportsSubstitutingAlgorithms/4.execution-should-succeed.omex b/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorSupportsSubstitutingAlgorithms/4.execution-should-succeed.omex new file mode 100644 index 0000000000..68f0245a64 Binary files /dev/null and b/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorSupportsSubstitutingAlgorithms/4.execution-should-succeed.omex differ diff --git a/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorSupportsUniformTimeCoursesWithNonZeroInitialTimes/1.execution-should-succeed.omex b/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorSupportsUniformTimeCoursesWithNonZeroInitialTimes/1.execution-should-succeed.omex new file mode 100644 index 0000000000..6730b9c98d Binary files /dev/null and b/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorSupportsUniformTimeCoursesWithNonZeroInitialTimes/1.execution-should-succeed.omex differ diff --git a/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorSupportsUniformTimeCoursesWithNonZeroOutputStartTimes/1.execution-should-succeed.omex b/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorSupportsUniformTimeCoursesWithNonZeroOutputStartTimes/1.execution-should-succeed.omex new file mode 100644 index 0000000000..e64fbec3d4 Binary files /dev/null and b/vcell-cli/src/test/resources/bsts-omex/synths/sedml/SimulatorSupportsUniformTimeCoursesWithNonZeroOutputStartTimes/1.execution-should-succeed.omex differ diff --git a/vcell-core/src/main/java/org/vcell/sedml/SEDMLImporter.java b/vcell-core/src/main/java/org/vcell/sedml/SEDMLImporter.java index da6a705c6b..3a90252d4b 100644 --- a/vcell-core/src/main/java/org/vcell/sedml/SEDMLImporter.java +++ b/vcell-core/src/main/java/org/vcell/sedml/SEDMLImporter.java @@ -81,38 +81,40 @@ public SEDMLImporter(VCLogger transLogger, ExternalDocInfo externalDocInfo, Sed } private void initialize() throws FileNotFoundException, XMLException { - bioModelBaseName = FileUtils.getBaseName(externalDocInfo.getFile().getAbsolutePath()); // extract bioModel name from sedx (or sedml) file + this.bioModelBaseName = FileUtils.getBaseName(externalDocInfo.getFile().getAbsolutePath()); // extract bioModel name from sedx (or sedml) file + this.resolver = new ModelResolver(sedml); + this.sbmlSupport = new SBMLSupport(); + if(externalDocInfo.getFile().getPath().toLowerCase().endsWith("sedx") || externalDocInfo.getFile().getPath().toLowerCase().endsWith("omex")) { - ac = Libsedml.readSEDMLArchive(new FileInputStream(externalDocInfo.getFile().getPath())); + this.ac = Libsedml.readSEDMLArchive(new FileInputStream(externalDocInfo.getFile().getPath())); } - resolver = new ModelResolver(sedml); - if(ac != null) { + + if(this.ac != null) { ArchiveModelResolver amr = new ArchiveModelResolver(ac); amr.setSedmlPath(sedml.getPathForURI()); - resolver.add(amr); + this.resolver.add(amr); } else { - resolver.add(new FileModelResolver()); // assumes absolute paths + this.resolver.add(new FileModelResolver()); // assumes absolute paths String sedmlRelativePrefix = externalDocInfo.getFile().getParent() + File.separator; - resolver.add(new RelativeFileModelResolver(sedmlRelativePrefix)); // in case model URIs are relative paths + this.resolver.add(new RelativeFileModelResolver(sedmlRelativePrefix)); // in case model URIs are relative paths } - sbmlSupport = new SBMLSupport(); + } public List getBioModels() throws Exception { - uniqueBioModelsList = new ArrayList(); - List modelList; List simulationList; List abstractTaskList; List dataGeneratorList; List outputList; - - Map bmMap; // Holds all entries for all SEDML Models where some may reference the same BioModel + Map bioModelMap; // Holds all entries for all SEDML Models where some may reference the same BioModel Map vcSimulations = new HashMap<>(); // We will parse all tasks and create Simulations in BioModels + + this.uniqueBioModelsList = new ArrayList(); + try { // iterate through all the elements and show them at the console - modelList = sedml.getModels(); - if (modelList.isEmpty()) return uniqueBioModelsList; // nothing to import + if ((modelList = sedml.getModels()).isEmpty()) return this.uniqueBioModelsList; // nothing to import simulationList = sedml.getSimulations(); abstractTaskList = sedml.getTasks(); dataGeneratorList = sedml.getDataGenerators(); @@ -121,8 +123,8 @@ public List getBioModels() throws Exception { this.printSEDMLSummary(modelList, simulationList, abstractTaskList, dataGeneratorList, outputList); // NB: We don't know how many BioModels we'll end up with as some model changes may be translatable as simulations with overrides - bmMap = this.createBioModels(modelList); - + bioModelMap = this.createBioModels(modelList); + // Creating one VCell Simulation for each SED-ML actual Task (RepeatedTasks get added as parameter scan overrides) for (AbstractTask selectedTask : abstractTaskList) { org.jlibsedml.Simulation sedmlSimulation = null; // this will become the vCell simulation @@ -182,7 +184,7 @@ public List getBioModels() throws Exception { } } - BioModel bioModel = bmMap.get(sedmlModel.getId()); + BioModel bioModel = bioModelMap.get(sedmlModel.getId()); // if language is VCML, we don't need to create Applications and Simulations in BioModel // we allow a subset of SED-ML Simulation settings (may have been edited) to override existing BioModel Simulation settings @@ -322,8 +324,154 @@ public List getBioModels() throws Exception { vcbms.add((vcbm == null)? bm : vcbm); } return vcbms; - } catch (Exception e) { - throw new RuntimeException("Unable to initialize bioModel for the given selection\n"+e.getMessage(), e); + } catch (Throwable e) { + if (e instanceof RuntimeException) throw e; + else throw new RuntimeException("Unable to initialize bioModel for the given selection\n"+e.getMessage(), e); + } + } + + private void generateSimulations(Map bioModelMap, Map vcSimulations, AbstractTask selectedTask) + throws Exception { + org.jlibsedml.Simulation sedmlSimulation = null; // this will become the vCell simulation + org.jlibsedml.Model sedmlModel = null; // the "original" model referred to by the task + String sedmlOriginalModelName = null; // this will be used in the BioModel name + String sedmlOriginalModelLanguage = null; // can be sbml or vcml + + // Determine Type of Task + if(selectedTask instanceof Task) { + sedmlModel = sedml.getModelWithId(selectedTask.getModelReference()); + sedmlSimulation = sedml.getSimulation(selectedTask.getSimulationReference()); + sedmlOriginalModelLanguage = sedmlModel.getLanguage(); + } else if (selectedTask instanceof RepeatedTask) { + return; // Repeated tasks refer to regular tasks, so first we need to create simulations for all regular tasks + } else { + throw new RuntimeException("Unexpected task " + selectedTask); + } + + // Confirm it's a UTC sim + if(!(sedmlSimulation instanceof UniformTimeCourse)) { // only UTC sims supported + lg.error("task '" + selectedTask.getName() + "' is being skipped, it references an unsupported simulation type: " + sedmlSimulation); + return; + } + + // at this point we assume that the sedml simulation, algorithm and kisaoID are all valid + + // identify the vCell solvers that would match best the sedml solver kisao id + SolverDescription solverDescription = this.determineKisaoSolver(sedmlSimulation, selectedTask); + + // find out everything else we need about the application we're going to use, + // some of the info will be needed when we parse the sbml file + boolean bSpatial = false; + Application appType = Application.NETWORK_DETERMINISTIC; + Set sfList = solverDescription.getSupportedFeatures(); + for(SolverDescription.SolverFeature sf : sfList) { + switch(sf) { + case Feature_Rulebased: + appType = Application.RULE_BASED_STOCHASTIC; + break; + case Feature_Stochastic: + appType = Application.NETWORK_STOCHASTIC; + break; + case Feature_Deterministic: + appType = Application.NETWORK_DETERMINISTIC; + break; + case Feature_Spatial: + bSpatial = true; + break; + default: + break; + } + } + + BioModel bioModel = bioModelMap.get(sedmlModel.getId()); + + // if language is VCML, we don't need to create Applications and Simulations in BioModel + // we allow a subset of SED-ML Simulation settings (may have been edited) to override existing BioModel Simulation settings + + if(sedmlOriginalModelLanguage.contentEquals(SUPPORTED_LANGUAGE.VCELL_GENERIC.getURN())) { + Simulation theSimulation = null; + for (Simulation sim : bioModel.getSimulations()) { + if (sim.getName().equals(selectedTask.getName())) { + lg.trace(" --- selected task - name: " + selectedTask.getName() + ", id: " + selectedTask.getId()); + sim.setImportedTaskID(selectedTask.getId()); + theSimulation = sim; + break; // found the one, no point to continue the for loop + } + } + + if(theSimulation == null) { + lg.error("Couldn't match sedml task '" + selectedTask.getName() + "' with any biomodel simulation"); + // TODO: should we throw an exception? + return; // should never happen + } + + SolverTaskDescription simTaskDesc = theSimulation.getSolverTaskDescription(); + this.translateTimeBounds(simTaskDesc, sedmlSimulation); + return; + } + + // if language is SBML, we must create Simulations + // we may need to also create Applications, since the default one from SBML import may not be the right type) + + // see first if there is a suitable application type for the specified kisao + // if not, we add one by doing a "copy as" to the right type + SimulationContext[] existingSimulationContexts = bioModel.getSimulationContexts(); + SimulationContext matchingSimulationContext = null; + for (SimulationContext simContext : existingSimulationContexts) { + if (simContext.getApplicationType().equals(appType) && ((simContext.getGeometry().getDimension() > 0) == bSpatial)) { + matchingSimulationContext = simContext; + break; + } + } + if (matchingSimulationContext == null) { + // this happens if we need a NETWORK_STOCHASTIC application + matchingSimulationContext = SimulationContext.copySimulationContext(bioModel.getSimulationContext(0), sedmlOriginalModelName+"_"+existingSimulationContexts.length, bSpatial, appType); + bioModel.addSimulationContext(matchingSimulationContext); + try { + String importedSCName = bioModel.getSimulationContext(0).getName(); + bioModel.getSimulationContext(0).setName("original_imported_"+importedSCName); + matchingSimulationContext.setName(importedSCName); + } catch (PropertyVetoException e) { + // we should never bomb out just for trying to set a pretty name + lg.warn("could not set pretty name on application from name of model "+sedmlModel); + } + } + matchingSimulationContext.refreshDependencies(); + MathMappingCallback callback = new MathMappingCallbackTaskAdapter(null); + matchingSimulationContext.refreshMathDescription(callback, NetworkGenerationRequirements.ComputeFullStandardTimeout); + + // making the new vCell simulation based on the sedml simulation + Simulation newSimulation = new Simulation(matchingSimulationContext.getMathDescription(), matchingSimulationContext); + if (selectedTask instanceof Task) { + String newSimName = selectedTask.getId(); + if(SEDMLUtil.getName(selectedTask) != null) { + newSimName += "_" + SEDMLUtil.getName(selectedTask); + } + newSimulation.setName(newSimName); + newSimulation.setImportedTaskID(selectedTask.getId()); + vcSimulations.put(selectedTask.getId(), newSimulation); + } else { + newSimulation.setName(SEDMLUtil.getName(sedmlSimulation)+"_"+SEDMLUtil.getName(selectedTask)); + } + + // we identify the type of sedml simulation (uniform time course, etc) + // and set the vCell simulation parameters accordingly + SolverTaskDescription simTaskDesc = newSimulation.getSolverTaskDescription(); + if(solverDescription != null) { + simTaskDesc.setSolverDescription(solverDescription); + } + + translateTimeBounds(simTaskDesc, sedmlSimulation); + translateAlgorithmParams(simTaskDesc, sedmlSimulation); + + newSimulation.setSolverTaskDescription(simTaskDesc); + newSimulation.setDescription(SEDMLUtil.getName(selectedTask)); + bioModel.addSimulation(newSimulation); + newSimulation.refreshDependencies(); + + // finally, add MathOverrides if referenced model has specified compatible changes + if (!sedmlModel.getListOfChanges().isEmpty() && canTranslateToOverrides(bioModel, sedmlModel)) { + createOverrides(newSimulation, sedmlModel.getListOfChanges()); } } @@ -964,4 +1112,17 @@ private void translateAlgorithmParams(SolverTaskDescription simTaskDesc, org.jli } simTaskDesc.setErrorTolerance(errorTolerance); } + + private SolverDescription determineKisaoSolver(org.jlibsedml.Simulation sedmlSimulation, AbstractTask selectedTask){ + String kisaoID = sedmlSimulation.getAlgorithm().getKisaoID(); + SolverDescription solverDescription = SolverUtilities.matchSolverWithKisaoId(kisaoID, exactMatchOnly); // try to find a match in the ontology tree + if (solverDescription != null) { + lg.info("Task (id='"+selectedTask.getId()+"') is compatible, solver match found in ontology: '" + kisaoID + "' matched to " + solverDescription); + } else { + solverDescription = SolverDescription.CombinedSundials; // give it a try anyway with our deterministic default solver + lg.error("Task (id='"+selectedTask.getId()+")' is not compatible, no equivalent solver found in ontology for requested algorithm '"+kisaoID + "'; trying with deterministic default solver "+solverDescription); + } + + return solverDescription; + } } diff --git a/vcell-core/src/test/java/org/vcell/sbml/SEDMLExporterSBMLTest.java b/vcell-core/src/test/java/org/vcell/sbml/SEDMLExporterSBMLTest.java index 03a40aae58..bb4c2cd52e 100644 --- a/vcell-core/src/test/java/org/vcell/sbml/SEDMLExporterSBMLTest.java +++ b/vcell-core/src/test/java/org/vcell/sbml/SEDMLExporterSBMLTest.java @@ -70,7 +70,6 @@ Map knownFaults() { @Override Map knownSEDMLFaults() { HashMap faults = new HashMap(); - faults.put("__export_adv_test.vcml", SEDML_FAULT.SIMULATION_NOT_FOUND_BY_NAME); // roundtripped simulation not found with name 'spatialnoscan' faults.put("biomodel_100596964.vcml", SEDML_FAULT.NO_MODELS_IN_OMEX); faults.put("biomodel_100961371.vcml", SEDML_FAULT.NO_MODELS_IN_OMEX); faults.put("biomodel_113655498.vcml", SEDML_FAULT.NO_MODELS_IN_OMEX);