Skip to content

Commit

Permalink
Bug Fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
thepritam authored Oct 18, 2021
1 parent 3fdebb5 commit fa003d4
Show file tree
Hide file tree
Showing 29 changed files with 225 additions and 128 deletions.
14 changes: 7 additions & 7 deletions causalpath-cytoscape-app/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,21 @@
<modelVersion>4.0.0</modelVersion>

<properties>
<bundle.symbolicName>CausalpathCytoscapeApp</bundle.symbolicName>
<bundle.namespace>org.biopax.cytoscape.causalpath_cytoscape_app</bundle.namespace>
<bundle.symbolicName>causalpath</bundle.symbolicName>
<bundle.namespace>org.biopax.cytoscape.causalpath</bundle.namespace>
<cytoscape.api.version>3.7.0</cytoscape.api.version>

<maven-bundle-plugin.version>3.5.0</maven-bundle-plugin.version>
<osgi.api.version>4.2.0</osgi.api.version>
</properties>

<groupId>org.biopax.cytoscape</groupId>
<artifactId>causalpath-cytoscape-app</artifactId>
<artifactId>causalpath</artifactId>
<packaging>bundle</packaging>
<version>0.99.1</version>
<version>1.0.1</version>

<name>causalpath</name>


<name>causalpath-cytoscape-app</name>


<build>
Expand Down Expand Up @@ -235,6 +236,5 @@
<artifactId>jackson-databind</artifactId>
<version>2.9.6</version>
</dependency>

</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,20 @@
import org.biopax.cytoscape.causalpath.Panel.CreateLegendAction;
import org.biopax.cytoscape.causalpath.Panel.ResultPanel;
import org.cytoscape.service.util.CyServiceRegistrar;
import org.cytoscape.work.SynchronousTaskManager;
import org.cytoscape.work.Tunable;
import org.osgi.framework.BundleContext;

import org.cytoscape.service.util.AbstractCyActivator;

import java.util.Properties;



public class CyActivator extends AbstractCyActivator {

public static CyServiceRegistrar cyServiceRegistrar;

SynchronousTaskManager synchronousTaskManager;
public static ResultPanel resultPanel;

public CyActivator() {
Expand All @@ -30,20 +33,24 @@ public CyActivator() {

public void start(BundleContext bc) {
CySwingApplication cytoscapeDesktopService = getService(bc, CySwingApplication.class);

// synchronousTaskManager = getService(bc,SynchronousTaskManager.class);

cyServiceRegistrar = getService(bc, CyServiceRegistrar.class);
resultPanel = new ResultPanel(cyServiceRegistrar);
registerService(bc, resultPanel, CytoPanelComponent.class, new Properties());
LegendPanel controlpanel = new LegendPanel(cyServiceRegistrar, resultPanel);
synchronousTaskManager = getService(bc,SynchronousTaskManager.class);
LegendPanel controlpanel = new LegendPanel(cyServiceRegistrar, resultPanel,synchronousTaskManager);
CreateLegendAction controlPanelAction = new CreateLegendAction(cytoscapeDesktopService, controlpanel, cyServiceRegistrar);
registerService(bc, controlpanel, CytoPanelComponent.class, new Properties());

registerService(bc, controlPanelAction, CyAction.class, new Properties());
// registerService(bc,synchronousTaskManager,SynchronousTaskManager.class,new Properties());

System.out.println("CausalPath started");

System.out.println("CausalPath App started");

}
public SynchronousTaskManager getSynchronousTaskManager(){
return synchronousTaskManager;
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public void writeJSON(File Jsonfile, String jsonpath, LegendPanel legendPanel) t
} else name = jsonpath.substring(jsonpath.lastIndexOf("/") + 1, jsonpath.length());
String modelID = name;

cyNetwork = CyNetworkUtils.readCyNetworkFromFile(cyServiceRegistrar, temp);
//cyNetwork = CyNetworkUtils.readCyNetworkFromFile(cyServiceRegistrar, temp);
cyNetwork.getRow(cyNetwork).set(CyNetwork.NAME, modelID);
JProgressBar jProgressBar = legendPanel.getStatusBar();
jProgressBar.setValue(50);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,25 @@

import java.awt.*;
import java.io.*;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.*;

import javax.swing.*;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.TransformerException;

import org.biopax.cytoscape.causalpath.CyActivator;
import org.biopax.cytoscape.causalpath.ImportandExecutor.utils.CommandExecutor;
import org.biopax.cytoscape.causalpath.Panel.LegendPanel;
import org.cytoscape.io.read.CyNetworkReader;
import org.cytoscape.io.read.CyNetworkReaderManager;
import org.cytoscape.model.CyEdge;
import org.cytoscape.model.CyNetwork;
import org.cytoscape.model.CyTable;
import org.cytoscape.service.util.CyServiceRegistrar;
import org.cytoscape.work.SynchronousTaskManager;
import org.cytoscape.work.TaskIterator;
import org.cytoscape.work.TaskManager;
import org.cytoscape.work.Tunable;
import org.xml.sax.SAXException;
import org.biopax.cytoscape.causalpath.utils.CyNetworkUtils;

Expand All @@ -35,21 +40,26 @@ public class SIFImport {
private String fXmlFile;
private File Siffile;
private LegendPanel legendPanel;
public CyNetwork SIFCyNetwork;

public static String Edge_Info_col_Name = "CausalPath_Edge_Information";
public File temp = File.createTempFile("tempSIF", ".sif");
public HashMap<String, String> edgeinformation = new HashMap<>();

public SIFImport(File siffile, String fXmlFile, CyServiceRegistrar cyServiceRegistrar, LegendPanel legendPanel) throws ParserConfigurationException, SAXException, IOException, TransformerException {
public CyNetwork SIFCyNetwork;

public SynchronousTaskManager synchronousTaskManager;
@Tunable(description = "networkName", context = "nogui")
public String networkName = "";
public SIFImport(File siffile, String fXmlFile, CyServiceRegistrar cyServiceRegistrar, LegendPanel legendPanel, SynchronousTaskManager synchronousTaskManager, boolean flag) throws ParserConfigurationException, SAXException, IOException, TransformerException {
this.synchronousTaskManager =synchronousTaskManager;
this.cyServiceRegistrar = cyServiceRegistrar;
this.fXmlFile = fXmlFile;
this.Siffile = siffile;
this.legendPanel = legendPanel;
writeSIF(siffile, fXmlFile);
writeSIF(siffile, fXmlFile,flag);
}

public void writeSIF(File siffile, String fXmlFile) throws ParserConfigurationException, SAXException, IOException, TransformerException {
public void writeSIF(File siffile, String fXmlFile, boolean flag) throws ParserConfigurationException, SAXException, IOException, TransformerException {


try {
Expand All @@ -67,6 +77,7 @@ public void writeSIF(File siffile, String fXmlFile) throws ParserConfigurationEx
if (splited.length >= 3) {

bw.write(splited[0] + "\t" + splited[1] + "\t" + splited[2]);
//System.out.println(splited[0] + "\t" + splited[1] + "\t" + splited[2]);
bw.write("\n");

if (splited.length == 5) {
Expand All @@ -75,19 +86,27 @@ public void writeSIF(File siffile, String fXmlFile) throws ParserConfigurationEx

}
}

sc.close(); //closes the scanner
bw.close();
String OS = System.getProperty("os.name").toLowerCase();
System.out.println("OS"+OS);
String name = "";
if (OS.indexOf("win") >= 0) {
name = fXmlFile.substring(fXmlFile.lastIndexOf("\\") + 1, fXmlFile.length());
} else name = fXmlFile.substring(fXmlFile.lastIndexOf("/") + 1, fXmlFile.length());
String[] arr;

String modelID = name;

SIFCyNetwork = CyNetworkUtils.readCyNetworkFromFile(cyServiceRegistrar, temp);
SIFCyNetwork.getRow(SIFCyNetwork).set(CyNetwork.NAME, modelID);

networkName = name;

// setting up the tunable here
if(flag)
CommandExecutor.execute("network set current network=" + networkName, cyServiceRegistrar);
SIFCyNetwork = CyNetworkUtils.readCyNetworkFromFile(cyServiceRegistrar, temp,synchronousTaskManager);

SIFCyNetwork.getRow(SIFCyNetwork).set(CyNetwork.NAME, networkName);
CyTable edgetable = SIFCyNetwork.getDefaultEdgeTable();
Collection<CyEdge> edgelist = SIFCyNetwork.getEdgeList();
edgetable.createColumn(Edge_Info_col_Name, String.class, false);
Expand All @@ -113,6 +132,8 @@ public void writeSIF(File siffile, String fXmlFile) throws ParserConfigurationEx
JButton submitbutton = legendPanel.getSubmitbutton();
submitbutton.setEnabled(false);
} catch (NullPointerException ignored) {
ignored.printStackTrace();

JOptionPane optionPane = new JOptionPane("File Open Failed", JOptionPane.ERROR_MESSAGE);
JDialog dialog = optionPane.createDialog("Failure");
dialog.setAlwaysOnTop(true);
Expand All @@ -121,6 +142,7 @@ public void writeSIF(File siffile, String fXmlFile) throws ParserConfigurationEx
legendPanel.getStatusLabel().setForeground(Color.RED);

} catch (FileNotFoundException e) {
e.printStackTrace();
JOptionPane optionPane = new JOptionPane("File Not Found", JOptionPane.ERROR_MESSAGE);
JDialog dialog = optionPane.createDialog("Failure");
dialog.setAlwaysOnTop(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,64 @@
import java.util.ArrayList;
import java.util.List;

import org.apache.poi.ss.formula.functions.T;
import org.biopax.cytoscape.causalpath.CyActivator;
import org.biopax.cytoscape.causalpath.Panel.LegendPanel;
import org.cytoscape.command.CommandExecutorTaskFactory;
import org.cytoscape.service.util.CyServiceRegistrar;
import org.cytoscape.work.SynchronousTaskManager;
import org.cytoscape.work.TaskIterator;
import org.cytoscape.work.*;
import org.cytoscape.work.swing.DialogTaskManager;

public class CommandExecutor {

public static void execute(String command, CyServiceRegistrar cyServiceRegistrar, LegendPanel legendPanel, int flag) {
public static void execute(String command, CyServiceRegistrar cyServiceRegistrar, LegendPanel legendPanel) {
CommandExecutorTaskFactory executor = cyServiceRegistrar.getService(CommandExecutorTaskFactory.class);

List<String> commands = new ArrayList<String>();
commands.add(command);

TaskIterator task = executor.createTaskIterator(commands, null);
SynchronousTaskManager manager = cyServiceRegistrar.getService(SynchronousTaskManager.class);
manager.execute(task);

legendPanel.getStatusBar().setValue(100);
legendPanel.getStatusLabel().setText("Success!");
manager.execute(task);

legendPanel.getSubmitbutton().setEnabled(false);
legendPanel.getFormatfileuploadbutton().setEnabled(false);
try{
Thread.sleep(3000);

} catch (InterruptedException e) {
System.out.println("Sleep for User's Understanding");
e.printStackTrace();
}

legendPanel.getStatusBar().setValue(0);


}
public static void execute(String command, CyServiceRegistrar cyServiceRegistrar) {
CommandExecutorTaskFactory executor = cyServiceRegistrar.getService(CommandExecutorTaskFactory.class);

List<String> commands = new ArrayList<String>();
commands.add(command);

TaskIterator task = executor.createTaskIterator(commands, null);
SynchronousTaskManager manager = cyServiceRegistrar.getService(SynchronousTaskManager.class);

manager.execute(task);

}

public static void execute(TaskIterator commandTask, CyServiceRegistrar cyServiceRegistrar) {
CyActivator cyActivator = cyServiceRegistrar.getService(CyActivator.class);
cyActivator.getSynchronousTaskManager().execute(commandTask);

public static void execute(TaskIterator commandTask, CyServiceRegistrar cyServiceRegistrar, int flag) {
cyServiceRegistrar.getService(SynchronousTaskManager.class).execute(commandTask);
}
public static void execute(TaskIterator commandTask, CyServiceRegistrar cyServiceRegistrar,SynchronousTaskManager synchronousTaskManager) {

synchronousTaskManager.execute(commandTask);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.cytoscape.application.swing.CytoPanelName;
import org.cytoscape.application.swing.CytoPanelState;
import org.cytoscape.service.util.CyServiceRegistrar;
import org.cytoscape.work.Tunable;


public class CreateLegendAction extends AbstractCyAction {
Expand All @@ -21,7 +22,7 @@ public class CreateLegendAction extends AbstractCyAction {
public CreateLegendAction(CySwingApplication desktopApp,
LegendPanel myCytoPanel, CyServiceRegistrar cyServiceRegistrar) {

super("CausalPath");
super("CausalPath ");
setPreferredMenu("Apps");

this.desktopApp = desktopApp;
Expand Down
Loading

0 comments on commit fa003d4

Please sign in to comment.