Question

In: Computer Science

A base-paired DNA sequence is one where A's line up with T's and G's line up...

A base-paired DNA sequence is one where A's line up with T's and G's line up with C's. For example:

base-paired DNA sequence ATCGAT TAGCTA

If A is not paired with T, T with A, G with C, or C with G, then the sequence is not base-paired. For example:

not a base-paired DNA sequence

ATCGAT TAGCAA

not a base-paired DNA sequence ATCGAT TATCTA

A base-paired sequence also needs both sides to have the same length. For example,

not a base-paired DNA sequence ATCG TAGCTA

Write a method base_check that takes two Strings as arguments and returns true if and only if the DNA sequence represented by the Strings is base-paired. Implement your solution in the file we have provided: BaseCheck.java. Your program should run and print only “Tests pass for base_check” in the console. It is your responsibility to make sure the program runs properly in IntelliJ.

Tips You will find the following String functions helpful • s.charAt(i), returns the ith character in the String s • s.length(), returns the number of characters in the String s

public class BaseCheck {

   public static void main(String[] args) {
        String seqA1 = "ATCGATTGAGCTCTAGCG";
      String seqB1 = "TAGCTAACTCGAGATCGC";
      if (!base_check(seqA1, seqB1)) {
            System.out.println("FAILED TEST 1");
            System.exit(1);
      }
        
      String seqA2 = "ATCGATGGAGCTGTAGCG";
      String seqB2 = "TAGCTAACTCGAGATCGA";
      if (base_check(seqA2, seqB2)) {
            System.out.println("FAILED TEST 2");
            System.exit(1);
      }
        
      String seqA3 = "ATCGATTGAGCT";
      String seqB3 = "TAGCTAACTCGAGATCGC";
      if (base_check(seqA3, seqB3)) {
            System.out.println("FAILED TEST 3");
            System.exit(1);
      }
      
        String seqA4 = "ATCGATTGAGCTCTAGCG";
      String seqB4 = "TAGCTAACTCGAGATC";
      if (base_check(seqA4, seqB4)) {
            System.out.println("FAILED TEST 4");
            System.exit(1);
      }
        
      String seqA5 = "ATCGATTGAGCTCTAGCG";
      String seqB5 = "ATCGATTGAGCTCTAGCG";
      if (base_check(seqA5, seqB5)) {
            System.out.println("FAILED TEST 5");
            System.exit(1);
      }
        
      String seqA6 = "GGGG";
      String seqB6 = "CCCC";
      if (!base_check(seqA6, seqB6)) {
            System.out.println("FAILED TEST 6");
            System.exit(1);
      }
        
        /* We will test your code on additional test
        cases, so make sure it really works. (e.g., you can
        add more of your own test cases, just copy one of the
      above ones and modify it).
        */
        
        System.out.println("Tests pass for base_check");
    }
    
    public static boolean base_check(String seq1, String seq2) {
        /* Your solution here; replace the following code with yours */
      return false;
    }
}

Solutions

Expert Solution

public class BaseCheck {

        public static void main(String[] args) {
                String seqA1 = "ATCGATTGAGCTCTAGCG";
                String seqB1 = "TAGCTAACTCGAGATCGC";
                if (!base_check(seqA1, seqB1)) {
                        System.out.println("FAILED TEST 1");
                        System.exit(1);
                }

                String seqA2 = "ATCGATGGAGCTGTAGCG";
                String seqB2 = "TAGCTAACTCGAGATCGA";
                if (base_check(seqA2, seqB2)) {
                        System.out.println("FAILED TEST 2");
                        System.exit(1);
                }

                String seqA3 = "ATCGATTGAGCT";
                String seqB3 = "TAGCTAACTCGAGATCGC";
                if (base_check(seqA3, seqB3)) {
                        System.out.println("FAILED TEST 3");
                        System.exit(1);
                }

                String seqA4 = "ATCGATTGAGCTCTAGCG";
                String seqB4 = "TAGCTAACTCGAGATC";
                if (base_check(seqA4, seqB4)) {
                        System.out.println("FAILED TEST 4");
                        System.exit(1);
                }

                String seqA5 = "ATCGATTGAGCTCTAGCG";
                String seqB5 = "ATCGATTGAGCTCTAGCG";
                if (base_check(seqA5, seqB5)) {
                        System.out.println("FAILED TEST 5");
                        System.exit(1);
                }

                String seqA6 = "GGGG";
                String seqB6 = "CCCC";
                if (!base_check(seqA6, seqB6)) {
                        System.out.println("FAILED TEST 6");
                        System.exit(1);
                }

                /*
                 * We will test your code on additional test cases, so make sure it really
                 * works. (e.g., you can add more of your own test cases, just copy one of the
                 * above ones and modify it).
                 */
                System.out.println("Tests pass for base_check");
        }

        public static boolean base_check(String seq1, String seq2) {
                if(seq1.length() != seq2.length()) {
                        return false;
                }
                
                int size = seq1.length();
                int i = 0;
                
                while(i < size) {
                        char c1 = seq1.charAt(i);
                        char c2 = seq2.charAt(i);
                        i++;
                        
                        if(c1 == c2) {
                                return false;
                        }

                        if((c1 == 'A' && c2 == 'T') || (c1 == 'T' && c2 == 'A')) {
                                continue;
                        }
                        if((c1 == 'G' && c2 == 'C') || (c1 == 'C' && c2 == 'G')) {
                                continue;
                        }
                        return false;
                }
                
                return true;
        }
}
**************************************************

Thanks for your question. We try our best to help you with detailed answers, But in any case, if you need any modification or have a query/issue with respect to above answer, Please ask that in the comment section. We will surely try to address your query ASAP and resolve the issue.

Please consider providing a thumbs up to this question if it helps you. by Doing that, You will help other students, who are facing similar issue.


Related Solutions

Write down the DNA base sequence that is the complementary strand to the DNA sequence shown...
Write down the DNA base sequence that is the complementary strand to the DNA sequence shown below? (5') C G A C T T C G A G C T (3')
One strand of a double-helical DNA has the sequence 5'-GCGCAATATTTCTCAAAATATTGCGC-3'. Write the base sequence of the...
One strand of a double-helical DNA has the sequence 5'-GCGCAATATTTCTCAAAATATTGCGC-3'. Write the base sequence of the complementary strand. What special type of sequence is contained in this DNA segment? Does this double-stranded DNA have the potential to form any alternative structures?
1. One strand of a double-helical DNA has the sequence 5¢-GCGCAATATTTCTCAAAATATTGCGC-3¢. Write the base sequence of...
1. One strand of a double-helical DNA has the sequence 5¢-GCGCAATATTTCTCAAAATATTGCGC-3¢. Write the base sequence of the complementary strand. What special type of sequence is contained in this DNA segment? Does this double-stranded DNA have the potential to form any alternative structures?   2. Compositional analysis of a certain lipid shows that it has exactly one mole of fatty acid per mole of inorganic phosphate. What could be the identify of this lipid? Explain.
I have a one strand DNA sequence that I am trying to determine the base pairs...
I have a one strand DNA sequence that I am trying to determine the base pairs for. The gene is CYP1A2 and the primers and sequence are below. Below is the sequence of part of the CYP1A2 gene (you are given only 1 strand, written in the 5’ – 3’ direction). 5’TGGGCTAGGTGTAGGGGTCCTGAGTTCCGGGCTTTGCTACCCAGCTCTTGACTTCTGTTTCCCGATTTTA AATGAGCAGTTTGGACTAAGCCATTTTTAAGGAGAGCGATGGGGAGGGCTTCCCCCTTAGCACAAGGGCA GCCCTGGCCCTGGCTGAAGCCCAACCCCAACCTCCAAGACTGTGAGAGGATGGGGACTCATCCCTGGAGG AGGTGCCCCTCCTGGTATTGATAAAGAATGCCCTGGGGAGGGGGCATCACAGGCTATTTGAACCAGCCCT GGGACCTTGGCCACCTCAGTGTCACTGGGTAGGGGGAACTCCTGGTCCCTTGGGTATATGGAAGGTATCA GCAGAAAGCCAGCACTGGCAGGGACTCTTTGGTACAATACCCAGCATGCATGCTGTGCCAGGGGCTGACA AGGGTGCTGTCCTTGGCTTCCCCATTTTGGAGTGGTCACTTGCCTCTACTCCAGCCCCAGAAGTGGAAAC TGAGATGATGTGTGGAGGAGAGAGCCAGCGTTCATGTTGGGAATCTTGAGGCTCCTTTCCAGCTCTCAGA TTCTGTGATGCTCAAAGGGTGAGCTCTGTGGGCCCAGGACGCATGGTAGATGGAGCTTAGTCTTTCTGGT ATCCAGCTGGGAGCCAAGCACAGAACACGCATCAGTGTTTATCAAATGACTGAGGAAATGAATGAATGAA TGTCTCCATCTCAACCCTCAGCCTGGTCCCTCCTTTTTTCCCTGCAGTTGGTACAGATGGCATTGTCCCA GTCTGTTCCCTTCTCGGCCACAGAGCTTCTCCTGGCCTCTGCCATCTTCTGCCTGGTATTCTGGGTGCTC AAGGGTTTGAGGCCTCGGGTCCCCAAAGGCCTGAAAAGTCCACCAGAGCCATGGGGCTGGCCCTTGCTCG GGCATGTGCTGACCCTGGGGAAGAACCCGCACCTGGCACTGTCAAGGATGAGCCAGCGCTACGGGGACGT CCTGCAGATCCGCATTGGCTCCACGCCCGTGCTGGTGCTGAGCCGCCTGGACACCATCCGGCAGGCCCTG 3’ The sequences of the primers used to amplify part of the CYP1A2 gene...
13. A) A change to a single base pair in the sequence of a DNA molecule...
13. A) A change to a single base pair in the sequence of a DNA molecule is called a ______ mutation. B) If that single nucleotide change results in a protein with the exact same amino acid sequence it is called a _________ mutation. C) If the base pair change results in an alteration of the amino acid sequence of the protein it is called a ___________ mutation. D) If the base pair changes results in a codon for an...
Suppose the DNA bases in a gene sequence follow the distribution: DNA base Probability A 1/3...
Suppose the DNA bases in a gene sequence follow the distribution: DNA base Probability A 1/3 C θ G 1/3 T 1/3 - θ In an experiment, the number of observed bases that are “A” or “C” in a gene sequence is x, and the number of observed bases that are “G” or “T” is y. The EM method is used to find the best value for the parameter θ. Describe the Expectation step for computing the expected numbers of...
If a sequence of one strand of DNA is ATTGCTCG, what is the complementary sequence?
If a sequence of one strand of DNA is ATTGCTCG, what is the complementary sequence?
Using the following DNA sequence, come up with your own corresponding sequence after a 1) point...
Using the following DNA sequence, come up with your own corresponding sequence after a 1) point mutation and 2) frameshift mutation. Also write out the corresponding RNA sequence: AGTAAACGTACCTGAGACGGG Explain how gene regulation in eukaryotes differs from gene regulation in prokaryotes.
1) The WILDTYPE DNA/gene has the base sequence:    5’GTACTGCAT3’ (the antisense strand of the gene is...
1) The WILDTYPE DNA/gene has the base sequence:    5’GTACTGCAT3’ (the antisense strand of the gene is shown) The gene has undergone a mutation. The mutant DNA/gene has the base sequence: 5’GTACTCCAT3’ (the mutation is in BOLD) based on this information, answer the following 1a)What is the base sequence of mutant mRNA? Label the ends of the mRNA 1b) this mutation is most likely to be caused by: a. soot b. analogues c. X-Ray d. RNA polymerase e. ribosome (pick one)...
The following is based on the DNA sequence and one of the oligos from the previous...
The following is based on the DNA sequence and one of the oligos from the previous problem set, which are reproduced below: 5'...GGAGCTTCATGCTAGTTGCAATAGC..[1,150 bp]..CGTGGCACGTATAGCGCTATCATTA...3'       oligo-B: CATGCTAGTTGC      a) If oligo-B is used as a primer for (Sanger) DNA sequencing, which type of dideoxynucleotide would be found on the “first” (shortest) chain to terminate synthesis? b) If oligo-B is used a sequencing primer, what the total length (number of nucleotides) of the SHORTEST DNA chain that would have a dideoxy-G (ddG, 2',3'-dideoxyguanosine)...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT