Class SoftMaskedAlphabet

  • All Implemented Interfaces:
    Annotatable, Alphabet, FiniteAlphabet, Changeable

    public final class SoftMaskedAlphabet
    extends Unchangeable
    implements FiniteAlphabet
    Soft masking is usually displayed by making the masked regions somehow different from the non masked regions. Typically the masked regions are lower case but other schemes could be invented. For example a softmasked DNA sequence may look like this:
    Where the lowercase regions are masked by low complexity.

    SoftMaskedAlphabets come with SymbolTokenizers that understand how to read and write the softmasking. The interpretation of what constitutes a masked region is governed by an implementation of a MaskingDetector. The DEFAULT field of the MaskingDetector interface defines lower case tokens as masked.

    Copyright (c) 2004 Novartis Institute for Tropical Diseases

    Mark Schreiber
    • Method Detail

      • getDelegate

        protected FiniteAlphabet getDelegate()
        The compound alpha that holds the symbols used by this wrapper
        a FiniteAlphabet
      • getName

        public String getName()
        The name of the Alphabet
        Specified by:
        getName in interface Alphabet
        a String in the form of "Softmasked {"+alphaToMask.getName()+"}"
      • getAlphabets

        public List getAlphabets()
        Gets the components of the Alphabet.
        Specified by:
        getAlphabets in interface Alphabet
        a List with two members, the first is the wrapped Alphabet the second is the binary SubIntegerAlphabet.
      • getSymbol

        public Symbol getSymbol​(List l)
                         throws IllegalSymbolException
        Gets the compound symbol composed of the Symbols in the List. The Symbols in the List must be from alpha (defined in the constructor) and SUBINTEGER[0..1]
        Specified by:
        getSymbol in interface Alphabet
        l - a List of Symbols
        A Symbol from this alphabet.
        IllegalSymbolException - if l is not as expected (see above)
      • getGapSymbol

        public Symbol getGapSymbol()
        Description copied from interface: Alphabet

        Get the 'gap' ambiguity symbol that is most appropriate for this alphabet.

        In general, this will be a BasisSymbol that represents a list of AlphabetManager.getGapSymbol() the same length as the getAlphabets list.

        Specified by:
        getGapSymbol in interface Alphabet
        the appropriate gap Symbol instance
      • contains

        public boolean contains​(Symbol s)
        Description copied from interface: Alphabet

        Returns whether or not this Alphabet contains the symbol.

        An alphabet contains an ambiguity symbol iff the ambiguity symbol's getMatches() returns an alphabet that is a proper sub-set of this alphabet. That means that every one of the symbols that could match the ambiguity symbol is also a member of this alphabet.

        Specified by:
        contains in interface Alphabet
        s - the Symbol to check
        boolean true if the Alphabet contains the symbol and false otherwise
      • validate

        public void validate​(Symbol s)
                      throws IllegalSymbolException
        Description copied from interface: Alphabet

        Throws a precanned IllegalSymbolException if the symbol is not contained within this Alphabet.

        This function is used all over the code to validate symbols as they enter a method. Also, the code is littered with catches for IllegalSymbolException. There is a preferred style of handling this, which should be covererd in the package documentation.

        Specified by:
        validate in interface Alphabet
        s - the Symbol to validate
        IllegalSymbolException - if r is not contained in this alphabet
      • getTokenization

        public SymbolTokenization getTokenization​(String type)
                                           throws BioException
        Description copied from interface: Alphabet

        Get a SymbolTokenization by name.

        The parser returned is guaranteed to return Symbols and SymbolLists that conform to this alphabet.

        Every alphabet should have a SymbolTokenzation under the name 'token' that uses the symbol token characters to translate a string into a SymbolList. Likewise, there should be a SymbolTokenization under the name 'name' that uses symbol names to identify symbols. Any other names may also be defined, but the behavior of the returned SymbolTokenization is not defined here.

        A SymbolTokenization under the name 'default' should be defined for all sequences, that determines the behavior when printing out a sequence. Standard behavior is to define the 'token' SymbolTokenization as default if it exists, else to define the 'name' SymbolTokenization as the default, but others are possible.

        Specified by:
        getTokenization in interface Alphabet
        type - the name of the parser
        a parser for that name
        BioException - if for any reason the tokenization could not be built
      • size

        public int size()
        Description copied from interface: FiniteAlphabet
        The number of symbols in the alphabet.
        Specified by:
        size in interface FiniteAlphabet
        the size of the alphabet
      • iterator

        public Iterator iterator()
        Description copied from interface: FiniteAlphabet
        Retrieve an Iterator over the AtomicSymbols in this FiniteAlphabet.

        Each AtomicSymbol as for which this.contains(as) is true will be returned exactly once by this iterator in no specified order.

        Specified by:
        iterator in interface FiniteAlphabet
        an Iterator over the contained AtomicSymbol objects