Search in sources :

Example 1 with TestCriteriaNewMathModel

use of cbit.vcell.numericstest.TestCriteriaNewMathModel in project vcell by virtualcell.

the class TestingFrameworkWindowManager method getNewTestCriteriaFromUser.

/**
 * Insert the method's description here.
 * Creation date: (4/9/2003 1:31:08 PM)
 * @return cbit.vcell.numericstestingframework.TestSuiteInfo
 */
public TestCriteriaNew getNewTestCriteriaFromUser(String solutionType, TestCriteriaNew origTestCriteria) throws UserCancelException {
    // Reset the text fields in the EditCriteriaPanel.
    getEditTestCriteriaPanel().setExistingTestCriteria(origTestCriteria);
    getEditTestCriteriaPanel().setSolutionType(solutionType);
    getEditTestCriteriaPanel().resetTextFields();
    while (true) {
        // display the editCriteriaPanel.
        Object choice = showEditTestCriteriaDialog(getEditTestCriteriaPanel(), getComponent());
        if (choice != null && choice.equals("OK")) {
            TestCriteriaNew tcritNew = getEditTestCriteriaPanel().getNewTestCriteria();
            if (tcritNew instanceof TestCriteriaNewMathModel) {
                TestCriteriaNewMathModel tcritNewMM = (TestCriteriaNewMathModel) tcritNew;
                if ((tcritNewMM.getRegressionMathModelInfo() == null && tcritNewMM.getRegressionSimInfo() != null) || (tcritNewMM.getRegressionMathModelInfo() != null && tcritNewMM.getRegressionSimInfo() == null)) {
                    PopupGenerator.showErrorDialog(TestingFrameworkWindowManager.this, "Must specify both Reference MathModel and Simulation");
                    continue;
                }
            } else if (tcritNew instanceof TestCriteriaNewBioModel) {
                TestCriteriaNewBioModel tcritNewBM = (TestCriteriaNewBioModel) tcritNew;
                if ((tcritNewBM.getRegressionBioModelInfo() == null && tcritNewBM.getRegressionSimInfo() != null) || (tcritNewBM.getRegressionBioModelInfo() != null && tcritNewBM.getRegressionSimInfo() == null)) {
                    PopupGenerator.showErrorDialog(TestingFrameworkWindowManager.this, "Must specify both Reference BioModel App and Simulation");
                    continue;
                }
            } else {
            }
            return tcritNew;
        }
        throw UserCancelException.CANCEL_GENERIC;
    }
}
Also used : TestCriteriaNewMathModel(cbit.vcell.numericstest.TestCriteriaNewMathModel) TestCriteriaNewBioModel(cbit.vcell.numericstest.TestCriteriaNewBioModel) TestCriteriaNew(cbit.vcell.numericstest.TestCriteriaNew)

Example 2 with TestCriteriaNewMathModel

use of cbit.vcell.numericstest.TestCriteriaNewMathModel in project vcell by virtualcell.

the class TestingFrameworkWindowManager method addTestCases.

/**
 * Insert the method's description here.
 * Creation date: (4/10/2003 11:27:32 AM)
 * @param testCase cbit.vcell.numericstestingframework.TestCase
 */
public String addTestCases(final TestSuiteInfoNew tsInfo, final TestCaseNew[] testCaseArray, int regrRefFlag, ClientTaskStatusSupport pp) {
    if (tsInfo == null) {
        throw new IllegalArgumentException("TestSuiteInfo cannot be null");
    }
    if (testCaseArray == null || testCaseArray.length == 0) {
        throw new IllegalArgumentException("TestCases cannot be null / empty");
    }
    // make modifiable list
    List<TestCaseNew> testCases = new ArrayList<>(Arrays.asList(testCaseArray));
    StringBuffer errors = new StringBuffer();
    // When a testCase (mathmodel/biomodel) is added to a testSuite, a new version of the mathModel/biomodel should be created.
    // Also, the simulations in the original mathmodel/biomodel should be rid of their parent simulation reference.
    pp.setMessage("Getting testSuite");
    pp.setProgress(1);
    TestSuiteNew testSuite = null;
    try {
        testSuite = getRequestManager().getDocumentManager().getTestSuite(tsInfo.getTSKey());
    } catch (Throwable e) {
        throw new RuntimeException("couldn't get test suite " + tsInfo.getTSID() + "\n" + e.getClass().getName() + " mesg=" + e.getMessage() + "\n");
    }
    if (testSuite != null && testSuite.getTSInfoNew().isLocked()) {
        throw new RuntimeException("Cannot addTestCases to locked table");
    }
    if (testSuite != null) {
        // Saving BioModels
        TestCaseNew[] existingTestCases = testSuite.getTestCases();
        java.util.HashMap<KeyValue, BioModel> bioModelHashMap = new java.util.HashMap<KeyValue, BioModel>();
        // if(existingTestCases != null){
        // Find BioModels, Using the same BM reference for sibling Applications
        int pcounter = 0;
        // use iterator to allow removal of test case from collection if exception
        Iterator<TestCaseNew> iter = testCases.iterator();
        while (iter.hasNext()) {
            TestCaseNew testCase = iter.next();
            pp.setProgress(Math.max(1, ((int) ((pcounter++ / (double) (testCases.size() * 3)) * 100))));
            pp.setMessage("Checking " + testCase.getVersion().getName());
            try {
                if (testCase instanceof TestCaseNewBioModel) {
                    TestCaseNewBioModel bioTestCase = (TestCaseNewBioModel) testCase;
                    // 
                    if (bioModelHashMap.get(bioTestCase.getBioModelInfo().getVersion().getVersionKey()) == null) {
                        pp.setMessage("Getting BM " + testCase.getVersion().getName());
                        BioModel bioModel = getRequestManager().getDocumentManager().getBioModel(bioTestCase.getBioModelInfo().getVersion().getVersionKey());
                        if (!bioModel.getVersion().getOwner().equals(getRequestManager().getDocumentManager().getUser())) {
                            throw new Exception("BioModel does not belong to VCELLTESTACCOUNT, cannot proceed with test!");
                        }
                        // 
                        // if biomodel already exists in same testsuite, then use this BioModel edition
                        // 
                        BioModel newBioModel = null;
                        if (existingTestCases != null) {
                            for (int j = 0; newBioModel == null && j < existingTestCases.length; j++) {
                                if (existingTestCases[j] instanceof TestCaseNewBioModel) {
                                    TestCaseNewBioModel existingTestCaseBioModel = (TestCaseNewBioModel) existingTestCases[j];
                                    // 
                                    if (existingTestCaseBioModel.getBioModelInfo().getVersion().getBranchID().equals(bioTestCase.getBioModelInfo().getVersion().getBranchID())) {
                                        // 
                                        if (existingTestCaseBioModel.getBioModelInfo().getVersion().getVersionKey().equals(bioTestCase.getBioModelInfo().getVersion().getVersionKey())) {
                                            // 
                                            // same, store this "unchanged" in bioModelHashMap
                                            // 
                                            newBioModel = bioModel;
                                        } else {
                                            // 
                                            throw new Exception("can't add new test case using (" + bioTestCase.getBioModelInfo().getVersion().getName() + " " + bioTestCase.getBioModelInfo().getVersion().getDate() + ")\n" + "a test case already exists with different edition of same BioModel dated " + existingTestCaseBioModel.getBioModelInfo().getVersion().getDate());
                                        }
                                    }
                                }
                            }
                        }
                        if (newBioModel == null) {
                            pp.setMessage("Saving BM " + testCase.getVersion().getName());
                            // 
                            // some older models have membrane voltage variable names which are not unique
                            // (e.g. membranes 'pm' and 'nm' both have membrane voltage variables named 'Voltage_Membrane0')
                            // 
                            // if this is the case, we will try to repair the conflict (for math testing purposes only) by renaming the voltage variables to their default values.
                            // 
                            // Ordinarily, the conflict will be identified as an "Error" issue and the user will be prompted to repair before saving or math generation.
                            // 
                            bioModel.refreshDependencies();
                            boolean bFoundIdentifierConflictUponLoading = hasDuplicateIdentifiers(bioModel);
                            if (bFoundIdentifierConflictUponLoading) {
                                // 
                                // look for two MembraneVoltage instances with same variable name, rename all
                                // 
                                HashSet<String> membraneVoltageVarNames = new HashSet<String>();
                                ArrayList<MembraneVoltage> membraneVoltageVars = new ArrayList<MembraneVoltage>();
                                for (Structure struct : bioModel.getModel().getStructures()) {
                                    if (struct instanceof Membrane) {
                                        MembraneVoltage membraneVoltage = ((Membrane) struct).getMembraneVoltage();
                                        if (membraneVoltage != null) {
                                            membraneVoltageVars.add(membraneVoltage);
                                            membraneVoltageVarNames.add(membraneVoltage.getName());
                                        }
                                    }
                                }
                                if (membraneVoltageVars.size() != membraneVoltageVarNames.size()) {
                                    // rename them all to the default names
                                    for (MembraneVoltage memVoltage : membraneVoltageVars) {
                                        memVoltage.setName(Membrane.getDefaultMembraneVoltageName(memVoltage.getMembrane().getName()));
                                    }
                                }
                            }
                            SimulationContext[] simContexts = bioModel.getSimulationContexts();
                            for (int j = 0; j < simContexts.length; j++) {
                                simContexts[j].clearVersion();
                                GeometrySurfaceDescription gsd = simContexts[j].getGeometry().getGeometrySurfaceDescription();
                                if (gsd != null) {
                                    GeometricRegion[] grArr = gsd.getGeometricRegions();
                                    if (grArr == null) {
                                        gsd.updateAll();
                                    }
                                }
                                MathMapping mathMapping = simContexts[j].createNewMathMapping();
                                // for older models that do not have absolute compartment sizes set, but have relative sizes (SVR/VF); or if there is only one compartment with size not set,
                                // compute absolute compartment sizes using relative sizes and assuming a default value of '1' for one of the compartments.
                                // Otherwise, the math generation will fail, since for the relaxed topology (VCell 5.3 and later) absolute compartment sizes are required.
                                GeometryContext gc = simContexts[j].getGeometryContext();
                                if (simContexts[j].getGeometry().getDimension() == 0 && ((gc.isAllSizeSpecifiedNull() && !gc.isAllVolFracAndSurfVolSpecifiedNull()) || (gc.getModel().getStructures().length == 1 && gc.isAllSizeSpecifiedNull()))) {
                                    // choose the first structure in model and set its size to '1'.
                                    Structure struct = simContexts[j].getModel().getStructure(0);
                                    double structSize = 1.0;
                                    StructureSizeSolver.updateAbsoluteStructureSizes(simContexts[j], struct, structSize, struct.getStructureSize().getUnitDefinition());
                                }
                                simContexts[j].setMathDescription(mathMapping.getMathDescription());
                            }
                            Simulation[] sims = bioModel.getSimulations();
                            String[] simNames = new String[sims.length];
                            for (int j = 0; j < sims.length; j++) {
                                // prevents parent simulation (from the original mathmodel) reference connection
                                // Otherwise it will refer to data from previous (parent) simulation.
                                sims[j].clearVersion();
                                simNames[j] = sims[j].getName();
                            // if(sims[j].getSolverTaskDescription().getSolverDescription().equals(SolverDescription.FiniteVolume)){
                            // sims[j].getSolverTaskDescription().setSolverDescription(SolverDescription.FiniteVolumeStandalone);
                            // }
                            }
                            newBioModel = getRequestManager().getDocumentManager().save(bioModel, simNames);
                        }
                        bioModelHashMap.put(bioTestCase.getBioModelInfo().getVersion().getVersionKey(), newBioModel);
                    }
                }
            } catch (Throwable e) {
                String identifier = testCase.getVersion() != null ? "Name=" + testCase.getVersion().getName() : "TCKey=" + testCase.getTCKey();
                if (lg.isInfoEnabled()) {
                    lg.info(identifier, e);
                }
                errors.append("Error collecting BioModel for TestCase " + identifier + '\n' + e.getClass().getName() + " " + e.getMessage() + '\n');
                // remove to avoid further processing attempts
                iter.remove();
            }
        }
        // }
        // then process each BioModelTestCase individually
        // if(bioModelHashMap != null){
        pcounter = 0;
        for (TestCaseNew testCase : testCases) {
            pp.setProgress(Math.max(1, ((int) ((pcounter++ / (double) (testCases.size() * 3)) * 100))));
            pp.setMessage("Checking " + testCase.getVersion().getName());
            try {
                AddTestCasesOP testCaseOP = null;
                if (testCase instanceof TestCaseNewBioModel) {
                    pp.setMessage("Processing BM " + testCase.getVersion().getName());
                    TestCaseNewBioModel bioTestCase = (TestCaseNewBioModel) testCase;
                    BioModel newBioModel = (BioModel) bioModelHashMap.get(bioTestCase.getBioModelInfo().getVersion().getVersionKey());
                    if (newBioModel == null) {
                        throw new Exception("BioModel not found");
                    }
                    SimulationContext simContext = null;
                    for (int j = 0; j < newBioModel.getSimulationContexts().length; j++) {
                        if (newBioModel.getSimulationContext(j).getName().equals(bioTestCase.getSimContextName())) {
                            simContext = newBioModel.getSimulationContext(j);
                        }
                    }
                    Simulation[] newSimulations = simContext.getSimulations();
                    AddTestCriteriaOPBioModel[] testCriteriaOPs = new AddTestCriteriaOPBioModel[newSimulations.length];
                    for (int j = 0; j < newSimulations.length; j++) {
                        TestCriteriaNewBioModel tcritOrigForSimName = null;
                        for (int k = 0; bioTestCase.getTestCriterias() != null && k < bioTestCase.getTestCriterias().length; k += 1) {
                            if (bioTestCase.getTestCriterias()[k].getSimInfo().getName().equals(newSimulations[j].getName())) {
                                tcritOrigForSimName = (TestCriteriaNewBioModel) bioTestCase.getTestCriterias()[k];
                                break;
                            }
                        }
                        KeyValue regressionBioModelKey = null;
                        KeyValue regressionBioModelSimKey = null;
                        if (bioTestCase.getType().equals(TestCaseNew.REGRESSION)) {
                            if (regrRefFlag == TestingFrameworkWindowManager.COPY_REGRREF) {
                                regressionBioModelKey = (tcritOrigForSimName != null && tcritOrigForSimName.getRegressionBioModelInfo() != null ? tcritOrigForSimName.getRegressionBioModelInfo().getVersion().getVersionKey() : null);
                                regressionBioModelSimKey = (tcritOrigForSimName != null && tcritOrigForSimName.getRegressionSimInfo() != null ? tcritOrigForSimName.getRegressionSimInfo().getVersion().getVersionKey() : null);
                            } else if (regrRefFlag == TestingFrameworkWindowManager.ASSIGNORIGINAL_REGRREF) {
                                regressionBioModelKey = (tcritOrigForSimName != null ? bioTestCase.getBioModelInfo().getVersion().getVersionKey() : null);
                                regressionBioModelSimKey = (tcritOrigForSimName != null ? tcritOrigForSimName.getSimInfo().getVersion().getVersionKey() : null);
                            } else if (regrRefFlag == TestingFrameworkWindowManager.ASSIGNNEW_REGRREF) {
                                regressionBioModelKey = newBioModel.getVersion().getVersionKey();
                                regressionBioModelSimKey = newSimulations[j].getVersion().getVersionKey();
                            } else {
                                throw new IllegalArgumentException(this.getClass().getName() + ".addTestCases(...) BIOMODEL Unknown Regression Operation Flag");
                            }
                        }
                        testCriteriaOPs[j] = new AddTestCriteriaOPBioModel(testCase.getTCKey(), newSimulations[j].getVersion().getVersionKey(), regressionBioModelKey, regressionBioModelSimKey, (tcritOrigForSimName != null ? tcritOrigForSimName.getMaxAbsError() : new Double(1e-16)), (tcritOrigForSimName != null ? tcritOrigForSimName.getMaxRelError() : new Double(1e-9)), null);
                    }
                    testCaseOP = new AddTestCasesOPBioModel(new BigDecimal(tsInfo.getTSKey().toString()), newBioModel.getVersion().getVersionKey(), simContext.getKey(), bioTestCase.getType(), bioTestCase.getAnnotation(), testCriteriaOPs);
                    getRequestManager().getDocumentManager().doTestSuiteOP(testCaseOP);
                }
            } catch (Throwable e) {
                errors.append("Error processing Biomodel for TestCase " + (testCase.getVersion() != null ? "Name=" + testCase.getVersion().getName() : "TCKey=" + testCase.getTCKey()) + "\n" + e.getClass().getName() + " " + e.getMessage() + "\n");
            }
        }
        // }
        // Process MathModels
        pcounter = 0;
        for (TestCaseNew testCase : testCases) {
            pp.setProgress(Math.max(1, ((int) ((pcounter++ / (double) (testCases.size() * 3)) * 100))));
            pp.setMessage("Checking " + testCase.getVersion().getName());
            try {
                AddTestCasesOP testCaseOP = null;
                if (testCase instanceof TestCaseNewMathModel) {
                    TestCaseNewMathModel mathTestCase = (TestCaseNewMathModel) testCase;
                    pp.setMessage("Getting MathModel " + testCase.getVersion().getName());
                    MathModel mathModel = getRequestManager().getDocumentManager().getMathModel(mathTestCase.getMathModelInfo().getVersion().getVersionKey());
                    if (!mathModel.getVersion().getOwner().equals(getRequestManager().getDocumentManager().getUser())) {
                        throw new Exception("MathModel does not belong to VCELLTESTACCOUNT, cannot proceed with test!");
                    }
                    Simulation[] sims = mathModel.getSimulations();
                    String[] simNames = new String[sims.length];
                    for (int j = 0; j < sims.length; j++) {
                        // prevents parent simulation (from the original mathmodel) reference connection
                        // Otherwise it will refer to data from previous (parent) simulation.
                        sims[j].clearVersion();
                        simNames[j] = sims[j].getName();
                    // if(sims[j].getSolverTaskDescription().getSolverDescription().equals(SolverDescription.FiniteVolume)){
                    // sims[j].getSolverTaskDescription().setSolverDescription(SolverDescription.FiniteVolumeStandalone);
                    // }
                    }
                    pp.setMessage("Saving MathModel " + testCase.getVersion().getName());
                    MathModel newMathModel = getRequestManager().getDocumentManager().save(mathModel, simNames);
                    Simulation[] newSimulations = newMathModel.getSimulations();
                    AddTestCriteriaOPMathModel[] testCriteriaOPs = new AddTestCriteriaOPMathModel[newSimulations.length];
                    for (int j = 0; j < newSimulations.length; j++) {
                        TestCriteriaNewMathModel tcritOrigForSimName = null;
                        for (int k = 0; mathTestCase.getTestCriterias() != null && k < mathTestCase.getTestCriterias().length; k += 1) {
                            if (mathTestCase.getTestCriterias()[k].getSimInfo().getName().equals(newSimulations[j].getName())) {
                                tcritOrigForSimName = (TestCriteriaNewMathModel) mathTestCase.getTestCriterias()[k];
                                break;
                            }
                        }
                        KeyValue regressionMathModelKey = null;
                        KeyValue regressionMathModelSimKey = null;
                        if (mathTestCase.getType().equals(TestCaseNew.REGRESSION)) {
                            if (regrRefFlag == TestingFrameworkWindowManager.COPY_REGRREF) {
                                regressionMathModelKey = (tcritOrigForSimName != null && tcritOrigForSimName.getRegressionMathModelInfo() != null ? tcritOrigForSimName.getRegressionMathModelInfo().getVersion().getVersionKey() : null);
                                regressionMathModelSimKey = (tcritOrigForSimName != null && tcritOrigForSimName.getRegressionSimInfo() != null ? tcritOrigForSimName.getRegressionSimInfo().getVersion().getVersionKey() : null);
                            } else if (regrRefFlag == TestingFrameworkWindowManager.ASSIGNORIGINAL_REGRREF) {
                                regressionMathModelKey = (tcritOrigForSimName != null ? mathTestCase.getMathModelInfo().getVersion().getVersionKey() : null);
                                regressionMathModelSimKey = (tcritOrigForSimName != null ? tcritOrigForSimName.getSimInfo().getVersion().getVersionKey() : null);
                            } else if (regrRefFlag == TestingFrameworkWindowManager.ASSIGNNEW_REGRREF) {
                                regressionMathModelKey = newMathModel.getVersion().getVersionKey();
                                regressionMathModelSimKey = newSimulations[j].getVersion().getVersionKey();
                            } else {
                                throw new IllegalArgumentException(this.getClass().getName() + ".addTestCases(...) MATHMODEL Unknown Regression Operation Flag");
                            }
                        }
                        testCriteriaOPs[j] = new AddTestCriteriaOPMathModel(testCase.getTCKey(), newSimulations[j].getVersion().getVersionKey(), regressionMathModelKey, regressionMathModelSimKey, (tcritOrigForSimName != null ? tcritOrigForSimName.getMaxAbsError() : new Double(1e-16)), (tcritOrigForSimName != null ? tcritOrigForSimName.getMaxRelError() : new Double(1e-9)), null);
                    }
                    testCaseOP = new AddTestCasesOPMathModel(new BigDecimal(tsInfo.getTSKey().toString()), newMathModel.getVersion().getVersionKey(), mathTestCase.getType(), mathTestCase.getAnnotation(), testCriteriaOPs);
                    getRequestManager().getDocumentManager().doTestSuiteOP(testCaseOP);
                }
            } catch (Throwable e) {
                errors.append("Error processing MathModel for TestCase " + (testCase.getVersion() != null ? "Name=" + testCase.getVersion().getName() : "TCKey=" + testCase.getTCKey()) + "\n" + e.getClass().getName() + " " + e.getMessage() + "\n");
            }
        }
    }
    if (errors.length() > 0) {
        return errors.toString();
    }
    return null;
}
Also used : AddTestCriteriaOPBioModel(cbit.vcell.numericstest.AddTestCriteriaOPBioModel) AddTestCasesOPBioModel(cbit.vcell.numericstest.AddTestCasesOPBioModel) ArrayList(java.util.ArrayList) TestCriteriaNewMathModel(cbit.vcell.numericstest.TestCriteriaNewMathModel) GeometryContext(cbit.vcell.mapping.GeometryContext) HashSet(java.util.HashSet) TestSuiteNew(cbit.vcell.numericstest.TestSuiteNew) TestCaseNew(cbit.vcell.numericstest.TestCaseNew) GeometricRegion(cbit.vcell.geometry.surface.GeometricRegion) AddTestCriteriaOPMathModel(cbit.vcell.numericstest.AddTestCriteriaOPMathModel) MathMapping(cbit.vcell.mapping.MathMapping) MathModel(cbit.vcell.mathmodel.MathModel) AddTestCasesOPMathModel(cbit.vcell.numericstest.AddTestCasesOPMathModel) TestCaseNewMathModel(cbit.vcell.numericstest.TestCaseNewMathModel) TestCriteriaNewMathModel(cbit.vcell.numericstest.TestCriteriaNewMathModel) EditTestCriteriaOPMathModel(cbit.vcell.numericstest.EditTestCriteriaOPMathModel) AddTestCriteriaOPMathModel(cbit.vcell.numericstest.AddTestCriteriaOPMathModel) KeyValue(org.vcell.util.document.KeyValue) GeometrySurfaceDescription(cbit.vcell.geometry.surface.GeometrySurfaceDescription) TestCriteriaNewBioModel(cbit.vcell.numericstest.TestCriteriaNewBioModel) AddTestCasesOP(cbit.vcell.numericstest.AddTestCasesOP) TestCaseNewBioModel(cbit.vcell.numericstest.TestCaseNewBioModel) AddTestCasesOPMathModel(cbit.vcell.numericstest.AddTestCasesOPMathModel) Membrane(cbit.vcell.model.Membrane) Structure(cbit.vcell.model.Structure) SimulationContext(cbit.vcell.mapping.SimulationContext) ObjectNotFoundException(org.vcell.util.ObjectNotFoundException) DataAccessException(org.vcell.util.DataAccessException) UserCancelException(org.vcell.util.UserCancelException) BigDecimal(java.math.BigDecimal) Simulation(cbit.vcell.solver.Simulation) MembraneVoltage(cbit.vcell.model.Membrane.MembraneVoltage) TestCaseNewBioModel(cbit.vcell.numericstest.TestCaseNewBioModel) TestCriteriaNewBioModel(cbit.vcell.numericstest.TestCriteriaNewBioModel) AddTestCasesOPBioModel(cbit.vcell.numericstest.AddTestCasesOPBioModel) BioModel(cbit.vcell.biomodel.BioModel) EditTestCriteriaOPBioModel(cbit.vcell.numericstest.EditTestCriteriaOPBioModel) AddTestCriteriaOPBioModel(cbit.vcell.numericstest.AddTestCriteriaOPBioModel) TestCaseNewMathModel(cbit.vcell.numericstest.TestCaseNewMathModel)

Example 3 with TestCriteriaNewMathModel

use of cbit.vcell.numericstest.TestCriteriaNewMathModel in project vcell by virtualcell.

the class TestingFrameworkWindowManager method duplicateTestSuite.

/**
 * Insert the method's description here.
 * Creation date: (4/10/2003 11:27:32 AM)
 * @param testCase cbit.vcell.numericstestingframework.TestCase
 */
public String duplicateTestSuite(final TestSuiteInfoNew testSuiteInfo_Original, final TestSuiteInfoNew newTestSuiteInfo, int regrRefFlag, ClientTaskStatusSupport pp) throws DataAccessException {
    if (testSuiteInfo_Original == null || newTestSuiteInfo == null) {
        throw new IllegalArgumentException(this.getClass().getName() + "duplicateTestSuite_Private: TestSuite cannot be null");
    }
    checkNewTestSuiteInfo(newTestSuiteInfo);
    TestSuiteNew testSuite_Original = getRequestManager().getDocumentManager().getTestSuite(testSuiteInfo_Original.getTSKey());
    if (testSuite_Original == null) {
        throw new DataAccessException("Couldn't get TestSuite for tsInfo " + testSuiteInfo_Original.getTSID());
    }
    AddTestSuiteOP testSuiteOP = new AddTestSuiteOP(newTestSuiteInfo.getTSID(), newTestSuiteInfo.getTSVCellBuild(), newTestSuiteInfo.getTSNumericsBuild(), null, newTestSuiteInfo.getTSAnnotation());
    getRequestManager().getDocumentManager().doTestSuiteOP(testSuiteOP);
    TestSuiteInfoNew[] tsinArr = getRequestManager().getDocumentManager().getTestSuiteInfos();
    TestSuiteInfoNew tsin = null;
    for (int i = 0; i < tsinArr.length; i += 1) {
        if (tsinArr[i].getTSID().equals(newTestSuiteInfo.getTSID())) {
            tsin = tsinArr[i];
            break;
        }
    }
    if (tsin == null) {
        throw new DataAccessException("couldn't find new TestSuiteInfo " + newTestSuiteInfo.getTSID() + " in DB");
    }
    TestCaseNew[] originalTestCases = testSuite_Original.getTestCases();
    TestCaseNew[] newTestCases = null;
    if (originalTestCases != null && originalTestCases.length > 0) {
        newTestCases = new TestCaseNew[originalTestCases.length];
        for (int i = 0; i < originalTestCases.length; i += 1) {
            if (originalTestCases[i] instanceof TestCaseNewMathModel) {
                TestCaseNewMathModel tcnmm = (TestCaseNewMathModel) originalTestCases[i];
                TestCriteriaNew[] tcritnmm = (TestCriteriaNew[]) tcnmm.getTestCriterias();
                TestCriteriaNewMathModel[] newTCrits = null;
                if (tcritnmm != null && tcritnmm.length > 0) {
                    // Copy regression and errors
                    newTCrits = new TestCriteriaNewMathModel[tcritnmm.length];
                    for (int j = 0; j < tcritnmm.length; j += 1) {
                        newTCrits[j] = new TestCriteriaNewMathModel(null, tcritnmm[j].getSimInfo(), ((TestCriteriaNewMathModel) tcritnmm[j]).getRegressionMathModelInfo(), tcritnmm[j].getRegressionSimInfo(), tcritnmm[j].getMaxRelError(), tcritnmm[j].getMaxAbsError(), null, // new will have no data
                        TestCriteriaNew.TCRIT_STATUS_NODATA, // new will have no data
                        null);
                    }
                }
                // copy mathmodel,type and annotation and copied tcrits
                newTestCases[i] = new TestCaseNewMathModel(null, tcnmm.getMathModelInfo(), tcnmm.getType(), tcnmm.getAnnotation(), newTCrits);
            } else if (originalTestCases[i] instanceof TestCaseNewBioModel) {
                TestCaseNewBioModel tcnbm = (TestCaseNewBioModel) originalTestCases[i];
                TestCriteriaNew[] tcritnbm = (TestCriteriaNew[]) tcnbm.getTestCriterias();
                TestCriteriaNewBioModel[] newTCrits = null;
                if (tcritnbm != null && tcritnbm.length > 0) {
                    // Copy regression and errors
                    newTCrits = new TestCriteriaNewBioModel[tcritnbm.length];
                    for (int j = 0; j < tcritnbm.length; j += 1) {
                        newTCrits[j] = new TestCriteriaNewBioModel(null, tcritnbm[j].getSimInfo(), ((TestCriteriaNewBioModel) tcritnbm[j]).getRegressionBioModelInfo(), ((TestCriteriaNewBioModel) tcritnbm[j]).getRegressionApplicationName(), tcritnbm[j].getRegressionSimInfo(), tcritnbm[j].getMaxRelError(), tcritnbm[j].getMaxAbsError(), null, // new will have no data
                        TestCriteriaNew.TCRIT_STATUS_NODATA, // new will have no data
                        null);
                    }
                }
                // copy mathmodel,type and annotation and copied tcrits
                newTestCases[i] = new TestCaseNewBioModel(null, tcnbm.getBioModelInfo(), tcnbm.getSimContextName(), tcnbm.getSimContextKey(), tcnbm.getType(), tcnbm.getAnnotation(), newTCrits);
            } else {
                throw new RuntimeException("Unsupported TestCase type " + originalTestCases[i].getClass().getName());
            }
        }
    }
    // Add the new TestCases
    if (newTestCases != null && newTestCases.length > 0) {
        return addTestCases(tsin, newTestCases, regrRefFlag, pp);
    } else {
        return null;
    }
}
Also used : TestSuiteNew(cbit.vcell.numericstest.TestSuiteNew) TestCriteriaNewBioModel(cbit.vcell.numericstest.TestCriteriaNewBioModel) TestCaseNew(cbit.vcell.numericstest.TestCaseNew) TestCaseNewBioModel(cbit.vcell.numericstest.TestCaseNewBioModel) AddTestSuiteOP(cbit.vcell.numericstest.AddTestSuiteOP) TestCriteriaNewMathModel(cbit.vcell.numericstest.TestCriteriaNewMathModel) TestCriteriaNew(cbit.vcell.numericstest.TestCriteriaNew) TestCaseNewMathModel(cbit.vcell.numericstest.TestCaseNewMathModel) TestSuiteInfoNew(cbit.vcell.numericstest.TestSuiteInfoNew) DataAccessException(org.vcell.util.DataAccessException)

Example 4 with TestCriteriaNewMathModel

use of cbit.vcell.numericstest.TestCriteriaNewMathModel in project vcell by virtualcell.

the class TestingFrameworkWindowManager method updateTestCriteria.

/**
 * Insert the method's description here.
 * Creation date: (4/9/2003 1:31:08 PM)
 * @return cbit.vcell.numericstestingframework.TestSuiteInfo
 */
public void updateTestCriteria(TestCriteriaNew origTestCriteria, TestCriteriaNew newTestCriteria) throws DataAccessException {
    EditTestCriteriaOP testCriteriaOP = null;
    if (newTestCriteria instanceof TestCriteriaNewMathModel) {
        MathModelInfo regrMMInfo = ((TestCriteriaNewMathModel) newTestCriteria).getRegressionMathModelInfo();
        SimulationInfo regrsimInfo = ((TestCriteriaNewMathModel) newTestCriteria).getRegressionSimInfo();
        testCriteriaOP = new EditTestCriteriaOPMathModel(origTestCriteria.getTCritKey(), (regrMMInfo != null ? regrMMInfo.getVersion().getVersionKey() : null), (regrsimInfo != null ? regrsimInfo.getVersion().getVersionKey() : null), newTestCriteria.getMaxAbsError(), newTestCriteria.getMaxRelError());
    } else if (newTestCriteria instanceof TestCriteriaNewBioModel) {
        BioModelInfo regrBMInfo = ((TestCriteriaNewBioModel) newTestCriteria).getRegressionBioModelInfo();
        SimulationInfo regrsimInfo = ((TestCriteriaNewBioModel) newTestCriteria).getRegressionSimInfo();
        testCriteriaOP = new EditTestCriteriaOPBioModel(origTestCriteria.getTCritKey(), (regrBMInfo != null ? regrBMInfo.getVersion().getVersionKey() : null), (regrsimInfo != null ? regrsimInfo.getVersion().getVersionKey() : null), newTestCriteria.getMaxAbsError(), newTestCriteria.getMaxRelError());
    }
    getRequestManager().getDocumentManager().doTestSuiteOP(testCriteriaOP);
    RemoveTestResultsOP removeTestResults = new RemoveTestResultsOP(new BigDecimal[] { origTestCriteria.getTCritKey() });
    getRequestManager().getDocumentManager().doTestSuiteOP(removeTestResults);
}
Also used : EditTestCriteriaOPMathModel(cbit.vcell.numericstest.EditTestCriteriaOPMathModel) TestCriteriaNewMathModel(cbit.vcell.numericstest.TestCriteriaNewMathModel) TestCriteriaNewBioModel(cbit.vcell.numericstest.TestCriteriaNewBioModel) EditTestCriteriaOP(cbit.vcell.numericstest.EditTestCriteriaOP) BioModelInfo(org.vcell.util.document.BioModelInfo) EditTestCriteriaOPBioModel(cbit.vcell.numericstest.EditTestCriteriaOPBioModel) MathModelInfo(org.vcell.util.document.MathModelInfo) RemoveTestResultsOP(cbit.vcell.numericstest.RemoveTestResultsOP) SimulationInfo(cbit.vcell.solver.SimulationInfo)

Example 5 with TestCriteriaNewMathModel

use of cbit.vcell.numericstest.TestCriteriaNewMathModel in project vcell by virtualcell.

the class EditTestCriteriaPanel method resetTextFields.

/**
 * Sets the testSuiteInfo property (cbit.vcell.numericstest.TestSuiteInfo) value.
 * @param testSuiteInfo The new value for the property.
 * @see #getTestSuiteInfo
 */
public void resetTextFields() {
    // If the chosen simInfo already has test criteria defined, set the fields with the appropriate values
    // Else set them to blank.
    getRelErrTextField().setText("");
    getAbsErrTextField().setText("");
    if (getExistingTestCriteria() != null) {
        Double relErr = getExistingTestCriteria().getMaxRelError();
        Double absErr = getExistingTestCriteria().getMaxAbsError();
        getRelErrTextField().setText((relErr != null ? relErr.toString() : null));
        getAbsErrTextField().setText((absErr != null ? absErr.toString() : null));
    }
    // Depending on test case soultion type (which is set by testingFrameworkWindowManager based on the test case
    // the simulation belongs to), enable apprpriate (ref MathModel, ref simInfo buttons) fields.
    // if (!getSolutionType().equals(TestCaseNew.REGRESSION)) {
    getRefMathModelLabel().setText(null);
    getRefSimLabel().setText(null);
    getBioModelAppLabel().setText(null);
    getBmAppSimLabel().setText(null);
    getRefMathModelButton().setEnabled(false);
    getRefMathModelLabel().setEnabled(false);
    getRefSimButton().setEnabled(false);
    getRefSimLabel().setEnabled(false);
    getSelectRefBMAppJButton().setEnabled(false);
    getBioModelAppLabel().setEnabled(false);
    getSelectRefSimJButton().setEnabled(false);
    getBmAppSimLabel().setEnabled(false);
    // } else {
    if (getExistingTestCriteria() instanceof TestCriteriaNewMathModel && getSolutionType().equals(TestCaseNew.REGRESSION)) {
        getRefMathModelButton().setEnabled(true);
        getRefMathModelLabel().setEnabled(true);
        getRefSimButton().setEnabled(true);
        getRefSimLabel().setEnabled(true);
    } else if (getExistingTestCriteria() instanceof TestCriteriaNewBioModel && getSolutionType().equals(TestCaseNew.REGRESSION)) {
        getSelectRefBMAppJButton().setEnabled(true);
        getBioModelAppLabel().setEnabled(true);
        getSelectRefSimJButton().setEnabled(true);
        getBmAppSimLabel().setEnabled(true);
    }
    if (getExistingTestCriteria() != null && getExistingTestCriteria().getRegressionSimInfo() != null) {
        if (getExistingTestCriteria() instanceof TestCriteriaNewMathModel) {
            MathModelInfo refMMInfo = ((TestCriteriaNewMathModel) getExistingTestCriteria()).getRegressionMathModelInfo();
            if (refMMInfo == null) {
                PopupGenerator.showErrorDialog(this, "No MathModelInfo found for SimInfo Key " + getExistingTestCriteria().getRegressionSimInfo().getVersion().getVersionKey());
            }
            SimulationInfo refSimInfo = null;
            refSimInfo = getExistingTestCriteria().getRegressionSimInfo();
            if (refSimInfo == null) {
                PopupGenerator.showErrorDialog(this, "No SimulationInfo found for simInfo Key " + getExistingTestCriteria().getRegressionSimInfo().getVersion().getVersionKey());
            }
            setReferenceMathModelInfo(refMMInfo);
            setReferenceSimInfo(refSimInfo);
            getRefMathModelLabel().setText("<html>" + refMMInfo.getVersion().getName() + "<br>(MathModelKey=" + refMMInfo.getVersion().getVersionKey() + ")<br>" + refMMInfo.getVersion().getDate() + "<html>");
            getRefSimLabel().setText("<html>" + refSimInfo.getVersion().getName() + "<br>(SimulationKey:" + refSimInfo.getVersion().getVersionKey() + ")</html>");
        } else if (getExistingTestCriteria() instanceof TestCriteriaNewBioModel) {
            BioModelInfo refBMInfo = ((TestCriteriaNewBioModel) getExistingTestCriteria()).getRegressionBioModelInfo();
            if (refBMInfo == null) {
                PopupGenerator.showErrorDialog(this, "No bioModelInfo found for SimInfo Key " + getExistingTestCriteria().getRegressionSimInfo().getVersion().getVersionKey());
            }
            SimulationInfo refSimInfo = null;
            refSimInfo = getExistingTestCriteria().getRegressionSimInfo();
            if (refSimInfo == null) {
                PopupGenerator.showErrorDialog(this, "No SimulationInfo found for simInfo Key " + getExistingTestCriteria().getRegressionSimInfo().getVersion().getVersionKey());
            }
            setbioModelInfo(refBMInfo);
            setbmAppSimInfo(refSimInfo);
            setappName(((TestCriteriaNewBioModel) getExistingTestCriteria()).getRegressionApplicationName());
            getBioModelAppLabel().setText("<html>" + refBMInfo.getVersion().getName() + "/" + getappName() + "<br>(BioModelKey=" + refBMInfo.getVersion().getVersionKey() + ")<br>" + refBMInfo.getVersion().getDate() + "</html>");
            getBmAppSimLabel().setText("<html>" + refSimInfo.getVersion().getName() + "<br>(SimulationKey:" + refSimInfo.getVersion().getVersionKey() + ")</html>");
        }
    } else {
        setReferenceMathModelInfo(null);
        setReferenceSimInfo(null);
        getRefMathModelLabel().setText("");
        getRefSimLabel().setText("");
        setbioModelInfo(null);
        setbmAppSimInfo(null);
        setappName(null);
        getBioModelAppLabel().setText(null);
        getBmAppSimLabel().setText(null);
    }
// }
}
Also used : TestCriteriaNewMathModel(cbit.vcell.numericstest.TestCriteriaNewMathModel) TestCriteriaNewBioModel(cbit.vcell.numericstest.TestCriteriaNewBioModel) BioModelInfo(org.vcell.util.document.BioModelInfo) MathModelInfo(org.vcell.util.document.MathModelInfo) SimulationInfo(cbit.vcell.solver.SimulationInfo)

Aggregations

TestCriteriaNewBioModel (cbit.vcell.numericstest.TestCriteriaNewBioModel)9 TestCriteriaNewMathModel (cbit.vcell.numericstest.TestCriteriaNewMathModel)9 TestCriteriaNew (cbit.vcell.numericstest.TestCriteriaNew)5 SimulationInfo (cbit.vcell.solver.SimulationInfo)5 TestCaseNewBioModel (cbit.vcell.numericstest.TestCaseNewBioModel)4 TestCaseNewMathModel (cbit.vcell.numericstest.TestCaseNewMathModel)4 DataAccessException (org.vcell.util.DataAccessException)4 BioModelInfo (org.vcell.util.document.BioModelInfo)4 MathModelInfo (org.vcell.util.document.MathModelInfo)4 EditTestCriteriaOPBioModel (cbit.vcell.numericstest.EditTestCriteriaOPBioModel)3 EditTestCriteriaOPMathModel (cbit.vcell.numericstest.EditTestCriteriaOPMathModel)3 TestCaseNew (cbit.vcell.numericstest.TestCaseNew)3 TestSuiteNew (cbit.vcell.numericstest.TestSuiteNew)3 ObjectNotFoundException (org.vcell.util.ObjectNotFoundException)3 BioModel (cbit.vcell.biomodel.BioModel)2 MathModel (cbit.vcell.mathmodel.MathModel)2 AddTestCasesOPBioModel (cbit.vcell.numericstest.AddTestCasesOPBioModel)2 AddTestCasesOPMathModel (cbit.vcell.numericstest.AddTestCasesOPMathModel)2 AddTestCriteriaOPBioModel (cbit.vcell.numericstest.AddTestCriteriaOPBioModel)2 AddTestCriteriaOPMathModel (cbit.vcell.numericstest.AddTestCriteriaOPMathModel)2