Beispiel #1
0
        /// <summary>
        /// Indication of whether or not an ISequenceItem is in the alphabet. This is
        /// a simple lookup and will only match exactly with items of this alphabet. It
        /// will not compare items from other alphabets that match the same amino acid.
        /// </summary>
        /// <param name="item">Item whose presence is to be checked</param>
        /// <returns>True if this contains input item</returns>
        public bool Contains(ISequenceItem item)
        {
            AminoAcid aa = item as AminoAcid;

            if (aa == null)
            {
                return(false);
            }

            return(values.Contains(aa));
        }
Beispiel #2
0
        /// <summary>
        /// Overrides Object Equals.
        /// Two nucleotides are judged equal, if they have the same symbol
        /// </summary>
        /// <param name="obj">Object to be compared with</param>
        /// <returns>True if equal</returns>
        public override bool Equals(object obj)
        {
            AminoAcid other = obj as AminoAcid;

            if (other != null)
            {
                return(this.Symbol == other.Symbol);
            }
            else
            {
                return(false);
            }
        }
Beispiel #3
0
        /// <summary>
        ///  Returns a new copy of the AminoAcid object.
        /// </summary>
        /// <returns>Clone of this amino acid</returns>
        public AminoAcid Clone()
        {
            AminoAcid amminoAcid = new AminoAcid();

            amminoAcid.val           = val;
            amminoAcid.symbol        = symbol;
            amminoAcid.extSymbol     = extSymbol;
            amminoAcid.Name          = name;
            amminoAcid.IsGap         = IsGap;
            amminoAcid.IsAmbiguous   = IsAmbiguous;
            amminoAcid.IsTermination = IsTermination;
            return(amminoAcid);
        }
Beispiel #4
0
        /// <summary>
        /// Find the set of symbols that is represented by input symbol
        /// </summary>
        /// <param name="symbol">Symbol to look up</param>
        /// <returns>Set of symbols</returns>
        public HashSet <ISequenceItem> GetBasicSymbols(ISequenceItem symbol)
        {
            if (symbol == null)
            {
                throw new ArgumentNullException("symbol");
            }

            // Validate input symbol
            AminoAcid aa = symbol as AminoAcid;

            if (aa == null || !values.Contains(aa))
            {
                throw new ArgumentException(string.Format(
                                                CultureInfo.CurrentCulture, Properties.Resource.INVALID_SYMBOL, symbol.Symbol, Name));
            }

            if (symbol == Xxx)
            {
                // Return all unambiguous symbols
                return(new HashSet <ISequenceItem>(values.Where(AA => !AA.IsAmbiguous).Select(AA => (ISequenceItem)AA)));
            }
            else
            {
                if (ambiguousToBasicSymbolMap.ContainsKey(symbol))
                {
                    return(ambiguousToBasicSymbolMap[symbol]);
                }
                else
                {
                    // It is base / unambiguous character
                    return(new HashSet <ISequenceItem>()
                    {
                        symbol
                    });
                }
            }
        }