Exemplo n.º 1
0
        public void CheckIsGapFalseTest()
        {
            IAlphabet alphabet = Alphabets.DNA;
            bool      actual   = alphabet.CheckIsGap('A');

            Assert.AreEqual(false, actual);
        }
Exemplo n.º 2
0
        public void CheckIsGapTrueTest()
        {
            IAlphabet alphabet = Alphabets.DNA;
            bool      actual   = alphabet.CheckIsGap('-');

            Assert.AreEqual(true, actual);
        }
        /// <summary>
        /// Checks if the provided item is a gap character or not
        /// </summary>
        /// <param name="alphabet">Alphabet to test against.</param>
        /// <param name="item">Item to be checked</param>
        /// <returns>True if the specified item is a gap</returns>
        public static bool CheckIsGap(this IAlphabet alphabet, char item)
        {
            if (alphabet == null)
            {
                throw new ArgumentNullException("alphabet", "Alphabet must be supplied.");
            }

            return(alphabet.CheckIsGap((byte)item));
        }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            var parser = SequenceParsers.FindParserByFileName(Filename);

            if (parser == null)
            {
                Console.WriteLine("No parser found.");
                return;
            }

            List <ISequence> allSequences = parser
                                            .Parse()
                                            .ToList();

            IAlphabet alphabet = allSequences[0].Alphabet;

            long totalColums = allSequences.Min(s => s.Count);

            //byte[] data = new byte[allSequences.Count];
            for (int column = 0; column < totalColums; column++)
            {
                //    for (int row = 0; row < allSequences.Count; row++)
                //        data[row] = allSequences[row][column];
                //ISequence newSequence = new Sequence(alphabet, data);

                ISequence newSequence = new Sequence(AmbiguousRnaAlphabet.Instance,
                                                     allSequences
                                                     .Select(s => s[column]).ToArray());
                SequenceStatistics stats =
                    new SequenceStatistics(newSequence);
                var TopCount =
                    alphabet
                    .Where(symbol => !alphabet.CheckIsGap(symbol))
                    .Select(symbol =>
                            new
                {
                    Symbol    = (char)symbol,
                    Count     = stats.GetCount(symbol),
                    Frequency = stats.GetFraction(symbol)
                })
                    .Where(tc => tc.Count > 0)
                    .OrderByDescending(c => c.Count)
                    .FirstOrDefault();

                if (TopCount != null)
                {
                    Console.WriteLine("{0}: {1} = {2} of {3}",
                                      column, TopCount.Symbol, TopCount.Count, totalColums);
                }
            }
        }
Exemplo n.º 5
0
        public void CheckIsGapNullSequence()
        {
            IAlphabet alphabet = null;

            alphabet.CheckIsGap('A');
        }
Exemplo n.º 6
0
        public void CheckIsGapNullSequence()
        {
            IAlphabet alphabet = null;

            Assert.Throws <ArgumentNullException>(() => alphabet.CheckIsGap('A'));
        }