Exemple #1
0
        private AlignmentResult GetAlignmentByAncestorsMatrix(string S1, string S2, int[,] ancestorsMatrix, double[,] scoringMatrix, int maxScoreI, int maxScoreJ)
        {
            int k = maxScoreI;
            int l = maxScoreJ;

            AlignmentResult result = new AlignmentResult();

            while (scoringMatrix[k, l] > 0)
            {
                if (ancestorsMatrix[k, l] == 0)
                {
                    result.S1 = S1[k] + result.S1;
                    result.S2 = S2[l] + result.S2;
                    k         = k - 1;
                    l         = l - 1;
                }
                else if (ancestorsMatrix[k, l] == 1)
                {
                    result.S1 = S1[k] + result.S1;
                    result.S2 = "-" + result.S2;
                    k         = k - 1;
                }
                else
                {
                    result.S1 = "-" + result.S1;
                    result.S2 = S2[l] + result.S2;
                    l         = l - 1;
                }
            }

            if (k < l)
            {
                result.S1 = new string('-', l - k) + S1.Substring(0, k) + "***" + result.S1 + "***";
                result.S2 = S2.Substring(0, l) + "***" + result.S2 + "***";
            }
            else
            {
                result.S1 = S1.Substring(0, k) + "***" + result.S1 + "***";
                result.S2 = new string('-', k - l) + S2.Substring(0, l) + "***" + result.S2 + "***";
            }
            result.S1 = result.S1 + S1.Substring(maxScoreI, S1.Length - maxScoreI);
            result.S2 = result.S2 + S2.Substring(maxScoreJ, S2.Length - maxScoreJ);
            if (result.S1.Length < result.S2.Length)
            {
                result.S1 = result.S1 += new string('-', result.S2.Length - result.S1.Length);
            }
            else
            {
                result.S2 = result.S2 += new string('-', result.S1.Length - result.S2.Length);
            }

            return(result);
        }
        private AlignmentResult GetAlignmentByAncestorsMatrix(string S1, string S2, int[,] ancestors)
        {
            int k = S1.Length - 1;
            int l = S2.Length - 1;

            AlignmentResult result = new AlignmentResult();

            while (k > 0 && l > 0)
            {
                if (ancestors[k, l] == 0)
                {
                    result.S1 = S1[k] + result.S1;
                    result.S2 = S2[l] + result.S2;
                    k         = k - 1;
                    l         = l - 1;
                }
                else if (ancestors[k, l] == 1)
                {
                    result.S1 = S1[k] + result.S1;
                    result.S2 = "-" + result.S2;
                    k         = k - 1;
                }
                else
                {
                    result.S1 = "-" + result.S1;
                    result.S2 = S2[l] + result.S2;
                    l         = l - 1;
                }
            }
            if (k >= 0)
            {
                result.S1 = S1.Substring(0, k + 1) + result.S1;
                result.S2 = new string('-', k + 1) + result.S2;
            }
            if (l >= 0)
            {
                result.S1 = new string('-', l + 1) + result.S1;
                result.S2 = S2.Substring(0, l + 1) + result.S2;
            }
            return(result);
        }
Exemple #3
0
        private AlignmentResult GetAlignmentByAncestorsMatrix(string S1, string S2, StepType[,] pointersM, StepType[,] pointersGaps1,
                                                              StepType[,] pointersGaps2, StepType startStep)
        {
            int k = S1.Length;
            int l = S2.Length;

            AlignmentResult result = new AlignmentResult();

            StepType curStep = startStep;

            while (k > 0 || l > 0)
            {
                if (curStep == StepType.M && k >= 0 && l >= 0)
                {
                    result.S1 = S1[k - 1] + result.S1;
                    result.S2 = S2[l - 1] + result.S2;
                    curStep   = pointersM[k, l];
                    k--;
                    l--;
                }
                else
                if ((k > 0 && curStep == StepType.Gaps2) || (k > 0 && l <= 0))
                {
                    result.S1 = S1[k - 1] + result.S1;
                    result.S2 = "-" + result.S2;
                    curStep   = pointersGaps2[k, Math.Max(0, l)];
                    k--;
                }
                else if ((l > 0 && curStep == StepType.Gaps1) || (l > 0 && k <= 0))
                {
                    result.S1 = "-" + result.S1;
                    result.S2 = S2[l - 1] + result.S2;
                    curStep   = pointersGaps1[Math.Max(k, 0), l];
                    l--;
                }
            }
            return(result);
        }