Example #1
0
        static void Main(string[] args)
        {
            string strPath = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);

            string[] files = Directory.GetFiles(strPath + @"\Rosalind", "*.txt"); //Assumes only one txt file in this directory - the data set
            string[] lines = { "" };
            foreach (string file in files)
            {
                lines = File.ReadAllLines(file);
            }
            List <Fasta> fastaList = Fasta.DecodeFasta(lines);

            string[] strings = new string[fastaList.Count];
            for (int i = 0; i < fastaList.Count; i++)
            {
                strings[i] = fastaList[i].DNA;
            }

            ProfileMatrix matrix = new ProfileMatrix(strings);

            Console.WriteLine(matrix.ConsensusString);
            ProfileMatrix.OutputProfileMatrix(matrix);

            Console.ReadLine();
        }
Example #2
0
        public static void OutputProfileMatrix(ProfileMatrix matrix, bool align = true)
        {
            if (matrix.ProfileHeadings == null)
            {
                Console.WriteLine("Cannot output Matrix: No headings available.");
            }
            else
            {
                char[] headers = matrix.ProfileHeadings;
                int[,] profileMatrix = matrix.Matrix;
                int maxPadding = 3;
                if (align)
                {
                    maxPadding = 2;
                    for (int i = 0; i < profileMatrix.GetLength(0); i++)
                    {
                        for (int j = 0; j < profileMatrix.GetLength(1); j++)
                        {
                            if (profileMatrix[i, j].ToString().Length > maxPadding)
                            {
                                maxPadding = profileMatrix[i, j].ToString().Length;
                            }
                        }
                    }
                }

                for (int i = 0; i < matrix.ProfileHeadings.Length; i++)
                {
                    Console.Write("{0}: ", matrix.ProfileHeadings[i]);
                    for (int j = 0; j < profileMatrix.GetLength(1); j++)
                    {
                        Console.Write(profileMatrix[i, j].ToString().PadRight(maxPadding));
                    }
                    Console.WriteLine();
                }
            }
        }