Commit 335c0242 authored by Philipp Spohr's avatar Philipp Spohr
Browse files

Changed column mapping parameters to Cytoscape ListSingleSelection -> easier...

Changed column mapping parameters to Cytoscape ListSingleSelection -> easier and more intuitive for automation users

Updated some license headers
parent 3c6c3f2f
/*******************************************************************************
* Copyright (C) 2018 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
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
******************************************************************************/
package de.hhu.ba.yoshikoWrapper.core;
import java.io.IOException;
import java.util.ArrayList;
import org.cytoscape.model.CyColumn;
import org.cytoscape.model.CyNetwork;
import org.cytoscape.work.Tunable;
import org.cytoscape.work.TunableValidator;
import org.cytoscape.work.util.ListSingleSelection;
public class ParameterSet implements TunableValidator
{
......@@ -16,13 +40,15 @@ public class ParameterSet implements TunableValidator
@Tunable(description="Time Limit for the ILP mode", context="nogui")
public int timeLimit = -1;
//COLUMN-MAPPINGS
@Tunable(description="A column in the edge table containing weights", context="nogui")
public String weightColumnName;
public ListSingleSelection<String> weightColumnName = null;
@Tunable(description="A column containing boolean entries for edges that are to be treated as permanent",context="nogui")
public String permanentColumnName;
public ListSingleSelection<String> permanentColumnName = null;
@Tunable(description="A column containing boolean entries for edges that are to be treated as forbidden",context="nogui")
public String forbiddenColumnName;
public ListSingleSelection<String> forbiddenColumnName = null;
@Tunable(description="The default insertion cost that is to be used for non-existing edges",context="nogui")
public double defaultInsertionCost = -1;
......@@ -54,6 +80,33 @@ public class ParameterSet implements TunableValidator
@Tunable(description="Determines the number of clusters that are to be generated. -1 generates the optimal amount of clusters in the sense of WCE",context="nogui")
public int clusterCount = -1;
/**
* Default constructor, initializes the column mappings to provide a selection of fitting columns
*/
public ParameterSet() {
ArrayList<String> columnNames = new ArrayList<String>();
//Only numeric columns are relevant for weight mapping
for (CyColumn col : net.getDefaultEdgeTable().getColumns()) {
if (Number.class.isAssignableFrom(col.getType())) {
columnNames.add(col.getName());
}
}
weightColumnName = new ListSingleSelection<String>(columnNames);
columnNames = new ArrayList<String>();
//Only boolean columns are relevant for forbidden/permanent mapping
for (CyColumn col : net.getDefaultEdgeTable().getColumns()) {
if (col.getType() == Boolean.class) {
columnNames.add(col.getName());
}
}
forbiddenColumnName = new ListSingleSelection<String>(columnNames);
permanentColumnName = new ListSingleSelection<String>(columnNames);
}
@Override
public ValidationState getValidationState(Appendable errMsg) {
......@@ -61,7 +114,7 @@ public class ParameterSet implements TunableValidator
try {
if (net!= null) {
//Verify column validity
CyColumn weightColumn = net.getDefaultEdgeTable().getColumn(weightColumnName);
CyColumn weightColumn = net.getDefaultEdgeTable().getColumn(weightColumnName.getSelectedValue());
if (weightColumn == null) {
errMsg.append("Could not find a column named: "+weightColumnName+"\n");
return ValidationState.INVALID;
......@@ -108,5 +161,51 @@ public class ParameterSet implements TunableValidator
//TODO
return ret;
}
//SETTER & GETTER
//TODO: Code Redundancy, might be smart to insert the three columns into some sort of super structure and then remove the redundant setters/getters, pass column type as argument
public void setWeightColumnName(String columnName) {
if (weightColumnName.getPossibleValues().contains(columnName)) {
weightColumnName.setSelectedValue(columnName);
}
else {
//Attempting to set a column that is not part of the possible values
//TODO: Output debug/warning if Cytoscape logger will eventually work
}
}
public void setPermanentColumnName(String columnName) {
if (permanentColumnName.getPossibleValues().contains(columnName)) {
permanentColumnName.setSelectedValue(columnName);
}
else {
//Attempting to set a column that is not part of the possible values
//TODO: Output debug/warning if Cytoscape logger will eventually work
}
}
public void setForbiddenColumnName(String columnName) {
if (forbiddenColumnName.getPossibleValues().contains(columnName)) {
forbiddenColumnName.setSelectedValue(columnName);
}
else {
//Attempting to set a column that is not part of the possible values
//TODO: Output debug/warning if Cytoscape logger will eventually work
}
}
public String getWeightColumnName() {
return weightColumnName.getSelectedValue();
}
public String getPermanentColumnName() {
return permanentColumnName.getSelectedValue();
}
public String getForbiddenColumnName() {
return forbiddenColumnName.getSelectedValue();
}
}
/*******************************************************************************
* Copyright (C) 2017 Philipp Spohr
* Copyright (C) 2018 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
......
/*******************************************************************************
* Copyright (C) 2017 Philipp Spohr
* Copyright (C) 2018 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
......
/*******************************************************************************
* Copyright (C) 2017 Philipp Spohr
* Copyright (C) 2018 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
......
......@@ -346,9 +346,9 @@ public class MainPanel extends JPanel implements CytoPanelComponent {
ParameterSet ret = new ParameterSet();
ret.net = net;
ret.timeLimit = opModePanel.getTimeLimit();
ret.weightColumnName = ecPanel.getWeightColumnName();
ret.permanentColumnName = ecPanel.getPermanentColumnName();
ret.forbiddenColumnName = ecPanel.getForbiddenColumnName();
ret.setWeightColumnName(ecPanel.getWeightColumnName());
ret.setPermanentColumnName(ecPanel.getPermanentColumnName());
ret.setForbiddenColumnName(ecPanel.getForbiddenColumnName());
ret.defaultInsertionCost = ecPanel.getDefaultInsertionCost();
ret.defaultDeletionCost = ecPanel.getDefaultDeletionCost();
ret.useHeuristic = opModePanel.useHeuristic();
......
/*******************************************************************************
* Copyright (C) 2017 Philipp Spohr
* Copyright (C) 2018 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
......
......@@ -132,9 +132,9 @@ public class AlgorithmTask extends AbstractTask implements ObservableTask, Tunab
taskMonitor.setProgress(0.1);
//We identify the columns if they exist from their given names
CyColumn weightColumn = parameterSet.weightColumnName != null ? parameterSet.net.getDefaultEdgeTable().getColumn(parameterSet.weightColumnName) : null;
CyColumn permanentColumn = parameterSet.permanentColumnName != null ? parameterSet.net.getDefaultEdgeTable().getColumn(parameterSet.permanentColumnName) : null;
CyColumn forbiddenColumn = parameterSet.forbiddenColumnName != null ? parameterSet.net.getDefaultEdgeTable().getColumn(parameterSet.forbiddenColumnName) : null;
CyColumn weightColumn = parameterSet.getWeightColumnName() != null ? parameterSet.net.getDefaultEdgeTable().getColumn(parameterSet.getWeightColumnName()) : null;
CyColumn permanentColumn = parameterSet.permanentColumnName != null ? parameterSet.net.getDefaultEdgeTable().getColumn(parameterSet.getPermanentColumnName()) : null;
CyColumn forbiddenColumn = parameterSet.forbiddenColumnName != null ? parameterSet.net.getDefaultEdgeTable().getColumn(parameterSet.getForbiddenColumnName()) : null;
//Generate an c_input instance from the network
c_input = NetworkParser.parseNetwork(
......
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