Question

In: Computer Science

Biologists use a sequence of the letters A, C, T, and G to model a genome....

Biologists use a sequence of the letters A, C, T, and G to model a genome. A gene is a substring of a genome that starts after a triplet ATG and ends before a triplet TAG, TAA, or TGA. Furthermore, the length of a gene string is a multiple of 3, and the gene does not contain any of the triplets ATG, TAG, TAA, or TGA. Write a program that prompts the user to enter a genome and displays all genes in the genome. If no gene is found in the input sequence, display “no gene is found”. use a for loop and string to create this program.

Here are the sample runs:

Enter a genome string:

TTATGTTTTAAGGATGGGGCGTTAGTT

TTT

GGGCGT

Enter a genome string:

TGTGTGTATAT

no gene is found

Solutions

Expert Solution

package MainPackage;

import java.util.Scanner;

public class GenomeString {
   public static void main(String[] args) {
       String result = "";
       System.out.println("Enter a Genome string:");
       Scanner s = new Scanner(System.in);
       String genome = s.next();
       int i=0,j=0;
       /*For and while both do the same functionality but here iam using increment of counter variable in middle of loop so I used while */
       while(i <= genome.length()-3) {
           //Iam iterating through all the letters and checking whether three letters starting with the letter matches "ATG"
           if(genome.substring(i, i+3).equals("ATG")) {
               // If three letters match we need start checking for the ending triplet of genome after third letter so added 3
               i = j = i+3;
               //Iterating through the remaining word for ending triplet
               while(j <= genome.length()-3) {
                   /* As the the gene cannot contain "ATG", if there is ATG I will start checking for ending triplet from the second "ATG" */
                   if(genome.substring(j, j+3).equals("ATG")) {
                       i = j = j+3;
                   }
                   if(genome.substring(j, j+3).equals("TAG") || genome.substring(j, j+3).equals("TAA") || genome.substring(j, j+3).equals("TGA")) {
                       result = genome.substring(i,j);
                       System.out.println(result);
                       break;
                   }
                   j++;
               }
               continue;
           }
           i++;
       }
       if(result == "") {
           System.out.println("No gene found");
       }
   }
}


Sample Outputs:-


Related Solutions

A DNA string is a sequence of the bases a, c, g, and t in any...
A DNA string is a sequence of the bases a, c, g, and t in any order, whose length is usually a multiple of three. In reality, it is not necessarily a multiple of three, but we will simplify it as such for discussion. For example, aacgtttgtaaccagaactgt is a DNA string with a length of 21 bases. Recall that a sequence of three consecutive letters is called a codon. Assuming the first codon starts at position 1, the codons are...
3` - T A T A G A G C A A T T G C...
3` - T A T A G A G C A A T T G C T A C G T G T A T C C C G A G A C T C C G T A A – 5` 5` - A T A T C T C G T T A A C G A T G C A C A T A G G G C T C T G A G G C A...
The genome of an organism was analyzed and provided the following: 17%A, 23%G, 32%C, 0%T, and...
The genome of an organism was analyzed and provided the following: 17%A, 23%G, 32%C, 0%T, and 28%U. This organism is likely: A virus A virus or a bacterium A bacterium A bacterium or a eukaryote A eukaryote It cannot be calculated based on that number alone
Radio stations in a certain country use a sequence of 3 or 4 letters as their...
Radio stations in a certain country use a sequence of 3 or 4 letters as their station identification call letters. The first letter must be Upper W comma Upper K comma Upper B comma Upper Q comma or Upper R. Assume there are no restrictions on the remaining​ letters, and repetition is allowed. ​a) How many 3​-letter station identifications are​ possible? ​b) How many 4​-letter station identifications are​ possible? ​c) How many total station identifications are​ possible? ​d) The identification...
Nucleotide Pairs The human genome is composed of the four DNA nucleotides: A, T, G, and...
Nucleotide Pairs The human genome is composed of the four DNA nucleotides: A, T, G, and C. Some regions of the human genome are extremely G–C rich (i.e., a high proportion of the DNA nucleotides there are guanine, G, and cytosine, C). Other regions are relatively A–T rich (i.e., a high proportion of the DNA nucleotides there are adenine, A, and thymine, T). Imagine that you want to compare nucleotide sequences from two regions of the genome. Sixty percent of...
Even though actinobacteria are high G + C organisms, there are regions of the genome that...
Even though actinobacteria are high G + C organisms, there are regions of the genome that are AT-rich. Suggest a few such regions and explain why they must be more AT-rich.
1. *Suppose that the economy is described by: Y =C(Y,T)+I(Y,i)+G, with G, T exogenous. (a) Use...
1. *Suppose that the economy is described by: Y =C(Y,T)+I(Y,i)+G, with G, T exogenous. (a) Use the total derivative to derive di/dY (b) What is the sign of this derivative? (c) What does the slope of the line depend on? Explain the intuition. (d) Graph this curve. (e) Use the total derivative to find dY/dG and dY/dT
The macroeconomy of the TELLA is represented by the following model. Goods Market Y=C+I+G+X-M C=200+0.7(T-T) T=0.2YI=100-10r...
The macroeconomy of the TELLA is represented by the following model. Goods Market Y=C+I+G+X-M C=200+0.7(T-T) T=0.2YI=100-10r G=150 EX=200 IM=0.1Y Money Market Md=1000-6666r Ms = [(C/D+1)/(C/D+R/D)]H Where C/D=0.2; R/D=0.2 and H=200 Use this model to answer the following questions: 1) The value of the money multiplier in this model is: A) 2.0 B) 2.5 C) 3.0 D) 3.5 E) 4.0 2) The value of the expenditure multiplier in this model is: A)1.54 B)4.23 C)2.51 D)1.85 E) 3.50 3) The value of...
1. Consider the following model of the economy: C = 170+.6(Y-T) I = 250 G =...
1. Consider the following model of the economy: C = 170+.6(Y-T) I = 250 G = 300 T = 200a. What is the value of the marginal propensity to consume?b. What is the value of the government budget deficit?c. Calculate the equilibrium level of GDP and show you work on a Keynesian-Cross diagram.d. What is the value of the government-purchases multiplier? Show all your work and explain fully.e. Use your answer to part d to calculate the amount by which...
A seqstring is a sequence of 18 letters(one of the 26 lowercase letters a-z). How many...
A seqstring is a sequence of 18 letters(one of the 26 lowercase letters a-z). How many seq strings are there where the number of letters between any two occurences of the same letter is at least 2?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT