public void CreateStatsWithMixedcaseLetterSequence() { ISequence sequence = new Sequence(Alphabets.DNA, "aAaAaAaA"); SequenceStatistics stats = new SequenceStatistics(sequence); Assert.AreEqual(8, stats.GetCount('A')); Assert.AreEqual(8, stats.GetCount(65)); Assert.AreEqual(8, stats.GetCount('a')); Assert.AreEqual(1.0, stats.GetFraction('A')); Assert.AreEqual(1.0, stats.GetFraction(65)); Assert.AreEqual(1.0, stats.GetFraction('a')); }
public void CreateSimpleStatsWithSingleLetterSequence() { ISequence sequence = new Sequence(Alphabets.DNA, "A"); SequenceStatistics stats = new SequenceStatistics(sequence); Assert.AreEqual(1, stats.GetCount('A')); Assert.AreEqual(1, stats.GetCount(65)); Assert.AreEqual(0, stats.GetCount('C')); Assert.AreEqual(0, stats.GetCount('G')); Assert.AreEqual(0, stats.GetCount('T')); Assert.AreEqual(1.0, stats.GetFraction('A')); Assert.AreEqual(1.0, stats.GetFraction(65)); }
public void CreateSimpleStatsWithSingleLetterSequence() { ISequence sequence = new Sequence(Alphabets.DNA, "A"); SequenceStatistics stats = new SequenceStatistics(sequence); Assert.AreEqual(1, stats.GetCount('A')); Assert.AreEqual(1, stats.GetCount(65)); Assert.AreEqual(0, stats.GetCount('C')); Assert.AreEqual(0, stats.GetCount('G')); Assert.AreEqual(0, stats.GetCount('T')); Assert.AreEqual(1.0, stats.GetFraction('A')); Assert.AreEqual(1.0, stats.GetFraction(65)); }
static void DumpStatsForOneSequence() { ISequence oneSequence = null; var parser = SequenceParsers.FindParserByFileName(Filename); if (parser != null) { oneSequence = parser.Parse().First(); parser.Close(); } if (oneSequence == null) { Console.WriteLine("Could not load sequence."); return; } SequenceStatistics stats = new SequenceStatistics(oneSequence); foreach (var symbol in oneSequence.Alphabet) { Console.WriteLine("{0} = Count={1}, Fraction={2}", (char)symbol, stats.GetCount(symbol), stats.GetFraction(symbol)); } }
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); } } }
public void CreateStatsWithSeveralMixedcaseLetterSequence() { ISequence sequence = new Sequence(Alphabets.DNA, "a-c-g-t-A-C-G-T-"); SequenceStatistics stats = new SequenceStatistics(sequence); Assert.AreEqual(2, stats.GetCount('A')); Assert.AreEqual(2, stats.GetCount('a')); Assert.AreEqual(2, stats.GetCount('C')); Assert.AreEqual(2, stats.GetCount('c')); Assert.AreEqual(2, stats.GetCount('G')); Assert.AreEqual(2, stats.GetCount('g')); Assert.AreEqual(2, stats.GetCount('T')); Assert.AreEqual(2, stats.GetCount('t')); Assert.AreEqual(8, stats.GetCount('-')); Assert.AreEqual(2.0 / 16.0, stats.GetFraction('A')); Assert.AreEqual(2.0 / 16.0, stats.GetFraction('C')); Assert.AreEqual(2.0 / 16.0, stats.GetFraction('G')); Assert.AreEqual(2.0 / 16.0, stats.GetFraction('T')); Assert.AreEqual(.5, stats.GetFraction('-')); Assert.AreEqual(.5, stats.GetFraction(45)); }
public void CreateStatsWithMixedcaseLetterSequence() { ISequence sequence = new Sequence(Alphabets.DNA, "aAaAaAaA"); SequenceStatistics stats = new SequenceStatistics(sequence); Assert.AreEqual(8, stats.GetCount('A')); Assert.AreEqual(8, stats.GetCount(65)); Assert.AreEqual(8, stats.GetCount('a')); Assert.AreEqual(1.0, stats.GetFraction('A')); Assert.AreEqual(1.0, stats.GetFraction(65)); Assert.AreEqual(1.0, stats.GetFraction('a')); }
public void CreateStatsWithSeveralMixedcaseLetterSequence() { ISequence sequence = new Sequence(Alphabets.DNA, "a-c-g-t-A-C-G-T-"); SequenceStatistics stats = new SequenceStatistics(sequence); Assert.AreEqual(2, stats.GetCount('A')); Assert.AreEqual(2, stats.GetCount('a')); Assert.AreEqual(2, stats.GetCount('C')); Assert.AreEqual(2, stats.GetCount('c')); Assert.AreEqual(2, stats.GetCount('G')); Assert.AreEqual(2, stats.GetCount('g')); Assert.AreEqual(2, stats.GetCount('T')); Assert.AreEqual(2, stats.GetCount('t')); Assert.AreEqual(8, stats.GetCount('-')); Assert.AreEqual(2.0 / 16.0, stats.GetFraction('A')); Assert.AreEqual(2.0 / 16.0, stats.GetFraction('C')); Assert.AreEqual(2.0 / 16.0, stats.GetFraction('G')); Assert.AreEqual(2.0 / 16.0, stats.GetFraction('T')); Assert.AreEqual(.5, stats.GetFraction('-')); Assert.AreEqual(.5, stats.GetFraction(45)); }