-
Notifications
You must be signed in to change notification settings - Fork 1
/
Demo.cpp
103 lines (78 loc) · 2.92 KB
/
Demo.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/**
* A demo program for humans vs neanderthals quest
*
* @author Kira Kondratyeva
* @since 2019-05
*/
#include "main.hpp"
#include "sequence.hpp"
int main() {
map <string, string> reference = getReference();
map <string, string> genbank = getSequences();
map <string, string>::iterator it;
cout << "Access GenBank IDs" << endl;
for (it = genbank.begin(); it != genbank.end(); ++it)
cout << it->first << endl;
cout << endl;
cout << "Access references" << endl;
auto human = reference.find("human");
cout << human->first << endl;
cout << human->second << endl;
auto neanderthal = reference.find("neanderthal");
cout << neanderthal->first << endl;
cout << neanderthal->second << endl;
cout << "Great! You have all sequences you need!" << endl;
cout << endl;
//Let's check gc_content
cout << "GC content" << endl;
double gc = gc_content("AACC");
cout << gc << endl; //print 50
gc = gc_content("AAAA");
cout << gc << endl; //print 0
string example = "GGCGCTAGCCGATC";
gc = gc_content(example);
cout << gc << endl; //print 71.4286
gc = gc_content(human->second);
cout << gc << endl; //print 45
gc = gc_content(neanderthal->second);
cout << gc << endl; //print 43.3333
cout << endl;
//Let's check hamming_distance
cout << "Hamming distance" << endl;
int dist = hamming_distance("AACC", "AACC");
cout << dist << endl; //print 0
dist = hamming_distance(human->second, neanderthal->second);
cout << dist << endl; //print 16
cout << endl;
//Let's check reverse_complement
cout << "Reverse complement" << endl;
string rev_comp = reverse_complement("AACC");
cout << rev_comp << endl; //print GGTT
rev_comp = reverse_complement(example);
cout << rev_comp << endl; //print GATCGGCTAGCGCC
if ( rev_comp == "GATCGGCTAGCGCC" )
cout << "Correct!" << endl;
else
cout << "Fail! Check your reverse_complement function!" << endl;
cout << endl;
//Let's check find_substring
cout << "Find substring" << endl;
string match = find_substring("AC", "AACC");
cout << rev_comp << endl; //print AC
match = find_substring("AC", "GGTT");
cout << rev_comp << endl; //print AC
string easy = example + human->second;
match = find_substring(neanderthal->second, easy);
if (match == human->second)
cout << "Good match!" << endl;
else
cout << "Easy fail! Check your find_substring function!" << endl;
string puzzle = reverse_complement(neanderthal->second);
puzzle = example + puzzle + human->second + example;
match = find_substring(neanderthal->second, puzzle);
if (match == neanderthal->second)
cout << "Awesome!" << endl;
else
cout << "Fail! Check your find_substring function!" << endl;
return 0;
}