Search in sources :

Example 1 with SimulationServiceImpl

use of org.vcell.vcellij.SimulationServiceImpl in project vcell by virtualcell.

the class SimulationServiceImplTest method test.

@Test
public void test() throws URISyntaxException, ThriftDataAccessException, TException {
    SimulationServiceImpl simService = new SimulationServiceImpl();
    // TODO - Eliminate code duplication.
    URL sbmlFileUrl = SimulationServiceImplTest.class.getResource("../../sbml/optoPlexin_PRG_rule_based.xml");
    File file = new File(sbmlFileUrl.toURI());
    VCMongoMessage.enabled = false;
    // TODO - Encapsulate this common setup stuff into VCellService initialization.
    // Then all VCell-based scripts can focus on the customization below.
    System.setProperty(PropertyLoader.installationRoot, new File("..").getAbsolutePath());
    ResourceUtil.setNativeLibraryDirectory();
    NativeLib.HDF5.load();
    file = new File("src/test/resources/org/vcell/sbml/optoPlexin_PRG_rule_based.xml");
    Assert.assertTrue(file.exists());
    SBMLModel sbmlModel = new SBMLModel(file.getAbsolutePath());
    SimulationSpec simSpec = new SimulationSpec();
    SimulationInfo simInfo = simService.computeModel(sbmlModel, simSpec);
    long timeMS = System.currentTimeMillis();
    while (simService.getStatus(simInfo).simState == SimulationState.running) {
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
        }
        long time2MS = System.currentTimeMillis();
        if (time2MS - timeMS > 10000) {
            fail("timed out after 10 seconds");
        }
    }
    List<VariableInfo> vars = simService.getVariableList(simInfo);
    Assert.assertNotNull(vars);
    // TODO - Assert more things.
    final List<Double> timePoints = simService.getTimePoints(simInfo);
    vars.stream().forEach(var -> {
        try {
            System.out.println(// 
            var.getVariableDisplayName() + "[0] = " + simService.getData(simInfo, var, 0));
        } catch (Exception exc) {
            exc.printStackTrace();
        }
    });
}
Also used : URL(java.net.URL) URISyntaxException(java.net.URISyntaxException) TException(org.apache.thrift.TException) SimulationServiceImpl(org.vcell.vcellij.SimulationServiceImpl) File(java.io.File) Test(org.junit.Test)

Example 2 with SimulationServiceImpl

use of org.vcell.vcellij.SimulationServiceImpl in project vcell by virtualcell.

the class VCellService method runSimulation.

public Task<List<Dataset>, SimulationState> runSimulation(final VCellModel model, final SimulationSpec simSpec, final List<Species> outputSpecies, final boolean shouldCreateIndividualDatasets) {
    try {
        final SimulationServiceImpl client = new SimulationServiceImpl();
        final Task<List<Dataset>, SimulationState> task = runSimulation(client, model, simSpec, outputSpecies, shouldCreateIndividualDatasets, opService, datasetService);
        return task;
    } catch (final Throwable e) {
        e.printStackTrace();
    }
    return null;
}
Also used : SimulationServiceImpl(org.vcell.vcellij.SimulationServiceImpl) SimulationState(org.vcell.vcellij.api.SimulationState) ArrayList(java.util.ArrayList) List(java.util.List)

Example 3 with SimulationServiceImpl

use of org.vcell.vcellij.SimulationServiceImpl in project vcell by virtualcell.

the class VCellService method getSBML.

public SBMLDocument getSBML(final String vcml, final String applicationName) {
    try {
        final SimulationServiceImpl client = setupClient();
        final SBMLDocument document = getSBML(client, vcml, applicationName);
        return document;
    } catch (final Throwable e) {
        e.printStackTrace();
    }
    return null;
}
Also used : SBMLDocument(org.sbml.jsbml.SBMLDocument) SimulationServiceImpl(org.vcell.vcellij.SimulationServiceImpl)

Aggregations

SimulationServiceImpl (org.vcell.vcellij.SimulationServiceImpl)3 File (java.io.File)1 URISyntaxException (java.net.URISyntaxException)1 URL (java.net.URL)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 TException (org.apache.thrift.TException)1 Test (org.junit.Test)1 SBMLDocument (org.sbml.jsbml.SBMLDocument)1 SimulationState (org.vcell.vcellij.api.SimulationState)1