Gene Coding Regions (2)

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".

Problem information

Author: Lluís Padró

Generation: 2026-01-25T13:11:06.673Z

© Jutge.org, 2006–2026.
https://jutge.org