Rosalind第42题:Creating a Distance Matrix

Problem

For two strings  and  of equal length, the p-distance between them, denoted , is the proportion of corresponding symbols that differ between  and .

For a general distance function  on  taxa  (taxa are often represented by genetic strings), we may encode the distances between pairs of taxa via a distance matrix  in which .

Given: A collection of  () DNA strings  of equal length (at most 1 kbp). Strings are given in FASTA format.

Return: The matrix  corresponding to the p-distance  on the given strings. As always, note that your answer is allowed an absolute error of 0.001.

对于长度相等的两个字符串 ,它们之间的p距离表示为和之间不同的相应符号的比例。

对于一般的距离函数上类群(类群通常由下式表示的遗传串)中,我们可以通过编码对分类单元之间的距离的距离矩阵,其中。 

给出:集合()DNA串长度相等(至多1的KBP)。字符串以FASTA格式给出。 

返回值:对应于给定字符串上p距离的矩阵。与往常一样,请注意,您的答案的绝对误差为0.001。

 

Sample Dataset

>Rosalind_9499
TTTCCATTTA
>Rosalind_0942
GATTCATTTC
>Rosalind_6568
TTTCCATTTT
>Rosalind_1833
GTTCCATTTA

Sample Output

0.00000 0.40000 0.10000 0.10000
0.40000 0.00000 0.40000 0.30000
0.10000 0.40000 0.00000 0.20000
0.10000 0.30000 0.20000 0.00000
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值