コード例 #1
0
        public void SetUp()
        {
            alphabet = new TestAlphabetClass();
			alphabet2 = new TestAlphabetClass();

            sym1 = new Symbol('a', "Ade", "Adenine");
            sym2 = new Symbol('u', "Ura", "Uracil");
            sym3 = new SymbolMeta('-', "GAP", "Gap");
        }
コード例 #2
0
 public void TestAdd()
 {
     SymbolMeta sym = new SymbolMeta('X', "XXX", "Unknown");
     Assert.AreEqual(0, sym.SymbolNumber);
     //sym.remove(new Symbol('a', "adenine"));
     sym.Add(new Symbol('a', "Ade", "Adenine"));
     sym.Add(new Symbol('u', "Ura", "Adenine"));
     Assert.AreEqual(2, sym.SymbolNumber);
     Assert.AreEqual("Adenine", sym[0].Name);
     Assert.AreEqual("Adenine", sym[1].Name);
 }
コード例 #3
0
        /** Tests the replacement of symbols within the symbol set */
        public void TestReplace()
        {
            SymbolMeta sym = new SymbolMeta('X', "XXX", "Unknown");
            Symbol sym1 = new Symbol('a', "Ade", "Adenine");
            Symbol sym2 = new Symbol('u', "Ura", "Uracil");
            Symbol sym3 = new Symbol('t', "Thy", "Thymine");

            sym.Add(sym1);
            sym.Add(sym2);
            Assert.AreEqual(2, sym.SymbolNumber);

            sym.Replace(sym2, sym3);
            Assert.AreEqual(2, sym.SymbolNumber);
            Assert.AreEqual(sym3, sym[1]);
        }
コード例 #4
0
        /** Tests the removal of symbols from the symbol set */
        public void TestRemove()
        {
            SymbolMeta sym = new SymbolMeta('X', "XXX", "Unknown");
            Symbol sym1 = new Symbol('a', "Ade", "Adenine");
            Symbol sym2 = new Symbol('u', "Ura", "Uracil");

            sym.Remove(sym1);
            sym.Add(sym1);
            sym.Add(sym2);
            
            
            Assert.AreEqual(2, sym.SymbolNumber);

            sym.Remove(sym1);
            Assert.AreEqual(1, sym.SymbolNumber);
            Assert.AreEqual(sym2, sym[0]);
        }
コード例 #5
0
        /** Tests the comparision with a meta symbol */
        public void TestEquals()
        {
            SymbolMeta sym = new SymbolMeta('X', "XXX", "Unknown");
            Symbol sym2 = new Symbol('a', "Ade", "Adenine");
            Symbol sym3 = new Symbol('u', "Ura", "Uracil");

            Assert.AreEqual(true, sym.Equals(sym2));
            Assert.AreEqual(true, sym2.Equals(sym));

            sym.Add(sym2);
            Assert.AreEqual(true, sym.Equals(sym2));
            Assert.AreEqual(true, sym2.Equals(sym));
            Assert.AreEqual(false, sym.Equals(sym3));
            Assert.AreEqual(false, sym3.Equals(sym));

            sym.Add(sym3);
            Assert.AreEqual(true, sym.Equals(sym));
            Assert.AreEqual(true, sym.Equals(sym2));
            Assert.AreEqual(true, sym.Equals(sym3));
        }
コード例 #6
0
        /// <summary>
        /// Parses the motif description and generates a symbol array that describes
        /// the motif. Alternatives are described by MetaSymbols.
        /// </summary>
        /// <param name="alphabet">Alphabet of the motif. </param>
        /// <param name="motif">Motif description.</param>
        /// <returns>Returns a symbol array.</returns>
        public static List<Symbol> Symbols
            (Alphabet alphabet, String motif)
        {
            List<Symbol> mySymbols = new List<Symbol>();
            SymbolMeta alternative = null;

            for (int i = 0; i < motif.Length; i++)
            {
                char letter = motif[i];

                if (letter == '[')
                {
                    if (alternative != null)
                        throw new ArgumentException
                            ("'[' within alternative is not permitted");

                    alternative = new SymbolMeta('#', "ALT", "Alternative");
                }

                else
                    if (letter == ']')
                    {
                        if (alternative == null)
                            throw new ArgumentException
                                ("Opening bracket for ']' is missing!");

                        mySymbols.Add(alternative);
                        alternative = null;
                    }

                 else 
                     if (alternative != null)
                        alternative.Add(alphabet[letter]);

                 else
                     mySymbols.Add(alphabet[letter]);

            }

            if (alternative != null)
                throw new ArgumentException
                    ("']' is missing");

            return mySymbols;

        }
コード例 #7
0
        /** Tests the letter representation of the symbol set */
        public void TestLetters()
        {
            SymbolMeta sym = new SymbolMeta('X', "XXX", "Unknown");
            sym.Add(new Symbol('a', "Ade", "Adenine"));
            sym.Add(new Symbol('u', "Ura", "Adenine"));

            Assert.AreEqual("au", sym.Letters);
        }