示例#1
0
        /// <summary>
        /// Copy the content to MUM.
        /// </summary>
        /// <param name="match">Maximum unique match.</param>
        public void CopyTo(MatchExtension match)
        {
            if (match != null)
            {
                match.ReferenceSequenceMumOrder = this.ReferenceSequenceMumOrder;
                match.ReferenceSequenceOffset   = this.ReferenceSequenceOffset;
                match.QuerySequenceMumOrder     = this.QuerySequenceMumOrder;
                match.QuerySequenceOffset       = this.QuerySequenceOffset;
                match.Length = this.Length;
                match.Query  = this.Query;

                match.ID          = this.ID;
                match.IsGood      = this.IsGood;
                match.IsTentative = this.IsTentative;
                match.Score       = this.Score;
                match.Adjacent    = this.Adjacent;
                match.From        = this.From;
                match.WrapScore   = this.WrapScore;
            }
        }
示例#2
0
        /// <summary>
        /// Copy the content to MUM.
        /// </summary>
        /// <param name="match">Maximum unique match.</param>
        public void CopyTo(MatchExtension match)
        {
            if (match != null)
            {
                match.ReferenceSequenceMumOrder = this.ReferenceSequenceMumOrder;
                match.ReferenceSequenceOffset = this.ReferenceSequenceOffset;
                match.QuerySequenceMumOrder = this.QuerySequenceMumOrder;
                match.QuerySequenceOffset = this.QuerySequenceOffset;
                match.Length = this.Length;
                match.Query = this.Query;

                match.ID = this.ID;
                match.IsGood = this.IsGood;
                match.IsTentative = this.IsTentative;
                match.Score = this.Score;
                match.Adjacent = this.Adjacent;
                match.From = this.From;
                match.WrapScore = this.WrapScore;
            }
        }
示例#3
0
        public void ValidateMatchAndMatchExtensionToString()
        {
            var match = new Match();
            match.Length = 20;
            match.QuerySequenceOffset = 33;

            var matchExtn = new MatchExtension(match);
            matchExtn.ID = 1;
            matchExtn.Length = 20;

            string actualMatchExtnString = matchExtn.ToString();
            string actualMatchstring = match.ToString();
            string ExpectedMatchExtnString = this.utilityObj.xmlUtil.GetTextValue(Constants.ToStringNodeName,
                                                                             Constants.ExpectedMatchExtnStringNode);
            string ExpectedMatchString = this.utilityObj.xmlUtil.GetTextValue(Constants.ToStringNodeName,
                                                                         Constants.ExpectedMatchStringNode);

            Assert.AreEqual(ExpectedMatchExtnString, actualMatchExtnString);
            Assert.AreEqual(actualMatchstring, ExpectedMatchString);
        }
示例#4
0
        public void ValidateClusterToString()
        {
            var match = new Match();

            var matchExtn1 = new MatchExtension(match);
            matchExtn1.ID = 1;
            matchExtn1.Length = 20;
            var matchExtn2 = new MatchExtension(match);
            matchExtn2.ID = 2;
            matchExtn2.Length = 30;
            IList<MatchExtension> extnList = new List<MatchExtension>();
            extnList.Add(matchExtn1);
            extnList.Add(matchExtn2);

            var clust = new Cluster(extnList);
            string actualString = clust.ToString();
            string expectedString = this.utilityObj.xmlUtil.GetTextValue(Constants.ToStringNodeName,
                                                                    Constants.ClusterExpectedNode);
            Assert.AreEqual(actualString, expectedString.Replace("\\r\\n", System.Environment.NewLine));
        }
示例#5
0
        /// <summary>
        /// Create a new delta alignment
        /// </summary>
        /// <param name="referenceSequence">Reference sequence</param>
        /// <param name="querySequence">Query sequence</param>
        /// <param name="cluster">Cluster object</param>
        /// <param name="match">Match object</param>
        /// <returns>Newly created DeltaAlignment object</returns>
        internal static DeltaAlignment NewAlignment(
                ISequence referenceSequence,
                ISequence querySequence,
                Cluster cluster,
                MatchExtension match)
        {
            DeltaAlignment deltaAlignment = new DeltaAlignment(referenceSequence, querySequence)
            {
                FirstSequenceStart = match.ReferenceSequenceOffset,
                SecondSequenceStart = match.QuerySequenceOffset,
                FirstSequenceEnd = match.ReferenceSequenceOffset + match.Length - 1,
                SecondSequenceEnd = match.QuerySequenceOffset + match.Length - 1,
                QueryDirection = cluster.QueryDirection
            };

            return deltaAlignment;
        }
示例#6
0
        /// <summary>
        /// Process the clusters
        /// </summary>
        /// <param name="clusters">List of clusters</param>
        /// <param name="matches">List of matches</param>
        /// <param name="indexToSkip">Start index upto which match extension to be ignored.</param>
        /// <param name="clusterSize">Size of cluster</param>
        private void ProcessCluster(
                List<Cluster> clusters,
                List<MatchExtension> matches,
                int indexToSkip,
                int clusterSize)
        {
            List<MatchExtension> clusterMatches;
            long total, endIndex, startIndex, score;
            int counter1, counter2, counter3, best;

            do
            {
                // remove cluster overlaps
                for (counter1 = 0; counter1 < clusterSize; counter1++)
                {
                    matches[indexToSkip + counter1].Score = matches[indexToSkip + counter1].Length;
                    matches[indexToSkip + counter1].Adjacent = 0;
                    matches[indexToSkip + counter1].From = -1;

                    for (counter2 = 0; counter2 < counter1; counter2++)
                    {
                        long cost, overlap, overlap1, overlap2;

                        overlap1 = matches[indexToSkip + counter2].ReferenceSequenceOffset
                                + matches[indexToSkip + counter2].Length
                                - matches[indexToSkip + counter1].ReferenceSequenceOffset;
                        overlap = Math.Max(0, overlap1);
                        overlap2 = matches[indexToSkip + counter2].QuerySequenceOffset
                                + matches[indexToSkip + counter2].Length -
                                matches[indexToSkip + counter1].QuerySequenceOffset;
                        overlap = Math.Max(overlap, overlap2);

                        // cost matches which are not on same diagonal
                        cost = overlap
                                + Math.Abs((matches[indexToSkip + counter1].QuerySequenceOffset - matches[indexToSkip + counter1].ReferenceSequenceOffset)
                                - (matches[indexToSkip + counter2].QuerySequenceOffset - matches[indexToSkip + counter2].ReferenceSequenceOffset));

                        if (matches[indexToSkip + counter2].Score + matches[indexToSkip + counter1].Length - cost > matches[indexToSkip + counter1].Score)
                        {
                            matches[indexToSkip + counter1].From = counter2;
                            matches[indexToSkip + counter1].Score = matches[indexToSkip + counter2].Score
                                    + matches[indexToSkip + counter1].Length
                                    - cost;
                            matches[indexToSkip + counter1].Adjacent = overlap;
                        }
                    }
                }

                // Find the match which has highest score
                best = 0;
                for (counter1 = 1; counter1 < clusterSize; counter1++)
                {
                    if (matches[indexToSkip + counter1].Score > matches[indexToSkip + best].Score)
                    {
                        best = counter1;
                    }
                }

                total = 0;
                endIndex = int.MinValue;
                startIndex = int.MaxValue;

                // TODO: remove below cast
                for (counter1 = best; counter1 >= 0; counter1 = (int)matches[indexToSkip + counter1].From)
                {
                    matches[indexToSkip + counter1].IsGood = true;
                    total += matches[indexToSkip + counter1].Length;
                    if (matches[indexToSkip + counter1].ReferenceSequenceOffset + matches[indexToSkip + counter1].Length > endIndex)
                    {
                        // Set the cluster end index
                        endIndex = matches[indexToSkip + counter1].ReferenceSequenceOffset + matches[indexToSkip + counter1].Length;
                    }

                    if (matches[indexToSkip + counter1].ReferenceSequenceOffset < startIndex)
                    {
                        // Set the cluster start index
                        startIndex = matches[indexToSkip + counter1].ReferenceSequenceOffset;
                    }
                }

                if (this.ScoreMethod == ClusterScoreMethod.MatchLength)
                {
                    score = total;
                }
                else 
                {
                    score = endIndex - startIndex;
                }

                // If the current score exceeds the minimum score
                // and the matches to cluster
                if (score >= this.MinimumScore)
                {
                    clusterMatches = new List<MatchExtension>();

                    for (counter1 = 0; counter1 < clusterSize; counter1++)
                    {
                        if (matches[indexToSkip + counter1].IsGood)
                        {
                            MatchExtension match = matches[indexToSkip + counter1];
                            if (matches[indexToSkip + counter1].Adjacent != 0)
                            {
                                match = new MatchExtension();
                                matches[indexToSkip + counter1].CopyTo(match);
                                match.ReferenceSequenceOffset += match.Adjacent;
                                match.QuerySequenceOffset += match.Adjacent;
                                match.Length -= match.Adjacent;
                            }

                            clusterMatches.Add(match);
                        }
                    }

                    // adding the cluster to list
                    if (0 < clusterMatches.Count)
                    {
                        clusters.Add(new Cluster(clusterMatches));
                    }
                }

                // Correcting the cluster indices
                for (counter1 = counter3 = 0; counter1 < clusterSize; counter1++)
                {
                    if (!matches[indexToSkip + counter1].IsGood)
                    {
                        if (counter1 != counter3)
                        {
                            matches[indexToSkip + counter3] = matches[indexToSkip + counter1];
                        }

                        counter3++;
                    }
                }

                clusterSize = counter3;
            }
            while (clusterSize > 0);
        }
示例#7
0
        public void TestMatchAndMatchExtensionToString()
        {
            Match match = new Match();
            match.Length = 20;
            match.QuerySequenceOffset = 33;

            MatchExtension matchExtn = new MatchExtension(match);
            matchExtn.ID = 1;
            matchExtn.Length = 20;

            string actualMatchExtnString = matchExtn.ToString();
            string actualMatchstring = match.ToString();
            string ExpectedMatchExtnString = "RefStart=0 QueryStart=33 Length=20 Score=0 WrapScore=0 IsGood=False";
            string ExpectedMatchString = "RefStart=0 QueryStart=33 Length=20";

            Assert.AreEqual(ExpectedMatchExtnString, actualMatchExtnString);
            Assert.AreEqual(actualMatchstring, ExpectedMatchString);
        }
示例#8
0
        public void TestClusterToString()
        {
            Match match = new Match();

            MatchExtension matchExtn1 = new MatchExtension(match);
            matchExtn1.ID = 1;
            matchExtn1.Length = 20;
            MatchExtension matchExtn2 = new MatchExtension(match);
            matchExtn2.ID = 2;
            matchExtn2.Length = 30;
            IList<MatchExtension> extnList = new List<MatchExtension>();
            extnList.Add(matchExtn1);
            extnList.Add(matchExtn2);

            Cluster clust = new Cluster(extnList);
            string actualString = clust.ToString();
            string expectedString = "RefStart=0 QueryStart=0 Length=20 Score=0 WrapScore=0 IsGood=False\r\nRefStart=0 QueryStart=0 Length=30 Score=0 WrapScore=0 IsGood=False\r\n".Replace ("\r\n", Environment.NewLine);
            Assert.AreEqual(actualString, expectedString);
        }