Exemplo n.º 1
0
        private static Tuple <int[, ], int[]> GetMatrixAndTriangle2(string[] lines)
        {
            List <string> dbn1s = new List <string>();
            List <string> dbn2s = new List <string>();

            for (int i = 0; i < lines.Length; i++)
            {
                for (int j = i + 1; j < lines.Length; j++)
                {
                    dbn1s.Add(lines[i]);
                    dbn2s.Add(lines[j]);
                }
            }
            int[] upperTriangle = RnaDistance.Distance(dbn1s.ToArray(), dbn2s.ToArray());

            int[,] matrix = new int[lines.Length, lines.Length];
            int index = 0;

            for (int i = 0; i < lines.Length; i++)
            {
                for (int j = i + 1; j < lines.Length; j++)
                {
                    matrix[i, j] = upperTriangle[index];
                    matrix[j, i] = upperTriangle[index];
                    index++;
                }
            }

            return(new Tuple <int[, ], int[]>(matrix, upperTriangle));
        }
Exemplo n.º 2
0
        public void DistTest3()
        {
            string dbn1     = "(((.((.(((((((((((.((......))..)))))))..))))..)).)))..(((((....)))))...";
            string dbn2     = ".(((((....))))).(((((....)))))..((((..((((...((((((...))))))...))))))))";
            int    expected = 64;
            int    actual   = RnaDistance.Distance(dbn1, dbn2);

            Assert.AreEqual(expected, actual);
        }
Exemplo n.º 3
0
        private static Tuple <int[, ], int[]> GetMatrixAndTriangle(string[] lines)
        {
            int[,] matrix = new int[lines.Length, lines.Length];
            List <int> triangle = new List <int>();

            for (int i = 0; i < lines.Length; i++)
            {
                int[] ds = RnaDistance.Distance(lines[i], lines.Skip(i + 1).ToArray());
                for (int j = i + 1; j < lines.Length; j++)
                {
                    int d = ds[j - i - 1];
                    matrix[i, j] = d;
                    matrix[j, i] = d;
                    triangle.Add(d);
                }
            }
            return(new Tuple <int[, ], int[]>(matrix, triangle.ToArray()));
        }