use of cbit.vcell.server.bionetgen.BNGOutput in project vcell by virtualcell.
the class RulebasedTransformer method generateNetwork.
private void generateNetwork(SimulationContext simContext, Set<ReactionRule> fromReactions, MathMappingCallback mathMappingCallback) throws ClassNotFoundException, IOException {
TaskCallbackMessage tcm;
BNGOutputSpec outputSpec;
speciesEquivalenceMap.clear();
kineticsParameterMap.clear();
NetworkGenerationRequirements networkGenerationRequirements = NetworkGenerationRequirements.ComputeFullStandardTimeout;
String input = convertToBngl(simContext, true, mathMappingCallback, networkGenerationRequirements);
// System.out.println(input); // TODO: uncomment to see the xml string
for (Map.Entry<FakeSeedSpeciesInitialConditionsParameter, Pair<SpeciesContext, Expression>> entry : speciesEquivalenceMap.entrySet()) {
FakeSeedSpeciesInitialConditionsParameter key = entry.getKey();
Pair<SpeciesContext, Expression> value = entry.getValue();
SpeciesContext sc = value.one;
Expression initial = value.two;
System.out.println("key: " + key.fakeParameterName + ", species: " + sc.getName() + ", initial: " + initial.infix());
}
BNGInput bngInput = new BNGInput(input);
BNGOutput bngOutput = null;
try {
// for the writeXML command we don't want to run iteration by iteration - it wouldn't even make sense since we don't flatten anything
// so we run bionetgen the "old" way
final BNGExecutorService bngService = BNGExecutorService.getInstanceOld(bngInput, networkGenerationRequirements.timeoutDurationMS);
bngOutput = bngService.executeBNG();
} catch (RuntimeException ex) {
ex.printStackTrace(System.out);
// rethrow without losing context
throw ex;
} catch (Exception ex) {
ex.printStackTrace(System.out);
throw new RuntimeException(ex.getMessage());
}
simContext.setInsufficientIterations(false);
simContext.setInsufficientMaxMolecules(false);
String bngConsoleString = bngOutput.getConsoleOutput();
tcm = new TaskCallbackMessage(TaskCallbackStatus.DetailBatch, bngConsoleString);
// simContext.appendToConsole(tcm);
// String bngNetString = bngOutput.getNetFileContent();
// outputSpec = BNGOutputFileParser.createBngOutputSpec(bngNetString);
// //BNGOutputFileParser.printBNGNetOutput(outputSpec); // prints all output to console
//
// if (mathMappingCallback.isInterrupted()){
// String msg = "Canceled by user.";
// // tcm = new TaskCallbackMessage(TaskCallbackStatus.Error, msg);
// // simContext.appendToConsole(tcm);
// // simContext.setMd5hash(null); // clean the cache if the user interrupts
// throw new UserCancelException(msg);
// }
// if(outputSpec.getBNGSpecies().length > SimulationConsolePanel.speciesLimit) {
// String message = SimulationConsolePanel.getSpeciesLimitExceededMessage(outputSpec);
// // tcm = new TaskCallbackMessage(TaskCallbackStatus.Error, message);
// // simContext.appendToConsole(tcm);
// // simContext.setMd5hash(null);
// throw new RuntimeException(message);
// }
// if(outputSpec.getBNGReactions().length > SimulationConsolePanel.reactionsLimit) {
// String message = SimulationConsolePanel.getReactionsLimitExceededMessage(outputSpec);
// // tcm = new TaskCallbackMessage(TaskCallbackStatus.Error, message);
// // simContext.appendToConsole(tcm);
// // simContext.setMd5hash(null);
// throw new RuntimeException(message);
// }
// TODO: uncomment here to parse the xml file!!!
parseBngOutput(simContext, fromReactions, bngOutput);
//
// Saving the observables, as produced by bionetgen
// in debug configurations add to command line -Ddebug.user=danv
//
// String debugUser = PropertyLoader.getProperty("debug.user", "not_defined");
// if (debugUser.equals("danv") || debugUser.equals("mblinov")){
// System.out.println("Saving their observables");
// parseObservablesBngOutput(simContext, bngOutput);
// }
// compareOutputs(simContext);
}
use of cbit.vcell.server.bionetgen.BNGOutput in project vcell by virtualcell.
the class CreateBNGOutputSpec method run.
public void run(Hashtable<String, Object> hashTable) throws Exception {
if (!bngService.isStopped()) {
broadcastRun();
}
BNGOutput bngOutput = (BNGOutput) hashTable.get("bngOutput");
String bngNetString = bngOutput.getNetFileContent();
BNGOutputSpec outputSpec = BNGOutputFileParser.createBngOutputSpec(bngNetString);
if (outputSpec != null) {
hashTable.put("outputSpec", outputSpec);
}
}
use of cbit.vcell.server.bionetgen.BNGOutput in project vcell by virtualcell.
the class DisplayBNGOutput method run.
/**
* Insert the method's description here.
* Creation date: (7/19/2006 2:19:07 PM)
* @param hashTable java.util.Hashtable
* @param clientWorker cbit.vcell.desktop.controls.ClientWorker
*/
public void run(Hashtable<String, Object> hashTable) throws Exception {
BNGOutputPanel bngOutputPanel = (BNGOutputPanel) hashTable.get(BNGWindowManager.BNG_OUTPUT_PANEL);
BNGOutput bngOutput = (BNGOutput) hashTable.get("bngOutput");
if (bngOutput != null) {
bngOutputPanel.changeBNGPanelTab();
bngOutputPanel.setBngOutput(bngOutput);
}
bngOutputPanel.refreshButton(false);
}
use of cbit.vcell.server.bionetgen.BNGOutput in project vcell by virtualcell.
the class BNGOutputPanel method enableImportButton.
/**
* Enable Import button if an *.xml file is present in BNGOutput; disable otherwise.
*/
private void enableImportButton() {
BNGOutput out = getBngOutput();
if (null == out) {
getImportButton().setEnabled(false);
return;
}
String[] files = out.getBNGFilenames();
final String XML_SUFFIX = ".xml";
for (int i = 0; i < files.length; ++i) {
String file = files[i];
if (file.endsWith(XML_SUFFIX)) {
getImportButton().setEnabled(true);
return;
}
}
getImportButton().setEnabled(false);
}
use of cbit.vcell.server.bionetgen.BNGOutput in project vcell by virtualcell.
the class BNGOutputPanel method setBngOutput.
/**
* Sets the bngOutput property (bngclientserverapi.BNGOutput) value.
* @param bngOutput The new value for the property.
* @see #getBngOutput
*/
public void setBngOutput(BNGOutput bngOutput) {
BNGOutput oldValue = fieldBngOutput;
fieldBngOutput = bngOutput;
enableImportButton();
enableSaveOutputButton();
firePropertyChange("bngOutput", oldValue, bngOutput);
}
Aggregations