171k views
5 votes
In molecular biology the "alphabet" of genes consists of four chemicals (called nucleotides) represented by the letters A C G T. A triad is a sequence of three nucleotides (for example AGA) and specifies an amino acid, a building block for proteins. A gene consists of a very, very long sequence of A-C-G-T combinations.Assume the input consists of a long sequence of A-C-G-T letters representing a gene. Write the code necessary to skip over the first 7 letters and then read the next 4 triads, printing each out on its own line

User Jazzer
by
6.4k points

2 Answers

5 votes

Answer:

#Python

1. def Triad(dna):

2. dna = list(dna)

3. fourTriad = dna[7:19]

4. print(fourTriad)

5. return(dna)

Step-by-step explanation:

We define a function called Triad that receives a string with a DNA sequence composed of A-C-G-T letters, then we transform this string into a list, to finally take the elements 7 to 18 (In python the first element is the element zero).

An example of the code:

Triad('ACAAGTCGATGAGCGATGCGATCAGTAGCGGGCTGGATGCTGCTAGATCGCAGCATGACGTACTGACTGT')

Output:

['G', 'A', 'T', 'G', 'A', 'G', 'C', 'G', 'A', 'T', 'G', 'C']

User Macke
by
6.2k points
1 vote

Answer:

Char Acid [4];

Cin.get (acid, 7);

cin.ignore ();

for(int i=0; i<4; i++)

{ cin.get (acid,4) ;

for (int j=0; j<3; j++)

cout << acid[j];

cout << endl;

User Pawel Urban
by
5.5k points