Esempio n. 1
0
        /// <summary>
        /// Method that finds the index of the 2 strings that have the maximum overlap
        /// </summary>
        /// <returns>The index of 2 strings with max overlap and the merged string of the 2 fragments</returns>
        public Tuple <int, int, string> FindMaxOverlap()
        {
            //nested loop to grab all unique fragment pairs to find overlap for
            for (int i = 0; i < fragmentCollection.Count; i++)
            {
                for (int j = i + 1; j < fragmentCollection.Count; j++)
                {
                    OverlapFinder finder = new OverlapFinder(fragmentCollection[i], fragmentCollection[j]);

                    var overlapResults = finder.FindOverlap();

                    //As we interate through each permutation, check if the current overlap is more than the previous max overlap
                    //Overwrite the old overlap details if the current overlap is longer
                    if (overlapResults.Item1 > maxOverlap)
                    {
                        maxOverlap     = overlapResults.Item1;
                        index1         = i;
                        index2         = j;
                        mergedFragment = overlapResults.Item2;
                    }
                }
            }

            return(Tuple.Create(index1, index2, mergedFragment));
        }
Esempio n. 2
0
        public void OverlapFinder_BothWayMatchEqually()
        {
            //Arrange
            string firstString          = "abxy";
            string secondString         = "xyab";
            int    expectedOverlap      = 2;
            string expectedMergedString = "abxyab";

            //Act
            GenomeSequencing.OverlapFinder finder = new GenomeSequencing.OverlapFinder(firstString, secondString);
            var result = finder.FindOverlap();

            //Assert
            Assert.AreEqual(expectedOverlap, result.Item1);
            Assert.AreEqual(expectedMergedString, result.Item2);
        }
Esempio n. 3
0
        public void OverlapFinder_SecondStringContainsFirstString()
        {
            //Arrange
            string firstString          = "ell";
            string secondString         = "s well tha";
            int    expectedOverlap      = 3;
            string expectedMergedString = "s well tha";

            //Act
            GenomeSequencing.OverlapFinder finder = new GenomeSequencing.OverlapFinder(firstString, secondString);
            var result = finder.FindOverlap();

            //Assert
            Assert.AreEqual(expectedOverlap, result.Item1);
            Assert.AreEqual(expectedMergedString, result.Item2);
        }
Esempio n. 4
0
        public void NoMatchTest()
        {
            //Arrange
            string firstString          = "abc";
            string secondString         = "xyz";
            int    expectedOverlap      = 0;
            string expectedMergedString = "abcxyz";

            //Act
            GenomeSequencing.OverlapFinder finder = new GenomeSequencing.OverlapFinder(firstString, secondString);
            var result = finder.FindOverlap();

            //Assert
            Assert.AreEqual(expectedOverlap, result.Item1);
            Assert.AreEqual(expectedMergedString, result.Item2);
        }
Esempio n. 5
0
        public void OverlapFinder_SecondStringOneCharLongMiddleMatch()
        {
            //Arrange
            string firstString          = "abc";
            string secondString         = "b";
            int    expectedOverlap      = 1;
            string expectedMergedString = "abc";

            //Act
            GenomeSequencing.OverlapFinder finder = new GenomeSequencing.OverlapFinder(firstString, secondString);
            var result = finder.FindOverlap();

            //Assert
            Assert.AreEqual(expectedOverlap, result.Item1);
            Assert.AreEqual(expectedMergedString, result.Item2);
        }
Esempio n. 6
0
        public void OverlapFinder_PostfixMatchesPrefix()
        {
            //Arrange
            string firstString          = "abij";
            string secondString         = "ijxy";
            int    expectedOverlap      = 2;
            string expectedMergedString = "abijxy";

            //Act
            GenomeSequencing.OverlapFinder finder = new GenomeSequencing.OverlapFinder(firstString, secondString);
            var result = finder.FindOverlap();

            //Assert
            Assert.AreEqual(expectedOverlap, result.Item1);
            Assert.AreEqual(expectedMergedString, result.Item2);
        }