Search in sources :

Example 6 with InterpreterImpl

use of org.cytoscape.equations.internal.interpreter.InterpreterImpl in project cytoscape-impl by cytoscape.

the class JoinTablesTaskTest method createTable.

private final CyTable createTable(String col, String listCol) {
    CyTable table1 = new CyTableImpl("dummy table", "ID", String.class, true, true, SavePolicy.DO_NOT_SAVE, eventHelper, ColumnDataFactory.createDefaultFactory(), new InterpreterImpl(), 2);
    table1.createColumn(col, String.class, false);
    CyRow row1 = table1.getRow(node1Name);
    row1.set(col, "col1 row1");
    CyRow row2 = table1.getRow(node2Name);
    row2.set(col, "col1 row2");
    List<String> s = new ArrayList<String>();
    s.add("listRow1-1");
    s.add("listRow1-2");
    List<String> s2 = new ArrayList<String>();
    s2.add("listRow2-1");
    s2.add("listRow2-2");
    table1.createListColumn(listCol, String.class, false);
    CyRow listRow1 = table1.getRow(node1Name);
    listRow1.set(listCol, s);
    CyRow listRow2 = table1.getRow(node2Name);
    listRow2.set(listCol, s2);
    return table1;
}
Also used : CyTable(org.cytoscape.model.CyTable) ArrayList(java.util.ArrayList) InterpreterImpl(org.cytoscape.equations.internal.interpreter.InterpreterImpl) CyRow(org.cytoscape.model.CyRow) CyTableImpl(org.cytoscape.model.internal.CyTableImpl)

Example 7 with InterpreterImpl

use of org.cytoscape.equations.internal.interpreter.InterpreterImpl in project cytoscape-impl by cytoscape.

the class DegreeTest method test.

@Test
public void test() {
    final EquationParserImpl parser = new EquationParserImpl(serviceRegistrar);
    final EquationCompilerImpl compiler = new EquationCompilerImpl(parser);
    parser.registerFunctionInternal(new Degree(serviceRegistrar));
    final Map<String, Class<?>> variableNameToTypeMap = new HashMap<String, Class<?>>();
    if (!compiler.compile("=DEGREE(101)", variableNameToTypeMap))
        fail(compiler.getLastErrorMsg());
    final Equation equation = compiler.getEquation();
    final Interpreter interpreter = new InterpreterImpl();
    final Map<String, IdentDescriptor> variableNameToDescriptorMap = new HashMap<String, IdentDescriptor>();
    assertEquals("Equation evaluation returned an unexpected result!", 3L, interpreter.execute(equation, variableNameToDescriptorMap));
}
Also used : EquationParserImpl(org.cytoscape.equations.internal.EquationParserImpl) EquationCompilerImpl(org.cytoscape.equations.internal.EquationCompilerImpl) Interpreter(org.cytoscape.equations.Interpreter) HashMap(java.util.HashMap) Equation(org.cytoscape.equations.Equation) InterpreterImpl(org.cytoscape.equations.internal.interpreter.InterpreterImpl) IdentDescriptor(org.cytoscape.equations.IdentDescriptor) Test(org.junit.Test)

Example 8 with InterpreterImpl

use of org.cytoscape.equations.internal.interpreter.InterpreterImpl in project cytoscape-impl by cytoscape.

the class TestCyNetworkFactory method mockCyServiceRegistrar.

private static CyServiceRegistrar mockCyServiceRegistrar(CyEventHelper deh) {
    CyServiceRegistrar serviceRegistrar = mock(CyServiceRegistrar.class);
    CyNetworkNaming namingUtil = mock(CyNetworkNaming.class);
    EquationCompiler compiler = new EquationCompilerImpl(new EquationParserImpl(serviceRegistrar));
    final Interpreter interpreter = new InterpreterImpl();
    when(serviceRegistrar.getService(CyEventHelper.class)).thenReturn(deh);
    when(serviceRegistrar.getService(CyNetworkNaming.class)).thenReturn(namingUtil);
    when(serviceRegistrar.getService(EquationCompiler.class)).thenReturn(compiler);
    when(serviceRegistrar.getService(Interpreter.class)).thenReturn(interpreter);
    return serviceRegistrar;
}
Also used : EquationParserImpl(org.cytoscape.equations.internal.EquationParserImpl) EquationCompilerImpl(org.cytoscape.equations.internal.EquationCompilerImpl) Interpreter(org.cytoscape.equations.Interpreter) CyNetworkNaming(org.cytoscape.session.CyNetworkNaming) InterpreterImpl(org.cytoscape.equations.internal.interpreter.InterpreterImpl) EquationCompiler(org.cytoscape.equations.EquationCompiler) CyServiceRegistrar(org.cytoscape.service.util.CyServiceRegistrar)

Example 9 with InterpreterImpl

use of org.cytoscape.equations.internal.interpreter.InterpreterImpl in project cytoscape-impl by cytoscape.

the class TestCyNetworkFactory method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    eh = new DummyCyEventHelper(false);
    Interpreter interpreter = new InterpreterImpl();
    EquationCompiler compiler = new EquationCompilerImpl(new EquationParserImpl(serviceRegistrar));
    when(serviceRegistrar.getService(CyEventHelper.class)).thenReturn(eh);
    when(serviceRegistrar.getService(CyNetworkNaming.class)).thenReturn(namingUtil);
    when(serviceRegistrar.getService(EquationCompiler.class)).thenReturn(compiler);
    when(serviceRegistrar.getService(Interpreter.class)).thenReturn(interpreter);
    netTblMgr = new CyNetworkTableManagerImpl();
    netMgr = new CyNetworkManagerImpl(serviceRegistrar);
    tblMgr = new CyTableManagerImpl(netTblMgr, netMgr, serviceRegistrar);
    tblFactory = new CyTableFactoryImpl(eh, serviceRegistrar);
    netFactory = new CyNetworkFactoryImpl(eh, tblMgr, netTblMgr, tblFactory, serviceRegistrar);
}
Also used : EquationParserImpl(org.cytoscape.equations.internal.EquationParserImpl) CyTableFactoryImpl(org.cytoscape.model.internal.CyTableFactoryImpl) Interpreter(org.cytoscape.equations.Interpreter) EquationCompilerImpl(org.cytoscape.equations.internal.EquationCompilerImpl) CyNetworkManagerImpl(org.cytoscape.model.internal.CyNetworkManagerImpl) CyNetworkTableManagerImpl(org.cytoscape.model.internal.CyNetworkTableManagerImpl) DummyCyEventHelper(org.cytoscape.event.DummyCyEventHelper) InterpreterImpl(org.cytoscape.equations.internal.interpreter.InterpreterImpl) CyNetworkFactoryImpl(org.cytoscape.model.internal.CyNetworkFactoryImpl) EquationCompiler(org.cytoscape.equations.EquationCompiler) CyTableManagerImpl(org.cytoscape.model.internal.CyTableManagerImpl) Before(org.junit.Before)

Example 10 with InterpreterImpl

use of org.cytoscape.equations.internal.interpreter.InterpreterImpl in project cytoscape-impl by cytoscape.

the class CyTableManagerTest method setUp.

@Before
public void setUp() {
    final Interpreter interpreter = new InterpreterImpl();
    when(serviceRegistrar.getService(CyEventHelper.class)).thenReturn(eventHelper);
    when(serviceRegistrar.getService(CyNetworkNaming.class)).thenReturn(namingUtil);
    when(serviceRegistrar.getService(EquationCompiler.class)).thenReturn(compiler);
    when(serviceRegistrar.getService(Interpreter.class)).thenReturn(interpreter);
    networkTableMgr = new CyNetworkTableManagerImpl();
    networkManager = new CyNetworkManagerImpl(serviceRegistrar);
    mgr = new CyTableManagerImpl(networkTableMgr, networkManager, serviceRegistrar);
    assertNotNull(mgr);
    assertEquals(0, mgr.getAllTables(true).size());
    final CyServiceRegistrar serviceRegistrar = mock(CyServiceRegistrar.class);
    final CyTableFactoryImpl tableFactory = new CyTableFactoryImpl(eventHelper, serviceRegistrar);
    goodNetwork = new CyRootNetworkImpl(eventHelper, (CyTableManagerImpl) mgr, networkTableMgr, tableFactory, serviceRegistrar, true, SavePolicy.DO_NOT_SAVE).getBaseNetwork();
    networkManager.addNetwork(goodNetwork);
    globalTable = tableFactory.createTable("test table", CyIdentifiable.SUID, Long.class, true, true);
    assertNotNull(globalTable);
    assertNotNull(goodNetwork);
    assertEquals(1, networkManager.getNetworkSet().size());
}
Also used : CyTableFactoryImpl(org.cytoscape.model.internal.CyTableFactoryImpl) Interpreter(org.cytoscape.equations.Interpreter) CyNetworkManagerImpl(org.cytoscape.model.internal.CyNetworkManagerImpl) CyNetworkTableManagerImpl(org.cytoscape.model.internal.CyNetworkTableManagerImpl) CyRootNetworkImpl(org.cytoscape.model.internal.CyRootNetworkImpl) InterpreterImpl(org.cytoscape.equations.internal.interpreter.InterpreterImpl) CyTableManagerImpl(org.cytoscape.model.internal.CyTableManagerImpl) CyServiceRegistrar(org.cytoscape.service.util.CyServiceRegistrar) Before(org.junit.Before)

Aggregations

InterpreterImpl (org.cytoscape.equations.internal.interpreter.InterpreterImpl)17 Interpreter (org.cytoscape.equations.Interpreter)14 EquationCompilerImpl (org.cytoscape.equations.internal.EquationCompilerImpl)9 EquationParserImpl (org.cytoscape.equations.internal.EquationParserImpl)9 HashMap (java.util.HashMap)7 IdentDescriptor (org.cytoscape.equations.IdentDescriptor)7 Test (org.junit.Test)7 Equation (org.cytoscape.equations.Equation)5 CyNetworkManagerImpl (org.cytoscape.model.internal.CyNetworkManagerImpl)5 CyNetworkTableManagerImpl (org.cytoscape.model.internal.CyNetworkTableManagerImpl)5 CyTableManagerImpl (org.cytoscape.model.internal.CyTableManagerImpl)5 Before (org.junit.Before)5 CyTableFactoryImpl (org.cytoscape.model.internal.CyTableFactoryImpl)4 CyTableImpl (org.cytoscape.model.internal.CyTableImpl)4 CyServiceRegistrar (org.cytoscape.service.util.CyServiceRegistrar)4 EquationCompiler (org.cytoscape.equations.EquationCompiler)3 DummyCyEventHelper (org.cytoscape.event.DummyCyEventHelper)3 CyRow (org.cytoscape.model.CyRow)2 CyNetworkFactoryImpl (org.cytoscape.model.internal.CyNetworkFactoryImpl)2 CyRootNetworkImpl (org.cytoscape.model.internal.CyRootNetworkImpl)2