Search in sources :

Example 1 with BNGOutput

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);
}
Also used : SpeciesContext(cbit.vcell.model.SpeciesContext) BNGExecutorService(cbit.vcell.server.bionetgen.BNGExecutorService) BNGOutput(cbit.vcell.server.bionetgen.BNGOutput) FakeSeedSpeciesInitialConditionsParameter(org.vcell.model.rbm.FakeSeedSpeciesInitialConditionsParameter) BNGOutputSpec(cbit.vcell.bionetgen.BNGOutputSpec) PropertyVetoException(java.beans.PropertyVetoException) ModelException(cbit.vcell.model.ModelException) IOException(java.io.IOException) ExpressionException(cbit.vcell.parser.ExpressionException) Expression(cbit.vcell.parser.Expression) NetworkGenerationRequirements(cbit.vcell.mapping.SimulationContext.NetworkGenerationRequirements) BNGInput(cbit.vcell.server.bionetgen.BNGInput) Map(java.util.Map) LinkedHashMap(java.util.LinkedHashMap) Pair(org.vcell.util.Pair)

Example 2 with BNGOutput

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);
    }
}
Also used : BNGOutput(cbit.vcell.server.bionetgen.BNGOutput) BNGOutputSpec(cbit.vcell.bionetgen.BNGOutputSpec)

Example 3 with BNGOutput

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);
}
Also used : BNGOutputPanel(cbit.vcell.client.bionetgen.BNGOutputPanel) BNGOutput(cbit.vcell.server.bionetgen.BNGOutput)

Example 4 with BNGOutput

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);
}
Also used : BNGOutput(cbit.vcell.server.bionetgen.BNGOutput)

Example 5 with BNGOutput

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);
}
Also used : BNGOutput(cbit.vcell.server.bionetgen.BNGOutput)

Aggregations

BNGOutput (cbit.vcell.server.bionetgen.BNGOutput)8 BNGOutputSpec (cbit.vcell.bionetgen.BNGOutputSpec)3 ModelException (cbit.vcell.model.ModelException)2 SpeciesContext (cbit.vcell.model.SpeciesContext)2 Expression (cbit.vcell.parser.Expression)2 ExpressionException (cbit.vcell.parser.ExpressionException)2 BNGExecutorService (cbit.vcell.server.bionetgen.BNGExecutorService)2 BNGInput (cbit.vcell.server.bionetgen.BNGInput)2 PropertyVetoException (java.beans.PropertyVetoException)2 IOException (java.io.IOException)2 LinkedHashMap (java.util.LinkedHashMap)2 Map (java.util.Map)2 FakeSeedSpeciesInitialConditionsParameter (org.vcell.model.rbm.FakeSeedSpeciesInitialConditionsParameter)2 Pair (org.vcell.util.Pair)2 BNGOutputPanel (cbit.vcell.client.bionetgen.BNGOutputPanel)1 NetworkGenerationRequirements (cbit.vcell.mapping.SimulationContext.NetworkGenerationRequirements)1 ExpressionBindingException (cbit.vcell.parser.ExpressionBindingException)1 BNGException (cbit.vcell.server.bionetgen.BNGException)1 HashMap (java.util.HashMap)1 ParseException (org.vcell.model.bngl.ParseException)1