本文整理汇总了Java中org.cytoscape.work.TaskMonitor.setProgress方法的典型用法代码示例。如果您正苦于以下问题:Java TaskMonitor.setProgress方法的具体用法?Java TaskMonitor.setProgress怎么用?Java TaskMonitor.setProgress使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.cytoscape.work.TaskMonitor
的用法示例。
在下文中一共展示了TaskMonitor.setProgress方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: run
import org.cytoscape.work.TaskMonitor; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void run(TaskMonitor m) throws Exception {
m.setTitle("Import BEL JSON Graph");
m.setStatusMessage(format("Read and validate \"%s\" against the BEL JSON Graph schema.", inputName));
GraphsWithValidation gv = checkSchema(inputStream, graphReader);
Graph[] graphs = gv.getGraphs();
m.setProgress(0.50);
m.setStatusMessage(format("Creating %d networks from \"%s\".", graphs.length, inputName));
this.networks = mapNetworks(graphs);
for (CyNetwork n : this.networks)
networkMgr.addNetwork(n);
// set up evidence table if we have cytoscape networks
if (this.networks.length > 0) {
CyTable table = getOrCreateEvidenceTable();
mapGraphsToEvidenceTable(graphs, table);
tableMgr.addTable(table);
}
m.setProgress(1.0);
}
示例2: run
import org.cytoscape.work.TaskMonitor; //导入方法依赖的package包/类
@Override
public void run(TaskMonitor monitor) throws Exception {
monitor.setStatusMessage("Executing ForceAtlas2 layout");
List<ExtensionCall> calls = exec.buildExtensionCalls();
double progress = 0.0;
for(ExtensionCall call : calls){
Object callRetValue = plugin.getInteractor().executeExtensionCall(call,false);
exec.processCallResponse(call,callRetValue);
++progress;
monitor.setProgress(progress / ((double)calls.size()));
}
}
示例3: run
import org.cytoscape.work.TaskMonitor; //导入方法依赖的package包/类
@Override
public void run(TaskMonitor taskMonitor) throws Exception {
if (taskMonitor != null) {
taskMonitor.setTitle("Writing to D3-Style JSON");
taskMonitor.setStatusMessage("Writing network in D3.js format...");
taskMonitor.setProgress(-1.0);
}
network2jsonMapper.writeValue(new OutputStreamWriter(outputStream, EncodingUtil.getEncoder()), network);
outputStream.close();
if (taskMonitor != null) {
taskMonitor.setStatusMessage("Success.");
taskMonitor.setProgress(1.0);
}
}
示例4: findTheta
import org.cytoscape.work.TaskMonitor; //导入方法依赖的package包/类
/**
* Calculate theta corresponding to theta
* @param d1
* @param d2
* @param l1
* @param l2
* @param varList
* @param M
* @param delta
* @param monitor
* @param secondStep
* @param firstStep
* @return
* @throws InterruptedException
*/
public static double findTheta(double[][] d1, double[][] d2,
double l1, double l2, String[] varList, int M,
double delta, TaskMonitor monitor, double firstStep, double secondStep) throws InterruptedException {
double portion = 0.2;
double remaining = secondStep;
standardizeData(d1);
standardizeData(d2);
KddnSettings dataSetting = new KddnSettings(l1, l2, 0.05, d1, d2, varList, 0.05);
KddnResults dataResult = solveDDN(dataSetting);
double high = 0.5;
double low = 0.02;
double mid = (high-low) / 2 + low;
double deviation = thetaError(d1, d2, l1, l2, varList, M, mid, dataResult);
while(high - low > 0.01) {
if(deviation > delta) {
high = mid;
mid = (high-low) / 2 + low;
deviation = thetaError(d1, d2, l1, l2, varList, M, mid, dataResult);
} else {
low = mid;
mid = (high-low) / 2 + low;
deviation = thetaError(d1, d2, l1, l2, varList, M, mid, dataResult);
}
double progress = remaining * portion;
remaining -= progress;
portion += 0.05;
monitor.setProgress(firstStep + secondStep - remaining);
}
return mid;
}
示例5: run
import org.cytoscape.work.TaskMonitor; //导入方法依赖的package包/类
@Override
public void run(TaskMonitor taskMonitor) throws Exception {
if (taskMonitor != null) {
taskMonitor.setTitle("Writing Network View to D3-Style JSON");
taskMonitor.setStatusMessage("Writing D3 style JSON...");
taskMonitor.setProgress(-1.0);
}
networkView2jsonMapper.writeValue(new OutputStreamWriter(outputStream, EncodingUtil.getEncoder()), view);
outputStream.close();
if (taskMonitor != null) {
taskMonitor.setStatusMessage("Success.");
taskMonitor.setProgress(1.0);
}
}
示例6: run
import org.cytoscape.work.TaskMonitor; //导入方法依赖的package包/类
@Override
public void run(TaskMonitor taskMonitor) throws Exception {
if (network == null) return;
taskMonitor.setStatusMessage("Removing groups.");
int i = 0;
Set<CyGroup> groupSet = groupManager.getGroupSet(network);
for (CyGroup group : groupSet) {
groupManager.destroyGroup(group);
i++;
taskMonitor.setProgress((double) i / (double) groupSet.size());
}
}
示例7: run
import org.cytoscape.work.TaskMonitor; //导入方法依赖的package包/类
@Override
public void run(TaskMonitor tm) {
if (parentNetwork == null) {
tm.showMessage(TaskMonitor.Level.ERROR, "Source network must be specified.");
return;
}
tm.setProgress(0.2);
// create subnetwork and add selected nodes and appropriate edges
final CySubNetwork newNet = rootNetMgr.getRootNetwork(parentNetwork).addSubNetwork();
//We need to cpy the columns to local tables, since copying them to default table will duplicate the virtual columns.
addColumns(parentNetwork.getTable(CyNode.class, CyNetwork.LOCAL_ATTRS), newNet.getTable(CyNode.class, CyNetwork.LOCAL_ATTRS));
addColumns(parentNetwork.getTable(CyEdge.class, CyNetwork.LOCAL_ATTRS), newNet.getTable(CyEdge.class, CyNetwork.LOCAL_ATTRS) );
addColumns(parentNetwork.getTable(CyNetwork.class, CyNetwork.LOCAL_ATTRS), newNet.getTable(CyNetwork.class, CyNetwork.LOCAL_ATTRS));
tm.setProgress(0.3);
for(CyNode node : nodes) {
newNet.addNode(node);
cloneRow(parentNetwork.getRow(node), newNet.getRow(node));
//Set rows and edges to not selected state to avoid conflicts with table browser
newNet.getRow(node).set(CyNetwork.SELECTED, false);
}
tm.setProgress(0.4);
for (final CyEdge edge : getEdges(parentNetwork, nodes)) {
newNet.addEdge(edge);
cloneRow(parentNetwork.getRow(edge), newNet.getRow(edge));
//Set rows and edges to not selected state to avoid conflicts with table browser
newNet.getRow(edge).set(CyNetwork.SELECTED, false);
}
tm.setProgress(0.5);
newNet.getRow(newNet).set(CyNetwork.NAME, getNetworkName());
resultNetwork = newNet;
tm.setProgress(1.0);
}
示例8: run
import org.cytoscape.work.TaskMonitor; //导入方法依赖的package包/类
@Override
public void run(final TaskMonitor taskMonitor) throws Exception{
CyNetwork outputNet = null, trainedNet = null, modelNetwork = null;
taskMonitor.setTitle("SCODE Progress");
try {
if (userInput.trainNewModel){
// Train a template
if (userInput.customModel) {
// Load custom template
modelNetwork = getNetwork(userInput.bayesModel.getSelectedValue());
} else {
// Load built-in template
modelNetwork = ClusterUtil.getDefaultModel(userInput.weightName.getSelectedValue(), SavePolicy.DO_NOT_SAVE);
}
// Create empty network for saving state of model
outputNet = CyActivator.networkFactory.createNetwork();
outputNet.getRow(outputNet).set(CyNetwork.NAME, CyActivator.networkNaming.getSuggestedNetworkTitle("Supervised Complex Model"));
// Set task monitor progress
taskMonitor.setProgress(0.1);
taskMonitor.setStatusMessage("Training...");
clusterModel = new SupervisedModel(rootNetwork, modelNetwork,outputNet, userInput);
CyActivator.networkManager.addNetwork(outputNet);
taskMonitor.setStatusMessage("Training is done.");
taskMonitor.setProgress(1.0);
}
else {
// Use an existing model
taskMonitor.setProgress(0.1);
taskMonitor.setStatusMessage("Loading model...");
trainedNet = getNetwork(userInput.existingModel.getSelectedValue());
clusterModel = new SupervisedModel(rootNetwork, trainedNet, userInput);
taskMonitor.setStatusMessage("Model loaded.");
taskMonitor.setProgress(1.0);
}
} catch ( Exception e){
e.printStackTrace();
throw new Exception("Training didn't work out so well..." + e.getMessage());
}
}
示例9: calculatePvalue
import org.cytoscape.work.TaskMonitor; //导入方法依赖的package包/类
/**
* calculate DDN and p-value
* @param network
* @param paras
* @param numPermutation
* @param monitor
* @param firstStep
* @param secondStep
* @return
* @throws InterruptedException
*/
public static KddnResults calculatePvalue(KddnResults network,
final KddnSettings paras,
int numPermutation, TaskMonitor monitor,
double firstStep, double secondStep) throws InterruptedException {
// copy settings
double pValueCutoff = paras.pValueCutoff;
String[] varList = paras.varList;
double[][] data1 = paras.data1;
double[][] data2 = paras.data2;
double lambda1 = paras.lambda1;
double lambda2 = paras.lambda2;
double alpha = paras.alpha;
int p = paras.p;
int N1 = paras.N1;
int N2 = paras.N2;
double theta = paras.theta;
int[][] W = paras.W;
double delta = paras.delta;
int[][] difNet = network.getDifferentialNetwork();
int[][] permNet = new int[p][p];
int numDif = 0;
for(int i=0; i<p; i++)
for(int j=0; j<p; j++) {
permNet[i][j] = 0;
if(difNet[i][j] != 0)
numDif++;
}
double thirdStep = 1 - firstStep - secondStep;
double progress = firstStep + secondStep;
for(int i=0; i<numPermutation; i++) {
int[] permId = permutation(N1+N2);
double[][] pd1 = permute(data1, data2, permId, 0, N1-1);
double[][] pd2 = permute(data1, data2, permId, N1, N1+N2-1);
standardizeData(pd1);
standardizeData(pd2);
KddnSettings aRun = new KddnSettings(lambda1, lambda2, pValueCutoff, theta, W, pd1, pd2, varList, alpha, delta);
KddnResults aResult = solveDDN(aRun);
permNet = addMatrix(permNet, aResult.getDifferentialBeta());
progress = firstStep + secondStep + thirdStep * (i+1) / numPermutation;
monitor.setProgress(progress);
}
double[][] pValue = new double[numDif][4];
int rowId = 0;
for(int i=0; i<p-1; i++)
for(int j=i+1; j<p; j++) {
if(difNet[i][j] != 0) {
pValue[rowId][0] = i;
pValue[rowId][1] = j;
double p1 = (double) permNet[i][j] / numPermutation;
double p2 = (double) permNet[j][i] / numPermutation;
pValue[rowId][2] = Math.min(p1, p2);
if(difNet[i][j] == 1)
pValue[rowId][3] = 1;
else
pValue[rowId][3] = 2;
rowId++;
}
}
return new KddnResults(paras.varList, network.adjacentMatrix, network.beta, pValue);
}
示例10: run
import org.cytoscape.work.TaskMonitor; //导入方法依赖的package包/类
@Override
public void run(final TaskMonitor taskMonitor)
{
taskMonitor.setTitle("Retrieving features...");
taskMonitor.setProgress(0.0d);
// if merge strategy is retain, skip to end
// foreach node in model
// retrieve existing features from node --> feature mapping
// foreach ensembl gene id per node
// retrieve feature for ensembl gene id
// if merge strategy is replace, remove existing node --> feature mappings and features from features and add new ones
// else if merge strategy is merge, remove existing node --> feature mappings and features from features, perform the merge and re-add merged ones
// (note that removing feature mappings should also remove downstream variations and consequences, and should update counts in node table)
if (!mergeStrategy.isRetain())
{
final Lock nodesReadLock = model.nodes().getReadWriteLock().readLock();
final Lock featuresWriteLock = model.features().getReadWriteLock().writeLock();
nodesReadLock.lock();
featuresWriteLock.lock();
try
{
for (int i = 0, size = model.nodes().size(); i < size; i++)
{
CyNode node = model.nodes().get(i);
for (String ensemblGeneId : ensemblGeneIds(node, model.getNetwork(), model.getEnsemblGeneIdColumn()))
{
if (StringUtils.isNotBlank(ensemblGeneId))
{
taskMonitor.setStatusMessage("Retrieving genome feature for Ensembl Gene " + ensemblGeneId + "...");
/*
todo: retrofit.RetrofitError with current version of ensembl-rest-client (1.2)
retrofit.RetrofitError
at retrofit.RetrofitError.httpError(RetrofitError.java:37)
at retrofit.RestAdapter$RestHandler.invokeRequest(RestAdapter.java:343)
at retrofit.RestAdapter$RestHandler.invoke(RestAdapter.java:222)
at com.sun.proxy.$Proxy38.lookup(Unknown Source)
at org.dishevelled.variation.ensembl.EnsemblRestClientFeatureService.feature(EnsemblRestClientFeatureService.java:69)
at org.dishevelled.variation.cytoscape3.internal.RetrieveFeaturesTask.run(RetrieveFeaturesTask.java:94)
at org.cytoscape.work.internal.task.JDialogTaskManager$TaskRunnable.innerRun(JDialogTaskManager.java:321)
at org.cytoscape.work.internal.task.JDialogTaskManager$TaskRunnable.run(JDialogTaskManager.java:350)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Ensembl search says:
Ensembl gene ENSG00000157763 is no longer in the database but it has been mapped to 1 deprecated identifier. Not a Primary Assembly Gene.
Fixed with new Ensembl gene identifiers for HLA-A, HLA-B, HLA-C, HLA-DQB1.
Need to handle this error appropriately; should probably use custom error handler in ensembl-rest-client APIs
MOVE THIS TO VARIATION LIBRARY INSIDE feature CALL
*/
Feature feature = model.getFeatureService().feature(model.getSpecies(), model.getReference(), ensemblGeneId);
taskMonitor.setStatusMessage(resultStatusMessage(feature == null ? 0 : 1, "genome feature", "Ensembl Gene", ensemblGeneId));
if (feature != null)
{
model.add(node, feature);
}
}
}
taskMonitor.setProgress(i / (double) size);
}
}
finally
{
nodesReadLock.unlock();
featuresWriteLock.unlock();
}
}
taskMonitor.setProgress(1.0d);
}
示例11: run
import org.cytoscape.work.TaskMonitor; //导入方法依赖的package包/类
@Override
public void run(TaskMonitor taskMonitor) throws Exception {
taskMonitor.setTitle("PathwayCommons: Expanding Selected Nodes to a New Network");
if(cancelled) return;
final String column = columnSelection.getSelectedValue();
final String graphType = querySelection.getSelectedValue();
taskMonitor.setStatusMessage("Getting the specified attribute values (IDs) from selected nodes");
//collect the specified column values from the selected nodes
Set<String> values = new HashSet<String>();
for(CyNode node : network.getNodeList()) {
if (!network.getRow(node).get(CyNetwork.SELECTED, Boolean.class))
continue;
String val = network.getRow(node).get(column, String.class);
if(val != null && !val.isEmpty())
values.add(val);
}
if(values.isEmpty()) {
taskMonitor.setStatusMessage("No values (IDs) " +
"found in the attribute column of currently selected nodes.");
cancel();
return;
}
taskMonitor.setProgress(0.1);
//execute, create a new network and view (if any data will be returned from the server)
taskMonitor.setStatusMessage("Executing " + graphType + " query (in Pathway Commons)");
final CPathGraphQuery graphQ = App.client.createGraphQuery()
.kind(("NEIGHBORHOOD".equals(graphType)) ? GraphType.NEIGHBORHOOD : GraphType.PATHSBETWEEN)
.sources(values)
.datasourceFilter(App.options.selectedDatasources())
.direction(("NEIGHBORHOOD".equals(graphType)) ? Direction.UNDIRECTED : null)
//.limit(1) TODO set limit via tunables (default is 1)
.organismFilter(App.options.selectedOrganisms());
App.cyServices.taskManager.execute(new TaskIterator(
new NetworkAndViewTask(graphQ, null)
));
taskMonitor.setStatusMessage("Done");
taskMonitor.setProgress(1.0);
}