Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/upstream/master' into Cluster-r…
Browse files Browse the repository at this point in the history
…ows-in-HeatMap
  • Loading branch information
sumanthreddy542 committed Jul 27, 2021
2 parents 0a43d32 + 68fd86d commit 164af7d
Show file tree
Hide file tree
Showing 7 changed files with 287 additions and 4 deletions.
96 changes: 95 additions & 1 deletion src/edu/iastate/metnet/metaomgraph/MetaOmGraph.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
import java.awt.Dimension;
import java.awt.Event;
import java.awt.EventQueue;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.GridLayout;
import java.awt.HeadlessException;
import java.awt.Image;
import java.awt.Rectangle;
Expand All @@ -26,14 +28,17 @@
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FilenameFilter;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.lang.reflect.InvocationTargetException;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.text.SimpleDateFormat;
import java.time.Instant;
import java.util.ArrayList;
Expand All @@ -47,7 +52,9 @@
import java.util.Vector;
import javax.imageio.ImageIO;
import javax.swing.AbstractAction;
import javax.swing.AbstractButton;
import javax.swing.Box;
import javax.swing.ButtonGroup;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JCheckBoxMenuItem;
Expand All @@ -62,6 +69,7 @@
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JTable;
import javax.swing.JToggleButton;
import javax.swing.KeyStroke;
Expand Down Expand Up @@ -108,6 +116,7 @@
import edu.iastate.metnet.metaomgraph.ui.AboutFrame;
import edu.iastate.metnet.metaomgraph.ui.AboutFrame4;
import edu.iastate.metnet.metaomgraph.ui.ClickableLabel;
import edu.iastate.metnet.metaomgraph.ui.CustomFileSaveDialog;
import edu.iastate.metnet.metaomgraph.ui.ListMergePanel;
import edu.iastate.metnet.metaomgraph.ui.MetaOmTablePanel;
import edu.iastate.metnet.metaomgraph.ui.MetadataFilter;
Expand Down Expand Up @@ -167,7 +176,12 @@ public class MetaOmGraph implements ActionListener {
private static StatisticalResultsFrame DCResultsFrame;
private static JButton plbbutton;
private static JPanel playbackForMac;


private enum DownloadSampleProject{
Metabolomics,
MicroArray,
HumanCancerRNASeq
}

public static StatisticalResultsFrame getDEAResultsFrame() {
return DEAResultsFrame;
Expand Down Expand Up @@ -511,7 +525,13 @@ public static String getVersion() {
public static final String NEW_PROJECT_ARRAYEXPRESS_COMMAND = "New project from ArrayExpress";

public static final String OPEN_COMMAND = "Open a project";

public static final String DOWNLOAD_METABOLOMICS_PROJ_COMMAND = "Sample MOG project- A. thaliana Metabolomics (0.8 MB) Try me";

public static final String DOWNLOAD_MICROARRAY_PROJ_COMMAND = "Sample MOG project- A. thaliana Microarray (29.5 MB) Try me";

public static final String DOWNLOAD_CANCER_RNASEQ_PROJ_COMMAND = "Sample MOG project- Human Cancer RNA-Seq (247 MB) Try me";

public static final String SAVE_COMMAND = "Save the current project";

public static final String SAVE_AS_COMMAND = "Save as";
Expand Down Expand Up @@ -2628,6 +2648,18 @@ public void actionPerformed(ActionEvent e) {
openAnotherProject();

}

if(DOWNLOAD_METABOLOMICS_PROJ_COMMAND.equals(e.getActionCommand())) {
downloadAndOpenProject(DownloadSampleProject.Metabolomics);
}

if(DOWNLOAD_MICROARRAY_PROJ_COMMAND.equals(e.getActionCommand())) {
downloadAndOpenProject(DownloadSampleProject.MicroArray);
}

if(DOWNLOAD_CANCER_RNASEQ_PROJ_COMMAND.equals(e.getActionCommand())) {
downloadAndOpenProject(DownloadSampleProject.HumanCancerRNASeq);
}

// Save the active project to a new file
if (SAVE_AS_COMMAND.equals(e.getActionCommand())) {
Expand Down Expand Up @@ -4066,6 +4098,68 @@ public static void openAnotherProject() {

return;
}


private static String downloadProjSelectionPanel(File projDirectory, DownloadSampleProject project) {
String destPath = "";
URL projURL = null;
if(project == DownloadSampleProject.Metabolomics) {
try {
projURL = new URL("https://metnetweb.gdcb.iastate.edu/MetaOmGraph/RNASeq/MOG_Athaliana_metabolomics.zip");
} catch (MalformedURLException e) {
e.printStackTrace();
}
destPath = projDirectory.getAbsolutePath();
destPath += File.separator + "MOG_Athaliana_Metabolomics";
if(Utils.downloadFile(projURL, destPath + ".zip")) {
Utils.unZipFile(destPath + ".zip", destPath);
}
} else if (project == DownloadSampleProject.MicroArray) {
try {
projURL = new URL("https://metnetweb.gdcb.iastate.edu/MetaOmGraph/RNASeq/MOG_AthalianaMAProj.zip");
} catch (MalformedURLException e) {
e.printStackTrace();
}
destPath = projDirectory.getAbsolutePath();
destPath += File.separator + "MOG_Athaliana_MicroArray";
if(Utils.downloadFile(projURL, destPath + ".zip")) {
Utils.unZipFile(destPath + ".zip", destPath);
}
} else {
try {
projURL = new URL("https://metnetweb.gdcb.iastate.edu/MetaOmGraph/RNASeq/MOG_HumanCancerRNASeqProject.zip");
} catch (MalformedURLException e) {
e.printStackTrace();
}
destPath = projDirectory.getAbsolutePath();
destPath += File.separator + "MOG_HumanCancerRNASeq";
if(Utils.downloadFile(projURL, destPath + ".zip")) {
Utils.unZipFile(destPath + ".zip", destPath);
}
}
return destPath;
}

private static void downloadAndOpenProject(DownloadSampleProject project) {
File currDir = Utils.getLastDir();
File projSelDir = CustomFileSaveDialog.showDirectoryDialog(currDir);
if(projSelDir == null) {
return;
}
String projDir = downloadProjSelectionPanel(projSelDir, project);
if(projDir.isEmpty()) {
return;
}
File projDirFile = new File(projDir);
File[] mogFiles = projDirFile.listFiles(new FilenameFilter() {
public boolean accept(File dir, String filename)
{ return filename.endsWith(".mog"); }
} );
if(mogFiles.length == 0)
return;
Utils.setLastDir(projDirFile);
new OpenProjectWorker(mogFiles[0]).start();
}

public static void openRecentProject(String name) {
if (activeProject != null)
Expand Down
14 changes: 14 additions & 0 deletions src/edu/iastate/metnet/metaomgraph/chart/ScatterPlotChart.java
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ public class ScatterPlotChart extends TaskbarInternalFrame implements ChartMouse
private JMenuItem singleSelectionMenu;
private JMenuItem multiSelectionMenu;
private JMenuItem zoomMenu;
private JMenuItem clearSelectionMenu;

// bottom toolbar
private JButton btnNewButton_1;
Expand Down Expand Up @@ -341,6 +342,11 @@ public void stateChanged(ChangeEvent e) {
zoomMenu.setIcon(theme.getDefaultZoom());
zoomMenu.setActionCommand("zoom tool");
zoomMenu.addActionListener(this);

clearSelectionMenu = new JMenuItem("Clear selection tool");
clearSelectionMenu.setIcon(theme.getDefaultZoom());
clearSelectionMenu.setActionCommand("clear selection");
clearSelectionMenu.addActionListener(this);

selectionPopUpMenu.add(singleSelectionMenu);
selectionPopUpMenu.add(multiSelectionMenu);
Expand Down Expand Up @@ -822,6 +828,7 @@ public void actionPerformed(ActionEvent e) {
setSelectionToolActive();
singleSelection = false;
multiSelection = true;
selectedRectangles.clear();
}

if("zoom tool".equals(e.getActionCommand())) {
Expand All @@ -831,6 +838,13 @@ public void actionPerformed(ActionEvent e) {
multiSelection = false;
}

if("clear selection".equals(e.getActionCommand())) {
singleSelection = false;
multiSelection = false;
selectedRectangles.clear();
selectedPointsDisplayTableObj.clearMetaDataCols();
}

if("create list".equals(e.getActionCommand())) {
List<String> selectedRows = selectedPointsDisplayTableObj.getMetaDataColsInTable();
createSampleListFrame("Selected samples list", new ArrayList<String>(), selectedRows);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ public class ScatterPlotDimReduction extends TaskbarInternalFrame implements Cha
private JMenuItem singleSelectionMenu;
private JMenuItem multiSelectionMenu;
private JMenuItem zoomMenu;
private JMenuItem clearSelectionMenu;

private JPanel chartButtonsPanel;

Expand Down Expand Up @@ -300,6 +301,11 @@ public void stateChanged(ChangeEvent e) {
zoomMenu.setActionCommand("zoom tool");
zoomMenu.addActionListener(this);

clearSelectionMenu = new JMenuItem("Clear selection tool");
clearSelectionMenu.setIcon(theme.getDefaultZoom());
clearSelectionMenu.setActionCommand("clear selection");
clearSelectionMenu.addActionListener(this);

selectionPopUpMenu.add(singleSelectionMenu);
selectionPopUpMenu.add(multiSelectionMenu);
selectionPopUpMenu.add(zoomMenu);
Expand Down Expand Up @@ -754,6 +760,7 @@ public void actionPerformed(ActionEvent e) {
setSelectionToolActive();
singleSelection = false;
multiSelection = true;
selectedRectangles.clear();
}

if("zoom tool".equals(e.getActionCommand())) {
Expand All @@ -763,6 +770,13 @@ public void actionPerformed(ActionEvent e) {
multiSelection = false;
}

if("clear selection".equals(e.getActionCommand())) {
singleSelection = false;
multiSelection = false;
selectedRectangles.clear();
selectedPointsDisplayTableObj.clearMetaDataCols();
}

if("create list".equals(e.getActionCommand())) {
List<String> selectedRows = selectedPointsDisplayTableObj.getMetaDataColsInTable();
createSampleListFrame("Selected samples list", new ArrayList<String>(), selectedRows);
Expand Down
12 changes: 11 additions & 1 deletion src/edu/iastate/metnet/metaomgraph/ui/ClickableLabel.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package edu.iastate.metnet.metaomgraph.ui;

import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.FocusEvent;
Expand All @@ -19,6 +20,7 @@ public class ClickableLabel extends JLabel implements java.awt.event.MouseListen
private String text;
private String htmlText;
private String pressedText;
private String textColor = "blue";
private javax.swing.border.Border pressedBorder;

public static void main(String[] args) {
Expand Down Expand Up @@ -64,11 +66,19 @@ public ClickableLabel(String text, Icon icon) {
super(text, icon, 2);
init();
}

public ClickableLabel(String text, String textColor, Icon icon) {
super(text, icon, 2);
this.textColor = textColor;
init();
this.text = htmlText;
setText(this.text);
}

private void init() {
text = getText();
htmlText =
("<html><u><font color=#0000ff>" + text + "</font></u></html>");
("<html><u><font color="+ textColor + ">" + text + "</font></u></html>");

pressedText =
("<html><u><font color=#ff0000>" + text + "</font></u></html>");
Expand Down
16 changes: 16 additions & 0 deletions src/edu/iastate/metnet/metaomgraph/ui/CustomFileSaveDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,21 @@ public File showSaveDialog() {
}
return savedFile;
}

/**
* Display file folder selection dialog and returns the directory chosen by the user.
* @return File
*/
public static File showDirectoryDialog(File currDirectory) {
JFileChooser fileChooser = new JFileChooser(currDirectory);
fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
fileChooser.setDialogTitle("Select folder");
int option = fileChooser.showOpenDialog(MetaOmGraph.getMainWindow());
File file = null;
if(option == JFileChooser.APPROVE_OPTION){
file = fileChooser.getSelectedFile();
}
return file;
}

}
23 changes: 21 additions & 2 deletions src/edu/iastate/metnet/metaomgraph/ui/WelcomePanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,29 @@ public WelcomePanel() throws IOException {
openOtherLabel.setActionCommand(MetaOmGraph.OPEN_COMMAND);
openOtherLabel.addActionListener(MetaOmGraph.getInstance());
c2.gridy++;
openPanel.add(new JLabel(" "), c2);
c2.gridy++;
c2.insets = new Insets(0, 10, 10, 0);
openPanel.add(openOtherLabel, c2);
ClickableLabel downloadMetabolomicsProjLabel = new ClickableLabel(
MetaOmGraph.DOWNLOAD_METABOLOMICS_PROJ_COMMAND, "red", openIcon);
downloadMetabolomicsProjLabel.setActionCommand(MetaOmGraph.DOWNLOAD_METABOLOMICS_PROJ_COMMAND);
downloadMetabolomicsProjLabel.addActionListener(MetaOmGraph.getInstance());
c2.gridy++;
c2.insets = new Insets(0, 10, 10, 0);
openPanel.add(downloadMetabolomicsProjLabel, c2);
ClickableLabel downloadMicroarrayProjLabel = new ClickableLabel(
MetaOmGraph.DOWNLOAD_MICROARRAY_PROJ_COMMAND, "red", openIcon);
downloadMicroarrayProjLabel.setActionCommand(MetaOmGraph.DOWNLOAD_MICROARRAY_PROJ_COMMAND);
downloadMicroarrayProjLabel.addActionListener(MetaOmGraph.getInstance());
c2.gridy++;
c2.insets = new Insets(0, 10, 10, 0);
openPanel.add(downloadMicroarrayProjLabel, c2);
ClickableLabel downloadRNASeqProjLabel = new ClickableLabel(
MetaOmGraph.DOWNLOAD_CANCER_RNASEQ_PROJ_COMMAND, "red", openIcon);
downloadRNASeqProjLabel.setActionCommand(MetaOmGraph.DOWNLOAD_CANCER_RNASEQ_PROJ_COMMAND);
downloadRNASeqProjLabel.addActionListener(MetaOmGraph.getInstance());
c2.gridy++;
c2.insets = new Insets(0, 10, 10, 0);
openPanel.add(downloadRNASeqProjLabel, c2);
openPanel.setBorder(BorderFactory.createEtchedBorder());
c.gridy = 0;
c.gridx = 1;
Expand Down
Loading

0 comments on commit 164af7d

Please sign in to comment.