001/*
002 * BioJava development code
003 * 
004 * This code may be freely distributed and modified under the
005 * terms of the GNU Lesser General Public Licence.  This should
006 * be distributed with the code.  If you do not have a copy,
007 * see:
008 * 
009 * http://www.gnu.org/copyleft/lesser.html
010 * 
011 * Copyright for this code is held jointly by the individual
012 * authors.  These should be listed in @author doc comments.
013 * 
014 * For more information on the BioJava project and its aims,
015 * or to join the biojava-l mailing list, visit the home page
016 * at:
017 * 
018 * http://www.biojava.org
019 *
020 */
021
022package org.biojava.bio.symbol;
023
024import java.io.Serializable;
025
026/**  
027 * Symbol list which just consists of non-informative symbols.
028 * A DummySymbolList can be constructed over any Alphabet, and may
029 * be of any length.  Calls to the symbolAt method will always return
030 * the non-informative symbol for the alphabet in question (i.e.
031 * 'n' for DNA, 'X' for protein, etc.).
032 *
033 * If you wish to work with <code>Feature</code> objects, but don't
034 * have the actual sequence data available, you can construct a
035 * <code>SimpleSequence</code> from a <code>DummySequence</code>,
036 * and create features. on that.
037 *
038 * @author Thomas Down
039 * @author Matthew Pocock
040 * @since 1.2
041 */
042
043public class DummySymbolList extends AbstractSymbolList implements Serializable {
044    private final Symbol sym;
045    private final Alphabet alpha;
046    private final int length;
047
048    public DummySymbolList(FiniteAlphabet alpha, int length) {
049        super();
050        this.alpha = alpha;
051        this.length = length;
052        sym = AlphabetManager.getAllAmbiguitySymbol(alpha);
053    }
054    
055    public DummySymbolList(Alphabet alpha, int length, Symbol sym)
056    throws IllegalSymbolException {
057        alpha.validate(sym);
058        
059        this.alpha = alpha;
060        this.length = length;
061        this.sym = sym;
062    }
063
064    public Alphabet getAlphabet() {
065        return alpha;
066    }
067
068    public int length() {
069        return length;
070    }
071
072    public Symbol symbolAt(int i) {
073        return sym;
074    }
075}
076