tools
Class Tools

java.lang.Object
  extended by tools.Tools

public class Tools
extends Object

Contains helper methods used throughout the whole library.

This class is not instantiatable.

Author:
Jan Krumsiek

Field Summary
static String CLUSTERERSFILE
           
static String CONFIGFILE
           
static String CONFIGPATH
           
static Map<String,Object> EMPTY_ANNOTATION_MAP
          An empty, immutable map of annotations, i.e. a String => Object map
static Map<String,String> EMPTY_STRING_MAP
          An empty, immutable String => String map
static String FULL_LIB_NAME
          Full program string assembled from libary name and version
static String LIBRARY_NAME
          Name of this library
static int MINOVERLAP
          Default minimum overlap required for two complexes to be mapped to each other
static Random random
          Globally used random number generator, uses a Mersenne twister
static String VERSION
          Current version of this library
 
Method Summary
static String extractBaseFilename(String fullPath)
          Extract the base file name (without extension) from a full path
static String extractFilename(String fullPath)
          Extracts the file name from a full path
static int findMax(Collection<Integer> col)
          Returns the maximum of a given integer collection.
static org.jfree.chart.JFreeChart generateHistogram(String title, double[] data, boolean relative, int bins)
          Generates a histogram chart from a given dataset.
static String getTempFilename()
          Returns an unused temporary file name.
static boolean isGZIPed(String file)
          Determines whether a file contains a GZIP header
static Comparable max(Comparable first, Comparable second)
          Returns the maximum of two Comparable objects
static Comparable min(Comparable first, Comparable second)
          Returns the minimum of two Comparable objects
static Map<String,Object> parseAnnotations(String parse)
          Parse annotations from a string coming from a network or annotations file.
static void verifyAnnotationType(Object value)
          Checks whether a given object is an Integer, a Float or a List.
static void writeAnnotations(Map<String,Object> annotations, PrintWriter writer)
          Writes a given annotations set to a writer.
static void writeChartToPNG(org.jfree.chart.JFreeChart chart, File output, int width, int height)
          Writes a given JFreeChart to a PNG file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MINOVERLAP

public static final int MINOVERLAP
Default minimum overlap required for two complexes to be mapped to each other

See Also:
Constant Field Values

random

public static Random random
Globally used random number generator, uses a Mersenne twister


EMPTY_ANNOTATION_MAP

public static final Map<String,Object> EMPTY_ANNOTATION_MAP
An empty, immutable map of annotations, i.e. a String => Object map


EMPTY_STRING_MAP

public static final Map<String,String> EMPTY_STRING_MAP
An empty, immutable String => String map


LIBRARY_NAME

public static final String LIBRARY_NAME
Name of this library

See Also:
Constant Field Values

VERSION

public static final String VERSION
Current version of this library

See Also:
Constant Field Values

FULL_LIB_NAME

public static final String FULL_LIB_NAME
Full program string assembled from libary name and version

See Also:
Constant Field Values

CONFIGPATH

public static final String CONFIGPATH

CONFIGFILE

public static final String CONFIGFILE

CLUSTERERSFILE

public static final String CLUSTERERSFILE
Method Detail

extractFilename

public static String extractFilename(String fullPath)
Extracts the file name from a full path

Parameters:
fullPath - full path
Returns:
file name

extractBaseFilename

public static String extractBaseFilename(String fullPath)
Extract the base file name (without extension) from a full path

Parameters:
fullPath - full path
Returns:
base file name

min

public static Comparable min(Comparable first,
                             Comparable second)
Returns the minimum of two Comparable objects

Parameters:
first - first object
second - second object
Returns:
smaller object according to their natural ordering

max

public static Comparable max(Comparable first,
                             Comparable second)
Returns the maximum of two Comparable objects

Parameters:
first - first object
second - second object
Returns:
larger object according to their natural ordering

findMax

public static int findMax(Collection<Integer> col)
Returns the maximum of a given integer collection.

Parameters:
col - integer collection
Returns:
maximum value of the given collection

getTempFilename

public static String getTempFilename()
Returns an unused temporary file name.

Returns:
path to temporary file

isGZIPed

public static boolean isGZIPed(String file)
Determines whether a file contains a GZIP header

Parameters:
file - path to file
Returns:
if the file is GZIPed

verifyAnnotationType

public static void verifyAnnotationType(Object value)
                                 throws ProCopeException
Checks whether a given object is an Integer, a Float or a List. Throws an exception if not.

Parameters:
value - object whose type will be checked
Throws:
ProCopeException - if the object is not an Integer, Float or List

generateHistogram

public static org.jfree.chart.JFreeChart generateHistogram(String title,
                                                           double[] data,
                                                           boolean relative,
                                                           int bins)
Generates a histogram chart from a given dataset.

Parameters:
data - dataset from which the histogram will be calculated
relative - show relative frequencies?
bins - number of bins
Returns:
the histogram chart

writeChartToPNG

public static void writeChartToPNG(org.jfree.chart.JFreeChart chart,
                                   File output,
                                   int width,
                                   int height)
                            throws IOException
Writes a given JFreeChart to a PNG file.

Parameters:
chart - the chart to be plotte
output - output file
width - width of the image
height - height of the image
Throws:
IOException - if the file could not be written
See Also:
generateHistogram(String, double[], boolean, int), ROCCurveHandler.generateChart(java.util.List, java.util.List)

writeAnnotations

public static void writeAnnotations(Map<String,Object> annotations,
                                    PrintWriter writer)
Writes a given annotations set to a writer.

Parameters:
annotations - annotations to be written
writer - the writer

parseAnnotations

public static Map<String,Object> parseAnnotations(String parse)
Parse annotations from a string coming from a network or annotations file.

Parameters:
parse - string to be parsed
Returns:
annotations parsed from that string