Search in sources :

Example 36 with CyNetwork

use of org.cytoscape.model.CyNetwork in project EnrichmentMapApp by BaderLab.

the class SessionModelIO method restoreModelFromTables.

private boolean restoreModelFromTables(CySession session) {
    boolean sessionHasEM = false;
    CyTable table = getPrivateTable();
    if (table != null) {
        for (CyRow row : table.getAllRows()) {
            Long suid = COL_NETWORK_ID.get(row);
            String json = COL_EM_JSON.get(row);
            if (suid != null && json != null) {
                CyNetwork network = networkManager.getNetwork(suid);
                if (network != null) {
                    EnrichmentMap em = ModelSerializer.deserialize(json);
                    if (em != null) {
                        em.setServiceRegistrar(serviceRegistrar);
                        em.setNetworkID(network.getSUID());
                        updateSuids(em, session);
                        emManager.registerEnrichmentMap(em);
                        sessionHasEM = true;
                    }
                }
            }
        }
    }
    return sessionHasEM;
}
Also used : CyTable(org.cytoscape.model.CyTable) CyNetwork(org.cytoscape.model.CyNetwork) EnrichmentMap(org.baderlab.csplugins.enrichmentmap.model.EnrichmentMap) CyRow(org.cytoscape.model.CyRow)

Example 37 with CyNetwork

use of org.cytoscape.model.CyNetwork in project EnrichmentMapApp by BaderLab.

the class LegacySessionLoadTest method test_2_LoadTwoDataSetWithPostAnalysisLegacySession.

@Test
@SessionFile("em_session_2.2_twodataset_pa.cys")
public void test_2_LoadTwoDataSetWithPostAnalysisLegacySession() {
    EnrichmentMap map = getEnrichmentMap();
    assertEquals(2, map.getDataSetCount());
    assertEquals(11445, map.getAllGenes().size());
    CyNetwork network = networkManager.getNetwork(map.getNetworkID());
    Map<String, CyEdge> edges = TestUtils.getEdges(network);
    assertEquals(15, edges.size());
    assertTrue(edges.containsKey("PA_TOP8_MIDDLE8_BOTTOM8 (sig_set1) BOTTOM8_PLUS100"));
    assertTrue(edges.containsKey("PA_TOP8_MIDDLE8_BOTTOM8 (sig_set1) TOP8_PLUS100"));
    assertTrue(edges.containsKey("PA_TOP8_MIDDLE8_BOTTOM8 (sig_set1) MIDDLE8_PLUS100"));
}
Also used : CyNetwork(org.cytoscape.model.CyNetwork) EnrichmentMap(org.baderlab.csplugins.enrichmentmap.model.EnrichmentMap) CyEdge(org.cytoscape.model.CyEdge) BaseIntegrationTest(org.baderlab.csplugins.enrichmentmap.integration.BaseIntegrationTest) Test(org.junit.Test) SessionFile(org.baderlab.csplugins.enrichmentmap.integration.SessionFile)

Example 38 with CyNetwork

use of org.cytoscape.model.CyNetwork in project EnrichmentMapApp by BaderLab.

the class Protocol1Test method testProtocol1.

@Test
public void testProtocol1() throws Exception {
    EMBuildCommandTask task = injector.getInstance(EMBuildCommandTask.class);
    File enrichmentFile = TestUtils.createTempFile(PATH, "gprofiler_results_mesenonly_ordered_computedinR.txt");
    assertTrue(enrichmentFile.exists());
    task.analysisType.setSelectedValue(EnrichmentMapParameters.method_generic);
    task.coeffecients.setSelectedValue(EnrichmentMapParameters.SM_JACCARD);
    task.enrichmentsDataset1 = enrichmentFile;
    task.pvalue = 1.0;
    task.qvalue = 0.00001;
    task.similaritycutoff = 0.25;
    SerialTestTaskManager taskManager = new SerialTestTaskManager();
    taskManager.execute(new TaskIterator(task));
    // Assert the network was created
    CyNetwork generatedNetwork = assertAndGetOnlyNetwork();
    CyNetwork expectedNetwork = importNetworkFromFile(PATH, "protocol_1_expected.xgmml");
    Set<String> columnsToIgnore = ImmutableSet.of("EM1_ENR_SET", "EM1_ENRICHMENT_SET", "EM1_Data Set");
    assertNetworksEqual(expectedNetwork, generatedNetwork, columnsToIgnore);
}
Also used : SerialTestTaskManager(org.baderlab.csplugins.enrichmentmap.integration.SerialTestTaskManager) TaskIterator(org.cytoscape.work.TaskIterator) CyNetwork(org.cytoscape.model.CyNetwork) EMBuildCommandTask(org.baderlab.csplugins.enrichmentmap.commands.EMBuildCommandTask) File(java.io.File) BaseIntegrationTest(org.baderlab.csplugins.enrichmentmap.integration.BaseIntegrationTest) Test(org.junit.Test)

Example 39 with CyNetwork

use of org.cytoscape.model.CyNetwork in project EnrichmentMapApp by BaderLab.

the class LegacySessionLoadTest method test_2_LoadTwoDataSetLegacySession.

@Test
@SessionFile("em_session_2.2_twodataset.cys")
public void test_2_LoadTwoDataSetLegacySession() {
    EnrichmentMap map = getEnrichmentMap();
    assertEquals(2, map.getDataSetCount());
    assertEquals(11445, map.getAllGenes().size());
    CyNetwork network = networkManager.getNetwork(map.getNetworkID());
    Map<String, CyEdge> edges = TestUtils.getEdges(network);
    assertEquals(12, edges.size());
    assertTrue(edges.containsKey("BOTTOM8_PLUS100 (Geneset_Overlap_set2) MIDDLE8_PLUS100"));
    assertTrue(edges.containsKey("BOTTOM8_PLUS100 (Geneset_Overlap_set2) TOP8_PLUS100"));
    assertTrue(edges.containsKey("MIDDLE8_PLUS100 (Geneset_Overlap_set2) TOP8_PLUS100"));
    assertTrue(edges.containsKey("MIDDLE8_PLUS100 (Geneset_Overlap_set2) TOP1_PLUS100"));
    assertTrue(edges.containsKey("TOP8_PLUS100 (Geneset_Overlap_set2) TOP1_PLUS100"));
    assertTrue(edges.containsKey("TOP8_PLUS100 (Geneset_Overlap_set1) TOP1_PLUS100"));
    assertTrue(edges.containsKey("BOTTOM8_PLUS100 (Geneset_Overlap_set2) TOP1_PLUS100"));
    assertTrue(edges.containsKey("BOTTOM8_PLUS100 (Geneset_Overlap_set1) TOP1_PLUS100"));
    assertTrue(edges.containsKey("BOTTOM8_PLUS100 (Geneset_Overlap_set1) MIDDLE8_PLUS100"));
    assertTrue(edges.containsKey("MIDDLE8_PLUS100 (Geneset_Overlap_set1) TOP1_PLUS100"));
    assertTrue(edges.containsKey("BOTTOM8_PLUS100 (Geneset_Overlap_set1) TOP8_PLUS100"));
    assertTrue(edges.containsKey("MIDDLE8_PLUS100 (Geneset_Overlap_set1) TOP8_PLUS100"));
}
Also used : CyNetwork(org.cytoscape.model.CyNetwork) EnrichmentMap(org.baderlab.csplugins.enrichmentmap.model.EnrichmentMap) CyEdge(org.cytoscape.model.CyEdge) BaseIntegrationTest(org.baderlab.csplugins.enrichmentmap.integration.BaseIntegrationTest) Test(org.junit.Test) SessionFile(org.baderlab.csplugins.enrichmentmap.integration.SessionFile)

Example 40 with CyNetwork

use of org.cytoscape.model.CyNetwork in project cytoscape-api by cytoscape.

the class SetSelectedNetworksEventTest method testGoodGetSelectedNetworksEvent.

@Test
public void testGoodGetSelectedNetworksEvent() {
    final List<CyNetwork> networks = new ArrayList<CyNetwork>();
    final SetSelectedNetworksEvent e = new SetSelectedNetworksEvent(source, networks);
    assertNotNull(e.getNetworks());
    assertEquals(networks, e.getNetworks());
}
Also used : SetSelectedNetworksEvent(org.cytoscape.application.events.SetSelectedNetworksEvent) ArrayList(java.util.ArrayList) CyNetwork(org.cytoscape.model.CyNetwork) Test(org.junit.Test)

Aggregations

CyNetwork (org.cytoscape.model.CyNetwork)48 Test (org.junit.Test)20 CyNode (org.cytoscape.model.CyNode)16 CyNetworkView (org.cytoscape.view.model.CyNetworkView)13 EnrichmentMap (org.baderlab.csplugins.enrichmentmap.model.EnrichmentMap)11 CyEdge (org.cytoscape.model.CyEdge)9 ArrayList (java.util.ArrayList)8 List (java.util.List)6 CyNetworkManager (org.cytoscape.model.CyNetworkManager)6 CyRow (org.cytoscape.model.CyRow)6 BaseIntegrationTest (org.baderlab.csplugins.enrichmentmap.integration.BaseIntegrationTest)5 DataSetFiles (org.baderlab.csplugins.enrichmentmap.model.DataSetFiles)5 EMDataSet (org.baderlab.csplugins.enrichmentmap.model.EMDataSet)5 CyTable (org.cytoscape.model.CyTable)5 Map (java.util.Map)4 Set (java.util.Set)4 EMCreationParameters (org.baderlab.csplugins.enrichmentmap.model.EMCreationParameters)4 View (org.cytoscape.view.model.View)4 Inject (com.google.inject.Inject)3 Color (java.awt.Color)3