use of cbit.vcell.mapping.SpeciesContextSpec in project vcell by virtualcell.
the class Generate2DExpModelOpAbstract method generateModel.
public final GeneratedModelResults generateModel(double deltaX, double bleachRadius, double cellRadius, double bleachDuration, double bleachRate, double postbleachDelay, double postbleachDuration, double psfSigma, double outputTimeStep, double primaryDiffusionRate, double primaryFraction, double bleachMonitorRate, double secondaryDiffusionRate, double secondaryFraction, String extracellularName, String cytosolName, Context context) throws PropertyVetoException, ExpressionException, GeometryException, ImageException, ModelException, MappingException, MathException, MatrixException {
double domainSize = 2.2 * cellRadius;
Extent extent = new Extent(domainSize, domainSize, 1.0);
Origin origin = new Origin(-extent.getX() / 2.0, -extent.getY() / 2.0, -extent.getZ() / 2.0);
String EXTRACELLULAR_NAME = extracellularName;
String CYTOSOL_NAME = cytosolName;
AnalyticSubVolume cytosolSubVolume = new AnalyticSubVolume(CYTOSOL_NAME, new Expression("pow(x,2)+pow(y,2)<pow(" + cellRadius + ",2)"));
AnalyticSubVolume extracellularSubVolume = new AnalyticSubVolume(EXTRACELLULAR_NAME, new Expression(1.0));
Geometry geometry = new Geometry("geometry", 2);
geometry.getGeometrySpec().setExtent(extent);
geometry.getGeometrySpec().setOrigin(origin);
geometry.getGeometrySpec().addSubVolume(extracellularSubVolume);
geometry.getGeometrySpec().addSubVolume(cytosolSubVolume, true);
geometry.getGeometrySurfaceDescription().updateAll();
BioModel bioModel = new BioModel(null);
bioModel.setName("unnamed");
Model model = new Model("model");
bioModel.setModel(model);
model.addFeature(EXTRACELLULAR_NAME);
Feature extracellular = (Feature) model.getStructure(EXTRACELLULAR_NAME);
model.addFeature(CYTOSOL_NAME);
Feature cytosol = (Feature) model.getStructure(CYTOSOL_NAME);
SpeciesContext immobileSC = model.createSpeciesContext(cytosol);
SpeciesContext primarySC = model.createSpeciesContext(cytosol);
SpeciesContext secondarySC = model.createSpeciesContext(cytosol);
//
// common bleaching rate for all species
//
double bleachStart = 10 * outputTimeStep - bleachDuration - postbleachDelay;
double bleachEnd = bleachStart + bleachDuration;
Expression bleachRateExp = createBleachExpression(bleachRadius, bleachRate, bleachMonitorRate, bleachStart, bleachEnd);
{
SimpleReaction immobileBWM = model.createSimpleReaction(cytosol);
GeneralKinetics immobileBWMKinetics = new GeneralKinetics(immobileBWM);
immobileBWM.setKinetics(immobileBWMKinetics);
immobileBWM.addReactant(immobileSC, 1);
immobileBWMKinetics.getReactionRateParameter().setExpression(Expression.mult(bleachRateExp, new Expression(immobileSC.getName())));
}
{
SimpleReaction primaryBWM = model.createSimpleReaction(cytosol);
GeneralKinetics primaryBWMKinetics = new GeneralKinetics(primaryBWM);
primaryBWM.setKinetics(primaryBWMKinetics);
primaryBWM.addReactant(primarySC, 1);
primaryBWMKinetics.getReactionRateParameter().setExpression(Expression.mult(bleachRateExp, new Expression(primarySC.getName())));
}
{
SimpleReaction secondaryBWM = model.createSimpleReaction(cytosol);
GeneralKinetics secondaryBWMKinetics = new GeneralKinetics(secondaryBWM);
secondaryBWM.setKinetics(secondaryBWMKinetics);
secondaryBWM.addReactant(secondarySC, 1);
secondaryBWMKinetics.getReactionRateParameter().setExpression(Expression.mult(bleachRateExp, new Expression(secondarySC.getName())));
}
// create simulation context
SimulationContext simContext = bioModel.addNewSimulationContext("simContext", SimulationContext.Application.NETWORK_DETERMINISTIC);
simContext.setGeometry(geometry);
FeatureMapping cytosolFeatureMapping = (FeatureMapping) simContext.getGeometryContext().getStructureMapping(cytosol);
FeatureMapping extracellularFeatureMapping = (FeatureMapping) simContext.getGeometryContext().getStructureMapping(extracellular);
SubVolume cytSubVolume = geometry.getGeometrySpec().getSubVolume(CYTOSOL_NAME);
SubVolume exSubVolume = geometry.getGeometrySpec().getSubVolume(EXTRACELLULAR_NAME);
// unused? SurfaceClass pmSurfaceClass = geometry.getGeometrySurfaceDescription().getSurfaceClass(exSubVolume, cytSubVolume);
cytosolFeatureMapping.setGeometryClass(cytSubVolume);
extracellularFeatureMapping.setGeometryClass(exSubVolume);
cytosolFeatureMapping.getUnitSizeParameter().setExpression(new Expression(1.0));
extracellularFeatureMapping.getUnitSizeParameter().setExpression(new Expression(1.0));
double fixedFraction = 1.0 - primaryFraction - secondaryFraction;
SpeciesContextSpec immobileSCS = simContext.getReactionContext().getSpeciesContextSpec(immobileSC);
immobileSCS.getInitialConditionParameter().setExpression(new Expression(fixedFraction));
immobileSCS.getDiffusionParameter().setExpression(new Expression(0.0));
SpeciesContextSpec primarySCS = simContext.getReactionContext().getSpeciesContextSpec(primarySC);
primarySCS.getInitialConditionParameter().setExpression(new Expression(primaryFraction));
primarySCS.getDiffusionParameter().setExpression(new Expression(primaryDiffusionRate));
SpeciesContextSpec secondarySCS = simContext.getReactionContext().getSpeciesContextSpec(secondarySC);
secondarySCS.getInitialConditionParameter().setExpression(new Expression(secondaryFraction));
secondarySCS.getDiffusionParameter().setExpression(new Expression(secondaryDiffusionRate));
simContext.getMicroscopeMeasurement().addFluorescentSpecies(immobileSC);
simContext.getMicroscopeMeasurement().addFluorescentSpecies(primarySC);
simContext.getMicroscopeMeasurement().addFluorescentSpecies(secondarySC);
simContext.getMicroscopeMeasurement().setConvolutionKernel(new GaussianConvolutionKernel(new Expression(psfSigma), new Expression(psfSigma)));
MathMapping mathMapping = simContext.createNewMathMapping();
MathDescription mathDesc = mathMapping.getMathDescription();
simContext.setMathDescription(mathDesc);
User owner = context.getDefaultOwner();
int meshSize = (int) (domainSize / deltaX);
if (meshSize % 2 == 0) {
// want an odd-sized mesh in x and y ... so centered at the origin.
meshSize = meshSize + 1;
}
TimeBounds timeBounds = new TimeBounds(0.0, postbleachDuration);
//
// simulation to use for data generation (output time steps as recorded by the microscope)
//
double bleachBlackoutBegin = bleachStart - postbleachDelay;
double bleachBlackoutEnd = bleachEnd + postbleachDelay;
// ArrayList<Double> times = new ArrayList<Double>();
// double time = 0;
// while (time<=timeBounds.getEndingTime()){
// if (time<=bleachBlackoutBegin || time>bleachBlackoutEnd){
// // postbleachDelay is the time it takes to switch the filters.
// times.add(time);
// }
// time += outputTimeStep.getData();
// }
// double[] timeArray = new double[times.size()];
// for (int i=0;i<timeArray.length;i++){
// timeArray[i] = times.get(i);
// }
// OutputTimeSpec fakeDataSimOutputTimeSpec = new ExplicitOutputTimeSpec(timeArray);
OutputTimeSpec fakeDataSimOutputTimeSpec = new UniformOutputTimeSpec(outputTimeStep);
KeyValue fakeDataSimKey = context.createNewKeyValue();
SimulationVersion fakeDataSimVersion = new SimulationVersion(fakeDataSimKey, "fakeDataSim", owner, new GroupAccessNone(), new KeyValue("0"), new BigDecimal(0), new Date(), VersionFlag.Current, "", null);
Simulation fakeDataSim = new Simulation(fakeDataSimVersion, mathDesc);
simContext.addSimulation(fakeDataSim);
fakeDataSim.getSolverTaskDescription().setTimeBounds(timeBounds);
fakeDataSim.getMeshSpecification().setSamplingSize(new ISize(meshSize, meshSize, 1));
fakeDataSim.getSolverTaskDescription().setSolverDescription(SolverDescription.SundialsPDE);
fakeDataSim.getSolverTaskDescription().setOutputTimeSpec(fakeDataSimOutputTimeSpec);
//
// simulation to use for viewing the protocol (output time steps to understand the physics)
//
KeyValue fullExperimentSimKey = context.createNewKeyValue();
SimulationVersion fullExperimentSimVersion = new SimulationVersion(fullExperimentSimKey, "fullExperiment", owner, new GroupAccessNone(), new KeyValue("0"), new BigDecimal(0), new Date(), VersionFlag.Current, "", null);
Simulation fullExperimentSim = new Simulation(fullExperimentSimVersion, mathDesc);
simContext.addSimulation(fullExperimentSim);
OutputTimeSpec fullExperimentOutputTimeSpec = new UniformOutputTimeSpec(outputTimeStep / 10.0);
fullExperimentSim.getSolverTaskDescription().setTimeBounds(timeBounds);
fullExperimentSim.getMeshSpecification().setSamplingSize(new ISize(meshSize, meshSize, 1));
fullExperimentSim.getSolverTaskDescription().setSolverDescription(SolverDescription.SundialsPDE);
fullExperimentSim.getSolverTaskDescription().setOutputTimeSpec(fullExperimentOutputTimeSpec);
GeneratedModelResults results = new GeneratedModelResults();
results.bioModel_2D = bioModel;
results.simulation_2D = fakeDataSim;
results.bleachBlackoutBeginTime = bleachBlackoutBegin;
results.bleachBlackoutEndTime = bleachBlackoutEnd;
return results;
}
use of cbit.vcell.mapping.SpeciesContextSpec in project vcell by virtualcell.
the class StochtestRunService method computeTrials.
private void computeTrials(SimulationContext simContext, StochtestRun stochtestRun, File baseDirectory, OutputTimeSpec outputTimeSpec, double endTime, int numTrials) throws PropertyVetoException, IOException {
//
// make simulation
//
MathMappingCallback callback = new MathMappingCallback() {
@Override
public void setProgressFraction(float fractionDone) {
}
@Override
public void setMessage(String message) {
}
@Override
public boolean isInterrupted() {
return false;
}
};
NetworkGenerationRequirements networkGenerationRequirements = NetworkGenerationRequirements.getComputeFull(bngTimeoutMS);
simContext.refreshMathDescription(callback, networkGenerationRequirements);
Simulation sim = simContext.addNewSimulation("stochtestrun_" + stochtestRun.key, callback, networkGenerationRequirements);
sim.setSimulationOwner(simContext);
//
// get variables to save
//
simContext.getModel().getSpeciesContexts();
ArrayList<String> varNameList = new ArrayList<String>();
for (SpeciesContextSpec scs : simContext.getReactionContext().getSpeciesContextSpecs()) {
varNameList.add(scs.getSpeciesContext().getName());
}
String[] varNames = varNameList.toArray(new String[0]);
//
// get time points to save
//
ArrayList<Double> sampleTimeList = new ArrayList<Double>();
if (outputTimeSpec instanceof UniformOutputTimeSpec) {
double dT = ((UniformOutputTimeSpec) outputTimeSpec).getOutputTimeStep();
int currTimeIndex = 0;
while (currTimeIndex * dT <= (endTime + 1e-8)) {
sampleTimeList.add(currTimeIndex * dT);
currTimeIndex++;
}
}
double[] sampleTimes = new double[sampleTimeList.size()];
for (int i = 0; i < sampleTimes.length; i++) {
sampleTimes[i] = sampleTimeList.get(i);
}
//
// run N trials and save data
//
TimeSeriesMultitrialData sampleData = new TimeSeriesMultitrialData(sim.getName(), varNames, sampleTimes, numTrials);
runsolver(sim, baseDirectory, numTrials, sampleData);
StochtestFileUtils.writeData(sampleData, StochtestFileUtils.getStochtestRunDataFile(baseDir, stochtestRun));
}
use of cbit.vcell.mapping.SpeciesContextSpec in project vcell by virtualcell.
the class StandaloneRuleBasedTest method checkNonspatialStochasticSimContext.
private static void checkNonspatialStochasticSimContext(SimulationContext srcSimContext, File baseDirectory, int numTrials, long bngTimeoutDuration) throws Exception {
if (!srcSimContext.getApplicationType().equals(Application.NETWORK_STOCHASTIC) || srcSimContext.getGeometry().getDimension() != 0) {
throw new RuntimeException("simContext is of type " + srcSimContext.getApplicationType() + " and geometry dimension of " + srcSimContext.getGeometry().getDimension() + ", expecting nonspatial stochastic");
}
BioModel origBioModel = srcSimContext.getBioModel();
BioModel bioModel = XmlHelper.XMLToBioModel(new XMLSource(XmlHelper.bioModelToXML(origBioModel)));
bioModel.refreshDependencies();
// create ODE and RuleBased
SimulationContext newODEApp = SimulationContext.copySimulationContext(srcSimContext, "aUniqueNewODEApp", false, Application.NETWORK_DETERMINISTIC);
SimulationContext newRuleBasedApp = SimulationContext.copySimulationContext(srcSimContext, "aUniqueNewRuleBasedApp", false, Application.RULE_BASED_STOCHASTIC);
newODEApp.setBioModel(bioModel);
newRuleBasedApp.setBioModel(bioModel);
ArrayList<AnnotatedFunction> outputFunctionsList = srcSimContext.getOutputFunctionContext().getOutputFunctionsList();
// OutputContext outputContext = new OutputContext(outputFunctionsList.toArray(new AnnotatedFunction[outputFunctionsList.size()]));
newODEApp.getOutputFunctionContext().setOutputFunctions(outputFunctionsList);
newRuleBasedApp.getOutputFunctionContext().setOutputFunctions(outputFunctionsList);
NetworkGenerationRequirements networkGenRequirements = NetworkGenerationRequirements.getComputeFull(bngTimeoutDuration);
bioModel.addSimulationContext(newODEApp);
newODEApp.refreshMathDescription(new MathMappingCallbackTaskAdapter(null), networkGenRequirements);
bioModel.addSimulationContext(newRuleBasedApp);
newRuleBasedApp.refreshMathDescription(new MathMappingCallbackTaskAdapter(null), networkGenRequirements);
srcSimContext.refreshMathDescription(new MathMappingCallbackTaskAdapter(null), networkGenRequirements);
// Create non-spatialStoch, ODE and RuleBased sims
Simulation nonspatialStochAppNewSim = srcSimContext.addNewSimulation(STOCH_SIM_NAME, /*SimulationOwner.DEFAULT_SIM_NAME_PREFIX*/
new MathMappingCallbackTaskAdapter(null), networkGenRequirements);
Simulation newODEAppNewSim = newODEApp.addNewSimulation(ODE_SIM_NAME, new MathMappingCallbackTaskAdapter(null), networkGenRequirements);
Simulation newRuleBasedAppNewSim = newRuleBasedApp.addNewSimulation(NFS_SIM_NAME, new MathMappingCallbackTaskAdapter(null), networkGenRequirements);
nonspatialStochAppNewSim.setSimulationOwner(srcSimContext);
newODEAppNewSim.setSimulationOwner(newODEApp);
newRuleBasedAppNewSim.setSimulationOwner(newRuleBasedApp);
try {
bioModel.getModel().getSpeciesContexts();
ArrayList<String> varNameList = new ArrayList<String>();
for (SpeciesContextSpec scs : srcSimContext.getReactionContext().getSpeciesContextSpecs()) {
varNameList.add(scs.getSpeciesContext().getName());
}
String[] varNames = varNameList.toArray(new String[0]);
OutputTimeSpec outputTimeSpec = nonspatialStochAppNewSim.getSolverTaskDescription().getOutputTimeSpec();
ArrayList<Double> sampleTimeList = new ArrayList<Double>();
if (outputTimeSpec instanceof UniformOutputTimeSpec) {
double endingTime = nonspatialStochAppNewSim.getSolverTaskDescription().getTimeBounds().getEndingTime();
double dT = ((UniformOutputTimeSpec) outputTimeSpec).getOutputTimeStep();
int currTimeIndex = 0;
while (currTimeIndex * dT <= (endingTime + 1e-8)) {
sampleTimeList.add(currTimeIndex * dT);
currTimeIndex++;
}
}
double[] sampleTimes = new double[sampleTimeList.size()];
for (int i = 0; i < sampleTimes.length; i++) {
sampleTimes[i] = sampleTimeList.get(i);
}
TimeSeriesMultitrialData sampleDataStoch1 = new TimeSeriesMultitrialData("stochastic1", varNames, sampleTimes, numTrials);
TimeSeriesMultitrialData sampleDataStoch2 = new TimeSeriesMultitrialData("stochastic2", varNames, sampleTimes, numTrials);
TimeSeriesMultitrialData sampleDataDeterministic = new TimeSeriesMultitrialData("determinstic", varNames, sampleTimes, 1);
runsolver(nonspatialStochAppNewSim, baseDirectory, numTrials, sampleDataStoch1);
runsolver(newODEAppNewSim, baseDirectory, 1, sampleDataDeterministic);
runsolver(newRuleBasedAppNewSim, baseDirectory, numTrials, sampleDataStoch2);
StochtestFileUtils.writeVarDiffData(new File(baseDirectory, VARDIFF_FILE), sampleDataStoch1, sampleDataStoch2);
StochtestFileUtils.writeKolmogorovSmirnovTest(new File(baseDirectory, KS_TEST_FILE), sampleDataStoch1, sampleDataStoch2);
StochtestFileUtils.writeChiSquareTest(new File(baseDirectory, ChiSquared_TEST_FILE), sampleDataStoch1, sampleDataStoch2);
StochtestFileUtils.writeData(sampleDataStoch1, new File(baseDirectory, "data." + sampleDataStoch1.datasetName + ".json"));
StochtestFileUtils.writeData(sampleDataStoch2, new File(baseDirectory, "data." + sampleDataStoch2.datasetName + ".json"));
StochtestFileUtils.writeData(sampleDataDeterministic, new File(baseDirectory, "data." + sampleDataDeterministic.datasetName + ".json"));
} finally {
srcSimContext.removeSimulation(nonspatialStochAppNewSim);
newODEApp.removeSimulation(newODEAppNewSim);
newRuleBasedApp.removeSimulation(newRuleBasedAppNewSim);
}
}
use of cbit.vcell.mapping.SpeciesContextSpec in project vcell by virtualcell.
the class BioModelEditor method setRightBottomPanelOnSelection.
@Override
protected void setRightBottomPanelOnSelection(Object[] selections) {
if (selections == null) {
return;
}
JComponent bottomComponent = rightBottomEmptyPanel;
int destComponentIndex = DocumentEditorTabID.object_properties.ordinal();
boolean bShowInDatabaseProperties = false;
boolean bShowPathway = false;
if (selections.length == 1) {
Object singleSelection = selections[0];
if (singleSelection instanceof ReactionStep) {
bottomComponent = getReactionPropertiesPanel();
} else if (singleSelection instanceof ReactionRule) {
bottomComponent = getReactionRulePropertiesPanel();
} else if (singleSelection instanceof SpeciesContext) {
bottomComponent = getSpeciesPropertiesPanel();
} else if (singleSelection instanceof MolecularType) {
bottomComponent = getMolecularTypePropertiesPanel();
} else if (singleSelection instanceof RbmObservable) {
bottomComponent = getObservablePropertiesPanel();
} else if (singleSelection instanceof Structure) {
bottomComponent = getStructurePropertiesPanel();
getStructurePropertiesPanel().setModel(bioModel.getModel());
} else if (singleSelection instanceof Parameter) {
bottomComponent = getParameterPropertiesPanel();
} else if (singleSelection instanceof SimulationContext) {
bottomComponent = getApplicationPropertiesPanel();
} else if (singleSelection instanceof ParameterEstimationTask) {
bottomComponent = parameterEstimationTaskPropertiesPanel;
} else if (singleSelection instanceof Product || singleSelection instanceof Reactant) {
bottomComponent = getReactionParticipantPropertiesPanel();
} else if (singleSelection instanceof BioModelInfo) {
bShowInDatabaseProperties = true;
bottomComponent = bioModelMetaDataPanel;
} else if (singleSelection instanceof MathModelInfo) {
bShowInDatabaseProperties = true;
bottomComponent = mathModelMetaDataPanel;
} else if (singleSelection instanceof GeometryInfo) {
bShowInDatabaseProperties = true;
bottomComponent = geometryMetaDataPanel;
} else if (singleSelection instanceof SpeciesContextSpec) {
bottomComponent = getSpeciesContextSpecPanel();
} else if (singleSelection instanceof ReactionSpec) {
bottomComponent = getKineticsTypeTemplatePanel();
} else if (singleSelection instanceof ReactionRuleSpec) {
//
bottomComponent = getReactionRuleSpecPropertiesPanel();
} else if (singleSelection instanceof BioModelsNetModelInfo) {
bShowInDatabaseProperties = true;
bottomComponent = getBioModelsNetPropertiesPanel();
} else if (singleSelection instanceof Simulation) {
bottomComponent = getSimulationSummaryPanel();
} else if (singleSelection instanceof DataSymbol) {
bottomComponent = getDataSymbolsSpecPanel();
} else if (singleSelection instanceof BioEvent) {
bottomComponent = getEventPanel();
} else if (singleSelection instanceof SpatialObject) {
bottomComponent = getSpatialObjectPropertyPanel();
} else if (singleSelection instanceof SpatialProcess) {
bottomComponent = getSpatialProcessPropertyPanel();
} else if (singleSelection instanceof BioPaxObject) {
bottomComponent = bioPaxObjectPropertiesPanel;
} else if (singleSelection instanceof BioModel || singleSelection instanceof VCMetaData) {
bottomComponent = bioModelEditorAnnotationPanel;
} else if (singleSelection instanceof PathwayData) {
bShowPathway = true;
bottomComponent = getBioModelEditorPathwayPanel();
} else if (singleSelection instanceof Model) {
} else if (singleSelection instanceof RuleParticipantSignature) {
bottomComponent = getReactionRuleParticipantSignaturePropertiesPanel();
} else if (singleSelection instanceof CSGObject) {
bottomComponent = csgObjectPropertiesPanel;
csgObjectPropertiesPanel.setSimulationContext(getSelectedSimulationContext());
} else if (singleSelection instanceof DocumentEditorTreeFolderNode) {
DocumentEditorTreeFolderClass folderClass = ((DocumentEditorTreeFolderNode) singleSelection).getFolderClass();
if ((folderClass == DocumentEditorTreeFolderClass.REACTIONS_NODE) && !(singleSelection instanceof ReactionRule)) {
bottomComponent = getReactionPropertiesPanel();
} else if ((folderClass == DocumentEditorTreeFolderClass.REACTIONS_NODE) && (singleSelection instanceof ReactionRule)) {
bottomComponent = getReactionRulePropertiesPanel();
} else if (folderClass == DocumentEditorTreeFolderClass.STRUCTURES_NODE) {
bottomComponent = getStructurePropertiesPanel();
} else if (folderClass == DocumentEditorTreeFolderClass.SPECIES_NODE) {
bottomComponent = getSpeciesPropertiesPanel();
} else if (folderClass == DocumentEditorTreeFolderClass.MOLECULAR_TYPES_NODE) {
bottomComponent = getMolecularTypePropertiesPanel();
} else if (folderClass == DocumentEditorTreeFolderClass.OBSERVABLES_NODE) {
bottomComponent = getObservablePropertiesPanel();
} else if (folderClass == DocumentEditorTreeFolderClass.APPLICATIONS_NODE) {
bottomComponent = getApplicationsPropertiesPanel();
getApplicationsPropertiesPanel().setBioModel(bioModel);
} else if (folderClass == DocumentEditorTreeFolderClass.PARAMETER_ESTIMATION_NODE) {
bottomComponent = parameterEstimationTaskPropertiesPanel;
}
}
}
if (bShowPathway) {
for (destComponentIndex = 0; destComponentIndex < rightBottomTabbedPane.getTabCount(); destComponentIndex++) {
if (rightBottomTabbedPane.getComponentAt(destComponentIndex) == bottomComponent) {
break;
}
}
String tabTitle = "Pathway Preview";
if (rightBottomTabbedPane.getTabCount() == destComponentIndex) {
rightBottomTabbedPane.addTab(tabTitle, new TabCloseIcon(), bottomComponent);
}
} else if (bShowInDatabaseProperties) {
for (destComponentIndex = 0; destComponentIndex < rightBottomTabbedPane.getTabCount(); destComponentIndex++) {
Component c = rightBottomTabbedPane.getComponentAt(destComponentIndex);
if (c == bioModelMetaDataPanel || c == mathModelMetaDataPanel || c == geometryMetaDataPanel || c == getBioModelsNetPropertiesPanel()) {
break;
}
}
if (rightBottomTabbedPane.getTabCount() == destComponentIndex) {
rightBottomTabbedPane.addTab(DATABASE_PROPERTIES_TAB_TITLE, new TabCloseIcon(), bottomComponent);
}
}
if (rightBottomTabbedPane.getComponentAt(destComponentIndex) != bottomComponent) {
bottomComponent.setBorder(GuiConstants.TAB_PANEL_BORDER);
rightBottomTabbedPane.setComponentAt(destComponentIndex, bottomComponent);
rightSplitPane.repaint();
}
if (rightBottomTabbedPane.getSelectedComponent() != bottomComponent) {
rightBottomTabbedPane.setSelectedComponent(bottomComponent);
}
}
use of cbit.vcell.mapping.SpeciesContextSpec in project vcell by virtualcell.
the class VFrapXmlHelper method ReplaceVFrapNamesWithSymbolNames.
//
// replace vFrap default names in field function arguments with data symbol names -----
//
public static void ReplaceVFrapNamesWithSymbolNames(BioModel bioModel) throws ExpressionException {
SimulationContext simContext = bioModel.getSimulationContexts()[0];
SpeciesContextSpec[] scsArray = simContext.getReactionContext().getSpeciesContextSpecs();
for (SpeciesContextSpec scs : scsArray) {
// vFrap('a','c',0.0,'volume')
Expression exp = scs.getInitialConditionParameter().getExpression();
FieldFunctionArguments[] fieldFunctionArgs = FieldUtilities.getFieldFunctionArguments(exp);
if (fieldFunctionArgs != null && fieldFunctionArgs.length > 0) {
for (FieldFunctionArguments args : fieldFunctionArgs) {
for (DataSymbol ds : simContext.getDataContext().getDataSymbols()) {
if (ds instanceof FieldDataSymbol) {
FieldDataSymbol fieldDataSymbol = (FieldDataSymbol) ds;
// String extDataIdentName = fieldDataSymbol.getExternalDataIdentifier().getName(); // name of field data
// String argsFieldName = args.getFieldName(); // roiData
// fieldDataSymbol.getFieldDataVarTime() == args.getTime().evaluateConstant()
// name of data symbol ex: postbleach_first_ccccF
String dataSymbolName = fieldDataSymbol.getName();
// name in expression as it comes from vFrap ex: postbleach_first
String argsVariableName = args.getVariableName();
if (dataSymbolName.startsWith(argsVariableName)) {
// vcField('roiData','postbleach_first',0.0,'Volume')
String oldExpression = args.infix();
exp.substituteInPlace(new Expression(oldExpression), new Expression(dataSymbolName));
exp.bindExpression(simContext);
}
}
}
}
}
}
}
Aggregations