/// <summary> /// Confirms that there is a symbol in the similarity matrix for every /// symbol in the sequence. /// </summary> /// <param name="sequence">Sequence to validate.</param> /// <returns>true if sequence is valid.</returns> public bool ValidateSequence(ISequence sequence) { foreach (ISequenceItem item in sequence) { if (!_encoding.Contains(item)) { return(false); } } return(true); }
/// <summary> /// Converts the ISequenceItem passed in as a parameter from one collection /// of such items to another. This is useful in going from encoded items to /// alphabet items for instance. /// </summary> public ISequenceItem Convert(ISequenceItem item) { if (direction == EncodingMapDirection.AlphabetToEncoding) { if (!alphabet.Contains(item)) { throw new ArgumentException("The alphabet does not contain the item being mapped"); } return(map[item]); } else if (direction == EncodingMapDirection.EncodingToAlphabet) { if (!encoding.Contains(item)) { throw new ArgumentException("The encoding does not contain the item being mapped"); } return(map[item]); } throw new Exception("Internal Error: Unrecognized encoding map direction"); }