nct.networkblast
Class CompatColorCodingPathSearch<NodeType extends java.lang.Comparable<? super NodeType>>

java.lang.Object
  extended by nct.networkblast.CompatColorCodingPathSearch<NodeType>
All Implemented Interfaces:
SearchGraph<NodeType,java.lang.Double>

public class CompatColorCodingPathSearch<NodeType extends java.lang.Comparable<? super NodeType>>
extends java.lang.Object
implements SearchGraph<NodeType,java.lang.Double>

This class implements a color coding algorithm to search for pathways of size n in a given graph using a scoring object. See: Scott, et al., 2005, Efficient Algorithms for Detecting Signaling Pathways in Protein Interaction Networks, Lecture Notes in Computer Science, vol. 3500.


Field Summary
static double DEFAULT_EPSILON
          The default epsilon value.
static int NUM_PATHS_PER_NODE
           
 
Constructor Summary
CompatColorCodingPathSearch(int size)
           
CompatColorCodingPathSearch(int size, int numSols)
           
CompatColorCodingPathSearch(int size, int numSols, double epsilon)
           
 
Method Summary
protected  boolean checkConstraint(int count)
          Checks if a given path contains at least one of the nodes in the constraint set.
protected  boolean consistentSegmentation(NodeType node, int colorCombination)
          Checks that the node is consistent with the segement indicated by the color combination (ie the number of bits).
 java.util.List<Graph<NodeType,java.lang.Double>> searchGraph(Graph<NodeType,java.lang.Double> graph, ScoreModel<NodeType,java.lang.Double> scoreObj)
          This function searches for pathways in the given graph of size pathSize using scoreObj and the color coding algorithm described by Scott, et al, 2005, Efficient Algorithms for Detecting Signaling Pathways in Protein Interaction Networks, Lecture Notes in Computer Science, vol 3500.
 void setBeginNodes(java.util.Set<NodeType> beginSet)
          This methods defines a set of nodes from which one must BEGIN every path.
 void setConstraint(java.util.Set<NodeType> constraintSet, int minNodes, int maxNodes)
          Sets a constraint on a path such that the path must contain a node (or nodes) in the specified constraint set.
 void setEndNodes(java.util.Set<NodeType> endSet)
          This methods defines a set of nodes from which one must END every path.
 void setSegments(java.util.Map<NodeType,java.lang.Integer> maxSegmentMap, java.util.Map<NodeType,java.lang.Integer> minSegmentMap)
          Sets the segments used for producing ordered paths.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_EPSILON

public static double DEFAULT_EPSILON
The default epsilon value. Epsilon is probability that we will miss a best path if we iterate the correct number of times.


NUM_PATHS_PER_NODE

public static int NUM_PATHS_PER_NODE
Constructor Detail

CompatColorCodingPathSearch

public CompatColorCodingPathSearch(int size)
Parameters:
size - the integer size of paths to search for

CompatColorCodingPathSearch

public CompatColorCodingPathSearch(int size,
                                   int numSols)
Parameters:
size - The lengths of the paths to search for.
numSols - The maximum number of solution paths PER NODE to return.

CompatColorCodingPathSearch

public CompatColorCodingPathSearch(int size,
                                   int numSols,
                                   double epsilon)
Parameters:
size - The lengths of the paths to search for.
numSols - The maximum number of solution paths PER NODE to return.
epsilon - The probability that we won't find a best path. The lower the probability, the longer this algorithm takes, however the length increases logarithmically, so .01 isn't orders of magnitude faster than .0000001. SECRET FEATURE: If the value of epsilon is greater than 1, then we'll instead use that (integer) number as the number of iterations for the algorithm instead of rigorously calculating the number of iterations. This is an easy way of speeding up this search. Since the majority of of best paths are found in the first several iterations, this is a simple heuristic. Remember: you WILL miss best paths using this technique. Any value X where 1 < X < 20 will emit a warning indicating that the number of iterations you have selected is too small (although the algorithm will still run). In summary, if you've got the time, be rigorous and use a small epsilon (e.g. .00001), if not, then use a reasonable number of iterations (e.g. 20).
Method Detail

setConstraint

public void setConstraint(java.util.Set<NodeType> constraintSet,
                          int minNodes,
                          int maxNodes)
Sets a constraint on a path such that the path must contain a node (or nodes) in the specified constraint set. The first (smallest) segment begins at 0 and increments by 1 from there. The last segment is the path size - 1.

Parameters:
constraintSet - The set of nodes that constrain the paths.
minNodes - The minimum number of nodes from the constraint set that must exist in the path.
maxNodes - The maximum number of nodes from the constraint set that may exist in the path.

setSegments

public void setSegments(java.util.Map<NodeType,java.lang.Integer> maxSegmentMap,
                        java.util.Map<NodeType,java.lang.Integer> minSegmentMap)
Sets the segments used for producing ordered paths.

Parameters:
maxSegmentMap - A map of nodes to the maximum segment number the node is allowed in.
minSegmentMap - A map of nodes to the minimum segment number the node is allowed in.

setBeginNodes

public void setBeginNodes(java.util.Set<NodeType> beginSet)
This methods defines a set of nodes from which one must BEGIN every path.

Parameters:
beginSet - The set containing the beginning nodes.

setEndNodes

public void setEndNodes(java.util.Set<NodeType> endSet)
This methods defines a set of nodes from which one must END every path.

Parameters:
endSet - The set containing the ending nodes.

searchGraph

public java.util.List<Graph<NodeType,java.lang.Double>> searchGraph(Graph<NodeType,java.lang.Double> graph,
                                                                    ScoreModel<NodeType,java.lang.Double> scoreObj)
This function searches for pathways in the given graph of size pathSize using scoreObj and the color coding algorithm described by Scott, et al, 2005, Efficient Algorithms for Detecting Signaling Pathways in Protein Interaction Networks, Lecture Notes in Computer Science, vol 3500.

Specified by:
searchGraph in interface SearchGraph<NodeType extends java.lang.Comparable<? super NodeType>,java.lang.Double>
Parameters:
graph - the Graph object to search
scoreObj - the scoring object (ie algorithm) to use to determine the the edgeweight between two nodes.
Returns:
a List of Graph objects that represent the found paths, or null if the given arguments are invalid.

checkConstraint

protected boolean checkConstraint(int count)
Checks if a given path contains at least one of the nodes in the constraint set.

Parameters:
count - The number of constrained nodes in the path.
Returns:
Whether or not the path contains enough constrained nodes.

consistentSegmentation

protected boolean consistentSegmentation(NodeType node,
                                         int colorCombination)
Checks that the node is consistent with the segement indicated by the color combination (ie the number of bits).

Parameters:
node - The node used whose segement is to be checked.
colorCombination - The bitmap that defines a color combination and segment.
Returns:
Whether or not the node is in the appropriate segment.