public class FileReaders
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
FileReaders.NameAndID |
Modifier and Type | Field and Description |
---|---|
static char |
GENE_NAME_SEPARATOR
Used to separate gene names in UnkownGeneException.
|
protected static java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.String>> |
idMappingMetaTable
A hashtable of hashtables; contains a hashtable for each gene ID file.
|
Constructor and Description |
---|
FileReaders() |
Modifier and Type | Method and Description |
---|---|
static int[] |
convertNamesToIDs(java.lang.String[] names,
java.lang.String filename)
Given the name of a file that contains gene name to gene ID mappings, and an array of gene names, will return a sorted array of
database IDs with duplicates removed, and modify names so that its elements correspond to those of the returned array, with trailing
empty slots in names set to null.
|
static Motif[] |
extractMotifs(java.lang.String motifFile,
Alphabet alf)
Reads motifs from anywhere in the file.
|
private static java.lang.String |
findName(java.lang.String[] names,
java.lang.String name)
Identifies the equivalent name in names, ignoring case.
|
static int[] |
readGenes(java.lang.String filename,
java.lang.String masterFile)
Intelligently reads genes from the given file; if the genes are already int, returns them as a sorted set of integers; if the genes are
not int, then they're assumed to be names and are checked in the masterFile.
|
static int[] |
readGenes(java.lang.String filename,
java.lang.String key,
java.lang.String masterFile)
Intelligently reads genes from the given file; if the genes are already int, returns them as a sorted set of integers; if the genes are
not int, then they're assumed to be names and are checked in the masterFile.
|
static java.lang.String[] |
readLines(java.lang.String file)
Reads in the contents of file and returns it as a String array.
|
static MotifList |
readMotifList(java.lang.String motifFile,
java.lang.String key,
boolean defaultFlag,
Alphabet alf) |
static MotifList[] |
readMotifLists(java.lang.String motifFile)
Given a file in which each line is either empty or is a motif, constructs an array of MotifLists, where each block of motifs in the
motifFile is a motif list, and blocks are seperated by empty lines; if a line has a flag, it will be read, otherwise, 'r' is assumed.
|
static Motif[] |
readMotifs(java.lang.String filename,
boolean defaultFlag,
Alphabet alf)
Intelligently reads Motifs from the given file, using
stringsToMotifs(String[], boolean, Alphabet) to convert each string into
a motif. |
static Motif[] |
readMotifs(java.lang.String filename,
java.lang.String key,
boolean defaultFlag,
Alphabet alf)
Intelligently reads Motifs from the given file, using
stringsToMotifs(String[], boolean, Alphabet) to convert each string into
a motif; if key is not null, it will only using those motifs that have the given key, as described in
MoreArrays.filterByKey(String[], String) . |
static Motif[] |
stringsToMotifs(java.lang.String[] motifs,
boolean defaultFlag,
Alphabet alf)
Converts an array of strings into an array of Motifs; for each string, it checks for the presence of a Motif SEPARATOR charactor; if
found, it uses
Motif.parseMotif(String, Alphabet) to create the
motif, otherwise, it assumes the String is simply a valid sequence and creates a new motif using the defaultFlag. |
static java.lang.String[] |
validateFasta(Scanner scanner)
Validates a fasta formatted scanner and returns an array of gene names.
|
public static final char GENE_NAME_SEPARATOR
protected static final java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.String>> idMappingMetaTable
public static int[] convertNamesToIDs(java.lang.String[] names, java.lang.String filename) throws java.io.IOException, UnknownGeneException
UnknownGeneException
- if any of the names do not have a matching entry in the file. The message will have a semi-colon-separated
listing of the missing names.java.io.IOException
- if anything is wrong reading the filename. The message contains the unknown genes, separated by the
GENE_NAME_SEPARATOR
.public static Motif[] extractMotifs(java.lang.String motifFile, Alphabet alf) throws java.io.IOException
java.io.IOException
private static java.lang.String findName(java.lang.String[] names, java.lang.String name)
public static int[] readGenes(java.lang.String filename, java.lang.String masterFile) throws java.io.IOException, UnknownGeneException
convertNamesToIDs(String[], String)
for more info on the Exception.java.io.IOException
UnknownGeneException
public static int[] readGenes(java.lang.String filename, java.lang.String key, java.lang.String masterFile) throws java.io.IOException, UnknownGeneException
MoreArrays.filterByKey(String[], String)
for more information. If any gene name is not found in the master file,
then an UnknownGeneException is thrown. This exception can be parsed to determine which gene(s) are causing the problem. See
convertNamesToIDs(String[], String)
for more info on the Exception.java.io.IOException
UnknownGeneException
public static java.lang.String[] readLines(java.lang.String file) throws java.io.IOException
java.io.IOException
public static MotifList readMotifList(java.lang.String motifFile, java.lang.String key, boolean defaultFlag, Alphabet alf) throws java.io.IOException
java.io.IOException
public static MotifList[] readMotifLists(java.lang.String motifFile) throws java.io.IOException
java.io.IOException
public static Motif[] readMotifs(java.lang.String filename, boolean defaultFlag, Alphabet alf) throws java.io.IOException
stringsToMotifs(String[], boolean, Alphabet)
to convert each string into
a motif. defaultFlag specifies the flag that will be used if no flag is present.java.util.NoSuchElementException
- if no entry matched the key.java.io.IOException
public static Motif[] readMotifs(java.lang.String filename, java.lang.String key, boolean defaultFlag, Alphabet alf) throws java.io.IOException
stringsToMotifs(String[], boolean, Alphabet)
to convert each string into
a motif; if key is not null, it will only using those motifs that have the given key, as described in
MoreArrays.filterByKey(String[], String)
.java.util.NoSuchElementException
- if no entry matched the key.java.io.IOException
public static Motif[] stringsToMotifs(java.lang.String[] motifs, boolean defaultFlag, Alphabet alf)
Motif.parseMotif(String, Alphabet)
to create the
motif, otherwise, it assumes the String is simply a valid sequence and creates a new motif using the defaultFlag.public static java.lang.String[] validateFasta(Scanner scanner)