如何找到两个序列之间的最佳序列比对数?

发布于 2025-01-22 07:26:45 字数 619 浏览 7 评论 0原文

今天,我有两个序列,

S1 = CCGGGTTACCA

S2 = GGAGTTCA

不匹配得分为-1,差距得分为-2。

最佳序列比对有两个答案(最低罚款为-8)。

ans1 = G    -   G   A   G   T   T   -   C   -   A
       C    C   G   G   G   T   T   A   C   C   A


ans2 = -    G   G   A   G   T   T   -   C   -   A
       C    C   G   G   G   T   T   A   C   C   A


ans3 = G    -   G   A   G   T   T   -   -   C   A
       C    C   G   G   G   T   T   A   C   C   A


ans4 = -    G   G   A   G   T   T   -   -   C   A
       C    C   G   G   G   T   T   A   C   C   A

如果有任何算法可以计算最佳序列比对数(它将返回“ 4”)?

还是我该怎么办来解决这个问题?

谢谢

Today I have two sequences,

s1 = CCGGGTTACCA

s2 = GGAGTTCA

The Mismatch Score is -1, the Gap Score is -2.

The Optimal Sequence Alignment has two answers (miniumn penalty is -8).

ans1 = G    -   G   A   G   T   T   -   C   -   A
       C    C   G   G   G   T   T   A   C   C   A


ans2 = -    G   G   A   G   T   T   -   C   -   A
       C    C   G   G   G   T   T   A   C   C   A


ans3 = G    -   G   A   G   T   T   -   -   C   A
       C    C   G   G   G   T   T   A   C   C   A


ans4 = -    G   G   A   G   T   T   -   -   C   A
       C    C   G   G   G   T   T   A   C   C   A

If any algorithm can calculate the number of Optimal Sequence Alignment (it will return "4") ?

Or what can I do to solve this problem?

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

霊感 2025-01-29 07:26:45

我的分数系统在图片上。

我执行Needleman-Wunsch算法(动态程序)来完成表。

最后,我放弃只找到最佳序列比对的数量。

我进行回顾以找到所有可能的答案并插入集合,因此集合的大小是我的答案。

set<pair<string, string>> st;
void findAll(string A, string B, int gap, int mis, int i, int j, string s1, string s2) {

    if (s1.size() == max(A.size(), B.size()) && s2.size() == max(A.size(), B.size())) {
        reverse(begin(s1), end(s1));
        reverse(begin(s2), end(s2));
        st.insert({s1, s2});
        return;
    }

    if (i != 0 || j != 0) {
        if (i == 0) {
            findAll(A, B, gap, mis, i, j - 1, s1 + "-", s2 + B[j - 1]);
        } else if (j == 0) {
            findAll(A, B, gap, mis, i - 1, j, s1 + A[i - 1], s2 + "-");
        } else {
            if ((A[i - 1] == B[j - 1] && dp[i][j] == dp[i - 1][j - 1]) || (A[i - 1] != B[j - 1] && dp[i][j] == dp[i - 1][j - 1] + mis)) {
                findAll(A, B, gap, mis, i - 1, j - 1, s1 + A[i - 1], s2 + B[j - 1]);
            }

            if (dp[i][j] == dp[i - 1][j] + gap) {
                findAll(A, B, gap, mis, i - 1, j, s1 + A[i - 1], s2 + "-");
            }

            if (dp[i][j] == dp[i][j - 1] + gap) {
                findAll(A, B, gap, mis, i, j - 1, s1 + "-", s2 + B[j - 1]);
            }
        }
    }
}

enter image description here

My score system is on the picture.

I do the Needleman-Wunsch algorithm (dynamic program) to complete the table.

Finally, I give up to only find the number of Optimal Sequence Alignment.

I trackback to find all the possible answers and insert the set, so the the size of set is my answer.

set<pair<string, string>> st;
void findAll(string A, string B, int gap, int mis, int i, int j, string s1, string s2) {

    if (s1.size() == max(A.size(), B.size()) && s2.size() == max(A.size(), B.size())) {
        reverse(begin(s1), end(s1));
        reverse(begin(s2), end(s2));
        st.insert({s1, s2});
        return;
    }

    if (i != 0 || j != 0) {
        if (i == 0) {
            findAll(A, B, gap, mis, i, j - 1, s1 + "-", s2 + B[j - 1]);
        } else if (j == 0) {
            findAll(A, B, gap, mis, i - 1, j, s1 + A[i - 1], s2 + "-");
        } else {
            if ((A[i - 1] == B[j - 1] && dp[i][j] == dp[i - 1][j - 1]) || (A[i - 1] != B[j - 1] && dp[i][j] == dp[i - 1][j - 1] + mis)) {
                findAll(A, B, gap, mis, i - 1, j - 1, s1 + A[i - 1], s2 + B[j - 1]);
            }

            if (dp[i][j] == dp[i - 1][j] + gap) {
                findAll(A, B, gap, mis, i - 1, j, s1 + A[i - 1], s2 + "-");
            }

            if (dp[i][j] == dp[i][j - 1] + gap) {
                findAll(A, B, gap, mis, i, j - 1, s1 + "-", s2 + B[j - 1]);
            }
        }
    }
}

enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文