Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

i have been trying this code in c++ and i am keep failing for one of the two test . can some one help please

i have been trying this code in c++ and i am keep failing for one of the two test . can some one help please

dnaErrors("GCATGGATTAATATGAG-CGACTACTAGGATAGTTGCAACCCTTACGTCACCGCC-TGA", "-GTACCTAATTATACT...66(expected 64)

dnaErrors("GGGA-GAATCTCTGGACT", "CTCTACTTA-AGACCGGTACAGG") 13

or

dnaErrors("GCATGGATTAATATGAG-CGACTACTAGGATAGTTGCAACCCTTACGTCACCGCC-TGA", "-GTACCTAATTATACT...64

dnaErrors("GGGA-GAATCTCTGGACT", "CTCTACTTA-AGACCGGTACAGG") 12(expected 13)

Write a function named dnaErrors that accepts two strings representing DNA sequences as parameters and returns an integer representing the number of errors found between the two sequences, using a formula described below. DNA contains nucleotides, which are represented by four different letters A, C, T, and G. DNA is made up of a pair of nucleotide strands, where a letter from the first strand is paired with a corresponding letter from the second. The letters are paired as follows:

  • A is paired with T and vice-versa.
  • C is paired with G and vice-versa.

Below are two perfectly matched DNA strands. Notice how the letters are paired up according to the above rules.

"GCATGGATTAATATGAGACGACTAATAGGATAGTTACAACCCTTACGTCACCGCCTTGA" ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| "CGTACCTAATTATACTCTGCTGATTATCCTATCAATGTTGGGAATGCAGTGGCGGAACT" 

In some cases, errors occur within DNA molecules; the task of your function is to find two particular kinds of errors:

  • Unmatched nucleotides, in which one strand contains a dash ('-') at a given index, or does not contain a nucleotide at the given index (if the strings are not the same length). Each of these counts as 1 error.
  • Point mutations, in which a letter from one strand is matched against the wrong letter in the other strand. For example, A might accidentally pair with C, or G might pair with G. Each of these counts as 2 errors.

For example, consider these two DNA strands:

index 01234567890123456789012 "GGGA-GAATCTCTGGACT" "CTCTACTTA-AGACCGGTACAGG" 

This pair of strands has three point mutations (at indexes 1, 15, and 17), and seven unmatched nucleotides (dashes at indexes 4 and 9, and nucleotides in the second string with no match at indexes 18-22). The point mutations count as a total of 3 * 2 = 6 errors, and the unmatched nucleotides count as 7 * 1 = 7 errors, so your function would return an error count of 6+7 = 13 total errors if passed the two above strands.

You may assume that each string consists purely of the characters A, C, T, G, and - (the dash character), but the letters could appear in either upper or lowercase. The strings might be the same length, or the first or second might be longer than the other. Either string could be very long, very short, or even the empty string. If the strings match perfectly with no errors as defined above, your function should return 0.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases And Information Systems 1 International Baltic Conference Dbandis 2020 Tallinn Estonia June 19 2020 Proceedings

Authors: Tarmo Robal ,Hele-Mai Haav ,Jaan Penjam ,Raimundas Matulevicius

1st Edition

303057671X, 978-3030576714

Students also viewed these Databases questions

Question

Complexity of linear search is O ( n ) . Your answer: True False

Answered: 1 week ago

Question

7. What decisions would you make as the city manager?

Answered: 1 week ago

Question

8. How would you explain your decisions to the city council?

Answered: 1 week ago