DNA比对
【编程题】(满分27分)
脱氧核糖核酸即常说的DNA,是一类带有遗传信息的生物大分子。它由4种主要的脱氧核苷酸(dAMP、dGMP、dCMT和dTMP)通过磷酸二酯键连接而成。这4种核苷酸可以分别记为:A、G、C、T。
DNA携带的遗传信息可以用形如:AGGTCGACTCCA.... 的串来表示。DNA在转录复制的过程中可能会发生随机的偏差,这才最终造就了生物的多样性。
为了简化问题,我们假设,DNA在复制的时候可能出现的偏差是(理论上,对每个碱基被复制时,都可能出现偏差):
1. 漏掉某个脱氧核苷酸。例如把 AGGT 复制成为:AGT
2. 错码,例如把 AGGT 复制成了:AGCT
3. 重码,例如把 AGGT 复制成了:AAGGT
如果某DNA串a,最少要经过 n 次出错,才能变为DNA串b,则称这两个DNA串的距离为 n。
例如:AGGTCATATTCC 与 CGGTCATATTC 的距离为 2
你的任务是:编写程序,找到两个DNA串的距离。
【输入、输出格式要求】
用户先输入整数n(n<100),表示接下来有2n行数据。
接下来输入的2n行每2行表示一组要比对的DNA。(每行数据长度<10000)
程序则输出n行,表示这n组DNA的距离。
例如:用户输入:
3
AGCTAAGGCCTT
AGCTAAGGCCT
AGCTAAGGCCTT
AGGCTAAGGCCTT
AGCTAAGGCCTT
AGCTTAAGGCTT
则程序应输出:
1
1
2
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <ctime>
#include <iomanip>
using namespace std;
const int INF=0x7ffffff;
const double EXP=1e-;
const int MS=;
typedef long long LL;
int dp[MS][MS]; int minv(int a,int b,int c)
{
return a>b?(b>c?c:b):(a>c?c:a); // min(a,min(b,c))
}
/*
ACT
ACTT dp[i][j]=dp[i][j-1]+1; ACTT
ACT dp[i][j]=dp[i-1][j]+1 丢失等效于增加 ACT
ACG dp[i][j]=d[i-1][j-1]+1 */ void solve(string &s1,string &s2)
{
int len1=s1.length();
int len2=s2.length();
for(int i=;i<=len1;i++)
dp[i][]=i;
for(int i=;i<=len2;i++)
dp[][i]=i;
for(int i=;i<=len1;i++)
{
for(int j=;j<=len2;j++)
{
if(s1[i-]==s2[j-])
dp[i][j]=dp[i-][j-];
else
{ // 增加 减少 修改
dp[i][j]=minv(dp[i][j-]+,dp[i-][j]+,dp[i-][j-]+);
}
}
}
cout<<dp[len1][len2]<<endl;
return ;
} int main()
{
int n;
string str1,str2;
cin>>n;
while(n--)
{
cin>>str1>>str2;
solve(str1,str2);
}
return ;
}
DNA比对的更多相关文章
- [LeetCode] Repeated DNA Sequences 求重复的DNA序列
All DNA is composed of a series of nucleotides abbreviated as A, C, G, and T, for example: "ACG ...
- DNA解链统计物理
来源:Kerson Huang, Lectures on Statistical Physics and Protein Folding, pp 24-25 把双链DNA解开就像拉拉链.设DNA有\( ...
- AC自动机+DP HDOJ 2457 DNA repair(DNA修复)
题目链接 题意: 给n串有疾病的DNA序列,现有一串DNA序列,问最少修改几个DNA,能使新的DNA序列不含有疾病的DNA序列. 思路: 构建AC自动机,设定end结点,dp[i][j]表示长度i的前 ...
- [Leetcode] Repeated DNA Sequences
All DNA is composed of a series of nucleotides abbreviated as A, C, G, and T, for example: "ACG ...
- 利用Python【Orange】结合DNA序列进行人种预测
http://blog.csdn.net/jj12345jj198999/article/details/8951120 coursera上 web intelligence and big data ...
- cfDNA(circulating cell free DNA)全基因组测序
参考资料: [cfDNA专题]cell-free DNA在非肿瘤疾病中的临床价值(好) ctDNA, cfDNA和CTCs有什么区别吗? cfDNA你懂多少? 新发现 | 基因是否表达,做个cfDNA ...
- 3.Complementing a Strand of DNA
Problem In DNA strings, symbols 'A' and 'T' are complements of each other, as are 'C' and 'G'. The r ...
- 2. Transcribing DNA into RNA
Problem An RNA string is a string formed from the alphabet containing 'A', 'C', 'G', and 'U'. Given ...
- 1.Counting DNA Nucleotides
Problem A string is simply an ordered collection of symbols selected from some alphabet and formed i ...
- leetcode 187. Repeated DNA Sequences 求重复的DNA串 ---------- java
All DNA is composed of a series of nucleotides abbreviated as A, C, G, and T, for example: "ACG ...
随机推荐
- bzoj 2049 [Sdoi2008]Cave 洞穴勘测(LCT)
[题目链接] http://www.lydsy.com/JudgeOnline/problem.php?id=2049 [题意] 给定森林,可能有连边或断边的操作,回答若干个连通性的询问. [思路] ...
- 关于Tokenizer与TokenFilter的区别
TokenStream是一个能在被调用后产生语汇单元流的类,但是 TokenStream 类有两个不同的类型:Tokenizer 类和 TokenFilter 类.这两个类都是从抽象类TokenStr ...
- HDU4864:Task(贪心)
题意: 给出n个机器和m个任务,对于一天来说,每个机器有最大工作时间xi,可接受最大等级yi,每个任务有一个工作时间xi,一个等级yi,可获价值为500*xi+2*yi,任务需要在一台机器一天内完成, ...
- Codevs No.1052 地鼠游戏
2016-05-31 18:22:32 题目链接: 地鼠游戏 Codevs No.1245 题目大意: 打地鼠,一开始所有地鼠都出现,但是维持的时间(s)和击中所得的积分各不同,求出采用最优策略(1s ...
- Git 一些日常使用积累
本来不想写这样的东西的,因为随处谷歌百度都有一大堆!但是,我却总是在百度谷歌,我在想,为什么我不自己写一篇存进来,顺便加深印象呢?既然这样,这篇随笔,就真的变成随笔好了,随时修改,随时添加. Git ...
- mongodb基础系列——数据库查询数据返回前台JSP(二)
上篇博客论述了,数据库查询数据返回前台JSP.博客中主要使用Ajax调用来显示JSON串,来获取其中某一个字段,赋给界面中的某一个控件. 那这篇博客中,我们讲解,把后台List传递JSP展示. Lis ...
- Epplus 使用的简单介绍
操作Excel的主要有以下类库: MyXls(http://sourceforge.net/projects/myxls/) Koogra(http://sourceforge.net/project ...
- flash的dragonbone插件导入cocos2d的注意事项
一:Flash版本号应该为CS 6.0,低版本号不提供支持 二:新建flash项目的时候应该选择ActionScript3.0 三:动画中仅仅有两种元素,一个是"元件",还有一个是 ...
- Codeforces Round #280 (Div. 2) C. Vanya and Exams 贪心
C. Vanya and Exams Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/492/pr ...
- POJ 2420 A Star not a Tree? 爬山算法
B - A Star not a Tree? Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/co ...