Search in sources :

Example 1 with VariableList

use of org.vcell.sbmlsim.api.common.VariableList in project vcell by virtualcell.

the class VCellSimService method getVariableList.

public VariableList getVariableList(SimulationHandle simHandle) throws ExecutableException {
    Gson gson = new Gson();
    Executable exe = new Executable(new String[] { command().getAbsolutePath(), scriptArgDashes + "simhandle", Long.toString(simHandle.remoteId), "varlist" });
    int[] expectedReturnCodes = new int[] { 0 };
    exe.start(expectedReturnCodes);
    VariableList varList = gson.fromJson(exe.getStdoutString(), VariableList.class);
    return varList;
}
Also used : VariableList(org.vcell.sbmlsim.api.common.VariableList) Gson(com.google.gson.Gson)

Example 2 with VariableList

use of org.vcell.sbmlsim.api.common.VariableList in project vcell by virtualcell.

the class VCellSimServiceTest method test.

@Test
public void test() throws URISyntaxException, Exception {
    VCellSimService simService = new VCellSimService();
    URL sbmlFileUrl = VCellSimServiceTest.class.getResource("../optoPlexin_PRG_rule_based.xml");
    File file = new File(sbmlFileUrl.toURI());
    Assert.assertTrue(file.exists());
    SBMLModel sbmlModel = new SBMLModel(file);
    SimulationSpec simSpec = new SimulationSpec();
    SimulationHandle simulationHandle = simService.submit(sbmlModel, simSpec);
    long timeMS = System.currentTimeMillis();
    while (simService.getStatus(simulationHandle).getSimState() != SimulationState.done && simService.getStatus(simulationHandle).getSimState() != SimulationState.failed) {
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
        }
        long time2MS = System.currentTimeMillis();
        if (time2MS - timeMS > 10000) {
            fail("timed out after 10 seconds");
        }
    }
    VariableList vars = simService.getVariableList(simulationHandle);
    Assert.assertNotNull(vars);
    // TODO - Assert more things.
    final TimePoints timePoints = simService.getTimePoints(simulationHandle);
    Arrays.asList(vars.varInfos).stream().forEach(var -> {
        try {
            System.out.println(// 
            var.getVariableDisplayName() + "[0] = " + simService.getSimData(simulationHandle, var, 0));
        } catch (Exception exc) {
            exc.printStackTrace();
        }
    });
}
Also used : TimePoints(org.vcell.sbmlsim.api.common.TimePoints) VariableList(org.vcell.sbmlsim.api.common.VariableList) SBMLModel(org.vcell.sbmlsim.api.common.SBMLModel) File(java.io.File) SimulationSpec(org.vcell.sbmlsim.api.common.SimulationSpec) URL(java.net.URL) URISyntaxException(java.net.URISyntaxException) Test(org.junit.Test)

Aggregations

VariableList (org.vcell.sbmlsim.api.common.VariableList)2 Gson (com.google.gson.Gson)1 File (java.io.File)1 URISyntaxException (java.net.URISyntaxException)1 URL (java.net.URL)1 Test (org.junit.Test)1 SBMLModel (org.vcell.sbmlsim.api.common.SBMLModel)1 SimulationSpec (org.vcell.sbmlsim.api.common.SimulationSpec)1 TimePoints (org.vcell.sbmlsim.api.common.TimePoints)1