Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You are to write a program that searches through an array that contains a sequence of characters. These characters are restricted to be the letters

You are to write a program that searches through an array that contains a sequence of characters. These characters are restricted to be the letters A, G, T, and C The last character in the sequence is set to be the code 0, which is thus easy to detect. That array should be declared and initialized exactly as follows in your program (a vector of only one row and many columns; search in the web how to use in

Matlab the function strfind

DNA = [A, G, C, G, G, G, A, C, C, G, T, C, ...

C, C, G, A, C, A, T, T, G, A, T, G, ...

A, A, G, G, G, T, C, A, T, A, G, A, ...

C, C, C, A, A, T, A, C, G, C, C, A, ...

C, C, A, C, C, C, C, A, A, G, T, T, ...

T, T, C, C, T, G, T, G, T, C, T, T, ...

C, C, A, T, T, G, A, G, T, A, G, A, ...

T, T, G, A, C, A, C, T, C, C, C, A, ...

G, A, T, G, 0

Your program should repeatedly ask the user for two things:

1. the length of a search sequence, and

2. the search sequence itself.

The program should then search through the entire array DNA to find the starting element subscript (index) of all matching sequences. The elements of the search sequence may take on one of five characters: A, G, T, C and *. The meaning of the * character is that of wild card - that is, it matches all four nucleotides: A, G, T,and C. The program should terminate when the length of the input sequence is zero or less. If the input search sequence contains a character other than A, G, T,C or *, the program should report that as an error and terminate, as shown in the examples below. You should only report the first character that has an error (and exit), there no need to check if there are more characters that are wrong.

C++Code

How test code Looks like

__________Run 1________

Enter length of DNA sequence to match: 4

Enter 4 characters (one of AGTC*) as a search sequence: CGGG

Match of search sequence found at element 2

Enter length of DNA sequence to match: 3

Enter 3 characters (one of AGTC*) as a search sequence: GAC

Match of search sequence found at element 5

Match of search sequence found at element 14

Match of search sequence found at element 34

Match of search sequence found at element 86

Enter length of DNA sequence to match: -1

Goodbye

__________Run 2________

Enter length of DNA sequence to match: 4

Enter 4 characters (one of AGTC*) as a search sequence: G*GG

Match of search sequence found at element 1

Enter length of DNA sequence to match: 3

Enter 3 characters (one of AGTC*) as a search sequence: TT*

Match of search sequence found at element 18

Match of search sequence found at element 58

Match of search sequence found at element 59

Match of search sequence found at element 60

Match of search sequence found at element 70

Match of search sequence found at element 75

Match of search sequence found at element 84

Enter length of DNA sequence to match: 5

Enter 5 characters (one of AGTC*) as a search sequence: *GTC*

Match of search sequence found at element 8

Match of search sequence found at element 27

Match of search sequence found at element 66

Enter length of DNA sequence to match: 0

Goodbye

__________Run 3________

Enter length of DNA sequence to match: 3

Enter 3 characters (one of AGTC*) as a search sequence: GFG

Erroneous character input F exiting

Goodbye

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

Database Security XI Status And Prospects

Authors: T.Y. Lin, Shelly Qian

1st Edition

0412820900, 978-0412820908

More Books

Students also viewed these Databases questions