-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
80 lines (67 loc) · 2.16 KB
/
main.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
#include <iostream>
#include <string>
#include <bits/stdc++.h>
#include "unistd.h"
#include <getopt.h>
using namespace std;
vector<string> readFile(std::string fileName);
int smith_waterman(string sequence1Name, string sequence1, string sequence2Name, string sequence2,
int gapopen, int gapext, int matchScore, int mismatchPenalty);
int needleman_wunsch(string sequence1Name, string sequence1, string sequence2Name, string sequence2,
int gapopen, int gapext, int matchScore, int mismatchPenalty);
int main(int argc, char *argv[]) {
int c;
string mode;
string fileName;
int gapopen;
int gapext;
while (1) {
static struct option long_options[] = {
{"mode", required_argument, 0, 'm'},
{"input", required_argument, 0, 'i'},
{"gapopen", required_argument, 0, 'o'},
{"gapext", required_argument, 0, 'e'},
{0, 0, 0, 0}
};
/* getopt_long stores the option index here. */
int option_index = 0;
c = getopt_long (argc, argv, "m:i:o:e:",
long_options, &option_index);
/* Detect the end of the options. */
if (c == -1)
break;
switch (c) {
case 'm':
mode = optarg;
break;
case 'i':
fileName = optarg;
break;
case 'o':
gapopen = atoi(optarg);
break;
case 'e':
gapext = atoi(optarg);
break;
case '?':
/* getopt_long already printed an error message. */
return 1;
break;
default:
abort ();
}
}
vector<string> sequences = readFile(fileName);
int matchScore = 2;
int mismatchPenalty = -3;
if(mode.compare("global") == 0){
needleman_wunsch(sequences[0], sequences[1], sequences[2], sequences[3], 0, gapopen, matchScore, mismatchPenalty);
} else if(mode.compare("aglobal") == 0){
needleman_wunsch(sequences[0], sequences[1], sequences[2], sequences[3], gapopen, gapext, matchScore, mismatchPenalty);
} else if(mode.compare("local") == 0){
smith_waterman(sequences[0], sequences[1], sequences[2], sequences[3], 0, gapopen, matchScore, mismatchPenalty);
} else if(mode.compare("alocal") == 0){
smith_waterman(sequences[0], sequences[1], sequences[2], sequences[3], gapopen, gapext, matchScore, mismatchPenalty);
}
return 0;
}