public class MotifFinderFactory
extends java.lang.Object
main
method that saves a motif finder and its bipartite caches to file. The motif creation methods also cache motif finders to file so that
they can be quickly retrieved on subsequent runs. Additionally, motif finders are cached to a hashtable to avoid having to load the same
motif finder from file multiple times during a program run.Modifier and Type | Field and Description |
---|---|
static java.lang.String |
MF_PACKAGE_NAME |
private static java.util.Map<java.lang.String,MotifFinder> |
mfCache |
static java.lang.String |
OBJ_FILE_EXT |
static java.lang.String |
SEQ_FILE_EXT |
Constructor and Description |
---|
MotifFinderFactory() |
Modifier and Type | Method and Description |
---|---|
static MotifFinder |
buildGroupMFFromFile(java.lang.String mfClassName,
java.lang.String seqRoot,
java.lang.String seqID,
int geneLength,
int[] group)
Returns a motif finder with runtime type mfClassName that has discardOverlaps set to false and wildcard optimization turned off.
|
static java.lang.String |
buildGroupSequence(java.lang.String seq,
int geneLength,
int[] group)
Returns a sequence that contains the specified group genes in the order given in the array, which doesn't need to be sorted.
|
static MotifFinder |
buildMF(java.lang.String mfClassName,
java.lang.String seq,
int geneLength,
java.lang.String seqID)
Returns a motif finder with runtime type mfClassName that has discardOverlaps set to false and wildcard optimization turned off.
|
static MotifFinder |
buildMFFromFasta(java.lang.String mfClassName,
Scanner scanner,
java.lang.String seqID)
Makes a motif finder from a fasta file pointed at by filename.
|
static MotifFinder |
buildMFFromFasta(java.lang.String mfClassName,
Scanner scanner,
java.lang.String seqID,
int geneLength) |
static MotifFinder |
buildMFFromFasta(java.lang.String MFClassName,
java.lang.String fastaString,
java.lang.String seqID)
Makes a motif finder from a fasta string.
|
static MotifFinder |
buildMFFromFastaFile(java.lang.String MFClassName,
java.lang.String filename,
java.lang.String seqID)
Makes a motif finder from a fasta file pointed at by filename.
|
static MotifFinder |
buildMFFromFile(java.lang.String mfClassName,
java.lang.String seqRoot,
java.lang.String seqID)
Returns a motif finder with runtime type mfClassName that has discardOverlaps set to false and wildcard optimization turned off.
|
static MotifFinder |
buildMFFromFile(java.lang.String mfClassName,
java.lang.String seqRoot,
java.lang.String seqID,
int geneLength)
Returns a motif finder with runtime type mfClassName that has discardOverlaps set to false and wildcard optimization turned off.
|
static java.lang.String |
buildSequenceFromFile(java.lang.String filePath,
boolean separateLines,
int geneLength,
int[] groupGeneIDs)
Returns a sequence with the contents of filePath.
|
static void |
main(java.lang.String[] args)
Saves a motif finder and its bipartite caches to file so that they can be loaded in quickly in the future.
|
private static void |
persistMF(java.lang.String mfObjFileName,
MotifFinder mf)
Serializes mf and stores it in a file called GlobalParams.objFileRoot() + mfObjFileName.
|
private static MotifFinder |
retrieveMF(java.lang.String mfObjFileName)
Returns a motif finder that has been serialized and stored in a file called GlobalParams.objFileRoot() + mfObjFileName; returns null if
retrieval is unsuccessful.
|
public static final java.lang.String MF_PACKAGE_NAME
private static java.util.Map<java.lang.String,MotifFinder> mfCache
public static final java.lang.String OBJ_FILE_EXT
public static final java.lang.String SEQ_FILE_EXT
public static MotifFinder buildGroupMFFromFile(java.lang.String mfClassName, java.lang.String seqRoot, java.lang.String seqID, int geneLength, int[] group)
buildMFFromFile(java.lang.String, java.lang.String, java.lang.String)
. The SEQ_FILE_EXT is optional.public static java.lang.String buildGroupSequence(java.lang.String seq, int geneLength, int[] group)
seq
- the source sequence from which the group needs to be made.java.lang.IllegalArgumentException
- if geneLength == UNEQUAL_GENE_LENGTHS.public static MotifFinder buildMF(java.lang.String mfClassName, java.lang.String seq, int geneLength, java.lang.String seqID)
public static MotifFinder buildMFFromFasta(java.lang.String mfClassName, Scanner scanner, java.lang.String seqID)
MFClassName
- The class name of the motif finder that is created. If the classname isn't known, a runtime exception is thrown.scanner
- A Scanner that contains a FASTA string, including comments and sequences, delimited by newline or return characters.seqID
- An identifier for the sequence, used for caching purposes.public static MotifFinder buildMFFromFasta(java.lang.String mfClassName, Scanner scanner, java.lang.String seqID, int geneLength)
public static MotifFinder buildMFFromFasta(java.lang.String MFClassName, java.lang.String fastaString, java.lang.String seqID)
MFClassName
- The class name of the motif finder that is created. If the classname isn't known, a runtime exception is thrown.fastaString
- A String containing all the lines of a FASTA file, delimited by newline or return characters. If the contents of the
String aren't in the FASTA format, a runtime exception with the message "not a fasta file" is thrown.seqID
- An identifier for the sequence, used for caching purposes.public static MotifFinder buildMFFromFastaFile(java.lang.String MFClassName, java.lang.String filename, java.lang.String seqID)
MFClassName
- The class name of the motif finder that is created. If the classname isn't known, a runtime exception is thrown.filename
- The name of the FASTA file. If this file doesn't exist, a RuntimeException with the text "Could not find FASTA file" is
thrown. If the contents of the file aren't in the FASTA format, a runtime exception with the message "not a fasta file" is
thrown.seqID
- An identifier for the sequence, used for caching purposes.public static MotifFinder buildMFFromFile(java.lang.String mfClassName, java.lang.String seqRoot, java.lang.String seqID)
public static MotifFinder buildMFFromFile(java.lang.String mfClassName, java.lang.String seqRoot, java.lang.String seqID, int geneLength)
If geneLength == UNEQUAL_GENE_LENGTHS, the sequence will be set to the concatenation of each line followed by a SEQUENCE_BREAK character. Otherwise, the sequence will be set to the concatenation of the first geneLength-1 characters of each line followed by a SEQUENCE_BREAK character; if a line is less than geneLength-1 characters long, FILLER characters will be prepended to the line so that SEQUENCE_BREAK characters occur at intervals of geneLenth.
public static java.lang.String buildSequenceFromFile(java.lang.String filePath, boolean separateLines, int geneLength, int[] groupGeneIDs)
public static void main(java.lang.String[] args) throws java.io.IOException
java.io.IOException
private static void persistMF(java.lang.String mfObjFileName, MotifFinder mf)
private static MotifFinder retrieveMF(java.lang.String mfObjFileName)