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 的相关文章

  • 如何通过csv文件仅更新sql表的一列

    我有一个 csv 文件包含一些数据 在我的 Sql 数据库中 我有一个具有多个列名的表 现在我只想通过 csv 文件更新一列 谢谢 你可以这样尝试 Import the csv file to a temp table Update you
  • C# 数据库包装设计

    我正在为 C 设计一个数据库包装器 以下是我有两个选择 选项A class DBWrapper IDisposable private SqlConnection sqlConn public DBWrapper sqlConn new S
  • 在数据库中存储多维数组:关系数组还是多维数组?

    我读过很多类似的帖子多维到单维 多维数据库等等 但没有一个答案有帮助 我确实在谷歌上找到了很多文档 但只提供了背景信息 并没有回答手头的问题 我有很多彼此相关的字符串 PHP 脚本中需要它们 结构是分层的 这是一个例子 A AA AAA A
  • 用户反馈系统的正确数据库模型(一个有趣的案例)

    我正在使用 PHP 和 Yii Framework 开发一个应用程序 我一直在考虑最适合给定功能的数据库结构 这就是我的想法 但我并不是 100 肯定应该这样做 因此我决定询问社区 应用程序说明 注册用户可以参加活动 每个事件都可以有一个
  • 带有 TextWrapping 的 WPF CheckBox 样式

    我需要申请一个TextWrapping在 WPF 中CheckBox 请看这两个示例
  • ORA-01438: 值大于此列允许的指定精度

    有时我们会从合作伙伴的数据库中收到以下错误 i ORA 01438 value larger than specified precision allows for this column i 完整响应如下所示
  • CSS:下拉菜单的间距问题

    我做了一个下拉菜单 http jsfiddle net QPxVe http jsfiddle net QPxVe 由于某种原因 jsFiddle 正在改变 jsFiddle 之外不存在的对齐方式 这不是问题 我似乎在项目之间有差距 但我不
  • ruby-on-rails 检查查询结果是否为空(Model.find)

    我正在 Rails 上使用 ruby 并尝试检查查询是否返回值 这是查询 search Customer find by name login name 如果查询找到结果 一切都很好 但是我如何对空结果做出反应 I tried if sea
  • 部分渲染冗余方法调用

    我知道 JSF 可能会调用托管 bean 方法几次 即使它在 xhtml 中只调用一次 我知道这是由于编码 方法造成的 我想请您向我解释一下以下案例 我有一个类似这样的 JSF 文件
  • 在iOS中启动应用程序时如何复制sqlite数据库?

    每次启动应用程序时 我想将带有最新更新的 sqlite 数据库从数据库位置复制到我的 iOS 应用程序 有什么办法可以做到吗 您可以将以下方法添加到您的应用程序委托中 void copyDatabaseIfNeeded Using NSFi
  • 使用mysqldump只转储数据,不转储任何表信息

    我正在寻找转储 mysql 数据库中所有数据的语法 我不需要任何表格信息 mysqldump no create info 您也可以使用 skip triggers 如果您使用触发器 no create db 如果您正在使用 databas
  • JavaScript 和数据库连接

    javascript可以直接访问数据库吗 我觉得我的问题是反问 因为这是一个安全问题 但这有可能吗 有可能的 有了新的html5功能 js可以通过WebSql连接 一个活生生的例子 http html5demos com database
  • 如果表不存在,如何使用 Derby Db 创建表

    我是新来的apache derby我似乎无法工作 CREATE TABLE IF NOT EXISTS table1 可以实现MySql等等我得到了 Syntax error Encountered NOT at line 1 column
  • 计算 HBase 表中列族的记录数

    我正在寻找一个 HBase shell 命令来计算指定列族中的记录数 我知道我可以运行 echo scan table name hbase shell grep column family name wc l 然而 这将比标准计数命令运行
  • 通过php将MYSQL数据导出到Excel/CSV

    我想通过 php 将 MYSQL 数据导出到 Excel CSV 这样我以后就可以使用我的数据库 或者有人可以使用并理解它 要使用适合 EXCEL 的语法创建 CSV 文件 您可以使用基本 SQL SELECT FROM mytable I
  • C# - 如何检测 SQLite DB 是否被锁定?

    我正在开发一个使用 SQLite 的多线程 C 程序 我遇到一个问题 有时运行 SQLiteCommand ExecuteNonQuery 来更新某些行会抱怨 SQLite 错误 5 数据库已锁定 我知道发生这种情况是因为数据库在插入或更新
  • 输入数据库时​​拆分文本框中的文本

    当插入 MS Access 数据库 时 如何将文本框中的单词拆分或放入另一行 例如 我的文本框有这些词 ABC DEF 生长激素指数 JKL 当用户按下回车按钮时 以下单词将被插入到文本框中 但每个单词都会在一个新行中 例如 ABC 将位于
  • 字符集和排序规则到底是什么意思?

    我可以阅读MySQL文档而且非常清楚 但是 如何决定使用哪种字符集呢 校对对什么数据有影响 我要求解释这两者以及如何选择它们 来自 MySQLdocs http dev mysql com doc refman 5 0 en charset
  • 重写方法的返回类型可以不同吗?

    重写方法可以有不同的返回类型 Java supports covariant return types for overridden methods This means an overridden method may have a mo
  • 将计算列设置为非空时遇到问题

    我在将计算列设置为时遇到问题not null 我想要实现的是C001 C002 等 同时将其设置为not null 我在论坛上读到 这可以通过使用 NULL 值的默认值 0 来实现 E g ISNULL Price Taxes 0 我尝试应

随机推荐

  • 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