Question

In this assignment, you will implement a deterministic finite automata (DFA) using C++ programming language to...

In this assignment, you will implement a deterministic finite automata (DFA) using C++ programming language to extract all matching patterns (substrings) from a given input DNA sequence string.

  1. The alphabet for generating DNA sequences is {A, T, G, C}. Write a regular expression that represents all DNA strings that contains at least two ‘A’s. Note: assume empty string is not a valid string.

  2. Design a deterministic finite automaton to recognize the regular expression.

  3. Write a program which asks the user to input a DNA sequence. The program should be able to extract all the patterns (substrings present in the DNA sequence) that match the regular expression given in 1. You MUST implement DFA from (2) to check if all possible substrings in the DNA sequence is a part of the regular expression or not.

Note: even if the same pattern is found multiple times, it should be printed every time it is found.

Below are two sample input/output. Only the bolded are user input.

Input a DNA sequence: CATTTGCAGG

Matching patterns are:

CATTTGCA

CATTTGCAG

CATTTGCAGG

ATTTGCA

ATTTGCAG

ATTTGCAGG

Input a DNA sequence: TTTATAA

Matching patterns are:

TTTATA

TTTATAA

TTATA

TTATAA

TATA

TATAA

ATA

ATAA

TAA

AA

What to submit:

  1. Submit a digital copy of the regular expression and diagram of the DFA.

  2. Submit a cpp file representing your program (just send the code I will paste the code in myself)

0 0
Add a comment Improve this question Transcribed image text
Answer #1

REGULAR EXPRESSION:-  

For alphabet generating DNA sequences {A, T, G, C}

(T+G+C)*A(T+G+C)*A(A+T+G+C)*

DFA:-

PROGRAM:

#include <iostream>
#include <string>
#include <cstring>
using namespace std;

void subString(char str[], int n)
{
//declaring the temporary stringvariable
string temp;
//declaring the variable count
int count;
// Pick starting point
for (int len = 1; len <= n; len++) //loop from 1 to length of string
{
// Pick ending point
for (int i = 0; i <= n - len; i++)
{
// Print characters from current
// starting point to current ending
// point.

int j = i + len - 1;
//emptying the temporary variable
temp.clear();
//count to zero
count=0;
for (int k = i; k <= j; k++)
{
//concatenating each letter to temporary variable
temp+=str[k];
//if the letter is 'a' or 'A'
//then increment count by one
if (str[k]=='a' || str[k]=='A')
count=count+1;
}
// if count is atleast two
//print corresponding string
if(count>=2)
cout << temp << endl;
}
}
}
int main()
{
string str;
cout << "INPUT A DNA SEQUENCE: ";
//reading dna sequence
//storing it in str
cin >> str;

//converting string to char array
//declaring cstr by assigning (size of str size + 1)
char cstr[str.size() + 1];
//copying string from str to cstr
str.copy(cstr, str.size() + 1);
//setting end of char array cstr
cstr[str.size()] = '\0';

//calling the method to find subString
//having atleast 2 'a'
subString(cstr,strlen(cstr));
return 0;
}

PROGRAM FILE:-

OUTPUT:-

Add a comment
Know the answer?
Add Answer to:
In this assignment, you will implement a deterministic finite automata (DFA) using C++ programming language to...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Implement a deterministic finite automata (DFA) using C++ programming language to extract matchin...

    Implement a deterministic finite automata (DFA) using C++ programming language to extract matching patterns from a given input DNA sequence string. Design a deterministic finite automata to recognize the regular expression A(A+T+G+C)*A + T(A+T+G+C)*T over the alphaber {A,T,G,C}. This regular expression recognize any string that starts and ends with ‘A’ or starts and ends with ‘T’. Write a program which asks the user to input a DNA sequence. The program should be able to extract all the patterns (substrings present...

  • In this assignment, you wil implement a deterministic finite automata (DFA) using C++ programming...

    In this assignment, you wil implement a deterministic finite automata (DFA) using C++ programming language to extract matching patterns from a given input DNA sequence string. 1. Design a deterministic finite automata to recognize the regular expression A(A+T+G+C)*A + T(A+T+G+C)*T over the alphaber (A,T,G,C). This regular expression recognize any string that starts and ends with 'A' or starts and ends with 'T. or starts and ends with T In this assignment, you wil implement a deterministic finite automata (DFA) using...

  • The Following Question belongs to Theory of Automata Make a DFA (Deterministic finite Automaton) for: •All...

    The Following Question belongs to Theory of Automata Make a DFA (Deterministic finite Automaton) for: •All words that start with a double letter

  • I need to construct a deterministic finite automata, DFA M, such that language of M, L(M),...

    I need to construct a deterministic finite automata, DFA M, such that language of M, L(M), is the set of all strings over the alphabet {a,b} in which every substring of length four has at least one b. Note: every substring with length less than four is in this language. For example, aba is in L(M) because there are no substrings of at least 4 so every substring of at least 4 contains at least one b. abaaab is in...

  • Write a class for DFA type objects. Deterministic Finite Automata are commonly defined as a quintuple...

    Write a class for DFA type objects. Deterministic Finite Automata are commonly defined as a quintuple consisting of a set of states, a set of symbals, a transition function, a start state and a set of accept states For this implementation let the alphabet be given as a string of symbols, the transition function as list of lists which represent an n by m matrix where the n rows represent the states and the m columns represent the alphabet symbols,...

  • How can we add new words to DFA, maintaining minimality? Maybe, you can advise some completely...

    How can we add new words to DFA, maintaining minimality? Maybe, you can advise some completely different approach to solve the following problem: A program must process two types of queries: Add new word to the language. Check if some word of the language occurs in the input string as a substring. Time and space complexity should be as low as possible. The only solution that I know so far is to rebuild an automaton from scratch every time, using...

  • IMPLEMENT IN C++ Implement a symbol balance checker function for the Pascal programming language. Pascal allows...

    IMPLEMENT IN C++ Implement a symbol balance checker function for the Pascal programming language. Pascal allows for the following pairs: {}, (), [], begin end . All programs will begin with the word "begin" and end with the word "end". Your function should receive an ifstream object which is already open and will return true, all of the symbols match, or false, they do not. You do not have to worry about comments in the program but you do have...

  • In this assignment, you will implement a Memory Management System(MMS). Using C Programming Language..... MAKE SURE...

    In this assignment, you will implement a Memory Management System(MMS). Using C Programming Language..... MAKE SURE YOU USE C PROGRAMMING Your MMS will handle all requests of allocation of memory space by different users (one thread per user) …. HINT(You will use Pthreads and Semaphores). Your MMS will provide the user with an interface for making memory requests and also for freeing up memory that is no longer needed by the user. One of the jobs of your memory management...

  • Utilizing the class diagram above, implement the voting system using JAVA. You will need a main...

    Utilizing the class diagram above, implement the voting system using JAVA. You will need a main method to allow a voter to register and vote (you need to take in user input). You need to assume getters, setters, constructors, and toString methods; and you need to take in the user input and validate it as well. Comment the code well and submit screenshot testing within your PDF. Hint: you can research regular expressions for the validation functions. VotePersonalldentification voterLastName:String voterFirstName:String...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT