Simultaneous .replace functionality

后端 未结 4 1401
一生所求
一生所求 2020-12-19 06:52

I have already converted user input of DNA code (A,T,G,C) into RNA code(A,U,G,C). This was fairly easy

RNA_Code=DNA_Code.replace(\'         


        
4条回答
  •  無奈伤痛
    2020-12-19 07:34

    If you're not already using it, I suggest trying out Biopython. It has all sorts of functions for dealing with biological data, including a pretty cool Seq object. There is a reverse_complement() function that does exactly what you're trying to do, and a bunch more that you might not even have thought of yet. Check it out, it's a real time-saver.

    >>> from Bio.Seq import Seq
    >>> from Bio.Alphabet import generic_dna
    >>> my_dna = Seq("AGTACACTGGT", generic_dna)
    >>> my_dna
    Seq('AGTACACTGGT', DNAAlphabet())
    >>> my_dna.complement()
    Seq('TCATGTGACCA', DNAAlphabet())
    >>> my_dna.reverse_complement()
    Seq('ACCAGTGTACT', DNAAlphabet())
    

提交回复
热议问题