edu.iastate.metnet.metaomgraph.utils
Class Utils

java.lang.Object
  extended by edu.iastate.metnet.metaomgraph.utils.Utils

public class Utils
extends java.lang.Object

Author:
Nick Ransom

Field Summary
static int AFFY25K
           
static int AFFY8K
           
static int LOCUS
           
static int NONE
           
 
Constructor Summary
Utils()
           
 
Method Summary
static java.io.File chooseFileToOpen()
           
static java.io.File chooseFileToOpen(javax.swing.filechooser.FileFilter filter, java.awt.Component parent)
           
static java.io.File chooseFileToSave()
           
static java.io.File chooseFileToSave(javax.swing.filechooser.FileFilter filter, java.lang.String extension, java.awt.Component parent, boolean forceExtension)
          Displays a JFileChooser that lets the user select a destination file.
static java.lang.String clean(java.lang.String cleanMe)
          Strips off spaces and quotes from the ends of a String.
static java.lang.String convertToValidElementName(java.lang.String convertMe)
           
static javax.swing.filechooser.FileFilter createFileFilter(java.lang.String[] extensions, java.lang.String description)
           
static javax.swing.filechooser.FileFilter createFileFilter(java.lang.String extension, java.lang.String description)
           
static java.lang.String getExtension(java.io.File f)
          Determines the extension of a given file.
static java.lang.String getExtension(java.lang.String filename)
           
static java.util.ArrayList<Gene> getGeneInfo(java.lang.String geneList, java.util.ArrayList<java.lang.String> attribs)
          Gets gene info from AtGeneSearch for a given list of genes.
static int getIDType(java.lang.String geneID)
          Determines whether the given String is a Locus ID, Affy8k ID, Affy8k ID, or none of the above.
static java.io.File getLastDir()
          Retrieves the directory last accessed by the user (as set by setLastDir(File).
static java.lang.String[][] getMetNetInfo(java.lang.Object[] ids)
           
static java.lang.String[] getMetNetInfo(java.lang.String searchMe)
           
static java.util.Hashtable<java.lang.String,java.lang.String> getPathwayInfo()
           
static java.lang.String getPathwayInfo(java.lang.String entityID)
           
static java.lang.String getPOName(java.lang.String POTerm)
           
static boolean isGeneID(java.lang.String checkMe)
          Determines if the given String represents a gene ID.
static boolean isIn(int findMe, int[] entries)
           
static int linearSearch(java.lang.Object[] array, java.lang.Object findMe)
          Searches a given array for a given value.
static java.lang.String makeQueryString(java.sql.ResultSet rs, java.lang.String column, java.lang.String name)
          Compiles a String for querying a MySQL database from the results of a previous query.
static java.lang.String makeQueryString(java.lang.String[] values, java.lang.String column)
           
static java.lang.String makeQueryString(java.util.Vector values, java.lang.String column)
           
static java.lang.String[][] newgetMetNetInfo(java.lang.Object[] ids)
           
static void setLastDir(java.io.File newLastDir)
          Sets the directory last accessed by the user.
static void setSearchFieldColors(javax.swing.JTextField field, boolean found)
          Used for setting the colors of a JTextField based on the results of a search.
static void sizeColumnWidthToFit(javax.swing.JTable table)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOCUS

public static final int LOCUS
See Also:
Constant Field Values

AFFY8K

public static final int AFFY8K
See Also:
Constant Field Values

AFFY25K

public static final int AFFY25K
See Also:
Constant Field Values

NONE

public static final int NONE
See Also:
Constant Field Values
Constructor Detail

Utils

public Utils()
Method Detail

isIn

public static boolean isIn(int findMe,
                           int[] entries)

clean

public static java.lang.String clean(java.lang.String cleanMe)
Strips off spaces and quotes from the ends of a String.

Parameters:
cleanMe - The String to clean.
Returns:
The given string with leading/trailing spaces and quotes removed.

getExtension

public static java.lang.String getExtension(java.io.File f)
Determines the extension of a given file. The file's extension is anything after the last period in the filename. Returned extensions are always in lowercase.

Parameters:
f - The file from which to get an extension.
Returns:
the lowercase extension of the given file, or an empty String if the given file is null, or if it has no extension.

getExtension

public static java.lang.String getExtension(java.lang.String filename)

isGeneID

public static boolean isGeneID(java.lang.String checkMe)
Determines if the given String represents a gene ID.

Parameters:
checkMe - The String to check
Returns:
True if checkMe is a gene ID, false otherwise.

getIDType

public static int getIDType(java.lang.String geneID)
Determines whether the given String is a Locus ID, Affy8k ID, Affy8k ID, or none of the above.

Parameters:
geneID - The ID to check
Returns:
Utils.LOCUS, Utils.AFFY8K, Utils.AFFY20K, or Utils.NONE.

makeQueryString

public static java.lang.String makeQueryString(java.sql.ResultSet rs,
                                               java.lang.String column,
                                               java.lang.String name)
                                        throws java.sql.SQLException
Compiles a String for querying a MySQL database from the results of a previous query. String will look like "where (name='column1' or name='column2' or name='column3' ...)"

Parameters:
rs - The ResultSet to use to create this String. After this method runs, rs.isAfterLast() will return true.
column - The column from the ResultSet that has the values to query.
name - The name of the column to use in
Returns:
Throws:
java.sql.SQLException

makeQueryString

public static java.lang.String makeQueryString(java.lang.String[] values,
                                               java.lang.String column)

makeQueryString

public static java.lang.String makeQueryString(java.util.Vector values,
                                               java.lang.String column)

newgetMetNetInfo

public static java.lang.String[][] newgetMetNetInfo(java.lang.Object[] ids)

getMetNetInfo

public static java.lang.String[][] getMetNetInfo(java.lang.Object[] ids)

getMetNetInfo

public static java.lang.String[] getMetNetInfo(java.lang.String searchMe)

getPathwayInfo

public static java.util.Hashtable<java.lang.String,java.lang.String> getPathwayInfo()

getPathwayInfo

public static java.lang.String getPathwayInfo(java.lang.String entityID)

chooseFileToOpen

public static java.io.File chooseFileToOpen()

chooseFileToOpen

public static java.io.File chooseFileToOpen(javax.swing.filechooser.FileFilter filter,
                                            java.awt.Component parent)

chooseFileToSave

public static java.io.File chooseFileToSave(javax.swing.filechooser.FileFilter filter,
                                            java.lang.String extension,
                                            java.awt.Component parent,
                                            boolean forceExtension)
Displays a JFileChooser that lets the user select a destination file.

Parameters:
filter - a filter for the file display. If null, all files will be displayed.
extension - an extension to add to the file name. If null, no extension will be added.
parent - a parent component for the JFileChooser.
forceExtension - if true, the destination file will have the specified extension. If false, the specified extension will only be added if no other extension is specified.
Returns:

getLastDir

public static java.io.File getLastDir()
Retrieves the directory last accessed by the user (as set by setLastDir(File).

Returns:
the last directory the user accessed

setLastDir

public static void setLastDir(java.io.File newLastDir)
Sets the directory last accessed by the user.

Parameters:
lastDir - the last directory the user accessed

chooseFileToSave

public static java.io.File chooseFileToSave()

linearSearch

public static int linearSearch(java.lang.Object[] array,
                               java.lang.Object findMe)
Searches a given array for a given value. The array doesn't need to be sorted in any way.

Parameters:
array - the array to search
findMe - the value to find
Returns:
the index of the value in the array, or -1 if the value isn't found

getPOName

public static java.lang.String getPOName(java.lang.String POTerm)

setSearchFieldColors

public static void setSearchFieldColors(javax.swing.JTextField field,
                                        boolean found)
Used for setting the colors of a JTextField based on the results of a search. If the search was successful (i.e. it found something), or if the search was empty, then the colors are set to black-on-white. If the search was unsuccessful, they're set to white-on-red.

Parameters:
field - the JTextField to color
found - whether or not the search was successful

getGeneInfo

public static java.util.ArrayList<Gene> getGeneInfo(java.lang.String geneList,
                                                    java.util.ArrayList<java.lang.String> attribs)
Gets gene info from AtGeneSearch for a given list of genes. Attributes must be one of Affy25kID, Affy8kID, AfgcID, AracycPathway, Comment, GoBiologicalProcess, GoCellularComponent, GoMolecularFunction, Locusid, MetnetLocation, MetnetPathway, PredictedLocation, UniprotID, or GeneName.

Parameters:
geneList - a semicolon-delimited list of genes
attribs - the attributes to get, or null to get all AtGeneSearch info
Returns:
an ArrayList of edu.iastate.metnet.datamodel.db.Genes

sizeColumnWidthToFit

public static void sizeColumnWidthToFit(javax.swing.JTable table)

createFileFilter

public static javax.swing.filechooser.FileFilter createFileFilter(java.lang.String[] extensions,
                                                                  java.lang.String description)

createFileFilter

public static javax.swing.filechooser.FileFilter createFileFilter(java.lang.String extension,
                                                                  java.lang.String description)

convertToValidElementName

public static java.lang.String convertToValidElementName(java.lang.String convertMe)