/// <summary> /// Reads a sequence of 8-bit extended ASCII characters over the alphabet /// { A, C, T, G } from standard input; compresses them using two bits per /// character; and writes the results to standard output.</summary> /// public void Compress() { string s = input.ReadString(); int N = s.Length; output.Write(N); // Write two-bit code for char. for (int i = 0; i < N; i++) { int d = DNA.ToIndex(s[i]); output.Write(d, 2); } output.Close(); input.Close(); }
private Node get(Node x, string key, int d) { if (x == null) { return(null); } if (d == key.Length) { return(x); } char c = key[d]; return(get(x[alphabet.ToIndex(c)], key, d + 1)); }
public static void MainTest(string[] args) { TextInput StdIn = new TextInput(); Alphabet alphabet = new Alphabet(args[0]); int R = alphabet.Radix; int[] count = new int[R]; while (StdIn.HasNextChar()) { char c = StdIn.ReadChar(); if (alphabet.Contains(c)) { count[alphabet.ToIndex(c)]++; } } for (int c = 0; c < R; c++) { Console.WriteLine(alphabet.ToChar(c) + " " + count[c]); } }