Rosalind第41题:Maximum Matchings and RNA Secondary Structures

Problem

Figure 1. The bonding graph of s = UAGCGUGAUCAC (left) has a perfect matching of basepair edges, but this is not the case for t = CAGCGUGAUCAC (right), in which one symbol has been replaced.

Figure 2. A maximum matching (highlighted in red) is shown in each of the three graphs above. You can verify that no other matching can contain more edges. (Courtesy: Miym, Wikimedia Commons User)

Figure 3. A red maximum matching of basepair edges in the bonding graph for t = CAGCGUGAUCAC.

The graph theoretical analogue of the quandary stated in the introduction above is that if we have an RNA string  that does not have the same number of occurrences of 'C' as 'G' and the same number of occurrences of 'A' as 'U', then the bonding graph of  cannot possibly possess a perfect matching among its basepair edges. For example, see Figure 1; in fact, most bonding graphs will not contain a perfect matching.

In light of this fact, we define a maximum matching in a graph as a matching containing as many edges as possible. See Figure 2 for three maximum matchings in graphs.

A maximum matching of basepair edges will correspond to a way of forming as many base pairs as possible in an RNA string, as shown in Figure 3.

Given: An RNA string  of length at most 100.

Return: The total possible number of maximum matchings of basepair edges in the bonding graph of .

在上面的引言中表示的图的理论图类似物是,如果我们的RNA字符串 的'C'的出现次数与'G'的发生次数不同,而'A'的出现数与'U'的发生次数相同”,则粘结图形的不可能拥有 完美匹配其之间碱基对的边缘。例如,参见图1。实际上,大多数绑定图不会包含完美匹配。

鉴于这一事实,我们将图形中的最大匹配定义为包含尽可能多的匹配。有关图形 中的三个最大匹配,请参见图2

碱基对边缘的最大匹配将对应于在RNA串中形成尽可能多的碱基对的方式,如图3所示。

给定:长度不超过100的RNA字符串。

返回值:的键合图中碱基对边的最大匹配总数。

 

Sample Dataset

>Rosalind_92
AUGCUUC

Sample Output

6
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值