C - the compound type of the compounds contained in this setpublic class BioJava3TokenSet<C extends org.biojava3.core.sequence.template.Compound> extends java.util.AbstractSet<C> implements TokenSet<C>
TokenSet backed by a BioJava CompoundSet object.| Constructor and Description |
|---|
BioJava3TokenSet(BioJava3TokenSet<C> tokenSet)
A constructor used to clone instances of this class.
|
BioJava3TokenSet(CharacterStateSetType type,
org.biojava3.core.sequence.template.CompoundSet<C> compoundSet,
boolean spaceForGap)
Creates a new instance of this class.
|
| Modifier and Type | Method and Description |
|---|---|
BioJava3TokenSet<C> |
clone()
Clones this instance.
|
java.lang.String |
descriptionByToken(C token)
An description of the specified token (e.g.
|
org.biojava3.core.sequence.template.CompoundSet<C> |
getCompoundSet()
Returns the BioJava compound set that is viewed by this instance.
|
C |
getGapToken()
Returns the compound associated with
AbstractTokenSet#DEFAULT_GAP_REPRESENTATION from the underlying
BioJava token set using CompoundSet.getCompoundForString(String). |
CharacterSymbolMeaning |
getMeaning(C token)
Returns the meaning of the specified symbol.
|
C |
getMissingInformationToken()
Returns the default object that represents an unknown position in this token set.
|
CharacterSymbolType |
getSymbolType(C token)
Returns the type of the specified token (symbol).
|
CharacterStateSetType |
getType()
Determines the type of tokens that are defined by this instance.
|
boolean |
isGapToken(C token)
Tests if the specified token represents a gap.
|
boolean |
isMissingInformationToken(C token)
Tests if the specified token represents an unknown position (usually '?').
|
boolean |
isSpaceForGap()
Determines whether
TokenSet.tokenByKeyStroke(KeyStroke) shall return the gap token, if the space bar is
pressed, even if that key stroke is not associated with that token. |
java.util.Iterator<C> |
iterator()
Returns an unmodifiable iterator of the underlying BioJava compound set.
|
int |
maxRepresentationLength()
Calculates the maximal length of a representation returned by
TokenSet.representationByToken(Object)
of all tokens contained in this set. |
java.lang.String |
representationByToken(C token)
Returns the representation string of the specified token that shall be displayed in an
AlignmentArea or written into an alignment file. |
boolean |
representationLengthEqual()
Checks if all representation strings returned by
TokenSet.representationByToken(Object)
have the same length. |
void |
setSpaceForGap(boolean spaceForGap)
Allows to specify whether
TokenSet.tokenByKeyStroke(KeyStroke) shall return the gap token, if the space
bar is pressed, even if that key stroke is not associated with that token. |
int |
size() |
C |
tokenByKeyStroke(javax.swing.KeyStroke key)
Returns the token from this set that is associated with the specified key stroke.
|
C |
tokenByRepresentation(java.lang.String representation)
Returns the token associated with the specified string representation used to display the token in
an
AlignmentArea or an alignment file. |
add, addAll, clear, contains, containsAll, isEmpty, remove, retainAll, toArray, toArray, toStringfinalize, getClass, notify, notifyAll, wait, wait, waitpublic BioJava3TokenSet(BioJava3TokenSet<C> tokenSet)
tokenSet - the instance to be clonedpublic BioJava3TokenSet(CharacterStateSetType type, org.biojava3.core.sequence.template.CompoundSet<C> compoundSet, boolean spaceForGap)
type - the token type of the new instance (Only a discrete type would make sense for this class.)compoundSet - the BioJava compound set containing the compounds to be copied into the new instancespaceForGap - determines whether the space key shall be associated with gap symboljava.lang.NullPointerException - if type or compoundSet are nullpublic org.biojava3.core.sequence.template.CompoundSet<C> getCompoundSet()
public C tokenByKeyStroke(javax.swing.KeyStroke key)
TokenSetAlignmentArea.
Note that the key character is only used by AlignmentArea if it does not collide with a default
keyboard action. (Usually the key character can be any lower or upper case letter or digit.)
tokenByKeyStroke in interface TokenSet<C extends org.biojava3.core.sequence.template.Compound>key - the key stroke (key code and shift mask) the user can press to insert the returned token
into an AlignmentAreanull if none is definedpublic java.util.Iterator<C> iterator()
Note that this iterator will return the elements of this set as they were when this method
if called. If the set is modified later on, the iterator will not reflect such changes and
will not throw a ConcurrentModificationException.
iterator in interface java.lang.Iterable<C extends org.biojava3.core.sequence.template.Compound>iterator in interface java.util.Collection<C extends org.biojava3.core.sequence.template.Compound>iterator in interface java.util.Set<C extends org.biojava3.core.sequence.template.Compound>iterator in class java.util.AbstractCollection<C extends org.biojava3.core.sequence.template.Compound>public int size()
size in interface java.util.Collection<C extends org.biojava3.core.sequence.template.Compound>size in interface java.util.Set<C extends org.biojava3.core.sequence.template.Compound>size in class java.util.AbstractCollection<C extends org.biojava3.core.sequence.template.Compound>public java.lang.String representationByToken(C token)
TokenSetAlignmentArea or written into an alignment file.
Note that some CharSequenceAdapters and StringAdapters only use the first character
of the returned string to represent a token.
representationByToken in interface TokenSet<C extends org.biojava3.core.sequence.template.Compound>token - the token associated with the representationpublic C tokenByRepresentation(java.lang.String representation)
TokenSetAlignmentArea or an alignment file.tokenByRepresentation in interface TokenSet<C extends org.biojava3.core.sequence.template.Compound>representation - the string representation of the tokennull if none is definedpublic int maxRepresentationLength()
TokenSetTokenSet.representationByToken(Object)
of all tokens contained in this set.maxRepresentationLength in interface TokenSet<C extends org.biojava3.core.sequence.template.Compound>public boolean representationLengthEqual()
TokenSetTokenSet.representationByToken(Object)
have the same length.representationLengthEqual in interface TokenSet<C extends org.biojava3.core.sequence.template.Compound>true if all lengths are equal, false otherwisepublic java.lang.String descriptionByToken(C token)
TokenSetdescriptionByToken in interface TokenSet<C extends org.biojava3.core.sequence.template.Compound>token - the token that shall be describedpublic CharacterStateSetType getType()
TokenSetpublic boolean isGapToken(C token)
TokenSetNote that it's legal to have multiple tokens to be considered as gaps, but one of them must be defined as the default gap tokens. When alignments are written to files (e.g. using JPhyloIO), some formats may accept only one of these tokens as a gap and the others may be represented as additional character states.
isGapToken in interface TokenSet<C extends org.biojava3.core.sequence.template.Compound>token - the token to be testedtrue if the specified token is recognized as a gap, false otherwise.public C getGapToken()
AbstractTokenSet#DEFAULT_GAP_REPRESENTATION from the underlying
BioJava token set using CompoundSet.getCompoundForString(String).getGapToken in interface TokenSet<C extends org.biojava3.core.sequence.template.Compound>null if the underlying BioJava token set does contain a representation for
AbstractTokenSet#DEFAULT_GAP_REPRESENTATIONTokenSet.getGapToken()public boolean isMissingInformationToken(C token)
TokenSetNote that it's legal to have multiple tokens to be considered as unknown symbols, but one of them must be defined as the default. When alignments are written to files, some formats may accept only one
isMissingInformationToken in interface TokenSet<C extends org.biojava3.core.sequence.template.Compound>token - the token to be testedtrue if the specified token is recognized as an unknown position, false otherwise.public C getMissingInformationToken()
TokenSetgetMissingInformationToken in interface TokenSet<C extends org.biojava3.core.sequence.template.Compound>public CharacterSymbolType getSymbolType(C token)
TokenSetgetSymbolType in interface TokenSet<C extends org.biojava3.core.sequence.template.Compound>token - the symbol to be testedpublic CharacterSymbolMeaning getMeaning(C token)
TokenSetgetMeaning in interface TokenSet<C extends org.biojava3.core.sequence.template.Compound>token - the token to determine the meaning frompublic boolean isSpaceForGap()
TokenSetTokenSet.tokenByKeyStroke(KeyStroke) shall return the gap token, if the space bar is
pressed, even if that key stroke is not associated with that token.isSpaceForGap in interface TokenSet<C extends org.biojava3.core.sequence.template.Compound>true if the gap token shall always be returned, false otherwise.public void setSpaceForGap(boolean spaceForGap)
TokenSetTokenSet.tokenByKeyStroke(KeyStroke) shall return the gap token, if the space
bar is pressed, even if that key stroke is not associated with that token.setSpaceForGap in interface TokenSet<C extends org.biojava3.core.sequence.template.Compound>spaceForGap - Specify true here, if the gap token shall always be returned, false
otherwise.