use of org.cytoscape.equations.internal.interpreter.InterpreterImpl in project cytoscape-impl by cytoscape.
the class MapTableToNetworkTableTaskTest method testMappingTableToNetwork.
@Test
public void testMappingTableToNetwork() throws Exception {
stm.addTunableHandlerFactory(syncTunableHandlerFactory, syncFactoryProp);
net1 = support.getNetwork();
node1 = net1.addNode();
node2 = net1.addNode();
net1.addEdge(node1, node2, true);
net1.getDefaultNodeTable().getRow(node1.getSUID()).set(CyRootNetwork.SHARED_NAME, node1Name);
net1.getDefaultNodeTable().getRow(node2.getSUID()).set(CyRootNetwork.SHARED_NAME, node2Name);
netMgr.addNetwork(net1);
table1 = new CyTableImpl("dummy table", "ID", String.class, true, true, SavePolicy.DO_NOT_SAVE, eventHelper, ColumnDataFactory.createDefaultFactory(), new InterpreterImpl(), 2);
table1.createColumn("col1", String.class, false);
CyRow row1 = table1.getRow(node1Name);
row1.set("col1", "col1 row1");
CyRow row2 = table1.getRow(node2Name);
row2.set("col1", "col1 row2");
mapping(table1, net1, false);
assertNotNull(net1.getDefaultNodeTable().getColumn("col1"));
assertEquals("col1 row1", net1.getRow(node1).get("col1", String.class));
}
use of org.cytoscape.equations.internal.interpreter.InterpreterImpl in project cytoscape-impl by cytoscape.
the class InDegreeTest method test.
@Test
public void test() {
final EquationParserImpl parser = new EquationParserImpl(serviceRegistrar);
final EquationCompilerImpl compiler = new EquationCompilerImpl(parser);
parser.registerFunctionInternal(new InDegree(serviceRegistrar));
final Map<String, Class<?>> variableNameToTypeMap = new HashMap<String, Class<?>>();
if (!compiler.compile("=INDEGREE(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));
}
use of org.cytoscape.equations.internal.interpreter.InterpreterImpl in project cytoscape-impl by cytoscape.
the class OutDegreeTest method test.
@Test
public void test() {
final EquationParserImpl parser = new EquationParserImpl(serviceRegistrar);
final EquationCompilerImpl compiler = new EquationCompilerImpl(parser);
parser.registerFunctionInternal(new OutDegree(serviceRegistrar));
final Map<String, Class<?>> variableNameToTypeMap = new HashMap<String, Class<?>>();
if (!compiler.compile("=OUTDEGREE(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));
}
use of org.cytoscape.equations.internal.interpreter.InterpreterImpl in project cytoscape-impl by cytoscape.
the class TargetIDTest method test.
@Test
public void test() {
final EquationParserImpl parser = new EquationParserImpl(serviceRegistrar);
final EquationCompilerImpl compiler = new EquationCompilerImpl(parser);
parser.registerFunctionInternal(new TargetID(serviceRegistrar));
final Map<String, Class<?>> variableNameToTypeMap = new HashMap<String, Class<?>>();
if (!compiler.compile("=TARGETID(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.internal.interpreter.InterpreterImpl in project cytoscape-impl by cytoscape.
the class CyActivator method start.
@Override
public void start(BundleContext bc) {
final CyServiceRegistrar serviceRegistrar = getService(bc, CyServiceRegistrar.class);
InterpreterImpl interpreter = new InterpreterImpl();
EquationParserImpl parser = new EquationParserImpl(serviceRegistrar);
EquationCompilerImpl compiler = new EquationCompilerImpl(parser);
registerService(bc, compiler, EquationCompiler.class, new Properties());
registerService(bc, interpreter, Interpreter.class, new Properties());
registerService(bc, parser, EquationParser.class, new Properties());
// For dynamically add functions.
registerServiceListener(bc, parser::registerFunctionService, parser::unregisterFunctionService, Function.class);
}
Aggregations