public class WebDriver extends BeamDriver
BeamDriver
designed for use by a web front end.
Each WebDriver is associated with a user. Static methods are supplied to check if a particular user has any running processes, to kill all of a user's running processes, and to write statistics about a user to a log file.
WebDriver.run()
executes super.runBeamPlus()
in a child process by using a
WebDriverJr
. Using a child process allows us to specify the max amount of memory used so that we aren't hindered by memory
constraints imposed by the server.
Unlike BeamDriver.run(), WebDriver.run() doesn't output anything to file-- instead, results are saved to a hashtable as arrays of motifs
which can be accessed with getResults(String)
. These results are alse sent to the user in an email (if an email address has been
supplied to the constructor).
WebDrivers also supply some peripheral functionality useful to the web front end. An html-formatted pwm for a motif can be generated
using getPWMFor(Motif)
, Detailed information about the locations in the group of a motif can be accessed by calling
getMotifInstances(Motif)
. Constants are also defined to specify light and dark colors for web pages.
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
DARK_COLOR
Dark color for web pages.
|
protected java.lang.String |
emailAddress |
protected java.lang.String[] |
geneNameKey
Contains the gene names in the order that they are listed in groupMF.
|
protected java.lang.String |
group |
protected MotifFinder |
groupMF |
static java.lang.String |
LIGHT_COLOR
Light color for web pages.
|
protected static java.lang.String |
LOG_DIR
Directory for storing various log files.
|
(package private) static org.apache.log4j.Logger |
logger |
protected java.util.Hashtable<Motif,MotifInstance[]> |
motifStatsCache
Used to cache a MotifInstance[] for each motif in results.
|
protected java.util.Hashtable<java.lang.String,Motif[]> |
results
Contains arrays of the motifs found for each stage of beam+.
|
protected static java.util.Hashtable<java.lang.String,java.util.Vector<java.lang.Process>> |
runningProcesses
For storing mappings of userID's to Vectors of their running processes.
|
protected java.lang.String |
userID |
AMBIGUIZER_NAME, BEAM_NAME, BIPARTITE_NAME, bpScorer, error, fileRoot, knownMotifs, MERGED_NAME, properties, scorer, subtestID, testID, verboseSave
Constructor and Description |
---|
WebDriver(java.lang.String userID,
java.lang.String emailAddress,
UberProperties properties,
java.lang.String group)
Calls
super(String) and sets up member variables, along with making sure that there is an entry
in runningProcesses for userID. |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
encodeQueryString(java.lang.String s)
Encodes a String to make it safe to send to the ServerSocketImageWriter by replacing special strings.
|
java.lang.String |
getGeneNamesQuery()
Returns a query string of the names and lengths of each gene.
|
MotifInstance[] |
getMotifInstances(Motif m)
Returns an array of
MotifInstances that represent the locations in the group of the given motif. |
java.lang.String |
getMotifInstancesQuery(Motif m)
Generates a the motif location part of the query string that gets sent as a URL to ServerSocketImageWriter, wherever that may be.
|
java.lang.String |
getPWMFor(Motif m)
Returns an HTML-formatted position-weight matrix for the given motif.
|
java.lang.String |
getQueryColor()
Reformats LIGHT_COLOR so it can fit in a query string.
|
Motif[] |
getResults(java.lang.String stepName)
Returns the results of the given stage of the run, or null if the given stage was not run; stepName should be set to
BeamDriver.BEAM_NAME, BeamDriver.AMBIGUIZER_NAME, BeamDriver.BIPARTITE_NAME, or BeamDriver.MERGED_NAME.
|
static boolean |
hasRunningProcesses(java.lang.String userID)
Returns true if this user has processes running.
|
boolean |
isDone()
Returns true if the run finished successfully; throws an exception if the run crashed.
|
static void |
killRunningProcesses(java.lang.String userID)
Kills all of this user's processes running.
|
static void |
logUser(java.lang.String ipAddress,
java.lang.String hostName,
java.lang.String emailAddress,
java.lang.String organism)
Write's information about a user to a log file named after the current year found in
LOG_DIR . |
void |
run()
Executes
BeamDriver.runBeamPlus() in a child process by using a WebDriverJr , and sends the results to the user in an
email. |
static void |
sendEmail(java.lang.String recipient,
java.lang.String subject,
java.lang.String message,
java.lang.String filename)
Sends an email to recipient using
scope/email/email.sh . |
getScorer, printBestMotif, refineBipartite, runAmbiguizerEtc, runBeamEtc, runBeamPlus, runBipartitesEtc, runFilterEtc, runMergeEtc, saveFilterResults, saveProperties, saveResults, saveSpecialStats, setFastaMotifFinder, setMostParams, setVerboseSave
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
public static final java.lang.String DARK_COLOR
public static final java.lang.String LIGHT_COLOR
protected static final java.lang.String LOG_DIR
static org.apache.log4j.Logger logger
protected static final java.util.Hashtable<java.lang.String,java.util.Vector<java.lang.Process>> runningProcesses
protected java.lang.String emailAddress
protected java.lang.String[] geneNameKey
protected java.lang.String group
protected MotifFinder groupMF
protected java.util.Hashtable<Motif,MotifInstance[]> motifStatsCache
protected java.util.Hashtable<java.lang.String,Motif[]> results
protected java.lang.String userID
public WebDriver(java.lang.String userID, java.lang.String emailAddress, UberProperties properties, java.lang.String group) throws java.io.IOException, UnknownGeneException
super(String)
and sets up member variables, along with making sure that there is an entry
in runningProcesses
for userID. When run() finishes running SCOPE, the results are sent to emailAddress, unless it is the
empty string or null.group
- should be a semi-colon- or whitespace-separated list of gene names.java.io.IOException
UnknownGeneException
public static java.lang.String encodeQueryString(java.lang.String s)
public static boolean hasRunningProcesses(java.lang.String userID)
public static void killRunningProcesses(java.lang.String userID)
public static void logUser(java.lang.String ipAddress, java.lang.String hostName, java.lang.String emailAddress, java.lang.String organism) throws java.io.IOException
LOG_DIR
.java.io.IOException
public static void sendEmail(java.lang.String recipient, java.lang.String subject, java.lang.String message, java.lang.String filename) throws java.lang.Exception
scope/email/email.sh
.java.lang.Exception
public java.lang.String getGeneNamesQuery()
public MotifInstance[] getMotifInstances(Motif m)
MotifInstances
that represent the locations in the group of the given motif. Uses a cache to
speed up multiple lookups of the same motif by a user.public java.lang.String getMotifInstancesQuery(Motif m)
public java.lang.String getPWMFor(Motif m)
public java.lang.String getQueryColor()
public Motif[] getResults(java.lang.String stepName)
public boolean isDone()
public void run()
BeamDriver.runBeamPlus()
in a child process by using a WebDriverJr
, and sends the results to the user in an
email.run
in interface java.lang.Runnable
run
in class BeamDriver