Search in sources :

Example 6 with BiomodelRepresentation

use of org.vcell.api.common.BiomodelRepresentation in project vcell by virtualcell.

the class VCellModelService method getModels.

public Task<List<VCellModel>, String> getModels(VCellService vCellService) {
    final Task<List<VCellModel>, String> task = new Task<List<VCellModel>, String>() {

        @Override
        protected List<VCellModel> doInBackground() throws Exception {
            boolean bIgnoreCertProblems = true;
            boolean bIgnoreHostMismatch = true;
            VCellApiClient vCellApiClient = null;
            List<VCellModel> vCellModels = new ArrayList<VCellModel>();
            try {
                vCellApiClient = new VCellApiClient(HOST, PORT, bIgnoreCertProblems, bIgnoreHostMismatch);
                vCellApiClient.authenticate("ImageJ", "richarddberlin", false);
                BioModelsQuerySpec querySpec = new BioModelsQuerySpec();
                querySpec.owner = "tutorial";
                final BiomodelRepresentation[] biomodelReps = vCellApiClient.getBioModels(querySpec);
                final int modelsToLoad = biomodelReps.length;
                int modelsLoaded = 0;
                for (BiomodelRepresentation biomodelRep : biomodelReps) {
                    setSubtask(biomodelRep.getName());
                    ApplicationRepresentation[] applicationReps = biomodelRep.getApplications();
                    if (applicationReps.length > 0) {
                        String vcml = getVCML(biomodelRep);
                        if (vcml != null) {
                            SBMLDocument sbml = vCellService.getSBML(vcml, applicationReps[0].getName());
                            VCellModel vCellModel = new VCellModel(biomodelRep.getName(), biomodelRep.getBmKey(), sbml);
                            vCellModels.add(vCellModel);
                            modelsLoaded++;
                            setProgress(modelsLoaded * 100 / modelsToLoad);
                        } else {
                            System.err.println("failed to return VCML for " + biomodelRep.bmKey);
                        }
                    }
                }
            } catch (Exception e) {
                e.printStackTrace(System.out);
            }
            return vCellModels;
        }
    };
    return task;
}
Also used : BiomodelRepresentation(org.vcell.api.common.BiomodelRepresentation) Task(org.vcell.imagej.common.gui.Task) SBMLDocument(org.sbml.jsbml.SBMLDocument) ArrayList(java.util.ArrayList) VCellApiClient(org.vcell.api.client.VCellApiClient) IOException(java.io.IOException) KeyManagementException(java.security.KeyManagementException) KeyStoreException(java.security.KeyStoreException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) ApplicationRepresentation(org.vcell.api.common.ApplicationRepresentation) ArrayList(java.util.ArrayList) List(java.util.List) BioModelsQuerySpec(org.vcell.api.client.query.BioModelsQuerySpec)

Aggregations

BiomodelRepresentation (org.vcell.api.common.BiomodelRepresentation)6 BioModelsQuerySpec (org.vcell.api.client.query.BioModelsQuerySpec)4 ApplicationRepresentation (org.vcell.api.common.ApplicationRepresentation)3 Gson (com.google.gson.Gson)2 IOException (java.io.IOException)2 HttpGet (org.apache.http.client.methods.HttpGet)2 VCellApiClient (org.vcell.api.client.VCellApiClient)2 SimulationRepresentation (org.vcell.api.common.SimulationRepresentation)2 RemoteProxyException (cbit.vcell.message.server.bootstrap.client.RemoteProxyVCellConnectionFactory.RemoteProxyException)1 KeyManagementException (java.security.KeyManagementException)1 KeyStoreException (java.security.KeyStoreException)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Test (org.junit.Test)1 SBMLDocument (org.sbml.jsbml.SBMLDocument)1 SimTasksQuerySpec (org.vcell.api.client.query.SimTasksQuerySpec)1 SimulationTaskRepresentation (org.vcell.api.common.SimulationTaskRepresentation)1 Task (org.vcell.imagej.common.gui.Task)1 DataAccessException (org.vcell.util.DataAccessException)1