Skip to content

Commit

Permalink
validation + Control refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Genet Abay committed Mar 3, 2018
1 parent d5fcd22 commit c9f102e
Show file tree
Hide file tree
Showing 16 changed files with 713 additions and 373 deletions.
212 changes: 129 additions & 83 deletions src/main/java/com/compomics/coss/Controller/MainFrameController.java

Large diffs are not rendered by default.

20 changes: 11 additions & 9 deletions src/main/java/com/compomics/coss/Controller/Validation.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import org.apache.avro.generic.GenericData;

/**
*
Expand All @@ -21,27 +22,28 @@ public Validation() {

}

public void compareNmerge(List<ArrayList<ComparisonResult>> targetResult, List<ArrayList<ComparisonResult>> decoyResult) {
public List<ArrayList<ComparisonResult>> compareNmerge(List<ArrayList<ComparisonResult>> targetResult, List<ArrayList<ComparisonResult>> decoyResult) {

List<ArrayList<ComparisonResult>> validatedResult = null;
List<ArrayList<ComparisonResult>> validatedResult = new ArrayList<>();
//calculate FDR=Ndecoy/Ntargethits

int c = 0;
int decoySSM = 0;

for (ArrayList<ComparisonResult> rTarget : targetResult) {
ArrayList<ComparisonResult> rDecoy = decoyResult.get(c++);
if (rTarget.get(0).compareTo(rDecoy.get(0)) < 0) {

rTarget.clear();
rTarget.addAll(rDecoy);
decoySSM++;

validatedResult.add(rDecoy);

}
else{
validatedResult.add(rTarget);
}


}
Collections.sort(targetResult, (ArrayList<ComparisonResult> o1, ArrayList<ComparisonResult> o2) -> Double.valueOf(o1.get(0).getScore()).compareTo(o2.get(0).getScore()));
Collections.sort(validatedResult, (ArrayList<ComparisonResult> o1, ArrayList<ComparisonResult> o2) -> Double.valueOf(o1.get(0).getScore()).compareTo(o2.get(0).getScore()));

return validatedResult;
}

public int validate(List<ArrayList<ComparisonResult>> result, double threshold) {
Expand Down
14 changes: 7 additions & 7 deletions src/main/java/com/compomics/coss/Model/ConfigData.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import com.compomics.ms2io.IndexKey;
import java.io.File;
import com.compomics.ms2io.SpectrumReader;
import com.compomics.ms2io.SpectraReader;
import java.util.List;
/**
*this class holds the configuration data for spectral comparison
Expand All @@ -15,8 +15,8 @@ public class ConfigData {
File specLibraryFile;
List<IndexKey> expIndex;
List<IndexKey> libIndex;
SpectrumReader rdExperimental;
SpectrumReader rdLibrary;
SpectraReader rdExperimental;
SpectraReader rdLibrary;

String outputPath;
int ScoringFun;//index
Expand Down Expand Up @@ -50,19 +50,19 @@ public List<IndexKey> getExpSpectraIndex() {
return this.expIndex;
}

public SpectrumReader getExpSpecReader(){
public SpectraReader getExpSpecReader(){
return this.rdExperimental;
}

public void setExpSpecReader(SpectrumReader rd){
public void setExpSpecReader(SpectraReader rd){
this.rdExperimental=rd;
}

public void setLibSpecReader(SpectrumReader rd){
public void setLibSpecReader(SpectraReader rd){
this.rdLibrary=rd;
}

public SpectrumReader getLibSpecReader(){
public SpectraReader getLibSpecReader(){
return this.rdLibrary;
}

Expand Down
80 changes: 16 additions & 64 deletions src/main/java/com/compomics/coss/View/MainGUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JProgressBar;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.WindowConstants;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;


/**
Expand All @@ -45,6 +47,7 @@ public class MainGUI extends JFrame {
* constructor of the class
* @param settings setting panel to be added on the main GUI
* @param result result panel to be added on the main GUI
* @param targetView
* @param controler controller class responsible for coordinating the process
*/
public MainGUI(SettingPanel settings, ResultPanel result, TargetDB_View targetView, MainFrameController controler) {
Expand Down Expand Up @@ -120,35 +123,12 @@ private void initComponents() {
pnlLog = new JPanel(new FlowLayout(FlowLayout.LEFT));
pnlLog.setLayout(new BorderLayout());

btnStartSearch=new JButton("Start Searching");
btnCancel=new JButton("Cancel");
prgProgress=new JProgressBar(0, 100);




JPanel innerControlPanel=new JPanel(new FlowLayout());
innerControlPanel.add(btnStartSearch);
innerControlPanel.add(btnCancel);

JPanel pnlValidationControl = new JPanel(new FlowLayout());


pnlCommands.add(innerControlPanel, BorderLayout.NORTH);
pnlCommands.add(prgProgress, BorderLayout.SOUTH);


txtlog = new JTextArea();
scrLogArea=new JScrollPane();
txtlog.setColumns(20);
txtlog.setRows(5);
scrLogArea.setViewportView(txtlog);







//this.setSize(dmnsn);
this.setExtendedState(JFrame.MAXIMIZED_BOTH);
tab = new JTabbedPane(JTabbedPane.TOP, JTabbedPane.WRAP_TAB_LAYOUT);
Expand All @@ -170,17 +150,7 @@ private void initComponents() {
pnlLower.add(pnlCommands);
pnlLower.add(pnlLog);



// //base panel it is the base panel holding the upper and the lower split panel
// splBase = new JSplitPane(JSplitPane.VERTICAL_SPLIT, pnlUpper, pnlLower);
// splBase.setResizeWeight(0.9);
// splBase.setDividerLocation(0.9);
// splBase.setEnabled(false);
// //splBase.setOneTouchExpandable(true);
//
//


//SettingPanel settings = new SettingPanel();
pnlsetting.add(settings);

Expand Down Expand Up @@ -215,30 +185,8 @@ public void windowClosing(final WindowEvent we
}
}
);

//start search button listenr
btnStartSearch.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {


control.startSearch();

}
}
);


//cancel button listener
btnCancel.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ev) {

control.stopSearch();

}
}
);


save.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ev) {
try {
Expand Down Expand Up @@ -277,10 +225,16 @@ public void actionPerformed(ActionEvent e) {
tab.addChangeListener((ChangeEvent e) -> {
if (e.getSource() instanceof JTabbedPane) {
JTabbedPane pane = (JTabbedPane) e.getSource();
changeControlView(pane.getSelectedIndex());
int ind = pane.getSelectedIndex();
control.cmdViewDisplay(ind);

}
});





setJMenuBar(menuBar);
BorderLayout layout=new BorderLayout();
getContentPane().setLayout(layout);
Expand All @@ -307,15 +261,13 @@ public void actionPerformed(ActionEvent e) {
public JPanel pnlsetting;
public JPanel pnlresult;

private JPanel pnlCommands;
public JPanel pnlCommands;
private JPanel pnlLog;


public JButton btnStartSearch;
private JButton btnCancel;
public JTextArea txtlog;
private JScrollPane scrLogArea;
public JProgressBar prgProgress;


private void changeControlView(int selectedIndex) {

Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/compomics/coss/View/RasterPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.compomics.ms2io.IndexKey;
import com.compomics.ms2io.Spectrum;
import com.compomics.ms2io.SpectrumReader;
import com.compomics.ms2io.SpectraReader;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
Expand All @@ -29,7 +29,7 @@
public class RasterPanel extends JPanel implements MouseListener, MouseMotionListener {

List<IndexKey> iKey;
SpectrumReader rd;
SpectraReader rd;
double scale = 1;
double retnTime = 0;
BufferedImage temp;
Expand All @@ -49,7 +49,7 @@ public class RasterPanel extends JPanel implements MouseListener, MouseMotionLis
* @param key index key to read the spectrum
* @param rd spectrum reader object
*/
public RasterPanel(List<IndexKey> key, SpectrumReader rd) {
public RasterPanel(List<IndexKey> key, SpectraReader rd) {
this.iKey = key;
this.rd=rd;

Expand Down
76 changes: 76 additions & 0 deletions src/main/java/com/compomics/coss/View/SearchCommandPnl.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.compomics.coss.View;

import com.compomics.coss.Controller.MainConsolControler;
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JProgressBar;
import com.compomics.coss.Controller.MainFrameController;

/**
*
* @author Genet
*/
public class SearchCommandPnl extends JPanel{

MainFrameController control;
public SearchCommandPnl(MainFrameController control) {
this.control=control;
init();
}

private void init(){


btnStartSearch=new JButton("Start Searching");
JButton btnCancel=new JButton("Cancel");
prgProgress=new JProgressBar(0, 100);

JPanel innerControlPanel=new JPanel(new FlowLayout());
innerControlPanel.add(btnStartSearch);
innerControlPanel.add(btnCancel);

//start search button listenr
btnStartSearch.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {


control.startSearch();

}
}
);


//cancel button listener
btnCancel.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ev) {

control.stopSearch();

}
}
);


setLayout(new BorderLayout());
add(innerControlPanel, BorderLayout.NORTH);
add(prgProgress, BorderLayout.SOUTH);


}

public JButton btnStartSearch;
public JProgressBar prgProgress;


}
2 changes: 1 addition & 1 deletion src/main/java/com/compomics/coss/View/SettingPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ public void valueChanged(TreeSelectionEvent e) {
);

//End of Matching panel layout
//this panel: the layout
//base input panel layout: panel to hold all the three different panels together
javax.swing.GroupLayout pnlMainLayout = new javax.swing.GroupLayout(pnlInputs);
pnlInputs.setLayout(pnlMainLayout);

Expand Down
Loading

0 comments on commit c9f102e

Please sign in to comment.