/** File: SearchGUI.java */ import java.awt.*; import java.awt.event.*; import java.io.*; import java.util.Hashtable; import java.util.StringTokenizer; import javax.swing.*; import javax.swing.event.*; import O2PlibSS.gui.*; /** * Class SearchGUI is used to create a popup GUI to run the converter. *
 * List of Methods
* =================== * SearchGUI() - Constructor * initGUI() - create the popup GUI * addMenuTree() - create pull down menus in menu bar for the GUI * clearGuiProcessingState() - clear the GUI state * processGuiStateData() - Process data specified by the GUI state * resetGuiState() - reset the GUI state so nothing is specified. * setCancelFlag() - set the Cancel flag value * getCancelFlag() - get the Cancel flag value * setDemoParameters() - set the Search Terms list for demo state. * setUserTermListFromFile() - set user search term-list state from a file. * setGUItoSGstate() - set GUI to instance of SGstate. * getGUItoSGstate() - get additional SGstate variables from GUI. * setEnableSearchParamsButtonsAndMenus() - set Search Params GUI & state * setEnableCancelButtonsAndMenus() - when are able to do processing state * setEnableViewingButtonsAndMenus() - enable view processed HTML files state * positionReportWindow() - position report window on the screen * setShow() - set the show/hide popup status * updateReportStatusLine() - clear text in popup window * clearText() - clear text in popup window * getDBgeneList() - get printable text list of genes in the database. * getEGsampleList() - get printable text list of EG samples in the database. * matchEGsampleBySearchTerms() - test sGSPID if match searchTerms list. * getReportText() - get the text from the Report popup window * setReportText() - update text in popup window * setGUItitle() - update title in popup window * setSaveAsFile() - set SaveAs file default file name * close() - close this popup and reset flags if needed * testAndSetProjDir() - test and set project directory cvt.userDir. * actionPerformed() - Handle menu actions and button clicks * resetInitialGuiProcessingState() - reset search terms & samples GUI state * quit() - closing down the window, get rid of the frame. * updateSearchGUIjarFile() - update SearchGui.jar from URL_HOME web server. * itemStateChanged() - handle item state changed events * viewHTMLfile() - popup browser on guiActiveHTMLfile file. * windowClosing() - closing down the window, get rid of the frame. * * Class SGstate - holds SearchGui GUI data that can be read/write by methods * ------------- * SGstate() - constructor * copyStateFromCvt() - copy the partial state from cvt Globals * copySGstateInstance() - copy from SGstate instance values to this. * cvtSGstateToStr() - convert SGstate vars. to .sgs state string to write to file. * copyGlobalsToSGstate() - copy Globals instance in SGstate variables. * readSGstateFile() - read the SearchGUI State file stateFile * parseHTtoSGstate() - parse .sgs state hashtable to SGstate variables. * writeSGstate() - write SearchGUI state to .sgs SGstate file. * readNameValuesHashTableFromFile() - read hashtable tab-delim name-value pairs * setStateHashtableForGetValue() - set working hash table for next getStateValue calls * getStateStr() - generate tab-delim SGstate string for writing .sgs state. * getStateValue() - get PARAM and use default if not found. *
*

* This code is available at the HTMLtools project on SourceForge at * http://htmltools.sourceforge.net/ * under the "Common Public License Version 1.0" * * http://www.opensource.org/licenses/cpl1.0.php.

*

* It was derived and refactored from the open source * MAExplorer (http://maexplorer.sourceforge.net/), and * Open2Dprot (http://Open2Dprot.sourceforge.net/) Table modules. *

* $Date: 2009/12/16 11:45:56 $ $Revision: 1.42 $ *
* Copyright 2008, 2009 by Peter Lemkin * E-Mail: lemkin@users.sourceforge.net * http://lemkingroup.com/ *
*/ public class SearchGUI extends JFrame implements ItemListener, ActionListener, WindowListener { /* SearchGUI */ public final static long serialVersionUID= 0; /** Home URL for server */ public final static String URL_HOME= "http://jak-stat.nih.gov/"; /** Home URL for DB on server */ public final static String URL_HOME_DB= "***NOT AVAILABLE***"; /** URL for SearchGui.jar if update from the server */ public final static String //URL_JAR_FILE= URL_HOME+"Prospector/jar/SearchGui.jar"; URL_JAR_FILE= "file:///C:/tmp/SearchGui.jar"; /* [DEBUG] */ /* Note all global variables are in Globals.java except the help * messages which are in HelpMsgs.java. */ public HTMLtools cvt; /* Primary GUI for use with InvokeLater */ public SearchGUI sGui; /** SearchGUI state variables that can be saved/imported from .sgs files. */ public SGstate sgs= null; /** string for title of frame */ private String title; /** The name of the program */ private String programName; /** version number of the program */ private String version; /* --------- SearchGUI components ----- */ /** menu bar for the frame */ private MenuBar mbar; /** "File" pull down Menu list */ private Menu fileMenu; /** "View" pull down Menu list */ private Menu viewMenu; /** "List" pull down Menu list */ private Menu listMenu; /** "Help" pull down Menu list */ private Menu helpMenu; /** Menu support functions using Hashtables to track what is active */ private MenuSupport ms; /** Menu checkbox item for Verbose reporting */ private CheckboxMenuItem verboseMCB= null; /** Menu checkbox item for "Report Fold Change of 2 sample subsets" */ private CheckboxMenuItem foldChangeMCB= null; /** Menu checkbox item for * "Only keep genes/probes with |fold-change| >= threshold" * This pops up a dialog to enter the threshold value between 0.0 and * some large number and saves it in sgs.foldChangeThr. The associated flag * is sgs.foldChangeThrFlag. */ private CheckboxMenuItem foldChangeThrMCB= null; /** MenuItem "Restore previously saved search .sgs parameters from file" */ private MenuItem lastRestoreSGstateMI= null; /** MenuItem "Restore previously saved search .sgs parameters from file" */ private MenuItem restoreSGstateMI= null; /** MenuItem "SaveAs current search .sgs parameters to file" */ private MenuItem saveSGstateMI= null; /** MenuItem "Assign EG samples to Class A" */ private MenuItem classAMI= null; /** MenuItem "Assign EG samples to Class A" */ private MenuItem classBMI= null; /** Menu checkbox item for "Show data heat-map in View HTML Results" */ private CheckboxMenuItem showDataHeatmapFlipTableMCB= null; /* showStatusFlag for setVisible(): show (true), hide (false) * set by calling program... */ public boolean showStatusFlag; /** font size */ private int textAreaFontSize= 12; /** Text area font family */ private String textFontFamily= "Helvetica"; /** Optional Big popup text viewer for Report-Log */ public PopupTextViewer bptv= null; /** Text area GUI for main Report-Log. Data is also kept int textReport and * can be saved in reportFile. */ private JTextArea reportTextarea; /** Text area GUI for entering list of search terms */ private JTextArea searchTermTextArea; /* List of Sample groups for search */ private JList samplesList; /** button for "Process" button - may enable/disable button */ public JButton processButton; /** button for "Cancel" button - may enable/disable button */ public JButton cancelButton; /** button for "ViewHTML" button - may enable/disable button */ public JButton viewHTMLButton; /** button for "Reset" converter button */ private JButton resetButton; /** Status line label updated with UtilCM.updateReportStatusLine() */ private JLabel statusLineLabel; /* Optional Expression Group filter by GSP ID substring */ private JTextField filterRowTextField; /** SearchResults filename Prefix text field */ private JTextField searchResultsFilenamePrefixTF; /** Exact match radio button for search-term specification, * button grouped with matchSearchStrTermRB. * Sets sgs.flipTableUseExactMatchFlag. */ private JRadioButton matchGeneTermRB= null; /** Substring match radio button for search-term specification, * button grouped with matchGeneTermRB. * Clears sgs.flipTableUseExactMatchFlag. */ private JRadioButton matchSubStrTermRB= null; /** AND match radio button for EG sample list specification, * button grouped with orEGnamesRB. * Sets sgs.evalSearchANDbooleanFlag. */ private JRadioButton andEGnamesRB= null; /** OR match radio button for EG sample list specification, * button grouped with andEGnamesRB. * Clears sgs.evalSearchANDbooleanFlag. */ private JRadioButton orEGnamesRB= null; /* ------ Report-Log state ----- */ /** Copy of text in Report-Log reportTextarea */ private String textReport= ""; /** Default SAVE AS .txt file for Report-Log textReport data used in * reportTextarea. */ private String reportFile= null; /* ------ Default -search 'Term' switches and GUI search term state. ----- * ------ Read from the ParamsSearchDefault.map file. ----- */ /** Switch supplied search Terms filter prompt for searchTermTextArea * Set by -searchTermsFilterPrompt:{...}. */ private String searchTermsFilterPrompt= null; /* List of search term lists from searchTermTextArea GUI * searchTermFilter[0:nSearchTermNames-1][]. The list is created * from the searchTermTextArea GUI associated * sgs.searchTermFilterStr String; */ private String searchTermFilter[][]= null; /* List of search term names. Set by * '-searchTermNames:{t1,t2,...,tn}'. */ private String searchTermNames[]= null; /* Size of list of search term lists from searchTermTextArea GUI * searchTermFilter[0:nSearchTermNames-1][]. * Set by '-searchTermNames:{t1,t2,...,tn}' */ private int nSearchTermNames= 0; /* -------------- Database Table and Index Map files ------ */ /** Name of database Table file that we will use to verify search terms. * We get this from '-flipTableByIndexMap:{dataSet.txt,dataSet.idx}'. */ public String flipTableDataFile= null; /** Name of Index Map file that we will use to verify search terms. * We get this from '-flipTableByIndexMap:{dataSet.txt,dataSet.idx}'. * This is used to read the ftIM FileTable. */ public String flipTableIndexMapFile= null; /** Index Map FileTable that we will use to verify search terms. * We get this from '-flipTableByIndexMap:{dataSet.txt,dataSet.idx}'. */ public FileTable ftIM= null; /** Header-only Data FileTable that we will use to get the list of * EG Samples.We get this from * '-flipTableByIndexMap:{dataSet.txt,dataSet.idx}'. */ public FileTable ftData= null; /** This is the list of ftData Data Table columns starting with "EG" * and is the list of EG GSP IDs in the database. */ private String dbGSPIDlist[]= null; /** The Index Map file into ftIM has been read successfully * by the ProcessLoadIndexMapData Thread. */ public volatile boolean indexMapReadyFlag= false; /** There has been a problem reading the Index Map file into ftIM * by the ProcessLoadIndexMapData Thread. */ public volatile boolean indexMapProblemFlag= false; /* --------- User supplied GUI samples list ------- */ /** The name of the sample list Table file. It is a 2 column array where * used for the sample Choice GUI where the choice Object value is [][0], * and the viewable choice name is [][1]. * Set by '-searchsearchSampleChoiceFile:{sample choice Table file}'. */ private String searchSampleChoiceFile= null; /** The sample list is a 2 column array where * the Object value is [][0], and the viewable choice * name is [][1]. */ private String sampleChoiceData[][]= null; /* ----- User supplied GUI labels and prompts from switches ----- */ /** Switch supplied search sample groups filter name for * sampleExprGroupsTextArea. Set by -searchRowFilterName:{...}. */ private String searchRowFilterName= null; /** Switch supplied search samples group filter prompt for * sampleExprGroupsTextArea. Set by -searchRowFilterPrompt:{...}. */ private String searchRowFilterPrompt= null; /* ---------- Process Data state ----------- */ /** Thread for converter processing */ public ProcessDataSearch pds= null; /** "Processing" data in the GUI */ public volatile boolean processFlag= false; /** "Process was ok" if true. Set to false if any problems. */ public volatile boolean processedOKflag= false; /** "Done" processing data in the GUI */ public volatile boolean doneFlag= false; /** "Close" the GUI */ public volatile boolean closeGuiFlag= false; /** "Cancel" the processing in the GUI */ public volatile boolean cancelFlag= false; /** GUI FSM state */ public volatile String guiFSMstate= "reset"; /** The subtitle for generated Web page by mapping to the preface * "$$DATA_SOURCE_SUBTITLE$$" */ private String dataSource= ""; /* ---- These are the default parameters used in the param .map * script generator ------ */ /** Param .map default input Dir */ public volatile String inputSearchDir= null; /** Param .map default output Dir */ public volatile String outputSearchDir= null; /** Param .map default table Dir */ public volatile String tableSearchDir= null; /** GUI Converter params map file */ public volatile String guiParamsMapFile= null; /** GUI Converter params map default file path */ public volatile String guiParamsMapDefaultPath= null; /* GUI Converter active HTML file that was selected for viewing. */ public volatile String guiActiveHTMLfile= null; /* GUI Converter active TXT excel compatible file generated. */ public volatile String guiActiveTXTfile= null; /* ----------- ----------- */ /** Command line string created to use when running the converter * used by ProcessDataSearch */ public volatile String sGuiArgV= null; /** Command line string array created to use when running the * converter used by ProcessDataSearch */ public volatile String guiArgV[]= null; /** * SearchGUI() - Constructor * @param cvt is an instance of the CvtTabDelim2HTML class * @param programName name of the program * @param version - of program * @param textReport is initial text string for buffer. * @param title of the window * @param String reportFile is default SAVE AS .txt file. Default * "log.txt" * @param guiParamsMapDefaultFile is default params. map file if not null, * else it uses "paramsSearchDefault.map". */ public SearchGUI(HTMLtools cvt, String programName, String version, String textReport, String title, String reportFile, String paramsMapDefaultFile) { /* SearchGUI */ super("SearchGUI"); /* [1] Setup copies of args */ this.sGui= this; /* may need for InvokeLater method calls */ this.cvt= cvt; this.programName= programName; this.version= version; this.title= title; this.textReport= ((textReport==null) ? "" : textReport); this.reportFile= (reportFile!=null) ? reportFile : programName+"-Report.txt"; this.showStatusFlag= true; /* [1.1] Set up SearchGUI state instance */ sgs= new SGstate(this); /* [1.1.1] Set up SearchGUI state instance */ if(!sgs.copyStateFromCvt(cvt)) UtilCM.logMsg("DRYROT - problem creating SGstate instance.\n"); /* [1.2] Setup defaults used when generate Params .map script */ sgs.showDataHeatmapFlipTableFlag= true; /* Force -showDataHeatmapFlipTables */ closeGuiFlag= false; /* Only set true by "Close" menu or button */ inputSearchDir= "data.search"; outputSearchDir= "data.search"; tableSearchDir= "data.Table"; guiParamsMapFile= "paramSearchFlip.map"; /* use same name & create it each time */ /* [1.3] This will contain the additional search parameters parsed by * getOtherSearchParams(). */ if(paramsMapDefaultFile!=null) guiParamsMapDefaultPath= inputSearchDir + cvt.fileSep + paramsMapDefaultFile; else guiParamsMapDefaultPath= inputSearchDir + cvt.fileSep + "paramsSearchDefault.map"; /* default */ if(!getOtherSearchParams(guiParamsMapDefaultPath)) { closeGuiFlag= false; return; } /* [2] Reset the GUI state flags to initial "Search Params" data state. */ clearGuiProcessingState(); /* clear the GUI state */ /* [3] Create and startup the popup GUI */ initGUI(); } /* SearchGUI */ /** * getOtherSearchParams() - get search information for GUI for prompts and menus * These terms are found in the default search params .map file. The following * must be defined: *

   * E.g.,
   *   -flipTableByIndexMap:{dataSet.txt,dataSet.idx}
   *   -searchTermNames:"Gene,Feature ID"
   *   -searchRowFilterName:"Sample Experiment Groups"
   *   -searchSampleChoiceFile:sampleExperimentGroupsChoices.txt
   *   -searchTermsDemoData:"Stat5a Stat5b 1438470_at 1441476_at 1446085_at"
   *   -searchUserTermList:"LitRefGeneList.txt,Gene,Literature Review"
   *   -searchTermsFilterPrompt:"'Gene' and/or 'Probe' names. E.g., Stat5a, Stat5b, 1449109_at, etc."
   *   -searchRowFilterPrompt:"'Sample Experiment Groups'. E.g., select one or more Experiment Groups"
   *
* @return true if succeed, false if do not find all of the search terms */ public boolean getOtherSearchParams(String paramsSearchDefaultPath) { /* getOtherSearchParams */ /* [1] Read the default parameter file to get additional args */ String psdf= cvt.fio.readFileAsString(paramsSearchDefaultPath); if(psdf==null) { UtilCM.logMsg("Problem with missing search parameters .map default file '"+ paramsSearchDefaultPath+"'\n"); return(false); } /* [2] Convert parameter string to parameter list for parsing */ String sParamsM= UtilCM.mapCRLF2space(psdf), argList[]= UtilCM.cvs2Array(sParamsM," "); for(int i=0;i2) ? sTmpList[2] : "user list"; } else if(sLine.startsWith("-searchTermsDemoData")) { /* "-searchTermsDemoData" */ sgs.searchTermsDemoData= sArg; } else if(sLine.startsWith("-searchRowFilterName")) { /* "-searchRowFilterName" */ searchRowFilterName= sArg; } else if(sLine.startsWith("-searchSampleChoice")) { /* "-searchSampleChoiceFile:{table of data}" */ searchSampleChoiceFile= inputSearchDir+cvt.fileSep+sArg; /* Read the data from the Table */ FileTable ft= new FileTable("Sample Choice Database"); ft.setHasTableHeaderFlag(cvt.hasTableHeaderRowFlag); ft.setRmvTrailingBlankLinesFlag(true); ft.setRmvTrailingEmptyColumnsFlag(true); if(!ft.readAndParseTable(searchSampleChoiceFile)) { /* failed*/ UtilCM.logMsg("Problem reading -searchSampleChoiceFile file '" + searchSampleChoiceFile+"'\n"+ ft.errMsgLog+"\n"); return(false); } else if(ft.tRows==0 || ft.tCols!=2) { /* failed - bad table */ UtilCM.logMsg("Problem -searchSampleChoiceFile file '" + searchSampleChoiceFile+"' - #rows="+ft.tRows+ " or #columns="+ft.tCols+ " in Table NEQ 2 required.\n"); return(false); } sampleChoiceData= ft.tData; /* Save the data */ } /* "-searchSampleChoiceFile:{table of data}" */ else if(sLine.startsWith("-searchTermsFilterPrompt")) { /* "-searchTermsFilterPrompt" */ searchTermsFilterPrompt= sArg; } else if(sLine.startsWith("-searchRowFilterPrompt")) { /* "-searchRowFilterPrompt" */ searchRowFilterPrompt= sArg; } else { UtilCM.logMsg("\nProblem with undefined -search parameters arg '"+ sLine+"'\n"); return(false); } } /* look for lines that start with "-search" */ /* Make sure all args are defined */ if(flipTableDataFile==null || flipTableIndexMapFile==null || searchTermNames==null || searchRowFilterName==null || searchSampleChoiceFile==null || searchTermsFilterPrompt==null || searchRowFilterPrompt==null) { UtilCM.logMsg("\nProblem with undefined -search switches in "+ "parameters .map default file '"+ paramsSearchDefaultPath+"'\n"); return(false); } return(true); } /* getOtherSearchParams */ /** * initGUI() - create the popup GUI * @return true if succeed */ @SuppressWarnings("deprecation") public boolean initGUI() { /* initGUI */ /* [1] Setup the GUI */ mbar= new MenuBar(); this.setMenuBar(mbar); /* activate menu bar even if menus * are not active*/ Font mbarFont= new Font("Helvetica", Font.PLAIN, 12); mbar.setFont(mbarFont); /* make it a larger font */ /* [2] Create pull down menus in menu bar */ addMenuTree(this, mbar); JPanel middlePanel= new JPanel(); middlePanel.setLayout(new GridLayout(6,1)); this.add("Center", middlePanel); //textFontFamily= "Helvetica"; textFontFamily= "Courier"; textAreaFontSize= 12; int nCols= 115; /* [2.1] Add Search term GUI objects including text area for * entering a list of search terms, etc. */ /* [2.1.1] Add Panel to put the searchTermsLabel and panel containing the * radio buttons matchGeneTermRB and matchSubStrTermRB. */ JPanel EPtermLblPanel= new JPanel(); EPtermLblPanel.setLayout(new GridLayout(3,1)); /* [2.1.1.1] Add Top step label for "1." */ String searchTermsDescr= "1. Enter list of "+searchTermsFilterPrompt+":"; JLabel searchTermsLabel= new JLabel(searchTermsDescr); EPtermLblPanel.add(searchTermsLabel); /* [2.1.1.2] Create Panel containing the radio buttons matchGeneTermRB * and matchSubStrTermRB. */ JPanel EPtermRBPanel= new JPanel(); EPtermRBPanel.setLayout(new GridLayout(1,2)); EPtermLblPanel.add(EPtermRBPanel); /* Set radio buttons group to match Gene Names or Match Substrings * of search terms. */ matchGeneTermRB= new JRadioButton("Match list of exact gene/probe names search terms"); matchSubStrTermRB= new JRadioButton("Match list of sub-strings search terms"); matchGeneTermRB.setActionCommand("MatchGeneNameTerms"); matchSubStrTermRB.setActionCommand("MatchSubStrTerms"); matchGeneTermRB.addActionListener(this); matchSubStrTermRB.addActionListener(this); matchGeneTermRB.setSelected(true); matchSubStrTermRB.setSelected(false); final ButtonGroup group1= new ButtonGroup(); group1.add(matchGeneTermRB); group1.add(matchSubStrTermRB); sgs.flipTableUseExactMatchFlag= true; EPtermRBPanel.add(matchGeneTermRB); EPtermRBPanel.add(matchSubStrTermRB); /* [2.1.1.3] Add another row with label & SR filename prefix text field */ JPanel SRPanel= new JPanel(); SRPanel.setLayout(new GridLayout(1,2)); EPtermLblPanel.add(SRPanel); JLabel SRFNlabel= new JLabel( "Change generated Search-Results files prefix (optional)"); SRPanel.add(SRFNlabel); searchResultsFilenamePrefixTF= new JTextField(sgs.searchResultsBaseFile); ActionListener srTFlistener= new ActionListener() { /* ActionListener */ public void actionPerformed(ActionEvent e) { String oldSRFNP= sgs.searchResultsBaseFile, arg= searchResultsFilenamePrefixTF.getText(); if(arg!=null) sgs.searchResultsBaseFile= arg; if(!oldSRFNP.equals(arg)) UtilCM.logMsg("\nChanging the "); else UtilCM.logMsg("\nThe current "); UtilCM.logMsg("generated filenames prefix to '"+ sgs.searchResultsBaseFile+"'.\n"); printSearchResultsFileNames(); /* Print to log */ } }; /* ActionListener */ String srfpTT= "Change the generated Search-Results filenames prefix to "+ "add to '-search' filename."; searchResultsFilenamePrefixTF.setToolTipText(srfpTT); searchResultsFilenamePrefixTF.addActionListener(srTFlistener); SRPanel.add(searchResultsFilenamePrefixTF); /* [2.1.1.4] Add EPtermLblPanel to second slot in middlePanel */ middlePanel.add(EPtermLblPanel); /* [2.1.2] Add the search term input text area */ sgs.searchTermFilterStr= ""; searchTermTextArea= new JTextArea(5,nCols); /* was nCols */ searchTermTextArea.setFont(new Font(textFontFamily,Font.PLAIN,textAreaFontSize)); searchTermTextArea.setEditable(true); searchTermTextArea.setBackground(Color.white); searchTermTextArea.setText(sgs.searchTermFilterStr); searchTermTextArea.setToolTipText("Enter Gene, Well ID or probe (Feature) "+ "ID search terms."); JScrollPane sttaPane= new JScrollPane(searchTermTextArea); middlePanel.add(sttaPane); /* [2.2] Add Sample Choice selector for entering 1 or more search row groups. */ JPanel EPchoicePanel= new JPanel(); EPchoicePanel.setLayout(new GridLayout(4,1)); middlePanel.add(EPchoicePanel); /* [2.2.1] Add instructions label */ String searchRowsStr= "2. Select one or more "+searchRowFilterPrompt+":"; JLabel searchRowLabel= new JLabel(searchRowsStr); EPchoicePanel.add(searchRowLabel); /* [2.2.2] Add EG group filter if not null. */ String filterRowsStr= "Filter further by optional AND/OR search sub-strings in matching "+ "Expression Groups samples (e.g., '.Stat5 .GH', etc.)"; JLabel filterRowLabel= new JLabel(filterRowsStr); EPchoicePanel.add(filterRowLabel); /* Add the search text field */ sgs.filterRowStr= ""; /* optional overide */ filterRowTextField= new JTextField(sgs.filterRowStr); ActionListener frtfListener= new ActionListener() { /* ActionListener */ public void actionPerformed(ActionEvent e) { String arg= filterRowTextField.getText(); if(arg!=null) { sgs.filterRowStr= arg; UtilCM.logMsg("Restricting Expression Groups by '"+arg+ "' filter sub-string for GSP ID names.\n"); } } }; /* ActionListener */ filterRowTextField.setToolTipText( "Filter further by optional AND/OR search sub-strings for "+ "Expression Groups by matching with GSP ID names "+ "(e.g., '.Stat5 .GH', etc.)"); filterRowTextField.addActionListener(frtfListener); /* Set radio buttons group for AND/OR of search terms */ andEGnamesRB= new JRadioButton("AND search terms"); orEGnamesRB= new JRadioButton("OR search terms"); andEGnamesRB.setActionCommand("ANDsearchTerms"); orEGnamesRB.setActionCommand("ORsearchTerms"); andEGnamesRB.addActionListener(this); orEGnamesRB.addActionListener(this); final ButtonGroup group2= new ButtonGroup(); group2.add(andEGnamesRB); group2.add(orEGnamesRB); andEGnamesRB.setSelected(true); orEGnamesRB.setSelected(false); sgs.evalSearchANDbooleanFlag= true; /* Add space before the EG list */ /* Panel to put the filterRowTextField and filterRowAndorEGnamesRB */ JPanel EPsearchStrPanel= new JPanel(); EPsearchStrPanel.setLayout(new GridLayout(1,3)); EPchoicePanel.add(EPsearchStrPanel); EPsearchStrPanel.add(filterRowTextField); EPsearchStrPanel.add(andEGnamesRB); EPsearchStrPanel.add(orEGnamesRB); JLabel spacerLabel2= new JLabel(" "); EPchoicePanel.add(spacerLabel2); /* [2.2.3] Build the samplesList Jlist */ int nSampleChoiceData= sampleChoiceData.length; sgs.nEGSelNames= nSampleChoiceData; sgs.egSelNamesFlag= new boolean[sgs.nEGSelNames]; String scList[]= new String[nSampleChoiceData]; /* setup the List GUI and the samples to use */ for(int i=0;i= threshold", "FoldChangeThr", 0, sgs.foldChangeThrFlag); sgs.foldChangeThr= 0.0F; classAMI.setEnabled(false); classBMI.setEnabled(false); foldChangeThrMCB.setEnabled(false); /* [5] Add "Help" pulldown menu */ ms.makeMenuItem(this,listMenu, "List all genes in database in the Report window", "ListAllGenes",0); ms.makeMenuItem(this,listMenu, "List matching genes in database in the Report window", "ListMatchingGenes",0); listMenu.addSeparator(); /* "__________" */ ms.makeMenuItem(this,listMenu,"List matching EG samples in Report window", "ListMatchingEGsamples",0); ms.makeMenuItem(this,listMenu, "List class A EG samples, if defined, in Report window", "ListClassAsamples",0); ms.makeMenuItem(this,listMenu, "List class B EG samples, if defined, in Report window", "ListClassBsamples",0); /* [6] Add "Help" pulldown menu */ ms.makeMenuItem(this,helpMenu,"Documentation on using Search GUI", "SearchGUIusage",0); ms.makeMenuItem(this,helpMenu,"Jak-Stat.nih.gov Web site", "jakStatWebsite",0); ms.makeMenuItem(this,helpMenu,"Jak-Stat.nih.gov Prospector Web site", "jakStatProspectorWebsite",0); ms.makeMenuItem(this,helpMenu, "Summary", "Summary",0); ms.makeMenuItem(this,helpMenu,"License", "License",0); ms.makeMenuItem(this,helpMenu,"About Jak-Stat Database", "AboutJSDB",0); ms.makeMenuItem(this,helpMenu,"About Software", "AboutSoftware",0); helpMenu.addSeparator(); /* "_______" */ ms.makeMenuItem(this,helpMenu,"Full Converter Reference Manual", "ReferenceManual",0); ms.makeMenuItem(this,helpMenu,"Update SearchGUI program", "UpdateSearchGUI",-1); } /* addMenuTree */ /** * processGuiStateData() - Process data specified by the GUI state. * This is called from the "Process" event-handler for the button * and menu handler. * @return true if succeed, false if any problems after write * err msg to window */ private boolean processGuiStateData() { /* processGuiStateData */ /* [1] Make sure not currently processing */ if(processFlag) { UtilCM.logMsg("\nCan't start a new process until the current "+ "one is finished or canceled.\n"); return(false); } /* [2] Make sure there is a list of search terms to process. Then assign * them to either the searchTermNames[0:nSearchTermNames-1] lists. * Parse the data into searchTermFilter[0:nSearchTermNames-1][] */ String sttaStr= searchTermTextArea.getText(); sgs.searchTermFilterStr= UtilCM.mapCRLF2space(sttaStr); if(sgs.searchTermFilterStr==null || sgs.searchTermFilterStr.length()==0) { /* make sure they specify at least one search term */ UtilCM.logMsg( "\nProblem: you need to define a list of one or more search terms:"); for(int k=0;k 0) { /* restrict the sampleRowFilter[] */ sgs.filterRowStr= arg; UtilCM.logMsg("Restricting Expression Groups by '" + arg + "' filter sub-string for filtering GSP ID names.\n"); } /* restrict the sampleRowFilter[] */ /* [3.1] Make sure there is a list of sample expression groups. */ if(sgs.sampleRowFilter == null || sgs.sampleRowFilter.length == 0) { /* problem with sample expression group list */ UtilCM.logMsg("\nProblem: you need to at least one '" + searchRowFilterName + "'. Set this and try again.\n"); return (false); } } /* Make sure intensity report has some EG samples */ /* [4] Set the "Processing" State. */ this.setEnableCancelButtonsAndMenus("Processing file ..."); /* [5] Build the Param .map processing string. If we can't schedule this * now, we will use it later after ensure pd thread is running. */ sGuiArgV= ""; sGuiArgV= inputSearchDir + cvt.fileSep + guiParamsMapFile; /* [5.1] Create guiParamsMapFile from default params.map file */ if(!createParamsMapFile()) { UtilCM.logMsg("\nProblem creating '"+guiParamsMapFile+".\n"+ "Set this and try again.\n"); return(false); } /* [6] Make it an arg list */ guiArgV= UtilCM.cvs2Array(sGuiArgV, " "); return(true); } /* processGuiStateData */ /** * createParamsMapFile() - Create guiParamsMapFile from default params.map file *
   * Add the following required switches:
   *   -flipOrderHdrColNames:"*LIST*,Stat5a,"
   *   -flipColumnName:"*LIST*,Gene,Stat5a,Stat5b"
   *   -flipColumnName:"*LIST*,Feature ID,1438470_at,1441476_at,1446085_at"
   *   -flipRowFilterNames:\"*LIST*,EG003.1,EG003.2"
   *  
   * Add the following optional switches:
   *   -flipRowGSPIDfilterSubstring:"AND,.stat,.GH"
   *   -flipAclass:"{classAsamples}"  [if sgs.reportFoldChangeFlag]
   *   -flipBclass:"{classBsamples}"  [if sgs.reportFoldChangeFlag]
   *   -flipFCthreshold:{foldChangeThr} [if foldChangeThrFlag && foldChangeThr>0.0F]
   *   -dataPrecisionHTMLtable:{precision of HTML table}
   *   -sortFlipTableByColumnName:{sort column}
   *   -showDataHeatmapFlipTable
   *   -flipUseExactColumnNameMatch:{sgs.flipTableUseExactMatchFlag}
   *   -flipDirectory:"{outputSearchDir}"
   *   -flipSaveOutputFile:"{searchResultsBaseFile}"
   * 
* @return true if created the params .map file */ private boolean createParamsMapFile() { /* createParamsMapFile */ /* [1] Make sure default params .map file exists */ String paramTemplate= cvt.fio.readFileAsString(guiParamsMapDefaultPath); if(paramTemplate==null) { UtilCM.logMsg("\nCan't find file '"+guiParamsMapDefaultPath+".\n"+ "Check the system setup.\n"); return(false); } /* [2] Create filter comma strings if the data exists. */ String searchFilterSW= ""; /* [2.1] Add -flipOrderHdrColNames that is from the list of * searchTermNames[] to searchFilterSW list. */ searchFilterSW += "-flipOrderHdrColNames:\""; for(int k=0;k0) { /* add it to searchFilterSW list */ /* Normalize the string */ sgs.flipRowGSPIDfilters= UtilCM.getCleanArgList(sgs.filterRowStr); searchFilterSW += "-flipRowGSPIDfilters:\""; searchFilterSW += (sgs.evalSearchANDbooleanFlag) ? "AND," : "OR,"; for(int k=0;k0.0F) { /* only write if report fold-change threshold flag set */ searchFilterSW += "#\"Set report Fold Change specify |fold-change threshold|.\"\n"+ "-flipFCthreshold:\""+UtilCM.cvf2s(sgs.foldChangeThr,4)+"\"\n"+ "#\n"; } } /* only write if report fold-change flag set */ /* [2.4] Add -dataPrecisionHTMLtable:{sgs.dataPrecisionHTMLtable}. */ searchFilterSW += "#\n#\"Set the data precision for generated HTML.\"\n"+ "-dataPrecisionHTMLtable:"+sgs.dataPrecisionHTMLtable+"\n"+ "#\n"; /* [2.5] Add -sortFlipTableByColumnName:{sort column} if doing sorting. */ if(sgs.sortFlipTableByColumnName!=null) { /* sort flip table by column name */ if(sgs.reportFoldChangeFlag) { UtilCM.logMsg("\nCan't sort data by header term-name if "+ "reporting fold-change. Not sorting report.\n"); sgs.sortFlipTableByColumnName= null; } searchFilterSW += "#\n#\"Set the flip-table sort by column name.\"\n"+ "-sortFlipTableByColumnName:\""+sgs.sortFlipTableByColumnName+"\"\n"+ "#\n"; } /* sort flip table by column name */ /* [2.6] If the "-showDataHeatmapFlipTable" switch is set, then pass it on. */ if(sgs.showDataHeatmapFlipTableFlag) searchFilterSW += "#\"Generate heat-map data cells in a HTML conversion if .sidx exists.\"\n"+ "-showDataHeatmapFlipTable\n"+ "#\n"; /* [2.7] Set the exact match filter flag. If an exact match, then * match flipColNameFilterData[][] exactly with equalsIgnoreCase(), * otherwise do lower case IndexOf() comparison to pick up substrings. * Set with the -flipUseExactColumnNameMatch:{TRUE | FALSE} switch. */ searchFilterSW += "#\"Generate heat-map data cells in a HTML conversion if .sidx exists.\"\n"+ "-flipUseExactColumnNameMatch:"+ ((sgs.flipTableUseExactMatchFlag) ? "TRUE" : "FALSE")+"\n"+ "#\n"; /* [2.8] Set the Search-Results base output directory It uses the base name from * the database set by "-flipTableByIndexMap:,..." . * Get the new value from JTextField searchResultsOutputDirTF * and set it to searchResultsOutputDir. Print names to Report-Log. */ searchFilterSW += "#\"Specify Search-Results base output directory for .txt and .html files.\"\n"+ "-flipDirectory:\""+ outputSearchDir +"\"\n"+ "#\n"; /* [2.8.1] Set the Search-Results base file name. It uses the base name from * the database set by "-flipTableByIndexMap:,..." . * Get the new value from JTextField searchResultsFilenamePrefixTF * and set it to searchResultsBaseFile. Print names to Report-Log. */ getSearchResultsFilenamePrefix(); printSearchResultsFileNames(); /* Print to log */ searchFilterSW += "#\"Specify Search-Results base file name for .txt and .html files.\"\n"+ "-flipSaveOutputFile:\""+ sgs.searchResultsBaseFile +"\"\n"+ "#"; /* [3] Setup and map keywords in the template, and then map template file */ int nMaps= 0, maxMaps= 100; String toStrList[]= new String[maxMaps]; String keyList[]= new String[maxMaps]; keyList[nMaps]= "$$DATE$$"; toStrList[nMaps++]= cvt.date; keyList[nMaps]= "$$INPUT_DATA$$"; toStrList[nMaps++]= inputSearchDir; keyList[nMaps]= "$$OUTPUT_DATA$$"; toStrList[nMaps++]= outputSearchDir; keyList[nMaps]= "$$TABLE_DATA$$"; toStrList[nMaps++]= tableSearchDir; keyList[nMaps]= "$$SEARCH_FILTERS$$"; toStrList[nMaps++]= searchFilterSW; keyList[nMaps]= "$$DATA_SOURCE_SUBTITLE$$"; toStrList[nMaps++]= dataSource; String pmData= UtilCM.mapAllkeywords(paramTemplate,keyList,toStrList,nMaps); /* [4] Write out the created Param .map file */ String pmPath= inputSearchDir + cvt.fileSep + guiParamsMapFile; if(!cvt.fio.writeStringToFile(pmPath, pmData)) { UtilCM.logMsg("\nCan't write the created param .map file: '"+pmPath+".\n"+ "Check the system setup.\n"); return(false); } return(true); } /* createParamsMapFile */ /** * setDemoParameters() - set the Search Terms list for demo state. * The demo argument to load into the searchTermTextArea GUI * Set by "-searchTermsDemoData:{list of search terms}" * The demo argument to load into the sample list choice GUI * and into sampleRowFilter[] data. Set by * "-searchRowsDemoData:{list of sample groups}" */ public void setDemoParameters() { /* setDemoParameters */ /* [1] Set list of Demo Data terms */ searchTermTextArea.setText(sgs.searchTermsDemoData); UtilCM.logMsg("Setting Demo Search Terms: "+ sgs.searchTermsDemoData+"\n"); /* [2] Set additional title for generated Web page */ dataSource= "Set to user demo list of search terms."; repaint(); } /* setDemoParameters */ /** * setUserSearchTermFileParameters() - set search term list from user file. * The demo argument to load into the searchTermTextArea GUI * Set by "-searchUserTermList:{userListTable,colName,title string}". * The demo argument to load into the sample list choice GUI. */ public void setUserSearchTermFileParameters() { /* setUserSearchTermFileParameters */ /* [1] Get the user search term file FileTable */ String sFile= inputSearchDir + cvt.fileSep + sgs.searchUserTermListFile; /* [2] Read the Table */ FileTable ft= new FileTable("User-Term-List"); ft.setNbrTableHdrLines(1); ft.setHasTableHeaderFlag(true); ft.setRmvTrailingBlankLinesFlag(true); ft.setRmvTrailingEmptyColumnsFlag(true); if(!ft.readAndParseTable(sFile)) { UtilCM.logMsg("Can't find "+sgs.searchUserTermListTitle+ " term-list data file '"+ sgs.searchUserTermListFile+"'\n"); return; } String colData[]= ft.getColumnData(sgs.searchUserTermListColName); if(colData==null) { UtilCM.logMsg("Can't set "+sgs.searchUserTermListTitle+ " term-list data from Table '"+ sgs.searchUserTermListFile+ "' - can't find column name '"+ sgs.searchUserTermListColName+"'\n"); return; } else { /* make a string separated by "" */ sgs.searchUserTermListStr= ""; for(int i=0;i0) { /* make list to select and then select them */ int toSelectList[]= new int[nToSelect]; for(int i=0;i0) { searchTermsStr= searchTermsStr.toLowerCase(); searchTerms= UtilCM.getCleanArgList(searchTermsStr); } int nbr= 0, nSearchTerms= (searchTerms==null) ? 0 : searchTerms.length, tRows= ftIM.tRows, tCols= ftIM.tCols, idxGene= ftIM.lookupFieldIdx("Gene"), idxFeatureID= ftIM.lookupFieldIdx("Feature ID"); StringBuffer sBuf= new StringBuffer(50000); for(int r=0;r0) searchTerms= UtilCM.getCleanArgList(searchTermsStr); int nSearchTerms= (searchTerms==null) ? 0 : searchTerms.length; /* Build list to work from */ int nSamplesInDB= dbGSPIDlist.length, nEGlist= egGroupList.length; String dbGSPIDname, egName, workingEGlist[]= new String[nSamplesInDB]; int nSamples= 0; for(int d=0;d0) searchTerms= UtilCM.getCleanArgList(searchTermsStr); int nSearchTerms= (searchTerms==null) ? 0 : searchTerms.length; /* Build list to work from */ int nSamplesInDB= dbGSPIDlist.length, nEGlist= egGroupList.length; String dbGSPIDname, egName, workingEGlist[]= new String[nSamplesInDB]; int nSamples= 0; for(int d=0;d=1 && !sgs.evalSearchANDbooleanFlag) foundIt= true; /* OR */ return(foundIt); } /* matchEGsampleBySearchTerms */ /** * setReportText() - update text in popup window * @param newText is string to copy into text window */ public void setReportText(String newText) { /* setReportText */ this.textReport= newText; reportTextarea.setText(this.textReport); this.repaint(); } /* setReportText */ /** * setGUItitle() - update title in popup window * @param title is new title. */ public void setGUItitle(String title) { /* setGUItitle */ this.title= title; this.setTitle(title); this.repaint(); } /* setGUItitle */ /** * setSaveAsFile() - set SaveAs file default file name * @param reportFile is new reportFile. */ public void setSaveAsFile(String reportFile) { this.reportFile= reportFile; } /** * close() - close this popup and reset flags if needed */ public void close() { /* close */ /* Save the last GUI GSstate so can recover it if want on startup */ String filePath= outputSearchDir+cvt.fileSep+"lastSearchState.sgs"; boolean ok= saveGUItoGSstateFile(filePath); if(reportFile!=null) { /* flush and kill the output channel */ textReport= reportTextarea.getText(); /* Get the current value */ cvt.fio.writeStringToFile(reportFile, textReport); } /* just exit */ this.setVisible(false); this.showStatusFlag= false; this.dispose(); closeGuiFlag= true; /* This exits the main() loop */ } /* close */ /** * testAndSetProjDir() - test and set project directory cvt.userDir. If valid, * then save it in cvt.userDir. * [TODO] need to [DEBUG] * @param testProjDir project directory * @return projDir if succeed in finding the project directory, else null */ public String testAndSetProjDir(String testProjDir, boolean fatalFlag) { /* testAndSetProjDir */ boolean dirOK= false; String projDir= testProjDir; try { /* try it straight */ File fd= new File(testProjDir); dirOK= fd.isDirectory(); projDir= testProjDir; } catch(Exception e) { dirOK= false; } /* Try putting test dir under userdir */ if(!dirOK) { /* try it inside of userDir */ try { String testProjDir2= cvt.userDir + testProjDir; File fd= new File(testProjDir2); dirOK= fd.isDirectory(); projDir= testProjDir2; } catch(Exception e) { dirOK= false; } } /* try it inside of userDir */ if(fatalFlag & !dirOK) { UtilCM.logMsg("\nProblem finding project directory ["+ testProjDir+" ] - exiting Application."); reportFile= null; /* Don't save it */ close(); } if(projDir!=null && dirOK) projDir= null; return(projDir); } /* testAndSetProjDir */ /** * actionPerformed() - Handle menu actions and button clicks * @param e is action evet */ public void actionPerformed(ActionEvent e) { /* actionPerformed */ /* displayURL("file://c:\\docs\\index.html") */ String filePrefix= "file://"+((cvt.isWinPCflag) ? "\\" : "")+cvt.userDir; String cmd= e.getActionCommand(); if (cmd.equals("SetProjDir")) { /* [TODO] File: SetProjDir */ String dirStr= FileIO.getDirPathByDirBrowser(cvt.userDir, "Select project directory"); /* test if and set project directory or exit */ String oldPrjDir= cvt.userDir; /* [TODO] debug test and set */ dirStr= testAndSetProjDir(dirStr, false); if(dirStr!=null) { UtilCM.logMsg("\nProject directory changed from ["+ oldPrjDir+"] to ["+ dirStr+"].\n"); cvt.userDir= dirStr; } else { UtilCM.logMsg("\nProblem finding project directory ["+ dirStr+"] - not changed from ["+oldPrjDir+"]\n."); return; } } /* File: SetProjDir */ else if (cmd.equals("SetDemoData")) { /* File: SetDemoData */ /* set the Term and Sample lists for demo state. */ setDemoParameters(); return; } /* File: SetDemoData */ else if (cmd.equals("GetUserTermListFile")) { /* File: SetUserTermList */ /* Set the search-term list from a file: either a Table * file with (Genes, Well ID, Feature ID) or just a list of genes * or feature ids. */ setUserTermListFromFile(); return; } /* File: SetUserTermList */ else if (cmd.equals("SaveAsSGstate")) { /* File: "SaveAs current search parameters GUI to .sgs file" */ /* Get the old search parameters from a .map file that we * previously saved. */ PopupFileDialog pfd= new PopupFileDialog(); String filePath= pfd.popupFileDialog(outputSearchDir+cvt.fileSep+ "savedSearchState.sgs", null, "Name of Search State file to SAVE", false); if(filePath==null) return; boolean ok= saveGUItoGSstateFile(filePath); return; } /* File: "SaveAs current search parameters GUI to .sgs file"*/ else if (cmd.equals("RestoreSGstate")) { /* File: "Restore previously saved search GUI from .sgs file" */ /* Get the old search parameters from a .map file that we * previously saved. */ PopupFileDialog pfd= new PopupFileDialog(); String filePath= pfd.popupFileDialog(inputSearchDir+cvt.fileSep+ "savedSearchState.sgs", ".sgs", "Restore GUI from Search State file", true); if(filePath==null) return; boolean ok= restoreGUIfromGSstateFile(filePath); return; } /* File: "Restore previously saved search GUI from .sgs file" */ else if (cmd.equals("RestoreLastSavedSGstate")) { /* File: "Restore last saved search GUI from .sgs file" */ /* Get the last search parameters from a .map file that we * previously saved. */ /* Test if the last .sgs saved file "lastSearchState.sgs" exists */ String filePath= outputSearchDir+cvt.fileSep+"lastSearchState.sgs"; File fd= new File(filePath); if(!fd.exists()) { UtilCM.logMsg("No lastSearchState.sgs file exists - ignoring.\n"); return; } boolean ok= restoreGUIfromGSstateFile(filePath); return; } /* File: "Restore last saved search GUI from .sgs file" */ else if (cmd.equals("ChangeSearchResultsOutputDir")) { /* File: "Change default Search-Results output directory" */ /* Popup Dir browser to set the directory */ PopupFileDialog pdq= new PopupFileDialog(); int idxFileSep= outputSearchDir.indexOf(cvt.fileSep); String fullDir= (idxFileSep==-1) ? cvt.userDir+outputSearchDir : outputSearchDir; String answer= pdq.popupDirectoryDialog(fullDir, "Change default Search-Results directory", false); if(answer!=null) { outputSearchDir= answer; UtilCM.logMsg("Changed the Search-Results output directory to '"+ outputSearchDir+"'\n"); } return; } /* File: "Change Search-Results output directory" */ else if (cmd.equals("ClearReportLog")) { /* File: ClearReport */ this.clearText(); return; } /* File: ClearReport */ else if (cmd.equals("SaveReportLogAs")) { /* File: SaveReportLogAs */ PopupFileDialog pfd= new PopupFileDialog(); String fileStr= pfd.popupFileDialog(reportFile, null,"reportFile", false); if(fileStr==null) return; /* NO-OP */ reportFile= fileStr; textReport= getReportText(); if(cvt.fio.writeStringToFile(reportFile, textReport)) UtilCM.logMsg("\nSaved Report-Log as ["+reportFile+"]\n"); else UtilCM.logMsg("\nProblem saving Report-Log ["+reportFile+ "] - not saved.\n"); return; } /* File: SaveReportLogAs */ else if (cmd.equals("resetConverter")) { /* File: resetConverter */ /* Reset the GUI state so no files specified and set initial Search Params * buttons and menus state. */ resetInitialGuiProcessingState(); /* reset search terms & samples GUI state */ setEnableSearchParamsButtonsAndMenus(); cvt.clearGenHTMLpathList(true); /* Clear list */ UtilCM.logMsg("\nReset the converter. You are ready to do a new search "+ "- enter search terms.\n"); this.repaint(); return; } /* File: resetConverter */ else if (cmd.equals("Close")) { /* File: Close */ close(); } /* File: Close */ else if (cmd.equals("ViewHTML")) { /* (Button): ViewHTML */ String genHTMLpathList[]= cvt.getGenHTMLpathList(); if(genHTMLpathList==null) { UtilCM.logMsg("\nThere were no HTML files that generated.\n"); guiActiveHTMLfile= null; guiActiveTXTfile= null; return; } else { guiActiveHTMLfile= genHTMLpathList[0]; if(guiActiveHTMLfile!=null) guiActiveTXTfile= guiActiveHTMLfile.substring(0, guiActiveHTMLfile.length()-5)+".txt"; } viewHTMLfile(); /* popup browser on guiActiveHTMLfile file. */ } /* (Button): ViewHTML */ else if(cmd.equals("ShowBigTextViewer")) { /* Show "Big Report Text Area" */ if(bptv==null) { String rptStr= reportTextarea.getText(); bptv= new PopupTextViewer("Report-Log", rptStr, 30,115, false); UtilCM.setBigReportTextViewer(bptv); } else { /* make it visible */ bptv.setVisible(true); } } /* Show "Big Report Text Area" */ else if (cmd.equals("SortByColData")) { /* view: SortByColData */ if(sgs.reportFoldChangeFlag) { UtilCM.logMsg("\nCan't sort data by header term-name if "+ "reporting fold-change. Not sorting.\n"); sgs.sortFlipTableByColumnName= null; return; } String defStr= (sgs.sortFlipTableByColumnName==null) ? "" : sgs.sortFlipTableByColumnName, msg= "Specify header data term-name to sort generated table rows."; PopupTextFieldDialog ptfd= new PopupTextFieldDialog(this, msg, defStr); if(!ptfd.okFlag || ptfd.answer==null) { UtilCM.logMsg("\nNo change.\n"); return; } String sAnswer= UtilCM.rmvEnclosingWhitespace(ptfd.answer); sgs.sortFlipTableByColumnName= sAnswer; UtilCM.logMsg("\nSort row data descending by '"+ sgs.sortFlipTableByColumnName+ "' in generated table.\n"); } /* File: SortByColData */ else if (cmd.equals("showDataHeatmapFlipTable")) { /* view: showDataHeatmapFlipTable */ String defPrecisionStr= (""+sgs.dataPrecisionHTMLtable), msg= "Specify precision for numeric data in generated HTML table as -1 (all) or 0 to 5."; PopupTextFieldDialog ptfd= new PopupTextFieldDialog(this, msg, defPrecisionStr); if(!ptfd.okFlag || ptfd.answer==null) { UtilCM.logMsg("\nNo change - using HTML data precision="+ sgs.dataPrecisionHTMLtable+".\n"); return; } int newPrecision= UtilCM.cvs2i(ptfd.answer, -1); newPrecision= Math.max(Math.min(newPrecision,5), -1); sgs.dataPrecisionHTMLtable= newPrecision; UtilCM.logMsg("\nUsing HTML data precision="+sgs.dataPrecisionHTMLtable+".\n"); } /* File: showDataHeatmapFlipTable */ else if (cmd.equals("SetdataPrecisionHTMLtable")) { /* view: SetdataPrecisionHTMLtable */ String defPrecisionStr= (""+sgs.dataPrecisionHTMLtable), msg= "Specify precision for numeric data in generated HTML table as -1 (all) or 0 to 5."; PopupTextFieldDialog ptfd= new PopupTextFieldDialog(this, msg, defPrecisionStr); if(!ptfd.okFlag || ptfd.answer==null) { UtilCM.logMsg("\nNo change - using HTML data precision="+ sgs.dataPrecisionHTMLtable+".\n"); return; } int newPrecision= UtilCM.cvs2i(ptfd.answer, -1); newPrecision= Math.max(Math.min(newPrecision,5), -1); sgs.dataPrecisionHTMLtable= newPrecision; UtilCM.logMsg("\nUsing HTML data precision="+ sgs.dataPrecisionHTMLtable); if(sgs.dataPrecisionHTMLtable<0) UtilCM.logMsg(" using full precision"); UtilCM.logMsg("\n"); } /* view: setdataPrecisionHTMLtable */ else if (cmd.equals("AssignEGsamplesToClassA")) { /* view: Assign EG samples to Class A */ if(!sgs.reportFoldChangeFlag) { UtilCM.logMsg("Command ignored - you must enable "+ "'Report Fold Change of 2 sample subsets' checkbox first.\n"); return; } sgs.filterRowStr= filterRowTextField.getText(); sgs.classAsamples= getEGsamplesString(sgs.filterRowStr,sgs.sampleRowFilter, sgs.evalSearchANDbooleanFlag); UtilCM.logMsg("\nAssigning currently specified EG samples to class A: "+ sgs.classAsamples+"\n"); String sR= getEGsampleList(sgs.filterRowStr,sgs.sampleRowFilter, sgs.evalSearchANDbooleanFlag, "Class A"); UtilCM.logMsg(sR); } /* view: Assign EG samples to Class A */ else if (cmd.equals("AssignEGsamplesToClassB")) { /* view: Assign EG samples to Class B */ if(!sgs.reportFoldChangeFlag) { UtilCM.logMsg("Command ignored - you must enable "+ "'Report Fold Change of 2 sample subsets' checkbox first.\n"); return; } sgs.filterRowStr= filterRowTextField.getText(); sgs.classBsamples= getEGsamplesString(sgs.filterRowStr,sgs.sampleRowFilter, sgs.evalSearchANDbooleanFlag); UtilCM.logMsg("\nAssigning currently specified EG samples to class B: "+ sgs.classBsamples+"\n"); String sR= getEGsampleList(sgs.filterRowStr,sgs.sampleRowFilter, sgs.evalSearchANDbooleanFlag, "Class B"); UtilCM.logMsg(sR); } /* view: Assign EG samples to Class B */ else if (cmd.equals("ListAllGenes")) { /* List: "List all genes in Report window" */ /* get printable text list of genes in the database.*/ if(processFlag) { UtilCM.logMsg("\nCan't list all of the genes until finished reading "+ "the database.\n Waiting ."); int maxCnts= 100; while(processFlag) { UtilCM.sleepMsec(500); UtilCM.logMsg("."); if(maxCnts-- <=0) return; } UtilCM.logMsg("\n"); } String sR= getDBgeneList(null,false); UtilCM.logMsg("\nList of all genes in the database.\n"+sR); } else if (cmd.equals("ListMatchingGenes")) { /* List: "List matching genes in Report window" */ /* get printable text list of genes in the database.*/ sgs.searchTermFilterStr= searchTermTextArea.getText(); sgs.searchTermFilterStr= UtilCM.getCleanSpaceList(sgs.searchTermFilterStr); String sR= getDBgeneList(sgs.searchTermFilterStr, !sgs.flipTableUseExactMatchFlag); UtilCM.logMsg("\nList of matching genes in the database.\n"+sR); } else if (cmd.equals("ListMatchingEGsamples")) { /* List: "List matching EG samples in Report window" */ /* Get printable text list of EG samples in the database. * Also need to use the selected EG groups. */ sgs.filterRowStr= filterRowTextField.getText(); String sR= getEGsampleList(sgs.filterRowStr,sgs.sampleRowFilter, sgs.evalSearchANDbooleanFlag, null); UtilCM.logMsg("\nList of matching EG samples in the database.\n"+sR); } else if (cmd.equals("ListClassAsamples")) { /* List: "List class A EG samples, if defined, in Report window" */ /* Get printable text list of EG samples in the database. */ String sR= getEGclassSampleList(sgs.classAsamples,"A",null); if(sR!=null) UtilCM.logMsg("\nList of class A EG samples in the database.\n"+sR); else UtilCM.logMsg("\nNeed to define class B EG samples first.\n"+sR); } else if (cmd.equals("ListClassBsamples")) { /* List: "List class B EG samples, if defined, in Report window" */ /* Get printable text list of EG samples in the database. */ String sR= getEGclassSampleList(sgs.classBsamples,"B",null); if(sR!=null) UtilCM.logMsg("\nList of class B EG samples in the database.\n"+sR); else UtilCM.logMsg("\nNeed to define class B EG samples first.\n"+sR); } else if (cmd.equals("SearchGUIusage")) { /* Help: SearchGUIusage */ String urlStr= filePrefix+"searchGUIusage.html", windowName= programName + " Search Database GUI Usage"; urlStr= UtilCM.replaceSubstrInString(urlStr,"\\","/"); PopupHTMLbrowser phb= new PopupHTMLbrowser(); String phbErrMsg= phb.popupHTMLbrowser(urlStr, windowName); if(phbErrMsg!=null) UtilCM.logMsg(phbErrMsg); } /* Help: SearchGUIusage */ else if (cmd.equals("jakStatWebsite")) { /* List: "Jak-Stat.nih.gov Web site" */ String urlStr= URL_HOME, windowName= programName + " Trans-NIH Jak-Stat Initiative"; urlStr= UtilCM.replaceSubstrInString(urlStr,"\\","/"); PopupHTMLbrowser phb= new PopupHTMLbrowser(); String phbErrMsg= phb.popupHTMLbrowser(urlStr, windowName); if(phbErrMsg!=null) UtilCM.logMsg(phbErrMsg); } else if (cmd.equals("jakStatProspectorWebsite")) { /* List: "Jak-Stat.nih.gov Prospector Web site" */ String urlStr= URL_HOME_DB, windowName= programName + "Jak-Stat Prospector"; urlStr= UtilCM.replaceSubstrInString(urlStr,"\\","/"); PopupHTMLbrowser phb= new PopupHTMLbrowser(); String phbErrMsg= phb.popupHTMLbrowser(urlStr, windowName); if(phbErrMsg!=null) UtilCM.logMsg(phbErrMsg); } else if (cmd.equals("ReferenceManual")) { /* Help: ReferenceManual */ String urlStr= filePrefix+cvt.referenceManual, windowName= programName + " Reference Manual"; urlStr= UtilCM.replaceSubstrInString(urlStr,"\\","/"); PopupHTMLbrowser phb= new PopupHTMLbrowser(); String phbErrMsg= phb.popupHTMLbrowser(urlStr, windowName); if(phbErrMsg!=null) UtilCM.logMsg(phbErrMsg); } /* Help: ReferenceManual */ else if (cmd.equals("Summary")) { /* Help: Summary */ String msg= "\n-------------------------------------------------------\n"+ "\n"+title+ cvt.programSummary+"\n"+ cvt.openSourceNotice; UtilCM.logMsg(msg); } /* Help: Summary */ else if (cmd.equals("License")) { /* Analyze: License */ String msg= "\n-------------------------------------------------------\n"+ "\n" + cvt.openSourceNotice; UtilCM.logMsg(msg); } /* Analyze: License */ else if (cmd.equals("AboutJSDB")) { /* Help: About Jak-Stat Database*/ String msg= "\n-------------------------------------------------------\n"+ "\n"+title+"\n\n"+ "The microarray data in the database has been generated as part of the\n" + "Group Stat Project ("+URL_HOME_DB+") \n" + "as part of the Trans-NIH JAK-STAT Initiative (http://jak-stat.nih.gov/).\n\n"+ "DATA SHARING AGREEMENT\n"+ "The microarray gene expression profiling experiments that are available\n"+ "in the \"JAK-STAT Prospector\" have been generated by researchers from\n"+ "the National Institutes of Health (NIDDK, NIAMS, NHLBI and NIAID) using\n"+ "Federal funds. The mouse data are freely available to researchers inside\n"+ "and outside the United States to foster their scientific endeavors. This\n"+ "Web site only contains the mouse data. For any Human data mentioned in\n"+ "the GSP Inventory, contact the respective PIs for availability. If information\n" + " from this database is to be included in scientific publications or\n" + "presentations, the National Institutes of Health and the \"JAK-STAT Prospector\"\n" + "(http://jak-stat.nih.gov/) should be acknowledged. If the data are also\n" + "available through GEO, the respective accession number should be acknowledged.\n\n"+ "For more information, contact Dr. Lothar Hennighausen (NIDDK) lotharh@mail.nih.gov\n"; UtilCM.logMsg(msg); } /* Help: About Jak-Stat Database */ else if (cmd.equals("AboutSoftware")) { /* Help: About Softare*/ String msg= "\n-------------------------------------------------------\n"+ "\n"+title+"\n\n"+ cvt.openSourceNotice; UtilCM.logMsg(msg); } /* Help: About Software */ else if (cmd.equals("UpdateSearchGUI")) { /* Help: UpdateSearchGUI */ UtilCM.logMsg("\n**********************************************************************\n"+ "* Updating the SearchGUI program .jar file from the jak-stat.nih.gov "+ "Web site is not available at this time.\n" + "**********************************************************************\n"); updateSearchGUIjarFile(); } /* Help: UpdateSearchGUI */ /* Radio button action commands */ else if (cmd.equals("MatchGeneNameTerms")) { /* "Match gene names" */ sgs.flipTableUseExactMatchFlag= true; UtilCM.logMsg("Use exact 'gene name' matching for search terms.\n"); } else if (cmd.equals("MatchSubStrTerms")) { /* "Match sub-strings" */ sgs.flipTableUseExactMatchFlag= false; UtilCM.logMsg("Use sub-string matching for search terms.\n"); } /* Radio button action commands */ else if (cmd.equals("ANDsearchTerms")) { /* "AND search terms" */ sgs.evalSearchANDbooleanFlag= true; UtilCM.logMsg("Use 'AND' of the search terms.\n"); } else if (cmd.equals("ORsearchTerms")) { /* "OR search terms" */ sgs.evalSearchANDbooleanFlag= false; UtilCM.logMsg("Use 'OR' or the search terms.\n"); } } /* actionPerformed */ /** * printSearchResultsFileNames() - print Search-Results File Names to log. */ private void printSearchResultsFileNames() { /* printSearchResultsFileNames */ String srBaseName= sgs.searchResultsBaseFile+"-search", srOutputDir= cvt.userDir+outputSearchDir; UtilCM.logMsg("\nPressing the Process button will generate a "+ "Search-Results Excel compatible file '"+ srBaseName+".txt'\n"+ "and a HTML file '"+srBaseName+ ".html' in the that is viewable in a Web browser.\n"+ "These files are in the '"+srOutputDir+ "' directory.\n"); } /* printSearchResultsFileNames */ /** * printGuiFSM() - print GuiFSM if printFlag set */ public void printGuiFSM(String preface, boolean printFlag) { /* printGuiFSM */ if(printFlag) UtilCM.logMsg(preface+" "+getGuiFSM()+"\n"); } /* printGuiFSM */ /** * printGuiFSMlf() - print GuiFSM if printFlag set followed by extra line feed */ public void printGuiFSMlf(String preface, boolean printFlag) { /* printGuiFSMlf */ if(printFlag) UtilCM.logMsg(preface+" "+getGuiFSM()+"\n\n"); } /* printGuiFSMlf */ /** * getGuiFSM() - Get the GUI FSM state string. * @return the current state string */ public String getGuiFSM() { /* getGuiFSM */ String sR= "GuiFSM["+guiFSMstate+"] ("; sR += "process:"+((processFlag) ? "T" : "F"); sR += ", processedOK:"+((processedOKflag) ? "T" : "F"); sR += ", done:"+((doneFlag) ? "T" : "F"); sR += ", cancel:"+((cancelFlag) ? "T" : "F"); sR += ", gui.pd("+sGui.pds+")"; if(sGui.pds!=null) sR += ".isAlive():"+sGui.pds.isAlive(); sR += ")"; return(sR); } /* getGuiFSM */ /** * resetInitialGuiProcessingState() - reset the search terms & samples GUI state */ public void resetInitialGuiProcessingState() { /* resetInitialGuiProcessingState */ /* [1] Clear the search term list searchTermTextArea GUI */ searchTermTextArea.setText(""); /* Clear search term from */ sgs.searchTermFilterStr= null; searchTermFilter= new String[nSearchTermNames][]; searchTermFilter[0]= null; searchTermFilter[1]= null; /* [2] Setup the List samplesList to ALL */ sgs.filterRowStr= ""; sgs.sampleRowFilterALLflag= true; int nsampleChoiceData= sampleChoiceData.length; sgs.sampleRowFilter= new String[nsampleChoiceData-1]; /* Default is "ALL" */ for(int i=0;i= threshold" */ sgs.foldChangeThrFlag= itemMCB.getState(); if(sgs.foldChangeThrFlag) { /* Get the fold-change threshold */ String defStr= UtilCM.cvf2s(sgs.foldChangeThr, 4), msg= "Specify Fold-Change Report threshold for '|fold-change| >= threshold'."; PopupTextFieldDialog ptfd= new PopupTextFieldDialog(this, msg, defStr); if(!ptfd.okFlag || ptfd.answer==null) { UtilCM.logMsg("\nNo change to Fold-Change Reporting fold-change threshold: "+ UtilCM.cvf2s(sgs.foldChangeThr,4)+"\n"); return; } float value= UtilCM.cvs2f(ptfd.answer,0.0F); if(value>=0.0F) { /* Change it */ sgs.foldChangeThr= value; UtilCM.logMsg("\nSet the Fold-Change Reporting fold-change threshold: "+ UtilCM.cvf2s(sgs.foldChangeThr,3)+"\n"); return; } UtilCM.logMsg("\nProblem, must specify |fold-change threshold| > or = 0.0.\n"); foldChangeThrMCB.setEnabled(false); sgs.foldChangeThrFlag= false; sgs.foldChangeThr= 0.0F; } /* Get the fold-change threshold */ else { /* Disable All foldchange related variables */ sgs.foldChangeThrFlag= false; sgs.foldChangeThr= 0.0F; } } /* viewMenu: "Only keep genes/probes with |fold-change| >= threshold" */ else if(itemMCB==showDataHeatmapFlipTableMCB) { /* "Show data heat-map in View HTML Results" */ sgs.showDataHeatmapFlipTableFlag= itemMCB.getState(); if(sgs.showDataHeatmapFlipTableFlag) UtilCM.logMsg("\nCreate data heat-map when generate View HTML.\n"); else UtilCM.logMsg("\nDon't create data heat-map when generate View HTML.\n"); } } /* itemStateChanged */ /** * updateSampleList() - handle item state changed events * NOTE: need to implement radio groups here since AWT only * implements radio groups for Checkboxes, and CheckboxMenuItems. * @param e is ItemEvent */ public void updateSampleList(ListSelectionEvent lsEvent) { /* itemStateChanged */ boolean isAdjusting= lsEvent.getValueIsAdjusting(); if(isAdjusting) { /* select the samples Experiment Groups to use in the search */ JList list= (JList)lsEvent.getSource(); int curIdx= list.getSelectedIndex(), selIdx[]= list.getSelectedIndices(); Object listObj[]= list.getSelectedValues(); if(selIdx==null) return; int nSelected= (selIdx==null) ? 0 : selIdx.length, nsampleChoiceData= sampleChoiceData.length; /* full data available in list */ if(curIdx!=0 && curIdx!=-1) { /* selected some samples that are not ALL */ int nSampleRowFilter= nSelected; if(selIdx[0]==0) nSampleRowFilter= nSelected-1; sgs.sampleRowFilter= new String[nSampleRowFilter]; UtilCM.logMsg("Using samples filter:"); int k= 0; for(int i=0;i1) { list.clearSelection(); list.setSelectedIndex(0); /* Clear everything but ALL */ } return; } /* use ALL */ else if(curIdx==-1) { /* Handle case where item was unselected */ UtilCM.logMsg("Using ALL samples filter.\n"); sgs.sampleRowFilter= new String[nsampleChoiceData-1]; /* Default is "ALL" */ for(int i=1;i= threshold". * When it switches to true it pops up the query for foldChangeThr. */ /* -flipFCthreshold:{foldChangeThr} * [if foldChangeThrFlag && foldChangeThr>0.0F] */ public boolean foldChangeThrFlag= false; /** Fold-change threshold value used from the Menu checkbox item * foldChangeThrMCB for * "Only keep genes/probes with |fold-change| >= threshold" * that pops up a dialog to enter the threshold value between 0.0 and * some large number. */ public float foldChangeThr= 0.0F; /* -dataPrecisionHTMLtable:{precision of HTML table} */ public int dataPrecisionHTMLtable= -1; /* -sortFlipTableByColumnName:{sort column} */ public String sortFlipTableByColumnName= null; /* -showDataHeatmapFlipTable */ public boolean showDataHeatmapFlipTableFlag= false; /* -flipUseExactColumnNameMatch:{flipTableUseExactMatchFlag} */ public boolean flipTableUseExactMatchFlag= false; /* -flipDirectory:"{outputSearchDir}" */ public String outputSearchDir= null; /** Default Search-Results base file name if not null or "". * It is used for "-flipSaveOutputFile:{flipSaveOutputFile}" in * the generated param map file. */ public String searchResultsBaseFile= null; /* -------------- GUI demo args ---------------------- */ /** The demo argument to load into the searchTermTextArea GUI * Set by "-searchTermsDemoData:{list of search terms}" * */ public String searchTermsDemoData= null; /* -------- GUI user default search terms args ---------------- */ /* Search terms from user entered data in searchTermTextArea GUI. * Note this could have embedded \r or \n or \r\n, so must map * if save/restore from .sgs file. */ public String searchTermFilterStr= null; /** The file name to use when reading data from a user * term list file Table to load into the the searchTermTextArea GUI. * Set by "-searchUserTermList:{userListTable,colName,title string}" */ public String searchUserTermListFile= null; /** The user column name to use when reading data from a user * term list file Table to load into the the searchTermTextArea GUI. * Set by "-searchUserTermList:{userListTable,colName,title string}" */ public String searchUserTermListColName= null; /** The user title string to use when reading data from a user * term list file Table to load into the the searchTermTextArea GUI. * Set by "-searchUserTermList:{userListTable,colName,title string}" */ public String searchUserTermListTitle= null; /** The user search terms list string to use when reading data from * a user term list file Table to load into the the * searchTermTextArea GUI. * Set by "-searchUserTermList:{userListTable,colName,title string}" */ public String searchUserTermListStr= null; /** Eval the search terms as an AND (if true) else OR (if false). * Set by the andEGnamesRB and orEGnamesRB radio buttons and * action commands. */ public boolean evalSearchANDbooleanFlag= true; /** Optional EG group filter if not null. This is set by the GUI * JTextField filterRowTextField. */ public String filterRowStr= ""; /** Number of EG samples selection Choice List. Used with * boolean egSelNames[] data. */ public int nEGSelNames= 0; /** Number of EG samples selection Choice List. Used with * boolean egSelNames[] data. */ public boolean egSelNamesFlag[]= null; /* List of GSPID filters used with * -flipRowGSPIDfilterSubstring:"AND,.stat,.GH" */ public String flipRowGSPIDfilters[]= null; /* Size of flipRowGSPIDfilters[] List of GSPID filters used with * -flipRowGSPIDfilterSubstring:"AND,.stat,.GH" */ public int nRowGSPIDfilters= 0; /** Currently specified EG samples assigned to class A. * -flipAclass:"{classAsamples}" [if reportFoldChangeFlag] */ public String classAsamples= null; /** Currently specified EG samples assigned to class B. * -flipBclass:"{classBsamples}" [if reportFoldChangeFlag]. */ public String classBsamples= null; /* ------------------------- */ /** * SGstate() - Constructor * @param sGui is an instance of the SearchGUI class */ public SGstate(SearchGUI sGui) { /* SGstate */ this.sGui= sGui; this.cvt= sGui.cvt; } /* SGstate */ /** * copyStateFromCvt() - copy the partial state from cvt Globals * @param cvt instance of CvtTabDelim2HTML * @return true if succeed */ public boolean copyStateFromCvt(HTMLtools cvt) { /* copyStateFromCvt */ /* Save to local variables */ boolean ok= copyGlobalsToSGstate(cvt); return(ok); } /* copyStateFromCvt */ /** * copySGstateInstance() - copy from SGstate instance values to this. * @param sg - instance to copy FROM * @return SGstate string in .sps file format. if succeed. */ public boolean copySGstateInstance(SGstate sg) { /* copySGstateInstance */ if(sg==null) return(false); /* Report Fold-Change data */ this.classAsamples= sg.classAsamples; this.classBsamples= sg.classBsamples; this.reportFoldChangeFlag= sg.reportFoldChangeFlag; this.foldChangeThrFlag= sg.foldChangeThrFlag; this.foldChangeThr= sg.foldChangeThr; /* Search Term data */ this.searchTermFilterStr= sg.searchTermFilterStr; this.flipTableUseExactMatchFlag= sg.flipTableUseExactMatchFlag; /* View menu data */ this.dataPrecisionHTMLtable= sg.dataPrecisionHTMLtable; this.showDataHeatmapFlipTableFlag= sg.showDataHeatmapFlipTableFlag; this.sortFlipTableByColumnName= sg.sortFlipTableByColumnName; /* EG Samples data */ this.nEGSelNames= sg.nEGSelNames; this.egSelNamesFlag= new boolean[sg.nEGSelNames]; for(int i=0;i * This method parses and sets following parameters * if the switch exists from the list: *
     *   -flipOrderHdrColNames:"*LIST*,Stat5a,"
     *   -flipColumnName:"*LIST*,Gene,Stat5a,Stat5b"
     *   -flipColumnName:"*LIST*,Feature ID,1438470_at,1441476_at,1446085_at"
     *   -flipRowFilterNames:\"*LIST*,EG003.1,EG003.2"
     *  
     *   -flipRowGSPIDfilterSubstring:"AND,.stat,.GH"
     *   -flipAclass:"{classAsamples}"  [if reportFoldChangeFlag]
     *   -flipAclass:"{classBsamples}"  [if reportFoldChangeFlag]
     *   -flipFCthreshold:{foldChangeThr} [if foldChangeThrFlag && foldChangeThr>0.0F]
     *   -dataPrecisionHTMLtable:{precision of HTML table}
     *   -sortFlipTableByColumnName:{sort column}
     *   -showDataHeatmapFlipTable
     *   -flipUseExactColumnNameMatch:{glb.flipTableUseExactMatchFlag}
     *   -flipDirectory:"{outputSearchDir}"
     *   -flipSaveOutputFile:"{searchResultsBaseFile}"
     * 
* @param glb Globals instance of parsed data file * @return true if succeed. */ public boolean copyGlobalsToSGstate(Globals glb) { /* copyGlobalsToSGstate */ /* [1] Copy some of the rms. global -flip variables to SearchGUI variables * See createParamsMapFile() for what variables to set. */ /* -flipOrderHdrColNames:"*LIST*,Stat5a," */ flipOrderHdrColList= glb.flipOrderHdrColList; nFlipOrderHdrColList= glb.nFlipOrderHdrColList; /* [2] [TODO] map to: nSearchTermNames, * searchTermNames[0:nSearchTermNames-1] and * searchTermFilter[0:nSearchTermNames-1][nbr of terms if any]. * -flipColumnName:"*LIST*,Gene,Stat5a,Stat5b" * -flipColumnName:"*LIST*,Well ID,123456,123444" * -flipColumnName:"*LIST*,Feature ID,1438470_at,1441476_at,1446085_at" * */ nFlipColumns= glb.nFlipColumns; flipColumnFile= glb.flipColumnFile; flipColumnName= glb.flipColumnName; /* [3] -flipRowFilterNames:\"*LIST*,EG003.1,EG003.2" */ if(glb.flipRowFilterNamesFile!=null && glb.flipRowFilterNamesFile.equals("*LIST*")) { sampleRowFilterALLflag= false; sampleRowFilter= glb.flipRowFilterNames; } /* [4] List of GSPID filters used with * -flipRowGSPIDfilterSubstring:"AND,.stat,.GH" */ nRowGSPIDfilters= (glb.flipRowGSPIDfilters==null) ? 0 : glb.flipRowGSPIDfilters.length; flipRowGSPIDfilters= (nRowGSPIDfilters==0) ? ((String[]) null) : new String[nRowGSPIDfilters]; for(int i=0;i0.0F] */ foldChangeThrFlag= glb.flipFCthrFlag; foldChangeThr= glb.flipFCthreshold; /* [7] -dataPrecisionHTMLtable:{precision of HTML table} */ dataPrecisionHTMLtable= glb.dataPrecisionHTMLtable; /* [8] -sortFlipTableByColumnName:{sort column} */ sortFlipTableByColumnName= glb.sortFlipTableByColumnName; /* [9] -showDataHeatmapFlipTable */ showDataHeatmapFlipTableFlag= glb.showDataHeatmapFlipTableFlag; /* [10] -flipUseExactColumnNameMatch:{glb.flipTableUseExactMatchFlag} */ flipTableUseExactMatchFlag= glb.flipTableUseExactMatchFlag; /* [11] -flipDirectory:"{outputSearchDir}" */ outputSearchDir= glb.flipDirectory; /* [12] -flipSaveOutputFile:"{searchResultsBaseFile}" */ searchResultsBaseFile= glb.flipSaveOutputFile; return(true); } /* copyGlobalsToSGstate */ /** * readSGstateFile() - read the SearchGUI State file stateFile * with a .sgs file extension. * @param stateFile is the name of the Flicker state file * @return true if setup and parsed the .sgs hashtable correctly */ public synchronized boolean readSGstateFile(String stateFile) { /* readSGstateFile */ File fd= new File(stateFile); if(stateFile==null) return(false); if(!stateFile.endsWith(".sgs")) { /* problem - hash file not found */ UtilCM.logMsg("Bad SearchGUI .sgs state file "+ "["+stateFile+"] - file must end with '.sgs'.\n"); return(false); } if(!fd.exists()) { /* problem - hash file not found */ UtilCM.logMsg("Can't find SearchGUI disk .sgs state file "+ "["+stateFile+"] - file not found\n"); return(false); } UtilCM.logMsg("Importing SearchGUI ["+stateFile+"] state file.\n"); Hashtable ht= readNameValuesHashTableFromFile(stateFile,15101); if(ht==null) { /* problem - hash file is corrupted */ UtilCM.logMsg("SearchGui .sgs state file ["+stateFile+"]"+ "is corrupted - ignoring importing old data.\n\n"); return(false); } setStateHashtableForGetValue(ht, nEntries); /* Parse the data in the hash table into state variables */ if(nStateEntries==0) return(false); /* Parse the base .sgs state properties */ if(!parseHTtoSGstate()) return(false); return(true); } /* readSGstateFile */ /** * parseHTtoSGstate() - parse .sgs state hashtable to SGstate variables. * It checks for each of the variables and then sets the corresponding * SGstate variable. * @return set the state variables if succeed and return true. */ public boolean parseHTtoSGstate() { /* parseHTtoSGstate */ /* Parse the data in the hash table into state variables */ if(nStateEntries==0) return(false); /* Report Fold-Change data */ classAsamples= getStateValue("classAsamples",null); classBsamples= getStateValue("classBsamples",null); reportFoldChangeFlag= getStateValue("reportFoldChangeFlag", false); foldChangeThrFlag= getStateValue("foldChangeThrFlag", false); foldChangeThr= getStateValue("foldChangeThr",0.0F); /* Search Term data */ searchTermFilterStr= getStateValue("searchTermFilterStr", ""); flipTableUseExactMatchFlag= getStateValue("flipTableUseExactMatchFlag", true); /* View menu data */ dataPrecisionHTMLtable= getStateValue("dataPrecisionHTMLtable",-1); showDataHeatmapFlipTableFlag= getStateValue("showDataHeatmapFlipTableFlag", false); sortFlipTableByColumnName= getStateValue("sortFlipTableByColumnName",null); /* EG Samples data */ nEGSelNames= getStateValue("nEGSelNames",0); egSelNamesFlag= new boolean[nEGSelNames]; for(int i=0;i