03 Complementing a Strand of DNA

Posted thinkanddo

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了03 Complementing a Strand of DNA相关的知识,希望对你有一定的参考价值。

Problem

In DNA stringssymbols ‘A‘ and ‘T‘ are complements of each other, as are ‘C‘ and ‘G‘.

The reverse complement of a DNA string ss is the string scsc formed by reversing the symbols of ss, then taking the complement of each symbol (e.g., the reverse complement of "GTCA" is "TGAC").

Given: A DNA string ss of length at most 1000 bp.

Return: The reverse complement scsc of ss.

Sample Dataset

AAAACCCGGT

Sample Output

ACCGGGTTTT

方法一
def reverse(seq):
    dict = {‘A‘: ‘T‘, ‘C‘: ‘G‘, ‘T‘: ‘A‘, ‘G‘: ‘C‘}

    revSeqList = list(reversed(seq))                #[‘T‘, ‘G‘, ‘G‘, ‘C‘, ‘C‘, ‘C‘, ‘A‘, ‘A‘, ‘A‘, ‘A‘]
    revComSeqList = [dict[k] for k in revSeqList]  # [‘A‘, ‘C‘, ‘C‘, ‘G‘, ‘G‘, ‘G‘, ‘T‘, ‘T‘, ‘T‘, ‘T‘]
    revComSeq = ‘‘.join(revComSeqList)             # ACCGGGTTTT
    return revComSeq


seq = ‘AAAACCCGGT‘


print (reverse(seq))

  



以上是关于03 Complementing a Strand of DNA的主要内容,如果未能解决你的问题,请参考以下文章

使用 boost strand 和 std::mutex

如何处理alert日志中出现Private Strand Flush Not Complete?

alert日志中出现Private Strand Flush Not Complete的处理方法

strand 在 boost asio 中的优势是啥?

boost::asio: “strand”类型的同步原语有啥名字吗?

Boost Asio总结class strand