use of org.cytoscape.equations.Interpreter in project cytoscape-impl by cytoscape.
the class SourceIDTest method test.
@Test
public void test() {
final EquationParserImpl parser = new EquationParserImpl(serviceRegistrar);
final EquationCompilerImpl compiler = new EquationCompilerImpl(parser);
parser.registerFunctionInternal(new SourceID(serviceRegistrar));
final Map<String, Class<?>> variableNameToTypeMap = new HashMap<String, Class<?>>();
if (!compiler.compile("=SOURCEID(11)", 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!", 101L, interpreter.execute(equation, variableNameToDescriptorMap));
}
use of org.cytoscape.equations.Interpreter in project cytoscape-impl by cytoscape.
the class CyTableManagerTest method tableWithVirtColumnDeletionTest.
@Test
public void tableWithVirtColumnDeletionTest() {
final Interpreter interpreter = new InterpreterImpl();
CyTable table = new CyTableImpl("homer", CyIdentifiable.SUID, Long.class, true, true, SavePolicy.SESSION_FILE, eventHelper, ColumnDataFactory.createDefaultFactory(), interpreter, 1000);
CyTable table2 = new CyTableImpl("marge", CyIdentifiable.SUID, Long.class, true, true, SavePolicy.SESSION_FILE, eventHelper, ColumnDataFactory.createDefaultFactory(), interpreter, 1000);
table.createColumn("x", Long.class, false);
CyColumn column = table.getColumn("x");
assertNull(column.getVirtualColumnInfo().getSourceTable());
table2.createListColumn("b", Boolean.class, false);
table.addVirtualColumn("b1", "b", table2, "x", true);
mgr.addTable(table2);
boolean caughtException = false;
try {
mgr.deleteTable(table2.getSUID());
} catch (IllegalArgumentException e) {
caughtException = true;
}
assertTrue(caughtException);
table2.deleteColumn("b1");
mgr.deleteTable(table.getSUID());
}
use of org.cytoscape.equations.Interpreter in project cytoscape-impl by cytoscape.
the class CySubNetworkCyTableManagerTest method setUp.
@Before
public void setUp() {
final CyEventHelper eh = new DummyCyEventHelper();
final CyNetworkNaming namingUtil = mock(CyNetworkNaming.class);
final CyServiceRegistrar serviceRegistrar = mock(CyServiceRegistrar.class);
final EquationCompiler compiler = new EquationCompilerImpl(new EquationParserImpl(serviceRegistrar));
final Interpreter interpreter = new InterpreterImpl();
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);
networkTableMgr = new CyNetworkTableManagerImpl();
networkManager = new CyNetworkManagerImpl(serviceRegistrar);
mgr = new CyTableManagerImpl(networkTableMgr, networkManager, serviceRegistrar);
CyTableFactoryImpl tableFactory = new CyTableFactoryImpl(eh, serviceRegistrar);
CyRootNetworkImpl baseNet = new CyRootNetworkImpl(eh, (CyTableManagerImpl) mgr, networkTableMgr, tableFactory, serviceRegistrar, true, SavePolicy.DO_NOT_SAVE);
// This is a different subnetwork and not "baseNetwork" in ArrayGraph.
goodNetwork = baseNet.addSubNetwork();
globalTable = tableFactory.createTable("test table", CyIdentifiable.SUID, Long.class, true, true);
networkManager.addNetwork(goodNetwork);
assertNotNull(globalTable);
assertNotNull(goodNetwork);
assertEquals(1, networkManager.getNetworkSet().size());
}
use of org.cytoscape.equations.Interpreter in project cytoscape-impl by cytoscape.
the class CyTableTest method setUp.
@Before
public void setUp() {
eventHelper = new DummyCyEventHelper();
compiler = new EquationCompilerImpl(new EquationParserImpl(serviceRegistrar));
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);
table = new CyTableImpl("homer", CyIdentifiable.SUID, Long.class, false, true, SavePolicy.SESSION_FILE, eventHelper, ColumnDataFactory.createDefaultFactory(), interpreter, 1000);
attrs = table.getRow(1L);
table2 = new CyTableImpl("marge", CyIdentifiable.SUID, Long.class, false, true, SavePolicy.SESSION_FILE, eventHelper, ColumnDataFactory.createDefaultFactory(), interpreter, 1000);
CyTableManagerImpl tblMgr = new CyTableManagerImpl(new CyNetworkTableManagerImpl(), new CyNetworkManagerImpl(serviceRegistrar), serviceRegistrar);
tblMgr.addTable(table);
((CyTableImpl) table).handleEvent(new TableAddedEvent(tblMgr, table));
tblMgr.addTable(table2);
((CyTableImpl) table2).handleEvent(new TableAddedEvent(tblMgr, table2));
}
use of org.cytoscape.equations.Interpreter in project cytoscape-impl by cytoscape.
the class CyNetworkTableManagerTest method setUp.
@Before
public void setUp() {
super.setUp();
final Interpreter interpreter = new InterpreterImpl();
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);
this.mgr = new CyNetworkTableManagerImpl();
this.networkManager = new CyNetworkManagerImpl(serviceRegistrar);
this.tableManager = new CyTableManagerImpl(mgr, networkManager, serviceRegistrar);
this.tableFactory = new CyTableFactoryImpl(eh, serviceRegistrar);
this.networkFactory = new CyNetworkFactoryImpl(eh, tableManager, mgr, tableFactory, serviceRegistrar);
goodNetwork = networkFactory.createNetwork();
}
Aggregations