Search in sources :

Example 46 with CyNetwork

use of org.cytoscape.model.CyNetwork in project cytoscape-impl by cytoscape.

the class CreateFilterTaskTest method testCreateColumnFilterBoolean.

@Test
public void testCreateColumnFilterBoolean() {
    CreateFilterTask task = new CreateFilterTask(serviceRegistrar, "MyFilter");
    task.jsonTunable.json = "{ \"id\" : \"ColumnFilter\", \"parameters\" : { \"criterion\" : false, \"columnName\" : \"name\", \"predicate\" : \"IS\"} }";
    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.IS, columnFilter.getPredicate());
    assertEquals(false, columnFilter.getCriterion());
    assertEquals("name", columnFilter.getColumnName());
}
Also used : TaskMonitor(org.cytoscape.work.TaskMonitor) CyNetwork(org.cytoscape.model.CyNetwork) ColumnFilter(org.cytoscape.filter.internal.filters.column.ColumnFilter) CyIdentifiable(org.cytoscape.model.CyIdentifiable) Test(org.junit.Test)

Example 47 with CyNetwork

use of org.cytoscape.model.CyNetwork in project cytoscape-impl by cytoscape.

the class CreateFilterTaskTest method testCreateDegreeFilter.

@Test
public void testCreateDegreeFilter() {
    CreateFilterTask task = new CreateFilterTask(serviceRegistrar, "MyFilter");
    task.jsonTunable.json = "{ \"id\" : \"DegreeFilter\", \"parameters\" : { \"predicate\" : \"BETWEEN\", \"criterion\" : [ 0, 1 ], \"edgeType\" : \"ANY\" } }";
    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);
    DegreeFilter filter = (DegreeFilter) transformer.getTransformers().get(0);
    assertEquals(Predicate.BETWEEN, filter.getPredicate());
    assertArrayEquals(new Number[] { 0l, 1l }, (Number[]) filter.getCriterion());
    assertEquals(CyEdge.Type.ANY, filter.getEdgeType());
}
Also used : TaskMonitor(org.cytoscape.work.TaskMonitor) CyNetwork(org.cytoscape.model.CyNetwork) DegreeFilter(org.cytoscape.filter.internal.filters.degree.DegreeFilter) CyIdentifiable(org.cytoscape.model.CyIdentifiable) Test(org.junit.Test)

Example 48 with CyNetwork

use of org.cytoscape.model.CyNetwork in project cytoscape-impl by cytoscape.

the class CreateFilterTaskTest method testCreateColumnFilterString.

@Test
public void testCreateColumnFilterString() {
    CreateFilterTask task = new CreateFilterTask(serviceRegistrar, "MyFilter");
    task.jsonTunable.json = "{ \"id\" : \"ColumnFilter\", \"parameters\" : { \"criterion\" : \"1\", \"columnName\" : \"name\", \"predicate\" : \"CONTAINS\"} }";
    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.CONTAINS, columnFilter.getPredicate());
    assertEquals("1", columnFilter.getCriterion());
    assertEquals("name", columnFilter.getColumnName());
}
Also used : TaskMonitor(org.cytoscape.work.TaskMonitor) CyNetwork(org.cytoscape.model.CyNetwork) ColumnFilter(org.cytoscape.filter.internal.filters.column.ColumnFilter) CyIdentifiable(org.cytoscape.model.CyIdentifiable) Test(org.junit.Test)

Example 49 with CyNetwork

use of org.cytoscape.model.CyNetwork in project cytoscape-impl by cytoscape.

the class CreateFilterTaskTest method testCreateCompositeFilter.

@Test
public void testCreateCompositeFilter() {
    CreateFilterTask task = new CreateFilterTask(serviceRegistrar, "MyFilter");
    String subFilterJson = "{ \"id\" : \"ColumnFilter\", \"parameters\" : { \"criterion\" : \"1\", \"columnName\" : \"name\", \"predicate\" : \"CONTAINS\"} }";
    task.jsonTunable.json = "{ \"id\" : \"org.cytoscape.CompositeFilter\", \"parameters\" : { \"type\" : \"ALL\" }, \"transformers\" : [ " + subFilterJson + " ] }";
    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);
    @SuppressWarnings("rawtypes") CompositeFilter compositeFilter = (CompositeFilter) transformer.getTransformers().get(0);
    assertEquals(CompositeFilter.Type.ALL, compositeFilter.getType());
    assertEquals(1, compositeFilter.getLength());
    ColumnFilter columnFilter = (ColumnFilter) compositeFilter.get(0);
    assertEquals(Predicate.CONTAINS, columnFilter.getPredicate());
    assertEquals("1", columnFilter.getCriterion());
    assertEquals("name", columnFilter.getColumnName());
}
Also used : CompositeFilter(org.cytoscape.filter.model.CompositeFilter) TaskMonitor(org.cytoscape.work.TaskMonitor) CyNetwork(org.cytoscape.model.CyNetwork) ColumnFilter(org.cytoscape.filter.internal.filters.column.ColumnFilter) CyIdentifiable(org.cytoscape.model.CyIdentifiable) Test(org.junit.Test)

Example 50 with CyNetwork

use of org.cytoscape.model.CyNetwork in project cytoscape-impl by cytoscape.

the class MapTableToNetworkTablesTaskFactoryImpl method createTaskIterator.

@Override
public TaskIterator createTaskIterator(CyTable globalTable, boolean selectedNetworksOnly, List<CyNetwork> networksList, Class<? extends CyIdentifiable> type) {
    TableType tableType = getTableType(type);
    if (tableType == null)
        throw new IllegalArgumentException("The specified type " + type + " is not acceptable.");
    ListSingleSelection<TableType> tableTypes = new ListSingleSelection<TableType>(tableType);
    tableTypes.setSelectedValue(tableType);
    List<String> networkNames = new ArrayList<String>();
    for (CyNetwork net : networksList) {
        networkNames.add(net.getRow(net).get(CyNetwork.NAME, String.class));
    }
    ListMultipleSelection<String> networksListTunable = new ListMultipleSelection<String>(networkNames);
    networksListTunable.setSelectedValues(networkNames);
    final Map<String, Object> m = new HashMap<String, Object>();
    m.put("dataTypeOptions", tableTypes);
    m.put("selectedNetworksOnly", selectedNetworksOnly);
    m.put("networkList", networksListTunable);
    return tunableSetter.createTaskIterator(createTaskIterator(globalTable), m);
}
Also used : TableType(org.cytoscape.task.internal.table.MapTableToNetworkTablesTask.TableType) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ListMultipleSelection(org.cytoscape.work.util.ListMultipleSelection) CyNetwork(org.cytoscape.model.CyNetwork) ListSingleSelection(org.cytoscape.work.util.ListSingleSelection)

Aggregations

CyNetwork (org.cytoscape.model.CyNetwork)517 CyNode (org.cytoscape.model.CyNode)183 CyNetworkView (org.cytoscape.view.model.CyNetworkView)129 CyEdge (org.cytoscape.model.CyEdge)108 Test (org.junit.Test)107 ArrayList (java.util.ArrayList)87 CyTable (org.cytoscape.model.CyTable)75 CyApplicationManager (org.cytoscape.application.CyApplicationManager)70 CyIdentifiable (org.cytoscape.model.CyIdentifiable)57 CyRow (org.cytoscape.model.CyRow)48 HashSet (java.util.HashSet)45 CyNetworkManager (org.cytoscape.model.CyNetworkManager)40 HashMap (java.util.HashMap)35 CyRootNetwork (org.cytoscape.model.subnetwork.CyRootNetwork)35 CySubNetwork (org.cytoscape.model.subnetwork.CySubNetwork)32 CyNetworkViewManager (org.cytoscape.view.model.CyNetworkViewManager)31 VisualStyle (org.cytoscape.view.vizmap.VisualStyle)30 AbstractNetworkReaderTest (org.cytoscape.io.internal.read.AbstractNetworkReaderTest)27 TaskIterator (org.cytoscape.work.TaskIterator)27 List (java.util.List)26