Complementing a Strand of DNA

A problem from rosalind “Bioinformatics Stronghold” category, String Algorithm

  • A problem from rosalind “Bioinformatics Stronghold” category
    Rosalind Problem Link

  • Description
    • Given DNA sequence, we should deduce the reverse complement
  • Input example : AGGCCTTAGGCAGT
  • Output example : ACTGCCTAAGGCCT

Biological Background

  • DNA consists of 2 strands
    • coding sequence : has same sequences with mRNA having information except T (should be changed to U)
    • noncoding sequence : complement version of coding sequence (A ↔ T, G ↔ C)
  • 2 strands are antiparellel
    • 5’-AGGCT-3’
    • 3’-TCCGA-5’
    • Reverse complement of 5’-AGGCT-3’ is 5’-AGCCT-3’

My Solution


DNA_seq = input()
reverse_c = ""

for i in range(len(DNA_seq) - 1, -1, -1):
    symbol = DNA_seq[i]
    newSymbol = ''

    if symbol == 'A':
        newSymbol = 'T'
    elif symbol == 'T':
        newSymbol = 'A'
    elif symbol == 'G':
        newSymbol = 'C'
    elif symbol == 'C':
        newSymbol = 'G'
    reverse_c += newSymbol

print(reverse_c)


  • Search by the reverse direction on suggested DNA sequence
  • add the complement symbol into reverse_c

© 2017. All rights reserved.

Powered by Hydejack v조현진