Human Gene Functions

2023-11-12

http://acm.hdu.edu.cn/showproblem.php?pid=1080

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
 &&&&&&&&&&&&&&&&&
以第一个为例:
初始化:第一行是长度为5的字符串全部匹配' '的时候的最大值,同理竖着的一行是长度为7的字符串全部匹配为' '的时候的最大值;
0 -2 -3 -4 -7 -9
-3 0 0 0 0 0
-5 0 0 0 0 0
-6 0 0 0 0 0
-8 0 0 0 0 0
-11 0 0 0 0 0
-12 0 0 0 0 0
-14 0 0 0 0 0
接着对其处理;(长度为5)第i个字母,要么与(长度为7)第j个字母匹配;要么匹配空格;
0 -2 -3 -4 -7 -9
-3 -2 -3 -4 1 -1
-5 2 1 0 -1 6
-6 1 7 6 3 5
-8 -1 5 5 4 8
-11 -4 2 4 10 8
-12 -5 1 7 9 8
-14 -7 -1 5 7 14




#include<stdio.h>
#include<iostream>
#include<string.h>
using namespace std;
int map[5][5]=
{
	  {5, -1, -2, -1, -3},
      {-1, 5, -3, -2, -4},
      {-2, -3, 5, -2, -2},
      {-1, -2, -2, 5, -1},
      {-3, -4, -2, -1,INT_MIN}
};
int MAX(int a,int b,int c)
{
	int tmp=a>b?a:b;
	return tmp>c?tmp:c;
}
char s1[200],s2[200];
int dp[200][200];
int main()
{
	int i,j,k,m,n,ncase;
	scanf("%d",&ncase);
	int t[256];
	t['A']=0;t['C']=1;t['G']=2;
	t['T']=3;t[' ']=4;
	while(ncase--)
	{
		scanf("%d %s",&m,s1);
		scanf("%d %s",&n,s2);
		//printf("s1==%s s2==%s\n",s1,s2);
		dp[0][0]=0;
		for(i=1;i<=n;i++)
		{
		   dp[0][i]=dp[0][i-1]+map[4][t[s2[i-1]]];
		   //printf("dp[0][%d]==%d ",i,dp[0][i]);
		}
		//printf("\n");
		for(i=1;i<=m;i++)
		{
		    dp[i][0]=dp[i-1][0]+map[4][t[s1[i-1]]];
		    //printf("dp[%d][0]==%d ",i,dp[i][0]);
		}
		/*for(i=0;i<=m;i++)
		{
			for(j=0;j<=n;j++)
			{
				printf("%d ",dp[i][j]);
			}
			printf("\n");
		}*/	
		for(i=1;i<=m;i++)
		{
			for(j=1;j<=n;j++)
			{
				int m1=dp[i-1][j-1]+map[t[s1[i-1]]][t[s2[j-1]]];
				int m2=dp[i-1][j]+map[t[s1[i-1]]][4];
				int m3=dp[i][j-1]+map[t[s2[j-1]]][4];
				int m4=MAX(m1,m2,m3);
				dp[i][j]=m4;
			}
		}
		/*for(i=0;i<=m;i++)
		{
			for(j=0;j<n;j++)
			{
				printf("%d ",dp[i][j]);
			}
			puts("");
		}*/
		printf("%d\n",dp[m][n]);
	}
	return 0;
}




本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Human Gene Functions 的相关文章

  • 如何在 Swift 方法中将字典作为参数传递?

    我在代码中创建了以下方法 func SignIn objDictionary Dictionary
  • 如何在自定义短代码中获取 WooCommerce 产品对象以避免错误

    我有一个函数 我试图使用产品 id 获取当前产品的产品简短描述 但我不断收到未捕获错误 调用成员函数 get short description on bool in 我有以下简码函数 我试图使用产品 ID 获取当前 WooCommerce
  • 在 SQLAlchemy 中选择 NULL 值

    这是我的 PostgreSQL 表 test gt create table people name varchar primary key marriage status varchar test gt insert into peopl
  • 将参数传递给 jQuery 每个函数

    当使用 jQuery each 函数时 有没有办法将参数传递给被调用的函数 something each build function build vars 我知道我可以简单地执行以下操作 但我想知道是否有一种方法可以直接传递参数 some
  • 什么时候数据库被称为嵌入式数据库?

    术语 嵌入式数据库 与 数据库 具有不同的含义吗 我见过的嵌入式数据库有两种定义 嵌入式数据库就像专门为 嵌入式 空间 移动设备等 设计的数据库系统一样 这意味着它们在紧张的环境中 内存 CPU 方面 可以合理地执行 嵌入式数据库就像不需要
  • 如果 CodeIgniter 方法不存在,则重定向到默认方法。

    我正在使用 CodeignIter 并且正在寻找一种在被调用方法不存在时为单个控制器编写自定义处理例程的方法 假设你打电话www website com components login In the components控制器 没有一个方
  • 在实时计算机上更新(或替换)整个数据库表的最佳方法是什么?

    我每周都会收到一个数据源 我将对其进行解析并放入数据库中 数据每周不会有太大变化 但我应该定期更新数据库 除了每周更新外 数据是静态的 目前重建整个数据库不是问题 但最终该数据库将上线 人们可以在我重建数据库时查询该数据库 数据量并不小 几
  • 在 MySQL 中对连续值进行分组并向这些组添加 id

    我有一个简单的表 我需要确定四行的组 这些组不是连续的 但每行的每一行的值都有 1 例如 language id C 16 C 17 Java 18 Python 19 HTML 65 JavaScript 66 PHP 67 Perl 6
  • ABSMIDDLE 在 Firefox 和 Chrome 上的工作方式不同吗?

    我有一个图标图像和文本 如下所示 一切的代码来源是 img src align left My Title Here 问题在于 与 Firefox 相比 Chrome 中的图标没有与标题垂直对齐 我觉得absmiddle根本不起作用 有什么
  • 数百个别名/同义词与数据库表的完全限定名称

    考虑到多个模式中的数百个数据库表 在创建存储过程和视图时 您是否建议使用别名 同义词或完全限定名称 给定一些 schema table 像这样 Orders OrderHeader Production LineThroughput Sal
  • JQgrid - 没有这样的方法 gridunload

    我使用的是最新版本的jqGrid 4 8 2 有一些奇怪的地方 文件夹中 或 github 中 没有文件 grid custom js In wiki http www trirand com jqgridwiki doku php id
  • Elasticsearch 聚合过滤器

    因为我在谷歌上找不到任何东西 是否可以在elasticsearch中过滤聚合 我正在考虑这样的事情 获取 SOME object X gt 100 的所有对象 提前致谢 编辑 样本数据 我有以下文档结构 docKey 1 value 2 d
  • 什么时候不应该使用 Cassandra? [关闭]

    Closed 这个问题是基于意见的 help closed questions 目前不接受答案 相关话题已经有很多讨论了卡桑德拉 http cassandra apache org lately Twitter Digg Facebook
  • 通过 Matlab 访问 Physionet 的 ptbdb 中的数据库

    我首先设置系统 old path which rdsamp if isempty old path rmpath old path 1 end 8 end wfdb url http physionet org physiotools ma
  • CloudKit 通过 cron 作业发送推送通知?

    我正在创建一个大学餐饮菜单应用程序 在其中我需要根据每日菜单发送推送通知 最初 我计划通过 Heroku 将用户数据存储在数据库中 并使用 cron 作业将数据库中的数据与每日菜单进行比较 并向用户发送适当的通知 然而 在 Cloudkit
  • 社交应用程序的数据库设计和优化注意事项

    通常的情况 我有一个简单的应用程序 允许人们上传照片并关注其他人 因此 每个用户都会有类似 墙 或 活动源 的东西 他或她可以在其中看到他 她的朋友 他或她关注的人 上传的最新照片 大多数功能都很容易实现 然而 当涉及到这个历史活动源时 由
  • 什么是数据库池?

    我只是想了解数据库连接池的概念以及它是如何实现的 数据库联系池是一种用于保持数据库连接打开的方法 以便其他人可以重用它们 通常 打开数据库连接是一项昂贵的操作 尤其是在数据库位于远程的情况下 您必须打开网络会话 进行身份验证 检查授权等等
  • Scrapy - 持续从数据库中获取要爬取的url

    我想不断地从数据库中获取要爬行的网址 到目前为止 我成功地从基地获取了 url 但我希望我的蜘蛛继续从该基地读取 因为该表将由另一个线程填充 我有一个管道 一旦爬行 工作 就会从表中删除 url 换句话说 我想使用我的数据库作为队列 我尝试
  • 如何在 Visual Studio 中更改 Azure 数据库表的列顺序

    我整个下午都在寻找在 MS Visual Studio 2022 中重新排序 Azure 数据库表列的方法 没有运气 在其他应用程序中 可以通过拖动或剪切和粘贴轻松重新排列列 这里无能为力 此时 我什至不确定可以在 VS 中移动列 我只对
  • Python 分析:“‘select.poll’对象的‘poll’方法”是什么?

    我已经使用 python 分析了我的 python 代码cProfile模块并得到以下结果 ncalls tottime percall cumtime percall filename lineno function 13937860 9

随机推荐

  • 7 SpringBoot整合RocketMQ发送单向消息

    发送单向消息是指producer向 broker 发送消息 执行 API 时直接返回 不等待broker 服务器的结果 这种方式主要用在不特别关心发送结果的场景 举例 日志发送 RocketMQTemplate给我们提供了sendOneWa
  • 通过Hyperic-hq产品的基础包sigar.jar来实现服务器状态数据的获取

    通过Hyperic hq产品的基础包sigar jar来实现服务器状态数据的获取 Sigar jar包是通过本地方法来调用操作系统API来获取系统相关数据 Windows操作系统下Sigar jar依赖sigar amd64 winnt d
  • 安卓培训开发!通宵都要看完这个Android关键技术点,看这一篇就够了!

    前言 上回承诺过大家 一定会出 HTTP 的系列文章 今天终于整理完成了 作为一个 web 开发 HTTP 几乎是天天要打交道的东西 但我发现大部分人对 HTTP 只是浅尝辄止 对更多的细节及原理就了解不深了 在面试的时候感觉非常吃力 这篇
  • C/C++文件操作、输入输出备忘

    1 C 文件操作 1 1 普通ascii字符 1 cin gt gt 结束条件 Enter Space Tab键 读取结束条件 while cin gt gt value cin gt gt 后便可以跟整型 浮点型 字符串 string c
  • TensorFlow中读取图像数据的三种方式

    Update on 2019 06 18 从tesorflow1 11之后 大概是这个版本号 谷歌推出了tf data模块来读取数据 甚至在tensorflow2 0中 取消了数据队列管道 所以我建议大家学习tf data模块 未来我也会做
  • JavaWeb——Servlet详解

    文章目录 什么是Servlet Servlet及其子类 Servlet中常用方法 init service distory Servlet的生命周期 Servlet初始化时机 钝化和活化 Http协议 Session 会话跟踪技术 常用AP
  • Content-encoding: gzip 请求接口响应结果带有乱码解决办法

    问题 在请求接口时 接口响应结果乱码 通过平常的编码格式转化来解码不能解决 观察接口的响应内容编码为Content encoding gzip 解决办法 public static String uncompressString Strin
  • PostgreSQL 系统参数调整及并行设置(转)

    转自 https yq aliyun com teams 5 OS 准备 yum y install coreutils glib2 lrzsz sysstat e4fsprogs xfsprogs ntp readline devel z
  • 如何写好代码?

    想要的都拥有 失去的都释怀 2020鼠于你 文章目录 1 写代码容易吗 2 设计模式 3 软件生命周期 4 技术业务架构 5 轮子 6 开源 7 真相 1 写代码容易吗 代码容易写 也不容易写 但做人不能一直太中立 那我选择好代码不容易写吧
  • 【Linux】make和makefile详解

    在linux系统上编译大一点的项目时 会用到make makefile文件 1 make与makefile 利用make工具 我们可以将大型的开发项目分解成为多个更易于管理的模块 对于一个包括几百个源文件的应用程序 使用make和makef
  • 卷积神经网络之计算机视觉

    深度学习给机器视觉带来了巨大的进步 深度学习和机器视觉能够帮助机器分清汽车和周围的行人 并且帮助汽车避开他们 机器视觉而且能够使得人脸识别更加高效和精准 计算机视觉标志着新兴应用的产生 通过这些工具 你能产生新的产品和应用 其次即使你未在机
  • 区块链技术栈-脚本系统

    脚本系统 脚本系统在区块链中是个比较抽象的概念 也是其中一个很重要的功能 可以说区块链系统之所以能形成一个有价值的网络 依靠的就是脚本系统 他就像是一个发动机一样 驱动着区块链系统不断进行着各种数据的收发 所谓脚本 就是指一组程序规则 在区
  • 使用scroll-view实现tabs(增加动画过渡效果)

    文章目录 前情提要 组件 scroll view 小程序项目 app json pages index index wxml pages index index wxss pages index index js 相关链接 前情提要 组件
  • IDEA操作技巧:一些常用且实用的插件

    CodeGlance 可帮助我们快速定位代码 下载之后会在IDEA的编辑区右侧显示一个代码进度条 设置方式 打开设置可以看到有一个codeGlance栏 点击可以进行设置 BackgroundImage 用于设置IDEA的背景图片 设置方式
  • Probabilistic Anchor Assignment with IoU Prediction for Object Detection论文阅读翻译 - 2020ECCV

    Probabilistic Anchor Assignment with IoU Prediction for Object Detection论文阅读翻译 目录 Probabilistic Anchor Assignment with I
  • 西门子plc s7-200写的先进先出范例 用fifo

    本人最近写了一个五台锅炉共用一个冷却水泵的程序 开始打算用时间戳来记录每台锅炉需要冷却的时间 然后用时间进行排序 但是后来无意中发现fifo可以实现表的先进先出的功能 就抱着学习的目的 用fifo写了本程序 第一步 先要建立一个表如下图 上
  • 分布式三高商城系统前言

    商城系统前言 前言 本商城致力于为中大型企业打造一个功能完整 易于维护的微服务B2B2C电商商城系统 采用主流的微服务技术实现 完全从零开始带领大家完成一个商城系统 包括基础的项目环境搭建 后端业务代码编写 前端页面等 微服务设计 mall
  • 多租户SaaS管理系统框架设计:多租户,多组织,用户区别

    数商云 已认证的官方帐号 转载自 多租户SaaS管理系统框架设计 多租户 多组织 用户区别 知乎 今天谈下云平台下的多租户架构 不论是在公有云还是私有云平台 是设计一个面向最终组织或用户的SaaS应用还是面向业务系统的PaaS平台 多租户都
  • 【物流配送的车辆路径问题】

    物流配送的车辆路径问题 提示 这里可以添加系列文章的所有文章的目录 目录需要自己手动添加 Two echelon capacitated vehicle routing problem with grouping constraints a
  • Human Gene Functions

    http acm hdu edu cn showproblem php pid 1080 Problem Description It is well known that a human gene can be considered as