use of org.cytoscape.equations.EquationCompiler in project cytoscape-impl by cytoscape.
the class CyTableManagerImpl method refreshTableEquations.
private void refreshTableEquations() {
final EquationCompiler compiler = serviceRegistrar.getService(EquationCompiler.class);
Set<CyTable> tables = getAllTables(true);
for (CyTable table : tables) {
EquationUtil.refreshEquations(table, compiler);
}
}
use of org.cytoscape.equations.EquationCompiler in project cytoscape-impl by cytoscape.
the class Cy3SessionReaderImplTest method setUp.
@Before
public void setUp() {
InputStream is = mock(InputStream.class);
GroupUtil groupUtil = mock(GroupUtil.class);
SUIDUpdater suidUpdater = mock(SUIDUpdater.class);
CyNetworkReaderManager netReaderMgr = mock(CyNetworkReaderManager.class);
CyPropertyReaderManager propReaderMgr = mock(CyPropertyReaderManager.class);
VizmapReaderManager vizmapReaderMgr = mock(VizmapReaderManager.class);
CSVCyReaderFactory csvCyReaderFactory = mock(CSVCyReaderFactory.class);
CyNetworkTableManager netTblMgr = mock(CyNetworkTableManager.class);
CyRootNetworkManager rootNetMgr = mock(CyRootNetworkManager.class);
EquationCompiler compiler = mock(EquationCompiler.class);
CyServiceRegistrar serviceRegistrar = mock(CyServiceRegistrar.class);
when(serviceRegistrar.getService(CyNetworkTableManager.class)).thenReturn(netTblMgr);
when(serviceRegistrar.getService(CyRootNetworkManager.class)).thenReturn(rootNetMgr);
when(serviceRegistrar.getService(EquationCompiler.class)).thenReturn(compiler);
ReadCache cache = new ReadCache(serviceRegistrar);
reader = new Cy3SessionReaderImpl(is, cache, groupUtil, suidUpdater, netReaderMgr, propReaderMgr, vizmapReaderMgr, csvCyReaderFactory, serviceRegistrar);
tblTestSupport = new TableTestSupport();
}
use of org.cytoscape.equations.EquationCompiler in project cytoscape-impl by cytoscape.
the class ReadDataManager method parseAllEquations.
/**
* Should be called only after all XGMML attributes have been read.
*/
protected void parseAllEquations() {
final EquationCompiler equationCompiler = serviceRegistrar.getService(EquationCompiler.class);
for (Map.Entry<CyRow, Map<String, String>> entry : equations.entrySet()) {
CyRow row = entry.getKey();
Map<String, String> colEquationMap = entry.getValue();
Map<String, Class<?>> colNameTypeMap = new Hashtable<String, Class<?>>();
Collection<CyColumn> columns = row.getTable().getColumns();
for (CyColumn col : columns) {
colNameTypeMap.put(col.getName(), col.getType());
}
for (Map.Entry<String, String> colEqEntry : colEquationMap.entrySet()) {
String columnName = colEqEntry.getKey();
String formula = colEqEntry.getValue();
if (equationCompiler.compile(formula, colNameTypeMap)) {
Equation equation = equationCompiler.getEquation();
row.set(columnName, equation);
} else {
logger.error("Error parsing equation \"" + formula + "\": " + equationCompiler.getLastErrorMsg());
}
}
}
}
use of org.cytoscape.equations.EquationCompiler 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;
}
use of org.cytoscape.equations.EquationCompiler 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);
}
Aggregations