-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpopcorn_demo.cpp
65 lines (50 loc) · 2.54 KB
/
popcorn_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
#include <iostream>
#include "kernels.h"
int main()
{
double beta;
double calculated_distance;
/* These are the 3 sequences given with assignment */
string s1 = "EFDVILKAAGANKVAVIKAVRGATGLGLKEAKDLVESAPAALKEGVSKDDAEALKKALEEAGAEVEVK";
string s2 = "VPCSDSKAIAQVGTISANSDETVGKLIAEAMDKVGKEGVITVEDGTGLQDELDVVEAGGVAVIKVGAATEVEMKEKKARVEDALHATRAAVEEG";
string s3 = "EFDVILKAAGANKVAVIKAVRGATGLALKEAKDLVESAPAALKEGVSKDDAEALKKALEEAGAEVEVK";
cout << "Please type the value of beta: ";
try
{
cin >> beta;
if (cin.fail()) throw runtime_error("Input is not an a correct data type! Please try again!\n");
if (beta < 0) throw runtime_error("Input is not a positive real number! Please try again!\n");
}
catch (const runtime_error& e)
{
cout << endl << e.what();
return 1;
}
unordered_map <string, double> local_K1 = read_blosum_build_kernel(beta);
/* Results from calculating the distance using all possible substrings */
/* Verify results are the same regardless of order */
calculated_distance= protein_distance(s1, s2, local_K1, 0);
cout << "Distance between sequence 1 and sequence 2 = " << calculated_distance << endl;
calculated_distance= protein_distance(s2, s1, local_K1, 0);
cout << "Distance between sequence 2 and sequence 1 = " << calculated_distance << endl;
cout << endl;
calculated_distance = protein_distance(s1, s3, local_K1);
cout << "Distance between sequence 1 and sequence 3 = " << calculated_distance << endl;
calculated_distance = protein_distance(s3, s1, local_K1);
cout << "Distance between sequence 3 and sequence 1 = " << calculated_distance << endl;
cout << endl;
calculated_distance = protein_distance(s2, s3, local_K1);
cout << "Distance between sequence 2 and sequence 3 = " << calculated_distance << endl;
calculated_distance = protein_distance(s3, s2, local_K1);
cout << "Distance between sequence 3 and sequence 2 = " << calculated_distance << endl;
cout << endl;
/* Verify distance is 0 for identities */
calculated_distance = protein_distance(s1, s1, local_K1);
cout << "Distance between sequence 1 and sequence 1 = " << calculated_distance << endl;
calculated_distance = protein_distance(s2, s2, local_K1);
cout << "Distance between sequence 2 and sequence 2 = " << calculated_distance << endl;
calculated_distance = protein_distance(s3, s3, local_K1);
cout << "Distance between sequence 3 and sequence 3 = " << calculated_distance << endl;
cout << endl;
return 0;
}