search2go.UIFrame.java Source code

Java tutorial

Introduction

Here is the source code for search2go.UIFrame.java

Source

/*
 * 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 search2go;

import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseWheelEvent;
import java.awt.event.MouseWheelListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.text.NumberFormat;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.imageio.ImageIO;
import javax.swing.DefaultListModel;
import javax.swing.JComboBox;
import javax.swing.JFileChooser;
import javax.swing.JFormattedTextField;
import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.ListSelectionModel;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.table.DefaultTableModel;
import javax.swing.text.DefaultCaret;
import javax.swing.text.DefaultFormatterFactory;
import javax.swing.text.NumberFormatter;
import org.graphstream.graph.Graph;
import org.graphstream.graph.implementations.SingleGraph;
import org.graphstream.ui.swingViewer.ViewPanel;
import org.graphstream.ui.view.Viewer;
import org.graphstream.ui.view.ViewerListener;
import org.graphstream.ui.view.ViewerPipe;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartMouseEvent;
import org.jfree.chart.ChartMouseListener;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.labels.CategoryItemLabelGenerator;
import org.jfree.chart.labels.ItemLabelAnchor;
import org.jfree.chart.labels.ItemLabelPosition;
import org.jfree.chart.labels.StandardCategoryItemLabelGenerator;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.renderer.category.BarRenderer;
import org.jfree.data.category.DefaultCategoryDataset;
import org.jfree.ui.TextAnchor;

/**
 *
 * @author Nicholas Berryman
 */
public final class UIFrame extends javax.swing.JFrame {
    private Workspace currentProj;
    private final JFileChooser fc = new JFileChooser();
    private final JFileChooser webSaveDialogue = new JFileChooser();
    private GTermSet gTerms = new GTermSet();
    private final String[] targetDBs = { "CC", "MF", "BP" };
    private DefaultTableModel GTermTableModel;
    private int identCount = 0;
    private int maxIdentCount = 0;
    private ProcessSequence gTermInfoGetter;
    private final TopLevelGTermSet CCs = new TopLevelGTermSet("GO:0005575", "CC");
    private final TopLevelGTermSet MFs = new TopLevelGTermSet("GO:0003674", "MF");
    private final TopLevelGTermSet BPs = new TopLevelGTermSet("GO:0008150", "BP");
    private final TopLevelGTermSet[] topLevels;
    private OS os = new OS();
    private ProcessSequence blastSequence;
    private ProcessSequence mapSequence;
    private ArrayList<ProcessSequence> identSequences;
    private final StopButton blastButton;
    private final StopButton mapButton;
    private final StopButton identButton;
    private final StopButton fullButton;
    private Viewer graphViewer;
    private final JPopupMenu webSaveMenu;

    public UIFrame() throws IOException, ParseException {
        topLevels = new TopLevelGTermSet[] { CCs, MFs, BPs };

        this.addWindowListener(new WindowAdapter() {
            @Override
            public void windowClosing(WindowEvent et) {
                try {
                    if (os.isWindows()) {
                        Runtime.getRuntime().exec("cmd /C TaskKill -IM blastx.exe -F");
                        Runtime.getRuntime().exec("cmd /C TaskKill -IM blastn.exe -F");
                        Runtime.getRuntime().exec("cmd /C TaskKill -IM blastp.exe -F");
                        Runtime.getRuntime().exec("cmd /C TaskKill -IM python.exe -F");
                    } else {
                        Runtime.getRuntime().exec("killAll -KILL blastx");
                        Runtime.getRuntime().exec("killAll -KILL blastn");
                        Runtime.getRuntime().exec("killAll -KILL blastp");
                        Runtime.getRuntime().exec("killAll -KILL python");
                    }
                } catch (IOException ex) {
                    System.out.println("Error closing child processes");
                }
            }
        });

        initComponents();

        txtBlastOutput.getDocument().addDocumentListener(new BufferEnforcer(txtBlastOutput));
        txtFullOutput.getDocument().addDocumentListener(new BufferEnforcer(txtFullOutput));
        txtMapOutput.getDocument().addDocumentListener(new BufferEnforcer(txtMapOutput));

        ((DefaultCaret) txtBlastOutput.getCaret()).setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
        ((DefaultCaret) txtMapOutput.getCaret()).setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
        ((DefaultCaret) txtFullOutput.getCaret()).setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);

        webSaveMenu = new JPopupMenu();
        JMenuItem saveWeb = new JMenuItem();
        saveWeb.setText("Save");
        saveWeb.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                webSaveDialogue.showSaveDialog(pnlChartHolder);
                File saveFile = webSaveDialogue.getSelectedFile();
                if (!saveFile.getPath().contains(".png"))
                    saveFile = new File(saveFile.getPath() + ".png");
                try {
                    BufferedImage webChartImage = new BufferedImage(pnlChartHolder.getWidth(),
                            pnlChartHolder.getHeight(), BufferedImage.TYPE_INT_RGB);
                    pnlChartHolder.print(webChartImage.getGraphics());
                    ImageIO.write(webChartImage, "png", saveFile);
                } catch (Exception ex) {
                    javax.swing.JOptionPane.showMessageDialog(pnlChartHolder,
                            "Error saving chart. Please try again.");
                }
            }

        });
        webSaveMenu.add(saveWeb);
        pnlChartHolder.add(webSaveMenu);
        pnlChartHolder.setLayout(new java.awt.BorderLayout());

        try {
            currentProj = Workspace.open(new Path("Search2GO_Data"));
            chkDoCCs.setState(currentProj.willDoCC());
            chkDoBPs.setState(currentProj.willDoBP());
            chkDoMFs.setState(currentProj.willDoMF());
            txtQuery.setText(currentProj.getQueryPath());
            txtQueryFP.setText(currentProj.getQueryPath());
            txtDatabase.setText(currentProj.getPathToDB());
            txtDatabaseFP.setText(currentProj.getPathToDB());
            txtThreads.setValue(currentProj.getThreadNo());
            txtThreadsFP.setValue(currentProj.getThreadNo());
            cbxNXP.setSelectedIndex(currentProj.getBlastTypeIndex());
            cbxNXPFP.setSelectedIndex(currentProj.getBlastTypeIndex());
            cbxDBID.setSelectedIndex(currentProj.getSelectedDBIndex());
            cbxDBIDFP.setSelectedIndex(currentProj.getSelectedDBIndex());
            txtBitScore.setValue(currentProj.getBitScoreThreshold());
            txtBitScoreFP.setValue(currentProj.getBitScoreThreshold());
            txtBlastE.setValue(currentProj.getEThreshold());
            txtMapE.setValue(currentProj.getEThreshold());
            txtEFP.setValue(currentProj.getEThreshold());
        } catch (FileNotFoundException e) {
            currentProj = Workspace.create(new Path("Search2GO_Data"));
            chkDoCCs.setState(currentProj.willDoCC());
            chkDoBPs.setState(currentProj.willDoBP());
            chkDoMFs.setState(currentProj.willDoMF());
        }
        this.setTitle("Search2GO " + currentProj.getPath().toString());

        GTermTableModel = new DefaultTableModel();
        GTermTableModel.setColumnCount(2);
        GTermTableModel.setColumnIdentifiers(new String[] { "GO ID", "Frequency" });

        ListSelectionModel GTermSelector = tblGOFreq.getSelectionModel();
        GTermSelector.addListSelectionListener(new ListSelectionListener() {
            @Override
            public void valueChanged(ListSelectionEvent e) {
                if (!e.getValueIsAdjusting()) {
                    if (tblGOFreq.getSelectedRow() > -1) {
                        DefaultListModel emptyModel = new DefaultListModel();
                        lstQueries.setModel(emptyModel);
                        txtTermInfo.setText("");
                        String selectedID = (String) tblGOFreq.getValueAt(tblGOFreq.getSelectedRow(), 0);
                        JTextArea tempHolderInfo = new JTextArea();
                        JTextArea tempHolderQueries = new JTextArea();

                        if (tblGOFreq.getSelectedRow() != -1) {
                            ResetGTermInfoGetter(tempHolderInfo, tempHolderQueries);
                            gTermInfoGetter.getProcess(0).addParameter("id",
                                    selectedID.substring(0, selectedID.indexOf("[")));
                            gTermInfoGetter.getProcess(1).addParameter("id",
                                    selectedID.substring(0, selectedID.indexOf("[")));
                            GTerm currentGTerm = gTerms.getGTerm(selectedID.substring(0, selectedID.indexOf("[")));
                            gTermInfoGetter.getProcess(1).addParameter("db", currentGTerm.getTopLevel().getCode());
                            gTermInfoGetter.setTail(new ProcessSequenceEnd() {
                                @Override
                                public void run() {
                                    tempHolderInfo.setText("id: " + selectedID + "\n" + tempHolderInfo.getText());
                                    txtTermInfo.setText(tempHolderInfo.getText());

                                    DefaultListModel queryList = new DefaultListModel();
                                    for (String str : tempHolderQueries.getText().split(";")) {
                                        queryList.addElement(str.replaceAll("Query: ", ""));
                                    }

                                    lstQueries.setModel(queryList);
                                    prgIdentification.setIndeterminate(false);
                                }
                            });
                            try {
                                gTermInfoGetter.start();
                                prgIdentification.setIndeterminate(true);
                            } catch (IOException ex) {
                                Logger.getLogger(UIFrame.class.getName()).log(Level.SEVERE, null, ex);
                            }
                        }
                    }
                }
            }
        });

        lstQueries.addListSelectionListener(new ListSelectionListener() {
            @Override
            public void valueChanged(ListSelectionEvent e) {
                if (!e.getValueIsAdjusting() && !e.toString().contains("invalid")
                        && lstQueries.getSelectedValue() != null) {
                    JTextArea tempHolder = new JTextArea();

                    ProcessSequence fetchLocusSequence = new ProcessSequence(new ProcessSequenceEnd() {
                        @Override
                        public void run() {
                            if (txtTermInfo.getText().contains("Score")) {
                                txtTermInfo.setText(
                                        txtTermInfo.getText().substring(0, txtTermInfo.getText().indexOf("Score")));
                            }
                            txtTermInfo.append(tempHolder.getText());
                            prgIdentification.setIndeterminate(false);
                        }
                    });
                    Path fetchLocusPath = new Path("Processes");
                    fetchLocusPath.append("fetchLocus.py");
                    Process fetchLocus = new Process(tempHolder);
                    fetchLocus.setScriptCommand(fetchLocusPath.toEscString());
                    fetchLocus.addParameter("dir", currentProj.getPath().toEscString());
                    fetchLocus.addParameter("q",
                            new ParameterString(lstQueries.getSelectedValue().replace("\n", "")).toString());

                    String selectedID = (String) tblGOFreq.getValueAt(tblGOFreq.getSelectedRow(), 0);
                    GTerm currentGTerm = gTerms.getGTerm(selectedID.substring(0, selectedID.indexOf("[")));
                    fetchLocus.addParameter("db", currentGTerm.getTopLevel().getCode());
                    fetchLocus.addParameter("id", currentGTerm.getID());
                    fetchLocusSequence.addProcess(fetchLocus);

                    try {
                        fetchLocusSequence.start();
                        prgIdentification.setIndeterminate(true);
                    } catch (IOException ex) {
                        Logger.getLogger(UIFrame.class.getName()).log(Level.SEVERE, null, ex);
                    }
                }
            }
        });

        DocumentListener filterListener = new DocumentListener() {
            private void anyUpdate() {
                gTerms.getFilter().setFilterString(txtSearchTerms.getText());
                if (!txtMinFreqFilter.getText().equals(""))
                    gTerms.getFilter().setMinFreq(Integer.parseInt(txtMinFreqFilter.getText()));
                else
                    gTerms.getFilter().setMinFreq(0);
                if (!txtMaxFreqFilter.getText().equals(""))
                    gTerms.getFilter().setMaxFreq(Integer.parseInt(txtMaxFreqFilter.getText()));
                else
                    gTerms.getFilter().setMaxFreq(-1);
                fillIdentTable(gTerms.stringFilter(), false);
            }

            @Override
            public void insertUpdate(DocumentEvent e) {
                anyUpdate();
            }

            @Override
            public void removeUpdate(DocumentEvent e) {
                anyUpdate();
            }

            @Override
            public void changedUpdate(DocumentEvent e) {
                anyUpdate();
            }
        };
        txtSearchTerms.getDocument().addDocumentListener(filterListener);
        txtMinFreqFilter.getDocument().addDocumentListener(filterListener);
        txtMaxFreqFilter.getDocument().addDocumentListener(filterListener);

        NumberFormat numberMask = NumberFormat.getIntegerInstance();
        numberMask.setGroupingUsed(false);
        NumberFormatter numberMasker = new NumberFormatter(numberMask);
        NumberFormatter numberMaskerAndBlank = new NumberFormatter(numberMask) {
            @Override
            public Object stringToValue(String s) throws ParseException {
                if (s == null || s.length() == 0)
                    return null;
                return super.stringToValue(s);
            }
        };
        DefaultFormatterFactory numberMaskFactory = new DefaultFormatterFactory(numberMasker);
        DefaultFormatterFactory numberMaskAndBlankFactory = new DefaultFormatterFactory(numberMaskerAndBlank);

        txtThreads.setFormatterFactory(numberMaskFactory);
        txtThreadsFP.setFormatterFactory(numberMaskFactory);
        txtBitScore.setFormatterFactory(numberMaskAndBlankFactory);
        txtBitScoreFP.setFormatterFactory(numberMaskAndBlankFactory);
        txtMinFreqFilter.setFormatterFactory(numberMaskFactory);
        txtMaxFreqFilter.setFormatterFactory(numberMaskFactory);
        txtBlastE.setFormatterFactory(numberMaskAndBlankFactory);
        txtMapE.setFormatterFactory(numberMaskAndBlankFactory);
        txtEFP.setFormatterFactory(numberMaskAndBlankFactory);

        blastButton = new StopButton(btnBlast);
        mapButton = new StopButton(btnMapIDs);
        identButton = new StopButton(btnGTermIdent);
        fullButton = new StopButton(btnProcessFP);

        if (currentProj.getStage() >= 2)
            identify(false);
    }

    public Workspace getProject() {
        return currentProj;
    }

    private void ResetGTermInfoGetter(JTextArea outBoxInfo, JTextArea outBoxQueries) {
        gTermInfoGetter = new ProcessSequence();

        Path getInfoPath = new Path("Processes");
        getInfoPath.append("getGTermData.py");
        Process getInfo = new Process(outBoxInfo);
        getInfo.setScriptCommand(getInfoPath.toEscString());
        getInfo.addParameter("dir", currentProj.getPath().toEscString());
        gTermInfoGetter.addProcess(getInfo);

        Path getMatchedQueriesPath = new Path("Processes");
        getMatchedQueriesPath.append("getMatchedQueries.py");
        Process getMatchedQueries = new Process(outBoxQueries);
        getMatchedQueries.setScriptCommand(getMatchedQueriesPath.toEscString());
        getMatchedQueries.addParameter("dir", currentProj.getPath().toEscString());
        gTermInfoGetter.addProcess(getMatchedQueries);

        prgIdentification.setIndeterminate(false);
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        tabbedPane = new javax.swing.JTabbedPane();
        pnlFullProcess = new javax.swing.JPanel();
        lblQueriesFP = new javax.swing.JLabel();
        lblDatabaseFP = new javax.swing.JLabel();
        lblThreadsFP = new javax.swing.JLabel();
        lblNXPFP = new javax.swing.JLabel();
        btnProcessFP = new javax.swing.JButton();
        prgFullProcess = new javax.swing.JProgressBar();
        jScrollPane5 = new javax.swing.JScrollPane();
        txtFullOutput = new javax.swing.JTextArea();
        cbxNXPFP = new javax.swing.JComboBox<>();
        txtThreadsFP = new javax.swing.JFormattedTextField();
        txtDatabaseFP = new javax.swing.JTextField();
        txtQueryFP = new javax.swing.JTextField();
        btnChooseQueriesFP = new javax.swing.JButton();
        btnChooseDBFP = new javax.swing.JButton();
        lblDBIDFP = new javax.swing.JLabel();
        cbxDBIDFP = new javax.swing.JComboBox<>();
        lblBitScoreFP = new javax.swing.JLabel();
        txtBitScoreFP = new javax.swing.JFormattedTextField();
        jLabel3 = new javax.swing.JLabel();
        txtEFP = new javax.swing.JFormattedTextField();
        blastPane = new javax.swing.JPanel();
        txtQuery = new javax.swing.JTextField();
        lblQuery = new javax.swing.JLabel();
        lblDatabase = new javax.swing.JLabel();
        txtDatabase = new javax.swing.JTextField();
        lblThreads = new javax.swing.JLabel();
        lblNXP = new javax.swing.JLabel();
        cbxNXP = new javax.swing.JComboBox<>();
        jScrollPane1 = new javax.swing.JScrollPane();
        txtBlastOutput = new javax.swing.JTextArea();
        btnBlast = new javax.swing.JButton();
        btnChooseDB = new javax.swing.JButton();
        prgBlast = new javax.swing.JProgressBar();
        btnChooseQueries = new javax.swing.JButton();
        txtThreads = new javax.swing.JFormattedTextField();
        jLabel1 = new javax.swing.JLabel();
        txtBlastE = new javax.swing.JFormattedTextField();
        mapPane = new javax.swing.JPanel();
        lblBitScore = new javax.swing.JLabel();
        lblDBID = new javax.swing.JLabel();
        cbxDBID = new javax.swing.JComboBox<>();
        btnMapIDs = new javax.swing.JButton();
        jScrollPane2 = new javax.swing.JScrollPane();
        txtMapOutput = new javax.swing.JTextArea();
        prgMapping = new javax.swing.JProgressBar();
        txtBitScore = new javax.swing.JFormattedTextField();
        jLabel2 = new javax.swing.JLabel();
        txtMapE = new javax.swing.JFormattedTextField();
        identPane = new javax.swing.JPanel();
        btnGTermIdent = new javax.swing.JButton();
        jScrollPane6 = new javax.swing.JScrollPane();
        lstQueries = new javax.swing.JList<>();
        jScrollPane4 = new javax.swing.JScrollPane();
        txtTermInfo = new javax.swing.JTextArea();
        txtTermInfo.setFont(new Font("monospaced", Font.PLAIN, 12));
        txtSearchTerms = new javax.swing.JTextField();
        lblMinFreqFilter = new javax.swing.JLabel();
        prgIdentification = new javax.swing.JProgressBar();
        lblMaxFreqFilter = new javax.swing.JLabel();
        jScrollPane8 = new javax.swing.JScrollPane();
        tblGOFreq = new javax.swing.JTable();
        txtMinFreqFilter = new javax.swing.JFormattedTextField();
        txtMaxFreqFilter = new javax.swing.JFormattedTextField();
        analysisPane = new javax.swing.JPanel();
        btnFrequencyGraph = new javax.swing.JButton();
        pnlChartHolder = new javax.swing.JPanel();
        btnWeb = new javax.swing.JToggleButton();
        lblMinHits = new javax.swing.JLabel();
        lblMaxHits = new javax.swing.JLabel();
        txtMinHits = new javax.swing.JFormattedTextField();
        txtMaxHits = new javax.swing.JFormattedTextField();
        prgChart = new javax.swing.JProgressBar();
        txtFilterGOID = new javax.swing.JTextField();
        lblFilterGOFamily = new javax.swing.JLabel();
        jScrollPane7 = new javax.swing.JScrollPane();
        txtGTermInfo = new javax.swing.JTextArea();
        mnuMenu = new javax.swing.JMenuBar();
        mnuFile = new javax.swing.JMenu();
        itmNewProject = new javax.swing.JMenuItem();
        itmLoadProject = new javax.swing.JMenuItem();
        chkDoCCs = new javax.swing.JCheckBoxMenuItem();
        chkDoMFs = new javax.swing.JCheckBoxMenuItem();
        chkDoBPs = new javax.swing.JCheckBoxMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setName("mainFrame"); // NOI18N

        tabbedPane.setPreferredSize(new java.awt.Dimension(670, 500));

        lblQueriesFP.setText("Queries:");

        lblDatabaseFP.setText("Database:");

        lblThreadsFP.setText("Number of Threads:");

        lblNXPFP.setText("BLAST Type:");

        btnProcessFP.setText("Perform Search");
        btnProcessFP.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnProcessFPActionPerformed(evt);
            }
        });

        ((DefaultCaret) txtFullOutput.getCaret()).setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
        txtFullOutput.setEditable(false);
        txtFullOutput.setColumns(20);
        txtFullOutput.setRows(5);
        jScrollPane5.setViewportView(txtFullOutput);

        cbxNXPFP.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "BLASTn", "BLASTp", "BLASTx" }));

        txtThreadsFP.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(
                new javax.swing.text.NumberFormatter(new java.text.DecimalFormat("#0"))));

        btnChooseQueriesFP.setText("...");
        btnChooseQueriesFP.setMargin(new java.awt.Insets(-2, 14, -2, 14));
        btnChooseQueriesFP.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnChooseQueriesFPActionPerformed(evt);
            }
        });

        btnChooseDBFP.setText("...");
        btnChooseDBFP.setMargin(new java.awt.Insets(-2, 14, -2, 14));
        btnChooseDBFP.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnChooseDBFPActionPerformed(evt);
            }
        });

        lblDBIDFP.setText("Database ID Type:");

        cbxDBIDFP.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Affy ID", "Agilent ID",
                "Allergome Code", "ApiDB_CryptoDB ID", "Biocarta Pathway Name", "BioCyc ID", "CCDS ID",
                "Chromosomal Location", "CleanEx ID", "CodeLink ID", "COSMIC ID", "CPDB Protein Interactor",
                "CTD Disease Info", "CTD Disease name", "CYGD ID", "dictyBase ID", "DIP ID", "DisProt ID",
                "DrugBank Drug ID", "DrugBank Drug Info", "DrugBank Drug Name", "EC Number", "EchoBASE ID",
                "EcoGene ID", "Ensembl Biotype", "Ensembl Gene Info", "Ensembl Protein ID", "Ensembl Transcript ID",
                "FlyBase Gene ID", "FlyBase Transcript ID", "GAD Disease Info", "GAD Disease Name",
                "GenBank Nucleotide Accession", "GenBank Nucleotid GI", "GenBank Protein Accession",
                "GenBank Protein GI", "Gene Info", "Gene Symbol", "Gene Symbol and Synonyms", "Gene Synonyms",
                "GeneFarm ID", "GSEA Standard Name", "H-Inv Locus ID", "HAMAP ID", "HGNC ID", "HMDB Metabolite",
                "Homolog - All Ens Gene ID", "Homolog - All Ens Protein ID", "Homolog - All Gene ID",
                "Homolog - Human Ens Gene ID", "Homolog - Human Ens Protein ID", "Homolog - Human Gene ID",
                "Homolog - Mouse Ens Gene ID", "Homolog - Mouse Ens Protein ID", "Homolog - Mouse Gene ID",
                "Homolog - Rat Ens Gene ID", "Homolog - Rat Ens Protein ID", "Homolog - Rat Gene ID",
                "HomoloGene ID", "HPA ID", "HPRD ID", "HPRD Protein Complex", "HPRD Protein Interactor",
                "Illumina ID", "IMGT/GENE-DB ID", "InterPro ID", "IPI ID", "KEGG Disease ID", "KEGG Gene ID",
                "KEGG Pathway ID", "KEGG Pathway Info", "KEGG Pathway Title", "LegioList ID", "Leproma ID",
                "Locus Tag", "MaizeGDB ID", "MGC(ZGC/XGC) ID", "MGC(ZGC/XGC) Image ID", "MGC(ZGC/XGC) Info",
                "MGI ID", "MIM ID", "MIM Info", "miRBase ID", "NCIPID Pathway Name", "NCIPID Protein Complex",
                "NCIPID Protein Interactor", "NCIPID PTM", "Orphanet ID", "PANTHER ID", "Paralog - Ens Gene ID",
                "PBR ID", "PDB ID", "PeroxiBase ID", "Pfam ID", "PharmGKB Drug Info", "PharmGKB Gene ID", "PIR ID",
                "PIRSF ID", "PptaseDB ID", "PRINTS ID", "ProDom ID", "PROSITE ID", "PseudoCAP ID", "PubMed ID",
                "Reactome Pathway Name", "REBASE ID", "RefSeq Genomic Accession", "RefSeq Genomic GI",
                "RefSeq mRNA Accession", "RefSeq ncRNA Accession", "RefSeq Nucleotide GI",
                "RefSeq Protein Accession", "RefSeq Protein GI", "Rfam ID", "RGD ID", "SGD ID", "SMART ID",
                "STRING Protein Interactor", "TAIR ID", "Taxon ID", "TCDB ID", "TIGRFAMs ID", "TubercuList ID",
                "UCSC ID", "UniGene ID", "UniProt Accession", "UniProt Enty Name", "UniProt Info",
                "UniProt Protein Name", "UniSTS ID", "VectorBase Gene ID", "VEGA Gene ID", "VEGA Protein ID",
                "VEGA Transcript ID", "WormBase Gene ID", "WormPep Protein ID", "XenBase Gene ID", "ZFIN ID" }));

        lblBitScoreFP.setText("Hit Bit Score Threshold:");

        txtBitScoreFP.setText("0");

        jLabel3.setText("Hit E-Value Threshold:");

        txtEFP.setText("10");

        javax.swing.GroupLayout pnlFullProcessLayout = new javax.swing.GroupLayout(pnlFullProcess);
        pnlFullProcess.setLayout(pnlFullProcessLayout);
        pnlFullProcessLayout.setHorizontalGroup(pnlFullProcessLayout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addComponent(prgFullProcess, javax.swing.GroupLayout.DEFAULT_SIZE,
                        javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jScrollPane5)
                .addGroup(pnlFullProcessLayout.createSequentialGroup().addGap(20, 20, 20)
                        .addGroup(pnlFullProcessLayout
                                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(btnProcessFP)
                                .addGroup(pnlFullProcessLayout.createSequentialGroup().addGroup(pnlFullProcessLayout
                                        .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addComponent(lblThreadsFP).addComponent(lblDatabaseFP)
                                        .addComponent(lblQueriesFP).addComponent(lblDBIDFP))
                                        .addGroup(pnlFullProcessLayout
                                                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING,
                                                        false)
                                                .addGroup(pnlFullProcessLayout
                                                        .createParallelGroup(
                                                                javax.swing.GroupLayout.Alignment.TRAILING)
                                                        .addGroup(pnlFullProcessLayout.createSequentialGroup()
                                                                .addGap(31, 31, 31)
                                                                .addComponent(txtQueryFP,
                                                                        javax.swing.GroupLayout.PREFERRED_SIZE, 381,
                                                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                                                .addPreferredGap(
                                                                        javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                                .addComponent(btnChooseQueriesFP,
                                                                        javax.swing.GroupLayout.PREFERRED_SIZE, 41,
                                                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                                                        .addGroup(javax.swing.GroupLayout.Alignment.LEADING,
                                                                pnlFullProcessLayout.createSequentialGroup()
                                                                        .addGap(32, 32, 32)
                                                                        .addComponent(txtDatabaseFP,
                                                                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                                                                381,
                                                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                                                        .addPreferredGap(
                                                                                javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                                        .addComponent(btnChooseDBFP,
                                                                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                                                                40,
                                                                                javax.swing.GroupLayout.PREFERRED_SIZE)))
                                                .addGroup(pnlFullProcessLayout.createSequentialGroup()
                                                        .addGap(32, 32, 32)
                                                        .addGroup(pnlFullProcessLayout
                                                                .createParallelGroup(
                                                                        javax.swing.GroupLayout.Alignment.LEADING)
                                                                .addGroup(pnlFullProcessLayout
                                                                        .createSequentialGroup()
                                                                        .addComponent(cbxDBIDFP,
                                                                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                                                                224,
                                                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                                                        .addPreferredGap(
                                                                                javax.swing.LayoutStyle.ComponentPlacement.RELATED,
                                                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                                                Short.MAX_VALUE)
                                                                        .addComponent(lblNXPFP)
                                                                        .addPreferredGap(
                                                                                javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                                        .addComponent(cbxNXPFP,
                                                                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                                                javax.swing.GroupLayout.PREFERRED_SIZE))
                                                                .addComponent(txtThreadsFP,
                                                                        javax.swing.GroupLayout.Alignment.TRAILING,
                                                                        javax.swing.GroupLayout.PREFERRED_SIZE, 430,
                                                                        javax.swing.GroupLayout.PREFERRED_SIZE)))))
                                .addGroup(pnlFullProcessLayout.createSequentialGroup().addGroup(pnlFullProcessLayout
                                        .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                        .addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .addComponent(lblBitScoreFP, javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addGroup(pnlFullProcessLayout
                                                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING,
                                                        false)
                                                .addComponent(txtBitScoreFP, javax.swing.GroupLayout.DEFAULT_SIZE,
                                                        80, Short.MAX_VALUE)
                                                .addComponent(txtEFP))))
                        .addContainerGap(183, Short.MAX_VALUE)));
        pnlFullProcessLayout.setVerticalGroup(
                pnlFullProcessLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(pnlFullProcessLayout.createSequentialGroup().addContainerGap()
                                .addGroup(pnlFullProcessLayout
                                        .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                        .addComponent(txtQueryFP, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addComponent(lblQueriesFP).addComponent(btnChooseQueriesFP))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(pnlFullProcessLayout
                                        .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                        .addComponent(lblDatabaseFP)
                                        .addComponent(txtDatabaseFP, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addComponent(btnChooseDBFP))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(pnlFullProcessLayout
                                        .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                        .addComponent(lblThreadsFP).addComponent(txtThreadsFP,
                                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(pnlFullProcessLayout
                                        .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                        .addComponent(cbxNXPFP, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addComponent(cbxDBIDFP, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addComponent(lblDBIDFP).addComponent(lblNXPFP))
                                .addGap(8, 8, 8)
                                .addGroup(pnlFullProcessLayout
                                        .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                        .addComponent(lblBitScoreFP).addComponent(txtBitScoreFP,
                                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(pnlFullProcessLayout
                                        .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                        .addComponent(jLabel3).addComponent(txtEFP,
                                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(btnProcessFP)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(prgFullProcess, javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(
                                        jScrollPane5, javax.swing.GroupLayout.DEFAULT_SIZE, 194, Short.MAX_VALUE)));

        tabbedPane.addTab("Full Process", pnlFullProcess);

        txtQuery.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtQueryActionPerformed(evt);
            }
        });

        lblQuery.setText("Queries:");

        lblDatabase.setText("Database:");

        lblThreads.setText("Number of Threads:");

        lblNXP.setText("BLAST Type:");

        cbxNXP.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "BLASTn", "BLASTp", "BLASTx" }));

        txtBlastOutput.setEditable(false);
        txtBlastOutput.setColumns(20);
        txtBlastOutput.setRows(5);
        jScrollPane1.setViewportView(txtBlastOutput);

        btnBlast.setText("Perform Search");
        btnBlast.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnBlastActionPerformed(evt);
            }
        });

        btnChooseDB.setText("...");
        btnChooseDB.setMargin(new java.awt.Insets(-2, 14, -2, 14));
        btnChooseDB.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnChooseDBActionPerformed(evt);
            }
        });

        btnChooseQueries.setText("...");
        btnChooseQueries.setMargin(new java.awt.Insets(-2, 14, -2, 14));
        btnChooseQueries.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnChooseQueriesActionPerformed(evt);
            }
        });

        txtThreads.setText("1");
        txtThreads.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtThreadsActionPerformed(evt);
            }
        });

        jLabel1.setText("E-value Threshold:");

        txtBlastE.setText("10");

        javax.swing.GroupLayout blastPaneLayout = new javax.swing.GroupLayout(blastPane);
        blastPane.setLayout(blastPaneLayout);
        blastPaneLayout.setHorizontalGroup(blastPaneLayout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addComponent(prgBlast, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
                        Short.MAX_VALUE)
                .addGroup(blastPaneLayout.createSequentialGroup().addGap(20, 20, 20).addGroup(blastPaneLayout
                        .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(btnBlast)
                        .addGroup(blastPaneLayout.createSequentialGroup().addGroup(blastPaneLayout
                                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(lblThreads).addComponent(lblQuery).addComponent(lblNXP)
                                .addGroup(blastPaneLayout
                                        .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                        .addComponent(jLabel1, javax.swing.GroupLayout.Alignment.LEADING,
                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .addComponent(lblDatabase, javax.swing.GroupLayout.Alignment.LEADING,
                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addGroup(blastPaneLayout
                                        .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                        .addGroup(blastPaneLayout.createSequentialGroup()
                                                .addComponent(txtQuery, javax.swing.GroupLayout.PREFERRED_SIZE, 381,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addComponent(btnChooseQueries,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE, 1, Short.MAX_VALUE))
                                        .addGroup(blastPaneLayout.createSequentialGroup().addGroup(blastPaneLayout
                                                .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING,
                                                        false)
                                                .addComponent(cbxNXP, javax.swing.GroupLayout.Alignment.LEADING, 0,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                                .addComponent(txtBlastE, javax.swing.GroupLayout.Alignment.LEADING)
                                                .addComponent(txtDatabase,
                                                        javax.swing.GroupLayout.Alignment.LEADING,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE, 381, Short.MAX_VALUE)
                                                .addComponent(txtThreads,
                                                        javax.swing.GroupLayout.Alignment.LEADING))
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addComponent(btnChooseDB, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                        40, Short.MAX_VALUE)))))
                        .addContainerGap(200, Short.MAX_VALUE))
                .addComponent(jScrollPane1));
        blastPaneLayout.setVerticalGroup(blastPaneLayout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(blastPaneLayout.createSequentialGroup().addContainerGap().addGroup(blastPaneLayout
                        .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(txtQuery, javax.swing.GroupLayout.PREFERRED_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(lblQuery).addComponent(btnChooseQueries))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(blastPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(lblDatabase)
                                .addComponent(txtDatabase, javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(btnChooseDB))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(blastPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jLabel1)
                                .addComponent(txtBlastE, javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(blastPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(lblThreads).addComponent(txtThreads,
                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(blastPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(lblNXP).addComponent(cbxNXP, javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(btnBlast)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(prgBlast, javax.swing.GroupLayout.PREFERRED_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 228, Short.MAX_VALUE)));

        tabbedPane.addTab("BLAST", blastPane);

        lblBitScore.setText("Hit Bit Score Threshold:");

        lblDBID.setText("Database ID Type:");

        cbxDBID.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Affy ID", "Agilent ID",
                "Allergome Code", "ApiDB_CryptoDB ID", "Biocarta Pathway Name", "BioCyc ID", "CCDS ID",
                "Chromosomal Location", "CleanEx ID", "CodeLink ID", "COSMIC ID", "CPDB Protein Interactor",
                "CTD Disease Info", "CTD Disease name", "CYGD ID", "dictyBase ID", "DIP ID", "DisProt ID",
                "DrugBank Drug ID", "DrugBank Drug Info", "DrugBank Drug Name", "EC Number", "EchoBASE ID",
                "EcoGene ID", "Ensembl Biotype", "Ensembl Gene Info", "Ensembl Protein ID", "Ensembl Transcript ID",
                "FlyBase Gene ID", "FlyBase Transcript ID", "GAD Disease Info", "GAD Disease Name",
                "GenBank Nucleotide Accession", "GenBank Nucleotid GI", "GenBank Protein Accession",
                "GenBank Protein GI", "Gene Info", "Gene Symbol", "Gene Symbol and Synonyms", "Gene Synonyms",
                "GeneFarm ID", "GSEA Standard Name", "H-Inv Locus ID", "HAMAP ID", "HGNC ID", "HMDB Metabolite",
                "Homolog - All Ens Gene ID", "Homolog - All Ens Protein ID", "Homolog - All Gene ID",
                "Homolog - Human Ens Gene ID", "Homolog - Human Ens Protein ID", "Homolog - Human Gene ID",
                "Homolog - Mouse Ens Gene ID", "Homolog - Mouse Ens Protein ID", "Homolog - Mouse Gene ID",
                "Homolog - Rat Ens Gene ID", "Homolog - Rat Ens Protein ID", "Homolog - Rat Gene ID",
                "HomoloGene ID", "HPA ID", "HPRD ID", "HPRD Protein Complex", "HPRD Protein Interactor",
                "Illumina ID", "IMGT/GENE-DB ID", "InterPro ID", "IPI ID", "KEGG Disease ID", "KEGG Gene ID",
                "KEGG Pathway ID", "KEGG Pathway Info", "KEGG Pathway Title", "LegioList ID", "Leproma ID",
                "Locus Tag", "MaizeGDB ID", "MGC(ZGC/XGC) ID", "MGC(ZGC/XGC) Image ID", "MGC(ZGC/XGC) Info",
                "MGI ID", "MIM ID", "MIM Info", "miRBase ID", "NCIPID Pathway Name", "NCIPID Protein Complex",
                "NCIPID Protein Interactor", "NCIPID PTM", "Orphanet ID", "PANTHER ID", "Paralog - Ens Gene ID",
                "PBR ID", "PDB ID", "PeroxiBase ID", "Pfam ID", "PharmGKB Drug Info", "PharmGKB Gene ID", "PIR ID",
                "PIRSF ID", "PptaseDB ID", "PRINTS ID", "ProDom ID", "PROSITE ID", "PseudoCAP ID", "PubMed ID",
                "Reactome Pathway Name", "REBASE ID", "RefSeq Genomic Accession", "RefSeq Genomic GI",
                "RefSeq mRNA Accession", "RefSeq ncRNA Accession", "RefSeq Nucleotide GI",
                "RefSeq Protein Accession", "RefSeq Protein GI", "Rfam ID", "RGD ID", "SGD ID", "SMART ID",
                "STRING Protein Interactor", "TAIR ID", "Taxon ID", "TCDB ID", "TIGRFAMs ID", "TubercuList ID",
                "UCSC ID", "UniGene ID", "UniProt Accession", "UniProt Enty Name", "UniProt Info",
                "UniProt Protein Name", "UniSTS ID", "VectorBase Gene ID", "VEGA Gene ID", "VEGA Protein ID",
                "VEGA Transcript ID", "WormBase Gene ID", "WormPep Protein ID", "XenBase Gene ID", "ZFIN ID" }));

        btnMapIDs.setText("Map IDs");
        btnMapIDs.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnMapIDsActionPerformed(evt);
            }
        });

        txtMapOutput.setEditable(false);
        txtMapOutput.setColumns(20);
        txtMapOutput.setRows(5);
        jScrollPane2.setViewportView(txtMapOutput);
        DefaultCaret caret = (DefaultCaret) txtMapOutput.getCaret();
        caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);

        txtBitScore.setText("0");
        txtBitScore.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtBitScoreActionPerformed(evt);
            }
        });

        jLabel2.setText("Hit E-Value Threshold:");

        txtMapE.setText("10");
        txtMapE.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtMapEActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout mapPaneLayout = new javax.swing.GroupLayout(mapPane);
        mapPane.setLayout(mapPaneLayout);
        mapPaneLayout
                .setHorizontalGroup(mapPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(prgMapping, javax.swing.GroupLayout.DEFAULT_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jScrollPane2)
                        .addGroup(mapPaneLayout.createSequentialGroup().addGap(23, 23, 23)
                                .addGroup(mapPaneLayout
                                        .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                        .addComponent(lblDBID)
                                        .addComponent(lblBitScore, javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .addComponent(btnMapIDs, javax.swing.GroupLayout.PREFERRED_SIZE, 130,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                                .addGap(36, 36, 36)
                                .addGroup(mapPaneLayout
                                        .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addComponent(
                                                cbxDBID, javax.swing.GroupLayout.PREFERRED_SIZE, 224,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addGroup(mapPaneLayout
                                                .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING,
                                                        false)
                                                .addComponent(txtMapE, javax.swing.GroupLayout.Alignment.LEADING,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE, 70, Short.MAX_VALUE)
                                                .addComponent(txtBitScore,
                                                        javax.swing.GroupLayout.Alignment.LEADING)))
                                .addContainerGap(357, Short.MAX_VALUE)));
        mapPaneLayout.setVerticalGroup(mapPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(mapPaneLayout.createSequentialGroup().addContainerGap()
                        .addGroup(mapPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(lblDBID).addComponent(cbxDBID, javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(mapPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(lblBitScore).addComponent(txtBitScore,
                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(mapPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jLabel2).addComponent(txtMapE, javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(btnMapIDs)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(prgMapping, javax.swing.GroupLayout.PREFERRED_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 298, Short.MAX_VALUE)));

        tabbedPane.addTab("Mapping", mapPane);

        btnGTermIdent.setText("Get GO Term Info");
        btnGTermIdent.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnGTermIdentActionPerformed(evt);
            }
        });

        lstQueries.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        lstQueries.setMaximumSize(new java.awt.Dimension(2147483647, 2147483647));
        lstQueries.setMinimumSize(new java.awt.Dimension(562, 122));
        jScrollPane6.setViewportView(lstQueries);

        txtTermInfo.setEditable(false);
        txtTermInfo.setColumns(20);
        txtTermInfo.setRows(5);
        jScrollPane4.setViewportView(txtTermInfo);

        txtSearchTerms.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtSearchTermsActionPerformed(evt);
            }
        });

        lblMinFreqFilter.setText("Min Frequency:");

        lblMaxFreqFilter.setText("Max Frequency:");

        tblGOFreq.setModel(new javax.swing.table.DefaultTableModel(new Object[][] {

        }, new String[] { "GO ID", "Frequency" }) {
            Class[] types = new Class[] { java.lang.String.class, java.lang.String.class };

            public Class getColumnClass(int columnIndex) {
                return types[columnIndex];
            }
        });
        jScrollPane8.setViewportView(tblGOFreq);

        javax.swing.GroupLayout identPaneLayout = new javax.swing.GroupLayout(identPane);
        identPane.setLayout(identPaneLayout);
        identPaneLayout.setHorizontalGroup(identPaneLayout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(identPaneLayout.createSequentialGroup().addContainerGap().addGroup(identPaneLayout
                        .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(identPaneLayout.createSequentialGroup().addGroup(identPaneLayout
                                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(prgIdentification, javax.swing.GroupLayout.Alignment.TRAILING,
                                        javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
                                        Short.MAX_VALUE)
                                .addGroup(identPaneLayout.createSequentialGroup()
                                        .addGroup(identPaneLayout
                                                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                .addComponent(btnGTermIdent).addComponent(jScrollPane8,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE, 184, Short.MAX_VALUE))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addGroup(identPaneLayout
                                                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                .addComponent(jScrollPane4).addComponent(jScrollPane6,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE, 586,
                                                        Short.MAX_VALUE))))
                                .addContainerGap())
                        .addGroup(identPaneLayout.createSequentialGroup().addGroup(identPaneLayout
                                .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                .addComponent(txtSearchTerms, javax.swing.GroupLayout.Alignment.LEADING,
                                        javax.swing.GroupLayout.PREFERRED_SIZE, 184,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGroup(identPaneLayout.createSequentialGroup()
                                        .addGroup(identPaneLayout
                                                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                .addComponent(lblMinFreqFilter).addComponent(lblMaxFreqFilter))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addGroup(identPaneLayout
                                                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING,
                                                        false)
                                                .addComponent(txtMaxFreqFilter,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE, 67, Short.MAX_VALUE)
                                                .addComponent(txtMinFreqFilter))))
                                .addGap(605, 605, 605)))));
        identPaneLayout.setVerticalGroup(identPaneLayout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(identPaneLayout.createSequentialGroup().addGap(8, 8, 8)
                        .addComponent(prgIdentification, javax.swing.GroupLayout.PREFERRED_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnGTermIdent)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(identPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                .addGroup(identPaneLayout.createSequentialGroup()
                                        .addComponent(jScrollPane6, javax.swing.GroupLayout.DEFAULT_SIZE, 92,
                                                Short.MAX_VALUE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 183,
                                                Short.MAX_VALUE))
                                .addComponent(jScrollPane8, javax.swing.GroupLayout.PREFERRED_SIZE, 0,
                                        Short.MAX_VALUE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(txtSearchTerms, javax.swing.GroupLayout.PREFERRED_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(identPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(lblMinFreqFilter).addComponent(txtMinFreqFilter,
                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(8, 8, 8)
                        .addGroup(identPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(lblMaxFreqFilter).addComponent(txtMaxFreqFilter,
                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(16, 16, 16)));

        tabbedPane.addTab("Identification", identPane);

        btnFrequencyGraph.setText("Generate Frequency Graph");
        btnFrequencyGraph.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnFrequencyGraphActionPerformed(evt);
            }
        });

        pnlChartHolder.setBackground(new java.awt.Color(153, 153, 153));
        pnlChartHolder.setPreferredSize(new java.awt.Dimension(640, 480));

        javax.swing.GroupLayout pnlChartHolderLayout = new javax.swing.GroupLayout(pnlChartHolder);
        pnlChartHolder.setLayout(pnlChartHolderLayout);
        pnlChartHolderLayout.setHorizontalGroup(pnlChartHolderLayout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 0, Short.MAX_VALUE));
        pnlChartHolderLayout.setVerticalGroup(pnlChartHolderLayout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 352, Short.MAX_VALUE));

        btnWeb.setText("Create Web");
        btnWeb.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnWebActionPerformed(evt);
            }
        });

        lblMinHits.setText("Minimum Hits:");

        lblMaxHits.setText("Maximum Hits:");

        txtMinHits.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtMinHitsActionPerformed(evt);
            }
        });

        txtMaxHits.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtMaxHitsActionPerformed(evt);
            }
        });

        txtFilterGOID.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtFilterGOIDActionPerformed(evt);
            }
        });

        lblFilterGOFamily.setText("GO Family filter: ");

        txtGTermInfo.setEditable(false);
        txtGTermInfo.setColumns(20);
        txtGTermInfo.setRows(5);
        txtGTermInfo.setMinimumSize(new java.awt.Dimension(164, 94));
        jScrollPane7.setViewportView(txtGTermInfo);

        javax.swing.GroupLayout analysisPaneLayout = new javax.swing.GroupLayout(analysisPane);
        analysisPane.setLayout(analysisPaneLayout);
        analysisPaneLayout.setHorizontalGroup(analysisPaneLayout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, analysisPaneLayout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(analysisPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                .addComponent(pnlChartHolder, javax.swing.GroupLayout.DEFAULT_SIZE, 779,
                                        Short.MAX_VALUE)
                                .addComponent(prgChart, javax.swing.GroupLayout.Alignment.LEADING,
                                        javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
                                        Short.MAX_VALUE)
                                .addGroup(javax.swing.GroupLayout.Alignment.LEADING, analysisPaneLayout
                                        .createSequentialGroup()
                                        .addGroup(analysisPaneLayout
                                                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                .addComponent(lblMinHits).addComponent(lblFilterGOFamily))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addGroup(analysisPaneLayout
                                                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING,
                                                        false)
                                                .addGroup(analysisPaneLayout.createSequentialGroup()
                                                        .addComponent(txtMinHits,
                                                                javax.swing.GroupLayout.PREFERRED_SIZE, 46,
                                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                                        .addPreferredGap(
                                                                javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                                        .addComponent(lblMaxHits)
                                                        .addPreferredGap(
                                                                javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                        .addComponent(txtMaxHits,
                                                                javax.swing.GroupLayout.PREFERRED_SIZE, 45,
                                                                javax.swing.GroupLayout.PREFERRED_SIZE))
                                                .addComponent(txtFilterGOID))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addGroup(analysisPaneLayout
                                                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                .addComponent(btnFrequencyGraph).addComponent(btnWeb))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(jScrollPane7, javax.swing.GroupLayout.DEFAULT_SIZE, 193,
                                                Short.MAX_VALUE)))
                        .addContainerGap()));
        analysisPaneLayout.setVerticalGroup(analysisPaneLayout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(analysisPaneLayout.createSequentialGroup().addContainerGap().addGroup(analysisPaneLayout
                        .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(analysisPaneLayout.createSequentialGroup().addGroup(analysisPaneLayout
                                .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(btnFrequencyGraph).addComponent(lblMinHits).addComponent(lblMaxHits)
                                .addComponent(txtMinHits, javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(txtMaxHits, javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(analysisPaneLayout
                                        .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                        .addComponent(lblFilterGOFamily)
                                        .addComponent(txtFilterGOID, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addComponent(btnWeb)))
                        .addComponent(jScrollPane7, javax.swing.GroupLayout.PREFERRED_SIZE, 80,
                                javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(prgChart, javax.swing.GroupLayout.PREFERRED_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(pnlChartHolder, javax.swing.GroupLayout.DEFAULT_SIZE, 352, Short.MAX_VALUE)));

        tabbedPane.addTab("Analysis", analysisPane);

        mnuFile.setText("File");

        itmNewProject.setText("New Project");
        itmNewProject.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                itmNewProjectActionPerformed(evt);
            }
        });
        mnuFile.add(itmNewProject);

        itmLoadProject.setText("Load Project");
        itmLoadProject.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                itmLoadProjectActionPerformed(evt);
            }
        });
        mnuFile.add(itmLoadProject);

        chkDoCCs.setSelected(true);
        chkDoCCs.setText("Cellular Components");
        chkDoCCs.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                chkDoCCsActionPerformed(evt);
            }
        });
        mnuFile.add(chkDoCCs);

        chkDoMFs.setSelected(true);
        chkDoMFs.setText("Molecular Functions");
        chkDoMFs.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                chkDoMFsActionPerformed(evt);
            }
        });
        mnuFile.add(chkDoMFs);

        chkDoBPs.setSelected(true);
        chkDoBPs.setText("Biological Processes");
        chkDoBPs.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                chkDoBPsActionPerformed(evt);
            }
        });
        mnuFile.add(chkDoBPs);

        mnuMenu.add(mnuFile);

        setJMenuBar(mnuMenu);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addComponent(tabbedPane, javax.swing.GroupLayout.DEFAULT_SIZE, 814, Short.MAX_VALUE));
        layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addComponent(tabbedPane, javax.swing.GroupLayout.DEFAULT_SIZE, 514, Short.MAX_VALUE));

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void itmNewProjectActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_itmNewProjectActionPerformed
        if (currentProj.isAvaialable()) {
            fc.setSelectedFile(fc.getCurrentDirectory());
            fc.showSaveDialog(this);

            try {
                currentProj = Workspace.create(new Path(fc.getSelectedFile().toString()));
                chkDoCCs.setState(currentProj.willDoCC());
                chkDoBPs.setState(currentProj.willDoBP());
                chkDoMFs.setState(currentProj.willDoMF());
                chkDoCCs.setState(currentProj.willDoCC());
                chkDoBPs.setState(currentProj.willDoBP());
                chkDoMFs.setState(currentProj.willDoMF());
                txtQuery.setText(currentProj.getQueryPath());
                txtQueryFP.setText(currentProj.getQueryPath());
                txtDatabase.setText(currentProj.getPathToDB());
                txtDatabaseFP.setText(currentProj.getPathToDB());
                txtThreads.setValue(currentProj.getThreadNo());
                txtThreadsFP.setValue(currentProj.getThreadNo());
                cbxNXP.setSelectedIndex(currentProj.getBlastTypeIndex());
                cbxNXPFP.setSelectedIndex(currentProj.getBlastTypeIndex());
                cbxDBID.setSelectedIndex(currentProj.getSelectedDBIndex());
                cbxDBIDFP.setSelectedIndex(currentProj.getSelectedDBIndex());
                txtBitScore.setValue(currentProj.getBitScoreThreshold());
                txtBitScoreFP.setValue(currentProj.getBitScoreThreshold());
                this.setTitle("Search2GO " + currentProj.getPath().toString());
            } catch (IOException ex) {
                javax.swing.JOptionPane.showMessageDialog(this,
                        "Cannot create project here (project may already exist here)");
            }
        } else
            javax.swing.JOptionPane.showMessageDialog(this,
                    "Another function is currently being performed on this project, please wait until completion or manually stop the process.");
    }//GEN-LAST:event_itmNewProjectActionPerformed

    private void itmLoadProjectActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_itmLoadProjectActionPerformed
        if (currentProj.isAvaialable()) {
            fc.setSelectedFile(fc.getCurrentDirectory());
            fc.showOpenDialog(this);

            try {
                Path projToOpen = new Path(fc.getSelectedFile().toString());
                projToOpen.truncate();
                currentProj = Workspace.open(projToOpen);
                chkDoCCs.setState(currentProj.willDoCC());
                chkDoBPs.setState(currentProj.willDoBP());
                chkDoMFs.setState(currentProj.willDoMF());
                txtQuery.setText(currentProj.getQueryPath());
                txtQueryFP.setText(currentProj.getQueryPath());
                txtDatabase.setText(currentProj.getPathToDB());
                txtDatabaseFP.setText(currentProj.getPathToDB());
                txtThreads.setValue(currentProj.getThreadNo());
                txtThreadsFP.setValue(currentProj.getThreadNo());
                cbxNXP.setSelectedIndex(currentProj.getBlastTypeIndex());
                cbxNXPFP.setSelectedIndex(currentProj.getBlastTypeIndex());
                cbxDBID.setSelectedIndex(currentProj.getSelectedDBIndex());
                cbxDBIDFP.setSelectedIndex(currentProj.getSelectedDBIndex());
                txtBitScore.setValue(currentProj.getBitScoreThreshold());
                txtBitScoreFP.setValue(currentProj.getBitScoreThreshold());
                txtBlastE.setValue(currentProj.getEThreshold());
                txtMapE.setValue(currentProj.getEThreshold());
                txtEFP.setValue(currentProj.getEThreshold());
                this.setTitle("Search2GO " + currentProj.getPath().toString());
                if (currentProj.checkStage(2))
                    identify(false);
            } catch (IOException ex) {
                javax.swing.JOptionPane.showMessageDialog(this,
                        "Cannot open project. Was the correct 'project.proj' file selected?");
            }
        } else
            javax.swing.JOptionPane.showMessageDialog(this,
                    "Another function is currently being performed on this project, please wait until completion or manually stop the process.");
    }//GEN-LAST:event_itmLoadProjectActionPerformed

    private void txtMaxHitsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtMaxHitsActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_txtMaxHitsActionPerformed

    private void txtMinHitsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtMinHitsActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_txtMinHitsActionPerformed

    private void btnWebActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnWebActionPerformed
        if (currentProj.isAvaialable()) {
            if (currentProj.checkStage(3)) {
                if (gTerms.getGTerm(txtFilterGOID.getText()) == null && !("".equals(txtFilterGOID.getText())))
                    javax.swing.JOptionPane.showMessageDialog(this,
                            "GO ID provded not in current dataset. Please ensure you have opened the correct project and/or used the format 'GO:#######' (without quotes)");
                else {
                    try {
                        graphViewer.close();
                    } catch (NullPointerException e) {
                    }
                    pnlChartHolder.removeAll();
                    gTerms.getFilter().setFamilyFilter(gTerms.getGTerm(txtFilterGOID.getText()));
                    if (!txtMinHits.getText().equals(""))
                        gTerms.getFilter().setMinFreq(Integer.parseInt(txtMinHits.getText()));
                    else
                        gTerms.getFilter().setMinFreq(0);
                    if (!txtMaxHits.getText().equals(""))
                        gTerms.getFilter().setMaxFreq(Integer.parseInt(txtMaxHits.getText()));
                    else
                        gTerms.getFilter().setMaxFreq(-1);
                    JTextArea tempHolder = new JTextArea();
                    pnlChartHolder.removeAll();

                    GTerm minFreqTerm = gTerms.getLeastFreqTerm();
                    float freqGradientScale = (gTerms.getMostFreqTerm().getFrequency()
                            - minFreqTerm.getFrequency());

                    try {
                        ProcessSequence webSequence = gTerms.getFamilyFilterSequence(currentProj);
                        webSequence.setTail(new ProcessSequenceFiller(tempHolder) {
                            @Override
                            public void run() {
                                new Thread(new Runnable() {
                                    @Override
                                    public void run() {
                                        GTermSet terms = gTerms.getFilteredTerms();
                                        int i = 0;

                                        Graph g = new SingleGraph("GO Network");

                                        for (GTerm child : terms.getGTerms()) {
                                            if (g.getNode(child.getID()) == null) {
                                                g.addNode(child.getID()).setAttribute("ui.label", child.getID());
                                                int blueAmount = (int) (((child.getFrequency()
                                                        - minFreqTerm.getFrequency()) / freqGradientScale) * 255);
                                                g.getNode(child.getID()).setAttribute("ui.style",
                                                        "fill-color: rgb(" + Integer.toString(blueAmount) + ",0,"
                                                                + Integer.toString(blueAmount) + ");");
                                            }
                                            if (gTerms.getFilter().getFamilyFilter() != null) {
                                                if (child.equals(gTerms.getFilter().getFamilyFilter()))
                                                    g.getNode(child.getID()).addAttribute("ui.style",
                                                            "fill-color: rgb(0,255,0);");
                                            }
                                            if (child.getID().equals("GO:0005575")
                                                    || child.getID().equals("GO:0003674")
                                                    || child.getID().equals("GO:0008150")) {
                                                g.getNode(child.getID()).addAttribute("ui.style",
                                                        "fill-color: rgb(255,0,0);");
                                            }
                                            for (GTerm parent : child.getParents()) {
                                                if (terms.getGTerms().contains(parent)) {
                                                    if (g.getNode(parent.getID()) == null) {
                                                        g.addNode(parent.getID()).addAttribute("ui.label",
                                                                parent.getID());
                                                        int blueAmount = (int) (((parent.getFrequency()
                                                                - minFreqTerm.getFrequency()) / freqGradientScale)
                                                                * 255);
                                                        g.getNode(parent.getID()).setAttribute("ui.style",
                                                                "fill-color: rgb(" + Integer.toString(blueAmount)
                                                                        + ",0," + Integer.toString(blueAmount)
                                                                        + ");");
                                                    }
                                                    if (gTerms.getFilter().getFamilyFilter() != null) {
                                                        if (parent.equals(gTerms.getFilter().getFamilyFilter()))
                                                            g.getNode(parent.getID()).addAttribute("ui.style",
                                                                    "fill-color: rgb(0,255,0);");
                                                    }
                                                    if (child.getID().equals("GO:0005575")
                                                            || child.getID().equals("GO:0003674")
                                                            || child.getID().equals("GO:0008150")) {
                                                        g.getNode(child.getID()).addAttribute("ui.style",
                                                                "fill-color: rgb(255,0,0);");
                                                    }
                                                    g.addEdge("Edge " + Integer.toString(i), parent.getID(),
                                                            child.getID(), true);
                                                    i++;
                                                }
                                            }
                                        }

                                        graphViewer = new Viewer(g, Viewer.ThreadingModel.GRAPH_IN_ANOTHER_THREAD);
                                        ViewPanel view = graphViewer.addDefaultView(false);
                                        ViewerPipe fromViewer = graphViewer.newViewerPipe();
                                        fromViewer.addViewerListener(new TermClickListener());
                                        fromViewer.addAttributeSink(g);

                                        new Thread(new Runnable() {
                                            @Override
                                            public void run() {
                                                while (true) {
                                                    try {
                                                        fromViewer.blockingPump();
                                                    } catch (InterruptedException ex) {
                                                        Logger.getLogger(UIFrame.class.getName()).log(Level.SEVERE,
                                                                null, ex);
                                                    }
                                                }
                                            }
                                        }).start();

                                        WebManipulator webManipulator = new WebManipulator(graphViewer);
                                        view.addKeyListener(webManipulator);
                                        view.addMouseWheelListener(webManipulator);
                                        pnlChartHolder.add(view);
                                        pnlChartHolder.validate();
                                        view.setComponentPopupMenu(webSaveMenu);
                                        graphViewer.enableAutoLayout();
                                        view.requestFocus();
                                        prgChart.setIndeterminate(false);
                                    }
                                }).start();
                            }
                        });

                        try {
                            webSequence.start();
                            prgChart.setIndeterminate(true);
                        } catch (IOException ex) {
                            System.out.println("Coud not generate network chart.");
                        }
                    } catch (IOException e) {
                        System.out.println("Could not filter network chart");
                    }
                }
            } else
                javax.swing.JOptionPane.showMessageDialog(this,
                        "Identification data unavailable. Please perform identification or load a project with completed identification to continue.");
        } else
            javax.swing.JOptionPane.showMessageDialog(this,
                    "Another function is currently being performed on this project, please wait until completion or manually stop the process.");
    }//GEN-LAST:event_btnWebActionPerformed

    private void btnFrequencyGraphActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnFrequencyGraphActionPerformed
        if (currentProj.isAvaialable()) {
            if (currentProj.checkStage(3)) {
                if (gTerms.getGTerm(txtFilterGOID.getText()) == null && !("".equals(txtFilterGOID.getText())))
                    javax.swing.JOptionPane.showMessageDialog(this,
                            "GO ID provded not in current dataset. Please ensure you have opened the correct project and/or used the format 'GO:#######' (without quotes)");
                else {
                    try {
                        graphViewer.close();
                    } catch (NullPointerException e) {
                    }
                    pnlChartHolder.removeAll();
                    gTerms.getFilter().setFamilyFilter(gTerms.getGTerm(txtFilterGOID.getText()));
                    if (!txtMinHits.getText().equals(""))
                        gTerms.getFilter().setMinFreq(Integer.parseInt(txtMinHits.getText()));
                    else
                        gTerms.getFilter().setMinFreq(0);
                    if (!txtMaxHits.getText().equals(""))
                        gTerms.getFilter().setMaxFreq(Integer.parseInt(txtMaxHits.getText()));
                    else
                        gTerms.getFilter().setMaxFreq(-1);

                    prgChart.setIndeterminate(true);

                    try {
                        ProcessSequence graphSequence = gTerms.getFamilyFilterSequence(currentProj);
                        graphSequence.setTail(new ProcessSequenceEnd() {
                            @Override
                            public void run() {
                                new Thread(new Runnable() {
                                    private JFreeChart barChart;
                                    private DefaultCategoryDataset dataset = new DefaultCategoryDataset();

                                    @Override
                                    public void run() {
                                        GTermSet termSet = gTerms.getFilteredTerms();

                                        termSet.freqSort();
                                        Collections.reverse(termSet.getGTerms());
                                        for (GTerm term : termSet.getGTerms()) {
                                            dataset.addValue(term.getFrequency(), "GO Term Frequency",
                                                    term.getID());
                                        }

                                        barChart = ChartFactory.createBarChart("GO Term Frequency", "GO Terms",
                                                "Frequency", dataset, PlotOrientation.VERTICAL, true, true, false);
                                        BarRenderer renderer = (BarRenderer) barChart.getCategoryPlot()
                                                .getRenderer();
                                        ChartPanel chartPanel = new ChartPanel(barChart);
                                        barChart.getCategoryPlot().setRenderer(renderer);
                                        CategoryItemLabelGenerator generator = new StandardCategoryItemLabelGenerator(
                                                "{1}", NumberFormat.getInstance());
                                        renderer.setItemLabelGenerator(generator);
                                        renderer.setItemLabelFont(new Font("SansSerif", Font.PLAIN, 12));
                                        renderer.setItemLabelsVisible(true);
                                        renderer.setPositiveItemLabelPosition(
                                                new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER,
                                                        TextAnchor.CENTER, -Math.PI / 2));
                                        chartPanel.addChartMouseListener(new TermClickListener());

                                        pnlChartHolder.add(chartPanel);
                                        pnlChartHolder.validate();
                                        prgChart.setIndeterminate(false);

                                    }
                                }).start();
                            }

                        });
                        graphSequence.start();
                    } catch (IOException ex) {
                        System.out.println("Coud not generate graph");
                    }

                }
            } else
                javax.swing.JOptionPane.showMessageDialog(this,
                        "Identification data unavailable. Please perform identification or load a project with completed identification to continue.");
        } else
            javax.swing.JOptionPane.showMessageDialog(this,
                    "Another function is currently being performed on this project, please wait until completion or manually stop the process.");
    }//GEN-LAST:event_btnFrequencyGraphActionPerformed

    private void txtSearchTermsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtSearchTermsActionPerformed

    }//GEN-LAST:event_txtSearchTermsActionPerformed

    public void identify(boolean fullProcess) {
        if ("Stop".equals(btnGTermIdent.getText())) {
            identButton.activate();
            try {
                if (os.isWindows()) {
                    Runtime.getRuntime().exec("cmd /C TaskKill -IM blastx.exe -F");
                    Runtime.getRuntime().exec("cmd /C TaskKill -IM blastn.exe -F");
                    Runtime.getRuntime().exec("cmd /C TaskKill -IM blastp.exe -F");
                } else {
                    Runtime.getRuntime().exec("killAll -KILL blastx");
                    Runtime.getRuntime().exec("killAll -KILL blastn");
                    Runtime.getRuntime().exec("killAll -KILL blastp");
                }
            } catch (IOException ex) {
                System.out.println("Error closing child processes");
            }
            prgIdentification.setIndeterminate(false);
        } else if (currentProj.checkStage(2)) {
            if (currentProj.isAvaialable()) {
                pnlChartHolder.removeAll();
                lstQueries.clearSelection();
                lstQueries.setModel(new DefaultListModel());
                txtTermInfo.setText("");

                tblGOFreq.clearSelection();
                DefaultTableModel d = new DefaultTableModel();
                d.setColumnCount(2);
                d.setColumnIdentifiers(new String[] { "GO ID", "Frequency" });
                tblGOFreq.setModel(d);

                identSequences = new ArrayList<>();

                resetIdentCount();
                for (int i = 0; i < 3; i++) {
                    if (currentProj.getTargetDBString().contains(targetDBs[i])) {
                        JTextArea tempHolder = new JTextArea();
                        ProcessSequence identSequence = new ProcessSequence(currentProj,
                                new ProcessSequenceFiller(tempHolder, Integer.toString(i)) {
                                    private final JTextArea sequenceOutput = tempHolder;

                                    @Override
                                    public void run() {
                                        new Thread(new Runnable() {
                                            @Override
                                            public void run() {
                                                for (String record : sequenceOutput.getText().split("\n")) {
                                                    String name = record.split("\t")[0];
                                                    GTerm nextGTerm = new GTerm(
                                                            name.substring(0, name.indexOf("[")),
                                                            name.substring(name.indexOf("[")));
                                                    nextGTerm.setTopLevel(topLevels[Integer.parseInt(getNotes())]);
                                                    nextGTerm.setFrequency(Integer.parseInt(record.split("\t")[1]));
                                                    gTerms.addGTerm(nextGTerm);
                                                }
                                                incIdentCount();
                                            }
                                        }).start();
                                    }
                                });
                        identSequences.add(identSequence);
                        Process checkFullIdent = new Process(tempHolder);
                        Path checkFullIdentPath = new Path("Processes");
                        checkFullIdentPath.append("gotFullGTerms.py");
                        checkFullIdent.setScriptCommand(checkFullIdentPath.toEscString());
                        checkFullIdent.addParameter("dir", currentProj.getPath().toEscString());
                        checkFullIdent.addParameter("db", targetDBs[i]);
                        identSequence.addProcess(checkFullIdent);
                        ProcessSequenceFiller doFullCheckOutputGetter = new ProcessSequenceFiller(tempHolder,
                                targetDBs[i]) {
                            @Override
                            public void run() {
                                if (this.getOutBox().getText().contains("false")) {
                                    this.getOutBox().setText("");
                                    Process mapSequenceGO = new Process(this.getOutBox());
                                    Path mapSequenceGOPath = new Path("Processes");
                                    mapSequenceGOPath.append("mapSequenceGO.py");
                                    mapSequenceGO.setScriptCommand(mapSequenceGOPath.toEscString());
                                    mapSequenceGO.addParameter("dir", currentProj.getPath().toEscString());
                                    mapSequenceGO.addParameter("db", this.getNotes());
                                    this.getParentSequence(0).addProcess(mapSequenceGO);

                                    Process parseConverts = new Process(this.getOutBox());
                                    Path parseConvertsPath = new Path("Processes");
                                    parseConvertsPath.append("parseConvertedIDs.py");
                                    parseConverts.setScriptCommand(parseConvertsPath.toEscString());
                                    parseConverts.addParameter("dir", currentProj.getPath().toEscString());
                                    parseConverts.addParameter("db", this.getNotes());
                                    this.getParentSequence(0).addProcess(parseConverts);

                                    identSequence.addProcess(new ProcessSequenceFiller(tempHolder) {
                                        @Override
                                        public void run() {
                                            tempHolder.setText("");
                                            try {
                                                this.finish();
                                            } catch (IOException ex) {
                                                System.out.println("Error finishing identification process filler");
                                            }
                                        }

                                    });
                                }
                                this.getOutBox().setText("");
                                Process getMatchedQueryFreq = new Process(this.getOutBox());
                                Path getMatchedQueryFreqPath = new Path("Processes");
                                getMatchedQueryFreqPath.append("getMatchedQueryFreq.py");
                                getMatchedQueryFreq.setScriptCommand(getMatchedQueryFreqPath.toEscString());
                                getMatchedQueryFreq.addParameter("dir", currentProj.getPath().toEscString());
                                getMatchedQueryFreq.addParameter("db", this.getNotes());
                                this.getParentSequence(0).addProcess(getMatchedQueryFreq);
                                try {
                                    this.finish();
                                } catch (IOException ex) {
                                    System.out.println("Error finishing identification process filler");
                                }
                            }
                        };

                        identSequence.addProcess(doFullCheckOutputGetter);
                        try {
                            gTerms.getGTerms().clear();
                            identSequence.start();
                            identButton.setStopTargets(
                                    identSequences.toArray(new ProcessSequence[identSequences.size()]));
                            if (currentProj.willDoCC())
                                currentProj.setStage(0, 2);
                            if (currentProj.willDoBP())
                                currentProj.setStage(1, 2);
                            if (currentProj.willDoBP())
                                currentProj.setStage(2, 2);
                            prgIdentification.setIndeterminate(true);
                        } catch (IOException ex) {
                            Logger.getLogger(UIFrame.class.getName()).log(Level.SEVERE, null, ex);
                        }
                    }
                }
                identButton.activate();
            } else
                javax.swing.JOptionPane.showMessageDialog(this,
                        "Another function is currently being performed on this project, please wait until completion or manually stop the process.");
        } else {
            System.out.println(currentProj.getStage());
            javax.swing.JOptionPane.showMessageDialog(this,
                    "Mapping data unavailable. Please complete mapping step or switch to a project with completed mapping to continue.");
        }

    }

    private void btnGTermIdentActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnGTermIdentActionPerformed
        identify(false);
    }//GEN-LAST:event_btnGTermIdentActionPerformed

    private void doParents() {
        JTextArea tempText = new JTextArea();

        ProcessSequence treeSequence = new ProcessSequence();
        Path treePath = new Path("Processes");
        treePath.append("getTree.py");

        if (currentProj.willDoCC()) {
            Process treeProcessCC = new Process(tempText);
            treeProcessCC.setScriptCommand(treePath.toEscString());
            treeProcessCC.addParameter("dir", currentProj.getPath().toEscString());
            treeProcessCC.addParameter("db", "CC");
            treeSequence.addProcess(treeProcessCC);
        }
        if (currentProj.willDoBP()) {
            Process treeProcessBP = new Process(tempText);
            treeProcessBP.setScriptCommand(treePath.toEscString());
            treeProcessBP.addParameter("dir", currentProj.getPath().toEscString());
            treeProcessBP.addParameter("db", "BP");
            treeSequence.addProcess(treeProcessBP);
        }
        if (currentProj.willDoBP()) {
            Process treeProcessMF = new Process(tempText);
            treeProcessMF.setScriptCommand(treePath.toEscString());
            treeProcessMF.addParameter("dir", currentProj.getPath().toEscString());
            treeProcessMF.addParameter("db", "MF");
            treeSequence.addProcess(treeProcessMF);
        }

        ProcessSequenceFiller setParents = new ProcessSequenceFiller(tempText) {
            private GTerm parent;
            private GTerm child;

            @Override
            public void run() {
                new Thread(new Runnable() {
                    @Override
                    public void run() {
                        for (String record : tempText.getText().split("\n")) {
                            if (record.length() > 0) {
                                parent = gTerms.getGTerm(record.substring(0, record.indexOf('\t')));
                                for (String childID : record.substring(record.indexOf('\t') + 1, record.length())
                                        .split(";")) {
                                    child = gTerms.getGTerm(childID);
                                    if (parent != null && child != null)
                                        child.addParent(parent);
                                }
                            }
                        }
                        fillIdentTable(gTerms, true);
                    }
                }).start();
            }
        };
        treeSequence.setTail(setParents);

        try {
            treeSequence.start();
        } catch (IOException ex) {
            Logger.getLogger(UIFrame.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    private void resetIdentCount() {
        identCount = 0;
        maxIdentCount = currentProj.getTargetDBString().length() / 2;
        if (maxIdentCount > 3)
            maxIdentCount = 3;
    }

    private void incIdentCount() {
        identCount++;
        if (identCount == maxIdentCount) {
            doParents();
        }
    }

    private void fillIdentTable(GTermSet terms, boolean identStage) {
        terms.stringFilter();
        GTermTableModel = new DefaultTableModel();
        GTermTableModel.setColumnCount(2);
        GTermTableModel.setColumnIdentifiers(new String[] { "GO ID", "Frequency" });
        tblGOFreq.setModel(GTermTableModel);
        terms.freqSort();
        for (GTerm term : terms.getGTerms()) {
            String[] row = { term.getID() + term.getName(), term.getFrequencyObject().toString() };
            GTermTableModel.addRow(row);
        }
        tblGOFreq.setModel(GTermTableModel);
        if (identStage) {
            prgIdentification.setIndeterminate(false);
            prgFullProcess.setIndeterminate(false);
            txtFullOutput.append(
                    "Done identifying!\nPlease go to the 'Identification' tab to see the results or 'Analysis' to view related graphs.\n");
            if (currentProj.willDoCC())
                currentProj.setStage(0, 3);
            if (currentProj.willDoBP())
                currentProj.setStage(1, 3);
            if (currentProj.willDoBP())
                currentProj.setStage(2, 3);
            identButton.restore();
            fullButton.restore();
            currentProj.setAvailable(true);
        }
    }

    private void map(JFormattedTextField bitScore, JFormattedTextField eValue, JComboBox originDB, JTextArea output,
            boolean fullProcess) {
        currentProj.setSelectedDBIndex(originDB.getSelectedIndex());
        currentProj.setBitScoreThreshold(Integer.parseInt(bitScore.getText()));
        currentProj.setEthreshold(Integer.parseInt(txtMapE.getText()));
        mapSequence = new ProcessSequence(currentProj, new ProcessSequenceEnd() {
            @Override
            public void run() {
                if (!output.getText().contains(
                        "No valid hits found. Please retry with lower bit score or higher e-value thresholds.")) {
                    if (currentProj.willDoCC())
                        currentProj.setStage(0, 2);
                    if (currentProj.willDoBP())
                        currentProj.setStage(1, 2);
                    if (currentProj.willDoBP())
                        currentProj.setStage(2, 2);
                    output.append("Mapping done! Please proceed to Identification.\n");
                    if (fullProcess) {
                        output.append("Identifying...\n");
                        identify(true);
                    }
                }
                currentProj.setAvailable(true);
                prgMapping.setIndeterminate(false);
                mapButton.restore();
            }
        });

        Process mapProcess = new Process(output);

        Path mapScriptPath = new Path("Processes");
        mapScriptPath.append("MapFromBlast.py");
        mapProcess.setScriptCommand(mapScriptPath.toEscString());

        mapSequence.addProcess(mapProcess);
        mapProcess.addParameter("dir", currentProj.getPath().toEscString());
        if (!bitScore.getText().equals(""))
            mapProcess.addParameter("bs", bitScore.getText());
        if (!eValue.getText().equals(""))
            mapProcess.addParameter("e", eValue.getText());
        mapProcess.addParameter("id", originDB.getSelectedItem().toString().replaceAll(" ", ""));
        Path blastLoc = new Path(currentProj.getPath());
        blastLoc.append("BLAST_Results.xml");
        mapProcess.addParameter("o", blastLoc.toString());
        mapProcess.addParameter("gdb", currentProj.getTargetDBString());

        try {
            mapSequence.start();
            mapButton.setStopTargets(mapSequence);
            if (!fullProcess)
                mapButton.activate();
            if (currentProj.willDoCC())
                currentProj.setStage(0, 1);
            if (currentProj.willDoBP())
                currentProj.setStage(1, 1);
            if (currentProj.willDoBP())
                currentProj.setStage(2, 1);
            System.out.println(currentProj.getStage());
            output.setText("Mapping...\n");
            prgMapping.setIndeterminate(true);
        } catch (IOException ex) {
            javax.swing.JOptionPane.showMessageDialog(this, "Error running mapping program.");
        }
    }

    private void btnMapIDsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnMapIDsActionPerformed
        if ("Stop".equals(btnMapIDs.getText())) {
            prgMapping.setIndeterminate(false);
            mapButton.activate();
        } else if (currentProj.checkStage(1)) {
            if (currentProj.isAvaialable()) {
                fillIdentTable(new GTermSet(), false);
                pnlChartHolder.removeAll();
                map(txtBitScore, txtMapE, cbxDBID, txtMapOutput, false);
            } else
                javax.swing.JOptionPane.showMessageDialog(this,
                        "Another function is currently being performed on this project, please wait until completion or manually stop the process.");
        } else
            javax.swing.JOptionPane.showMessageDialog(this,
                    "BLAST data unavailable. Please either complete Blast step, or switch to a project with completed BLAST to continue.");
    }//GEN-LAST:event_btnMapIDsActionPerformed

    private void btnChooseDBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnChooseDBActionPerformed
        SelectFile(txtDatabase);
        Path truncatedPath = new Path(txtDatabase.getText());
        truncatedPath.truncateFileExtension();
        txtDatabase.setText(truncatedPath.toString());
        currentProj.setPathToDB(txtDatabase.getText());
    }//GEN-LAST:event_btnChooseDBActionPerformed

    private void SelectFile(JTextField outField) {
        fc.setSelectedFile(fc.getCurrentDirectory());
        fc.showOpenDialog(this);
        if (fc.getSelectedFile().exists() && !fc.getSelectedFile().isDirectory()) {
            outField.setText(fc.getSelectedFile().toString());
        } else {
            javax.swing.JOptionPane.showMessageDialog(this, "Invalid file selected.");
        }
    }

    private void blast(JTextField queries, JFormattedTextField eValue, JTextField db, JTextField threads,
            JComboBox type, JTextArea output, boolean fullProcess) throws IOException {
        Path queriesPath = new Path(queries.getText());
        Path dbPath = new Path(db.getText());
        String threadNo = threads.getText();
        String blastType = type.getSelectedItem().toString().replace("BLAST", "");

        currentProj.setQueries(queriesPath.toEscString());
        currentProj.setPathToDB(dbPath.toEscString());
        currentProj.setThreadNo(Integer.parseInt(threadNo));
        currentProj.setBlastTypeIndex(type.getSelectedIndex());
        currentProj.setEthreshold(Integer.parseInt(txtBlastE.getText()));

        blastSequence = new ProcessSequence(currentProj, new ProcessSequenceEnd() {
            @Override
            public void run() {
                output.append("BLAST Done! Please proceed to Mapping\n");
                prgBlast.setIndeterminate(false);
                currentProj.setAvailable(true);
                currentProj.setStage(1);
                if (fullProcess) {
                    map(txtBitScoreFP, eValue, cbxDBIDFP, txtFullOutput, true);
                }
                blastButton.restore();
            }
        });

        Path outLoc = new Path(currentProj.getPath());
        outLoc.append("BLAST_Results.xml");
        Process blastProcess = new Process(output, outLoc);

        blastProcess.setBaseCommand("");
        blastProcess.setScriptCommand(type.getSelectedItem().toString().toLowerCase());
        blastProcess.addParameter("query", queriesPath.toEscString());
        blastProcess.addParameter("db", dbPath.toEscString());
        blastProcess.addParameter("num_threads", threadNo);
        if (!eValue.getText().equals(""))
            blastProcess.addParameter("evalue", eValue.getText());
        blastProcess.addParameter("outfmt", Integer.toString(5));

        blastSequence.addProcess(blastProcess);

        try {
            blastSequence.start();
            blastButton.setStopTargets(blastSequence);
            if (!fullProcess)
                blastButton.activate();
            currentProj.setStage(0);
            output.setText("Searching...\n");
            prgBlast.setIndeterminate(true);
        } catch (IOException ex) {
            javax.swing.JOptionPane.showMessageDialog(this, "Error running BLAST search.");
        }
    }

    private void btnBlastActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnBlastActionPerformed
        if ("Stop".equals(btnBlast.getText())) {
            prgBlast.setIndeterminate(false);
            try {
                if (os.isWindows()) {
                    Runtime.getRuntime().exec("cmd /C TaskKill -IM blastx.exe -F");
                    Runtime.getRuntime().exec("cmd /C TaskKill -IM blastn.exe -F");
                    Runtime.getRuntime().exec("cmd /C TaskKill -IM blastp.exe -F");
                } else {
                    Runtime.getRuntime().exec("killAll -KILL blastx");
                    Runtime.getRuntime().exec("killAll -KILL blastn");
                    Runtime.getRuntime().exec("killAll -KILL blastp");
                }
            } catch (IOException ex) {
                System.out.println("Error closing child processes");
            }
            blastButton.activate();
        } else if (currentProj.checkStage(0)) {
            if (currentProj.isAvaialable()) {
                try {
                    fillIdentTable(new GTermSet(), false);
                    pnlChartHolder.removeAll();
                    blast(txtQuery, txtBlastE, txtDatabase, txtThreads, cbxNXP, txtBlastOutput, false);
                } catch (IOException ex) {
                    javax.swing.JOptionPane.showMessageDialog(this, "Error creating BLAST output file.");
                }
            } else
                javax.swing.JOptionPane.showMessageDialog(this,
                        "Another function is currently being performed on this project, please wait until completion or manually stop the process.");
        } else
            javax.swing.JOptionPane.showMessageDialog(this,
                    "Current project appears to be corrupted, please delete 'project.proj' in the project directory to continue.");

    }//GEN-LAST:event_btnBlastActionPerformed

    private void btnProcessFPActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnProcessFPActionPerformed
        if (!"Stop".equals(btnProcessFP.getText())) {
            if (currentProj.isAvaialable()) {
                fullButton.activate();
                txtFullOutput.setText("");
                try {
                    blast(txtQueryFP, txtEFP, txtDatabaseFP, txtThreadsFP, cbxNXPFP, txtFullOutput, true);
                } catch (IOException ex) {
                    javax.swing.JOptionPane.showMessageDialog(this, "Error creating BLAST output file.");
                }
                prgFullProcess.setIndeterminate(true);
            } else
                javax.swing.JOptionPane.showMessageDialog(this,
                        "Another function is currently being performed on this project, please wait until completion or manually stop the process.");
        } else {
            fullButton.activate();
            prgFullProcess.setIndeterminate(false);
            try {
                if (os.isWindows()) {
                    Runtime.getRuntime().exec("cmd /C TaskKill -IM blastx.exe -F");
                    Runtime.getRuntime().exec("cmd /C TaskKill -IM blastn.exe -F");
                    Runtime.getRuntime().exec("cmd /C TaskKill -IM blastp.exe -F");
                } else {
                    Runtime.getRuntime().exec("killAll -KILL blastx");
                    Runtime.getRuntime().exec("killAll -KILL blastn");
                    Runtime.getRuntime().exec("killAll -KILL blastp");
                }
            } catch (IOException ex) {
                System.out.println("Error closing child processes");
            }
        }

    }//GEN-LAST:event_btnProcessFPActionPerformed

    private void btnChooseQueriesFPActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnChooseQueriesFPActionPerformed
        SelectFile(txtQueryFP);
        currentProj.setQueries(txtQueryFP.getText());
    }//GEN-LAST:event_btnChooseQueriesFPActionPerformed

    private void btnChooseDBFPActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnChooseDBFPActionPerformed
        SelectFile(txtDatabaseFP);
        Path truncatedPath = new Path(txtDatabaseFP.getText());
        truncatedPath.truncateFileExtension();
        txtDatabaseFP.setText(truncatedPath.toString());
        currentProj.setPathToDB(txtDatabaseFP.getText());
    }//GEN-LAST:event_btnChooseDBFPActionPerformed

    private void txtQueryActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtQueryActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_txtQueryActionPerformed

    private void txtFilterGOIDActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtFilterGOIDActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_txtFilterGOIDActionPerformed

    private void btnChooseQueriesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnChooseQueriesActionPerformed
        SelectFile(txtQuery);
        currentProj.setQueries(txtQuery.getText());
    }//GEN-LAST:event_btnChooseQueriesActionPerformed

    private void chkDoCCsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chkDoCCsActionPerformed
        currentProj.setCC(chkDoCCs.getState());
    }//GEN-LAST:event_chkDoCCsActionPerformed

    private void chkDoMFsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chkDoMFsActionPerformed
        currentProj.setMF(chkDoMFs.getState());
    }//GEN-LAST:event_chkDoMFsActionPerformed

    private void chkDoBPsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chkDoBPsActionPerformed
        currentProj.setBP(chkDoBPs.getState());
    }//GEN-LAST:event_chkDoBPsActionPerformed

    private void txtThreadsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtThreadsActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_txtThreadsActionPerformed

    private void txtBitScoreActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtBitScoreActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_txtBitScoreActionPerformed

    private void txtMapEActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtMapEActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_txtMapEActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JPanel analysisPane;
    private javax.swing.JPanel blastPane;
    private javax.swing.JButton btnBlast;
    private javax.swing.JButton btnChooseDB;
    private javax.swing.JButton btnChooseDBFP;
    private javax.swing.JButton btnChooseQueries;
    private javax.swing.JButton btnChooseQueriesFP;
    private javax.swing.JButton btnFrequencyGraph;
    private javax.swing.JButton btnGTermIdent;
    private javax.swing.JButton btnMapIDs;
    private javax.swing.JButton btnProcessFP;
    private javax.swing.JToggleButton btnWeb;
    private javax.swing.JComboBox<String> cbxDBID;
    private javax.swing.JComboBox<String> cbxDBIDFP;
    private javax.swing.JComboBox<String> cbxNXP;
    private javax.swing.JComboBox<String> cbxNXPFP;
    private javax.swing.JCheckBoxMenuItem chkDoBPs;
    private javax.swing.JCheckBoxMenuItem chkDoCCs;
    private javax.swing.JCheckBoxMenuItem chkDoMFs;
    private javax.swing.JPanel identPane;
    private javax.swing.JMenuItem itmLoadProject;
    private javax.swing.JMenuItem itmNewProject;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JScrollPane jScrollPane5;
    private javax.swing.JScrollPane jScrollPane6;
    private javax.swing.JScrollPane jScrollPane7;
    private javax.swing.JScrollPane jScrollPane8;
    private javax.swing.JLabel lblBitScore;
    private javax.swing.JLabel lblBitScoreFP;
    private javax.swing.JLabel lblDBID;
    private javax.swing.JLabel lblDBIDFP;
    private javax.swing.JLabel lblDatabase;
    private javax.swing.JLabel lblDatabaseFP;
    private javax.swing.JLabel lblFilterGOFamily;
    private javax.swing.JLabel lblMaxFreqFilter;
    private javax.swing.JLabel lblMaxHits;
    private javax.swing.JLabel lblMinFreqFilter;
    private javax.swing.JLabel lblMinHits;
    private javax.swing.JLabel lblNXP;
    private javax.swing.JLabel lblNXPFP;
    private javax.swing.JLabel lblQueriesFP;
    private javax.swing.JLabel lblQuery;
    private javax.swing.JLabel lblThreads;
    private javax.swing.JLabel lblThreadsFP;
    private javax.swing.JList<String> lstQueries;
    private javax.swing.JPanel mapPane;
    private javax.swing.JMenu mnuFile;
    private javax.swing.JMenuBar mnuMenu;
    private javax.swing.JPanel pnlChartHolder;
    private javax.swing.JPanel pnlFullProcess;
    private javax.swing.JProgressBar prgBlast;
    private javax.swing.JProgressBar prgChart;
    private javax.swing.JProgressBar prgFullProcess;
    private javax.swing.JProgressBar prgIdentification;
    private javax.swing.JProgressBar prgMapping;
    private javax.swing.JTabbedPane tabbedPane;
    private javax.swing.JTable tblGOFreq;
    private javax.swing.JFormattedTextField txtBitScore;
    private javax.swing.JFormattedTextField txtBitScoreFP;
    private javax.swing.JFormattedTextField txtBlastE;
    private javax.swing.JTextArea txtBlastOutput;
    private javax.swing.JTextField txtDatabase;
    private javax.swing.JTextField txtDatabaseFP;
    private javax.swing.JFormattedTextField txtEFP;
    private javax.swing.JTextField txtFilterGOID;
    private javax.swing.JTextArea txtFullOutput;
    private javax.swing.JTextArea txtGTermInfo;
    private javax.swing.JFormattedTextField txtMapE;
    private javax.swing.JTextArea txtMapOutput;
    private javax.swing.JFormattedTextField txtMaxFreqFilter;
    private javax.swing.JFormattedTextField txtMaxHits;
    private javax.swing.JFormattedTextField txtMinFreqFilter;
    private javax.swing.JFormattedTextField txtMinHits;
    private javax.swing.JTextField txtQuery;
    private javax.swing.JTextField txtQueryFP;
    private javax.swing.JTextField txtSearchTerms;
    private javax.swing.JTextArea txtTermInfo;
    private javax.swing.JFormattedTextField txtThreads;
    private javax.swing.JFormattedTextField txtThreadsFP;

    // End of variables declaration//GEN-END:variables
    private class TermClickListener implements ViewerListener, ChartMouseListener {
        private ProcessSequence getInfoSequence;

        TermClickListener() {
        }

        private void resetGetterSequence() {
            getInfoSequence = new ProcessSequence(new ProcessSequenceEnd() {
                @Override
                public void run() {
                    String s = "";
                    for (String line : txtGTermInfo.getText().split("\n")) {
                        if (!line.contains("name"))
                            s = s + line + "\n";
                    }
                    txtGTermInfo.setText(s);
                    prgChart.setIndeterminate(false);
                }
            });
            Path getInfoPath = new Path("Processes");
            getInfoPath.append("getGTermData.py");
            Process getInfoProcess = new Process(txtGTermInfo);
            getInfoProcess.setScriptCommand(getInfoPath.toEscString());
            getInfoProcess.addParameter("dir", currentProj.getPath().toEscString());
            getInfoSequence.addProcess(getInfoProcess);
        }

        private void showNameAndID(String id) {
            GTerm term = gTerms.getGTerm(id);
            txtGTermInfo.append("ID: " + term.getID() + "\n");
            txtGTermInfo.append("Name: " + term.getName().replace("[", "").replace("]", "") + "\n");
            txtGTermInfo.append("Frequency: " + term.getFrequencyObject().toString() + "\n");
        }

        @Override
        public void viewClosed(String arg0) {
        }

        @Override
        public void buttonPushed(String nodeID) {
            prgChart.setIndeterminate(true);
            new Thread(new Runnable() {
                @Override
                public void run() {
                    txtGTermInfo.setText("");
                    showNameAndID(nodeID);
                    resetGetterSequence();
                    getInfoSequence.getProcess(0).addParameter("id", nodeID);
                    try {
                        getInfoSequence.start();
                    } catch (IOException ex) {
                        Logger.getLogger(UIFrame.class.getName()).log(Level.SEVERE, null, ex);
                    }
                }
            }).start();
        }

        @Override
        public void buttonReleased(String arg0) {
        }

        @Override
        public void chartMouseClicked(ChartMouseEvent cme) {
            new Thread(new Runnable() {
                @Override
                public void run() {
                    String nodeID = cme.getEntity().toString();
                    resetGetterSequence();
                    if (nodeID != null && !"PlotEntity: tooltip = null".equals(nodeID)) {
                        txtGTermInfo.setText("");
                        prgChart.setIndeterminate(true);
                        nodeID = nodeID.substring(nodeID.indexOf("columnKey=") + 10,
                                nodeID.indexOf("columnKey=") + 20);
                        showNameAndID(nodeID);
                        getInfoSequence.getProcess(0).addParameter("id", nodeID);
                        try {
                            getInfoSequence.start();
                        } catch (IOException ex) {
                            Logger.getLogger(UIFrame.class.getName()).log(Level.SEVERE, null, ex);
                        }
                    }
                }
            }).start();
        }

        @Override
        public void chartMouseMoved(ChartMouseEvent cme) {
        }
    }

    private class WebManipulator implements KeyListener, MouseWheelListener {
        private boolean frozenFlag = false;
        private final Viewer v;
        private double scrollAmount = 0;

        WebManipulator(Viewer av) {
            v = av;
        }

        @Override
        public void keyTyped(KeyEvent e) {
        }

        @Override
        public void keyPressed(KeyEvent e) {
            if (e.getKeyChar() == 'f') {
                if (!frozenFlag)
                    v.disableAutoLayout();
                else
                    v.enableAutoLayout();
                frozenFlag = !frozenFlag;
            } else if (e.getKeyChar() == 'r') {
                v.getDefaultView().getCamera().resetView();
            }
        }

        @Override
        public void keyReleased(KeyEvent e) {
        }

        @Override
        public void mouseWheelMoved(MouseWheelEvent e) {
        }
    }
}