DNA Consensus String
来源:互联网 发布:kindle pc阅读软件 编辑:程序博客网 时间:2024/06/04 17:42
Figure 1.
``Thymine-Adenine-Adenine-Cytosine-Thymine-Guanine-Cytosine-Cytosine-Guanine-Adenine-Thymine"
Then we can represent the above DNA strand with the string ``TAACTGCCGAT." The biologist Prof. Ahn found that a gene X commonly exists in the DNA strands of five different kinds of animals, namely dogs, cats, horses, cows, and monkeys. He also discovered that the DNA sequences of the gene X from each animal were very alike. See Figure 2.
Prof. Ahn thought that humans might also have the gene X and decided to search for the DNA sequence of X in human DNA. However, before searching, he should define a representative DNA sequence of gene X because its sequences are not exactly the same in the DNA of the five animals. He decided to use the Hamming distance to define the representative sequence. The Hamming distance is the number of different characters at each position from two strings of equal length. For example, assume we are given the two strings ``AGCAT" and ``GGAAT." The Hamming distance of these two strings is 2 because the 1st and the 3rd characters of the two strings are different. Using the Hamming distance, we can define a representative string for a set of multiple strings of equal length. Given a set of strings S = s1,..., sm of length n , the consensus error between a string y of length n and the set S is the sum of the Hamming distances between y and each si in S . If the consensus error between y and S is the minimum among all possible strings y of length n , y is called a consensus string of S . For example, given the three strings ``AGCAT" ``AGACT" and ``GGAAT" the consensus string of the given strings is ``AGAAT" because the sum of the Hamming distances between ``AGAAT" and the three strings is 3 which is minimal. (In this case, the consensus string is unique, but in general, there can be more than one consensus string.) We use the consensus string as a representative of the DNA sequence. For the example of Figure 2 above, a consensus string of gene X is ``GCAAATGGCTGTGCA" and the consensus error is 7.
Input
Output
Sample Input
3 5 8 TATGATAC TAAGCTAC AAAGATCC TGAGATAC TAAGATGT 4 10 ACGTACGTAC CCGTACGTAG GCGTACGTAT TCGTACGTAA 6 10 ATGTTACCAT AAGTTACGAT AACAAAGCAA AAGTTACCTT AAGTTACCAA TACTTACCAA
Sample Output
TAAGATAC 7 ACGTACGTAA 6 AAGTTACCAA 12
题目大意:
输出的字符串对应的每个字符都是输入字符数组对应每列的最多的字符, 如果最多的字符有多个, 那就选择最小的字符。然后对比输出的字符与输入的每一串,得到与输出字符串所有不同个数的和。
#include<iostream>#include<stdio.h>#include<string.h>#include<algorithm>#define N 100#define M 1100using namespace std;char arr[N][M], s[M];int str[4];int main(){int k, n, m;int i, j, h, max, g, ans, end;scanf("%d", &k);while (k --){h = 0;end = 0;memset(s, 0, sizeof(s));scanf("%d%d", &n, &m);for (i = 0; i < n; i ++){scanf("%s", arr[i]);}for (i = 0; i < m; i ++){max = 0;memset(str, 0, sizeof(str));for (j = 0; j < n; j ++){if (arr[j][i] == 'A'){str[0] ++;}else if (arr[j][i] == 'C'){str[1] ++;}else if (arr[j][i] == 'G'){str[2] ++;}else if (arr[j][i] == 'T'){str[3] ++;}}for (g = 0; g < 4; g ++){if (max < str[g]){max = str[g];ans = g;}}end = end + n - max;if (ans == 0){s[h ++] = 'A';}else if (ans == 1){s[h ++] = 'C';}else if (ans == 2){s[h ++] = 'G';}else{s[h ++] = 'T';}}printf("%s\n", s);printf("%d\n", end);}return 0;}
- DNA Consensus String
- uva1368 - DNA Consensus String
- Uva1368 DNA Consensus String
- Uva1368 - DNA Consensus String
- UVA1368- DNA Consensus String
- UVA_1368 - DNA Consensus String
- 1368 - DNA Consensus String
- UVaOJ1368 - DNA Consensus String
- DNA Consensus String
- 1368 - DNA Consensus String
- 1368 - DNA Consensus String
- UVA1368 - DNA Consensus String
- DNA Consensus String
- uva1368 - DNA Consensus String
- DNA Consensus String
- DNA Consensus String
- uva1368 - DNA Consensus String
- [UVA1368]DNA Consensus String
- 关于代码评审的微博讨论汇集
- 未将对象引用设置到对象的实例
- hdu 1257 最少拦截系统
- Oracle中的注意点
- 基于Hadoop HBase的一淘搜索离线系统
- DNA Consensus String
- 服务器组件加载失败,创建游戏房间失败
- hdu KM小集(中低难度)
- 工作中shell使用技巧【想到多少写多少】
- QJsonDocument Class
- 实例讲解如何才能让你的SQL运行得更快
- [ jQuery ] jQuery操作select、checkbox、radio详细讲解!
- 大数据引发的变革与企业面临的挑战
- struts2整合tiles及配置