Search in sources :

Example 1 with CyNetworkView

use of org.cytoscape.view.model.CyNetworkView in project EnrichmentMapApp by BaderLab.

the class HeatMapMediator method heatMapParamsChanged.

/**
	 * Callback that HeatMapMainPanel calls.
	 */
public void heatMapParamsChanged(HeatMapParams params) {
    CyNetworkView networkView = applicationManager.getCurrentNetworkView();
    if (networkView != null) {
        Long suid = networkView.getModel().getSUID();
        EnrichmentMap map = emManager.getEnrichmentMap(suid);
        // Overwrite all the params of the other one except 'operator'.
        // The 'operator' field is the only param that is kept separate.
        HeatMapParams otherParams = getHeatMapParams(map, suid, !onlyEdges);
        HeatMapParams newOtherParams = new HeatMapParams.Builder(params).setOperator(otherParams.getOperator()).build();
        emManager.registerHeatMapParams(suid, !onlyEdges, newOtherParams);
        emManager.registerHeatMapParams(suid, onlyEdges, params);
    }
}
Also used : EMStyleBuilder(org.baderlab.csplugins.enrichmentmap.style.EMStyleBuilder) EnrichmentMap(org.baderlab.csplugins.enrichmentmap.model.EnrichmentMap) CyNetworkView(org.cytoscape.view.model.CyNetworkView)

Example 2 with CyNetworkView

use of org.cytoscape.view.model.CyNetworkView in project EnrichmentMapApp by BaderLab.

the class SessionViewIO method restoreView.

public void restoreView(CySession session) {
    if (!headless) {
        CyTable table = getPrivateTable();
        if (table != null) {
            for (CyRow row : table.getAllRows()) {
                Long suid = COL_NETWORK_VIEW_ID.get(row);
                String json = COL_VIEW_JSON.get(row);
                if (suid != null && json != null) {
                    CyNetworkView netView = getNetworkView(suid);
                    if (netView != null) {
                        ViewParams params = ViewSerializer.deserialize(json);
                        if (params != null) {
                            params.setNetworkViewID(netView.getSUID());
                            controlPanelMediatorProvider.get().reset(params);
                        }
                    }
                }
            }
        }
    }
}
Also used : CyTable(org.cytoscape.model.CyTable) CyRow(org.cytoscape.model.CyRow) CyNetworkView(org.cytoscape.view.model.CyNetworkView)

Example 3 with CyNetworkView

use of org.cytoscape.view.model.CyNetworkView in project EnrichmentMapApp by BaderLab.

the class BaseNetworkTest method runPostAnalysis.

protected void runPostAnalysis(CyNetwork emNetwork, PostAnalysisParameters.Builder builder, String dataSetName) throws Exception {
    // Set up mocks
    when(applicationManager.getCurrentNetwork()).thenReturn(emNetwork);
    CyNetworkView networkViewMock = mock(CyNetworkView.class);
    when(applicationManager.getCurrentNetworkView()).thenReturn(networkViewMock);
    when(networkViewManager.getNetworkViews(emNetwork)).thenReturn(Arrays.asList(networkViewMock));
    @SuppressWarnings("unchecked") View<CyNode> nodeViewMock = Mockito.mock(View.class);
    when(networkViewMock.getNodeView(Matchers.<CyNode>anyObject())).thenReturn(nodeViewMock);
    when(nodeViewMock.getVisualProperty(BasicVisualLexicon.NODE_Y_LOCATION)).thenReturn(Double.valueOf(0.0));
    EnrichmentMap map = emManager.getEnrichmentMap(emNetwork.getSUID());
    assertNotNull(map);
    // Load the gene-sets from the file
    SerialTestTaskManager testTaskManager = new SerialTestTaskManager();
    File file = new File(builder.getSignatureGMTFileName());
    LoadSignatureSetsActionListener loader = loadSignatureSetsActionListenerFactory.create(file, new FilterMetric.None(), map);
    loader.setTaskManager(testTaskManager);
    loader.setGeneSetCallback(builder::setLoadedGMTGeneSets);
    loader.setFilteredSignatureSetsCallback(builder::addSelectedGeneSetNames);
    loader.actionPerformed(null);
    PostAnalysisParameters paParams = builder.build();
    // Run post-analysis
    EMDataSet dataSet = map.getDataSet(dataSetName);
    CreateDiseaseSignatureTaskParallel signatureTask = buildDiseaseSignatureTaskFactory.create(paParams, map, Arrays.asList(dataSet));
    testTaskManager = new SerialTestTaskManager();
    testTaskManager.execute(new TaskIterator(signatureTask));
}
Also used : SerialTestTaskManager(org.baderlab.csplugins.enrichmentmap.SerialTestTaskManager) EnrichmentMap(org.baderlab.csplugins.enrichmentmap.model.EnrichmentMap) FilterMetric(org.baderlab.csplugins.enrichmentmap.task.postanalysis.FilterMetric) CreateDiseaseSignatureTaskParallel(org.baderlab.csplugins.enrichmentmap.task.postanalysis.CreateDiseaseSignatureTaskParallel) PostAnalysisParameters(org.baderlab.csplugins.enrichmentmap.model.PostAnalysisParameters) TaskIterator(org.cytoscape.work.TaskIterator) LoadSignatureSetsActionListener(org.baderlab.csplugins.enrichmentmap.actions.LoadSignatureSetsActionListener) CyNode(org.cytoscape.model.CyNode) EMDataSet(org.baderlab.csplugins.enrichmentmap.model.EMDataSet) CyNetworkView(org.cytoscape.view.model.CyNetworkView) File(java.io.File)

Example 4 with CyNetworkView

use of org.cytoscape.view.model.CyNetworkView in project EnrichmentMapApp by BaderLab.

the class ControlPanel method getEmViewCombo.

JComboBox<CyNetworkView> getEmViewCombo() {
    if (emViewCombo == null) {
        emViewCombo = new JComboBox<>();
        emViewCombo.setRenderer(new DefaultListCellRenderer() {

            @Override
            public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
                super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
                if (value instanceof CyNetworkView)
                    this.setText(NetworkUtil.getTitle((CyNetworkView) value));
                else
                    this.setText("-- Select EnrichmentMap View --");
                return this;
            }
        });
    }
    return emViewCombo;
}
Also used : DefaultListCellRenderer(javax.swing.DefaultListCellRenderer) Component(java.awt.Component) JComponent(javax.swing.JComponent) CyNetworkView(org.cytoscape.view.model.CyNetworkView)

Example 5 with CyNetworkView

use of org.cytoscape.view.model.CyNetworkView in project EnrichmentMapApp by BaderLab.

the class ControlPanel method updateEmViewCombo.

void updateEmViewCombo() {
    CyNetworkView selectedItem = (CyNetworkView) getEmViewCombo().getSelectedItem();
    Map<Long, EnrichmentMap> emMap = emManager.getAllEnrichmentMaps();
    getEmViewCombo().setEnabled(!emMap.isEmpty());
    getEmViewCombo().removeAllItems();
    if (!emMap.isEmpty()) {
        Set<CyNetworkView> allViews = networkViewManager.getNetworkViewSet();
        List<CyNetworkView> emViews = allViews.stream().filter(emManager::isEnrichmentMap).collect(Collectors.toList());
        Collator collator = Collator.getInstance(Locale.getDefault());
        emViews.sort((v1, v2) -> collator.compare(NetworkUtil.getTitle(v1), NetworkUtil.getTitle(v2)));
        emViews.forEach(getEmViewCombo()::addItem);
        getEmViewCombo().setSelectedItem(selectedItem);
    }
}
Also used : EnrichmentMap(org.baderlab.csplugins.enrichmentmap.model.EnrichmentMap) CyNetworkView(org.cytoscape.view.model.CyNetworkView) Collator(java.text.Collator)

Aggregations

CyNetworkView (org.cytoscape.view.model.CyNetworkView)41 Test (org.junit.Test)16 CyNetwork (org.cytoscape.model.CyNetwork)13 EnrichmentMap (org.baderlab.csplugins.enrichmentmap.model.EnrichmentMap)10 VisualStyle (org.cytoscape.view.vizmap.VisualStyle)8 CyNode (org.cytoscape.model.CyNode)7 HashMap (java.util.HashMap)5 JPanel (javax.swing.JPanel)5 CyEdge (org.cytoscape.model.CyEdge)5 TaskIterator (org.cytoscape.work.TaskIterator)5 Timer (javax.swing.Timer)4 EMDataSet (org.baderlab.csplugins.enrichmentmap.model.EMDataSet)4 EMSignatureDataSet (org.baderlab.csplugins.enrichmentmap.model.EMSignatureDataSet)4 CyTable (org.cytoscape.model.CyTable)4 CyCustomGraphics2 (org.cytoscape.view.presentation.customgraphics.CyCustomGraphics2)4 Inject (com.google.inject.Inject)3 ActionEvent (java.awt.event.ActionEvent)3 ActionListener (java.awt.event.ActionListener)3 HashSet (java.util.HashSet)3 List (java.util.List)3