Please explain DNA Sequencing more clearly for me please there's a picture of the decription and also please comment on each line if possible on the code below to for me to have an understanding of what each line is doing. It is in C++. #include #include #include #include using namespace std; set longestCommonSubstring(const string& a,        const string& b) {     int maxLen = 0;    vector > longestSuffix(a.size(), vector(b.size()));    set result;    for(int i = 0; i < a.size(); ++i) {       for(int j = 0; j < b.size(); ++j) {          if (a[i] == b[j]) {             int ¤t = longestSuffix[i][j];             current = i == 0 || j == 0 ? 1 :                 longestSuffix[i - 1][j - 1] + 1;             int from = i - current + 1;             if (current > maxLen) {                result.clear();                result.insert(a.substr(from, current));                maxLen = current;             } else if (current == maxLen) {                result.insert(a.substr(from, current));             }          }       }    }    return result; } int main() {    string a, b;    bool first = true;    while(cin >> a >> b) {       if (!first)          cout << '\n';       else          first = false;       set result = longestCommonSubstring(a, b);       if (result.empty())          cout << "No common sequence."<::const_iterator it = result.begin();                it != result.end(); ++it)             cout << *it << '\n';       }    } }

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Please explain DNA Sequencing more clearly for me please there's a picture of the decription and also please comment on each line if possible on the code below to for me to have an understanding of what each line is doing. It is in C++.

#include <iostream>
#include <string>
#include <vector>
#include <set>

using namespace std;

set<string> longestCommonSubstring(const string& a, 
      const string& b) { 
   int maxLen = 0;

   vector<vector<int> > longestSuffix(a.size(), vector<int>(b.size()));
   set<string> result;

   for(int i = 0; i < a.size(); ++i) {
      for(int j = 0; j < b.size(); ++j) {
         if (a[i] == b[j]) {
            int &current = longestSuffix[i][j];
            current = i == 0 || j == 0 ? 1 : 
               longestSuffix[i - 1][j - 1] + 1;

            int from = i - current + 1;

            if (current > maxLen) {
               result.clear();
               result.insert(a.substr(from, current));
               maxLen = current;
            } else if (current == maxLen) {
               result.insert(a.substr(from, current));
            }
         }
      }
   }

   return result;
}

int main() {
   string a, b;
   bool first = true;

   while(cin >> a >> b) {
      if (!first)
         cout << '\n';
      else
         first = false;

      set<string> result = longestCommonSubstring(a, b);

      if (result.empty())
         cout << "No common sequence."<<endl;
      else {
         for(set<string>::const_iterator it = result.begin();
               it != result.end(); ++it)
            cout << *it << '\n';
      }
   }
}

DNA Sequencing
Description
A DNA molecule consists of two strands that wrap around each other to resemble a twisted ladder whose sides, made of sugar and phosphate molecules, are connected by rungs of nitrogen-containing chemi
cals called bases. Each strand is linear arrangement of repeating similar units called nucleotides, which are each composed of one sugar, one phosphate, and a nitrogenous base. Four different bases are pres
ent in DNA: adenine (A), thymine (T), cytosine (C), and guanine (G). The particular order of the bases arranged along the sugar-phosphate backbone is called the DNA sequence;the sequence specifies the e
xact genetic instructions required to create a particular organism with its own unique traits.
Geneticists often compare DNA strands and are interested in finding the longest common base sequence in the two strands. Note that these strands can be represented as strings consisting of the letters a, t,
c and g.So, the longest common sequence in the two strands atgc and tga is tg .It is entirely possible that two different common sequences exist that are the same length and are the longest possible comm
on sequences. For example in the strands atgs and gctg, the longest common sequences are gc and tg
Write a program that accepts as input two strings representing DNA strands, and print as output the longest common sequence(s) in lexicographical order.
Input
The input file contains several test cases with a blank line between two consecutive.
The string are at most 300 characters-long.
Output
For each test case, print all the longest common sequences, one per line, in lexicographical order.
If there isn't any common sequence between the two strings, just print: 'No common sequence.'
Print a blank line between the output of consecutive datasets.
Sample Input 1
Sample Output 1
atgc
tg
tga
gc
atgc
tg
gctg
Transcribed Image Text:DNA Sequencing Description A DNA molecule consists of two strands that wrap around each other to resemble a twisted ladder whose sides, made of sugar and phosphate molecules, are connected by rungs of nitrogen-containing chemi cals called bases. Each strand is linear arrangement of repeating similar units called nucleotides, which are each composed of one sugar, one phosphate, and a nitrogenous base. Four different bases are pres ent in DNA: adenine (A), thymine (T), cytosine (C), and guanine (G). The particular order of the bases arranged along the sugar-phosphate backbone is called the DNA sequence;the sequence specifies the e xact genetic instructions required to create a particular organism with its own unique traits. Geneticists often compare DNA strands and are interested in finding the longest common base sequence in the two strands. Note that these strands can be represented as strings consisting of the letters a, t, c and g.So, the longest common sequence in the two strands atgc and tga is tg .It is entirely possible that two different common sequences exist that are the same length and are the longest possible comm on sequences. For example in the strands atgs and gctg, the longest common sequences are gc and tg Write a program that accepts as input two strings representing DNA strands, and print as output the longest common sequence(s) in lexicographical order. Input The input file contains several test cases with a blank line between two consecutive. The string are at most 300 characters-long. Output For each test case, print all the longest common sequences, one per line, in lexicographical order. If there isn't any common sequence between the two strings, just print: 'No common sequence.' Print a blank line between the output of consecutive datasets. Sample Input 1 Sample Output 1 atgc tg tga gc atgc tg gctg
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Functions
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education