sem.util
Class Tools

java.lang.Object
  extended by sem.util.Tools

public class Tools
extends java.lang.Object

Collection of small useful functions.


Constructor Summary
Tools()
           
 
Method Summary
static
<T> java.util.HashMap<T,java.lang.Double>
_convert_to_ranks(java.util.HashMap<T,java.lang.Double> v)
           
static double gaussianPdf(double x)
          Calculate the value based on the Gaussian probability density function.
static double gaussianPdf(double x, double mean, double stddev)
          Calculate the value based on the Gaussian probability density function.
static double getDouble(java.lang.String text, double def)
          Get the double from text.
static java.util.ArrayList<java.lang.String> getFileList(java.lang.String dir)
          Get the list of files in a directory.
static int getInt(java.lang.String text, int def)
          Get the integer from text.
static boolean isBrack(java.lang.String string)
          Check whether the string is a bracket.
static boolean isEndBrack(java.lang.String string)
          Check whether the string is an ending bracket.
static boolean isFirstLetterCapitalized(java.lang.String string)
           
static boolean isInt(java.lang.String string)
          Check whether the string is an integer.
static boolean isStartBrack(java.lang.String string)
          Check whether the string is a starting bracket.
static java.lang.String join(java.util.List<java.lang.String> pieces, java.lang.String delimiter)
          Join a string using the delimiter.
static java.lang.String join(java.lang.String[] pieces, java.lang.String delimiter)
          Join a string using the delimiter.
static java.lang.Object load(java.lang.String file)
          Load the serialised object from a file.
static
<T> double
pearson(java.util.HashMap<T,java.lang.Double> v1, java.util.HashMap<T,java.lang.Double> v2)
          Calculate Pearson's correlation coefficient.
static void runCommand(java.lang.String command)
          Run a system command.
static void save(java.lang.Object obj, java.lang.String file)
          Serialise the object into a file.
static
<T> java.util.LinkedHashMap<T,java.lang.Double>
sort(java.util.HashMap<T,java.lang.Double> v, boolean desc)
          Sort a hashmap based on the values (descenging or ascending).
static
<T> double
spearman(java.util.HashMap<T,java.lang.Double> v1, java.util.HashMap<T,java.lang.Double> v2)
          Calculate Spearman's correlation coefficient.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Tools

public Tools()
Method Detail

runCommand

public static void runCommand(java.lang.String command)
Run a system command.

Parameters:
command -

isInt

public static boolean isInt(java.lang.String string)
Check whether the string is an integer.

Parameters:
string -
Returns:

isBrack

public static boolean isBrack(java.lang.String string)
Check whether the string is a bracket.

Parameters:
string -
Returns:

isEndBrack

public static boolean isEndBrack(java.lang.String string)
Check whether the string is an ending bracket.

Parameters:
string -
Returns:

isStartBrack

public static boolean isStartBrack(java.lang.String string)
Check whether the string is a starting bracket.

Parameters:
string -
Returns:

gaussianPdf

public static double gaussianPdf(double x)
Calculate the value based on the Gaussian probability density function.

Parameters:
x -
Returns:

gaussianPdf

public static double gaussianPdf(double x,
                                 double mean,
                                 double stddev)
Calculate the value based on the Gaussian probability density function.

Parameters:
x -
Returns:

isFirstLetterCapitalized

public static boolean isFirstLetterCapitalized(java.lang.String string)

getInt

public static int getInt(java.lang.String text,
                         int def)
Get the integer from text. If not an integer, return the default value.

Parameters:
text -
def -
Returns:

getDouble

public static double getDouble(java.lang.String text,
                               double def)
Get the double from text. If not a double, return the default value.

Parameters:
text -
def -
Returns:

getFileList

public static java.util.ArrayList<java.lang.String> getFileList(java.lang.String dir)
Get the list of files in a directory.

Parameters:
dir -
Returns:

save

public static void save(java.lang.Object obj,
                        java.lang.String file)
Serialise the object into a file.

Parameters:
obj -
file -

load

public static java.lang.Object load(java.lang.String file)
Load the serialised object from a file.

Parameters:
file -
Returns:

pearson

public static <T> double pearson(java.util.HashMap<T,java.lang.Double> v1,
                                 java.util.HashMap<T,java.lang.Double> v2)
Calculate Pearson's correlation coefficient.

Parameters:
v1 -
v2 -
Returns:

sort

public static <T> java.util.LinkedHashMap<T,java.lang.Double> sort(java.util.HashMap<T,java.lang.Double> v,
                                                                   boolean desc)
Sort a hashmap based on the values (descenging or ascending).

Parameters:
v -
desc -
Returns:

_convert_to_ranks

public static <T> java.util.HashMap<T,java.lang.Double> _convert_to_ranks(java.util.HashMap<T,java.lang.Double> v)

spearman

public static <T> double spearman(java.util.HashMap<T,java.lang.Double> v1,
                                  java.util.HashMap<T,java.lang.Double> v2)
Calculate Spearman's correlation coefficient.

Parameters:
v1 -
v2 -
Returns:

join

public static java.lang.String join(java.lang.String[] pieces,
                                    java.lang.String delimiter)
Join a string using the delimiter.

Parameters:
pieces -
delimiter -
Returns:

join

public static java.lang.String join(java.util.List<java.lang.String> pieces,
                                    java.lang.String delimiter)
Join a string using the delimiter.

Parameters:
pieces -
delimiter -
Returns: