Commit f8d44b69 authored by Philipp Spohr's avatar Philipp Spohr
Browse files

stuff

parent 26552aa1
/*******************************************************************************
* Copyright (C) 2017 Philipp Spohr
*
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
......@@ -25,9 +25,9 @@ import org.cytoscape.property.AbstractConfigDirPropsReader;
import org.cytoscape.property.CyProperty;
public class ConfigurationManager extends AbstractConfigDirPropsReader{
public ConfigurationManager(String appName, String fileName){
super(appName, fileName, CyProperty.SavePolicy.CONFIG_DIR);
this.getProperties().list(System.out);
}
//this.getProperties().list(System.out);
}
}
......@@ -4,12 +4,16 @@ package de.hhu.ba.yoshikoWrapper.core;
import java.io.IOException;
import org.cytoscape.model.CyColumn;
import org.cytoscape.model.CyNetwork;
import org.cytoscape.work.Tunable;
import org.cytoscape.work.TunableValidator;
public class ParameterSet implements TunableValidator
{
@Tunable(description="Network to analyze for clusters", context="nogui")
public CyNetwork net = CyCore.cy.getCurrentNetwork();
@Tunable(description="Time Limit for the ILP mode", context="nogui")
public int timeLimit = -1;
......@@ -50,16 +54,26 @@ public class ParameterSet implements TunableValidator
@Override
public ValidationState getValidationState(Appendable errMsg) {
if (!checkBitmask(reductionRulesBitMask)) {
try {
errMsg.append("The Bitmask provided is invalid! Needs to be six bit binary (example: 011001)");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.out.println("DEBUG: Running VALIDATION of tunables"); //TODO: Move to logger (if it would work)
try {
if (net!= null) {
//Verify column validity
CyColumn weightColumn = net.getDefaultEdgeTable().getColumn(weightColumnName);
if (weightColumn == null) {
errMsg.append("Could not find a column named: "+weightColumnName+"\n");
return ValidationState.INVALID;
}
}
if (!checkBitmask(reductionRulesBitMask)) {
errMsg.append("The Bitmask provided is invalid! Needs to be six bit binary (example: 011001)\n");
return ValidationState.INVALID;
}
return ValidationState.INVALID;
return ValidationState.OK;
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return ValidationState.OK;
return ValidationState.INVALID;
}
/**
......@@ -79,4 +93,5 @@ public class ParameterSet implements TunableValidator
return true;
}
}
......@@ -314,7 +314,6 @@ public class MainPanel extends JPanel implements CytoPanelComponent {
if (YoshikoLoader.isLibraryLoaded()){
AbstractTask yoshiko = new AlgorithmTask(
popupLevel,
networkToBeProcessed,
fetchParameters(networkToBeProcessed)
);
/**
......@@ -345,6 +344,7 @@ public class MainPanel extends JPanel implements CytoPanelComponent {
*/
private ParameterSet fetchParameters(CyNetwork net) {
ParameterSet ret = new ParameterSet();
ret.net = net;
ret.timeLimit = opModePanel.getTimeLimit();
ret.weightColumnName = ecPanel.getWeightColumn().getName();
ret.permanentColumn = ecPanel.getPermanentColumn();
......
......@@ -185,7 +185,7 @@ NetworkAboutToBeDestroyedListener
verticalGroup
.addComponent(marker,DEFAULT_SIZE,DEFAULT_SIZE,PREFERRED_SIZE)
.addComponent(invalidLabel,DEFAULT_SIZE, DEFAULT_SIZE,DEFAULT_SIZE)
.addComponent(tabbedPane,PREFERRED_SIZE, DEFAULT_SIZE,Short.MAX_VALUE)
.addComponent(tabbedPane,DEFAULT_SIZE, DEFAULT_SIZE,DEFAULT_SIZE)
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(destroyButton,DEFAULT_SIZE, DEFAULT_SIZE,PREFERRED_SIZE);
......
......@@ -218,8 +218,8 @@ public class SolutionTab extends JPanel {
.addGap(8)
.addComponent(clusterCount,DEFAULT_SIZE,DEFAULT_SIZE,DEFAULT_SIZE)
.addComponent(hideSingles,DEFAULT_SIZE,DEFAULT_SIZE,DEFAULT_SIZE)
.addGap(8)
.addComponent(scrollPane,DEFAULT_SIZE,DEFAULT_SIZE,DEFAULT_SIZE)
.addGap(4)
.addComponent(scrollPane,DEFAULT_SIZE,DEFAULT_SIZE,PREFERRED_SIZE)
.addGap(4)
);
......
......@@ -45,7 +45,6 @@ public class CommandTaskFactory implements TaskFactory{
else if (command == YoshikoCommand.PERFORM_ALGORITHM) {
return new TaskIterator(
new AlgorithmTask(
null,
null,
new ParameterSet()
)
......
......@@ -77,8 +77,7 @@ public class AlgorithmTask extends AbstractTask implements ObservableTask {
@ContainsTunables
public ParameterSet parameterSet = null;
@Tunable(description="Network to analyze for clusters", context="nogui")
public CyNetwork net = CyCore.cy.getCurrentNetwork();
//Temps, pointing to and need to be freed in C++
private LibraryInput c_input;
......@@ -98,12 +97,10 @@ public class AlgorithmTask extends AbstractTask implements ObservableTask {
*/
public AlgorithmTask(
Window statusWindow,
CyNetwork net,
ParameterSet parameterSet
)
{
this.statusWindow = statusWindow;
this.net = net;
this.parameterSet = parameterSet;
}
......@@ -115,8 +112,8 @@ public class AlgorithmTask extends AbstractTask implements ObservableTask {
taskMonitor.setTitle(LocalizationManager.get("yoshTask"));
taskMonitor.setProgress(0.0);
//Get current network
if (net == null) {
//Check current network
if (parameterSet.net == null) {
logger.warn("CoreAlgorithm called on a net that is NULL!");
throw new Exception("CoreAlgorithm called on a net that is NULL!"); //TODO: Localize
}
......@@ -131,14 +128,14 @@ public class AlgorithmTask extends AbstractTask implements ObservableTask {
}
//Create a node map to identify nodes and eges in the solution
NodeMap nodeMap = new NodeMap(net);
NodeMap nodeMap = new NodeMap(parameterSet.net);
taskMonitor.setProgress(0.1);
//Generate an c_input instance from the network
c_input = NetworkParser.parseNetwork(
net,
parameterSet.net,
nodeMap,
net.getDefaultEdgeTable().getColumn(parameterSet.weightColumnName),
parameterSet.net.getDefaultEdgeTable().getColumn(parameterSet.weightColumnName), //Simplify
parameterSet.permanentColumn,
parameterSet.forbiddenColumn,
parameterSet.defaultDeletionCost
......@@ -146,8 +143,8 @@ public class AlgorithmTask extends AbstractTask implements ObservableTask {
taskMonitor.setProgress(0.2);
boolean containsRealValues = GraphAnalyzer.containsRealValues(
net,
net.getDefaultEdgeTable().getColumn(parameterSet.weightColumnName),
parameterSet.net,
parameterSet.net.getDefaultEdgeTable().getColumn(parameterSet.weightColumnName),
parameterSet.permanentColumn,
parameterSet.forbiddenColumn,
parameterSet.defaultInsertionCost,
......@@ -184,7 +181,7 @@ public class AlgorithmTask extends AbstractTask implements ObservableTask {
taskMonitor.setStatusMessage("Found: "+numberOfSolutions+" solutions!"); //TODO: Localize
result = new YoshikoResult(net,c_result.getFlags());
result = new YoshikoResult(parameterSet.net,c_result.getFlags());
//Loop over (multiple) solutions
for (long i=0;i<numberOfSolutions;i++) {
......@@ -195,8 +192,8 @@ public class AlgorithmTask extends AbstractTask implements ObservableTask {
String columnName = SOLUTION_COLUMN_PREFIX+(i+1);
net.getDefaultNodeTable().deleteColumn(columnName);
net.getDefaultNodeTable().createColumn(columnName, String.class, false);
parameterSet.net.getDefaultNodeTable().deleteColumn(columnName);
parameterSet.net.getDefaultNodeTable().createColumn(columnName, String.class, false);
//Fetch number of clusters in the solution
long numberOfClusters = c_result.getNumberOfClusters(i);
......@@ -218,7 +215,7 @@ public class AlgorithmTask extends AbstractTask implements ObservableTask {
CyNode node = nodeMap.indexOf(nodeID); //<<< Another int/long conversion
cluster.addNode(node);
net.getRow(node).set(columnName, ""+(k+1)); //Add Cluster ID in table (Remove in final version?)
parameterSet.net.getRow(node).set(columnName, ""+(k+1)); //Add Cluster ID in table (Remove in final version?)
}
//Register clusters with solution for further reference
solution.addCluster(cluster);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment