use of cbit.vcell.math.Variable.Domain in project vcell by virtualcell.
the class MathDescription method read_database.
/**
* This method was created by a SmartGuide.
* @param tokens java.util.StringTokenizer
* @exception java.lang.Exception The exception description.
*/
public void read_database(CommentStringTokenizer tokens) throws MathException {
clearAll();
VariableHash varHash = new VariableHash();
try {
Token token = tokens.next();
if (token.getValue().equalsIgnoreCase(VCML.MathDescription)) {
// token = tokens.nextToken();
// setName(token);
// CHECK THIS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// if(!token.equals(argName)){
// throw new DataAccessException("MathDescription Version Name and Token Name Don't match");
// }
String tokenStr = tokens.nextToken();
if (!tokenStr.equalsIgnoreCase(VCML.BeginBlock)) {
throw new MathException("unexpected token " + tokenStr + " expecting " + VCML.BeginBlock);
}
}
while (tokens.hasMoreTokens()) {
token = tokens.next();
String tokenStr = token.getValue();
if (tokenStr.equalsIgnoreCase(VCML.EndBlock)) {
break;
}
if (tokenStr.equalsIgnoreCase(VCML.VolumeVariable)) {
tokenStr = tokens.nextToken();
Domain domain = Variable.getDomainFromCombinedIdentifier(tokenStr);
String name = Variable.getNameFromCombinedIdentifier(tokenStr);
VolVariable var = new VolVariable(name, domain);
transcribeComments(var, token);
varHash.addVariable(var);
// addVariable0(outside);
continue;
}
//
if (tokenStr.equalsIgnoreCase(VCML.Task)) {
while (tokens.hasMoreTokens()) {
// toss away until end of block
tokenStr = tokens.nextToken();
if (tokenStr.equalsIgnoreCase(VCML.EndBlock)) {
break;
}
}
continue;
}
if (tokenStr.equalsIgnoreCase(VCML.MembraneVariable)) {
tokenStr = tokens.nextToken();
Domain domain = Variable.getDomainFromCombinedIdentifier(tokenStr);
String name = Variable.getNameFromCombinedIdentifier(tokenStr);
MemVariable var = new MemVariable(name, domain);
transcribeComments(var, token);
varHash.addVariable(var);
continue;
}
if (tokenStr.equalsIgnoreCase(VCML.FilamentVariable)) {
tokenStr = tokens.nextToken();
Domain domain = Variable.getDomainFromCombinedIdentifier(tokenStr);
String name = Variable.getNameFromCombinedIdentifier(tokenStr);
FilamentVariable var = new FilamentVariable(name, domain);
transcribeComments(var, token);
varHash.addVariable(var);
continue;
}
if (tokenStr.equalsIgnoreCase(VCML.PointVariable)) {
tokenStr = tokens.nextToken();
Domain domain = Variable.getDomainFromCombinedIdentifier(tokenStr);
String name = Variable.getNameFromCombinedIdentifier(tokenStr);
PointVariable var = new PointVariable(name, domain);
transcribeComments(var, token);
varHash.addVariable(var);
continue;
}
if (tokenStr.equalsIgnoreCase(VCML.VolumeRegionVariable)) {
tokenStr = tokens.nextToken();
Domain domain = Variable.getDomainFromCombinedIdentifier(tokenStr);
String name = Variable.getNameFromCombinedIdentifier(tokenStr);
VolumeRegionVariable var = new VolumeRegionVariable(name, domain);
transcribeComments(var, token);
varHash.addVariable(var);
continue;
}
if (tokenStr.equalsIgnoreCase(VCML.MembraneRegionVariable)) {
tokenStr = tokens.nextToken();
Domain domain = Variable.getDomainFromCombinedIdentifier(tokenStr);
String name = Variable.getNameFromCombinedIdentifier(tokenStr);
MembraneRegionVariable var = new MembraneRegionVariable(name, domain);
transcribeComments(var, token);
varHash.addVariable(var);
continue;
}
if (tokenStr.equalsIgnoreCase(VCML.FilamentRegionVariable)) {
tokenStr = tokens.nextToken();
Domain domain = Variable.getDomainFromCombinedIdentifier(tokenStr);
String name = Variable.getNameFromCombinedIdentifier(tokenStr);
FilamentRegionVariable var = new FilamentRegionVariable(name, domain);
transcribeComments(var, token);
varHash.addVariable(var);
continue;
}
if (tokenStr.equalsIgnoreCase(VCML.Constant)) {
tokenStr = tokens.nextToken();
Expression exp = MathFunctionDefinitions.fixFunctionSyntax(tokens);
Constant constant = new Constant(tokenStr, exp);
transcribeComments(constant, token);
varHash.addVariable(constant);
continue;
}
if (tokenStr.equalsIgnoreCase("Parameter")) {
tokenStr = tokens.nextToken();
ParameterVariable pv = new ParameterVariable(tokenStr);
transcribeComments(pv, token);
varHash.addVariable(pv);
continue;
}
// stochastic variable
if (tokenStr.equalsIgnoreCase(VCML.StochVolVariable)) {
tokenStr = tokens.nextToken();
String name = Variable.getNameFromCombinedIdentifier(tokenStr);
StochVolVariable var = new StochVolVariable(name);
transcribeComments(var, token);
varHash.addVariable(var);
continue;
}
if (tokenStr.equalsIgnoreCase(VCML.VolumeParticleVariable)) {
tokenStr = tokens.nextToken();
Domain domain = Variable.getDomainFromCombinedIdentifier(tokenStr);
String name = Variable.getNameFromCombinedIdentifier(tokenStr);
VolumeParticleVariable var = new VolumeParticleVariable(name, domain);
transcribeComments(var, token);
varHash.addVariable(var);
continue;
}
if (tokenStr.equalsIgnoreCase(VCML.MembraneParticleVariable)) {
tokenStr = tokens.nextToken();
Domain domain = Variable.getDomainFromCombinedIdentifier(tokenStr);
String name = Variable.getNameFromCombinedIdentifier(tokenStr);
MembraneParticleVariable var = new MembraneParticleVariable(name, domain);
transcribeComments(var, token);
varHash.addVariable(var);
continue;
}
if (tokenStr.equalsIgnoreCase(VCML.ParticleMolecularType)) {
tokenStr = tokens.nextToken();
String name = tokenStr;
ParticleMolecularType particleMolecularType = new ParticleMolecularType(name);
particleMolecularType.read(tokens);
addParticleMolecularType(particleMolecularType);
continue;
}
if (tokenStr.equalsIgnoreCase(VCML.VolumeParticleObservable)) {
tokenStr = tokens.nextToken();
Domain domain = Variable.getDomainFromCombinedIdentifier(tokenStr);
String name = Variable.getNameFromCombinedIdentifier(tokenStr);
VolumeParticleObservable particle = new VolumeParticleObservable(name, domain, ObservableType.Molecules);
// TODO: here
particle.read(this, tokens, varHash);
varHash.addVariable(particle);
continue;
}
if (tokenStr.equalsIgnoreCase(VCML.VolumeParticleSpeciesPattern)) {
tokenStr = tokens.nextToken();
Domain domain = Variable.getDomainFromCombinedIdentifier(tokenStr);
String name = Variable.getNameFromCombinedIdentifier(tokenStr);
// will set the locationName inside .read()
VolumeParticleSpeciesPattern var = new VolumeParticleSpeciesPattern(name, domain, null);
var.read(this, tokens);
// this is not really a variable and shouldn't be in the hash
// sadly the way we check consistency for compartments makes in necessary
varHash.addVariable(var);
continue;
}
if (tokenStr.equalsIgnoreCase(VCML.Function)) {
tokenStr = tokens.nextToken();
Expression exp = MathFunctionDefinitions.fixFunctionSyntax(tokens);
Domain domain = Variable.getDomainFromCombinedIdentifier(tokenStr);
String name = Variable.getNameFromCombinedIdentifier(tokenStr);
/**
* ---------------------------------------------------------------
* ATTENTATION: this is a quick fix for a specific user to load his model
* with a function name as "ATP/ADP". This syntax is not allowed.
*-----------------------------------------------------------------------
*/
if (name.equals("ATP/ADP")) {
name = "ATP_ADP_renamed";
System.err.print("Applying species function name change ATP/ADP to ATP_ADP for a specific user (key=2288008)");
Thread.dumpStack();
}
Function function = new Function(name, exp, domain);
transcribeComments(function, token);
varHash.addVariable(function);
continue;
}
if (tokenStr.equalsIgnoreCase(VCML.CompartmentSubDomain)) {
if (variableList.size() == 0) {
setAllVariables(varHash.getAlphabeticallyOrderedVariables());
}
CompartmentSubDomain subDomain = new CompartmentSubDomain(token, this, tokens);
addSubDomain0(subDomain);
continue;
}
if (tokenStr.equalsIgnoreCase(VCML.MembraneSubDomain)) {
if (variableList.size() == 0) {
setAllVariables(varHash.getAlphabeticallyOrderedVariables());
}
MembraneSubDomain subDomain = MembraneSubDomain.create(this, token, tokens);
addSubDomain0(subDomain);
continue;
}
if (tokenStr.equalsIgnoreCase(VCML.FilamentSubDomain)) {
if (variableList.size() == 0) {
setAllVariables(varHash.getAlphabeticallyOrderedVariables());
}
tokenStr = tokens.nextToken();
String subDomainName = tokenStr;
tokenStr = tokens.nextToken();
CompartmentSubDomain outsideCompartment = getCompartmentSubDomain(tokenStr);
if (outsideCompartment == null) {
throw new MathFormatException("defined membrane subdomain without a corresponding outside volume subdomain first");
}
FilamentSubDomain subDomain = new FilamentSubDomain(subDomainName, outsideCompartment);
subDomain.read(this, tokens);
addSubDomain0(subDomain);
continue;
}
if (tokenStr.equalsIgnoreCase(VCML.PointSubDomain)) {
if (variableList.size() == 0) {
setAllVariables(varHash.getAlphabeticallyOrderedVariables());
}
tokenStr = tokens.nextToken();
String subDomainName = tokenStr;
PointSubDomain subDomain = new PointSubDomain(subDomainName);
subDomain.parseBlock(this, tokens);
addSubDomain0(subDomain);
continue;
}
//
if (tokenStr.equalsIgnoreCase(VCML.Mesh)) {
while (tokens.hasMoreTokens()) {
// toss away until end of block
tokenStr = tokens.nextToken();
if (tokenStr.equalsIgnoreCase(VCML.EndBlock)) {
break;
}
}
continue;
}
if (tokenStr.equalsIgnoreCase(VCML.Event)) {
if (variableList.size() == 0) {
setAllVariables(varHash.getAlphabeticallyOrderedVariables());
}
// Event event = new Event(tokenStr, this, tokens);
Event event = new Event(token, this, tokens);
eventList.add(event);
continue;
}
if (tokenStr.equalsIgnoreCase(VCML.VolumeRandomVariable)) {
tokenStr = tokens.nextToken();
Domain domain = Variable.getDomainFromCombinedIdentifier(tokenStr);
String name = Variable.getNameFromCombinedIdentifier(tokenStr);
RandomVariable randomVariable = new VolumeRandomVariable(name, this, tokens, domain);
transcribeComments(randomVariable, token);
varHash.addVariable(randomVariable);
continue;
}
if (tokenStr.equalsIgnoreCase(VCML.MembraneRandomVariable)) {
tokenStr = tokens.nextToken();
Domain domain = Variable.getDomainFromCombinedIdentifier(tokenStr);
String name = Variable.getNameFromCombinedIdentifier(tokenStr);
RandomVariable randomVariable = new MembraneRandomVariable(name, this, tokens, domain);
transcribeComments(randomVariable, token);
varHash.addVariable(randomVariable);
continue;
}
if (tokenStr.equalsIgnoreCase(VCML.PostProcessingBlock)) {
postProcessingBlock.read(tokens);
continue;
}
throw new MathFormatException("unexpected identifier " + tokenStr);
}
} catch (Throwable e) {
e.printStackTrace(System.out);
throw new MathException("line #" + tokens.lineIndex() + " Exception: " + e.getMessage());
}
refreshDependencies();
fireStateChanged();
}
use of cbit.vcell.math.Variable.Domain in project vcell by virtualcell.
the class ParticleMathMapping method refreshVariables.
/**
* This method was created in VisualAge.
* @Override
*/
private void refreshVariables() throws MappingException {
Enumeration<SpeciesContextMapping> enum1 = getSpeciesContextMappings();
//
// non-constant independent variables require either a membrane or volume variable
//
enum1 = getSpeciesContextMappings();
while (enum1.hasMoreElements()) {
SpeciesContextMapping scm = (SpeciesContextMapping) enum1.nextElement();
SpeciesContextSpec scs = getSimulationContext().getReactionContext().getSpeciesContextSpec(scm.getSpeciesContext());
// if (scm.getDependencyExpression() == null && (!scs.isConstant() || getSimulationContext().hasEventAssignment(scs.getSpeciesContext()))){
StructureMapping sm = getSimulationContext().getGeometryContext().getStructureMapping(scm.getSpeciesContext().getStructure());
Structure struct = scm.getSpeciesContext().getStructure();
Domain domain = null;
if (sm.getGeometryClass() != null) {
domain = new Domain(sm.getGeometryClass());
}
if (struct instanceof Feature || struct instanceof Membrane) {
if (sm.getGeometryClass() instanceof SurfaceClass) {
if (scs.isWellMixed()) {
// scm.setVariable(new StochMembraneRegionVariable(scm.getSpeciesContext().getName(),domain));
throw new MappingException("stochastic membrane region variables not yet supported");
} else {
scm.setVariable(new MembraneParticleVariable(scm.getSpeciesContext().getName(), domain));
}
} else {
if (scs.isWellMixed()) {
throw new MappingException("stochastic volume region variables not yet supported");
// scm.setVariable(new StochVolumeRegionVariable(scm.getSpeciesContext().getName(),domain));
} else {
scm.setVariable(new VolumeParticleVariable(scm.getSpeciesContext().getName(), domain));
}
}
} else {
throw new MappingException("class " + scm.getSpeciesContext().getStructure().getClass() + " not supported");
}
mathSymbolMapping.put(scm.getSpeciesContext(), scm.getVariable().getName());
// }
}
}
use of cbit.vcell.math.Variable.Domain in project vcell by virtualcell.
the class PostProcessingBlock method read.
public void read(CommentStringTokenizer tokens) throws ExpressionException, MathException {
String token = null;
token = tokens.nextToken();
if (!token.equalsIgnoreCase(VCML.BeginBlock)) {
throw new MathFormatException("unexpected token " + token + " expecting " + VCML.BeginBlock);
}
while (tokens.hasMoreTokens()) {
token = tokens.nextToken();
if (token.equalsIgnoreCase(VCML.EndBlock)) {
break;
}
if (token.equalsIgnoreCase(VCML.ExplicitDataGenerator)) {
token = tokens.nextToken();
Domain domain = Variable.getDomainFromCombinedIdentifier(token);
String name = Variable.getNameFromCombinedIdentifier(token);
Expression exp = new Expression(tokens.readToSemicolon());
DataGenerator dataGenerator = new ExplicitDataGenerator(name, domain, exp);
addDataGenerator(dataGenerator);
continue;
}
if (token.equalsIgnoreCase(VCML.ProjectionDataGenerator)) {
token = tokens.nextToken();
Domain domain = Variable.getDomainFromCombinedIdentifier(token);
String name = Variable.getNameFromCombinedIdentifier(token);
DataGenerator dataGenerator = new ProjectionDataGenerator(name, domain, tokens);
addDataGenerator(dataGenerator);
continue;
}
if (token.equalsIgnoreCase(VCML.ConvolutionDataGenerator)) {
token = tokens.nextToken();
DataGenerator dataGenerator = new ConvolutionDataGenerator(token, tokens);
addDataGenerator(dataGenerator);
continue;
}
}
}
use of cbit.vcell.math.Variable.Domain in project vcell by virtualcell.
the class PDEDataViewer method showSpatialPlot.
/**
* Comment
*/
private void showSpatialPlot() {
// check selections
final SpatialSelection[] sl = getPDEDataContextPanel1().fetchSpatialSelections(false, true);
if (sl == null) {
PopupGenerator.showErrorDialog(this, "Nothing selected!");
return;
}
for (int i = 0; i < sl.length; i++) {
if (sl[i].isPoint()) {
PopupGenerator.showErrorDialog(this, "One or more selections are single points - no spatial plot will be produced for those selections");
break;
}
}
final String varName = getPdeDataContext().getVariableName();
final double timePoint = getPdeDataContext().getTimePoint();
final SymbolTableEntry[] symbolTableEntries = new SymbolTableEntry[1];
if (getSimulation() != null && getSimulation().getMathDescription() != null) {
symbolTableEntries[0] = getSimulation().getMathDescription().getEntry(varName);
}
if (symbolTableEntries[0] == null) {
// TODO domain
Domain domain = null;
symbolTableEntries[0] = new VolVariable(varName, domain);
}
AsynchClientTask task1 = new AsynchClientTask("Retrieving spatial series for variable '" + varName, AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
// get plots, ignoring points
PlotData[] plotDatas = new PlotData[sl.length];
for (int i = 0; i < sl.length; i++) {
PlotData plotData = null;
if (getPdeDataContext() instanceof PDEDataViewerPostProcess.PostProcessDataPDEDataContext) {
SpatialSelectionVolume ssVolume = (SpatialSelectionVolume) sl[i];
SpatialSelection.SSHelper ssvHelper = ssVolume.getIndexSamples(0.0, 1.0);
ssvHelper.initializeValues_VOLUME(getPdeDataContext().getDataValues());
double[] values = ssvHelper.getSampledValues();
plotData = new PlotData(ssvHelper.getWorldCoordinateLengths(), values);
} else {
plotData = getPdeDataContext().getLineScan(varName, timePoint, sl[i]);
}
plotDatas[i] = plotData;
}
hashTable.put("plotDatas", plotDatas);
}
};
AsynchClientTask task2 = new AsynchClientTask("Showing spatial plot for variable" + varName, AsynchClientTask.TASKTYPE_SWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
PlotData[] plotDatas = (PlotData[]) hashTable.get("plotDatas");
for (PlotData plotData : plotDatas) {
if (plotData != null) {
PlotPane plotPane = new PlotPane();
Plot2D plot2D = new Plot2D(symbolTableEntries, getSimulationModelInfo().getDataSymbolMetadataResolver(), new String[] { varName }, new PlotData[] { plotData }, new String[] { "Values along curve", "Distance (\u00b5m)", "[" + varName + "]" });
plotPane.setPlot2D(plot2D);
String title = createContextTitle(PDEDataViewer.this.isPostProcess(), "Spatial Plot:'" + varName + "' ", getPdeDataContext(), getSimulationModelInfo(), getSimulation());
ChildWindowManager childWindowManager = ChildWindowManager.findChildWindowManager(PDEDataViewer.this);
ChildWindow childWindow = childWindowManager.addChildWindow(plotPane, plotPane, title);
childWindow.setIsCenteredOnParent();
childWindow.pack();
childWindow.show();
// System.out.println("Spatial plot requesting focus. Result is: "+childWindow.requestFocusInWindow());
}
}
}
};
ClientTaskDispatcher.dispatch(this, new Hashtable<String, Object>(), new AsynchClientTask[] { task1, task2 }, false);
}
use of cbit.vcell.math.Variable.Domain in project vcell by virtualcell.
the class XmlReader method getMemVariable.
/**
* This method returns a MemVariable object from a XML element.
* Creation date: (5/16/2001 3:17:18 PM)
* @return cbit.vcell.math.MemVariable
* @param param org.jdom.Element
*/
private MemVariable getMemVariable(Element param) {
String name = unMangle(param.getAttributeValue(XMLTags.NameAttrTag));
String domainStr = unMangle(param.getAttributeValue(XMLTags.DomainAttrTag));
Domain domain = null;
if (domainStr != null) {
domain = new Domain(domainStr);
}
// Create new memVariable
MemVariable memVariable = new MemVariable(name, domain);
transcribeComments(param, memVariable);
return memVariable;
}
Aggregations