use of org.cytoscape.filter.internal.filters.column.ColumnFilter in project cytoscape-impl by cytoscape.
the class CreateFilterTaskTest method testCreateColumnFilterNumber.
@Test
public void testCreateColumnFilterNumber() {
CreateFilterTask task = new CreateFilterTask(serviceRegistrar, "MyFilter");
task.jsonTunable.json = "{ \"id\" : \"ColumnFilter\", \"parameters\" : { \"predicate\" : \"BETWEEN\", \"criterion\" : [1,1], \"columnName\" : \"name\"} }";
TaskMonitor tm = mock(TaskMonitor.class);
task.run(tm);
verify(tm, times(0)).showMessage(any(), any());
NamedTransformer<CyNetwork, CyIdentifiable> transformer = transformerContainer.getNamedTransformer(task.name);
assertNotNull(transformer);
ColumnFilter columnFilter = (ColumnFilter) transformer.getTransformers().get(0);
assertEquals(Predicate.BETWEEN, columnFilter.getPredicate());
assertArrayEquals(new Number[] { 1l, 1l }, (Number[]) columnFilter.getCriterion());
assertEquals("name", columnFilter.getColumnName());
}
use of org.cytoscape.filter.internal.filters.column.ColumnFilter in project cytoscape-impl by cytoscape.
the class ColumnFilterTest method testColumnFilterInteger.
@Test
public void testColumnFilterInteger() {
NetworkTestSupport networkSupport = new NetworkTestSupport();
CyNetwork network = networkSupport.getNetworkFactory().createNetwork();
network.getDefaultNodeTable().createColumn("i", Integer.class, false);
CyNode n1 = network.addNode();
CyNode n2 = network.addNode();
CyNode n3 = network.addNode();
CyNode n4 = network.addNode();
network.getRow(n1).set("i", 111);
network.getRow(n2).set("i", 222);
network.getRow(n3).set("i", 333);
ColumnFilter columnFilter = new ColumnFilter("i", Predicate.BETWEEN, new Number[] { 200, 300 });
assertFalse(columnFilter.accepts(network, n1));
assertTrue(columnFilter.accepts(network, n2));
assertFalse(columnFilter.accepts(network, n3));
assertFalse(columnFilter.accepts(network, n4));
columnFilter.setPredicateAndCriterion(Predicate.IS_NOT_BETWEEN, new Number[] { 200, 300 });
assertTrue(columnFilter.accepts(network, n1));
assertFalse(columnFilter.accepts(network, n2));
assertTrue(columnFilter.accepts(network, n3));
assertTrue(columnFilter.accepts(network, n4));
}
use of org.cytoscape.filter.internal.filters.column.ColumnFilter in project cytoscape-impl by cytoscape.
the class ColumnFilterTest method testColumnFilterString.
@Test
public void testColumnFilterString() {
NetworkTestSupport networkSupport = new NetworkTestSupport();
CyNetwork network = networkSupport.getNetworkFactory().createNetwork();
network.getDefaultNodeTable().createColumn("s", String.class, false);
CyNode n1 = network.addNode();
CyNode n2 = network.addNode();
CyNode n3 = network.addNode();
CyNode n4 = network.addNode();
network.getRow(n1).set("s", "aaa");
network.getRow(n2).set("s", "bbb");
network.getRow(n3).set("s", "ccc");
ColumnFilter columnFilter = new ColumnFilter("s", Predicate.CONTAINS, "a");
assertTrue(columnFilter.accepts(network, n1));
assertFalse(columnFilter.accepts(network, n2));
assertFalse(columnFilter.accepts(network, n3));
assertFalse(columnFilter.accepts(network, n4));
columnFilter.setPredicateAndCriterion(Predicate.DOES_NOT_CONTAIN, "a");
assertFalse(columnFilter.accepts(network, n1));
assertTrue(columnFilter.accepts(network, n2));
assertTrue(columnFilter.accepts(network, n3));
assertTrue(columnFilter.accepts(network, n4));
columnFilter.setPredicateAndCriterion(Predicate.IS, "a");
assertFalse(columnFilter.accepts(network, n1));
assertFalse(columnFilter.accepts(network, n2));
assertFalse(columnFilter.accepts(network, n3));
assertFalse(columnFilter.accepts(network, n4));
columnFilter.setPredicateAndCriterion(Predicate.IS, "aaa");
assertTrue(columnFilter.accepts(network, n1));
assertFalse(columnFilter.accepts(network, n2));
assertFalse(columnFilter.accepts(network, n3));
assertFalse(columnFilter.accepts(network, n4));
columnFilter.setPredicateAndCriterion(Predicate.IS_NOT, "aaa");
assertFalse(columnFilter.accepts(network, n1));
assertTrue(columnFilter.accepts(network, n2));
assertTrue(columnFilter.accepts(network, n3));
assertTrue(columnFilter.accepts(network, n4));
columnFilter.setPredicateAndCriterion(Predicate.REGEX, ".a.");
assertTrue(columnFilter.accepts(network, n1));
assertFalse(columnFilter.accepts(network, n2));
assertFalse(columnFilter.accepts(network, n3));
assertFalse(columnFilter.accepts(network, n4));
}
use of org.cytoscape.filter.internal.filters.column.ColumnFilter in project cytoscape-impl by cytoscape.
the class ColumnFilterTest method testColumnFilterAlwaysFalse.
@Test
public void testColumnFilterAlwaysFalse() {
ColumnFilter columnFilter = new ColumnFilter();
assertTrue(columnFilter.isAlwaysFalse());
columnFilter.setPredicateAndCriterion(Predicate.IS, "a");
assertTrue(columnFilter.isAlwaysFalse());
columnFilter.setColumnName("c");
assertFalse(columnFilter.isAlwaysFalse());
}
use of org.cytoscape.filter.internal.filters.column.ColumnFilter in project cytoscape-impl by cytoscape.
the class TopologyFilterTest method testTopologyFilterCycle.
@Test
public void testTopologyFilterCycle() {
NetworkTestSupport networkSupport = new NetworkTestSupport();
CyNetwork network = networkSupport.getNetworkFactory().createNetwork();
network.getDefaultNodeTable().createColumn("s", String.class, false);
CyNode n1 = network.addNode();
CyNode n2 = network.addNode();
CyNode n3 = network.addNode();
CyNode n4 = network.addNode();
network.addEdge(n1, n2, false);
network.addEdge(n2, n3, false);
network.addEdge(n3, n1, false);
network.addEdge(n3, n1, false);
network.addEdge(n3, n4, false);
network.getRow(n4).set("s", "a");
TopologyFilter topologyFilter = new TopologyFilter();
topologyFilter.setThreshold(1);
topologyFilter.setDistance(100);
topologyFilter.setPredicate(Predicate.GREATER_THAN_OR_EQUAL);
ColumnFilter columnFilter = new ColumnFilter("s", Predicate.IS, "a");
topologyFilter.append(columnFilter);
// not getting caught in a cycle!
assertTrue(topologyFilter.accepts(network, n1));
topologyFilter.setThreshold(10);
topologyFilter.setDistance(1000);
topologyFilter.setPredicate(Predicate.GREATER_THAN_OR_EQUAL);
// not getting caught in a cycle!
assertFalse(topologyFilter.accepts(network, n1));
}
Aggregations