`

Human Gene Functions 动态规划

 
阅读更多

 

Human Gene Functions

Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 451 Accepted Submission(s): 277


Problem Description
It is well known that a human gene can be considered as a sequence, consisting of four nucleotides, which are simply denoted by four letters, A, C, G, and T. Biologists have been interested in identifying human genes and determining their functions, because these can be used to diagnose human diseases and to design new drugs for them.

A human gene can be identified through a series of time-consuming biological experiments, often with the help of computer programs. Once a sequence of a gene is obtained, the next job is to determine its function. One of the methods for biologists to use in determining the function of a new gene sequence that they have just identified is to search a database with the new gene as a query. The database to be searched stores many gene sequences and their functions – many researchers have been submitting their genes and functions to the database and the database is freely accessible through the Internet.

A database search will return a list of gene sequences from the database that are similar to the query gene. Biologists assume that sequence similarity often implies functional similarity. So, the function of the new gene might be one of the functions that the genes from the list have. To exactly determine which one is the right one another series of biological experiments will be needed.

Your job is to make a program that compares two genes and determines their similarity as explained below. Your program may be used as a part of the database search if you can provide an efficient one.

Given two genes AGTGATG and GTTAG, how similar are they? One of the methods to measure the similarity of two genes is called alignment. In an alignment, spaces are inserted, if necessary, in appropriate positions of the genes to make them equally long and score the resulting genes according to a scoring matrix.

For example, one space is inserted into AGTGATG to result in AGTGAT-G, and three spaces are inserted into GTTAG to result in –GT--TAG. A space is denoted by a minus sign (-). The two genes are now of equal length. These two strings are aligned:

AGTGAT-G
-GT--TAG

In this alignment, there are four matches, namely, G in the second position, T in the third, T in the sixth, and G in the eighth. Each pair of aligned characters is assigned a score according to the following scoring matrix.

* denotes that a space-space match is not allowed. The score of the alignment above is (-3)+5+5+(-2)+(-3)+5+(-3)+5=9.

Of course, many other alignments are possible. One is shown below (a different number of spaces are inserted into different positions):

AGTGATG
-GTTA-G

This alignment gives a score of (-3)+5+5+(-2)+5+(-1) +5=14. So, this one is better than the previous one. As a matter of fact, this one is optimal since no other alignment can have a higher score. So, it is said that the similarity of the two genes is 14.
 

 

Input
The input consists of T test cases. The number of test cases ) (T is given in the first line of the input. Each test case consists of two lines: each line contains an integer, the length of a gene, followed by a gene sequence. The length of each gene sequence is at least one and does not exceed 100.
 

 

Output
The output should print the similarity of each test case, one per line.
 

 

Sample Input
2 
7 AGTGATG 
5 GTTAG 
7 AGCTATT 
9 AGCTTTAAA 
 

 

Sample Output

 

14 
21 
#include<stdio.h>
int p[110][110];
int mat[102][102];
int max(int a,int b,int c)
{
	return(a>b?(a>c?a:c):(b>c?b:c));
}
int main()
{
	mat['A']['A'] = mat['C']['C'] = mat['G']['G'] = mat['T']['T'] = 5;
	mat['A']['C'] = mat['C']['A'] = mat['A']['T'] = mat['T']['A'] = mat['-']['T'] = -1;
	mat['A']['G'] = mat['G']['A'] = mat['C']['T'] = mat['T']['C'] = mat['G']['T'] = mat['T']['G'] = mat['-']['G'] = -2;
	mat['-']['A'] = mat['C']['G'] = mat['G']['C'] = -3;
	mat['-']['C'] = -4;
	//freopen("in.txt","r",stdin);
	int T,n1,n2,i,j;
	char str1[110],str2[110];
	scanf("%d",&T);
	while(T--)
	{
		scanf("%d%s%d%s",&n1,str1,&n2,str2);
		for(j=1;j<=n2;j++)
			p[0][j]=p[0][j-1]+mat['-'][str2[j-1]];
		for(i=1;i<=n1;i++)
			p[i][0]=p[i-1][0]+mat['-'][str1[i-1]];
		for(i=1;i<=n1;i++)
			for(j=1;j<=n2;j++)
p[i][j]=max(p[i-1][j-1]+mat[str1[i-1]][str2[j-1]],p[i-1][j]+mat['-'][str1[i-1]],p[i][j-1]+mat['-'][str2[j-1]]);
		printf("%d\n",p[n1][n2]);
	}
	return(0);
}

 

 

 

 

 

 

 

 

 

 

 

 

 

分享到:
评论

相关推荐

    acm pku 第1080题 Human Gene Functions c代码

    pku acm 第1080题Human Gene Functions c完整的代码,有详细的注释

    POJ1080-Human Gene Functions

    3. **序列比对**:可能需要将未知基因序列与已知的基因或功能区域进行比对,寻找相似性,这可能需要用到动态规划、Smith-Waterman或Needleman-Wunsch算法。 4. **生物信息学数据库查询**:可能需要访问像NCBI(美国...

    北大POJ1080-Human Gene Functions

    北大POJ1080-Human Gene Functions

    poj dp总结,动态规划分类

    - **1080**:“Human Gene Functions”——区间DP的经典应用。 - **1733**:“Parity game”——涉及状态压缩和位运算的技巧。 3. **高级动态规划** - **1015, 1635, 1636, 1671, 1682, 1692, 1704, 1717, 1722,...

    poj题目分类

    4. **1027 Human Gene Functions** - **背景**: 涉及到基因序列的分析与匹配。 - **解法**: 应用动态规划解决最长公共子序列等问题。 5. **1037 Gridland** - **背景**: 在网格中寻找最短路径。 - **解法**: ...

    北大Acm分类

    ##### 1027 Human Gene Functions **题目描述**:人类基因功能相关问题,可能是分析或预测基因的功能。 **解题思路**:可能需要对基因序列进行处理,找到合适的动态规划模型进行求解。 --- ##### 1037 Gridland ...

    acm ZJU分类

    - **1027 Human Gene Functions**: 字符串处理与模式匹配。 - **1052 Algernon's Noxious Emissions**: 图论基础应用,如广度优先搜索(BFS)和深度优先搜索(DFS)。 - **1409 Communication System**: 探讨网络流理论...

    浙江大学ACM题型分类

    1027 Human Gene Functions 求基因匹配度 DP:lcs的变形 1028 Flip and Shift 首尾相连的01串是否可经过以其中一位为中心的左右对调的若干次操作,成为0串+1串 math 1029 Moving Tables 连接同一通道的若干房间间...

    北大acm题库题型分类

    在北大ACM题库中,压缩存储的DP题目,如“1038 Bugs Integrated Inc.”,以及最长公共子串(LCS)类问题,如“1080 Human Gene Functions”,都是动态规划的典型应用。这类问题通常需要构建状态转移方程,以最优子...

    浙大oj的acm题分类

    **1027 Human Gene Functions** - 生物信息学中的DP应用 在生物信息学领域,DP可以用于基因序列比对、功能预测等复杂任务,是连接生物学与计算机科学的重要桥梁。 #### 5. **1037 Gridland** - 格网上的路径问题 ...

    ACM常用代码总结

    #### 代码示例:《Human Gene Functions》(题目编号:1080) 该代码示例主要解决的是DNA序列比对问题,即如何找到两个DNA序列之间的最大匹配得分。这个问题通常出现在生物信息学中,但其解决思路同样适用于一般的...

    ACM POJ PKU 最全题目分类

    4. **1027 - Human Gene Functions**:基因序列处理问题。 5. **1037 - Gridland**:网格地图上的路径规划问题。 6. **1052 - Algernons Noxious Emissions**:涉及环境评估的优化问题。 7. **1409 - Communication ...

    ZJU_ACM_All_Anwer 搞编程的都知道的浙江大学A 题库.本书 集了所有经 Z 题解集,集合并附 Mathimaticsumerical algorithms 数值算法

    1027 Human Gene Functions 简单题 1037 Gridland 简单题 1052 Algernon s Noxious Emissions 简单题 1409 Communication System 简单题,但是很容易看错~~~ 1425 Crossed Matchings 简单题 1438 ...

    浙江大学ACM题解/ZJU 题型分类

    1027 Human Gene Functions 简单题 1037 Gridland 简单题 1052 Algernon s Noxious Emissions 简单题 1409 Communication System 简单题,但是很容易看错~~~ 1425 Crossed Matchings 简单题 1438 ...

Global site tag (gtag.js) - Google Analytics