Search in sources :

Example 6 with EquationCompiler

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);
    }
}
Also used : CyTable(org.cytoscape.model.CyTable) EquationCompiler(org.cytoscape.equations.EquationCompiler)

Example 7 with EquationCompiler

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();
}
Also used : CyNetworkTableManager(org.cytoscape.model.CyNetworkTableManager) CyRootNetworkManager(org.cytoscape.model.subnetwork.CyRootNetworkManager) InputStream(java.io.InputStream) CyNetworkReaderManager(org.cytoscape.io.read.CyNetworkReaderManager) ReadCache(org.cytoscape.io.internal.util.ReadCache) CyServiceRegistrar(org.cytoscape.service.util.CyServiceRegistrar) GroupUtil(org.cytoscape.io.internal.util.GroupUtil) VizmapReaderManager(org.cytoscape.io.read.VizmapReaderManager) CyPropertyReaderManager(org.cytoscape.io.read.CyPropertyReaderManager) TableTestSupport(org.cytoscape.model.TableTestSupport) SUIDUpdater(org.cytoscape.io.internal.util.SUIDUpdater) CSVCyReaderFactory(org.cytoscape.io.internal.read.datatable.CSVCyReaderFactory) EquationCompiler(org.cytoscape.equations.EquationCompiler) Before(org.junit.Before)

Example 8 with EquationCompiler

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());
            }
        }
    }
}
Also used : Hashtable(java.util.Hashtable) CyColumn(org.cytoscape.model.CyColumn) Equation(org.cytoscape.equations.Equation) CyRow(org.cytoscape.model.CyRow) EquationCompiler(org.cytoscape.equations.EquationCompiler) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

Example 9 with EquationCompiler

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;
}
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 10 with EquationCompiler

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);
}
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)

Aggregations

EquationCompiler (org.cytoscape.equations.EquationCompiler)13 CyTable (org.cytoscape.model.CyTable)5 Equation (org.cytoscape.equations.Equation)4 EquationCompilerImpl (org.cytoscape.equations.internal.EquationCompilerImpl)4 EquationParserImpl (org.cytoscape.equations.internal.EquationParserImpl)4 CyRow (org.cytoscape.model.CyRow)4 Before (org.junit.Before)4 HashMap (java.util.HashMap)3 Interpreter (org.cytoscape.equations.Interpreter)3 InterpreterImpl (org.cytoscape.equations.internal.interpreter.InterpreterImpl)3 CyNetworkManagerImpl (org.cytoscape.model.internal.CyNetworkManagerImpl)3 CyNetworkTableManagerImpl (org.cytoscape.model.internal.CyNetworkTableManagerImpl)3 CyTableManagerImpl (org.cytoscape.model.internal.CyTableManagerImpl)3 CyServiceRegistrar (org.cytoscape.service.util.CyServiceRegistrar)3 Map (java.util.Map)2 DummyCyEventHelper (org.cytoscape.event.DummyCyEventHelper)2 CyColumn (org.cytoscape.model.CyColumn)2 CyTableFactoryImpl (org.cytoscape.model.internal.CyTableFactoryImpl)2 Font (java.awt.Font)1 ActionEvent (java.awt.event.ActionEvent)1