Skip to content

Commit 4b30cb8

Browse files
committed
Change simulation entity checks
1 parent 9e6b4f6 commit 4b30cb8

File tree

2 files changed

+30
-29
lines changed

2 files changed

+30
-29
lines changed

org.insilico.vissim.sbscl/src/org/insilico/vissim/sbscl/simulation/SEDMLSimulation.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
import org.jlibsedml.Output;
1212
import org.jlibsedml.SEDMLDocument;
1313
import org.jlibsedml.SedML;
14+
import org.jlibsedml.execution.IProcessedSedMLSimulationResults;
1415
import org.jlibsedml.execution.IRawSedmlSimulationResults;
15-
import org.simulator.math.odes.MultiTable;
1616
import org.simulator.sedml.SedMLSBMLSimulatorExecutor;
1717

1818
public class SEDMLSimulation extends AbstractSimulation {
@@ -33,13 +33,10 @@ public SimulationResult simulate(String path) throws Exception {
3333
SedMLSBMLSimulatorExecutor exe = new SedMLSBMLSimulatorExecutor(sedml, wanted, sedmlDir);
3434
Map<AbstractTask, List<IRawSedmlSimulationResults>> res = exe.run();
3535
if (res == null || res.isEmpty() || !exe.isExecuted()) {
36-
// XXX: throw Ex. and log
36+
//
3737
} else {
38-
@SuppressWarnings("rawtypes")
39-
Map results = exe.runSimulations();
40-
@SuppressWarnings("unchecked")
41-
MultiTable solution = (MultiTable) exe.processSimulationResults(wanted, results);
42-
return new ResultAdapter(solution).getResult();
38+
IProcessedSedMLSimulationResults results = exe.processSimulationResults(wanted, res);
39+
return new ResultAdapter(results, sedml.getElementName()).getResult();
4340
}
4441
return null;
4542
}

org.insilico.vissim.sbscl/src/org/insilico/vissim/sbscl/utils/Utils.java

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,48 +4,51 @@
44
import static org.junit.Assert.assertTrue;
55

66
import java.io.File;
7+
import java.io.IOException;
78

89
import javax.xml.stream.XMLStreamException;
910

11+
import org.insilico.vissim.sbscl.factory.SimulationResult;
1012
import org.insilico.vissim.sbscl.simulation.SimulationType;
1113
import org.jlibsedml.Libsedml;
14+
import org.sbml.jsbml.Model;
1215
import org.sbml.jsbml.SBMLReader;
1316
import org.simulator.omex.OMEXArchive;
1417

1518
/**
16-
* Some basic utilities which need to be in helping project (for shifting operations or
17-
* other reasons), which are not toolkit dependent.
19+
* Some basic utilities which need to be in helping project (for shifting
20+
* operations or other reasons), which are not toolkit dependent.
1821
*/
1922
public class Utils {
2023

2124
/**
2225
* Provides the type of corresponding simulation
2326
*
2427
* <p>
25-
* Every simulation is eponymous to the type of the file specified.
26-
* e.g SimulationType.SEDML is a simulation described with SED-ML file.
28+
* Every simulation is eponymous to the type of the file specified. e.g
29+
* SimulationType.SEDML is a simulation described with SED-ML file.
2730
*
2831
* @param path absolute path to the file
2932
* @return {@link SimulationType}
30-
* */
33+
*/
3134
public SimulationType getSimulationType(String path) {
32-
if (Libsedml.isSEDML(new File(path)))
33-
return SimulationType.SEDML;
34-
if (isOMEXArchiv(path)) {
35-
return SimulationType.OMEX;
36-
}
37-
if (isSBML(path)) {
38-
return SimulationType.SBML;
39-
}
35+
if (isSBML(path)) {
36+
return SimulationType.SBML;
37+
}
38+
if (Libsedml.isSEDML(new File(path)))
39+
return SimulationType.SEDML;
40+
if (isOMEXArchiv(path)) {
41+
return SimulationType.OMEX;
42+
}
4043
return SimulationType.UNKNOWN_ENTITY;
4144
}
4245

4346
/**
44-
* Checks if provided file is a OMEXArchiv (combination of SED-ML
45-
* and SBML file with additional data)
47+
* Checks if provided file is a OMEXArchiv (combination of SED-ML and SBML file
48+
* with additional data)
4649
*
4750
* @param path absolute path to the file
48-
* */
51+
*/
4952
private boolean isOMEXArchiv(String path) {
5053
OMEXArchive archive;
5154
try {
@@ -59,20 +62,21 @@ private boolean isOMEXArchiv(String path) {
5962
return Boolean.FALSE;
6063
}
6164
}
62-
65+
6366
/**
64-
* Checks if provided file is a SBML file
65-
* XXX: more efficient check should be considered
67+
* Checks if provided file is a SBML file XXX: more efficient check should be
68+
* considered
6669
*
6770
* @param path absolute path to the file
68-
* */
71+
*/
6972
private boolean isSBML(String path) {
7073
try {
7174
// this check should be changed
7275
// reading file to define file type is inefficient
73-
SBMLReader.read(path);
76+
SBMLReader reader = new SBMLReader();
77+
assertNotNull(reader.readSBML(path).getModel());
7478
return Boolean.TRUE;
75-
} catch (XMLStreamException e) {
79+
} catch (XMLStreamException | IOException e) {
7680
return Boolean.FALSE;
7781
}
7882
}

0 commit comments

Comments
 (0)