|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.biojava.bio.seq.io.ChunkedSymbolListFactory
public class ChunkedSymbolListFactory
class that makes ChunkedSymbolLists with the chunks implemented as SymbolLists themselves.
The advantage is that those SymbolLists can be packed implementations.
You can build a SequenceBuilderFactory to create a packed chunked sequence from an input file without making an intermediate symbol list with:-
public class PackedChunkedListFactory implements SequenceBuilderFactory
{
public SequenceBuilder makeSequenceBuilder()
{
return new SequenceBuilderBase() {
private ChunkedSymbolListFactory chunker = new ChunkedSymbolListFactory(new PackedSymbolListFactory(true));
// deal with symbols
public void addSymbols(Alphabet alpha, Symbol[] syms, int pos, int len)
throws IllegalAlphabetException
{
chunker.addSymbols(alpha, syms, pos, len);
}
// make the sequence
public Sequence makeSequence()
{
try {
// make the SymbolList
SymbolList symbols = chunker.makeSymbolList();
seq = new SimpleSequence(symbols, uri, name, annotation);
// call superclass method
return super.makeSequence();
}
catch (IllegalAlphabetException iae) {
throw new BioError("couldn't create symbol list");
}
}
};
}
}
Then reading in FASTA files can be done with something like:-
SequenceIterator seqI = new StreamReader(br, new FastaFormat(),
DNATools.getDNA().getTokenization("token"),
new PackedChunkedListFactory() );
Blend to suit taste.
Alternatively, you can input Symbols to the factory with addSymbols make the sequence eventually with makeSymbolList.
NOTE: An improvement has been introduced where an internal default SymbolList factory is used for small sequences. This implementation allows for faster SymbolList creation and access for small sequences while allowing a more space-efficient implementation to be selected for large sequences.
NOTE: This class is inherantly not threadsafe. You should create one instance for each symbol list you wish to manufacture, and then you should throw that instance away.
| Constructor Summary | |
|---|---|
ChunkedSymbolListFactory(SymbolListFactory symListFactory)
|
|
ChunkedSymbolListFactory(SymbolListFactory userSymListFactory,
int threshold)
|
|
| Method Summary | |
|---|---|
void |
addSymbols(Alphabet alfa,
Symbol[] syms,
int pos,
int len)
tool to construct the SymbolList by adding Symbols. |
SymbolList |
make(SymbolReader sr)
Method to create a Sequence with a SymbolReader. |
SymbolList |
makeSymbolList()
Converts accumulated Symbols to a SymbolList |
void |
useSuppliedSymListFactory()
Call this to convert from default SymbolList implementation to user-supplied implementation. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ChunkedSymbolListFactory(SymbolListFactory symListFactory)
symListFactory - class which produces the SymbolLists that are used
to store the chunked symbols.
public ChunkedSymbolListFactory(SymbolListFactory userSymListFactory,
int threshold)
userSymListFactory - User-supplied class which produces the SymbolLists
that are used to store the chunked symbols (only used when the chunked list
to be created is larger than threshold.threshold - the size of the SymbolList beyond which the userSymListFactory
is used. Below that, the internal default SymbolList factory is used.| Method Detail |
|---|
public void addSymbols(Alphabet alfa,
Symbol[] syms,
int pos,
int len)
throws IllegalArgumentException,
IllegalAlphabetException
IllegalArgumentException
IllegalAlphabetExceptionpublic void useSuppliedSymListFactory()
public SymbolList makeSymbolList()
throws IllegalAlphabetException
IllegalAlphabetException
public SymbolList make(SymbolReader sr)
throws IOException,
IllegalSymbolException,
IllegalAlphabetException,
BioException
IOException
IllegalSymbolException
IllegalAlphabetException
BioException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||