Gene Coding Regions (2) V62955


Statement
 

pdf   zip

In a DNA sequence, start codons and stop codons delimit a coding region of a gene –a.k.a. coding DNA sequence (CDS)–, which is the part of a gene that is translated into a protein.

Any CDS starts with the universal start codon ATG and ends with the first occurrence of a stop codon (either TAA, TAG, or TGA).

Write a program that, given a DNA sequence, counts codons inside each CDS found in the sequence, and prints the count of each codon in the CDS.

Input

A sequence of codons (triplets of A, T, C, G), which may contain zero or more CDS delimited by start/stop codons.

The input sequence may appear in several lines, with one or more whitespaces or newlines between one codon and the next.

Assume that the CDS in the sequence –if any– are well-formed. That is, if a start codon appears, an end codon will appear later before the sequence ends or the start codon appears again. No end codon will appear if no start codon has previously appeared.

Output

For each CDS (fragment comprised between a start and an end codon), the codons belonging to the CDS are printed in alphabetical order, along with their frequencies.

If no CDS is found in the sequence, the output is "No CDS found".

Public test cases
  • Input

    TGC ATG GCT CCG GCT AAG
     TAA TGC CGT ATG
    AAT CTC AAT   GAG AAT CCG TAG AAG

    Output

    CDS 1
      AAG 1
      CCG 1
      GCT 2
    CDS 2
      AAT 3
      CCG 1
      CTC 1
      GAG 1
    
  • Input

    CGT TGC TAC TGC CGT TGC GCT CCG 
    GCT AAG AAT CTC AAT GAG GAT AAG

    Output

    No CDS found
    
  • Input

    CCA CGG ATA GAA ACA GGA CCC CGA AAG CTG CAC ACC GAC CAA
     TAC ATG GTG GGT AGA TCT GAG GCA CTT TTT TTA ACA TAT TAT
    GGC TCT TCA TGC CCT GGT CGA AGG CAG TAG CGT TTA CGT CAG 
    TGT CGT ACT TAT GGA ACG TCC  GAT TGG TTT TTG ATC ATG GTC 
    CAC CTC AAG TAT CAT AAC AGA TTT GTT GGT GCC CCA CTA CTA
     GTA GAT TCG TGG GGA TCG GTG AAA ACC CGG ACC TGA AAG CAG 
    GTC GTG CTC TAT CGG GAC CGG GAA AAG AAT TGG AGT CCC TTC CTC
     GAC CTG CTT CCT CCA CCT CTA GGC AGC AAC TCA ACA AAA ACC 
    AGA GTG ATA CCC GCT ATG TCA ACC CGA ACT AGG CCG GCA TCG 
    GCA TTT GCC GTT CAG AAC CGC AGC TTG CAT CGT ACA GGG ACC 
    GGT CCC AAA CTA AAA CTC TAA CTC ACC ACG CGA AAA CTA ATC TCA
     CAG CAT AGT ATT GCT CTA CAG ACT AAC TAC

    Output

    CDS 1
      ACA 1
      AGA 1
      AGG 1
      CAG 1
      CCT 1
      CGA 1
      CTT 1
      GAG 1
      GCA 1
      GGC 1
      GGT 2
      GTG 1
      TAT 2
      TCA 1
      TCT 2
      TGC 1
      TTA 1
      TTT 1
    CDS 2
      AAA 1
      AAC 1
      AAG 1
      ACC 2
      AGA 1
      CAC 1
      CAT 1
      CCA 1
      CGG 1
      CTA 2
      CTC 1
      GAT 1
      GCC 1
      GGA 1
      GGT 1
      GTA 1
      GTC 1
      GTG 1
      GTT 1
      TAT 1
      TCG 2
      TGG 1
      TTT 1
    CDS 3
      AAA 2
      AAC 1
      ACA 1
      ACC 2
      ACT 1
      AGC 1
      AGG 1
      CAG 1
      CAT 1
      CCC 1
      CCG 1
      CGA 1
      CGC 1
      CGT 1
      CTA 1
      CTC 1
      GCA 2
      GCC 1
      GGG 1
      GGT 1
      GTT 1
      TCA 1
      TCG 1
      TTG 1
      TTT 1
    
  • Information
    Author
    Lluís Padró
    Language
    English
    Official solutions
    Python
    User solutions
    Python